@betteroffice/docx 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
  4. package/dist/agent/index.d.mts +531 -0
  5. package/dist/agent/index.mjs +1 -0
  6. package/dist/chunk-34K66SY4.mjs +1 -0
  7. package/dist/chunk-3UBMCDME.mjs +1 -0
  8. package/dist/chunk-4RCISPPE.mjs +1 -0
  9. package/dist/chunk-4UD54UM5.mjs +1 -0
  10. package/dist/chunk-52GB3Y42.mjs +1 -0
  11. package/dist/chunk-6NEKRDXF.mjs +1 -0
  12. package/dist/chunk-6PW4CWUG.mjs +1 -0
  13. package/dist/chunk-7DEIW7FL.mjs +1 -0
  14. package/dist/chunk-7PCO5I2O.mjs +1 -0
  15. package/dist/chunk-BI3B33LI.mjs +1 -0
  16. package/dist/chunk-BIQWVK5P.mjs +2 -0
  17. package/dist/chunk-CIRN3LZA.mjs +1 -0
  18. package/dist/chunk-DXKG3HQ5.mjs +16 -0
  19. package/dist/chunk-EUUIJVM6.mjs +0 -0
  20. package/dist/chunk-FPZBTOD6.mjs +1 -0
  21. package/dist/chunk-FZIA7OFY.mjs +1 -0
  22. package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
  23. package/dist/chunk-H3JCIGWK.mjs +1 -0
  24. package/dist/chunk-HJGAQIU7.mjs +2 -0
  25. package/dist/chunk-I6KKMUUC.mjs +1 -0
  26. package/dist/chunk-IL5JZJT7.mjs +1 -0
  27. package/dist/chunk-JY6ILTNS.mjs +1 -0
  28. package/dist/chunk-KEE52TT5.mjs +1 -0
  29. package/dist/chunk-KVKLLTDP.mjs +58 -0
  30. package/dist/chunk-KXNZFTTK.mjs +1 -0
  31. package/dist/chunk-L5ISVQ3W.mjs +1 -0
  32. package/dist/chunk-LDUWIM7M.mjs +1 -0
  33. package/dist/chunk-N5Q3YN64.mjs +1 -0
  34. package/dist/chunk-NEWOMDTX.mjs +1 -0
  35. package/dist/chunk-O2QSE2I7.mjs +1 -0
  36. package/dist/chunk-OBQGPMPQ.mjs +1 -0
  37. package/dist/chunk-OJOHXQNQ.mjs +1 -0
  38. package/dist/chunk-OMR3TWCD.mjs +2 -0
  39. package/dist/chunk-P3KDV4M2.mjs +1 -0
  40. package/dist/chunk-Q7PO7V73.mjs +1 -0
  41. package/dist/chunk-QOUFE3VX.mjs +1 -0
  42. package/dist/chunk-SINEY6ZF.mjs +1 -0
  43. package/dist/chunk-T4EZMUXM.mjs +1 -0
  44. package/dist/chunk-TTRUPDAB.mjs +1 -0
  45. package/dist/chunk-TYHI7RAD.mjs +1 -0
  46. package/dist/chunk-UIEJWORW.mjs +1 -0
  47. package/dist/chunk-VAOUFAUH.mjs +1 -0
  48. package/dist/chunk-VBOTMRXV.mjs +1 -0
  49. package/dist/chunk-VCER63GQ.mjs +1 -0
  50. package/dist/chunk-WAUF2UC7.mjs +2 -0
  51. package/dist/chunk-WRWRCBLK.mjs +1 -0
  52. package/dist/chunk-X4XDO3LZ.mjs +1 -0
  53. package/dist/chunk-XQBCCJBO.mjs +9 -0
  54. package/dist/chunk-XWUOLYRQ.mjs +2 -0
  55. package/dist/chunk-XYH6XWP3.mjs +10 -0
  56. package/dist/chunk-YBIM6UJV.mjs +8 -0
  57. package/dist/chunk-YCIH2Q3E.mjs +1 -0
  58. package/dist/chunk-YUOKI2HB.mjs +1 -0
  59. package/dist/chunk-ZOV5KL7C.mjs +1 -0
  60. package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
  61. package/dist/content-sSHuWw49.d.mts +2202 -0
  62. package/dist/core-plugins.d.mts +37 -0
  63. package/dist/core-plugins.mjs +1 -0
  64. package/dist/core.d.mts +451 -0
  65. package/dist/core.mjs +1 -0
  66. package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
  67. package/dist/docx/index.d.mts +618 -0
  68. package/dist/docx/index.mjs +2 -0
  69. package/dist/docx/parser.d.mts +41 -0
  70. package/dist/docx/parser.mjs +1 -0
  71. package/dist/docx/rezip.d.mts +148 -0
  72. package/dist/docx/rezip.mjs +1 -0
  73. package/dist/docx/serializer/index.d.mts +42 -0
  74. package/dist/docx/serializer/index.mjs +1 -0
  75. package/dist/docx/wrapTypes.d.mts +19 -0
  76. package/dist/docx/wrapTypes.mjs +1 -0
  77. package/dist/docxInput-DTbCa48g.d.mts +21 -0
  78. package/dist/editor/index.d.mts +170 -0
  79. package/dist/editor/index.mjs +1 -0
  80. package/dist/editorTree-DO5PyDK8.d.mts +37 -0
  81. package/dist/executor-7O2RBJ2B.mjs +1 -0
  82. package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
  83. package/dist/formatting-DoL7KBSL.d.mts +823 -0
  84. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  85. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  86. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  87. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  88. package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
  89. package/dist/headless.d.mts +69 -0
  90. package/dist/headless.mjs +1 -0
  91. package/dist/layout/flow/index.d.mts +149 -0
  92. package/dist/layout/flow/index.mjs +1 -0
  93. package/dist/layout/index.d.mts +307 -0
  94. package/dist/layout/index.mjs +1 -0
  95. package/dist/layout/measure/index.d.mts +324 -0
  96. package/dist/layout/measure/index.mjs +1 -0
  97. package/dist/layout/pagination/index.d.mts +60 -0
  98. package/dist/layout/pagination/index.mjs +1 -0
  99. package/dist/layout/pagination/types.d.mts +4 -0
  100. package/dist/layout/pagination/types.mjs +1 -0
  101. package/dist/layout/render/index.d.mts +733 -0
  102. package/dist/layout/render/index.mjs +1 -0
  103. package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
  104. package/dist/managers/AutoSaveManager.d.mts +81 -0
  105. package/dist/managers/AutoSaveManager.mjs +1 -0
  106. package/dist/managers/TableSelectionManager.d.mts +74 -0
  107. package/dist/managers/TableSelectionManager.mjs +1 -0
  108. package/dist/managers/types.d.mts +113 -0
  109. package/dist/managers/types.mjs +0 -0
  110. package/dist/mcp-cli.mjs +142 -0
  111. package/dist/mcp.d.mts +162 -0
  112. package/dist/mcp.mjs +16 -0
  113. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
  114. package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
  115. package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
  116. package/dist/plugin-api/RenderedDomContext.mjs +1 -0
  117. package/dist/plugin-api/index.d.mts +7 -0
  118. package/dist/plugin-api/index.mjs +0 -0
  119. package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
  120. package/dist/plugin-api/resolveItemPositions.mjs +1 -0
  121. package/dist/plugin-api/types.d.mts +193 -0
  122. package/dist/plugin-api/types.mjs +0 -0
  123. package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
  124. package/dist/registry-DMM5VTdT.d.mts +165 -0
  125. package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
  126. package/dist/rustPagination-Bj2hq013.d.mts +106 -0
  127. package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
  128. package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
  129. package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
  130. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
  131. package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
  132. package/dist/styles/index.d.mts +162 -0
  133. package/dist/styles/index.mjs +1 -0
  134. package/dist/styles-VxNcXLdi.d.mts +189 -0
  135. package/dist/types/agentApi.d.mts +456 -0
  136. package/dist/types/agentApi.mjs +1 -0
  137. package/dist/types/content.d.mts +3 -0
  138. package/dist/types/content.mjs +1 -0
  139. package/dist/types/document.d.mts +117 -0
  140. package/dist/types/document.mjs +1 -0
  141. package/dist/types-DNrYr6yQ.d.mts +1754 -0
  142. package/dist/types-dYdjUZMo.d.mts +311 -0
  143. package/dist/units-O5Y02RKQ.d.mts +34 -0
  144. package/dist/utils/autoScroll.d.mts +24 -0
  145. package/dist/utils/autoScroll.mjs +1 -0
  146. package/dist/utils/cardStyles.d.mts +22 -0
  147. package/dist/utils/cardStyles.mjs +1 -0
  148. package/dist/utils/comments.d.mts +120 -0
  149. package/dist/utils/comments.mjs +4 -0
  150. package/dist/utils/findReplace.d.mts +114 -0
  151. package/dist/utils/findReplace.mjs +2 -0
  152. package/dist/utils/findVerticalScrollParent.d.mts +25 -0
  153. package/dist/utils/findVerticalScrollParent.mjs +1 -0
  154. package/dist/utils/fontOptions.d.mts +21 -0
  155. package/dist/utils/fontOptions.mjs +1 -0
  156. package/dist/utils/headingCollector.d.mts +28 -0
  157. package/dist/utils/headingCollector.mjs +1 -0
  158. package/dist/utils/highlightColors.d.mts +14 -0
  159. package/dist/utils/highlightColors.mjs +1 -0
  160. package/dist/utils/index.d.mts +956 -0
  161. package/dist/utils/index.mjs +84 -0
  162. package/dist/utils/listState.d.mts +27 -0
  163. package/dist/utils/listState.mjs +1 -0
  164. package/dist/utils/reportIssue.d.mts +23 -0
  165. package/dist/utils/reportIssue.mjs +2 -0
  166. package/dist/utils/sidebarConstants.d.mts +10 -0
  167. package/dist/utils/sidebarConstants.mjs +1 -0
  168. package/dist/utils/stylePreview.d.mts +70 -0
  169. package/dist/utils/stylePreview.mjs +1 -0
  170. package/dist/utils/textSelection.d.mts +92 -0
  171. package/dist/utils/textSelection.mjs +1 -0
  172. package/dist/utils/units.d.mts +78 -0
  173. package/dist/utils/units.mjs +1 -0
  174. package/dist/variableDetector-Borj29SF.d.mts +115 -0
  175. package/dist/wasm-FZQ5XB2Y.mjs +1 -0
  176. package/dist/wasm-SA237OSP.mjs +1 -0
  177. package/dist/wasm-edit.d.mts +473 -0
  178. package/dist/wasm-edit.mjs +1 -0
  179. package/dist/wasm-layout.d.mts +112 -0
  180. package/dist/wasm-layout.mjs +1 -0
  181. package/dist/wasm-opc.d.mts +16 -0
  182. package/dist/wasm-opc.mjs +1 -0
  183. package/dist/wasm-parse.d.mts +18 -0
  184. package/dist/wasm-parse.mjs +1 -0
  185. package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
  186. package/dist/yrs/index.d.mts +882 -0
  187. package/dist/yrs/index.mjs +1 -0
  188. package/dist/yrs/residentEngineWorker.d.mts +2 -0
  189. package/dist/yrs/residentEngineWorker.mjs +1 -0
  190. package/package.json +365 -0
@@ -0,0 +1,58 @@
1
+ import {a as a$2}from'./chunk-BIQWVK5P.mjs';import {a,b,c}from'./chunk-H3JCIGWK.mjs';import {h}from'./chunk-N5Q3YN64.mjs';import {a as a$1,g}from'./chunk-SINEY6ZF.mjs';new TextEncoder;new TextDecoder;async function L(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e).buffer);return Array.from(new Uint8Array(t),r=>r.toString(16).padStart(2,"0")).join("")}var V=new TextEncoder,Y=new TextDecoder("utf-8",{ignoreBOM:true});function m(e){return typeof e=="string"?V.encode(e):e instanceof Uint8Array?e:new Uint8Array(e)}function u(e){return e?Y.decode(e):void 0}function w(e){let t=c(Object.fromEntries(e)),r=new ArrayBuffer(t.byteLength);return new Uint8Array(r).set(t),r}function k(e){return e.startsWith("/")?e.slice(1):`word/${e}`}function H(e){let t=[{relsPath:"word/_rels/document.xml.rels",blocks:e.package.document.content}],r=a=>(a??[]).flatMap(p=>p.content),n=[...r(e.package.footnoteSeparators),...r(e.package.footnotes)];n.length>0&&t.push({relsPath:"word/_rels/footnotes.xml.rels",blocks:n});let o=[...r(e.package.endnoteSeparators),...r(e.package.endnotes)];o.length>0&&t.push({relsPath:"word/_rels/endnotes.xml.rels",blocks:o});let i=e.package.relationships;if(!i)return t;let s=(a,p)=>{if(a)for(let[f,y]of a.entries()){let d=i.get(f);if(!d||d.type!==p||!d.target)continue;let x=k(d.target).replace(/^word\//,"");t.push({relsPath:`word/_rels/${x}.rels`,blocks:y.content});}};return s(e.package.headers,a$2.header),s(e.package.footers,a$2.footer),t}function E(e){let t=0;for(let r of e.matchAll(/Id="rId(\d+)"/g)){let n=parseInt(r[1],10);n>t&&(t=n);}return t}async function z(e,t,r={},n,o){await a(),await a$1();let i=o??{seed:await L(new Uint8Array(t)),now:new Date().toISOString()};G(i);let s=e.package,a$2={determinism:i,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:r.updateModifiedDate??true,...r.modifiedBy===void 0?{}:{modifiedBy:r.modifiedBy}},...n===void 0?{}:{selective:{changedParaIds:[...n.changedParaIds]}}};I(a$2,"save");let p=g(JSON.stringify(a$2),new Uint8Array(t)),f=ee(p);return n||Z(e,t,f),{buffer:f,determinism:i}}function Z(e,t,r){let n=b(new Uint8Array(t)),o=b(new Uint8Array(r));for(let a of H(e)){let p=u(n[a.relsPath])??"",f=u(o[a.relsPath])??"",y=new Set(A(p).map(c=>l(c,"Id"))),d=A(f).filter(c=>l(c,"Type")?.endsWith("/image")).map(c=>l(c,"Id")).filter(c=>!!c&&!y.has(c)),h=J(a.blocks);if(h.length>d.length)throw new Error(`Rust save image mutation mismatch in ${a.relsPath}: ${h.length} model images, ${d.length} relationships`);h.forEach((c,g)=>{c.rId=d[g];});let x=A(f).filter(c=>l(c,"Type")?.endsWith("/hyperlink")&&l(c,"TargetMode")==="External");for(let c of B(a.blocks)){if(!c.href){W(f,c.rId)||(c.rId=void 0);continue}let g=x.find(S=>K(l(S,"Target")??"")===c.href),b=g&&l(g,"Id");b&&(c.rId=b);}}let i=e.package.headers,s=e.package.relationships;if(!(!i||!s))for(let[a,p]of i){let f=p.watermark;if(!f||f.kind!=="picture")continue;let y=s.get(a);if(!y?.target)continue;let h=`word/_rels/${k(y.target).replace(/^word\//,"")}.rels`,x=u(o[h])??"";if(W(x,f.relId))continue;let c=f.mediaPath?.split("/").pop(),g=A(x).find(S=>{if(!l(S,"Type")?.endsWith("/image"))return false;let q=l(S,"Target")?.split("/").pop();return c?q===c:true}),b=g&&l(g,"Id");b&&(f.relId=b);}}function J(e){let t=[],r=n=>{for(let o of n.content)o.type==="drawing"&&o.image.src?.startsWith("data:")&&!o.image.rId&&t.push(o.image);};for(let n of e)if(n.type==="paragraph"){for(let o of n.content)if(o.type==="run")r(o);else if(o.type==="insertion"||o.type==="deletion"||o.type==="moveFrom"||o.type==="moveTo")for(let i of o.content)i.type==="run"&&r(i);}else if(n.type==="table")for(let o of n.rows)for(let i of o.cells)t.push(...J(i.content));return t}function B(e){let t=[];for(let r of e)if(r.type==="paragraph")for(let n of r.content)n.type==="hyperlink"&&(n.href||n.rId)&&!n.anchor&&t.push(n);else if(r.type==="table")for(let n of r.rows)for(let o of n.cells)t.push(...B(o.content));else r.type==="blockSdt"&&t.push(...B(r.content));return t}function A(e){return [...e.matchAll(/<Relationship\b[^>]*\/?>/g)].map(t=>t[0])}function l(e,t){return e.match(new RegExp(`\\b${t}="([^"]*)"`))?.[1]}function W(e,t){if(t)return A(e).find(r=>l(r,"Id")===t)}function K(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCodePoint(Number(r))).replace(/&#x([0-9A-Fa-f]+);/g,(t,r)=>String.fromCodePoint(parseInt(r,16))).replace(/&amp;/g,"&")}function G(e){if(!/^[0-9a-f]{64}$/i.test(e.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(e.now))throw new TypeError("Rust save clock must be a UTC ISO-8601 millisecond timestamp")}var Q=new Set(["__proto__","constructor","prototype"]);function I(e,t,r=new WeakSet){if(!(e===null||typeof e!="object")){if(r.has(e))throw new TypeError(`${t} contains a cycle`);if(r.add(e),Array.isArray(e))e.forEach((n,o)=>I(n,`${t}[${o}]`,r));else for(let n of Object.keys(e)){if(Q.has(n))throw new TypeError(`${t} contains forbidden key ${n}`);I(e[n],`${t}.${n}`,r);}r.delete(e);}}function ee(e){let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t}async function M(){let e=new Map;e.set("[Content_Types].xml",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
4
+ <Default Extension="xml" ContentType="application/xml"/>
5
+ <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
6
+ <Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
7
+ <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
8
+ <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
9
+ </Types>`)),e.set("_rels/.rels",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
11
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
12
+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
13
+ <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
14
+ </Relationships>`)),e.set("word/_rels/document.xml.rels",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
15
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
16
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
17
+ </Relationships>`)),e.set("word/document.xml",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
18
+ <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
19
+ <w:body>
20
+ <w:p>
21
+ <w:r>
22
+ <w:t></w:t>
23
+ </w:r>
24
+ </w:p>
25
+ <w:sectPr>
26
+ <w:pgSz w:w="12240" w:h="15840"/>
27
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
28
+ </w:sectPr>
29
+ </w:body>
30
+ </w:document>`)),e.set("word/styles.xml",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
31
+ <w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
32
+ <w:docDefaults>
33
+ <w:rPrDefault>
34
+ <w:rPr>
35
+ <w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/>
36
+ <w:sz w:val="22"/>
37
+ </w:rPr>
38
+ </w:rPrDefault>
39
+ <w:pPrDefault>
40
+ <w:pPr>
41
+ <w:spacing w:after="200" w:line="276" w:lineRule="auto"/>
42
+ </w:pPr>
43
+ </w:pPrDefault>
44
+ </w:docDefaults>
45
+ <w:style w:type="paragraph" w:default="1" w:styleId="Normal">
46
+ <w:name w:val="Normal"/>
47
+ </w:style>
48
+ </w:styles>`));let t=new Date().toISOString();return e.set("docProps/core.xml",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
49
+ <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">
50
+ <dc:creator>OpenOOXML DOCX Editor</dc:creator>
51
+ <dcterms:created xsi:type="dcterms:W3CDTF">${t}</dcterms:created>
52
+ <dcterms:modified xsi:type="dcterms:W3CDTF">${t}</dcterms:modified>
53
+ </cp:coreProperties>`)),e.set("docProps/app.xml",m(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
54
+ <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
55
+ <Application>OpenOOXML DOCX Editor</Application>
56
+ <AppVersion>1.0.0</AppVersion>
57
+ </Properties>`)),w(e)}var De="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Oe="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Re="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml",Ee="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml",te="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",re="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";async function C(e,t={}){if(!e.originalBuffer)throw new Error("Cannot repack document: no original buffer for round-trip. Use createDocx() for new documents.");return (await z(e,e.originalBuffer,t)).buffer}async function Be(e,t,r={}){return C({...e,originalBuffer:t.originalBuffer},r)}function O(e){return new Map(Object.entries(b(new Uint8Array(e))))}async function Ie(e,t,r={}){return X(e,new Map([["word/document.xml",t]]),r)}async function Me(e,t,r,n={}){return X(e,new Map([[t,r]]),n)}async function X(e,t,r={}){return ne(O(e),t,r)}async function ne(e,t,r={}){for(let[n,o]of t)e.set(n,m(o));return w(e)}function v(e,t){let r="word/_rels/document.xml.rels",n=u(e.get(r));if(n===void 0)throw new Error("document.xml.rels not found in DOCX");let o=`rId${E(n)+1}`,i=t.targetMode==="External"?' TargetMode="External"':"",s=`<Relationship Id="${o}" Type="${P(t.type)}" Target="${P(t.target)}"${i}/>`,a=n.replace(/<Relationships([^>]*)\/>/,"<Relationships$1></Relationships>");return e.set(r,m(a.replace("</Relationships>",`${s}</Relationships>`))),o}async function Ce(e,t){let r=O(e),n=v(r,t);return {buffer:w(r),rId:n}}async function Ue(e,t,r,n){let o=O(e),i=`word/media/${t}`;o.set(i,m(r));let s=v(o,{type:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",target:`media/${t}`}),a=u(o.get("[Content_Types].xml")),p=t.split(".").pop()?.toLowerCase()??"";if(a!==void 0&&p&&!a.includes(`Extension="${p}"`)){let f=`<Default Extension="${P(p)}" ContentType="${P(n||oe(p))}"/>`;o.set("[Content_Types].xml",m(a.replace("</Types>",`${f}</Types>`)));}return {buffer:w(o),rId:s,path:i}}function oe(e){return {png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",tif:"image/tiff",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp",wmf:"image/x-wmf",emf:"image/x-emf"}[e]??"application/octet-stream"}function Fe(e,t){let r=e;if(t.updateModifiedDate){let n=`<dcterms:modified xsi:type="dcterms:W3CDTF">${new Date().toISOString()}</dcterms:modified>`;r=r.includes("<dcterms:modified")?r.replace(/<dcterms:modified[^<>]*>[^<]*<\/dcterms:modified>/,n):r.replace("</cp:coreProperties>",`${n}</cp:coreProperties>`);}if(t.modifiedBy){let n=`<cp:lastModifiedBy>${P(t.modifiedBy)}</cp:lastModifiedBy>`;r=r.includes("<cp:lastModifiedBy")?r.replace(/<cp:lastModifiedBy>[^<]*<\/cp:lastModifiedBy>/,n):r.replace("</cp:coreProperties>",`${n}</cp:coreProperties>`);}return r}async function Ne(e){let t=[],r=[];try{let n=O(e);for(let s of ["[Content_Types].xml","word/document.xml"])n.has(s)||t.push(`Missing required file: ${s}`);for(let s of ["_rels/.rels","word/_rels/document.xml.rels","word/styles.xml"])n.has(s)||r.push(`Missing recommended file: ${s}`);let o=u(n.get("word/document.xml"));o!==void 0&&(o.includes("<?xml")||r.push("document.xml missing XML declaration"),o.includes("<w:document")||t.push("document.xml missing w:document element"),o.includes("<w:body>")||t.push("document.xml missing w:body element"));let i=u(n.get("[Content_Types].xml"));i!==void 0&&!i.includes("word/document.xml")&&!i.includes("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")&&r.push("Content_Types.xml may be missing document.xml type declaration");}catch(n){let o=n instanceof Error?n.message:typeof n=="string"?n:"Unknown error";t.push(`Failed to read as ZIP: ${o}`);}return {valid:t.length===0,errors:t,warnings:r}}function je(e){if(e.byteLength<4)return false;let t=new Uint8Array(e);return t[0]===80&&t[1]===75}async function _e(e){let t=await M();return C({...e,originalBuffer:t})}function Le(e){let t=new Map,r=e.package.relationships;if(!r)return t;let n=[{map:e.package.headers,relationshipType:te},{map:e.package.footers,relationshipType:re}];for(let{map:o,relationshipType:i}of n)for(let[s,a]of o??[]){let p=r.get(s);p?.type===i&&p.target&&t.set(k(p.target),h(a));}return t}function P(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var He=C;
58
+ export{E as a,z as b,M as c,De as d,Oe as e,Re as f,Ee as g,C as h,Be as i,Ie as j,Me as k,X as l,ne as m,Ce as n,Ue as o,Fe as p,Ne as q,je as r,_e as s,Le as t,He as u};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-TTRUPDAB.mjs';function y(i,t){let e=i?{...i}:{},r=t,n=[["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","csTheme"]],a=new Set;for(let[l,o]of n)a.add(l),a.add(o),(r[l]!==void 0||r[o]!==void 0)&&(delete e[l],delete e[o],r[l]!==void 0&&(e[l]=r[l]),r[o]!==void 0&&(e[o]=r[o]));for(let l of Object.keys(r))!a.has(l)&&r[l]!==void 0&&(e[l]=r[l]);return e}function g(i,t){if(!t&&!i)return;if(!t)return i;if(!i)return {...t};let e={...i};for(let r of Object.keys(t)){let n=t[r];if(n!==void 0){if(r==="fontFamily"&&typeof n=="object"&&n!==null){e.fontFamily=y(i.fontFamily,n);continue}if(r==="color"&&typeof n=="object"&&n!==null){let a=n,l=!!(a.rgb||a.themeColor||a.themeTint||a.themeShade);(!a.auto||l)&&(e.color=a);continue}if(typeof n=="object"&&n!==null&&!Array.isArray(n)){e[r]={...i[r]??{},...n};continue}e[r]=n;}}return e}var m={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},f=class{constructor(t){b(this,"stylesById");b(this,"docDefaults");b(this,"defaultParagraphStyle");b(this,"defaultTableStyle");b(this,"defaultCharacterStyle");if(this.stylesById=new Map,this.docDefaults=t?.docDefaults,t?.styles)for(let e of t.styles)e.styleId&&this.stylesById.set(e.styleId,e);this.defaultParagraphStyle=this.findDefaultStyle("paragraph"),this.defaultTableStyle=this.findDefaultStyle("table"),this.defaultCharacterStyle=this.findDefaultStyle("character");}getStyle(t){return this.stylesById.get(t)}getParagraphStyles(){let t=[];for(let e of this.stylesById.values())e.type==="paragraph"&&!e.hidden&&!e.semiHidden&&t.push(e);return t.sort((e,r)=>{let n=e.uiPriority??99,a=r.uiPriority??99;return n!==a?n-a:(e.name??e.styleId).localeCompare(r.name??r.styleId)})}hasParagraphStyle(t){return this.stylesById.get(t)?.type==="paragraph"}resolveParagraphStyle(t){let e={};if(this.docDefaults?.pPr&&(e.paragraphFormatting={...this.docDefaults.pPr}),this.docDefaults?.rPr&&(e.runFormatting={...this.docDefaults.rPr}),!t)return this.defaultParagraphStyle&&this.mergeStyleIntoResult(e,this.defaultParagraphStyle),e;let r=this.stylesById.get(t);return r?(this.mergeStyleIntoResult(e,r),e):(this.defaultParagraphStyle&&this.mergeStyleIntoResult(e,this.defaultParagraphStyle),e)}getNextStyleId(t){if(!t)return null;let e=this.stylesById.get(t)?.next;return e&&e!==t?e:null}getTableStyles(){let t=[];for(let e of this.stylesById.values())e.type==="table"&&!e.hidden&&!e.semiHidden&&t.push(e);return t.sort((e,r)=>{let n=e.uiPriority??99,a=r.uiPriority??99;return n!==a?n-a:(e.name??e.styleId).localeCompare(r.name??r.styleId)})}resolveRunStyle(t){let e={};if(this.docDefaults?.rPr&&(e={...this.docDefaults.rPr}),this.defaultCharacterStyle?.rPr&&(e=this.mergeTextFormatting(e,this.defaultCharacterStyle.rPr)??e),!t)return Object.keys(e).length>0?e:void 0;let r=this.stylesById.get(t);if(!r?.rPr)return Object.keys(e).length>0?e:void 0;let n=this.mergeTextFormatting(e,r.rPr);return n&&Object.keys(n).length>0?n:void 0}getRunStyleOwnProperties(t){if(!t)return;let e=this.stylesById.get(t);if(e?.rPr)return Object.keys(e.rPr).length>0?{...e.rPr}:void 0}getDocDefaults(){return this.docDefaults}getDefaultParagraphStyle(){return this.defaultParagraphStyle}getDefaultTableStyle(){return this.defaultTableStyle}getDefaultCharacterStyle(){return this.defaultCharacterStyle}hasStyle(t){return this.stylesById.has(t)}findDefaultStyle(t){for(let e of this.stylesById.values())if(e.type===t&&e.default)return e;if(t==="paragraph")return this.stylesById.get("Normal")??(this.docDefaults?void 0:m)}mergeStyleIntoResult(t,e){e.pPr&&(t.paragraphFormatting=this.mergeParagraphFormatting(t.paragraphFormatting,e.pPr)),e.rPr&&(t.runFormatting=this.mergeTextFormatting(t.runFormatting,e.rPr));}mergeParagraphFormatting(t,e){if(!e)return t;if(!t)return e?{...e}:void 0;let r={...t};for(let n of Object.keys(e)){let a=e[n];if(a!==void 0)if(n==="runProperties")r.runProperties=this.mergeTextFormatting(r.runProperties,e.runProperties);else if(n==="borders"||n==="numPr"||n==="frame"){let l=r[n],o=a;r[n]={...l||{},...o||{}};}else n==="tabs"&&Array.isArray(a)?r.tabs=[...a]:r[n]=a;}return r}mergeTextFormatting(t,e){return g(t,e)}};function p(i){return new f(i)}var h={firstRow:true,firstColumn:true,lastRow:false,lastColumn:false,noHBand:false,noVBand:true};function c(i,t){if(i.toLowerCase()==="tablenormal")return true;let e=t?.trim().toLowerCase();return e==="table normal"||e==="normal table"}function S(i,t){if(!t)return;if(i&&t.hasStyle(i))return i;let e=t.getDefaultTableStyle();if(e?.styleId)return c(e.styleId,e.name)?void 0:e.styleId}export{g as a,f as b,p as c,h as d,S as e};
@@ -0,0 +1 @@
1
+ import {d as d$1,a,c}from'./chunk-FZIA7OFY.mjs';var s={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""};function d(e){if(!e||e==="none")return "";let r=s[e];return r?`#${r}`:""}function S(e,r){return e?e.auto?"transparent":d$1(e,r):""}function v(e,r){if(!e)return false;if(e.auto)return true;let n=d$1(e,r).replace(/^#/,"").toLowerCase(),o=a(n);return (o.r+o.g+o.b)/3<20}function k(e,r){if(!e)return false;let n=d$1(e,r).replace(/^#/,"").toLowerCase(),o=a(n);return (o.r+o.g+o.b)/3>235}function V(e){if(!e)return;let r=e.trim();if(r.toLowerCase()==="auto")return {auto:true};let t=c(r);if(t)return {themeColor:t};let n=r.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(n)?{rgb:n}:/^[0-9A-F]{3}$/i.test(n)?{rgb:n.split("").map(u=>u+u).join("")}:{rgb:n.padStart(6,"0").slice(0,6)}}function y(e,r,t){let n={themeColor:e};return r!==void 0&&r>0&&r<1&&(n.themeTint=Math.round(r*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(n.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),n}function B(e){return {rgb:e.replace(/^#/,"").toUpperCase()}}function f(e){return e.startsWith("#")?e:`#${e}`}function H(e){return d(e)||f(e)}function w(e,r,t){if(!e&&!r)return true;if(!e||!r)return false;let n=d$1(e,t).toUpperCase(),o=d$1(r,t).toUpperCase();return n===o}export{d as a,S as b,v as c,k as d,V as e,y as f,B as g,f as h,H as i,w as j};
@@ -0,0 +1 @@
1
+ import {a as a$2,C as C$1,v}from'./chunk-DXKG3HQ5.mjs';import {a as a$3}from'./chunk-FPZBTOD6.mjs';import {a}from'./chunk-H3JCIGWK.mjs';import {a as a$1}from'./chunk-SINEY6ZF.mjs';var x=new WeakMap;function D(t){return x.get(t)}var C=new WeakMap;function h(t){let e=C.get(t);if(e)return e;let a=typeof process>"u"?void 0:process.env.OPENOOXML_DOCX_PARSE_BACKEND??process.env.DOCX_PARSE_BACKEND;return a==="rust"?a:F}var F="rust";async function s(t,e={}){await a(),await a$1();let a$4=t instanceof ArrayBuffer?t:await a$2(t);h(e);let n=e.onProgress??(()=>{});try{n("Extracting DOCX...",0);let r=a$3(a$4,g(e));return k(e,n),await w(r,e.preloadFonts??!0,n),n("Assembling document...",95),n("Complete",100),r.document}catch(r){let o=r instanceof Error?r.message:String(r);if(o.startsWith("Failed to parse DOCX: "))throw r;let i=S(o),P=i.code==="Container"?o.replace(/^container error: /,""):o,c=new Error(`Failed to parse DOCX: ${P}`,{cause:r});throw Object.assign(c,i),c}}function g(t){let e=D(t)?.seed;return {parseHeadersFooters:t.parseHeadersFooters??true,parseNotes:t.parseNotes??true,detectVariables:t.detectVariables??true,...e?{determinismSeed:e}:{},includeCanonical:false}}function k(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 w(t,e,a){if(!e){a("Skipping font loading",95);return}a("Loading fonts...",80),await O(t.document.package.theme??null,t.document.package.styles,t.document.package.document),await C$1(t.document.package.fontTable,t.embeddedFonts,t.fontTableRelationshipsXml),a("Loaded fonts",95);}async function O(t,e,a){let n=new Set;t?.fontScheme?.majorFont?.latin&&n.add(t.fontScheme.majorFont.latin),t?.fontScheme?.minorFont?.latin&&n.add(t.fontScheme.minorFont.latin),e?.docDefaults?.rPr?.fontFamily?.ascii&&n.add(e.docDefaults.rPr.fontFamily.ascii);for(let r of e?.styles??[])r.rPr?.fontFamily?.ascii&&n.add(r.rPr.fontFamily.ascii),r.rPr?.fontFamily?.hAnsi&&n.add(r.rPr.fontFamily.hAnsi);for(let r of a.content)if(r.type==="paragraph")for(let o of r.content)o.type==="run"&&(o.formatting?.fontFamily?.ascii&&n.add(o.formatting.fontFamily.ascii),o.formatting?.fontFamily?.hAnsi&&n.add(o.formatting.fontFamily.hAnsi));if(n.size!==0)try{await v([...n]);}catch(r){console.warn("Failed to load some fonts:",r);}}function S(t){let e=/(?:unsafe XML|resource limit .* exceeded|malformed XML|invalid relationship) in ([^:]+)(?::| at)/.exec(t)?.[1],a=/ 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}:{},...a?{offset:Number(a)}:{}}}async function A(t){return s(t,{preloadFonts:false,parseHeadersFooters:false,parseNotes:false,detectVariables:true})}async function _(t,e){return s(t,{onProgress:e,preloadFonts:true,parseHeadersFooters:true,parseNotes:true,detectVariables:true})}async function V(t){return (await A(t)).templateVariables??[]}async function j(t){let e=await s(t,{preloadFonts:false}),a=e.package,n=new Set([...a.media?.values()??[]].map(r=>r.path));return {hasDocument:true,hasStyles:a.styles!==void 0,hasTheme:a.theme!==void 0,hasNumbering:a.numbering!==void 0,headerCount:a.headers?.size??0,footerCount:a.footers?.size??0,mediaCount:n.size,variableCount:e.templateVariables?.length??0}}export{s as a,A as b,_ as c,V as d,j as e};
@@ -0,0 +1 @@
1
+ import {d,e,f as f$1}from'./chunk-SINEY6ZF.mjs';var l={seed:"0".repeat(64),now:"2000-01-01T00:00:00.000Z"};function n(e$1,t){let i=JSON.stringify({...t,determinism:l}),s=e$1==="S10"?d(i):e$1==="S11"?e(i):f$1(i),r=JSON.parse(s);if(!r||typeof r!="object")throw new TypeError(`${e$1} Rust serializer returned a non-object response`);let o=r;if(o.wireVersion!==1||o.family!==t.family||typeof o.xml!="string")throw new TypeError(`invalid ${e$1} Rust serializer response for ${String(t.family)}`);return o.xml}function m(e){switch(e.type){case "paragraph":return f(e);case "table":return p(e);case "blockSdt":return n("S11",{family:"blockSdt",sdt:e})}}function g(e){return m(e)}function z(e){return n("S12",{family:"document",body:e.package.document})}function x(e){let t=n("S12",{family:"document",body:e}),i="<w:body>",s="</w:body>",r=t.indexOf(i),o=t.lastIndexOf(s);if(r<0||o<r)throw new Error("Rust document serializer omitted w:body");return t.slice(r+i.length,o)}function w(e){return n("S10",{family:"section",properties:e})}function f(e){return n("S11",{family:"paragraph",paragraph:e})}function h(e){return n("S11",{family:"run",run:e})}function p(e){return n("S11",{family:"table",table:e})}function D(e){return n("S12",{family:"headerFooter",story:e})}function b(e){return n("S12",{family:"comments",comments:e})}function T(e){return n("S12",{family:"footnotes",notes:e})}function k(e){return n("S12",{family:"endnotes",notes:e})}export{g as a,z as b,x as c,w as d,f as e,h as f,p as g,D as h,b as i,T as j,k};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-T4EZMUXM.mjs';var I=class{__destroy_into_raw(){let _=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),_}free(){let _=this.__destroy_into_raw();e.__wbg_editsession_free(_,0);}accept_change(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_accept_change(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}add_comment(_,r,o,n){let t,l;try{let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i,v=e.editsession_add_comment(this.__wbg_ptr,w,f,g,p,m,y,h,x);var c=v[0],s=v[1];if(v[3])throw c=0,s=0,b(v[2]);return t=c,l=s,u(c,s)}finally{e.__wbindgen_free(t,l,1);}}apply_delete(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=e.editsession_apply_delete(this.__wbg_ptr,o,n,r);if(t[3])throw b(t[2]);var l=S(t[0],t[1]).slice();return e.__wbindgen_free(t[0],t[1]*1,1),l}apply_delete_profiled(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=e.editsession_apply_delete_profiled(this.__wbg_ptr,o,n,r);if(t[3])throw b(t[2]);var l=S(t[0],t[1]).slice();return e.__wbindgen_free(t[0],t[1]*1,1),l}apply_input(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=e.editsession_apply_input(this.__wbg_ptr,o,n,r);if(t[3])throw b(t[2]);var l=S(t[0],t[1]).slice();return e.__wbindgen_free(t[0],t[1]*1,1),l}apply_input_profile_json(){let _,r;try{let o=e.editsession_apply_input_profile_json(this.__wbg_ptr);return _=o[0],r=o[1],u(o[0],o[1])}finally{e.__wbindgen_free(_,r,1);}}apply_input_profiled(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=e.editsession_apply_input_profiled(this.__wbg_ptr,o,n,r);if(t[3])throw b(t[2]);var l=S(t[0],t[1]).slice();return e.__wbindgen_free(t[0],t[1]*1,1),l}apply_local_update(_){let r=D(_,e.__wbindgen_malloc),o=i,n=e.editsession_apply_local_update(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}apply_paragraph_style(_,r,o,n,t,l,c,s){let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i;var v=j(c)?0:a(c,e.__wbindgen_malloc,e.__wbindgen_realloc),E=i,W=j(s)?0:a(s,e.__wbindgen_malloc,e.__wbindgen_realloc),k=i;let A=e.editsession_apply_paragraph_style(this.__wbg_ptr,w,f,g,p,o,m,y,t,h,x,v,E,W,k);if(A[1])throw b(A[0])}apply_raw_ops(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=e.editsession_apply_raw_ops(this.__wbg_ptr,o,n,t,l);if(c[1])throw b(c[0])}apply_update(_){let r=D(_,e.__wbindgen_malloc),o=i,n=e.editsession_apply_update(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}build_display_list_frame(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=e.editsession_build_display_list_frame(this.__wbg_ptr,o,n,r);if(t[3])throw b(t[2]);var l=S(t[0],t[1]).slice();return e.__wbindgen_free(t[0],t[1]*1,1),l}build_display_list_json(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_build_display_list_json(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}can_redo(){return e.editsession_can_redo(this.__wbg_ptr)!==0}can_undo(){return e.editsession_can_undo(this.__wbg_ptr)!==0}cell_selection(){let _,r;try{let t=e.editsession_cell_selection(this.__wbg_ptr);var o=t[0],n=t[1];if(t[3])throw o=0,n=0,b(t[2]);return _=o,r=n,u(o,n)}finally{e.__wbindgen_free(_,r,1);}}clear_content_control_value(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_clear_content_control_value(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}clear_formatting(_,r,o,n,t){let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i,f=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,p=e.editsession_clear_formatting(this.__wbg_ptr,l,c,s,w,o,f,g,t);if(p[1])throw b(p[0])}clear_measure_fonts(){e.editsession_clear_measure_fonts(this.__wbg_ptr);}clear_update_observer(){e.editsession_clear_update_observer(this.__wbg_ptr);}client_id(){return e.editsession_client_id(this.__wbg_ptr)}create_story(_,r,o,n){let t,l;try{let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i,v=e.editsession_create_story(this.__wbg_ptr,w,f,g,p,m,y,h,x);var c=v[0],s=v[1];if(v[3])throw c=0,s=0,b(v[2]);return t=c,l=s,u(c,s)}finally{e.__wbindgen_free(t,l,1);}}delete_column(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_delete_column(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}delete_range(_,r,o,n,t,l,c){let s,w;try{let x=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),v=i,E=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),W=i,k=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),A=i;var f=j(l)?0:a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,p=j(c)?0:a(c,e.__wbindgen_malloc,e.__wbindgen_realloc),m=i;let T=e.editsession_delete_range(this.__wbg_ptr,x,v,E,W,o,k,A,t,f,g,p,m);var y=T[0],h=T[1];if(T[3])throw y=0,h=0,b(T[2]);return s=y,w=h,u(y,h)}finally{e.__wbindgen_free(s,w,1);}}delete_row(_,r,o){let n,t;try{let p=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),m=i;var l=j(r)?0:a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=j(o)?0:a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i;let y=e.editsession_delete_row(this.__wbg_ptr,p,m,l,c,s,w);var f=y[0],g=y[1];if(y[3])throw f=0,g=0,b(y[2]);return n=f,t=g,u(f,g)}finally{e.__wbindgen_free(n,t,1);}}delete_story(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_delete_story(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}delete_table(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_delete_table(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}display_hit_test_regions_json(_,r,o){let n,t;try{let s=e.editsession_display_hit_test_regions_json(this.__wbg_ptr,_,r,o);var l=s[0],c=s[1];if(s[3])throw l=0,c=0,b(s[2]);return n=l,t=c,u(l,c)}finally{e.__wbindgen_free(n,t,1);}}display_range_rects_json(_,r){let o,n;try{let c=e.editsession_display_range_rects_json(this.__wbg_ptr,_,r);var t=c[0],l=c[1];if(c[3])throw t=0,l=0,b(c[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}display_range_rects_region_json(_,r,o,n){let t,l;try{let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=e.editsession_display_range_rects_region_json(this.__wbg_ptr,w,f,g,p,o,n);var c=m[0],s=m[1];if(m[3])throw c=0,s=0,b(m[2]);return t=c,l=s,u(c,s)}finally{e.__wbindgen_free(t,l,1);}}encode_state(){let _=e.editsession_encode_state(this.__wbg_ptr);var r=S(_[0],_[1]).slice();return e.__wbindgen_free(_[0],_[1]*1,1),r}format_range(_,r,o,n,t,l){let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=e.editsession_format_range(this.__wbg_ptr,c,s,w,f,o,g,p,t,m,y);if(h[1])throw b(h[0])}insert_column(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=e.editsession_insert_column(this.__wbg_ptr,c,s,r);var t=w[0],l=w[1];if(w[3])throw t=0,l=0,b(w[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}insert_image(_,r,o,n,t,l){let c,s;try{let h=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i,v=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),E=i,W=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),k=i;var w=j(t)?0:a(t,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=j(l)?0:a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i;let A=e.editsession_insert_image(this.__wbg_ptr,h,x,v,E,o,W,k,w,f,g,p);var m=A[0],y=A[1];if(A[3])throw m=0,y=0,b(A[2]);return c=m,s=y,u(m,y)}finally{e.__wbindgen_free(c,s,1);}}insert_page_break(_,r,o){let n=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),t=i,l=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_insert_page_break(this.__wbg_ptr,n,t,l,c,o);if(s[1])throw b(s[0])}insert_row(_,r,o,n){let t,l;try{let m=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i;var c=j(o)?0:a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=j(n)?0:a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i;let h=e.editsession_insert_row(this.__wbg_ptr,m,y,r,c,s,w,f);var g=h[0],p=h[1];if(h[3])throw g=0,p=0,b(h[2]);return t=g,l=p,u(g,p)}finally{e.__wbindgen_free(t,l,1);}}insert_section_break(_,r,o,n){let t=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_insert_section_break(this.__wbg_ptr,t,l,c,s,o,w,f);if(g[1])throw b(g[0])}insert_table(_,r,o,n,t,l,c){let s,w;try{let x=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),v=i,E=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),W=i;var f=j(l)?0:a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,p=j(c)?0:a(c,e.__wbindgen_malloc,e.__wbindgen_realloc),m=i;let k=e.editsession_insert_table(this.__wbg_ptr,x,v,E,W,o,n,t,f,g,p,m);var y=k[0],h=k[1];if(k[3])throw y=0,h=0,b(k[2]);return s=y,w=h,u(y,h)}finally{e.__wbindgen_free(s,w,1);}}insert_text(_,r,o,n,t,l){let c,s;try{let h=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i,v=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),E=i,W=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),k=i;var w=j(t)?0:a(t,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=j(l)?0:a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i;let A=e.editsession_insert_text(this.__wbg_ptr,h,x,v,E,o,W,k,w,f,g,p);var m=A[0],y=A[1];if(A[3])throw m=0,y=0,b(A[2]);return c=m,s=y,u(m,y)}finally{e.__wbindgen_free(c,s,1);}}insert_watermark(_,r,o,n){let t=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_insert_watermark(this.__wbg_ptr,t,l,c,s,o,w,f);if(g[1])throw b(g[0])}layout_document_json(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_layout_document_json(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}list_revisions(){let _,r;try{let t=e.editsession_list_revisions(this.__wbg_ptr);var o=t[0],n=t[1];if(t[3])throw o=0,n=0,b(t[2]);return _=o,r=n,u(o,n)}finally{e.__wbindgen_free(_,r,1);}}load(_){let r=D(_,e.__wbindgen_malloc),o=i,n=e.editsession_load(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}load_json(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_load_json(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}locate_paragraph(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_locate_paragraph(this.__wbg_ptr,c,s,w,f);var t=g[0],l=g[1];if(g[3])throw t=0,l=0,b(g[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}measure_paragraph_json(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_measure_paragraph_json(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}merge_cells(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_merge_cells(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}merge_paragraphs(_,r,o,n){let t,l;try{let m=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i;var c=j(o)?0:a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=j(n)?0:a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i;let v=e.editsession_merge_paragraphs(this.__wbg_ptr,m,y,h,x,c,s,w,f);var g=v[0],p=v[1];if(v[3])throw g=0,p=0,b(v[2]);return t=g,l=p,u(g,p)}finally{e.__wbindgen_free(t,l,1);}}constructor(_){let r=e.editsession_new(_);if(r[2])throw b(r[1]);return this.__wbg_ptr=r[0],z.register(this,this.__wbg_ptr,this),this}outline_glyph_json(_,r){let o,n;try{let c=e.editsession_outline_glyph_json(this.__wbg_ptr,_,r);var t=c[0],l=c[1];if(c[3])throw t=0,l=0,b(c[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}paragraph_spans(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_paragraph_spans(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}paragraphs(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_paragraphs(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}redo(){return e.editsession_redo(this.__wbg_ptr)!==0}redo_depth(){return e.editsession_redo_depth(this.__wbg_ptr)>>>0}register_measure_font(_){let r=D(_,e.__wbindgen_malloc),o=i,n=e.editsession_register_measure_font(this.__wbg_ptr,r,o);if(n[2])throw b(n[1]);return n[0]>>>0}reject_change(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_reject_change(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}replace_range(_,r,o,n,t,l,c,s){let w,f;try{let v=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),E=i,W=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),k=i,A=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),T=i,J=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),Y=i;var g=j(c)?0:a(c,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=j(s)?0:a(s,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i;let U=e.editsession_replace_range(this.__wbg_ptr,v,E,W,k,o,A,T,t,J,Y,g,p,m,y);var h=U[0],x=U[1];if(U[3])throw h=0,x=0,b(U[2]);return w=h,f=x,u(h,x)}finally{e.__wbindgen_free(w,f,1);}}resolve_comment(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_resolve_comment(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}selection(){let _,r;try{let t=e.editsession_selection(this.__wbg_ptr);var o=t[0],n=t[1];if(t[3])throw o=0,n=0,b(t[2]);return _=o,r=n,u(o,n)}finally{e.__wbindgen_free(_,r,1);}}selection_context(_,r,o,n,t){let l,c;try{let f=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,p=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),m=i,y=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),h=i,x=e.editsession_selection_context(this.__wbg_ptr,f,g,p,m,o,y,h,t);var s=x[0],w=x[1];if(x[3])throw s=0,w=0,b(x[2]);return l=s,c=w,u(s,w)}finally{e.__wbindgen_free(l,c,1);}}set_cell_borders(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_set_cell_borders(this.__wbg_ptr,c,s,w,f);var t=g[0],l=g[1];if(g[3])throw t=0,l=0,b(g[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}set_cell_selection(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_set_cell_selection(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}set_cell_shading(_,r){let o,n;try{let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i;var t=j(r)?0:a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i;let g=e.editsession_set_cell_shading(this.__wbg_ptr,w,f,t,l);var c=g[0],s=g[1];if(g[3])throw c=0,s=0,b(g[2]);return o=c,n=s,u(c,s)}finally{e.__wbindgen_free(o,n,1);}}set_cell_text_format(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_set_cell_text_format(this.__wbg_ptr,c,s,w,f);var t=g[0],l=g[1];if(g[3])throw t=0,l=0,b(g[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}set_column_width(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=e.editsession_set_column_width(this.__wbg_ptr,c,s,r);var t=w[0],l=w[1];if(w[3])throw t=0,l=0,b(w[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}set_content_control_value(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=e.editsession_set_content_control_value(this.__wbg_ptr,o,n,t,l);if(c[1])throw b(c[0])}set_content_control_value_at(_,r,o,n){let t=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_set_content_control_value_at(this.__wbg_ptr,t,l,c,s,o,w,f);if(g[1])throw b(g[0])}set_hyperlink(_,r,o,n,t,l){let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=e.editsession_set_hyperlink(this.__wbg_ptr,c,s,w,f,o,g,p,t,m,y);if(h[1])throw b(h[0])}set_image_geometry(_,r){let o=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),n=i,t=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i,c=e.editsession_set_image_geometry(this.__wbg_ptr,o,n,t,l);if(c[1])throw b(c[0])}set_paragraph_attr(_,r,o){let n=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),t=i,l=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=a(o,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i,f=e.editsession_set_paragraph_attr(this.__wbg_ptr,n,t,l,c,s,w);if(f[1])throw b(f[0])}set_paragraph_attrs(_,r,o,n,t,l,c,s){let w=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),x=i;var v=j(c)?0:a(c,e.__wbindgen_malloc,e.__wbindgen_realloc),E=i,W=j(s)?0:a(s,e.__wbindgen_malloc,e.__wbindgen_realloc),k=i;let A=e.editsession_set_paragraph_attrs(this.__wbg_ptr,w,f,g,p,o,m,y,t,h,x,v,E,W,k);if(A[1])throw b(A[0])}set_selection(_,r,o,n,t){let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i,f=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,p=e.editsession_set_selection(this.__wbg_ptr,l,c,s,w,o,f,g,t);if(p[1])throw b(p[0])}set_table_width(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=e.editsession_set_table_width(this.__wbg_ptr,c,s,r);var t=w[0],l=w[1];if(w[3])throw t=0,l=0,b(w[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}set_update_observer(_){let r=e.editsession_set_update_observer(this.__wbg_ptr,_);if(r[1])throw b(r[0])}split_cell(_,r,o){let n,t;try{let s=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i,f=e.editsession_split_cell(this.__wbg_ptr,s,w,j(r)?Number.MAX_SAFE_INTEGER:r>>>0,j(o)?Number.MAX_SAFE_INTEGER:o>>>0);var l=f[0],c=f[1];if(f[3])throw l=0,c=0,b(f[2]);return n=l,t=c,u(l,c)}finally{e.__wbindgen_free(n,t,1);}}split_paragraph(_,r,o,n,t){let l,c;try{let y=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),h=i,x=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),v=i;var s=j(n)?0:a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),w=i,f=j(t)?0:a(t,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i;let E=e.editsession_split_paragraph(this.__wbg_ptr,y,h,x,v,o,s,w,f,g);var p=E[0],m=E[1];if(E[3])throw p=0,m=0,b(E[2]);return l=p,c=m,u(p,m)}finally{e.__wbindgen_free(l,c,1);}}story_checksum(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_story_checksum(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}story_ids(){let _=e.editsession_story_ids(this.__wbg_ptr);var r=Z(_[0],_[1]).slice();return e.__wbindgen_free(_[0],_[1]*4,4),r}story_len(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_story_len(this.__wbg_ptr,r,o);if(n[2])throw b(n[1]);return n[0]>>>0}story_segments(_){let r,o;try{let l=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),c=i,s=e.editsession_story_segments(this.__wbg_ptr,l,c);var n=s[0],t=s[1];if(s[3])throw n=0,t=0,b(s[2]);return r=n,o=t,u(n,t)}finally{e.__wbindgen_free(r,o,1);}}toggle_mark(_,r,o,n,t,l){let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=a(n,e.__wbindgen_malloc,e.__wbindgen_realloc),p=i,m=a(l,e.__wbindgen_malloc,e.__wbindgen_realloc),y=i,h=e.editsession_toggle_mark(this.__wbg_ptr,c,s,w,f,o,g,p,t,m,y);if(h[1])throw b(h[0])}track_table_undo(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_track_table_undo(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}track_undo(_){let r=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,n=e.editsession_track_undo(this.__wbg_ptr,r,o);if(n[1])throw b(n[0])}undo(){return e.editsession_undo(this.__wbg_ptr)!==0}undo_depth(){return e.editsession_undo_depth(this.__wbg_ptr)>>>0}yrs_blocks_for_story(_,r){let o,n;try{let c=a(_,e.__wbindgen_malloc,e.__wbindgen_realloc),s=i,w=a(r,e.__wbindgen_malloc,e.__wbindgen_realloc),f=i,g=e.editsession_yrs_blocks_for_story(this.__wbg_ptr,c,s,w,f);var t=g[0],l=g[1];if(g[3])throw t=0,l=0,b(g[2]);return o=t,n=l,u(t,l)}finally{e.__wbindgen_free(o,n,1);}}};Symbol.dispose&&(I.prototype[Symbol.dispose]=I.prototype.free);function C(){return {__proto__:null,"./docx_edit_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(_,r){throw new Error(u(_,r))},__wbg_call_a6e5c5dce5018821:function(){return B(function(_,r,o){return _.call(r,o)},arguments)},__wbg_getRandomValues_3f44b700395062e5:function(){return B(function(_,r){globalThis.crypto.getRandomValues(S(_,r));},arguments)},__wbg_new_from_slice_77cdfb7977362f3c:function(_,r){return new Uint8Array(S(_,r))},__wbg_now_374e0d8e8b91c892:function(){return performance.now()},__wbindgen_cast_0000000000000001:function(_,r){return u(_,r)},__wbindgen_init_externref_table:function(){let _=e.__wbindgen_externrefs,r=_.grow(4);_.set(0,void 0),_.set(r+0,void 0),_.set(r+1,null),_.set(r+2,true),_.set(r+3,false);}}}}var z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(d=>e.__wbg_editsession_free(d,1));function Q(d){let _=e.__externref_table_alloc();return e.__wbindgen_externrefs.set(_,d),_}function Z(d,_){d=d>>>0;let r=$(),o=[];for(let n=d;n<d+4*_;n+=4)o.push(e.__wbindgen_externrefs.get(r.getUint32(n,true)));return e.__externref_drop_slice(d,_),o}function S(d,_){return d=d>>>0,M().subarray(d/1,d/1+_)}var R=null;function $(){return (R===null||R.buffer.detached===true||R.buffer.detached===void 0&&R.buffer!==e.memory.buffer)&&(R=new DataView(e.memory.buffer)),R}function u(d,_){return _e(d>>>0,_)}var F=null;function M(){return (F===null||F.byteLength===0)&&(F=new Uint8Array(e.memory.buffer)),F}function B(d,_){try{return d.apply(this,_)}catch(r){let o=Q(r);e.__wbindgen_exn_store(o);}}function j(d){return d==null}function D(d,_){let r=_(d.length*1,1)>>>0;return M().set(d,r/1),i=d.length,r}function a(d,_,r){if(r===void 0){let c=O.encode(d),s=_(c.length,1)>>>0;return M().subarray(s,s+c.length).set(c),i=c.length,s}let o=d.length,n=_(o,1)>>>0,t=M(),l=0;for(;l<o;l++){let c=d.charCodeAt(l);if(c>127)break;t[n+l]=c;}if(l!==o){l!==0&&(d=d.slice(l)),n=r(n,o,o=l+d.length*3,1)>>>0;let c=M().subarray(n+l,n+o),s=O.encodeInto(d,c);l+=s.written,n=r(n,o,l,1)>>>0;}return i=l,n}function b(d){let _=e.__wbindgen_externrefs.get(d);return e.__externref_table_dealloc(d),_}var L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});L.decode();var ee=2146435072,N=0;function _e(d,_){return N+=_,N>=ee&&(L=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),L.decode(),N=_),L.decode(M().subarray(d,d+_))}var O=new TextEncoder;"encodeInto"in O||(O.encodeInto=function(d,_){let r=O.encode(d);return _.set(r),{read:d.length,written:r.length}});var i=0,e;function q(d,_){return e=d.exports,R=null,F=null,e.__wbindgen_start(),e}async function re(d,_){if(typeof Response=="function"&&d instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(d,_)}catch(n){if(d.ok&&r(d.type)&&d.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",n);else throw n}let o=await d.arrayBuffer();return await WebAssembly.instantiate(o,_)}else {let o=await WebAssembly.instantiate(d,_);return o instanceof WebAssembly.Instance?{instance:o,module:d}:o}function r(o){switch(o){case "basic":case "cors":case "default":return true}return false}}function P(d){if(e!==void 0)return e;d!==void 0&&(Object.getPrototypeOf(d)===Object.prototype?{module:d}=d:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let _=C();d instanceof WebAssembly.Module||(d=new WebAssembly.Module(d));let r=new WebAssembly.Instance(d,_);return q(r)}async function X(d){if(e!==void 0)return e;if(d!==void 0&&(Object.getPrototypeOf(d)===Object.prototype?{module_or_path:d}=d:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),d===void 0)throw new Error("docx-edit wasm requires an explicit module or URL");let _=C();(typeof d=="string"||typeof Request=="function"&&d instanceof Request||typeof URL=="function"&&d instanceof URL)&&(d=fetch(d));let{instance:r,module:o}=await re(await d,_);return q(r)}var G=a$1({label:"docx-edit",preloadName:"preloadEditWasm",assetUrl:()=>new URL("./generated/edit/docx_edit_bg.wasm",import.meta.url),initAsync:X,initSync:P});function ce(d){return G.preload(d)}function ae(d){return G.ensure(),new I(d)}export{ce as a,ae as b};
@@ -0,0 +1 @@
1
+ import p from'pizzip';import l from'docxtemplater';function T(e,r,t={}){return b(e,r,t).buffer}function b(e,r,t={}){let{nullGetter:n="keep",linebreaks:s=true,delimiters:o}=t,a=[],i=[],g=[];try{let d=new p(e),m=new l(d,{paragraphLoop:!0,linebreaks:s,nullGetter:c=>{let f=c.value||"";if(n==="error")throw new Error(`Undefined variable: ${f}`);return n==="empty"?(g.push(f),""):(g.push(f),`{${f}}`)},delimiters:o?{start:o.start||"{",end:o.end||"}"}:void 0});return Object.keys(r).forEach(c=>{r[c]!==void 0&&r[c]!==null&&i.push(c);}),m.setData(r),m.render(),{buffer:m.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:i,unreplacedVariables:g,warnings:a}}catch(d){throw u(d)}}function x(e,r,t={}){let n=T(e,r,t);return new Blob([n],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function D(e,r,t="document",n={}){let s=x(e,r,n);E(s,`${t}.docx`);}function L(e){try{let r=new p(e),n=new l(r,{paragraphLoop:!0,linebreaks:!0}).getFullText();return y(n)}catch(r){throw u(r)}}function O(e){let r=[],t=[];try{let n=new p(e),o=new l(n,{paragraphLoop:!0,linebreaks:!0}).getFullText();t=y(o);let a=h(o);for(let i of a)r.push({message:`Unclosed tag: ${i}`,variable:i,type:"parse"});return {valid:r.length===0,errors:r,tags:t}}catch(n){return r.push(u(n)),{valid:false,errors:r,tags:t}}}function P(e,r){return e.filter(t=>!(t in r)||r[t]===void 0||r[t]===null)}function U(e,r){try{let t=new p(e),n=new l(t,{paragraphLoop:!0,linebreaks:!0,nullGetter:s=>`[${s.value||""}]`});return n.setData(r),n.render(),n.getFullText()}catch(t){throw u(t)}}function y(e){let r=[],t=/\{([^{}]+)\}/g,n;for(;(n=t.exec(e))!==null;){let s=n[1].trim();s&&!r.includes(s)&&r.push(s);}return r.sort()}function h(e){let r=[],t=0,n="";for(let s of e)s==="{"?(t++,n=""):s==="}"?(t--,t<0&&(t=0)):t>0&&(n+=s);return t>0&&n.trim()&&r.push(n.trim()),r}function w(e){return "properties"in e&&typeof e.properties=="object"}function u(e){if(e instanceof Error){if(w(e)&&e.properties?.errors){let r=e.properties.errors[0];return {message:r?.message||"Template processing error",variable:r?.properties?.tag,type:"render",originalError:e}}if(e.message.includes("undefined")){let r=e.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:e.message,variable:r?r[1]:void 0,type:"undefined",originalError:e}}return e.message.includes("parse")||e.message.includes("unclosed")||e.message.includes("syntax")?{message:e.message,type:"parse",originalError:e}:{message:e.message,type:"unknown",originalError:e}}return {message:String(e),type:"unknown"}}function E(e,r){let t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t);}function z(e,r,t={}){let{linebreaks:n=true,delimiters:s}=t;try{let o=new p(e),a=new l(o,{paragraphLoop:!0,linebreaks:n,delimiters:s?{start:s.start||"{",end:s.end||"}"}:void 0});return a.setData(r),a.render(),a.getZip().generate({type:"arraybuffer",compression:"DEFLATE"})}catch(o){throw u(o)}}function F(e={}){return (r,t)=>T(r,t,e)}var V=T;export{T as a,b,x as c,D as d,L as e,O as f,P as g,U as h,z as i,F as j,V as k};
@@ -0,0 +1 @@
1
+ var t=["square","tight","through"],e=["behind","inFront"],o=[...t,...e];function s(n){return !!n&&o.includes(n)}function a(n){return n==="behind"||n==="inFront"}function d(n){return !!n&&t.includes(n)}export{s as a,a as b,d as c};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-KVKLLTDP.mjs';async function l(n,r,t){if(!i(n,r,t))return null;try{return (await b(n,r,{updateModifiedDate:!0},{changedParaIds:t.changedParaIds})).buffer}catch{return null}}function i(n,r,t){return t.structuralChange||t.hasUntrackedChanges||!r?false:!a(n.package.document.content)}function a(n){let r=t=>t.content.some(e=>e.type==="drawing"&&e.image?.src?.startsWith("data:")&&!e.image.rId);for(let t of n)if(t.type==="paragraph")for(let e of t.content){if(e.type==="run"&&r(e)||e.type==="hyperlink"&&e.href&&!e.rId&&!e.anchor)return true;if(e.type==="insertion"||e.type==="deletion"||e.type==="moveFrom"||e.type==="moveTo"){for(let o of e.content)if(o.type==="run"&&r(o))return true}}else if(t.type==="table"){for(let e of t.rows)for(let o of e.cells)if(a(o.content))return true}else if(t.type==="blockSdt"&&a(t.content))return true;return false}export{l as a};
@@ -0,0 +1,2 @@
1
+ import {o,j as j$1,q,k}from'./chunk-HJGAQIU7.mjs';import {a}from'./chunk-FPZBTOD6.mjs';import {c}from'./chunk-H3JCIGWK.mjs';function U(t,n=null,e=null,o=null,r=null,l=null,u,T=null){if(!t)return x([],new Map);let s=F("footnote",t),p=[...s.footnoteSeparators??[],...s.footnotes??[]];return x(p,new Map(p.map(m=>[m.id,m])))}function D(t,n=null,e=null,o=null,r=null,l=null,u,T=null){if(!t)return h([],new Map);let s=F("endnote",t),p=[...s.endnoteSeparators??[],...s.endnotes??[]];return h(p,new Map(p.map(m=>[m.id,m])))}function F(t,n){let e=`${t}s`,o=new TextEncoder,r={"[Content_Types].xml":o.encode(`<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/${e}.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${e}+xml"/></Types>`),"_rels/.rels":o.encode('<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>'),"word/document.xml":o.encode('<?xml version="1.0" encoding="UTF-8"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p/></w:body></w:document>'),"word/_rels/document.xml.rels":o.encode(`<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/${e}" Target="${e}.xml"/></Relationships>`),[`word/${e}.xml`]:o.encode(n)},l=c(r),u=new ArrayBuffer(l.byteLength);return new Uint8Array(u).set(l),a(u,{parseHeadersFooters:false,parseNotes:true,detectVariables:false}).document.package}function E(t){return t?{decimal:"decimal",upperRoman:"upperRoman",lowerRoman:"lowerRoman",upperLetter:"upperLetter",lowerLetter:"lowerLetter",ordinal:"ordinal",cardinalText:"cardinalText",ordinalText:"ordinalText",bullet:"bullet",chicago:"chicago",none:"none"}[t]:void 0}function S(t){return t==="pageBottom"||t==="beneathText"||t==="sectEnd"||t==="docEnd"?t:void 0}function P(t){return t==="sectEnd"||t==="docEnd"?t:void 0}function w(t){return t==="continuous"||t==="eachSect"||t==="eachPage"?t:void 0}function $(t){let n={};if(!t)return n;n.position=S(o(j$1(t,"w","pos"),"w","val"));let e=j$1(t,"w","numFmt");n.numFmt=E(o(e,"w","val"));let o$1=o(e,"w","format");o$1&&(n.customNumberFormat=o$1.slice(0,255)),n.numStart=q(j$1(t,"w","numStart"),"w","val"),n.numRestart=w(o(j$1(t,"w","numRestart"),"w","val"));let r=M(t,"footnote");return r.length&&(n.separators=r),y(n)}function L(t){let n={};if(!t)return n;n.position=P(o(j$1(t,"w","pos"),"w","val"));let e=j$1(t,"w","numFmt");n.numFmt=E(o(e,"w","val"));let o$1=o(e,"w","format");o$1&&(n.customNumberFormat=o$1.slice(0,255)),n.numStart=q(j$1(t,"w","numStart"),"w","val"),n.numRestart=w(o(j$1(t,"w","numRestart"),"w","val"));let r=M(t,"endnote");return r.length&&(n.separators=r),y(n)}function M(t,n){return k(t,"w",n).slice(0,32).map(e=>q(e,"w","id")).filter(e=>e!==void 0).map(e=>({noteId:e,kind:e===-1?"separator":e===0?"continuationSeparator":"continuationNotice"}))}function y(t){for(let n of Object.keys(t))t[n]===void 0&&delete t[n];return t}function j(t){return b(t)}function O(t){return b(t)}function b(t){return t.content.filter(n=>n.type==="paragraph").map(n=>n.content.filter(e=>e.type==="run").flatMap(e=>e.content).filter(e=>e.type==="text").map(e=>e.text).join("")).join(`
2
+ `)}function N(t){return t.noteType!=="normal"}function R(t){return t.noteType!=="normal"}function x(t,n){return {byId:n,footnotes:t,getFootnote:e=>n.get(e),hasFootnote:e=>n.has(e),getNormalFootnotes:()=>t.filter(e=>!N(e)),getSeparator:()=>t.find(e=>e.noteType==="separator"),getContinuationSeparator:()=>t.find(e=>e.noteType==="continuationSeparator")}}function h(t,n){return {byId:n,endnotes:t,getEndnote:e=>n.get(e),hasEndnote:e=>n.has(e),getNormalEndnotes:()=>t.filter(e=>!R(e)),getSeparator:()=>t.find(e=>e.noteType==="separator"),getContinuationSeparator:()=>t.find(e=>e.noteType==="continuationSeparator")}}export{U as a,D as b,$ as c,L as d,j as e,O as f,N as g,R as h};
@@ -0,0 +1 @@
1
+ import {a,b as b$1}from'./chunk-7PCO5I2O.mjs';import {e}from'./chunk-OMR3TWCD.mjs';import {b}from'./chunk-3UBMCDME.mjs';import {d,e as e$1,g,c,f}from'./chunk-TTRUPDAB.mjs';var $=12,ce=24,O=6;function V(e,a){if(e.size!==a.size)return false;for(let[n,i]of e)if(a.get(n)!==i)return false;return true}function de(e,a){for(let[n,i]of a)if((e.get(n)??0)<i)return false;return true}function pe(e,a){let n=new Map(e);for(let[i,o]of a)n.set(i,Math.max(n.get(i)??0,o));return n}var N=8;function Q(e){return e.noteKind==="endnote"?-Math.abs(e.footnoteId)-1:e.footnoteId}function me(e){let a=[],n=(i,o)=>{for(let r of i)if(r.kind==="paragraph")for(let t of r.runs)t.kind==="text"&&t.footnoteRefId!=null?a.push({footnoteId:t.footnoteRefId,pmPos:t.pmStart??0,...o??{}}):t.kind==="text"&&t.endnoteRefId!=null&&a.push({footnoteId:t.endnoteRefId,pmPos:t.pmStart??0,noteKind:"endnote",...o??{}});else r.kind==="table"?r.rows.forEach((t,s)=>{for(let l of t.cells)n(l.blocks,o??{tableBlockId:r.id,rowIndex:s});}):r.kind==="textBox"&&n(r.content,o);};return n(e),a}function Z(e,a){let n=new Map;if(a.length===0)return n;let i=(o,r)=>{let t=n.get(o)??[];t.includes(r)||t.push(r),n.set(o,t);};for(let o of a){let r=false;for(let t of e){for(let s of t.fragments){let l=false;if(o.tableBlockId!=null&&o.rowIndex!=null)l=s.kind==="table"&&s.blockId===o.tableBlockId&&o.rowIndex>=s.rowStart&&o.rowIndex<s.rowEnd;else {let u=s.pmStart??-1,f=s.pmEnd??-1;l=u>=0&&f>=0&&o.pmPos>=u&&o.pmPos<f;}if(l){i(t.number,Q(o)),r=true;break}}if(r)break}}return n}function j(e,a,n=String(a)){if(e.length===0)return [{kind:"paragraph",id:`fn-empty-${a}`,runs:[{kind:"text",text:`${n} `,fontSize:N,superscript:true}]}];let i=e.map(r=>{if(r.kind!=="paragraph")return r;let t=r;return {...t,runs:t.runs.map(s=>(s.kind==="text"||s.kind==="tab")&&s.fontSize==null?{...s,fontSize:N}:s)}}),o=i[0];if(o.kind==="paragraph"){let r=o,t=r.runs.find(l=>l.kind==="text"),s={kind:"text",text:`${n} `,fontSize:N,superscript:true,...t?.fontFamily?{fontFamily:t.fontFamily}:{}};i[0]={...r,runs:[s,...r.runs]};}return i}function J(e,a,n,i,o){let r=e.type==="footnote"?`fn:${e.id}`:null,t=(r?i.yrsStoryBlocks?.(r):null)??[],s=o?.displayLabel??String(a),l=j(t,a,s),u=i.measureBlocks(l,n),f=u.reduce((c,d)=>d.kind==="paragraph"||d.kind==="table"?c+d.totalHeight:d.kind==="image"||d.kind==="shape"||d.kind==="chart"||d.kind==="textBox"?c+d.height:c,0);return {id:e.id,displayNumber:a,blocks:l,measures:u,height:f,noteKind:o?.noteKind??(e.type==="endnote"?"endnote":"footnote"),displayLabel:s,anchor:o?.anchor}}function ge(e,a,n,i,o,r){let t=new Map,s=new Map(e.map(c=>[c.id,c])),l=new Map(a.map(c=>[c.id,c])),u=new Set,f=1;for(let c of n){let d=Q(c);if(u.has(d))continue;u.add(d);let m=c.noteKind??"footnote",g=m==="endnote"?l.get(c.footnoteId):s.get(c.footnoteId);if(!g||g.noteType&&g.noteType!=="normal")continue;let x=typeof i=="function"?i(c):i,p=r?.get(d)??{displayNumber:f,displayLabel:String(f)};t.set(d,J(g,p.displayNumber,x,o,{noteKind:m,displayLabel:p.displayLabel,anchor:p.anchor})),f++;}return t}function he(e,a,n,i){return ge(e,[],a.map(o=>({...o,pmPos:0})),o=>typeof n=="function"?n(o):n,i)}function ee(e,a){let n=Math.max(1,Math.floor(a));if(n<=1||e.length<=1)return [e];let o=e.reduce((s,l)=>s+l.height,0)/n,r=[[]],t=0;for(let s of e)r.length<n&&t>0&&t+s.height/2>o&&(r.push([]),t=0),r[r.length-1].push(s),t+=s.height;return r}function A(e,a,n=1){let i=new Map;for(let[o,r]of e){let t=r.map(u=>a.get(u)).filter(u=>u!==void 0&&u.height>0);if(t.length===0)continue;let s=typeof n=="number"?n:n.get(o)??1,l=0;for(let u of ["footnote","endnote"]){let f=t.filter(m=>(m.noteKind??"footnote")===u);if(!f.length)continue;let d=ee(f,u==="footnote"?s:1).reduce((m,g)=>Math.max(m,g.reduce((x,p)=>x+p.height,0)),0);d>0&&(l+=d+$);}l>0&&i.set(o,l);}return i}function be(e){let{blocks:a$1,measures:n,layoutOpts:i,paginate:o,footnoteRefs:r,footnoteContentMap:t,initialLayout:s}=e,l=a(a$1,n),u=e.footnoteColumns??1,f=p=>typeof u=="number"?Math.max(1,u):Math.max(1,u.get(p)??1),c=e.mapReferencesToPages??Z,d=c(s.pages,r),m=A(d,t,u);if(m.size===0)return {layout:s,pageFootnoteMap:d,converged:true};let g=s,x=false;for(let p=0;p<O;p++){g=o(l,{...i,footnoteReservedHeights:m});let M=c(g.pages,r),b=A(M,t,u);if(d=M,V(m,b)){m=b,x=true;break}m=b;}if(!x){let p=m,M=false;for(let b=0;b<O;b++){g=o(l,{...i,footnoteReservedHeights:p}),d=c(g.pages,r);let F=A(d,t,u);if(de(p,F)){M=true;break}p=pe(p,F);}M||(g=o(l,{...i,footnoteReservedHeights:p}),d=c(g.pages,r)),console.warn(`[docx-editor] footnote layout did not stabilize within ${O} passes; settling with conservative page reservations. If footnotes appear misplaced, please file a bug with the document.`);}for(let[p,M]of d){let b=g.pages.find(F=>F.number===p);if(b){b.footnoteIds=M;let F=f(p);F>1&&(b.footnoteColumns=F);}}return {layout:g,pageFootnoteMap:d,converged:x}}function ye(e$1,a,n){let i=new Map;if(!n?.package||!n.package.footnotes?.length&&!n.package.endnotes?.length)return i;let o=new Map;for(let t of n.package.footnotes??[])t.noteType&&t.noteType!=="normal"||o.set(t.id,t);let r=new Map;for(let t of n.package.endnotes??[])t.noteType&&t.noteType!=="normal"||r.set(t.id,t);for(let[t,s]of e$1){let l=[];for(let u of s){let f=a.get(u);if(!f)continue;let c=f.noteKind==="endnote"?r.get(f.id):o.get(f.id);if(!c)continue;let d=f?.displayNumber??0;l.push({displayNumber:f.displayLabel??String(d),text:e(c),content:f});}l.length>0&&i.set(t,l);}return i}function Fe(e){if(e.kind!=="paragraph")return false;let a=e.attrs;return a?!!(a.borders?.top||a.borders?.bottom||a.spacingExplicit?.before||a.spacingExplicit?.after):false}function te(e){return oe(e)}function oe(e){let a=new Set;for(let n=1;n<e.length;n++){let i=e[n-1],o=e[n];i.kind==="table"&&o.kind==="paragraph"&&(o.runs.length>0||Fe(o)||a.add(n));}return e.map((n,i)=>{if(n.kind==="table")return ke(n);if(n.kind!=="paragraph")return n;let o=a.has(i),r=n.attrs?.spacingExplicit,t=n.attrs?.spacing?.before!=null,s=n.attrs?.spacing?.after!=null,l=t&&!r?.before,u=s&&!r?.after,f=l||u;if(!f&&!o)return n;let c=n.attrs;return f&&c?.spacing&&(c={...c,spacing:{...c.spacing,before:r?.before?c.spacing.before:void 0,after:r?.after?c.spacing.after:void 0}}),o&&(c={...c??{},suppressEmptyParagraphHeight:true}),{...n,attrs:c}})}function ke(e){let a=false,n=e.rows.map(i=>{let o=false,r=i.cells.map(t=>{let s=oe(t.blocks);return s.some((u,f)=>u!==t.blocks[f])?(o=true,{...t,blocks:s}):t});return o?(a=true,{...i,cells:r}):i});return a?{...e,rows:n}:e}function xe(e){return e?.align??e?.alignment}function ne(e,a,n,i){let o=i.section==="header"?i.margins.header??48:i.pageSize.h-(i.margins.footer??48)-n,r=e.position?.vertical;if(!r)return a;let t=xe(r),s=r.posOffset!==void 0?b(r.posOffset):void 0;if(r.relativeTo==="page"){if(s!==void 0)return s-o;if(t==="top")return -o;if(t==="bottom")return i.pageSize.h-e.height-o;if(t==="center")return (i.pageSize.h-e.height)/2-o}if(r.relativeTo==="margin"){let l=i.margins.top,u=i.pageSize.h-i.margins.top-i.margins.bottom;if(s!==void 0)return l+s-o;if(t==="top")return l-o;if(t==="bottom")return l+u-e.height-o;if(t==="center")return l+(u-e.height)/2-o}return s!==void 0?a+s:a}function re(e){switch(e.kind){case "paragraph":case "table":return true;case "image":return !e.anchor?.isAnchored;case "shape":case "chart":return true;case "textBox":return e.displayMode===void 0||e.displayMode==="inline";default:return false}}function Me(e){return e?e.kind==="paragraph"||e.kind==="table"?e.totalHeight:e.kind==="image"||e.kind==="shape"||e.kind==="chart"||e.kind==="textBox"?e.height:0:0}function ae(e,a,n,i){let o=0,r=0,t=0;for(let s=0;s<e.length;s++){let l=e[s],u=a[s];if(!(!l||!u)){if(l.kind==="paragraph"&&u.kind==="paragraph"){let f=t,c=f+u.totalHeight;o=Math.min(o,f),r=Math.max(r,c);for(let d of l.runs){if(d.kind!=="image"||!d.position)continue;let m=ne(d,f,n,i);o=Math.min(o,m),r=Math.max(r,m+d.height);}t=c;}else if(l.kind==="table"&&u.kind==="table"){let f=t+u.totalHeight;o=Math.min(o,t),r=Math.max(r,f),t=f;}else if(l.kind==="image"&&u.kind==="image"){let f=t+u.height;o=Math.min(o,t),r=Math.max(r,f),t=f;}else if(l.kind==="shape"&&u.kind==="shape"){let f=t+u.height;o=Math.min(o,t),r=Math.max(r,f),t=f;}else if(l.kind==="chart"&&u.kind==="chart"){let f=t+u.height;o=Math.min(o,t),r=Math.max(r,f),t=f;}else if(l.kind==="textBox"&&u.kind==="textBox"){let f=t+u.height;o=Math.min(o,t),r=Math.max(r,f),l.displayMode!=="float"&&(t=f);}}}return {visualTop:o,visualBottom:r}}function Te(e,a,n,i,o){if(!e||!e.content||e.content.length===0)return;let r=o?i.yrsStoryBlocks?.(o):null;if(!r||r.length===0)return;let t=te(r),s=i.measureBlocks(t,a),l=0,u=0;for(let d=0;d<t.length;d++){let m=Me(s[d]);l+=m,re(t[d])&&(u+=m);}let{visualTop:f,visualBottom:c}=ae(t,s,l,n);return {blocks:t,measures:s,height:l,flowHeight:u,visualTop:f,visualBottom:c}}function Be(e,a,n,i,o){let r=e.hfCaretRects(a,n,i);return o===void 0?r:r.filter(t=>t.pageIndex===o)}function He(e,a,n,i,o,r){let t=e.hfRangeRects(a,n,Math.min(i,o),Math.max(i,o));return r===void 0?t:t.filter(s=>s.pageIndex===r)}function ie(e){return e?e.flowHeight??e.height:0}function Le(e){let{pageSize:a,margins:n,finalMargins:i,bodyBlocks:o,headers:r,footers:t,warn:s}=e,l=n.header??48,u=n.footer??48,f=n.top-l,c=n.bottom-u,d=Math.max(0,...(r??[]).map(ie)),m=Math.max(0,...(t??[]).map(ie)),g=d>f,x=m>c;if(!g&&!x)return {margins:n,finalMargins:i};let p=Math.max(0,a.h-24),M=false,b=I=>{let h={...I};return g&&(h.top=Math.max(I.top,l+d)),x&&(h.bottom=Math.max(I.bottom,u+m)),h.top+h.bottom>p&&(M=true,h.bottom=Math.max(0,Math.min(h.bottom,p-h.top)),h.top+h.bottom>p&&(h.top=Math.max(0,p-h.bottom))),h},F=b(n),fe=b(i);if(o)for(let I of o){if(I.kind!=="sectionBreak")continue;let h=I;h.margins&&(h.margins=b(h.margins));}return M&&s&&s(`[layout] header/footer content exceeds page height; clamping margins to preserve a content area. pageHeight=${Math.round(a.h)} headerBand=${Math.round(d)} footerBand=${Math.round(m)} top=${Math.round(F.top)} bottom=${Math.round(F.bottom)}`),{margins:F,finalMargins:fe}}var T,B,H,L,P,_,U,z=class{constructor(){d(this,_);d(this,T,0);d(this,B,0);d(this,H,false);d(this,L,false);d(this,P,new Set);}setStateSeq(a){e$1(this,T,a);}incrementStateSeq(){return ++g(this,T)._}getStateSeq(){return c(this,T)}getRenderSeq(){return c(this,B)}onLayoutStart(){e$1(this,H,true);}onLayoutComplete(a){e$1(this,B,a),e$1(this,H,false),c(this,L)&&this.isSafeToRender()&&(e$1(this,L,false),f(this,_,U).call(this));}isSafeToRender(){return !c(this,H)&&c(this,B)>=c(this,T)}requestRender(){this.isSafeToRender()?f(this,_,U).call(this):e$1(this,L,true);}onRender(a){return c(this,P).add(a),()=>c(this,P).delete(a)}reset(){e$1(this,T,0),e$1(this,B,0),e$1(this,H,false),e$1(this,L,false);}getDebugInfo(){return {stateSeq:c(this,T),renderSeq:c(this,B),layoutUpdating:c(this,H),hasPendingRender:c(this,L),isSafe:this.isSafeToRender()}}};T=new WeakMap,B=new WeakMap,H=new WeakMap,L=new WeakMap,P=new WeakMap,_=new WeakSet,U=function(){for(let a of c(this,P))try{a();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var se=816,ue=1056,w=96,K=48;function S(e){return Math.round(e/1440*96)}function C(e,a){return e!=null?S(e):a}function Se(e){return {w:e?.pageWidth?S(e.pageWidth):se,h:e?.pageHeight?S(e.pageHeight):ue}}function Re(e){let a=e?.gutter!=null?S(e.gutter):void 0;return {top:C(e?.marginTop,w),right:C(e?.marginRight,w),bottom:C(e?.marginBottom,w),left:C(e?.marginLeft,w)+(a??0),header:C(e?.headerDistance,K),footer:C(e?.footerDistance,K),gutter:a}}function Ie(e,a){let n={header:null,footer:null,firstHeader:null,firstFooter:null};if(!e?.package)return n;let i=e.package.headers,o=e.package.footers,r=null,t=null,s=null,l=null;if(i&&a?.headerReferences){let u=a.headerReferences.find(c=>c.type==="default");u?.rId&&(r=i.get(u.rId)??null);let f=a.headerReferences.find(c=>c.type==="first");f?.rId&&(s=i.get(f.rId)??null);}if(o&&a?.footerReferences){let u=a.footerReferences.find(c=>c.type==="default");u?.rId&&(t=o.get(u.rId)??null);let f=a.footerReferences.find(c=>c.type==="first");f?.rId&&(l=o.get(f.rId)??null);}return a?.titlePg||(!r&&s&&(r=s),!t&&l&&(t=l)),{header:r,footer:t,firstHeader:s,firstFooter:l}}function Pe(e){let a=e?.columnCount??e?.columns?.length??1;if(a<=1)return;let n=S(e?.columnSpace??720);return {count:a,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator,columns:e?.columns?.slice(0,a).map(i=>({width:i.width!=null?S(i.width):void 0,space:i.space!=null?S(i.space):void 0}))}}function le(e){let a=e.pageSize.w-e.margins.left-e.margins.right,n=e.columns;if(!n||n.count<=1)return a;if(n.equalWidth===false&&n.columns?.length){let i=n.columns[0]?.width;if(i!=null&&Number.isFinite(i)&&i>0)return i}return Math.floor((a-(n.count-1)*n.gap)/n.count)}function Ce(e,a,n){let{configs:i,breakIndices:o}=b$1(e,a,n),r=0,t=[];for(let s=0;s<e.length;s++)t.push(le(i[r]??a)),r<o.length&&s===o[r]&&r++;return t}export{w as A,K as B,S as C,Se as D,Re as E,Ie as F,Pe as G,le as H,Ce as I,$ as a,ce as b,O as c,V as d,Q as e,me as f,Z as g,j as h,J as i,ge as j,he as k,ee as l,A as m,be as n,ye as o,te as p,ne as q,re as r,ae as s,Te as t,Be as u,He as v,Le as w,z as x,se as y,ue as z};
@@ -0,0 +1 @@
1
+ function a(e){return {start:e,end:e,collapsed:true}}function n(e,t){return {start:e,end:t,collapsed:e.paragraphIndex===t.paragraphIndex&&e.offset===t.offset}}function r(e,t){return !(e.paragraphIndex<t.start.paragraphIndex||e.paragraphIndex===t.start.paragraphIndex&&e.offset<t.start.offset||e.paragraphIndex>t.end.paragraphIndex||e.paragraphIndex===t.end.paragraphIndex&&e.offset>t.end.offset)}function o(e,t){return e.paragraphIndex<t.paragraphIndex?-1:e.paragraphIndex>t.paragraphIndex?1:e.offset<t.offset?-1:e.offset>t.offset?1:0}function i(e){return {askAI:"Ask AI",rewrite:"Rewrite",expand:"Expand",summarize:"Summarize",translate:"Translate",explain:"Explain",fixGrammar:"Fix Grammar",makeFormal:"Make Formal",makeCasual:"Make Casual",custom:"Custom Prompt"}[e]}function s(e){return {askAI:"Ask AI a question about this text",rewrite:"Rewrite this text in a different way",expand:"Expand this text with more details",summarize:"Summarize this text to be shorter",translate:"Translate this text to another language",explain:"Explain what this text means",fixGrammar:"Fix grammar and spelling errors",makeFormal:"Make the tone more formal",makeCasual:"Make the tone more casual",custom:"Enter a custom prompt"}[e]}var m=["askAI","rewrite","expand","summarize","translate","explain"];function p(e){return {...e,id:g()}}function g(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}var l={createCollapsedRange:a,createRange:n,isPositionInRange:r,comparePositions:o,getActionLabel:i,getActionDescription:s,createCommand:p,DEFAULT_AI_ACTIONS:m};export{a,n as b,r as c,o as d,i as e,s as f,m as g,p as h,l as i};
@@ -0,0 +1 @@
1
+ import {y,D,E as E$1,x as x$1,z as z$1,a,G as G$1,b as b$1,c}from'./chunk-YBIM6UJV.mjs';function g(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function E(t){let e=[];switch(t.alias&&e.push(`<w:alias w:val="${g(t.alias)}"/>`),t.tag&&e.push(`<w:tag w:val="${g(t.tag)}"/>`),t.id!=null&&e.push(`<w:id w:val="${t.id}"/>`),t.lock&&t.lock!=="unlocked"&&e.push(`<w:lock w:val="${t.lock}"/>`),t.placeholder&&e.push(`<w:placeholder><w:docPart w:val="${g(t.placeholder)}"/></w:placeholder>`),t.showingPlaceholder&&e.push("<w:showingPlcHdr/>"),t.sdtType){case "plainText":e.push("<w:text/>");break;case "date":e.push(t.dateFormat?`<w:date><w:dateFormat w:val="${g(t.dateFormat)}"/></w:date>`:"<w:date/>");break;case "dropDownList":case "comboBox":{let o=(t.listItems??[]).map(n=>`<w:listItem w:displayText="${g(n.displayText)}" w:value="${g(n.value)}"/>`).join("");e.push(`<w:${t.sdtType} w:lastValue="">${o}</w:${t.sdtType}>`);break}case "checkbox":e.push(`<w14:checkbox><w14:checked w14:val="${t.checked?"1":"0"}"/><w14:checkedState w14:val="2612" w14:font="MS Gothic"/><w14:uncheckedState w14:val="2610" w14:font="MS Gothic"/></w14:checkbox>`);break;case "picture":e.push("<w:picture/>");break}return `<w:sdtPr>${e.join("")}</w:sdtPr>`}var w=class extends Error{constructor(e){super(e),this.name="ContentControlCreateError";}};function H(t){return t.type==="run"?b$1(t).length:t.type==="hyperlink"?c(t).length:0}function O(t,e,o){let n=t.text.slice(e,o),r={type:"text",text:n};return (t.preserveSpace||/^\s|\s$/.test(n))&&(r.preserveSpace=true),r}function A(t,e){let o=[],n=[],r=0;for(let c of t.content)if(c.type==="text")if(r>=e)n.push(c);else if(r+c.text.length<=e)o.push(c),r+=c.text.length;else {let i=e-r;o.push(O(c,0,i)),n.push(O(c,i)),r+=c.text.length;}else (r>=e?n:o).push(c);return [{...t,content:o},{...t,content:n}]}function L(t,e,o,n){let r=[],c=[],i=[],a=0;for(let s of t){let d=H(s),l=a,u=a+d;if(a=u,u<=e){r.push(s);continue}if(l>=o){i.push(s);continue}if(l>=e&&u<=o){if(s.type==="inlineSdt")throw new w("The text span overlaps an existing inline content control; cannot wrap it.");if(!G$1(s))throw new w(`The text span contains a '${s.type}' that cannot be placed inside an inline content control.`);c.push(s);continue}if(s.type!=="run")throw new w(s.type==="inlineSdt"?"The text span overlaps an existing inline content control; cannot wrap it.":`A content-control boundary falls inside a '${s.type}'; wrap on a run boundary instead.`);let p=Math.max(e,l)-l,f=Math.min(o,u)-l,[h,y]=A(s,p),[m,I]=A(y,f-p);h.content.length>0&&r.push(h),c.push(m),I.content.length>0&&i.push(I);}return [...r,{...n,content:c},...i]}function J(t){return x$1(t,{},{includeHeadersFooters:true}).reduce((e,o)=>o.id!=null&&o.id>e?o.id:e,0)}var X=new Set(["richText","plainText","date","dropDownList","comboBox","checkbox","picture"]);function _(t,e){let o=t.sdtType??"richText";if(!X.has(o))throw new w(`Cannot create a '${o}' content control; supported types: ${[...X].join(", ")}.`);let n={sdtType:o,id:e};return t.tag!=null&&(n.tag=t.tag),t.alias!=null&&(n.alias=t.alias),t.lock!=null&&(n.lock=t.lock),t.listItems!=null&&(n.listItems=t.listItems),t.dateFormat!=null&&(n.dateFormat=t.dateFormat),t.checked!=null&&(n.checked=t.checked),t.showingPlaceholder&&(n.showingPlaceholder=true),n.rawPropertiesXml=E(n),n}function P(t,e,o,n){let r=false,c=[];for(let i of t){if(n.done){c.push(i);continue}if(i.type==="paragraph")e(i)?(c.push(o(i)),n.done=true,r=true):c.push(i);else if(i.type==="blockSdt"){let a=P(i.content,e,o,n);a!==i.content?(c.push({...i,content:a}),r=true):c.push(i);}else if(i.type==="table"){let a=false,s=i.rows.map(d=>{if(n.done)return d;let l=false,u=d.cells.map(p=>{if(n.done)return p;let f=p.content,h=P(f,e,o,n);return h!==f?(l=true,{...p,content:h}):p});return l?(a=true,{...d,cells:u}):d});a?(c.push({...i,rows:s}),r=true):c.push(i);}else c.push(i);}return r?c:t}function nt(t,e,o={}){if(!e.text)throw new w("`text` must be a non-empty string.");let n=e.occurrence??1;if(n<1)throw new w("`occurrence` must be >= 1.");if(o.id!=null&&y(t,{id:o.id},{includeHeadersFooters:true}))throw new w(`A content control with id ${o.id} already exists; omit \`id\` to auto-assign a unique one.`);let r=o.id??J(t)+1,c=_(o,r),i=u=>{let p=a(u),f=-1,h=0;for(let m=p.indexOf(e.text);m!==-1;m=p.indexOf(e.text,m+e.text.length))if(++h===n){f=m;break}if(f===-1)throw new w(h===0?`Text ${JSON.stringify(e.text)} was not found in the paragraph.`:`Occurrence ${n} of ${JSON.stringify(e.text)} not found (only ${h} present).`);let y={type:"inlineSdt",properties:c,content:[]};return {...u,content:L(u.content,f,f+e.text.length,y)}},a$1={done:false},s=P(t.package.document.content,u=>u.paraId===e.paraId,i,a$1);if(!a$1.done)throw new w(`No paragraph found with paraId ${JSON.stringify(e.paraId)}.`);let d=E$1(t,s),l=y(d,{id:r});if(!l)throw new w("Created control could not be located after insertion.");return {doc:d,control:l}}function q(t){return /<w15:repeatingSection[\s/>]/.test(t??"")}function z(t){return /<w15:repeatingSectionItem[\s/>]/.test(t??"")}function G(t){return q(t.rawPropertiesXml)}function Y(t){return z(t.rawPropertiesXml)}var b=class extends Error{constructor(e){super(e),this.name="RepeatingSectionError";}};function x(t,e){if(Array.isArray(t)){for(let n of t)x(n,e);return}if(!t||typeof t!="object")return;let o=t;(o.type==="blockSdt"||o.type==="inlineSdt")&&o.properties&&e(o);for(let[n,r]of Object.entries(o))n==="properties"||n==="rawPropertiesXml"||n==="rawEndPropertiesXml"||(Array.isArray(r)||r&&typeof r=="object")&&x(r,e);}function V(t){let e=0,o=n=>{typeof n.properties?.id=="number"&&(e=Math.max(e,n.properties.id));};x(t.package.document.content,o);for(let n of t.package.headers?.values()??[])x(n.content,o);for(let n of t.package.footers?.values()??[])x(n.content,o);return e}function Z(t,e){return t&&(/<w:id\b/.test(t)?t.replace(/(<w:id\b[^>]*\bw:val=")[^"]*(")/,`$1${e}$2`):/<w:sdtPr\b[^>]*\/>/.test(t)?t.replace(/<w:sdtPr\b([^>]*)\/>/,`<w:sdtPr$1><w:id w:val="${e}"/></w:sdtPr>`):t.replace(/(<w:sdtPr\b[^>]*[^/]>)/,`$1<w:id w:val="${e}"/>`))}function K(t,e){let o=structuredClone(t);return x(o,n=>{let r=e(),c=n.properties;n.properties={...c,id:r,rawPropertiesXml:Z(c.rawPropertiesXml,r)};}),o}function M(t,e){let o,n=r=>{for(let c of r){if(o)return;if(c.type==="blockSdt"){let i=c.properties;(e.tag===void 0||i.tag===e.tag)&&(e.alias===void 0||i.alias===e.alias)&&(e.id===void 0||i.id===e.id)?o=c:n(c.content);}else if(c.type==="table")for(let i of c.rows)for(let a of i.cells)n(a.content);}};if(n(t.package.document.content),!o)throw new z$1(e);if(!G(o.properties))throw new b(`Control ${e.tag??e.alias??e.id} is not a repeating section.`);return o}function j(t){let e=[];return t.content.forEach((o,n)=>{o.type==="blockSdt"&&Y(o.properties)&&e.push(n);}),e}function it(t,e,o={}){let n=M(t,e),r=j(n);if(r.length===0)throw new b("Repeating section has no item to clone.");let c=o.afterIndex??r.length-1,i=r[Math.max(0,Math.min(c,r.length-1))],a=n.content[i],s=V(t),d=K(a,()=>++s),l={done:false},u=f=>{let h=[...f.content];return h.splice(i+1,0,d),[{...f,content:h}]},p=D(t.package.document.content,e,u,l);return E$1(t,p)}function at(t,e,o){let n=M(t,e),r=j(n);if(r.length<=1)throw new b("Cannot remove the last item of a repeating section.");if(o<0||o>=r.length)throw new b(`Item index ${o} out of range (0..${r.length-1}).`);let c=r[o],i={done:false},a=d=>{let l=d.content.filter((u,p)=>p!==c);return [{...d,content:l}]},s=D(t.package.document.content,e,a,i);return E$1(t,s)}export{w as a,nt as b,G as c,Y as d,b as e,it as f,at as g};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-T4EZMUXM.mjs';function U(e,n){let t,r;try{let i=W(e,o.__wbindgen_malloc),_=a,f=w(n,o.__wbindgen_malloc,o.__wbindgen_realloc),h=a,d=o.parse_docx_s9(i,_,f,h);var s=d[0],c=d[1];if(d[3])throw s=0,c=0,p(d[2]);return t=s,r=c,u(s,c)}finally{o.__wbindgen_free(t,r,1);}}function O(e,n){let t,r;try{let i=W(e,o.__wbindgen_malloc),_=a,f=w(n,o.__wbindgen_malloc,o.__wbindgen_realloc),h=a,d=o.parse_relationships_xml(i,_,f,h);var s=d[0],c=d[1];if(d[3])throw s=0,c=0,p(d[2]);return t=s,r=c,u(s,c)}finally{o.__wbindgen_free(t,r,1);}}function T(e){let n,t;try{let c=w(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a,_=o.serialize_docx_s10(c,i);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,p(_[2]);return n=r,t=s,u(r,s)}finally{o.__wbindgen_free(n,t,1);}}function D(e){let n,t;try{let c=w(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a,_=o.serialize_docx_s11(c,i);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,p(_[2]);return n=r,t=s,u(r,s)}finally{o.__wbindgen_free(n,t,1);}}function M(e){let n,t;try{let c=w(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a,_=o.serialize_docx_s12(c,i);var r=_[0],s=_[1];if(_[3])throw r=0,s=0,p(_[2]);return n=r,t=s,u(r,s)}finally{o.__wbindgen_free(n,t,1);}}function E(e,n){let t=w(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a,s=W(n,o.__wbindgen_malloc),c=a,i=o.write_docx_s13_wasm(t,r,s,c);if(i[3])throw p(i[2]);var _=A(i[0],i[1]).slice();return o.__wbindgen_free(i[0],i[1]*1,1),_}function I(){return {__proto__:null,"./docx_parse_bg.js":{__proto__:null,__wbg___wbindgen_string_get_b0ca35b86a603356:function(n,t){let r=t,s=typeof r=="string"?r:void 0;var c=C(s)?0:w(s,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;S().setInt32(n+4,i,true),S().setInt32(n+0,c,true);},__wbg___wbindgen_throw_344f42d3211c4765:function(n,t){throw new Error(u(n,t))},__wbg_get_78f252d074a84d0b:function(){return R(function(n,t){return Reflect.get(n,t)},arguments)},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(n,t){return n[t>>>0]},__wbg_instanceof_Object_33f20e6f12439f3e:function(n){let t;try{t=n instanceof Object;}catch{t=false;}return t},__wbg_keys_58421f8f96795607:function(n){return Object.keys(n)},__wbg_length_1f0964f4a5e2c6d8:function(n){return n.length},__wbg_length_370319915dc99107:function(n){return n.length},__wbg_new_cd45aabdf6073e84:function(n){return new Uint8Array(n)},__wbg_new_da52cf8fe3429cb2:function(){return new Object},__wbg_new_from_slice_77cdfb7977362f3c:function(n,t){return new Uint8Array(A(n,t))},__wbg_prototypesetcall_4770620bbe4688a0:function(n,t,r){Uint8Array.prototype.set.call(A(n,t),r);},__wbg_set_8535240470bf2500:function(){return R(function(n,t,r){return Reflect.set(n,t,r)},arguments)},__wbindgen_cast_0000000000000001:function(n,t){return u(n,t)},__wbindgen_init_externref_table:function(){let n=o.__wbindgen_externrefs,t=n.grow(4);n.set(0,void 0),n.set(t+0,void 0),n.set(t+1,null),n.set(t+2,true),n.set(t+3,false);}}}}function P(e){let n=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(n,e),n}function A(e,n){return e=e>>>0,g().subarray(e/1,e/1+n)}var l=null;function S(){return (l===null||l.buffer.detached===true||l.buffer.detached===void 0&&l.buffer!==o.memory.buffer)&&(l=new DataView(o.memory.buffer)),l}function u(e,n){return q(e>>>0,n)}var y=null;function g(){return (y===null||y.byteLength===0)&&(y=new Uint8Array(o.memory.buffer)),y}function R(e,n){try{return e.apply(this,n)}catch(t){let r=P(t);o.__wbindgen_exn_store(r);}}function C(e){return e==null}function W(e,n){let t=n(e.length*1,1)>>>0;return g().set(e,t/1),a=e.length,t}function w(e,n,t){if(t===void 0){let _=x.encode(e),f=n(_.length,1)>>>0;return g().subarray(f,f+_.length).set(_),a=_.length,f}let r=e.length,s=n(r,1)>>>0,c=g(),i=0;for(;i<r;i++){let _=e.charCodeAt(i);if(_>127)break;c[s+i]=_;}if(i!==r){i!==0&&(e=e.slice(i)),s=t(s,r,r=i+e.length*3,1)>>>0;let _=g().subarray(s+i,s+r),f=x.encodeInto(e,_);i+=f.written,s=t(s,r,i,1)>>>0;}return a=i,s}function p(e){let n=o.__wbindgen_externrefs.get(e);return o.__externref_table_dealloc(e),n}var m=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});m.decode();var V=2146435072,v=0;function q(e,n){return v+=n,v>=V&&(m=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),m.decode(),v=n),m.decode(g().subarray(e,e+n))}var x=new TextEncoder;"encodeInto"in x||(x.encodeInto=function(e,n){let t=x.encode(e);return n.set(t),{read:e.length,written:t.length}});var a=0,o;function j(e,n){return o=e.exports,l=null,y=null,o.__wbindgen_start(),o}async function Y(e,n){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,n)}catch(s){if(e.ok&&t(e.type)&&e.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",s);else throw s}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,n)}else {let r=await WebAssembly.instantiate(e,n);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function t(r){switch(r){case "basic":case "cors":case "default":return true}return false}}function k(e){if(o!==void 0)return o;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let n=I();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));let t=new WebAssembly.Instance(e,n);return j(t)}async function L(e){if(o!==void 0)return o;if(e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0)throw new Error("docx-parse wasm requires an explicit module or URL");let n=I();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:t,module:r}=await Y(await e,n);return j(t)}var b=a$1({label:"docx-parse",preloadName:"preloadParseWasm",assetUrl:()=>new URL("./generated/parse/docx_parse_bg.wasm",import.meta.url),initAsync:L,initSync:k});function Q(e){return b.preload(e)}function Z(e,n){return b.ensure(),U(e,n)}function $(e,n){return b.ensure(),O(e,n)}function ee(e){return b.ensure(),T(e)}function ne(e){return b.ensure(),D(e)}function te(e){return b.ensure(),M(e)}function re(e,n){return b.ensure(),E(e,n)}export{Q as a,Z as b,$ as c,ee as d,ne as e,te as f,re as g};
@@ -0,0 +1 @@
1
+ function s(e){let n=globalThis.process;if(typeof n?.getBuiltinModule=="function")try{return n.getBuiltinModule(e)}catch{return}}function u(e){if(e.protocol!=="file:")return;let n=s("node:fs"),t=s("node:url");if(!(!n||!t))try{return n.readFileSync(t.fileURLToPath(e))}catch{return}}function d(e){let n=false,t;return {preload(r){return n?Promise.resolve():t||(t=e.initAsync({module_or_path:r??e.assetUrl()}).then(()=>{n=true;},i=>{throw t=void 0,i instanceof Error?i:new Error(String(i))}),t)},ensure(){if(n)return;let r=u(e.assetUrl());if(r){e.initSync({module:r}),n=true;return}throw new Error(`${e.label} wasm is not initialized; await ${e.preloadName}() before first use (browser builds load the external wasm asset asynchronously)`)}}}export{d as a};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var g=a=>{throw TypeError(a)};var i=(a,b,c)=>b in a?f(a,b,{enumerable:true,configurable:true,writable:true,value:c}):a[b]=c;var l=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:true});};var m=(a,b,c)=>i(a,typeof b!="symbol"?b+"":b,c),e=(a,b,c)=>b.has(a)||g("Cannot "+c);var j=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),n=(a,b,c)=>b.has(a)?g("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),k=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c),o=(a,b,c)=>(e(a,b,"access private method"),c);var p=(a,b,c,d)=>({set _(h){k(a,b,h,c);},get _(){return j(a,b,d)}});export{l as a,m as b,j as c,n as d,k as e,o as f,p as g};
@@ -0,0 +1 @@
1
+ function d(a){let i=[];return a.descendants((n,l)=>{if(n.type.name==="paragraph"){let o=n.attrs.outlineLevel,r=n.attrs.styleId,e=o;if(e==null&&r){let t=r.match(/^[Hh]eading(\d)$/);t&&(e=parseInt(t[1],10)-1);}if(e!=null&&e>=0&&e<=8){let t="";n.forEach(s=>{s.isText&&(t+=s.text||"");}),t.trim()&&i.push({text:t.trim(),level:e,pmPos:l});}}}),i}export{d as a};
@@ -0,0 +1 @@
1
+ function b(e){return h(e).variables}function h(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let r=d(e.package.document);r.forEach(s=>{t.push({name:s,location:"body"});}),n.body=Array.from(new Set(r)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((r,s)=>{r.properties.headerReferences&&r.properties.headerReferences.forEach(R=>{});}),e.package?.footnotes){let r=u(e.package.footnotes);r.forEach(s=>{t.push({name:s,location:"footnote"});}),n.footnotes=Array.from(new Set(r)).sort();}if(e.package?.endnotes){let r=u(e.package.endnotes);r.forEach(s=>{t.push({name:s,location:"endnote"});}),n.endnotes=Array.from(new Set(r)).sort();}e.templateVariables&&e.templateVariables.forEach(r=>{t.some(s=>s.name===r)||t.push({name:r,location:"body"});});let o=new Set;return t.forEach(r=>o.add(r.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function d(e){let t=[];if(e.content&&t.push(...c(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...c(n.content));return t}function c(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(...a(n)):n.type==="table"&&t.push(...l(n));return t}function a(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...i(n)):n.type==="hyperlink"?t.push(...m(n)):n.type==="simpleField"?t.push(...x(n)):n.type==="complexField"&&t.push(...V(n));return t}function i(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...g(n.text));return t}function m(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...i(n));return t}function x(e){let t=[];if(e.instruction&&t.push(...g(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...i(n));return t}function V(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...i(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...i(n));return t}function l(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let o of n.cells)t.push(...y(o));return t}function y(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(...a(n)):n.type==="table"&&t.push(...l(n));return t}function u(e){let t=[];for(let n of e)if(n.content)for(let o of n.content)o.type==="paragraph"&&t.push(...a(o));return t}var f=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,p=/\{([^{}]+)\}/g;function g(e){if(!e)return [];let t=[],n=new RegExp(f),o;for(;(o=n.exec(e))!==null;)t.push(o[1]);return t}function v(e){return f.test(e)}function k(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function I(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function F(e){return `{${e}}`}function T(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function _(e,t){return e&&e.replace(p,(n,o)=>{let r=o.trim();return r in t?t[r]:n})}function B(e,t=""){return e&&e.replace(p,t)}function C(e){return b(e).length>0}export{b as a,h as b,d as c,a as d,g as e,v as f,k as g,I as h,F as i,T as j,_ as k,B as l,C as m};
@@ -0,0 +1 @@
1
+ function i(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function r(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function n(e={}){let t=r();e.pageWidth!==void 0&&(t.pageWidth=Math.round(e.pageWidth)),e.pageHeight!==void 0&&(t.pageHeight=Math.round(e.pageHeight)),e.orientation!==void 0&&(t.orientation=e.orientation),e.marginTop!==void 0&&(t.marginTop=Math.round(e.marginTop)),e.marginBottom!==void 0&&(t.marginBottom=Math.round(e.marginBottom)),e.marginLeft!==void 0&&(t.marginLeft=Math.round(e.marginLeft)),e.marginRight!==void 0&&(t.marginRight=Math.round(e.marginRight));let a={type:"text",text:e.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:e.initialText?[a]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:i()}},templateVariables:[],warnings:[]}}function d(e,t={}){return n({...t,initialText:e})}export{n as a,d as b};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-TTRUPDAB.mjs';var a=class{constructor(){b(this,"plugins",new Map);b(this,"commandHandlers",new Map);b(this,"eventListeners",new Set);b(this,"initialized",new Set);}register(e,r){let t=[];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 i of e.dependencies)if(!this.plugins.has(i))return {success:false,error:`Plugin '${e.id}' requires '${i}' which is not registered`}}if(e.commandHandlers)for(let[i,o]of Object.entries(e.commandHandlers)){if(this.commandHandlers.has(i)){let d=this.commandHandlers.get(i);t.push(`Command '${i}' from '${e.id}' overrides handler from '${d.pluginId}'`);}this.commandHandlers.set(i,{pluginId:e.id,handler:o});}if(this.plugins.set(e.id,e),e.initialize&&!this.initialized.has(e.id))try{let i=e.initialize();i instanceof Promise?i.then(()=>{this.initialized.add(e.id);}).catch(o=>{this.emit({type:"error",pluginId:e.id,error:o});}):this.initialized.add(e.id);}catch(i){this.emit({type:"error",pluginId:e.id,error:i});}return r?.debug&&console.log(`[PluginRegistry] Registered plugin: ${e.id}`),this.emit({type:"registered",plugin:e}),{success:true,plugin:e,warnings:t.length>0?t:void 0}}unregister(e){let r=this.plugins.get(e);if(!r)return false;for(let[t,i]of this.plugins)if(i.dependencies?.includes(e))return console.warn(`Cannot unregister '${e}': '${t}' depends on it`),false;for(let[t,{pluginId:i}]of this.commandHandlers)i===e&&this.commandHandlers.delete(t);if(r.destroy)try{let t=r.destroy();t instanceof Promise&&t.catch(i=>{this.emit({type:"error",pluginId:e,error:i});});}catch(t){this.emit({type:"error",pluginId:e,error:t});}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 r of this.plugins.values())r.mcpTools&&e.push(...r.mcpTools);return e}getMcpToolsForPlugin(e){return this.plugins.get(e)?.mcpTools||[]}getMcpTool(e){for(let r of this.plugins.values())if(r.mcpTools){let t=r.mcpTools.find(i=>i.name===e);if(t)return t}}addEventListener(e){this.eventListeners.add(e);}removeEventListener(e){this.eventListeners.delete(e);}emit(e){for(let r of this.eventListeners)try{r(e);}catch(t){console.error("[PluginRegistry] Event listener error:",t);}}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)}}},l=new a;function u(s,e){return s.map(r=>l.register(r,e))}function m(s){return e=>l.register(e,s)}export{a,l as b,u as c,m as d};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-BI3B33LI.mjs';import {b}from'./chunk-TTRUPDAB.mjs';var v="docx-editor-autosave",d=3e4,m=1440*60*1e3,S=2e3,c=1;function h(){try{let t="__docx_editor_test__";return localStorage.setItem(t,"test"),localStorage.removeItem(t),!0}catch{return false}}function l(t){return JSON.stringify({...t,originalBuffer:null})}function f(t){try{let s=JSON.parse(t);return !s||typeof s!="object"||!s.document||!s.savedAt?null:(s.version!==c&&console.warn("Auto-save data version mismatch, may need migration"),s)}catch{return null}}function g(t,s){let e=new Date(t).getTime();return Date.now()-e>s}var u=class extends a{constructor(e={}){super({status:"idle",lastSaveTime:null,hasRecoveryData:false,isEnabled:true});b(this,"storageKey");b(this,"interval");b(this,"maxAge");b(this,"saveOnChange");b(this,"debounceDelay");b(this,"onSaveCallback");b(this,"onErrorCallback");b(this,"onRecoveryAvailableCallback");b(this,"storageAvailable");b(this,"currentDocument",null);b(this,"lastSavedJson",null);b(this,"intervalTimer",null);b(this,"debounceTimer",null);b(this,"status","idle");b(this,"lastSaveTime",null);b(this,"_hasRecoveryData",false);b(this,"_isEnabled");this.storageKey=e.storageKey??v,this.interval=e.interval??d,this.maxAge=e.maxAge??m,this.saveOnChange=e.saveOnChange??true,this.debounceDelay=e.debounceDelay??S,this.onSaveCallback=e.onSave,this.onErrorCallback=e.onError,this.onRecoveryAvailableCallback=e.onRecoveryAvailable,this._isEnabled=true,this.storageAvailable=h(),this.checkRecoveryData();}onDocumentChanged(e){this.currentDocument=e,this._isEnabled&&this.saveOnChange&&e&&this.storageAvailable&&this.debounceSave();}async save(){if(!this.storageAvailable)return this.onErrorCallback?.(new Error("localStorage is not available")),false;let e=this.currentDocument;if(!e)return false;this.updateStatus("saving");try{let r=l(e);if(r===this.lastSavedJson)return this.updateStatus("saved"),!0;this.persistToStorage(r),this.lastSavedJson=r;let i=new Date;return this.lastSaveTime=i,this.updateStatus("saved"),this.onSaveCallback?.(i),!0}catch(r){return console.error("Auto-save failed:",r),this.updateStatus("error"),this.onErrorCallback?.(r),false}}clear(){if(this.storageAvailable)try{localStorage.removeItem(this.storageKey),this._hasRecoveryData=!1,this.lastSavedJson=null,this.emitSnapshot();}catch(e){console.error("Failed to clear auto-save:",e);}}getRecoveryData(){if(!this.storageAvailable)return null;try{let e=localStorage.getItem(this.storageKey);if(!e)return null;let r=f(e);return r?g(r.savedAt,this.maxAge)?(this.clear(),null):r:null}catch{return null}}acceptRecovery(){let e=this.getRecoveryData();return e?(this._hasRecoveryData=false,this.emitSnapshot(),e.document):null}dismissRecovery(){this.clear(),this._hasRecoveryData=false,this.emitSnapshot();}enable(){this._isEnabled=true,this.startInterval(),this.emitSnapshot();}disable(){this._isEnabled=false,this.stopTimers(),this.emitSnapshot();}startInterval(){this.stopTimers(),!(!this._isEnabled||!this.storageAvailable)&&(this.intervalTimer=setInterval(()=>{this.save();},this.interval));}destroy(){if(this.stopTimers(),this._isEnabled&&this.currentDocument&&this.storageAvailable)try{this.persistToStorage(l(this.currentDocument));}catch(e){console.error("Failed to save on destroy:",e);}}checkRecoveryData(){if(!this.storageAvailable)return;let e=this.getRecoveryData();e&&(this._hasRecoveryData=true,this.emitSnapshot(),this.onRecoveryAvailableCallback?.(e));}persistToStorage(e){let r={document:JSON.parse(e),savedAt:new Date().toISOString(),version:c};localStorage.setItem(this.storageKey,JSON.stringify(r));}debounceSave(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.save();},this.debounceDelay);}stopTimers(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null);}updateStatus(e){this.status=e,this.emitSnapshot();}emitSnapshot(){this.setSnapshot({status:this.status,lastSaveTime:this.lastSaveTime,hasRecoveryData:this._hasRecoveryData,isEnabled:this._isEnabled});}};function y(t){if(!t)return "Never";let e=new Date().getTime()-t.getTime(),r=Math.floor(e/1e3),i=Math.floor(r/60),o=Math.floor(i/60);return r<10?"Just now":r<60?`${r} seconds ago`:i<60?`${i} minute${i===1?"":"s"} ago`:o<24?`${o} hour${o===1?"":"s"} ago`:t.toLocaleDateString()}function A(t){return {idle:"Ready",saving:"Saving...",saved:"Saved",error:"Save failed"}[t]}function T(t=v){try{let s=localStorage.getItem(t);return s?new Blob([s]).size:0}catch{return 0}}function E(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function _(){return h()}export{u as a,y as b,A as c,T as d,E as e,_ as f};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-BIQWVK5P.mjs';function E(t){let o=t?.package.headers;if(o){for(let n of o.values())if(n.watermark)return n.watermark}}function R(t){let o=t.package.headers;if(!o||o.size===0)return t;let n=false,s=new Map;for(let[a,i]of o)if(i.watermark){let{watermark:d,...u}=i;s.set(a,u),n=true;}else s.set(a,i);return n?{...t,package:{...t.package,headers:s}}:t}function y(t,o){let n=t.package.headers;if(!n||n.size===0)return t;let s=new Map;for(let[a,i]of n)s.set(a,{...i,watermark:{...o}});return {...t,package:{...t.package,headers:s}}}function $(t){let o=t.package.document,n=[];if(o.sections)for(let s of o.sections)s.properties&&n.push(s.properties);return o.finalSectionProperties&&n.push(o.finalSectionProperties),n}function M(t,o){let n=t.package,s=n.document,a$1=n.headers,i=$(t),d=new Set;if(a$1)for(let e of a$1.values())d.add(e.hdrFtrType);let u=!a$1||a$1.size===0,F=i.some(e=>e.titlePg),D=i.some(e=>e.evenAndOddHeaders),h=u,g=F&&!d.has("first"),k=D&&!d.has("even");if(!h&&!g&&!k)return t;let f=n.relationships?new Map(n.relationships):new Map,H=new Map(a$1??[]),p=new Set;for(let e of f.values())e.target&&p.add(e.target.replace(/^\/?word\//,"").toLowerCase());function T(){let e=1;for(;p.has(`header${e}.xml`);)e++;let r=`header${e}.xml`;return p.add(r.toLowerCase()),r}function v(e){let r=`rIdWmHdr${e[0].toUpperCase()}${e.slice(1)}`,c=1;for(;f.has(r);)r=`rIdWmHdr${e[0].toUpperCase()}${e.slice(1)}${c++}`;return f.set(r,{id:r,type:a.header,target:T()}),H.set(r,{type:"header",hdrFtrType:e,content:[],watermark:{...o}}),r}let l={};function x(e){return l[e]??(l[e]=v(e))}function m(e,r){let c=e?.headerReferences?[...e.headerReferences]:[];return c.some(I=>I.type===r)?e??{}:(c.push({type:r,rId:x(r)}),{...e??{},headerReferences:c})}function P(e){let r=e;return h&&(r=m(r,"default")),g&&r?.titlePg&&(r=m(r,"first")),k&&r?.evenAndOddHeaders&&(r=m(r,"even")),r}let W=P(s.finalSectionProperties),w=s.sections?.map(e=>({...e,properties:P(e.properties)??e.properties}));return {...t,package:{...n,relationships:f,headers:H,document:{...s,finalSectionProperties:W,...w?{sections:w}:{}}}}}function z(t,o){if(!o)return R(t);let n=y(t,o);return M(n,o)}
2
+ export{E as a,z as b};
@@ -0,0 +1 @@
1
+ function C(s){return Array.from(s.querySelectorAll("canvas[data-page-index]"))}function T(s,c,a,o){let h=s.querySelector(`canvas[data-page-index="${a}"]`);if(h){let e=h.getBoundingClientRect();if(e.width>0&&e.height>0)return e}let p=c.pageSize(a);if(!p||p.width<=0||p.height<=0)return null;let r=s.getBoundingClientRect();if(r.width<=0)return null;let n=s.offsetWidth||s.clientWidth||r.width,i=n>0?r.width/n:1,g=Number.isFinite(i)&&i>0?i:1,l=o?.pageGap??24,f=o?.paddingTop??l;for(let e=0;e<a;e++)f+=(c.pageSize(e)?.height??0)+l;let u=p.width*g,m=p.height*g,t=r.left+(r.width-u)/2,d=r.top+f*g;return {left:t,top:d,right:t+u,bottom:d+m,width:u,height:m}}function H(s,c,a,o,h){let p=C(s),r=new Map;for(let t of p){let d=Number(t.dataset.pageIndex);Number.isFinite(d)&&r.set(d,t);}let n=null,i=null;for(let t=0;t<c.pageCount();t++){let e=r.get(t)?.getBoundingClientRect()??T(s,c,t,h);if(!e||e.width<=0||e.height<=0)continue;if(a>=e.left&&a<=e.right&&o>=e.top&&o<=e.bottom){n={pageIndex:t,rect:e};break}let y=o<e.top?e.top-o:Math.max(0,o-e.bottom),v=a<e.left?e.left-a:Math.max(0,a-e.right),x=y*4+v;(!i||x<i.dist)&&(i={pageIndex:t,rect:e,dist:x});}if(!n){if(!h?.clampToNearestPage||!i)return null;n={pageIndex:i.pageIndex,rect:i.rect};}let g=n.pageIndex,l=c.pageSize(g);if(!l)return null;let b=l.width/n.rect.width,f=l.height/n.rect.height,u=Math.min(Math.max((a-n.rect.left)*b,0),l.width),m=Math.min(Math.max((o-n.rect.top)*f,0),l.height);return {pageIndex:g,x:u,y:m,hit:c.hitTestRegions(g,u,m)}}export{T as a,H as b};
@@ -0,0 +1 @@
1
+ import {b as b$1,c as c$1}from'./chunk-OBQGPMPQ.mjs';import {b}from'./chunk-3UBMCDME.mjs';var c={top:4,bottom:4,left:7,right:7},h=200;function y(e,r){let o=e.kind??"<unknown>";throw new Error(`${r}: unhandled LayoutBlock kind "${o}". Add the case alongside the other LayoutBlock switches (see types.ts).`)}function x(e){return {pageWidth:e.size.w,pageHeight:e.size.h,marginLeft:e.margins.left,marginTop:e.margins.top,contentWidth:e.size.w-e.margins.left-e.margins.right,contentHeight:e.size.h-e.margins.top-e.margins.bottom}}function f(e,r,o){return u(e,r,o)}function u(e,r,o){let n=e.position?.vertical;if(!n)return r;let t=p(n.relativeTo,r,o);return n.align==="top"?t.base:n.align==="center"?t.size?t.base+(t.size-e.height)/2:r:n.align==="bottom"?t.size?t.base+t.size-e.height:r:n.posOffset!==void 0?t.base+b(n.posOffset):n.relativeTo==="paragraph"||n.relativeTo==="line"?r:t.base}function p(e,r,o){let n=o?.pageHeight??0,t=o?.marginTop??0,a=o?.contentHeight??0;switch(e){case "paragraph":case "line":return {base:r,size:0};case "page":return {base:-t,size:n};case "topMargin":return {base:-t,size:t};case "bottomMargin":return {base:a,size:t};default:return {base:0,size:a}}}function k(e){return b$1(e.wrapType)||e.wrapType==="topAndBottom"?false:c$1(e.wrapType)?true:e.displayMode==="float"&&e.cssFloat!=="none"}export{c as a,h as b,y as c,x as d,f as e,k as f};
@@ -0,0 +1,9 @@
1
+ import {a as a$1}from'./chunk-UIEJWORW.mjs';import {b as b$1,a as a$3}from'./chunk-6PW4CWUG.mjs';import {a as a$2}from'./chunk-OJOHXQNQ.mjs';import {h as h$1,s}from'./chunk-KVKLLTDP.mjs';import {a}from'./chunk-LDUWIM7M.mjs';import {b}from'./chunk-TTRUPDAB.mjs';var P=class o{constructor(t){b(this,"_document");b(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await a(t);return new o(e)}static fromDocument(t){return new o(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return a$1(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(i=>i.type==="paragraph"),r=n.map((i,s)=>{let c=this._getParagraphText(i),p=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:p,isHeading:p?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(p),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),a=(e.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:r,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let r={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(r)}replaceRange(t,e,n={}){let r={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(r)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,r={}){let a={type:"insertTable",position:t,rows:e,columns:n,data:r.data,hasHeader:r.hasHeader};return this._executeCommand(a)}insertImage(t,e,n={}){let r={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(r)}insertHyperlink(t,e,n={}){let r={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(r)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:r}=await import('./processTemplate-HDUIZFJ5.mjs'),a$1=r(n,e),i=await a(a$1),s=new o(i);return s._pendingVariables={},s}async toBuffer(t){if(this._document.originalBuffer){if(t?.selective){let n=await a$2(this._document,this._document.originalBuffer,t.selective);if(n)return this._document.originalBuffer=n,n}let e=await h$1(this._document);return this._document.originalBuffer=e,e}return s(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){return new o(b$1(this._document,t))}_executeCommand(t){let e=new o(a$3(this._document,t));return e._pendingVariables={...this._pendingVariables},e}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
2
+ `)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let r of n.cells)for(let a of r.content)a.type==="paragraph"&&e.push(this._getParagraphText(a));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let r=this._getRunText(n);r&&e.push({text:r,formatting:n.formatting});}else if(n.type==="hyperlink"){let r=n.href||"";for(let a of n.children)if(a.type==="run"){let i=this._getRunText(a);i&&e.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:r});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let r of n.content)if(r.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function Pt(o){return P.fromBuffer(o)}function Tt(o){return P.fromDocument(o)}function W(o,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:n=50}=t,r=o.package.document,a=r.content.filter(y=>y.type==="paragraph"),i=$(a,e,n),s=a$1(o),c=U(o),p=G(r),u=q(r),d=J(r),f=r.content.some(y=>y.type==="table"),x=Q(r),l=X(r);return {paragraphCount:a.length,wordCount:u,characterCount:d,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:p,hasTables:f,hasImages:x,hasHyperlinks:l}}function wt(o,t,e={}){let{contextChars:n=200,includeSuggestions:r=true}=e,i=o.package.document.content.filter(m=>m.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=g(s),p="";if(t.start.paragraphIndex===t.end.paragraphIndex)p=c.slice(t.start.offset,t.end.offset);else {let m=[];for(let b=t.start.paragraphIndex;b<=t.end.paragraphIndex;b++){let H=i[b];if(!H)continue;let _=g(H);b===t.start.paragraphIndex?m.push(_.slice(t.start.offset)):b===t.end.paragraphIndex?m.push(_.slice(0,t.end.offset)):m.push(_);}p=m.join(`
3
+ `);}let u=tt(i,t.start.paragraphIndex,t.start.offset,n),d=et(i,t.end.paragraphIndex,t.end.offset,n),f=nt(s,t.start.offset),x=s.formatting||{},l={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:v(c)},y=false,A=rt(s,t.start.offset),S=r?ot(p):[];return {selectedText:p,range:t,formatting:f,paragraphFormatting:x,textBefore:u,textAfter:d,paragraph:l,inTable:y,inHyperlink:A,suggestedActions:S}}function z(o){let t=W(o,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let n=t.outline.filter(r=>r.isHeading);if(n.length>0){e.push(`
4
+ Headings:`);for(let r of n.slice(0,5)){let a=r.headingLevel||1;e.push(`${" ".repeat(a-1)}- ${r.preview}`);}n.length>5&&e.push(` ... and ${n.length-5} more headings`);}return e.join(" ")}function $(o,t,e){let n=[];for(let r=0;r<Math.min(o.length,e);r++){let a=o[r],i=g(a),s=a.formatting?.styleId;n.push({index:r,preview:i.slice(0,t),style:s,isHeading:Y(s),headingLevel:Z(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return n}function U(o){let t=o.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let a=r;e.push({id:n,name:a.name||n,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return e}function G(o){return o.sections?o.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function q(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=v(n);}else e.type==="table"&&(t+=K(e));return t}function v(o){return o.split(/\s+/).filter(e=>e.length>0).length}function J(o){let t=0;for(let e of o.content)if(e.type==="paragraph"){let n=g(e);t+=n.length;}else e.type==="table"&&(t+=N(e));return t}function K(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=v(a);}return t}function N(o){let t=0;for(let e of o.rows)for(let n of e.cells)for(let r of n.content)if(r.type==="paragraph"){let a=g(r);t+=a.length;}return t}function g(o){let t=[];for(let e of o.content)e.type==="run"?t.push(T(e)):e.type==="hyperlink"&&t.push(F(e));return t.join("")}function T(o){return o.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function F(o){let t=[];for(let e of o.children)e.type==="run"&&t.push(T(e));return t.join("")}function Q(o){for(let t of o.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let n of e.content)if(n.type==="drawing")return true}}return false}function X(o){for(let t of o.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function Y(o){return o?o.toLowerCase().includes("heading"):false}function Z(o){if(!o)return;let t=o.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function tt(o,t,e,n){let r=[],a=0,i=o[t];if(i){let p=g(i).slice(0,e);r.unshift(p),a+=p.length;}for(let c=t-1;c>=0&&a<n;c--){let p=o[c];if(!p)continue;let u=g(p);r.unshift(u),a+=u.length;}let s=r.join(`
5
+ `);return s.length>n?"..."+s.slice(-n):s}function et(o,t,e,n){let r=[],a=0,i=o[t];if(i){let p=g(i).slice(e);r.push(p),a+=p.length;}for(let c=t+1;c<o.length&&a<n;c++){let p=o[c];if(!p)continue;let u=g(p);r.push(u),a+=u.length;}let s=r.join(`
6
+ `);return s.length>n?s.slice(0,n)+"...":s}function nt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=T(n),a=e,i=e+r.length;if(t>=a&&t<i)return n.formatting||{};e=i;}else if(n.type==="hyperlink"){let r=F(n),a=e,i=e+r.length;if(t>=a&&t<i){for(let s of n.children)if(s.type==="run")return s.formatting||{}}e=i;}return {}}function rt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=T(n);e+=r.length;}else if(n.type==="hyperlink"){let r=F(n),a=e,i=e+r.length;if(t>=a&&t<i)return true;e=i;}return false}function ot(o,t,e){let n=[];return o.length>0&&(n.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),o.length>200&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),o.length<50&&o.split(/\s+/).length<10&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),n.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),n.sort((r,a)=>(a.priority||0)-(r.priority||0)),n}function at(o,t,e={}){let{contextCharsBefore:n=200,contextCharsAfter:r=200,includeSuggestions:a=true}=e,i=o.package.document,s=i.content.filter(m=>m.type==="paragraph");if(t.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=s[t.start.paragraphIndex],p=it(s,t),u=st(s,t.start,n),d=ct(s,t.end,r),f=pt(c,t.start.offset),x=c.formatting||{},l={index:t.start.paragraphIndex,fullText:h(c),style:c.formatting?.styleId,wordCount:R(h(c))},y=lt(i,t.start),A=gt(c,t.start.offset),S=a?ft(p):[];return {selectedText:p,range:t,formatting:f,paragraphFormatting:x,textBefore:u,textAfter:d,paragraph:l,inTable:y,inHyperlink:A,suggestedActions:S}}function Rt(o,t,e={}){let n=at(o,t,e),{includeDocumentSummary:r=true}=e,i=o.package.document.content.filter(l=>l.type==="paragraph"),s=R(n.selectedText),c=n.selectedText.length,p=t.start.paragraphIndex!==t.end.paragraphIndex,u=[];for(let l=t.start.paragraphIndex;l<=t.end.paragraphIndex;l++)u.push(l);let d=mt(i,t),f=r?z(o):void 0,x=ht(n.selectedText);return {...n,documentSummary:f,wordCount:s,characterCount:c,isMultiParagraph:p,paragraphIndices:u,detectedLanguage:x,contentType:d}}function Ht(o,t){let n=o.package.document.content.filter(s=>s.type==="paragraph"),r=[];for(let s=t.start.paragraphIndex;s<=t.end.paragraphIndex;s++){let c=n[s];if(!c)continue;let p=s===t.start.paragraphIndex?t.start.offset:0,u=s===t.end.paragraphIndex?t.end.offset:1/0;ut(c,p,u,r);}let a=r.length<=1||r.every(s=>dt(s,r[0]));return {predominant:r.length>0?r[0]:{},isConsistent:a,allFormatting:r}}function it(o,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let n=o[t.start.paragraphIndex];return n?h(n).slice(t.start.offset,t.end.offset):""}let e=[];for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let r=o[n];if(!r)continue;let a=h(r);n===t.start.paragraphIndex?e.push(a.slice(t.start.offset)):n===t.end.paragraphIndex?e.push(a.slice(0,t.end.offset)):e.push(a);}return e.join(`
7
+ `)}function st(o,t,e){let n=[],r=0,a=o[t.paragraphIndex];if(a){let c=h(a).slice(0,t.offset);n.unshift(c),r+=c.length;}for(let s=t.paragraphIndex-1;s>=0&&r<e;s--){let c=o[s];if(!c)continue;let p=h(c);n.unshift(p),r+=p.length;}let i=n.join(`
8
+ `);return i.length>e?"..."+i.slice(-e):i}function ct(o,t,e){let n=[],r=0,a=o[t.paragraphIndex];if(a){let c=h(a).slice(t.offset);n.push(c),r+=c.length;}for(let s=t.paragraphIndex+1;s<o.length&&r<e;s++){let c=o[s];if(!c)continue;let p=h(c);n.push(p),r+=p.length;}let i=n.join(`
9
+ `);return i.length>e?i.slice(0,e)+"...":i}function pt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=C(n),a=e+r.length;if(t>=e&&t<a)return n.formatting||{};e=a;}else if(n.type==="hyperlink"){let r=I(n),a=e+r.length;if(t>=e&&t<a){for(let i of n.children)if(i.type==="run")return i.formatting||{}}e=a;}return {}}function ut(o,t,e,n){let r=0;for(let a of o.content)if(a.type==="run"){let i=C(a),s=r,c=r+i.length;c>t&&s<e&&a.formatting&&n.push({...a.formatting}),r=c;}else if(a.type==="hyperlink"){let i=I(a),s=r,c=r+i.length;if(c>t&&s<e)for(let p of a.children)p.type==="run"&&p.formatting&&n.push({...p.formatting});r=c;}}function lt(o,t){return false}function gt(o,t){let e=0;for(let n of o.content)if(n.type==="run"){let r=C(n);e+=r.length;}else if(n.type==="hyperlink"){let r=I(n),a=e,i=e+r.length;if(t>=a&&t<i)return true;e=i;}return false}function ft(o,t,e){let n=[];if(!o||o.trim().length===0)return n;n.push({id:"askAI",label:"Ask AI",description:"Ask AI about this text",priority:11},{id:"rewrite",label:"Rewrite",description:"Rewrite this text differently",priority:10});let r=R(o);return r>50&&n.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),r<20&&n.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),n.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7},{id:"translate",label:"Translate",description:"Translate to another language",priority:6},{id:"explain",label:"Explain",description:"Explain what this means",priority:5}),n.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),n.sort((a,i)=>(i.priority||0)-(a.priority||0)),n}function mt(o,t){let e=new Set;for(let n=t.start.paragraphIndex;n<=t.end.paragraphIndex;n++){let r=o[n];r&&(r.listRendering?e.add("list"):r.formatting?.styleId?.toLowerCase().includes("heading")?e.add("heading"):e.add("prose"));}return e.size>1?"mixed":e.has("list")?"list":e.has("heading")?"heading":"prose"}function ht(o){return /[а-яА-ЯёЁ]/.test(o)?"ru":/[一-龯]/.test(o)?"zh":/[ひらがなカタカナ]/.test(o)||/[\u3040-\u309F\u30A0-\u30FF]/.test(o)?"ja":/[가-힣]/.test(o)?"ko":/[àâäéèêëïîôùûüç]/i.test(o)?"fr":/[äöüß]/i.test(o)?"de":/[áéíóúñ]/i.test(o)?"es":"en"}function h(o){let t=[];for(let e of o.content)e.type==="run"?t.push(C(e)):e.type==="hyperlink"&&t.push(I(e));return t.join("")}function C(o){return o.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function I(o){let t=[];for(let e of o.children)e.type==="run"&&t.push(C(e));return t.join("")}function R(o){return o.split(/\s+/).filter(t=>t.length>0).length}function dt(o,t){let e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?false:e.every(r=>{let a=o[r],i=t[r];return a===i})}export{P as a,Pt as b,Tt as c,W as d,wt as e,z as f,at as g,Rt as h,Ht as i};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-FPZBTOD6.mjs';import {c as c$1}from'./chunk-H3JCIGWK.mjs';var m=new TextEncoder;function I(e){if(!e)return d({abstractNums:[],nums:[]});let t=c$1({"[Content_Types].xml":m.encode('<?xml version="1.0" encoding="UTF-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/></Types>'),"word/document.xml":m.encode('<?xml version="1.0" encoding="UTF-8"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p/></w:body></w:document>'),"word/_rels/document.xml.rels":m.encode('<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/></Relationships>'),"word/numbering.xml":m.encode(e)}),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),n=a(r,{parseHeadersFooters:false,parseNotes:false,detectVariables:false}).document.package.numbering??{abstractNums:[],nums:[]};return d(n)}var b=new WeakMap;function T(e){let t=b.get(e);return t||(t=d(e),b.set(e,t)),t}function d(e){let t=new Map;for(let n of e.abstractNums)t.set(n.abstractNumId,n);let r=new Map;for(let n of e.nums)r.set(n.numId,n);return {definitions:e,getLevel(n,i){let s=r.get(n);if(!s)return null;if(s.levelOverrides){let o=s.levelOverrides.find(l=>l.ilvl===i);if(o){if(o.lvl)return o.lvl;let l=t.get(s.abstractNumId);if(l){let u=l.levels.find(x=>x.ilvl===i);if(u&&o.startOverride!==void 0)return {...u,start:o.startOverride}}}}let a=t.get(s.abstractNumId);if(!a)return null;if(a.numStyleLink&&a.levels.length===0){for(let o of t.values())if(o.styleLink===a.numStyleLink&&o.levels.length>0){a=o;break}}return a.levels.find(o=>o.ilvl===i)??null},getAbstract(n){return t.get(n)??null},getInstance(n){return r.get(n)??null},hasNumbering(n){return r.has(n)}}}function k(e,t){let{numId:r,ilvl:n=0}=e;if(r===void 0||r===0)return null;let i=t.getLevel(r,n);if(!i)return null;let s=[];for(let l=0;l<=n;l+=1){let u=t.getLevel(r,l);s.push(u?.numFmt??"decimal");}let a=t.getInstance(r),o=a?.levelOverrides?.find(l=>l.ilvl===n);return {level:n,numId:r,marker:i.lvlText,isBullet:i.numFmt==="bullet",numFmt:i.numFmt,markerHidden:i.rPr?.hidden||void 0,markerFontFamily:i.rPr?.fontFamily?.ascii||i.rPr?.fontFamily?.hAnsi||void 0,markerFontSize:i.rPr?.fontSize?i.rPr.fontSize/2:void 0,markerSuffix:i.suffix,levelNumFmts:s,abstractNumId:a?.abstractNumId,startOverride:o?.startOverride}}function N(e,t){switch(t){case "decimal":return e.toString();case "decimalZero":return c(e,2);case "decimalZero3":return c(e,3);case "decimalZero4":return c(e,4);case "decimalZero5":return c(e,5);case "upperRoman":return g(e).toUpperCase();case "lowerRoman":return g(e).toLowerCase();case "upperLetter":return v(e).toUpperCase();case "lowerLetter":return v(e).toLowerCase();case "ordinal":return h(e);case "bullet":return "\u2022";case "none":return "";case "decimalEnclosedParen":return `(${e})`;case "numberInDash":return `-${e}-`;default:return e.toString()}}function c(e,t){return e<0?e.toString():e.toString().padStart(t,"0")}function g(e){if(e<=0||e>3999)return e.toString();let t=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],r="",n=e;for(let[i,s]of t)for(;n>=i;)r+=s,n-=i;return r}function v(e){if(e<=0)return "";let t="",r=e;for(;r>0;)r--,t=String.fromCharCode(97+r%26)+t,r=Math.floor(r/26);return t}function h(e){let t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}function C(e,t,r){let n=e;for(let i=1;i<=9;i++){let s=`%${i}`;if(n.includes(s)){let a=i-1,o=t[a]??1,l=r[a]??"decimal",u=N(o,l);n=n.replace(s,u);}}return n}function M(e){if(e.lvlText)return e.lvlText;let t=e.rPr?.fontFamily?.ascii||e.rPr?.fontFamily?.hAnsi;if(t){let r=t.toLowerCase();if(r==="symbol")return "\u2022";if(r.includes("wingding"))return "\u2751"}return "\u2022"}function S(e){return e.numFmt==="bullet"||e.numFmt==="none"}
2
+ export{I as a,T as b,d as c,k as d,N as e,c as f,C as g,M as h,S as i};
@@ -0,0 +1,10 @@
1
+ import {b as b$1,f as f$1}from'./chunk-O2QSE2I7.mjs';import {b}from'./chunk-UIEJWORW.mjs';import {a}from'./chunk-LDUWIM7M.mjs';function D(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function C(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{${t}}`;return M(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function P(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];V(l,n.start.offset,n.end.offset);let p=`{${t}}`;return M(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function M(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=x(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,b=a.slice(0,m),y=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);b&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:b}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),y&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:y}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=x(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function V(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=x(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function x(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var f={type:"string",description:"Document ID from a previous docx_load call"},R={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"]},S={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
2
+ Returns variable names without braces, along with their locations (body, headers, footers, etc.).
3
+ Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.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}'}]}},k={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
4
+ The variable can later be substituted with actual values using docx_apply_template.
5
+ Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:f,position:R,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(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-7O2RBJ2B.mjs'),a=r(e.document,{type:"insertText",position:n,text:`{${t}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{${t}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.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"}}]}},E={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
6
+ Replaces all {variable} placeholders with the corresponding values provided.
7
+ Preserves all formatting (fonts, styles, colors, tables).
8
+ Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:f,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(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=b$1(e.buffer,n,{nullGetter:t?"keep":"empty"}),a$1=await a(r.buffer);return e.document=a$1,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.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"}}}]}},_={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
9
+ Checks for syntax errors like unclosed braces, invalid tag names, etc.
10
+ Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!n.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let t=f$1(n.buffer);return {content:[{type:"text",text:JSON.stringify({valid:t.valid,tags:t.tags,errors:t.errors.map(e=>({message:e.message,variable:e.variable,type:e.type}))},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},I=[S,k,E,_];var J={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:C,replaceWithTemplateVariable:P},mcpTools:I};export{D as a,J as b};
@@ -0,0 +1,8 @@
1
+ function d(t){let e=[];for(let n of t.content)n.type==="run"?e.push(g(n)):n.type==="hyperlink"&&e.push(y(n));return e.join("")}function g(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function y(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(g(n));return e.join("")}function B(t){let e=[];for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&e.push(d(r));return e.join(" ")}function Ct(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(d(n)):n.type==="table"&&e.push(B(n));return e.join(`
2
+ `)}function A(t){return t.split(/\s+/).filter(n=>n.length>0).length}function mt(t,e=true){return e?t.length:t.replace(/\s/g,"").length}function kt(t){let e=0;for(let n of t.content)n.type==="paragraph"?e+=A(d(n)):n.type==="table"&&(e+=J(n));return e}function J(t){let e=0;for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&(e+=A(d(r)));return e}function xt(t){let e=0;for(let n of t.content)n.type==="paragraph"?e+=d(n).length:n.type==="table"&&(e+=G(n));return e}function G(t){let e=0;for(let n of t.rows)for(let o of n.cells)for(let r of o.content)r.type==="paragraph"&&(e+=d(r).length);return e}function bt(t,e,n){let o=[],r=0,a=t[e.paragraphIndex];if(a){let s=d(a).slice(0,e.offset);o.unshift(s),r+=s.length;}for(let c=e.paragraphIndex-1;c>=0&&r<n;c--){let s=t[c];if(!s)continue;let l=d(s);o.unshift(l),r+=l.length;}let i=o.join(`
3
+ `);return i.length>n?"..."+i.slice(-n):i}function wt(t,e,n){let o=[],r=0,a=t[e.paragraphIndex];if(a){let s=d(a).slice(e.offset);o.push(s),r+=s.length;}for(let c=e.paragraphIndex+1;c<t.length&&r<n;c++){let s=t[c];if(!s)continue;let l=d(s);o.push(l),r+=l.length;}let i=o.join(`
4
+ `);return i.length>n?i.slice(0,n)+"...":i}function St(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o),a=n+r.length;if(e>=n&&e<a)return o.formatting||{};n=a;}else if(o.type==="hyperlink"){let r=y(o),a=n+r.length;if(e>=n&&e<a){for(let i of o.children)if(i.type==="run")return i.formatting||{}}n=a;}return {}}function Tt(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o);n+=r.length;}else if(o.type==="hyperlink"){let r=y(o),a=n,i=n+r.length;if(e>=a&&e<i)return true;n=i;}return false}function Pt(t,e){let n=0;for(let o of t.content)if(o.type==="run"){let r=g(o);n+=r.length;}else if(o.type==="hyperlink"){let r=y(o),a=n,i=n+r.length;if(e>=a&&e<i)return o;n=i;}}function Bt(t){return t?t.toLowerCase().includes("heading"):false}function It(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function Ft(t){for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let o of n.content)if(o.type==="drawing")return true}}return false}function Dt(t){for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}function Ot(t){return t.content.some(e=>e.type==="table")}function K(t){return t.content.filter(e=>e.type==="paragraph")}function Mt(t,e){return K(t)[e]}function Et(t,e){let n=0;for(let o=0;o<t.content.length;o++)if(t.content[o].type==="paragraph"){if(n===e)return o;n++;}return -1}function Q(t){return "package"in t?t.package.document:t}function tt(t){return t.type==="inlineSdt"?Y(t.content):q(t.content)}function q(t){let e=[];for(let n of t)n.type==="paragraph"?e.push(d(n)):n.type==="table"?e.push(B(n)):n.type==="blockSdt"&&e.push(q(n.content));return e.join(`
5
+ `)}function Y(t){let e=[];for(let n of t)switch(n.type){case "run":e.push(g(n));break;case "hyperlink":e.push(y(n));break;case "simpleField":for(let o of n.content)e.push(o.type==="run"?g(o):y(o));break;case "complexField":for(let o of n.fieldResult)e.push(g(o));break;case "inlineSdt":e.push(Y(n.content));break;case "mathEquation":n.plainText&&e.push(n.plainText);break}return e.join("")}function x(t,e){return !(e.tag!==void 0&&t.tag!==e.tag||e.alias!==void 0&&t.alias!==e.alias||e.id!==void 0&&t.id!==e.id||e.type!==void 0&&t.sdtType!==e.type)}function W(t,e,n,o){let r=t.properties;return {tag:r.tag,alias:r.alias,id:r.id,sdtType:r.sdtType,lock:r.lock,listItems:r.listItems,placeholder:r.placeholder,showingPlaceholder:r.showingPlaceholder,checked:r.checked,dateFormat:r.dateFormat,dataBinding:r.dataBinding,text:tt(t),path:e,depth:n,kind:t.type==="inlineSdt"?"inline":"block",location:o}}function et(t,e={},n={}){let o=[],r=(i,c,s,l)=>{for(let p of i)p.type==="inlineSdt"&&(x(p.properties,e)&&o.push(W(p,s,l,c)),r(p.content,c,s,l+1));},a=(i,c,s,l)=>{for(let p=0;p<i.length;p++){let u=i[p],f=[...s,p];if(u.type==="blockSdt")x(u.properties,e)&&o.push(W(u,f,l,c)),a(u.content,c,f,l+1);else if(u.type==="table")for(let k of u.rows)for(let w of k.cells)a(w.content,c,f,l);else u.type==="paragraph"&&r(u.content,c,f,l);}};if(a(Q(t).content,{part:"body"},[],0),n.includeHeadersFooters&&"package"in t){let i=(c,s)=>{if(c)for(let l of [...c.keys()].sort())a(c.get(l).content,{part:s,rId:l},[],0);};i(t.package.headers,"header"),i(t.package.footers,"footer");}return o}function Lt(t,e,n={}){return et(t,e,n)[0]}var I=class extends Error{constructor(e){super(`No content control matched ${JSON.stringify(e)}`),this.name="ContentControlNotFoundError";}},m=class extends Error{constructor(e,n){super(`Content control is ${e}; cannot ${n} it without { force: true }`),this.name="ContentControlLockedError";}},F=class extends Error{constructor(e){super(`Content control is a '${e}' control; replacing its content with free text would desync it. Use a type-specific value setter or pass { force: true }.`),this.name="ContentControlTypeError";}},b=class extends Error{constructor(){super("Content control is data-bound (w:dataBinding); its content is driven by the Custom XML store and a direct write will not persist. Update the store, or pass { force: true }."),this.name="ContentControlBoundError";}},nt=new Set(["richText","plainText","unknown"]);function ot(t){return nt.has(t)}function O(t){return t==="contentLocked"||t==="sdtContentLocked"}function rt(t){return t==="sdtLocked"||t==="sdtContentLocked"}function it(t){return /<w15:repeatingSection(Item)?[\s/>]/.test(t.rawPropertiesXml??"")}function M(t){return t.dataBinding!=null}function E(t){return t&&t.replace(/<w:showingPlcHdr\b[^>]*\/>/g,"").replace(/<w:showingPlcHdr\b[^>]*>[\s\S]*?<\/w:showingPlcHdr>/g,"")}function X(t){if(!t.showingPlaceholder&&!/showingPlcHdr/.test(t.rawPropertiesXml??""))return t;let e={...t,showingPlaceholder:false},n=E(t.rawPropertiesXml);return n!==void 0&&(e.rawPropertiesXml=n),e}function V(t){return {type:"paragraph",content:t?[{type:"run",content:[{type:"text",text:t}]}]:[]}}function ct(t,e={}){return typeof t!="string"?structuredClone(t):e.singleParagraph?[V(t)]:t.split(`
6
+ `).map(V)}function at(t,e,n,o){let r=[];for(let a of t){if(o.done){r.push(a);continue}if(a.type==="blockSdt"){if(x(a.properties,e)){r.push(...n(a)),o.done=true;continue}r.push({...a,content:at(a.content,e,n,o)});}else r.push(a);}return r}function st(t,e){return {...t,package:{...t.package,document:{...t.package.document,content:e}}}}var D=class extends Error{constructor(e){super(e),this.name="ContentControlKindError";}};function lt(t){switch(t.type){case "run":case "hyperlink":case "simpleField":case "complexField":case "inlineSdt":case "mathEquation":return true;default:return false}}function ut(t){let e=t.content.find(n=>n.type==="run");return e?.formatting?structuredClone(e.formatting):void 0}function j(t){let e={type:"text",text:t};return /^\s|\s$/.test(t)&&(e.preserveSpace=true),e}function pt(t,e){if(typeof t!="string"){if(t.length===1&&t[0].type==="paragraph"&&t[0].content.every(lt))return structuredClone(t[0].content);throw new D("Cannot place block content (paragraphs/tables) inside an inline content control. Pass a string, or a single paragraph whose content is entirely inline.")}if(t==="")return [];let n=ut(e),o=e.properties.sdtType==="plainText",r=[];o||!t.includes(`
7
+ `)?r.push(j(t)):t.split(`
8
+ `).forEach((i,c)=>{c>0&&r.push({type:"break",breakType:"textWrapping"}),i&&r.push(j(i));});let a={type:"run",content:r};return n&&(a.formatting=n),[a]}var C=t=>t.stopAtFirst&&t.matched>0;function Z(t,e,n,o){let r=false,a=[];for(let i of t){if(C(o)||i.type!=="inlineSdt"){a.push(i);continue}if(x(i.properties,e)){a.push(...n(i)),o.matched+=1,r=true;continue}let c=i.content,s=Z(c,e,n,o);s!==c?(a.push({...i,content:s}),r=true):a.push(i);}return r?a:t}function dt(t,e,n,o,r){if(C(r))return t;let a=false,i=t.rows.map(c=>{if(C(r))return c;let s=false,l=c.cells.map(p=>{if(C(r))return p;let u=p.content,f=S(u,e,n,o,r);return f!==u?(s=true,{...p,content:f}):p});return s?(a=true,{...c,cells:l}):c});return a?{...t,rows:i}:t}function S(t,e,n,o,r){let a=false,i=[];for(let c of t){if(C(r)){i.push(c);continue}if(c.type==="blockSdt"){if(x(c.properties,e)){i.push(...n(c)),r.matched+=1,a=true;continue}let s=S(c.content,e,n,o,r);s!==c.content?(i.push({...c,content:s}),a=true):i.push(c);}else if(c.type==="table"){let s=dt(c,e,n,o,r);s!==c?(i.push(s),a=true):i.push(c);}else if(c.type==="paragraph"){let s=Z(c.content,e,o,r);s!==c.content?(i.push({...c,content:s}),a=true):i.push(c);}else i.push(c);}return a?i:t}function ft(t,e,n,o){let r=e==="header"?"headers":"footers",a=new Map(t.package[r]);return a.set(n,o),{...t,package:{...t.package,[r]:a}}}function T(t,e,n,o,r,a=c=>c,i=false){let c={matched:0,stopAtFirst:!i},s=t,l=S(t.package.document.content,e,n,o,c);if(l!==t.package.document.content&&(s=st(s,a(l))),C(c))return s;if(r)for(let p of ["header","footer"]){let u=p==="header"?s.package.headers:s.package.footers;if(u)for(let f of [...u.keys()].sort()){let k=u.get(f),w=S(k.content,e,n,o,c);if(w!==k.content&&(s=ft(s,p,f,{...k,content:w})),C(c))return s}}if(c.matched===0)throw new I(e);return s}function U(t,e){if(!e&&O(t.lock))throw new m(t.lock,"edit");if(!e&&!ot(t.sdtType))throw new F(t.sdtType);if(!e&&M(t))throw new b}function N(t,e){if(!e.force&&rt(t.lock))throw new m(t.lock,"remove");if(e.keepContent&&!e.force&&it(t))throw new m(t.lock,"remove")}function vt(t,e,n,o={}){return T(t,e,i=>(U(i.properties,o.force),[{...i,properties:X(i.properties),content:ct(n,{singleParagraph:i.properties.sdtType==="plainText"})}]),i=>(U(i.properties,o.force),[{...i,properties:X(i.properties),content:pt(n,i)}]),o.includeHeadersFooters??false,void 0,o.all??false)}function At(t,e,n={}){let o=i=>(N(i.properties,n),n.keepContent?i.content:[]),r=i=>(N(i.properties,n),n.keepContent?i.content:[]),a=i=>i.length>0?i:[{type:"paragraph",content:[]}];return T(t,e,o,r,n.includeHeadersFooters??false,a,n.all??false)}var h=class extends Error{constructor(e){super(e),this.name="ContentControlValueError";}};function P(t,e,n){let o=new RegExp(`<${e}\\b[^>]*>`).exec(t);if(!o)return;let r=new RegExp(`\\b${n}="([^"]*)"`).exec(o[0]);return r?r[1]:void 0}function H(t,e,n,o){let a=new RegExp(`<${e}\\b[^>]*?(/?)>`).exec(t);if(!a)return t;let i=a[0],c=a[1]==="/",s=i.slice(1,c?-2:-1),p=new RegExp(`\\b${n}="[^"]*"`).test(s)?s.replace(new RegExp(`\\b${n}="[^"]*"`),()=>`${n}="${o}"`):`${s} ${n}="${o}"`;return t.replace(i,()=>`<${p}${c?"/>":">"}`)}function gt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ht(t,e){if(!t)return e;let n=parseInt(t,16);return Number.isNaN(n)||n<0||n>1114111||n>=55296&&n<=57343?e:String.fromCodePoint(n)}function yt(t,e,n){let[o,r,a]=t.slice(0,10).split("-").map(u=>parseInt(u,10));if(!z(o,r,a))return t;let i=e&&e.trim()?e:"M/d/yyyy",c=u=>String(u).padStart(2,"0"),s=new Date(Date.UTC(o,r-1,a)),l=u=>{try{return new Intl.DateTimeFormat(n||"en",{month:u,timeZone:"UTC"}).format(s)}catch{return new Intl.DateTimeFormat("en",{month:u,timeZone:"UTC"}).format(s)}},p={yyyy:String(o),yy:String(o).slice(-2),MMMM:l("long"),MMM:l("short"),MM:c(r),M:String(r),dd:c(a),d:String(a)};return i.replace(/yyyy|yy|MMMM|MMM|MM|M|dd|d/g,u=>p[u])}function z(t,e,n){if(!t||!e||!n)return false;let o=new Date(Date.UTC(t,e-1,n));return o.getUTCFullYear()===t&&o.getUTCMonth()===e-1&&o.getUTCDate()===n}function R(t,e){return t?{type:"paragraph",content:[{type:"run",content:[{type:"text",text:t}],...e?{formatting:{fontFamily:{ascii:e,hAnsi:e,eastAsia:e,cs:e}}}:{}}]}:{type:"paragraph",content:[]}}function $(t,e){let n=E(e);return {...t,showingPlaceholder:false,rawPropertiesXml:(n??e)||void 0}}function _(t,e){let n=t.rawPropertiesXml??"";switch(e.kind){case "dropdown":{if(t.sdtType!=="dropDownList"&&t.sdtType!=="comboBox")throw new h(`Control is '${t.sdtType}', not a dropdown/combo box.`);let o=t.listItems?.find(l=>l.value===e.value||l.displayText===e.value);if(!o&&t.sdtType==="dropDownList")throw new h(`'${e.value}' is not one of the control's list items.`);let r=o?.value??e.value,a=o?.displayText??e.value,i=o?t.listItems?.indexOf(o):void 0,c=t.sdtType==="comboBox"?"w:comboBox":"w:dropDownList",s=H(n,c,"w:lastValue",gt(r));return {properties:{...$(t,s),listLastValue:r,controlState:{...t.controlState,value:a,selectedValue:r,selectedIndex:i,placeholder:false}},content:[R(a)]}}case "checkbox":{if(t.sdtType!=="checkbox")throw new h(`Control is '${t.sdtType}', not a checkbox.`);if(P(n,"w14:checked","w14:val")==null)throw new h("Checkbox control has no <w14:checked> state to update (not a Word checkbox).");let o=e.checked?"w14:checkedState":"w14:uncheckedState",r=ht(P(n,o,"w14:val"),e.checked?"\u2612":"\u2610"),a=P(n,o,"w14:font"),i=H(n,"w14:checked","w14:val",e.checked?"1":"0");return {properties:{...$(t,i),checked:e.checked,controlState:{...t.controlState,checked:e.checked,value:r,placeholder:false}},content:[R(r,a)]}}case "date":{if(t.sdtType!=="date")throw new h(`Control is '${t.sdtType}', not a date control.`);let o=e.date.slice(0,10),[r,a,i]=/^\d{4}-\d{2}-\d{2}$/.test(o)?o.split("-").map(Number):[];if(!z(r,a,i))throw new h(`Date must be ISO yyyy-mm-dd, got '${e.date}'.`);let c=`${o}T00:00:00`,s=H(n,"w:date","w:fullDate",c),l=t.dateState?.format??t.dateFormat??P(n,"w:dateFormat","w:val"),p=t.dateState?.language,u=yt(o,l,p);return {properties:{...$(t,s),dateFormat:l,dateState:{...t.dateState,fullDate:c,format:l},controlState:{...t.controlState,value:o,placeholder:false}},content:[R(u)]}}}}function jt(t,e,n,o={}){let r=c=>{if(!o.force&&O(c.lock))throw new m(c.lock,"edit");if(!o.force&&M(c))throw new b};return T(t,e,c=>{r(c.properties);let{properties:s,content:l}=_(c.properties,n);return [{...c,properties:s,content:l}]},c=>{r(c.properties);let{properties:s,content:l}=_(c.properties,n),p=l[0],u=p&&p.type==="paragraph"?p.content:[];return [{...c,properties:s,content:u}]},o.includeHeadersFooters??false,void 0,o.all??false)}export{m as A,F as B,b as C,at as D,st as E,D as F,lt as G,vt as H,At as I,h as J,yt as K,_ as L,jt as M,d as a,g as b,y as c,B as d,Ct as e,A as f,mt as g,kt as h,xt as i,bt as j,wt as k,St as l,Tt as m,Pt as n,Bt as o,It as p,Ft as q,Dt as r,Ot as s,K as t,Mt as u,Et as v,tt as w,et as x,Lt as y,I as z};
@@ -0,0 +1 @@
1
+ var F={FFFF00:"yellow","00FF00":"green","00FFFF":"cyan",FF00FF:"magenta","0000FF":"blue",FF0000:"red","00008B":"darkBlue","008080":"darkCyan","008000":"darkGreen",800080:"darkMagenta","8B0000":"darkRed",808e3:"darkYellow",808080:"darkGray",C0C0C0:"lightGray","000000":"black",FFFFFF:"white"};function t(e){let r=e.replace(/^#/,"").toUpperCase();return F[r]||null}export{F as a,t as b};
@@ -0,0 +1 @@
1
+ var D=340,I=12,o=176,t=8;export{D as a,I as b,o as c,t as d};
@@ -0,0 +1 @@
1
+ var t=/^[a-z][a-z0-9+.-]*:/i,i=/^(https?|mailto|tel|ftp):/i;function d(n){if(!n)return;let e=n.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(e)return t.test(e)?i.test(e)?n:void 0:n}export{d as a};