@eigenpal/docx-js-editor 0.0.30 → 0.0.32

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 (62) hide show
  1. package/dist/{ClipboardManager-D0D4aUKE.d.ts → ClipboardManager-C0rTRkVQ.d.ts} +29 -1
  2. package/dist/{ClipboardManager-t936d0KD.d.mts → ClipboardManager-CgpKW2At.d.mts} +29 -1
  3. package/dist/PageSetupDialog-2SKHDRTF.js +1 -0
  4. package/dist/PageSetupDialog-SMQJXEBL.mjs +1 -0
  5. package/dist/chunk-2HDYCD2Q.mjs +1 -0
  6. package/dist/chunk-37SLIJPH.mjs +58 -0
  7. package/dist/{chunk-KCUPCJFL.mjs → chunk-6AJI5NPH.mjs} +1 -1
  8. package/dist/chunk-7MGFEP2R.mjs +26 -0
  9. package/dist/chunk-7QTNB64A.mjs +9 -0
  10. package/dist/chunk-EEV6TUOX.mjs +261 -0
  11. package/dist/chunk-EF3LLEN7.js +4 -0
  12. package/dist/chunk-EV3CM6TU.js +1 -0
  13. package/dist/chunk-HWWZOJMR.mjs +4 -0
  14. package/dist/{chunk-VHWEKJ35.js → chunk-KCOGY3V2.js} +5 -5
  15. package/dist/chunk-KUL2SDYC.js +26 -0
  16. package/dist/chunk-P7WEP4JU.js +9 -0
  17. package/dist/{chunk-Z35FA4M4.mjs → chunk-RTFUE3KK.mjs} +5 -5
  18. package/dist/{chunk-XGL3EGKF.js → chunk-UMDJQ3Q4.js} +4 -4
  19. package/dist/chunk-WH2EK2HU.js +261 -0
  20. package/dist/chunk-ZJNGMDRE.js +58 -0
  21. package/dist/core-plugins-reexport.js +1 -1
  22. package/dist/core-plugins-reexport.mjs +1 -1
  23. package/dist/core-reexport.d.mts +2 -2
  24. package/dist/core-reexport.d.ts +2 -2
  25. package/dist/core-reexport.js +1 -1
  26. package/dist/core-reexport.mjs +1 -1
  27. package/dist/headless-reexport.js +2 -2
  28. package/dist/headless-reexport.mjs +1 -1
  29. package/dist/index.d.mts +10 -27
  30. package/dist/index.d.ts +10 -27
  31. package/dist/index.js +23 -66
  32. package/dist/index.mjs +23 -66
  33. package/dist/mcp-reexport.js +10 -10
  34. package/dist/mcp-reexport.mjs +9 -9
  35. package/dist/{react-C-pJU0Y4.d.mts → react-B2h6vE3D.d.mts} +118 -83
  36. package/dist/{react-By80Gfi-.d.ts → react-CAc4htNH.d.ts} +118 -83
  37. package/dist/react.d.mts +2 -2
  38. package/dist/react.d.ts +2 -2
  39. package/dist/react.js +1 -1
  40. package/dist/react.mjs +1 -1
  41. package/dist/selectionRects-DEX5THEG.js +1 -0
  42. package/dist/selectionRects-SQTAHMCH.mjs +1 -0
  43. package/dist/styles.css +1 -1
  44. package/dist/ui.js +1 -1
  45. package/dist/ui.mjs +1 -1
  46. package/package.json +2 -1
  47. package/dist/PageSetupDialog-3QCVUNDL.mjs +0 -1
  48. package/dist/PageSetupDialog-ZZTFPZKJ.js +0 -1
  49. package/dist/chunk-2KHL5RSD.js +0 -4
  50. package/dist/chunk-7HZRJTOL.mjs +0 -4
  51. package/dist/chunk-CQRI4YUS.mjs +0 -26
  52. package/dist/chunk-G72SXG7G.js +0 -258
  53. package/dist/chunk-I6LFWQFR.mjs +0 -59
  54. package/dist/chunk-IRO7KGGC.js +0 -59
  55. package/dist/chunk-MRWJ3GNH.js +0 -9
  56. package/dist/chunk-MVCTPHRR.mjs +0 -258
  57. package/dist/chunk-QQ63M65M.js +0 -1
  58. package/dist/chunk-TDEHAPMZ.mjs +0 -1
  59. package/dist/chunk-VR6PT4IZ.js +0 -26
  60. package/dist/chunk-YGTSQZRK.mjs +0 -9
  61. package/dist/selectionRects-6TRAXB7D.js +0 -1
  62. package/dist/selectionRects-IS7ZAS3A.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export{w as DEFAULT_SELECTION_STYLE,j as DocxEditor,a as EditorToolbar,d as ErrorBoundary,c as ErrorProvider,x as HIGH_CONTRAST_SELECTION_STYLE,U as PLUGIN_HOST_STYLES,e as ParseErrorDisplay,V as PluginHost,y as SELECTION_CSS_VARS,f as UnsupportedFeatureWarning,m as ZOOM_PRESETS,P as areSelectionStylesInjected,v as clampZoom,K as clearSelection,Q as createSelectionChangeHandler,p as findNearestZoomPreset,s as formatZoom,S as generateOverlayElements,D as generateSelectionCSS,C as getHighlightRectStyle,B as getMergedSelectionRects,q as getNextZoomPreset,r as getPreviousZoomPreset,F as getSelectedText,H as getSelectionBoundingRect,z as getSelectionRects,h as getUserFriendlyMessage,o as getZoomPresets,E as hasActiveSelection,I as highlightTextRange,N as injectSelectionStyles,g as isParseError,L as isSelectionBackwards,G as isSelectionWithin,u as isZoomPreset,A as mergeAdjacentRects,M as normalizeSelectionDirection,t as parseZoom,O as removeSelectionStyles,k as renderAsync,J as selectRange,l as useAutoSave,T as useClipboard,b as useErrorNotifications,R as useSelectionHighlight,i as useTableSelection,n as useWheelZoom}from'./chunk-MVCTPHRR.mjs';import'./chunk-TDEHAPMZ.mjs';export{k as ColorPicker,a as ContextMenu,V as InsertImageDialog,da as InsertSymbolDialog,O as InsertTableDialog,qa as KeyboardShortcutsDialog,B as LoadingIndicator,ka as PasteSpecialDialog,l as PrintButton,m as PrintStyles,g as ResponsePreview,J as ResponsiveToolbar,K as ResponsiveToolbarGroup,ca as SYMBOL_CATEGORIES,u as TableInsertButtons,t as TableMergeButton,v as UnsavedIndicator,_ as calculateFitDimensions,S as clampTableConfig,A as createChangeTracker,Q as createDefaultTableConfig,j as createErrorResponse,i as createMockResponse,L as createToolbarItem,M as createToolbarItems,$ as dataUrlToBlob,H as delay,ba as formatFileSize,r as formatPrintPageRange,xa as formatShortcutKeys,T as formatTableDimensions,c as getActionShortcut,f as getAllActions,wa as getAllCategories,z as getAllIndicatorPositions,y as getAllIndicatorVariants,G as getAllLoadingSizes,F as getAllLoadingVariants,na as getAllPasteOptions,va as getCategoryLabel,ua as getCommonShortcuts,e as getDefaultActions,oa as getDefaultPasteOption,p as getDefaultPrintOptions,sa as getDefaultShortcuts,Z as getImageAcceptString,aa as getImageDimensions,E as getLoadingVariantLabel,ma as getPasteOption,N as getRecommendedPriority,ta as getShortcutsByCategory,Y as getSupportedImageExtensions,fa as getSymbolCategories,ha as getSymbolUnicodeInfo,ga as getSymbolsByCategory,U as getTablePresets,x as getVariantLabel,d as isActionAvailable,pa as isPasteSpecialShortcut,s as isPrintSupported,X as isValidImageFile,R as isValidTableConfig,o as openPrintWindow,q as parsePageRange,ia as searchSymbols,ja as symbolFromCodePoint,n as triggerPrint,b as useContextMenu,W as useInsertImageDialog,ea as useInsertSymbolDialog,P as useInsertTableDialog,ra as useKeyboardShortcutsDialog,C as useLoading,D as useLoadingOperations,la as usePasteSpecial,h as useResponsePreview,I as useResponsiveToolbar,w as useUnsavedChanges}from'./chunk-KCUPCJFL.mjs';export{k as AdvancedColorPicker,l as AlignmentButtons,K as CLIPBOARD_TYPES,g as FontPicker,j as FontSizePicker,y as FormattingBar,E as HorizontalRuler,J as INTERNAL_CLIPBOARD_TYPE,o as LineSpacingPicker,m as ListButtons,p as StylePicker,s as TableBorderColorPicker,r as TableBorderPicker,t as TableBorderWidthPicker,u as TableCellFillPicker,v as TableMoreDropdown,da as TableToolbar,Z as TextContextMenu,D as Toolbar,A as ToolbarButton,B as ToolbarGroup,C as ToolbarSeparator,q as ZoomControl,ja as addColumn,ha as addRow,W as cleanWordHtml,N as copyParagraphs,M as copyRuns,Y as createClipboardHandlers,n as createDefaultListState,ea as createTableContext,ka as deleteColumn,ia as deleteRow,ga as getCellAt,fa as getColumnCount,ba as getDefaultTextContextMenuItems,H as getMarginInUnits,G as getRulerDimensions,$ as getTextActionLabel,aa as getTextActionShortcut,S as handlePasteEvent,X as htmlToRuns,V as isEditorHtml,ca as isTextActionAvailable,U as isWordHtml,la as mergeCells,P as paragraphsToClipboardContent,T as parseClipboardHtml,I as parseMarginFromUnits,F as positionToMargin,R as readFromClipboard,O as runsToClipboardContent,ma as splitCell,_ as useTextContextMenu,Q as writeToClipboard}from'./chunk-7HZRJTOL.mjs';export{n as FindReplaceDialog,a as createDefaultFindOptions,c as createSearchPattern,b as escapeRegexString,d as findAllMatches,j as findInDocument,k as findInParagraph,i as getDefaultHighlightOptions,g as getMatchCountText,h as isEmptySearch,e as replaceAllInContent,f as replaceFirstInContent,l as scrollToMatch,m as useFindReplace}from'./chunk-XWBCP563.mjs';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-AZRYS2WF.mjs';export{x as TABLE_DATA_ATTRIBUTES,n as countPageBreaks,b as createColumnBreak,g as createHorizontalRule,c as createLineBreak,a as createPageBreak,e as createPageBreakParagraph,d as createPageBreakRun,F as createSelectionFromDOM,o as findPageBreaks,s as formatLastSaveTime,v as formatStorageSize,t as getAutoSaveStatusLabel,u as getAutoSaveStorageSize,E as getSelectionRuns,m as hasPageBreakBefore,h as insertHorizontalRule,f as insertPageBreak,w as isAutoSaveSupported,l as isBreakContent,j as isColumnBreak,k as isLineBreak,i as isPageBreak,p as removePageBreak}from'./chunk-QTSXJRP6.mjs';import'./chunk-6WPRCJ5A.mjs';export{f as DocumentAgent,m as buildExtendedSelectionContext,l as buildSelectionContext,e as createDocumentWithText,d as createEmptyDocument,i as getAgentContext,k as getDocumentSummary}from'./chunk-YGTSQZRK.mjs';export{l as blendColors,q as colorsEqual,i as createRgbColor,h as createThemeColor,j as darkenColor,f as getContrastingColor,d as isBlack,e as isWhite,k as lightenColor,g as parseColorString,a as resolveColor,b as resolveHighlightColor,c as resolveShadingColor}from'./chunk-QAZ4233N.mjs';export{o as docxtemplaterPlugin}from'./chunk-Z35FA4M4.mjs';export{e as getTemplateTags,a as processTemplate,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-DLVLK5FT.mjs';export{b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties}from'./chunk-I6LFWQFR.mjs';export{a as executeCommand,b as executeCommands}from'./chunk-M5F4SK3W.mjs';export{i as canRenderFont,g as getLoadedFonts,e as isFontLoaded,f as isFontsLoading,c as loadFont,j as loadFontFromBuffer,d as loadFonts,h as onFontsLoaded,n as parseDocx,k as preloadCommonFonts,m as toArrayBuffer}from'./chunk-CQRI4YUS.mjs';export{a as PluginRegistry,b as pluginRegistry,c as registerPlugins}from'./chunk-W53SI3XW.mjs';export{c as emuToPixels,e as emuToTwips,k as formatPx,h as halfPointsToPixels,d as pixelsToEmu,b as pixelsToTwips,g as pointsToPixels,f as twipsToEmu,a as twipsToPixels}from'./chunk-LYBG4YI7.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-TAUMSKRE.mjs';import ye,{useState,useRef,useMemo,useCallback,useEffect}from'react';import {PluginKey,TextSelection,Plugin}from'prosemirror-state';import {DecorationSet,Decoration}from'prosemirror-view';import {jsx,jsxs}from'react/jsx-runtime';var Ra=/[\p{L}\p{N}''\-]/u,Aa=/\s/;function M(e){return !e||e.length===0?false:Ra.test(e)}function K(e){return !e||e.length===0?false:Aa.test(e)}function R(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let o=e[t];if(K(o)){let n=t,r=t;for(;n>0&&K(e[n-1]);)n--;for(;r<e.length&&K(e[r]);)r++;return [n,r]}if(M(o)){let n=t,r=t;for(;n>0&&M(e[n-1]);)n--;for(;r<e.length&&M(e[r]);)r++;return [n,r]}return [t,t+1]}function wa(e,t){let[o,n]=R(e,t);return e.slice(o,n)}function Ia(e,t){let[o,n]=R(e,t);return {word:e.slice(o,n),startIndex:o,endIndex:n}}function $(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),o=t.startContainer;if(o.nodeType===Node.TEXT_NODE){let n=o.textContent||"",r=t.startOffset,[a,i]=R(n,r);if(i>a)return t.setStart(o,a),t.setEnd(o,i),e.removeAllRanges(),e.addRange(t),true}if(o.nodeType===Node.ELEMENT_NODE){let n=o,r=q(n);if(r.length>0){let a=t.startOffset,i=null,l=a;if(a<n.childNodes.length){let p=n.childNodes[a];if(p.nodeType===Node.TEXT_NODE)i=p,l=0;else if(p instanceof Element){let d=q(p);d.length>0&&(i=d[0],l=0);}}if(!i&&r.length>0&&(i=r[0],l=0),i){let p=i.textContent||"",[d,c]=R(p,l);if(c>d){let u=document.createRange();return u.setStart(i,d),u.setEnd(i,c),e.removeAllRanges(),e.addRange(u),true}}}}return false}function Na(e,t){let o=window.getSelection();if(!o)return false;let n=e.textContent||"",[r,a]=R(n,t);if(a>r){let i=document.createRange();return i.setStart(e,r),i.setEnd(e,a),o.removeAllRanges(),o.addRange(i),true}return false}function Oa(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return $();let o=t.startContainer,n=t.endContainer,r=t.startOffset,a=t.endOffset;if(o.nodeType===Node.TEXT_NODE){let i=o.textContent||"",[l]=R(i,t.startOffset);r=l;}if(n.nodeType===Node.TEXT_NODE){let i=n.textContent||"",l=Math.max(0,t.endOffset-1),[,p]=R(i,l);a=p;}try{return t.setStart(o,r),t.setEnd(n,a),e.removeAllRanges(),e.addRange(t),!0}catch(i){return console.warn("Could not expand selection to word boundaries:",i),false}}function J(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let o=e.getRangeAt(0).commonAncestorContainer,n=Da(o);if(n){let r=document.createRange();return r.selectNodeContents(n),e.removeAllRanges(),e.addRange(r),true}return false}function Da(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function q(e){let t=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),n;for(;n=o.nextNode();)n.nodeType===Node.TEXT_NODE&&t.push(n);return t}var V=0,O=null,G=null,La=500;function j(){V=0,G=null,O&&(clearTimeout(O),O=null);}function Q(e){return e.target!==G&&j(),V++,G=e.target,O&&clearTimeout(O),O=setTimeout(j,La),Math.min(V,3)}function ka(){return e=>{e.ctrlKey||e.metaKey||e.altKey||$();}}function Ma(){return e=>{if(Q(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;J();}}}function P(e){return e?/[\p{L}\p{N}_]/u.test(e):false}function Y(e){return e?/\s/.test(e):false}function Ka(e){return e?/[\p{P}]/u.test(e):false}function Ha(e,t){if(t<=0)return 0;t>e.length&&(t=e.length);let o=t;for(;o>0&&Y(e[o-1]);)o--;if(o===0)return 0;for(;o>0&&P(e[o-1]);)o--;return o}function _a(e,t){if(t>=e.length)return e.length;t<0&&(t=0);let o=t;for(;o<e.length&&P(e[o]);)o++;for(;o<e.length&&Y(e[o]);)o++;return o}function ee(e,t){if(t>=e.length)return e.length;let o=t;for(;o<e.length&&P(e[o]);)o++;for(;o<e.length&&!P(e[o]);)o++;return o}function te(e,t){if(t<=0)return 0;let o=t;for(;o>0&&!P(e[o-1]);)o--;for(;o>0&&P(e[o-1]);)o--;return o}function oe(e,t){if(!window.getSelection())return null;let n=document.createRange();if(e.nodeType===Node.TEXT_NODE){n.setStart(e,Math.min(t,e.textContent?.length||0)),n.collapse(true);let a=n.getBoundingClientRect().top,i=0,l=t;for(;i<l;){let p=Math.floor((i+l)/2);n.setStart(e,p),n.collapse(true);let d=n.getBoundingClientRect();Math.abs(d.top-a)<2?l=p:i=p+1;}return {node:e,offset:i}}return null}function ne(e,t){if(!window.getSelection())return null;let n=e.textContent?.length||0,r=document.createRange();if(e.nodeType===Node.TEXT_NODE){r.setStart(e,Math.min(t,n)),r.collapse(true);let i=r.getBoundingClientRect().top,l=t,p=n;for(;l<p;){let d=Math.ceil((l+p)/2);r.setStart(e,d),r.collapse(true);let c=r.getBoundingClientRect();Math.abs(c.top-i)<2?l=d:p=d-1;}return {node:e,offset:l}}return null}function Ba(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return {node:t.startContainer,offset:t.startOffset,anchorNode:e.anchorNode,anchorOffset:e.anchorOffset,focusNode:e.focusNode,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,text:e.toString()}}function H(e,t){let o=window.getSelection();if(!o)return;let n=document.createRange(),r=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;n.setStart(e,Math.min(t,r)),n.collapse(true),o.removeAllRanges(),o.addRange(n);}function _(e,t){let o=window.getSelection();if(!(!o||!o.anchorNode))try{o.extend(e,Math.min(t,e.textContent?.length||0));}catch{let n=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;o.setBaseAndExtent(o.anchorNode,o.anchorOffset,e,Math.min(t,n));}}function re(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let n=o.focusNode;if(!n||n.nodeType!==Node.TEXT_NODE)return false;let r=n.textContent||"",a=o.focusOffset,i;return e==="left"?i=te(r,a):i=ee(r,a),t?_(n,i):H(n,i),true}function ae(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let n=o.focusNode;if(!n)return false;if(n.nodeType===Node.TEXT_NODE){let i=e==="start"?oe(n,o.focusOffset):ne(n,o.focusOffset);if(i)return t?_(i.node,i.offset):H(i.node,i.offset),true}let r=n.textContent||"",a=e==="start"?0:r.length;return t?_(n,a):H(n,a),true}function ie(e){let{key:t,ctrlKey:o,metaKey:n,shiftKey:r,altKey:a}=e,i=o||n;switch(t){case "ArrowLeft":if(i)return {direction:"left",unit:"word",extend:r};break;case "ArrowRight":if(i)return {direction:"right",unit:"word",extend:r};break;case "Home":return i?{direction:"left",unit:"document",extend:r}:{direction:"left",unit:"line",extend:r};case "End":return i?{direction:"right",unit:"document",extend:r}:{direction:"right",unit:"line",extend:r}}return null}function Wa(e,t){let o=ie(e);if(!o)return false;switch(o.unit){case "word":if((o.direction==="left"||o.direction==="right")&&re(o.direction,o.extend))return e.preventDefault(),true;break;case "line":let n=o.direction==="left"?"start":"end";if(ae(n,o.extend))return e.preventDefault(),true;break;case "document":if(o.direction==="left"&&t?.onDocumentStart)return e.preventDefault(),t.onDocumentStart(),true;if(o.direction==="right"&&t?.onDocumentEnd)return e.preventDefault(),t.onDocumentEnd(),true;break}return false}function Fa(e){let{key:t,ctrlKey:o,metaKey:n}=e;return !!((o||n)&&(t==="ArrowLeft"||t==="ArrowRight")||t==="Home"||t==="End")}function Ua(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return false;let o=t.textContent||"",n=e.focusOffset,r=n,a=n;for(;r>0&&P(o[r-1]);)r--;for(;a<o.length&&P(o[a]);)a++;if(r===a)return false;let i=document.createRange();return i.setStart(t,r),i.setEnd(t,a),e.removeAllRanges(),e.addRange(i),true}function za(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return null;let o=t.textContent||"",n=e.focusOffset,r=n,a=n;for(;r>0&&P(o[r-1]);)r--;for(;a<o.length&&P(o[a]);)a++;return r===a?null:o.slice(r,a)}function Va(e,t){let o=e.ctrlKey||e.metaKey,n=t.ctrlKey||t.metaKey;return e.key.toLowerCase()===t.key.toLowerCase()&&o===!!n&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}var T={wordLeft:{key:"ArrowLeft",ctrlKey:true},wordRight:{key:"ArrowRight",ctrlKey:true},selectWordLeft:{key:"ArrowLeft",ctrlKey:true,shiftKey:true},selectWordRight:{key:"ArrowRight",ctrlKey:true,shiftKey:true},lineStart:{key:"Home"},lineEnd:{key:"End"},selectToLineStart:{key:"Home",shiftKey:true},selectToLineEnd:{key:"End",shiftKey:true},documentStart:{key:"Home",ctrlKey:true},documentEnd:{key:"End",ctrlKey:true},selectToDocumentStart:{key:"Home",ctrlKey:true,shiftKey:true},selectToDocumentEnd:{key:"End",ctrlKey:true,shiftKey:true}};function S(e){let t=[];if(e.ctrlKey||e.metaKey){let n=typeof navigator<"u"&&/Mac/i.test(navigator.platform);t.push(n?"\u2318":"Ctrl");}e.shiftKey&&t.push("Shift"),e.altKey&&t.push("Alt");let o=e.key;return o==="ArrowLeft"?o="\u2190":o==="ArrowRight"?o="\u2192":o==="ArrowUp"?o="\u2191":o==="ArrowDown"&&(o="\u2193"),t.push(o),t.join("+")}function Ga(){return [{action:"Move by word (left)",shortcut:S(T.wordLeft)},{action:"Move by word (right)",shortcut:S(T.wordRight)},{action:"Select word (left)",shortcut:S(T.selectWordLeft)},{action:"Select word (right)",shortcut:S(T.selectWordRight)},{action:"Go to line start",shortcut:S(T.lineStart)},{action:"Go to line end",shortcut:S(T.lineEnd)},{action:"Select to line start",shortcut:S(T.selectToLineStart)},{action:"Select to line end",shortcut:S(T.selectToLineEnd)},{action:"Go to document start",shortcut:S(T.documentStart)},{action:"Go to document end",shortcut:S(T.documentEnd)},{action:"Select to document start",shortcut:S(T.selectToDocumentStart)},{action:"Select to document end",shortcut:S(T.selectToDocumentEnd)}]}var se=/\{([#/^@]?)([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}/g,m=new PluginKey("template");function Xa(e,t,o){return `${e}:${t}:${o}`}function le(e){let t=[];e.descendants((p,d)=>(p.isText&&p.text&&t.push({text:p.text,pos:d}),true));let o="",n=[];for(let p of t){for(let d=0;d<p.text.length;d++)n.push(p.pos+d);o+=p.text;}let r=[],a=[],i=new Map,l;for(se.lastIndex=0;(l=se.exec(o))!==null;){let[p,d,c]=l,u=n[l.index],x=n[l.index+p.length-1]+1,g;d==="#"?g="sectionStart":d==="/"?g="sectionEnd":d==="^"?g="invertedStart":d==="@"?g="raw":g="variable";let b=`${g}:${c}`,k=i.get(b)??0;i.set(b,k+1);let w={id:Xa(g,c,k),type:g,name:c,rawTag:p,from:u,to:x};if(g==="sectionStart"||g==="invertedStart")w.nestedVars=[],a.push(w);else if(g==="sectionEnd"){for(let s=a.length-1;s>=0;s--)if(a[s].name===c){a.splice(s,1);break}}else g==="variable"&&a.length>0&&(a[a.length-1].nestedVars?.push(c),w.insideSection=true);r.push(w);}return r}function qa(e){switch(e){case "sectionStart":case "sectionEnd":return "#3b82f6";case "invertedStart":return "#8b5cf6";case "raw":return "#ef4444";default:return "#f59e0b"}}function Z(e,t,o,n){let r=[];for(let a of t){let i=a.id===o,l=a.id===n,p=qa(a.type),d=["docx-template-tag"];i&&d.push("hovered"),l&&d.push("selected"),r.push(Decoration.inline(a.from,a.to,{class:d.join(" "),"data-tag-id":a.id,style:`background-color: ${p}22; border-radius: 2px;`}));}return DecorationSet.create(e,r)}function ja(e,t){if(e.length!==t.length)return false;for(let o=0;o<e.length;o++)if(e[o].id!==t[o].id)return false;return true}function B(){return new Plugin({key:m,state:{init(e,t){let o=le(t.doc);return {tags:o,decorations:Z(t.doc,o)}},apply(e,t,o,n){if(e.docChanged){let a=le(n.doc),i=ja(t.tags,a);return {tags:a,decorations:i?t.decorations.map(e.mapping,e.doc):Z(n.doc,a,t.hoveredId,t.selectedId),hoveredId:t.hoveredId,selectedId:t.selectedId}}let r=e.getMeta(m);if(r){let a=r.hoveredId??t.hoveredId,i=r.selectedId??t.selectedId;return {...t,hoveredId:a,selectedId:i,decorations:Z(n.doc,t.tags,a,i)}}return {...t,decorations:t.decorations.map(e.mapping,e.doc)}}},props:{decorations(e){return m.getState(e)?.decorations??DecorationSet.empty},handleClick(e,t){let n=(m.getState(e.state)?.tags??[]).find(a=>t>=a.from&&t<=a.to);return n?(e.dispatch(e.state.tr.setMeta(m,{selectedId:n.id})),true):(m.getState(e.state)?.selectedId&&e.dispatch(e.state.tr.setMeta(m,{selectedId:void 0})),false)},handleDOMEvents:{mouseover(e,t){let n=t.target.closest?.("[data-tag-id]")?.getAttribute("data-tag-id")||void 0,r=m.getState(e.state)?.hoveredId;return n!==r&&e.dispatch(e.state.tr.setMeta(m,{hoveredId:n})),false},mouseout(e,t){return t.relatedTarget?.closest?.("[data-tag-id]")||m.getState(e.state)?.hoveredId&&e.dispatch(e.state.tr.setMeta(m,{hoveredId:void 0})),false}}}})}function pe(e){return m.getState(e)?.tags??[]}function D(e,t){e.dispatch(e.state.tr.setMeta(m,{hoveredId:t}));}function L(e,t){e.dispatch(e.state.tr.setMeta(m,{selectedId:t}));}var W=`
1
+ export{w as DEFAULT_SELECTION_STYLE,j as DocxEditor,a as EditorToolbar,d as ErrorBoundary,c as ErrorProvider,x as HIGH_CONTRAST_SELECTION_STYLE,U as PLUGIN_HOST_STYLES,e as ParseErrorDisplay,V as PluginHost,y as SELECTION_CSS_VARS,f as UnsupportedFeatureWarning,m as ZOOM_PRESETS,P as areSelectionStylesInjected,v as clampZoom,K as clearSelection,Q as createSelectionChangeHandler,p as findNearestZoomPreset,s as formatZoom,S as generateOverlayElements,D as generateSelectionCSS,C as getHighlightRectStyle,B as getMergedSelectionRects,q as getNextZoomPreset,r as getPreviousZoomPreset,F as getSelectedText,H as getSelectionBoundingRect,z as getSelectionRects,h as getUserFriendlyMessage,o as getZoomPresets,E as hasActiveSelection,I as highlightTextRange,N as injectSelectionStyles,g as isParseError,L as isSelectionBackwards,G as isSelectionWithin,u as isZoomPreset,A as mergeAdjacentRects,M as normalizeSelectionDirection,t as parseZoom,O as removeSelectionStyles,k as renderAsync,J as selectRange,l as useAutoSave,T as useClipboard,b as useErrorNotifications,R as useSelectionHighlight,i as useTableSelection,n as useWheelZoom}from'./chunk-EEV6TUOX.mjs';import'./chunk-2HDYCD2Q.mjs';export{k as ColorPicker,a as ContextMenu,V as InsertImageDialog,da as InsertSymbolDialog,O as InsertTableDialog,qa as KeyboardShortcutsDialog,B as LoadingIndicator,ka as PasteSpecialDialog,l as PrintButton,m as PrintStyles,g as ResponsePreview,J as ResponsiveToolbar,K as ResponsiveToolbarGroup,ca as SYMBOL_CATEGORIES,u as TableInsertButtons,t as TableMergeButton,v as UnsavedIndicator,_ as calculateFitDimensions,S as clampTableConfig,A as createChangeTracker,Q as createDefaultTableConfig,j as createErrorResponse,i as createMockResponse,L as createToolbarItem,M as createToolbarItems,$ as dataUrlToBlob,H as delay,ba as formatFileSize,r as formatPrintPageRange,xa as formatShortcutKeys,T as formatTableDimensions,c as getActionShortcut,f as getAllActions,wa as getAllCategories,z as getAllIndicatorPositions,y as getAllIndicatorVariants,G as getAllLoadingSizes,F as getAllLoadingVariants,na as getAllPasteOptions,va as getCategoryLabel,ua as getCommonShortcuts,e as getDefaultActions,oa as getDefaultPasteOption,p as getDefaultPrintOptions,sa as getDefaultShortcuts,Z as getImageAcceptString,aa as getImageDimensions,E as getLoadingVariantLabel,ma as getPasteOption,N as getRecommendedPriority,ta as getShortcutsByCategory,Y as getSupportedImageExtensions,fa as getSymbolCategories,ha as getSymbolUnicodeInfo,ga as getSymbolsByCategory,U as getTablePresets,x as getVariantLabel,d as isActionAvailable,pa as isPasteSpecialShortcut,s as isPrintSupported,X as isValidImageFile,R as isValidTableConfig,o as openPrintWindow,q as parsePageRange,ia as searchSymbols,ja as symbolFromCodePoint,n as triggerPrint,b as useContextMenu,W as useInsertImageDialog,ea as useInsertSymbolDialog,P as useInsertTableDialog,ra as useKeyboardShortcutsDialog,C as useLoading,D as useLoadingOperations,la as usePasteSpecial,h as useResponsePreview,I as useResponsiveToolbar,w as useUnsavedChanges}from'./chunk-6AJI5NPH.mjs';export{k as AdvancedColorPicker,l as AlignmentButtons,K as CLIPBOARD_TYPES,g as FontPicker,j as FontSizePicker,y as FormattingBar,E as HorizontalRuler,J as INTERNAL_CLIPBOARD_TYPE,o as LineSpacingPicker,m as ListButtons,p as StylePicker,s as TableBorderColorPicker,r as TableBorderPicker,t as TableBorderWidthPicker,u as TableCellFillPicker,v as TableMoreDropdown,da as TableToolbar,Z as TextContextMenu,D as Toolbar,A as ToolbarButton,B as ToolbarGroup,C as ToolbarSeparator,q as ZoomControl,ja as addColumn,ha as addRow,W as cleanWordHtml,N as copyParagraphs,M as copyRuns,Y as createClipboardHandlers,n as createDefaultListState,ea as createTableContext,ka as deleteColumn,ia as deleteRow,ga as getCellAt,fa as getColumnCount,ba as getDefaultTextContextMenuItems,H as getMarginInUnits,G as getRulerDimensions,$ as getTextActionLabel,aa as getTextActionShortcut,S as handlePasteEvent,X as htmlToRuns,V as isEditorHtml,ca as isTextActionAvailable,U as isWordHtml,la as mergeCells,P as paragraphsToClipboardContent,T as parseClipboardHtml,I as parseMarginFromUnits,F as positionToMargin,R as readFromClipboard,O as runsToClipboardContent,ma as splitCell,_ as useTextContextMenu,Q as writeToClipboard}from'./chunk-HWWZOJMR.mjs';export{n as FindReplaceDialog,a as createDefaultFindOptions,c as createSearchPattern,b as escapeRegexString,d as findAllMatches,j as findInDocument,k as findInParagraph,i as getDefaultHighlightOptions,g as getMatchCountText,h as isEmptySearch,e as replaceAllInContent,f as replaceFirstInContent,l as scrollToMatch,m as useFindReplace}from'./chunk-XWBCP563.mjs';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-AZRYS2WF.mjs';export{x as TABLE_DATA_ATTRIBUTES,n as countPageBreaks,b as createColumnBreak,g as createHorizontalRule,c as createLineBreak,a as createPageBreak,e as createPageBreakParagraph,d as createPageBreakRun,F as createSelectionFromDOM,o as findPageBreaks,s as formatLastSaveTime,v as formatStorageSize,t as getAutoSaveStatusLabel,u as getAutoSaveStorageSize,E as getSelectionRuns,m as hasPageBreakBefore,h as insertHorizontalRule,f as insertPageBreak,w as isAutoSaveSupported,l as isBreakContent,j as isColumnBreak,k as isLineBreak,i as isPageBreak,p as removePageBreak}from'./chunk-QTSXJRP6.mjs';import'./chunk-6WPRCJ5A.mjs';export{f as DocumentAgent,m as buildExtendedSelectionContext,l as buildSelectionContext,e as createDocumentWithText,d as createEmptyDocument,i as getAgentContext,k as getDocumentSummary}from'./chunk-7QTNB64A.mjs';export{l as blendColors,q as colorsEqual,i as createRgbColor,h as createThemeColor,j as darkenColor,f as getContrastingColor,d as isBlack,e as isWhite,k as lightenColor,g as parseColorString,a as resolveColor,b as resolveHighlightColor,c as resolveShadingColor}from'./chunk-QAZ4233N.mjs';export{o as docxtemplaterPlugin}from'./chunk-RTFUE3KK.mjs';export{e as getTemplateTags,a as processTemplate,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-DLVLK5FT.mjs';export{b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties}from'./chunk-37SLIJPH.mjs';export{a as executeCommand,b as executeCommands}from'./chunk-M5F4SK3W.mjs';export{i as canRenderFont,g as getLoadedFonts,e as isFontLoaded,f as isFontsLoading,c as loadFont,j as loadFontFromBuffer,d as loadFonts,h as onFontsLoaded,n as parseDocx,k as preloadCommonFonts,m as toArrayBuffer}from'./chunk-7MGFEP2R.mjs';export{a as PluginRegistry,b as pluginRegistry,c as registerPlugins}from'./chunk-W53SI3XW.mjs';export{c as emuToPixels,e as emuToTwips,k as formatPx,h as halfPointsToPixels,d as pixelsToEmu,b as pixelsToTwips,g as pointsToPixels,f as twipsToEmu,a as twipsToPixels}from'./chunk-LYBG4YI7.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-TAUMSKRE.mjs';import ae,{useState,useCallback,useMemo,useEffect}from'react';import {PluginKey,TextSelection,Plugin}from'prosemirror-state';import {DecorationSet,Decoration}from'prosemirror-view';import {jsx,jsxs}from'react/jsx-runtime';var yi=/[\p{L}\p{N}''\-]/u,hi=/\s/;function R(e){return !e||e.length===0?false:yi.test(e)}function v(e){return !e||e.length===0?false:hi.test(e)}function S(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let o=e[t];if(v(o)){let r=t,n=t;for(;r>0&&v(e[r-1]);)r--;for(;n<e.length&&v(e[n]);)n++;return [r,n]}if(R(o)){let r=t,n=t;for(;r>0&&R(e[r-1]);)r--;for(;n<e.length&&R(e[n]);)n++;return [r,n]}return [t,t+1]}function Ti(e,t){let[o,r]=S(e,t);return e.slice(o,r)}function Si(e,t){let[o,r]=S(e,t);return {word:e.slice(o,r),startIndex:o,endIndex:r}}function L(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),o=t.startContainer;if(o.nodeType===Node.TEXT_NODE){let r=o.textContent||"",n=t.startOffset,[i,a]=S(r,n);if(a>i)return t.setStart(o,i),t.setEnd(o,a),e.removeAllRanges(),e.addRange(t),true}if(o.nodeType===Node.ELEMENT_NODE){let r=o,n=B(r);if(n.length>0){let i=t.startOffset,a=null,l=i;if(i<r.childNodes.length){let s=r.childNodes[i];if(s.nodeType===Node.TEXT_NODE)a=s,l=0;else if(s instanceof Element){let c=B(s);c.length>0&&(a=c[0],l=0);}}if(!a&&n.length>0&&(a=n[0],l=0),a){let s=a.textContent||"",[c,d]=S(s,l);if(d>c){let g=document.createRange();return g.setStart(a,c),g.setEnd(a,d),e.removeAllRanges(),e.addRange(g),true}}}}return false}function xi(e,t){let o=window.getSelection();if(!o)return false;let r=e.textContent||"",[n,i]=S(r,t);if(i>n){let a=document.createRange();return a.setStart(e,n),a.setEnd(e,i),o.removeAllRanges(),o.addRange(a),true}return false}function bi(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return L();let o=t.startContainer,r=t.endContainer,n=t.startOffset,i=t.endOffset;if(o.nodeType===Node.TEXT_NODE){let a=o.textContent||"",[l]=S(a,t.startOffset);n=l;}if(r.nodeType===Node.TEXT_NODE){let a=r.textContent||"",l=Math.max(0,t.endOffset-1),[,s]=S(a,l);i=s;}try{return t.setStart(o,n),t.setEnd(r,i),e.removeAllRanges(),e.addRange(t),!0}catch(a){return console.warn("Could not expand selection to word boundaries:",a),false}}function W(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let o=e.getRangeAt(0).commonAncestorContainer,r=Pi(o);if(r){let n=document.createRange();return n.selectNodeContents(r),e.removeAllRanges(),e.addRange(n),true}return false}function Pi(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function B(e){let t=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),r;for(;r=o.nextNode();)r.nodeType===Node.TEXT_NODE&&t.push(r);return t}var O=0,x=null,k=null,Ci=500;function _(){O=0,k=null,x&&(clearTimeout(x),x=null);}function F(e){return e.target!==k&&_(),O++,k=e.target,x&&clearTimeout(x),x=setTimeout(_,Ci),Math.min(O,3)}function Ei(){return e=>{e.ctrlKey||e.metaKey||e.altKey||L();}}function Ri(){return e=>{if(F(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;W();}}}function y(e){return e?/[\p{L}\p{N}_]/u.test(e):false}function M(e){return e?/\s/.test(e):false}function vi(e){return e?/[\p{P}]/u.test(e):false}function wi(e,t){if(t<=0)return 0;t>e.length&&(t=e.length);let o=t;for(;o>0&&M(e[o-1]);)o--;if(o===0)return 0;for(;o>0&&y(e[o-1]);)o--;return o}function Ii(e,t){if(t>=e.length)return e.length;t<0&&(t=0);let o=t;for(;o<e.length&&y(e[o]);)o++;for(;o<e.length&&M(e[o]);)o++;return o}function U(e,t){if(t>=e.length)return e.length;let o=t;for(;o<e.length&&y(e[o]);)o++;for(;o<e.length&&!y(e[o]);)o++;return o}function V(e,t){if(t<=0)return 0;let o=t;for(;o>0&&!y(e[o-1]);)o--;for(;o>0&&y(e[o-1]);)o--;return o}function z(e,t){if(!window.getSelection())return null;let r=document.createRange();if(e.nodeType===Node.TEXT_NODE){r.setStart(e,Math.min(t,e.textContent?.length||0)),r.collapse(true);let i=r.getBoundingClientRect().top,a=0,l=t;for(;a<l;){let s=Math.floor((a+l)/2);r.setStart(e,s),r.collapse(true);let c=r.getBoundingClientRect();Math.abs(c.top-i)<2?l=s:a=s+1;}return {node:e,offset:a}}return null}function G(e,t){if(!window.getSelection())return null;let r=e.textContent?.length||0,n=document.createRange();if(e.nodeType===Node.TEXT_NODE){n.setStart(e,Math.min(t,r)),n.collapse(true);let a=n.getBoundingClientRect().top,l=t,s=r;for(;l<s;){let c=Math.ceil((l+s)/2);n.setStart(e,c),n.collapse(true);let d=n.getBoundingClientRect();Math.abs(d.top-a)<2?l=c:s=c-1;}return {node:e,offset:l}}return null}function Ai(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return {node:t.startContainer,offset:t.startOffset,anchorNode:e.anchorNode,anchorOffset:e.anchorOffset,focusNode:e.focusNode,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,text:e.toString()}}function w(e,t){let o=window.getSelection();if(!o)return;let r=document.createRange(),n=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;r.setStart(e,Math.min(t,n)),r.collapse(true),o.removeAllRanges(),o.addRange(r);}function I(e,t){let o=window.getSelection();if(!(!o||!o.anchorNode))try{o.extend(e,Math.min(t,e.textContent?.length||0));}catch{let r=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;o.setBaseAndExtent(o.anchorNode,o.anchorOffset,e,Math.min(t,r));}}function $(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let r=o.focusNode;if(!r||r.nodeType!==Node.TEXT_NODE)return false;let n=r.textContent||"",i=o.focusOffset,a;return e==="left"?a=V(n,i):a=U(n,i),t?I(r,a):w(r,a),true}function Z(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let r=o.focusNode;if(!r)return false;if(r.nodeType===Node.TEXT_NODE){let a=e==="start"?z(r,o.focusOffset):G(r,o.focusOffset);if(a)return t?I(a.node,a.offset):w(a.node,a.offset),true}let n=r.textContent||"",i=e==="start"?0:n.length;return t?I(r,i):w(r,i),true}function X(e){let{key:t,ctrlKey:o,metaKey:r,shiftKey:n,altKey:i}=e,a=o||r;switch(t){case "ArrowLeft":if(a)return {direction:"left",unit:"word",extend:n};break;case "ArrowRight":if(a)return {direction:"right",unit:"word",extend:n};break;case "Home":return a?{direction:"left",unit:"document",extend:n}:{direction:"left",unit:"line",extend:n};case "End":return a?{direction:"right",unit:"document",extend:n}:{direction:"right",unit:"line",extend:n}}return null}function Ni(e,t){let o=X(e);if(!o)return false;switch(o.unit){case "word":if((o.direction==="left"||o.direction==="right")&&$(o.direction,o.extend))return e.preventDefault(),true;break;case "line":let r=o.direction==="left"?"start":"end";if(Z(r,o.extend))return e.preventDefault(),true;break;case "document":if(o.direction==="left"&&t?.onDocumentStart)return e.preventDefault(),t.onDocumentStart(),true;if(o.direction==="right"&&t?.onDocumentEnd)return e.preventDefault(),t.onDocumentEnd(),true;break}return false}function Di(e){let{key:t,ctrlKey:o,metaKey:r}=e;return !!((o||r)&&(t==="ArrowLeft"||t==="ArrowRight")||t==="Home"||t==="End")}function Oi(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return false;let o=t.textContent||"",r=e.focusOffset,n=r,i=r;for(;n>0&&y(o[n-1]);)n--;for(;i<o.length&&y(o[i]);)i++;if(n===i)return false;let a=document.createRange();return a.setStart(t,n),a.setEnd(t,i),e.removeAllRanges(),e.addRange(a),true}function ki(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return null;let o=t.textContent||"",r=e.focusOffset,n=r,i=r;for(;n>0&&y(o[n-1]);)n--;for(;i<o.length&&y(o[i]);)i++;return n===i?null:o.slice(n,i)}function Li(e,t){let o=e.ctrlKey||e.metaKey,r=t.ctrlKey||t.metaKey;return e.key.toLowerCase()===t.key.toLowerCase()&&o===!!r&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}var f={wordLeft:{key:"ArrowLeft",ctrlKey:true},wordRight:{key:"ArrowRight",ctrlKey:true},selectWordLeft:{key:"ArrowLeft",ctrlKey:true,shiftKey:true},selectWordRight:{key:"ArrowRight",ctrlKey:true,shiftKey:true},lineStart:{key:"Home"},lineEnd:{key:"End"},selectToLineStart:{key:"Home",shiftKey:true},selectToLineEnd:{key:"End",shiftKey:true},documentStart:{key:"Home",ctrlKey:true},documentEnd:{key:"End",ctrlKey:true},selectToDocumentStart:{key:"Home",ctrlKey:true,shiftKey:true},selectToDocumentEnd:{key:"End",ctrlKey:true,shiftKey:true}};function m(e){let t=[];if(e.ctrlKey||e.metaKey){let r=typeof navigator<"u"&&/Mac/i.test(navigator.platform);t.push(r?"\u2318":"Ctrl");}e.shiftKey&&t.push("Shift"),e.altKey&&t.push("Alt");let o=e.key;return o==="ArrowLeft"?o="\u2190":o==="ArrowRight"?o="\u2192":o==="ArrowUp"?o="\u2191":o==="ArrowDown"&&(o="\u2193"),t.push(o),t.join("+")}function Mi(){return [{action:"Move by word (left)",shortcut:m(f.wordLeft)},{action:"Move by word (right)",shortcut:m(f.wordRight)},{action:"Select word (left)",shortcut:m(f.selectWordLeft)},{action:"Select word (right)",shortcut:m(f.selectWordRight)},{action:"Go to line start",shortcut:m(f.lineStart)},{action:"Go to line end",shortcut:m(f.lineEnd)},{action:"Select to line start",shortcut:m(f.selectToLineStart)},{action:"Select to line end",shortcut:m(f.selectToLineEnd)},{action:"Go to document start",shortcut:m(f.documentStart)},{action:"Go to document end",shortcut:m(f.documentEnd)},{action:"Select to document start",shortcut:m(f.selectToDocumentStart)},{action:"Select to document end",shortcut:m(f.selectToDocumentEnd)}]}var Y=/\{([#/^@]?)([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}/g,p=new PluginKey("template");function _i(e,t,o){return `${e}:${t}:${o}`}function q(e){let t=[];e.descendants((s,c)=>(s.isText&&s.text&&t.push({text:s.text,pos:c}),true));let o="",r=[];for(let s of t){for(let c=0;c<s.text.length;c++)r.push(s.pos+c);o+=s.text;}let n=[],i=[],a=new Map,l;for(Y.lastIndex=0;(l=Y.exec(o))!==null;){let[s,c,d]=l,g=r[l.index],h=r[l.index+s.length-1]+1,u;c==="#"?u="sectionStart":c==="/"?u="sectionEnd":c==="^"?u="invertedStart":c==="@"?u="raw":u="variable";let T=`${u}:${d}`,H=a.get(T)??0;a.set(T,H+1);let E={id:_i(u,d,H),type:u,name:d,rawTag:s,from:g,to:h};if(u==="sectionStart"||u==="invertedStart")E.nestedVars=[],i.push(E);else if(u==="sectionEnd"){for(let P=i.length-1;P>=0;P--)if(i[P].name===d){i.splice(P,1);break}}else u==="variable"&&i.length>0&&(i[i.length-1].nestedVars?.push(d),E.insideSection=true);n.push(E);}return n}function Wi(e){switch(e){case "sectionStart":case "sectionEnd":return "#3b82f6";case "invertedStart":return "#8b5cf6";case "raw":return "#ef4444";default:return "#f59e0b"}}function K(e,t,o,r){let n=[];for(let i of t){let a=i.id===o,l=i.id===r,s=Wi(i.type),c=["docx-template-tag"];a&&c.push("hovered"),l&&c.push("selected"),n.push(Decoration.inline(i.from,i.to,{class:c.join(" "),"data-tag-id":i.id,style:`background-color: ${s}22; border-radius: 2px;`}));}return DecorationSet.create(e,n)}function Fi(e,t){if(e.length!==t.length)return false;for(let o=0;o<e.length;o++)if(e[o].id!==t[o].id)return false;return true}function A(){return new Plugin({key:p,state:{init(e,t){let o=q(t.doc);return {tags:o,decorations:K(t.doc,o)}},apply(e,t,o,r){if(e.docChanged){let i=q(r.doc),a=Fi(t.tags,i);return {tags:i,decorations:a?t.decorations.map(e.mapping,e.doc):K(r.doc,i,t.hoveredId,t.selectedId),hoveredId:t.hoveredId,selectedId:t.selectedId}}let n=e.getMeta(p);if(n){let i=n.hoveredId??t.hoveredId,a=n.selectedId??t.selectedId;return {...t,hoveredId:i,selectedId:a,decorations:K(r.doc,t.tags,i,a)}}return {...t,decorations:t.decorations.map(e.mapping,e.doc)}}},props:{decorations(e){return p.getState(e)?.decorations??DecorationSet.empty},handleClick(e,t){let r=(p.getState(e.state)?.tags??[]).find(i=>t>=i.from&&t<=i.to);return r?(e.dispatch(e.state.tr.setMeta(p,{selectedId:r.id})),true):(p.getState(e.state)?.selectedId&&e.dispatch(e.state.tr.setMeta(p,{selectedId:void 0})),false)},handleDOMEvents:{mouseover(e,t){let r=t.target.closest?.("[data-tag-id]")?.getAttribute("data-tag-id")||void 0,n=p.getState(e.state)?.hoveredId;return r!==n&&e.dispatch(e.state.tr.setMeta(p,{hoveredId:r})),false},mouseout(e,t){return t.relatedTarget?.closest?.("[data-tag-id]")||p.getState(e.state)?.hoveredId&&e.dispatch(e.state.tr.setMeta(p,{hoveredId:void 0})),false}}}})}function J(e){return p.getState(e)?.tags??[]}function C(e,t){e.dispatch(e.state.tr.setMeta(p,{hoveredId:t}));}function N(e,t){e.dispatch(e.state.tr.setMeta(p,{selectedId:t}));}var D=`
2
2
  .docx-template-tag {
3
3
  cursor: pointer;
4
4
  transition: background-color 0.1s;
@@ -12,51 +12,31 @@ export{w as DEFAULT_SELECTION_STYLE,j as DocxEditor,a as EditorToolbar,d as Erro
12
12
  .docx-template-tag.selected {
13
13
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
14
14
  }
15
- `;var ti={variable:"#f59e0b",sectionStart:"#3b82f6",sectionEnd:"#3b82f6",invertedStart:"#8b5cf6",raw:"#ef4444"};function oi(e){switch(e){case "sectionStart":return "LOOP / IF";case "invertedStart":return "IF NOT";case "raw":return "HTML";default:return ""}}function U({editorView:e,pluginState:t,renderedDomContext:o}){let n=t?.tags??[],r=t?.hoveredId,a=t?.selectedId,[i,l]=useState(0),p=useRef(null),d=useRef(new Map),c=useRef([]),u=useMemo(()=>n.filter(s=>s.type!=="sectionEnd"&&!s.insideSection),[n]),x=useCallback(()=>{if(u.length===0||!o)return c.current;let s=[],h=o.getContainerOffset(),E=new Map;for(let f of c.current)E.set(f.tag.id,f.top);for(let f of u){let y=o.getRectsForRange(f.from,f.from+1);if(y.length>0){let v=y[0].y+h.y-40;s.push({tag:f,top:v});}else {let v=E.get(f.id);v!==void 0&&s.push({tag:f,top:v});}}s.sort((f,y)=>f.top-y.top);let I=6;for(let f=1;f<s.length;f++){let y=s[f-1],v=s[f],C=d.current.get(y.tag.id),N=32;C?N=C.offsetHeight:y.tag.nestedVars&&y.tag.nestedVars.length>0&&(N=42+y.tag.nestedVars.length*26),v.top<y.top+N+I&&(v.top=y.top+N+I);}return c.current=s,s},[u,o]),g=useMemo(()=>x(),[x,i]);useEffect(()=>{if(!o)return;let s=new ResizeObserver(()=>{requestAnimationFrame(()=>l(h=>h+1));});return s.observe(o.pagesContainer),()=>s.disconnect()},[o]),useEffect(()=>{let s=()=>{requestAnimationFrame(()=>l(h=>h+1));};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);let b=useRef("");useEffect(()=>{let s=u.map(h=>h.id).join(",");if(s&&b.current!==s){let h=setTimeout(()=>{b.current=s,l(E=>E+1);},50);return ()=>clearTimeout(h)}},[u]);let k=s=>{e&&D(e,s);},w=s=>{if(!e)return;L(e,s.id);let{state:h}=e,E=h.tr.setSelection(TextSelection.near(h.doc.resolve(s.from)));e.dispatch(E),e.focus();};return u.length===0?null:jsx("div",{className:"template-panel",ref:p,children:jsx("div",{className:"template-panel-annotations",children:g.map(({tag:s,top:h})=>{let E=oi(s.type),I=ti[s.type],f=s.type==="sectionStart"||s.type==="invertedStart",y=s.id===r,v=s.id===a;return jsxs("div",{className:"template-annotation-anchor",style:{top:`${h}px`},children:[jsx("div",{className:"template-annotation-connector"}),jsxs("div",{ref:C=>{C?d.current.set(s.id,C):d.current.delete(s.id);},className:`template-annotation-chip ${y?"hovered":""} ${v?"selected":""}`,style:{borderLeftColor:I},onMouseEnter:()=>k(s.id),onMouseLeave:()=>k(void 0),onClick:()=>w(s),title:f?`${s.rawTag}
16
- Iterates over ${s.name}[]. Access nested properties via ${s.name}.property`:s.rawTag,children:[E&&jsx("span",{className:"template-chip-badge",style:{background:I},children:E}),!E&&jsx("span",{className:"template-chip-dot",style:{color:I},children:"\u25CF"}),jsx("span",{className:"template-chip-name",children:s.name}),f&&s.nestedVars&&s.nestedVars.length>0&&jsx("div",{className:"template-chip-nested",children:s.nestedVars.map((C,N)=>jsx("span",{className:"template-nested-var",title:`Access: ${s.name}.${C}`,children:C.includes(".")?C.split(".").pop():C},N))})]})]},s.id)})})})}var z=`
17
- .template-panel {
18
- display: flex;
19
- min-height: 100%;
20
- background: transparent;
21
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
22
- position: relative;
23
- }
24
-
25
- .template-panel-annotations {
26
- flex: 1;
27
- position: relative;
28
- overflow: visible;
29
- min-height: 100%;
30
- pointer-events: none;
31
- will-change: transform;
32
- }
33
-
34
- .template-panel-annotations > * {
35
- pointer-events: auto;
36
- }
37
-
38
- .template-annotation-anchor {
15
+ `;var Gi={variable:"rgba(245, 158, 11, 0.3)",sectionStart:"rgba(59, 130, 246, 0.3)",sectionEnd:"rgba(59, 130, 246, 0.3)",invertedStart:"rgba(139, 92, 246, 0.3)",raw:"rgba(239, 68, 68, 0.3)"},$i={variable:"rgba(245, 158, 11, 0.5)",sectionStart:"rgba(59, 130, 246, 0.5)",sectionEnd:"rgba(59, 130, 246, 0.5)",invertedStart:"rgba(139, 92, 246, 0.5)",raw:"rgba(239, 68, 68, 0.5)"};function te({context:e,tags:t,hoveredId:o,selectedId:r,onHover:n,onSelect:i}){let[a,l]=useState(0),s=useCallback(()=>{let d=e.getContainerOffset(),g=[];for(let h of t){let u=e.getRectsForRange(h.from,h.to);for(let T of u)g.push({tagId:h.id,tagType:h.type,x:T.x+d.x,y:T.y+d.y,width:T.width,height:T.height});}return g},[e,t]),c=useMemo(()=>s(),[s,a]);return useEffect(()=>{let d=()=>{requestAnimationFrame(()=>l(g=>g+1));};return window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]),useEffect(()=>{let d=new ResizeObserver(()=>{requestAnimationFrame(()=>l(g=>g+1));});return d.observe(e.pagesContainer),()=>d.disconnect()},[e.pagesContainer]),c.length===0?null:jsx("div",{className:"template-highlight-overlay",children:c.map((d,g)=>{let h=d.tagId===o,u=d.tagId===r,T=h||u?$i[d.tagType]:Gi[d.tagType];return jsx("div",{className:`template-highlight ${h?"hovered":""} ${u?"selected":""}`,style:{position:"absolute",left:d.x,top:d.y,width:d.width,height:d.height,backgroundColor:T,borderRadius:2,cursor:"pointer"},onMouseEnter:()=>n?.(d.tagId),onMouseLeave:()=>n?.(void 0),onClick:()=>i?.(d.tagId)},`${d.tagId}-${g}`)})})}var oe=`
16
+ .template-highlight-overlay {
39
17
  position: absolute;
18
+ top: 0;
40
19
  left: 0;
41
20
  right: 0;
42
- display: flex;
43
- align-items: flex-start;
44
- transition: top 0.15s ease-out;
21
+ bottom: 0;
22
+ pointer-events: none;
23
+ overflow: visible;
45
24
  }
46
25
 
47
- .template-annotation-connector {
48
- width: 20px;
49
- height: 1px;
50
- background: #d0d0d0;
51
- margin-top: 12px;
52
- margin-right: 4px;
53
- flex-shrink: 0;
26
+ .template-highlight {
27
+ pointer-events: auto;
28
+ transition: background-color 0.1s ease;
54
29
  }
55
30
 
56
- .template-annotation-anchor:hover .template-annotation-connector {
57
- background: #3b82f6;
31
+ .template-highlight:hover,
32
+ .template-highlight.hovered {
33
+ filter: brightness(0.9);
58
34
  }
59
35
 
36
+ .template-highlight.selected {
37
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.6);
38
+ }
39
+ `;var Zi={variable:"#f59e0b",sectionStart:"#3b82f6",sectionEnd:"#3b82f6",invertedStart:"#8b5cf6",raw:"#ef4444"};function Xi(e){switch(e){case "sectionStart":return "LOOP / IF";case "invertedStart":return "IF NOT";case "raw":return "HTML";default:return ""}}var ne=`
60
40
  .template-annotation-chip {
61
41
  display: inline-flex;
62
42
  flex-wrap: wrap;
@@ -124,32 +104,9 @@ Iterates over ${s.name}[]. Access nested properties via ${s.name}.property`:s.ra
124
104
  background: rgba(59, 130, 246, 0.15);
125
105
  color: #1e40af;
126
106
  }
127
- `;var ii={variable:"rgba(245, 158, 11, 0.3)",sectionStart:"rgba(59, 130, 246, 0.3)",sectionEnd:"rgba(59, 130, 246, 0.3)",invertedStart:"rgba(139, 92, 246, 0.3)",raw:"rgba(239, 68, 68, 0.3)"},si={variable:"rgba(245, 158, 11, 0.5)",sectionStart:"rgba(59, 130, 246, 0.5)",sectionEnd:"rgba(59, 130, 246, 0.5)",invertedStart:"rgba(139, 92, 246, 0.5)",raw:"rgba(239, 68, 68, 0.5)"};function me({context:e,tags:t,hoveredId:o,selectedId:n,onHover:r,onSelect:a}){let[i,l]=useState(0),p=useCallback(()=>{let c=e.getContainerOffset(),u=[];for(let x of t){let g=e.getRectsForRange(x.from,x.to);for(let b of g)u.push({tagId:x.id,tagType:x.type,x:b.x+c.x,y:b.y+c.y,width:b.width,height:b.height});}return u},[e,t]),d=useMemo(()=>p(),[p,i]);return useEffect(()=>{let c=()=>{requestAnimationFrame(()=>l(u=>u+1));};return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),useEffect(()=>{let c=new ResizeObserver(()=>{requestAnimationFrame(()=>l(u=>u+1));});return c.observe(e.pagesContainer),()=>c.disconnect()},[e.pagesContainer]),d.length===0?null:jsx("div",{className:"template-highlight-overlay",children:d.map((c,u)=>{let x=c.tagId===o,g=c.tagId===n,b=x||g?si[c.tagType]:ii[c.tagType];return jsx("div",{className:`template-highlight ${x?"hovered":""} ${g?"selected":""}`,style:{position:"absolute",left:c.x,top:c.y,width:c.width,height:c.height,backgroundColor:b,borderRadius:2,cursor:"pointer"},onMouseEnter:()=>r?.(c.tagId),onMouseLeave:()=>r?.(void 0),onClick:()=>a?.(c.tagId)},`${c.tagId}-${u}`)})})}var he=`
128
- .template-highlight-overlay {
129
- position: absolute;
130
- top: 0;
131
- left: 0;
132
- right: 0;
133
- bottom: 0;
134
- pointer-events: none;
135
- overflow: visible;
136
- }
137
-
138
- .template-highlight {
139
- pointer-events: auto;
140
- transition: background-color 0.1s ease;
141
- }
142
-
143
- .template-highlight:hover,
144
- .template-highlight.hovered {
145
- filter: brightness(0.9);
146
- }
147
-
148
- .template-highlight.selected {
149
- box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.6);
150
- }
151
- `;var ci=ye.memo(U,(e,t)=>{let o=e.pluginState,n=t.pluginState;if(o?.hoveredId!==n?.hoveredId||o?.selectedId!==n?.selectedId)return false;let r=o?.tags??[],a=n?.tags??[];if(r.length!==a.length)return false;for(let i=0;i<r.length;i++)if(r[i].id!==a[i].id)return false;return e.renderedDomContext===t.renderedDomContext});function Te(e={}){return {id:"template",name:"Template",proseMirrorPlugins:[B()],Panel:ci,panelConfig:{position:e.panelPosition??"right",defaultSize:e.panelWidth??280,minSize:200,maxSize:400,resizable:true,collapsible:true,defaultCollapsed:e.defaultCollapsed??false},onStateChange:o=>{let n=m.getState(o.state);if(n)return {tags:n.tags,hoveredId:n.hoveredId,selectedId:n.selectedId}},initialize:o=>({tags:[]}),renderOverlay:(o,n,r)=>!n||n.tags.length===0?null:ye.createElement(me,{context:o,tags:n.tags,hoveredId:n.hoveredId,selectedId:n.selectedId,onHover:a=>{r&&D(r,a);},onSelect:a=>{if(r){L(r,a);let i=n.tags.find(l=>l.id===a);if(i){let l=r.state.tr.setSelection(TextSelection.near(r.state.doc.resolve(i.from)));r.dispatch(l),r.focus();}}}}),styles:`
152
- ${W}
153
- ${z}
154
- ${he}
155
- `}}var pi=Te();var Di="0.0.2";export{z as ANNOTATION_PANEL_STYLES,U as AnnotationPanel,T as NAVIGATION_SHORTCUTS,W as TEMPLATE_DECORATION_STYLES,Di as VERSION,ka as createDoubleClickWordSelector,Te as createTemplatePlugin,B as createTemplateProseMirrorPlugin,Ma as createTripleClickParagraphSelector,S as describeShortcut,Ua as expandSelectionToWord,Oa as expandSelectionToWordBoundaries,_ as extendSelectionTo,ee as findNextWordStart,te as findPreviousWordStart,ne as findVisualLineEnd,oe as findVisualLineStart,Ia as findWordAt,R as findWordBoundaries,_a as findWordEnd,Ha as findWordStart,Ga as getNavigationShortcutDescriptions,Ba as getSelectionInfo,pe as getTemplatePluginTags,wa as getWordAt,za as getWordAtCursor,Q as handleClickForMultiClick,Wa as handleNavigationKey,Fa as isNavigationKey,Ka as isPunctuation,K as isWhitespace,Y as isWhitespaceChar,P as isWordChar,M as isWordCharacter,Va as matchesShortcut,re as moveByWord,ae as moveToLineEdge,ie as parseNavigationAction,J as selectParagraphAtCursor,$ as selectWordAtCursor,Na as selectWordInTextNode,D as setHoveredElement,L as setSelectedElement,H as setSelectionPosition,pi as templatePlugin,m as templatePluginKey};
107
+ `;function ie({tag:e,isHovered:t,measureRef:o,onHover:r,onSelect:n}){let i=Xi(e.type),a=Zi[e.type],l=e.type==="sectionStart"||e.type==="invertedStart";return jsxs("div",{ref:o,style:{display:"flex",alignItems:"flex-start"},children:[jsx("div",{style:{width:20,height:1,background:t?"#3b82f6":"#d0d0d0",marginTop:12,marginRight:4,flexShrink:0}}),jsxs("div",{className:`template-annotation-chip ${t?"hovered":""}`,style:{borderLeftColor:a},onMouseEnter:()=>r(e.id),onMouseLeave:()=>r(void 0),onClick:s=>{s.stopPropagation(),n(e.id);},onMouseDown:s=>s.stopPropagation(),title:l?`${e.rawTag}
108
+ Iterates over ${e.name}[]. Access nested properties via ${e.name}.property`:e.rawTag,children:[i&&jsx("span",{className:"template-chip-badge",style:{background:a},children:i}),!i&&jsx("span",{className:"template-chip-dot",style:{color:a},children:"\u25CF"}),jsx("span",{className:"template-chip-name",children:e.name}),l&&e.nestedVars&&e.nestedVars.length>0&&jsx("div",{className:"template-chip-nested",children:e.nestedVars.map((s,c)=>jsx("span",{className:"template-nested-var",title:`Access: ${e.name}.${s}`,children:s.includes(".")?s.split(".").pop():s},c))})]})]})}function se(e,t,o){if(!e)return;N(e,o);let r=t.find(n=>n.id===o);if(r){let n=e.state.tr.setSelection(TextSelection.near(e.state.doc.resolve(r.from)));e.dispatch(n),e.focus();}}function le(e={}){return {id:"template",name:"Template",proseMirrorPlugins:[A()],onStateChange:o=>{let r=p.getState(o.state);if(r)return {tags:r.tags,hoveredId:r.hoveredId,selectedId:r.selectedId}},initialize:o=>({tags:[]}),getSidebarItems:(o,r)=>!o||o.tags.length===0?[]:o.tags.filter(i=>i.type!=="sectionEnd"&&!i.insideSection).map(i=>({id:`template-${i.id}`,anchorPos:i.from,priority:10,estimatedHeight:32,render:a=>ae.createElement(ie,{...a,tag:i,isHovered:i.id===o.hoveredId,onHover:l=>{r.editorView&&C(r.editorView,l);},onSelect:l=>se(r.editorView,o.tags,l)})})),renderOverlay:(o,r,n)=>!r||r.tags.length===0?null:ae.createElement(te,{context:o,tags:r.tags,hoveredId:r.hoveredId,selectedId:r.selectedId,onHover:i=>{n&&C(n,i);},onSelect:i=>se(n,r.tags,i)}),styles:`
109
+ ${D}
110
+ ${ne}
111
+ ${oe}
112
+ `}}var qi=le();var fa="0.0.2";export{f as NAVIGATION_SHORTCUTS,D as TEMPLATE_DECORATION_STYLES,fa as VERSION,Ei as createDoubleClickWordSelector,le as createTemplatePlugin,A as createTemplateProseMirrorPlugin,Ri as createTripleClickParagraphSelector,m as describeShortcut,Oi as expandSelectionToWord,bi as expandSelectionToWordBoundaries,I as extendSelectionTo,U as findNextWordStart,V as findPreviousWordStart,G as findVisualLineEnd,z as findVisualLineStart,Si as findWordAt,S as findWordBoundaries,Ii as findWordEnd,wi as findWordStart,Mi as getNavigationShortcutDescriptions,Ai as getSelectionInfo,J as getTemplatePluginTags,Ti as getWordAt,ki as getWordAtCursor,F as handleClickForMultiClick,Ni as handleNavigationKey,Di as isNavigationKey,vi as isPunctuation,v as isWhitespace,M as isWhitespaceChar,y as isWordChar,R as isWordCharacter,Li as matchesShortcut,$ as moveByWord,Z as moveToLineEdge,X as parseNavigationAction,W as selectParagraphAtCursor,L as selectWordAtCursor,xi as selectWordInTextNode,C as setHoveredElement,N as setSelectedElement,w as setSelectionPosition,qi as templatePlugin,p as templatePluginKey};
@@ -1,16 +1,16 @@
1
- 'use strict';var chunkIRO7KGGC_js=require('./chunk-IRO7KGGC.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkVR6PT4IZ_js=require('./chunk-VR6PT4IZ.js'),chunkBUEMG4NW_js=require('./chunk-BUEMG4NW.js');require('./chunk-SE5EN2QL.js'),require('./chunk-IFPN3NT3.js'),require('./chunk-H5NTJZO4.js');var u={type:"string",description:"Document ID returned from docx_load"},h={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},T={type:"object",properties:{start:h,end:h},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
1
+ 'use strict';var chunkZJNGMDRE_js=require('./chunk-ZJNGMDRE.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkKUL2SDYC_js=require('./chunk-KUL2SDYC.js'),chunkBUEMG4NW_js=require('./chunk-BUEMG4NW.js');require('./chunk-SE5EN2QL.js'),require('./chunk-IFPN3NT3.js'),require('./chunk-H5NTJZO4.js');var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
2
2
  Returns a document ID that can be used with other tools.
3
- The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await chunkVR6PT4IZ_js.n(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
- Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await chunkIRO7KGGC_js.f(c.document):t=await chunkIRO7KGGC_js.l(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
3
+ The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);let o=n.buffer,a=await chunkKUL2SDYC_js.n(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
+ Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await chunkZJNGMDRE_js.i(c.document):t=await chunkZJNGMDRE_js.r(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
5
5
  Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
6
- Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(x=>x.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
6
+ Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
7
7
  Returns all text concatenated with paragraph breaks.
8
8
  Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
9
9
  `),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
10
10
  `).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
11
- Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:h,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
- Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:T,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
- Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:T},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=chunkAARNCPWR_js.a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
- Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:T,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
- Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var y=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of y)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=chunkBUEMG4NW_js.b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function x(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:x,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
- `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}exports.applyStyleTool=O;exports.closeDocumentTool=R;exports.coreMcpTools=y;exports.createMcpServer=q;exports.deleteTextTool=j;exports.formatTextTool=E;exports.getDocumentInfoTool=k;exports.getDocumentTextTool=$;exports.handleJsonRpcRequest=F;exports.insertTextTool=J;exports.loadDocumentTool=D;exports.replaceTextTool=v;exports.saveDocumentTool=C;exports.startStdioServer=H;
11
+ Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
+ Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
+ Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=chunkAARNCPWR_js.a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
+ Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
+ Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=chunkAARNCPWR_js.a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=chunkBUEMG4NW_js.b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
+ `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}exports.applyStyleTool=O;exports.closeDocumentTool=R;exports.coreMcpTools=T;exports.createMcpServer=q;exports.deleteTextTool=j;exports.formatTextTool=E;exports.getDocumentInfoTool=k;exports.getDocumentTextTool=$;exports.handleJsonRpcRequest=F;exports.insertTextTool=J;exports.loadDocumentTool=D;exports.replaceTextTool=v;exports.saveDocumentTool=C;exports.startStdioServer=H;
@@ -1,16 +1,16 @@
1
- import {f,l}from'./chunk-I6LFWQFR.mjs';import {a}from'./chunk-M5F4SK3W.mjs';import {n}from'./chunk-CQRI4YUS.mjs';import {b}from'./chunk-W53SI3XW.mjs';import'./chunk-LYBG4YI7.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-TAUMSKRE.mjs';var u={type:"string",description:"Document ID returned from docx_load"},h={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},T={type:"object",properties:{start:h,end:h},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
1
+ import {i,r}from'./chunk-37SLIJPH.mjs';import {a}from'./chunk-M5F4SK3W.mjs';import {n}from'./chunk-7MGFEP2R.mjs';import {b}from'./chunk-W53SI3XW.mjs';import'./chunk-LYBG4YI7.mjs';import'./chunk-WOHFANC5.mjs';import'./chunk-TAUMSKRE.mjs';var u={type:"string",description:"Document ID returned from docx_load"},x={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},h={type:"object",properties:{start:x,end:x},required:["start","end"]},D={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
2
2
  Returns a document ID that can be used with other tools.
3
3
  The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(r,s)=>{let{content:e,source:c}=r;try{let t=atob(e),n$1=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n$1[l]=t.charCodeAt(l);let o=n$1.buffer,a=await n(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a,buffer:o,source:c,lastModified:Date.now()});let p=a.package.document.content.filter(l=>l.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:d,source:c,paragraphCount:p,message:"Document loaded successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to load document: ${t.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},C={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
4
- Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await f(c.document):t=await l(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
4
+ Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r$1,s)=>{let{documentId:e}=r$1,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await i(c.document):t=await r(c.document);let n=new Uint8Array(t),o="";for(let d=0;d<n.length;d++)o+=String.fromCharCode(n[d]);let a=btoa(o);return {content:[{type:"text",text:JSON.stringify({documentId:e,base64:a,size:t.byteLength,message:"Document exported successfully"})}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to save document: ${t.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},R={name:"docx_close",description:`Close a document and free its memory.
5
5
  Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r;return s.session.documents.has(e)?(s.session.documents.delete(e),{content:[{type:"text",text:JSON.stringify({documentId:e,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${e}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},k={name:"docx_get_info",description:`Get metadata and statistics about a document.
6
- Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(x=>x.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
6
+ Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(r,s)=>{let{documentId:e}=r,c=s.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let t=c.document,n=t.package.document,o=n.content.filter(p=>p.type==="paragraph"),a=n.content.filter(p=>p.type==="table"),d=0;for(let p of o)if(p.type==="paragraph"){let l=P(p);d+=l.split(/\s+/).filter(y=>y.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:e,paragraphCount:o.length,tableCount:a.length,wordCount:d,hasStyles:!!t.package.styles,hasTheme:!!t.package.theme,source:c.source,lastModified:c.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},$={name:"docx_get_text",description:`Get the plain text content of the document.
7
7
  Returns all text concatenated with paragraph breaks.
8
8
  Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:u,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(r,s)=>{let{documentId:e,maxLength:c=1e4}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};let n=t.document.package.document,o=[];for(let p of n.content)p.type==="paragraph"?o.push(P(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
9
9
  `),d=a.length>c;return d&&(a=a.slice(0,c)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:e,text:a,truncated:d,totalLength:d?o.join(`
10
10
  `).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},J={name:"docx_insert_text",description:`Insert text at a specific position in the document.
11
- Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:h,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
- Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:T,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
- Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:T},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
- Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:T,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
- Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var y=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of y)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function x(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:x,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
- `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,y as coreMcpTools,q as createMcpServer,j as deleteTextTool,E as formatTextTool,k as getDocumentInfoTool,$ as getDocumentTextTool,F as handleJsonRpcRequest,J as insertTextTool,D as loadDocumentTool,v as replaceTextTool,C as saveDocumentTool,H as startStdioServer};
11
+ Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:u,position:x,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(r,s)=>{let{documentId:e,position:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"insertText",position:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:t.length,position:c})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},v={name:"docx_replace_text",description:`Replace text in a range with new text.
12
+ Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:u,range:h,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(r,s)=>{let{documentId:e,range:c,text:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"replaceText",range:c,text:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:c,newTextLength:t.length})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},j={name:"docx_delete_text",description:`Delete text in a range.
13
+ Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:u,range:h},required:["documentId","range"]},handler:async(r,s)=>{let{documentId:e,range:c}=r,t=s.session.documents.get(e);if(!t)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let n=a(t.document,{type:"deleteText",range:c});return t.document=n,t.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:c})}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${n.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},E={name:"docx_format_text",description:`Apply formatting to text in a range.
14
+ Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:u,range:h,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(r,s)=>{let{documentId:e,range:c,formatting:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"formatText",range:c,formatting:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:c,appliedFormatting:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to format text: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},O={name:"docx_apply_style",description:`Apply a named style to a paragraph.
15
+ Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:u,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(r,s)=>{let{documentId:e,paragraphIndex:c,styleId:t}=r,n=s.session.documents.get(e);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let o=a(n.document,{type:"applyStyle",paragraphIndex:c,styleId:t});return n.document=o,n.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:c,styleId:t})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function P(r){let s=[];for(let e of r.content)e.type==="run"?s.push(_(e)):e.type==="hyperlink"&&s.push(A(e));return s.join("")}function _(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function A(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(_(e));return s.join("")}var T=[D,C,R,k,$,J,v,j,E,O];function q(r={}){let{name:s="docx-editor",version:e="0.1.0",includeCoreTools:c=true,debug:t=false,additionalTools:n=[]}=r,o=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(c)for(let i of T)o.set(i.name,i),t&&console.log(`[MCP] Registered core tool: ${i.name}`);let d=b.getMcpTools();for(let i of d)o.has(i.name)&&console.warn(`[MCP] Tool '${i.name}' from plugin overrides existing tool`),o.set(i.name,i),t&&console.log(`[MCP] Registered plugin tool: ${i.name}`);for(let i of n)o.set(i.name,i),t&&console.log(`[MCP] Registered additional tool: ${i.name}`);let p=t?(i,f)=>{console.log(`[MCP] ${i}`,f??"");}:()=>{};async function l(i,f){let M=o.get(i);if(!M)throw new Error(`Unknown tool: ${i}`);p(`Calling tool: ${i}`,f);let N={session:a,log:p};try{let g=await M.handler(f,N);return p(`Tool ${i} completed`,g),g}catch(g){throw p(`Tool ${i} failed`,g),g}}function y(){return Array.from(o.values()).map(i=>({name:i.name,description:i.description,inputSchema:z(i.inputSchema),category:i.annotations?.category}))}function L(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:L}}async function F(r,s){let{id:e,method:c,params:t}=s;try{switch(c){case "initialize":return {jsonrpc:"2.0",id:e,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:r.getInfo()}};case "tools/list":{let n=r.listTools();return {jsonrpc:"2.0",id:e,result:{tools:n.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))}}}case "tools/call":{let{name:n,arguments:o}=t,a=await r.handleToolCall(n,o);return {jsonrpc:"2.0",id:e,result:a}}default:return {jsonrpc:"2.0",id:e,error:{code:-32601,message:`Method not found: ${c}`}}}}catch(n){return {jsonrpc:"2.0",id:e,error:{code:-32e3,message:n.message}}}}async function H(r={}){let s=q(r);r.debug&&(console.error(`[MCP] Server started: ${s.getInfo().name} v${s.getInfo().version}`),console.error(`[MCP] Tools registered: ${s.tools.size}`));let c=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),t="";c.on("line",async n=>{t+=n;try{let o=JSON.parse(t);t="";let a=await F(s,o);process.stdout.write(JSON.stringify(a)+`
16
+ `);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function z(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{O as applyStyleTool,R as closeDocumentTool,T as coreMcpTools,q as createMcpServer,j as deleteTextTool,E as formatTextTool,k as getDocumentInfoTool,$ as getDocumentTextTool,F as handleJsonRpcRequest,J as insertTextTool,D as loadDocumentTool,v as replaceTextTool,C as saveDocumentTool,H as startStdioServer};