@docx-editor.dev/core 2.12.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -14
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.cts +5 -5
- package/dist/automation.d.ts +5 -5
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +8 -8
- package/dist/binding.d.ts +8 -8
- package/dist/binding.js +1 -1
- package/dist/chunk-3AT4RUQ3.cjs +19 -0
- package/dist/chunk-4NAQLFXA.cjs +2 -0
- package/dist/{chunk-XCFM3G5L.cjs → chunk-67S7OHE6.cjs} +1 -1
- package/dist/chunk-BHAUFJO6.js +20 -0
- package/dist/{chunk-TKEGK4GQ.cjs → chunk-F7U4OLMS.cjs} +2 -2
- package/dist/chunk-FNMXRLGW.cjs +5 -0
- package/dist/{chunk-W77HJGYX.js → chunk-HWWHGREA.js} +1 -1
- package/dist/chunk-I36WS6XX.cjs +20 -0
- package/dist/chunk-IOTL2GGW.js +1 -0
- package/dist/chunk-OF2QZCTN.js +19 -0
- package/dist/chunk-PFSJVAWJ.cjs +1 -0
- package/dist/chunk-PRIBU3UH.js +2 -0
- package/dist/{chunk-WU7PUTVA.js → chunk-RIYSCEFQ.js} +1 -1
- package/dist/chunk-RO3HFCML.js +5 -0
- package/dist/chunk-SFOUCTKA.js +2 -0
- package/dist/{chunk-MHQNR2OU.js → chunk-VBEKERLJ.js} +2 -2
- package/dist/chunk-WANKXD34.cjs +2 -0
- package/dist/chunk-XETEMUIP.cjs +11 -0
- package/dist/chunk-YMW34EBA.js +11 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.cts +3 -3
- package/dist/collaboration/replication.d.ts +3 -3
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.cts +3 -3
- package/dist/collaboration.d.ts +3 -3
- package/dist/contracts/editor.d.cts +7 -7
- package/dist/contracts/editor.d.ts +7 -7
- package/dist/contracts/interaction.d.cts +7 -7
- package/dist/contracts/interaction.d.ts +7 -7
- package/dist/contracts/modules.d.cts +7 -7
- package/dist/contracts/modules.d.ts +7 -7
- package/dist/{custom-node-writes-D4rMJIES.d.cts → custom-node-writes-C46r3_5O.d.cts} +2 -2
- package/dist/{custom-node-writes-CcNeHH5C.d.ts → custom-node-writes-DntmaAVW.d.ts} +2 -2
- package/dist/{dist-YFULGVS3.js → dist-OSUJGKTK.js} +1 -1
- package/dist/{editor-B76SEMZw.d.cts → editor-DLrTueVe.d.cts} +21 -9
- package/dist/{editor-BcdsPdbY.d.ts → editor-KiB6JNvk.d.ts} +21 -9
- package/dist/editor.cjs +1 -1
- package/dist/editor.d.cts +22 -22
- package/dist/editor.d.ts +22 -22
- package/dist/editor.js +1 -1
- package/dist/{index-BYTvklN5.d.ts → index-D4Pxdo_p.d.ts} +168 -13
- package/dist/{index-CDGhPib1.d.cts → index-D_PA2Xv6.d.cts} +168 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +179 -519
- package/dist/layout.d.ts +179 -519
- package/dist/layout.js +1 -1
- package/dist/{note-properties-Bx7rXruA.d.ts → note-properties-CDFiNXcD.d.ts} +1 -1
- package/dist/{note-properties-zQ8w04en.d.cts → note-properties-Y6qYh2Hv.d.cts} +1 -1
- package/dist/{omml-equation-69O1Pd8G.d.ts → omml-equation-BY49UOIF.d.ts} +1 -1
- package/dist/{omml-equation-BmV51rim.d.cts → omml-equation-DB8d-jCq.d.cts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +6 -6
- package/dist/output.d.ts +6 -6
- package/dist/output.js +1 -1
- package/dist/{protocol-FTXtrAIT.d.cts → protocol-C8L58j66.d.cts} +2 -2
- package/dist/{protocol-DC7ueVuo.d.ts → protocol-DjgYKCAy.d.ts} +2 -2
- package/dist/{review-items-B78OsJU2.d.ts → review-items-CCS1h93f.d.ts} +1 -1
- package/dist/{review-items-C-2WQdEb.d.cts → review-items-CaAkgi5s.d.cts} +1 -1
- package/dist/{review-reads-CbBQlb-n.d.cts → review-reads-BrTDmoYH.d.cts} +2 -2
- package/dist/{review-reads-UexYBp-m.d.ts → review-reads-DcGYCH0w.d.ts} +2 -2
- package/dist/{revision-projection-B2v9U3qx.d.ts → revision-projection-BmLtLPxH.d.ts} +1 -1
- package/dist/{revision-projection-6u8lae9J.d.cts → revision-projection-Dknlar93.d.cts} +1 -1
- package/dist/{semantic-cell-selection-DsYz2Vg3.d.ts → semantic-cell-selection-BZ50i-Fu.d.ts} +4 -4
- package/dist/{semantic-cell-selection-nEE7E3Z8.d.cts → semantic-cell-selection-COnfaOZO.d.cts} +4 -4
- package/dist/{semantic-interaction-C00BpIyC.d.ts → semantic-interaction-BDJ4TBjm.d.ts} +4 -2
- package/dist/{semantic-interaction-DiOX0FIH.d.cts → semantic-interaction-Bq3ixB0I.d.cts} +4 -2
- package/dist/{semantic-paint-Cc11nrDL.d.cts → semantic-paint-C5SMTO8Y.d.cts} +2 -2
- package/dist/{semantic-paint-ofuoBsYo.d.ts → semantic-paint-DuhhY5-R.d.ts} +2 -2
- package/dist/{semantic-records-CzI0ZEuR.d.ts → semantic-records-BI1jpft7.d.ts} +603 -8
- package/dist/{semantic-records-CRG1r6-a.d.cts → semantic-records-Btw3Ao4v.d.cts} +603 -8
- package/dist/{shaped-measurer-CneACGcP.d.cts → shaped-measurer-CqdYa0fa.d.cts} +9 -1
- package/dist/{shaped-measurer-CkOGZQn9.d.ts → shaped-measurer-qnBJziPx.d.ts} +9 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +15 -12
- package/dist/store.d.ts +15 -12
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-CA7qgAUF.d.cts → tree-op-types-BUulYD5y.d.cts} +15 -2
- package/dist/{tree-op-types-HKfUzt_-.d.ts → tree-op-types-D6HzlPR4.d.ts} +15 -2
- package/dist/{tree-package-fragment-oJZX_5iN.d.ts → tree-package-fragment-B1supBtE.d.ts} +2 -2
- package/dist/{tree-package-fragment-Cz-v-0B3.d.cts → tree-package-fragment-ByN5yzll.d.cts} +2 -2
- package/dist/{tree-session-contract-BPDLrEPX.d.ts → tree-session-contract-BasiwZgZ.d.ts} +28 -5
- package/dist/{tree-session-contract-Cbl87xa8.d.cts → tree-session-contract-DbeBenMR.d.cts} +28 -5
- package/dist/{tree-store-B7hd6cEa.d.ts → tree-store-APgWx6qn.d.ts} +1 -1
- package/dist/{tree-store-BenW0Mg_.d.cts → tree-store-DEEQ9wz_.d.cts} +1 -1
- package/package.json +5 -2
- package/dist/chunk-3JON7JMD.cjs +0 -1
- package/dist/chunk-5V6FNKBE.cjs +0 -2
- package/dist/chunk-BXRVGHTY.cjs +0 -18
- package/dist/chunk-BXTTPJSH.js +0 -5
- package/dist/chunk-ILTZTY3K.cjs +0 -10
- package/dist/chunk-IUM7FZPA.js +0 -2
- package/dist/chunk-JWZG4QJ5.cjs +0 -2
- package/dist/chunk-JXZYDBKU.cjs +0 -19
- package/dist/chunk-KBOOIC2Q.js +0 -19
- package/dist/chunk-L6XZTLPS.js +0 -10
- package/dist/chunk-L7OR5TJK.cjs +0 -5
- package/dist/chunk-MLGPISGH.js +0 -1
- package/dist/chunk-NJXQABQU.js +0 -18
- package/dist/chunk-VGFMPWND.js +0 -2
|
@@ -2931,6 +2931,19 @@ type TreeDocOp = {
|
|
|
2931
2931
|
readonly paragraphId: string;
|
|
2932
2932
|
readonly pageNumberText: string;
|
|
2933
2933
|
}[];
|
|
2934
|
+
} | {
|
|
2935
|
+
/**
|
|
2936
|
+
* Rewrite recognized fields' cached RESULT runs in place — between the `separate` and
|
|
2937
|
+
* `end` fldChars, or a `w:fldSimple`'s content. The instruction is never modified; a
|
|
2938
|
+
* result holding anything but plain runs is skipped (see `tree-op-field-results.ts`).
|
|
2939
|
+
*/
|
|
2940
|
+
readonly op: 'refreshFieldResults';
|
|
2941
|
+
readonly updates: readonly {
|
|
2942
|
+
readonly paragraphId: string;
|
|
2943
|
+
/** Node id of the field's begin `w:fldChar`, or of the `w:fldSimple` element. */
|
|
2944
|
+
readonly fieldNodeId: string;
|
|
2945
|
+
readonly text: string;
|
|
2946
|
+
}[];
|
|
2934
2947
|
};
|
|
2935
2948
|
/** Drawing mutation ops from typed-drawings-and-images task 11. */
|
|
2936
2949
|
type DrawingTreeDocOp = Extract<TreeDocOp, {
|
|
@@ -2939,7 +2952,7 @@ type DrawingTreeDocOp = Extract<TreeDocOp, {
|
|
|
2939
2952
|
/** Just the `op` discriminants, for dispatch tables and validation. */
|
|
2940
2953
|
type TreeDocOpKind = TreeDocOp['op'];
|
|
2941
2954
|
/** Every {@link TreeDocOpKind}, for validation and exhaustiveness checks. */
|
|
2942
|
-
declare const TREE_DOC_OP_KINDS: readonly ["replaceStoryBlocks", "insertText", "deleteText", "setParagraphMarkRevision", "proposeParagraphMerge", "insertCommentMarker", "acceptRevision", "rejectRevision", "acceptAllRevisions", "rejectAllRevisions", "insertTab", "insertHardBreak", "insertPageBreak", "insertPageField", "setListLevel", "setListNumbering", "setParagraphTabStops", "setParagraphMarkProperties", "splitParagraph", "splitParagraphMany", "joinParagraphs", "setRunProperties", "setParagraphProperties", "setSectionProperties", "setSectionMark", "insertHyperlink", "setHyperlinkTarget", "removeHyperlink", "setMathEquation", "removeMathEquation", "setContentControlValue", "removeContentControl", "insertInlineContentControl", "addRepeatingSectionItem", "removeRepeatingSectionItem", "deleteBlock", "insertTable", "insertTableRow", "deleteTableRow", "insertTableColumn", "deleteTableColumn", "setTableColumnWidths", "setTableRightEdgeWidth", "setTableRowHeight", "setTableCellBorders", "setTableCellFill", "setTableCellVerticalAlignment", "createHeaderFooter", "deleteHeaderFooter", "linkToPrevious", "unlinkFromPrevious", "setSectionFurnitureOptions", "insertNote", "deleteNote", "convertNote", "convertAllNotes", "setNoteProperties", "setContentControlProperties", "insertContentControl", "insertFragment", "insertDrawing", "replaceDrawingResource", "deleteDrawing", "resizeDrawing", "cropDrawing", "positionDrawing", "setDrawingWrap", "setDrawingMetadata", "setDrawingLocks", "transformDrawing", "insertToc", "replaceTocResult", "rewriteTocPageNumbers"];
|
|
2955
|
+
declare const TREE_DOC_OP_KINDS: readonly ["replaceStoryBlocks", "insertText", "deleteText", "setParagraphMarkRevision", "proposeParagraphMerge", "insertCommentMarker", "acceptRevision", "rejectRevision", "acceptAllRevisions", "rejectAllRevisions", "insertTab", "insertHardBreak", "insertPageBreak", "insertPageField", "setListLevel", "setListNumbering", "setParagraphTabStops", "setParagraphMarkProperties", "splitParagraph", "splitParagraphMany", "joinParagraphs", "setRunProperties", "setParagraphProperties", "setSectionProperties", "setSectionMark", "insertHyperlink", "setHyperlinkTarget", "removeHyperlink", "setMathEquation", "removeMathEquation", "setContentControlValue", "removeContentControl", "insertInlineContentControl", "addRepeatingSectionItem", "removeRepeatingSectionItem", "deleteBlock", "insertTable", "insertTableRow", "deleteTableRow", "insertTableColumn", "deleteTableColumn", "setTableColumnWidths", "setTableRightEdgeWidth", "setTableRowHeight", "setTableCellBorders", "setTableCellFill", "setTableCellVerticalAlignment", "createHeaderFooter", "deleteHeaderFooter", "linkToPrevious", "unlinkFromPrevious", "setSectionFurnitureOptions", "insertNote", "deleteNote", "convertNote", "convertAllNotes", "setNoteProperties", "setContentControlProperties", "insertContentControl", "insertFragment", "insertDrawing", "replaceDrawingResource", "deleteDrawing", "resizeDrawing", "cropDrawing", "positionDrawing", "setDrawingWrap", "setDrawingMetadata", "setDrawingLocks", "transformDrawing", "insertToc", "replaceTocResult", "rewriteTocPageNumbers", "refreshFieldResults"];
|
|
2943
2956
|
/**
|
|
2944
2957
|
* How far a committed op can reach, so layout can scope its work (task 5.2).
|
|
2945
2958
|
*
|
|
@@ -3083,4 +3096,4 @@ type TreeOpResult = {
|
|
|
3083
3096
|
readonly detail?: string;
|
|
3084
3097
|
};
|
|
3085
3098
|
|
|
3086
|
-
export { type ContentControlKind as $, type DrawingVerticalReferenceFrame as A, type VectorImageMime as B, type ImageDecodePort as C, type DrawingKind as D, type RevisionAttributionInput as E, type DrawingTreeDocOp as F, type
|
|
3099
|
+
export { type ContentControlKind as $, type DrawingVerticalReferenceFrame as A, type VectorImageMime as B, type ImageDecodePort as C, type DrawingKind as D, type RevisionAttributionInput as E, type DrawingTreeDocOp as F, type TreeDocColorValue as G, DEFAULT_IMAGE_RESOURCE_LIMITS as H, type ImpactClass as I, IMAGE_WRAP_TARGETS as J, type ImageResourceLimits as K, resolveImageResourceLimits as L, resolveSvgIntrinsicSize as M, sniffImageMime as N, type OoxmlPart as O, type PreservedImageMime as P, validateRasterHeader as Q, type RevisionAddress as R, type SourceCrop as S, type TreeDocOp as T, type DrawingAccessibility as U, type ValidatedImageBytesHandle as V, type DrawingTransform as W, type VectorShapeProjection as X, type DrawingProjection as Y, type OoxmlDrawingNode as Z, type TableBorderStyle as _, type OoxmlNode as a, type OoxmlContentControlStoreMappedDataAsNode as a$, type ContentControlLevel as a0, type ContentControlLock as a1, type ContentControlDataBinding as a2, type ResourceLimits as a3, type OoxmlInvariantResult as a4, type RelationshipRecord as a5, type OoxmlInvariantIssue as a6, type OoxmlHardBreakNode as a7, type OoxmlFldCharNode as a8, type OoxmlFldSimpleNode as a9, IMAGE_RESOURCE_HARD_CEILINGS as aA, type ImageRelationshipResolution as aB, type ImageResourceLookup as aC, type IndexResult as aD, MAX_CONTENT_CONTROLS_PER_PART as aE, MAX_CONTENT_CONTROL_NESTING as aF, MAX_SVG_SNIFF_BYTES as aG, type NameRejection as aH, type NameResult as aI, OFFICE_RELATIONSHIP_NAMESPACE_URI as aJ, OOXML_NODE_IDENTITY_RULES as aK, type OoxmlBodyNode as aL, type OoxmlBookmarkEndNode as aM, type OoxmlBookmarkStartNode as aN, type OoxmlContentControlCalendarNode as aO, type OoxmlContentControlCheckboxNode as aP, type OoxmlContentControlCheckedNode as aQ, type OoxmlContentControlCheckedStateNode as aR, type OoxmlContentControlComboBoxNode as aS, type OoxmlContentControlDataBindingNode as aT, type OoxmlContentControlDateFormatNode as aU, type OoxmlContentControlDateNode as aV, type OoxmlContentControlDropDownListNode as aW, type OoxmlContentControlEndPropertiesNode as aX, type OoxmlContentControlLidNode as aY, type OoxmlContentControlListItemNode as aZ, type OoxmlContentControlPropertiesNode as a_, type OoxmlInstrTextNode as aa, type OoxmlAttribute as ab, type TreeOpResult as ac, ACCEPTED_PARAGRAPH_PROPERTIES as ad, ACCEPTED_RUN_PROPERTIES as ae, CONTENT_CONTROL_ID_MAX as af, CONTENT_CONTROL_PROPERTY_ORDER as ag, type ContentControlCheckbox as ah, type ContentControlCheckboxState as ai, type ContentControlDateFormat as aj, type ContentControlEntry as ak, type ContentControlListItem as al, type ContentControlProperties as am, type ContentTypeError as an, type ContentTypeIndex as ao, type ContentTypeRecords as ap, type CreateImageResourceCacheOptions as aq, DEFAULT_LIMITS as ar, DEFAULT_OOXML_PACKAGE_LIMITS as as, DEFAULT_ZIP_LIMITS as at, type DefaultRecord as au, HARD_CEILINGS as av, HYPERLINK_RELATIONSHIP_TYPE as aw, type HyperlinkKind as ax, type HyperlinkTarget as ay, IMAGE_RELATIONSHIP_TYPE as az, type OoxmlPackage as b, flattenContentControls as b$, type OoxmlContentControlTextNode as b0, type OoxmlContentControlUncheckedStateNode as b1, type OoxmlDocumentNode as b2, type OoxmlExternalTarget as b3, type OoxmlGenericExtensionAttribute as b4, type OoxmlHyperlinkNode as b5, type OoxmlInvariantIssueCode as b6, type OoxmlKnownNodeAttribute as b7, type OoxmlNamespaceBinding as b8, type OoxmlNodeIdentityRules as b9, XMLNS_NAMESPACE_URI as bA, XML_NAMESPACE_URI as bB, type XmlLimits as bC, type XmlNode as bD, type XmlRejection as bE, type XmlResult as bF, type ZipLimits as bG, type ZipReadResult as bH, type ZipRejection as bI, allocateContentControlId as bJ, asciiFold as bK, buildContentTypeIndex as bL, buildRelationshipSet as bM, childElements as bN, contentControlContentChildren as bO, contentControlContentNodeOf as bP, contentControlEndPropertiesNodeOf as bQ, contentControlLevelOf as bR, contentControlPropertiesNodeOf as bS, contentControlPropertiesOf as bT, contentControlTextOf as bU, contentControlsIn as bV, createImageResourceCache as bW, detectDuplicateNames as bX, extensionKey as bY, findContentControl as bZ, findElement as b_, type OoxmlPackageResult as ba, type OoxmlParagraphPropertiesNode as bb, type OoxmlPartMetadata as bc, type OoxmlReadRejection as bd, type OoxmlReadResult as be, type OoxmlRunNode as bf, type OoxmlRunPropertiesNode as bg, type OoxmlTabNode as bh, type OoxmlTextElementNode as bi, type OoxmlTextNode as bj, type OoxmlWmlValAttribute as bk, type OoxmlXmlSpaceAttribute as bl, type OverrideRecord as bm, type RelationshipError as bn, type RelationshipSetResult as bo, type RelationshipTargetResolver as bp, type ResolveResult as bq, type ResolvedRelationship as br, TABLE_BORDER_STYLES as bs, TREE_DOC_OP_KINDS as bt, type TabStopWrite as bu, type TargetMode as bv, type TreeDocOpKind as bw, type TreeOpEffect as bx, type ValidatedRasterHeader as by, WML_NAMESPACE_URI as bz, type OoxmlNodeId as c, hasBoundedSvgRoot as c0, hyperlinkAnchorOf as c1, hyperlinkRelationshipIdOf as c2, hyperlinkTargetOf as c3, imageResourceLookupFor as c4, isContentControlContentNode as c5, isContentControlNode as c6, isContentControlWrapper as c7, isContentRevisionKind as c8, isHyperlinkNode as c9, withPart as cA, writeOoxmlPackage as cB, writeZip as cC, isRangeMarkerKind as ca, isValidMime as cb, liveDrawingReferenceCount as cc, lockForbidsEdit as cd, lockForbidsRemoval as ce, normalizePartName as cf, orderedContentControlProperties as cg, parseContentControlId as ch, partNameKey as ci, projectDrawing as cj, readOnOffChild as ck, readOoxmlPackage as cl, readOoxmlPart as cm, readXml as cn, readZip as co, resolveContentControlLock as cp, resolveContentType as cq, resolveImageRelationship as cr, resolveInternalTarget as cs, resolveLimits as ct, resolveRelationship as cu, textContent as cv, validateExternalTarget as cw, validateGifHeader as cx, validateJpegHeader as cy, validatePngHeader as cz, type OoxmlGenericElementNode as d, type OoxmlPackageLimits as e, type OoxmlPackageRejection as f, type OoxmlElement as g, type OoxmlContentControlNode as h, type OoxmlContentControlContentNode as i, type OoxmlParagraphNode as j, type OoxmlNoteNode as k, type OoxmlContinuationSeparatorNode as l, type OoxmlEndnotesNode as m, type OoxmlFootnotesNode as n, type OoxmlNoteRefNode as o, type OoxmlNoteReferenceNode as p, type OoxmlSeparatorNode as q, type TreeOpRejection as r, type OoxmlProperty as s, type RenderableImageMime as t, type ImageWrapTarget as u, type DrawingPositionInput as v, type DrawingLocks as w, type ImageResourceState as x, type SupportedImageMime as y, type DrawingHorizontalReferenceFrame as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as OoxmlPackage, y as SupportedImageMime, O as OoxmlPart, a as OoxmlNode, g as OoxmlElement, E as RevisionAttributionInput, C as ImageDecodePort, F as DrawingTreeDocOp, r as TreeOpRejection, T as TreeDocOp } from './tree-op-types-
|
|
2
|
-
import { N as NoteKind, T as TreeModelChange, a as TreeDocumentStore, c as TreeStoryRef, d as TransactionContext, b as TransactOptions, S as SelectionMark, e as TreeDocumentCheckpoint } from './tree-store-
|
|
1
|
+
import { b as OoxmlPackage, y as SupportedImageMime, O as OoxmlPart, a as OoxmlNode, g as OoxmlElement, E as RevisionAttributionInput, C as ImageDecodePort, F as DrawingTreeDocOp, r as TreeOpRejection, T as TreeDocOp } from './tree-op-types-D6HzlPR4.js';
|
|
2
|
+
import { N as NoteKind, T as TreeModelChange, a as TreeDocumentStore, c as TreeStoryRef, d as TransactionContext, b as TransactOptions, S as SelectionMark, e as TreeDocumentCheckpoint } from './tree-store-APgWx6qn.js';
|
|
3
3
|
|
|
4
4
|
/** A freshly allocated drawing property id, or the reason one could not be minted. */
|
|
5
5
|
type DrawingPropertyIdResult = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as OoxmlPackage, y as SupportedImageMime, O as OoxmlPart, a as OoxmlNode, g as OoxmlElement, E as RevisionAttributionInput, C as ImageDecodePort, F as DrawingTreeDocOp, r as TreeOpRejection, T as TreeDocOp } from './tree-op-types-
|
|
2
|
-
import { N as NoteKind, T as TreeModelChange, a as TreeDocumentStore, c as TreeStoryRef, d as TransactionContext, b as TransactOptions, S as SelectionMark, e as TreeDocumentCheckpoint } from './tree-store-
|
|
1
|
+
import { b as OoxmlPackage, y as SupportedImageMime, O as OoxmlPart, a as OoxmlNode, g as OoxmlElement, E as RevisionAttributionInput, C as ImageDecodePort, F as DrawingTreeDocOp, r as TreeOpRejection, T as TreeDocOp } from './tree-op-types-BUulYD5y.cjs';
|
|
2
|
+
import { N as NoteKind, T as TreeModelChange, a as TreeDocumentStore, c as TreeStoryRef, d as TransactionContext, b as TransactOptions, S as SelectionMark, e as TreeDocumentCheckpoint } from './tree-store-DEEQ9wz_.cjs';
|
|
3
3
|
|
|
4
4
|
/** A freshly allocated drawing property id, or the reason one could not be minted. */
|
|
5
5
|
type DrawingPropertyIdResult = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as StoryScope, a as StoryTargetRejection, b as HeaderFooterParts, c as HeaderFooterSectionResolution, I as InsertImageInput, d as ImageIntentResult, R as ReplaceImageOptions, A as ApplyImagePropertiesInput, F as FragmentPasteInput, e as FragmentPasteResult } from './tree-package-fragment-
|
|
2
|
-
import { T as TreeDocOp, O as OoxmlPart, a as OoxmlNode, b as OoxmlPackage, g as OoxmlElement, y as SupportedImageMime, C as ImageDecodePort, E as RevisionAttributionInput } from './tree-op-types-
|
|
3
|
-
import { D as DocumentTrackingSettings, I as InsertCustomNodeWrite, C as CustomNodeWriteResult, a as CustomNodeSweepOutcome, E as EmbeddedFont, B as BookmarkIndex, L as ListKind } from './custom-node-writes-
|
|
1
|
+
import { S as StoryScope, a as StoryTargetRejection, b as HeaderFooterParts, c as HeaderFooterSectionResolution, I as InsertImageInput, d as ImageIntentResult, R as ReplaceImageOptions, A as ApplyImagePropertiesInput, F as FragmentPasteInput, e as FragmentPasteResult } from './tree-package-fragment-B1supBtE.js';
|
|
2
|
+
import { T as TreeDocOp, O as OoxmlPart, a as OoxmlNode, b as OoxmlPackage, g as OoxmlElement, y as SupportedImageMime, C as ImageDecodePort, E as RevisionAttributionInput } from './tree-op-types-D6HzlPR4.js';
|
|
3
|
+
import { D as DocumentTrackingSettings, I as InsertCustomNodeWrite, C as CustomNodeWriteResult, a as CustomNodeSweepOutcome, E as EmbeddedFont, B as BookmarkIndex, L as ListKind } from './custom-node-writes-DntmaAVW.js';
|
|
4
4
|
import { D as DocumentProperties } from './document-properties-D6Ahr8D6.js';
|
|
5
|
-
import { S as SelectionMark, b as TransactOptions, T as TreeModelChange } from './tree-store-
|
|
6
|
-
import { a as ReviewItem } from './review-items-
|
|
5
|
+
import { S as SelectionMark, b as TransactOptions, T as TreeModelChange } from './tree-store-APgWx6qn.js';
|
|
6
|
+
import { a as ReviewItem } from './review-items-CCS1h93f.js';
|
|
7
7
|
import { Node } from 'prosemirror-model';
|
|
8
8
|
import { CollaborationDocumentPort } from './collaboration/replication.js';
|
|
9
9
|
|
|
@@ -264,6 +264,18 @@ interface TreeDocxSessionView {
|
|
|
264
264
|
* and one undo unit without swapping the body store.
|
|
265
265
|
*/
|
|
266
266
|
applyTreeOps(ops: readonly TreeDocOp[], selectionBefore?: SelectionMark | null, selectionAfter?: SelectionMark | null, scope?: StoryScope, options?: TreeApplyOptions): TreeApplyResult;
|
|
267
|
+
/**
|
|
268
|
+
* Commit several stories' ops as ONE transaction and ONE undo unit.
|
|
269
|
+
*
|
|
270
|
+
* `applyTreeOps` addresses one story; a write that must land in the body AND note parts
|
|
271
|
+
* together — the save-time field-result refresh — needs all-or-nothing semantics, or a
|
|
272
|
+
* mid-sequence refusal exports a file mixing refreshed and stale values and a single undo
|
|
273
|
+
* restores only the last part. Any refusal rolls every group back. Lifecycle ops refuse.
|
|
274
|
+
*/
|
|
275
|
+
applyTreeOpsAtomic(groups: readonly {
|
|
276
|
+
readonly scope: StoryScope;
|
|
277
|
+
readonly ops: readonly TreeDocOp[];
|
|
278
|
+
}[], options?: TreeApplyOptions): TreeApplyResult;
|
|
267
279
|
/**
|
|
268
280
|
* Every part that holds a story, body first, then headers, footers and note parts.
|
|
269
281
|
*
|
|
@@ -328,6 +340,17 @@ interface TreeDocxSessionView {
|
|
|
328
340
|
* Memoized per package revision.
|
|
329
341
|
*/
|
|
330
342
|
documentFonts(): readonly string[];
|
|
343
|
+
/**
|
|
344
|
+
* Font families the document's RENDERED text resolves to, over the story roots only:
|
|
345
|
+
* direct run `w:rFonts` of text-bearing runs plus the style chains those runs,
|
|
346
|
+
* paragraphs and tables actually reference — never a declaration in an unused style.
|
|
347
|
+
* Memoized per package revision.
|
|
348
|
+
*
|
|
349
|
+
* The font-substitution notice reads this one: `documentFonts` reports what the
|
|
350
|
+
* document DECLARES, and Word writes latent styles (Balloon Text naming Segoe UI)
|
|
351
|
+
* into documents that never render a character in them.
|
|
352
|
+
*/
|
|
353
|
+
renderedFontFamilies(): readonly string[];
|
|
331
354
|
/**
|
|
332
355
|
* Whether the document puts any literal character on a page, over the same roots
|
|
333
356
|
* {@link TreeDocxSessionView.documentFonts} reads. Memoized per package revision.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as StoryScope, a as StoryTargetRejection, b as HeaderFooterParts, c as HeaderFooterSectionResolution, I as InsertImageInput, d as ImageIntentResult, R as ReplaceImageOptions, A as ApplyImagePropertiesInput, F as FragmentPasteInput, e as FragmentPasteResult } from './tree-package-fragment-
|
|
2
|
-
import { T as TreeDocOp, O as OoxmlPart, a as OoxmlNode, b as OoxmlPackage, g as OoxmlElement, y as SupportedImageMime, C as ImageDecodePort, E as RevisionAttributionInput } from './tree-op-types-
|
|
3
|
-
import { D as DocumentTrackingSettings, I as InsertCustomNodeWrite, C as CustomNodeWriteResult, a as CustomNodeSweepOutcome, E as EmbeddedFont, B as BookmarkIndex, L as ListKind } from './custom-node-writes-
|
|
1
|
+
import { S as StoryScope, a as StoryTargetRejection, b as HeaderFooterParts, c as HeaderFooterSectionResolution, I as InsertImageInput, d as ImageIntentResult, R as ReplaceImageOptions, A as ApplyImagePropertiesInput, F as FragmentPasteInput, e as FragmentPasteResult } from './tree-package-fragment-ByN5yzll.cjs';
|
|
2
|
+
import { T as TreeDocOp, O as OoxmlPart, a as OoxmlNode, b as OoxmlPackage, g as OoxmlElement, y as SupportedImageMime, C as ImageDecodePort, E as RevisionAttributionInput } from './tree-op-types-BUulYD5y.cjs';
|
|
3
|
+
import { D as DocumentTrackingSettings, I as InsertCustomNodeWrite, C as CustomNodeWriteResult, a as CustomNodeSweepOutcome, E as EmbeddedFont, B as BookmarkIndex, L as ListKind } from './custom-node-writes-C46r3_5O.cjs';
|
|
4
4
|
import { D as DocumentProperties } from './document-properties-D6Ahr8D6.cjs';
|
|
5
|
-
import { S as SelectionMark, b as TransactOptions, T as TreeModelChange } from './tree-store-
|
|
6
|
-
import { a as ReviewItem } from './review-items-
|
|
5
|
+
import { S as SelectionMark, b as TransactOptions, T as TreeModelChange } from './tree-store-DEEQ9wz_.cjs';
|
|
6
|
+
import { a as ReviewItem } from './review-items-CaAkgi5s.cjs';
|
|
7
7
|
import { Node } from 'prosemirror-model';
|
|
8
8
|
import { CollaborationDocumentPort } from './collaboration/replication.cjs';
|
|
9
9
|
|
|
@@ -264,6 +264,18 @@ interface TreeDocxSessionView {
|
|
|
264
264
|
* and one undo unit without swapping the body store.
|
|
265
265
|
*/
|
|
266
266
|
applyTreeOps(ops: readonly TreeDocOp[], selectionBefore?: SelectionMark | null, selectionAfter?: SelectionMark | null, scope?: StoryScope, options?: TreeApplyOptions): TreeApplyResult;
|
|
267
|
+
/**
|
|
268
|
+
* Commit several stories' ops as ONE transaction and ONE undo unit.
|
|
269
|
+
*
|
|
270
|
+
* `applyTreeOps` addresses one story; a write that must land in the body AND note parts
|
|
271
|
+
* together — the save-time field-result refresh — needs all-or-nothing semantics, or a
|
|
272
|
+
* mid-sequence refusal exports a file mixing refreshed and stale values and a single undo
|
|
273
|
+
* restores only the last part. Any refusal rolls every group back. Lifecycle ops refuse.
|
|
274
|
+
*/
|
|
275
|
+
applyTreeOpsAtomic(groups: readonly {
|
|
276
|
+
readonly scope: StoryScope;
|
|
277
|
+
readonly ops: readonly TreeDocOp[];
|
|
278
|
+
}[], options?: TreeApplyOptions): TreeApplyResult;
|
|
267
279
|
/**
|
|
268
280
|
* Every part that holds a story, body first, then headers, footers and note parts.
|
|
269
281
|
*
|
|
@@ -328,6 +340,17 @@ interface TreeDocxSessionView {
|
|
|
328
340
|
* Memoized per package revision.
|
|
329
341
|
*/
|
|
330
342
|
documentFonts(): readonly string[];
|
|
343
|
+
/**
|
|
344
|
+
* Font families the document's RENDERED text resolves to, over the story roots only:
|
|
345
|
+
* direct run `w:rFonts` of text-bearing runs plus the style chains those runs,
|
|
346
|
+
* paragraphs and tables actually reference — never a declaration in an unused style.
|
|
347
|
+
* Memoized per package revision.
|
|
348
|
+
*
|
|
349
|
+
* The font-substitution notice reads this one: `documentFonts` reports what the
|
|
350
|
+
* document DECLARES, and Word writes latent styles (Balloon Text naming Segoe UI)
|
|
351
|
+
* into documents that never render a character in them.
|
|
352
|
+
*/
|
|
353
|
+
renderedFontFamilies(): readonly string[];
|
|
331
354
|
/**
|
|
332
355
|
* Whether the document puts any literal character on a page, over the same roots
|
|
333
356
|
* {@link TreeDocxSessionView.documentFonts} reads. Memoized per package revision.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OoxmlNode, j as OoxmlParagraphNode, k as OoxmlNoteNode, l as OoxmlContinuationSeparatorNode, m as OoxmlEndnotesNode, n as OoxmlFootnotesNode, o as OoxmlNoteRefNode, p as OoxmlNoteReferenceNode, q as OoxmlSeparatorNode, I as ImpactClass, O as OoxmlPart, b as OoxmlPackage, T as TreeDocOp, r as TreeOpRejection } from './tree-op-types-
|
|
1
|
+
import { a as OoxmlNode, j as OoxmlParagraphNode, k as OoxmlNoteNode, l as OoxmlContinuationSeparatorNode, m as OoxmlEndnotesNode, n as OoxmlFootnotesNode, o as OoxmlNoteRefNode, p as OoxmlNoteReferenceNode, q as OoxmlSeparatorNode, I as ImpactClass, O as OoxmlPart, b as OoxmlPackage, T as TreeDocOp, r as TreeOpRejection } from './tree-op-types-D6HzlPR4.js';
|
|
2
2
|
|
|
3
3
|
/** UTF-16 placeholder for one atomic note unit in `paragraphTextOf` / segments. */
|
|
4
4
|
declare const NOTE_ATOM_CHAR = "\uFFFC";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OoxmlNode, j as OoxmlParagraphNode, k as OoxmlNoteNode, l as OoxmlContinuationSeparatorNode, m as OoxmlEndnotesNode, n as OoxmlFootnotesNode, o as OoxmlNoteRefNode, p as OoxmlNoteReferenceNode, q as OoxmlSeparatorNode, I as ImpactClass, O as OoxmlPart, b as OoxmlPackage, T as TreeDocOp, r as TreeOpRejection } from './tree-op-types-
|
|
1
|
+
import { a as OoxmlNode, j as OoxmlParagraphNode, k as OoxmlNoteNode, l as OoxmlContinuationSeparatorNode, m as OoxmlEndnotesNode, n as OoxmlFootnotesNode, o as OoxmlNoteRefNode, p as OoxmlNoteReferenceNode, q as OoxmlSeparatorNode, I as ImpactClass, O as OoxmlPart, b as OoxmlPackage, T as TreeDocOp, r as TreeOpRejection } from './tree-op-types-BUulYD5y.cjs';
|
|
2
2
|
|
|
3
3
|
/** UTF-16 placeholder for one atomic note unit in `paragraphTextOf` / segments. */
|
|
4
4
|
declare const NOTE_ATOM_CHAR = "\uFFFC";
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docx-editor.dev/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "Framework-agnostic core for docx-editor.dev: OOXML parse/serialize, the canonical document tree, layout and paint, and the Editor contract the adapters render.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^20.16.0 || >=22.3.0"
|
|
8
|
+
},
|
|
6
9
|
"exports": {
|
|
7
10
|
".": {
|
|
8
11
|
"types": "./dist/index.d.ts",
|
|
@@ -97,7 +100,7 @@
|
|
|
97
100
|
"directory": "packages/core"
|
|
98
101
|
},
|
|
99
102
|
"dependencies": {
|
|
100
|
-
"@docx-editor.dev/i18n": "^2.
|
|
103
|
+
"@docx-editor.dev/i18n": "^2.13.0",
|
|
101
104
|
"bidi-js": "1.0.3",
|
|
102
105
|
"emf-converter": "2.0.2",
|
|
103
106
|
"fast-xml-parser": "^5.10.1",
|
package/dist/chunk-3JON7JMD.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkJWZG4QJ5_cjs=require('./chunk-JWZG4QJ5.cjs'),chunkILTZTY3K_cjs=require('./chunk-ILTZTY3K.cjs');var Bt=Object.freeze(["default","first","even"]),ct=Object.freeze({kind:"body"});function B(n){switch(n.kind){case "body":return "body";case "note":return `note:${n.noteKind}:${String(n.noteId)}`;default:return `${n.kind}:${String(n.sectionIndex)}:${n.variant}`}}function an(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="body"?true:e.kind==="note"?(e.noteKind==="footnote"||e.noteKind==="endnote")&&Number.isInteger(e.noteId):e.kind!=="header"&&e.kind!=="footer"?false:Number.isInteger(e.sectionIndex)&&e.sectionIndex>=0&&Bt.includes(e.variant)}var fr=["getDocument","getBody","getParagraphs","getSpanParagraphs","getText","getSpanText","getParagraphId","search","getFont","getParagraphFormat","getStyle","getSections","getPageSetup","getFurniture","getNotes","getNoteBody","getNoteText","getNoteKind","getLists","getListId","getListById","getListParagraphs","getParagraphList","getListLevel","getHyperlink","getBookmarks","getBookmarkName","getBookmarkRange","getComments","getCommentReplies","getCommentId","getCommentAuthor","getCommentDate","getCommentText","getCommentRange","getCommentResolved","getRevisions","getRevisionType","getRevisionAuthor","getRevisionDate","getRevisionRange","getContentControls","getContentControlById","getContentControlsByTag","getContentControlsByTitle","getContentControlTag","getContentControlTitle","getContentControlFileId","getContentControlSubtype","getContentControlLock","getContentControlIsBound","getContentControlPlaceholderShown","getContentControlTemporary","getContentControlText","getContentControlParagraphs","getContentControlRange"],lo=["insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],uo=["deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],co=new Set(uo);function Zt(n){return co.has(n.op)}var po=new Set(lo);function qt(n){return po.has(n.op)}function mo(){let n=globalThis.crypto,e=n?.getRandomValues;if(typeof e!="function")throw new Error("automation: no secure random source. globalThis.crypto.getRandomValues is required to scope document handles to one host.");let s=e.call(n,new Uint8Array(16)),a="";for(let i of s)a+=i.toString(16).padStart(2,"0");return a}function fo(n){return typeof n=="object"&&n!==null&&"kind"in n&&"ref"in n}function sn(){let n=new Map,e=new Map,s=new Map,a=new Map,i=mo(),u=null,c=(m,y)=>{let v=(a.get(m)??0)+1;a.set(m,v);let k=`${m}:${i}:${String(v)}`;return n.set(k,y),Object.freeze({kind:m,ref:k})},g=(m,y,v)=>{let k=`${m}\0${y}`,S=s.get(k);if(S)return Object.freeze({kind:m,ref:S});let A=c(m,v);return s.set(k,A.ref),A};return {document(){return u??=c("document",{kind:"document"}),u},body(m){return g("body",B(m),{kind:"body",story:m})},paragraph(m,y){let v=e.get(m);if(v)return Object.freeze({kind:"paragraph",ref:v});let k=c("paragraph",{kind:"paragraph",paragraphId:m,story:y});return e.set(m,k.ref),k},section(m){return g("section",String(m),{kind:"section",index:m})},note(m,y){return g("note",`${m}:${String(y)}`,{kind:"note",noteKind:m,noteId:y})},comment(m,y){return g("comment",`${B(y)}\0${m}`,{kind:"comment",commentId:m,story:y})},revision(m,y){return g("revision",`${B(y)}\0${m}`,{kind:"revision",revisionId:m,story:y})},bookmark(m,y){return g("bookmark",`${B(y)}\0${m}`,{kind:"bookmark",name:m,story:y})},list(m,y){return g("list",`${B(y)}\0${m}`,{kind:"list",numId:m,story:y})},contentControl(m,y){return g("contentControl",`${B(y)}\0${m}`,{kind:"contentControl",nodeId:m,story:y})},retarget(m,y){let v=e.get(m);if(!v||m===y)return;let k=n.get(v);!k||k.kind!=="paragraph"||(e.delete(m),n.set(v,{kind:"paragraph",paragraphId:y,story:k.story}),e.has(y)||e.set(y,v));},resolve(m,y){if(!fo(m)||m.kind!==y||typeof m.ref!="string")return null;let v=n.get(m.ref);return !v||v.kind!==y?null:v}}}var yo=255,go=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function dn(n){let e=chunkILTZTY3K_cjs.wd(n);if(!e)return go;let s=new Map,a=new Map,i=null;for(let u of chunkILTZTY3K_cjs.vd(e).values())if(u.type==="paragraph"){if(s.set(u.styleId,u.name),u.name!==null){let c=u.name.trim().toLowerCase();a.has(c)||a.set(c,u.styleId);}u.isDefault&&i===null&&(i=u.styleId);}return Object.freeze({nameOf:u=>s.get(u)??null,idOf:u=>a.get(u.trim().toLowerCase())??null,defaultId:i,present:true})}function Ft(n,e,s){let a=chunkILTZTY3K_cjs.Ca(n,e);if(!a||a.kind!=="paragraph")return null;let i=ho(chunkILTZTY3K_cjs.Ge(chunkILTZTY3K_cjs.Ee(a),"pStyle"));return i!==null?s.nameOf(i):s.defaultId===null?null:s.nameOf(s.defaultId)}function ho(n){if(!n)return null;for(let e of n.attributes)if(e.localName==="val")return e.value;return null}function _t(n,e){if(typeof n!="string"||n.trim().length===0)return {ok:false,detail:"style: not a name"};if(n.length>yo)return {ok:false,detail:"style: name too long"};if(!chunkILTZTY3K_cjs.O(n))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let s=e.idOf(n);return s===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:s}}var ko=31680,Ao=1999,vo=Object.freeze({bold:null,italic:null,name:null,size:null,color:null});function Y(n,e){if(!n)return null;for(let s of n.attributes)if(s.localName===e)return s.value;return null}function te(n){if(!n)return null;let e=Y(n,"val");if(e===null)return true;let s=e.trim().toLowerCase();return !(s==="0"||s==="false"||s==="off"||s==="none")}function bo(n){if(n===null)return null;let e=n.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function xo(n){if(n===null)return null;let e=Number(n.trim());return !Number.isFinite(e)||e<=0?null:e/2}function ft(n){if(n===null)return null;let e=Number(n.trim());return Number.isFinite(e)?chunkILTZTY3K_cjs.ld(chunkILTZTY3K_cjs.jd(e)):null}function Rt(n){if(n.length===0)return null;let e=n[0];if(e===null)return null;for(let s of n)if(s!==e)return null;return e}function un(n,e,s=chunkJWZG4QJ5_cjs.C){let a=[];for(let i of e)for(let u of chunkJWZG4QJ5_cjs.U(n,i.paragraphId,i.start,i.end,s))a.push(chunkILTZTY3K_cjs.Fe(u));return a.length===0?vo:{bold:Rt(a.map(i=>te(chunkILTZTY3K_cjs.Ge(i,"b")))),italic:Rt(a.map(i=>te(chunkILTZTY3K_cjs.Ge(i,"i")))),name:Rt(a.map(i=>{let u=chunkILTZTY3K_cjs.Ge(i,"rFonts"),c=Y(u,"ascii");return c===null||c.length===0?null:c})),size:Rt(a.map(i=>xo(Y(chunkILTZTY3K_cjs.Ge(i,"sz"),"val")))),color:Rt(a.map(i=>bo(Y(chunkILTZTY3K_cjs.Ge(i,"color"),"val"))))}}var Io=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),So=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function Ro(n){let e=Y(chunkILTZTY3K_cjs.Ge(n,"jc"),"val");return e===null?"Unknown":Io[e.trim().toLowerCase()]??"Unknown"}function cn(n,e,s){let a=chunkILTZTY3K_cjs.Ca(n,e);if(!a||a.kind!=="paragraph")return null;let i=chunkILTZTY3K_cjs.Ee(a),u=chunkILTZTY3K_cjs.Ge(i,"spacing"),c=chunkILTZTY3K_cjs.Ge(i,"ind");return {alignment:Ro(i),style:Ft(n,e,s),firstLineIndent:Co(c),leftIndent:ft(Y(c,"left")??Y(c,"start")),rightIndent:ft(Y(c,"right")??Y(c,"end")),lineSpacing:ft(Y(u,"line")),spaceBefore:ft(Y(u,"before")),spaceAfter:ft(Y(u,"after")),widowControl:te(chunkILTZTY3K_cjs.Ge(i,"widowControl"))}}function Co(n){let e=ft(Y(n,"hanging"));if(e!==null&&e>0)return -e;let s=ft(Y(n,"firstLine"));return s!==null?s:e===null?null:-e}function Dt(n,e){if(typeof n!="number"||!Number.isFinite(n))return {ok:false,detail:`${e}: not a measurement`};let s=chunkILTZTY3K_cjs.md(chunkILTZTY3K_cjs.kd(n));return Math.abs(s)>ko?{ok:false,detail:`${e}: out of range`}:{ok:true,value:s}}function pn(n){let e=[];if(n.bold!==void 0){if(typeof n.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};e.push({localName:"b",...n.bold?{}:{attributes:{val:"0"}}});}if(n.italic!==void 0){if(typeof n.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};e.push({localName:"i",...n.italic?{}:{attributes:{val:"0"}}});}if(n.name!==void 0){let s=n.name;if(typeof s!="string"||s.length===0||s.length>128)return {ok:false,detail:"name: not a font name"};if(!chunkILTZTY3K_cjs.O(s))return {ok:false,detail:"name: not valid XML text"};e.push({localName:"rFonts",attributes:{ascii:s,hAnsi:s}});}if(n.size!==void 0){let s=n.size;if(typeof s!="number"||!Number.isFinite(s)||s<=0)return {ok:false,detail:"size: not a positive number of points"};let a=Math.round(s*2);if(a<1||a>Ao)return {ok:false,detail:"size: out of range"};e.push({localName:"sz",attributes:{val:String(a)}}),e.push({localName:"szCs",attributes:{val:String(a)}});}if(n.color!==void 0){let s=n.color;if(typeof s!="string"||!/^#[0-9a-fA-F]{6}$/.test(s.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};e.push({localName:"color",attributes:{val:s.trim().slice(1).toUpperCase()}});}return e.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:e}}function mn(n,e,s,a){let i=chunkILTZTY3K_cjs.Ca(n,e);if(!i||i.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let u=chunkILTZTY3K_cjs.Ee(i),c=[];if(s.style!==void 0){let A=_t(s.style,a);if(!A.ok)return {ok:false,detail:A.detail};c.push({localName:"pStyle",attributes:{val:A.styleId}});}if(s.alignment!==void 0){let A=So[s.alignment];if(A===void 0)return {ok:false,detail:`alignment: ${String(s.alignment)}`};c.push({localName:"jc",attributes:{val:A}});}let g=chunkILTZTY3K_cjs.Ge(u,"ind"),m=ln(g),y=false;if(s.firstLineIndent!==void 0){let A=Dt(s.firstLineIndent,"firstLineIndent");if(!A.ok)return A;delete m.firstLine,delete m.hanging,A.value<0?m.hanging=String(-A.value):m.firstLine=String(A.value),y=true;}for(let[A,b,C]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let O=s[A];if(O===void 0)continue;let T=Dt(O,A);if(!T.ok)return T;delete m[C],m[b]=String(T.value),y=true;}y&&c.push({localName:"ind",attributes:m});let v=chunkILTZTY3K_cjs.Ge(u,"spacing"),k=ln(v),S=false;for(let[A,b]of [["spaceBefore","before"],["spaceAfter","after"]]){let C=s[A];if(C===void 0)continue;let O=Dt(C,A);if(!O.ok)return O;if(O.value<0)return {ok:false,detail:`${A}: out of range`};k[b]=String(O.value),S=true;}if(s.lineSpacing!==void 0){let A=Dt(s.lineSpacing,"lineSpacing");if(!A.ok)return A;if(A.value<=0)return {ok:false,detail:"lineSpacing: out of range"};k.line=String(A.value),k.lineRule??="auto",S=true;}if(S&&c.push({localName:"spacing",attributes:k}),s.widowControl!==void 0){if(typeof s.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};c.push({localName:"widowControl",...s.widowControl?{}:{attributes:{val:"0"}}});}return c.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:chunkJWZG4QJ5_cjs.M(chunkJWZG4QJ5_cjs.K(n,e),c)}}function ln(n){let e=Object.create(null);if(!n)return e;for(let s of n.attributes)e[s.localName]=s.value;return e}function fn(){let n=false,e=false,s=false;return {conflict(a){let i=qt(a),u=Zt(a),c=a.op==="deleteComment";return u&&n||e&&i?{message:"that command commits on its own and cannot share a batch",detail:a.op}:c&&n&&!s||s&&i&&!c?{message:"comment deletions may share a batch only with other comment deletions",detail:a.op}:null},note(a){qt(a)&&(n=true,Zt(a)&&(e=true),a.op==="deleteComment"&&(s=true));},get hasCommands(){return n}}}var Po=63360;function lt(n){return Math.round(chunkILTZTY3K_cjs.ld(chunkILTZTY3K_cjs.jd(n))*100)/100}function Oo(n,e){if(typeof n!="number"||!Number.isFinite(n))return null;let s=chunkILTZTY3K_cjs.md(chunkILTZTY3K_cjs.kd(n));return s>Po||s<0||s===0&&!e?null:s}var wo=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function yn(n){if(typeof n!="object"||n===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=n,s={},a=0;for(let[u,c,g]of wo){let m=e[u];if(m===void 0)continue;let y=Oo(m,g);if(y===null)return {ok:false,reason:`that is not a value for ${u}`,detail:String(m)};s[c]=y,a+=1;}let i=e.orientation;if(i!==void 0){if(i!=="portrait"&&i!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(i)};s.orientation=i,a+=1;}return a===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:s}}function To(n){let e=chunkILTZTY3K_cjs.Lg(n),s=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:lt(e.widthTwips),pageHeight:lt(e.heightTwips),orientation:s,topMargin:lt(e.topTwips),rightMargin:lt(e.rightTwips),bottomMargin:lt(e.bottomTwips),leftMargin:lt(e.leftTwips),headerDistance:lt(e.headerTwips),footerDistance:lt(e.footerTwips),gutter:lt(e.gutterTwips)})}function No(n,e){if(!e)return null;let s=null,a=(i,u,c)=>{if(s!==null||i.kind==="textValue"||c>64)return;let g=i.kind==="paragraph"?i.id:u;if(i.id===e.id){s=g;return}for(let m of i.children)a(m,g,c+1);};return a(n.root,null,0),s}function gn(n,e,s){let a=chunkILTZTY3K_cjs.vc(e.root);return Object.freeze(a.map((i,u)=>{let c=s[u];return Object.freeze({index:u,markParagraphId:No(e,i),pageSetup:To(i),titlePage:c?.titlePage??false,evenAndOddHeaders:c?.evenAndOddHeaders??false})}))}function kn(n,e,s){if(s==="allMarkup")return hn(e);let a=Ho(n);if(a.length===0)return hn(e);let i=[],u=[],c=0,g=0;for(let m of a){if(c<m.start){let y=e.slice(c,m.start);i.push({projectedStart:g,projectedEnd:g+y.length,rawStart:c,rawEnd:m.start}),u.push(y),g+=y.length;}c=Math.max(c,m.end);}if(c<e.length){let m=e.slice(c);i.push({projectedStart:g,projectedEnd:g+m.length,rawStart:c,rawEnd:e.length}),u.push(m);}return An(u.join(""),i)}function hn(n){return An(n,n.length===0?[]:[{projectedStart:0,projectedEnd:n.length,rawStart:0,rawEnd:n.length}])}function An(n,e){return {text:n,projectedOffset(s){let a=0;for(let i of e)if(s<=i.rawStart||(a+=Math.max(0,Math.min(s,i.rawEnd)-i.rawStart),s<=i.rawEnd))return a;return a},rawRange(s,a){let i=e.find(c=>s>=c.projectedStart&&s<c.projectedEnd),u=e.find(c=>a>c.projectedStart&&a<=c.projectedEnd);return !i||!u||s>=a?null:{start:i.rawStart+s-i.projectedStart,end:u.rawStart+a-u.projectedStart}},sliceRaw(s,a){return s>=a?"":e.map(i=>{let u=Math.max(s,i.rawStart),c=Math.min(a,i.rawEnd);return u<c?n.slice(i.projectedStart+u-i.rawStart,i.projectedStart+c-i.rawStart):""}).join("")}}}function Ho(n){let e=chunkILTZTY3K_cjs.Ie(n),s=[],a=(u,c)=>{if(!(c>64||u.kind==="textValue")){if(u.kind==="revisionInsert"||u.kind==="revisionMoveTo"){let g=e.spanOf(u);g&&g.end>g.start&&s.push({start:g.start,end:g.end});return}for(let g of u.children)a(g,c+1);}};a(n,0),s.sort((u,c)=>u.start-c.start||c.end-u.end);let i=[];for(let u of s){let c=i[i.length-1];c&&u.start<=c.end?c.end=Math.max(c.end,u.end):i.push({...u});}return i}var ne="\r",jo=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),Mo=Object.freeze([]),Lo=Object.freeze([]),vn=Object.freeze([]),Eo=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>Lo,furniture:()=>vn,noteIds:()=>({ok:true,ids:xn}),styles:()=>jo});function Bo(n){return n.kind==="textValue"?Mo:Object.freeze(n.children.filter(e=>e.kind!=="textValue").map(e=>{let s=[];chunkILTZTY3K_cjs.Lf([e],s,0);let a=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",i=e.kind==="paragraph"&&chunkILTZTY3K_cjs.Ge(chunkILTZTY3K_cjs.Ee(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:a,paragraphIds:Object.freeze(s.map(u=>u.id)),removable:a!=="other"&&!i})}))}function ee(n,e,s,a,i){let u=chunkILTZTY3K_cjs.Kf(a),c=Object.freeze(u.map(A=>A.id)),g=new Map,m=new Map;u.forEach((A,b)=>{g.set(A.id,b),m.set(A.id,A);});let y=new Map,v=A=>{if(!g.has(A))return null;let b=y.get(A);if(b!==void 0)return b;let C=chunkILTZTY3K_cjs._g(e,A)??"";return y.set(A,C),C},k=new Map,S=(A,b="allMarkup")=>{let C=m.get(A);if(!C||C.kind!=="paragraph")return null;let O=`${A}:${b}`,T=k.get(O);if(T)return T;let L=kn(C,v(A)??"",b);return k.set(O,L),L};return {story:n,part:e,root:a,scope:s,paragraphIds:c,blocks:Bo(a),has:A=>g.has(A),indexOf:A=>g.get(A)??-1,paragraph(A){let b=m.get(A);return b?{nodeId:A,paraId:chunkILTZTY3K_cjs.vb(b),text:v(A)??""}:null},node:A=>m.get(A)??null,paragraphText:(A,b)=>S(A,b)?.text??null,projectedText:S,text:A=>c.map(b=>S(b,A)?.text??"").join(ne),styles:i}}function bn(n){let e=n.parts.get(n.mainDocumentPart);if(!e)return Eo;let s,a=()=>s??=dn(n),i,u=()=>i??=chunkILTZTY3K_cjs.xc(n),c,g=new Map,m=new Map,y=b=>{let C=m.get(b);if(C)return C;let O=chunkILTZTY3K_cjs.Pe(n,b);if(!O){let V={ok:true,ids:xn};return m.set(b,V),V}let T=[],L=new Set,F=new Set,J=0,X=false;for(let V of O.root.children){if(chunkILTZTY3K_cjs.Yd(V)!==b)continue;if(J+=1,V.kind!=="note"){X=true;continue}if(!chunkILTZTY3K_cjs.$d(V))continue;let nt=chunkILTZTY3K_cjs.Zd(V);if(nt===null){X=true;continue}L.has(nt)?F.add(nt):(L.add(nt),T.push(nt));}let M=J>chunkILTZTY3K_cjs.ge?{ok:false,reason:"truncated"}:X?{ok:false,reason:"malformed"}:F.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...F])}:{ok:true,ids:Object.freeze(T)};return m.set(b,M),M},v=b=>{let C=u()[b.sectionIndex];return C?(b.kind==="header"?C.headers:C.footers).get(b.variant)??null:null},k=b=>{if(b.kind==="body"){let O=chunkILTZTY3K_cjs.Jf(e);return O?ee(b,e,{kind:"body"},O,a):null}if(b.kind==="note"){let O=y(b.noteKind);if(!O.ok||!O.ids.includes(b.noteId))return null;let T=chunkILTZTY3K_cjs.Pe(n,b.noteKind);if(!T)return null;let L=chunkILTZTY3K_cjs.je(T.root,b.noteId);return !L||!chunkILTZTY3K_cjs.$d(L)?null:ee(b,T,{kind:"notesPart",noteKind:b.noteKind},L,a)}let C=v(b);return C?ee(b,C.part,{kind:"headerFooter",rId:C.rId},C.part.root,a):null},S=b=>{let C=B(b);if(g.has(C))return g.get(C)??null;let O=k(b);return g.set(C,O),O};return {package:n,get body(){return S(ct)},story:S,storyOf:b=>{if(S(ct)?.has(b))return ct;for(let[O]of u().entries())for(let T of ["header","footer"])for(let L of Bt){let F={kind:T,sectionIndex:O,variant:L};if(S(F)?.has(b))return F}for(let O of ["footnote","endnote"]){let T=y(O);if(T.ok)for(let L of T.ids){let F={kind:"note",noteKind:O,noteId:L};if(S(F)?.has(b))return F}}return null},sections:()=>c??=gn(n,e,u()),furniture(b){let C=u()[b];if(!C)return vn;let O=[];for(let T of ["header","footer"]){let L=T==="header"?C.headers:C.footers;for(let F of Bt){let J=L.get(F);J&&O.push(Object.freeze({kind:T,variant:F,declared:!J.inherited}));}}return Object.freeze(O)},noteIds:y,styles:a}}var xn=Object.freeze([]);function rt(n,e){return {ok:false,code:n,detail:e}}function at(n){return {ok:true,value:n}}function K(n,e,s,a){let i=s.resolve(n,e);if(!i||i.kind!=="body"&&i.kind!=="paragraph")return rt("invalid-handle",`not-a-${e}-handle`);let u=a.story(i.story);return u?at(u):rt("invalid-handle",`no-such-story:${B(i.story)}`)}function Z(n,e,s){let a=e.resolve(n,"paragraph");if(!a||a.kind!=="paragraph")return rt("invalid-handle","not-a-paragraph-handle");let i=s.story(a.story);if(!i)return rt("invalid-handle",`no-such-story:${B(a.story)}`);let u=i.indexOf(a.paragraphId);return u<0?rt("invalid-handle","paragraph-not-in-body"):at({story:a.story,paragraphId:a.paragraphId,index:u,offset:0})}function Fo(n,e,s){let a=Z(n.paragraph,e,s);if(!a.ok)return a;let u=(s.story(a.value.story)?.paragraphText(a.value.paragraphId)??"").length,{offset:c}=n;return !Number.isInteger(c)||c<0||c>u?rt("invalid-offset",`offset ${String(c)} outside 0..${String(u)}`):at({...a.value,offset:c})}function kt(n,e,s){if("paragraph"in n){if(!("at"in n))return Fo(n,e,s);let g=Z(n.paragraph,e,s);if(!g.ok||n.at==="start")return g;let y=(s.story(g.value.story)?.paragraphText(g.value.paragraphId)??"").length;return at({...g.value,offset:y})}let a=K(n.body,"body",e,s);if(!a.ok)return a;let i=a.value.paragraphIds;if(i.length===0)return rt("invalid-offset","empty-story");if(n.at==="start")return at({story:a.value.story,paragraphId:i[0],index:0,offset:0});let u=i.length-1,c=i[u];return at({story:a.value.story,paragraphId:c,index:u,offset:(a.value.paragraphText(c)??"").length})}function _o(n,e){return n.index<e.index||n.index===e.index&&n.offset<=e.offset}function Do(n){let e=n.paragraphIds;if(e.length===0)return null;let s=e.length-1,a=e[s];return {start:{story:n.story,paragraphId:e[0],index:0,offset:0},end:{story:n.story,paragraphId:a,index:s,offset:(n.paragraphText(a)??"").length}}}function W(n,e,s){if("body"in n){let u=K(n.body,"body",e,s);return u.ok?at(Do(u.value)):u}if("paragraph"in n){let u=Z(n.paragraph,e,s);if(!u.ok)return u;let g=(s.story(u.value.story)?.paragraphText(u.value.paragraphId)??"").length;return at({start:u.value,end:{...u.value,offset:g}})}let a=kt(n.start,e,s);if(!a.ok)return a;let i=kt(n.end,e,s);return i.ok?B(a.value.story)!==B(i.value.story)?rt("invalid-handle","span-crosses-stories"):_o(a.value,i.value)?at({start:a.value,end:i.value}):rt("invalid-offset","span-start-after-end"):i}function q(n,e,s){if("body"in n)return K(n.body,"body",e,s);if("paragraph"in n)return K(n.paragraph,"paragraph",e,s);let a=n.start;return "paragraph"in a?K(a.paragraph,"paragraph",e,s):K(a.body,"body",e,s)}function Wt(n,e,s){if("paragraph"in n)return Z(n.paragraph,e,s);let a=K(n.body,"body",e,s);if(!a.ok)return a;let i=a.value.paragraphIds;if(i.length===0)return rt("invalid-offset","empty-story");let u=n.at==="first"?0:i.length-1;return at({story:a.value.story,paragraphId:i[u],index:u,offset:0})}function tt(n,e){return n?e.paragraphIds.slice(n.start.index,n.end.index+1):[]}function oe(n,e){if(!n)return [];let s=tt(n,e),a=s.length-1;return s.map((i,u)=>{let c=(e.paragraphText(i)??"").length,g=u===0?n.start.offset:0,m=u===a?n.end.offset:c;return {paragraphId:i,start:g,end:m,whole:g===0&&m===c}})}function In(n,e,s,a="allMarkup"){if(!n)return "";let i=tt(n,e);return i.length===1?e.projectedText(n.start.paragraphId,a)?.sliceRaw(n.start.offset,n.end.offset)??"":i.map((u,c)=>{let g=e.projectedText(u,a);if(!g)return "";let m=(e.paragraphText(u)??"").length;return c===0?g.sliceRaw(n.start.offset,m):c===i.length-1?g.sliceRaw(0,n.end.offset):g.text}).join(s)}function re(n,e){return {start:{paragraph:e.paragraph(n.start.paragraphId,n.start.story),offset:n.start.offset},end:{paragraph:e.paragraph(n.end.paragraphId,n.end.story),offset:n.end.offset}}}var Wo=256,Sn=1e4;function ae(n,e){if(n.kind!=="textValue"){for(let s of n.attributes)if(s.namespaceUri===chunkILTZTY3K_cjs.ca&&s.localName===e)return s.value}}function zo(n){return n.startsWith("_")}function se(n){let e=new Map,s=[],a=new Set;for(let i of n.paragraphIds){let u=n.node(i);if(u?.kind!=="paragraph")continue;let c=chunkILTZTY3K_cjs.Ie(u),g=m=>{if(m.kind!=="textValue"){if(m.kind==="bookmarkStart"){if(s.length>=Sn||e.size>=Sn)return;let y=ae(m,"id"),v=ae(m,"name");if(y===void 0||v===void 0||v.length===0||v.length>Wo||zo(v)||a.has(v)||e.has(y))return;let k=c.spanOf(m)?.start??0;e.set(y,{name:v,start:{paragraphId:i,offset:k}});return}if(m.kind==="bookmarkEnd"){let y=ae(m,"id");if(y===void 0)return;let v=e.get(y);if(!v)return;e.delete(y),a.add(v.name);let k=c.spanOf(m)?.start??0;s.push(Object.freeze({name:v.name,start:v.start,end:{paragraphId:i,offset:k}}));return}for(let y of m.children)g(y);}};for(let m of u.children)g(m);}return Object.freeze(s)}function ie(n,e){return se(n).find(s=>s.name===e)??null}function Rn(n,e){let s=n.node(e);if(s?.kind!=="paragraph")return Object.freeze([]);let a=chunkILTZTY3K_cjs.Ie(s),i=[],u=(c,g)=>{if(!(c.kind==="textValue"||g>32)){if(chunkILTZTY3K_cjs.Qa(c)){let m=a.spanOf(c);m&&i.push(Object.freeze({id:c.id,paragraphId:e,start:m.start,end:m.end}));return}for(let m of c.children)u(m,g+1);}};for(let c of s.children)u(c,0);return Object.freeze(i)}function Cn(n,e,s){let a=chunkILTZTY3K_cjs.Ta(s,i=>chunkILTZTY3K_cjs.Fd(n,e,i));if(a.kind==="external")return a.href;if(a.kind==="internal"){let i=chunkILTZTY3K_cjs.Ra(s);return i===void 0||i.length===0?null:`#${i}`}return null}var At=8;function Pn(n){if(!n||n.kind==="textValue")return null;for(let e of n.attributes)if(e.namespaceUri===chunkILTZTY3K_cjs.ca&&e.localName==="val")return e.value;return null}function On(n){let e=chunkILTZTY3K_cjs.Ge(chunkILTZTY3K_cjs.Ee(n),"numPr");if(!e)return null;let s=Pn(chunkILTZTY3K_cjs.Ge(e,"numId"));if(s===null||!/^\d{1,10}$/.test(s)||s==="0")return null;let a=Pn(chunkILTZTY3K_cjs.Ge(e,"ilvl")),i=a===null?0:Number(a);return !Number.isInteger(i)||i<0||i>At?null:{numId:s,level:i}}function zt(n){let e=new Map;for(let s of n.paragraphIds){let a=n.node(s);if(!a)continue;let i=On(a);if(!i)continue;let u=e.get(i.numId);u?u.push(s):e.set(i.numId,[s]);}return Object.freeze([...e].map(([s,a])=>Object.freeze({numId:s,paragraphIds:Object.freeze(a)})))}function Ct(n,e){let s=n.node(e);return s?On(s):null}function wn(n,e,s,a,i){let u=Math.min(i?.limit??2e3,2e3),c=[],g=tt(e,n),m=g.length-1;for(let[y,v]of g.entries()){if(u<=0)break;let k=n.projectedText(v,i?.projection??"allMarkup");if(!k)continue;let S=chunkJWZG4QJ5_cjs.oa(k.text,a,u,{matchCase:i?.matchCase===true,wholeWord:i?.matchWholeWord===true,...y===0&&e?{from:k.projectedOffset(e.start.offset)}:{},...y===m&&e?{to:k.projectedOffset(e.end.offset)}:{}});for(let A of S.matches){let b=k.rawRange(A.start,A.start+A.length);if(!b)return {ok:false,paragraphId:v};if(y===0&&e&&b.start<e.start.offset||y===m&&e&&b.end>e.end.offset)continue;let C=s.paragraph(v,n.story);c.push({start:{paragraph:C,offset:b.start},end:{paragraph:C,offset:b.end}}),u-=1;}}return {ok:true,spans:c}}var Ko={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Vo(n){return n.kind==="note"}function $o(n,e){return e.length===0?!Vo(n.story):e.every(s=>n.has(s.start.paragraphId))}function Uo(n){return Object.freeze(chunkJWZG4QJ5_cjs.da(n.part).filter(e=>$o(n,e.ranges)))}function de(n){let e=[];for(let s of Uo(n)){if(s.readOnly||s.revisionKind==="structural")continue;let a=Ko[s.revisionKind];a!==void 0&&e.push(Object.freeze({id:s.id,type:a,author:s.author,date:s.date??"",item:s}));}return Object.freeze(e)}function Xo(n,e){let s=n;for(let a=0;s!==void 0&&a<=64;a+=1){if(s.parentId===void 0)return s.range!==null;s=e.get(s.parentId);}return false}var Yo=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function Tn(n,e){let s=n.parts.get(chunkJWZG4QJ5_cjs.o(n,e.part.name));if(!s)return Yo;let a=n.parts.get(chunkJWZG4QJ5_cjs.p(n,e.part.name)),i=chunkILTZTY3K_cjs.Pf(s),u=a?chunkILTZTY3K_cjs.Qf(a):new Map,c=chunkILTZTY3K_cjs.Of(e.part).filter(k=>e.has(k.start.paragraphId)),g=chunkJWZG4QJ5_cjs.ea(i,c,u),m=new Map(g.map(k=>[k.id,k])),y=g.filter(k=>Xo(k,m)),v=new Map(y.map(k=>[k.id,k]));return Object.freeze({items:Object.freeze(y),roots:Object.freeze(y.filter(k=>k.parentId===void 0)),byId:k=>v.get(k)??null,textOf:k=>{let S=v.get(k);return S?chunkJWZG4QJ5_cjs.ba(S.comment):""}})}function Nn(n,e,s){if("body"in n){let a=K(n.body,"body",e,s);return a.ok?{ok:true,reads:a.value}:{ok:false,code:a.code,message:"that handle does not name a body",detail:a.detail}}return e.resolve(n.document,"document")?s.body?{ok:true,reads:s.body}:{ok:false,code:"document-unavailable",message:"this host holds no document"}:{ok:false,code:"invalid-handle",message:"that handle does not name a document",detail:"document"}}function Hn(n,e){let s=n.op==="acceptAllRevisions",a=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [s?{op:"acceptAllRevisions",...a}:{op:"rejectAllRevisions",...a}]}var Go=/[\r\n\u2028\u2029]/u,Mn=Object.freeze({kind:"applied"});function vt(n,e,s){return {ok:false,error:Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}}function le(n,e){return vt("unsupported-content",n==="author"?"a comment records who wrote it":n==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",n)}function ue(n){return chunkJWZG4QJ5_cjs.g(n.author)?le("author",n.kind):chunkJWZG4QJ5_cjs.h(n.text)?le("text",n.kind):typeof n.text=="string"&&Go.test(n.text)?vt("unsupported-content",n.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):chunkJWZG4QJ5_cjs.j(n.date)?le("date",n.kind):null}function ce(n){if(n===void 0)return;let e=chunkJWZG4QJ5_cjs.i(n);return e.ok?e.value:void 0}function jn(n,e){let s=chunkILTZTY3K_cjs.Ca(n.part,e);for(;s;){if(s.kind==="tableCell"||s.kind!=="textValue"&&s.namespaceUri===chunkILTZTY3K_cjs.ca&&s.localName==="tc")return s.id;s=chunkILTZTY3K_cjs.Da(n.part,s.id);}return null}function Ln(n,e,s,a){let i=ue({author:n.author,text:n.text,date:n.date,kind:"comment"});if(i)return i;let u=W(n.span,e,s);if(!u.ok)return vt(u.code,"that span is not a place",u.detail);if(u.value===null)return vt("invalid-handle","an empty story has no comment anchor");let c=q(n.span,e,s);if(!c.ok)return vt(c.code,"that span is not a place",c.detail);let g=u.value;if(jn(c.value,g.start.paragraphId)!==jn(c.value,g.end.paragraphId))return vt("unsupported-content","a comment range cannot cross a table-cell boundary");let m=a(c.value);if(m)return m;let y=ce(n.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:g.start.paragraphId,start:g.start.offset,end:g.end.offset,...g.end.paragraphId===g.start.paragraphId?{}:{endParagraphId:g.end.paragraphId}},text:n.text,author:n.author,...y===void 0?{}:{date:y}},story:c.value.story,answer:(k,S)=>S===void 0?Mn:{kind:"handle",handle:e.comment(S,c.value.story)}}}function En(n,e,s){let a=s(e);if(a)return a;let i=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:n.id,...n.parentId===void 0?{}:{parentCommentId:n.parentId},...i.kind==="note"?{noteId:i.noteId}:{}},story:i,answer:()=>Mn}}var Jo=1e4;function Bn(n,e){let s=[],a=e.kind==="contentControl"?chunkILTZTY3K_cjs.tf(e):e;if(!a)return s;for(let i of chunkILTZTY3K_cjs.xf(a))if(!(i.ancestors.length>0)){if(s.length>=Jo)break;s.push(Wn(n,i.node));}return s}function Fn(n,e){for(let s of chunkILTZTY3K_cjs.xf(n.root))if(s.node.id===e)return Wn(n,s.node);return null}function _n(n,e){for(let s of chunkILTZTY3K_cjs.xf(n.root))if(s.node.id===e)return s.node;return null}function Kt(n,e){let s=zn(e);if(s.length>0){let a=s[0],i=s[s.length-1],u=n.paragraphText(i);return u===null||!n.has(a)?null:{start:{paragraphId:a,offset:0},end:{paragraphId:i,offset:u.length}}}for(let a of n.paragraphIds){let i=n.node(a);if(!i||i.kind!=="paragraph"||!i.children.some(c=>c.id===e.id))continue;let u=chunkILTZTY3K_cjs.Ie(i).spanOf(e);return u?{start:{paragraphId:a,offset:u.start},end:{paragraphId:a,offset:u.end}}:null}return null}function Dn(n,e,s="allMarkup"){if(s==="allMarkup")return chunkILTZTY3K_cjs.zf(e);let a=Kt(n,e);if(!a)return "";let i=n.indexOf(a.start.paragraphId),u=n.indexOf(a.end.paragraphId);if(i<0||u<i)return "";let c=[];for(let g=i;g<=u;g+=1){let m=n.paragraphIds[g],y=n.projectedText(m,s),v=n.paragraphText(m);if(!y||v===null)return "";c.push(y.sliceRaw(g===i?a.start.offset:0,g===u?a.end.offset:v.length));}return c.join("\r")}function Wn(n,e){return {nodeId:e.id,properties:chunkILTZTY3K_cjs.vf(e),lock:chunkILTZTY3K_cjs.zg(n.part,e.id),paragraphIds:zn(e)}}function zn(n){let e=chunkILTZTY3K_cjs.tf(n);if(!e)return [];let s=[];return chunkILTZTY3K_cjs.Lf(e.children,s,0),s.map(a=>a.id)}var Qo=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Zo=4096,Kn=64;function Vn(n){if(n===void 0)return {ok:true,value:null};if(typeof n!="object"||n===null)return {ok:false,field:"payload"};let e=n;for(let s of ["namespaceUri","rootLocalName","nodeId"]){let a=e[s];if(typeof a!="string"||a.length===0||a.length>Zo)return {ok:false,field:s}}return typeof e.label!="string"||e.label.length>chunkJWZG4QJ5_cjs.u?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>chunkJWZG4QJ5_cjs.t?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function $n(n){let e=n.at!==void 0,s=n.span!==void 0;return e===s?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof n.tag!="string"||n.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:n.tag.length>Kn?{message:`w:tag caps at ${String(Kn)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof n.text!="string"||n.text.length===0?{message:"a custom node shows some text",detail:"text"}:n.lock!==void 0&&!Qo.has(n.lock)?{message:"that is not a lock",detail:String(n.lock)}:null}function Un(n,e,s,a){return {paragraphId:e.paragraphId,offset:e.offset,...s.offset>e.offset?{replaceUntil:s.offset}:{},tag:n.tag,text:n.text,...n.title===void 0?{}:{alias:n.title},...n.lock===void 0||n.lock==="unlocked"?{}:{lock:n.lock},...a===null?{}:{payload:a}}}function Xn(n,e,s){if(n.span){let i=W(n.span,e,s);return i.ok?i.value?i.value.start.paragraphId!==i.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:i.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:i.code,message:"that span is not a place",detail:i.detail}}let a=kt(n.at,e,s);return a.ok?{range:{start:a.value,end:a.value}}:{code:a.code,message:"that is not a place",detail:a.detail}}var Pt=/[\r\n\v\f\u2028\u2029]/,qo=16,tr=64,Yn=/\s/;function er(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function l(n,e,s){return {ok:false,error:er(n,e,s)}}var E=Object.freeze({kind:"applied"});function I(n){return {ok:true,kind:"query",value:n}}function Gn(n){let e=n.kind==="contentControl"?chunkILTZTY3K_cjs.tf(n):n;return e?chunkILTZTY3K_cjs.xf(e).map(s=>s.node):[]}var nr=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),or=new Set(["whole","content","start","end","before","after"]),rr=new Set(["richText","plainText","dropDownList","comboBox","date"]),ar=4096;function sr(n){let e=(i,u)=>({ok:false,code:"unsupported-content",message:i,detail:u});if(typeof n!="object"||n===null||!("kind"in n))return e("a control value states its kind","value");let s=n,a=s.kind;if(a==="text"||a==="listItem"){let i=a==="text"?s.text:s.value;return typeof i!="string"?e("that value is not a string",String(a)):i.length>ar?e("that value is too long",String(i.length)):{ok:true,value:a==="text"?{kind:"text",text:i}:{kind:"listItem",value:i}}}if(a==="checkbox"){let i=s.checked;return typeof i!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:i}}}if(a==="date"){let i=s.iso;return typeof i!="string"?e("a date is an ISO-8601 string","iso"):i.length>64?e("that is not a date",String(i.length)):{ok:true,value:{kind:"date",iso:i}}}return e("that is not a value any control accepts",String(a))}function ir(n,e){let s=[],a=0;for(;a<n.length;){let i=null;for(let u of e){let c=n.indexOf(u,a);c<0||(!i||c<i.start||c===i.start&&u.length>i.length)&&(i={start:c,length:u.length});}if(!i)break;s.push(i),a=i.start+i.length;}return s}function dr(n,e,s){let a=e[s]?.markParagraphId??null;if(a!==null)return a;let i=n.paragraphIds,u=i[i.length-1];return u===void 0||new Set(e.map(g=>g.markParagraphId).filter(g=>g!==null)).has(u)?null:u}function lr(n,e){for(let s of [n.start,n.end]){let a=e.paragraphText(s.paragraphId);if(a===null||s.offset>a.length)return false}return true}function ur(n,e,s){let a=e,i=s;for(;a<i&&Yn.test(n[a]);)a+=1;for(;i>a&&Yn.test(n[i-1]);)i-=1;return [a,i]}function Jn(n){let{handles:e,capabilities:s}=n,a=n.reads,i=new Map,u=o=>{let t=B(o.story),r=i.get(t);if(r)return r;let d=new Map,p=o.paragraphIds.map(h=>{let x={id:h};return d.set(h,x),x}),f={reads:o,order:p,slotById:d,created:[],restructured:new Set,touched:new Set,formatted:new Set,selected:new Set,retargets:[]};return i.set(t,f),f},c=[],g=fn(),m=null,y=o=>m===null?(m=o,null):m===o?null:l("conflicting-operations","one batch writes into one story",`${B(m.reads.story)} then ${B(o.reads.story)}`),v=o=>y(u(o)),k=o=>{let t=a.package;return t===null?null:Tn(t,o)},S=o=>{let t=e.resolve(o,"comment");if(!t||t.kind!=="comment")return {ok:false,planned:l("invalid-handle","that handle does not name a comment","comment")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let p=k(r)?.byId(t.commentId)??null;return p?{ok:true,reads:r,item:p}:{ok:false,planned:l("invalid-handle","this document no longer holds that comment",t.commentId)}},A=o=>{let t=e.resolve(o,"revision");if(!t||t.kind!=="revision")return {ok:false,planned:l("invalid-handle","that handle does not name a tracked change","revision")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let d=de(r).find(p=>p.id===t.revisionId)??null;return d?{ok:true,reads:r,item:d}:{ok:false,planned:l("invalid-handle","this document no longer holds that tracked change",t.revisionId)}},b=(o,t)=>{let r=o.paragraphText(t.start.paragraphId),d=o.paragraphText(t.end.paragraphId);if(r===null||d===null)return null;let p={story:o.story,paragraphId:t.start.paragraphId,index:o.indexOf(t.start.paragraphId),offset:Math.min(t.start.offset,r.length)},f={story:o.story,paragraphId:t.end.paragraphId,index:o.indexOf(t.end.paragraphId),offset:Math.min(t.end.offset,d.length)};return X({start:p,end:f})},C=(o,t)=>o.order.indexOf(t),O=(o,t)=>o.selected.has(t)?l("conflicting-operations","this batch selects a paragraph it also edits",t):null,T=(o,t)=>{let r=O(o,t);return r||(o.restructured.has(t)||o.touched.has(t)?l("conflicting-operations","another operation in this batch already changes that paragraph",t):(o.restructured.add(t),o.touched.add(t),null))},L=(o,t)=>{let r=O(o,t);return r||(o.restructured.has(t)?l("conflicting-operations","another operation in this batch restructures that paragraph",t):(o.touched.add(t),null))},F=(o,t,r)=>{let d=`${r}:${t}`;if(o.formatted.has(d))return l("conflicting-operations","another operation in this batch already writes that formatting",t);let p=L(o,t);return p||(o.formatted.add(d),null)},J=(o,t)=>{let r={id:null};return o.order.splice(t,0,r),o.created.push(r),r},X=o=>re(o,e),M=o=>o===null?null:a.story(o.start.story),V=o=>o===void 0||o==="allMarkup"||o==="original",nt=(o,t,r,d)=>{if(!V(d?.projection))return l("unsupported-content","unknown text projection","projection");if(d?.matchWildcards===true)return l("unsupported-capability","wildcard search is not implemented","matchWildcards");if(d?.ignorePunct===true)return l("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(d?.ignoreSpace===true)return l("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!chunkJWZG4QJ5_cjs.na(r))return l("unsupported-content","that is not a query this host will scan for","text");let p=d?.limit;if(p!==void 0&&(!Number.isInteger(p)||p<0))return l("invalid-offset","limit must be a non-negative integer",String(p));let f=wn(o,t,e,r,d);return f.ok?I({kind:"spans",spans:f.spans}):l("invalid-offset","projection mapping failed",f.paragraphId)},bt=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","insertText needs text","text");if(Pt.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=y(o);if(d)return d;let p=L(o,t.paragraphId);if(p)return p;let f=r.length===0?[]:[{op:"insertText",paragraphId:t.paragraphId,offset:t.offset,text:r}],h=()=>({kind:"span",span:X({start:t,end:{...t,offset:t.offset+r.length}})});return {ok:true,kind:"command",ops:f,story:o.reads.story,answer:h}},Ot=(o,t,r)=>{let d=o.reads;if(typeof r!="string")return l("unsupported-content","replaceSpan needs text","text");if(Pt.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let p=tt(t,d),f=t.start.paragraphId,h=[],x=y(o);if(x)return x;if(p.length===1){let j=L(o,f);if(j)return j;t.end.offset>t.start.offset&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:t.end.offset});}else {for(let w of p){let P=T(o,w);if(P)return P}let j=t.end.paragraphId,D=(d.paragraphText(f)??"").length;t.start.offset<D&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:D}),t.end.offset>0&&h.push({op:"deleteText",paragraphId:j,start:0,end:t.end.offset});for(let w of p.slice(1,-1))h.push({op:"deleteBlock",blockId:w});h.push({op:"joinParagraphs",firstId:f,secondId:j});for(let w of p.slice(1)){let P=o.slotById.get(w);P&&o.order.splice(C(o,P),1);}}r.length>0&&h.push({op:"insertText",paragraphId:f,offset:t.start.offset,text:r});let R={...t.start,paragraphId:f},H=()=>({kind:"span",span:X({start:R,end:{...R,offset:R.offset+r.length}})});return {ok:true,kind:"command",ops:h,story:o.reads.story,answer:H}},pe=(o,t)=>{let r=o.reads;if(typeof t!="string")return l("unsupported-content","replaceSpan needs text","text");if(Pt.test(t))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=r.blocks,p=d.filter(P=>P.removable),f=d.filter(P=>!P.removable).flatMap(P=>P.paragraphIds),h=f.length===0?p.find(P=>P.kind==="paragraph"):void 0;if(!h&&f.length===0)return l("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let x=y(o);if(x)return x;for(let P of r.paragraphIds){let Q=T(o,P);if(Q)return Q}let R=[],H=(h?[h.id]:[...f]).sort((P,Q)=>r.indexOf(P)-r.indexOf(Q)),j=H[0];for(let P of H){let Q=(r.paragraphText(P)??"").length;Q>0&&R.push({op:"deleteText",paragraphId:P,start:0,end:Q});}for(let P of p)P.id!==h?.id&&R.push({op:"deleteBlock",blockId:P.id});t.length>0&&R.push({op:"insertText",paragraphId:j,offset:0,text:t});for(let P of p)if(P.id!==h?.id)for(let Q of P.paragraphIds){let wt=o.slotById.get(Q);wt&&o.order.splice(C(o,wt),1);}let D={story:r.story,paragraphId:j,index:r.indexOf(j),offset:0},w=()=>({kind:"span",span:X({start:D,end:{...D,offset:t.length}})});return {ok:true,kind:"command",ops:R,story:r.story,answer:w}},N=(o,t)=>{if(!Array.isArray(t)||t.length<1||t.length>1e4||t.some(d=>typeof d!="string"||Pt.test(d)||!chunkILTZTY3K_cjs.O(d)))return l("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let r=y(o);if(r)return r;for(let d of o.reads.paragraphIds){let p=T(o,d);if(p)return p}o.order.splice(0,o.order.length);for(let d=0;d<t.length;d+=1)J(o,d);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:o.reads.root.id,paragraphs:t}],story:o.reads.story,answer:()=>E}},z=(o,t,r,d)=>{let p=o.reads;if(typeof d!="string")return l("unsupported-content","insertParagraph needs text","text");if(Pt.test(d))return l("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let f=y(o);if(f)return f;let h=T(o,t.paragraphId);if(h)return h;let x=o.slotById.get(t.paragraphId);if(!x)return l("invalid-handle","that paragraph is not in the body");let R=(p.paragraphText(t.paragraphId)??"").length,H=[];r==="after"?(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:R,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:R})):(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:0,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:d.length}));let j=J(o,C(o,x)+1);r==="before"&&o.retargets.push({from:t.paragraphId,slot:j});let D=()=>{let w=r==="after"?j.id:t.paragraphId;return w===null?E:{kind:"handle",handle:e.paragraph(w,p.story)}};return {ok:true,kind:"command",ops:H,story:p.story,answer:D}},st=(o,t,r,d,p)=>{let f=o.reads;if(!Array.isArray(r)||r.length===0)return l("unsupported-content","split needs at least one delimiter","delimiters");if(r.length>qo)return l("unsupported-content","too many delimiters",String(r.length));for(let $ of r){if(typeof $!="string"||$.length===0)return l("unsupported-content","a delimiter must be a non-empty string","delimiters");if($.length>tr)return l("unsupported-content","that delimiter is too long","delimiters")}let h=y(o);if(h)return h;let x=T(o,t.paragraphId);if(x)return x;let R=o.slotById.get(t.paragraphId);if(!R)return l("invalid-handle","that paragraph is not in the body");let H=f.paragraphText(t.paragraphId)??"",j=ir(H,r),D=[],w=[],P=[];if(j.length===0)P.push(H);else if(d){for(let U of [...j].reverse())D.push({op:"deleteText",paragraphId:t.paragraphId,start:U.start,end:U.start+U.length});let $=0,ut=0;for(let U of j){let Ut=U.start-$;w.push(Ut),P.push(H.slice(ut,U.start)),ut=U.start+U.length,$+=U.length;}P.push(H.slice(ut));}else {let $=0;for(let ut of j){let U=ut.start+ut.length;w.push(U),P.push(H.slice($,U)),$=U;}P.push(H.slice($));}w.length>0&&D.push({op:"splitParagraphMany",paragraphId:t.paragraphId,offsets:w});let Q=[R];for(let $=0;$<w.length;$+=1)Q.push(J(o,C(o,R)+1+$));let wt=$=>{let ut=$.story(f.story),U=[];return Q.forEach((Ut,ao)=>{let Xt=Ut.id;if(Xt===null)return;let Yt=ut?.paragraphText(Xt)??P[ao]??"",[so,io]=p?ur(Yt,0,Yt.length):[0,Yt.length],ge=e.paragraph(Xt,f.story);U.push({start:{paragraph:ge,offset:so},end:{paragraph:ge,offset:io}});}),{kind:"spans",spans:U}};return {ok:true,kind:"command",ops:D,story:f.story,answer:wt}},xt=(o,t)=>{let r=y(o);if(r)return r;let d=T(o,t.paragraphId);if(d)return d;let p=o.slotById.get(t.paragraphId);return p&&o.order.splice(C(o,p),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:t.paragraphId}],story:o.reads.story,answer:()=>E}},pt=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=pn(r??{});if(!h.ok)return l("unsupported-content","that is not formatting this host writes",h.detail);let x=[];for(let R of oe(t,d)){if(R.end<=R.start&&!R.whole)continue;let H=F(o,R.paragraphId,"runs");if(H)return H;for(let j of chunkJWZG4QJ5_cjs.S(p,R.paragraphId,R.start,R.end,h.value,n.displayMode))x.push({op:"setRunProperties",paragraphId:R.paragraphId,start:j.start,end:j.end,properties:j.properties,...j.targetRunIds?{targetRunIds:j.targetRunIds}:{}});R.whole&&x.push({op:"setParagraphMarkProperties",paragraphId:R.paragraphId,properties:chunkJWZG4QJ5_cjs.R(p,R.paragraphId,h.value)});}return x.length===0?l("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:x,story:d.story,answer:()=>E}},Qn=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=_t(r,d.styles());if(!h.ok)return l("unsupported-content","that is not a style this document has",h.detail);let x={localName:"pStyle",attributes:{val:h.styleId}},R=[];for(let H of tt(t,d)){let j=F(o,H,"paragraph");if(j)return j;R.push({op:"setParagraphProperties",paragraphId:H,properties:chunkJWZG4QJ5_cjs.M(chunkJWZG4QJ5_cjs.K(p,H),x)});}return R.length===0?l("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:R,story:d.story,answer:()=>E}},Zn=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=mn(p,t.paragraphId,r??{},d.styles());if(!h.ok)return l("unsupported-content","that is not paragraph formatting this host writes",h.detail);let x=F(o,t.paragraphId,"paragraph");return x||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:t.paragraphId,properties:h.value}],story:d.story,answer:()=>E}},qn=(o,t)=>{let r=a.body;if(!r)return l("document-unavailable","this host holds no document right now");let d=a.sections();if(!d[o])return l("invalid-handle","that section is not in this document");let f=yn(t);if(!f.ok)return l("unsupported-content",f.reason,f.detail);let h=dr(r,d,o);if(h===null)return l("unsupported-content","that section holds no paragraph to address it by","no-anchor");let x=u(r),R=y(x);return R||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...f.value,anchorParagraphId:h}],story:ct,answer:()=>E}},to=(o,t)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:o,noteId:t}],story:ct,lifecycle:true,answer:()=>E}),Vt=o=>{let t=e.resolve(o,"list");if(!t||t.kind!=="list")return l("invalid-handle","that handle does not name a list","list");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=zt(r).find(p=>p.numId===t.numId);return d?{ok:true,plan:u(r),list:d}:l("invalid-handle","this story numbers nothing with that list",t.numId)},$t=o=>{if(typeof o!="object"||o===null)return l("invalid-handle","that is not a scope a control lives in","scope");let t=o;if("body"in o){let r=K(t.body,"body",e,a);return r.ok?{reads:r.value,node:r.value.root}:l(r.code,"that handle does not name a body",r.detail)}if("contentControl"in o){let r=ot(t.contentControl);return "control"in r?{reads:r.reads,node:r.node}:r}return l("invalid-handle","that is not a scope a control lives in","scope")},ot=o=>{let t=e.resolve(o,"contentControl");if(!t||t.kind!=="contentControl")return l("invalid-handle","that handle does not name a content control","contentControl");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Fn(r,t.nodeId),p=_n(r,t.nodeId);return !d||!p?l("invalid-handle","this document no longer holds that content control"):{reads:r,control:d,node:p}},eo=(o,t,r)=>{if(!Number.isInteger(r)||r<0||r>At)return l("invalid-offset",`a list level is 0 to ${String(At)}`,String(r));if(!Ct(o.reads,t))return l("unsupported-content","that paragraph is not in a list",t);let d=y(o);if(d)return d;let p=F(o,t,"paragraph");return p||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:t,level:r}],story:o.reads.story,answer:()=>E}},no=(o,t,r,d)=>{if(r!=="start"&&r!=="end")return l("unknown-operation","a list takes an item at its start or its end",String(r));let p=o.reads,f=r==="start"?t.paragraphIds[0]:t.paragraphIds[t.paragraphIds.length-1];if(f===void 0)return l("invalid-handle","that list holds no paragraph");let h={story:p.story,paragraphId:f,index:p.indexOf(f)};return z(o,h,r==="start"?"before":"after",d)},me=(o,t)=>{if(t.start.paragraphId!==t.end.paragraphId)return null;for(let r of Rn(o,t.start.paragraphId))if(r.start<=t.start.offset&&r.end>=t.end.offset)return r;return null},oo=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","a hyperlink target is a string","target");let d=o.reads,p=me(d,t),f=t.start.paragraphId===t.end.paragraphId&&t.start.offset===t.end.offset;if(r.length===0){if(!p)return l("unsupported-content","that text is not a link","no-link");let w=y(o);if(w)return w;let P=L(o,p.paragraphId);return P||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:p.id}],story:d.story,answer:()=>E}}let h={},x=null;if(r.startsWith("#")){let w=r.slice(1);if(w.length===0||!ie(d,w))return l("unsupported-content","this document declares no such bookmark",r);h={anchor:w};}else {if(chunkILTZTY3K_cjs.Dd(r)===null)return l("unsupported-content","this engine will not author that target","target");x=r;}let R=y(o);if(R)return R;let H=w=>x===null?{ok:true,kind:"command",ops:[w(h)],story:d.story,answer:()=>E}:{ok:true,kind:"command",ops:[],relate:{url:x,ops:P=>[w({relationshipId:P})]},story:d.story,answer:()=>E};if(p){let w=L(o,p.paragraphId);return w||H(P=>({op:"setHyperlinkTarget",linkId:p.id,...P}))}if(f)return l("unsupported-content","a link with no text has nothing to click","collapsed");if(t.start.paragraphId!==t.end.paragraphId)return l("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let j=L(o,t.start.paragraphId);if(j)return j;let D=d.styles().idOf("hyperlink");return H(w=>({op:"insertHyperlink",paragraphId:t.start.paragraphId,start:t.start.offset,end:t.end.offset,...w,...D===null?{}:{styleId:D}}))},fe=(o,t,r)=>{let d=o.reads;if(!s.selection||!n.select)return l("unsupported-capability","this host has no reader to move","selection");if(r!=="select"&&r!=="start"&&r!=="end")return l("unknown-operation","that is not a selection mode",String(r));let p=tt(t,d);for(let f of p)if(o.touched.has(f))return l("conflicting-operations","this batch edits a paragraph the selection covers",f);for(let f of p)o.selected.add(f);return c.push({range:t,mode:r}),{ok:true,kind:"command",ops:[],story:d.story,answer:()=>E}},ye=o=>{let t=e.resolve(o,"bookmark");if(!t||t.kind!=="bookmark")return l("invalid-handle","that handle does not name a bookmark","bookmark");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=ie(r,t.name);if(!d)return l("invalid-handle","this document no longer declares that bookmark",t.name);let p=f=>({story:r.story,paragraphId:f.paragraphId,index:r.indexOf(f.paragraphId),offset:f.offset});return {reads:r,range:{start:p(d.start),end:p(d.end)}}},ro=o=>{switch(o.op){case "getDocument":return I({kind:"handle",handle:e.document()});case "getBody":return e.resolve(o.document,"document")?a.body?I({kind:"handle",handle:e.body(ct)}):l("document-unavailable","this host holds no document right now"):l("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:t.value.paragraphIds.map(r=>e.paragraph(r,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getSpanParagraphs":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"handles",handles:tt(t.value,r.value).map(d=>e.paragraph(d,r.value.story))}):l(r.code,"that span is not a place",r.detail)}case "getText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");if(e.resolve(o.target,"body")){let p=K(o.target,"body",e,a);return p.ok?I({kind:"text",text:p.value.text(o.projection??"allMarkup")}):l(p.code,"that handle does not name a body",p.detail)}let r=Z(o.target,e,a);if(!r.ok)return l(r.code,"that handle does not name a body or a paragraph",r.detail);let d=a.story(r.value.story);return I({kind:"text",text:d?.paragraphText(r.value.paragraphId,o.projection??"allMarkup")??""})}case "getSpanText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"text",text:In(t.value,r.value,ne,o.projection??"allMarkup")}):l(r.code,"that span is not a place",r.detail)}case "getParagraphId":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let d=a.story(t.value.story)?.paragraph(t.value.paragraphId);return I({kind:"text",text:d?.paraId??""})}case "search":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that is not a scope to search",t.detail);let r=q(o.scope,e,a);return r.ok?nt(r.value,t.value,o.text,o.options):l(r.code,"that is not a scope to search",r.detail)}case "insertText":{let t=kt(o.at,e,a);if(!t.ok)return l(t.code,"that is not a place to insert at",t.detail);let r=a.story(t.value.story);return r?bt(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in o.span){let d=K(o.span.body,"body",e,a);return d.ok?pe(u(d.value),o.text):l(d.code,"that handle does not name a body",d.detail)}let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to write into","empty-story");let r=M(t.value);return r?Ot(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let t=K(o.body,"body",e,a);return t.ok?N(u(t.value),o.paragraphs):l(t.code,"that handle does not name a body",t.detail)}case "insertParagraph":{let t=Wt(o.anchor,e,a);if(!t.ok)return l(t.code,"that is not a paragraph to insert beside",t.detail);if(o.where!=="before"&&o.where!=="after")return l("unknown-operation","that is not a place to insert",String(o.where));let r=a.story(t.value.story);return r?z(u(r),t.value,o.where,o.text):l("invalid-handle","that story is not in this document")}case "splitParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?st(u(r),t.value,o.delimiters,o.trimDelimiters===true,o.trimSpacing===true):l("invalid-handle","that story is not in this document")}case "getFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=oe(t.value,r.value);return I({kind:"font",font:un(r.value.part,d,n.displayMode)})}case "setFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to format","empty-story");let r=M(t.value);return r?pt(u(r),t.value,o.font):l("invalid-handle","that story is not in this document")}case "getStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value.part,p=r.value.styles(),f=tt(t.value,r.value).map(x=>Ft(d,x,p)),h=f.length>0&&f.every(x=>x!==null&&x===f[0])?f[0]:null;return I({kind:"style",name:h})}case "setStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to style","empty-story");let r=M(t.value);return r?Qn(u(r),t.value,o.name):l("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let t=Wt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("document-unavailable","this host holds no document right now");let d=cn(r.part,t.value.paragraphId,r.styles());return d?I({kind:"paragraphFormat",format:d}):l("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let t=Wt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);return r?Zn(u(r),t.value,o.format):l("invalid-handle","that story is not in this document")}case "deleteParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?xt(u(r),t.value):l("invalid-handle","that story is not in this document")}case "getSections":return e.resolve(o.document,"document")?I({kind:"handles",handles:a.sections().map(t=>e.section(t.index))}):l("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");let r=a.sections()[t.index];return r?I({kind:"pageSetup",setup:r.pageSetup}):l("invalid-handle","that section is not in this document")}case "setPageSetup":{let t=e.resolve(o.section,"section");return !t||t.kind!=="section"?l("invalid-handle","that handle does not name a section","section"):qn(t.index,o.setup)}case "getFurniture":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");if(o.kind!=="header"&&o.kind!=="footer")return l("unknown-operation","that is not furniture",String(o.kind));let r={kind:o.kind,sectionIndex:t.index,variant:o.variant};return an(r)?a.story(r)?I({kind:"handle",handle:e.body(r)}):l("invalid-handle","this document declares no such header or footer",B(r)):l("unknown-operation","that is not a furniture variant",String(o.variant))}case "getNotes":{if(!e.resolve(o.document,"document"))return l("invalid-handle","that handle does not name a document","document");if(o.noteKind!=="footnote"&&o.noteKind!=="endnote")return l("unknown-operation","that is not a kind of note",String(o.noteKind));let t=o.noteKind,r=a.noteIds(t);return r.ok?I({kind:"handles",handles:r.ids.map(d=>e.note(t,d))}):l("ambiguous-document",`${t} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getNoteBody":case "getNoteText":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=t,d=a.story(r);return d?o.op==="getNoteText"?I({kind:"text",text:d.text(o.projection)}):I({kind:"handle",handle:e.body(r)}):l("invalid-handle","that note is not in this document",B(r))}case "getNoteKind":{let t=e.resolve(o.note,"note");return !t||t.kind!=="note"?l("invalid-handle","that handle does not name a note","note"):I({kind:"text",text:t.noteKind})}case "deleteNote":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=a.noteIds(t.noteKind);return r.ok?r.ids.includes(t.noteId)?to(t.noteKind,t.noteId):l("invalid-handle","that note is not in this document"):l("ambiguous-document",`${t.noteKind} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getLists":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:zt(t.value).map(r=>e.list(r.numId,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getListId":{let t=Vt(o.list);return "list"in t?I({kind:"number",value:Number(t.list.numId)}):t}case "getListById":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);if(!Number.isInteger(o.id)||o.id<=0)return l("unsupported-content","a list is numbered from one",String(o.id));let r=String(o.id),d=zt(t.value).find(p=>p.numId===r);return d?I({kind:"handle",handle:e.list(d.numId,t.value.story)}):l("invalid-handle","no list in that story carries that number",r)}case "getListParagraphs":{let t=Vt(o.list);if(!("list"in t))return t;let r=o.level;if(r!==void 0&&(!Number.isInteger(r)||r<0||r>At))return l("invalid-offset",`a list level is 0 to ${String(At)}`,String(r));let d=t.plan.reads,p=r===void 0?t.list.paragraphIds:t.list.paragraphIds.filter(f=>Ct(d,f)?.level===r);return I({kind:"handles",handles:p.map(f=>e.paragraph(f,d.story))})}case "getParagraphList":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Ct(r,t.value.paragraphId);return d?I({kind:"handle",handle:e.list(d.numId,r.story)}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "getListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Ct(r,t.value.paragraphId);return d?I({kind:"number",value:d.level}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "setListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?eo(u(r),t.value.paragraphId,o.level):l("invalid-handle","that story is not in this document")}case "insertListParagraph":{let t=Vt(o.list);return "list"in t?no(t.plan,t.list,o.where,o.text):t}case "getHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=a.package;if(!d||!t.value)return I({kind:"text",text:""});let p=me(r.value,t.value);if(!p)return I({kind:"text",text:""});let f=chunkILTZTY3K_cjs.Ca(r.value.part,p.id),h=f?Cn(d,r.value.part.name,f):null;return I({kind:"text",text:h??""})}case "setHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no text to link","empty-story");let r=M(t.value);return r?oo(u(r),t.value,o.target):l("invalid-handle","that story is not in this document")}case "getBookmarks":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value,p=t.value,f=p===null?null:new Set(tt(p,d)),h=se(d).filter(x=>{if(!f||!f.has(x.start.paragraphId)&&!f.has(x.end.paragraphId)||p===null)return false;let R=x.start.paragraphId===p.end.paragraphId&&x.start.offset>p.end.offset,H=x.end.paragraphId===p.start.paragraphId&&x.end.offset<p.start.offset;return !R&&!H});return I({kind:"handles",handles:h.map(x=>e.bookmark(x.name,d.story))})}case "getBookmarkName":{let t=e.resolve(o.bookmark,"bookmark");return !t||t.kind!=="bookmark"?l("invalid-handle","that handle does not name a bookmark","bookmark"):I({kind:"text",text:t.name})}case "getBookmarkRange":{let t=ye(o.bookmark);return "reads"in t?I({kind:"span",span:X(t.range)}):t}case "getComments":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that scope is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that scope names no story",r.detail);let d=r.value,p=k(d);if(!p)return l("document-unavailable","this host holds no document");let f=t.value,h=p.roots.filter(x=>{if(!f)return true;let R=x.range;if(!R)return false;let H=d.indexOf(R.start.paragraphId),j=d.indexOf(R.end.paragraphId),D=d.indexOf(f.start.paragraphId),w=d.indexOf(f.end.paragraphId);return j<D||H>w?false:j===D&&H===D&&w===D?R.end.offset>f.start.offset&&R.start.offset<f.end.offset:true});return I({kind:"handles",handles:h.map(x=>e.comment(x.id,d.story))})}case "getCommentReplies":{let t=S(o.comment);return t.ok?I({kind:"handles",handles:t.item.replyIds.map(r=>e.comment(r,t.reads.story))}):t.planned}case "getCommentId":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.id}):t.planned}case "getCommentAuthor":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.author}):t.planned}case "getCommentDate":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.date??""}):t.planned}case "getCommentText":{let t=S(o.comment);if(!t.ok)return t.planned;let r=k(t.reads);return I({kind:"text",text:r?.textOf(t.item.id)??""})}case "getCommentRange":{let t=S(o.comment);if(!t.ok)return t.planned;let r=t.item.range;if(!r||t.item.orphaned)return l("invalid-handle","that comment has no range in this document");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let t=S(o.comment);return t.ok?I({kind:"flag",value:t.item.resolved}):t.planned}case "insertComment":return Ln(o,e,a,v);case "setCommentResolved":{let t=S(o.comment);if(!t.ok)return t.planned;if(typeof o.resolved!="boolean")return l("unsupported-content","resolved is a yes or a no",String(o.resolved));let r=y(u(t.reads));return r||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:t.item.id,resolved:o.resolved},story:t.reads.story,answer:()=>E}}case "replyToComment":{let t=S(o.comment);if(!t.ok)return t.planned;let r=ue({author:o.author,text:o.text,date:o.date,kind:"reply"});if(r)return r;let d=t.item.range;if(!d||t.item.orphaned)return l("invalid-handle","that comment has no range to reply over");let p=y(u(t.reads));if(p)return p;let f=t.reads.story,h=ce(o.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:t.item.id,anchor:{paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,...d.end.paragraphId===d.start.paragraphId?{}:{endParagraphId:d.end.paragraphId}},text:o.text,author:o.author,...h===void 0?{}:{date:h}},story:t.reads.story,answer:(x,R)=>R===void 0?E:{kind:"handle",handle:e.comment(R,f)}}}case "deleteComment":{let t=S(o.comment);return t.ok?En(t.item,t.reads,r=>y(u(r))):t.planned}case "getRevisions":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);let r=t.value;return I({kind:"handles",handles:de(r).map(d=>e.revision(d.id,r.story))})}case "getRevisionType":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.type}):t.planned}case "getRevisionAuthor":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.author}):t.planned}case "getRevisionDate":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.date}):t.planned}case "getRevisionRange":{let t=A(o.revision);if(!t.ok)return t.planned;let[r]=t.item.item.ranges;if(!r)return l("invalid-handle","that change covers no characters");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let t=A(o.revision);if(!t.ok)return t.planned;let r=u(t.reads),d=y(r);if(d)return d;let p=o.op==="acceptRevision";return {ok:true,kind:"command",story:t.reads.story,ops:t.item.item.addresses.map(f=>p?{op:"acceptRevision",revision:f}:{op:"rejectRevision",revision:f}),answer:()=>E}}case "acceptAllRevisions":case "rejectAllRevisions":{let t=Nn(o,e,a);if(!t.ok)return l(t.code,t.message,t.detail);let r=u(t.reads),d=y(r);if(d)return d;let p=Hn(o,t.reads);return {ok:true,kind:"command",story:t.reads.story,ops:p,answer:()=>E}}case "selectSpan":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to select","empty-story");let r=M(t.value);return r?fe(u(r),t.value,o.mode):l("invalid-handle","that story is not in this document")}case "selectBookmark":{let t=ye(o.bookmark);return "reads"in t?fe(u(t.reads),t.range,o.mode):t}case "getContentControls":{let t=$t(o.scope);return "reads"in t?I({kind:"handles",handles:Bn(t.reads,t.node).map(r=>e.contentControl(r.nodeId,t.reads.story))}):t}case "getContentControlById":{let t=$t(o.scope);if(!("reads"in t))return t;if(!Number.isInteger(o.id))return l("unsupported-content","a control id is a whole number",String(o.id));let r=Gn(t.node).find(d=>chunkILTZTY3K_cjs.vf(d).id===o.id);return r?I({kind:"handle",handle:e.contentControl(r.id,t.reads.story)}):l("invalid-handle","no control in that scope carries that id",String(o.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let t=$t(o.scope);if(!("reads"in t))return t;let r=o.op==="getContentControlsByTag"?o.tag:o.title;if(typeof r!="string"||r.length===0)return l("unsupported-content","a tag or title to match is required",o.op);let d=Gn(t.node).filter(p=>{let f=chunkILTZTY3K_cjs.vf(p);return o.op==="getContentControlsByTag"?f.tag===r:f.alias===r});return I({kind:"handles",handles:d.map(p=>e.contentControl(p.id,t.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=t.control.properties;if(o.op==="getContentControlLock")return I({kind:"text",text:t.control.lock});if(o.op==="getContentControlSubtype")return I({kind:"text",text:r.type});if(o.op==="getContentControlFileId")return I({kind:"text",text:r.id===void 0?"":String(r.id)});let d=o.op==="getContentControlTag"?r.tag:r.alias;return I({kind:"text",text:d??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.op==="getContentControlIsBound"?t.control.properties.dataBinding!==void 0:o.op==="getContentControlPlaceholderShown"?t.control.properties.showingPlaceholder:t.control.properties.temporary;return I({kind:"flag",value:r})}case "getContentControlText":{let t=ot(o.contentControl);return "control"in t?I({kind:"text",text:Dn(t.reads,t.node,o.projection)}):t}case "getContentControlParagraphs":{let t=ot(o.contentControl);return "control"in t?I({kind:"handles",handles:t.control.paragraphIds.map(r=>e.paragraph(r,t.reads.story))}):t}case "getContentControlRange":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.location??"whole";if(!or.has(r))return l("unsupported-content","that is not a place in a control",r);let d=Kt(t.reads,t.node);if(!d)return l("unsupported-content","that control holds nothing addressable","empty");let p=r==="start"||r==="before"?d.start:d.end,f=r!=="whole"&&r!=="content",h=x=>({story:t.reads.story,paragraphId:x.paragraphId,index:t.reads.indexOf(x.paragraphId),offset:x.offset});return I({kind:"span",span:re(f?{start:h(p),end:h(p)}:{start:h(d.start),end:h(d.end)},e)})}case "setContentControlValue":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=sr(o.value);if(!r.ok)return l(r.code,r.message,r.detail);let d=u(t.reads),p=y(d);return p||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:r.value}],answer:()=>E}}case "setContentControlProperties":{let t=ot(o.contentControl);if(!("control"in t))return t;if(o.tag===void 0&&o.title===void 0&&o.lock===void 0)return l("unsupported-content","nothing to write","no-properties");if(o.lock!==void 0&&!nr.has(o.lock))return l("unsupported-content","that is not a lock this schema declares",o.lock);let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlProperties",controlId:t.control.nodeId,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title},...o.lock===void 0?{}:{lock:o.lock}}],answer:()=>E}}case "insertContentControlText":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.text!="string")return l("unsupported-content","text is required","text");if(o.at!=="replace"&&o.at!=="start"&&o.at!=="end")return l("unsupported-content","that is not a place to insert at",String(o.at));let r=u(t.reads),d=y(r);if(d)return d;let p=Kt(t.reads,t.node);if(!p)return l("unsupported-content","that control holds nothing addressable","empty");let f=o.at==="end"?p.end:p.start,h=()=>({kind:"span",span:X({start:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset},end:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset+o.text.length}})});return o.at==="replace"?{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:{kind:"text",text:o.text}}],answer:h}:{ok:true,kind:"command",story:t.reads.story,ops:o.text.length===0?[]:[{op:"insertText",paragraphId:f.paragraphId,offset:f.offset,text:o.text,inside:t.node.id}],answer:h}}case "deleteContentControl":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.keepContent!="boolean")return l("unsupported-content","keepContent is required","keepContent");let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"removeContentControl",controlId:t.control.nodeId,keepContent:o.keepContent}],answer:()=>E}}case "insertContentControl":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds nothing to wrap","empty-story");let r=M(t.value);if(!r)return l("invalid-handle","that story is not in this document");let d=t.value;if(d.start.paragraphId!==d.end.paragraphId)return l("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!rr.has(o.subtype))return l("unsupported-content","that control type cannot be inserted",o.subtype);let p=u(r),f=y(p);return f||{ok:true,kind:"command",story:r.story,ops:[{op:"insertContentControl",paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,type:o.subtype,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title}}],answer:()=>E}}case "insertCustomNode":{let t=$n(o);if(t)return l("unsupported-content",t.message,t.detail);let r=Vn(o.payload);if(!r.ok)return l("unsupported-content","that payload cannot be written",r.field);let d=Xn(o,e,a);if("code"in d)return l(d.code,d.message,d.detail);let{start:p,end:f}=d.range,h=M(d.range);if(!h)return l("invalid-handle","that story is not in this document");let x=y(u(h));return x||{ok:true,kind:"customNodeWrite",story:h.story,write:Un(o,p,f,r.value),answer:()=>E}}default:return l("unknown-operation","this host does not implement that operation",String(o.op))}};return {plan(o){let t=g.conflict(o);if(t)return l("conflicting-operations",t.message,t.detail);let r=ro(o);return r.ok&&g.note(o),r},get hasCommands(){return g.hasCommands},get writeScope(){return m?.reads.scope??null},settle(o){let t=m;if(t){let r=o.story(t.reads.story);if(!r)return {ok:false,detail:`the story this batch wrote is gone: ${B(t.reads.story)}`};let d=new Set(t.reads.paragraphIds),p=r.paragraphIds.filter(h=>!d.has(h));if(p.length!==t.created.length)return {ok:false,detail:`planned ${String(t.created.length)} new paragraphs, the transaction made ${String(p.length)}`};t.order.filter(h=>h.id===null).forEach((h,x)=>{h.id=p[x]??null;});for(let h of t.retargets)h.slot.id&&e.retarget(h.from,h.slot.id);}for(let r of c){let d=o.story(r.range.start.story);!d||!lr(r.range,d)||n.select?.(r.range,r.mode);}return {ok:true}}}}var cr=Object.freeze({status:"skipped"});function G(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function pr(n){let e=n==="unsupported-revision"||n.startsWith("unsupported-revision:");return G(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",n)}function et(n,e,s,a){return {ok:false,results:n.map((i,u)=>u===e?{status:"error",error:s}:cr),revision:a,changed:false}}function ns(n){let{port:e}=n,s=Object.freeze({...n.capabilities}),a=sn(),i=new Set,u=false,c=null,g=s.events?e.subscribe(()=>{if(u)return;let v=Object.freeze({revision:e.revision()});for(let k of [...i])k(v);}):()=>{},m=v=>{if(c&&c.pkg===v)return c.value;let k=bn(v);return c={pkg:v,value:k},k};return {capabilities:s,revision:()=>e.revision(),execute:v=>{let k=Array.isArray(v?.operations)?v.operations:[],S=e.revision();if(u)return et(k,0,G("disposed","this host was disposed"),S);if(!s.document)return et(k,0,G("unsupported-capability","this host has no document","document"),S);let A=e.currentPackage();if(!A)return et(k,0,G("document-unavailable","this host holds no document right now"),S);if(v.expectedRevision!==void 0&&v.expectedRevision!==S)return et(k,0,G("stale-revision","the document moved since that revision",`expected ${String(v.expectedRevision)}, at ${S}`),S);let b=Jn({handles:a,reads:m(A),capabilities:s,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.select?{select:e.select.bind(e)}:{}}),C=[],O=[],T=null,L=[],F=null,J,X=null,M=-1;for(let N=0;N<k.length;N+=1){let z=b.plan(k[N]);if(!z.ok)return et(k,N,z.error,S);if(C.push(z),z.kind==="command")if(M<0&&(M=N),z.lifecycle)T=z.ops[0]??null;else if(z.relate){let st=z.relate;O.push(xt=>{let pt=xt(st.url);return pt===null?null:st.ops(pt)});}else {let{ops:st}=z;O.push(()=>st);}else z.kind==="commentWrite"?(M<0&&(M=N),L.push(z.write),F=b.writeScope??{kind:"body"}):z.kind==="customNodeWrite"&&(M<0&&(M=N),X={write:z.write,scope:b.writeScope??{kind:"body"}});}let V=false;if(L.length>0){let N=e.applyCommentWrites(L,F??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the comment write",N.reason),S);V=N.changed,J=N.commentId;}if(X){let N=e.applyCustomNodeWrite(X.write,X.scope);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the custom-node write",N.reason),S);V=N.changed;}if(T){let N=e.applyLifecycle(T);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the transaction",N.reason),S);V=N.changed;}if(O.length>0){let N=e.apply(z=>{let st=[];for(let xt of O){let pt=xt(z);if(pt===null)return null;st.push(...pt);}return st},b.writeScope??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,pr(N.reason),S);V=N.changed;}let nt=e.currentPackage();if(!nt)return et(k,0,G("document-unavailable","this host holds no document right now"),S);let bt=m(nt),Ot=b.settle(bt);return Ot.ok?{ok:true,results:C.map(N=>({status:"ok",value:N.kind==="query"?N.value:N.kind==="customNodeWrite"?N.answer(bt):N.answer(bt,J)})),revision:e.revision(),changed:V}:et(k,M<0?0:M,G("transaction-refused","the transaction did not produce the document the batch planned",Ot.detail),e.revision())},save(){if(u)return {ok:false,error:G("disposed","this host was disposed")};if(!s.save)return {ok:false,error:G("unsupported-capability","this host cannot save","save")};let v=e.save();return v?{ok:true,bytes:v}:{ok:false,error:G("document-unavailable","this host holds no document right now")}},subscribe(v){return u||!s.events?()=>{}:(i.add(v),()=>{i.delete(v);})},dispose(){u||(u=true,i.clear(),g(),e.dispose(),c=null);}}}exports.a=Bt;exports.b=fr;exports.c=lo;exports.d=uo;exports.e=Zt;exports.f=qt;exports.g=ns;
|
package/dist/chunk-5V6FNKBE.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkILTZTY3K_cjs=require('./chunk-ILTZTY3K.cjs');var Gt=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Kt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,qt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ut(e){return Kt.test(e)||qt.test(e)}function oe(e,t){if(!ut(e))throw new Error(`invalid ${t??"registry"} id ${JSON.stringify(e)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var Yt=/^(\d+)\.(\d+)\.(\d+)$/;function M(e){let t=Yt.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function re(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function ie(e,t){let n=M(e),o=t.trim();if(o==="*")return true;if(o.startsWith("^")){let r=M(o.slice(1));return re(n,r)<0?false:r.major>0?n.major===r.major:r.minor>0?n.major===0&&n.minor===r.minor:n.major===0&&n.minor===0}if(o.includes(" ")){let r=o.split(/\s+/);if(r.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let i of r){let a=i.startsWith(">=")?">=":i.startsWith("<")?"<":null;if(!a)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=M(i.slice(a.length)),c=re(n,l);a===">="?s=s&&c>=0:s=s&&c<0;}return s}return re(n,M(o))===0}var b=class extends Error{constructor(n,o,r=[]){super(o);this.code=n;this.responsible=r;this.name="RegistryError";}code;responsible},we=(e,t)=>`${e}:${t}`;function Xt(e,t={}){let n=new Map;for(let c of e){if(oe(c.id,"extension"),ft(c.version,c.id),n.has(c.id))throw new b("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let p of c.contributions)oe(p.id,p.kind),ft(p.version,`${c.id} \u2192 ${p.id}`),p.replaces&&Zt(p.replaces.targetRange,`${c.id} \u2192 replaces ${p.replaces.targetId}`);}for(let c of e){for(let p of c.dependencies??[])if(!n.has(p))throw new b("missing-dependency",`${c.id} requires missing extension ${p}`,[c.id,p]);for(let p of c.conflicts??[])if(n.has(p)){let h=[c.id,p].sort();throw new b("conflict",`extensions ${h[0]} and ${h[1]} conflict`,h)}}Qt(n);let o=new Set(t.availablePorts??[]);for(let c of e)for(let p of c.contributions)p.kind==="runtimePort"&&o.add(p.id);for(let c of e)for(let p of c.requiredPorts??[])if(!o.has(p))throw new b("missing-port",`${c.id} requires unavailable port ${p}`,[c.id,p]);let r=new Map,s=new Map,i=new Map;for(let c of e)for(let p of c.contributions){let h=we(p.kind,p.id);if(p.replaces){let x=we(p.kind,p.replaces.targetId),R=i.get(x)??[];R.push({ext:c.id,c:p}),i.set(x,R);continue}if(s.has(h)){let x=[r.get(h),c.id].sort();throw new b("id-collision",`${p.kind} id ${p.id} registered by both ${x[0]} and ${x[1]}`,x)}s.set(h,p),r.set(h,c.id);}let a=new Map(s);for(let[c,p]of i){let h=s.get(c);if(!h){let v=p[0];throw new b("replacement-target-missing",`${v.ext} replaces missing target ${v.c.replaces.targetId}`,[v.ext,v.c.replaces.targetId])}let x=h.replaceable??{kind:"none"};for(let{ext:v,c:k}of p){if(!ie(h.version,k.replaces.targetRange))throw new b("replacement-version-mismatch",`${v} replaces ${k.replaces.targetId}@${h.version} outside range ${k.replaces.targetRange}`,[v,k.replaces.targetId]);if(x.kind==="none")throw new b("unauthorized-replacement",`${k.replaces.targetId} does not authorize replacement (attempted by ${v})`,[v,k.replaces.targetId])}let R=Jt(h,p);a.set(c,R);}return {extensions:n,contributions:a,get:(c,p)=>a.get(we(c,p))}}function Jt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let r=[...t].sort((a,l)=>(l.c.replaces.priority??0)-(a.c.replaces.priority??0)),s=r[0].c.replaces.priority??0,i=r.filter(a=>(a.c.replaces.priority??0)===s);if(i.length>1){let a=i.map(l=>l.ext).sort();throw new b("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${a.join(", ")}`,a)}return r[0].c}let o=t.map(r=>r.ext).sort();throw new b("ambiguous-replacement",`multiple replacers of ${e.id}: ${o.join(", ")}`,o)}function Qt(e){let r=new Map,s=[],i=a=>{r.set(a,1),s.push(a);let l=[...e.get(a)?.dependencies??[]].sort();for(let c of l){let p=r.get(c)??0;if(p===1){let h=s.indexOf(c),x=[...s.slice(h),c];throw new b("dependency-cycle",`dependency cycle: ${x.join(" -> ")}`,x)}p===0&&i(c);}s.pop(),r.set(a,2);};for(let a of [...e.keys()].sort())(r.get(a)??0)===0&&i(a);}function ft(e,t){try{M(e);}catch{throw new b("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Zt(e,t){try{ie("0.0.0",e);}catch{throw new b("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var L=class extends Error{constructor(t){super(t),this.name="BudgetError";}},K=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunkILTZTY3K_cjs.p(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,o=this;return {amount:t,get released(){return n},release(){n||(n=true,o.used.release(t),o.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let o=new e(t,n);return o.parent=this,o.carveAmount=n,this.children.add(o),o}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new L(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new L(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let t=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(o){t.push(o);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),t.length>0)throw new L(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new L(`${this.label}: budget already released`)}};var ae=class extends Error{constructor(n,o){super(o?`cancelled: ${o}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},q=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new ae(t.derivedOnly,t._reason)}}}};var se=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},ke=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new se(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(chunkILTZTY3K_cjs.f.clock)}identity(){return this.resolve(chunkILTZTY3K_cjs.f.identity)}},Ne=class{constructor(t=0,n=1){this.step=n;this.t=t;}step;t;now(){let t=this.t;return this.t+=this.step,t}},Te=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function en(e){let t=chunkILTZTY3K_cjs.k(e.limits),n=Object.freeze({...e.config??{}}),o=e.capacity??t.maxDecompressedBytes,r=e.id??"op",s={id:r,limits:t,config:n,ports:e.ports,budget:new K(`op:${r}`,o),cancellation:new q};return Object.freeze(s)}function tn(e){e.budget.dispose();}var _e=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),yt=Object.keys(_e);function nn(e,t){return new chunkILTZTY3K_cjs.p(`${_e[t].phase}:${t}`,e[t])}var Pe=class{counter;current=0;peak=0;constructor(t){this.counter=new chunkILTZTY3K_cjs.p("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function on(){for(let e of yt){let t=chunkILTZTY3K_cjs.j[e],n=chunkILTZTY3K_cjs.i[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function Y(e,t=new Set){let n=new WeakSet,o=r=>{if(r===null)return "null";let s=typeof r;if(s==="boolean")return r?"true":"false";if(s==="number"){let i=r;if(!Number.isFinite(i))throw new Error(`non-finite number is not comparable: ${i}`);return Object.is(i,-0)?"0":String(i)}if(s==="string")return JSON.stringify(r);if(s==="bigint")return `${r.toString()}n`;if(Array.isArray(r))return `[${r.map(o).join(",")}]`;if(s==="object"){let i=r;if(n.has(i))throw new Error("cannot canonicalize a cyclic structure");n.add(i);let l=Object.keys(i).filter(c=>!t.has(c)).sort().map(c=>`${JSON.stringify(c)}:${o(i[c])}`).join(",");return n.delete(i),`{${l}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return o(e)}function Ae(e,t){let n=Y(e,t),o=0xcbf29ce484222325n,r=0x100000001b3n,s=0xffffffffffffffffn;for(let i=0;i<n.length;i++)o^=BigInt(n.charCodeAt(i)),o=o*r&s;return o.toString(16).padStart(16,"0")}var w="dev.docx-editor.core.comparator",$e={authoredState:{id:`${w}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${w}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${w}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${w}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${w}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${w}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${w}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${w}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${w}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${w}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Me(e,t,n,o={}){let r=$e[e];switch(r.mode){case "sync-optimization-only":throw new Error(`${r.id} is not an equivalence basis (${r.note})`);case "tolerance":{if(o.epsilon===void 0)throw new Error(`${r.id} requires an explicit epsilon`);return {equal:ht(t,n,o.epsilon)}}case "exact":case "canonical-exact":{let s=r.mode==="canonical-exact"?new Set(r.ephemera):new Set,i=Y(t,s),a=Y(n,s);return i===a?{equal:true}:{equal:false,left:i,right:a}}}}function Le(e,t){let n=$e[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let o=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Ae(t,o)}function ht(e,t,n){return typeof e=="number"&&typeof t=="number"?Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e-t)<=n:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,r)=>ht(o,t[r],n)):false}var xt=new Set([...chunkILTZTY3K_cjs.c,...chunkILTZTY3K_cjs.d]),gt=/^[0-9a-f]{16}$/,rn=/^[0-9a-f]*$/;function Fe(e){let t=[],n=r=>t.push(r);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let o=-1;e.steps.forEach((r,s)=>{let i=`step[${s}]`;xt.has(r.origin)||n(`${i}: unknown origin ${r.origin}`),(!Number.isInteger(r.baseRevision)||r.baseRevision<0)&&n(`${i}: baseRevision must be a non-negative integer`),r.baseRevision<o&&n(`${i}: baseRevision regressed below ${o}`);let a=r.expect;a.outcome==="applied"?(a.committedRevision===void 0?n(`${i}: applied step needs committedRevision`):a.committedRevision<=r.baseRevision?n(`${i}: committedRevision ${a.committedRevision} must exceed baseRevision ${r.baseRevision}`):o=a.committedRevision,a.modelChange&&an(a.modelChange,i,n)):(a.committedRevision!==void 0&&n(`${i}: ${a.outcome} step must not commit a revision`),a.authoredStateHash!==void 0&&n(`${i}: ${a.outcome} step must not change authored state`)),a.authoredStateHash!==void 0&&!gt.test(a.authoredStateHash)&&n(`${i}: authoredStateHash must be 16-hex`),a.outputHash!==void 0&&!gt.test(a.outputHash)&&n(`${i}: outputHash must be 16-hex`);});for(let r of [...e.snapshots??[],...e.updates??[]])r.documentId!==e.documentId&&n(`envelope documentId ${r.documentId} != ${e.documentId}`),rn.test(r.bytesHex)||n("envelope bytesHex must be hex"),r.bytesHex.length!==r.byteLength*2&&n(`envelope byteLength ${r.byteLength} disagrees with ${r.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function an(e,t,n){xt.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function sn(e,t){let n=Fe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let o=[];return t.init(e),e.steps.forEach((r,s)=>{let i=`step[${s}]`,a=t.applyStep(r),l=r.expect;if(a.outcome!==l.outcome){o.push(`${i}: outcome ${a.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(a.committedRevision!==l.committedRevision&&o.push(`${i}: revision ${a.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(a.authoredState===void 0)o.push(`${i}: store returned no authored state to hash`);else {Me("authoredState",a.authoredState,a.authoredState).equal||o.push(`${i}: authored state is not self-consistent`);let p=Rt(a.authoredState);p!==l.authoredStateHash&&o.push(`${i}: authoredStateHash ${p} != expected ${l.authoredStateHash}`);}}),{ok:o.length===0,mismatches:o}}function Rt(e){return Le("authoredState",e)}var F="http://schemas.openxmlformats.org/officeDocument/2006/relationships",ln="http://schemas.openxmlformats.org/package/2006/relationships",cn="http://schemas.openxmlformats.org/drawingml/2006/main",Et="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",vt="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",St="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",It="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",Ct="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",wt="application/vnd.openxmlformats-package.relationships+xml",De=`${F}/styles`,Be=`${F}/numbering`,kt=`${F}/footnotes`,Nt=`${F}/endnotes`,Tt=`${F}/officeDocument`,dn=`${F}/theme`;function I(e){return e.kind!=="textValue"}function Ot(e,t){return {...e,children:t}}function P(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)P(n,t);}var pn=new Set(["pStyle","rStyle","tblStyle"]);function Ue(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue"&&pn.has(o.localName)&&o.namespaceUri===chunkILTZTY3K_cjs.ca){let r=chunkILTZTY3K_cjs.ze(o,"val");r&&t.add(r);}});}function Ve(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue"&&o.localName==="numId"&&o.namespaceUri===chunkILTZTY3K_cjs.ca){let r=chunkILTZTY3K_cjs.ze(o,"val");r&&t.add(r);}});}function ce(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue")for(let r of o.attributes)r.namespaceUri===F&&r.value.length>0&&t.add(r.value);});}function je(e,t){let n=new Set;for(let o of e)P(o,r=>{if(r.kind!=="textValue"&&r.kind==="noteReference"&&r.localName===t){let s=chunkILTZTY3K_cjs.ze(r,"id");s!==void 0&&n.add(s);}});return n}function mn(e,t){for(let n of chunkILTZTY3K_cjs.Zb(e,t)){if(n.type!==De||n.targetMode==="External")continue;let o=chunkILTZTY3K_cjs.w(n.ownerPart,n.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return e.parts.get("/word/styles.xml")??null}function Pt(e,t,n){for(let o of chunkILTZTY3K_cjs.Zb(e,t)){if(o.type!==n||o.targetMode==="External")continue;let r=chunkILTZTY3K_cjs.w(o.ownerPart,o.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return null}function _t(e,t){let n=mn(e,t),o=new Map,r=[],s=null;if(n&&I(n.root))for(let i of n.root.children){if(!I(i))continue;if(i.localName==="docDefaults"&&i.namespaceUri===chunkILTZTY3K_cjs.ca){s=i;continue}if(i.localName!=="style"||i.namespaceUri!==chunkILTZTY3K_cjs.ca)continue;let a=chunkILTZTY3K_cjs.ze(i,"styleId");a&&o.set(a,i),(chunkILTZTY3K_cjs.ze(i,"default")==="1"||chunkILTZTY3K_cjs.ze(i,"default")==="true")&&r.push(i);}return {part:n,byId:o,defaults:r,docDefaults:s}}var un=new Set(["basedOn","link","next"]);function ze(e,t){let n=new Set,o=[...t];for(let i of e.defaults){let a=chunkILTZTY3K_cjs.ze(i,"styleId");a&&o.push(a);}let r=[];for(;o.length>0;){let i=o.pop();if(n.has(i))continue;n.add(i);let a=e.byId.get(i);if(a){r.push(a);for(let l of a.children)if(I(l)&&un.has(l.localName)&&l.namespaceUri===chunkILTZTY3K_cjs.ca){let c=chunkILTZTY3K_cjs.ze(l,"val");c&&o.push(c);}}}if(!e.part||!I(e.part.root))return r;let s=new Map;return e.part.root.children.forEach((i,a)=>s.set(i,a)),r.sort((i,a)=>(s.get(i)??0)-(s.get(a)??0))}function At(e,t,n){let o=Pt(e,t,Be)??e.parts.get("/word/numbering.xml")??null;if(!o||!I(o.root)||n.size===0)return {part:o,nums:[],abstracts:[]};let r=[],s=new Set;for(let a of o.root.children){if(!I(a)||a.localName!=="num"||a.namespaceUri!==chunkILTZTY3K_cjs.ca)continue;let l=chunkILTZTY3K_cjs.ze(a,"numId");if(!(!l||!n.has(l))){r.push(a);for(let c of a.children)if(I(c)&&c.localName==="abstractNumId"){let p=chunkILTZTY3K_cjs.ze(c,"val");p&&s.add(p);}}}let i=[];for(let a of o.root.children){if(!I(a)||a.localName!=="abstractNum"||a.namespaceUri!==chunkILTZTY3K_cjs.ca)continue;let l=chunkILTZTY3K_cjs.ze(a,"abstractNumId");l&&s.has(l)&&i.push(a);}return {part:o,nums:r,abstracts:i}}var le={latin:null,eastAsia:null,cs:null};function $t(e,t){let n=Pt(e,t,dn);if(!n)return {major:le,minor:le};let o={major:{...le},minor:{...le}};return P(n.root,r=>{if(r.kind==="textValue"||r.namespaceUri!==cn||r.localName!=="majorFont"&&r.localName!=="minorFont")return;let s=r.localName==="majorFont"?o.major:o.minor;for(let i of r.children){if(!I(i))continue;let a=chunkILTZTY3K_cjs.ze(i,"typeface");a&&(i.localName==="latin"?s.latin=a:i.localName==="ea"?s.eastAsia=a:i.localName==="cs"&&(s.cs=a));}}),{major:o.major,minor:o.minor}}function fn(e,t){let n=t.startsWith("major")?e.major:e.minor;return t.endsWith("EastAsia")?n.eastAsia??n.latin:t.endsWith("Bidi")?n.cs??n.latin:n.latin}var yn=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],bt=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function _(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===chunkILTZTY3K_cjs.ca){let s=[],i=new Map;for(let a of e.attributes){let l=yn.find(([c])=>c===a.localName);if(l&&a.namespaceUri===chunkILTZTY3K_cjs.ca){let c=fn(t,a.value);c&&i.set(l[1],c);continue}s.push(a);}for(let[a,l]of i)s.some(c=>c.localName===a)||s.push({kind:"genericExtension",namespaceUri:chunkILTZTY3K_cjs.ca,localName:a,prefix:"w",value:l});n=s;}else e.attributes.some(s=>bt.has(s.localName)&&s.namespaceUri===chunkILTZTY3K_cjs.ca&&e.attributes.some(i=>i.localName==="val"))&&(n=e.attributes.filter(s=>!(bt.has(s.localName)&&s.namespaceUri===chunkILTZTY3K_cjs.ca)));let o=e.children.map(s=>_(s,t)),r=o.some((s,i)=>s!==e.children[i]);return n===e.attributes&&!r?e:{...e,attributes:n,children:o}}function Mt(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Lt(e,t){if(e.root.kind==="document"){let o=e.root.children.find(s=>s.kind==="body"),r=o&&I(o)?Ot(o,t):{id:"fragment#body",kind:"body",namespaceUri:chunkILTZTY3K_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return Ot(e.root,[r])}let n={id:"fragment#body",kind:"body",namespaceUri:chunkILTZTY3K_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:chunkILTZTY3K_cjs.ca,localName:"document",prefix:"w",namespaceBindings:I(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function X(e){let t=e.map(n=>{let o=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${chunkILTZTY3K_cjs.N(n.id)}" Type="${chunkILTZTY3K_cjs.N(n.type)}" Target="${chunkILTZTY3K_cjs.N(n.rawTarget)}"${o}/>`}).join("");return `<Relationships xmlns="${ln}">${t}</Relationships>`}function Ft(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Dt(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}var hn="http://schemas.openxmlformats.org/package/2006/content-types",gn=5e4;function A(e){return e.kind!=="textValue"}function z(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)z(n,t);return t}function de(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let o=de(n,t);if(o)return o}return null}function S(e,t){return {...e,children:t}}function H(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunkILTZTY3K_cjs.ca}function xn(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&A(t)?t:null}return A(e.root)?e.root:null}function Rn(e,t){return z(e).some(n=>t.has(n))}function On(e){let t=o=>{if(o.kind==="textValue")return o;if(H(o,"vMerge")){if(chunkILTZTY3K_cjs.ze(o,"val")==="restart")return o;let r=[...o.attributes.filter(s=>!(s.localName==="val"&&s.namespaceUri===chunkILTZTY3K_cjs.ca)),{kind:"wmlVal",namespaceUri:chunkILTZTY3K_cjs.ca,localName:"val",prefix:"w",value:"restart"}];return {...o,attributes:r}}if(H(o,"tc")||H(o,"tcPr")){let r=o.children.map(t);return S(o,r)}return o},n=e.children.map(t);return S(e,n)}function bn(e,t,n){let o=e.children.filter(l=>l.kind!=="textValue"&&H(l,"tr")),r=new Set(z(e).filter(l=>t.inRange.has(l)));if(r.size===0)return;let s=o.filter(l=>{let c=z(l);return c.length>0&&c.every(p=>t.covered.has(p))}),i=new Set(s.flatMap(l=>z(l)));if(s.length>0&&r.size===i.size&&[...r].every(l=>i.has(l))){let l=true,c=[];for(let p of e.children){if(!H(p,"tr")){c.push(p);continue}s.includes(p)&&(c.push(l?On(p):p),l=false);}n.push(S(e,c));return}for(let l of z(e)){if(!t.inRange.has(l))continue;let c=de(e,l);c&&n.push(c);}}function He(e,t,n){for(let o of e)if(A(o)){if(o.kind==="paragraph"){t.inRange.has(o.id)&&n.push(o);continue}if(t.fullBlocks.has(o.id)){n.push(o);continue}if(o.kind==="table"){bn(o,t,n);continue}if(o.kind==="contentControl"){let r=o.children.find(s=>s.kind==="contentControlContent");r&&A(r)&&He(r.children,t,n);continue}Rn(o,t.inRange)&&He(o.children,t,n);}}var En=new Set(["commentRangeStart","commentRangeEnd"]);function vn(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function We(e){if(e.kind==="textValue")return e;if(En.has(e.localName)&&e.namespaceUri===chunkILTZTY3K_cjs.ca||vn(e)||H(e,"sectPr"))return null;let t=false,n=[];for(let o of e.children){let r=We(o);if(r===null){t=true;continue}r!==o&&(t=true),n.push(r);}return t?S(e,n):e}function Sn(e){if(e.kind!=="run")return null;for(let t of e.children)if(t.kind==="fldChar"){let n=chunkILTZTY3K_cjs.ze(t,"fldCharType");return n==="begin"||n==="separate"||n==="end"?n:"begin"}return null}function In(e){return e.kind==="run"&&e.children.some(t=>t.kind==="instrText")}function Cn(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){let c=Sn(l);c?t.push({nodeId:l.id,type:c}):In(l)&&t.push({nodeId:l.id,type:"instr"});return}for(let c of l.children)n(c);}};for(let l of e)n(l);if(t.length===0)return e;let o=new Set,r=[],s=null,i=[];for(let l of t){if(l.type==="begin"){r.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let p=r[r.length-1];p?p.separateId=l.nodeId:s=l.nodeId;continue}if(l.type==="instr"){let p=r[r.length-1];p?p.instrIds.push(l.nodeId):s===null&&i.push(l.nodeId);continue}if(!r.pop()){o.add(l.nodeId),s!==null&&o.add(s);for(let p of i)o.add(p);s=null,i=[];}}for(let l of r){o.add(l.beginId),l.separateId!==null&&o.add(l.separateId);for(let c of l.instrIds)o.add(c);}s!==null&&o.add(s);for(let l of i)o.add(l);if(o.size===0)return e;let a=l=>{if(l.kind==="textValue")return l;if(o.has(l.id))return null;let c=[],p=false;for(let h of l.children){let x=a(h);if(x===null){p=true;continue}x!==h&&(p=true),c.push(x);}return p?S(l,c):l};return e.map(l=>a(l)).filter(l=>l!==null)}function Ge(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=Ge(n);return t}function wn(e,t){let n=[];for(let o of e.children){if(o.kind!=="contentControl"){n.push(o);continue}let r=t.get(o.id),s=Ge(o);if(r===void 0||s>=r){n.push(o);continue}if(s===0)continue;let i=o.children.find(a=>a.kind==="contentControlContent");i&&A(i)?n.push(...i.children):n.push(o);}return S(e,n)}function kn(e){let t=new Set,n=new Set,o=i=>{if(i.kind!=="textValue"){if(i.kind==="bookmarkStart"){let a=chunkILTZTY3K_cjs.ze(i,"id");a!==void 0&&t.add(a);}if(i.kind==="bookmarkEnd"){let a=chunkILTZTY3K_cjs.ze(i,"id");a!==void 0&&n.add(a);}for(let a of i.children)o(a);}};for(let i of e)o(i);let r=new Set([...t].filter(i=>n.has(i)));if(r.size===t.size&&r.size===n.size)return e;let s=i=>{if(i.kind==="textValue")return i;if(i.kind==="bookmarkStart"||i.kind==="bookmarkEnd"){let c=chunkILTZTY3K_cjs.ze(i,"id");return c!==void 0&&r.has(c)?i:null}let a=[],l=false;for(let c of i.children){let p=s(c);if(p===null){l=true;continue}p!==c&&(l=true),a.push(p);}return l?S(i,a):i};return e.map(i=>s(i)??i)}function Nn(e,t,n){let o=e.parts.get(t.partName);if(!o)return {ok:false,reason:"unknown-part"};if(t.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let r=t.paragraphIds[0],s=t.paragraphIds[t.paragraphIds.length-1],i=new Map;for(let d of [r,s]){let m=de(o.root,d);if(!m)return {ok:false,reason:"empty-range"};for(let u of m.children)u.kind==="contentControl"&&i.set(u.id,Ge(u));}let a=o,l=de(a.root,s);if(!l)return {ok:false,reason:"empty-range"};let c=chunkILTZTY3K_cjs.Je(l);if(t.endOffset<c){let d=chunkILTZTY3K_cjs.Zg(a,{op:"deleteText",paragraphId:s,start:t.endOffset,end:c},{deferValidation:true});if(!d.ok)return {ok:false,reason:"trim-refused"};a=d.part;}if(t.startOffset>0){let d=chunkILTZTY3K_cjs.Zg(a,{op:"deleteText",paragraphId:r,start:0,end:t.startOffset},{deferValidation:true});if(!d.ok)return {ok:false,reason:"trim-refused"};a=d.part;}let p=xn(a);if(!p)return {ok:false,reason:"unknown-part"};let h={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},x=[];if(He(p.children,h,x),x.length===0)return {ok:false,reason:"empty-range"};if(x.length>gn)return {ok:false,reason:"resource-limit"};let R=x.map(d=>We(d)).filter(d=>d!==null).map(d=>d.kind!=="paragraph"||d.id!==r&&d.id!==s?d:wn(d,i));R=[...Cn(R)],R=[...kn(R)];let v=je(R,"footnoteReference"),k=je(R,"endnoteReference"),J=v.size>0?chunkILTZTY3K_cjs.Pe(e,"footnote"):null,Q=k.size>0?chunkILTZTY3K_cjs.Pe(e,"endnote"):null,Ke=(d,m)=>{if(!d||!A(d.root))return [];let u=[];for(let O of d.root.children){if(!A(O)||O.kind!=="note")continue;let E=chunkILTZTY3K_cjs.ze(O,"id"),g=chunkILTZTY3K_cjs.ze(O,"type");if(g==="separator"||g==="continuationSeparator"){u.push(O);continue}if(E!==void 0&&m.has(E)){let U=We(O);U&&A(U)&&u.push(U);}}return u},qe=Ke(J,v),Ye=Ke(Q,k),Bt=[...qe,...Ye],Xe=[...R,...Bt],Je=new Set;Ue(Xe,Je);let D=_t(e,e.mainDocumentPart),pe=ze(D,Je),me=new Set;Ve(Xe,me),Ve(pe,me);let C=At(e,e.mainDocumentPart,me),ue=new Set;Ue([...C.nums,...C.abstracts],ue);for(let d of [...C.nums,...C.abstracts])P(d,m=>{if(m.kind!=="textValue"&&(m.localName==="styleLink"||m.localName==="numStyleLink")&&m.namespaceUri===chunkILTZTY3K_cjs.ca){let u=chunkILTZTY3K_cjs.ze(m,"val");u&&ue.add(u);}});let Ut=ze(D,ue).filter(d=>!pe.includes(d)),Vt=[...pe,...Ut],B=$t(e,e.mainDocumentPart),Qe=Vt.map(d=>_(d,B)),fe=D.docDefaults?_(D.docDefaults,B):null;R=R.map(d=>_(d,B));let ye=qe.map(d=>_(d,B)),he=Ye.map(d=>_(d,B)),Ze=new Set;ce(R,Ze);let et=chunkILTZTY3K_cjs.Zb(e,o.name).filter(d=>Ze.has(d.id)),tt=new Map,nt=0,ot=d=>{let m=new Set;for(let u of d){if(u.targetMode==="External")continue;let O=chunkILTZTY3K_cjs.w(u.ownerPart,u.rawTarget);if(!O.ok){m.add(u.id);continue}if((chunkILTZTY3K_cjs._b(e,O.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let g=e.partBytes.get(O.partName)??e.partBytes.get(O.partName.replace(/^\//,""));g?(tt.set(O.partName,g),nt+=g.byteLength):m.add(u.id);continue}m.add(u.id);}return m},ge=ot(et),xe=(d,m)=>{if(d.kind==="textValue")return d;if(d.kind==="drawing"){let E=new Set;ce([d],E);for(let g of E)if(m.has(g))return null;return d}let u=[],O=false;for(let E of d.children){let g=xe(E,m);if(g===null){O=true;continue}g!==E&&(O=true),u.push(g);}return O?S(d,u):d};ge.size>0&&(R=R.map(d=>xe(d,ge)).filter(d=>d!==null));let jt=et.filter(d=>!ge.has(d.id)),rt=(d,m)=>{if(!d)return [];let u=new Set;ce(m,u);let O=chunkILTZTY3K_cjs.Zb(e,d.name).filter(g=>u.has(g.id)),E=ot(O);if(E.size>0)for(let g=0;g<m.length;g+=1){let U=xe(m[g],E);U!==null&&(m[g]=U);}return O.filter(g=>!E.has(g.id))},it=rt(J,ye),at=rt(Q,he),T=new Map,st=[],W=(d,m,u)=>{T.set(d.slice(1),chunkILTZTY3K_cjs.Ka(chunkILTZTY3K_cjs.ma(Mt(d,m,u)))),st.push([d,m]);},Z=[...jt],lt=new Set(Z.map(d=>d.id)),ct=9001,ee=(d,m)=>{let u=Ft(lt,ct);ct+=1,lt.add(u),Z.push({ownerPart:"/word/document.xml",id:u,type:d,rawTarget:m,targetMode:"Internal",order:Z.length});},zt=Lt(a,R);if(W("/word/document.xml",Et,zt),D.part&&(Qe.length>0||fe)){let d=S(D.part.root,[...fe?[fe]:[],...Qe]);W("/word/styles.xml",vt,d),ee(De,"styles.xml");}if(C.part&&(C.nums.length>0||C.abstracts.length>0)){let d=S(C.part.root,[...C.abstracts.map(m=>_(m,B)),...C.nums]);W("/word/numbering.xml",St,d),ee(Be,"numbering.xml");}J&&ye.length>0&&(W("/word/footnotes.xml",It,S(J.root,ye)),ee(kt,"footnotes.xml"),it.length>0&&T.set("word/_rels/footnotes.xml.rels",chunkILTZTY3K_cjs.Ka(X(it)))),Q&&he.length>0&&(W("/word/endnotes.xml",Ct,S(Q.root,he)),ee(Nt,"endnotes.xml"),at.length>0&&T.set("word/_rels/endnotes.xml.rels",chunkILTZTY3K_cjs.Ka(X(at))));let Re=new Map;for(let[d,m]of tt){T.set(d.slice(1),m);let u=Dt(d);u&&!Re.has(u)&&Re.set(u,chunkILTZTY3K_cjs._b(e,d)??"application/octet-stream");}T.set("word/_rels/document.xml.rels",chunkILTZTY3K_cjs.Ka(X(Z))),T.set("_rels/.rels",chunkILTZTY3K_cjs.Ka(X([{ownerPart:"/",id:"rId1",type:Tt,rawTarget:"word/document.xml",targetMode:"Internal",order:0}])));let Ht=[`<Default Extension="rels" ContentType="${wt}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...Re].map(([d,m])=>`<Default Extension="${chunkILTZTY3K_cjs.N(d)}" ContentType="${chunkILTZTY3K_cjs.N(m)}"/>`)].join(""),Wt=st.map(([d,m])=>`<Override PartName="${chunkILTZTY3K_cjs.N(d)}" ContentType="${chunkILTZTY3K_cjs.N(m)}"/>`).join("");return T.set("[Content_Types].xml",chunkILTZTY3K_cjs.Ka(`<Types xmlns="${hn}">${Ht}${Wt}</Types>`)),{ok:true,bytes:chunkILTZTY3K_cjs.Na(T),lastMarkCovered:t.lastMarkCovered,blockCount:R.length,mediaBytes:nt}}
|
|
2
|
-
exports.A=Me;exports.B=Le;exports.C=Fe;exports.D=sn;exports.E=Rt;exports.F=Nn;exports.a=Gt;exports.b=ut;exports.c=oe;exports.d=M;exports.e=re;exports.f=ie;exports.g=b;exports.h=Xt;exports.i=L;exports.j=K;exports.k=ae;exports.l=q;exports.m=se;exports.n=ke;exports.o=Ne;exports.p=Te;exports.q=en;exports.r=tn;exports.s=_e;exports.t=yt;exports.u=nn;exports.v=Pe;exports.w=on;exports.x=Y;exports.y=Ae;exports.z=$e;
|