@stll/folio-vue 0.2.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.
Files changed (109) hide show
  1. package/dist/ListButtons-B498PX1d.js +4256 -0
  2. package/dist/ListButtons-D-zMJ7rl.cjs +4 -0
  3. package/dist/PageSetupDialog-CGBaBVzo.cjs +15 -0
  4. package/dist/PageSetupDialog-DsjAfJy0.js +4873 -0
  5. package/dist/TablePropertiesDialog-A-1Pm1f9.cjs +1 -0
  6. package/dist/TablePropertiesDialog-PyXEJC_o.js +887 -0
  7. package/dist/components/DocxEditor/pagedEditorRef.d.ts +75 -0
  8. package/dist/components/DocxEditor/types.d.ts +528 -0
  9. package/dist/components/EditorToolbarContext.d.ts +9 -0
  10. package/dist/components/FormattingBar.types.d.ts +67 -0
  11. package/dist/components/Toolbar/presets.d.ts +25 -0
  12. package/dist/components/dialogs/index.d.ts +24 -0
  13. package/dist/components/imageContextMenuTypes.d.ts +30 -0
  14. package/dist/components/imageSelectionTypes.d.ts +13 -0
  15. package/dist/components/insertTableState.d.ts +9 -0
  16. package/dist/components/sidebar/cardStyles.d.ts +1 -0
  17. package/dist/components/sidebar/cardUtils.d.ts +1 -0
  18. package/dist/components/sidebar/resolveItemPositions.d.ts +22 -0
  19. package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
  20. package/dist/components/tableStylePresets.d.ts +60 -0
  21. package/dist/components/toolbarUtils.d.ts +3 -0
  22. package/dist/components/ui/AlignmentButtons.types.d.ts +13 -0
  23. package/dist/components/ui/StylePicker.types.d.ts +16 -0
  24. package/dist/components/ui/ZoomControl.types.d.ts +21 -0
  25. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  26. package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
  27. package/dist/composables/commentMarks.d.ts +32 -0
  28. package/dist/composables/imageOverlayRect.d.ts +44 -0
  29. package/dist/composables/index.d.ts +30 -0
  30. package/dist/composables/useAutoSave.d.ts +39 -0
  31. package/dist/composables/useClipboard.d.ts +21 -0
  32. package/dist/composables/useColorMode.d.ts +8 -0
  33. package/dist/composables/useCommentLifecycle.d.ts +39 -0
  34. package/dist/composables/useCommentManagement.d.ts +47 -0
  35. package/dist/composables/useCommentSidebarItems.d.ts +24 -0
  36. package/dist/composables/useContextMenus.d.ts +64 -0
  37. package/dist/composables/useControllableBoolean.d.ts +16 -0
  38. package/dist/composables/useDocumentLifecycle.d.ts +11 -0
  39. package/dist/composables/useDocxEditor.d.ts +123 -0
  40. package/dist/composables/useDocxEditorRefApi.d.ts +68 -0
  41. package/dist/composables/useDragAutoScroll.d.ts +11 -0
  42. package/dist/composables/useFileIO.d.ts +43 -0
  43. package/dist/composables/useFindReplace.d.ts +22 -0
  44. package/dist/composables/useFixedDropdown.d.ts +14 -0
  45. package/dist/composables/useFormattingActions.d.ts +21 -0
  46. package/dist/composables/useHistory.d.ts +9 -0
  47. package/dist/composables/useHostCallbacks.d.ts +24 -0
  48. package/dist/composables/useHyperlinkManagement.d.ts +40 -0
  49. package/dist/composables/useImageActions.d.ts +25 -0
  50. package/dist/composables/useKeyboardShortcuts.d.ts +25 -0
  51. package/dist/composables/useMenuActions.d.ts +36 -0
  52. package/dist/composables/useOutlineSidebar.d.ts +24 -0
  53. package/dist/composables/usePageSetupControls.d.ts +28 -0
  54. package/dist/composables/usePagesPointer.d.ts +87 -0
  55. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  56. package/dist/composables/usePortalClass.d.ts +8 -0
  57. package/dist/composables/useSelectionHighlight.d.ts +19 -0
  58. package/dist/composables/useSelectionSync.d.ts +30 -0
  59. package/dist/composables/useTableResize.d.ts +7 -0
  60. package/dist/composables/useTableSelection.d.ts +10 -0
  61. package/dist/composables/useToolbarDropdowns.d.ts +15 -0
  62. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  63. package/dist/composables/useTrackedChanges.d.ts +12 -0
  64. package/dist/composables/useVisualLineNavigation.d.ts +11 -0
  65. package/dist/composables/useWheelZoom.d.ts +10 -0
  66. package/dist/composables/useZoom.d.ts +16 -0
  67. package/dist/composables.cjs +61 -0
  68. package/dist/composables.js +378 -0
  69. package/dist/dialogs.cjs +1 -0
  70. package/dist/dialogs.js +3 -0
  71. package/dist/folio-vue.css +2 -0
  72. package/dist/i18n/index.d.ts +36 -0
  73. package/dist/i18n/messages.d.ts +1 -0
  74. package/dist/index.cjs +1 -0
  75. package/dist/index.d.ts +50 -0
  76. package/dist/index.js +4088 -0
  77. package/dist/messages.cjs +1 -0
  78. package/dist/messages.js +1 -0
  79. package/dist/renderAsync.d.ts +35 -0
  80. package/dist/styles/index.d.ts +12 -0
  81. package/dist/styles/zIndex.d.ts +18 -0
  82. package/dist/styles.cjs +1 -0
  83. package/dist/styles.js +5 -0
  84. package/dist/ui/folio-ui.d.ts +139 -0
  85. package/dist/ui.cjs +1 -0
  86. package/dist/ui.d.ts +67 -0
  87. package/dist/ui.js +446 -0
  88. package/dist/useZoom-BryUw3Cu.cjs +1 -0
  89. package/dist/useZoom-CIIRid8U.js +626 -0
  90. package/dist/utils/aiEditRange.d.ts +26 -0
  91. package/dist/utils/autoScroll.d.ts +22 -0
  92. package/dist/utils/cardStyles.d.ts +3 -0
  93. package/dist/utils/colorMode.d.ts +32 -0
  94. package/dist/utils/comments.d.ts +20 -0
  95. package/dist/utils/cssTypes.d.ts +7 -0
  96. package/dist/utils/domQueries.d.ts +39 -0
  97. package/dist/utils/fontOptions.d.ts +26 -0
  98. package/dist/utils/hostFonts.d.ts +25 -0
  99. package/dist/utils/imageClipboard.d.ts +9 -0
  100. package/dist/utils/index.d.ts +13 -0
  101. package/dist/utils/listState.d.ts +22 -0
  102. package/dist/utils/reportIssue.d.ts +18 -0
  103. package/dist/utils/selectionHighlight.d.ts +44 -0
  104. package/dist/utils/sidebarConstants.d.ts +8 -0
  105. package/dist/utils/stylePreview.d.ts +53 -0
  106. package/dist/utils/textSelection.d.ts +40 -0
  107. package/dist/zIndex-BY0qa8Au.js +12 -0
  108. package/dist/zIndex-dFsQbASx.cjs +1 -0
  109. package/package.json +99 -0
package/dist/index.js ADDED
@@ -0,0 +1,4088 @@
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./PageSetupDialog-DsjAfJy0.js";
2
+ import { A as u, C as d, F as f, I as p, P as m, S as h, a as g, b as _, f as v, i as y, n as b, p as x, r as S, t as C, x as ee, y as te } from "./ListButtons-B498PX1d.js";
3
+ import { t as ne } from "./zIndex-BY0qa8Au.js";
4
+ import { a as re, i as w, o as ie, r as ae, t as T } from "./useZoom-CIIRid8U.js";
5
+ import { Fragment as E, Teleport as D, computed as O, createApp as oe, createBlock as k, createCommentVNode as A, createElementBlock as j, createElementVNode as M, createSlots as se, createStaticVNode as ce, createTextVNode as le, createVNode as N, defineComponent as P, h as F, inject as ue, mergeProps as de, nextTick as I, normalizeClass as L, normalizeStyle as R, onBeforeUnmount as fe, onMounted as pe, openBlock as z, provide as me, ref as B, renderList as V, renderSlot as H, shallowRef as he, toDisplayString as U, unref as W, vModelText as G, watch as K, withCtx as ge, withDirectives as q, withKeys as J, withModifiers as Y } from "vue";
6
+ import { createStyleResolver as _e, extractSelectionState as ve, insertImageFromFile as ye, insertImageFromFile as be, insertPageBreakInView as xe, insertPageBreakInView as Se, insertTableInView as X, insertTableInView as Ce, insertTableOfContentsInView as we, insertTableOfContentsInView as Te } from "@stll/folio-core/prosemirror";
7
+ import { extractSelectionContext as Ee } from "@stll/folio-core/prosemirror/plugins/selectionTracker";
8
+ import { inspectDocxCompatibility as De } from "@stll/folio-core/docx/compatibility";
9
+ import { clearAllCaches as Oe, resetCanvasContext as ke } from "@stll/folio-core/layout-bridge/engine/measuring";
10
+ import { onFontsLoaded as Ae } from "@stll/folio-core/utils/fontLoader";
11
+ import { twipsToPixels as je } from "@stll/folio-core/paged-layout/sectionGeometry";
12
+ import { measureDirectiveGutter as Me, projectRangesToRects as Ne } from "@stll/folio-core/paged-layout/rangeProjection";
13
+ import { prefersReducedMotionBehavior as Pe } from "@stll/folio-core/paged-layout/scrollNavigation";
14
+ import { anonymizationDecorationsKey as Fe, getAnonymizationMatches as Ie, getAnonymizationMatches as Le, setAnonymizationTermsMeta as Re, slugAnonymizationLabel as ze } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
15
+ import { NodeSelection as Be, Selection as Z, TextSelection as Ve } from "prosemirror-state";
16
+ import { pixelsToEmu as He } from "@stll/folio-core/utils/units";
17
+ import { IMAGE_LAYOUT_OPTIONS as Ue, captureInlinePositionEmu as We, deriveLayoutChoice as Ge, findImageElement as Ke, isImageLayoutOptionEnabled as qe, toolbarValueToLayoutTarget as Je } from "@stll/folio-core/layout-painter/imageLayout";
18
+ import { isTrackChangesMode as Ye, toggledTrackChangesMode as Xe } from "@stll/folio-core/managers/EditorModeManager";
19
+ import { clickToPositionDom as Ze } from "@stll/folio-core/layout-bridge/dom/clickToPositionDom";
20
+ import { calculateResizedImageDimensions as Qe, commitImageFloatMove as $e, commitImageInlineMove as et, commitImageResize as tt, isFloatingImage as nt } from "@stll/folio-core/prosemirror/imageCommit";
21
+ import { findBodyPmAnchor as rt, findBodyPmSpans as it } from "@stll/folio-core/layout-bridge/dom/findBodyPmSpans";
22
+ import { getTemplateDirectives as at, getTemplateDirectives as ot, scanDirectives as st } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
23
+ import { clearFormatting as ct } from "@stll/folio-core/prosemirror/commands/formatting";
24
+ import { getTableContext as lt } from "@stll/folio-core/prosemirror/extensions/nodes/TableExtension";
25
+ import { PENDING_COMMENT_ID as ut, createCommentIdAllocator as dt, seedCommentAllocator as ft } from "@stll/folio-core/prosemirror/commentIdAllocator";
26
+ import { createComment as pt } from "@stll/folio-core/prosemirror/commentOps";
27
+ import { findChangeRange as mt } from "@stll/folio-core/prosemirror/queries";
28
+ import { acceptAIEditRevision as ht, acceptChange as gt, findAIEditRevisionRange as _t, rejectAIEditRevision as vt, rejectChange as yt } from "@stll/folio-core/prosemirror/commands/comments";
29
+ import { makeRevisionInfo as bt } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
30
+ import { setTemplatePreviewValues as xt } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
31
+ import { clearTemplateSlashMenu as St, consumeTemplateSlashQuery as Ct, getTemplateSlashMenu as wt, resetTemplateSlashQuery as Tt, templateSlashMenuKey as Et } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
32
+ import { applyFolioAIEditOperations as Dt, applyFolioAIEditOperations as Ot, createFolioAIEditSnapshot as kt, createFolioAIEditSnapshot as At, diffWordSegments as jt, hashFolioAIBlockText as Mt, normalizeFolioAIBlockText as Nt } from "@stll/folio-core/ai-edits";
33
+ import { findPageIndexContainingPmPos as Pt } from "@stll/folio-core/layout-engine";
34
+ import { findParagraphFragmentsByParaId as Ft, flashParagraphElements as Q } from "@stll/folio-core/paged-layout/paragraphFlash";
35
+ import { blockSdtAttrsToSdtProperties as It, findBlockSdtMatch as $, findBlockSdtMatches as Lt, removeContentControlTr as Rt, setContentControlContentTr as zt, setContentControlValueTr as Bt } from "@stll/folio-core/prosemirror/commands/contentControls";
36
+ import { setContentControlContentBlocksTr as Vt } from "@stll/folio-core/prosemirror/commands/contentControlsBlockFill";
37
+ import { createFolioAIEditSnapshot as Ht } from "@stll/folio-core/ai-edits/snapshot";
38
+ import { findParagraphByParaId as Ut } from "@stll/folio-core/prosemirror/utils/findParagraphByParaId";
39
+ import { deriveBlockId as Wt, getFolioParaIdFromBlockId as Gt, getFolioParaIdFromBlockId as Kt, getSequentialFolioBlockIdIndex as qt, isFolioBlockId as Jt, isSequentialFolioBlockId as Yt } from "@stll/folio-core/types/block-id";
40
+ import { applyStyle as Xt, removeTabStop as Zt, setIndentFirstLine as Qt, setIndentLeft as $t, setIndentRight as en } from "@stll/folio-core/prosemirror/commands/paragraph";
41
+ import { getCachedNumberingMap as tn } from "@stll/folio-core/docx";
42
+ import { insertPageBreak as nn } from "@stll/folio-core/prosemirror/commands/pageBreak";
43
+ import { insertSectionBreakContinuous as rn, insertSectionBreakNextPage as an } from "@stll/folio-core/prosemirror/commands/sectionBreak";
44
+ import { editHyperlinkAtCursor as on, removeHyperlinkAtCursor as sn } from "@stll/folio-core/prosemirror/commands/hyperlink";
45
+ import { TABLE_INSERT_HIDE_DELAY_MS as cn, detectTableInsertHover as ln } from "@stll/folio-core/layout-bridge/tableInsertHover";
46
+ import { createCellDragTracker as un, findCellPosFromPmPos as dn } from "@stll/folio-core/prosemirror/cellDragSelection";
47
+ import { createEmptyDocument as fn } from "@stll/folio-core/utils/createDocument";
48
+ import { createDocx as pn } from "@stll/folio-core/docx/rezip";
49
+ import { DEFAULT_AI_SUGGESTION_PRESETS as mn } from "@stll/folio-core/ai-suggestions/types";
50
+ import { applySuggestions as hn } from "@stll/folio-core/ai-suggestions/apply";
51
+ import { isSuggestionStale as gn, resolveSuggestionAnchor as _n } from "@stll/folio-core/ai-suggestions/conflict";
52
+ import { buildPositionalText as vn } from "@stll/folio-core/ai-suggestions/text-positions";
53
+ import { setAISuggestionsMeta as yn, setFocusedSuggestionMeta as bn } from "@stll/folio-core/prosemirror/plugins/aiSuggestionDecorations";
54
+ import { scrollFolioPositionIntoView as xn } from "@stll/folio-core/paged-layout/scrollToPmPosition";
55
+ import { getFolioCaretViewportRect as Sn, getFolioSelectionViewportRect as Cn } from "@stll/folio-core/paged-layout/selectionViewportRect";
56
+ import { createAICitationDecorationsPlugin as wn, setAICitationsMeta as Tn, setActiveCitationMeta as En } from "@stll/folio-core/prosemirror/plugins/aiCitationDecorations";
57
+ import { DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES as Dn, acceptAutocompleteSuggestion as On, acceptAutocompleteWord as kn, appendAutocompleteToken as An, autocompleteSuggestionKey as jn, autocompleteSuggestionPlugin as Mn, clearAutocompleteSuggestion as Nn, finishAutocompleteSuggestion as Pn, getAutocompleteSuggestion as Fn, shouldTriggerAutocomplete as In, startAutocompleteSuggestion as Ln } from "@stll/folio-core/prosemirror/plugins/autocompleteSuggestion";
58
+ import { fromMarkdown as Rn, toMarkdown as zn, toMarkdownResult as Bn } from "@stll/folio-core/markdown";
59
+ //#region src/components/AnonymizationRectsOverlay.vue?vue&type=script&setup=true&lang.ts
60
+ var Vn = [
61
+ "data-folio-anonymization-label",
62
+ "data-folio-anonymization-canonical",
63
+ "data-folio-anonymization-selected",
64
+ "title"
65
+ ], Hn = /*#__PURE__*/ l(/* @__PURE__ */ P({
66
+ __name: "AnonymizationRectsOverlay",
67
+ props: {
68
+ getView: { type: Function },
69
+ getPagesContainer: { type: Function },
70
+ editorState: {},
71
+ zoom: {},
72
+ layout: {},
73
+ blocks: {},
74
+ measures: {},
75
+ onTermClick: { type: Function },
76
+ selectedCanonical: {},
77
+ selectionSeq: {}
78
+ },
79
+ setup(e) {
80
+ let t = e, n = B(null), r = B([]), i = 0, a = null;
81
+ function o() {
82
+ a !== null && cancelAnimationFrame(a), a = requestAnimationFrame(() => {
83
+ a = null, s();
84
+ });
85
+ }
86
+ async function s() {
87
+ let e = ++i, n = t.getView(), a = t.getPagesContainer(), o = t.editorState;
88
+ if (!n || !a || !o) {
89
+ r.value = [];
90
+ return;
91
+ }
92
+ let s = Le(o);
93
+ if (s.length === 0) {
94
+ r.value = [];
95
+ return;
96
+ }
97
+ let c = await Ne(s, {
98
+ pagesContainer: a,
99
+ zoom: t.zoom,
100
+ layout: t.layout,
101
+ blocks: t.blocks,
102
+ measures: t.measures
103
+ });
104
+ if (e !== i) return;
105
+ let l = t.zoom;
106
+ r.value = c.map(({ range: e, rects: t }) => ({
107
+ label: e.label,
108
+ canonical: e.canonical,
109
+ rects: t.map((e) => ({
110
+ left: e.x * l,
111
+ top: e.y * l,
112
+ width: e.width * l,
113
+ height: e.height * l
114
+ }))
115
+ }));
116
+ }
117
+ K(() => [
118
+ t.editorState,
119
+ t.zoom,
120
+ t.layout,
121
+ t.blocks,
122
+ t.measures
123
+ ], () => o());
124
+ let c = null;
125
+ function l() {
126
+ let e = n.value, r = t.selectedCanonical;
127
+ if (!e || !r) {
128
+ c = null;
129
+ return;
130
+ }
131
+ let i = e.querySelectorAll(`[data-folio-anonymization-canonical="${CSS.escape(r)}"]`);
132
+ if (i.length === 0) return;
133
+ let a = c?.canonical === r ? (c.index + 1) % i.length : 0;
134
+ c = {
135
+ canonical: r,
136
+ index: a
137
+ }, i.item(a)?.scrollIntoView({
138
+ block: "center",
139
+ behavior: Pe()
140
+ });
141
+ }
142
+ K(() => [t.selectedCanonical, t.selectionSeq], () => l(), { flush: "post" });
143
+ function u(e) {
144
+ if (e.button !== 0 || !t.onTermClick) return;
145
+ let r = n.value;
146
+ if (!r) return;
147
+ let i = r.querySelectorAll("[data-folio-anonymization-canonical]");
148
+ for (let n = i.length - 1; n >= 0; --n) {
149
+ let r = i.item(n);
150
+ if (!r) continue;
151
+ let a = r.getBoundingClientRect();
152
+ if (e.clientX >= a.left && e.clientX < a.right && e.clientY >= a.top && e.clientY < a.bottom) {
153
+ let e = r.dataset.folioAnonymizationCanonical, n = r.dataset.folioAnonymizationLabel;
154
+ e && n && t.onTermClick(e, n);
155
+ return;
156
+ }
157
+ }
158
+ }
159
+ return pe(() => {
160
+ document.addEventListener("click", u), o();
161
+ }), fe(() => {
162
+ document.removeEventListener("click", u), a !== null && (cancelAnimationFrame(a), a = null);
163
+ }), (t, i) => (z(), j("div", {
164
+ ref_key: "rootRef",
165
+ ref: n,
166
+ class: "folio-anonymization-overlay",
167
+ "data-folio-anonymization-overlay": ""
168
+ }, [(z(!0), j(E, null, V(r.value, (t) => (z(), j(E, { key: `${t.label}:${t.canonical}` }, [(z(!0), j(E, null, V(t.rects, (n, r) => (z(), j("span", {
169
+ key: `${t.canonical}:${r}:${n.left}:${n.top}`,
170
+ class: L(["folio-anonymization-term", `folio-anonymization-term--${W(ze)(t.label)}`]),
171
+ "data-folio-anonymization-label": t.label,
172
+ "data-folio-anonymization-canonical": t.canonical,
173
+ "data-folio-anonymization-selected": t.canonical === e.selectedCanonical ? "true" : void 0,
174
+ title: `Anonymized: ${t.canonical}`,
175
+ style: R({
176
+ position: "absolute",
177
+ left: `${n.left}px`,
178
+ top: `${n.top}px`,
179
+ width: `${n.width}px`,
180
+ height: `${n.height}px`
181
+ })
182
+ }, null, 14, Vn))), 128))], 64))), 128))], 512));
183
+ }
184
+ }), [["__scopeId", "data-v-c7db88e1"]]), Un = { class: "doc-outline__header" }, Wn = { class: "doc-outline__body" }, Gn = {
185
+ key: 0,
186
+ class: "doc-outline__empty"
187
+ }, Kn = ["onMousedown"], qn = /*#__PURE__*/ l(/* @__PURE__ */ P({
188
+ __name: "DocumentOutline",
189
+ props: {
190
+ isOpen: { type: Boolean },
191
+ headings: {},
192
+ leftOffset: { default: 12 },
193
+ topPx: { default: 24 }
194
+ },
195
+ emits: ["close", "navigate"],
196
+ setup(e) {
197
+ let t = e, n = O(() => t.headings.length ? Math.min(...t.headings.map((e) => e.level)) : 0);
198
+ return (t, r) => e.isOpen ? (z(), j("nav", {
199
+ key: 0,
200
+ class: "doc-outline",
201
+ style: R({
202
+ left: e.leftOffset + "px",
203
+ top: e.topPx + "px"
204
+ }),
205
+ role: "navigation",
206
+ "aria-label": "Document outline",
207
+ onMousedown: r[1] ||= Y(() => {}, ["stop"])
208
+ }, [M("div", Un, [M("button", {
209
+ class: "doc-outline__back",
210
+ title: "Close outline",
211
+ "aria-label": "Close outline",
212
+ onClick: r[0] ||= (e) => t.$emit("close")
213
+ }, [N(p, {
214
+ name: "arrow_back",
215
+ size: 20
216
+ })]), r[2] ||= M("span", { class: "doc-outline__title" }, "Document Outline", -1)]), M("div", Wn, [e.headings.length === 0 ? (z(), j("div", Gn, "No headings found")) : A("", !0), (z(!0), j(E, null, V(e.headings, (e, r) => (z(), j("button", {
217
+ key: r,
218
+ class: "doc-outline__item",
219
+ style: R({ paddingLeft: 8 + (e.level - n.value) * 16 + "px" }),
220
+ onMousedown: Y((n) => t.$emit("navigate", e.pmPos), ["prevent"])
221
+ }, U(e.text || "(untitled)"), 45, Kn))), 128))])], 36)) : A("", !0);
222
+ }
223
+ }), [["__scopeId", "data-v-94e471af"]]), Jn = /* @__PURE__ */ P({
224
+ __name: "DocxEditorDialogs",
225
+ props: {
226
+ view: {},
227
+ bookmarks: {},
228
+ selectedImagePmPos: {},
229
+ sectionProperties: {},
230
+ showFindReplace: { type: Boolean },
231
+ showHyperlink: { type: Boolean },
232
+ showInsertSymbol: { type: Boolean },
233
+ showImageProperties: { type: Boolean },
234
+ showPageSetup: { type: Boolean }
235
+ },
236
+ emits: [
237
+ "update:showFindReplace",
238
+ "update:showHyperlink",
239
+ "update:showInsertSymbol",
240
+ "update:showImageProperties",
241
+ "update:showPageSetup",
242
+ "insert-symbol",
243
+ "hyperlink-submit",
244
+ "hyperlink-remove",
245
+ "page-setup-apply"
246
+ ],
247
+ setup(t, { emit: r }) {
248
+ let a = r;
249
+ return (r, s) => (z(), j(E, null, [
250
+ N(e, {
251
+ "is-open": t.showFindReplace,
252
+ view: t.view,
253
+ onClose: s[0] ||= (e) => a("update:showFindReplace", !1)
254
+ }, null, 8, ["is-open", "view"]),
255
+ N(n, {
256
+ "is-open": t.showHyperlink,
257
+ view: t.view,
258
+ bookmarks: t.bookmarks,
259
+ onClose: s[1] ||= (e) => a("update:showHyperlink", !1),
260
+ onSubmit: s[2] ||= (e) => a("hyperlink-submit", e),
261
+ onRemove: s[3] ||= (e) => a("hyperlink-remove")
262
+ }, null, 8, [
263
+ "is-open",
264
+ "view",
265
+ "bookmarks"
266
+ ]),
267
+ N(i, {
268
+ "is-open": t.showInsertSymbol,
269
+ onClose: s[4] ||= (e) => a("update:showInsertSymbol", !1),
270
+ onInsert: s[5] ||= (e) => a("insert-symbol", e)
271
+ }, null, 8, ["is-open"]),
272
+ N(o, {
273
+ "is-open": t.showImageProperties,
274
+ view: t.view,
275
+ "pm-pos": t.selectedImagePmPos,
276
+ onClose: s[6] ||= (e) => a("update:showImageProperties", !1)
277
+ }, null, 8, [
278
+ "is-open",
279
+ "view",
280
+ "pm-pos"
281
+ ]),
282
+ N(c, {
283
+ "is-open": t.showPageSetup,
284
+ "section-properties": t.sectionProperties,
285
+ onClose: s[7] ||= (e) => a("update:showPageSetup", !1),
286
+ onApply: s[8] ||= (e) => a("page-setup-apply", e)
287
+ }, null, 8, ["is-open", "section-properties"])
288
+ ], 64));
289
+ }
290
+ }), Yn = {
291
+ key: 0,
292
+ class: "docx-editor-vue__title-bar"
293
+ }, Xn = { class: "docx-editor-vue__title-bar-left" }, Zn = { class: "docx-editor-vue__title-bar-center" }, Qn = { class: "docx-editor-vue__title-bar-right" }, $n = /* @__PURE__ */ P({
294
+ __name: "DocxEditorMenuBar",
295
+ props: {
296
+ showMenuBar: {
297
+ type: Boolean,
298
+ default: !0
299
+ },
300
+ documentName: { default: "" },
301
+ documentNameEditable: {
302
+ type: Boolean,
303
+ default: !0
304
+ },
305
+ showFileOpen: {
306
+ type: Boolean,
307
+ default: !0
308
+ },
309
+ showHelpMenu: {
310
+ type: Boolean,
311
+ default: !0
312
+ },
313
+ showTableInsert: {
314
+ type: Boolean,
315
+ default: !0
316
+ }
317
+ },
318
+ emits: [
319
+ "rename",
320
+ "menu-action",
321
+ "insert-table"
322
+ ],
323
+ setup(e, { emit: t }) {
324
+ let n = t;
325
+ return (t, r) => e.showMenuBar ? (z(), j("div", Yn, [
326
+ M("div", Xn, [H(t.$slots, "title-bar-left")]),
327
+ M("div", Zn, [N(m, {
328
+ "model-value": e.documentName,
329
+ editable: e.documentNameEditable,
330
+ "onUpdate:modelValue": r[0] ||= (e) => n("rename", e)
331
+ }, null, 8, ["model-value", "editable"]), N(u, {
332
+ "show-file-open": e.showFileOpen,
333
+ "show-help-menu": e.showHelpMenu,
334
+ "show-table-insert": e.showTableInsert,
335
+ onAction: r[1] ||= (e) => n("menu-action", e),
336
+ onInsertTable: r[2] ||= (e, t) => n("insert-table", e, t)
337
+ }, null, 8, [
338
+ "show-file-open",
339
+ "show-help-menu",
340
+ "show-table-insert"
341
+ ])]),
342
+ M("div", Qn, [H(t.$slots, "title-bar-right")])
343
+ ])) : A("", !0);
344
+ }
345
+ }), er = Symbol("docx-portal-class");
346
+ function tr(e) {
347
+ me(er, O(() => ({
348
+ "ep-root": !0,
349
+ dark: !!W(e)
350
+ })));
351
+ }
352
+ function nr() {
353
+ return ue(er, O(() => ({ "ep-root": !0 })));
354
+ }
355
+ //#endregion
356
+ //#region src/components/ImageContextMenu.vue?vue&type=script&setup=true&lang.ts
357
+ var rr = ["aria-label"], ir = { class: "image-ctx-menu__icon" }, ar = { class: "image-ctx-menu__label" }, or = {
358
+ key: 1,
359
+ class: "image-ctx-menu__divider",
360
+ role: "separator"
361
+ }, sr = [
362
+ "data-wrap-type",
363
+ "data-current",
364
+ "data-disabled",
365
+ "disabled",
366
+ "title",
367
+ "onClick"
368
+ ], cr = { class: "image-ctx-menu__icon" }, lr = { class: "image-ctx-menu__label" }, ur = ["aria-label"], dr = ["disabled", "onClick"], fr = { class: "image-ctx-menu__label" }, pr = {
369
+ key: 0,
370
+ class: "image-ctx-menu__shortcut"
371
+ }, mr = {
372
+ key: 0,
373
+ class: "image-ctx-menu__divider",
374
+ role: "separator"
375
+ }, hr = 18, gr = 260, _r = 10, vr = /*#__PURE__*/ l(/* @__PURE__ */ P({
376
+ __name: "ImageContextMenu",
377
+ props: {
378
+ state: {},
379
+ textActions: {},
380
+ canOpenProperties: {
381
+ type: Boolean,
382
+ default: !1
383
+ }
384
+ },
385
+ emits: [
386
+ "close",
387
+ "select",
388
+ "text-action",
389
+ "open-properties"
390
+ ],
391
+ setup(e, { emit: t }) {
392
+ let n = e, i = t;
393
+ function a() {
394
+ i("open-properties"), i("close");
395
+ }
396
+ let { t: o } = r(), s = nr(), c = Ue, l = O(() => n.state ? Ge(n.state.currentWrapType, n.state.currentCssFloat ?? null) : null), u = {
397
+ inline: "wrap_text",
398
+ squareLeft: "format_image_left",
399
+ squareRight: "format_image_right",
400
+ behind: "flip_to_back",
401
+ inFront: "flip_to_front"
402
+ };
403
+ function d(e) {
404
+ return u[e];
405
+ }
406
+ let f = O(() => {
407
+ if (!n.state) return {};
408
+ let e = Ue.length * 36 + 16, t = n.state.position.x, r = n.state.position.y;
409
+ return typeof window < "u" && (t + gr > window.innerWidth && (t = window.innerWidth - gr - _r), r + e > window.innerHeight && (r = window.innerHeight - e - _r), t < _r && (t = _r), r < _r && (r = _r)), {
410
+ position: "fixed",
411
+ left: `${t}px`,
412
+ top: `${r}px`,
413
+ minWidth: `${gr}px`,
414
+ zIndex: 400
415
+ };
416
+ });
417
+ function m(e) {
418
+ return n.state ? qe(e, n.state.currentWrapType) : !1;
419
+ }
420
+ function h(e) {
421
+ m(e) && (i("select", e.choice), i("close"));
422
+ }
423
+ function g(e) {
424
+ e.disabled || (i("text-action", e.action), i("close"));
425
+ }
426
+ function _(e) {
427
+ e.preventDefault(), i("close");
428
+ }
429
+ function v(e) {
430
+ e.key === "Escape" && (e.preventDefault(), i("close"));
431
+ }
432
+ return (t, n) => (z(), k(D, { to: "body" }, [e.state && e.state.open ? (z(), j("div", {
433
+ key: 0,
434
+ class: "image-ctx-menu-backdrop",
435
+ onMousedown: _,
436
+ onContextmenu: n[0] ||= Y((e) => t.$emit("close"), ["prevent"])
437
+ }, null, 32)) : A("", !0), e.state && e.state.open ? (z(), j("div", {
438
+ key: 1,
439
+ class: L(["image-ctx-menu", W(s)]),
440
+ role: "menu",
441
+ "aria-label": W(o)("imageWrap.menu.ariaLabel"),
442
+ "data-testid": "image-context-menu",
443
+ style: R(f.value),
444
+ onContextmenu: n[4] ||= Y(() => {}, ["prevent"]),
445
+ onKeydown: v
446
+ }, [
447
+ e.canOpenProperties ? (z(), j("button", {
448
+ key: 0,
449
+ type: "button",
450
+ role: "menuitem",
451
+ class: "image-ctx-menu__item",
452
+ "data-action": "open-properties",
453
+ onMousedown: n[1] ||= Y(() => {}, ["prevent"]),
454
+ onClick: a
455
+ }, [M("span", ir, [N(p, {
456
+ name: "settings",
457
+ size: hr
458
+ })]), M("span", ar, U(W(o)("imageWrap.menu.imageProperties")), 1)], 32)) : A("", !0),
459
+ e.canOpenProperties ? (z(), j("div", or)) : A("", !0),
460
+ (z(!0), j(E, null, V(W(c), (e) => (z(), j("button", {
461
+ key: e.choice,
462
+ type: "button",
463
+ role: "menuitem",
464
+ class: L(["image-ctx-menu__item", { "image-ctx-menu__item--current": e.choice === l.value }]),
465
+ "data-wrap-type": e.choice,
466
+ "data-current": e.choice === l.value ? "true" : "false",
467
+ "data-disabled": m(e) ? "false" : "true",
468
+ disabled: !m(e),
469
+ title: W(o)(`imageWrap.menuDesc.${e.i18nDescKey}`),
470
+ onMousedown: n[2] ||= Y(() => {}, ["prevent"]),
471
+ onClick: (t) => h(e)
472
+ }, [
473
+ M("span", cr, [N(p, {
474
+ name: d(e.iconHint),
475
+ size: hr
476
+ }, null, 8, ["name"])]),
477
+ M("span", lr, U(W(o)(`imageWrap.menu.${e.i18nLabelKey}`)), 1),
478
+ e.choice === l.value ? (z(), j("span", {
479
+ key: 0,
480
+ class: "image-ctx-menu__current-dot",
481
+ "aria-label": W(o)("imageWrap.menu.ariaLabel")
482
+ }, "●", 8, ur)) : A("", !0)
483
+ ], 42, sr))), 128)),
484
+ e.textActions && e.textActions.length > 0 ? (z(), j(E, { key: 2 }, [n[5] ||= M("div", {
485
+ class: "image-ctx-menu__divider",
486
+ role: "separator"
487
+ }, null, -1), (z(!0), j(E, null, V(e.textActions, (e, t) => (z(), j(E, { key: `${e.action}-${t}` }, [M("button", {
488
+ type: "button",
489
+ role: "menuitem",
490
+ class: "image-ctx-menu__item image-ctx-menu__item--text",
491
+ disabled: e.disabled,
492
+ onMousedown: n[3] ||= Y(() => {}, ["prevent"]),
493
+ onClick: (t) => g(e)
494
+ }, [M("span", fr, U(e.label), 1), e.shortcut ? (z(), j("span", pr, U(e.shortcut), 1)) : A("", !0)], 40, dr), e.dividerAfter ? (z(), j("div", mr)) : A("", !0)], 64))), 128))], 64)) : A("", !0)
495
+ ], 46, rr)) : A("", !0)]));
496
+ }
497
+ }), [["__scopeId", "data-v-1bdca3c9"]]), yr = ["disabled", "onMousedown"], br = {
498
+ key: 0,
499
+ class: "ctx-menu__icon"
500
+ }, xr = { class: "ctx-menu__label" }, Sr = {
501
+ key: 1,
502
+ class: "ctx-menu__shortcut"
503
+ }, Cr = 220, wr = 32, Tr = 10, Er = /*#__PURE__*/ l(/* @__PURE__ */ P({
504
+ __name: "TextContextMenu",
505
+ props: {
506
+ isOpen: { type: Boolean },
507
+ position: {},
508
+ hasSelection: { type: Boolean },
509
+ isEditable: { type: Boolean },
510
+ inTable: { type: Boolean },
511
+ onImage: { type: Boolean },
512
+ canMergeCells: { type: Boolean },
513
+ canSplitCell: { type: Boolean },
514
+ customItems: {}
515
+ },
516
+ emits: ["close", "action"],
517
+ setup(e, { emit: t }) {
518
+ let n = e, i = ({ node: e }) => e;
519
+ i.props = ["node"];
520
+ let a = t, { t: o } = r(), s = nr(), c = B(null), l = O(() => {
521
+ let e = [], t = n.customItems ?? [];
522
+ for (let [n, r] of t.entries()) e.push({
523
+ id: `custom-${r.id}`,
524
+ label: r.label,
525
+ action: `custom:${r.id}`,
526
+ emphasis: !0,
527
+ ...r.icon === void 0 ? {} : { icon: r.icon }
528
+ }), n === t.length - 1 && e.push({
529
+ id: "div-custom",
530
+ label: "",
531
+ action: "",
532
+ divider: !0
533
+ });
534
+ return e.push({
535
+ id: "cut",
536
+ label: o("cut"),
537
+ action: "cut",
538
+ shortcut: o("contextMenu.cutShortcut"),
539
+ disabled: !n.hasSelection || !n.isEditable
540
+ }, {
541
+ id: "copy",
542
+ label: o("copy"),
543
+ action: "copy",
544
+ shortcut: o("contextMenu.copyShortcut"),
545
+ disabled: !n.hasSelection
546
+ }, {
547
+ id: "paste",
548
+ label: o("paste"),
549
+ action: "paste",
550
+ shortcut: o("contextMenu.pasteShortcut"),
551
+ disabled: !n.isEditable
552
+ }, {
553
+ id: "pasteAsPlainText",
554
+ label: o("pasteUnformatted"),
555
+ action: "pasteAsPlainText",
556
+ shortcut: o("contextMenu.pastePlainTextShortcut"),
557
+ disabled: !n.isEditable
558
+ }, {
559
+ id: "div1",
560
+ label: "",
561
+ action: "",
562
+ divider: !0
563
+ }, {
564
+ id: "delete",
565
+ label: o("delete"),
566
+ action: "delete",
567
+ shortcut: o("contextMenu.deleteShortcut"),
568
+ disabled: !n.hasSelection || !n.isEditable
569
+ }, {
570
+ id: "selectAll",
571
+ label: o("selectAll"),
572
+ action: "selectAll",
573
+ shortcut: o("contextMenu.selectAllShortcut")
574
+ }), n.onImage && n.isEditable && e.push({
575
+ id: "div-img",
576
+ label: "",
577
+ action: "",
578
+ divider: !0
579
+ }, {
580
+ id: "replaceImage",
581
+ label: o("imageOverlay.replaceImage"),
582
+ action: "replaceImage"
583
+ }, {
584
+ id: "imageProperties",
585
+ label: o("imageWrap.menu.imageProperties"),
586
+ action: "imageProperties"
587
+ }, {
588
+ id: "deleteImage",
589
+ label: o("imageOverlay.deleteImage"),
590
+ action: "deleteImage",
591
+ shortcut: o("contextMenu.deleteShortcut")
592
+ }), n.inTable && n.isEditable && e.push({
593
+ id: "div2",
594
+ label: "",
595
+ action: "",
596
+ divider: !0
597
+ }, {
598
+ id: "addRowAbove",
599
+ label: o("insertRowAbove"),
600
+ action: "addRowAbove"
601
+ }, {
602
+ id: "addRowBelow",
603
+ label: o("insertRowBelow"),
604
+ action: "addRowBelow"
605
+ }, {
606
+ id: "deleteRow",
607
+ label: o("deleteRow"),
608
+ action: "deleteRow"
609
+ }, {
610
+ id: "div3",
611
+ label: "",
612
+ action: "",
613
+ divider: !0
614
+ }, {
615
+ id: "addColLeft",
616
+ label: o("insertColumnLeft"),
617
+ action: "addColumnLeft"
618
+ }, {
619
+ id: "addColRight",
620
+ label: o("insertColumnRight"),
621
+ action: "addColumnRight"
622
+ }, {
623
+ id: "deleteCol",
624
+ label: o("deleteColumn"),
625
+ action: "deleteColumn"
626
+ }, {
627
+ id: "div4",
628
+ label: "",
629
+ action: "",
630
+ divider: !0
631
+ }, {
632
+ id: "mergeCells",
633
+ label: o("table.mergeCells"),
634
+ action: "mergeCells",
635
+ disabled: !n.canMergeCells
636
+ }, {
637
+ id: "splitCell",
638
+ label: o("table.splitCell"),
639
+ action: "splitCell",
640
+ disabled: !n.canSplitCell
641
+ }, {
642
+ id: "div5",
643
+ label: "",
644
+ action: "",
645
+ divider: !0
646
+ }, {
647
+ id: "selectTable",
648
+ label: o("table.selectTable"),
649
+ action: "selectTable"
650
+ }, {
651
+ id: "deleteTable",
652
+ label: o("table.deleteTable"),
653
+ action: "deleteTable"
654
+ }), e;
655
+ }), u = O(() => {
656
+ let e = n.position.x, t = n.position.y, r = l.value.filter((e) => !e.divider).length, i = l.value.filter((e) => e.divider).length, a = r * wr + i * 9;
657
+ return typeof window < "u" && (e + Cr + Tr > window.innerWidth && (e = window.innerWidth - Cr - Tr), t + a + Tr > window.innerHeight && (t = window.innerHeight - a - Tr)), {
658
+ position: "fixed",
659
+ left: `${e}px`,
660
+ top: `${t}px`,
661
+ zIndex: 400
662
+ };
663
+ });
664
+ function d(e) {
665
+ e && (a("action", e), a("close"));
666
+ }
667
+ function f(e) {
668
+ e.key === "Escape" && a("close");
669
+ }
670
+ return K(() => n.isOpen, (e) => {
671
+ e && I(() => c.value?.focus());
672
+ }), (t, n) => (z(), k(D, { to: "body" }, [e.isOpen ? (z(), j("div", {
673
+ key: 0,
674
+ class: "ctx-menu-backdrop",
675
+ onMousedown: n[0] ||= (e) => t.$emit("close"),
676
+ onContextmenu: n[1] ||= Y((e) => t.$emit("close"), ["prevent"])
677
+ }, null, 32)) : A("", !0), e.isOpen ? (z(), j("div", {
678
+ key: 1,
679
+ ref_key: "menuRef",
680
+ ref: c,
681
+ class: L(["ctx-menu", W(s)]),
682
+ style: R(u.value),
683
+ onContextmenu: n[2] ||= Y(() => {}, ["prevent"]),
684
+ onKeydown: f
685
+ }, [(z(!0), j(E, null, V(l.value, (e, t) => (z(), j("button", {
686
+ key: e.id || t,
687
+ class: L(["ctx-menu__item", {
688
+ "ctx-menu__item--disabled": e.disabled,
689
+ "ctx-menu__item--divider": e.divider,
690
+ "ctx-menu__item--emphasis": e.emphasis
691
+ }]),
692
+ disabled: e.disabled,
693
+ onMousedown: Y((t) => d(e.action), ["prevent"])
694
+ }, [
695
+ e.icon ? (z(), j("span", br, [N(i, { node: e.icon }, null, 8, ["node"])])) : A("", !0),
696
+ M("span", xr, U(e.label), 1),
697
+ e.shortcut ? (z(), j("span", Sr, U(e.shortcut), 1)) : A("", !0)
698
+ ], 42, yr))), 128))], 38)) : A("", !0)]));
699
+ }
700
+ }), [["__scopeId", "data-v-e71bb6e2"]]), Dr = /* @__PURE__ */ P({
701
+ __name: "DocxEditorOverlays",
702
+ props: {
703
+ readOnly: { type: Boolean },
704
+ contextMenu: {},
705
+ imageContextMenu: {},
706
+ imageContextMenuTextActions: {},
707
+ canOpenImageProperties: { type: Boolean },
708
+ customTextMenuItems: {}
709
+ },
710
+ emits: [
711
+ "context-menu-action",
712
+ "close-context-menu",
713
+ "image-wrap-select",
714
+ "close-image-context-menu",
715
+ "open-image-properties"
716
+ ],
717
+ setup(e, { emit: t }) {
718
+ let n = t;
719
+ return (t, r) => (z(), j(E, null, [N(Er, {
720
+ "is-open": e.contextMenu.isOpen,
721
+ position: e.contextMenu.position,
722
+ "has-selection": e.contextMenu.hasSelection,
723
+ "is-editable": !e.readOnly,
724
+ "in-table": e.contextMenu.inTable,
725
+ "on-image": e.contextMenu.onImage,
726
+ "can-merge-cells": e.contextMenu.canMergeCells,
727
+ "can-split-cell": e.contextMenu.canSplitCell,
728
+ "custom-items": e.customTextMenuItems,
729
+ onAction: r[0] ||= (e) => n("context-menu-action", e),
730
+ onClose: r[1] ||= (e) => n("close-context-menu")
731
+ }, null, 8, [
732
+ "is-open",
733
+ "position",
734
+ "has-selection",
735
+ "is-editable",
736
+ "in-table",
737
+ "on-image",
738
+ "can-merge-cells",
739
+ "can-split-cell",
740
+ "custom-items"
741
+ ]), N(vr, {
742
+ state: e.imageContextMenu,
743
+ "text-actions": e.imageContextMenuTextActions,
744
+ "can-open-properties": e.canOpenImageProperties,
745
+ onClose: r[2] ||= (e) => n("close-image-context-menu"),
746
+ onSelect: r[3] ||= (e) => n("image-wrap-select", e),
747
+ onTextAction: r[4] ||= (e) => n("context-menu-action", e),
748
+ onOpenProperties: r[5] ||= (e) => n("open-image-properties")
749
+ }, null, 8, [
750
+ "state",
751
+ "text-actions",
752
+ "can-open-properties"
753
+ ])], 64));
754
+ }
755
+ });
756
+ //#endregion
757
+ //#region src/composables/imageOverlayRect.ts
758
+ function Or(e) {
759
+ let t = Math.max(0, e.parentOffsetWidth - e.parentClientWidth) / 2, n = e.zoom || 1;
760
+ return {
761
+ left: (e.imageRect.left - e.parentRect.left - t + e.scrollLeft) / n,
762
+ top: (e.imageRect.top - e.parentRect.top + e.scrollTop) / n,
763
+ width: e.imageRect.width / n,
764
+ height: e.imageRect.height / n
765
+ };
766
+ }
767
+ //#endregion
768
+ //#region src/components/ImageSelectionOverlay.vue?vue&type=script&setup=true&lang.ts
769
+ var kr = ["data-handle", "onMousedown"], Ar = ["title"], jr = {
770
+ key: 0,
771
+ class: "image-overlay__dim"
772
+ }, Mr = {
773
+ key: 1,
774
+ class: "image-overlay__dim image-overlay__dim--rotate"
775
+ }, Nr = 4, Pr = 15, Fr = 250, Ir = 700, Lr = /*#__PURE__*/ l(/* @__PURE__ */ P({
776
+ __name: "ImageSelectionOverlay",
777
+ props: {
778
+ imageInfo: {},
779
+ zoom: {},
780
+ view: {}
781
+ },
782
+ emits: [
783
+ "deselect",
784
+ "interact-start",
785
+ "interact-end",
786
+ "context-menu"
787
+ ],
788
+ setup(e, { emit: t }) {
789
+ let { t: n } = r(), i = e, a = t, o = B(null), s = B(!1), c = B(!1), l = B(!1), u = B(0), d = B(0), f = B(0), p = B(null), m = "se", h = 0, g = 0, _ = 0, v = 0, y = null, b = null, x = null, S = null;
790
+ function C(e, t) {
791
+ if (!e) return null;
792
+ try {
793
+ let n = e.state.doc.nodeAt(t);
794
+ return n && n.type.name === "image" ? n : null;
795
+ } catch {
796
+ return null;
797
+ }
798
+ }
799
+ function ee(e) {
800
+ if (!e) return null;
801
+ let t = e.attrs.transform;
802
+ return typeof t == "string" ? t : null;
803
+ }
804
+ function te() {
805
+ return o.value?.closest(".docx-editor-vue__pages-viewport")?.querySelector(".docx-editor-vue__pages") ?? null;
806
+ }
807
+ function re() {
808
+ let e = i.imageInfo;
809
+ if (!e) return null;
810
+ if (e.element.isConnected) return e.element;
811
+ let t = te();
812
+ if (!t) return null;
813
+ let n = rt(t, e.pmPos);
814
+ return n ? Ke(n) : null;
815
+ }
816
+ function w() {
817
+ let e = re();
818
+ if (!e || !o.value) {
819
+ p.value = null;
820
+ return;
821
+ }
822
+ let t = o.value.offsetParent;
823
+ if (!(t instanceof HTMLElement)) {
824
+ p.value = null;
825
+ return;
826
+ }
827
+ let n = t.getBoundingClientRect();
828
+ p.value = Or({
829
+ imageRect: e.getBoundingClientRect(),
830
+ parentRect: n,
831
+ scrollLeft: t.scrollLeft,
832
+ scrollTop: t.scrollTop,
833
+ parentOffsetWidth: t.offsetWidth,
834
+ parentClientWidth: t.clientWidth,
835
+ zoom: i.zoom
836
+ });
837
+ }
838
+ let ie = null;
839
+ function ae() {
840
+ ie?.();
841
+ let e = 0, t = "", n = 0, r = 0, i = (a) => {
842
+ r === 0 && (r = a);
843
+ let o = a - r;
844
+ w();
845
+ let s = p.value, c = s ? `${s.left}|${s.top}|${s.width}|${s.height}` : "";
846
+ n = c === t ? n + 1 : 0, t = c, !(o >= Fr && n >= 2) && o < Ir && (e = requestAnimationFrame(i));
847
+ };
848
+ e = requestAnimationFrame(i);
849
+ let a = setTimeout(w, Fr);
850
+ ie = () => {
851
+ cancelAnimationFrame(e), clearTimeout(a);
852
+ };
853
+ }
854
+ K(() => i.imageInfo, (e, t, n) => {
855
+ if (!i.imageInfo) {
856
+ p.value = null;
857
+ return;
858
+ }
859
+ ae(), n(() => ie?.());
860
+ }, { immediate: !0 }), K(() => i.zoom, () => {
861
+ i.imageInfo && ae();
862
+ }), K(() => i.imageInfo, (e, t, n) => {
863
+ if (!i.imageInfo) return;
864
+ let r = () => {
865
+ b && cancelAnimationFrame(b), b = requestAnimationFrame(w);
866
+ }, a = o.value?.closest(".docx-editor-vue__pages-viewport");
867
+ a?.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", r, { passive: !0 });
868
+ let s = null, c = !1;
869
+ I(() => {
870
+ if (c || !i.imageInfo) return;
871
+ let e = te();
872
+ e && (s = new MutationObserver(() => ae()), s.observe(e, {
873
+ attributes: !0,
874
+ attributeFilter: ["style"]
875
+ }));
876
+ }), n(() => {
877
+ c = !0, a?.removeEventListener("scroll", r), window.removeEventListener("resize", r), s?.disconnect(), b && cancelAnimationFrame(b);
878
+ });
879
+ }, { immediate: !0 });
880
+ let T = O(() => s.value ? u.value : p.value?.width || 0), D = O(() => s.value ? d.value : p.value?.height || 0), oe = O(() => {
881
+ let e = p.value;
882
+ if (!e) return {
883
+ position: "absolute",
884
+ top: "0px",
885
+ left: "0px",
886
+ visibility: "hidden",
887
+ pointerEvents: "none"
888
+ };
889
+ let t = s.value ? u.value : e.width, n = s.value ? d.value : e.height, r = i.zoom || 1;
890
+ return {
891
+ position: "absolute",
892
+ left: `${e.left * r}px`,
893
+ top: `${e.top * r}px`,
894
+ width: `${t}px`,
895
+ height: `${n}px`,
896
+ transform: r === 1 ? void 0 : `scale(${r})`,
897
+ transformOrigin: "top left",
898
+ zIndex: ne.imageOverlay,
899
+ pointerEvents: "auto"
900
+ };
901
+ }), k = O(() => {
902
+ let e = T.value, t = D.value, n = `${e / 2 - 5}px`, r = `${t / 2 - 5}px`, i = `${e - 5}px`, a = `${t - 5}px`, o = "-5px";
903
+ return [
904
+ {
905
+ pos: "nw",
906
+ style: {
907
+ left: o,
908
+ top: o,
909
+ cursor: "nwse-resize"
910
+ }
911
+ },
912
+ {
913
+ pos: "n",
914
+ style: {
915
+ left: n,
916
+ top: o,
917
+ cursor: "ns-resize"
918
+ }
919
+ },
920
+ {
921
+ pos: "ne",
922
+ style: {
923
+ left: i,
924
+ top: o,
925
+ cursor: "nesw-resize"
926
+ }
927
+ },
928
+ {
929
+ pos: "e",
930
+ style: {
931
+ left: i,
932
+ top: r,
933
+ cursor: "ew-resize"
934
+ }
935
+ },
936
+ {
937
+ pos: "se",
938
+ style: {
939
+ left: i,
940
+ top: a,
941
+ cursor: "nwse-resize"
942
+ }
943
+ },
944
+ {
945
+ pos: "s",
946
+ style: {
947
+ left: n,
948
+ top: a,
949
+ cursor: "ns-resize"
950
+ }
951
+ },
952
+ {
953
+ pos: "sw",
954
+ style: {
955
+ left: o,
956
+ top: a,
957
+ cursor: "nesw-resize"
958
+ }
959
+ },
960
+ {
961
+ pos: "w",
962
+ style: {
963
+ left: o,
964
+ top: r,
965
+ cursor: "ew-resize"
966
+ }
967
+ }
968
+ ];
969
+ });
970
+ function se(e, t) {
971
+ !i.imageInfo || !p.value || (m = t, h = e.clientX, g = e.clientY, _ = p.value.width, v = p.value.height, y = { ...p.value }, u.value = Math.round(_), d.value = Math.round(v), s.value = !0, a("interact-start"), document.addEventListener("mousemove", ce), document.addEventListener("mouseup", le));
972
+ }
973
+ function ce(e) {
974
+ let t = i.zoom, n = (e.clientX - h) / t, r = (e.clientY - g) / t, a = !e.shiftKey, o = Qe(m, n, r, _, v, a);
975
+ u.value = Math.round(o.width), d.value = Math.round(o.height);
976
+ let s = y;
977
+ s && (p.value = {
978
+ left: m.includes("w") ? s.left + (s.width - o.width) : s.left,
979
+ top: m.includes("n") ? s.top + (s.height - o.height) : s.top,
980
+ width: s.width,
981
+ height: s.height
982
+ });
983
+ }
984
+ function le() {
985
+ document.removeEventListener("mousemove", ce), document.removeEventListener("mouseup", le), s.value = !1, y = null, a("interact-end");
986
+ let e = i.view, t = i.imageInfo;
987
+ if (!e || !t) {
988
+ w();
989
+ return;
990
+ }
991
+ let n = tt(e, t.pmPos, u.value, d.value);
992
+ n !== null && ve(n), I(() => w());
993
+ }
994
+ let N = 0, P = 0, F = 0, ue = 0, de = null, L = null;
995
+ function pe(e) {
996
+ if (!e) return 0;
997
+ let t = e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/)?.[1];
998
+ return t ? parseFloat(t) : 0;
999
+ }
1000
+ function me(e, t) {
1001
+ let n = /scaleX\(-1\)/.test(e || ""), r = /scaleY\(-1\)/.test(e || ""), i = [], a = (t % 360 + 360) % 360;
1002
+ return a !== 0 && i.push(`rotate(${a}deg)`), n && i.push("scaleX(-1)"), r && i.push("scaleY(-1)"), i.length > 0 ? i.join(" ") : null;
1003
+ }
1004
+ function H(e, t) {
1005
+ return Math.atan2(e - N, -(t - P)) * 180 / Math.PI;
1006
+ }
1007
+ function he(e) {
1008
+ if (!i.imageInfo) return;
1009
+ let t = i.imageInfo.element.getBoundingClientRect();
1010
+ N = t.left + t.width / 2, P = t.top + t.height / 2, de = ee(C(i.view, i.imageInfo.pmPos)), ue = pe(de), L = i.imageInfo.element.querySelector("img"), F = H(e.clientX, e.clientY), f.value = ue, l.value = !0, a("interact-start"), document.addEventListener("mousemove", G), document.addEventListener("mouseup", ge);
1011
+ }
1012
+ function G(e) {
1013
+ let t = H(e.clientX, e.clientY) - F, n = ue + t;
1014
+ e.shiftKey || (n = Math.round(n / Pr) * Pr), f.value = (n % 360 + 360) % 360, L && (L.style.transform = me(de, f.value) || "");
1015
+ }
1016
+ function ge() {
1017
+ document.removeEventListener("mousemove", G), document.removeEventListener("mouseup", ge), l.value = !1, a("interact-end");
1018
+ let e = i.view, t = i.imageInfo;
1019
+ try {
1020
+ let n = e && t ? C(e, t.pmPos) : null;
1021
+ e && t && n && (e.dispatch(e.state.tr.setNodeMarkup(t.pmPos, void 0, {
1022
+ ...n.attrs,
1023
+ transform: me(ee(n), f.value)
1024
+ })), ve(t.pmPos));
1025
+ } catch {} finally {
1026
+ L && (L.style.transform = ""), L = null, de = null;
1027
+ }
1028
+ I(() => w());
1029
+ }
1030
+ let q = null;
1031
+ function J(e) {
1032
+ if (!i.imageInfo || !p.value) return;
1033
+ let t = e.clientX, n = e.clientY, r = p.value, o = !1, s = (e) => {
1034
+ let s = e.clientX - t, l = e.clientY - n;
1035
+ if (!(!o && Math.sqrt(s * s + l * l) < Nr)) {
1036
+ if (!o) {
1037
+ o = !0, c.value = !0, a("interact-start"), q = document.createElement("div"), q.style.cssText = "position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);";
1038
+ let e = i.zoom;
1039
+ q.style.width = `${r.width * e}px`, q.style.height = `${r.height * e}px`, document.body.appendChild(q);
1040
+ }
1041
+ if (q) {
1042
+ let t = i.zoom;
1043
+ q.style.left = `${e.clientX - r.width * t / 2}px`, q.style.top = `${e.clientY - r.height * t / 2}px`;
1044
+ }
1045
+ }
1046
+ }, l = (e) => {
1047
+ document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", l), x = null, S = null, q &&= (q.remove(), null), c.value = !1, o && (a("interact-end"), _e(e.clientX, e.clientY));
1048
+ };
1049
+ x = s, S = l, document.addEventListener("mousemove", s), document.addEventListener("mouseup", l);
1050
+ }
1051
+ function _e(e, t) {
1052
+ let n = i.view, r = i.imageInfo;
1053
+ if (!n || !r) return;
1054
+ let a = C(n, r.pmPos);
1055
+ if (a) {
1056
+ if (nt(a)) {
1057
+ let a = (o.value?.closest(".docx-editor-vue__pages-viewport"))?.querySelectorAll(".layout-page");
1058
+ if (!a || a.length === 0) return;
1059
+ let s = null;
1060
+ for (let e of a) {
1061
+ let n = e.getBoundingClientRect();
1062
+ if (t >= n.top && t <= n.bottom) {
1063
+ s = e.querySelector(".layout-page-content");
1064
+ break;
1065
+ }
1066
+ }
1067
+ if (!s) {
1068
+ let e = a.item(a.length - 1);
1069
+ s = e ? e.querySelector(".layout-page-content") : null;
1070
+ }
1071
+ if (!s) return;
1072
+ let c = s.getBoundingClientRect(), l = i.zoom, u = He((e - c.left) / l), d = He((t - c.top) / l), f = $e(n, r.pmPos, u, d);
1073
+ f !== null && ve(f);
1074
+ } else {
1075
+ let i = te();
1076
+ if (!i) return;
1077
+ let a = Ze(i, e, t, 1);
1078
+ if (a == null || a < 0) return;
1079
+ let o = et(n, r.pmPos, a);
1080
+ o !== null && ve(o);
1081
+ }
1082
+ I(() => w());
1083
+ }
1084
+ }
1085
+ function ve(e) {
1086
+ let t = i.view;
1087
+ if (t) try {
1088
+ let n = Be.create(t.state.doc, e);
1089
+ t.dispatch(t.state.tr.setSelection(n));
1090
+ } catch {}
1091
+ }
1092
+ return fe(() => {
1093
+ document.removeEventListener("mousemove", ce), document.removeEventListener("mouseup", le), document.removeEventListener("mousemove", G), document.removeEventListener("mouseup", ge), x && document.removeEventListener("mousemove", x), S && document.removeEventListener("mouseup", S), q &&= (q.remove(), null), b && cancelAnimationFrame(b), ie?.();
1094
+ }), (t, r) => e.imageInfo ? (z(), j("div", {
1095
+ key: 0,
1096
+ ref_key: "overlayRootRef",
1097
+ ref: o,
1098
+ class: "image-overlay",
1099
+ style: R(oe.value),
1100
+ onMousedown: r[3] ||= Y(() => {}, ["stop"])
1101
+ }, [
1102
+ r[4] ||= M("div", { class: "image-overlay__border" }, null, -1),
1103
+ M("div", {
1104
+ class: "image-overlay__body",
1105
+ style: R({ cursor: c.value ? "grabbing" : "grab" }),
1106
+ onMousedown: r[0] ||= Y((e) => J(e), ["prevent", "stop"]),
1107
+ onContextmenu: r[1] ||= Y((e) => t.$emit("context-menu", e), ["prevent", "stop"])
1108
+ }, null, 36),
1109
+ (z(!0), j(E, null, V(k.value, (e) => (z(), j("div", {
1110
+ key: e.pos,
1111
+ class: "image-overlay__handle",
1112
+ style: R(e.style),
1113
+ "data-handle": e.pos,
1114
+ onMousedown: Y((t) => se(t, e.pos), ["prevent", "stop"])
1115
+ }, null, 44, kr))), 128)),
1116
+ r[5] ||= M("div", { class: "image-overlay__rotate-line" }, null, -1),
1117
+ M("div", {
1118
+ class: "image-overlay__rotate-handle",
1119
+ style: R({ left: `${T.value / 2 - 7}px` }),
1120
+ title: W(n)("imageOverlay.rotate"),
1121
+ onMousedown: r[2] ||= Y((e) => he(e), ["prevent", "stop"])
1122
+ }, null, 44, Ar),
1123
+ s.value ? (z(), j("div", jr, U(Math.round(u.value)) + " × " + U(Math.round(d.value)), 1)) : A("", !0),
1124
+ l.value ? (z(), j("div", Mr, U(Math.round(f.value)) + "° ", 1)) : A("", !0)
1125
+ ], 36)) : A("", !0);
1126
+ }
1127
+ }), [["__scopeId", "data-v-f24116b0"]]), Rr = ["title", "aria-label"], zr = /* @__PURE__ */ P({
1128
+ __name: "OutlineToggleButton",
1129
+ props: {
1130
+ leftOffset: {},
1131
+ topPx: { default: 24 }
1132
+ },
1133
+ emits: ["toggle"],
1134
+ setup(e) {
1135
+ let { t } = r();
1136
+ return (n, r) => (z(), j("button", {
1137
+ type: "button",
1138
+ class: "docx-outline-toggle docx-editor-vue__outline-toggle",
1139
+ style: R({
1140
+ left: e.leftOffset + "px",
1141
+ top: e.topPx + "px"
1142
+ }),
1143
+ title: W(t)("editor.showDocumentOutline"),
1144
+ "aria-label": W(t)("editor.showDocumentOutline"),
1145
+ onClick: r[0] ||= (e) => n.$emit("toggle"),
1146
+ onMousedown: r[1] ||= Y(() => {}, ["stop"])
1147
+ }, [N(p, {
1148
+ name: "format_list_bulleted",
1149
+ size: 20
1150
+ })], 44, Rr));
1151
+ }
1152
+ }), Br = /*#__PURE__*/ l(/* @__PURE__ */ P({
1153
+ __name: "PageIndicator",
1154
+ props: {
1155
+ currentPage: {},
1156
+ totalPages: {},
1157
+ visible: { type: Boolean }
1158
+ },
1159
+ setup(e) {
1160
+ let { t } = r();
1161
+ return (n, r) => (z(), j("div", {
1162
+ class: "docx-editor-vue__page-indicator",
1163
+ style: R({ opacity: +!!e.visible }),
1164
+ "aria-live": "polite",
1165
+ role: "status"
1166
+ }, U(W(t)("viewer.pageIndicator", {
1167
+ current: e.currentPage,
1168
+ total: e.totalPages
1169
+ })), 5));
1170
+ }
1171
+ }), [["__scopeId", "data-v-21d010d4"]]), Vr = ["data-folio-block-id"], Hr = ["data-folio-block-id", "title"], Ur = 2.5, Wr = 5, Gr = 6, Kr = 2, qr = 2, Jr = /*#__PURE__*/ l(/* @__PURE__ */ P({
1172
+ __name: "TemplateDirectivesOverlay",
1173
+ props: {
1174
+ getView: { type: Function },
1175
+ getPagesContainer: { type: Function },
1176
+ editorState: {},
1177
+ zoom: {},
1178
+ layout: {},
1179
+ blocks: {},
1180
+ measures: {}
1181
+ },
1182
+ setup(e) {
1183
+ let t = e, n = new Set(["if", "each"]), r = new Set(["endif", "endeach"]), i = (e) => e === "each" ? "each" : "if";
1184
+ function a(e) {
1185
+ let t = e - Gr - Ur - Kr;
1186
+ return t <= 0 ? 0 : Math.floor(t / Wr);
1187
+ }
1188
+ function o(e, t, n) {
1189
+ let r = a(n), i = Math.min(Math.max(0, e), r);
1190
+ return t - Gr - Ur - (r - i) * Wr;
1191
+ }
1192
+ function s(e, t) {
1193
+ if (t.length === 0) return e.bottom - e.top >= qr ? [e] : [];
1194
+ let n = [];
1195
+ for (let r of t) {
1196
+ let t = Math.max(e.top, r.top), i = Math.min(e.bottom, r.bottom);
1197
+ i - t >= qr && n.push({
1198
+ top: t,
1199
+ bottom: i
1200
+ });
1201
+ }
1202
+ return n;
1203
+ }
1204
+ function c(e) {
1205
+ let t = e.filter((e) => e.block && (n.has(e.kind) || r.has(e.kind))).slice().sort((e, t) => e.from - t.from), a = [], o = [];
1206
+ for (let e of t) {
1207
+ if (n.has(e.kind)) {
1208
+ o.push({
1209
+ range: e,
1210
+ depth: o.length
1211
+ });
1212
+ continue;
1213
+ }
1214
+ let t = e.kind === "endif" ? "if" : "each", r, s = -1;
1215
+ for (let e = o.length - 1; e >= 0; --e) {
1216
+ let n = o[e];
1217
+ if (n?.range.kind === t) {
1218
+ r = n, s = e;
1219
+ break;
1220
+ }
1221
+ }
1222
+ r && (o.length = s, a.push({
1223
+ blockId: r.range.from,
1224
+ kind: i(r.range.kind),
1225
+ depth: r.depth,
1226
+ openerFrom: r.range.from,
1227
+ closerFrom: e.from,
1228
+ closerTo: e.to,
1229
+ openerExpr: r.range.expr
1230
+ }));
1231
+ }
1232
+ return a;
1233
+ }
1234
+ function l(e, t) {
1235
+ let n = e === "each" ? "/each" : "/if";
1236
+ return t ? `${n} · ${t}` : n;
1237
+ }
1238
+ function u(e, t) {
1239
+ if (t === null) return null;
1240
+ let n = null, r = -Infinity;
1241
+ for (let i of e) t >= i.openerFrom && t <= i.closerTo && i.openerFrom > r && (r = i.openerFrom, n = i.blockId);
1242
+ return n;
1243
+ }
1244
+ function d(e, t, n) {
1245
+ let r = new Map(t.map((e) => [e.range.from, e])), i = [];
1246
+ for (let t of e) {
1247
+ let e = r.get(t.openerFrom)?.rects[0], a = r.get(t.closerFrom)?.rects[0];
1248
+ if (!e || !a) continue;
1249
+ let c = s({
1250
+ top: e.y,
1251
+ bottom: a.y + a.height
1252
+ }, n.pageBands);
1253
+ c.length !== 0 && i.push({
1254
+ blockId: t.blockId,
1255
+ kind: t.kind,
1256
+ railX: o(t.depth, n.contentLeft, n.marginWidth),
1257
+ segments: c
1258
+ });
1259
+ }
1260
+ return i;
1261
+ }
1262
+ let f = B([]), p = B([]), m = B(null), h = B(null), g = B(null), _ = 0, v = null;
1263
+ function y() {
1264
+ v !== null && cancelAnimationFrame(v), v = requestAnimationFrame(() => {
1265
+ v = null, b();
1266
+ });
1267
+ }
1268
+ async function b() {
1269
+ let e = ++_, n = t.getView(), r = t.getPagesContainer(), i = t.editorState;
1270
+ if (!n || !r || !i) {
1271
+ f.value = [], p.value = [], m.value = null, h.value = null;
1272
+ return;
1273
+ }
1274
+ let a = ot(i);
1275
+ if (a.length === 0) {
1276
+ f.value = [], p.value = [], m.value = null, h.value = null;
1277
+ return;
1278
+ }
1279
+ let o = Me(r, t.zoom), s = await Ne(a, {
1280
+ pagesContainer: r,
1281
+ zoom: t.zoom,
1282
+ layout: t.layout,
1283
+ blocks: t.blocks,
1284
+ measures: t.measures
1285
+ });
1286
+ e === _ && (f.value = a, h.value = i.selection.head, m.value = o, p.value = s);
1287
+ }
1288
+ K(() => [
1289
+ t.editorState,
1290
+ t.zoom,
1291
+ t.layout,
1292
+ t.blocks,
1293
+ t.measures
1294
+ ], () => y());
1295
+ let x = O(() => c(f.value)), S = O(() => m.value ? d(x.value, p.value, m.value) : []), C = O(() => {
1296
+ let e = /* @__PURE__ */ new Map();
1297
+ for (let t of x.value) e.set(t.openerFrom, t.blockId), e.set(t.closerFrom, t.blockId);
1298
+ return e;
1299
+ }), ee = O(() => {
1300
+ let e = /* @__PURE__ */ new Map();
1301
+ for (let t of x.value) e.set(t.closerFrom, l(t.kind, t.openerExpr));
1302
+ return e;
1303
+ }), te = O(() => u(x.value, h.value));
1304
+ function ne(e) {
1305
+ return e === g.value || e === te.value;
1306
+ }
1307
+ function re(e) {
1308
+ return e.block && (n.has(e.kind) || r.has(e.kind));
1309
+ }
1310
+ function w(e) {
1311
+ return e.block ? C.value.get(e.from) : void 0;
1312
+ }
1313
+ function ie(e) {
1314
+ return e.block ? ee.value.get(e.from) : void 0;
1315
+ }
1316
+ function ae(e) {
1317
+ let t = w(e), n = t !== void 0 && ne(t);
1318
+ return [
1319
+ "folio-template-directive",
1320
+ `folio-template-directive--${e.kind}`,
1321
+ { "folio-template-directive--block": re(e) },
1322
+ { "folio-template-directive--active": n }
1323
+ ];
1324
+ }
1325
+ function T(e) {
1326
+ if (!(e instanceof HTMLElement)) return null;
1327
+ let t = e.dataset.folioBlockId;
1328
+ return t === void 0 ? null : Number(t);
1329
+ }
1330
+ function D(e) {
1331
+ let t = T(e.target);
1332
+ t !== null && (g.value = t);
1333
+ }
1334
+ function oe(e) {
1335
+ let t = T(e.target);
1336
+ if (t === null) return;
1337
+ let n = T(e.relatedTarget);
1338
+ n !== t && g.value === t && (g.value = n);
1339
+ }
1340
+ return pe(() => y()), fe(() => {
1341
+ v !== null && (cancelAnimationFrame(v), v = null);
1342
+ }), (t, n) => (z(), j("div", {
1343
+ class: "folio-template-directives-overlay",
1344
+ "data-folio-template-directives-overlay": "",
1345
+ onPointerover: D,
1346
+ onPointerout: oe
1347
+ }, [(z(!0), j(E, null, V(S.value, (t) => (z(), j(E, { key: `rail:${t.blockId}` }, [(z(!0), j(E, null, V(t.segments, (n, r) => (z(), j("div", {
1348
+ key: `rail:${t.blockId}:${r}`,
1349
+ class: L([
1350
+ "folio-template-band-rail",
1351
+ `folio-template-band-rail--${t.kind}`,
1352
+ { "folio-template-band-rail--active": ne(t.blockId) }
1353
+ ]),
1354
+ "data-folio-block-id": t.blockId,
1355
+ style: R({
1356
+ position: "absolute",
1357
+ left: `${t.railX * e.zoom}px`,
1358
+ top: `${n.top * e.zoom}px`,
1359
+ width: `${Ur * e.zoom}px`,
1360
+ height: `${Math.max(0, n.bottom - n.top) * e.zoom}px`
1361
+ })
1362
+ }, null, 14, Vr))), 128))], 64))), 128)), (z(!0), j(E, null, V(p.value, (t, n) => (z(), j(E, { key: `d:${n}` }, [(z(!0), j(E, null, V(t.rects, (r, i) => (z(), j("span", {
1363
+ key: `d:${n}:${i}`,
1364
+ class: L(ae(t.range)),
1365
+ "data-folio-block-id": w(t.range),
1366
+ title: ie(t.range),
1367
+ style: R({
1368
+ position: "absolute",
1369
+ left: `${(r.x - 1) * e.zoom}px`,
1370
+ top: `${(r.y + 1) * e.zoom}px`,
1371
+ width: `${(r.width + 2) * e.zoom}px`,
1372
+ height: `${Math.max(0, r.height - 2) * e.zoom}px`
1373
+ })
1374
+ }, null, 14, Hr))), 128))], 64))), 128))], 32));
1375
+ }
1376
+ }), [["__scopeId", "data-v-142d2ac6"]]), Yr = ["href", "title"], Xr = ["title"], Zr = ["title"], Qr = ["title"], $r = { class: "docx-hyperlink-popup__edit-row" }, ei = ["placeholder", "onKeydown"], ti = { class: "docx-hyperlink-popup__edit-row" }, ni = ["onKeydown"], ri = ["disabled"], ii = /*#__PURE__*/ l(/* @__PURE__ */ P({
1377
+ __name: "HyperlinkPopup",
1378
+ props: {
1379
+ data: {},
1380
+ readOnly: { type: Boolean }
1381
+ },
1382
+ emits: [
1383
+ "navigate",
1384
+ "copy",
1385
+ "edit",
1386
+ "remove",
1387
+ "close"
1388
+ ],
1389
+ setup(e, { emit: t }) {
1390
+ let { t: n } = r(), i = e, a = t, o = B(!1), s = B(""), c = B(""), l = B(null), u = O(() => ({
1391
+ left: (i.data?.position.left ?? 0) + "px",
1392
+ top: (i.data?.position.top ?? 0) + "px"
1393
+ }));
1394
+ K(() => i.data?.href, () => {
1395
+ o.value = !1;
1396
+ });
1397
+ let d = null, f = null;
1398
+ function p() {
1399
+ f &&= (clearTimeout(f), null), d &&= (document.removeEventListener("mousedown", d), null);
1400
+ }
1401
+ K(() => i.data, (e) => {
1402
+ p(), e && (d = (e) => {
1403
+ let t = l.value, n = e.target;
1404
+ t && n instanceof Node && !t.contains(n) && a("close");
1405
+ }, f = setTimeout(() => {
1406
+ d && document.addEventListener("mousedown", d);
1407
+ }, 0));
1408
+ }, { immediate: !0 }), fe(p);
1409
+ function m() {
1410
+ i.data && (s.value = i.data.displayText, c.value = i.data.href, o.value = !0);
1411
+ }
1412
+ function h() {
1413
+ c.value.trim() && (a("edit", s.value, c.value), o.value = !1);
1414
+ }
1415
+ function g() {
1416
+ i.data && (a("copy", i.data.href), typeof navigator < "u" && navigator.clipboard && navigator.clipboard.writeText(i.data.href).catch(() => {}));
1417
+ }
1418
+ return (t, r) => e.data ? (z(), j("div", {
1419
+ key: 0,
1420
+ ref_key: "popupRef",
1421
+ ref: l,
1422
+ class: L(["docx-hyperlink-popup", { "docx-hyperlink-popup--edit": o.value }]),
1423
+ style: R(u.value),
1424
+ onMousedown: r[6] ||= Y(() => {}, ["stop"])
1425
+ }, [o.value ? (z(), j(E, { key: 1 }, [M("div", $r, [q(M("input", {
1426
+ class: "docx-hyperlink-popup__input",
1427
+ placeholder: W(n)("displayText"),
1428
+ "onUpdate:modelValue": r[2] ||= (e) => s.value = e,
1429
+ onKeydown: [J(Y(h, ["prevent"]), ["enter"]), r[3] ||= J((e) => t.$emit("close"), ["esc"])]
1430
+ }, null, 40, ei), [[G, s.value]])]), M("div", ti, [q(M("input", {
1431
+ class: "docx-hyperlink-popup__input",
1432
+ placeholder: "https://...",
1433
+ "onUpdate:modelValue": r[4] ||= (e) => c.value = e,
1434
+ onKeydown: [J(Y(h, ["prevent"]), ["enter"]), r[5] ||= J((e) => t.$emit("close"), ["esc"])]
1435
+ }, null, 40, ni), [[G, c.value]]), M("button", {
1436
+ class: "docx-hyperlink-popup__apply",
1437
+ disabled: !c.value.trim(),
1438
+ onClick: Y(h, ["prevent"])
1439
+ }, U(W(n)("common.apply")), 9, ri)])], 64)) : (z(), j(E, { key: 0 }, [
1440
+ r[10] ||= ce("<span class=\"docx-hyperlink-popup__icon\" aria-hidden data-v-7f0cecdf><svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-7f0cecdf><circle cx=\"12\" cy=\"12\" r=\"10\" data-v-7f0cecdf></circle><path d=\"M2 12h20\" data-v-7f0cecdf></path><path d=\"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z\" data-v-7f0cecdf></path></svg></span>", 1),
1441
+ M("a", {
1442
+ class: "docx-hyperlink-popup__url",
1443
+ href: e.data.href,
1444
+ title: e.data.href,
1445
+ onClick: r[0] ||= Y((n) => t.$emit("navigate", e.data.href), ["prevent"])
1446
+ }, U(e.data.href), 9, Yr),
1447
+ r[11] ||= M("span", { class: "docx-hyperlink-popup__sep" }, null, -1),
1448
+ M("button", {
1449
+ class: "docx-hyperlink-popup__btn",
1450
+ title: W(n)("copyLink"),
1451
+ onClick: Y(g, ["prevent"])
1452
+ }, [...r[7] ||= [M("svg", {
1453
+ width: "18",
1454
+ height: "18",
1455
+ viewBox: "0 0 24 24",
1456
+ fill: "none",
1457
+ stroke: "currentColor",
1458
+ "stroke-width": "2",
1459
+ "stroke-linecap": "round",
1460
+ "stroke-linejoin": "round"
1461
+ }, [M("rect", {
1462
+ x: "9",
1463
+ y: "9",
1464
+ width: "13",
1465
+ height: "13",
1466
+ rx: "2",
1467
+ ry: "2"
1468
+ }), M("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })], -1)]], 8, Xr),
1469
+ e.readOnly ? A("", !0) : (z(), j("button", {
1470
+ key: 0,
1471
+ class: "docx-hyperlink-popup__btn",
1472
+ title: W(n)("editLink"),
1473
+ onClick: Y(m, ["prevent"])
1474
+ }, [...r[8] ||= [M("svg", {
1475
+ width: "18",
1476
+ height: "18",
1477
+ viewBox: "0 0 24 24",
1478
+ fill: "none",
1479
+ stroke: "currentColor",
1480
+ "stroke-width": "2",
1481
+ "stroke-linecap": "round",
1482
+ "stroke-linejoin": "round"
1483
+ }, [M("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), M("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })], -1)]], 8, Zr)),
1484
+ e.readOnly ? A("", !0) : (z(), j("button", {
1485
+ key: 1,
1486
+ class: "docx-hyperlink-popup__btn",
1487
+ title: W(n)("removeLink"),
1488
+ onClick: r[1] ||= Y((e) => t.$emit("remove"), ["prevent"])
1489
+ }, [...r[9] ||= [ce("<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-7f0cecdf><path d=\"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71\" data-v-7f0cecdf></path><path d=\"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71\" data-v-7f0cecdf></path><line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"5\" data-v-7f0cecdf></line><line x1=\"2\" y1=\"8\" x2=\"5\" y2=\"8\" data-v-7f0cecdf></line><line x1=\"16\" y1=\"19\" x2=\"16\" y2=\"22\" data-v-7f0cecdf></line><line x1=\"19\" y1=\"16\" x2=\"22\" y2=\"16\" data-v-7f0cecdf></line></svg>", 1)]], 8, Qr))
1490
+ ], 64))], 38)) : A("", !0);
1491
+ }
1492
+ }), [["__scopeId", "data-v-7f0cecdf"]]);
1493
+ //#endregion
1494
+ //#region src/composables/commentMarks.ts
1495
+ function ai(e, t) {
1496
+ let n = Math.max(0, Math.min(t.from, e)), r = Math.max(n, Math.min(t.to, e));
1497
+ return n === r ? null : {
1498
+ from: n,
1499
+ to: r
1500
+ };
1501
+ }
1502
+ function oi({ docSize: e, capturedRange: t, currentRange: n, savedRange: r }) {
1503
+ let i = t.from === t.to ? n.from === n.to ? r && r.from !== r.to ? r : null : n : t;
1504
+ return i ? ai(e, i) : null;
1505
+ }
1506
+ function si(e, t, n, r) {
1507
+ let i = e.state.schema.marks.comment, a = ai(e.state.doc.content.size, t);
1508
+ if (!i || !a) return !1;
1509
+ let o = e.state.tr;
1510
+ return r?.replacePending && (o = o.removeMark(a.from, a.to, i.create({ commentId: ut }))), o = o.addMark(a.from, a.to, i.create({ commentId: n })), r?.selectEnd && (o = o.setSelection(Z.near(o.doc.resolve(a.to), -1))), e.dispatch(o), !0;
1511
+ }
1512
+ function ci(e, t) {
1513
+ let n = e.state.schema.marks.comment, r = ai(e.state.doc.content.size, t);
1514
+ !n || !r || e.dispatch(e.state.tr.removeMark(r.from, r.to, n.create({ commentId: ut })));
1515
+ }
1516
+ //#endregion
1517
+ //#region src/composables/useCommentLifecycle.ts
1518
+ var li = 408, ui = 12;
1519
+ function di(e) {
1520
+ let t = B(!1), n = B(null), r = B(null), i = B(null), a = B(null);
1521
+ function o(t) {
1522
+ let n = e.editorView.value, r = e.pagesContainer.value;
1523
+ if (!n || !r) return null;
1524
+ try {
1525
+ return n.coordsAtPos(t).top - r.getBoundingClientRect().top;
1526
+ } catch {
1527
+ return null;
1528
+ }
1529
+ }
1530
+ function s() {
1531
+ let n = e.editorView.value, i = e.pagesViewport.value;
1532
+ if (!n || !i || t.value || e.readOnly.value) {
1533
+ r.value = null;
1534
+ return;
1535
+ }
1536
+ let { from: o, to: s } = n.state.selection;
1537
+ if (o === s) {
1538
+ r.value = null;
1539
+ return;
1540
+ }
1541
+ a.value = {
1542
+ from: o,
1543
+ to: s
1544
+ };
1545
+ let c;
1546
+ try {
1547
+ c = n.coordsAtPos(o);
1548
+ } catch {
1549
+ r.value = null;
1550
+ return;
1551
+ }
1552
+ let l = i.getBoundingClientRect(), u = e.pagesContainer.value?.getBoundingClientRect(), d = u ? u.right - l.left + ui : l.width / 2 + li;
1553
+ r.value = {
1554
+ top: c.top - l.top,
1555
+ left: Math.max(16, Math.min(d, l.width - 16)),
1556
+ from: o,
1557
+ to: s
1558
+ };
1559
+ }
1560
+ function c() {
1561
+ let s = e.editorView.value;
1562
+ if (!s) return;
1563
+ let c = r.value, l = s.state.selection, u = oi({
1564
+ docSize: s.state.doc.content.size,
1565
+ capturedRange: c ? {
1566
+ from: c.from,
1567
+ to: c.to
1568
+ } : {
1569
+ from: 0,
1570
+ to: 0
1571
+ },
1572
+ currentRange: {
1573
+ from: l.from,
1574
+ to: l.to
1575
+ },
1576
+ savedRange: a.value
1577
+ });
1578
+ if (!u) {
1579
+ r.value = null;
1580
+ return;
1581
+ }
1582
+ if (!si(s, u, ut, { selectEnd: !0 })) {
1583
+ r.value = null, i.value = null;
1584
+ return;
1585
+ }
1586
+ i.value = u, n.value = o(u.from) ?? c?.top ?? null, e.showSidebar.value = !0, t.value = !0, r.value = null;
1587
+ }
1588
+ function l() {
1589
+ t.value = !1, i.value = null, n.value = null;
1590
+ }
1591
+ function u(t) {
1592
+ let n = e.editorView.value, r = i.value;
1593
+ if (!n || !r) return !1;
1594
+ let a = e.createComment(t);
1595
+ return si(n, r, a.id, { replacePending: !0 }) ? (e.pushComment(a), e.reLayout(), e.setActiveSidebarItem(`comment-${a.id}`), l(), !0) : !1;
1596
+ }
1597
+ function d() {
1598
+ let t = e.editorView.value;
1599
+ t && i.value && ci(t, i.value), l();
1600
+ }
1601
+ return {
1602
+ isAddingComment: t,
1603
+ addCommentYPosition: n,
1604
+ floatingCommentButton: r,
1605
+ updateFloatingButton: s,
1606
+ startAddComment: c,
1607
+ handleAddComment: u,
1608
+ handleCancelAddComment: d
1609
+ };
1610
+ }
1611
+ //#endregion
1612
+ //#region src/composables/useCommentManagement.ts
1613
+ function fi(e) {
1614
+ let t = dt(), n = B([]), r = B(!1);
1615
+ function i() {
1616
+ r.value = !0;
1617
+ }
1618
+ function a() {
1619
+ r.value = !1;
1620
+ }
1621
+ let o = O(() => e.commentsProp() !== void 0), s = O(() => o.value ? e.commentsProp() ?? [] : n.value);
1622
+ function c(t) {
1623
+ o.value || (n.value = t), e.onCommentsChange(t);
1624
+ }
1625
+ function l(e) {
1626
+ i(), c([...s.value, e]);
1627
+ }
1628
+ function u(n, r) {
1629
+ return ft(t, s.value, e.editorView.value), pt(t, n, e.author(), r);
1630
+ }
1631
+ function d() {
1632
+ if (a(), o.value) return;
1633
+ let n = e.getDocument()?.package.document.comments;
1634
+ ft(t, n, e.editorView.value), c(n && n.length > 0 ? n : []);
1635
+ }
1636
+ function f(e, t) {
1637
+ l(u(t, e));
1638
+ }
1639
+ function p(e) {
1640
+ i(), c(s.value.map((t) => t.id === e ? {
1641
+ ...t,
1642
+ done: !0
1643
+ } : t));
1644
+ }
1645
+ function m(e) {
1646
+ i(), c(s.value.map((t) => t.id === e ? {
1647
+ ...t,
1648
+ done: !1
1649
+ } : t));
1650
+ }
1651
+ function h(e) {
1652
+ i(), c(s.value.filter((t) => t.id !== e && t.parentId !== e));
1653
+ }
1654
+ function g(e, t) {
1655
+ l(u(t, e));
1656
+ }
1657
+ function _(t, n) {
1658
+ let r = e.editorView.value;
1659
+ if (!r) return;
1660
+ let i = mt(r, t);
1661
+ i && (n ? gt : yt)(i.from, i.to)(r.state, r.dispatch);
1662
+ }
1663
+ function v(e) {
1664
+ _(e, !0);
1665
+ }
1666
+ function y(e) {
1667
+ _(e, !1);
1668
+ }
1669
+ function b(t, n) {
1670
+ let r = e.editorView.value;
1671
+ r && gt(t, n)(r.state, r.dispatch);
1672
+ }
1673
+ function x(t, n) {
1674
+ let r = e.editorView.value;
1675
+ r && yt(t, n)(r.state, r.dispatch);
1676
+ }
1677
+ return {
1678
+ comments: s,
1679
+ commentsDirty: O(() => r.value),
1680
+ clearCommentsDirty: a,
1681
+ createComment: u,
1682
+ pushComment: l,
1683
+ setComments: c,
1684
+ seedFromDocument: d,
1685
+ handleReply: f,
1686
+ handleResolve: p,
1687
+ handleUnresolve: m,
1688
+ handleDelete: h,
1689
+ handleTrackedChangeReply: g,
1690
+ handleAcceptChangeById: v,
1691
+ handleRejectChangeById: y,
1692
+ handleAcceptChange: b,
1693
+ handleRejectChange: x
1694
+ };
1695
+ }
1696
+ //#endregion
1697
+ //#region src/utils/imageClipboard.ts
1698
+ function pi(e, t, n) {
1699
+ let r = bt(e.state), i = e.state.schema.marks.insertion;
1700
+ if (!r || !i) return;
1701
+ let a = t.selection.from, o = a - n.nodeSize;
1702
+ o < 0 || t.addMark(o, a, i.create({
1703
+ revisionId: r.id,
1704
+ author: r.author,
1705
+ date: r.date
1706
+ }));
1707
+ }
1708
+ function mi(e, t) {
1709
+ let n = e.state.doc.nodeAt(t);
1710
+ if (!n || n.type.name !== "image") return;
1711
+ let r = n.attrs.src;
1712
+ if (typeof r != "string") return;
1713
+ let i = `<img src="${r}" data-pm-image="true" data-width="${String(n.attrs.width ?? "")}" data-height="${String(n.attrs.height ?? "")}" data-wrap-type="${String(n.attrs.wrapType ?? "")}" data-display-mode="${String(n.attrs.displayMode ?? "")}" data-rid="${String(n.attrs.rId ?? "")}" />`, a = new ClipboardItem({
1714
+ "text/html": new Blob([i], { type: "text/html" }),
1715
+ "text/plain": new Blob(["[image]"], { type: "text/plain" })
1716
+ });
1717
+ navigator.clipboard.write([a]).catch(() => {
1718
+ let e = document.createElement("textarea");
1719
+ e.value = i, document.body.appendChild(e), e.select(), document.execCommand("copy"), document.body.removeChild(e);
1720
+ });
1721
+ }
1722
+ function hi(e) {
1723
+ return new Promise((t, n) => {
1724
+ let r = new FileReader();
1725
+ r.onload = () => {
1726
+ typeof r.result == "string" ? t(r.result) : n(/* @__PURE__ */ Error("Failed to read blob as data URL"));
1727
+ }, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to read blob")), r.readAsDataURL(e);
1728
+ });
1729
+ }
1730
+ function gi(e) {
1731
+ return new Promise((t) => {
1732
+ let n = new Image();
1733
+ n.onload = () => t({
1734
+ width: n.naturalWidth,
1735
+ height: n.naturalHeight
1736
+ }), n.onerror = () => t({
1737
+ width: 200,
1738
+ height: 200
1739
+ }), n.src = e;
1740
+ });
1741
+ }
1742
+ function _i(e, t, n, r) {
1743
+ let i = e.state.schema.nodes.image;
1744
+ if (!i) return;
1745
+ let a = i.create({
1746
+ src: t,
1747
+ width: n,
1748
+ height: r,
1749
+ rId: `rId_img_${Date.now()}`,
1750
+ wrapType: "inline",
1751
+ displayMode: "inline"
1752
+ }), o = e.state.tr.replaceSelectionWith(a);
1753
+ pi(e, o, a), e.dispatch(o);
1754
+ }
1755
+ async function vi(e) {
1756
+ try {
1757
+ let t = await navigator.clipboard.read();
1758
+ for (let n of t) {
1759
+ let t = n.types.find((e) => e.startsWith("image/"));
1760
+ if (t) {
1761
+ let r = await hi(await n.getType(t)), i = await gi(r), a = i.width, o = i.height;
1762
+ a > 612 && (o = Math.round(612 / a * o), a = 612), _i(e, r, a, o);
1763
+ return;
1764
+ }
1765
+ if (n.types.includes("text/html")) {
1766
+ let t = await (await n.getType("text/html")).text(), r = /<img[^>]+src="(?<src>[^"]+)"[^>]*>/iu.exec(t)?.groups?.src;
1767
+ if (r) {
1768
+ let n = /data-width="(?<w>\d+)"/u.exec(t)?.groups?.w, i = /data-height="(?<h>\d+)"/u.exec(t)?.groups?.h, a = n ? Number(n) : 200, o = i ? Number(i) : 200;
1769
+ _i(e, r, a || 200, o || 200);
1770
+ return;
1771
+ }
1772
+ }
1773
+ if (n.types.includes("text/plain")) {
1774
+ let t = await (await n.getType("text/plain")).text();
1775
+ if (t && t !== "[image]") {
1776
+ let { from: n } = e.state.selection;
1777
+ e.dispatch(e.state.tr.insertText(t, n));
1778
+ }
1779
+ return;
1780
+ }
1781
+ }
1782
+ } catch {
1783
+ let t = await navigator.clipboard?.readText();
1784
+ if (t) {
1785
+ let { from: n } = e.state.selection;
1786
+ e.dispatch(e.state.tr.insertText(t, n));
1787
+ }
1788
+ }
1789
+ }
1790
+ function yi(e, t) {
1791
+ let n = e.state.doc.nodeAt(t);
1792
+ if (!n || n.type.name !== "image") return;
1793
+ let r = document.createElement("input");
1794
+ r.type = "file", r.accept = "image/*", r.onchange = async () => {
1795
+ let i = r.files?.[0];
1796
+ if (!i) return;
1797
+ let a = await hi(i), o = await gi(a), s = n.attrs.width, c = n.attrs.height, l = typeof s == "number" ? s : o.width, u = typeof c == "number" ? c : o.height, d = Math.min(l / o.width, u / o.height), f = Math.round(o.width * d), p = Math.round(o.height * d);
1798
+ try {
1799
+ let r = e.state.tr.setNodeMarkup(t, void 0, {
1800
+ ...n.attrs,
1801
+ src: a,
1802
+ width: f,
1803
+ height: p,
1804
+ rId: `rId_img_${Date.now()}`
1805
+ });
1806
+ e.dispatch(r);
1807
+ } catch {}
1808
+ }, r.click();
1809
+ }
1810
+ //#endregion
1811
+ //#region src/composables/useContextMenus.ts
1812
+ var bi = new Set([
1813
+ "inline",
1814
+ "square",
1815
+ "tight",
1816
+ "through",
1817
+ "topAndBottom",
1818
+ "behind",
1819
+ "inFront"
1820
+ ]);
1821
+ function xi(e) {
1822
+ return typeof e == "string" && bi.has(e);
1823
+ }
1824
+ function Si(e) {
1825
+ return xi(e) ? e : "inline";
1826
+ }
1827
+ function Ci(e) {
1828
+ return e === "left" || e === "right" || e === "none" ? e : null;
1829
+ }
1830
+ function wi(e) {
1831
+ let { t } = r(), n = B({
1832
+ isOpen: !1,
1833
+ position: {
1834
+ x: 0,
1835
+ y: 0
1836
+ },
1837
+ hasSelection: !1,
1838
+ inTable: !1,
1839
+ onImage: !1,
1840
+ canMergeCells: !1,
1841
+ canSplitCell: !1
1842
+ }), i = B(null), a = B({
1843
+ from: 0,
1844
+ to: 0
1845
+ }), o = O(() => (e.customContextMenuItems?.() ?? []).filter((e) => !e.requiresSelection || n.value.hasSelection)), s = O(() => [
1846
+ {
1847
+ action: "cut",
1848
+ label: t("contextMenu.cut"),
1849
+ shortcut: t("contextMenu.cutShortcut")
1850
+ },
1851
+ {
1852
+ action: "copy",
1853
+ label: t("contextMenu.copy"),
1854
+ shortcut: t("contextMenu.copyShortcut")
1855
+ },
1856
+ {
1857
+ action: "paste",
1858
+ label: t("contextMenu.paste"),
1859
+ shortcut: t("contextMenu.pasteShortcut"),
1860
+ dividerAfter: !0
1861
+ },
1862
+ {
1863
+ action: "delete",
1864
+ label: t("contextMenu.delete"),
1865
+ shortcut: t("contextMenu.deleteShortcut")
1866
+ }
1867
+ ]);
1868
+ function c(e, t) {
1869
+ t(e.state, (t) => e.dispatch(t), e);
1870
+ }
1871
+ function l(t, n, r, i, a) {
1872
+ let o = i === "inline" ? We(t, e.zoom.value) : void 0;
1873
+ return {
1874
+ open: !0,
1875
+ position: r,
1876
+ pmPos: n,
1877
+ currentWrapType: i,
1878
+ currentCssFloat: a,
1879
+ ...o !== void 0 && { inlinePositionEmu: o }
1880
+ };
1881
+ }
1882
+ function u(t) {
1883
+ let r = e.editorView.value;
1884
+ if (!r) return;
1885
+ let o = Ke(t.target);
1886
+ if (o) {
1887
+ let a = Number(o.dataset.pmStart);
1888
+ if (!Number.isNaN(a)) {
1889
+ try {
1890
+ let e = Be.create(r.state.doc, a);
1891
+ r.dispatch(r.state.tr.setSelection(e));
1892
+ } catch {}
1893
+ e.selectedImage.value = {
1894
+ element: o,
1895
+ pmPos: a,
1896
+ width: o.offsetWidth,
1897
+ height: o.offsetHeight
1898
+ }, e.clearOverlay();
1899
+ let s = r.state.doc.nodeAt(a);
1900
+ if (s && s.type.name === "image") {
1901
+ i.value = l(o, a, {
1902
+ x: t.clientX,
1903
+ y: t.clientY
1904
+ }, Si(s.attrs.wrapType), Ci(s.attrs.cssFloat)), n.value.isOpen = !1;
1905
+ return;
1906
+ }
1907
+ }
1908
+ }
1909
+ {
1910
+ let { from: n, to: i } = r.state.selection, a = e.resolvePos(t.clientX, t.clientY);
1911
+ if (a !== null && (a < n || a > i)) try {
1912
+ e.setPmSelection(a);
1913
+ } catch {}
1914
+ }
1915
+ let s = lt(r.state), { empty: c, from: u, to: d } = r.state.selection;
1916
+ a.value = {
1917
+ from: u,
1918
+ to: d
1919
+ }, i.value &&= null, n.value = {
1920
+ isOpen: !0,
1921
+ position: {
1922
+ x: t.clientX,
1923
+ y: t.clientY
1924
+ },
1925
+ hasSelection: !c,
1926
+ inTable: s.isInTable,
1927
+ onImage: !!o,
1928
+ canMergeCells: !!s.hasMultiCellSelection,
1929
+ canSplitCell: !!s.canSplitCell
1930
+ };
1931
+ }
1932
+ function d(t) {
1933
+ let r = e.editorView.value, a = e.selectedImage.value;
1934
+ if (!r || !a) return;
1935
+ let o = r.state.doc.nodeAt(a.pmPos);
1936
+ !o || o.type.name !== "image" || (i.value = l(a.element, a.pmPos, {
1937
+ x: t.clientX,
1938
+ y: t.clientY
1939
+ }, Si(o.attrs.wrapType), Ci(o.attrs.cssFloat)), n.value.isOpen = !1);
1940
+ }
1941
+ function f(t) {
1942
+ let n = e.editorView.value, r = i.value;
1943
+ if (!n || !r) return;
1944
+ let a = r.inlinePositionEmu && t !== "inline" ? { initialPositionEmu: r.inlinePositionEmu } : void 0, o = e.getCommands().setImageWrapType;
1945
+ o && (c(n, o(r.pmPos, t, a)), n.focus());
1946
+ }
1947
+ function p(t) {
1948
+ let n = e.editorView.value;
1949
+ if (!n) return;
1950
+ let r = e.getCommands();
1951
+ if (t.startsWith("custom:")) {
1952
+ let r = a.value, i = r.from === r.to ? {
1953
+ from: n.state.selection.from,
1954
+ to: n.state.selection.to
1955
+ } : r;
1956
+ e.onCustomContextAction?.(t.slice(7), i), n.focus();
1957
+ return;
1958
+ }
1959
+ switch (t) {
1960
+ case "cut":
1961
+ if (e.selectedImage.value) {
1962
+ let t = e.selectedImage.value.pmPos;
1963
+ mi(n, t);
1964
+ let r = n.state.doc.nodeAt(t);
1965
+ r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
1966
+ } else n.focus(), document.execCommand("cut");
1967
+ break;
1968
+ case "copy":
1969
+ e.selectedImage.value ? mi(n, e.selectedImage.value.pmPos) : (n.focus(), document.execCommand("copy"));
1970
+ break;
1971
+ case "paste":
1972
+ vi(n);
1973
+ break;
1974
+ case "pasteAsPlainText":
1975
+ navigator.clipboard.readText().then((e) => {
1976
+ e && n.dispatch(n.state.tr.insertText(e).scrollIntoView());
1977
+ }).catch(() => {});
1978
+ break;
1979
+ case "delete": {
1980
+ let { from: e, to: t } = n.state.selection;
1981
+ e !== t && n.dispatch(n.state.tr.delete(e, t));
1982
+ break;
1983
+ }
1984
+ case "selectAll": {
1985
+ let e = Ve.create(n.state.doc, 0, n.state.doc.content.size);
1986
+ n.dispatch(n.state.tr.setSelection(e));
1987
+ break;
1988
+ }
1989
+ case "imageProperties":
1990
+ e.selectedImage.value && (e.showImageProperties.value = !0);
1991
+ break;
1992
+ case "replaceImage":
1993
+ e.selectedImage.value && yi(n, e.selectedImage.value.pmPos);
1994
+ break;
1995
+ case "deleteImage":
1996
+ if (e.selectedImage.value) {
1997
+ let t = e.selectedImage.value.pmPos, r = n.state.doc.nodeAt(t);
1998
+ r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
1999
+ }
2000
+ break;
2001
+ case "addRowAbove":
2002
+ case "addRowBelow":
2003
+ case "deleteRow":
2004
+ case "addColumnLeft":
2005
+ case "addColumnRight":
2006
+ case "deleteColumn":
2007
+ case "mergeCells":
2008
+ case "splitCell":
2009
+ case "selectTable":
2010
+ case "deleteTable": {
2011
+ let e = r[t];
2012
+ e && c(n, e());
2013
+ break;
2014
+ }
2015
+ }
2016
+ n.focus();
2017
+ }
2018
+ return {
2019
+ contextMenu: n,
2020
+ imageContextMenu: i,
2021
+ imageContextMenuTextActions: s,
2022
+ customTextMenuItems: o,
2023
+ handleContextMenu: u,
2024
+ handleSelectedImageContextMenu: d,
2025
+ handleImageWrapSelect: f,
2026
+ handleContextMenuAction: p
2027
+ };
2028
+ }
2029
+ //#endregion
2030
+ //#region src/composables/useDocumentLifecycle.ts
2031
+ function Ti(e) {
2032
+ async function t(t) {
2033
+ e.sidebarAutoOpenedRef.value = !1, await e.loadDocumentBuffer(t);
2034
+ }
2035
+ function n(t) {
2036
+ e.sidebarAutoOpenedRef.value = !1, e.loadDocument(t);
2037
+ }
2038
+ K(e.documentBuffer, (e) => {
2039
+ e && t(e);
2040
+ }), K(e.document, (e) => {
2041
+ e && n(e);
2042
+ }), pe(async () => {
2043
+ await I();
2044
+ let r = e.documentBuffer(), i = e.document();
2045
+ r ? await t(r) : i && n(i);
2046
+ });
2047
+ }
2048
+ //#endregion
2049
+ //#region src/utils/aiEditRange.ts
2050
+ var Ei = ({ blockId: e, doc: t, snapshot: n }) => {
2051
+ let r = Kt(e);
2052
+ if (r !== null) {
2053
+ let e = Ut(t, r);
2054
+ if (e !== null) return {
2055
+ from: e.from,
2056
+ to: e.to
2057
+ };
2058
+ }
2059
+ let i = n ?? Ht(t), a = i.anchors[e] ?? Di(e, i);
2060
+ return a ? Oi(t.content.size, a) : null;
2061
+ }, Di = (e, t) => {
2062
+ let n = qt(e);
2063
+ if (n === null) return;
2064
+ let r = t.blocks.at(n - 1);
2065
+ return r ? t.anchors[r.id] : void 0;
2066
+ };
2067
+ function Oi(e, t) {
2068
+ return {
2069
+ from: Math.min(Math.max(t.from, 0), e),
2070
+ to: Math.min(Math.max(t.to, 0), e)
2071
+ };
2072
+ }
2073
+ //#endregion
2074
+ //#region src/composables/useDocxEditorRefApi.ts
2075
+ function ki(e) {
2076
+ function t() {
2077
+ e.onPrint?.(), window.print();
2078
+ }
2079
+ async function n(t) {
2080
+ let n = await e.save(t);
2081
+ if (!n) return null;
2082
+ let r = await n.arrayBuffer();
2083
+ return e.clearCommentsDirty(), e.onSave?.(r), r;
2084
+ }
2085
+ function r(t, n) {
2086
+ let r = e.pagesRef.value;
2087
+ if (!r) return !1;
2088
+ let i = Ft(r, t), a = i.at(0);
2089
+ return a ? (a.scrollIntoView({
2090
+ block: "center",
2091
+ behavior: "smooth"
2092
+ }), n?.highlight && Q(i, n.highlight), !0) : !1;
2093
+ }
2094
+ function i() {
2095
+ return e.zoom.value;
2096
+ }
2097
+ function a() {
2098
+ return e.layout.value?.pages.length ?? 0;
2099
+ }
2100
+ function o() {
2101
+ let t = e.layout.value, n = e.editorView.value;
2102
+ if (!t || !n) return 0;
2103
+ let r = Pt(t, n.state.selection.from);
2104
+ return r == null ? 0 : r + 1;
2105
+ }
2106
+ function s(t) {
2107
+ if (!Number.isInteger(t) || t < 1) return;
2108
+ let n = e.pagesViewportRef.value, r = e.pagesRef.value?.querySelector(`[data-page-number="${t}"]`);
2109
+ if (!n || !r) return;
2110
+ let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
2111
+ n.scrollTo({
2112
+ top: a.top - i.top + n.scrollTop - 24,
2113
+ behavior: "smooth"
2114
+ });
2115
+ }
2116
+ return { exposed: {
2117
+ getDocument: e.getDocument,
2118
+ hasPendingChanges: () => e.editorView.value ? e.isDirty.value || e.commentsDirty.value : !1,
2119
+ getEditorRef: () => null,
2120
+ getEditor: () => e.editor,
2121
+ save: n,
2122
+ setZoom: e.setZoom,
2123
+ getZoom: i,
2124
+ focus: e.focus,
2125
+ getCurrentPage: o,
2126
+ getTotalPages: a,
2127
+ scrollToPage: s,
2128
+ scrollToParaId: r,
2129
+ openPrintPreview: () => t(),
2130
+ print: t,
2131
+ loadDocument: e.loadDocument,
2132
+ loadDocumentBuffer: e.loadDocumentBuffer,
2133
+ ensureEditorView: () => e.editor.ensureView(),
2134
+ createAIEditSnapshot: () => {
2135
+ let t = e.editorView.value;
2136
+ return t ? At(t.state.doc) : null;
2137
+ },
2138
+ applyAIEditOperations: ({ snapshot: t, operations: n, mode: r = "tracked-changes", author: i = e.author() }) => {
2139
+ let a = e.editorView.value;
2140
+ return a ? Ot({
2141
+ view: a,
2142
+ snapshot: t,
2143
+ operations: n,
2144
+ mode: r,
2145
+ author: i,
2146
+ createCommentId: e.createAIEditComment
2147
+ }) : {
2148
+ applied: [],
2149
+ skipped: n.map((e) => ({
2150
+ id: e.id,
2151
+ reason: "unsupportedBlock"
2152
+ }))
2153
+ };
2154
+ },
2155
+ acceptAIEditOperation: (t) => {
2156
+ let n = e.editorView.value;
2157
+ return n ? ht(t)(n.state, n.dispatch) : !1;
2158
+ },
2159
+ rejectAIEditOperation: (t) => {
2160
+ let n = e.editorView.value;
2161
+ return n ? vt(t)(n.state, n.dispatch) : !1;
2162
+ },
2163
+ undo: () => e.editor.undo(),
2164
+ redo: () => e.editor.redo(),
2165
+ scrollToAIEditOperation: (t) => {
2166
+ let n = e.editorView.value;
2167
+ if (!n) return !1;
2168
+ let r = _t(n.state, t);
2169
+ if (!r) return !1;
2170
+ let { from: i, to: a } = Oi(n.state.doc.content.size, r), o = n.state.doc.resolve(i), s = n.state.doc.resolve(a);
2171
+ return n.dispatch(n.state.tr.setSelection(Ve.between(o, s))), requestAnimationFrame(() => e.scrollVisiblePositionIntoView(i)), !0;
2172
+ },
2173
+ scrollToBlock: (t, n) => {
2174
+ let r = e.editorView.value;
2175
+ if (!r) return !1;
2176
+ let i = Ei({
2177
+ blockId: t,
2178
+ doc: r.state.doc,
2179
+ snapshot: n
2180
+ });
2181
+ if (i === null) return !1;
2182
+ let { from: a, to: o } = i, s = r.state.doc.resolve(a), c = r.state.doc.resolve(o);
2183
+ return r.dispatch(r.state.tr.setSelection(Ve.between(s, c))), requestAnimationFrame(() => e.scrollVisiblePositionIntoView(a)), !0;
2184
+ },
2185
+ getContentControls: (t = {}) => {
2186
+ let n = e.editorView.value;
2187
+ return n ? Lt(n.state.doc, t).map((e) => ({
2188
+ properties: It(e.node),
2189
+ path: e.path,
2190
+ pmPos: e.pos
2191
+ })) : [];
2192
+ },
2193
+ scrollToContentControl: (t) => {
2194
+ let n = e.editorView.value;
2195
+ if (!n) return !1;
2196
+ let r = $(n.state.doc, t);
2197
+ if (!r) return !1;
2198
+ let i = r.pos + 1, a = n.state.doc.resolve(i);
2199
+ return n.dispatch(n.state.tr.setSelection(Ve.near(a))), requestAnimationFrame(() => e.scrollVisiblePositionIntoView(i)), !0;
2200
+ },
2201
+ setContentControlContent: (t, n, r = {}) => {
2202
+ let i = e.editorView.value;
2203
+ if (!i) return !1;
2204
+ let a = typeof n == "string" ? zt(i.state, t, n, r) : Vt(i.state, t, n, r);
2205
+ return a ? (i.dispatch(a), !0) : !1;
2206
+ },
2207
+ setContentControlValue: (t, n, r = {}) => {
2208
+ let i = e.editorView.value;
2209
+ if (!i) return !1;
2210
+ let a = Bt(i.state, t, n, r);
2211
+ return a ? (i.dispatch(a), !0) : !1;
2212
+ },
2213
+ removeContentControl: (t, n = {}) => {
2214
+ let r = e.editorView.value;
2215
+ if (!r) return !1;
2216
+ let i = Rt(r.state, t, n);
2217
+ return i ? (r.dispatch(i), !0) : !1;
2218
+ }
2219
+ } };
2220
+ }
2221
+ //#endregion
2222
+ //#region src/composables/useFormattingActions.ts
2223
+ function Ai(e) {
2224
+ let t = () => e.activeView?.value ?? e.editorView.value;
2225
+ function n() {
2226
+ let e = t();
2227
+ e && (ct(e.state, e.dispatch, e), e.focus());
2228
+ }
2229
+ function r(n) {
2230
+ let r = t();
2231
+ if (!r) return;
2232
+ let i = e.getDocument(), a = i?.package?.styles;
2233
+ if (a) {
2234
+ let e = _e(a).resolveParagraphStyle(n), t = { numbering: i?.package?.numbering ? tn(i.package.numbering) : null };
2235
+ e.paragraphFormatting && (t.paragraphFormatting = e.paragraphFormatting), e.runFormatting && (t.runFormatting = e.runFormatting), Xt(n, t)(r.state, (e) => r.dispatch(e));
2236
+ } else Xt(n)(r.state, (e) => r.dispatch(e));
2237
+ r.focus();
2238
+ }
2239
+ function i() {
2240
+ let t = e.editorView.value;
2241
+ t && (nn(t.state, (e) => t.dispatch(e), t), t.focus());
2242
+ }
2243
+ function a() {
2244
+ let t = e.editorView.value;
2245
+ t && (an(t.state, (e) => t.dispatch(e), t), t.focus());
2246
+ }
2247
+ function o() {
2248
+ let t = e.editorView.value;
2249
+ t && (rn(t.state, (e) => t.dispatch(e), t), t.focus());
2250
+ }
2251
+ function s(e) {
2252
+ let n = t();
2253
+ if (!n) return;
2254
+ let { from: r } = n.state.selection, i = n.state.tr.insertText(e, r);
2255
+ n.dispatch(i.scrollIntoView()), n.focus();
2256
+ }
2257
+ return {
2258
+ handleClearFormatting: n,
2259
+ handleApplyStyle: r,
2260
+ handleInsertPageBreak: i,
2261
+ handleInsertSectionBreakNextPage: a,
2262
+ handleInsertSectionBreakContinuous: o,
2263
+ handleInsertSymbol: s
2264
+ };
2265
+ }
2266
+ //#endregion
2267
+ //#region src/composables/useHyperlinkManagement.ts
2268
+ function ji(e) {
2269
+ let t = B(null);
2270
+ function n(e, t) {
2271
+ t(e.state, (t) => e.dispatch(t), e);
2272
+ }
2273
+ function r(t) {
2274
+ let r = e.editorView.value;
2275
+ if (!r) return;
2276
+ let i = e.getCommands(), { empty: a } = r.state.selection, o = t.bookmark ? `#${t.bookmark}` : t.url;
2277
+ if (o) {
2278
+ if (a && t.displayText) {
2279
+ let e = i.insertHyperlink;
2280
+ e && n(r, e(t.displayText, o, t.tooltip || void 0));
2281
+ } else {
2282
+ let e = i.setHyperlink;
2283
+ e && n(r, e(o, t.tooltip || void 0));
2284
+ }
2285
+ r.focus();
2286
+ }
2287
+ }
2288
+ function i() {
2289
+ let t = e.editorView.value;
2290
+ if (!t) return;
2291
+ let r = e.getCommands().removeHyperlink;
2292
+ r && n(t, r()), t.focus();
2293
+ }
2294
+ function a(e) {
2295
+ window.open(e, "_blank", "noopener,noreferrer"), t.value = null;
2296
+ }
2297
+ function o(n, r) {
2298
+ let i = e.editorView.value;
2299
+ i && (on(i, {
2300
+ displayText: n,
2301
+ href: r
2302
+ }), t.value = null, i.focus());
2303
+ }
2304
+ function s() {
2305
+ let n = e.editorView.value;
2306
+ n && (sn(n, { popupHref: t.value?.href }), t.value = null, n.focus());
2307
+ }
2308
+ return {
2309
+ hyperlinkPopupData: t,
2310
+ handleHyperlinkSubmit: r,
2311
+ handleHyperlinkRemove: i,
2312
+ handleHyperlinkPopupNavigate: a,
2313
+ handleHyperlinkPopupEdit: o,
2314
+ handleHyperlinkPopupRemove: s
2315
+ };
2316
+ }
2317
+ //#endregion
2318
+ //#region src/composables/useImageActions.ts
2319
+ function Mi(e) {
2320
+ let t = he(null), n = B(!1), r = O(() => {
2321
+ e.stateTick.value;
2322
+ let n = e.editorView.value, r = t.value;
2323
+ if (!n || !r) return null;
2324
+ let i = n.state.doc.nodeAt(r.pmPos);
2325
+ if (!i || i.type.name !== "image") return null;
2326
+ let a = i.attrs.wrapType, o = i.attrs.displayMode, s = i.attrs.cssFloat;
2327
+ return {
2328
+ wrapType: typeof a == "string" ? a : "inline",
2329
+ displayMode: typeof o == "string" ? o : "inline",
2330
+ cssFloat: typeof s == "string" ? s : null
2331
+ };
2332
+ });
2333
+ function i(e, t) {
2334
+ t(e.state, (t) => e.dispatch(t), e);
2335
+ }
2336
+ function a(n) {
2337
+ let r = e.editorView.value, a = t.value;
2338
+ if (!r || !a) return;
2339
+ let o = Je(n);
2340
+ if (!o) return;
2341
+ let s = r.state.doc.nodeAt(a.pmPos)?.attrs.wrapType === "inline" && o !== "inline" ? { initialPositionEmu: We(a.element, e.zoom.value) } : void 0, c = e.getCommands().setImageWrapType;
2342
+ c && (i(r, c(a.pmPos, o, s)), r.focus());
2343
+ }
2344
+ function o(n) {
2345
+ let r = e.editorView.value, i = t.value;
2346
+ if (!r || !i) return;
2347
+ let a = r.state.doc.nodeAt(i.pmPos);
2348
+ if (!a || a.type.name !== "image") return;
2349
+ let o = a.attrs.transform, s = typeof o == "string" ? o : "", c = /rotate\((?<deg>-?\d+(?:\.\d+)?)deg\)/u.exec(s)?.groups?.deg, l = c ? Number.parseFloat(c) : 0, u = /scaleX\(-1\)/u.test(s), d = /scaleY\(-1\)/u.test(s);
2350
+ n === "rotateCW" ? l = (l + 90) % 360 : n === "rotateCCW" ? l = (l - 90 + 360) % 360 : n === "flipH" ? u = !u : n === "flipV" && (d = !d);
2351
+ let f = [];
2352
+ l !== 0 && f.push(`rotate(${l}deg)`), u && f.push("scaleX(-1)"), d && f.push("scaleY(-1)");
2353
+ let p = f.length > 0 ? f.join(" ") : null, m = r.state.tr.setNodeMarkup(i.pmPos, void 0, {
2354
+ ...a.attrs,
2355
+ transform: p
2356
+ });
2357
+ r.dispatch(m.scrollIntoView()), r.focus();
2358
+ }
2359
+ return {
2360
+ selectedImage: t,
2361
+ imageInteracting: n,
2362
+ imageToolbarContext: r,
2363
+ handleToolbarImageWrap: a,
2364
+ handleImageTransform: o
2365
+ };
2366
+ }
2367
+ //#endregion
2368
+ //#region src/composables/usePageSetupControls.ts
2369
+ function Ni(e) {
2370
+ function t(t) {
2371
+ let n = e.getDocument();
2372
+ if (!n?.package?.document) return;
2373
+ let r = n.package.document.finalSectionProperties ?? {};
2374
+ n.package.document.finalSectionProperties = {
2375
+ ...r,
2376
+ ...t
2377
+ }, e.stateTick.value++, e.reLayout(), e.onChange(n);
2378
+ }
2379
+ function n(n, r) {
2380
+ e.readOnly.value || t({ [n]: r });
2381
+ }
2382
+ function r(e) {
2383
+ n("marginLeft", e);
2384
+ }
2385
+ function i(e) {
2386
+ n("marginRight", e);
2387
+ }
2388
+ function a(e) {
2389
+ n("marginTop", e);
2390
+ }
2391
+ function o(e) {
2392
+ n("marginBottom", e);
2393
+ }
2394
+ function s(t) {
2395
+ let n = e.editorView.value;
2396
+ n && $t(t)(n.state, n.dispatch);
2397
+ }
2398
+ function c(t) {
2399
+ let n = e.editorView.value;
2400
+ n && en(t)(n.state, n.dispatch);
2401
+ }
2402
+ function l(t) {
2403
+ let n = e.editorView.value;
2404
+ n && (t < 0 ? Qt(-t, !0)(n.state, n.dispatch) : Qt(t, !1)(n.state, n.dispatch));
2405
+ }
2406
+ function u(t) {
2407
+ let n = e.editorView.value;
2408
+ n && Zt(t)(n.state, n.dispatch);
2409
+ }
2410
+ return {
2411
+ handlePageSetupApply: t,
2412
+ handleLeftMarginChange: r,
2413
+ handleRightMarginChange: i,
2414
+ handleTopMarginChange: a,
2415
+ handleBottomMarginChange: o,
2416
+ handleIndentLeftChange: s,
2417
+ handleIndentRightChange: c,
2418
+ handleFirstLineIndentChange: l,
2419
+ handleTabStopRemove: u
2420
+ };
2421
+ }
2422
+ //#endregion
2423
+ //#region src/utils/textSelection.ts
2424
+ var Pi = /[\p{L}\p{N}\p{M}_''-]/u, Fi = /\s/;
2425
+ function Ii(e) {
2426
+ return !e || e.length === 0 ? !1 : Pi.test(e);
2427
+ }
2428
+ function Li(e) {
2429
+ return !e || e.length === 0 ? !1 : Fi.test(e);
2430
+ }
2431
+ function Ri(e, t) {
2432
+ if (!e || e.length === 0) return [0, 0];
2433
+ t = Math.max(0, Math.min(t, e.length - 1));
2434
+ let n = e[t];
2435
+ if (Li(n)) {
2436
+ let n = t, r = t;
2437
+ for (; n > 0 && Li(e[n - 1]);) n--;
2438
+ for (; r < e.length && Li(e[r]);) r++;
2439
+ return [n, r];
2440
+ }
2441
+ if (Ii(n)) {
2442
+ let n = t, r = t;
2443
+ for (; n > 0 && Ii(e[n - 1]);) n--;
2444
+ for (; r < e.length && Ii(e[r]);) r++;
2445
+ return [n, r];
2446
+ }
2447
+ return [t, t + 1];
2448
+ }
2449
+ //#endregion
2450
+ //#region src/utils/domQueries.ts
2451
+ function zi(e, t, n) {
2452
+ let r = n ? Array.from(e.querySelectorAll(`.layout-page-${n} span[data-pm-start][data-pm-end]`)) : it(e);
2453
+ for (let e of r) {
2454
+ let n = Number(e.dataset.pmStart), r = Number(e.dataset.pmEnd);
2455
+ if (!Number.isNaN(n) && !Number.isNaN(r) && t >= n && t <= r) return e;
2456
+ }
2457
+ return null;
2458
+ }
2459
+ function Bi(e, t, n) {
2460
+ if (!e || !t) return;
2461
+ let r = rt(e, n);
2462
+ if (!r) for (let t of it(e)) {
2463
+ let e = Number(t.dataset.pmStart), i = Number(t.dataset.pmEnd);
2464
+ if (Number.isFinite(e) && Number.isFinite(i) && n >= e && n <= i) {
2465
+ r = t;
2466
+ break;
2467
+ }
2468
+ }
2469
+ if (!r) return;
2470
+ let i = t.getBoundingClientRect(), a = r.getBoundingClientRect();
2471
+ t.scrollTo({
2472
+ top: a.top - i.top + t.scrollTop - 48,
2473
+ behavior: "smooth"
2474
+ });
2475
+ }
2476
+ function Vi(e, t, n, r) {
2477
+ if (!e || !t) return null;
2478
+ let i = Ze(e, n, r, 1);
2479
+ return i === null || i < 0 ? null : Math.min(i, t.state.doc.content.size);
2480
+ }
2481
+ function Hi(e, t, n, r) {
2482
+ if (!e) return;
2483
+ let i = zi(e, t, r);
2484
+ if (!i) return;
2485
+ let a = i.textContent ?? "", o = Number(i.dataset.pmStart) || 0, [s, c] = Ri(a, t - o), l = o + s, u = o + c;
2486
+ l < u && n(l, u);
2487
+ }
2488
+ function Ui(e, t, n, r) {
2489
+ if (!e) return;
2490
+ let i = zi(e, t, r);
2491
+ if (!i) return;
2492
+ let a = i.closest(".layout-paragraph");
2493
+ if (!a) return;
2494
+ let o = Number(a.dataset.pmStart), s = Number(a.dataset.pmEnd);
2495
+ !Number.isNaN(o) && !Number.isNaN(s) && o < s && n(o, s);
2496
+ }
2497
+ //#endregion
2498
+ //#region src/composables/usePagesPointer.ts
2499
+ var Wi = 500;
2500
+ function Gi(e) {
2501
+ let t = B(null), n = null;
2502
+ function r() {
2503
+ n !== null && (clearTimeout(n), n = null);
2504
+ }
2505
+ let i = he(null), a = 0, o = null, s = 0, c = !1, l = null, u = un(), d = re({
2506
+ pagesContainer: e.pagesRef,
2507
+ onScrollExtendSelection: (e, t) => {
2508
+ if (!c || l === null) return;
2509
+ let n = m(e, t);
2510
+ n !== null && n !== l && g(l, n);
2511
+ }
2512
+ }), f = B({
2513
+ currentPage: 1,
2514
+ totalPages: 1,
2515
+ visible: !1
2516
+ }), p = null;
2517
+ function m(t, n) {
2518
+ return Vi(e.pagesRef.value, e.editorView.value, t, n);
2519
+ }
2520
+ function h() {
2521
+ let t = i.value;
2522
+ if (t?.headerFooter && e.getHfPmView) {
2523
+ let n = e.getHfPmView(t.headerFooter);
2524
+ if (n) return n;
2525
+ }
2526
+ return e.editorView.value;
2527
+ }
2528
+ function g(e, t) {
2529
+ let n = h();
2530
+ if (n) try {
2531
+ let r = n.state.doc.resolve(e), i = t === void 0 ? r : n.state.doc.resolve(t), a = Ve.between(r, i);
2532
+ n.dispatch(n.state.tr.setSelection(a));
2533
+ } catch {}
2534
+ }
2535
+ function _(t) {
2536
+ Bi(e.pagesRef.value, e.pagesViewportRef.value, t);
2537
+ }
2538
+ function v(t) {
2539
+ Hi(e.pagesRef.value, t, g, i.value?.position);
2540
+ }
2541
+ function y(t) {
2542
+ Ui(e.pagesRef.value, t, g, i.value?.position);
2543
+ }
2544
+ function b(t) {
2545
+ let n = e.editorView.value;
2546
+ if (!n) return;
2547
+ let r = null;
2548
+ if (n.state.doc.descendants((e, n) => {
2549
+ if (r !== null) return !1;
2550
+ let i = e.attrs.bookmarks;
2551
+ if (Array.isArray(i)) {
2552
+ let e = i;
2553
+ for (let i of e) if (typeof i == "object" && i && "name" in i && i.name === t) return r = n, !1;
2554
+ }
2555
+ return !0;
2556
+ }), r !== null) {
2557
+ _(r);
2558
+ try {
2559
+ g(Math.min(r + 1, n.state.doc.content.size));
2560
+ } catch {
2561
+ g(r);
2562
+ }
2563
+ }
2564
+ }
2565
+ function x(a) {
2566
+ if (e.readOnly.value || c) return;
2567
+ let o = e.pagesRef.value;
2568
+ if (!o) return;
2569
+ let s = e.pagesViewportRef.value;
2570
+ if (!s || !(a.target instanceof HTMLElement)) return;
2571
+ let l = ln({
2572
+ mouseX: a.clientX,
2573
+ mouseY: a.clientY,
2574
+ pagesContainer: o,
2575
+ target: a.target,
2576
+ hfEditMode: i.value?.position ?? null
2577
+ });
2578
+ if (!l) {
2579
+ n === null && (n = setTimeout(() => {
2580
+ t.value = null, n = null;
2581
+ }, cn));
2582
+ return;
2583
+ }
2584
+ let u = e.zoom.value || 1, d = s.getBoundingClientRect();
2585
+ t.value = {
2586
+ type: l.type,
2587
+ x: (l.clientX - d.left) / u,
2588
+ y: (l.clientY - d.top) / u,
2589
+ cellPmPos: l.cellPmPos
2590
+ }, r();
2591
+ }
2592
+ function S(n) {
2593
+ n.preventDefault(), n.stopPropagation();
2594
+ let r = t.value, i = e.editorView.value;
2595
+ if (!r || !i) return;
2596
+ let a = i.state.tr.setSelection(Ve.create(i.state.doc, r.cellPmPos + 1));
2597
+ i.dispatch(a);
2598
+ let o = e.getCommands(), s = r.type === "row" ? o.addRowBelow : o.addColumnRight;
2599
+ s && (s()(i.state, (e) => i.dispatch(e), i), t.value = null, i.focus());
2600
+ }
2601
+ function C(t) {
2602
+ let n = t.target, r = n instanceof HTMLElement ? n.closest("a[href]") : null;
2603
+ if (!r) return;
2604
+ t.preventDefault();
2605
+ let i = r.getAttribute("href") ?? "";
2606
+ if (i.startsWith("#")) {
2607
+ let e = i.slice(1);
2608
+ e && b(e);
2609
+ return;
2610
+ }
2611
+ let a = h();
2612
+ if (a && a.state.selection.from !== a.state.selection.to) return;
2613
+ let o = e.pagesViewportRef.value;
2614
+ if (!o) return;
2615
+ let s = o.getBoundingClientRect(), c = r.getBoundingClientRect(), l = r.getAttribute("title");
2616
+ e.hyperlinkPopupData.value = {
2617
+ href: i,
2618
+ displayText: r.textContent ?? "",
2619
+ position: {
2620
+ top: c.bottom - s.top + o.scrollTop + 4,
2621
+ left: c.left - s.left + o.scrollLeft
2622
+ },
2623
+ ...l ? { tooltip: l } : {}
2624
+ };
2625
+ }
2626
+ function ee(t) {
2627
+ if (!(t.target instanceof HTMLElement)) return;
2628
+ let n = t.target, r = n.closest(".layout-page-header"), a = n.closest(".layout-page-footer"), o = r ?? a;
2629
+ if (!o) return;
2630
+ let s = r ? "header" : "footer", c = e.getDocument();
2631
+ if (!c?.package) return;
2632
+ let l = c.package.document?.sections?.[0]?.properties ?? c.package.document?.finalSectionProperties ?? null, u = s === "header" ? l?.headerReferences : l?.footerReferences, d = s === "header" ? c.package.headers : c.package.footers, f = (u?.find((e) => e.type === "default") ?? u?.find((e) => e.type === "first") ?? null)?.rId ?? null, p = f ? d?.get(f) ?? null : null;
2633
+ if (!p) {
2634
+ if (!l) return;
2635
+ let t = "default", n = `rId_new_${s}_${t}`, r = {
2636
+ type: s,
2637
+ hdrFtrType: t,
2638
+ content: [{
2639
+ type: "paragraph",
2640
+ content: []
2641
+ }]
2642
+ }, i = s === "header" ? "headers" : "footers", a = s === "header" ? "headerReferences" : "footerReferences", o = new Map(c.package[i] ?? []);
2643
+ o.set(n, r);
2644
+ let u = c.package.relationships, d = /* @__PURE__ */ new Set();
2645
+ for (let e of u?.values() ?? []) e.target && d.add(e.target);
2646
+ let m = 1;
2647
+ for (; d.has(`${s}${m}.xml`);) m++;
2648
+ let h = s === "header" ? "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", g = new Map(u);
2649
+ g.set(n, {
2650
+ id: n,
2651
+ type: h,
2652
+ target: `${s}${m}.xml`
2653
+ });
2654
+ let _ = {
2655
+ type: t,
2656
+ rId: n
2657
+ }, v = {
2658
+ ...l,
2659
+ [a]: [...l[a] ?? [], _]
2660
+ }, y = c.package.document, b = y?.sections?.map((e, t) => t === 0 ? {
2661
+ ...e,
2662
+ properties: v
2663
+ } : e), x = y?.finalSectionProperties === l ? v : y?.finalSectionProperties, S = {
2664
+ ...c,
2665
+ package: {
2666
+ ...c.package,
2667
+ [i]: o,
2668
+ relationships: g,
2669
+ document: y && {
2670
+ ...y,
2671
+ ...b !== void 0 && { sections: b },
2672
+ ...x !== void 0 && { finalSectionProperties: x }
2673
+ }
2674
+ }
2675
+ };
2676
+ f = n, p = r, e.setDocument?.(S), e.syncHfPMs?.(), e.reLayout(), e.emit("change", S);
2677
+ }
2678
+ let m = e.pagesViewportRef.value;
2679
+ if (!m) return;
2680
+ let h = o.getBoundingClientRect(), g = m.getBoundingClientRect(), _ = e.zoom.value || 1;
2681
+ i.value = {
2682
+ position: s,
2683
+ rId: f,
2684
+ headerFooter: p,
2685
+ targetRect: {
2686
+ top: (h.top - g.top + m.scrollTop) / _,
2687
+ left: (h.left - g.left + m.scrollLeft) / _,
2688
+ width: h.width / _,
2689
+ height: h.height / _
2690
+ }
2691
+ };
2692
+ }
2693
+ function te(t) {
2694
+ let n = e.getDocument(), r = i.value;
2695
+ if (!n?.package || !r) return;
2696
+ let a = r.position === "header" ? n.package.headers : n.package.footers;
2697
+ if (!a || !r.rId) return;
2698
+ let o = a.get(r.rId);
2699
+ o && (o.content = t), e.syncHfPMs?.(), e.reLayout(), e.emit("change", n);
2700
+ }
2701
+ function ne() {
2702
+ let t = e.getDocument(), n = i.value;
2703
+ if (!t?.package || !n || !n.rId) {
2704
+ i.value = null;
2705
+ return;
2706
+ }
2707
+ let r = n.position === "header" ? "headers" : "footers", a = n.position === "header" ? "headerReferences" : "footerReferences", o = n.rId, s = new Map(t.package[r] ?? []);
2708
+ s.delete(o);
2709
+ let c = (e) => ({
2710
+ ...e,
2711
+ [a]: (e[a] ?? []).filter((e) => e.rId !== o)
2712
+ }), l = (e) => "sectionProperties" in e && e.sectionProperties ? {
2713
+ ...e,
2714
+ sectionProperties: c(e.sectionProperties)
2715
+ } : e, u = t.package.document, d = u?.sections?.map((e) => ({
2716
+ ...e,
2717
+ properties: c(e.properties)
2718
+ })), f = u?.finalSectionProperties ? c(u.finalSectionProperties) : void 0, p = {
2719
+ ...t,
2720
+ package: {
2721
+ ...t.package,
2722
+ [r]: s,
2723
+ document: u && {
2724
+ ...u,
2725
+ content: u.content.map(l),
2726
+ ...d !== void 0 && { sections: d },
2727
+ ...f !== void 0 && { finalSectionProperties: f }
2728
+ }
2729
+ }
2730
+ };
2731
+ i.value = null, e.setDocument?.(p), e.syncHfPMs?.(), e.reLayout(), e.emit("change", p);
2732
+ }
2733
+ function w(t) {
2734
+ if (t.button !== 0 || e.imageInteracting.value) return;
2735
+ let n = e.editorView.value;
2736
+ if (!n) return;
2737
+ let r = t.target, d = r instanceof HTMLElement ? r : null;
2738
+ i.value && d && (d.closest(".layout-page-header") || d.closest(".layout-page-footer") || d.closest(".hf-editor") || (i.value = null, n.focus()));
2739
+ let f = h() ?? n;
2740
+ if (!e.readOnly.value && e.tableResize.tryStartResize(t, f)) return;
2741
+ let p = Ke(r);
2742
+ if (p) {
2743
+ t.preventDefault(), t.stopPropagation();
2744
+ let n = Number(p.dataset.pmStart);
2745
+ if (!Number.isNaN(n)) {
2746
+ try {
2747
+ f.dispatch(f.state.tr.setSelection(Be.create(f.state.doc, n)));
2748
+ } catch {}
2749
+ e.selectedImage.value = {
2750
+ element: p,
2751
+ pmPos: n,
2752
+ width: p.offsetWidth,
2753
+ height: p.offsetHeight
2754
+ }, e.clearOverlay();
2755
+ }
2756
+ f.focus();
2757
+ return;
2758
+ }
2759
+ e.selectedImage.value = null, t.preventDefault();
2760
+ let _ = m(t.clientX, t.clientY);
2761
+ if (_ === null) {
2762
+ f.focus();
2763
+ return;
2764
+ }
2765
+ let b = Date.now();
2766
+ if (b - a < Wi && o === _ ? s++ : s = 1, a = b, o = _, s === 2) v(_);
2767
+ else if (s >= 3) y(_), s = 0;
2768
+ else if (t.shiftKey) {
2769
+ let { from: e } = f.state.selection;
2770
+ g(e, _);
2771
+ } else g(_), l = _, c = !0, u.begin(dn(f, _));
2772
+ f.focus();
2773
+ }
2774
+ function ie(e) {
2775
+ if (!c || l === null) return;
2776
+ let t = m(e.clientX, e.clientY);
2777
+ if (t !== null) {
2778
+ let n = h();
2779
+ if (n && u.update(n, t, e.clientX)) {
2780
+ d.updateMousePosition(e.clientX, e.clientY);
2781
+ return;
2782
+ }
2783
+ t !== l && g(l, t);
2784
+ }
2785
+ d.updateMousePosition(e.clientX, e.clientY);
2786
+ }
2787
+ function ae() {
2788
+ c = !1, u.end(), d.stopAutoScroll();
2789
+ }
2790
+ function T() {
2791
+ let t = e.pagesViewportRef.value, n = e.layout.value;
2792
+ if (!t || !n || n.pages.length === 0) return;
2793
+ let r = t.scrollTop, i = n.pages.length, a = r + t.clientHeight / 2, o = 24, s = 1;
2794
+ for (let e = 0; e < n.pages.length; e++) {
2795
+ let t = n.pages[e];
2796
+ if (!t) continue;
2797
+ let r = o + t.size.h;
2798
+ if (a < r) {
2799
+ s = e + 1;
2800
+ break;
2801
+ }
2802
+ o = r + 24, s = e + 2;
2803
+ }
2804
+ s = Math.min(s, i), f.value = {
2805
+ currentPage: s,
2806
+ totalPages: i,
2807
+ visible: !0
2808
+ }, p && clearTimeout(p), p = setTimeout(() => {
2809
+ f.value = {
2810
+ ...f.value,
2811
+ visible: !1
2812
+ };
2813
+ }, 600);
2814
+ }
2815
+ return pe(() => {
2816
+ window.addEventListener("mousemove", ie), window.addEventListener("mouseup", ae), e.pagesViewportRef.value?.addEventListener("scroll", T, { passive: !0 });
2817
+ }), fe(() => {
2818
+ r(), window.removeEventListener("mousemove", ie), window.removeEventListener("mouseup", ae), e.pagesViewportRef.value?.removeEventListener("scroll", T), p && clearTimeout(p);
2819
+ }), {
2820
+ tableInsertButton: t,
2821
+ hfEdit: i,
2822
+ scrollPageInfo: f,
2823
+ resolvePos: m,
2824
+ setPmSelection: g,
2825
+ scrollVisiblePositionIntoView: _,
2826
+ navigateToBookmark: b,
2827
+ handlePagesMouseDown: w,
2828
+ handlePagesMouseMove: x,
2829
+ handlePagesClick: C,
2830
+ handlePagesDoubleClick: ee,
2831
+ handleTableInsertClick: S,
2832
+ clearTableInsertTimer: r,
2833
+ handleHfSave: te,
2834
+ handleHfRemove: ne
2835
+ };
2836
+ }
2837
+ //#endregion
2838
+ //#region src/utils/hostFonts.ts
2839
+ function Ki(e) {
2840
+ return typeof e == "string" && e.trim().length > 0;
2841
+ }
2842
+ function qi(e) {
2843
+ return typeof e != "object" || !e ? !1 : Ki(Reflect.get(e, "family")) && Ki(Reflect.get(e, "src"));
2844
+ }
2845
+ function Ji(e) {
2846
+ if (!e) return [];
2847
+ let t = [];
2848
+ for (let n of e) {
2849
+ if (!qi(n)) continue;
2850
+ let e = { display: "swap" };
2851
+ (typeof n.weight == "number" || typeof n.weight == "string") && (e.weight = String(n.weight)), t.push({
2852
+ family: n.family.trim(),
2853
+ source: `url(${JSON.stringify(n.src.trim())})`,
2854
+ descriptors: e
2855
+ });
2856
+ }
2857
+ return t;
2858
+ }
2859
+ function Yi() {
2860
+ return typeof document > "u" || !("fonts" in document) ? null : document.fonts;
2861
+ }
2862
+ async function Xi(e, t, n, r) {
2863
+ let i;
2864
+ try {
2865
+ i = new FontFace(t, n, r), e.add(i);
2866
+ } catch {
2867
+ return null;
2868
+ }
2869
+ return await i.load().then(() => !0, () => !1) ? i : (e.delete(i), null);
2870
+ }
2871
+ async function Zi(e) {
2872
+ let t = Yi();
2873
+ if (!t) return [];
2874
+ let n = Ji(e);
2875
+ if (n.length === 0) return [];
2876
+ let r = [];
2877
+ return await Promise.all(n.map(async ({ family: e, source: n, descriptors: i }) => {
2878
+ let a = await Xi(t, e, n, i);
2879
+ a && r.push(a);
2880
+ })), r;
2881
+ }
2882
+ function Qi(e) {
2883
+ let t = Yi();
2884
+ if (t) for (let n of e) t.delete(n);
2885
+ }
2886
+ //#endregion
2887
+ //#region src/components/DocxEditor.vue?vue&type=script&setup=true&lang.ts
2888
+ var $i = { class: "docx-editor-vue__toolbar-shell" }, ea = {
2889
+ key: 0,
2890
+ class: "docx-editor-vue__error"
2891
+ }, ta = {
2892
+ key: 1,
2893
+ class: "docx-editor-vue__loading"
2894
+ }, na = {
2895
+ key: 2,
2896
+ class: "docx-editor-vue__placeholder"
2897
+ }, ra = { class: "docx-editor-vue__editor-area" }, ia = {
2898
+ key: 0,
2899
+ class: "docx-editor-vue__ruler-h"
2900
+ }, aa = {
2901
+ key: 1,
2902
+ class: "docx-editor-vue__ruler-v"
2903
+ }, oa = {
2904
+ class: "docx-editor-vue__editor-content-wrapper",
2905
+ style: {
2906
+ position: "relative",
2907
+ display: "flex",
2908
+ flexDirection: "column",
2909
+ minHeight: "100%"
2910
+ }
2911
+ }, sa = {
2912
+ "data-testid": "selection-overlay",
2913
+ class: "docx-editor-vue__decoration-origin",
2914
+ "aria-hidden": "true"
2915
+ }, ca = ["aria-label"], la = /*#__PURE__*/ l(/* @__PURE__ */ P({
2916
+ __name: "DocxEditor",
2917
+ props: {
2918
+ documentBuffer: { default: null },
2919
+ document: { default: null },
2920
+ documentKey: {},
2921
+ onSave: {},
2922
+ author: { default: "User" },
2923
+ onChange: {},
2924
+ onSelectionChange: {},
2925
+ onSelectionTextChange: {},
2926
+ onError: {},
2927
+ onFontsLoaded: {},
2928
+ fontFamilies: {},
2929
+ fonts: {},
2930
+ theme: {},
2931
+ showToolbar: {
2932
+ type: Boolean,
2933
+ default: !0
2934
+ },
2935
+ showZoomControl: {
2936
+ type: Boolean,
2937
+ default: !0
2938
+ },
2939
+ showReviewControls: {
2940
+ type: Boolean,
2941
+ default: !0
2942
+ },
2943
+ showHeaderFooterEditing: { type: Boolean },
2944
+ showMarginGuides: { type: Boolean },
2945
+ marginGuideColor: {},
2946
+ showRuler: { type: Boolean },
2947
+ rulerUnit: {},
2948
+ initialZoom: { default: 1 },
2949
+ enableWheelZoom: { type: Boolean },
2950
+ readOnly: {
2951
+ type: Boolean,
2952
+ default: !1
2953
+ },
2954
+ autoOpenReviewSidebar: { type: Boolean },
2955
+ components: {},
2956
+ toolbarExtra: { type: [
2957
+ Object,
2958
+ String,
2959
+ Number,
2960
+ Boolean,
2961
+ null,
2962
+ Array
2963
+ ] },
2964
+ className: { default: "" },
2965
+ style: {},
2966
+ placeholder: { type: [
2967
+ Object,
2968
+ String,
2969
+ Number,
2970
+ Boolean,
2971
+ null,
2972
+ Array
2973
+ ] },
2974
+ loadingIndicator: { type: [
2975
+ Object,
2976
+ String,
2977
+ Number,
2978
+ Boolean,
2979
+ null,
2980
+ Array
2981
+ ] },
2982
+ preserveDocumentWhileLoading: { type: Boolean },
2983
+ initialScrollTop: {},
2984
+ onScrollTopChange: {},
2985
+ showOutline: {
2986
+ type: Boolean,
2987
+ default: !1
2988
+ },
2989
+ showPrintButton: { type: Boolean },
2990
+ onPrint: {},
2991
+ onInsertImage: {},
2992
+ onInsertTable: {},
2993
+ showTableInsert: {
2994
+ type: Boolean,
2995
+ default: !0
2996
+ },
2997
+ onInsertPageBreak: {},
2998
+ onInsertTOC: {},
2999
+ onCopy: {},
3000
+ onCut: {},
3001
+ onPaste: {},
3002
+ mode: { default: "editing" },
3003
+ onModeChange: {},
3004
+ onReadonlyEditAttempt: {},
3005
+ comments: {},
3006
+ onCommentsChange: {},
3007
+ onCompatibilityChange: {},
3008
+ onEditorViewReady: {},
3009
+ collaboration: {},
3010
+ onAnonymizationMatchesChange: {},
3011
+ onAnonymizationTermClick: {},
3012
+ selectedAnonymizationCanonical: {},
3013
+ anonymizationSelectionSeq: {},
3014
+ showTemplateDirectives: { type: Boolean },
3015
+ onSlashMenuChange: {},
3016
+ onSlashMenuKeyAction: {},
3017
+ customContextMenuItems: {},
3018
+ onCustomContextAction: {},
3019
+ featureFlags: {},
3020
+ onSelectiveSaveTripwire: {}
3021
+ },
3022
+ emits: [
3023
+ "change",
3024
+ "update:document",
3025
+ "error",
3026
+ "ready",
3027
+ "rename",
3028
+ "menu-action",
3029
+ "mode-change",
3030
+ "comments-change"
3031
+ ],
3032
+ setup(e, { expose: n, emit: i }) {
3033
+ let a = e, o = i;
3034
+ t(), h(a.components), tr(B(!1));
3035
+ let s = B(a.mode), c = O(() => a.readOnly || s.value === "viewing"), l = O(() => a.showReviewControls), u = O(() => Ye(s.value)), d = B("all-markup");
3036
+ function m() {
3037
+ cn(Xe(s.value));
3038
+ }
3039
+ function y(e) {
3040
+ d.value = e;
3041
+ }
3042
+ let b = O(() => d.value === "all-markup" ? "" : `folio-root--${d.value}`), { t: S } = r(), C = ({ node: e }) => e;
3043
+ C.props = ["node"];
3044
+ let ee = O(() => a.documentBuffer != null || a.document != null), ne = B(!1);
3045
+ K(ee, (e) => {
3046
+ e || (ne.value = !1);
3047
+ });
3048
+ let re = B(null), D = B(null), oe = B(null), ce = B(null), P = O(() => a.showRuler ?? !1), F = B(0), ue = B(!1), I = B(!1), me = B(!1), V = B(!1), G = B(!1), q = B(a.showOutline), J = B(!1), _e = B(null), ye = he([]), xe = he([]), { zoom: X, zoomPercent: we, isMinZoom: Me, isMaxZoom: Ne, setZoom: Pe, zoomIn: Fe, zoomOut: Ie, handleWheel: Le, ZOOM_PRESETS: Re } = T(a.initialZoom);
3049
+ function ze(e) {
3050
+ a.enableWheelZoom !== !1 && Le(e);
3051
+ }
3052
+ let { editor: Be, editorView: Z, editorState: Ve, isReady: He, isDirty: Ue, parseError: We, layout: Ge, blocks: Ke, measures: qe, loadBuffer: Je, loadDocument: Ze, save: Qe, getDocument: $e, getCommands: et, focus: tt, reLayout: nt } = ie({
3053
+ hiddenContainer: re,
3054
+ pagesContainer: D,
3055
+ readOnly: c,
3056
+ editorMode: s,
3057
+ author: () => a.author,
3058
+ documentKey: () => a.documentKey,
3059
+ externalPlugins: [],
3060
+ onAnonymizationMatchesChange: (e) => a.onAnonymizationMatchesChange?.(e),
3061
+ showTemplateDirectives: () => a.showTemplateDirectives,
3062
+ onSlashMenuChange: (e) => a.onSlashMenuChange?.(e),
3063
+ onSlashMenuKeyAction: (e) => a.onSlashMenuKeyAction?.(e) ?? !1,
3064
+ onChange: (e) => {
3065
+ a.onChange?.(e), o("change", e), o("update:document", e);
3066
+ },
3067
+ onError: (e) => {
3068
+ a.onError?.(e), o("error", e);
3069
+ },
3070
+ onSelectionUpdate: (e) => {
3071
+ if (a.onSelectionChange?.(ve(e)), a.onSelectionTextChange) {
3072
+ let { from: t, to: n } = e.selection, r = t === n ? "" : e.doc.textBetween(t, n, " ", " ");
3073
+ a.onSelectionTextChange({
3074
+ from: t,
3075
+ to: n,
3076
+ text: r
3077
+ });
3078
+ }
3079
+ },
3080
+ onEditorViewReady: (e) => a.onEditorViewReady?.(e),
3081
+ onReadOnlyEditAttempt: () => a.onReadonlyEditAttempt?.(),
3082
+ featureFlags: () => a.featureFlags,
3083
+ onSelectiveSaveTripwire: a.onSelectiveSaveTripwire ? (e) => a.onSelectiveSaveTripwire?.(e) : void 0
3084
+ }), rt = O(() => !He.value && ee.value && !(a.preserveDocumentWhileLoading === !0 && ne.value));
3085
+ function it() {
3086
+ Z.value && (ke(), Oe(), nt());
3087
+ }
3088
+ K(() => a.fonts, (e, t, n) => {
3089
+ if (!e || e.length === 0) return;
3090
+ let r = !1, i = [];
3091
+ Zi(e).then((e) => {
3092
+ if (r) {
3093
+ Qi(e);
3094
+ return;
3095
+ }
3096
+ i = e, e.length !== 0 && it();
3097
+ }), n(() => {
3098
+ r = !0, i.length !== 0 && (Qi(i), it());
3099
+ });
3100
+ }, { immediate: !0 });
3101
+ let { selectedImage: at, imageInteracting: ot, imageToolbarContext: st, handleToolbarImageWrap: ct, handleImageTransform: lt } = Mi({
3102
+ editorView: Z,
3103
+ zoom: X,
3104
+ stateTick: F,
3105
+ getCommands: et
3106
+ }), { hyperlinkPopupData: ut, handleHyperlinkSubmit: dt, handleHyperlinkRemove: ft, handleHyperlinkPopupNavigate: pt, handleHyperlinkPopupEdit: mt, handleHyperlinkPopupRemove: ht } = ji({
3107
+ editorView: Z,
3108
+ getCommands: et
3109
+ }), gt = w(), { tableInsertButton: _t, scrollPageInfo: vt, resolvePos: yt, setPmSelection: bt, scrollVisiblePositionIntoView: xt, handlePagesMouseDown: St, handlePagesMouseMove: Ct, handlePagesClick: wt, handleTableInsertClick: Tt } = Gi({
3110
+ editorView: Z,
3111
+ pagesRef: D,
3112
+ pagesViewportRef: oe,
3113
+ selectedImage: at,
3114
+ imageInteracting: ot,
3115
+ hyperlinkPopupData: ut,
3116
+ readOnly: c,
3117
+ zoom: X,
3118
+ layout: Ge,
3119
+ tableResize: {
3120
+ tryStartResize: gt.tryStartResize,
3121
+ isResizing: O(() => gt.isResizing())
3122
+ },
3123
+ getCommands: et,
3124
+ getDocument: $e,
3125
+ reLayout: nt,
3126
+ emit: () => {},
3127
+ clearOverlay: () => {}
3128
+ }), { contextMenu: Et, imageContextMenu: Dt, imageContextMenuTextActions: Ot, customTextMenuItems: kt, handleContextMenu: At, handleSelectedImageContextMenu: jt, handleImageWrapSelect: Mt, handleContextMenuAction: Nt } = wi({
3129
+ editorView: Z,
3130
+ selectedImage: at,
3131
+ zoom: X,
3132
+ showImageProperties: V,
3133
+ getCommands: et,
3134
+ clearOverlay: () => {},
3135
+ setPmSelection: bt,
3136
+ resolvePos: yt,
3137
+ customContextMenuItems: () => c.value ? void 0 : a.customContextMenuItems,
3138
+ onCustomContextAction: (e, t) => a.onCustomContextAction?.(e, t)
3139
+ }), Pt = ae(Z, F), Ft = O(() => Pt.value.entries), Q = fi({
3140
+ editorView: Z,
3141
+ getDocument: $e,
3142
+ author: () => a.author,
3143
+ commentsProp: () => a.comments,
3144
+ onCommentsChange: (e) => {
3145
+ a.onCommentsChange?.(e), o("comments-change", e);
3146
+ },
3147
+ reLayout: nt
3148
+ }), It = Q.comments, $ = di({
3149
+ editorView: Z,
3150
+ pagesViewport: oe,
3151
+ pagesContainer: D,
3152
+ readOnly: c,
3153
+ createComment: Q.createComment,
3154
+ pushComment: Q.pushComment,
3155
+ reLayout: nt,
3156
+ showSidebar: J,
3157
+ setActiveSidebarItem: (e) => {
3158
+ _e.value = e;
3159
+ }
3160
+ });
3161
+ function Lt(e) {
3162
+ navigator.clipboard?.writeText(e), ut.value = null;
3163
+ }
3164
+ let Rt = O(() => {
3165
+ F.value;
3166
+ let e = $e()?.package.document;
3167
+ return e ? e.finalSectionProperties ?? e.sections?.[0]?.properties ?? null : null;
3168
+ }), zt = O(() => {
3169
+ F.value;
3170
+ let e = {};
3171
+ a.fontFamilies !== void 0 && (e.fontFamilies = a.fontFamilies);
3172
+ let t = $e()?.package.styles?.styles;
3173
+ return t !== void 0 && (e.documentStyles = t), e;
3174
+ }), Bt = O(() => je(Rt.value?.pageWidth ?? 12240) * X.value), Vt = O(() => {
3175
+ let e = /* @__PURE__ */ new Set();
3176
+ for (let t of It.value) t.done && e.add(t.id);
3177
+ return e;
3178
+ }), Ht = O(() => ({
3179
+ transform: X.value === 1 ? void 0 : `scale(${X.value})`,
3180
+ transformOrigin: "top center",
3181
+ transition: "transform 0.2s ease"
3182
+ })), { handleApplyStyle: Ut, handleInsertSymbol: Wt, handleInsertSectionBreakNextPage: Gt, handleInsertSectionBreakContinuous: Kt } = Ai({
3183
+ editorView: Z,
3184
+ getDocument: $e
3185
+ });
3186
+ function qt() {
3187
+ if (a.onInsertImage) {
3188
+ a.onInsertImage();
3189
+ return;
3190
+ }
3191
+ let e = Z.value;
3192
+ if (!e) return;
3193
+ let t = document.createElement("input");
3194
+ t.type = "file", t.accept = "image/*", t.style.display = "none", t.addEventListener("change", () => {
3195
+ let n = t.files?.[0];
3196
+ n && be(e, n, () => e.focus()), t.remove();
3197
+ }), document.body.appendChild(t), t.click();
3198
+ }
3199
+ function Jt(e, t) {
3200
+ if (a.onInsertTable) {
3201
+ a.onInsertTable(e, t);
3202
+ return;
3203
+ }
3204
+ let n = Z.value;
3205
+ n && (Ce(n, e, t), n.focus());
3206
+ }
3207
+ function Yt() {
3208
+ if (a.onInsertPageBreak) {
3209
+ a.onInsertPageBreak();
3210
+ return;
3211
+ }
3212
+ let e = Z.value;
3213
+ e && (Se(e), e.focus());
3214
+ }
3215
+ function Xt() {
3216
+ if (a.onInsertTOC) {
3217
+ a.onInsertTOC();
3218
+ return;
3219
+ }
3220
+ let e = Z.value;
3221
+ e && (Te(e), e.focus());
3222
+ }
3223
+ let { handlePageSetupApply: Zt, handleLeftMarginChange: Qt, handleRightMarginChange: $t, handleTopMarginChange: en, handleBottomMarginChange: tn, handleIndentLeftChange: nn, handleIndentRightChange: rn, handleFirstLineIndentChange: an, handleTabStopRemove: on } = Ni({
3224
+ editorView: Z,
3225
+ getDocument: $e,
3226
+ readOnly: c,
3227
+ stateTick: F,
3228
+ reLayout: nt,
3229
+ onChange: (e) => {
3230
+ a.onChange?.(e), o("change", e), o("update:document", e);
3231
+ }
3232
+ }), sn = O(() => {
3233
+ F.value;
3234
+ let e = Z.value, t = e ? Ee(e.state).paragraphFormatting : {};
3235
+ return {
3236
+ indentLeft: t.indentLeft ?? 0,
3237
+ indentRight: t.indentRight ?? 0,
3238
+ firstLineIndent: t.indentFirstLine ?? 0,
3239
+ hangingIndent: t.hangingIndent ?? !1,
3240
+ tabs: t.tabs ?? null
3241
+ };
3242
+ });
3243
+ function cn(e) {
3244
+ s.value !== e && (s.value = e, a.onModeChange?.(e), o("mode-change", e));
3245
+ }
3246
+ function ln(e) {
3247
+ switch (e) {
3248
+ case "find":
3249
+ case "findReplace":
3250
+ ue.value = !0;
3251
+ break;
3252
+ case "insertSymbol":
3253
+ me.value = !0;
3254
+ break;
3255
+ case "insertHyperlink":
3256
+ I.value = !0;
3257
+ break;
3258
+ case "pageSetup":
3259
+ G.value = !0;
3260
+ break;
3261
+ case "toggleOutline":
3262
+ q.value = !q.value;
3263
+ break;
3264
+ case "toggleSidebar":
3265
+ J.value = !J.value;
3266
+ break;
3267
+ case "insertImage":
3268
+ qt();
3269
+ break;
3270
+ case "insertPageBreak":
3271
+ Yt();
3272
+ break;
3273
+ case "insertSectionBreakNextPage":
3274
+ Gt();
3275
+ break;
3276
+ case "insertSectionBreakContinuous":
3277
+ Kt();
3278
+ break;
3279
+ case "insertTOC":
3280
+ Xt();
3281
+ break;
3282
+ default: break;
3283
+ }
3284
+ o("menu-action", e);
3285
+ }
3286
+ function un(e, t) {
3287
+ Jt(e, t);
3288
+ }
3289
+ let dn = B(!1);
3290
+ Ti({
3291
+ documentBuffer: () => a.documentBuffer ?? null,
3292
+ document: () => a.document ?? null,
3293
+ loadDocumentBuffer: Je,
3294
+ loadDocument: Ze,
3295
+ sidebarAutoOpenedRef: dn
3296
+ }), K(() => a.mode, (e) => {
3297
+ e && e !== s.value && (s.value = e);
3298
+ }), K(() => a.showOutline, (e) => {
3299
+ q.value = !!e;
3300
+ });
3301
+ let fn = B(!1);
3302
+ function pn(e) {
3303
+ let t = e.currentTarget;
3304
+ t instanceof HTMLElement && a.onScrollTopChange?.(t.scrollTop);
3305
+ }
3306
+ function mn() {
3307
+ if (a.initialScrollTop === void 0 || fn.value) return;
3308
+ fn.value = !0;
3309
+ let e = a.initialScrollTop;
3310
+ requestAnimationFrame(() => {
3311
+ ce.value && (ce.value.scrollTop = e);
3312
+ });
3313
+ }
3314
+ K(He, (e) => {
3315
+ if (!e) {
3316
+ fn.value = !1;
3317
+ return;
3318
+ }
3319
+ ne.value = !0, Q.seedFromDocument();
3320
+ let t = $e();
3321
+ t && a.onCompatibilityChange?.(De(t)), a.autoOpenReviewSidebar !== !1 && !dn.value && (It.value.length > 0 || Ft.value.length > 0) && (dn.value = !0, J.value = !0), mn(), o("ready");
3322
+ }), pe(() => {
3323
+ let e = Be.on("selectionChange", () => {
3324
+ F.value++, $.updateFloatingButton();
3325
+ }), t = Be.on("docChange", () => {
3326
+ F.value++;
3327
+ }), n = Be.on("layoutComplete", () => {
3328
+ F.value++;
3329
+ }), r = gt.install(), i = Ae(() => a.onFontsLoaded?.());
3330
+ fe(() => {
3331
+ e(), t(), n(), r(), i();
3332
+ });
3333
+ });
3334
+ let { exposed: hn } = ki({
3335
+ editor: Be,
3336
+ editorView: Z,
3337
+ isDirty: Ue,
3338
+ commentsDirty: Q.commentsDirty,
3339
+ clearCommentsDirty: Q.clearCommentsDirty,
3340
+ layout: Ge,
3341
+ pagesRef: D,
3342
+ pagesViewportRef: oe,
3343
+ zoom: X,
3344
+ scrollVisiblePositionIntoView: xt,
3345
+ author: () => a.author,
3346
+ createAIEditComment: (e) => {
3347
+ let t = Q.createComment(e);
3348
+ return Q.pushComment(t), t.id;
3349
+ },
3350
+ focus: tt,
3351
+ getDocument: $e,
3352
+ setZoom: Pe,
3353
+ save: Qe,
3354
+ loadDocument: Ze,
3355
+ loadDocumentBuffer: Je,
3356
+ onPrint: a.onPrint,
3357
+ onSave: a.onSave
3358
+ });
3359
+ return n(hn), (t, n) => (z(), j("div", {
3360
+ class: L([
3361
+ "docx-editor-vue ep-root paged-editor",
3362
+ e.className,
3363
+ b.value,
3364
+ { "paged-editor--readonly": c.value }
3365
+ ]),
3366
+ style: R(e.style)
3367
+ }, [
3368
+ M("div", $i, [N($n, {
3369
+ "show-table-insert": a.showTableInsert !== !1,
3370
+ onRename: n[0] ||= (e) => o("rename", e),
3371
+ onMenuAction: ln,
3372
+ onInsertTable: un
3373
+ }, {
3374
+ "title-bar-left": ge(() => [H(t.$slots, "title-bar-left", {}, void 0, !0)]),
3375
+ "title-bar-right": ge(() => [H(t.$slots, "title-bar-right", {}, void 0, !0)]),
3376
+ _: 3
3377
+ }, 8, ["show-table-insert"]), e.showToolbar ? (z(), k(_, de({
3378
+ key: 0,
3379
+ view: W(Z),
3380
+ "get-commands": W(et),
3381
+ "state-tick": F.value,
3382
+ "zoom-percent": W(we),
3383
+ "is-min-zoom": W(Me),
3384
+ "is-max-zoom": W(Ne),
3385
+ "zoom-presets": W(Re),
3386
+ "show-zoom-control": e.showZoomControl,
3387
+ "editor-mode": s.value,
3388
+ "show-review-controls": l.value,
3389
+ "track-changes-on": u.value,
3390
+ "display-mode": d.value,
3391
+ "read-only": c.value,
3392
+ "comments-sidebar-open": J.value,
3393
+ "image-context": W(st),
3394
+ theme: e.theme ?? null
3395
+ }, zt.value, {
3396
+ onFindReplace: n[1] ||= (e) => ue.value = !0,
3397
+ onInsertLink: n[2] ||= (e) => I.value = !0,
3398
+ onInsertSymbol: n[3] ||= (e) => me.value = !0,
3399
+ onInsertPageBreak: Yt,
3400
+ onPageSetup: n[4] ||= (e) => G.value = !0,
3401
+ onToggleOutline: n[5] ||= (e) => q.value = !q.value,
3402
+ onApplyStyle: W(Ut),
3403
+ onZoomIn: W(Fe),
3404
+ onZoomOut: W(Ie),
3405
+ onZoomSet: W(Pe),
3406
+ onToggleSidebar: n[6] ||= (e) => J.value = !J.value,
3407
+ onModeChange: cn,
3408
+ onToggleTrackChanges: m,
3409
+ "onUpdate:displayMode": y,
3410
+ onImageProperties: n[7] ||= (e) => V.value = !0,
3411
+ onImageWrapType: W(ct),
3412
+ onImageTransform: W(lt)
3413
+ }), se({
3414
+ "table-context": ge(() => [N(x, {
3415
+ view: W(Z),
3416
+ "get-commands": W(et),
3417
+ "state-tick": F.value,
3418
+ theme: e.theme ?? null
3419
+ }, null, 8, [
3420
+ "view",
3421
+ "get-commands",
3422
+ "state-tick",
3423
+ "theme"
3424
+ ])]),
3425
+ _: 2
3426
+ }, [t.$slots["toolbar-extra"] || e.toolbarExtra ? {
3427
+ name: "toolbar-extra",
3428
+ fn: ge(() => [H(t.$slots, "toolbar-extra", {}, () => [e.toolbarExtra ? (z(), k(C, {
3429
+ key: 0,
3430
+ node: e.toolbarExtra
3431
+ }, null, 8, ["node"])) : A("", !0)], !0)]),
3432
+ key: "0"
3433
+ } : void 0]), 1040, [
3434
+ "view",
3435
+ "get-commands",
3436
+ "state-tick",
3437
+ "zoom-percent",
3438
+ "is-min-zoom",
3439
+ "is-max-zoom",
3440
+ "zoom-presets",
3441
+ "show-zoom-control",
3442
+ "editor-mode",
3443
+ "show-review-controls",
3444
+ "track-changes-on",
3445
+ "display-mode",
3446
+ "read-only",
3447
+ "comments-sidebar-open",
3448
+ "image-context",
3449
+ "theme",
3450
+ "onApplyStyle",
3451
+ "onZoomIn",
3452
+ "onZoomOut",
3453
+ "onZoomSet",
3454
+ "onImageWrapType",
3455
+ "onImageTransform"
3456
+ ])) : A("", !0)]),
3457
+ N(Jn, {
3458
+ "show-find-replace": ue.value,
3459
+ "onUpdate:showFindReplace": n[8] ||= (e) => ue.value = e,
3460
+ "show-hyperlink": I.value,
3461
+ "onUpdate:showHyperlink": n[9] ||= (e) => I.value = e,
3462
+ "show-insert-symbol": me.value,
3463
+ "onUpdate:showInsertSymbol": n[10] ||= (e) => me.value = e,
3464
+ "show-image-properties": V.value,
3465
+ "onUpdate:showImageProperties": n[11] ||= (e) => V.value = e,
3466
+ "show-page-setup": G.value,
3467
+ "onUpdate:showPageSetup": n[12] ||= (e) => G.value = e,
3468
+ view: W(Z),
3469
+ bookmarks: ye.value,
3470
+ "selected-image-pm-pos": W(at)?.pmPos ?? null,
3471
+ "section-properties": Rt.value,
3472
+ onInsertSymbol: W(Wt),
3473
+ onHyperlinkSubmit: W(dt),
3474
+ onHyperlinkRemove: W(ft),
3475
+ onPageSetupApply: W(Zt)
3476
+ }, null, 8, [
3477
+ "show-find-replace",
3478
+ "show-hyperlink",
3479
+ "show-insert-symbol",
3480
+ "show-image-properties",
3481
+ "show-page-setup",
3482
+ "view",
3483
+ "bookmarks",
3484
+ "selected-image-pm-pos",
3485
+ "section-properties",
3486
+ "onInsertSymbol",
3487
+ "onHyperlinkSubmit",
3488
+ "onHyperlinkRemove",
3489
+ "onPageSetupApply"
3490
+ ]),
3491
+ W(We) ? (z(), j("div", ea, U(W(We)), 1)) : rt.value ? (z(), j("div", ta, [H(t.$slots, "loading-indicator", {}, () => [e.loadingIndicator ? (z(), k(C, {
3492
+ key: 0,
3493
+ node: e.loadingIndicator
3494
+ }, null, 8, ["node"])) : (z(), j(E, { key: 1 }, [le(U(W(S)("loadingDocument")), 1)], 64))], !0)])) : !W(He) && !ee.value ? (z(), j("div", na, [H(t.$slots, "placeholder", {}, () => [e.placeholder ? (z(), k(C, {
3495
+ key: 0,
3496
+ node: e.placeholder
3497
+ }, null, 8, ["node"])) : (z(), j(E, { key: 1 }, [le("No document loaded")], 64))], !0)])) : A("", !0),
3498
+ M("div", {
3499
+ ref_key: "hiddenPmRef",
3500
+ ref: re,
3501
+ class: "docx-editor-vue__hidden-pm paged-editor__hidden-pm"
3502
+ }, null, 512),
3503
+ M("div", {
3504
+ ref_key: "editorScrollRef",
3505
+ ref: ce,
3506
+ class: "docx-editor-vue__editor-scroll",
3507
+ onScroll: pn
3508
+ }, [M("div", ra, [
3509
+ P.value && !c.value ? (z(), j("div", ia, [N(te, {
3510
+ "section-props": Rt.value,
3511
+ zoom: W(X),
3512
+ unit: e.rulerUnit ?? "inch",
3513
+ editable: !c.value,
3514
+ "indent-left": sn.value.indentLeft,
3515
+ "indent-right": sn.value.indentRight,
3516
+ "first-line-indent": sn.value.firstLineIndent,
3517
+ "hanging-indent": sn.value.hangingIndent,
3518
+ "show-first-line-indent": !0,
3519
+ "tab-stops": sn.value.tabs,
3520
+ onLeftMarginChange: W(Qt),
3521
+ onRightMarginChange: W($t),
3522
+ onIndentLeftChange: W(nn),
3523
+ onIndentRightChange: W(rn),
3524
+ onFirstLineIndentChange: W(an),
3525
+ onTabStopRemove: W(on)
3526
+ }, null, 8, [
3527
+ "section-props",
3528
+ "zoom",
3529
+ "unit",
3530
+ "editable",
3531
+ "indent-left",
3532
+ "indent-right",
3533
+ "first-line-indent",
3534
+ "hanging-indent",
3535
+ "tab-stops",
3536
+ "onLeftMarginChange",
3537
+ "onRightMarginChange",
3538
+ "onIndentLeftChange",
3539
+ "onIndentRightChange",
3540
+ "onFirstLineIndentChange",
3541
+ "onTabStopRemove"
3542
+ ])])) : A("", !0),
3543
+ P.value && !c.value ? (z(), j("div", aa, [N(v, {
3544
+ "section-props": Rt.value,
3545
+ zoom: W(X),
3546
+ unit: e.rulerUnit ?? "inch",
3547
+ editable: !c.value,
3548
+ onTopMarginChange: W(en),
3549
+ onBottomMarginChange: W(tn)
3550
+ }, null, 8, [
3551
+ "section-props",
3552
+ "zoom",
3553
+ "unit",
3554
+ "editable",
3555
+ "onTopMarginChange",
3556
+ "onBottomMarginChange"
3557
+ ])])) : A("", !0),
3558
+ M("div", {
3559
+ ref_key: "pagesViewportRef",
3560
+ ref: oe,
3561
+ class: "docx-editor-vue__pages-viewport",
3562
+ onWheel: ze,
3563
+ onMousedown: n[21] ||= (...e) => W(St) && W(St)(...e),
3564
+ onMousemove: n[22] ||= (...e) => W(Ct) && W(Ct)(...e),
3565
+ onClick: n[23] ||= (...e) => W(wt) && W(wt)(...e),
3566
+ onContextmenu: n[24] ||= Y((...e) => W(At) && W(At)(...e), ["prevent"])
3567
+ }, [
3568
+ M("div", oa, [M("div", {
3569
+ ref_key: "pagesRef",
3570
+ ref: D,
3571
+ class: "docx-editor-vue__pages paged-editor__pages",
3572
+ style: R(Ht.value)
3573
+ }, null, 4), M("div", sa, [N(Hn, {
3574
+ "get-view": () => W(Z),
3575
+ "get-pages-container": () => D.value,
3576
+ "editor-state": W(Ve),
3577
+ zoom: W(X),
3578
+ layout: W(Ge),
3579
+ blocks: W(Ke),
3580
+ measures: W(qe),
3581
+ "on-term-click": a.onAnonymizationTermClick,
3582
+ "selected-canonical": a.selectedAnonymizationCanonical,
3583
+ "selection-seq": a.anonymizationSelectionSeq
3584
+ }, null, 8, [
3585
+ "get-view",
3586
+ "get-pages-container",
3587
+ "editor-state",
3588
+ "zoom",
3589
+ "layout",
3590
+ "blocks",
3591
+ "measures",
3592
+ "on-term-click",
3593
+ "selected-canonical",
3594
+ "selection-seq"
3595
+ ]), a.showTemplateDirectives ? (z(), k(Jr, {
3596
+ key: 0,
3597
+ "get-view": () => W(Z),
3598
+ "get-pages-container": () => D.value,
3599
+ "editor-state": W(Ve),
3600
+ zoom: W(X),
3601
+ layout: W(Ge),
3602
+ blocks: W(Ke),
3603
+ measures: W(qe)
3604
+ }, null, 8, [
3605
+ "get-view",
3606
+ "get-pages-container",
3607
+ "editor-state",
3608
+ "zoom",
3609
+ "layout",
3610
+ "blocks",
3611
+ "measures"
3612
+ ])) : A("", !0)])]),
3613
+ N(Lr, {
3614
+ "image-info": W(at),
3615
+ zoom: W(X),
3616
+ view: W(Z),
3617
+ onDeselect: n[13] ||= (e) => at.value = null,
3618
+ onInteractStart: n[14] ||= (e) => ot.value = !0,
3619
+ onInteractEnd: n[15] ||= (e) => ot.value = !1,
3620
+ onContextMenu: W(jt)
3621
+ }, null, 8, [
3622
+ "image-info",
3623
+ "zoom",
3624
+ "view",
3625
+ "onContextMenu"
3626
+ ]),
3627
+ N(ii, {
3628
+ data: W(ut),
3629
+ "read-only": c.value,
3630
+ onNavigate: W(pt),
3631
+ onCopy: Lt,
3632
+ onEdit: W(mt),
3633
+ onRemove: W(ht),
3634
+ onClose: n[16] ||= (e) => ut.value = null
3635
+ }, null, 8, [
3636
+ "data",
3637
+ "read-only",
3638
+ "onNavigate",
3639
+ "onEdit",
3640
+ "onRemove"
3641
+ ]),
3642
+ W(_t) ? (z(), j("button", {
3643
+ key: 0,
3644
+ type: "button",
3645
+ class: "docx-editor-vue__table-insert-btn",
3646
+ style: R({
3647
+ left: W(_t).x + "px",
3648
+ top: W(_t).y + "px"
3649
+ }),
3650
+ "aria-label": W(_t).type === "row" ? "Insert row" : "Insert column",
3651
+ onMousedown: n[17] ||= (...e) => W(Tt) && W(Tt)(...e)
3652
+ }, " + ", 44, ca)) : A("", !0),
3653
+ N(f, {
3654
+ comments: W(It),
3655
+ "pages-container": D.value,
3656
+ zoom: W(X),
3657
+ "page-width-px": Bt.value,
3658
+ "sidebar-open": J.value,
3659
+ "resolved-comment-ids": Vt.value,
3660
+ onMarkerClick: () => {}
3661
+ }, null, 8, [
3662
+ "comments",
3663
+ "pages-container",
3664
+ "zoom",
3665
+ "page-width-px",
3666
+ "sidebar-open",
3667
+ "resolved-comment-ids"
3668
+ ]),
3669
+ N(g, {
3670
+ "is-open": J.value,
3671
+ comments: W(It),
3672
+ "tracked-changes": Ft.value,
3673
+ "show-resolved": !0,
3674
+ "is-adding-comment": W($).isAddingComment.value,
3675
+ "add-comment-y-position": W($).addCommentYPosition.value,
3676
+ "pages-container": D.value,
3677
+ "page-width-px": Bt.value,
3678
+ zoom: W(X),
3679
+ "active-item-id": _e.value,
3680
+ onClose: n[18] ||= (e) => J.value = !1,
3681
+ "onUpdate:activeItemId": n[19] ||= (e) => _e.value = e,
3682
+ onAddComment: W($).handleAddComment,
3683
+ onCancelAddComment: W($).handleCancelAddComment,
3684
+ onCommentReply: W(Q).handleReply,
3685
+ onCommentResolve: W(Q).handleResolve,
3686
+ onCommentUnresolve: W(Q).handleUnresolve,
3687
+ onCommentDelete: W(Q).handleDelete,
3688
+ onAcceptChange: W(Q).handleAcceptChange,
3689
+ onRejectChange: W(Q).handleRejectChange,
3690
+ onAcceptChangeById: W(Q).handleAcceptChangeById,
3691
+ onRejectChangeById: W(Q).handleRejectChangeById,
3692
+ onTrackedChangeReply: W(Q).handleTrackedChangeReply
3693
+ }, null, 8, [
3694
+ "is-open",
3695
+ "comments",
3696
+ "tracked-changes",
3697
+ "is-adding-comment",
3698
+ "add-comment-y-position",
3699
+ "pages-container",
3700
+ "page-width-px",
3701
+ "zoom",
3702
+ "active-item-id",
3703
+ "onAddComment",
3704
+ "onCancelAddComment",
3705
+ "onCommentReply",
3706
+ "onCommentResolve",
3707
+ "onCommentUnresolve",
3708
+ "onCommentDelete",
3709
+ "onAcceptChange",
3710
+ "onRejectChange",
3711
+ "onAcceptChangeById",
3712
+ "onRejectChangeById",
3713
+ "onTrackedChangeReply"
3714
+ ]),
3715
+ W($).floatingCommentButton.value && !c.value ? (z(), j("button", {
3716
+ key: 1,
3717
+ type: "button",
3718
+ class: "docx-editor-vue__add-comment-btn",
3719
+ style: R({
3720
+ top: W($).floatingCommentButton.value.top + "px",
3721
+ left: W($).floatingCommentButton.value.left + "px"
3722
+ }),
3723
+ "aria-label": "Add comment",
3724
+ title: "Add comment",
3725
+ onMousedown: n[20] ||= Y((...e) => W($).startAddComment && W($).startAddComment(...e), ["prevent", "stop"])
3726
+ }, [N(p, {
3727
+ name: "add_comment",
3728
+ size: 18
3729
+ })], 36)) : A("", !0)
3730
+ ], 544),
3731
+ q.value ? A("", !0) : (z(), k(zr, {
3732
+ key: 2,
3733
+ "left-offset": 12,
3734
+ onToggle: n[25] ||= (e) => q.value = !0
3735
+ })),
3736
+ W(vt).totalPages > 1 ? (z(), k(Br, {
3737
+ key: 3,
3738
+ "current-page": W(vt).currentPage,
3739
+ "total-pages": W(vt).totalPages,
3740
+ visible: W(vt).visible
3741
+ }, null, 8, [
3742
+ "current-page",
3743
+ "total-pages",
3744
+ "visible"
3745
+ ])) : A("", !0),
3746
+ N(qn, {
3747
+ "is-open": q.value,
3748
+ headings: xe.value,
3749
+ onClose: n[26] ||= (e) => q.value = !1,
3750
+ onNavigate: () => {}
3751
+ }, null, 8, ["is-open", "headings"])
3752
+ ])], 544),
3753
+ N(Dr, {
3754
+ "read-only": c.value,
3755
+ "context-menu": W(Et),
3756
+ "image-context-menu": W(Dt),
3757
+ "image-context-menu-text-actions": W(Ot),
3758
+ "custom-text-menu-items": W(kt),
3759
+ "can-open-image-properties": W(at) !== null,
3760
+ onContextMenuAction: W(Nt),
3761
+ onCloseContextMenu: n[27] ||= (e) => W(Et).isOpen = !1,
3762
+ onImageWrapSelect: W(Mt),
3763
+ onCloseImageContextMenu: n[28] ||= (e) => Dt.value = null,
3764
+ onOpenImageProperties: n[29] ||= (e) => V.value = !0
3765
+ }, null, 8, [
3766
+ "read-only",
3767
+ "context-menu",
3768
+ "image-context-menu",
3769
+ "image-context-menu-text-actions",
3770
+ "custom-text-menu-items",
3771
+ "can-open-image-properties",
3772
+ "onContextMenuAction",
3773
+ "onImageWrapSelect"
3774
+ ])
3775
+ ], 6));
3776
+ }
3777
+ }), [["__scopeId", "data-v-1c285fdf"]]), ua = ["aria-label"], da = ["aria-label"], fa = [
3778
+ "disabled",
3779
+ "title",
3780
+ "aria-label"
3781
+ ], pa = [
3782
+ "disabled",
3783
+ "title",
3784
+ "aria-label"
3785
+ ], ma = ["aria-label"], ha = [
3786
+ "disabled",
3787
+ "title",
3788
+ "aria-label",
3789
+ "aria-pressed"
3790
+ ], ga = [
3791
+ "disabled",
3792
+ "title",
3793
+ "aria-label",
3794
+ "aria-pressed"
3795
+ ], _a = [
3796
+ "disabled",
3797
+ "title",
3798
+ "aria-label",
3799
+ "aria-pressed"
3800
+ ], va = /*#__PURE__*/ l(/* @__PURE__ */ P({
3801
+ __name: "FormattingBar",
3802
+ props: {
3803
+ currentFormatting: {},
3804
+ disabled: {
3805
+ type: Boolean,
3806
+ default: !1
3807
+ },
3808
+ canUndo: {
3809
+ type: Boolean,
3810
+ default: !1
3811
+ },
3812
+ canRedo: {
3813
+ type: Boolean,
3814
+ default: !1
3815
+ },
3816
+ className: {},
3817
+ showStylePicker: {
3818
+ type: Boolean,
3819
+ default: !0
3820
+ },
3821
+ showTextColorPicker: {
3822
+ type: Boolean,
3823
+ default: !0
3824
+ },
3825
+ showAlignmentButtons: {
3826
+ type: Boolean,
3827
+ default: !0
3828
+ },
3829
+ showListButtons: {
3830
+ type: Boolean,
3831
+ default: !0
3832
+ },
3833
+ documentStyles: {},
3834
+ theme: {}
3835
+ },
3836
+ emits: [
3837
+ "format",
3838
+ "undo",
3839
+ "redo"
3840
+ ],
3841
+ setup(e, { emit: t }) {
3842
+ let { ColorPicker: n } = d(), i = e, a = t, { t: o } = r(), s = O(() => i.currentFormatting ?? {}), c = O(() => i.documentStyles ? { styles: i.documentStyles } : {}), l = O(() => s.value.listState ?? b()), u = O(() => {
3843
+ let e = s.value.color;
3844
+ return e ? e.replace(/^#/, "").toUpperCase() : void 0;
3845
+ }), f = O(() => {
3846
+ let e = l.value;
3847
+ return e.isInList && e.level > 0 || (s.value.indentLeft ?? 0) > 0;
3848
+ });
3849
+ function m(e) {
3850
+ a("format", {
3851
+ type: "textColor",
3852
+ value: e
3853
+ });
3854
+ }
3855
+ return (t, r) => (z(), j("div", {
3856
+ class: L(["docx-formatting-bar", e.className]),
3857
+ role: "toolbar",
3858
+ "aria-label": W(o)("formattingToolbar"),
3859
+ "data-folio-toolbar": "true"
3860
+ }, [
3861
+ M("span", {
3862
+ class: "docx-formatting-bar__group",
3863
+ role: "group",
3864
+ "aria-label": W(o)("historyGroup")
3865
+ }, [M("button", {
3866
+ type: "button",
3867
+ class: "docx-formatting-bar__btn",
3868
+ disabled: e.disabled || !e.canUndo,
3869
+ title: W(o)("undoShortcut"),
3870
+ "aria-label": W(o)("undo"),
3871
+ onMousedown: r[0] ||= Y((e) => a("undo"), ["prevent"])
3872
+ }, [N(p, {
3873
+ name: "undo",
3874
+ size: 18
3875
+ })], 40, fa), M("button", {
3876
+ type: "button",
3877
+ class: "docx-formatting-bar__btn",
3878
+ disabled: e.disabled || !e.canRedo,
3879
+ title: W(o)("redoShortcut"),
3880
+ "aria-label": W(o)("redo"),
3881
+ onMousedown: r[1] ||= Y((e) => a("redo"), ["prevent"])
3882
+ }, [N(p, {
3883
+ name: "redo",
3884
+ size: 18
3885
+ })], 40, pa)], 8, da),
3886
+ r[13] ||= M("span", {
3887
+ class: "docx-formatting-bar__divider",
3888
+ role: "separator"
3889
+ }, null, -1),
3890
+ e.showStylePicker ? (z(), j(E, { key: 0 }, [N(y, de({ value: s.value.styleId ?? "Normal" }, c.value, {
3891
+ disabled: e.disabled,
3892
+ onChange: r[2] ||= (e) => a("format", {
3893
+ type: "applyStyle",
3894
+ value: e
3895
+ })
3896
+ }), null, 16, ["value", "disabled"]), r[11] ||= M("span", {
3897
+ class: "docx-formatting-bar__divider",
3898
+ role: "separator"
3899
+ }, null, -1)], 64)) : A("", !0),
3900
+ M("span", {
3901
+ class: "docx-formatting-bar__group",
3902
+ role: "group",
3903
+ "aria-label": W(o)("textFormattingGroup")
3904
+ }, [
3905
+ M("button", {
3906
+ type: "button",
3907
+ class: L(["docx-formatting-bar__btn", { "docx-formatting-bar__btn--active": s.value.bold }]),
3908
+ disabled: e.disabled,
3909
+ title: W(o)("boldShortcut"),
3910
+ "aria-label": W(o)("bold"),
3911
+ "aria-pressed": !!s.value.bold,
3912
+ onMousedown: r[3] ||= Y((e) => a("format", "bold"), ["prevent"])
3913
+ }, [N(p, {
3914
+ name: "format_bold",
3915
+ size: 18
3916
+ })], 42, ha),
3917
+ M("button", {
3918
+ type: "button",
3919
+ class: L(["docx-formatting-bar__btn", { "docx-formatting-bar__btn--active": s.value.italic }]),
3920
+ disabled: e.disabled,
3921
+ title: W(o)("italicShortcut"),
3922
+ "aria-label": W(o)("italic"),
3923
+ "aria-pressed": !!s.value.italic,
3924
+ onMousedown: r[4] ||= Y((e) => a("format", "italic"), ["prevent"])
3925
+ }, [N(p, {
3926
+ name: "format_italic",
3927
+ size: 18
3928
+ })], 42, ga),
3929
+ M("button", {
3930
+ type: "button",
3931
+ class: L(["docx-formatting-bar__btn", { "docx-formatting-bar__btn--active": s.value.underline }]),
3932
+ disabled: e.disabled,
3933
+ title: W(o)("underlineShortcut"),
3934
+ "aria-label": W(o)("underline"),
3935
+ "aria-pressed": !!s.value.underline,
3936
+ onMousedown: r[5] ||= Y((e) => a("format", "underline"), ["prevent"])
3937
+ }, [N(p, {
3938
+ name: "format_underlined",
3939
+ size: 18
3940
+ })], 42, _a)
3941
+ ], 8, ma),
3942
+ e.showTextColorPicker ? (z(), j(E, { key: 1 }, [r[12] ||= M("span", {
3943
+ class: "docx-formatting-bar__divider",
3944
+ role: "separator"
3945
+ }, null, -1), N(W(n), {
3946
+ mode: "text",
3947
+ value: u.value,
3948
+ theme: e.theme ?? null,
3949
+ disabled: e.disabled,
3950
+ onChange: m
3951
+ }, null, 8, [
3952
+ "value",
3953
+ "theme",
3954
+ "disabled"
3955
+ ])], 64)) : A("", !0),
3956
+ r[14] ||= M("span", {
3957
+ class: "docx-formatting-bar__divider",
3958
+ role: "separator"
3959
+ }, null, -1),
3960
+ e.showAlignmentButtons ? (z(), k(S, {
3961
+ key: 2,
3962
+ value: s.value.alignment ?? "left",
3963
+ disabled: e.disabled,
3964
+ onChange: r[6] ||= (e) => a("format", {
3965
+ type: "alignment",
3966
+ value: e
3967
+ })
3968
+ }, null, 8, ["value", "disabled"])) : A("", !0),
3969
+ e.showListButtons ? (z(), k(C, {
3970
+ key: 3,
3971
+ "list-state": l.value,
3972
+ disabled: e.disabled,
3973
+ "can-outdent": f.value,
3974
+ onBulletList: r[7] ||= (e) => a("format", "bulletList"),
3975
+ onNumberedList: r[8] ||= (e) => a("format", "numberedList"),
3976
+ onIndent: r[9] ||= (e) => a("format", "indent"),
3977
+ onOutdent: r[10] ||= (e) => a("format", "outdent")
3978
+ }, null, 8, [
3979
+ "list-state",
3980
+ "disabled",
3981
+ "can-outdent"
3982
+ ])) : A("", !0)
3983
+ ], 10, ua));
3984
+ }
3985
+ }), [["__scopeId", "data-v-225f770f"]]), ya = ["value", "disabled"], ba = ["value"], xa = ["value"], Sa = [
3986
+ {
3987
+ value: .5,
3988
+ label: "50%"
3989
+ },
3990
+ {
3991
+ value: .75,
3992
+ label: "75%"
3993
+ },
3994
+ {
3995
+ value: 1,
3996
+ label: "100%"
3997
+ },
3998
+ {
3999
+ value: 1.25,
4000
+ label: "125%"
4001
+ },
4002
+ {
4003
+ value: 1.5,
4004
+ label: "150%"
4005
+ },
4006
+ {
4007
+ value: 2,
4008
+ label: "200%"
4009
+ }
4010
+ ], Ca = /*#__PURE__*/ l(/* @__PURE__ */ P({
4011
+ __name: "ZoomControl",
4012
+ props: {
4013
+ value: { default: 1 },
4014
+ levels: {},
4015
+ disabled: {
4016
+ type: Boolean,
4017
+ default: !1
4018
+ },
4019
+ className: {},
4020
+ compact: {
4021
+ type: Boolean,
4022
+ default: !1
4023
+ }
4024
+ },
4025
+ emits: ["change"],
4026
+ setup(e, { emit: t }) {
4027
+ let n = e, r = t, i = O(() => n.levels ?? Sa), a = O(() => i.value.find((e) => Math.abs(e.value - n.value) < .001)), o = O(() => a.value ? a.value.label : `${Math.round(n.value * 100)}%`), s = O(() => a.value ? String(a.value.value) : String(n.value));
4028
+ function c(e) {
4029
+ if (!(e.target instanceof HTMLSelectElement)) return;
4030
+ let t = Number.parseFloat(e.target.value);
4031
+ Number.isNaN(t) || r("change", t);
4032
+ }
4033
+ return (t, n) => (z(), j("select", {
4034
+ class: L(["docx-zoom-control", [{ "docx-zoom-control--compact": e.compact }, e.className]]),
4035
+ value: s.value,
4036
+ disabled: e.disabled,
4037
+ "aria-label": "Zoom level",
4038
+ onChange: c
4039
+ }, [a.value ? A("", !0) : (z(), j("option", {
4040
+ key: 0,
4041
+ value: s.value
4042
+ }, U(o.value), 9, ba)), (z(!0), j(E, null, V(i.value, (e) => (z(), j("option", {
4043
+ key: e.value,
4044
+ value: String(e.value)
4045
+ }, U(e.label), 9, xa))), 128))], 42, ya));
4046
+ }
4047
+ }), [["__scopeId", "data-v-4408d2e8"]]), wa = (e, t, n = {}) => {
4048
+ let { locale: r = "en", ...i } = n;
4049
+ return new Promise((n, a) => {
4050
+ let o = B(null), c = null, l = !1, u = {
4051
+ save: async () => {
4052
+ let e = await (o.value?.save() ?? Promise.resolve(null));
4053
+ return e ? new Blob([e], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }) : null;
4054
+ },
4055
+ getDocument: () => o.value?.getDocument() ?? null,
4056
+ focus: () => {
4057
+ o.value?.focus();
4058
+ },
4059
+ setZoom: (e) => {
4060
+ o.value?.setZoom(e);
4061
+ },
4062
+ scrollToPosition: (e) => {
4063
+ o.value?.getEditorRef()?.scrollToPosition(e);
4064
+ },
4065
+ scrollToPage: (e) => {
4066
+ o.value?.scrollToPage(e);
4067
+ },
4068
+ destroy: () => {
4069
+ l || (l = !0, a(/* @__PURE__ */ Error("Editor was destroyed before mounting completed."))), c?.unmount(), c = null;
4070
+ }
4071
+ };
4072
+ c = oe({ setup() {
4073
+ return () => F(la, {
4074
+ ...i,
4075
+ documentBuffer: e,
4076
+ ref: o,
4077
+ onReady: () => {
4078
+ l || (l = !0, n(u));
4079
+ },
4080
+ onError: (e) => {
4081
+ i.onError?.(e), l || (l = !0, c?.unmount(), c = null, a(e));
4082
+ }
4083
+ });
4084
+ } }), c.use(s, r), c.mount(t);
4085
+ });
4086
+ };
4087
+ //#endregion
4088
+ export { mn as DEFAULT_AI_SUGGESTION_PRESETS, Dn as DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, la as DocxEditor, ee as FolioUIProvider, va as FormattingBar, Ca as ZoomControl, On as acceptAutocompleteSuggestion, kn as acceptAutocompleteWord, Fe as anonymizationDecorationsKey, An as appendAutocompleteToken, Dt as applyFolioAIEditOperations, hn as applySuggestions, jn as autocompleteSuggestionKey, Mn as autocompleteSuggestionPlugin, vn as buildPositionalText, Nn as clearAutocompleteSuggestion, St as clearTemplateSlashMenu, Ct as consumeTemplateSlashQuery, wn as createAICitationDecorationsPlugin, pn as createDocx, fn as createEmptyDocument, kt as createFolioAIEditSnapshot, a as defaultLocale, Wt as deriveBlockId, jt as diffWordSegments, Pn as finishAutocompleteSuggestion, Rn as fromMarkdown, Ie as getAnonymizationMatches, Fn as getAutocompleteSuggestion, Sn as getFolioCaretViewportRect, Gt as getFolioParaIdFromBlockId, Cn as getFolioSelectionViewportRect, at as getTemplateDirectives, wt as getTemplateSlashMenu, Mt as hashFolioAIBlockText, s as i18nPlugin, ye as insertImageFromFile, xe as insertPageBreakInView, X as insertTableInView, we as insertTableOfContentsInView, Jt as isFolioBlockId, Yt as isSequentialFolioBlockId, gn as isSuggestionStale, Nt as normalizeFolioAIBlockText, t as provideLocale, wa as renderAsync, Tt as resetTemplateSlashQuery, _n as resolveSuggestionAnchor, st as scanDirectives, xn as scrollFolioPositionIntoView, Tn as setAICitationsMeta, yn as setAISuggestionsMeta, En as setActiveCitationMeta, Re as setAnonymizationTermsMeta, bn as setFocusedSuggestionMeta, xt as setTemplatePreviewValues, In as shouldTriggerAutocomplete, Ln as startAutocompleteSuggestion, Et as templateSlashMenuKey, zn as toMarkdown, Bn as toMarkdownResult, r as useTranslation, T as useWheelZoom };