@eigenpal/docx-js-editor 0.0.6 → 0.0.8

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 (47) hide show
  1. package/README.md +26 -2
  2. package/dist/{chunk-FXILBPZI.cjs → chunk-7O7MPYI7.cjs} +6 -6
  3. package/dist/chunk-AZFSFU4G.js +58 -0
  4. package/dist/{chunk-AOL255XD.js → chunk-B2GPMRIP.js} +2 -2
  5. package/dist/chunk-CEBRVCHO.js +11 -0
  6. package/dist/chunk-CWWSDDRF.cjs +11 -0
  7. package/dist/{chunk-D2GERZ7M.cjs → chunk-EKU3VR4Y.cjs} +2 -2
  8. package/dist/chunk-NZ7XUW4I.cjs +1 -0
  9. package/dist/{chunk-H2UMX5CK.js → chunk-VMT4DN2Q.js} +6 -6
  10. package/dist/chunk-W2TDS3UO.js +1 -0
  11. package/dist/chunk-WWGV3HB2.cjs +58 -0
  12. package/dist/{colorResolver-DrNkos_H.d.ts → colorResolver-CTmPdBGz.d.cts} +27 -7
  13. package/dist/{colorResolver-WsUxFs5p.d.cts → colorResolver-DGxlMbv2.d.ts} +27 -7
  14. package/dist/core-plugins.cjs +1 -1
  15. package/dist/core-plugins.d.cts +3 -3
  16. package/dist/core-plugins.d.ts +3 -3
  17. package/dist/core-plugins.js +1 -1
  18. package/dist/headless.cjs +2 -2
  19. package/dist/headless.d.cts +4 -4
  20. package/dist/headless.d.ts +4 -4
  21. package/dist/headless.js +1 -1
  22. package/dist/index.cjs +26 -27
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.cts +118 -109
  25. package/dist/index.d.ts +118 -109
  26. package/dist/index.js +26 -27
  27. package/dist/mcp-cli.js +21 -20
  28. package/dist/mcp.cjs +3 -3
  29. package/dist/mcp.d.cts +1 -1
  30. package/dist/mcp.d.ts +1 -1
  31. package/dist/mcp.js +2 -2
  32. package/dist/{registry-BWDZlJx6.d.cts → registry-C73dM_1E.d.cts} +1 -1
  33. package/dist/{registry-DifIQR1O.d.ts → registry-Djkwny4j.d.ts} +1 -1
  34. package/dist/selectionRects-5TGQE33Q.cjs +1 -0
  35. package/dist/selectionRects-JSPKYXPU.js +1 -0
  36. package/dist/styles.css +1 -1
  37. package/dist/{types-XVRXTi4o.d.ts → types-Do_Q8vaT.d.cts} +5 -1
  38. package/dist/{types-XVRXTi4o.d.cts → types-Do_Q8vaT.d.ts} +5 -1
  39. package/package.json +10 -5
  40. package/dist/chunk-2CFVFSUH.js +0 -57
  41. package/dist/chunk-BBGDBZJY.cjs +0 -1
  42. package/dist/chunk-DQHQWQHL.cjs +0 -11
  43. package/dist/chunk-HGOIKOKZ.js +0 -1
  44. package/dist/chunk-I2C6ENCR.js +0 -11
  45. package/dist/chunk-TL3YTVN2.cjs +0 -57
  46. package/dist/selectionRects-M7QY6HKR.cjs +0 -1
  47. package/dist/selectionRects-O6YQMMCP.js +0 -1
@@ -1,10 +1,10 @@
1
- 'use strict';var chunkDQHQWQHL_cjs=require('./chunk-DQHQWQHL.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs'),g=require('pizzip'),b=require('docxtemplater');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);var b__default=/*#__PURE__*/_interopDefault(b);function J(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function v(e,t){let r=t,{position:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.paragraphIndex} out of bounds`);let c=s[o.paragraphIndex],l=`{{${n}}}`;return k(c,o.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function w(e,t){let r=t,{range:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.start.paragraphIndex!==o.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(o.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.start.paragraphIndex} out of bounds`);let c=s[o.start.paragraphIndex];Z(c,o.start.offset,o.end.offset);let l=`{{${n}}}`;return k(c,o.start.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function k(e,t,r){let o=0,n=false;for(let a=0;a<e.content.length;a++){let i=e.content[a];if(i.type==="run"){let s=T(i),c=o,l=o+s.length;if(!n&&t>=c&&t<=l){let u=t-c,y=s.slice(0,u),m=s.slice(u),p=[];for(let d=0;d<a;d++)p.push(e.content[d]);y&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:y}]}),p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:r}]}),m&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:m}]});for(let d=a+1;d<e.content.length;d++)p.push(e.content[d]);e.content=p,n=true;break}o=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(o+=T(s).length);}n||e.content.push({type:"run",content:[{type:"text",text:r}]});}function Z(e,t,r){let o=[],n=0;for(let a of e.content)if(a.type==="run"){let i=T(a),s=n,c=n+i.length;if(c<=t||s>=r)o.push(a);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>r&&(l+=i.slice(r-s)),l.length>0&&o.push({type:"run",formatting:a.formatting,content:[{type:"text",text:l}]});}n=c;}else o.push(a);e.content=o;}function T(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function U(e){return V(e).variables}function V(e){let t=[],r={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let n=j(e.package.document);n.forEach(a=>{t.push({name:a,location:"body"});}),r.body=Array.from(new Set(n)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((n,a)=>{n.properties.headerReferences&&n.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let n=A(e.package.footnotes);n.forEach(a=>{t.push({name:a,location:"footnote"});}),r.footnotes=Array.from(new Set(n)).sort();}if(e.package?.endnotes){let n=A(e.package.endnotes);n.forEach(a=>{t.push({name:a,location:"endnote"});}),r.endnotes=Array.from(new Set(n)).sort();}e.templateVariables&&e.templateVariables.forEach(n=>{t.some(a=>a.name===n)||t.push({name:n,location:"body"});});let o=new Set;return t.forEach(n=>o.add(n.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:r,occurrences:t}}function j(e){let t=[];if(e.content&&t.push(...I(e.content)),e.sections)for(let r of e.sections)r.content&&t.push(...I(r.content));return t}function I(e){let t=[];for(let r of e)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function R(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="run"?t.push(...f(r)):r.type==="hyperlink"?t.push(...q(r)):r.type==="simpleField"?t.push(...W(r)):r.type==="complexField"&&t.push(...G(r));return t}function f(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="text"&&r.text&&t.push(...B(r.text));return t}function q(e){let t=[];if(!e.children)return t;for(let r of e.children)r.type==="run"&&t.push(...f(r));return t}function W(e){let t=[];if(e.instruction&&t.push(...B(e.instruction)),e.content)for(let r of e.content)r.type==="run"&&t.push(...f(r));return t}function G(e){let t=[];if(e.fieldCode)for(let r of e.fieldCode)r.type==="run"&&t.push(...f(r));if(e.fieldResult)for(let r of e.fieldResult)r.type==="run"&&t.push(...f(r));return t}function M(e){let t=[];if(!e.rows)return t;for(let r of e.rows)if(r.cells)for(let o of r.cells)t.push(...X(o));return t}function X(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function A(e){let t=[];for(let r of e)if(r.content)for(let o of r.content)t.push(...R(o));return t}var S=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,_=/\{(.+?)\}/g;function B(e){if(!e)return [];let t=[],r=new RegExp(S),o;for(;(o=r.exec(e))!==null;)t.push(o[1]);return t}function oe(e){return S.test(e)}function ae(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 ie(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 se(e){return `{${e}}`}function ce(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function le(e,t){return e&&e.replace(_,(r,o)=>{let n=o.trim();return n in t?t[n]:r})}function pe(e,t=""){return e&&e.replace(_,t)}function ue(e){return U(e).length>0}function O(e,t,r={}){return E(e,t,r).buffer}function E(e,t,r={}){let{nullGetter:o="keep",linebreaks:n=true,delimiters:a}=r,i=[],s=[],c=[];try{let l=new g__default.default(e),u=new b__default.default(l,{paragraphLoop:!0,linebreaks:n,nullGetter:m=>{let p=m.value||"";if(o==="error")throw new Error(`Undefined variable: ${p}`);return o==="empty"?(c.push(p),""):(c.push(p),`{${p}}`)},delimiters:a?{start:a.start||"{",end:a.end||"}"}:void 0});return Object.keys(t).forEach(m=>{t[m]!==void 0&&t[m]!==null&&s.push(m);}),u.setData(t),u.render(),{buffer:u.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:s,unreplacedVariables:c,warnings:i}}catch(l){throw x(l)}}function ge(e,t,r={}){let o=O(e,t,r);return new Blob([o],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function be(e){try{let t=new g__default.default(e),o=new b__default.default(t,{paragraphLoop:!0,linebreaks:!0}).getFullText();return $(o)}catch(t){throw x(t)}}function L(e){let t=[],r=[];try{let o=new g__default.default(e),a=new b__default.default(o,{paragraphLoop:!0,linebreaks:!0}).getFullText();r=$(a);let i=K(a);for(let s of i)t.push({message:`Unclosed tag: ${s}`,variable:s,type:"parse"});return {valid:t.length===0,errors:t,tags:r}}catch(o){return t.push(x(o)),{valid:false,errors:t,tags:r}}}function xe(e,t){return e.filter(r=>!(r in t)||t[r]===void 0||t[r]===null)}function he(e,t){try{let r=new g__default.default(e),o=new b__default.default(r,{paragraphLoop:!0,linebreaks:!0,nullGetter:n=>`[${n.value||""}]`});return o.setData(t),o.render(),o.getFullText()}catch(r){throw x(r)}}function $(e){let t=[],r=/\{([^{}]+)\}/g,o;for(;(o=r.exec(e))!==null;){let n=o[1].trim();n&&!t.includes(n)&&t.push(n);}return t.sort()}function K(e){let t=[],r=0,o="";for(let n of e)n==="{"?(r++,o=""):n==="}"?(r--,r<0&&(r=0)):r>0&&(o+=n);return r>0&&o.trim()&&t.push(o.trim()),t}function Q(e){return "properties"in e&&typeof e.properties=="object"}function x(e){if(e instanceof Error){if(Q(e)&&e.properties?.errors){let t=e.properties.errors[0];return {message:t?.message||"Template processing error",variable:t?.properties?.tag,type:"render",originalError:e}}if(e.message.includes("undefined")){let t=e.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:e.message,variable:t?t[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 ye(e,t,r={}){let{linebreaks:o=true,delimiters:n}=r;try{let a=new g__default.default(e),i=new b__default.default(a,{paragraphLoop:!0,linebreaks:o,delimiters:n?{start:n.start||"{",end:n.end||"}"}:void 0});return i.setData(t),i.render(),i.getZip().generate({type:"arraybuffer",compression:"DEFLATE"})}catch(a){throw x(a)}}function Te(e={}){return (t,r)=>O(t,r,e)}var h={type:"string",description:"Document ID from a previous docx_load call"},Y={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"]},N={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
1
+ 'use strict';var chunkCWWSDDRF_cjs=require('./chunk-CWWSDDRF.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs'),g=require('pizzip'),b=require('docxtemplater');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);var b__default=/*#__PURE__*/_interopDefault(b);function J(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function v(e,t){let r=t,{position:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.paragraphIndex} out of bounds`);let c=s[o.paragraphIndex],l=`{{${n}}}`;return k(c,o.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function w(e,t){let r=t,{range:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.start.paragraphIndex!==o.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(o.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.start.paragraphIndex} out of bounds`);let c=s[o.start.paragraphIndex];Z(c,o.start.offset,o.end.offset);let l=`{{${n}}}`;return k(c,o.start.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function k(e,t,r){let o=0,n=false;for(let a=0;a<e.content.length;a++){let i=e.content[a];if(i.type==="run"){let s=T(i),c=o,l=o+s.length;if(!n&&t>=c&&t<=l){let u=t-c,y=s.slice(0,u),m=s.slice(u),p=[];for(let d=0;d<a;d++)p.push(e.content[d]);y&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:y}]}),p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:r}]}),m&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:m}]});for(let d=a+1;d<e.content.length;d++)p.push(e.content[d]);e.content=p,n=true;break}o=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(o+=T(s).length);}n||e.content.push({type:"run",content:[{type:"text",text:r}]});}function Z(e,t,r){let o=[],n=0;for(let a of e.content)if(a.type==="run"){let i=T(a),s=n,c=n+i.length;if(c<=t||s>=r)o.push(a);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>r&&(l+=i.slice(r-s)),l.length>0&&o.push({type:"run",formatting:a.formatting,content:[{type:"text",text:l}]});}n=c;}else o.push(a);e.content=o;}function T(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function U(e){return V(e).variables}function V(e){let t=[],r={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let n=j(e.package.document);n.forEach(a=>{t.push({name:a,location:"body"});}),r.body=Array.from(new Set(n)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((n,a)=>{n.properties.headerReferences&&n.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let n=A(e.package.footnotes);n.forEach(a=>{t.push({name:a,location:"footnote"});}),r.footnotes=Array.from(new Set(n)).sort();}if(e.package?.endnotes){let n=A(e.package.endnotes);n.forEach(a=>{t.push({name:a,location:"endnote"});}),r.endnotes=Array.from(new Set(n)).sort();}e.templateVariables&&e.templateVariables.forEach(n=>{t.some(a=>a.name===n)||t.push({name:n,location:"body"});});let o=new Set;return t.forEach(n=>o.add(n.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:r,occurrences:t}}function j(e){let t=[];if(e.content&&t.push(...I(e.content)),e.sections)for(let r of e.sections)r.content&&t.push(...I(r.content));return t}function I(e){let t=[];for(let r of e)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function R(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="run"?t.push(...f(r)):r.type==="hyperlink"?t.push(...q(r)):r.type==="simpleField"?t.push(...W(r)):r.type==="complexField"&&t.push(...G(r));return t}function f(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="text"&&r.text&&t.push(...B(r.text));return t}function q(e){let t=[];if(!e.children)return t;for(let r of e.children)r.type==="run"&&t.push(...f(r));return t}function W(e){let t=[];if(e.instruction&&t.push(...B(e.instruction)),e.content)for(let r of e.content)r.type==="run"&&t.push(...f(r));return t}function G(e){let t=[];if(e.fieldCode)for(let r of e.fieldCode)r.type==="run"&&t.push(...f(r));if(e.fieldResult)for(let r of e.fieldResult)r.type==="run"&&t.push(...f(r));return t}function M(e){let t=[];if(!e.rows)return t;for(let r of e.rows)if(r.cells)for(let o of r.cells)t.push(...X(o));return t}function X(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function A(e){let t=[];for(let r of e)if(r.content)for(let o of r.content)t.push(...R(o));return t}var S=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,_=/\{(.+?)\}/g;function B(e){if(!e)return [];let t=[],r=new RegExp(S),o;for(;(o=r.exec(e))!==null;)t.push(o[1]);return t}function oe(e){return S.test(e)}function ae(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 ie(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 se(e){return `{${e}}`}function ce(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function le(e,t){return e&&e.replace(_,(r,o)=>{let n=o.trim();return n in t?t[n]:r})}function pe(e,t=""){return e&&e.replace(_,t)}function ue(e){return U(e).length>0}function O(e,t,r={}){return E(e,t,r).buffer}function E(e,t,r={}){let{nullGetter:o="keep",linebreaks:n=true,delimiters:a}=r,i=[],s=[],c=[];try{let l=new g__default.default(e),u=new b__default.default(l,{paragraphLoop:!0,linebreaks:n,nullGetter:m=>{let p=m.value||"";if(o==="error")throw new Error(`Undefined variable: ${p}`);return o==="empty"?(c.push(p),""):(c.push(p),`{${p}}`)},delimiters:a?{start:a.start||"{",end:a.end||"}"}:void 0});return Object.keys(t).forEach(m=>{t[m]!==void 0&&t[m]!==null&&s.push(m);}),u.setData(t),u.render(),{buffer:u.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:s,unreplacedVariables:c,warnings:i}}catch(l){throw x(l)}}function ge(e,t,r={}){let o=O(e,t,r);return new Blob([o],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function be(e){try{let t=new g__default.default(e),o=new b__default.default(t,{paragraphLoop:!0,linebreaks:!0}).getFullText();return $(o)}catch(t){throw x(t)}}function L(e){let t=[],r=[];try{let o=new g__default.default(e),a=new b__default.default(o,{paragraphLoop:!0,linebreaks:!0}).getFullText();r=$(a);let i=K(a);for(let s of i)t.push({message:`Unclosed tag: ${s}`,variable:s,type:"parse"});return {valid:t.length===0,errors:t,tags:r}}catch(o){return t.push(x(o)),{valid:false,errors:t,tags:r}}}function xe(e,t){return e.filter(r=>!(r in t)||t[r]===void 0||t[r]===null)}function he(e,t){try{let r=new g__default.default(e),o=new b__default.default(r,{paragraphLoop:!0,linebreaks:!0,nullGetter:n=>`[${n.value||""}]`});return o.setData(t),o.render(),o.getFullText()}catch(r){throw x(r)}}function $(e){let t=[],r=/\{([^{}]+)\}/g,o;for(;(o=r.exec(e))!==null;){let n=o[1].trim();n&&!t.includes(n)&&t.push(n);}return t.sort()}function K(e){let t=[],r=0,o="";for(let n of e)n==="{"?(r++,o=""):n==="}"?(r--,r<0&&(r=0)):r>0&&(o+=n);return r>0&&o.trim()&&t.push(o.trim()),t}function Q(e){return "properties"in e&&typeof e.properties=="object"}function x(e){if(e instanceof Error){if(Q(e)&&e.properties?.errors){let t=e.properties.errors[0];return {message:t?.message||"Template processing error",variable:t?.properties?.tag,type:"render",originalError:e}}if(e.message.includes("undefined")){let t=e.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:e.message,variable:t?t[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 ye(e,t,r={}){let{linebreaks:o=true,delimiters:n}=r;try{let a=new g__default.default(e),i=new b__default.default(a,{paragraphLoop:!0,linebreaks:o,delimiters:n?{start:n.start||"{",end:n.end||"}"}:void 0});return i.setData(t),i.render(),i.getZip().generate({type:"arraybuffer",compression:"DEFLATE"})}catch(a){throw x(a)}}function Te(e={}){return (t,r)=>O(t,r,e)}var h={type:"string",description:"Document ID from a previous docx_load call"},Y={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"]},N={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
2
2
  Returns variable names without braces, along with their locations (body, headers, footers, etc.).
3
3
  Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:h},required:["documentId"]},handler:async(e,t)=>{let{documentId:r}=e,o=t.session.documents.get(r);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};try{let n=V(o.document);return {content:[{type:"text",text:JSON.stringify({variables:n.variables,count:n.variables.length,totalOccurrences:n.totalOccurrences,byLocation:n.byLocation},null,2)}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${n.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}'}]}},F={name:"docx_insert_variable",description:`Insert a template variable placeholder ({{name}}) at a specific position in the document.
4
4
  The variable can later be substituted with actual values using docx_apply_template.
5
5
  Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:h,position:Y,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(e,t)=>{let{documentId:r,position:o,variableName:n}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(n))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${n}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:i}=await import('./executor-FSMRGT73.cjs'),s=i(a.document,{type:"insertText",position:o,text:`{{${n}}}`});return a.document=s,a.lastModified=Date.now(),s.templateVariables||(s.templateVariables=[]),s.templateVariables.includes(n)||s.templateVariables.push(n),{content:[{type:"text",text:JSON.stringify({success:!0,variable:n,insertedAs:`{{${n}}}`,position:o})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${i.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"}}]}},z={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
6
6
  Replaces all {variable} placeholders with the corresponding values provided.
7
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:h,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(e,t)=>{let{documentId:r,variables:o,keepUnmatchedVariables:n=true}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let i=E(a.buffer,o,{nullGetter:n?"keep":"empty"}),s=await chunkDQHQWQHL_cjs.l(i.buffer);return a.document=s,a.buffer=i.buffer,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:i.replacedVariables,unreplacedVariables:i.unreplacedVariables,warnings:i.warnings})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${i.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"}}}]}},H={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
8
+ Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:h,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(e,t)=>{let{documentId:r,variables:o,keepUnmatchedVariables:n=true}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let i=E(a.buffer,o,{nullGetter:n?"keep":"empty"}),s=await chunkCWWSDDRF_cjs.n(i.buffer);return a.document=s,a.buffer=i.buffer,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:i.replacedVariables,unreplacedVariables:i.unreplacedVariables,warnings:i.warnings})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${i.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"}}}]}},H={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
9
9
  Checks for syntax errors like unclosed braces, invalid tag names, etc.
10
10
  Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:h},required:["documentId"]},handler:async(e,t)=>{let{documentId:r}=e,o=t.session.documents.get(r);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!o.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let n=L(o.buffer);return {content:[{type:"text",text:JSON.stringify({valid:n.valid,tags:n.tags,errors:n.errors.map(a=>({message:a.message,variable:a.variable,type:a.type}))},null,2)}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${n.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},D=[N,F,z,H];var ee={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:v,replaceWithTemplateVariable:w},mcpTools:D,initialize:()=>{try{chunkRTESADL3_cjs.a("docxtemplater"),chunkRTESADL3_cjs.a("pizzip");}catch{console.warn("[docxtemplater-plugin] Warning: docxtemplater or pizzip not installed. Template features may not work. Install with: npm install docxtemplater pizzip");}}};exports.a=U;exports.b=V;exports.c=j;exports.d=R;exports.e=B;exports.f=oe;exports.g=ae;exports.h=ie;exports.i=se;exports.j=ce;exports.k=le;exports.l=pe;exports.m=ue;exports.n=O;exports.o=E;exports.p=ge;exports.q=be;exports.r=L;exports.s=xe;exports.t=he;exports.u=ye;exports.v=Te;exports.w=J;exports.x=ee;
@@ -0,0 +1 @@
1
+ 'use strict';var K="Calibri";var _=null;function W(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function ce(){_=null;}var oe='"Segoe UI", Arial, sans-serif';function U(e){let n=[];e.italic&&n.push("italic"),e.bold&&n.push("bold");let c=e.fontSize??11,r=J(c);n.push(`${r}px`);let a=e.fontFamily??K,t=a.includes(" ")?`"${a}"`:a;return n.push(`${t}, ${oe}`),n.join(" ")}function ae(e){let n=e.fontSize??11,c=e.fontFamily??K,r=J(n),a=r*.8,t=r*.2,s=r*1.15;try{let i=W();i.font=U(e);let o=i.measureText("Hg");typeof o.actualBoundingBoxAscent=="number"&&typeof o.actualBoundingBoxDescent=="number"&&(a=o.actualBoundingBoxAscent,t=o.actualBoundingBoxDescent),typeof o.fontBoundingBoxAscent=="number"&&typeof o.fontBoundingBoxDescent=="number"&&(s=o.fontBoundingBoxAscent+o.fontBoundingBoxDescent);}catch{}return s=Math.max(s,a+t),{fontSize:n,ascent:a,descent:t,lineHeight:s,fontFamily:c}}function se(e,n){if(!e)return 0;let c=W();c.font=U(n);let r=c.measureText(e),a=r.width,t=(r.actualBoundingBoxLeft||0)+(r.actualBoundingBoxRight||0),s=Math.max(a,t);return n.letterSpacing&&e.length>1&&(s+=n.letterSpacing*(e.length-1)),e.length>1&&(s+=(e.length-1)*.15),s}function G(e,n){let c=ae(n);if(!e)return {width:0,charWidths:[],metrics:c};let r=W();r.font=U(n);let a=n.letterSpacing??0,t=[],s=0;for(let i=0;i<e.length;i++){let o=e[i],m=r.measureText(o).width;a&&i<e.length-1&&(m+=a),t.push(m),s+=m;}return {width:s,charWidths:t,metrics:c}}function le(e,n){if(n.length===0||e<=0)return 0;let c=0;for(let r=0;r<n.length;r++){let a=n[r],t=c+a/2;if(e<=t)return r;c+=a;}return n.length}function J(e){return e*96/72}function $(e,n){let c=e.pageGap??0,r=0;for(let a=0;a<n&&a<e.pages.length;a++){let s=e.pages[a].size?.h??e.pageSize.h;r+=s+c;}return r}function Q(e,n){return e.findIndex(c=>c.id===n)}function ie(e,n){let c=0;for(let r=e.fromLine;r<e.toLine&&r<n.lines.length;r++)c+=n.lines[r].lineHeight;return c}function ge(e,n,c,r){let a=[...e.page.fragments].sort((t,s)=>{let i=t.y-s.y;return Math.abs(i)>.5?i:t.x-s.x});for(let t of a){let s=Q(n,t.blockId);if(s===-1)continue;let i=n[s],o=c[s];if(!i||!o)continue;let g;if(t.kind==="paragraph"){if(i.kind!=="paragraph"||o.kind!=="paragraph")continue;g=ie(t,o);}else if(t.kind==="table")g=t.height;else if(t.kind==="image")g=t.height;else continue;let m=r.x>=t.x&&r.x<=t.x+t.width,l=r.y>=t.y&&r.y<=t.y+g;if(m&&l)return {fragment:t,block:i,measure:o,pageIndex:e.pageIndex,localX:r.x-t.x,localY:r.y-t.y}}return null}function fe(e,n,c,r){for(let a of e.page.fragments){if(a.kind!=="table")continue;let t=a,s=r.x>=t.x&&r.x<=t.x+t.width,i=r.y>=t.y&&r.y<=t.y+t.height;if(!s||!i)continue;let o=Q(n,t.blockId);if(o===-1)continue;let g=n[o],m=c[o];if(!g||g.kind!=="table"||!m||m.kind!=="table")continue;let l=g,f=m,p=r.x-t.x,M=r.y-t.y,b=0,d=-1;if(f.rows.length===0||l.rows.length===0)continue;for(let u=t.fromRow;u<t.toRow&&u<f.rows.length;u++){let w=f.rows[u];if(M>=b&&M<b+w.height){d=u;break}b+=w.height;}if(d===-1&&(d=Math.min(t.toRow-1,f.rows.length-1),d<t.fromRow))continue;let h=f.rows[d],T=l.rows[d];if(!h||!T)continue;let x=0,k=-1;if(h.cells.length===0||T.cells.length===0)continue;for(let u=0;u<h.cells.length;u++){let w=h.cells[u];if(p>=x&&p<x+w.width){k=u;break}x+=w.width;}if(k===-1&&(k=h.cells.length-1,k<0))continue;let I=h.cells[k],B=T.cells[k];if(!I||!B)continue;let F=0;for(let u=t.fromRow;u<d;u++)F+=f.rows[u]?.height??0;let y=0;for(let u=0;u<k;u++)y+=h.cells[u]?.width??0;let S,P;if(B.blocks&&B.blocks.length>0){let u=B.blocks[0],w=I.blocks[0];u.kind==="paragraph"&&w?.kind==="paragraph"&&(S=u,P=w);}let R=p-y,H=M-F;return {fragment:t,block:l,measure:f,pageIndex:e.pageIndex,rowIndex:d,colIndex:k,cellBlock:S,cellMeasure:P,cellLocalX:Math.max(0,R),cellLocalY:Math.max(0,H)}}return null}function V(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Z(e,n){return e.findIndex(c=>c.id===n)}function z(e,n){let r=(e.pmStart??0)+1,a=0,t;for(let o=0;o<e.runs.length&&o<=n.toRun;o++){let g=e.runs[o];if(g){if(o<n.fromRun)g.kind==="text"?a+=(g.text??"").length:a+=1;else if(o===n.fromRun){a+=n.fromChar,t=r+a;break}}}t===void 0&&(t=r);let s=0;for(let o=n.fromRun;o<=n.toRun&&o<e.runs.length;o++){let g=e.runs[o];if(g)if(g.kind==="text"){let m=g.text??"",l=o===n.fromRun?n.fromChar:0,f=o===n.toRun?n.toChar:m.length;s+=f-l;}else s+=1;}let i=t+s;return {pmStart:t,pmEnd:i}}function ee(e,n,c,r){let a=[];for(let t=0;t<n.lines.length;t++){let s=n.lines[t],i=z(e,s);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>c&&i.pmStart<r&&a.push({line:s,index:t});}return a}function X(e,n,c){let r=z(e,n);return r.pmStart===void 0?0:Math.max(0,c-r.pmStart)}function A(e,n,c,r){let a=0,t=0;for(let s=n.fromRun;s<=n.toRun&&s<e.runs.length;s++){let i=e.runs[s];if(i){if(i.kind==="tab"){let o=i.width??48;if(t+1>=c)return c<=t?a:a+o;a+=o,t+=1;continue}if(i.kind==="image"){let o=i.width;if(t+1>=c)return c<=t?a:a+o;a+=o,t+=1;continue}if(i.kind==="lineBreak"){if(c<=t)return a;t+=1;continue}if(i.kind==="text"){let o=i.text??"",g=s===n.fromRun,m=s===n.toRun,l=g?n.fromChar:0,f=m?n.toChar:o.length,p=o.slice(l,f);if(t+p.length>=c){let d=c-t,h=V(i),T=G(p.slice(0,d),h);return a+T.width}let M=V(i),b=G(p,M);a+=b.width,t+=p.length;}}}return a}function Y(e,n){let c=0;for(let r=0;r<n&&r<e.lines.length;r++)c+=e.lines[r].lineHeight;return c}function de(e,n,c,r,a){if(r===a)return [];let t=Math.min(r,a),s=Math.max(r,a),i=[];for(let o=0;o<e.pages.length;o++){let g=e.pages[o],m=$(e,o);for(let l of g.fragments){if(l.kind==="paragraph"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="paragraph"||!M||M.kind!=="paragraph")continue;let b=p,d=M,h=l,T=ee(b,d,t,s);for(let{line:x,index:k}of T){if(k<h.fromLine||k>=h.toLine)continue;let I=z(b,x);if(I.pmStart===void 0||I.pmEnd===void 0)continue;let B=Math.max(I.pmStart,t),F=Math.min(I.pmEnd,s);if(B>=F)continue;let y=X(b,x,B),S=X(b,x,F),P=b.attrs?.indent,R=P?.left??0,H=P?.right??0,u=Math.max(0,l.width-R-H),w=A(b,x,y),D=A(b,x,S),C=b.attrs?.alignment??"left",L=0;C==="center"?L=Math.max(0,(u-x.width)/2):C==="right"&&(L=Math.max(0,u-x.width));let v=Y(d,k)-Y(d,h.fromLine),E=l.x+R+L+Math.min(w,D),N=Math.max(1,Math.abs(D-w)),O=l.y+v;i.push({x:E,y:O+m,width:N,height:x.lineHeight,pageIndex:o});}}if(l.kind==="table"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="table"||!M||M.kind!=="table")continue;let b=p,d=M,h=l,T=0;for(let x=h.fromRow;x<h.toRow&&x<b.rows.length;x++){let k=b.rows[x],I=d.rows[x];if(!k||!I)continue;let B=0;for(let F=0;F<k.cells.length;F++){let y=k.cells[F],S=I.cells[F];if(!(!y||!S)){for(let P=0;P<y.blocks.length;P++){let R=y.blocks[P],H=S.blocks[P];if(!R||R.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let u=R,w=H,D=ee(u,w,t,s),C=0;for(let{line:L,index:v}of D){let E=z(u,L);if(E.pmStart===void 0||E.pmEnd===void 0)continue;let N=Math.max(E.pmStart,t),O=Math.min(E.pmEnd,s);if(N>=O)continue;let te=X(u,L,N),ne=X(u,L,O),j=A(u,L,te,S.width),q=A(u,L,ne,S.width),re=Y(w,v);i.push({x:h.x+B+Math.min(j,q),y:h.y+T+C+re+m,width:Math.max(1,Math.abs(q-j)),height:L.lineHeight,pageIndex:o});}C+=w.totalHeight;}B+=S.width;}}T+=I.height;}}if(l.kind==="image"){let f=l.pmStart??0;(l.pmEnd??f+1)>t&&f<s&&i.push({x:l.x,y:l.y+m,width:l.width,height:l.height,pageIndex:o});}}}return i}function xe(e,n,c,r){for(let a=0;a<e.pages.length;a++){let t=e.pages[a],s=$(e,a);for(let i of t.fragments){if(i.kind==="paragraph"){let o=Z(n,i.blockId);if(o===-1)continue;let g=n[o],m=c[o];if(!g||g.kind!=="paragraph"||!m||m.kind!=="paragraph")continue;let l=g,f=m,p=i,M=l.pmStart??0,b=l.pmEnd??M;if(r<M||r>b)continue;for(let d=p.fromLine;d<p.toLine;d++){let h=f.lines[d];if(!h)continue;let T=z(l,h);if(!(T.pmStart===void 0||T.pmEnd===void 0)&&r>=T.pmStart&&r<=T.pmEnd){let x=X(l,h,r),k=l.attrs?.indent,I=k?.left??0,B=k?.right??0,F=Math.max(0,i.width-I-B),y=A(l,h,x),S=l.attrs?.alignment??"left",P=0;S==="center"?P=Math.max(0,(F-h.width)/2):S==="right"&&(P=Math.max(0,F-h.width));let R=Y(f,d)-Y(f,p.fromLine);return {x:i.x+I+P+y,y:i.y+R+s,height:h.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let o=i.pmStart??0,g=i.pmEnd??o+1;if(r>=o&&r<=g){let m=r===o?0:i.width;return {x:i.x+m,y:i.y+s,height:i.height,pageIndex:a}}}}}return null}function be(e){return e.length<=1?false:new Set(e.map(c=>c.pageIndex)).size>1}function ke(e){let n=new Map;for(let c of e){let r=n.get(c.pageIndex)??[];r.push(c),n.set(c.pageIndex,r);}return n}exports.a=ce;exports.b=ae;exports.c=se;exports.d=G;exports.e=le;exports.f=J;exports.g=ge;exports.h=fe;exports.i=de;exports.j=xe;exports.k=be;exports.l=ke;
@@ -1,9 +1,9 @@
1
- import {a,n}from'./chunk-AOL255XD.js';import {d,e as e$1}from'./chunk-2CFVFSUH.js';import {l}from'./chunk-I2C6ENCR.js';import {b,a as a$1}from'./chunk-AQ35GWDV.js';import {e}from'./chunk-3IYNTJO5.js';var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},J={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:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function $(n){if(!n)return 1;let t=parseInt(n,16);return isNaN(t)?1:t/255}function C(n){let t=n.padStart(6,"0").slice(0,6),e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return {r:isNaN(e)?0:e,g:isNaN(r)?0:r,b:isNaN(a)?0:a}}function B(n,t,e){let r=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0");return `${r(n)}${r(t)}${r(e)}`.toUpperCase()}function U(n,t,e){n/=255,t/=255,e/=255;let r=Math.max(n,t,e),a=Math.min(n,t,e),o=(r+a)/2;if(r===a)return {h:0,s:0,l:o};let i=r-a,s=o>.5?i/(2-r-a):i/(r+a),c;switch(r){case n:c=((t-e)/i+(t<e?6:0))/6;break;case t:c=((e-n)/i+2)/6;break;case e:c=((n-t)/i+4)/6;break;default:c=0;}return {h:c*360,s,l:o}}function G(n,t,e){if(n=n/360,t===0){let i=Math.round(e*255);return {r:i,g:i,b:i}}let r=(i,s,c)=>(c<0&&(c+=1),c>1&&(c-=1),c<1/6?i+(s-i)*6*c:c<1/2?s:c<2/3?i+(s-i)*(2/3-c)*6:i),a=e<.5?e*(1+t):e+t-e*t,o=2*e-a;return {r:Math.round(r(o,a,n+1/3)*255),g:Math.round(r(o,a,n)*255),b:Math.round(r(o,a,n-1/3)*255)}}function q(n,t){if(t<=0||t>=1)return t>=1?"FFFFFF":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l+(1-r.l)*t;let a=G(r.h,r.s,r.l);return B(a.r,a.g,a.b)}function X(n,t){if(t<=0||t>=1)return t<=0?"000000":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l*t;let a=G(r.h,r.s,r.l);return B(a.r,a.g,a.b)}function Q(n,t){let e=w[t]??t,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],a=o=>r.includes(o);return n?.colorScheme?a(e)?n.colorScheme[e]??W[e]??"000000":"000000":a(e)?W[e]??"000000":"000000"}function K(n){if(!n)return null;let t=n.toLowerCase();return w[n]??w[t]??null}function g(n,t,e="000000"){if(!n)return `#${e}`;if(n.auto)return `#${e}`;let r;if(n.themeColor){let a=K(n.themeColor);if(a?r=Q(t,a):r=n.rgb??e,n.themeTint){let o=$(n.themeTint);r=q(r,o);}else if(n.themeShade){let o=$(n.themeShade);r=X(r,o);}}else n.rgb?r=n.rgb:r=e;return `#${r.toUpperCase().replace(/^#/,"")}`}function Bt(n){if(!n||n==="none")return "";let t=J[n];return t?`#${t}`:""}function Et(n,t){return n?n.auto?"transparent":g(n,t):""}function vt(n,t){if(!n)return false;if(n.auto)return true;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3<20}function Ot(n,t){if(!n)return false;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3>235}function Nt(n,t){if(!n)return "#000000";let r=g(n,t).replace(/^#/,""),a=C(r);return (.299*a.r+.587*a.g+.114*a.b)/255>.5?"#000000":"#FFFFFF"}function Vt(n){if(!n)return;let t=n.trim();if(t.toLowerCase()==="auto")return {auto:true};let e=K(t);if(e)return {themeColor:e};let r=t.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(o=>o+o).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Lt(n,t,e){let r={themeColor:n};return t!==void 0&&t>0&&t<1&&(r.themeTint=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),e!==void 0&&e>0&&e<1&&(r.themeShade=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),r}function Mt(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function jt(n,t,e){let a=g(n,t).replace(/^#/,""),o=1-e/100;return `#${X(a,o)}`}function zt(n,t,e){let a=g(n,t).replace(/^#/,""),o=e/100;return `#${q(a,o)}`}function Wt(n,t,e,r){let a=g(n,r).replace(/^#/,""),o=g(t,r).replace(/^#/,""),i=C(a),s=C(o),c={r:Math.round(i.r*(1-e)+s.r*e),g:Math.round(i.g*(1-e)+s.g*e),b:Math.round(i.b*(1-e)+s.b*e)};return `#${B(c.r,c.g,c.b)}`}function $t(n,t,e){if(!n&&!t)return true;if(!n||!t)return false;let r=g(n,e).toUpperCase(),a=g(t,e).toUpperCase();return r===a}function Gt(n){return n/1440*96}function qt(n){return n/96*1440}function Xt(n){return n/914400*96}function Kt(n){return n/96*914400}function Yt(n){return n/914400*1440}function Jt(n){return n/1440*914400}function Qt(n){return n/72*96}function Zt(n){return n/144*96}function te(n){return n/2}function ee(n){return n/576*96}function Z(n,t=2){let e=Math.pow(10,t);return Math.round(n*e)/e}function ne(n){return `${Z(n)}px`}var A=class n$1{constructor(t){e(this,"_document");e(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 l(t);return new n$1(e)}static fromDocument(t){return new n$1(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 r of e.content)r.type==="paragraph"&&this._extractParagraphSegments(r,t);return t}getVariables(){return a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.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,r=e.content.filter(i=>i.type==="paragraph"),a=r.map((i,s)=>{let c=this._getParagraphText(i),u=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:u,isHeading:u?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(u),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),o=(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:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,r={}){let a={type:"insertText",position:t,text:e,formatting:r.formatting};return this._executeCommand(a)}replaceRange(t,e,r={}){let a={type:"replaceText",range:t,text:e,formatting:r.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let r={type:"formatText",range:t,formatting:e};return this._executeCommand(r)}applyStyle(t,e){let r={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(r)}applyParagraphFormatting(t,e){let r={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(r)}insertTable(t,e,r,a={}){let o={type:"insertTable",position:t,rows:e,columns:r,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,r={}){let a={type:"insertImage",position:t,src:e,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(a)}insertHyperlink(t,e,r={}){let a={type:"insertHyperlink",range:t,url:e,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(a)}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 r={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(r)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,r]of Object.entries(t))this._pendingVariables[e]=r;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 r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let a=n(r,e),o=await l(a),i=new n$1(o);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){let e=b(this._document,t);return new n$1(e)}_executeCommand(t){let e=a$1(this._document,t),r=new n$1(e);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(t){let e=[];for(let r of t.content)r.type==="paragraph"?e.push(this._getParagraphText(r)):r.type==="table"&&e.push(this._getTableText(r));return e.join(`
2
- `)}_getParagraphText(t){let e=[];for(let r of t.content)r.type==="run"?e.push(this._getRunText(r)):r.type==="hyperlink"&&e.push(this._getHyperlinkText(r));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let r of t.children)r.type==="run"&&e.push(this._getRunText(r));return e.join("")}_getTableText(t){let e=[];for(let r of t.rows)for(let a of r.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let r of t.content)if(r.type==="run"){let a=this._getRunText(r);a&&e.push({text:a,formatting:r.formatting});}else if(r.type==="hyperlink"){let a=r.href||"";for(let o of r.children)if(o.type==="run"){let i=this._getRunText(o);i&&e.push({text:i,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_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 r of e.content)if(r.type==="run"){for(let a of r.content)if(a.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 r of e.content)if(r.type==="hyperlink")return true}return false}};async function ue(n){return A.fromBuffer(n)}function le(n){return A.fromDocument(n)}function tt(n,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:r=50}=t,a$1=n.package.document,o=a$1.content.filter(y=>y.type==="paragraph"),i=et(o,e,r),s=a(n),c=nt(n),u=rt(a$1),l=at(a$1),x=ot(a$1),d=a$1.content.some(y=>y.type==="table"),b=ct(a$1),p=ut(a$1);return {paragraphCount:o.length,wordCount:l,characterCount:x,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:u,hasTables:d,hasImages:b,hasHyperlinks:p}}function de(n,t,e={}){let{contextChars:r=200,includeSuggestions:a=true}=e,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=m(s),u="";if(t.start.paragraphIndex===t.end.paragraphIndex)u=c.slice(t.start.offset,t.end.offset);else {let f=[];for(let P=t.start.paragraphIndex;P<=t.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===t.start.paragraphIndex?f.push(R.slice(t.start.offset)):P===t.end.paragraphIndex?f.push(R.slice(0,t.end.offset)):f.push(R);}u=f.join(`
3
- `);}let l=mt(i,t.start.paragraphIndex,t.start.offset,r),x=gt(i,t.end.paragraphIndex,t.end.offset,r),d=dt(s,t.start.offset),b=s.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:E(c)},y=false,F=ft(s,t.start.offset),_=a?ht(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function Y(n){let t=tt(n,{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 r=t.outline.filter(a=>a.isHeading);if(r.length>0){e.push(`
4
- Headings:`);for(let a of r.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}r.length>5&&e.push(` ... and ${r.length-5} more headings`);}return e.join(" ")}function et(n,t,e){let r=[];for(let a=0;a<Math.min(n.length,e);a++){let o=n[a],i=m(o),s=o.formatting?.styleId;r.push({index:a,preview:i.slice(0,t),style:s,isHeading:lt(s),headingLevel:pt(s),isListItem:!!o.listRendering,isEmpty:i.trim().length===0});}return r}function nt(n){let t=n.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function rt(n){return n.sections?n.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 at(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=E(r);}else e.type==="table"&&(t+=it(e));return t}function E(n){return n.split(/\s+/).filter(e=>e.length>0).length}function ot(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=r.length;}else e.type==="table"&&(t+=st(e));return t}function it(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=E(o);}return t}function st(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=o.length;}return t}function m(n){let t=[];for(let e of n.content)e.type==="run"?t.push(S(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function S(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(S(e));return t.join("")}function ct(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let r of e.content)if(r.type==="drawing")return true}}return false}function ut(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function lt(n){return n?n.toLowerCase().includes("heading"):false}function pt(n){if(!n)return;let t=n.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function mt(n,t,e,r){let a=[],o=0,i=n[t];if(i){let u=m(i).slice(0,e);a.unshift(u),o+=u.length;}for(let c=t-1;c>=0&&o<r;c--){let u=n[c];if(!u)continue;let l=m(u);a.unshift(l),o+=l.length;}let s=a.join(`
1
+ import {a,n as n$1}from'./chunk-B2GPMRIP.js';import {d,e as e$1}from'./chunk-AZFSFU4G.js';import {n}from'./chunk-CEBRVCHO.js';import {b,a as a$1}from'./chunk-AQ35GWDV.js';import {e}from'./chunk-3IYNTJO5.js';var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},J={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:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function $(n){if(!n)return 1;let t=parseInt(n,16);return isNaN(t)?1:t/255}function C(n){let t=n.padStart(6,"0").slice(0,6),e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return {r:isNaN(e)?0:e,g:isNaN(r)?0:r,b:isNaN(a)?0:a}}function E(n,t,e){let r=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0");return `${r(n)}${r(t)}${r(e)}`.toUpperCase()}function U(n,t,e){n/=255,t/=255,e/=255;let r=Math.max(n,t,e),a=Math.min(n,t,e),o=(r+a)/2;if(r===a)return {h:0,s:0,l:o};let i=r-a,s=o>.5?i/(2-r-a):i/(r+a),c;switch(r){case n:c=((t-e)/i+(t<e?6:0))/6;break;case t:c=((e-n)/i+2)/6;break;case e:c=((n-t)/i+4)/6;break;default:c=0;}return {h:c*360,s,l:o}}function G(n,t,e){if(n=n/360,t===0){let i=Math.round(e*255);return {r:i,g:i,b:i}}let r=(i,s,c)=>(c<0&&(c+=1),c>1&&(c-=1),c<1/6?i+(s-i)*6*c:c<1/2?s:c<2/3?i+(s-i)*(2/3-c)*6:i),a=e<.5?e*(1+t):e+t-e*t,o=2*e-a;return {r:Math.round(r(o,a,n+1/3)*255),g:Math.round(r(o,a,n)*255),b:Math.round(r(o,a,n-1/3)*255)}}function q(n,t){if(t<=0||t>=1)return t>=1?"FFFFFF":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l+(1-r.l)*t;let a=G(r.h,r.s,r.l);return E(a.r,a.g,a.b)}function X(n,t){if(t<=0||t>=1)return t<=0?"000000":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l*t;let a=G(r.h,r.s,r.l);return E(a.r,a.g,a.b)}function Q(n,t){let e=w[t]??t,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],a=o=>r.includes(o);return n?.colorScheme?a(e)?n.colorScheme[e]??W[e]??"000000":"000000":a(e)?W[e]??"000000":"000000"}function K(n){if(!n)return null;let t=n.toLowerCase();return w[n]??w[t]??null}function g(n,t,e="000000"){if(!n)return `#${e}`;if(n.auto)return `#${e}`;let r;if(n.themeColor){let a=K(n.themeColor);if(a?r=Q(t,a):r=n.rgb??e,n.themeTint){let o=$(n.themeTint);r=q(r,o);}else if(n.themeShade){let o=$(n.themeShade);r=X(r,o);}}else n.rgb?r=n.rgb:r=e;return `#${r.toUpperCase().replace(/^#/,"")}`}function Et(n){if(!n||n==="none")return "";let t=J[n];return t?`#${t}`:""}function Bt(n,t){return n?n.auto?"transparent":g(n,t):""}function vt(n,t){if(!n)return false;if(n.auto)return true;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3<20}function Ot(n,t){if(!n)return false;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3>235}function Nt(n,t){if(!n)return "#000000";let r=g(n,t).replace(/^#/,""),a=C(r);return (.299*a.r+.587*a.g+.114*a.b)/255>.5?"#000000":"#FFFFFF"}function Vt(n){if(!n)return;let t=n.trim();if(t.toLowerCase()==="auto")return {auto:true};let e=K(t);if(e)return {themeColor:e};let r=t.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(o=>o+o).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Lt(n,t,e){let r={themeColor:n};return t!==void 0&&t>0&&t<1&&(r.themeTint=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),e!==void 0&&e>0&&e<1&&(r.themeShade=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),r}function Mt(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function jt(n,t,e){let a=g(n,t).replace(/^#/,""),o=1-e/100;return `#${X(a,o)}`}function zt(n,t,e){let a=g(n,t).replace(/^#/,""),o=e/100;return `#${q(a,o)}`}function Wt(n,t,e,r){let a=g(n,r).replace(/^#/,""),o=g(t,r).replace(/^#/,""),i=C(a),s=C(o),c={r:Math.round(i.r*(1-e)+s.r*e),g:Math.round(i.g*(1-e)+s.g*e),b:Math.round(i.b*(1-e)+s.b*e)};return `#${E(c.r,c.g,c.b)}`}function $t(n,t,e){if(!n&&!t)return true;if(!n||!t)return false;let r=g(n,e).toUpperCase(),a=g(t,e).toUpperCase();return r===a}function Gt(n){return n/1440*96}function qt(n){return n/96*1440}function Xt(n){return n/914400*96}function Kt(n){return n/96*914400}function Yt(n){return n/914400*1440}function Jt(n){return n/1440*914400}function Qt(n){return n/72*96}function Zt(n){return n/144*96}function te(n){return n/2}function ee(n){return n/576*96}function Z(n,t=2){let e=Math.pow(10,t);return Math.round(n*e)/e}function ne(n){return `${Z(n)}px`}var S=class n$2{constructor(t){e(this,"_document");e(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 n(t);return new n$2(e)}static fromDocument(t){return new n$2(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 r of e.content)r.type==="paragraph"&&this._extractParagraphSegments(r,t);return t}getVariables(){return a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.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,r=e.content.filter(i=>i.type==="paragraph"),a=r.map((i,s)=>{let c=this._getParagraphText(i),u=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:u,isHeading:u?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(u),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),o=(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:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,r={}){let a={type:"insertText",position:t,text:e,formatting:r.formatting};return this._executeCommand(a)}replaceRange(t,e,r={}){let a={type:"replaceText",range:t,text:e,formatting:r.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let r={type:"formatText",range:t,formatting:e};return this._executeCommand(r)}applyStyle(t,e){let r={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(r)}applyParagraphFormatting(t,e){let r={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(r)}insertTable(t,e,r,a={}){let o={type:"insertTable",position:t,rows:e,columns:r,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,r={}){let a={type:"insertImage",position:t,src:e,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(a)}insertHyperlink(t,e,r={}){let a={type:"insertHyperlink",range:t,url:e,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(a)}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 r={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(r)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,r]of Object.entries(t))this._pendingVariables[e]=r;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 r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let a=n$1(r,e),o=await n(a),i=new n$2(o);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){let e=b(this._document,t);return new n$2(e)}_executeCommand(t){let e=a$1(this._document,t),r=new n$2(e);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(t){let e=[];for(let r of t.content)r.type==="paragraph"?e.push(this._getParagraphText(r)):r.type==="table"&&e.push(this._getTableText(r));return e.join(`
2
+ `)}_getParagraphText(t){let e=[];for(let r of t.content)r.type==="run"?e.push(this._getRunText(r)):r.type==="hyperlink"&&e.push(this._getHyperlinkText(r));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let r of t.children)r.type==="run"&&e.push(this._getRunText(r));return e.join("")}_getTableText(t){let e=[];for(let r of t.rows)for(let a of r.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let r of t.content)if(r.type==="run"){let a=this._getRunText(r);a&&e.push({text:a,formatting:r.formatting});}else if(r.type==="hyperlink"){let a=r.href||"";for(let o of r.children)if(o.type==="run"){let i=this._getRunText(o);i&&e.push({text:i,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_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 r of e.content)if(r.type==="run"){for(let a of r.content)if(a.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 r of e.content)if(r.type==="hyperlink")return true}return false}};async function ue(n){return S.fromBuffer(n)}function le(n){return S.fromDocument(n)}function tt(n,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:r=50}=t,a$1=n.package.document,o=a$1.content.filter(y=>y.type==="paragraph"),i=et(o,e,r),s=a(n),c=nt(n),u=rt(a$1),l=at(a$1),x=ot(a$1),d=a$1.content.some(y=>y.type==="table"),b=ct(a$1),p=ut(a$1);return {paragraphCount:o.length,wordCount:l,characterCount:x,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:u,hasTables:d,hasImages:b,hasHyperlinks:p}}function de(n,t,e={}){let{contextChars:r=200,includeSuggestions:a=true}=e,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=m(s),u="";if(t.start.paragraphIndex===t.end.paragraphIndex)u=c.slice(t.start.offset,t.end.offset);else {let f=[];for(let P=t.start.paragraphIndex;P<=t.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===t.start.paragraphIndex?f.push(R.slice(t.start.offset)):P===t.end.paragraphIndex?f.push(R.slice(0,t.end.offset)):f.push(R);}u=f.join(`
3
+ `);}let l=mt(i,t.start.paragraphIndex,t.start.offset,r),x=gt(i,t.end.paragraphIndex,t.end.offset,r),d=dt(s,t.start.offset),b=s.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:B(c)},y=false,F=ft(s,t.start.offset),_=a?ht(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function Y(n){let t=tt(n,{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 r=t.outline.filter(a=>a.isHeading);if(r.length>0){e.push(`
4
+ Headings:`);for(let a of r.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}r.length>5&&e.push(` ... and ${r.length-5} more headings`);}return e.join(" ")}function et(n,t,e){let r=[];for(let a=0;a<Math.min(n.length,e);a++){let o=n[a],i=m(o),s=o.formatting?.styleId;r.push({index:a,preview:i.slice(0,t),style:s,isHeading:lt(s),headingLevel:pt(s),isListItem:!!o.listRendering,isEmpty:i.trim().length===0});}return r}function nt(n){let t=n.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function rt(n){return n.sections?n.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 at(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=B(r);}else e.type==="table"&&(t+=it(e));return t}function B(n){return n.split(/\s+/).filter(e=>e.length>0).length}function ot(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=r.length;}else e.type==="table"&&(t+=st(e));return t}function it(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=B(o);}return t}function st(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=o.length;}return t}function m(n){let t=[];for(let e of n.content)e.type==="run"?t.push(A(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function A(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(A(e));return t.join("")}function ct(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let r of e.content)if(r.type==="drawing")return true}}return false}function ut(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function lt(n){return n?n.toLowerCase().includes("heading"):false}function pt(n){if(!n)return;let t=n.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function mt(n,t,e,r){let a=[],o=0,i=n[t];if(i){let u=m(i).slice(0,e);a.unshift(u),o+=u.length;}for(let c=t-1;c>=0&&o<r;c--){let u=n[c];if(!u)continue;let l=m(u);a.unshift(l),o+=l.length;}let s=a.join(`
5
5
  `);return s.length>r?"..."+s.slice(-r):s}function gt(n,t,e,r){let a=[],o=0,i=n[t];if(i){let u=m(i).slice(e);a.push(u),o+=u.length;}for(let c=t+1;c<n.length&&o<r;c++){let u=n[c];if(!u)continue;let l=m(u);a.push(l),o+=l.length;}let s=a.join(`
6
- `);return s.length>r?s.slice(0,r)+"...":s}function dt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=S(r),o=e,i=e+a.length;if(t>=o&&t<i)return r.formatting||{};e=i;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i){for(let s of r.children)if(s.type==="run")return s.formatting||{}}e=i;}return {}}function ft(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=S(r);e+=a.length;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function ht(n,t,e){let r=[];return n.length>0&&(r.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),n.length>200&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),n.length<50&&n.split(/\s+/).length<10&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),r.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),r.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),r.sort((a,o)=>(o.priority||0)-(a.priority||0)),r}function xt(n,t,e={}){let{contextCharsBefore:r=200,contextCharsAfter:a=200,includeSuggestions:o=true}=e,i=n.package.document,s=i.content.filter(f=>f.type==="paragraph");if(t.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=s[t.start.paragraphIndex],u=bt(s,t),l=yt(s,t.start,r),x=Ct(s,t.end,a),d=Pt(c,t.start.offset),b=c.formatting||{},p={index:t.start.paragraphIndex,fullText:h(c),style:c.formatting?.styleId,wordCount:O(h(c))},y=Tt(i,t.start),F=At(c,t.start.offset),_=o?St(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function xe(n,t,e={}){let r=xt(n,t,e),{includeDocumentSummary:a=true}=e,i=n.package.document.content.filter(p=>p.type==="paragraph"),s=O(r.selectedText),c=r.selectedText.length,u=t.start.paragraphIndex!==t.end.paragraphIndex,l=[];for(let p=t.start.paragraphIndex;p<=t.end.paragraphIndex;p++)l.push(p);let x=kt(i,t),d=a?Y(n):void 0,b=Ft(r.selectedText);return {...r,documentSummary:d,wordCount:s,characterCount:c,isMultiParagraph:u,paragraphIndices:l,detectedLanguage:b,contentType:x}}function be(n,t){let r=n.package.document.content.filter(s=>s.type==="paragraph"),a=[];for(let s=t.start.paragraphIndex;s<=t.end.paragraphIndex;s++){let c=r[s];if(!c)continue;let u=s===t.start.paragraphIndex?t.start.offset:0,l=s===t.end.paragraphIndex?t.end.offset:1/0;It(c,u,l,a);}let o=a.length<=1||a.every(s=>_t(s,a[0]));return {predominant:a.length>0?a[0]:{},isConsistent:o,allFormatting:a}}function bt(n,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let r=n[t.start.paragraphIndex];return r?h(r).slice(t.start.offset,t.end.offset):""}let e=[];for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];if(!a)continue;let o=h(a);r===t.start.paragraphIndex?e.push(o.slice(t.start.offset)):r===t.end.paragraphIndex?e.push(o.slice(0,t.end.offset)):e.push(o);}return e.join(`
6
+ `);return s.length>r?s.slice(0,r)+"...":s}function dt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=A(r),o=e,i=e+a.length;if(t>=o&&t<i)return r.formatting||{};e=i;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i){for(let s of r.children)if(s.type==="run")return s.formatting||{}}e=i;}return {}}function ft(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=A(r);e+=a.length;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function ht(n,t,e){let r=[];return n.length>0&&(r.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),n.length>200&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),n.length<50&&n.split(/\s+/).length<10&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),r.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),r.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),r.sort((a,o)=>(o.priority||0)-(a.priority||0)),r}function xt(n,t,e={}){let{contextCharsBefore:r=200,contextCharsAfter:a=200,includeSuggestions:o=true}=e,i=n.package.document,s=i.content.filter(f=>f.type==="paragraph");if(t.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=s[t.start.paragraphIndex],u=bt(s,t),l=yt(s,t.start,r),x=Ct(s,t.end,a),d=Pt(c,t.start.offset),b=c.formatting||{},p={index:t.start.paragraphIndex,fullText:h(c),style:c.formatting?.styleId,wordCount:O(h(c))},y=Tt(i,t.start),F=St(c,t.start.offset),_=o?At(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function xe(n,t,e={}){let r=xt(n,t,e),{includeDocumentSummary:a=true}=e,i=n.package.document.content.filter(p=>p.type==="paragraph"),s=O(r.selectedText),c=r.selectedText.length,u=t.start.paragraphIndex!==t.end.paragraphIndex,l=[];for(let p=t.start.paragraphIndex;p<=t.end.paragraphIndex;p++)l.push(p);let x=kt(i,t),d=a?Y(n):void 0,b=Ft(r.selectedText);return {...r,documentSummary:d,wordCount:s,characterCount:c,isMultiParagraph:u,paragraphIndices:l,detectedLanguage:b,contentType:x}}function be(n,t){let r=n.package.document.content.filter(s=>s.type==="paragraph"),a=[];for(let s=t.start.paragraphIndex;s<=t.end.paragraphIndex;s++){let c=r[s];if(!c)continue;let u=s===t.start.paragraphIndex?t.start.offset:0,l=s===t.end.paragraphIndex?t.end.offset:1/0;It(c,u,l,a);}let o=a.length<=1||a.every(s=>_t(s,a[0]));return {predominant:a.length>0?a[0]:{},isConsistent:o,allFormatting:a}}function bt(n,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let r=n[t.start.paragraphIndex];return r?h(r).slice(t.start.offset,t.end.offset):""}let e=[];for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];if(!a)continue;let o=h(a);r===t.start.paragraphIndex?e.push(o.slice(t.start.offset)):r===t.end.paragraphIndex?e.push(o.slice(0,t.end.offset)):e.push(o);}return e.join(`
7
7
  `)}function yt(n,t,e){let r=[],a=0,o=n[t.paragraphIndex];if(o){let c=h(o).slice(0,t.offset);r.unshift(c),a+=c.length;}for(let s=t.paragraphIndex-1;s>=0&&a<e;s--){let c=n[s];if(!c)continue;let u=h(c);r.unshift(u),a+=u.length;}let i=r.join(`
8
8
  `);return i.length>e?"..."+i.slice(-e):i}function Ct(n,t,e){let r=[],a=0,o=n[t.paragraphIndex];if(o){let c=h(o).slice(t.offset);r.push(c),a+=c.length;}for(let s=t.paragraphIndex+1;s<n.length&&a<e;s++){let c=n[s];if(!c)continue;let u=h(c);r.push(u),a+=u.length;}let i=r.join(`
9
- `);return i.length>e?i.slice(0,e)+"...":i}function Pt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r),o=e+a.length;if(t>=e&&t<o)return r.formatting||{};e=o;}else if(r.type==="hyperlink"){let a=k(r),o=e+a.length;if(t>=e&&t<o){for(let i of r.children)if(i.type==="run")return i.formatting||{}}e=o;}return {}}function It(n,t,e,r){let a=0;for(let o of n.content)if(o.type==="run"){let i=I(o),s=a,c=a+i.length;c>t&&s<e&&o.formatting&&r.push({...o.formatting}),a=c;}else if(o.type==="hyperlink"){let i=k(o),s=a,c=a+i.length;if(c>t&&s<e)for(let u of o.children)u.type==="run"&&u.formatting&&r.push({...u.formatting});a=c;}}function Tt(n,t){return false}function At(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r);e+=a.length;}else if(r.type==="hyperlink"){let a=k(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function St(n,t,e){let r=[];if(!n||n.trim().length===0)return r;r.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 a=O(n);return a>50&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),a<20&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),r.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}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),r.sort((o,i)=>(i.priority||0)-(o.priority||0)),r}function kt(n,t){let e=new Set;for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];a&&(a.listRendering?e.add("list"):a.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 Ft(n){return /[а-яА-ЯёЁ]/.test(n)?"ru":/[一-龯]/.test(n)?"zh":/[ひらがなカタカナ]/.test(n)||/[\u3040-\u309F\u30A0-\u30FF]/.test(n)?"ja":/[가-힣]/.test(n)?"ko":/[àâäéèêëïîôùûüç]/i.test(n)?"fr":/[äöüß]/i.test(n)?"de":/[áéíóúñ]/i.test(n)?"es":"en"}function h(n){let t=[];for(let e of n.content)e.type==="run"?t.push(I(e)):e.type==="hyperlink"&&t.push(k(e));return t.join("")}function I(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function k(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(I(e));return t.join("")}function O(n){return n.split(/\s+/).filter(t=>t.length>0).length}function _t(n,t){let e=Object.keys(n),r=Object.keys(t);return e.length!==r.length?false:e.every(a=>{let o=n[a],i=t[a];return o===i})}function Rt(){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 Ht(){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 Dt(n={}){let t=Ht();n.pageWidth!==void 0&&(t.pageWidth=n.pageWidth),n.pageHeight!==void 0&&(t.pageHeight=n.pageHeight),n.orientation!==void 0&&(t.orientation=n.orientation),n.marginTop!==void 0&&(t.marginTop=n.marginTop),n.marginBottom!==void 0&&(t.marginBottom=n.marginBottom),n.marginLeft!==void 0&&(t.marginLeft=n.marginLeft),n.marginRight!==void 0&&(t.marginRight=n.marginRight);let e={type:"text",text:n.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:n.initialText?[e]:[],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:Rt()}},templateVariables:[],warnings:[]}}function Ce(n,t={}){return Dt({...t,initialText:n})}function Ie(n){return {start:n,end:n,collapsed:true}}function Te(n,t){return {start:n,end:t,collapsed:n.paragraphIndex===t.paragraphIndex&&n.offset===t.offset}}function Ae(n,t){return !(n.paragraphIndex<t.start.paragraphIndex||n.paragraphIndex===t.start.paragraphIndex&&n.offset<t.start.offset||n.paragraphIndex>t.end.paragraphIndex||n.paragraphIndex===t.end.paragraphIndex&&n.offset>t.end.offset)}function Se(n,t){return n.paragraphIndex<t.paragraphIndex?-1:n.paragraphIndex>t.paragraphIndex?1:n.offset<t.offset?-1:n.offset>t.offset?1:0}function ke(n){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"}[n]}function Fe(n){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"}[n]}var _e=["askAI","rewrite","expand","summarize","translate","explain"];function Re(n){return {...n,id:wt()}}function wt(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{le as A,tt as B,de as C,Y as D,xt as E,xe as F,be as G,Dt as H,Ce as I,Ie as J,Te as K,Ae as L,Se as M,ke as N,Fe as O,_e as P,Re as Q,g as a,Bt as b,Et as c,vt as d,Ot as e,Nt as f,Vt as g,Lt as h,Mt as i,jt as j,zt as k,Wt as l,$t as m,Gt as n,qt as o,Xt as p,Kt as q,Yt as r,Jt as s,Qt as t,Zt as u,te as v,ee as w,ne as x,A as y,ue as z};
9
+ `);return i.length>e?i.slice(0,e)+"...":i}function Pt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r),o=e+a.length;if(t>=e&&t<o)return r.formatting||{};e=o;}else if(r.type==="hyperlink"){let a=k(r),o=e+a.length;if(t>=e&&t<o){for(let i of r.children)if(i.type==="run")return i.formatting||{}}e=o;}return {}}function It(n,t,e,r){let a=0;for(let o of n.content)if(o.type==="run"){let i=I(o),s=a,c=a+i.length;c>t&&s<e&&o.formatting&&r.push({...o.formatting}),a=c;}else if(o.type==="hyperlink"){let i=k(o),s=a,c=a+i.length;if(c>t&&s<e)for(let u of o.children)u.type==="run"&&u.formatting&&r.push({...u.formatting});a=c;}}function Tt(n,t){return false}function St(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r);e+=a.length;}else if(r.type==="hyperlink"){let a=k(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function At(n,t,e){let r=[];if(!n||n.trim().length===0)return r;r.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 a=O(n);return a>50&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),a<20&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),r.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}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),r.sort((o,i)=>(i.priority||0)-(o.priority||0)),r}function kt(n,t){let e=new Set;for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];a&&(a.listRendering?e.add("list"):a.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 Ft(n){return /[а-яА-ЯёЁ]/.test(n)?"ru":/[一-龯]/.test(n)?"zh":/[ひらがなカタカナ]/.test(n)||/[\u3040-\u309F\u30A0-\u30FF]/.test(n)?"ja":/[가-힣]/.test(n)?"ko":/[àâäéèêëïîôùûüç]/i.test(n)?"fr":/[äöüß]/i.test(n)?"de":/[áéíóúñ]/i.test(n)?"es":"en"}function h(n){let t=[];for(let e of n.content)e.type==="run"?t.push(I(e)):e.type==="hyperlink"&&t.push(k(e));return t.join("")}function I(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function k(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(I(e));return t.join("")}function O(n){return n.split(/\s+/).filter(t=>t.length>0).length}function _t(n,t){let e=Object.keys(n),r=Object.keys(t);return e.length!==r.length?false:e.every(a=>{let o=n[a],i=t[a];return o===i})}function Rt(){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 Ht(){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 Dt(n={}){let t=Ht();n.pageWidth!==void 0&&(t.pageWidth=n.pageWidth),n.pageHeight!==void 0&&(t.pageHeight=n.pageHeight),n.orientation!==void 0&&(t.orientation=n.orientation),n.marginTop!==void 0&&(t.marginTop=n.marginTop),n.marginBottom!==void 0&&(t.marginBottom=n.marginBottom),n.marginLeft!==void 0&&(t.marginLeft=n.marginLeft),n.marginRight!==void 0&&(t.marginRight=n.marginRight);let e={type:"text",text:n.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:n.initialText?[e]:[],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:Rt()}},templateVariables:[],warnings:[]}}function Ce(n,t={}){return Dt({...t,initialText:n})}function Ie(n){return {start:n,end:n,collapsed:true}}function Te(n,t){return {start:n,end:t,collapsed:n.paragraphIndex===t.paragraphIndex&&n.offset===t.offset}}function Se(n,t){return !(n.paragraphIndex<t.start.paragraphIndex||n.paragraphIndex===t.start.paragraphIndex&&n.offset<t.start.offset||n.paragraphIndex>t.end.paragraphIndex||n.paragraphIndex===t.end.paragraphIndex&&n.offset>t.end.offset)}function Ae(n,t){return n.paragraphIndex<t.paragraphIndex?-1:n.paragraphIndex>t.paragraphIndex?1:n.offset<t.offset?-1:n.offset>t.offset?1:0}function ke(n){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"}[n]}function Fe(n){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"}[n]}var _e=["askAI","rewrite","expand","summarize","translate","explain"];function Re(n){return {...n,id:wt()}}function wt(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{le as A,tt as B,de as C,Y as D,xt as E,xe as F,be as G,Dt as H,Ce as I,Ie as J,Te as K,Se as L,Ae as M,ke as N,Fe as O,_e as P,Re as Q,g as a,Et as b,Bt as c,vt as d,Ot as e,Nt as f,Vt as g,Lt as h,Mt as i,jt as j,zt as k,Wt as l,$t as m,Gt as n,qt as o,Xt as p,Kt as q,Yt as r,Jt as s,Qt as t,Zt as u,te as v,ee as w,ne as x,S as y,ue as z};
@@ -0,0 +1 @@
1
+ var K="Calibri";var _=null;function W(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function ce(){_=null;}var oe='"Segoe UI", Arial, sans-serif';function U(e){let n=[];e.italic&&n.push("italic"),e.bold&&n.push("bold");let c=e.fontSize??11,r=J(c);n.push(`${r}px`);let a=e.fontFamily??K,t=a.includes(" ")?`"${a}"`:a;return n.push(`${t}, ${oe}`),n.join(" ")}function ae(e){let n=e.fontSize??11,c=e.fontFamily??K,r=J(n),a=r*.8,t=r*.2,s=r*1.15;try{let i=W();i.font=U(e);let o=i.measureText("Hg");typeof o.actualBoundingBoxAscent=="number"&&typeof o.actualBoundingBoxDescent=="number"&&(a=o.actualBoundingBoxAscent,t=o.actualBoundingBoxDescent),typeof o.fontBoundingBoxAscent=="number"&&typeof o.fontBoundingBoxDescent=="number"&&(s=o.fontBoundingBoxAscent+o.fontBoundingBoxDescent);}catch{}return s=Math.max(s,a+t),{fontSize:n,ascent:a,descent:t,lineHeight:s,fontFamily:c}}function se(e,n){if(!e)return 0;let c=W();c.font=U(n);let r=c.measureText(e),a=r.width,t=(r.actualBoundingBoxLeft||0)+(r.actualBoundingBoxRight||0),s=Math.max(a,t);return n.letterSpacing&&e.length>1&&(s+=n.letterSpacing*(e.length-1)),e.length>1&&(s+=(e.length-1)*.15),s}function G(e,n){let c=ae(n);if(!e)return {width:0,charWidths:[],metrics:c};let r=W();r.font=U(n);let a=n.letterSpacing??0,t=[],s=0;for(let i=0;i<e.length;i++){let o=e[i],m=r.measureText(o).width;a&&i<e.length-1&&(m+=a),t.push(m),s+=m;}return {width:s,charWidths:t,metrics:c}}function le(e,n){if(n.length===0||e<=0)return 0;let c=0;for(let r=0;r<n.length;r++){let a=n[r],t=c+a/2;if(e<=t)return r;c+=a;}return n.length}function J(e){return e*96/72}function $(e,n){let c=e.pageGap??0,r=0;for(let a=0;a<n&&a<e.pages.length;a++){let s=e.pages[a].size?.h??e.pageSize.h;r+=s+c;}return r}function Q(e,n){return e.findIndex(c=>c.id===n)}function ie(e,n){let c=0;for(let r=e.fromLine;r<e.toLine&&r<n.lines.length;r++)c+=n.lines[r].lineHeight;return c}function ge(e,n,c,r){let a=[...e.page.fragments].sort((t,s)=>{let i=t.y-s.y;return Math.abs(i)>.5?i:t.x-s.x});for(let t of a){let s=Q(n,t.blockId);if(s===-1)continue;let i=n[s],o=c[s];if(!i||!o)continue;let g;if(t.kind==="paragraph"){if(i.kind!=="paragraph"||o.kind!=="paragraph")continue;g=ie(t,o);}else if(t.kind==="table")g=t.height;else if(t.kind==="image")g=t.height;else continue;let m=r.x>=t.x&&r.x<=t.x+t.width,l=r.y>=t.y&&r.y<=t.y+g;if(m&&l)return {fragment:t,block:i,measure:o,pageIndex:e.pageIndex,localX:r.x-t.x,localY:r.y-t.y}}return null}function fe(e,n,c,r){for(let a of e.page.fragments){if(a.kind!=="table")continue;let t=a,s=r.x>=t.x&&r.x<=t.x+t.width,i=r.y>=t.y&&r.y<=t.y+t.height;if(!s||!i)continue;let o=Q(n,t.blockId);if(o===-1)continue;let g=n[o],m=c[o];if(!g||g.kind!=="table"||!m||m.kind!=="table")continue;let l=g,f=m,p=r.x-t.x,M=r.y-t.y,b=0,d=-1;if(f.rows.length===0||l.rows.length===0)continue;for(let u=t.fromRow;u<t.toRow&&u<f.rows.length;u++){let w=f.rows[u];if(M>=b&&M<b+w.height){d=u;break}b+=w.height;}if(d===-1&&(d=Math.min(t.toRow-1,f.rows.length-1),d<t.fromRow))continue;let h=f.rows[d],T=l.rows[d];if(!h||!T)continue;let x=0,k=-1;if(h.cells.length===0||T.cells.length===0)continue;for(let u=0;u<h.cells.length;u++){let w=h.cells[u];if(p>=x&&p<x+w.width){k=u;break}x+=w.width;}if(k===-1&&(k=h.cells.length-1,k<0))continue;let I=h.cells[k],B=T.cells[k];if(!I||!B)continue;let F=0;for(let u=t.fromRow;u<d;u++)F+=f.rows[u]?.height??0;let y=0;for(let u=0;u<k;u++)y+=h.cells[u]?.width??0;let S,P;if(B.blocks&&B.blocks.length>0){let u=B.blocks[0],w=I.blocks[0];u.kind==="paragraph"&&w?.kind==="paragraph"&&(S=u,P=w);}let R=p-y,H=M-F;return {fragment:t,block:l,measure:f,pageIndex:e.pageIndex,rowIndex:d,colIndex:k,cellBlock:S,cellMeasure:P,cellLocalX:Math.max(0,R),cellLocalY:Math.max(0,H)}}return null}function V(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Z(e,n){return e.findIndex(c=>c.id===n)}function z(e,n){let r=(e.pmStart??0)+1,a=0,t;for(let o=0;o<e.runs.length&&o<=n.toRun;o++){let g=e.runs[o];if(g){if(o<n.fromRun)g.kind==="text"?a+=(g.text??"").length:a+=1;else if(o===n.fromRun){a+=n.fromChar,t=r+a;break}}}t===void 0&&(t=r);let s=0;for(let o=n.fromRun;o<=n.toRun&&o<e.runs.length;o++){let g=e.runs[o];if(g)if(g.kind==="text"){let m=g.text??"",l=o===n.fromRun?n.fromChar:0,f=o===n.toRun?n.toChar:m.length;s+=f-l;}else s+=1;}let i=t+s;return {pmStart:t,pmEnd:i}}function ee(e,n,c,r){let a=[];for(let t=0;t<n.lines.length;t++){let s=n.lines[t],i=z(e,s);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>c&&i.pmStart<r&&a.push({line:s,index:t});}return a}function X(e,n,c){let r=z(e,n);return r.pmStart===void 0?0:Math.max(0,c-r.pmStart)}function A(e,n,c,r){let a=0,t=0;for(let s=n.fromRun;s<=n.toRun&&s<e.runs.length;s++){let i=e.runs[s];if(i){if(i.kind==="tab"){let o=i.width??48;if(t+1>=c)return c<=t?a:a+o;a+=o,t+=1;continue}if(i.kind==="image"){let o=i.width;if(t+1>=c)return c<=t?a:a+o;a+=o,t+=1;continue}if(i.kind==="lineBreak"){if(c<=t)return a;t+=1;continue}if(i.kind==="text"){let o=i.text??"",g=s===n.fromRun,m=s===n.toRun,l=g?n.fromChar:0,f=m?n.toChar:o.length,p=o.slice(l,f);if(t+p.length>=c){let d=c-t,h=V(i),T=G(p.slice(0,d),h);return a+T.width}let M=V(i),b=G(p,M);a+=b.width,t+=p.length;}}}return a}function Y(e,n){let c=0;for(let r=0;r<n&&r<e.lines.length;r++)c+=e.lines[r].lineHeight;return c}function de(e,n,c,r,a){if(r===a)return [];let t=Math.min(r,a),s=Math.max(r,a),i=[];for(let o=0;o<e.pages.length;o++){let g=e.pages[o],m=$(e,o);for(let l of g.fragments){if(l.kind==="paragraph"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="paragraph"||!M||M.kind!=="paragraph")continue;let b=p,d=M,h=l,T=ee(b,d,t,s);for(let{line:x,index:k}of T){if(k<h.fromLine||k>=h.toLine)continue;let I=z(b,x);if(I.pmStart===void 0||I.pmEnd===void 0)continue;let B=Math.max(I.pmStart,t),F=Math.min(I.pmEnd,s);if(B>=F)continue;let y=X(b,x,B),S=X(b,x,F),P=b.attrs?.indent,R=P?.left??0,H=P?.right??0,u=Math.max(0,l.width-R-H),w=A(b,x,y),D=A(b,x,S),C=b.attrs?.alignment??"left",L=0;C==="center"?L=Math.max(0,(u-x.width)/2):C==="right"&&(L=Math.max(0,u-x.width));let v=Y(d,k)-Y(d,h.fromLine),E=l.x+R+L+Math.min(w,D),N=Math.max(1,Math.abs(D-w)),O=l.y+v;i.push({x:E,y:O+m,width:N,height:x.lineHeight,pageIndex:o});}}if(l.kind==="table"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="table"||!M||M.kind!=="table")continue;let b=p,d=M,h=l,T=0;for(let x=h.fromRow;x<h.toRow&&x<b.rows.length;x++){let k=b.rows[x],I=d.rows[x];if(!k||!I)continue;let B=0;for(let F=0;F<k.cells.length;F++){let y=k.cells[F],S=I.cells[F];if(!(!y||!S)){for(let P=0;P<y.blocks.length;P++){let R=y.blocks[P],H=S.blocks[P];if(!R||R.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let u=R,w=H,D=ee(u,w,t,s),C=0;for(let{line:L,index:v}of D){let E=z(u,L);if(E.pmStart===void 0||E.pmEnd===void 0)continue;let N=Math.max(E.pmStart,t),O=Math.min(E.pmEnd,s);if(N>=O)continue;let te=X(u,L,N),ne=X(u,L,O),j=A(u,L,te,S.width),q=A(u,L,ne,S.width),re=Y(w,v);i.push({x:h.x+B+Math.min(j,q),y:h.y+T+C+re+m,width:Math.max(1,Math.abs(q-j)),height:L.lineHeight,pageIndex:o});}C+=w.totalHeight;}B+=S.width;}}T+=I.height;}}if(l.kind==="image"){let f=l.pmStart??0;(l.pmEnd??f+1)>t&&f<s&&i.push({x:l.x,y:l.y+m,width:l.width,height:l.height,pageIndex:o});}}}return i}function xe(e,n,c,r){for(let a=0;a<e.pages.length;a++){let t=e.pages[a],s=$(e,a);for(let i of t.fragments){if(i.kind==="paragraph"){let o=Z(n,i.blockId);if(o===-1)continue;let g=n[o],m=c[o];if(!g||g.kind!=="paragraph"||!m||m.kind!=="paragraph")continue;let l=g,f=m,p=i,M=l.pmStart??0,b=l.pmEnd??M;if(r<M||r>b)continue;for(let d=p.fromLine;d<p.toLine;d++){let h=f.lines[d];if(!h)continue;let T=z(l,h);if(!(T.pmStart===void 0||T.pmEnd===void 0)&&r>=T.pmStart&&r<=T.pmEnd){let x=X(l,h,r),k=l.attrs?.indent,I=k?.left??0,B=k?.right??0,F=Math.max(0,i.width-I-B),y=A(l,h,x),S=l.attrs?.alignment??"left",P=0;S==="center"?P=Math.max(0,(F-h.width)/2):S==="right"&&(P=Math.max(0,F-h.width));let R=Y(f,d)-Y(f,p.fromLine);return {x:i.x+I+P+y,y:i.y+R+s,height:h.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let o=i.pmStart??0,g=i.pmEnd??o+1;if(r>=o&&r<=g){let m=r===o?0:i.width;return {x:i.x+m,y:i.y+s,height:i.height,pageIndex:a}}}}}return null}function be(e){return e.length<=1?false:new Set(e.map(c=>c.pageIndex)).size>1}function ke(e){let n=new Map;for(let c of e){let r=n.get(c.pageIndex)??[];r.push(c),n.set(c.pageIndex,r);}return n}export{ce as a,ae as b,se as c,G as d,le as e,J as f,ge as g,fe as h,de as i,xe as j,be as k,ke as l};
@@ -0,0 +1,58 @@
1
+ 'use strict';var chunkCWWSDDRF_cjs=require('./chunk-CWWSDDRF.cjs'),R=require('jszip');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var R__default=/*#__PURE__*/_interopDefault(R);function u(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Z(e){if(!e)return "";let t=[];return e.auto?t.push('w:val="auto"'):e.rgb&&t.push(`w:val="${e.rgb}"`),e.themeColor&&t.push(`w:themeColor="${e.themeColor}"`),e.themeTint&&t.push(`w:themeTint="${e.themeTint}"`),e.themeShade&&t.push(`w:themeShade="${e.themeShade}"`),t.length===0?"":`<w:color ${t.join(" ")}/>`}function Y(e){if(!e)return "";let t=[];return e.pattern?t.push(`w:val="${e.pattern}"`):t.push('w:val="clear"'),e.color?.rgb?t.push(`w:color="${e.color.rgb}"`):e.color?.auto&&t.push('w:color="auto"'),e.fill?.rgb?t.push(`w:fill="${e.fill.rgb}"`):e.fill?.auto&&t.push('w:fill="auto"'),e.fill?.themeColor&&t.push(`w:themeFill="${e.fill.themeColor}"`),e.fill?.themeTint&&t.push(`w:themeFillTint="${e.fill.themeTint}"`),e.fill?.themeShade&&t.push(`w:themeFillShade="${e.fill.themeShade}"`),t.length===0?"":`<w:shd ${t.join(" ")}/>`}function C(e){if(!e)return "";let t=[];if(e.styleId&&t.push(`<w:rStyle w:val="${u(e.styleId)}"/>`),e.fontFamily){let i=[];e.fontFamily.ascii&&i.push(`w:ascii="${u(e.fontFamily.ascii)}"`),e.fontFamily.hAnsi&&i.push(`w:hAnsi="${u(e.fontFamily.hAnsi)}"`),e.fontFamily.eastAsia&&i.push(`w:eastAsia="${u(e.fontFamily.eastAsia)}"`),e.fontFamily.cs&&i.push(`w:cs="${u(e.fontFamily.cs)}"`),e.fontFamily.asciiTheme&&i.push(`w:asciiTheme="${e.fontFamily.asciiTheme}"`),e.fontFamily.hAnsiTheme&&i.push(`w:hAnsiTheme="${e.fontFamily.hAnsiTheme}"`),e.fontFamily.eastAsiaTheme&&i.push(`w:eastAsiaTheme="${e.fontFamily.eastAsiaTheme}"`),e.fontFamily.csTheme&&i.push(`w:csTheme="${e.fontFamily.csTheme}"`),i.length>0&&t.push(`<w:rFonts ${i.join(" ")}/>`);}e.bold===true?t.push("<w:b/>"):e.bold===false&&t.push('<w:b w:val="0"/>'),e.boldCs===true?t.push("<w:bCs/>"):e.boldCs===false&&t.push('<w:bCs w:val="0"/>'),e.italic===true?t.push("<w:i/>"):e.italic===false&&t.push('<w:i w:val="0"/>'),e.italicCs===true?t.push("<w:iCs/>"):e.italicCs===false&&t.push('<w:iCs w:val="0"/>'),e.allCaps&&t.push("<w:caps/>"),e.smallCaps&&t.push("<w:smallCaps/>"),e.strike&&t.push("<w:strike/>"),e.doubleStrike&&t.push("<w:dstrike/>"),e.outline&&t.push("<w:outline/>"),e.shadow&&t.push("<w:shadow/>"),e.emboss&&t.push("<w:emboss/>"),e.imprint&&t.push("<w:imprint/>"),e.hidden&&t.push("<w:vanish/>");let n=Z(e.color);if(n&&t.push(n),e.spacing!==void 0&&t.push(`<w:spacing w:val="${e.spacing}"/>`),e.scale!==void 0&&t.push(`<w:w w:val="${e.scale}"/>`),e.kerning!==void 0&&t.push(`<w:kern w:val="${e.kerning}"/>`),e.position!==void 0&&t.push(`<w:position w:val="${e.position}"/>`),e.fontSize!==void 0&&t.push(`<w:sz w:val="${e.fontSize}"/>`),e.fontSizeCs!==void 0&&t.push(`<w:szCs w:val="${e.fontSizeCs}"/>`),e.highlight&&e.highlight!=="none"&&new Set(["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","red","white","yellow"]).has(e.highlight)&&t.push(`<w:highlight w:val="${e.highlight}"/>`),e.underline){let i=[`w:val="${e.underline.style}"`];e.underline.color&&(e.underline.color.rgb&&i.push(`w:color="${e.underline.color.rgb}"`),e.underline.color.themeColor&&i.push(`w:themeColor="${e.underline.color.themeColor}"`)),t.push(`<w:u ${i.join(" ")}/>`);}e.effect&&e.effect!=="none"&&t.push(`<w:effect w:val="${e.effect}"/>`),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(`<w:em w:val="${e.emphasisMark}"/>`);let r=Y(e.shading);return r&&t.push(r),e.vertAlign&&e.vertAlign!=="baseline"&&t.push(`<w:vertAlign w:val="${e.vertAlign}"/>`),e.rtl&&t.push("<w:rtl/>"),e.cs&&t.push("<w:cs/>"),t.length===0?"":`<w:rPr>${t.join("")}</w:rPr>`}function J(e){return `<w:t${e.preserveSpace||e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${u(e.text)}</w:t>`}function K(e){return "<w:tab/>"}function Q(e){let t=[];return e.breakType==="page"?t.push('w:type="page"'):e.breakType==="column"?t.push('w:type="column"'):e.breakType==="textWrapping"&&(t.push('w:type="textWrapping"'),e.clear&&e.clear!=="none"&&t.push(`w:clear="${e.clear}"`)),t.length===0?"<w:br/>":`<w:br ${t.join(" ")}/>`}function ee(e){return `<w:sym w:font="${u(e.font)}" w:char="${u(e.char)}"/>`}function te(e){return e.type==="footnoteRef"?`<w:footnoteReference w:id="${e.id}"/>`:`<w:endnoteReference w:id="${e.id}"/>`}function ne(e){let t=[`w:fldCharType="${e.charType}"`];return e.fldLock&&t.push('w:fldLock="true"'),e.dirty&&t.push('w:dirty="true"'),`<w:fldChar ${t.join(" ")}/>`}function re(e){return `<w:instrText${e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${u(e.text)}</w:instrText>`}function ie(e){return "<w:softHyphen/>"}function se(e){return "<w:noBreakHyphen/>"}function B(e){if(!e)return "";if(e.rgb)return `<a:srgbClr val="${e.rgb.replace("#","")}"/>`;if(e.themeColor){let t=`<a:schemeClr val="${e.themeColor}"`;return e.themeTint?t+=`><a:tint val="${e.themeTint}"/></a:schemeClr>`:e.themeShade?t+=`><a:shade val="${e.themeShade}"/></a:schemeClr>`:t+="/>",t}return ""}function oe(e){if(!e||e.type==="none")return "<a:noFill/>";if(e.type==="solid"&&e.color)return `<a:solidFill>${B(e.color)}</a:solidFill>`;if(e.type==="gradient"&&e.gradient){let t=e.gradient,n=t.stops.map(i=>`<a:gs pos="${i.position}">${B(i.color)}</a:gs>`).join(""),r=t.type==="linear"?`<a:lin ang="${(t.angle||0)*6e4}" scaled="1"/>`:"";return `<a:gradFill><a:gsLst>${n}</a:gsLst>${r}</a:gradFill>`}return ""}function j(e){if(!e)return "";let t=[];e.width!=null&&t.push(`w="${e.width}"`),e.cap&&t.push(`cap="${e.cap}"`);let n=[];return e.color&&n.push(`<a:solidFill>${B(e.color)}</a:solidFill>`),e.style&&e.style!=="solid"&&n.push(`<a:prstDash val="${e.style}"/>`),e.headEnd&&n.push(`<a:headEnd type="${e.headEnd.type}"${e.headEnd.width?` w="${e.headEnd.width}"`:""}${e.headEnd.length?` len="${e.headEnd.length}"`:""}/>`),e.tailEnd&&n.push(`<a:tailEnd type="${e.tailEnd.type}"${e.tailEnd.width?` w="${e.tailEnd.width}"`:""}${e.tailEnd.length?` len="${e.tailEnd.length}"`:""}/>`),n.length===0&&t.length===0?"":`<a:ln${t.length?" "+t.join(" "):""}>${n.join("")}</a:ln>`}function E(e){let t=[],n=e.horizontal;t.push(`<wp:positionH relativeFrom="${n.relativeTo}">`),n.alignment?t.push(`<wp:align>${n.alignment}</wp:align>`):t.push(`<wp:posOffset>${n.posOffset||0}</wp:posOffset>`),t.push("</wp:positionH>");let r=e.vertical;return t.push(`<wp:positionV relativeFrom="${r.relativeTo}">`),r.alignment?t.push(`<wp:align>${r.alignment}</wp:align>`):t.push(`<wp:posOffset>${r.posOffset||0}</wp:posOffset>`),t.push("</wp:positionV>"),t.join("")}function I(e){let t=e.wrapText?` wrapText="${e.wrapText}"`:' wrapText="bothSides"';switch(e.type){case "square":return `<wp:wrapSquare${t}/>`;case "tight":return `<wp:wrapTight${t}><wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="21600"/><wp:lineTo x="21600" y="21600"/><wp:lineTo x="21600" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon></wp:wrapTight>`;case "through":return `<wp:wrapThrough${t}><wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="21600"/><wp:lineTo x="21600" y="21600"/><wp:lineTo x="21600" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon></wp:wrapThrough>`;case "topAndBottom":return "<wp:wrapTopAndBottom/>";case "behind":case "inFront":return "<wp:wrapNone/>";default:return "<wp:wrapNone/>"}}function ae(e){let t=e.size.width,n=e.size.height,r=e.rId||"rId1",i=e.id||"0",s=e.filename||`image${i}`,o="";return e.transform?.rotation&&(o+=` rot="${Math.round(e.transform.rotation*6e4)}"`),e.transform?.flipH&&(o+=' flipH="1"'),e.transform?.flipV&&(o+=' flipV="1"'),['<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">','<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">','<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">',"<pic:nvPicPr>",`<pic:cNvPr id="${i}" name="${u(s)}"${e.alt?` descr="${u(e.alt)}"`:""}/>`,"<pic:cNvPicPr/>","</pic:nvPicPr>","<pic:blipFill>",`<a:blip r:embed="${r}"/>`,"<a:stretch><a:fillRect/></a:stretch>","</pic:blipFill>","<pic:spPr>",`<a:xfrm${o}>`,'<a:off x="0" y="0"/>',`<a:ext cx="${t}" cy="${n}"/>`,"</a:xfrm>",'<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>',e.outline?j(e.outline):"","</pic:spPr>","</pic:pic>","</a:graphicData>","</a:graphic>"].join("")}function ce(e){let t=e.image,n=t.wrap.type!=="inline",r=t.size.width,i=t.size.height,s=t.padding?.top??t.wrap.distT??0,o=t.padding?.bottom??t.wrap.distB??0,a=t.padding?.left??t.wrap.distL??0,l=t.padding?.right??t.wrap.distR??0,c=t.id||"1",p=t.title||t.filename||`Picture ${c}`,m=ae(t);if(!n)return ["<w:drawing>",`<wp:inline distT="${s}" distB="${o}" distL="${a}" distR="${l}">`,`<wp:extent cx="${r}" cy="${i}"/>`,'<wp:effectExtent l="0" t="0" r="0" b="0"/>',`<wp:docPr id="${c}" name="${u(p)}"${t.alt?` descr="${u(t.alt)}"`:""}${t.decorative?' hidden="1"':""}/>`,'<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr>',m,"</wp:inline>","</w:drawing>"].join("");let w=t.wrap.type==="behind"?"1":"0",S=t.position?E(t.position):'<wp:positionH relativeFrom="column"><wp:posOffset>0</wp:posOffset></wp:positionH><wp:positionV relativeFrom="paragraph"><wp:posOffset>0</wp:posOffset></wp:positionV>',P=I(t.wrap);return ["<w:drawing>",`<wp:anchor distT="${s}" distB="${o}" distL="${a}" distR="${l}" simplePos="0" relativeHeight="251658240" behindDoc="${w}" locked="0" layoutInCell="1" allowOverlap="1">`,'<wp:simplePos x="0" y="0"/>',S,`<wp:extent cx="${r}" cy="${i}"/>`,'<wp:effectExtent l="0" t="0" r="0" b="0"/>',P,`<wp:docPr id="${c}" name="${u(p)}"${t.alt?` descr="${u(t.alt)}"`:""}/>`,'<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr>',m,"</wp:anchor>","</w:drawing>"].join("")}function pe(e){return e.map(t=>y(t)).join("")}function le(e){let t=e.shape,n=t.size.width,r=t.size.height,i=t.shapeType==="textBox",s=t.wrap&&t.wrap.type!=="inline",o=t.wrap?.distT??0,a=t.wrap?.distB??0,l=t.wrap?.distL??0,c=t.wrap?.distR??0,p=t.id||"1",m=t.name||(i?`TextBox ${p}`:`Shape ${p}`),w="";t.transform?.rotation&&(w+=` rot="${Math.round(t.transform.rotation*6e4)}"`),t.transform?.flipH&&(w+=' flipH="1"'),t.transform?.flipV&&(w+=' flipV="1"');let S=["<wps:spPr>",`<a:xfrm${w}>`,'<a:off x="0" y="0"/>',`<a:ext cx="${n}" cy="${r}"/>`,"</a:xfrm>",`<a:prstGeom prst="${t.shapeType==="textBox"?"rect":t.shapeType}"><a:avLst/></a:prstGeom>`,oe(t.fill),j(t.outline),"</wps:spPr>"].join(""),P="";if(t.textBody){let h=t.textBody,g=['rot="0"','vert="horz"'];h.anchor&&g.push(`anchor="${h.anchor==="middle"?"ctr":h.anchor}"`),h.anchorCenter&&g.push('anchorCtr="1"'),h.margins&&(h.margins.left!=null&&g.push(`lIns="${h.margins.left}"`),h.margins.top!=null&&g.push(`tIns="${h.margins.top}"`),h.margins.right!=null&&g.push(`rIns="${h.margins.right}"`),h.margins.bottom!=null&&g.push(`bIns="${h.margins.bottom}"`)),i?P=["<wps:txbx><w:txbxContent>",pe(h.content),"</w:txbxContent></wps:txbx>",`<wps:bodyPr ${g.join(" ")}/>`].join(""):P=[`<wps:bodyPr ${g.join(" ")}/>`].join("");}let k=['<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">','<a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">',["<wps:wsp>",`<wps:cNvSpPr${i?' txBox="1"':""}/>`,S,P,"</wps:wsp>"].join(""),"</a:graphicData>","</a:graphic>"].join("");if(!s)return ["<w:drawing>",`<wp:inline distT="${o}" distB="${a}" distL="${l}" distR="${c}">`,`<wp:extent cx="${n}" cy="${r}"/>`,'<wp:effectExtent l="0" t="0" r="0" b="0"/>',`<wp:docPr id="${p}" name="${u(m)}"/>`,"<wp:cNvGraphicFramePr/>",k,"</wp:inline>","</w:drawing>"].join("");let _=t.wrap?.type==="behind"?"1":"0",q=t.position?E(t.position):'<wp:positionH relativeFrom="column"><wp:posOffset>0</wp:posOffset></wp:positionH><wp:positionV relativeFrom="paragraph"><wp:posOffset>0</wp:posOffset></wp:positionV>',U=I(t.wrap);return ["<w:drawing>",`<wp:anchor distT="${o}" distB="${a}" distL="${l}" distR="${c}" simplePos="0" relativeHeight="251658240" behindDoc="${_}" locked="0" layoutInCell="1" allowOverlap="1">`,'<wp:simplePos x="0" y="0"/>',q,`<wp:extent cx="${n}" cy="${r}"/>`,'<wp:effectExtent l="0" t="0" r="0" b="0"/>',U,`<wp:docPr id="${p}" name="${u(m)}"/>`,"<wp:cNvGraphicFramePr/>",k,"</wp:anchor>","</w:drawing>"].join("")}function ue(e){switch(e.type){case "text":return J(e);case "tab":return K();case "break":return Q(e);case "symbol":return ee(e);case "footnoteRef":case "endnoteRef":return te(e);case "fieldChar":return ne(e);case "instrText":return re(e);case "softHyphen":return ie();case "noBreakHyphen":return se();case "drawing":return ce(e);case "shape":return le(e);default:return ""}}function x(e){let t=[],n=C(e.formatting);n&&t.push(n);for(let r of e.content){let i=ue(r);i&&t.push(i);}return `<w:r>${t.join("")}</w:r>`}function f(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function T(e,t){if(!e||e.style==="none"||e.style==="nil")return "";let n=[`w:val="${e.style}"`];return e.size!==void 0&&n.push(`w:sz="${e.size}"`),e.space!==void 0&&n.push(`w:space="${e.space}"`),e.color&&(e.color.auto?n.push('w:color="auto"'):e.color.rgb&&n.push(`w:color="${e.color.rgb}"`),e.color.themeColor&&n.push(`w:themeColor="${e.color.themeColor}"`),e.color.themeTint&&n.push(`w:themeTint="${e.color.themeTint}"`),e.color.themeShade&&n.push(`w:themeShade="${e.color.themeShade}"`)),e.shadow&&n.push('w:shadow="true"'),e.frame&&n.push('w:frame="true"'),`<w:${t} ${n.join(" ")}/>`}function fe(e){if(!e)return "";let t=[];if(e.top){let n=T(e.top,"top");n&&t.push(n);}if(e.left){let n=T(e.left,"left");n&&t.push(n);}if(e.bottom){let n=T(e.bottom,"bottom");n&&t.push(n);}if(e.right){let n=T(e.right,"right");n&&t.push(n);}if(e.between){let n=T(e.between,"between");n&&t.push(n);}if(e.bar){let n=T(e.bar,"bar");n&&t.push(n);}return t.length===0?"":`<w:pBdr>${t.join("")}</w:pBdr>`}function he(e){if(!e)return "";let t=[];return e.pattern?t.push(`w:val="${e.pattern}"`):t.push('w:val="clear"'),e.color?.rgb?t.push(`w:color="${e.color.rgb}"`):e.color?.auto&&t.push('w:color="auto"'),e.fill?.rgb?t.push(`w:fill="${e.fill.rgb}"`):e.fill?.auto&&t.push('w:fill="auto"'),e.fill?.themeColor&&t.push(`w:themeFill="${e.fill.themeColor}"`),e.fill?.themeTint&&t.push(`w:themeFillTint="${e.fill.themeTint}"`),e.fill?.themeShade&&t.push(`w:themeFillShade="${e.fill.themeShade}"`),t.length===0?"":`<w:shd ${t.join(" ")}/>`}function de(e){return !e||e.length===0?"":`<w:tabs>${e.map(n=>{let r=[`w:val="${n.alignment}"`,`w:pos="${n.position}"`];return n.leader&&n.leader!=="none"&&r.push(`w:leader="${n.leader}"`),`<w:tab ${r.join(" ")}/>`}).join("")}</w:tabs>`}function me(e){let t=[];return e.spaceBefore!==void 0&&t.push(`w:before="${e.spaceBefore}"`),e.spaceAfter!==void 0&&t.push(`w:after="${e.spaceAfter}"`),e.lineSpacing!==void 0&&t.push(`w:line="${e.lineSpacing}"`),e.lineSpacingRule&&t.push(`w:lineRule="${e.lineSpacingRule}"`),e.beforeAutospacing&&t.push('w:beforeAutospacing="1"'),e.afterAutospacing&&t.push('w:afterAutospacing="1"'),t.length===0?"":`<w:spacing ${t.join(" ")}/>`}function we(e){let t=[];return e.indentLeft!==void 0&&t.push(`w:left="${e.indentLeft}"`),e.indentRight!==void 0&&t.push(`w:right="${e.indentRight}"`),e.indentFirstLine!==void 0&&(e.hangingIndent?t.push(`w:hanging="${Math.abs(e.indentFirstLine)}"`):e.indentFirstLine!==0&&t.push(`w:firstLine="${e.indentFirstLine}"`)),t.length===0?"":`<w:ind ${t.join(" ")}/>`}function ge(e){if(!e)return "";let t=[];return e.ilvl!==void 0&&t.push(`<w:ilvl w:val="${e.ilvl}"/>`),e.numId!==void 0&&t.push(`<w:numId w:val="${e.numId}"/>`),t.length===0?"":`<w:numPr>${t.join("")}</w:numPr>`}function xe(e){if(!e)return "";let t=[];return e.width!==void 0&&t.push(`w:w="${e.width}"`),e.height!==void 0&&t.push(`w:h="${e.height}"`),e.hAnchor&&t.push(`w:hAnchor="${e.hAnchor}"`),e.vAnchor&&t.push(`w:vAnchor="${e.vAnchor}"`),e.x!==void 0&&t.push(`w:x="${e.x}"`),e.y!==void 0&&t.push(`w:y="${e.y}"`),e.xAlign&&t.push(`w:xAlign="${e.xAlign}"`),e.yAlign&&t.push(`w:yAlign="${e.yAlign}"`),e.wrap&&t.push(`w:wrap="${e.wrap}"`),t.length===0?"":`<w:framePr ${t.join(" ")}/>`}function ye(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:pStyle w:val="${f(e.styleId)}"/>`),e.keepNext&&t.push("<w:keepNext/>"),e.keepLines&&t.push("<w:keepLines/>"),e.contextualSpacing&&t.push("<w:contextualSpacing/>"),e.pageBreakBefore&&t.push("<w:pageBreakBefore/>");let n=xe(e.frame);n&&t.push(n),e.widowControl===false?t.push('<w:widowControl w:val="0"/>'):e.widowControl===true&&t.push("<w:widowControl/>");let r=ge(e.numPr);r&&t.push(r);let i=fe(e.borders);i&&t.push(i);let s=he(e.shading);s&&t.push(s);let o=de(e.tabs);o&&t.push(o),e.suppressLineNumbers&&t.push("<w:suppressLineNumbers/>"),e.suppressAutoHyphens&&t.push("<w:suppressAutoHyphens/>");let a=me(e);a&&t.push(a);let l=we(e);if(l&&t.push(l),e.bidi&&t.push("<w:bidi/>"),e.alignment&&t.push(`<w:jc w:val="${e.alignment}"/>`),e.outlineLevel!==void 0&&t.push(`<w:outlineLvl w:val="${e.outlineLevel}"/>`),e.runProperties){let c=C(e.runProperties);c&&t.push(c);}return t.length===0?"":`<w:pPr>${t.join("")}</w:pPr>`}function z(e){let t=[];e.rId&&t.push(`r:id="${e.rId}"`),e.anchor&&t.push(`w:anchor="${f(e.anchor)}"`),e.tooltip&&t.push(`w:tooltip="${f(e.tooltip)}"`),e.target&&t.push(`w:tgtFrame="${f(e.target)}"`),e.history===false&&t.push('w:history="0"'),e.docLocation&&t.push(`w:docLocation="${f(e.docLocation)}"`);let n=e.children.map(i=>i.type==="run"?x(i):i.type==="bookmarkStart"?L(i):i.type==="bookmarkEnd"?O(i):"").join("");return `<w:hyperlink${t.length>0?" "+t.join(" "):""}>${n}</w:hyperlink>`}function L(e){let t=[`w:id="${e.id}"`,`w:name="${f(e.name)}"`];return e.colFirst!==void 0&&t.push(`w:colFirst="${e.colFirst}"`),e.colLast!==void 0&&t.push(`w:colLast="${e.colLast}"`),`<w:bookmarkStart ${t.join(" ")}/>`}function O(e){return `<w:bookmarkEnd w:id="${e.id}"/>`}function $e(e){let t=[],n=e.content.find(a=>a.type==="run"),r=n?.formatting?C(n.formatting):"",i=['w:fldCharType="begin"'];e.fldLock&&i.push('w:fldLock="true"'),t.push(`<w:r>${r}<w:fldChar ${i.join(" ")}/></w:r>`);let o=e.instruction.startsWith(" ")||e.instruction.endsWith(" ")||e.instruction.includes(" ")?' xml:space="preserve"':"";t.push(`<w:r>${r}<w:instrText${o}>${f(e.instruction)}</w:instrText></w:r>`),t.push(`<w:r>${r}<w:fldChar w:fldCharType="separate"/></w:r>`);for(let a of e.content)a.type==="run"&&t.push(x(a));return t.push(`<w:r>${r}<w:fldChar w:fldCharType="end"/></w:r>`),t.join("")}function Te(e){let t=[],n=e.fieldResult?.[0]?.formatting,r=n?C(n):"",i=['w:fldCharType="begin"'];if(e.fldLock&&i.push('w:fldLock="true"'),t.push(`<w:r>${r}<w:fldChar ${i.join(" ")}/></w:r>`),e.fieldCode.length>0)t.push(...e.fieldCode.map(s=>x(s)));else {let o=e.instruction.startsWith(" ")||e.instruction.endsWith(" ")||e.instruction.includes(" ")?' xml:space="preserve"':"";t.push(`<w:r>${r}<w:instrText${o}>${f(e.instruction)}</w:instrText></w:r>`);}return t.push(`<w:r>${r}<w:fldChar w:fldCharType="separate"/></w:r>`),t.push(...e.fieldResult.map(s=>x(s))),t.push(`<w:r>${r}<w:fldChar w:fldCharType="end"/></w:r>`),t.join("")}function be(e){let t=e.properties,n=[];switch(t.alias&&n.push(`<w:alias w:val="${f(t.alias)}"/>`),t.tag&&n.push(`<w:tag w:val="${f(t.tag)}"/>`),t.lock&&t.lock!=="unlocked"&&n.push(`<w:lock w:val="${t.lock}"/>`),t.showingPlaceholder&&n.push("<w:showingPlcHdr/>"),t.sdtType){case "plainText":n.push("<w:text/>");break;case "date":t.dateFormat?n.push(`<w:date w:fullDate="${f(t.dateFormat)}"/>`):n.push("<w:date/>");break;case "dropdown":{let i=(t.listItems??[]).map(s=>`<w:listItem w:displayText="${f(s.displayText)}" w:value="${f(s.value)}"/>`).join("");n.push(`<w:dropDownList>${i}</w:dropDownList>`);break}case "comboBox":{let i=(t.listItems??[]).map(s=>`<w:listItem w:displayText="${f(s.displayText)}" w:value="${f(s.value)}"/>`).join("");n.push(`<w:comboBox>${i}</w:comboBox>`);break}case "checkbox":n.push(`<w14:checkbox><w14:checked w14:val="${t.checked?"1":"0"}"/></w14:checkbox>`);break;case "picture":n.push("<w:picture/>");break}let r=e.content.map(i=>i.type==="run"?x(i):i.type==="hyperlink"?z(i):"").join("");return `<w:sdt><w:sdtPr>${n.join("")}</w:sdtPr><w:sdtContent>${r}</w:sdtContent></w:sdt>`}function X(e,t){let n=t.info,r=[`w:id="${n.id}"`,`w:author="${f(n.author)}"`];n.date&&r.push(`w:date="${f(n.date)}"`);let i=t.content.map(s=>s.type==="run"?x(s):s.type==="hyperlink"?z(s):"").join("");return `<w:${e} ${r.join(" ")}>${i}</w:${e}>`}function Pe(e){switch(e.type){case "run":return x(e);case "hyperlink":return z(e);case "bookmarkStart":return L(e);case "bookmarkEnd":return O(e);case "simpleField":return $e(e);case "complexField":return Te(e);case "inlineSdt":return be(e);case "commentRangeStart":return `<w:commentRangeStart w:id="${e.id}"/>`;case "commentRangeEnd":return `<w:commentRangeEnd w:id="${e.id}"/>`;case "insertion":return X("ins",e);case "deletion":return X("del",e);case "mathEquation":return e.ommlXml||"";default:return ""}}function y(e){let t=[],n=[];e.paraId&&n.push(`w14:paraId="${e.paraId}"`),e.textId&&n.push(`w14:textId="${e.textId}"`);let r=n.length>0?" "+n.join(" "):"",i=ye(e.formatting);i&&t.push(i);for(let s of e.content){let o=Pe(s);o&&t.push(o);}return `<w:p${r}>${t.join("")}</w:p>`}function Ce(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function $(e,t){if(!e)return "";let n=[`w:w="${e.value}"`,`w:type="${e.type}"`];return `<w:${t} ${n.join(" ")}/>`}function b(e,t){if(!e||e.style==="none"||e.style==="nil")return "";let n=[`w:val="${e.style}"`];return e.size!==void 0&&n.push(`w:sz="${e.size}"`),e.space!==void 0&&n.push(`w:space="${e.space}"`),e.color&&(e.color.auto?n.push('w:color="auto"'):e.color.rgb&&n.push(`w:color="${e.color.rgb}"`),e.color.themeColor&&n.push(`w:themeColor="${e.color.themeColor}"`),e.color.themeTint&&n.push(`w:themeTint="${e.color.themeTint}"`),e.color.themeShade&&n.push(`w:themeShade="${e.color.themeShade}"`)),e.shadow&&n.push('w:shadow="true"'),e.frame&&n.push('w:frame="true"'),`<w:${t} ${n.join(" ")}/>`}function H(e,t){if(!e)return "";let n=[];if(e.top){let r=b(e.top,"top");r&&n.push(r);}if(e.left){let r=b(e.left,"left");r&&n.push(r);}if(e.bottom){let r=b(e.bottom,"bottom");r&&n.push(r);}if(e.right){let r=b(e.right,"right");r&&n.push(r);}if(e.insideH){let r=b(e.insideH,"insideH");r&&n.push(r);}if(e.insideV){let r=b(e.insideV,"insideV");r&&n.push(r);}return n.length===0?"":`<w:${t}>${n.join("")}</w:${t}>`}function M(e,t){if(!e)return "";let n=[];return e.top&&n.push($(e.top,"top")),e.left&&n.push($(e.left,"left")),e.bottom&&n.push($(e.bottom,"bottom")),e.right&&n.push($(e.right,"right")),n.length===0?"":`<w:${t}>${n.join("")}</w:${t}>`}function N(e){if(!e)return "";let t=[];return e.pattern?t.push(`w:val="${e.pattern}"`):t.push('w:val="clear"'),e.color?.rgb?t.push(`w:color="${e.color.rgb}"`):e.color?.auto&&t.push('w:color="auto"'),e.fill?.rgb?t.push(`w:fill="${e.fill.rgb}"`):e.fill?.auto&&t.push('w:fill="auto"'),e.fill?.themeColor&&t.push(`w:themeFill="${e.fill.themeColor}"`),e.fill?.themeTint&&t.push(`w:themeFillTint="${e.fill.themeTint}"`),e.fill?.themeShade&&t.push(`w:themeFillShade="${e.fill.themeShade}"`),t.length===0?"":`<w:shd ${t.join(" ")}/>`}function ve(e){if(!e)return "";let t=[];return e.firstRow&&t.push('w:firstRow="1"'),e.lastRow&&t.push('w:lastRow="1"'),e.firstColumn&&t.push('w:firstColumn="1"'),e.lastColumn&&t.push('w:lastColumn="1"'),e.noHBand&&t.push('w:noHBand="1"'),e.noVBand&&t.push('w:noVBand="1"'),t.length===0?"":`<w:tblLook ${t.join(" ")}/>`}function Fe(e){if(!e)return "";let t=[];return e.horzAnchor&&t.push(`w:horzAnchor="${e.horzAnchor}"`),e.vertAnchor&&t.push(`w:vertAnchor="${e.vertAnchor}"`),e.tblpX!==void 0&&t.push(`w:tblpX="${e.tblpX}"`),e.tblpXSpec&&t.push(`w:tblpXSpec="${e.tblpXSpec}"`),e.tblpY!==void 0&&t.push(`w:tblpY="${e.tblpY}"`),e.tblpYSpec&&t.push(`w:tblpYSpec="${e.tblpYSpec}"`),e.topFromText!==void 0&&t.push(`w:topFromText="${e.topFromText}"`),e.bottomFromText!==void 0&&t.push(`w:bottomFromText="${e.bottomFromText}"`),e.leftFromText!==void 0&&t.push(`w:leftFromText="${e.leftFromText}"`),e.rightFromText!==void 0&&t.push(`w:rightFromText="${e.rightFromText}"`),t.length===0?"":`<w:tblpPr ${t.join(" ")}/>`}function Se(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:tblStyle w:val="${Ce(e.styleId)}"/>`);let n=Fe(e.floating);n&&t.push(n),e.bidi&&t.push("<w:bidiVisual/>");let r=$(e.width,"tblW");r&&t.push(r),e.justification&&t.push(`<w:jc w:val="${e.justification}"/>`);let i=$(e.cellSpacing,"tblCellSpacing");i&&t.push(i);let s=$(e.indent,"tblInd");s&&t.push(s);let o=H(e.borders,"tblBorders");o&&t.push(o);let a=M(e.cellMargins,"tblCellMar");a&&t.push(a),e.layout&&t.push(`<w:tblLayout w:type="${e.layout}"/>`);let l=N(e.shading);l&&t.push(l);let c=ve(e.look);return c&&t.push(c),e.overlap&&t.push(`<w:tblOverlap w:val="${e.overlap}"/>`),t.length===0?"":`<w:tblPr>${t.join("")}</w:tblPr>`}function Ae(e){if(!e)return "";let t=[];if(e.cantSplit&&t.push("<w:cantSplit/>"),e.header&&t.push("<w:tblHeader/>"),e.height){let n=[`w:val="${e.height.value}"`];e.heightRule&&n.push(`w:hRule="${e.heightRule}"`),t.push(`<w:trHeight ${n.join(" ")}/>`);}return e.justification&&t.push(`<w:jc w:val="${e.justification}"/>`),e.hidden&&t.push("<w:hidden/>"),t.length===0?"":`<w:trPr>${t.join("")}</w:trPr>`}function Be(e){if(!e)return "";let n=[e.firstRow?"1":"0",e.lastRow?"1":"0",e.firstColumn?"1":"0",e.lastColumn?"1":"0",e.oddVBand?"1":"0",e.evenVBand?"1":"0",e.oddHBand?"1":"0",e.evenHBand?"1":"0",e.nwCell?"1":"0",e.neCell?"1":"0",e.swCell?"1":"0",e.seCell?"1":"0"].join("");return n==="000000000000"?"":`<w:cnfStyle w:val="${n}"/>`}function ze(e){if(!e)return "";let t=[],n=Be(e.conditionalFormat);n&&t.push(n);let r=$(e.width,"tcW");r&&t.push(r),e.gridSpan&&e.gridSpan>1&&t.push(`<w:gridSpan w:val="${e.gridSpan}"/>`),e.vMerge&&(e.vMerge==="restart"?t.push('<w:vMerge w:val="restart"/>'):t.push("<w:vMerge/>"));let i=H(e.borders,"tcBorders");i&&t.push(i);let s=N(e.shading);s&&t.push(s),e.noWrap&&t.push("<w:noWrap/>");let o=M(e.margins,"tcMar");return o&&t.push(o),e.textDirection&&t.push(`<w:textDirection w:val="${e.textDirection}"/>`),e.fitText&&t.push("<w:tcFitText/>"),e.verticalAlign&&t.push(`<w:vAlign w:val="${e.verticalAlign}"/>`),e.hideMark&&t.push("<w:hideMark/>"),t.length===0?"":`<w:tcPr>${t.join("")}</w:tcPr>`}function De(e){return !e||e.length===0?"":`<w:tblGrid>${e.map(n=>`<w:gridCol w:w="${n}"/>`).join("")}</w:tblGrid>`}function Re(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(y(n)):n.type==="table"&&t.push(v(n));return t.length===0&&t.push("<w:p/>"),t.join("")}function ke(e){let t=[],n=ze(e.formatting);return n&&t.push(n),t.push(Re(e.content)),`<w:tc>${t.join("")}</w:tc>`}function je(e){let t=[],n=Ae(e.formatting);n&&t.push(n);for(let r of e.cells)t.push(ke(r));return `<w:tr>${t.join("")}</w:tr>`}function v(e){let t=[],n=Se(e.formatting);n&&t.push(n);let r=De(e.columnWidths);r&&t.push(r);for(let i of e.rows)t.push(je(i));return `<w:tbl>${t.join("")}</w:tbl>`}var d={wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"};function Ee(){let e={wpc:d.wpc,mc:d.mc,o:d.o,r:d.r,m:d.m,v:d.v,wp14:d.wp14,wp:d.wp,w10:d.w10,w:d.w,w14:d.w14,w15:d.w15,wpg:d.wpg,wps:d.wps};return Object.entries(e).map(([t,n])=>`xmlns:${t}="${n}"`).join(" ")}function F(e,t){if(!e||e.style==="none"||e.style==="nil")return "";let n=[`w:val="${e.style}"`];return e.size!==void 0&&n.push(`w:sz="${e.size}"`),e.space!==void 0&&n.push(`w:space="${e.space}"`),e.color&&(e.color.auto?n.push('w:color="auto"'):e.color.rgb&&n.push(`w:color="${e.color.rgb}"`),e.color.themeColor&&n.push(`w:themeColor="${e.color.themeColor}"`),e.color.themeTint&&n.push(`w:themeTint="${e.color.themeTint}"`),e.color.themeShade&&n.push(`w:themeShade="${e.color.themeShade}"`)),e.shadow&&n.push('w:shadow="true"'),e.frame&&n.push('w:frame="true"'),`<w:${t} ${n.join(" ")}/>`}function Ie(e){return `<w:headerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function Xe(e){return `<w:footerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function Le(e){if(!e)return "";let t=[];return e.position&&t.push(`<w:pos w:val="${e.position}"/>`),e.numFmt&&t.push(`<w:numFmt w:val="${e.numFmt}"/>`),e.numStart!==void 0&&t.push(`<w:numStart w:val="${e.numStart}"/>`),e.numRestart&&t.push(`<w:numRestart w:val="${e.numRestart}"/>`),t.length===0?"":`<w:footnotePr>${t.join("")}</w:footnotePr>`}function Oe(e){if(!e)return "";let t=[];return e.position&&t.push(`<w:pos w:val="${e.position}"/>`),e.numFmt&&t.push(`<w:numFmt w:val="${e.numFmt}"/>`),e.numStart!==void 0&&t.push(`<w:numStart w:val="${e.numStart}"/>`),e.numRestart&&t.push(`<w:numRestart w:val="${e.numRestart}"/>`),t.length===0?"":`<w:endnotePr>${t.join("")}</w:endnotePr>`}function He(e){let t=[];return e.pageWidth!==void 0&&t.push(`w:w="${e.pageWidth}"`),e.pageHeight!==void 0&&t.push(`w:h="${e.pageHeight}"`),e.orientation==="landscape"&&t.push('w:orient="landscape"'),t.length===0?"":`<w:pgSz ${t.join(" ")}/>`}function Me(e){let t=[];return e.marginTop!==void 0&&t.push(`w:top="${e.marginTop}"`),e.marginRight!==void 0&&t.push(`w:right="${e.marginRight}"`),e.marginBottom!==void 0&&t.push(`w:bottom="${e.marginBottom}"`),e.marginLeft!==void 0&&t.push(`w:left="${e.marginLeft}"`),e.headerDistance!==void 0&&t.push(`w:header="${e.headerDistance}"`),e.footerDistance!==void 0&&t.push(`w:footer="${e.footerDistance}"`),e.gutter!==void 0&&t.push(`w:gutter="${e.gutter}"`),t.length===0?"":`<w:pgMar ${t.join(" ")}/>`}function Ne(e){if(!e.columnCount&&!e.columns?.length)return "";let t=[];e.columnCount!==void 0&&e.columnCount>1&&t.push(`w:num="${e.columnCount}"`),e.columnSpace!==void 0&&t.push(`w:space="${e.columnSpace}"`),e.equalWidth!==void 0&&t.push(`w:equalWidth="${e.equalWidth?"1":"0"}"`),e.separator&&t.push('w:sep="1"');let n="";return e.columns&&e.columns.length>0&&(n=e.columns.map(i=>{let s=[];return i.width!==void 0&&s.push(`w:w="${i.width}"`),i.space!==void 0&&s.push(`w:space="${i.space}"`),`<w:col ${s.join(" ")}/>`}).join("")),t.length===0&&!n?"":`<w:cols${t.length>0?" "+t.join(" "):""}>${n}</w:cols>`}function We(e){if(!e.lineNumbers)return "";let t=e.lineNumbers,n=[];return t.countBy!==void 0&&n.push(`w:countBy="${t.countBy}"`),t.start!==void 0&&n.push(`w:start="${t.start}"`),t.distance!==void 0&&n.push(`w:distance="${t.distance}"`),t.restart&&n.push(`w:restart="${t.restart}"`),n.length===0?"":`<w:lnNumType ${n.join(" ")}/>`}function Ge(e){if(!e.pageBorders)return "";let t=e.pageBorders,n=[],r=[];if(t.display&&n.push(`w:display="${t.display}"`),t.offsetFrom&&n.push(`w:offsetFrom="${t.offsetFrom}"`),t.zOrder&&n.push(`w:zOrder="${t.zOrder}"`),t.top){let s=F(t.top,"top");s&&r.push(s);}if(t.left){let s=F(t.left,"left");s&&r.push(s);}if(t.bottom){let s=F(t.bottom,"bottom");s&&r.push(s);}if(t.right){let s=F(t.right,"right");s&&r.push(s);}return r.length===0?"":`<w:pgBorders${n.length>0?" "+n.join(" "):""}>${r.join("")}</w:pgBorders>`}function Ve(e){if(!e.docGrid)return "";let t=e.docGrid,n=[];return t.type&&n.push(`w:type="${t.type}"`),t.linePitch!==void 0&&n.push(`w:linePitch="${t.linePitch}"`),t.charSpace!==void 0&&n.push(`w:charSpace="${t.charSpace}"`),n.length===0?"":`<w:docGrid ${n.join(" ")}/>`}function _e(e){if(!e)return "";let t=[];if(e.headerReferences)for(let p of e.headerReferences)t.push(Ie(p));if(e.footerReferences)for(let p of e.footerReferences)t.push(Xe(p));let n=Le(e.footnotePr);n&&t.push(n);let r=Oe(e.endnotePr);r&&t.push(r),e.sectionStart&&t.push(`<w:type w:val="${e.sectionStart}"/>`);let i=He(e);i&&t.push(i);let s=Me(e);if(s&&t.push(s),e.paperSrcFirst!==void 0||e.paperSrcOther!==void 0){let p=[];e.paperSrcFirst!==void 0&&p.push(`w:first="${e.paperSrcFirst}"`),e.paperSrcOther!==void 0&&p.push(`w:other="${e.paperSrcOther}"`),t.push(`<w:paperSrc ${p.join(" ")}/>`);}let o=Ge(e);o&&t.push(o);let a=We(e);a&&t.push(a);let l=Ne(e);l&&t.push(l);let c=Ve(e);return c&&t.push(c),e.verticalAlign&&t.push(`<w:vAlign w:val="${e.verticalAlign}"/>`),e.bidi&&t.push("<w:bidi/>"),e.titlePg&&t.push("<w:titlePg/>"),e.evenAndOddHeaders&&t.push("<w:evenAndOddHeaders/>"),t.length===0?"":`<w:sectPr>${t.join("")}</w:sectPr>`}function W(e){if(e.type==="paragraph")return y(e);if(e.type==="table")return v(e);if(e.type==="blockSdt"){let t=e.content.map(i=>W(i)).join(""),n=e.properties,r=[];return n.alias&&r.push(`<w:alias w:val="${n.alias}"/>`),n.tag&&r.push(`<w:tag w:val="${n.tag}"/>`),`<w:sdt><w:sdtPr>${r.join("")}</w:sdtPr><w:sdtContent>${t}</w:sdtContent></w:sdt>`}return ""}function qe(e){return e.map(t=>W(t)).join("")}function Ue(e){let t=[];return t.push(qe(e.content)),e.finalSectionProperties&&t.push(_e(e.finalSectionProperties)),t.join("")}function G(e){let t=[];t.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');let n=Ee();return t.push(`<w:document ${n} mc:Ignorable="w14 w15 wp14">`),t.push("<w:body>"),t.push(Ue(e.package.document)),t.push("</w:body>"),t.push("</w:document>"),t.join("")}var Ze={wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"};function Ye(){return Object.entries(Ze).map(([e,t])=>`xmlns:${e}="${t}"`).join(" ")}function Je(e){return e.type==="paragraph"?y(e):e.type==="table"?v(e):""}function D(e){let t=e.type==="header"?"w:hdr":"w:ftr",n=Ye(),r=e.content.map(i=>Je(i)).join("");return r||(r="<w:p><w:pPr/></w:p>"),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <${t} ${n}>${r}</${t}>`}async function Ke(e,t={}){if(!e.originalBuffer)throw new Error("Cannot repack document: no original buffer for round-trip. Use createDocx() for new documents.");let{compressionLevel:n=6,updateModifiedDate:r=true,modifiedBy:i}=t,s=await R__default.default.loadAsync(e.originalBuffer),o=new R__default.default;for(let[c,p]of Object.entries(s.files)){if(p.dir){o.folder(c.replace(/\/$/,""));continue}let m=await p.async("arraybuffer");o.file(c,m,{compression:"DEFLATE",compressionOptions:{level:n}});}let a=G(e);if(o.file("word/document.xml",a,{compression:"DEFLATE",compressionOptions:{level:n}}),Qe(e,o,n),r){let c="docProps/core.xml",p=s.file(c);if(p){let m=await p.async("text"),w=et(m,{updateModifiedDate:r,modifiedBy:i});o.file(c,w,{compression:"DEFLATE",compressionOptions:{level:n}});}}return await o.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:n}})}function Qe(e,t,n){let r=e.package.relationships;if(!r)return;let i={level:n};if(e.package.headers)for(let[s,o]of e.package.headers.entries()){let a=r.get(s);if(a&&a.type===chunkCWWSDDRF_cjs.b.header&&a.target){let l=a.target.startsWith("/")?a.target.slice(1):`word/${a.target}`,c=D(o);t.file(l,c,{compression:"DEFLATE",compressionOptions:i});}}if(e.package.footers)for(let[s,o]of e.package.footers.entries()){let a=r.get(s);if(a&&a.type===chunkCWWSDDRF_cjs.b.footer&&a.target){let l=a.target.startsWith("/")?a.target.slice(1):`word/${a.target}`,c=D(o);t.file(l,c,{compression:"DEFLATE",compressionOptions:i});}}}function et(e,t){let n=e;if(t.updateModifiedDate){let r=new Date().toISOString();n.includes("<dcterms:modified")?n=n.replace(/<dcterms:modified[^>]*>[^<]*<\/dcterms:modified>/,`<dcterms:modified xsi:type="dcterms:W3CDTF">${r}</dcterms:modified>`):n=n.replace("</cp:coreProperties>",`<dcterms:modified xsi:type="dcterms:W3CDTF">${r}</dcterms:modified></cp:coreProperties>`);}return t.modifiedBy&&(n.includes("<cp:lastModifiedBy")?n=n.replace(/<cp:lastModifiedBy>[^<]*<\/cp:lastModifiedBy>/,`<cp:lastModifiedBy>${V(t.modifiedBy)}</cp:lastModifiedBy>`):n=n.replace("</cp:coreProperties>",`<cp:lastModifiedBy>${V(t.modifiedBy)}</cp:lastModifiedBy></cp:coreProperties>`)),n}function V(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function tt(){let e=new R__default.default;e.file("[Content_Types].xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
4
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
5
+ <Default Extension="xml" ContentType="application/xml"/>
6
+ <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
7
+ <Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
8
+ <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
9
+ <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
10
+ </Types>`),e.file("_rels/.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
11
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
12
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
13
+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
14
+ <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
15
+ </Relationships>`),e.file("word/_rels/document.xml.rels",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
16
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
17
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
18
+ </Relationships>`),e.file("word/document.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
19
+ <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
20
+ <w:body>
21
+ <w:p>
22
+ <w:r>
23
+ <w:t></w:t>
24
+ </w:r>
25
+ </w:p>
26
+ <w:sectPr>
27
+ <w:pgSz w:w="12240" w:h="15840"/>
28
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
29
+ </w:sectPr>
30
+ </w:body>
31
+ </w:document>`),e.file("word/styles.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
+ <w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
33
+ <w:docDefaults>
34
+ <w:rPrDefault>
35
+ <w:rPr>
36
+ <w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/>
37
+ <w:sz w:val="22"/>
38
+ </w:rPr>
39
+ </w:rPrDefault>
40
+ <w:pPrDefault>
41
+ <w:pPr>
42
+ <w:spacing w:after="200" w:line="276" w:lineRule="auto"/>
43
+ </w:pPr>
44
+ </w:pPrDefault>
45
+ </w:docDefaults>
46
+ <w:style w:type="paragraph" w:default="1" w:styleId="Normal">
47
+ <w:name w:val="Normal"/>
48
+ </w:style>
49
+ </w:styles>`);let t=new Date().toISOString();return e.file("docProps/core.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
50
+ <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">
51
+ <dc:creator>EigenPal DOCX Editor</dc:creator>
52
+ <dcterms:created xsi:type="dcterms:W3CDTF">${t}</dcterms:created>
53
+ <dcterms:modified xsi:type="dcterms:W3CDTF">${t}</dcterms:modified>
54
+ </cp:coreProperties>`),e.file("docProps/app.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
55
+ <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
56
+ <Application>EigenPal DOCX Editor</Application>
57
+ <AppVersion>1.0.0</AppVersion>
58
+ </Properties>`),e.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}})}async function yt(e){let t=await tt(),n={...e,originalBuffer:t};return Ke(n)}exports.a=_e;exports.b=Ue;exports.c=G;exports.d=Ke;exports.e=yt;
@@ -1,4 +1,24 @@
1
- import { h as Document, T as TextFormatting, a6 as StyleInfo, k as AgentContext, g as Position, Y as Range, U as ParagraphFormatting, j as AgentCommand, a2 as SelectionContext, D as DocumentBody, a1 as SectionProperties, al as ColorValue, ab as Theme, am as ThemeColorSlot } from './types-XVRXTi4o.js';
1
+ import { h as Document, T as TextFormatting, a6 as StyleInfo, k as AgentContext, g as Position, Y as Range, U as ParagraphFormatting, j as AgentCommand, a2 as SelectionContext, D as DocumentBody, a1 as SectionProperties, al as ColorValue, ab as Theme, am as ThemeColorSlot } from './types-Do_Q8vaT.cjs';
2
+
3
+ /**
4
+ * Flexible input types for DOCX documents.
5
+ *
6
+ * Accepts any common binary format so consumers don't need to manually
7
+ * convert before passing data to the editor or parser.
8
+ */
9
+ /**
10
+ * Any binary representation of a DOCX file that the editor can consume.
11
+ *
12
+ * - `ArrayBuffer` — from `FileReader.readAsArrayBuffer()` or `fetch().arrayBuffer()`
13
+ * - `Uint8Array` — from Node.js `fs.readFile()` or streaming APIs
14
+ * - `Blob` — from drag-and-drop or `<input type="file">`
15
+ * - `File` — subclass of Blob, from `<input type="file">`
16
+ */
17
+ type DocxInput = ArrayBuffer | Uint8Array | Blob | File;
18
+ /**
19
+ * Normalize any {@link DocxInput} into an `ArrayBuffer` for internal use.
20
+ */
21
+ declare function toArrayBuffer(input: DocxInput): Promise<ArrayBuffer>;
2
22
 
3
23
  /**
4
24
  * DocumentAgent - High-level fluent API for programmatic document manipulation
@@ -94,12 +114,12 @@ declare class DocumentAgent {
94
114
  */
95
115
  constructor(source: Document | ArrayBuffer);
96
116
  /**
97
- * Create a DocumentAgent from an ArrayBuffer (async)
117
+ * Create a DocumentAgent from a DOCX buffer (async)
98
118
  *
99
- * @param buffer - DOCX file as ArrayBuffer
119
+ * @param buffer - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
100
120
  * @returns Promise resolving to DocumentAgent
101
121
  */
102
- static fromBuffer(buffer: ArrayBuffer): Promise<DocumentAgent>;
122
+ static fromBuffer(buffer: DocxInput): Promise<DocumentAgent>;
103
123
  /**
104
124
  * Create a DocumentAgent from a Document object
105
125
  *
@@ -598,12 +618,12 @@ interface ParseOptions {
598
618
  /**
599
619
  * Parse a DOCX file into a complete Document model
600
620
  *
601
- * @param buffer - DOCX file as ArrayBuffer
621
+ * @param input - DOCX file as ArrayBuffer, Uint8Array, Blob, or File
602
622
  * @param options - Parsing options
603
623
  * @returns Promise resolving to Document
604
624
  * @throws Error if parsing fails
605
625
  */
606
- declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions): Promise<Document>;
626
+ declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
607
627
 
608
628
  /**
609
629
  * Document Serializer - Serialize complete document.xml
@@ -1003,4 +1023,4 @@ declare function blendColors(color1: ColorValue | undefined | null, color2: Colo
1003
1023
  */
1004
1024
  declare function colorsEqual(color1: ColorValue | undefined | null, color2: ColorValue | undefined | null, theme: Theme | null | undefined): boolean;
1005
1025
 
1006
- export { resolveColor as $, type AgentContextOptions as A, getDocumentSummary as B, type CreateEmptyDocumentOptions as C, DocumentAgent as D, type ExtendedSelectionContext as E, type FormattedTextSegment as F, getMissingVariables as G, getSelectionFormattingSummary as H, type InsertHyperlinkOptions as I, getTemplateTags as J, halfPointsToPixels as K, isBlack as L, isWhite as M, lightenColor as N, parseColorString as O, type ProcessTemplateOptions as P, parseDocx as Q, pixelsToEmu as R, type SelectionContextOptions$1 as S, type TemplateError as T, pixelsToTwips as U, pointsToPixels as V, previewTemplate as W, processTemplate as X, processTemplateAdvanced as Y, processTemplateAsBlob as Z, processTemplateDetailed as _, type FormattingSummary as a, resolveHighlightColor as a0, resolveShadingColor as a1, serializeDocumentBody as a2, serializeDocument as a3, serializeSectionProperties as a4, twipsToEmu as a5, twipsToPixels as a6, validateTemplate as a7, type InsertImageOptions as b, type InsertTableOptions as c, type InsertTextOptions as d, type ProcessTemplateResult as e, type SelectionContextOptions as f, blendColors as g, buildExtendedSelectionContext as h, buildSelectionContext as i, buildSelectionContext$1 as j, colorsEqual as k, createAgent as l, createAgentFromDocument as m, createDocumentWithText as n, createEmptyDocument as o, createRgbColor as p, createTemplateProcessor as q, createThemeColor as r, darkenColor as s, emuToPixels as t, emuToTwips as u, executeCommand as v, executeCommands as w, formatPx as x, getAgentContext as y, getContrastingColor as z };
1026
+ export { resolveColor as $, type AgentContextOptions as A, getDocumentSummary as B, type CreateEmptyDocumentOptions as C, DocumentAgent as D, type ExtendedSelectionContext as E, type FormattedTextSegment as F, getMissingVariables as G, getSelectionFormattingSummary as H, type InsertHyperlinkOptions as I, getTemplateTags as J, halfPointsToPixels as K, isBlack as L, isWhite as M, lightenColor as N, parseColorString as O, type ProcessTemplateOptions as P, parseDocx as Q, pixelsToEmu as R, type SelectionContextOptions$1 as S, type TemplateError as T, pixelsToTwips as U, pointsToPixels as V, previewTemplate as W, processTemplate as X, processTemplateAdvanced as Y, processTemplateAsBlob as Z, processTemplateDetailed as _, type FormattingSummary as a, resolveHighlightColor as a0, resolveShadingColor as a1, serializeDocumentBody as a2, serializeDocument as a3, serializeSectionProperties as a4, twipsToEmu as a5, twipsToPixels as a6, validateTemplate as a7, type DocxInput as a8, toArrayBuffer as a9, type InsertImageOptions as b, type InsertTableOptions as c, type InsertTextOptions as d, type ProcessTemplateResult as e, type SelectionContextOptions as f, blendColors as g, buildExtendedSelectionContext as h, buildSelectionContext as i, buildSelectionContext$1 as j, colorsEqual as k, createAgent as l, createAgentFromDocument as m, createDocumentWithText as n, createEmptyDocument as o, createRgbColor as p, createTemplateProcessor as q, createThemeColor as r, darkenColor as s, emuToPixels as t, emuToTwips as u, executeCommand as v, executeCommands as w, formatPx as x, getAgentContext as y, getContrastingColor as z };