@betteroffice/docx 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/chunk-AEQOEQJ7.mjs +57 -0
- package/dist/chunk-AZ52IWB6.mjs +16 -0
- package/dist/{chunk-SINEY6ZF.mjs → chunk-B4IR6YP4.mjs} +1 -1
- package/dist/chunk-GGEGIQRK.mjs +1 -0
- package/dist/chunk-IFT6DUJX.mjs +1 -0
- package/dist/chunk-J7LNO6SM.mjs +1 -0
- package/dist/{chunk-H3JCIGWK.mjs → chunk-NJHOPXZW.mjs} +1 -1
- package/dist/{chunk-KXNZFTTK.mjs → chunk-WBH3SXI6.mjs} +1 -1
- package/dist/chunk-WON6K4FY.mjs +1 -0
- package/dist/chunk-Y7RUNRU2.mjs +1 -0
- package/dist/collaboration/index.d.mts +65 -0
- package/dist/collaboration/index.mjs +1 -0
- package/dist/{content-sSHuWw49.d.mts → content-MOZ6hKP4.d.mts} +357 -357
- package/dist/core.d.mts +148 -341
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-p-ijSzdh.d.mts → displayListQueries-BJlo7Jkz.d.mts} +24 -6
- package/dist/docx/index.d.mts +40 -520
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +36 -151
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-Bx6DK6-2.d.mts → fontLoader-aSewHMKF.d.mts} +65 -63
- package/dist/{formatting-DoL7KBSL.d.mts → formatting-D1EPSaJP.d.mts} +1 -1
- package/dist/{rustDisplayList-dqunvwxH.d.mts → frameDelta-D965X8yK.d.mts} +3 -274
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-Dx4Z3lkz.d.mts +1010 -0
- package/dist/layout/index.d.mts +19 -240
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +10 -58
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +11 -11
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +9 -9
- package/dist/plugin-api/index.d.mts +191 -6
- package/dist/plugin-api/resolveItemPositions.d.mts +4 -5
- package/dist/rustDisplayList-BRuZBqdL.d.mts +278 -0
- package/dist/rustMeasureSource-D1KsQvVC.d.mts +106 -0
- package/dist/selectiveSave-CVoajSKE.d.mts +56 -0
- package/dist/styles/index.d.mts +4 -39
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-VxNcXLdi.d.mts → styles-Dn_o3Vo5.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +40 -14
- package/dist/{types-DNrYr6yQ.d.mts → types-BfqUl2h_.d.mts} +3 -71
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +110 -576
- package/dist/utils/index.mjs +1 -84
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +33 -2
- package/dist/wasm-DO3BUV7C.mjs +1 -0
- package/dist/wasm-NWXX4H5G.mjs +1 -0
- package/dist/wasm-edit.d.mts +14 -5
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +10 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +6 -881
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +16 -139
- package/dist/Subscribable-DOz6Ohoo.d.mts +0 -33
- package/dist/agent/index.d.mts +0 -531
- package/dist/agent/index.mjs +0 -1
- package/dist/chunk-34K66SY4.mjs +0 -1
- package/dist/chunk-4RCISPPE.mjs +0 -1
- package/dist/chunk-52GB3Y42.mjs +0 -1
- package/dist/chunk-6NEKRDXF.mjs +0 -1
- package/dist/chunk-6PW4CWUG.mjs +0 -1
- package/dist/chunk-7DEIW7FL.mjs +0 -1
- package/dist/chunk-7PCO5I2O.mjs +0 -1
- package/dist/chunk-BI3B33LI.mjs +0 -1
- package/dist/chunk-BIQWVK5P.mjs +0 -2
- package/dist/chunk-CIRN3LZA.mjs +0 -1
- package/dist/chunk-DXKG3HQ5.mjs +0 -16
- package/dist/chunk-FPZBTOD6.mjs +0 -1
- package/dist/chunk-FZIA7OFY.mjs +0 -1
- package/dist/chunk-GWKJ2Y4Y.mjs +0 -1
- package/dist/chunk-HJGAQIU7.mjs +0 -2
- package/dist/chunk-I6KKMUUC.mjs +0 -1
- package/dist/chunk-IL5JZJT7.mjs +0 -1
- package/dist/chunk-JY6ILTNS.mjs +0 -1
- package/dist/chunk-KEE52TT5.mjs +0 -1
- package/dist/chunk-KVKLLTDP.mjs +0 -58
- package/dist/chunk-L5ISVQ3W.mjs +0 -1
- package/dist/chunk-LDUWIM7M.mjs +0 -1
- package/dist/chunk-N5Q3YN64.mjs +0 -1
- package/dist/chunk-NEWOMDTX.mjs +0 -1
- package/dist/chunk-O2QSE2I7.mjs +0 -1
- package/dist/chunk-OJOHXQNQ.mjs +0 -1
- package/dist/chunk-OMR3TWCD.mjs +0 -2
- package/dist/chunk-P3KDV4M2.mjs +0 -1
- package/dist/chunk-Q7PO7V73.mjs +0 -1
- package/dist/chunk-QOUFE3VX.mjs +0 -1
- package/dist/chunk-TYHI7RAD.mjs +0 -1
- package/dist/chunk-UIEJWORW.mjs +0 -1
- package/dist/chunk-VAOUFAUH.mjs +0 -1
- package/dist/chunk-VBOTMRXV.mjs +0 -1
- package/dist/chunk-VCER63GQ.mjs +0 -1
- package/dist/chunk-WAUF2UC7.mjs +0 -2
- package/dist/chunk-X4XDO3LZ.mjs +0 -1
- package/dist/chunk-XQBCCJBO.mjs +0 -9
- package/dist/chunk-XWUOLYRQ.mjs +0 -2
- package/dist/chunk-XYH6XWP3.mjs +0 -10
- package/dist/chunk-YBIM6UJV.mjs +0 -8
- package/dist/chunk-YCIH2Q3E.mjs +0 -1
- package/dist/chunk-ZOV5KL7C.mjs +0 -1
- package/dist/colorResolver-n0o7H7ep.d.mts +0 -290
- package/dist/core-plugins.d.mts +0 -37
- package/dist/core-plugins.mjs +0 -1
- package/dist/docx/parser.d.mts +0 -41
- package/dist/docx/parser.mjs +0 -1
- package/dist/docx/rezip.d.mts +0 -148
- package/dist/docx/rezip.mjs +0 -1
- package/dist/docx/serializer/index.d.mts +0 -42
- package/dist/docx/serializer/index.mjs +0 -1
- package/dist/editorTree-DO5PyDK8.d.mts +0 -37
- package/dist/executor-7O2RBJ2B.mjs +0 -1
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +0 -316
- package/dist/headless.d.mts +0 -69
- package/dist/headless.mjs +0 -1
- package/dist/layout/flow/index.d.mts +0 -149
- package/dist/layout/flow/index.mjs +0 -1
- package/dist/layout/measure/index.d.mts +0 -324
- package/dist/layout/measure/index.mjs +0 -1
- package/dist/layout/pagination/types.d.mts +0 -4
- package/dist/layout/pagination/types.mjs +0 -1
- package/dist/managers/AutoSaveManager.d.mts +0 -81
- package/dist/managers/AutoSaveManager.mjs +0 -1
- package/dist/managers/TableSelectionManager.d.mts +0 -74
- package/dist/managers/TableSelectionManager.mjs +0 -1
- package/dist/managers/types.d.mts +0 -113
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +0 -142
- package/dist/mcp.d.mts +0 -162
- package/dist/mcp.mjs +0 -16
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +0 -109
- package/dist/measuredBlock-DZwz8zhD.d.mts +0 -26
- package/dist/plugin-api/types.d.mts +0 -193
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +0 -1
- package/dist/registry-DMM5VTdT.d.mts +0 -165
- package/dist/rustPagination-Bj2hq013.d.mts +0 -106
- package/dist/sectionConfigs-DW3J8q0X.d.mts +0 -55
- package/dist/selectionContext-Buc9BCU1.d.mts +0 -570
- package/dist/selectiveSave-oFBJ1n71.d.mts +0 -16
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +0 -23
- package/dist/settingsParser-CcGvtmCK.d.mts +0 -33
- package/dist/types/agentApi.d.mts +0 -456
- package/dist/types/agentApi.mjs +0 -1
- package/dist/types-dYdjUZMo.d.mts +0 -311
- package/dist/units-O5Y02RKQ.d.mts +0 -34
- package/dist/utils/headingCollector.d.mts +0 -28
- package/dist/utils/headingCollector.mjs +0 -1
- package/dist/utils/highlightColors.d.mts +0 -14
- package/dist/utils/highlightColors.mjs +0 -1
- package/dist/utils/textSelection.d.mts +0 -92
- package/dist/utils/textSelection.mjs +0 -1
- package/dist/variableDetector-Borj29SF.d.mts +0 -115
- package/dist/wasm-FZQ5XB2Y.mjs +0 -1
- package/dist/wasm-SA237OSP.mjs +0 -1
- package/dist/watermarkApi-DCxjutkg.d.mts +0 -38
package/dist/mcp-cli.mjs
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import rt from'pizzip';import ot from'docxtemplater';var Xe=Object.defineProperty;var Jn=(t,e,n)=>e in t?Xe(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n;var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var Xn=(t,e)=>{for(var n in e)Xe(t,n,{get:e[n],enumerable:true});};var P=(t,e,n)=>Jn(t,typeof e!="symbol"?e+"":e,n);var ge,C,ee=S(()=>{ge=class{constructor(){P(this,"plugins",new Map);P(this,"commandHandlers",new Map);P(this,"eventListeners",new Set);P(this,"initialized",new Set);}register(e,n){let r=[];if(!e.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(e.id))return {success:false,error:`Plugin '${e.id}' is already registered`};if(e.dependencies){for(let o of e.dependencies)if(!this.plugins.has(o))return {success:false,error:`Plugin '${e.id}' requires '${o}' which is not registered`}}if(e.commandHandlers)for(let[o,a]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(o)){let s=this.commandHandlers.get(o);r.push(`Command '${o}' from '${e.id}' overrides handler from '${s.pluginId}'`);}this.commandHandlers.set(o,{pluginId:e.id,handler:a});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let o=e.initialize();o instanceof Promise?o.then(()=>{this.initialized.add(e.id);}).catch(a=>{this.emit({type:"error",pluginId:e.id,error:a});}):this.initialized.add(e.id);}catch(o){this.emit({type:"error",pluginId:e.id,error:o});}return n?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:r.length>0?r:void 0}}unregister(e){let n=this.plugins.get(e);if(!n)return false;for(let[r,o]of this.plugins)if(o.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${r}' depends on it`),false;for(let[r,{pluginId:o}]of this.commandHandlers)o===e&&this.commandHandlers.delete(r);if(n.destroy)try{let r=n.destroy();r instanceof Promise&&r.catch(o=>{this.emit({type:"error",pluginId:e,error:o});});}catch(r){this.emit({type:"error",pluginId:e,error:r});}return this.plugins.delete(e),this.initialized.delete(e),this.emit({type:"unregistered",pluginId:e}),true}get(e){return this.plugins.get(e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get size(){return this.plugins.size}getCommandHandler(e){return this.commandHandlers.get(e)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(e){return this.commandHandlers.has(e)}getMcpTools(){let e=[];for(let n of this.plugins.values())n.mcpTools&&e.push(...n.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let n of this.plugins.values())if(n.mcpTools){let r=n.mcpTools.find(o=>o.name===e);if(r)return r}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let n of this.eventListeners)try{n(e);}catch(r){console.error("[PluginRegistry] Event listener error:",r);}}clear(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(e=>e.name),initialized:Array.from(this.initialized)}}},C=new ge;});function _(t){return JSON.parse(JSON.stringify(t))}function h(t,e){let n=0;for(let r=0;r<t.content.length;r++)if(t.content[r].type==="paragraph"){if(n===e)return r;n++;}return -1}function F(t){let e="";for(let n of t.content)if(n.type==="run")for(let r of n.content)r.type==="text"&&(e+=r.text);else if(n.type==="hyperlink"){for(let r of n.children)if(r.type==="run")for(let o of r.content)o.type==="text"&&(e+=o.text);}return e}function Y(t,e){return {type:"run",formatting:e,content:[{type:"text",text:t}]}}function V(t,e,n,r){let o=[],a=0,s=false;for(let i of t.content)if(i.type==="run"){let c=i.content.filter(p=>p.type==="text").map(p=>p.text).join(""),l=a,u=a+c.length;if(!s&&e>=l&&e<=u){let p=e-l;p>0&&o.push({...i,content:[{type:"text",text:c.slice(0,p)}]}),o.push(Y(n,r||i.formatting)),p<c.length&&o.push({...i,content:[{type:"text",text:c.slice(p)}]}),s=true;}else o.push(i);a=u;}else o.push(i);return s||o.push(Y(n,r)),o}function k(t,e,n){let r=[],o=0;for(let a of t.content)if(a.type==="run"){let s=a.content.filter(l=>l.type==="text").map(l=>l.text).join(""),i=o,c=o+s.length;if(c<=e||i>=n)r.push(a);else {let l="";i<e&&(l+=s.slice(0,e-i)),c>n&&(l+=s.slice(n-i)),l.length>0&&r.push({...a,content:[{type:"text",text:l}]});}o=c;}else r.push(a);return r}function Le(t,e,n,r){let o=[],a=0;for(let s of t.content)if(s.type==="run"){let i=s.content.filter(u=>u.type==="text").map(u=>u.text).join(""),c=a,l=a+i.length;if(l<=e||c>=n)o.push(s);else if(c>=e&&l<=n)o.push({...s,formatting:{...s.formatting,...r}});else {let u=Math.max(e,c),p=Math.min(n,l);c<u&&o.push({...s,content:[{type:"text",text:i.slice(0,u-c)}]}),o.push({...s,formatting:{...s.formatting,...r},content:[{type:"text",text:i.slice(u-c,p-c)}]}),l>p&&o.push({...s,content:[{type:"text",text:i.slice(p-c)}]});}a=l;}else o.push(s);return o}var Z=S(()=>{});function en(t,e){let n=_(t),r=n.package.document,o=h(r,e.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let a=r.content[o];return a.content=V(a,e.position.offset,e.text,e.formatting),n}function tn(t,e){let n=_(t),r=n.package.document,{start:o,end:a}=e.range;if(o.paragraphIndex===a.paragraphIndex){let s=h(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let i=r.content[s];i.content=k(i,o.offset,a.offset),i.content=V(i,o.offset,e.text,e.formatting);}else {let s=h(r,o.paragraphIndex),i=r.content[s],c=F(i);i.content=k(i,o.offset,c.length),i.content=V(i,o.offset,e.text,e.formatting);let l=[];for(let u=o.paragraphIndex+1;u<=a.paragraphIndex;u++)l.push(h(r,u));for(let u=l.length-1;u>=0;u--)l[u]!==-1&&r.content.splice(l[u],1);}return n}function nn(t,e){let n=_(t),r=n.package.document,{start:o,end:a}=e.range;if(o.paragraphIndex===a.paragraphIndex){let s=h(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let i=r.content[s];i.content=k(i,o.offset,a.offset);}else {let s=h(r,o.paragraphIndex),i=r.content[s],c=F(i);i.content=k(i,o.offset,c.length);let l=h(r,a.paragraphIndex),u=r.content[l];u.content=k(u,0,a.offset),i.content.push(...u.content);let p=[];for(let d=o.paragraphIndex+1;d<=a.paragraphIndex;d++)p.push(h(r,d));for(let d=p.length-1;d>=0;d--)p[d]!==-1&&r.content.splice(p[d],1);}return n}function rn(t,e){let n=_(t),r=n.package.document,{start:o,end:a}=e.range;if(o.paragraphIndex===a.paragraphIndex){let s=h(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let i=r.content[s];i.content=Le(i,o.offset,a.offset,e.formatting);}else for(let s=o.paragraphIndex;s<=a.paragraphIndex;s++){let i=h(r,s);if(i===-1)continue;let c=r.content[i],l=F(c),u=0,p=l.length;s===o.paragraphIndex&&(u=o.offset),s===a.paragraphIndex&&(p=a.offset),c.content=Le(c,u,p,e.formatting);}return n}function on(t,e){let n=_(t),r=n.package.document,o=h(r,e.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let a=r.content[o];if(a.formatting={...a.formatting,...e.formatting},"numPr"in e.formatting){let s=e.formatting.numPr;if(s&&s.numId!==void 0&&s.numId!==0){let i=s.ilvl??0,c=s.numId===1,l=c?"\u2022":"1.";if(n.package.numbering){let u=n.package.numbering.nums.find(p=>p.numId===s.numId);if(u){let p=n.package.numbering.abstractNums.find(d=>d.abstractNumId===u.abstractNumId);if(p){let d=p.levels.find(f=>f.ilvl===i);d&&(l=d.lvlText||l);}}}a.listRendering={level:i,numId:s.numId,marker:l,isBullet:c};}else delete a.listRendering;}return n}function an(t,e){let n=_(t),r=n.package.document,o=h(r,e.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let a=r.content[o];return a.formatting={...a.formatting,styleId:e.styleId},n}var sn=S(()=>{Z();});function fe(t){return Math.round(t/96*914400)}var cn=S(()=>{});var ln=S(()=>{cn();});function un(t,e){if(e<=0)return [];let n=Math.floor(t/e),r=t-n*e;return Array.from({length:e},()=>{let o=n+(r>0?1:0);return r=Math.max(0,r-1),Math.max(1,o)})}var fn=S(()=>{});function pn(t,e){let n=t?{...t}:{},r=e,o=[["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","csTheme"]],a=new Set;for(let[s,i]of o)a.add(s),a.add(i),(r[s]!==void 0||r[i]!==void 0)&&(delete n[s],delete n[i],r[s]!==void 0&&(n[s]=r[s]),r[i]!==void 0&&(n[i]=r[i]));for(let s of Object.keys(r))!a.has(s)&&r[s]!==void 0&&(n[s]=r[s]);return n}var dn=S(()=>{});function mn(t,e){if(!e&&!t)return;if(!e)return t;if(!t)return {...e};let n={...t};for(let r of Object.keys(e)){let o=e[r];if(o!==void 0){if(r==="fontFamily"&&typeof o=="object"&&o!==null){n.fontFamily=pn(t.fontFamily,o);continue}if(r==="color"&&typeof o=="object"&&o!==null){let a=o,s=!!(a.rgb||a.themeColor||a.themeTint||a.themeShade);(!a.auto||s)&&(n.color=a);continue}if(typeof o=="object"&&o!==null&&!Array.isArray(o)){n[r]={...t[r]??{},...o};continue}n[r]=o;}}return n}var gn=S(()=>{dn();});function Ne(t){return new pe(t)}var lo,pe,yn=S(()=>{gn();lo={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},pe=class{constructor(e){P(this,"stylesById");P(this,"docDefaults");P(this,"defaultParagraphStyle");P(this,"defaultTableStyle");P(this,"defaultCharacterStyle");if(this.stylesById=new Map,this.docDefaults=e?.docDefaults,e?.styles)for(let n of e.styles)n.styleId&&this.stylesById.set(n.styleId,n);this.defaultParagraphStyle=this.findDefaultStyle("paragraph"),this.defaultTableStyle=this.findDefaultStyle("table"),this.defaultCharacterStyle=this.findDefaultStyle("character");}getStyle(e){return this.stylesById.get(e)}getParagraphStyles(){let e=[];for(let n of this.stylesById.values())n.type==="paragraph"&&!n.hidden&&!n.semiHidden&&e.push(n);return e.sort((n,r)=>{let o=n.uiPriority??99,a=r.uiPriority??99;return o!==a?o-a:(n.name??n.styleId).localeCompare(r.name??r.styleId)})}hasParagraphStyle(e){return this.stylesById.get(e)?.type==="paragraph"}resolveParagraphStyle(e){let n={};if(this.docDefaults?.pPr&&(n.paragraphFormatting={...this.docDefaults.pPr}),this.docDefaults?.rPr&&(n.runFormatting={...this.docDefaults.rPr}),!e)return this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n;let r=this.stylesById.get(e);return r?(this.mergeStyleIntoResult(n,r),n):(this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n)}getNextStyleId(e){if(!e)return null;let n=this.stylesById.get(e)?.next;return n&&n!==e?n:null}getTableStyles(){let e=[];for(let n of this.stylesById.values())n.type==="table"&&!n.hidden&&!n.semiHidden&&e.push(n);return e.sort((n,r)=>{let o=n.uiPriority??99,a=r.uiPriority??99;return o!==a?o-a:(n.name??n.styleId).localeCompare(r.name??r.styleId)})}resolveRunStyle(e){let n={};if(this.docDefaults?.rPr&&(n={...this.docDefaults.rPr}),this.defaultCharacterStyle?.rPr&&(n=this.mergeTextFormatting(n,this.defaultCharacterStyle.rPr)??n),!e)return Object.keys(n).length>0?n:void 0;let r=this.stylesById.get(e);if(!r?.rPr)return Object.keys(n).length>0?n:void 0;let o=this.mergeTextFormatting(n,r.rPr);return o&&Object.keys(o).length>0?o:void 0}getRunStyleOwnProperties(e){if(!e)return;let n=this.stylesById.get(e);if(n?.rPr)return Object.keys(n.rPr).length>0?{...n.rPr}:void 0}getDocDefaults(){return this.docDefaults}getDefaultParagraphStyle(){return this.defaultParagraphStyle}getDefaultTableStyle(){return this.defaultTableStyle}getDefaultCharacterStyle(){return this.defaultCharacterStyle}hasStyle(e){return this.stylesById.has(e)}findDefaultStyle(e){for(let n of this.stylesById.values())if(n.type===e&&n.default)return n;if(e==="paragraph")return this.stylesById.get("Normal")??(this.docDefaults?void 0:lo)}mergeStyleIntoResult(e,n){n.pPr&&(e.paragraphFormatting=this.mergeParagraphFormatting(e.paragraphFormatting,n.pPr)),n.rPr&&(e.runFormatting=this.mergeTextFormatting(e.runFormatting,n.rPr));}mergeParagraphFormatting(e,n){if(!n)return e;if(!e)return n?{...n}:void 0;let r={...e};for(let o of Object.keys(n)){let a=n[o];if(a!==void 0)if(o==="runProperties")r.runProperties=this.mergeTextFormatting(r.runProperties,n.runProperties);else if(o==="borders"||o==="numPr"||o==="frame"){let s=r[o],i=a;r[o]={...s||{},...i||{}};}else o==="tabs"&&Array.isArray(a)?r.tabs=[...a]:r[o]=a;}return r}mergeTextFormatting(e,n){return mn(e,n)}};});function uo(t,e){if(t.toLowerCase()==="tablenormal")return true;let n=e?.trim().toLowerCase();return n==="table normal"||n==="normal table"}function $e(t,e){if(!e)return;if(t&&e.hasStyle(t))return t;let n=e.getDefaultTableStyle();if(n?.styleId)return uo(n.styleId,n.name)?void 0:n.styleId}var Oe,hn=S(()=>{Oe={firstRow:true,firstColumn:true,lastRow:false,lastColumn:false,noHBand:false,noVBand:true};});var xn=S(()=>{yn();hn();});function wn(t,e){let n=_(t),r=n.package.document,o=un(9360,e.columns),a=[];for(let u=0;u<e.rows;u++){let p=[];for(let d=0;d<e.columns;d++){let f=e.data?.[u]?.[d]||"";p.push({type:"tableCell",formatting:o[d]?{width:{value:o[d],type:"dxa"}}:void 0,content:[{type:"paragraph",content:f?[Y(f)]:[]}]});}a.push({type:"tableRow",formatting:u===0&&e.hasHeader?{header:true}:void 0,cells:p});}let s=Ne(n.package.styles),i=$e(n.package.settings?.defaultTableStyle,s),c={type:"table",formatting:{width:{value:9360,type:"dxa"},layout:"fixed",...i?{styleId:i,look:{...Oe}}:{}},columnWidths:o,rows:a},l=h(r,e.position.paragraphIndex);return l===-1?r.content.push(c):r.content.splice(l+1,0,c),n}function _n(t,e){let n=_(t),r=n.package.document,o=h(r,e.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let a=r.content[o],i={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:e.src,alt:e.alt,size:{width:fe(e.width||100),height:fe(e.height||100)},wrap:{type:"inline"}}}]},c=V(a,e.position.offset,"",void 0),l=false,u=0;for(let p=0;p<c.length;p++){let d=c[p];if(d.type==="run"){let f=d.content.filter(m=>m.type==="text").map(m=>m.text).join("");if(u+=f.length,!l&&u>=e.position.offset){c.splice(p+1,0,i),l=true;break}}}return l||c.push(i),a.content=c,n}function Tn(t,e){let n=_(t),r=n.package.document,{start:o,end:a}=e.range;if(o.paragraphIndex!==a.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let s=h(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let i=r.content[s],c=F(i),l=e.displayText||c.slice(o.offset,a.offset);i.content=k(i,o.offset,a.offset);let u={type:"hyperlink",href:e.url,tooltip:e.tooltip,children:[Y(l)]},p=false,d=0,f=[];for(let m of i.content)if(m.type==="run"){let T=m.content.filter(b=>b.type==="text").map(b=>b.text).join(""),E=d+T.length;if(!p&&d<=o.offset&&o.offset<=E){let b=o.offset-d;b>0&&f.push({...m,content:[{type:"text",text:T.slice(0,b)}]}),f.push(u),b<T.length&&f.push({...m,content:[{type:"text",text:T.slice(b)}]}),p=true;}else f.push(m);d=E;}else f.push(m);return p||f.push(u),i.content=f,n}function Sn(t,e){let n=_(t),r=n.package.document,{start:o}=e.range,a=h(r,o.paragraphIndex);if(a===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let s=r.content[a],i=[];for(let c of s.content)if(c.type==="hyperlink")for(let l of c.children)l.type==="run"&&i.push(l);else i.push(c);return s.content=i,n}var Pn=S(()=>{ln();fn();xn();Z();});function Be(t,e){let n=_(t),r=n.package.document,o=h(r,e.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.position.paragraphIndex} not found`);let a=r.content[o],s=F(a),i=k({...a,content:[...a.content]},e.position.offset,s.length),c=k({...a,content:[...a.content]},0,e.position.offset);a.content=i;let l={type:"paragraph",formatting:a.formatting,content:c};return r.content.splice(o+1,0,l),n}function kn(t,e){let n=_(t),r=n.package.document,o=h(r,e.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let a=r.content[o],s=[];for(let i=1;i<=e.count;i++){let c=h(r,e.paragraphIndex+i);if(c!==-1){let l=r.content[c];a.content.push(...l.content),s.push(c);}}for(let i=s.length-1;i>=0;i--)r.content.splice(s[i],1);return n}function In(t,e){return Be(t,{position:e.position})}var En=S(()=>{Z();});function Dn(t,e){let n=_(t);return n.templateVariables||(n.templateVariables=[]),n.templateVariables.includes(e.name)||n.templateVariables.push(e.name),n}function An(t,e){let n=_(t),r=n.package.document;function o(i){for(let c of i.content)if(c.type==="text")for(let[l,u]of Object.entries(e.values)){let p=new RegExp(`\\{${l}\\}`,"g");c.text=c.text.replace(p,u);}}function a(i){for(let c of i.content)if(c.type==="run")o(c);else if(c.type==="hyperlink")for(let l of c.children)l.type==="run"&&o(l);}function s(i){if(i.type==="paragraph")a(i);else if(i.type==="table")for(let c of i.rows)for(let l of c.cells)for(let u of l.content)s(u);}for(let i of r.content)s(i);return n}var Rn=S(()=>{Z();});var Cn={};Xn(Cn,{executeCommand:()=>v,executeCommands:()=>fo});function v(t,e){let n=C.getCommandHandler(e.type);if(n)return n(t,e);switch(e.type){case "insertText":return en(t,e);case "replaceText":return tn(t,e);case "deleteText":return nn(t,e);case "formatText":return rn(t,e);case "formatParagraph":return on(t,e);case "applyStyle":return an(t,e);case "insertTable":return wn(t,e);case "insertImage":return _n(t,e);case "insertHyperlink":return Tn(t,e);case "removeHyperlink":return Sn(t,e);case "insertParagraphBreak":return Be(t,e);case "mergeParagraphs":return kn(t,e);case "splitParagraph":return In(t,e);case "setVariable":return Dn(t,e);case "applyVariables":return An(t,e);default:{let r=e;throw new Error(`Unknown command type: ${r.type}`)}}}function fo(t,e){return e.reduce((n,r)=>v(n,r),t)}var Ue=S(()=>{ee();sn();Pn();En();Rn();});ee();function qe(t,e){let n=e,{position:r,variableName:o}=n,a=JSON.parse(JSON.stringify(t)),i=a.package.document.content.filter(u=>u.type==="paragraph");if(r.paragraphIndex>=i.length)throw new Error(`Paragraph index ${r.paragraphIndex} out of bounds`);let c=i[r.paragraphIndex],l=`{${o}}`;return Ye(c,r.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(o)||a.templateVariables.push(o),a}function Ke(t,e){let n=e,{range:r,variableName:o}=n,a=JSON.parse(JSON.stringify(t)),i=a.package.document.content.filter(u=>u.type==="paragraph");if(r.start.paragraphIndex!==r.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(r.start.paragraphIndex>=i.length)throw new Error(`Paragraph index ${r.start.paragraphIndex} out of bounds`);let c=i[r.start.paragraphIndex];qn(c,r.start.offset,r.end.offset);let l=`{${o}}`;return Ye(c,r.start.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(o)||a.templateVariables.push(o),a}function Ye(t,e,n){let r=0,o=false;for(let a=0;a<t.content.length;a++){let s=t.content[a];if(s.type==="run"){let i=ye(s),c=r,l=r+i.length;if(!o&&e>=c&&e<=l){let u=e-c,p=i.slice(0,u),d=i.slice(u),f=[];for(let m=0;m<a;m++)f.push(t.content[m]);p&&f.push({type:"run",formatting:s.formatting,content:[{type:"text",text:p}]}),f.push({type:"run",formatting:s.formatting,content:[{type:"text",text:n}]}),d&&f.push({type:"run",formatting:s.formatting,content:[{type:"text",text:d}]});for(let m=a+1;m<t.content.length;m++)f.push(t.content[m]);t.content=f,o=true;break}r=l;}else if(s.type==="hyperlink")for(let i of s.children)i.type==="run"&&(r+=ye(i).length);}o||t.content.push({type:"run",content:[{type:"text",text:n}]});}function qn(t,e,n){let r=[],o=0;for(let a of t.content)if(a.type==="run"){let s=ye(a),i=o,c=o+s.length;if(c<=e||i>=n)r.push(a);else {let l="";i<e&&(l+=s.slice(0,e-i)),c>n&&(l+=s.slice(n-i)),l.length>0&&r.push({type:"run",formatting:a.formatting,content:[{type:"text",text:l}]});}o=c;}else r.push(a);t.content=r;}function ye(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function et(t){let e=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(t.package?.document){let o=Kn(t.package.document);o.forEach(a=>{e.push({name:a,location:"body"});}),n.body=Array.from(new Set(o)).sort();}if(t.package?.document?.sections&&t.package.document.sections.forEach((o,a)=>{o.properties.headerReferences&&o.properties.headerReferences.forEach(s=>{});}),t.package?.footnotes){let o=Qe(t.package.footnotes);o.forEach(a=>{e.push({name:a,location:"footnote"});}),n.footnotes=Array.from(new Set(o)).sort();}if(t.package?.endnotes){let o=Qe(t.package.endnotes);o.forEach(a=>{e.push({name:a,location:"endnote"});}),n.endnotes=Array.from(new Set(o)).sort();}t.templateVariables&&t.templateVariables.forEach(o=>{e.some(a=>a.name===o)||e.push({name:o,location:"body"});});let r=new Set;return e.forEach(o=>r.add(o.name)),{variables:Array.from(r).sort(),totalOccurrences:e.length,byLocation:n,occurrences:e}}function Kn(t){let e=[];if(t.content&&e.push(...Ze(t.content)),t.sections)for(let n of t.sections)n.content&&e.push(...Ze(n.content));return e}function Ze(t){let e=[];for(let n of t)n.type==="paragraph"?e.push(...he(n)):n.type==="table"&&e.push(...tt(n));return e}function he(t){let e=[];if(!t.content)return e;for(let n of t.content)n.type==="run"?e.push(...j(n)):n.type==="hyperlink"?e.push(...Yn(n)):n.type==="simpleField"?e.push(...Zn(n)):n.type==="complexField"&&e.push(...Qn(n));return e}function j(t){let e=[];if(!t.content)return e;for(let n of t.content)n.type==="text"&&n.text&&e.push(...nt(n.text));return e}function Yn(t){let e=[];if(!t.children)return e;for(let n of t.children)n.type==="run"&&e.push(...j(n));return e}function Zn(t){let e=[];if(t.instruction&&e.push(...nt(t.instruction)),t.content)for(let n of t.content)n.type==="run"&&e.push(...j(n));return e}function Qn(t){let e=[];if(t.fieldCode)for(let n of t.fieldCode)n.type==="run"&&e.push(...j(n));if(t.fieldResult)for(let n of t.fieldResult)n.type==="run"&&e.push(...j(n));return e}function tt(t){let e=[];if(!t.rows)return e;for(let n of t.rows)if(n.cells)for(let r of n.cells)e.push(...er(r));return e}function er(t){let e=[];if(!t.content)return e;for(let n of t.content)n.type==="paragraph"?e.push(...he(n)):n.type==="table"&&e.push(...tt(n));return e}function Qe(t){let e=[];for(let n of t)if(n.content)for(let r of n.content)r.type==="paragraph"&&e.push(...he(r));return e}var tr=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function nt(t){if(!t)return [];let e=[],n=new RegExp(tr),r;for(;(r=n.exec(t))!==null;)e.push(r[1]);return e}function at(t,e,n={}){let{nullGetter:r="keep",linebreaks:o=true,delimiters:a}=n,s=[],i=[],c=[];try{let l=new rt(t),u=new ot(l,{paragraphLoop:!0,linebreaks:o,nullGetter:d=>{let f=d.value||"";if(r==="error")throw new Error(`Undefined variable: ${f}`);return r==="empty"?(c.push(f),""):(c.push(f),`{${f}}`)},delimiters:a?{start:a.start||"{",end:a.end||"}"}:void 0});return Object.keys(e).forEach(d=>{e[d]!==void 0&&e[d]!==null&&i.push(d);}),u.setData(e),u.render(),{buffer:u.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:i,unreplacedVariables:c,warnings:s}}catch(l){throw it(l)}}function st(t){let e=[],n=[];try{let r=new rt(t),a=new ot(r,{paragraphLoop:!0,linebreaks:!0}).getFullText();n=nr(a);let s=rr(a);for(let i of s)e.push({message:`Unclosed tag: ${i}`,variable:i,type:"parse"});return {valid:e.length===0,errors:e,tags:n}}catch(r){return e.push(it(r)),{valid:false,errors:e,tags:n}}}function nr(t){let e=[],n=/\{([^{}]+)\}/g,r;for(;(r=n.exec(t))!==null;){let o=r[1].trim();o&&!e.includes(o)&&e.push(o);}return e.sort()}function rr(t){let e=[],n=0,r="";for(let o of t)o==="{"?(n++,r=""):o==="}"?(n--,n<0&&(n=0)):n>0&&(r+=o);return n>0&&r.trim()&&e.push(r.trim()),e}function or(t){return "properties"in t&&typeof t.properties=="object"}function it(t){if(t instanceof Error){if(or(t)&&t.properties?.errors){let e=t.properties.errors[0];return {message:e?.message||"Template processing error",variable:e?.properties?.tag,type:"render",originalError:t}}if(t.message.includes("undefined")){let e=t.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:t.message,variable:e?e[1]:void 0,type:"undefined",originalError:t}}return t.message.includes("parse")||t.message.includes("unclosed")||t.message.includes("syntax")?{message:t.message,type:"parse",originalError:t}:{message:t.message,type:"unknown",originalError:t}}return {message:String(t),type:"unknown"}}async function ct(t){if(t instanceof ArrayBuffer)return t;if(t instanceof Uint8Array){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}if(t instanceof Blob)return t.arrayBuffer();throw new TypeError(`Unsupported DocxInput type: ${typeof t}`)}function ft(t,e){let n,r;try{let s=we(t,g.__wbindgen_malloc),i=D,c=re(e,g.__wbindgen_malloc,g.__wbindgen_realloc),l=D,u=g.parse_docx_s9(s,i,c,l);var o=u[0],a=u[1];if(u[3])throw o=0,a=0,_e(u[2]);return n=o,r=a,ne(o,a)}finally{g.__wbindgen_free(n,r,1);}}function pt(t,e){let n,r;try{let s=we(t,g.__wbindgen_malloc),i=D,c=re(e,g.__wbindgen_malloc,g.__wbindgen_realloc),l=D,u=g.parse_relationships_xml(s,i,c,l);var o=u[0],a=u[1];if(u[3])throw o=0,a=0,_e(u[2]);return n=o,r=a,ne(o,a)}finally{g.__wbindgen_free(n,r,1);}}function dt(t,e){let n=re(t,g.__wbindgen_malloc,g.__wbindgen_realloc),r=D,o=we(e,g.__wbindgen_malloc),a=D,s=g.write_docx_s13_wasm(n,r,o,a);if(s[3])throw _e(s[2]);var i=be(s[0],s[1]).slice();return g.__wbindgen_free(s[0],s[1]*1,1),i}function mt(){return {__proto__:null,"./docx_parse_bg.js":{__proto__:null,__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,n){let r=n,o=typeof r=="string"?r:void 0;var a=sr(o)?0:re(o,g.__wbindgen_malloc,g.__wbindgen_realloc),s=D;lt().setInt32(e+4,s,true),lt().setInt32(e+0,a,true);},__wbg___wbindgen_throw_344f42d3211c4765:function(e,n){throw new Error(ne(e,n))},__wbg_get_78f252d074a84d0b:function(){return ut(function(e,n){return Reflect.get(e,n)},arguments)},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(e,n){return e[n>>>0]},__wbg_instanceof_Object_33f20e6f12439f3e:function(e){let n;try{n=e instanceof Object;}catch{n=false;}return n},__wbg_keys_58421f8f96795607:function(e){return Object.keys(e)},__wbg_length_1f0964f4a5e2c6d8:function(e){return e.length},__wbg_length_370319915dc99107:function(e){return e.length},__wbg_new_cd45aabdf6073e84:function(e){return new Uint8Array(e)},__wbg_new_da52cf8fe3429cb2:function(){return new Object},__wbg_new_from_slice_77cdfb7977362f3c:function(e,n){return new Uint8Array(be(e,n))},__wbg_prototypesetcall_4770620bbe4688a0:function(e,n,r){Uint8Array.prototype.set.call(be(e,n),r);},__wbg_set_8535240470bf2500:function(){return ut(function(e,n,r){return Reflect.set(e,n,r)},arguments)},__wbindgen_cast_0000000000000001:function(e,n){return ne(e,n)},__wbindgen_init_externref_table:function(){let e=g.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,true),e.set(n+3,false);}}}}function ar(t){let e=g.__externref_table_alloc();return g.__wbindgen_externrefs.set(e,t),e}function be(t,e){return t=t>>>0,O().subarray(t/1,t/1+e)}var L=null;function lt(){return (L===null||L.buffer.detached===true||L.buffer.detached===void 0&&L.buffer!==g.memory.buffer)&&(L=new DataView(g.memory.buffer)),L}function ne(t,e){return cr(t>>>0,e)}var H=null;function O(){return (H===null||H.byteLength===0)&&(H=new Uint8Array(g.memory.buffer)),H}function ut(t,e){try{return t.apply(this,e)}catch(n){let r=ar(n);g.__wbindgen_exn_store(r);}}function sr(t){return t==null}function we(t,e){let n=e(t.length*1,1)>>>0;return O().set(t,n/1),D=t.length,n}function re(t,e,n){if(n===void 0){let i=W.encode(t),c=e(i.length,1)>>>0;return O().subarray(c,c+i.length).set(i),D=i.length,c}let r=t.length,o=e(r,1)>>>0,a=O(),s=0;for(;s<r;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==r){s!==0&&(t=t.slice(s)),o=n(o,r,r=s+t.length*3,1)>>>0;let i=O().subarray(o+s,o+r),c=W.encodeInto(t,i);s+=c.written,o=n(o,r,s,1)>>>0;}return D=s,o}function _e(t){let e=g.__wbindgen_externrefs.get(t);return g.__externref_table_dealloc(t),e}var te=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});te.decode();var ir=2146435072,xe=0;function cr(t,e){return xe+=e,xe>=ir&&(te=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),te.decode(),xe=e),te.decode(O().subarray(t,t+e))}var W=new TextEncoder;"encodeInto"in W||(W.encodeInto=function(t,e){let n=W.encode(t);return e.set(n),{read:t.length,written:n.length}});var D=0,g;function gt(t,e){return g=t.exports,L=null,H=null,g.__wbindgen_start(),g}async function fr(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(o){if(t.ok&&n(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}function n(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function yt(t){if(g!==void 0)return g;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=mt();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let n=new WebAssembly.Instance(t,e);return gt(n)}async function ht(t){if(g!==void 0)return g;if(t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),t===void 0)throw new Error("docx-parse wasm requires an explicit module or URL");let e=mt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await fr(await t,e);return gt(n)}function xt(t){let e=globalThis.process;if(typeof e?.getBuiltinModule=="function")try{return e.getBuiltinModule(t)}catch{return}}function pr(t){if(t.protocol!=="file:")return;let e=xt("node:fs"),n=xt("node:url");if(!(!e||!n))try{return e.readFileSync(n.fileURLToPath(t))}catch{return}}function oe(t){let e=false,n;return {preload(r){return e?Promise.resolve():n||(n=t.initAsync({module_or_path:r??t.assetUrl()}).then(()=>{e=true;},o=>{throw n=void 0,o instanceof Error?o:new Error(String(o))}),n)},ensure(){if(e)return;let r=pr(t.assetUrl());if(r){t.initSync({module:r}),e=true;return}throw new Error(`${t.label} wasm is not initialized; await ${t.preloadName}() before first use (browser builds load the external wasm asset asynchronously)`)}}}var ae=oe({label:"docx-parse",preloadName:"preloadParseWasm",assetUrl:()=>new URL("./generated/parse/docx_parse_bg.wasm",import.meta.url),initAsync:ht,initSync:yt});function se(t){return ae.preload(t)}function bt(t,e){return ae.ensure(),ft(t,e)}function wt(t,e){return ae.ensure(),pt(t,e)}function _t(t,e){return ae.ensure(),dt(t,e)}var dr=new Set(["__proto__","constructor","prototype"]);function Pt(t,e){return mr(bt(new Uint8Array(t),JSON.stringify(e)),t)}function mr(t,e){let n=JSON.parse(t);Se(n,"wire");let r=x(n,"wire");if(A(r,["wireVersion","document","embeddedFontParts","fontTableRelationshipsXml","canonicalBase64","canonicalSha256"],"wire",["fontTableRelationshipsXml","canonicalBase64","canonicalSha256"]),r.wireVersion!==1)throw new TypeError("wire.wireVersion must be 1");let o=gr(r.document,e),a=br(r.embeddedFontParts);if((r.canonicalBase64!==void 0||r.canonicalSha256!==void 0)&&(r.canonicalBase64===void 0||r.canonicalSha256===void 0))throw new TypeError("wire canonical fields must be present together");let i=r.canonicalSha256===void 0?void 0:w(r.canonicalSha256,"wire.canonicalSha256");if(i!==void 0&&!/^[0-9a-f]{64}$/.test(i))throw new TypeError("wire.canonicalSha256 is invalid");return {wireVersion:1,document:o,embeddedFonts:a,...r.fontTableRelationshipsXml===void 0?{}:{fontTableRelationshipsXml:w(r.fontTableRelationshipsXml,"wire.fontTableRelationshipsXml")},...r.canonicalBase64===void 0?{}:{rustCanonicalBytes:Pe(w(r.canonicalBase64,"wire.canonicalBase64")),rustCanonicalSha256:i}}}function gr(t,e){let n=x(t,"wire.document");A(n,["package","templateVariables","warnings"],"wire.document",["templateVariables","warnings"]);let o={package:yr(n.package),originalBuffer:e};return n.templateVariables!==void 0&&(o.templateVariables=Tt(n.templateVariables,"wire.document.templateVariables")),n.warnings!==void 0&&(o.warnings=Tt(n.warnings,"wire.document.warnings")),o}function yr(t){let e=x(t,"wire.document.package");A(e,["document","styles","theme","numbering","settings","fontTable","headerEntries","footerEntries","footnotes","endnotes","footnoteSeparators","endnoteSeparators","relationshipEntries","mediaEntries","chartEntries"],"wire.document.package",["styles","headerEntries","footerEntries","footnotes","endnotes","footnoteSeparators","endnoteSeparators"]);let o={document:hr(e.document),theme:x(e.theme,"wire.document.package.theme"),numbering:x(e.numbering,"wire.document.package.numbering"),settings:x(e.settings,"wire.document.package.settings"),fontTable:x(e.fontTable,"wire.document.package.fontTable"),relationships:kt(e.relationshipEntries,"wire.document.package.relationshipEntries"),media:xr(e.mediaEntries),charts:Te(e.chartEntries,"wire.document.package.chartEntries",(a,s)=>x(a,s))};e.styles!==void 0&&(o.styles=x(e.styles,"wire.document.package.styles"));for(let[a,s]of [["headerEntries","headers"],["footerEntries","footers"]]){let i=e[a];i!==void 0&&(o[s]=Te(i,`wire.document.package.${a}`,(c,l)=>x(c,l)));}return e.footnotes!==void 0&&(o.footnotes=z(e.footnotes,"wire.document.package.footnotes")),e.endnotes!==void 0&&(o.endnotes=z(e.endnotes,"wire.document.package.endnotes")),e.footnoteSeparators!==void 0&&(o.footnoteSeparators=z(e.footnoteSeparators,"wire.document.package.footnoteSeparators")),e.endnoteSeparators!==void 0&&(o.endnoteSeparators=z(e.endnoteSeparators,"wire.document.package.endnoteSeparators")),o}function hr(t){let e="wire.document.package.document",n=x(t,e);if(A(n,["content","sections","finalSectionProperties","comments"],e,["sections","finalSectionProperties","comments"]),!Array.isArray(n.content))throw new TypeError(`${e}.content must be an array`);n.content.forEach((o,a)=>x(o,`${e}.content[${a}]`));let r={content:n.content};if(n.sections!==void 0){if(!Array.isArray(n.sections))throw new TypeError(`${e}.sections must be an array`);r.sections=n.sections.map((o,a)=>{let s=`${e}.sections[${a}]`,i=x(o,s);A(i,["id","properties","contentStart","contentEnd"],s,["id"]);let c=St(i.contentStart,`${s}.contentStart`),l=St(i.contentEnd,`${s}.contentEnd`);if(c>l||l>r.content.length)throw new TypeError(`${s} has an invalid content range`);return {...i.id===void 0?{}:{id:w(i.id,`${s}.id`)},properties:x(i.properties,`${s}.properties`),content:r.content.slice(c,l)}});}return n.finalSectionProperties!==void 0&&(r.finalSectionProperties=x(n.finalSectionProperties,`${e}.finalSectionProperties`)),n.comments!==void 0&&(r.comments=z(n.comments,`${e}.comments`)),r}function kt(t,e){return Te(t,e,(n,r,o)=>wr(n,r,o))}function xr(t){let e="wire.document.package.mediaEntries";if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);let n=new Map,r=new Map;for(let o=0;o<t.length;o+=1){let a=`${e}[${o}]`,s=t[o];if(!Array.isArray(s)||s.length!==2)throw new TypeError(`${a} must be a key/value pair`);let i=w(s[0],`${a}[0]`);if(n.has(i))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(i)}`);let c=`${a}[1]`,l=x(s[1],c);A(l,["path","filename","mimeType","base64","dataUrl"],c,["filename"]);let u=w(l.path,`${c}.path`),p=r.get(u);if(!p){let d=Pe(w(l.base64,`${c}.base64`)),f={path:u,...l.filename===void 0?{}:{filename:w(l.filename,`${c}.filename`)},mimeType:w(l.mimeType,`${c}.mimeType`),data:It(d),dataUrl:w(l.dataUrl,`${c}.dataUrl`)};p=f,r.set(u,f);}n.set(i,p);}return n}function br(t){let e="wire.embeddedFontParts";if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);let n=new Map;return t.forEach((r,o)=>{let a=`${e}[${o}]`,s=x(r,a);A(s,["path","base64"],a);let i=w(s.path,`${a}.path`);if(n.has(i))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(i)}`);n.set(i,It(Pe(w(s.base64,`${a}.base64`))));}),n}function Te(t,e,n){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);let r=new Map;return t.forEach((o,a)=>{let s=`${e}[${a}]`;if(!Array.isArray(o)||o.length!==2)throw new TypeError(`${s} must be a key/value pair`);let i=w(o[0],`${s}[0]`);if(r.has(i))throw new TypeError(`${e} contains duplicate key ${JSON.stringify(i)}`);r.set(i,n(o[1],`${s}[1]`,i));}),r}function Tt(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map((n,r)=>w(n,`${e}[${r}]`))}function z(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.forEach((n,r)=>x(n,`${e}[${r}]`)),t}function It(t){return Uint8Array.from(t).buffer}function St(t,e){let n=_r(t,e);if(!Number.isSafeInteger(n)||n<0)throw new TypeError(`${e} must be a non-negative safe integer`);return n}function Et(t,e="word/_rels/document.xml.rels"){let n=JSON.parse(wt(new TextEncoder().encode(t),e));Se(n,"relationshipPart");let r=x(n,"relationshipPart");return A(r,["path","relationships","canonicalBase64","canonicalSha256"],"relationshipPart"),w(r.path,"relationshipPart.path"),kt(r.relationships,"relationshipPart.relationships")}function wr(t,e,n){let r=x(t,e);A(r,["id","type","target","targetMode"],e,["targetMode"]);let o=w(r.id,`${e}.id`);if(o!==n)throw new TypeError(`${e}.id does not match its map key`);let a={id:o,type:w(r.type,`${e}.type`),target:w(r.target,`${e}.target`)};if(r.targetMode!==void 0){if(r.targetMode!=="External"&&r.targetMode!=="Internal")throw new TypeError(`${e}.targetMode is invalid`);a.targetMode=r.targetMode;}return a}function Se(t,e,n=new WeakSet){if(!(t===null||typeof t!="object")){if(n.has(t))throw new TypeError(`${e} contains a cycle`);n.add(t);try{for(let r of Object.keys(t)){if(dr.has(r))throw new TypeError(`${e} contains forbidden key ${r}`);Se(t[r],`${e}.${r}`,n);}}finally{n.delete(t);}}}function x(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object`);return t}function A(t,e,n,r=[]){let o=new Set(e);for(let s of Object.keys(t))if(!o.has(s))throw new TypeError(`${n} contains unknown key ${s}`);let a=new Set(r);for(let s of e)if(!a.has(s)&&!Object.prototype.hasOwnProperty.call(t,s))throw new TypeError(`${n} is missing ${s}`)}function w(t,e){if(typeof t!="string")throw new TypeError(`${e} must be a string`);return t}function _r(t,e){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError(`${e} must be a finite number`);return t}function Pe(t){let e;try{e=atob(t);}catch{throw new TypeError("wire canonicalBase64 is invalid")}let n=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=e.charCodeAt(r);return n}function Ct(t){let e=y.rezip_docx(t);if(e[3])throw Ee(e[2]);var n=Ie(e[0],e[1]).slice();return y.__wbindgen_free(e[0],e[1]*1,1),n}function Ft(t){let e=Pr(t,y.__wbindgen_malloc),n=X,r=y.unzip_docx(e,n);if(r[2])throw Ee(r[1]);return Ee(r[0])}function vt(){return {__proto__:null,"./ooxml_opc_bg.js":{__proto__:null,__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,n){let r=n,o=typeof r=="string"?r:void 0;var a=Sr(o)?0:kr(o,y.__wbindgen_malloc,y.__wbindgen_realloc),s=X;Dt().setInt32(e+4,s,true),Dt().setInt32(e+0,a,true);},__wbg___wbindgen_throw_344f42d3211c4765:function(e,n){throw new Error(At(e,n))},__wbg_get_78f252d074a84d0b:function(){return Rt(function(e,n){return Reflect.get(e,n)},arguments)},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(e,n){return e[n>>>0]},__wbg_instanceof_Object_33f20e6f12439f3e:function(e){let n;try{n=e instanceof Object;}catch{n=false;}return n},__wbg_keys_58421f8f96795607:function(e){return Object.keys(e)},__wbg_length_1f0964f4a5e2c6d8:function(e){return e.length},__wbg_length_370319915dc99107:function(e){return e.length},__wbg_new_cd45aabdf6073e84:function(e){return new Uint8Array(e)},__wbg_new_da52cf8fe3429cb2:function(){return new Object},__wbg_new_from_slice_77cdfb7977362f3c:function(e,n){return new Uint8Array(Ie(e,n))},__wbg_prototypesetcall_4770620bbe4688a0:function(e,n,r){Uint8Array.prototype.set.call(Ie(e,n),r);},__wbg_set_8535240470bf2500:function(){return Rt(function(e,n,r){return Reflect.set(e,n,r)},arguments)},__wbindgen_cast_0000000000000001:function(e,n){return At(e,n)},__wbindgen_init_externref_table:function(){let e=y.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,true),e.set(n+3,false);}}}}function Tr(t){let e=y.__externref_table_alloc();return y.__wbindgen_externrefs.set(e,t),e}function Ie(t,e){return t=t>>>0,$().subarray(t/1,t/1+e)}var N=null;function Dt(){return (N===null||N.buffer.detached===true||N.buffer.detached===void 0&&N.buffer!==y.memory.buffer)&&(N=new DataView(y.memory.buffer)),N}function At(t,e){return Er(t>>>0,e)}var G=null;function $(){return (G===null||G.byteLength===0)&&(G=new Uint8Array(y.memory.buffer)),G}function Rt(t,e){try{return t.apply(this,e)}catch(n){let r=Tr(n);y.__wbindgen_exn_store(r);}}function Sr(t){return t==null}function Pr(t,e){let n=e(t.length*1,1)>>>0;return $().set(t,n/1),X=t.length,n}function kr(t,e,n){if(n===void 0){let i=J.encode(t),c=e(i.length,1)>>>0;return $().subarray(c,c+i.length).set(i),X=i.length,c}let r=t.length,o=e(r,1)>>>0,a=$(),s=0;for(;s<r;s++){let i=t.charCodeAt(s);if(i>127)break;a[o+s]=i;}if(s!==r){s!==0&&(t=t.slice(s)),o=n(o,r,r=s+t.length*3,1)>>>0;let i=$().subarray(o+s,o+r),c=J.encodeInto(t,i);s+=c.written,o=n(o,r,s,1)>>>0;}return X=s,o}function Ee(t){let e=y.__wbindgen_externrefs.get(t);return y.__externref_table_dealloc(t),e}var ie=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});ie.decode();var Ir=2146435072,ke=0;function Er(t,e){return ke+=e,ke>=Ir&&(ie=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),ie.decode(),ke=e),ie.decode($().subarray(t,t+e))}var J=new TextEncoder;"encodeInto"in J||(J.encodeInto=function(t,e){let n=J.encode(t);return e.set(n),{read:t.length,written:n.length}});var X=0,y;function Mt(t,e){return y=t.exports,N=null,G=null,y.__wbindgen_start(),y}async function Rr(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(o){if(t.ok&&n(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await t.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(t,e);return r instanceof WebAssembly.Instance?{instance:r,module:t}:r}function n(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function Lt(t){if(y!==void 0)return y;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=vt();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let n=new WebAssembly.Instance(t,e);return Mt(n)}async function Nt(t){if(y!==void 0)return y;if(t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),t===void 0)throw new Error("ooxml-opc wasm requires an explicit module or URL");let e=vt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:r}=await Rr(await t,e);return Mt(n)}var De=oe({label:"ooxml-opc",preloadName:"preloadOpcWasm",assetUrl:()=>new URL("./generated/opc/ooxml_opc_bg.wasm",import.meta.url),initAsync:Nt,initSync:Lt});function ce(t){return De.preload(t)}function Ae(t){return De.ensure(),Ft(t)}function Ot(t){return De.ensure(),Ct(t)}function $t(t){let e=t.replace(/[^0-9a-fA-F]/g,"");if(e.length!==32)return null;let n=new Uint8Array(16);for(let o=0;o<16;o++){let a=Number.parseInt(e.slice(o*2,o*2+2),16);if(Number.isNaN(a))return null;n[o]=a;}let r=new Uint8Array(16);for(let o=0;o<16;o++)r[o]=n[15-o];return r}function Bt(t){return t?$t(t)!==null:false}function Ut(t,e){let n=$t(e);if(!n)throw new Error(`Invalid embedded-font key: "${e}"`);let r=new Uint8Array(t.slice(0)),o=Math.min(32,r.length);for(let a=0;a<o;a++)r[a]^=n[a%16];return r.buffer}var Cr={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1172},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1074},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","\uFF2D\uFF33 \u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u660E\u671D":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS PMincho","\uFF2D\uFF33 \uFF30\u660E\u671D","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","\uFF2D\uFF33 \u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},"\uFF4D\uFF53 \uFF50\u30B4\u30B7\u30C3\u30AF":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS PGothic","\uFF2D\uFF33 \uFF30\u30B4\u30B7\u30C3\u30AF","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\u5B8B\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","\u5B8B\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u9ED1\u4F53:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","\u9ED1\u4F53","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u5FAE\u8F6F\u96C5\u9ED1:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["Microsoft YaHei","\u5FAE\u8F6F\u96C5\u9ED1","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u7B49\u7EBF:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["DengXian","\u7B49\u7EBF","Noto Sans SC","sans-serif"],singleLineRatio:1.15},\u4EFF\u5B8B:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["FangSong","\u4EFF\u5B8B","Noto Serif SC","serif"],singleLineRatio:1.15},\u6977\u4F53:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["KaiTi","\u6977\u4F53","Noto Serif SC","serif"],singleLineRatio:1.15},\u65B0\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["PMingLiU","\u65B0\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u7D30\u660E\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["MingLiU","\u7D30\u660E\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},\u5FAE\u8EDF\u6B63\u9ED1\u9AD4:{googleFont:"Noto Sans TC",category:"sans-serif",fallbackStack:["Microsoft JhengHei","\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","Noto Sans TC","sans-serif"],singleLineRatio:1.15},\u6A19\u6977\u9AD4:{googleFont:"Noto Serif TC",category:"serif",fallbackStack:["DFKai-SB","\u6A19\u6977\u9AD4","Noto Serif TC","serif"],singleLineRatio:1.15},"\uB9D1\uC740 \uACE0\uB515":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","\uB9D1\uC740 \uACE0\uB515","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uAD74\uB9BC:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Gulim","\uAD74\uB9BC","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uB3CB\uC6C0:{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Dotum","\uB3CB\uC6C0","Noto Sans KR","sans-serif"],singleLineRatio:1.15},\uBC14\uD0D5:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Batang","\uBC14\uD0D5","Noto Serif KR","serif"],singleLineRatio:1.15},\uAD81\uC11C:{googleFont:"Noto Serif KR",category:"serif",fallbackStack:["Gungsuh","\uAD81\uC11C","Noto Serif KR","serif"],singleLineRatio:1.15}},Fr={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function vr(t){let e=t.toLowerCase();return e.includes("mono")||e.includes("courier")||e.includes("consolas")||e.includes("console")||e.includes("code")||e.includes("terminal")?"monospace":e.includes("times")||e.includes("georgia")||e.includes("garamond")||e.includes("palatino")||e.includes("baskerville")||e.includes("bodoni")||e.includes("cambria")||e.includes("mincho")||e.includes("\u660E\u671D")||e.includes("\u660E\u9AD4")||e.includes("\u5B8B")||e.includes("ming")||e.includes("song")||e.includes("serif")?"serif":e.includes("script")||e.includes("cursive")||e.includes("comic")||e.includes("brush")||e.includes("hand")?"cursive":"sans-serif"}var Mr={"microsoft yahei":"\u5FAE\u8F6F\u96C5\u9ED1",dengxian:"\u7B49\u7EBF",fangsong:"\u4EFF\u5B8B",kaiti:"\u6977\u4F53",pmingliu:"\u65B0\u7D30\u660E\u9AD4",mingliu:"\u7D30\u660E\u9AD4","microsoft jhenghei":"\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","dfkai-sb":"\u6A19\u6977\u9AD4",gulim:"\uAD74\uB9BC",dotum:"\uB3CB\uC6C0",batang:"\uBC14\uD0D5",gungsuh:"\uAD81\uC11C",meiryo:"ms gothic",\u30E1\u30A4\u30EA\u30AA:"ms gothic","yu gothic":"ms gothic",\u6E38\u30B4\u30B7\u30C3\u30AF:"ms gothic","yu mincho":"ms mincho",\u6E38\u660E\u671D:"ms mincho"};function jt(t){let e=t.trim().toLowerCase(),n=Cr[Mr[e]??e];if(n)return {googleFont:n.googleFont,cssFallback:n.fallbackStack.map(Vt).join(", "),originalFont:t,hasGoogleEquivalent:true,singleLineRatio:n.singleLineRatio};let r=vr(t),o=Fr[r];return {googleFont:null,cssFallback:`${Vt(t)}, ${o}`,originalFont:t,hasGoogleEquivalent:false,singleLineRatio:1.15}}var Lr={"\n":"\\a ","\r":"\\d ","\f":"\\c "};function Nr(t){return t.replace(/["\\]/g,"\\$&").replace(/[\n\r\f]/g,e=>Lr[e])}function Vt(t){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(t.toLowerCase())?t:/[\s,'"()]/.test(t)?`"${Nr(t)}"`:t}var U=new Set,K=new Map,Jt=new Set,B=new Map,Or=new Set,Ht=new Set,Wt=true,Fe=new Set,Re=new Set;function ve(t,e){let n=t instanceof Error?t.message:String(t),r=new Error(`[font] ${e}: ${n}`,{cause:t});if(Ht.size>0)for(let o of Ht)try{o(r);}catch(a){console.error("Font error subscriber threw:",a);}else console.warn(r.message);}function $r(t,e="normal",n="normal"){return `${t.trim()}|${e}|${n}`}function Ce(t){return Fe.has(t)?false:Re.has(t)?true:zr(t)?(Re.add(t),queueMicrotask(()=>Me([t])),true):false}function Br(t){let e=`${t}|`,n=[];for(let[r,o]of B)r.startsWith(e)&&n.push(o);return n}function Ur(t,e){Jt.add(t),U.add(e),Me([e]);}function Vr(t,e=[400,700],n=["normal","italic"]){let r=encodeURIComponent(t),o=[];for(let s of n){let i=s==="italic"?1:0;for(let c of e)o.push(`${i},${c}`);}o.sort();let a=o.join(";");return `https://fonts.googleapis.com/css2?family=${r}:ital,wght@${a}&display=swap`}async function zt(t,e){if(typeof document>"u")return false;let n=t.trim();if(U.has(n))return true;let r=K.get(n);if(r)return r;if(Ce(n))return true;let o=Br(n);let a=(async()=>{try{if(o.length>0&&(await Promise.all(o),U.has(n)||!e&&Ce(n)))return !0;if(!Wt);let s=Vr(n,e?.weights,e?.styles),i=document.createElement("link");return i.rel="stylesheet",i.href=s,await new Promise(l=>{let u=setTimeout(()=>l(!1),5e3);i.onload=()=>{clearTimeout(u),l(!0);},i.onerror=()=>{clearTimeout(u),l(!1);},document.head.appendChild(i);})?(await Xt(n,3e3),U.add(n),Me([n]),!0):!1}catch(s){return ve(s,`failed to load "${n}"`),false}finally{K.delete(n),K.size===0&&B.size===0&&(false);}})();return K.set(n,a),a}function jr(t){let e=t.trim();return U.has(e)||Re.has(e)}function Me(t){for(let e of Or)try{e(t);}catch(n){ve(n,"load callback threw");}}async function Xt(t,e){if("fonts"in document)try{let n=`400 16px "${t}"`;return await Promise.race([document.fonts.load(n),new Promise(r=>setTimeout(r,e))]),document.fonts.check(n)}catch{}return await new Promise(n=>setTimeout(n,100)),true}var q,Gt=new Map,Hr="abcdefghijklmnopqrstuvwxyz0123456789";function Wr(){return q===void 0&&(q=document.createElement("canvas").getContext("2d"),q&&(q.textBaseline="top")),q}function zr(t,e="sans-serif"){if(typeof document>"u")return false;let n=Wr();if(!n)return false;let r=a=>(n.font=a,n.measureText(Hr).width),o=a=>{let s=Gt.get(a);return s===void 0&&(s=r(`72px ${a}`),Gt.set(a,s)),r(`72px "${t}", ${a}`)!==s};return o(e)||o(e==="sans-serif"?"serif":"sans-serif")}var Gr={"<":"\\3c ",">":"\\3e ","\n":"\\a ","\r":"\\d ","\f":"\\c "},Jr=t=>t.replace(/["\\]/g,"\\$&").replace(/[<>\n\r\f]/g,e=>Gr[e]);async function qt(t,e,n){if(typeof document>"u")return false;let r=t.trim(),o=n?.style??"normal",a=$r(r,n?.weight,o);if(Fe.add(r),Jt.has(a))return true;let s=B.get(a);if(s)return s;let i=(async()=>{try{let c=new Blob([e],{type:"font/ttf"}),l=URL.createObjectURL(c),u=document.createElement("style");return u.textContent=`
|
|
3
|
-
@font-face {
|
|
4
|
-
font-family: "${Jr(r)}";
|
|
5
|
-
src: url(${l}) format('truetype');
|
|
6
|
-
font-weight: ${n?.weight??"normal"};
|
|
7
|
-
font-style: ${o};
|
|
8
|
-
font-display: swap;
|
|
9
|
-
}
|
|
10
|
-
`,document.head.appendChild(u),await Xt(r,3e3),Ur(a,r),!0}catch(c){return ve(c,`failed to load "${r}" from buffer`),false}finally{B.delete(a),K.size===0&&B.size===0&&(false);}})();return B.set(a,i),i}var Xr={Calibri:"Carlito",Cambria:"Caladea",Arial:"Arimo","Times New Roman":"Tinos","Courier New":"Cousine",Garamond:"EB Garamond","Book Antiqua":"EB Garamond",Georgia:"Tinos",Verdana:"Open Sans",Tahoma:"Open Sans","Trebuchet MS":"Source Sans Pro","Century Gothic":"Poppins","Franklin Gothic":"Libre Franklin",Palatino:"EB Garamond","Palatino Linotype":"EB Garamond","Lucida Sans":"Open Sans","Segoe UI":"Open Sans",Impact:"Anton","Comic Sans MS":"Comic Neue",Consolas:"Inconsolata","Lucida Console":"Inconsolata",Monaco:"Fira Code"};function qr(t){let e=t.trim();return Xr[e]||jt(e).googleFont||e}async function Kr(t){let e=t.trim(),n=qr(e);if(n!==e){if(!Fe.has(e)&&jr(e)||Ce(e))return true;let r=await zt(n);return r&&U.add(e),r}return zt(n)}async function Kt(t){let e=[...new Set(t.map(n=>n.trim()))];await Promise.all(e.map(n=>Kr(n)));}var Yr=[{key:"embedRegular",weight:"normal",style:"normal"},{key:"embedBold",weight:"bold",style:"normal"},{key:"embedItalic",weight:"normal",style:"italic"},{key:"embedBoldItalic",weight:"bold",style:"italic"}];function Zr(t,e){let n=t.replace(/^\/+/,""),o=(n.toLowerCase().startsWith("word/")?n:`word/${n}`).toLowerCase();for(let[a,s]of e)if(a.toLowerCase()===o)return s}function Qr(t,e,n,r,o){let a=o.get(e.relId);if(!a)return null;let s=Zr(a,r);if(!s)return null;let i;if(e.fontKey&&Bt(e.fontKey))try{i=Ut(s,e.fontKey);}catch{return null}else i=s.slice(0);return {family:t,weight:n.weight,style:n.style,data:i,subsetted:e.subsetted??false}}function eo(t,e,n){if(!t||t.fonts.length===0)return [];if(!n||e.size===0)return [];let r=Et(n,"word/_rels/fontTable.xml.rels"),o=new Map;for(let[s,i]of r)o.set(s,i.target);let a=[];for(let s of t.fonts)for(let i of Yr){let c=s[i.key];if(!c)continue;let l=Qr(s.name,c,i,e,o);l&&a.push(l);}return a}async function Yt(t,e,n){let r=eo(t,e,n),o=new Set;return r.length===0||await Promise.all(r.map(async a=>{await qt(a.family,a.data,{weight:a.weight,style:a.style})?o.add(a.family):typeof document<"u"&&console.warn(`[embeddedFonts] embedded face "${a.family}" (${a.weight} ${a.style}) failed to load; text using it falls back to the CSS stack`);})),o}var to=new WeakMap;function Zt(t){return to.get(t)}var no=new WeakMap;function Qt(t){let e=no.get(t);if(e)return e;let n=typeof process>"u"?void 0:process.env.OPENOOXML_DOCX_PARSE_BACKEND??process.env.DOCX_PARSE_BACKEND;return n==="rust"?n:ro}var ro="rust";async function ue(t,e={}){await ce(),await se();let n=t instanceof ArrayBuffer?t:await ct(t);Qt(e);let r=e.onProgress??(()=>{});try{r("Extracting DOCX...",0);let o=Pt(n,oo(e));return ao(e,r),await so(o,e.preloadFonts??!0,r),r("Assembling document...",95),r("Complete",100),o.document}catch(o){let a=o instanceof Error?o.message:String(o);if(a.startsWith("Failed to parse DOCX: "))throw o;let s=co(a),i=s.code==="Container"?a.replace(/^container error: /,""):a,c=new Error(`Failed to parse DOCX: ${i}`,{cause:o});throw Object.assign(c,s),c}}function oo(t){let e=Zt(t)?.seed;return {parseHeadersFooters:t.parseHeadersFooters??true,parseNotes:t.parseNotes??true,detectVariables:t.detectVariables??true,...e?{determinismSeed:e}:{},includeCanonical:false}}function ao(t,e){e("Extracted DOCX",10),e("Parsing relationships...",10),e("Parsed relationships",15),e("Parsing theme...",15),e("Parsed theme",20),e("Parsing styles...",20),e("Parsed styles",30),e("Parsing numbering...",30),e("Parsed numbering",35),e("Processing media files...",35),e("Processed media",40),e("Parsing document body...",40),e("Parsed document body",55),t.parseHeadersFooters??true?(e("Parsing headers/footers...",55),e("Parsed headers/footers",65)):e("Skipping headers/footers",65),t.parseNotes??true?(e("Parsing footnotes/endnotes...",65),e("Parsed footnotes/endnotes",75)):e("Skipping footnotes/endnotes",75),e("Parsing comments...",75),t.detectVariables??true?(e("Detecting template variables...",75),e("Detected variables",80)):e("Skipping variable detection",80);}async function so(t,e,n){if(!e){n("Skipping font loading",95);return}n("Loading fonts...",80),await io(t.document.package.theme??null,t.document.package.styles,t.document.package.document),await Yt(t.document.package.fontTable,t.embeddedFonts,t.fontTableRelationshipsXml),n("Loaded fonts",95);}async function io(t,e,n){let r=new Set;t?.fontScheme?.majorFont?.latin&&r.add(t.fontScheme.majorFont.latin),t?.fontScheme?.minorFont?.latin&&r.add(t.fontScheme.minorFont.latin),e?.docDefaults?.rPr?.fontFamily?.ascii&&r.add(e.docDefaults.rPr.fontFamily.ascii);for(let o of e?.styles??[])o.rPr?.fontFamily?.ascii&&r.add(o.rPr.fontFamily.ascii),o.rPr?.fontFamily?.hAnsi&&r.add(o.rPr.fontFamily.hAnsi);for(let o of n.content)if(o.type==="paragraph")for(let a of o.content)a.type==="run"&&(a.formatting?.fontFamily?.ascii&&r.add(a.formatting.fontFamily.ascii),a.formatting?.fontFamily?.hAnsi&&r.add(a.formatting.fontFamily.hAnsi));if(r.size!==0)try{await Kt([...r]);}catch(o){console.warn("Failed to load some fonts:",o);}}function co(t){let e=/(?:unsafe XML|resource limit .* exceeded|malformed XML|invalid relationship) in ([^:]+)(?::| at)/.exec(t)?.[1],n=/ at byte (\d+):/.exec(t)?.[1];return {code:t.startsWith("unsafe XML")?"UnsafeXml":t.startsWith("resource limit")?"ResourceLimit":t.startsWith("malformed XML")?"MalformedXml":t.startsWith("invalid relationship")?"Relationship":t.startsWith("container error")?"Container":t.startsWith("wire.")?"Wire":"Parse",...e?{part:e}:{},...n?{offset:Number(n)}:{}}}var de={type:"string",description:"Document ID from a previous docx_load call"},po={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},mo={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
11
|
-
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
12
|
-
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:de},required:["documentId"]},handler:async(t,e)=>{let{documentId:n}=t,r=e.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let o=et(r.document);return {content:[{type:"text",text:JSON.stringify({variables:o.variables,count:o.variables.length,totalOccurrences:o.totalOccurrences,byLocation:o.byLocation},null,2)}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${o.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},go={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
13
|
-
The variable can later be substituted with actual values using docx_apply_template.
|
|
14
|
-
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:de,position:po,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(t,e)=>{let{documentId:n,position:r,variableName:o}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(o))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${o}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:s}=await Promise.resolve().then(()=>(Ue(),Cn)),i=s(a.document,{type:"insertText",position:r,text:`{${o}}`});return a.document=i,a.lastModified=Date.now(),i.templateVariables||(i.templateVariables=[]),i.templateVariables.includes(o)||i.templateVariables.push(o),{content:[{type:"text",text:JSON.stringify({success:!0,variable:o,insertedAs:`{${o}}`,position:r})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${s.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},yo={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
15
|
-
Replaces all {variable} placeholders with the corresponding values provided.
|
|
16
|
-
Preserves all formatting (fonts, styles, colors, tables).
|
|
17
|
-
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:de,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(t,e)=>{let{documentId:n,variables:r,keepUnmatchedVariables:o=true}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let s=at(a.buffer,r,{nullGetter:o?"keep":"empty"}),i=await ue(s.buffer);return a.document=i,a.buffer=s.buffer,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:s.replacedVariables,unreplacedVariables:s.unreplacedVariables,warnings:s.warnings})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${s.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},ho={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
18
|
-
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
19
|
-
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:de},required:["documentId"]},handler:async(t,e)=>{let{documentId:n}=t,r=e.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!r.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let o=st(r.buffer);return {content:[{type:"text",text:JSON.stringify({valid:o.valid,tags:o.tags,errors:o.errors.map(a=>({message:a.message,variable:a.variable,type:a.type}))},null,2)}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${o.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},Fn=[mo,go,yo,ho];var vn={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:qe,replaceWithTemplateVariable:Ke},mcpTools:Fn};ee();new TextEncoder;new TextDecoder;async function Mn(t){let e=await crypto.subtle.digest("SHA-256",Uint8Array.from(t).buffer);return Array.from(new Uint8Array(e),n=>n.toString(16).padStart(2,"0")).join("")}var Ve={header:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",footer:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"};var xo=new TextEncoder,bo=new TextDecoder("utf-8",{ignoreBOM:true});function M(t){return typeof t=="string"?xo.encode(t):t instanceof Uint8Array?t:new Uint8Array(t)}function me(t){return t?bo.decode(t):void 0}function Ln(t){let e=Ot(Object.fromEntries(t)),n=new ArrayBuffer(e.byteLength);return new Uint8Array(n).set(e),n}function je(t){return t.startsWith("/")?t.slice(1):`word/${t}`}function Nn(t){let e=[{relsPath:"word/_rels/document.xml.rels",blocks:t.package.document.content}],n=i=>(i??[]).flatMap(c=>c.content),r=[...n(t.package.footnoteSeparators),...n(t.package.footnotes)];r.length>0&&e.push({relsPath:"word/_rels/footnotes.xml.rels",blocks:r});let o=[...n(t.package.endnoteSeparators),...n(t.package.endnotes)];o.length>0&&e.push({relsPath:"word/_rels/endnotes.xml.rels",blocks:o});let a=t.package.relationships;if(!a)return e;let s=(i,c)=>{if(i)for(let[l,u]of i.entries()){let p=a.get(l);if(!p||p.type!==c||!p.target)continue;let f=je(p.target).replace(/^word\//,"");e.push({relsPath:`word/_rels/${f}.rels`,blocks:u.content});}};return s(t.package.headers,Ve.header),s(t.package.footers,Ve.footer),e}async function $n(t,e,n={},r,o){await ce(),await se();let a=o??{seed:await Mn(new Uint8Array(e)),now:new Date().toISOString()};To(a);let s=t.package,i={determinism:a,document:s.document,headerEntries:[...s.headers?.entries()??[]],footerEntries:[...s.footers?.entries()??[]],footnotes:s.footnotes??[],endnotes:s.endnotes??[],footnoteSeparators:s.footnoteSeparators??[],endnoteSeparators:s.endnoteSeparators??[],relationshipEntries:[...s.relationships?.entries()??[]],...s.numbering===void 0?{}:{numbering:s.numbering},options:{updateModifiedDate:n.updateModifiedDate??true,...n.modifiedBy===void 0?{}:{modifiedBy:n.modifiedBy}},...{}};We(i,"save");let c=_t(JSON.stringify(i),new Uint8Array(e)),l=Po(c);return wo(t,e,l),{buffer:l,determinism:a}}function wo(t,e,n){let r=Ae(new Uint8Array(e)),o=Ae(new Uint8Array(n));for(let i of Nn(t)){let c=me(r[i.relsPath])??"",l=me(o[i.relsPath])??"",u=new Set(Q(c).map(m=>I(m,"Id"))),p=Q(l).filter(m=>I(m,"Type")?.endsWith("/image")).map(m=>I(m,"Id")).filter(m=>!!m&&!u.has(m)),d=Bn(i.blocks);if(d.length>p.length)throw new Error(`Rust save image mutation mismatch in ${i.relsPath}: ${d.length} model images, ${p.length} relationships`);d.forEach((m,T)=>{m.rId=p[T];});let f=Q(l).filter(m=>I(m,"Type")?.endsWith("/hyperlink")&&I(m,"TargetMode")==="External");for(let m of He(i.blocks)){if(!m.href){On(l,m.rId)||(m.rId=void 0);continue}let T=f.find(b=>_o(I(b,"Target")??"")===m.href),E=T&&I(T,"Id");E&&(m.rId=E);}}let a=t.package.headers,s=t.package.relationships;if(!(!a||!s))for(let[i,c]of a){let l=c.watermark;if(!l||l.kind!=="picture")continue;let u=s.get(i);if(!u?.target)continue;let d=`word/_rels/${je(u.target).replace(/^word\//,"")}.rels`,f=me(o[d])??"";if(On(f,l.relId))continue;let m=l.mediaPath?.split("/").pop(),T=Q(f).find(b=>{if(!I(b,"Type")?.endsWith("/image"))return false;let Gn=I(b,"Target")?.split("/").pop();return m?Gn===m:true}),E=T&&I(T,"Id");E&&(l.relId=E);}}function Bn(t){let e=[],n=r=>{for(let o of r.content)o.type==="drawing"&&o.image.src?.startsWith("data:")&&!o.image.rId&&e.push(o.image);};for(let r of t)if(r.type==="paragraph"){for(let o of r.content)if(o.type==="run")n(o);else if(o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo")for(let a of o.content)a.type==="run"&&n(a);}else if(r.type==="table")for(let o of r.rows)for(let a of o.cells)e.push(...Bn(a.content));return e}function He(t){let e=[];for(let n of t)if(n.type==="paragraph")for(let r of n.content)r.type==="hyperlink"&&(r.href||r.rId)&&!r.anchor&&e.push(r);else if(n.type==="table")for(let r of n.rows)for(let o of r.cells)e.push(...He(o.content));else n.type==="blockSdt"&&e.push(...He(n.content));return e}function Q(t){return [...t.matchAll(/<Relationship\b[^>]*\/?>/g)].map(e=>e[0])}function I(t,e){return t.match(new RegExp(`\\b${e}="([^"]*)"`))?.[1]}function On(t,e){if(e)return Q(t).find(n=>I(n,"Id")===e)}function _o(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(e,n)=>String.fromCodePoint(Number(n))).replace(/&#x([0-9A-Fa-f]+);/g,(e,n)=>String.fromCodePoint(parseInt(n,16))).replace(/&/g,"&")}function To(t){if(!/^[0-9a-f]{64}$/i.test(t.seed))throw new TypeError("Rust save determinism seed must be a SHA-256 hex digest");if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(t.now))throw new TypeError("Rust save clock must be a UTC ISO-8601 millisecond timestamp")}var So=new Set(["__proto__","constructor","prototype"]);function We(t,e,n=new WeakSet){if(!(t===null||typeof t!="object")){if(n.has(t))throw new TypeError(`${e} contains a cycle`);if(n.add(t),Array.isArray(t))t.forEach((r,o)=>We(r,`${e}[${o}]`,n));else for(let r of Object.keys(t)){if(So.has(r))throw new TypeError(`${e} contains forbidden key ${r}`);We(t[r],`${e}.${r}`,n);}n.delete(t);}}function Po(t){let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(t),e}async function Un(){let t=new Map;t.set("[Content_Types].xml",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
20
|
-
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
21
|
-
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
22
|
-
<Default Extension="xml" ContentType="application/xml"/>
|
|
23
|
-
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
24
|
-
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
|
|
25
|
-
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
|
|
26
|
-
<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
|
|
27
|
-
</Types>`)),t.set("_rels/.rels",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
28
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
29
|
-
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
|
|
30
|
-
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
|
|
31
|
-
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
|
|
32
|
-
</Relationships>`)),t.set("word/_rels/document.xml.rels",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
33
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
34
|
-
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
|
|
35
|
-
</Relationships>`)),t.set("word/document.xml",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
36
|
-
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
37
|
-
<w:body>
|
|
38
|
-
<w:p>
|
|
39
|
-
<w:r>
|
|
40
|
-
<w:t></w:t>
|
|
41
|
-
</w:r>
|
|
42
|
-
</w:p>
|
|
43
|
-
<w:sectPr>
|
|
44
|
-
<w:pgSz w:w="12240" w:h="15840"/>
|
|
45
|
-
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
|
|
46
|
-
</w:sectPr>
|
|
47
|
-
</w:body>
|
|
48
|
-
</w:document>`)),t.set("word/styles.xml",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49
|
-
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
50
|
-
<w:docDefaults>
|
|
51
|
-
<w:rPrDefault>
|
|
52
|
-
<w:rPr>
|
|
53
|
-
<w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/>
|
|
54
|
-
<w:sz w:val="22"/>
|
|
55
|
-
</w:rPr>
|
|
56
|
-
</w:rPrDefault>
|
|
57
|
-
<w:pPrDefault>
|
|
58
|
-
<w:pPr>
|
|
59
|
-
<w:spacing w:after="200" w:line="276" w:lineRule="auto"/>
|
|
60
|
-
</w:pPr>
|
|
61
|
-
</w:pPrDefault>
|
|
62
|
-
</w:docDefaults>
|
|
63
|
-
<w:style w:type="paragraph" w:default="1" w:styleId="Normal">
|
|
64
|
-
<w:name w:val="Normal"/>
|
|
65
|
-
</w:style>
|
|
66
|
-
</w:styles>`));let e=new Date().toISOString();return t.set("docProps/core.xml",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
67
|
-
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
68
|
-
<dc:creator>OpenOOXML DOCX Editor</dc:creator>
|
|
69
|
-
<dcterms:created xsi:type="dcterms:W3CDTF">${e}</dcterms:created>
|
|
70
|
-
<dcterms:modified xsi:type="dcterms:W3CDTF">${e}</dcterms:modified>
|
|
71
|
-
</cp:coreProperties>`)),t.set("docProps/app.xml",M(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
72
|
-
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
|
|
73
|
-
<Application>OpenOOXML DOCX Editor</Application>
|
|
74
|
-
<AppVersion>1.0.0</AppVersion>
|
|
75
|
-
</Properties>`)),Ln(t)}async function ze(t,e={}){if(!t.originalBuffer)throw new Error("Cannot repack document: no original buffer for round-trip. Use createDocx() for new documents.");return (await $n(t,t.originalBuffer,e)).buffer}async function Vn(t){let e=await Un();return ze({...t,originalBuffer:e})}Ue();var R={type:"string",description:"Document ID returned from docx_load"},Ge={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"]},Je={type:"object",properties:{start:Ge,end:Ge},required:["start","end"]},ko={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
|
|
76
|
-
Returns a document ID that can be used with other tools.
|
|
77
|
-
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(t,e)=>{let{content:n,source:r}=t;try{let o=atob(n),a=new Uint8Array(o.length);for(let u=0;u<o.length;u++)a[u]=o.charCodeAt(u);let s=a.buffer,i=await ue(s),c=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;e.session.documents.set(c,{id:c,document:i,buffer:s,source:r,lastModified:Date.now()});let l=i.package.document.content.filter(u=>u.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:c,source:r,paragraphCount:l,message:"Document loaded successfully"})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to load document: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Io={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
|
|
78
|
-
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:R},required:["documentId"]},handler:async(t,e)=>{let{documentId:n}=t,r=e.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let o;r.buffer?o=await ze(r.document):o=await Vn(r.document);let a=new Uint8Array(o),s="";for(let c=0;c<a.length;c++)s+=String.fromCharCode(a[c]);let i=btoa(s);return {content:[{type:"text",text:JSON.stringify({documentId:n,base64:i,size:o.byteLength,message:"Document exported successfully"})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to save document: ${o.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},Eo={name:"docx_close",description:`Close a document and free its memory.
|
|
79
|
-
Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:R},required:["documentId"]},handler:async(t,e)=>{let{documentId:n}=t;return e.session.documents.has(n)?(e.session.documents.delete(n),{content:[{type:"text",text:JSON.stringify({documentId:n,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${n}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},Do={name:"docx_get_info",description:`Get metadata and statistics about a document.
|
|
80
|
-
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:R},required:["documentId"]},handler:async(t,e)=>{let{documentId:n}=t,r=e.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};let o=r.document,a=o.package.document,s=a.content.filter(l=>l.type==="paragraph"),i=a.content.filter(l=>l.type==="table"),c=0;for(let l of s)if(l.type==="paragraph"){let u=jn(l);c+=u.split(/\s+/).filter(p=>p.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:n,paragraphCount:s.length,tableCount:i.length,wordCount:c,hasStyles:!!o.package.styles,hasTheme:!!o.package.theme,source:r.source,lastModified:r.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},Ao={name:"docx_get_text",description:`Get the plain text content of the document.
|
|
81
|
-
Returns all text concatenated with paragraph breaks.
|
|
82
|
-
Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:R,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(t,e)=>{let{documentId:n,maxLength:r=1e4}=t,o=e.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};let a=o.document.package.document,s=[];for(let l of a.content)l.type==="paragraph"?s.push(jn(l)):l.type==="table"&&s.push("[TABLE]");let i=s.join(`
|
|
83
|
-
`),c=i.length>r;return c&&(i=i.slice(0,r)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:n,text:i,truncated:c,totalLength:c?s.join(`
|
|
84
|
-
`).length:i.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},Ro={name:"docx_insert_text",description:`Insert text at a specific position in the document.
|
|
85
|
-
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:R,position:Ge,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(t,e)=>{let{documentId:n,position:r,text:o}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=v(a.document,{type:"insertText",position:r,text:o});return a.document=s,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:o.length,position:r})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Co={name:"docx_replace_text",description:`Replace text in a range with new text.
|
|
86
|
-
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:R,range:Je,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(t,e)=>{let{documentId:n,range:r,text:o}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=v(a.document,{type:"replaceText",range:r,text:o});return a.document=s,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:r,newTextLength:o.length})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Fo={name:"docx_delete_text",description:`Delete text in a range.
|
|
87
|
-
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:R,range:Je},required:["documentId","range"]},handler:async(t,e)=>{let{documentId:n,range:r}=t,o=e.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let a=v(o.document,{type:"deleteText",range:r});return o.document=a,o.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:r})}]}}catch(a){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${a.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},vo={name:"docx_format_text",description:`Apply formatting to text in a range.
|
|
88
|
-
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:R,range:Je,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(t,e)=>{let{documentId:n,range:r,formatting:o}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=v(a.document,{type:"formatText",range:r,formatting:o});return a.document=s,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:r,appliedFormatting:o})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to format text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},Mo={name:"docx_apply_style",description:`Apply a named style to a paragraph.
|
|
89
|
-
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:R,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(t,e)=>{let{documentId:n,paragraphIndex:r,styleId:o}=t,a=e.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=v(a.document,{type:"applyStyle",paragraphIndex:r,styleId:o});return a.document=s,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:r,styleId:o})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function jn(t){let e=[];for(let n of t.content)n.type==="run"?e.push(Hn(n)):n.type==="hyperlink"&&e.push(Lo(n));return e.join("")}function Hn(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function Lo(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(Hn(n));return e.join("")}var Wn=[ko,Io,Eo,Do,Ao,Ro,Co,Fo,vo,Mo];function No(t={}){let{name:e="docx-editor",version:n="0.1.0",includeCoreTools:r=true,debug:o=false,additionalTools:a=[]}=t,s=new Map,i={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(r)for(let f of Wn)s.set(f.name,f),o&&console.log(`[MCP] Registered core tool: ${f.name}`);let c=C.getMcpTools();for(let f of c)s.has(f.name)&&console.warn(`[MCP] Tool '${f.name}' from plugin overrides existing tool`),s.set(f.name,f),o&&console.log(`[MCP] Registered plugin tool: ${f.name}`);for(let f of a)s.set(f.name,f),o&&console.log(`[MCP] Registered additional tool: ${f.name}`);let l=o?(f,m)=>{console.log(`[MCP] ${f}`,m??"");}:()=>{};async function u(f,m){let T=s.get(f);if(!T)throw new Error(`Unknown tool: ${f}`);l(`Calling tool: ${f}`,m);let E={session:i,log:l};try{let b=await T.handler(m,E);return l(`Tool ${f} completed`,b),b}catch(b){throw l(`Tool ${f} failed`,b),b}}function p(){return Array.from(s.values()).map(f=>({name:f.name,description:f.description,inputSchema:$o(f.inputSchema),category:f.annotations?.category}))}function d(){return {name:e,version:n,toolCount:s.size}}return {tools:s,session:i,handleToolCall:u,listTools:p,getInfo:d}}async function Oo(t,e){let{id:n,method:r,params:o}=e;try{switch(r){case "initialize":return {jsonrpc:"2.0",id:n,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:t.getInfo()}};case "tools/list":{let a=t.listTools();return {jsonrpc:"2.0",id:n,result:{tools:a.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))}}}case "tools/call":{let{name:a,arguments:s}=o,i=await t.handleToolCall(a,s);return {jsonrpc:"2.0",id:n,result:i}}default:return {jsonrpc:"2.0",id:n,error:{code:-32601,message:`Method not found: ${r}`}}}}catch(a){return {jsonrpc:"2.0",id:n,error:{code:-32e3,message:a.message}}}}async function zn(t={}){let e=No(t);t.debug&&(console.error(`[MCP] Server started: ${e.getInfo().name} v${e.getInfo().version}`),console.error(`[MCP] Tools registered: ${e.tools.size}`));let r=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),o="";r.on("line",async a=>{o+=a;try{let s=JSON.parse(o);o="";let i=await Oo(e,s);process.stdout.write(JSON.stringify(i)+`
|
|
90
|
-
`);}catch{}}),r.on("close",()=>{t.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function $o(t){return typeof t=="object"&&t!==null&&("type"in t||"properties"in t)?t:{type:"object",properties:{}}}function Bo(){let t=process.argv.slice(2);return {debug:t.includes("--debug")||t.includes("-d"),help:t.includes("--help")||t.includes("-h"),version:t.includes("--version")||t.includes("-v")}}var Uo=`
|
|
91
|
-
docx-editor-mcp - MCP server for DOCX document editing
|
|
92
|
-
|
|
93
|
-
USAGE:
|
|
94
|
-
docx-editor-mcp [OPTIONS]
|
|
95
|
-
|
|
96
|
-
OPTIONS:
|
|
97
|
-
-d, --debug Enable debug logging (logs to stderr)
|
|
98
|
-
-h, --help Show this help message
|
|
99
|
-
-v, --version Show version number
|
|
100
|
-
|
|
101
|
-
DESCRIPTION:
|
|
102
|
-
Starts an MCP (Model Context Protocol) server that exposes DOCX document
|
|
103
|
-
editing tools to AI clients like Claude Desktop.
|
|
104
|
-
|
|
105
|
-
AVAILABLE TOOLS:
|
|
106
|
-
Core Tools:
|
|
107
|
-
docx_load Load a DOCX document from base64
|
|
108
|
-
docx_save Export document to base64
|
|
109
|
-
docx_close Close a document
|
|
110
|
-
docx_get_info Get document metadata
|
|
111
|
-
docx_get_text Get document plain text
|
|
112
|
-
docx_insert_text Insert text at position
|
|
113
|
-
docx_replace_text Replace text in range
|
|
114
|
-
docx_delete_text Delete text in range
|
|
115
|
-
docx_format_text Apply text formatting
|
|
116
|
-
docx_apply_style Apply paragraph style
|
|
117
|
-
|
|
118
|
-
Template Tools (docxtemplater plugin):
|
|
119
|
-
docx_get_variables List template variables
|
|
120
|
-
docx_insert_variable Insert {variable} placeholder
|
|
121
|
-
docx_apply_template Substitute template variables
|
|
122
|
-
docx_validate_template Validate template syntax
|
|
123
|
-
|
|
124
|
-
CLAUDE DESKTOP CONFIGURATION:
|
|
125
|
-
Add to your Claude Desktop config:
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
"mcpServers": {
|
|
129
|
-
"docx-editor": {
|
|
130
|
-
"command": "npx",
|
|
131
|
-
"args": ["-y", "@betteroffice/docx", "--mcp"]
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
EXAMPLES:
|
|
137
|
-
# Start server (normal mode)
|
|
138
|
-
docx-editor-mcp
|
|
139
|
-
|
|
140
|
-
# Start server with debug logging
|
|
141
|
-
docx-editor-mcp --debug
|
|
142
|
-
`;async function Vo(){let{debug:t,help:e,version:n}=Bo();e&&(console.log(Uo),process.exit(0)),n&&(console.log("0.1.0"),process.exit(0)),C.register(vn),t&&(console.error("[MCP CLI] Registered docxtemplater plugin"),console.error(`[MCP CLI] Total plugins: ${C.size}`),console.error(`[MCP CLI] Total MCP tools: ${C.getMcpTools().length}`)),await zn({name:"docx-editor",version:"0.1.0",debug:t});}Vo().catch(t=>{console.error("[MCP CLI] Fatal error:",t),process.exit(1);});
|
package/dist/mcp.d.mts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { f as McpToolDefinition, M as McpSession, J as JsonSchema } from './types-dYdjUZMo.mjs';
|
|
2
|
-
import './types/document.mjs';
|
|
3
|
-
import './content-sSHuWw49.mjs';
|
|
4
|
-
import './formatting-DoL7KBSL.mjs';
|
|
5
|
-
import './docx/wrapTypes.mjs';
|
|
6
|
-
import './styles-VxNcXLdi.mjs';
|
|
7
|
-
import './settingsParser-CcGvtmCK.mjs';
|
|
8
|
-
import './types/agentApi.mjs';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Core MCP Tools
|
|
12
|
-
*
|
|
13
|
-
* Built-in MCP tools for document operations that are always available.
|
|
14
|
-
* These provide basic document manipulation without requiring plugins.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Load a DOCX document from base64
|
|
19
|
-
*/
|
|
20
|
-
declare const loadDocumentTool: McpToolDefinition;
|
|
21
|
-
/**
|
|
22
|
-
* Save a document to base64
|
|
23
|
-
*/
|
|
24
|
-
declare const saveDocumentTool: McpToolDefinition;
|
|
25
|
-
/**
|
|
26
|
-
* Close a document
|
|
27
|
-
*/
|
|
28
|
-
declare const closeDocumentTool: McpToolDefinition;
|
|
29
|
-
/**
|
|
30
|
-
* Get document information
|
|
31
|
-
*/
|
|
32
|
-
declare const getDocumentInfoTool: McpToolDefinition;
|
|
33
|
-
/**
|
|
34
|
-
* Get document plain text
|
|
35
|
-
*/
|
|
36
|
-
declare const getDocumentTextTool: McpToolDefinition;
|
|
37
|
-
/**
|
|
38
|
-
* Insert text at a position
|
|
39
|
-
*/
|
|
40
|
-
declare const insertTextTool: McpToolDefinition;
|
|
41
|
-
/**
|
|
42
|
-
* Replace text in a range
|
|
43
|
-
*/
|
|
44
|
-
declare const replaceTextTool: McpToolDefinition;
|
|
45
|
-
/**
|
|
46
|
-
* Delete text in a range
|
|
47
|
-
*/
|
|
48
|
-
declare const deleteTextTool: McpToolDefinition;
|
|
49
|
-
/**
|
|
50
|
-
* Apply text formatting
|
|
51
|
-
*/
|
|
52
|
-
declare const formatTextTool: McpToolDefinition;
|
|
53
|
-
/**
|
|
54
|
-
* Apply paragraph style
|
|
55
|
-
*/
|
|
56
|
-
declare const applyStyleTool: McpToolDefinition;
|
|
57
|
-
declare const coreMcpTools: McpToolDefinition[];
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* MCP Server
|
|
61
|
-
*
|
|
62
|
-
* Model Context Protocol server that exposes document editing tools to AI clients.
|
|
63
|
-
* Discovers and registers tools from the plugin system plus core built-in tools.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* import { createMcpServer, startStdioServer } from '@betteroffice/docx/mcp';
|
|
68
|
-
* import { pluginRegistry, docxtemplaterPlugin } from '@betteroffice/docx/core-plugins';
|
|
69
|
-
*
|
|
70
|
-
* // Register plugins
|
|
71
|
-
* pluginRegistry.register(docxtemplaterPlugin);
|
|
72
|
-
*
|
|
73
|
-
* // Start MCP server
|
|
74
|
-
* startStdioServer();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* MCP Server configuration
|
|
80
|
-
*/
|
|
81
|
-
interface McpServerConfig {
|
|
82
|
-
/** Server name */
|
|
83
|
-
name?: string;
|
|
84
|
-
/** Server version */
|
|
85
|
-
version?: string;
|
|
86
|
-
/** Include core tools (default: true) */
|
|
87
|
-
includeCoreTools?: boolean;
|
|
88
|
-
/** Enable debug logging */
|
|
89
|
-
debug?: boolean;
|
|
90
|
-
/** Custom tools to add */
|
|
91
|
-
additionalTools?: McpToolDefinition[];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* MCP Server instance
|
|
95
|
-
*/
|
|
96
|
-
interface McpServer {
|
|
97
|
-
/** All registered tools */
|
|
98
|
-
tools: Map<string, McpToolDefinition>;
|
|
99
|
-
/** Active session */
|
|
100
|
-
session: McpSession;
|
|
101
|
-
/** Handle a tool call */
|
|
102
|
-
handleToolCall(toolName: string, input: unknown): Promise<unknown>;
|
|
103
|
-
/** List available tools */
|
|
104
|
-
listTools(): McpToolInfo[];
|
|
105
|
-
/** Get server info */
|
|
106
|
-
getInfo(): {
|
|
107
|
-
name: string;
|
|
108
|
-
version: string;
|
|
109
|
-
toolCount: number;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Tool info for listing
|
|
114
|
-
*/
|
|
115
|
-
interface McpToolInfo {
|
|
116
|
-
name: string;
|
|
117
|
-
description: string;
|
|
118
|
-
inputSchema: JsonSchema;
|
|
119
|
-
category?: string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Create an MCP server instance
|
|
123
|
-
*
|
|
124
|
-
* @param config - Server configuration
|
|
125
|
-
* @returns MCP server instance
|
|
126
|
-
*/
|
|
127
|
-
declare function createMcpServer(config?: McpServerConfig): McpServer;
|
|
128
|
-
/**
|
|
129
|
-
* JSON-RPC request
|
|
130
|
-
*/
|
|
131
|
-
interface JsonRpcRequest {
|
|
132
|
-
jsonrpc: '2.0';
|
|
133
|
-
id: string | number;
|
|
134
|
-
method: string;
|
|
135
|
-
params?: unknown;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* JSON-RPC response
|
|
139
|
-
*/
|
|
140
|
-
interface JsonRpcResponse {
|
|
141
|
-
jsonrpc: '2.0';
|
|
142
|
-
id: string | number;
|
|
143
|
-
result?: unknown;
|
|
144
|
-
error?: {
|
|
145
|
-
code: number;
|
|
146
|
-
message: string;
|
|
147
|
-
data?: unknown;
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Handle a JSON-RPC request
|
|
152
|
-
*/
|
|
153
|
-
declare function handleJsonRpcRequest(server: McpServer, request: JsonRpcRequest): Promise<JsonRpcResponse>;
|
|
154
|
-
/**
|
|
155
|
-
* Start the MCP server with stdio transport
|
|
156
|
-
*
|
|
157
|
-
* Reads JSON-RPC requests from stdin, writes responses to stdout.
|
|
158
|
-
* This is the standard way to run an MCP server for Claude Desktop.
|
|
159
|
-
*/
|
|
160
|
-
declare function startStdioServer(config?: McpServerConfig): Promise<void>;
|
|
161
|
-
|
|
162
|
-
export { type McpServer, type McpServerConfig, type McpToolInfo, applyStyleTool, closeDocumentTool, coreMcpTools, createMcpServer, deleteTextTool, formatTextTool, getDocumentInfoTool, getDocumentTextTool, handleJsonRpcRequest, insertTextTool, loadDocumentTool, replaceTextTool, saveDocumentTool, startStdioServer };
|
package/dist/mcp.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';import {b}from'./chunk-VBOTMRXV.mjs';import {h as h$1,s}from'./chunk-KVKLLTDP.mjs';import'./chunk-BIQWVK5P.mjs';import'./chunk-3UBMCDME.mjs';import {a}from'./chunk-LDUWIM7M.mjs';import'./chunk-DXKG3HQ5.mjs';import'./chunk-FPZBTOD6.mjs';import'./chunk-H3JCIGWK.mjs';import'./chunk-N5Q3YN64.mjs';import'./chunk-SINEY6ZF.mjs';import'./chunk-T4EZMUXM.mjs';import'./chunk-TTRUPDAB.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"]},R={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
|
|
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$1=await a(o),d=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;s.session.documents.set(d,{id:d,document:a$1,buffer:o,source:c,lastModified:Date.now()});let p=a$1.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"}},k={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$1)=>{let{documentId:e}=r,c=s$1.session.documents.get(e);if(!c)return {isError:true,content:[{type:"text",text:`Document not found: ${e}`}]};try{let t;c.buffer?t=await h$1(c.document):t=await s(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"}},$={name:"docx_close",description:`Close a document and free its memory.
|
|
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"}},J={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=q(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"}},v={name:"docx_get_text",description:`Get the plain text content of the document.
|
|
7
|
-
Returns all text concatenated with paragraph breaks.
|
|
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(q(p)):p.type==="table"&&o.push("[TABLE]");let a=o.join(`
|
|
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
|
-
`).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: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$1(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"}},E={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$1(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"}},O={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$1(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"}},P={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$1(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"}},_={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$1(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 q(r){let s=[];for(let e of r.content)e.type==="run"?s.push(F(e)):e.type==="hyperlink"&&s.push(z(e));return s.join("")}function F(r){return r.content.filter(s=>s.type==="text").map(s=>s.text).join("")}function z(r){let s=[];for(let e of r.children)e.type==="run"&&s.push(F(e));return s.join("")}var T=[R,k,$,J,v,j,E,O,P,_];function L(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 H={session:a,log:p};try{let g=await M.handler(f,H);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:B(i.inputSchema),category:i.annotations?.category}))}function A(){return {name:s,version:e,toolCount:o.size}}return {tools:o,session:a,handleToolCall:l,listTools:y,getInfo:A}}async function N(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 U(r={}){let s=L(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 N(s,o);process.stdout.write(JSON.stringify(a)+`
|
|
16
|
-
`);}catch{}}),c.on("close",()=>{r.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function B(r){return typeof r=="object"&&r!==null&&("type"in r||"properties"in r)?r:{type:"object",properties:{}}}export{_ as applyStyleTool,$ as closeDocumentTool,T as coreMcpTools,L as createMcpServer,O as deleteTextTool,P as formatTextTool,J as getDocumentInfoTool,v as getDocumentTextTool,N as handleJsonRpcRequest,j as insertTextTool,R as loadDocumentTool,E as replaceTextTool,k as saveDocumentTool,U as startStdioServer};
|