@eigenpal/docx-js-editor 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-6HBUJFBB.js +1 -0
- package/dist/{chunk-YJJ7HRPG.js → chunk-BQWGTYDH.js} +1 -1
- package/dist/{chunk-T3I3VSJ3.js → chunk-CCXUC6LX.js} +1 -1
- package/dist/{chunk-CDT2SOKB.cjs → chunk-DWFWDKAH.cjs} +2 -2
- package/dist/{chunk-CM5WP7HZ.cjs → chunk-EUHVOGCB.cjs} +2 -2
- package/dist/chunk-FFPSMP4Q.cjs +11 -0
- package/dist/chunk-QB7IFLG2.cjs +1 -0
- package/dist/chunk-ZMWEAP5S.js +11 -0
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.js +1 -1
- package/dist/headless.cjs +2 -2
- package/dist/headless.js +1 -1
- package/dist/index.cjs +24 -25
- package/dist/index.d.cts +211 -45
- package/dist/index.d.ts +211 -45
- package/dist/index.js +24 -25
- package/dist/mcp-cli.js +16 -16
- package/dist/mcp.cjs +2 -2
- package/dist/mcp.js +1 -1
- package/dist/selectionRects-2VAWY4ZQ.cjs +1 -0
- package/dist/selectionRects-ONIZYUUI.js +1 -0
- package/dist/styles.css +1 -1
- package/package.json +9 -11
- package/dist/chunk-7KNRIGGW.cjs +0 -1
- package/dist/chunk-EU5LN2WS.js +0 -11
- package/dist/chunk-G4AXMTQY.cjs +0 -11
- package/dist/chunk-HRPNPUU4.js +0 -1
- package/dist/selectionRects-3PJ6FGHQ.js +0 -1
- package/dist/selectionRects-6QL5E7CE.cjs +0 -1
package/dist/mcp-cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import yt from'pizzip';import xt from'docxtemplater';import ot from'jszip';import {xml2js}from'xml-js';var ct=Object.defineProperty;var Yn=(e,t,n)=>t in e?ct(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var ut=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ft=(e,t)=>()=>(e&&(t=e(e=0)),t);var Kn=(e,t)=>{for(var n in t)ct(e,n,{get:t[n],enumerable:true});};var pe=(e,t,n)=>Yn(e,typeof t!="symbol"?t+"":t,n);var Oe,Q,we=ft(()=>{Oe=class{constructor(){pe(this,"plugins",new Map);pe(this,"commandHandlers",new Map);pe(this,"eventListeners",new Set);pe(this,"initialized",new Set);}register(t,n){let r=[];if(!t.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(t.id))return {success:false,error:`Plugin '${t.id}' is already registered`};if(t.dependencies){for(let o of t.dependencies)if(!this.plugins.has(o))return {success:false,error:`Plugin '${t.id}' requires '${o}' which is not registered`}}if(t.commandHandlers)for(let[o,i]of Object.entries(t.commandHandlers)){if(this.commandHandlers.has(o)){let s=this.commandHandlers.get(o);r.push(`Command '${o}' from '${t.id}' overrides handler from '${s.pluginId}'`);}this.commandHandlers.set(o,{pluginId:t.id,handler:i});}if(this.plugins.set(t.id,t),t.initialize&&!this.initialized.has(t.id))try{let o=t.initialize();o instanceof Promise?o.then(()=>{this.initialized.add(t.id);}).catch(i=>{this.emit({type:"error",pluginId:t.id,error:i});}):this.initialized.add(t.id);}catch(o){this.emit({type:"error",pluginId:t.id,error:o});}return n?.debug&&console.log(`[PluginRegistry] Registered plugin: ${t.id}`),this.emit({type:"registered",plugin:t}),{success:true,plugin:t,warnings:r.length>0?r:void 0}}unregister(t){let n=this.plugins.get(t);if(!n)return false;for(let[r,o]of this.plugins)if(o.dependencies?.includes(t))return console.warn(`Cannot unregister '${t}': '${r}' depends on it`),false;for(let[r,{pluginId:o}]of this.commandHandlers)o===t&&this.commandHandlers.delete(r);if(n.destroy)try{let r=n.destroy();r instanceof Promise&&r.catch(o=>{this.emit({type:"error",pluginId:t,error:o});});}catch(r){this.emit({type:"error",pluginId:t,error:r});}return this.plugins.delete(t),this.initialized.delete(t),this.emit({type:"unregistered",pluginId:t}),true}get(t){return this.plugins.get(t)}getAll(){return Array.from(this.plugins.values())}has(t){return this.plugins.has(t)}get size(){return this.plugins.size}getCommandHandler(t){return this.commandHandlers.get(t)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(t){return this.commandHandlers.has(t)}getMcpTools(){let t=[];for(let n of this.plugins.values())n.mcpTools&&t.push(...n.mcpTools);return t}getMcpToolsForPlugin(t){return this.plugins.get(t)?.mcpTools||[]}getMcpTool(t){for(let n of this.plugins.values())if(n.mcpTools){let r=n.mcpTools.find(o=>o.name===t);if(r)return r}}addEventListener(t){this.eventListeners.add(t);}removeEventListener(t){this.eventListeners.delete(t);}emit(t){for(let n of this.eventListeners)try{n(t);}catch(r){console.error("[PluginRegistry] Event listener error:",r);}}clear(){for(let t of this.plugins.values())if(t.destroy)try{t.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(t=>t.name),initialized:Array.from(this.initialized)}}},Q=new Oe;});var An={};Kn(An,{default:()=>gi,executeCommand:()=>Z,executeCommands:()=>ei});function Z(e,t){let n=Q.getCommandHandler(t.type);if(n)return n(e,t);switch(t.type){case "insertText":return ti(e,t);case "replaceText":return ni(e,t);case "deleteText":return ri(e,t);case "formatText":return oi(e,t);case "formatParagraph":return ii(e,t);case "applyStyle":return si(e,t);case "insertTable":return ai(e,t);case "insertImage":return li(e,t);case "insertHyperlink":return ci(e,t);case "removeHyperlink":return ui(e,t);case "insertParagraphBreak":return Dn(e,t);case "mergeParagraphs":return fi(e,t);case "splitParagraph":return pi(e,t);case "setVariable":return di(e,t);case "applyVariables":return mi(e,t);default:let r=t;throw new Error(`Unknown command type: ${r.type}`)}}function ei(e,t){return t.reduce((n,r)=>Z(n,r),e)}function X(e){return JSON.parse(JSON.stringify(e))}function L(e,t){let n=0;for(let r=0;r<e.content.length;r++)if(e.content[r].type==="paragraph"){if(n===t)return r;n++;}return -1}function he(e){let t="";for(let n of e.content)if(n.type==="run")for(let r of n.content)r.type==="text"&&(t+=r.text);else if(n.type==="hyperlink"){for(let r of n.children)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}return t}function Be(e,t){return {type:"run",formatting:t,content:[{type:"text",text:e}]}}function $e(e,t,n,r){let o=[],i=0,s=false;for(let a of e.content)if(a.type==="run"){let l=a.content.filter(d=>d.type==="text").map(d=>d.text).join(""),f=i,p=i+l.length;if(!s&&t>=f&&t<=p){let d=t-f;d>0&&o.push({...a,content:[{type:"text",text:l.slice(0,d)}]}),o.push(Be(n,r||a.formatting)),d<l.length&&o.push({...a,content:[{type:"text",text:l.slice(d)}]}),s=true;}else o.push(a);i=p;}else o.push(a);return s||o.push(Be(n,r)),o}function ee(e,t,n){let r=[],o=0;for(let i of e.content)if(i.type==="run"){let s=i.content.filter(f=>f.type==="text").map(f=>f.text).join(""),a=o,l=o+s.length;if(l<=t||a>=n)r.push(i);else {let f="";a<t&&(f+=s.slice(0,t-a)),l>n&&(f+=s.slice(n-a)),f.length>0&&r.push({...i,content:[{type:"text",text:f}]});}o=l;}else r.push(i);return r}function In(e,t,n,r){let o=[],i=0;for(let s of e.content)if(s.type==="run"){let a=s.content.filter(p=>p.type==="text").map(p=>p.text).join(""),l=i,f=i+a.length;if(f<=t||l>=n)o.push(s);else if(l>=t&&f<=n)o.push({...s,formatting:{...s.formatting,...r}});else {let p=Math.max(t,l),d=Math.min(n,f);l<p&&o.push({...s,content:[{type:"text",text:a.slice(0,p-l)}]}),o.push({...s,formatting:{...s.formatting,...r},content:[{type:"text",text:a.slice(p-l,d-l)}]}),f>d&&o.push({...s,content:[{type:"text",text:a.slice(d-l)}]});}i=f;}else o.push(s);return o}function ti(e,t){let n=X(e),r=n.package.document,o=L(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o];return i.content=$e(i,t.position.offset,t.text,t.formatting),n}function ni(e,t){let n=X(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=L(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=ee(a,o.offset,i.offset),a.content=$e(a,o.offset,t.text,t.formatting);}else {let s=L(r,o.paragraphIndex),a=r.content[s],l=he(a);a.content=ee(a,o.offset,l.length),a.content=$e(a,o.offset,t.text,t.formatting);let f=[];for(let p=o.paragraphIndex+1;p<=i.paragraphIndex;p++)f.push(L(r,p));for(let p=f.length-1;p>=0;p--)f[p]!==-1&&r.content.splice(f[p],1);}return n}function ri(e,t){let n=X(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=L(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=ee(a,o.offset,i.offset);}else {let s=L(r,o.paragraphIndex),a=r.content[s],l=he(a);a.content=ee(a,o.offset,l.length);let f=L(r,i.paragraphIndex),p=r.content[f];p.content=ee(p,0,i.offset),a.content.push(...p.content);let d=[];for(let w=o.paragraphIndex+1;w<=i.paragraphIndex;w++)d.push(L(r,w));for(let w=d.length-1;w>=0;w--)d[w]!==-1&&r.content.splice(d[w],1);}return n}function oi(e,t){let n=X(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=L(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=In(a,o.offset,i.offset,t.formatting);}else for(let s=o.paragraphIndex;s<=i.paragraphIndex;s++){let a=L(r,s);if(a===-1)continue;let l=r.content[a],f=he(l),p=0,d=f.length;s===o.paragraphIndex&&(p=o.offset),s===i.paragraphIndex&&(d=i.offset),l.content=In(l,p,d,t.formatting);}return n}function ii(e,t){let n=X(e),r=n.package.document,o=L(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o];if(i.formatting={...i.formatting,...t.formatting},"numPr"in t.formatting){let s=t.formatting.numPr;if(s&&s.numId!==void 0&&s.numId!==0){let a=s.ilvl??0,l=s.numId===1,f=l?"\u2022":"1.";if(n.package.numbering){let p=n.package.numbering.nums.find(d=>d.numId===s.numId);if(p){let d=n.package.numbering.abstractNums.find(w=>w.abstractNumId===p.abstractNumId);if(d){let w=d.levels.find(g=>g.ilvl===a);w&&(f=w.lvlText||f);}}}i.listRendering={level:a,numId:s.numId,marker:f,isBullet:l};}else delete i.listRendering;}return n}function si(e,t){let n=X(e),r=n.package.document,o=L(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o];return i.formatting={...i.formatting,styleId:t.styleId},n}function ai(e,t){let n=X(e),r=n.package.document,o=[];for(let a=0;a<t.rows;a++){let l=[];for(let f=0;f<t.columns;f++){let p=t.data?.[a]?.[f]||"";l.push({type:"tableCell",content:[{type:"paragraph",content:p?[Be(p)]:[]}]});}o.push({type:"tableRow",formatting:a===0&&t.hasHeader?{header:true}:void 0,cells:l});}let i={type:"table",rows:o},s=L(r,t.position.paragraphIndex);return s===-1?r.content.push(i):r.content.splice(s+1,0,i),n}function li(e,t){let n=X(e),r=n.package.document,o=L(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:t.src,alt:t.alt,size:{width:(t.width||100)*914400,height:(t.height||100)*914400},wrap:{type:"inline"}}}]},l=$e(i,t.position.offset,"",void 0),f=false,p=0;for(let d=0;d<l.length;d++){let w=l[d];if(w.type==="run"){let g=w.content.filter(m=>m.type==="text").map(m=>m.text).join("");if(p+=g.length,!f&&p>=t.position.offset){l.splice(d+1,0,a),f=true;break}}}return f||l.push(a),i.content=l,n}function ci(e,t){let n=X(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex!==i.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let s=L(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s],l=he(a),f=t.displayText||l.slice(o.offset,i.offset);a.content=ee(a,o.offset,i.offset);let p={type:"hyperlink",href:t.url,tooltip:t.tooltip,children:[Be(f)]},d=false,w=0,g=[];for(let m of a.content)if(m.type==="run"){let b=m.content.filter(k=>k.type==="text").map(k=>k.text).join(""),D=w+b.length;if(!d&&w<=o.offset&&o.offset<=D){let k=o.offset-w;k>0&&g.push({...m,content:[{type:"text",text:b.slice(0,k)}]}),g.push(p),k<b.length&&g.push({...m,content:[{type:"text",text:b.slice(k)}]}),d=true;}else g.push(m);w=D;}else g.push(m);return d||g.push(p),a.content=g,n}function ui(e,t){let n=X(e),r=n.package.document,{start:o}=t.range,i=L(r,o.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let s=r.content[i],a=[];for(let l of s.content)if(l.type==="hyperlink")for(let f of l.children)f.type==="run"&&a.push(f);else a.push(l);return s.content=a,n}function Dn(e,t){let n=X(e),r=n.package.document,o=L(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o],s=he(i),a=ee({...i,content:[...i.content]},t.position.offset,s.length),l=ee({...i,content:[...i.content]},0,t.position.offset);i.content=a;let f={type:"paragraph",formatting:i.formatting,content:l};return r.content.splice(o+1,0,f),n}function fi(e,t){let n=X(e),r=n.package.document,o=L(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o],s=[];for(let a=1;a<=t.count;a++){let l=L(r,t.paragraphIndex+a);if(l!==-1){let f=r.content[l];i.content.push(...f.content),s.push(l);}}for(let a=s.length-1;a>=0;a--)r.content.splice(s[a],1);return n}function pi(e,t){return Dn(e,{position:t.position})}function di(e,t){let n=X(e);return n.templateVariables||(n.templateVariables=[]),n.templateVariables.includes(t.name)||n.templateVariables.push(t.name),n}function mi(e,t){let n=X(e),r=n.package.document;function o(a){for(let l of a.content)if(l.type==="text")for(let[f,p]of Object.entries(t.values)){let d=new RegExp(`\\{${f}\\}`,"g");l.text=l.text.replace(d,p);}}function i(a){for(let l of a.content)if(l.type==="run")o(l);else if(l.type==="hyperlink")for(let f of l.children)f.type==="run"&&o(f);}function s(a){if(a.type==="paragraph")i(a);else if(a.type==="table")for(let l of a.rows)for(let f of l.cells)for(let p of f.content)s(p);}for(let a of r.content)s(a);return n}var gi,et=ft(()=>{we();gi=Z;});we();function ze(e,t){let n=t,{position:r,variableName:o}=n,i=JSON.parse(JSON.stringify(e)),a=i.package.document.content.filter(p=>p.type==="paragraph");if(r.paragraphIndex>=a.length)throw new Error(`Paragraph index ${r.paragraphIndex} out of bounds`);let l=a[r.paragraphIndex],f=`{{${o}}}`;return pt(l,r.offset,f),i.templateVariables||(i.templateVariables=[]),i.templateVariables.includes(o)||i.templateVariables.push(o),i}function Ve(e,t){let n=t,{range:r,variableName:o}=n,i=JSON.parse(JSON.stringify(e)),a=i.package.document.content.filter(p=>p.type==="paragraph");if(r.start.paragraphIndex!==r.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(r.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${r.start.paragraphIndex} out of bounds`);let l=a[r.start.paragraphIndex];Qn(l,r.start.offset,r.end.offset);let f=`{{${o}}}`;return pt(l,r.start.offset,f),i.templateVariables||(i.templateVariables=[]),i.templateVariables.includes(o)||i.templateVariables.push(o),i}function pt(e,t,n){let r=0,o=false;for(let i=0;i<e.content.length;i++){let s=e.content[i];if(s.type==="run"){let a=je(s),l=r,f=r+a.length;if(!o&&t>=l&&t<=f){let p=t-l,d=a.slice(0,p),w=a.slice(p),g=[];for(let m=0;m<i;m++)g.push(e.content[m]);d&&g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:d}]}),g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:n}]}),w&&g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:w}]});for(let m=i+1;m<e.content.length;m++)g.push(e.content[m]);e.content=g,o=true;break}r=f;}else if(s.type==="hyperlink")for(let a of s.children)a.type==="run"&&(r+=je(a).length);}o||e.content.push({type:"run",content:[{type:"text",text:n}]});}function Qn(e,t,n){let r=[],o=0;for(let i of e.content)if(i.type==="run"){let s=je(i),a=o,l=o+s.length;if(l<=t||a>=n)r.push(i);else {let f="";a<t&&(f+=s.slice(0,t-a)),l>n&&(f+=s.slice(n-a)),f.length>0&&r.push({type:"run",formatting:i.formatting,content:[{type:"text",text:f}]});}o=l;}else r.push(i);e.content=r;}function je(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function gt(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let o=er(e.package.document);o.forEach(i=>{t.push({name:i,location:"body"});}),n.body=Array.from(new Set(o)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((o,i)=>{o.properties.headerReferences&&o.properties.headerReferences.forEach(s=>{});}),e.package?.footnotes){let o=mt(e.package.footnotes);o.forEach(i=>{t.push({name:i,location:"footnote"});}),n.footnotes=Array.from(new Set(o)).sort();}if(e.package?.endnotes){let o=mt(e.package.endnotes);o.forEach(i=>{t.push({name:i,location:"endnote"});}),n.endnotes=Array.from(new Set(o)).sort();}e.templateVariables&&e.templateVariables.forEach(o=>{t.some(i=>i.name===o)||t.push({name:o,location:"body"});});let r=new Set;return t.forEach(o=>r.add(o.name)),{variables:Array.from(r).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function er(e){let t=[];if(e.content&&t.push(...dt(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...dt(n.content));return t}function dt(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(..._e(n)):n.type==="table"&&t.push(...ht(n));return t}function _e(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...de(n)):n.type==="hyperlink"?t.push(...tr(n)):n.type==="simpleField"?t.push(...nr(n)):n.type==="complexField"&&t.push(...rr(n));return t}function de(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...wt(n.text));return t}function tr(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...de(n));return t}function nr(e){let t=[];if(e.instruction&&t.push(...wt(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...de(n));return t}function rr(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...de(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...de(n));return t}function ht(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let r of n.cells)t.push(...or(r));return t}function or(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(..._e(n)):n.type==="table"&&t.push(...ht(n));return t}function mt(e){let t=[];for(let n of e)if(n.content)for(let r of n.content)t.push(..._e(r));return t}var ir=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function wt(e){if(!e)return [];let t=[],n=new RegExp(ir),r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t}function bt(e,t,n={}){let{nullGetter:r="keep",linebreaks:o=true,delimiters:i}=n,s=[],a=[],l=[];try{let f=new yt(e),p=new xt(f,{paragraphLoop:!0,linebreaks:o,nullGetter:w=>{let g=w.value||"";if(r==="error")throw new Error(`Undefined variable: ${g}`);return r==="empty"?(l.push(g),""):(l.push(g),`{${g}}`)},delimiters:i?{start:i.start||"{",end:i.end||"}"}:void 0});return Object.keys(t).forEach(w=>{t[w]!==void 0&&t[w]!==null&&a.push(w);}),p.setData(t),p.render(),{buffer:p.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:a,unreplacedVariables:l,warnings:s}}catch(f){throw Ct(f)}}function Tt(e){let t=[],n=[];try{let r=new yt(e),i=new xt(r,{paragraphLoop:!0,linebreaks:!0}).getFullText();n=sr(i);let s=ar(i);for(let a of s)t.push({message:`Unclosed tag: ${a}`,variable:a,type:"parse"});return {valid:t.length===0,errors:t,tags:n}}catch(r){return t.push(Ct(r)),{valid:false,errors:t,tags:n}}}function sr(e){let t=[],n=/\{([^{}]+)\}/g,r;for(;(r=n.exec(e))!==null;){let o=r[1].trim();o&&!t.includes(o)&&t.push(o);}return t.sort()}function ar(e){let t=[],n=0,r="";for(let o of e)o==="{"?(n++,r=""):o==="}"?(n--,n<0&&(n=0)):n>0&&(r+=o);return n>0&&r.trim()&&t.push(r.trim()),t}function lr(e){return "properties"in e&&typeof e.properties=="object"}function Ct(e){if(e instanceof Error){if(lr(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"}}async function Ft(e){let t=await ot.loadAsync(e),n={documentXml:null,stylesXml:null,themeXml:null,numberingXml:null,fontTableXml:null,settingsXml:null,webSettingsXml:null,headers:new Map,footers:new Map,footnotesXml:null,endnotesXml:null,commentsXml:null,documentRels:null,packageRels:null,contentTypesXml:null,corePropsXml:null,appPropsXml:null,customPropsXml:null,media:new Map,fonts:new Map,allXml:new Map,originalZip:t,originalBuffer:e};for(let[r,o]of Object.entries(t.files)){if(o.dir)continue;let i=r.toLowerCase();if(i.endsWith(".xml")||i.endsWith(".rels")){let s=await o.async("text");if(n.allXml.set(r,s),i==="word/document.xml")n.documentXml=s;else if(i==="word/styles.xml")n.stylesXml=s;else if(i==="word/theme/theme1.xml")n.themeXml=s;else if(i==="word/numbering.xml")n.numberingXml=s;else if(i==="word/fonttable.xml")n.fontTableXml=s;else if(i==="word/settings.xml")n.settingsXml=s;else if(i==="word/websettings.xml")n.webSettingsXml=s;else if(i==="word/footnotes.xml")n.footnotesXml=s;else if(i==="word/endnotes.xml")n.endnotesXml=s;else if(i==="word/comments.xml")n.commentsXml=s;else if(i==="word/_rels/document.xml.rels")n.documentRels=s;else if(i==="_rels/.rels")n.packageRels=s;else if(i==="[content_types].xml")n.contentTypesXml=s;else if(i==="docprops/core.xml")n.corePropsXml=s;else if(i==="docprops/app.xml")n.appPropsXml=s;else if(i==="docprops/custom.xml")n.customPropsXml=s;else if(i.match(/^word\/header\d+\.xml$/)){let a=r.split("/").pop()||r;n.headers.set(a,s);}else if(i.match(/^word\/footer\d+\.xml$/)){let a=r.split("/").pop()||r;n.footers.set(a,s);}}else if(i.startsWith("word/media/")){let s=await o.async("arraybuffer");n.media.set(r,s);}else if(i.startsWith("word/fonts/")){let s=await o.async("arraybuffer");n.fonts.set(r,s);}}return n}function St(e){switch(e.toLowerCase().split(".").pop()){case "png":return "image/png";case "jpg":case "jpeg":return "image/jpeg";case "gif":return "image/gif";case "bmp":return "image/bmp";case "tif":case "tiff":return "image/tiff";case "wmf":return "image/x-wmf";case "emf":return "image/x-emf";case "svg":return "image/svg+xml";case "webp":return "image/webp";default:return "application/octet-stream"}}function W(e){return xml2js(e,{compact:false,ignoreComment:true,ignoreInstruction:true,ignoreDoctype:true,alwaysArray:false,trim:false,attributesKey:"attributes",textKey:"text"})}function U(e){try{let t=W(e);return t.elements&&t.elements.length>0?t.elements.find(n=>n.type==="element")??null:t}catch(t){return console.warn("Failed to parse XML:",t),null}}function ye(e){let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function u(e,t,n){if(!e||!e.elements)return null;let r=`${t}:${n}`;for(let o of e.elements)if(o.type==="element"&&(o.name===r||ye(o.name||"")===n))return o;return null}function A(e,t,n){if(!e||!e.elements)return [];let r=`${t}:${n}`,o=[];for(let i of e.elements)i.type==="element"&&(i.name===r||ye(i.name||"")===n)&&o.push(i);return o}function N(e){return !e||!e.elements?[]:e.elements.filter(t=>t.type==="element")}function c(e,t,n){if(!e||!e.attributes)return null;let r=e.attributes;if(t){let o=`${t}:${n}`;if(o in r)return r[o]}return n in r?r[n]:null}function xe(e){if(!e)return "";if("text"in e&&typeof e.text=="string")return e.text;if(!e.elements)return "";let t="";for(let n of e.elements)n.type==="text"&&"text"in n?t+=n.text??"":n.type==="element"&&(t+=xe(n));return t}function vt(e){return e?{val:c(e,"w","val")??void 0,themeColor:c(e,"w","themeColor")??void 0,themeTint:c(e,"w","themeTint")??void 0,themeShade:c(e,"w","themeShade")??void 0}:null}function h(e,t,n,r=1){let o=c(e,t,n);if(o===null)return;let i=parseInt(o,10);if(!isNaN(i))return i*r}function T(e,t="w"){if(!e)return false;let n=c(e,t,"val");return n===null?true:!(n==="0"||n==="false"||n==="off")}var be={hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",header:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",footer:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"};function Te(e){let t=new Map;if(!e||e.trim().length===0)return t;let n=U(e);if(!n)return console.warn("Failed to parse relationships XML"),t;let r=N(n);for(let o of r){let i=o.name||"";if(!i.endsWith("Relationship")&&!i.includes(":Relationship"))continue;let s=c(o,null,"Id"),a=c(o,null,"Type"),l=c(o,null,"Target"),f=c(o,null,"TargetMode");if(!s||!a||!l){console.warn("Relationship missing required attributes:",{id:s,type:a,target:l});continue}let p={id:s,type:a,target:l};f==="External"?p.targetMode="External":f==="Internal"&&(p.targetMode="Internal"),t.set(s,p);}return t}function kt(e){return e.type===be.hyperlink&&e.targetMode==="External"}var Mt={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Ce={majorFont:{latin:"Calibri Light",ea:"",cs:"",fonts:{}},minorFont:{latin:"Calibri",ea:"",cs:"",fonts:{}}},We={name:"Office Theme",colorScheme:Mt,fontScheme:Ce},fr=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function pr(e){if(!e)return null;switch(ye(e.name||"")){case "srgbClr":return c(e,"a","val")??c(e,null,"val")??null;case "sysClr":{let n=c(e,"a","lastClr")??c(e,null,"lastClr");if(n)return n;switch(c(e,"a","val")??c(e,null,"val")){case "windowText":case "menuText":case "captionText":case "btnText":return "000000";case "window":case "menu":case "btnFace":case "btnHighlight":return "FFFFFF";case "highlight":return "0078D7";case "highlightText":return "FFFFFF";case "grayText":return "808080";default:return null}}case "schemeClr":{c(e,"a","val")??c(e,null,"val");return null}default:return null}}function dr(e){let t={...Mt};if(!e)return t;for(let n of fr){let r=u(e,"a",n);if(r){let o=N(r);if(o.length>0){let i=pr(o[0]);i&&(t[n]=i);}}}return t}function Pt(e){let t={latin:"",ea:"",cs:"",fonts:{}};if(!e)return t;let n=u(e,"a","latin");n&&(t.latin=c(n,"a","typeface")??c(n,null,"typeface")??"");let r=u(e,"a","ea");r&&(t.ea=c(r,"a","typeface")??c(r,null,"typeface")??"");let o=u(e,"a","cs");o&&(t.cs=c(o,"a","typeface")??c(o,null,"typeface")??"");let i=A(e,"a","font");for(let s of i){let a=c(s,"a","script")??c(s,null,"script"),l=c(s,"a","typeface")??c(s,null,"typeface");a&&l&&(t.fonts=t.fonts||{},t.fonts[a]=l);}return t}function mr(e){let t={...Ce};if(!e)return t;let n=u(e,"a","majorFont");n&&(t.majorFont=Pt(n));let r=u(e,"a","minorFont");return r&&(t.minorFont=Pt(r)),t}function Et(e){if(!e)return {...We};try{let t=U(e);if(!t)return {...We};let n=c(t,"a","name")??c(t,null,"name")??"Office Theme",r=u(t,"a","themeElements"),o=u(r,"a","clrScheme"),i=dr(o),s=u(r,"a","fontScheme"),a=mr(s);return {name:n,colorScheme:i,fontScheme:a}}catch(t){return console.warn("Failed to parse theme:",t),{...We}}}function gr(e,t="latin"){if(!e?.fontScheme?.majorFont)return Ce.majorFont?.latin??"Calibri Light";let n=e.fontScheme.majorFont;return t==="latin"?n.latin||"Calibri Light":t==="ea"?n.ea||"":t==="cs"?n.cs||"":n.fonts?.[t]?n.fonts[t]:n.latin||"Calibri Light"}function Rt(e,t="latin"){if(!e?.fontScheme?.minorFont)return Ce.minorFont?.latin??"Calibri";let n=e.fontScheme.minorFont;return t==="latin"?n.latin||"Calibri":t==="ea"?n.ea||"":t==="cs"?n.cs||"":n.fonts?.[t]?n.fonts[t]:n.latin||"Calibri"}function _(e,t){if(!t)return "Calibri";let n=t.toLowerCase().includes("major"),r=t.toLowerCase().includes("minor"),o="latin",i=t.toLowerCase();return i.includes("eastasia")?o="ea":(i.includes("bidi")||i.includes("cs"))&&(o="cs"),n?gr(e,o):r?Rt(e,o):Rt(e,"latin")}function Fe(e,t){if(!e)return;let n={},r=u(e,"w","b");r&&(n.bold=T(r));let o=u(e,"w","bCs");o&&(n.boldCs=T(o));let i=u(e,"w","i");i&&(n.italic=T(i));let s=u(e,"w","iCs");s&&(n.italicCs=T(s));let a=u(e,"w","u");if(a){let P=c(a,"w","val");if(P){n.underline={style:P};let v=c(a,"w","color"),O=c(a,"w","themeColor");(v||O)&&(n.underline.color=Ue(v,O,c(a,"w","themeTint"),c(a,"w","themeShade")));}}let l=u(e,"w","strike");l&&(n.strike=T(l));let f=u(e,"w","dstrike");f&&(n.doubleStrike=T(f));let p=u(e,"w","vertAlign");if(p){let P=c(p,"w","val");(P==="superscript"||P==="subscript"||P==="baseline")&&(n.vertAlign=P);}let d=u(e,"w","smallCaps");d&&(n.smallCaps=T(d));let w=u(e,"w","caps");w&&(n.allCaps=T(w));let g=u(e,"w","vanish");g&&(n.hidden=T(g));let m=u(e,"w","color");m&&(n.color=Ue(c(m,"w","val"),c(m,"w","themeColor"),c(m,"w","themeTint"),c(m,"w","themeShade")));let b=u(e,"w","highlight");if(b){let P=c(b,"w","val");P&&(n.highlight=P);}let D=u(e,"w","shd");D&&(n.shading=Se(D));let k=u(e,"w","sz");if(k){let P=h(k,"w","val");P!==void 0&&(n.fontSize=P);}let M=u(e,"w","szCs");if(M){let P=h(M,"w","val");P!==void 0&&(n.fontSizeCs=P);}let R=u(e,"w","rFonts");if(R){n.fontFamily={ascii:c(R,"w","ascii")??void 0,hAnsi:c(R,"w","hAnsi")??void 0,eastAsia:c(R,"w","eastAsia")??void 0,cs:c(R,"w","cs")??void 0};let P=c(R,"w","asciiTheme");P&&(n.fontFamily.asciiTheme=P,t&&!n.fontFamily.ascii&&(n.fontFamily.ascii=_(t,P)));let v=c(R,"w","hAnsiTheme");v&&(n.fontFamily.hAnsiTheme=v,t&&!n.fontFamily.hAnsi&&(n.fontFamily.hAnsi=_(t,v)));let O=c(R,"w","eastAsiaTheme");O&&(n.fontFamily.eastAsiaTheme=O,t&&!n.fontFamily.eastAsia&&(n.fontFamily.eastAsia=_(t,O)));let V=c(R,"w","cstheme");V&&(n.fontFamily.csTheme=V,t&&!n.fontFamily.cs&&(n.fontFamily.cs=_(t,V)));}let y=u(e,"w","spacing");if(y){let P=h(y,"w","val");P!==void 0&&(n.spacing=P);}let C=u(e,"w","position");if(C){let P=h(C,"w","val");P!==void 0&&(n.position=P);}let x=u(e,"w","w");if(x){let P=h(x,"w","val");P!==void 0&&(n.scale=P);}let F=u(e,"w","kern");if(F){let P=h(F,"w","val");P!==void 0&&(n.kerning=P);}let S=u(e,"w","effect");if(S){let P=c(S,"w","val");P&&(n.effect=P);}let E=u(e,"w","em");if(E){let P=c(E,"w","val");P&&(n.emphasisMark=P);}let I=u(e,"w","emboss");I&&(n.emboss=T(I));let $=u(e,"w","imprint");$&&(n.imprint=T($));let z=u(e,"w","outline");z&&(n.outline=T(z));let le=u(e,"w","shadow");le&&(n.shadow=T(le));let ce=u(e,"w","rtl");ce&&(n.rtl=T(ce));let ue=u(e,"w","cs");ue&&(n.cs=T(ue));let fe=u(e,"w","rStyle");if(fe){let P=c(fe,"w","val");P&&(n.styleId=P);}return Object.keys(n).length>0?n:void 0}function Ue(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Se(e){if(!e)return;let t={},n=c(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=c(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=c(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=c(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=c(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=c(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function j(e){if(!e)return;let t=c(e,"w","val");if(!t)return;let n={style:t},r=c(e,"w","color"),o=c(e,"w","themeColor");(r||o)&&(n.color=Ue(r,o,c(e,"w","themeTint"),c(e,"w","themeShade")));let i=h(e,"w","sz");i!==void 0&&(n.size=i);let s=h(e,"w","space");s!==void 0&&(n.space=s);let a=c(e,"w","shadow");a&&(n.shadow=a==="1"||a==="true");let l=c(e,"w","frame");return l&&(n.frame=l==="1"||l==="true"),n}function hr(e){if(!e)return;let t=A(e,"w","tab");if(t.length===0)return;let n=[];for(let r of t){let o=h(r,"w","pos"),i=c(r,"w","val");if(o!==void 0&&i){let s={position:o,alignment:i},a=c(r,"w","leader");a&&(s.leader=a),n.push(s);}}return n.length>0?n:void 0}function qe(e,t){if(!e)return;let n={},r=u(e,"w","jc");if(r){let y=c(r,"w","val");y&&(n.alignment=y);}let o=u(e,"w","bidi");o&&(n.bidi=T(o));let i=u(e,"w","spacing");if(i){let y=h(i,"w","before");y!==void 0&&(n.spaceBefore=y);let C=h(i,"w","after");C!==void 0&&(n.spaceAfter=C);let x=h(i,"w","line");x!==void 0&&(n.lineSpacing=x);let F=c(i,"w","lineRule");F&&(n.lineSpacingRule=F);let S=c(i,"w","beforeAutospacing");S&&(n.beforeAutospacing=S==="1"||S==="true");let E=c(i,"w","afterAutospacing");E&&(n.afterAutospacing=E==="1"||E==="true");}let s=u(e,"w","ind");if(s){let y=h(s,"w","left");y!==void 0&&(n.indentLeft=y);let C=h(s,"w","right");C!==void 0&&(n.indentRight=C);let x=h(s,"w","firstLine");x!==void 0&&(n.indentFirstLine=x);let F=h(s,"w","hanging");F!==void 0&&(n.indentFirstLine=-F,n.hangingIndent=true);}let a=u(e,"w","pBdr");if(a){let y={},C=j(u(a,"w","top"));C&&(y.top=C);let x=j(u(a,"w","bottom"));x&&(y.bottom=x);let F=j(u(a,"w","left"));F&&(y.left=F);let S=j(u(a,"w","right"));S&&(y.right=S);let E=j(u(a,"w","between"));E&&(y.between=E);let I=j(u(a,"w","bar"));I&&(y.bar=I),Object.keys(y).length>0&&(n.borders=y);}let l=u(e,"w","shd");l&&(n.shading=Se(l));let f=u(e,"w","tabs");f&&(n.tabs=hr(f));let p=u(e,"w","keepNext");p&&(n.keepNext=T(p));let d=u(e,"w","keepLines");d&&(n.keepLines=T(d));let w=u(e,"w","widowControl");w&&(n.widowControl=T(w));let g=u(e,"w","pageBreakBefore");g&&(n.pageBreakBefore=T(g));let m=u(e,"w","numPr");if(m){let y=u(m,"w","numId"),C=u(m,"w","ilvl");if(y||C){if(n.numPr={},y){let x=h(y,"w","val");x!==void 0&&(n.numPr.numId=x);}if(C){let x=h(C,"w","val");x!==void 0&&(n.numPr.ilvl=x);}}}let b=u(e,"w","outlineLvl");if(b){let y=h(b,"w","val");y!==void 0&&(n.outlineLevel=y);}let D=u(e,"w","pStyle");if(D){let y=c(D,"w","val");y&&(n.styleId=y);}let k=u(e,"w","suppressLineNumbers");k&&(n.suppressLineNumbers=T(k));let M=u(e,"w","suppressAutoHyphens");M&&(n.suppressAutoHyphens=T(M));let R=u(e,"w","rPr");return R&&(n.runProperties=Fe(R,t)),Object.keys(n).length>0?n:void 0}function q(e){if(!e)return;let t=h(e,"w","w"),n=c(e,"w","type");if(t!==void 0&&n)return {value:t,type:n}}function Bt(e){if(!e)return;let t={},n=j(u(e,"w","top"));n&&(t.top=n);let r=j(u(e,"w","bottom"));r&&(t.bottom=r);let o=j(u(e,"w","left"));o&&(t.left=o);let i=j(u(e,"w","right"));i&&(t.right=i);let s=j(u(e,"w","insideH"));s&&(t.insideH=s);let a=j(u(e,"w","insideV"));return a&&(t.insideV=a),Object.keys(t).length>0?t:void 0}function $t(e){if(!e)return;let t={},n=q(u(e,"w","top"));n&&(t.top=n);let r=q(u(e,"w","bottom"));r&&(t.bottom=r);let o=q(u(e,"w","left"));o&&(t.left=o);let i=q(u(e,"w","right"));return i&&(t.right=i),Object.keys(t).length>0?t:void 0}function wr(e){if(!e)return;let t={},n=c(e,"w","val");if(n){let f=parseInt(n,16);isNaN(f)||(t.firstRow=(f&32)!==0,t.lastRow=(f&64)!==0,t.firstColumn=(f&128)!==0,t.lastColumn=(f&256)!==0,t.noHBand=(f&512)!==0,t.noVBand=(f&1024)!==0);}let r=c(e,"w","firstColumn");r&&(t.firstColumn=r==="1");let o=c(e,"w","firstRow");o&&(t.firstRow=o==="1");let i=c(e,"w","lastColumn");i&&(t.lastColumn=i==="1");let s=c(e,"w","lastRow");s&&(t.lastRow=s==="1");let a=c(e,"w","noHBand");a&&(t.noHBand=a==="1");let l=c(e,"w","noVBand");return l&&(t.noVBand=l==="1"),Object.keys(t).length>0?t:void 0}function It(e,t){if(!e)return;let n={},r=u(e,"w","tblW");r&&(n.width=q(r));let o=u(e,"w","jc");if(o){let m=c(o,"w","val");(m==="left"||m==="center"||m==="right")&&(n.justification=m);}let i=u(e,"w","tblCellSpacing");i&&(n.cellSpacing=q(i));let s=u(e,"w","tblInd");s&&(n.indent=q(s));let a=u(e,"w","tblBorders");a&&(n.borders=Bt(a));let l=u(e,"w","tblCellMar");l&&(n.cellMargins=$t(l));let f=u(e,"w","tblLayout");if(f){let m=c(f,"w","type");(m==="fixed"||m==="autofit")&&(n.layout=m);}let p=u(e,"w","tblStyle");if(p){let m=c(p,"w","val");m&&(n.styleId=m);}let d=u(e,"w","tblLook");d&&(n.look=wr(d));let w=u(e,"w","shd");w&&(n.shading=Se(w));let g=u(e,"w","bidiVisual");return g&&(n.bidi=T(g)),Object.keys(n).length>0?n:void 0}function Dt(e){if(!e)return;let t={},n=u(e,"w","trHeight");if(n){t.height=q(n);let a=c(n,"w","hRule");a&&(t.heightRule=a);}let r=u(e,"w","tblHeader");r&&(t.header=T(r));let o=u(e,"w","cantSplit");o&&(t.cantSplit=T(o));let i=u(e,"w","jc");if(i){let a=c(i,"w","val");(a==="left"||a==="center"||a==="right")&&(t.justification=a);}let s=u(e,"w","hidden");return s&&(t.hidden=T(s)),Object.keys(t).length>0?t:void 0}function At(e,t){if(!e)return;let n={},r=u(e,"w","tcW");r&&(n.width=q(r));let o=u(e,"w","tcBorders");o&&(n.borders=Bt(o));let i=u(e,"w","tcMar");i&&(n.margins=$t(i));let s=u(e,"w","shd");s&&(n.shading=Se(s));let a=u(e,"w","vAlign");if(a){let m=c(a,"w","val");(m==="top"||m==="center"||m==="bottom")&&(n.verticalAlign=m);}let l=u(e,"w","textDirection");if(l){let m=c(l,"w","val");m&&(n.textDirection=m);}let f=u(e,"w","gridSpan");if(f){let m=h(f,"w","val");m!==void 0&&(n.gridSpan=m);}let p=u(e,"w","vMerge");if(p){let m=c(p,"w","val");n.vMerge=m==="restart"?"restart":"continue";}let d=u(e,"w","tcFitText");d&&(n.fitText=T(d));let w=u(e,"w","noWrap");w&&(n.noWrap=T(w));let g=u(e,"w","hideMark");return g&&(n.hideMark=T(g)),Object.keys(n).length>0?n:void 0}function yr(e,t){let n={styleId:c(e,"w","styleId")??"",type:c(e,"w","type")??"paragraph"},r=c(e,"w","default");r&&(n.default=r==="1"||r==="true");let o=u(e,"w","name");o&&(n.name=c(o,"w","val")??void 0);let i=u(e,"w","basedOn");i&&(n.basedOn=c(i,"w","val")??void 0);let s=u(e,"w","next");s&&(n.next=c(s,"w","val")??void 0);let a=u(e,"w","link");a&&(n.link=c(a,"w","val")??void 0);let l=u(e,"w","uiPriority");if(l){let y=h(l,"w","val");y!==void 0&&(n.uiPriority=y);}let f=u(e,"w","hidden");f&&(n.hidden=T(f));let p=u(e,"w","semiHidden");p&&(n.semiHidden=T(p));let d=u(e,"w","unhideWhenUsed");d&&(n.unhideWhenUsed=T(d));let w=u(e,"w","qFormat");w&&(n.qFormat=T(w));let g=u(e,"w","personal");g&&(n.personal=T(g));let m=u(e,"w","pPr");m&&(n.pPr=qe(m,t));let b=u(e,"w","rPr");b&&(n.rPr=Fe(b,t));let D=u(e,"w","tblPr");D&&(n.tblPr=It(D));let k=u(e,"w","trPr");k&&(n.trPr=Dt(k));let M=u(e,"w","tcPr");M&&(n.tcPr=At(M));let R=A(e,"w","tblStylePr");if(R.length>0){n.tblStylePr=[];for(let y of R){let C=c(y,"w","type");if(C){let x={type:C},F=u(y,"w","pPr");F&&(x.pPr=qe(F,t));let S=u(y,"w","rPr");S&&(x.rPr=Fe(S,t));let E=u(y,"w","tblPr");E&&(x.tblPr=It(E));let I=u(y,"w","trPr");I&&(x.trPr=Dt(I));let $=u(y,"w","tcPr");$&&(x.tcPr=At($)),n.tblStylePr.push(x);}}}return n}function xr(e,t){if(!e)return;let n={},r=u(e,"w","rPrDefault");if(r){let i=u(r,"w","rPr");i&&(n.rPr=Fe(i,t));}let o=u(e,"w","pPrDefault");if(o){let i=u(o,"w","pPr");i&&(n.pPr=qe(i,t));}return n.rPr||n.pPr?n:void 0}function Lt(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let r of Object.keys(t)){let o=t[r];o!==void 0&&(n[r]=typeof o=="object"&&o!==null?{...n[r]||{},...o}:o);}return n}function br(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let r of Object.keys(t)){let o=t[r];if(o!==void 0)if(r==="runProperties")n.runProperties=Lt(n.runProperties,t.runProperties);else if(r==="borders"||r==="numPr"||r==="frame"){let i=n[r],s=o;n[r]={...i||{},...s||{}};}else r==="tabs"&&Array.isArray(o)?n.tabs=[...o]:n[r]=o;}return n}function Nt(e,t,n,r=new Set){if(r.has(e.styleId)||(r.add(e.styleId),!e.basedOn))return e;let o=t.get(e.basedOn);if(!o)return e;let i=Nt(o,t,n,r),s={...e,pPr:br(i.pPr,e.pPr),rPr:Lt(i.rPr,e.rPr)};return e.type==="table"&&((i.tblPr||e.tblPr)&&(s.tblPr={...i.tblPr||{},...e.tblPr||{}}),(i.trPr||e.trPr)&&(s.trPr={...i.trPr||{},...e.trPr||{}}),(i.tcPr||e.tcPr)&&(s.tcPr={...i.tcPr||{},...e.tcPr||{}})),s}function Ge(e,t){let n=new Map;try{let r=U(e);if(!r)return n;let o=A(r,"w","style");for(let i of o){let s=yr(i,t);s.styleId&&n.set(s.styleId,s);}for(let[i,s]of n){let a=Nt(s,n,t);n.set(i,a);}}catch(r){console.warn("Failed to parse styles:",r);}return n}function Xt(e,t){let n={styles:[]};try{let r=U(e);if(!r)return n;let o=u(r,"w","docDefaults");n.docDefaults=xr(o,t);let i=u(r,"w","latentStyles");i&&(n.latentStyles={defLockedState:c(i,"w","defLockedState")==="1",defUIPriority:h(i,"w","defUIPriority"),defSemiHidden:c(i,"w","defSemiHidden")==="1",defUnhideWhenUsed:c(i,"w","defUnhideWhenUsed")==="1",defQFormat:c(i,"w","defQFormat")==="1",count:h(i,"w","count")});let s=Ge(e,t);n.styles=Array.from(s.values());}catch(r){console.warn("Failed to parse style definitions:",r);}return n}function Ht(e){let t={abstractNums:[],nums:[]};if(!e)return Je(t);let n=U(e);if(!n)return Je(t);let r=A(n,"w","abstractNum");for(let i of r){let s=Tr(i);s&&t.abstractNums.push(s);}let o=A(n,"w","num");for(let i of o){let s=Cr(i);s&&t.nums.push(s);}return Je(t)}function Tr(e){let t=c(e,"w","abstractNumId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let r={abstractNumId:n,levels:[]},o=u(e,"w","multiLevelType");if(o){let f=c(o,"w","val");(f==="hybridMultilevel"||f==="multilevel"||f==="singleLevel")&&(r.multiLevelType=f);}let i=u(e,"w","name");i&&(r.name=c(i,"w","val")??void 0);let s=u(e,"w","numStyleLink");s&&(r.numStyleLink=c(s,"w","val")??void 0);let a=u(e,"w","styleLink");a&&(r.styleLink=c(a,"w","val")??void 0);let l=A(e,"w","lvl");for(let f of l){let p=Ot(f);p&&r.levels.push(p);}return r.levels.sort((f,p)=>f.ilvl-p.ilvl),r}function Cr(e){let t=c(e,"w","numId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let r=u(e,"w","abstractNumId");if(!r)return null;let o=c(r,"w","val");if(o===null)return null;let i=parseInt(o,10);if(isNaN(i))return null;let s={numId:n,abstractNumId:i},a=A(e,"w","lvlOverride");if(a.length>0){s.levelOverrides=[];for(let l of a){let f=c(l,"w","ilvl");if(f===null)continue;let p=parseInt(f,10);if(isNaN(p))continue;let d={ilvl:p},w=u(l,"w","startOverride");if(w){let m=c(w,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(d.startOverride=b);}}let g=u(l,"w","lvl");g&&(d.lvl=Ot(g)??void 0),s.levelOverrides.push(d);}}return s}function Ot(e){let t=c(e,"w","ilvl");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n)||n<0||n>8)return null;let r={ilvl:n,numFmt:"decimal",lvlText:""},o=u(e,"w","start");if(o){let m=c(o,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(r.start=b);}}let i=u(e,"w","numFmt");if(i){let m=c(i,"w","val");m&&(r.numFmt=Fr(m));}let s=u(e,"w","lvlText");s&&(r.lvlText=c(s,"w","val")??"");let a=u(e,"w","lvlJc");if(a){let m=c(a,"w","val");(m==="left"||m==="center"||m==="right")&&(r.lvlJc=m);}let l=u(e,"w","suff");if(l){let m=c(l,"w","val");(m==="tab"||m==="space"||m==="nothing")&&(r.suffix=m);}let f=u(e,"w","isLgl");f&&(r.isLgl=T(f));let p=u(e,"w","lvlRestart");if(p){let m=c(p,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(r.lvlRestart=b);}}let d=u(e,"w","legacy");d&&(r.legacy={legacy:T(d),legacySpace:h(d,"w","legacySpace"),legacyIndent:h(d,"w","legacyIndent")});let w=u(e,"w","pPr");w&&(r.pPr=Sr(w));let g=u(e,"w","rPr");return g&&(r.rPr=Pr(g)),r}function Fr(e){return {decimal:"decimal",upperRoman:"upperRoman",lowerRoman:"lowerRoman",upperLetter:"upperLetter",lowerLetter:"lowerLetter",ordinal:"ordinal",cardinalText:"cardinalText",ordinalText:"ordinalText",hex:"hex",chicago:"chicago",bullet:"bullet",none:"none",decimalZero:"decimalZero",ganada:"ganada",chosung:"chosung",ideographDigital:"ideographDigital",japaneseCounting:"japaneseCounting",aiueo:"aiueo",iroha:"iroha",decimalFullWidth:"decimalFullWidth",decimalHalfWidth:"decimalHalfWidth",japaneseLegal:"japaneseLegal",japaneseDigitalTenThousand:"japaneseDigitalTenThousand",decimalEnclosedCircle:"decimalEnclosedCircle",decimalFullWidth2:"decimalFullWidth2",aiueoFullWidth:"aiueoFullWidth",irohaFullWidth:"irohaFullWidth",decimalEnclosedFullstop:"decimalEnclosedFullstop",decimalEnclosedParen:"decimalEnclosedParen",decimalEnclosedCircleChinese:"decimalEnclosedCircleChinese",ideographEnclosedCircle:"ideographEnclosedCircle",ideographTraditional:"ideographTraditional",ideographZodiac:"ideographZodiac",ideographZodiacTraditional:"ideographZodiacTraditional",taiwaneseCounting:"taiwaneseCounting",ideographLegalTraditional:"ideographLegalTraditional",taiwaneseCountingThousand:"taiwaneseCountingThousand",taiwaneseDigital:"taiwaneseDigital",chineseCounting:"chineseCounting",chineseLegalSimplified:"chineseLegalSimplified",chineseCountingThousand:"chineseCountingThousand",koreanDigital:"koreanDigital",koreanCounting:"koreanCounting",koreanLegal:"koreanLegal",koreanDigital2:"koreanDigital2",vietnameseCounting:"vietnameseCounting",russianLower:"russianLower",russianUpper:"russianUpper",numberInDash:"numberInDash",hebrew1:"hebrew1",hebrew2:"hebrew2",arabicAlpha:"arabicAlpha",arabicAbjad:"arabicAbjad",hindiVowels:"hindiVowels",hindiConsonants:"hindiConsonants",hindiNumbers:"hindiNumbers",hindiCounting:"hindiCounting",thaiLetters:"thaiLetters",thaiNumbers:"thaiNumbers",thaiCounting:"thaiCounting"}[e]??"decimal"}function Sr(e){let t={},n=u(e,"w","ind");if(n){let o=h(n,"w","left"),i=h(n,"w","right"),s=h(n,"w","firstLine"),a=h(n,"w","hanging");o!==void 0&&(t.indentLeft=o),i!==void 0&&(t.indentRight=i),a!==void 0?(t.indentFirstLine=-a,t.hangingIndent=true):s!==void 0&&(t.indentFirstLine=s);}let r=u(e,"w","tabs");if(r){t.tabs=[];let o=A(r,"w","tab");for(let i of o){let s=h(i,"w","pos"),a=c(i,"w","val"),l=c(i,"w","leader");s!==void 0&&a&&t.tabs.push({position:s,alignment:vr(a),leader:kr(l)});}}return t}function vr(e){switch(e){case "left":return "left";case "center":return "center";case "right":return "right";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "num";default:return "left"}}function kr(e){if(e)switch(e){case "none":return "none";case "dot":return "dot";case "hyphen":return "hyphen";case "underscore":return "underscore";case "heavy":return "heavy";case "middleDot":return "middleDot";default:return}}function Pr(e){let t={},n=u(e,"w","rFonts");n&&(t.fontFamily={ascii:c(n,"w","ascii")??void 0,hAnsi:c(n,"w","hAnsi")??void 0,eastAsia:c(n,"w","eastAsia")??void 0,cs:c(n,"w","cs")??void 0});let r=u(e,"w","sz");if(r){let a=h(r,"w","val");a!==void 0&&(t.fontSize=a);}let o=u(e,"w","color");if(o){let a=c(o,"w","val"),l=c(o,"w","themeColor");a==="auto"?t.color={auto:true}:l?t.color={themeColor:l,themeTint:c(o,"w","themeTint")??void 0,themeShade:c(o,"w","themeShade")??void 0}:a&&(t.color={rgb:a});}let i=u(e,"w","b");i&&(t.bold=T(i));let s=u(e,"w","i");return s&&(t.italic=T(s)),t}function Je(e){let t=new Map;for(let r of e.abstractNums)t.set(r.abstractNumId,r);let n=new Map;for(let r of e.nums)n.set(r.numId,r);return {definitions:e,getLevel(r,o){let i=n.get(r);if(!i)return null;if(i.levelOverrides){let a=i.levelOverrides.find(l=>l.ilvl===o);if(a){if(a.lvl)return a.lvl;let l=t.get(i.abstractNumId);if(l){let f=l.levels.find(p=>p.ilvl===o);if(f&&a.startOverride!==void 0)return {...f,start:a.startOverride}}}}let s=t.get(i.abstractNumId);return s?s.levels.find(a=>a.ilvl===o)??null:null},getAbstract(r){return t.get(r)??null},hasNumbering(r){return n.has(r)}}}function Rr(e){if(!e)return;let t=parseInt(e,10);if(!isNaN(t))return t/6e4}function B(e,t){let n=N(e);for(let r of n)if(r.name===t)return r;return null}function Mr(e,t){let n=N(e);for(let r of n)if(t.includes(r.name||""))return r;return null}function jt(e){if(!e)return {width:0,height:0};let t=h(e,null,"cx")??0,n=h(e,null,"cy")??0;return {width:t,height:n}}function zt(e){if(!e)return;let t=h(e,null,"l")??0,n=h(e,null,"t")??0,r=h(e,null,"r")??0,o=h(e,null,"b")??0;if(!(t===0&&n===0&&r===0&&o===0))return {left:t,top:n,right:r,bottom:o}}function Vt(e){if(!e)return {};let t=c(e,null,"id")??void 0,n=c(e,null,"name")??void 0,r=c(e,null,"descr")??void 0,o=c(e,null,"title")??void 0,i=c(e,null,"decorative")==="1";return {id:t,name:n,alt:r,title:o,decorative:i||void 0}}function Er(e){if(!e)return;let t=c(e,null,"relativeFrom")??"column",n=B(e,"wp:align");if(n){let o=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:o}}let r=B(e,"wp:posOffset");if(r){let o=String(r.elements?.[0]?.text??"0"),i=parseInt(o,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}function Ir(e){if(!e)return;let t=c(e,null,"relativeFrom")??"paragraph",n=B(e,"wp:align");if(n){let o=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:o}}let r=B(e,"wp:posOffset");if(r){let o=String(r.elements?.[0]?.text??"0"),i=parseInt(o,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}var Dr=["wp:wrapNone","wp:wrapSquare","wp:wrapTight","wp:wrapThrough","wp:wrapTopAndBottom"];function Ar(e,t){if(!e)return {type:t?"behind":"inFront"};let r=(e.name||"").replace("wp:",""),o=h(e,null,"distT")??void 0,i=h(e,null,"distB")??void 0,s=h(e,null,"distL")??void 0,a=h(e,null,"distR")??void 0,l=c(e,null,"wrapText")??void 0,f;switch(r){case "wrapNone":f=t?"behind":"inFront";break;case "wrapSquare":f="square";break;case "wrapTight":f="tight";break;case "wrapThrough":f="through";break;case "wrapTopAndBottom":f="topAndBottom";break;default:f="square";}let p={type:f};return l&&(p.wrapText=l),o!==void 0&&(p.distT=o),i!==void 0&&(p.distB=i),s!==void 0&&(p.distL=s),a!==void 0&&(p.distR=a),p}function _t(e){if(!e)return;let t=c(e,null,"rot"),n=c(e,null,"flipH")==="1",r=c(e,null,"flipV")==="1",o=Rr(t);if(o===void 0&&!n&&!r)return;let i={};return o!==void 0&&(i.rotation=o),n&&(i.flipH=true),r&&(i.flipV=true),i}function Wt(e){let t=B(e,"a:graphic");if(!t)return null;let n=B(t,"a:graphicData");if(!n)return null;let r=B(n,"pic:pic");if(!r)return null;let o=B(r,"pic:blipFill");return o?B(o,"a:blip"):null}function Ut(e){if(!e)return "";let t=c(e,"r","embed");if(t)return t;let n=c(e,null,"embed");if(n)return n;let r=c(e,"r","link");return r||""}function qt(e){let t=B(e,"a:graphic");if(!t)return null;let n=B(t,"a:graphicData");if(!n)return null;let r=B(n,"pic:pic");if(!r)return null;let o=B(r,"pic:spPr");return o?B(o,"a:xfrm"):null}function Br(e){if(!e)return e;let t=e.replace(/^\/+/,"");return t.startsWith("media/")?t=`word/${t}`:t.startsWith("word/")||(t=`word/${t}`),t}function $r(e){let t=e.split(".").pop()?.toLowerCase()??"";return {png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",webp:"image/webp",svg:"image/svg+xml",emf:"image/x-emf",wmf:"image/x-wmf"}[t]??"application/octet-stream"}function Gt(e,t,n){if(!e||!t)return {};let r=t.get(e);if(!r)return {};let o=r.target;if(!o)return {};let i=Br(o),s=o.split("/").pop(),a=(l,f)=>{let p=f.toLowerCase();for(let[d,w]of l.entries())if(d.toLowerCase()===p)return w};if(n){let l=a(n,i);if(l)return {src:l.dataUrl||l.base64,mimeType:l.mimeType,filename:s};let f=o.replace(/^\/+/,""),p=a(n,f);if(p)return {src:p.dataUrl||p.base64,mimeType:p.mimeType,filename:s};let d=`word/${f}`,w=a(n,d);if(w)return {src:w.dataUrl||w.base64,mimeType:w.mimeType,filename:s}}return {mimeType:$r(o),filename:s}}function Lr(e,t,n){let r=B(e,"wp:extent"),o=jt(r),i=B(e,"wp:effectExtent"),s=zt(i),a=B(e,"wp:docPr"),l=Vt(a),f=Wt(e),p=Ut(f),d=Gt(p,t,n),w=qt(e),g=_t(w),m={type:"image",rId:p,size:o,wrap:{type:"inline"}};return l.id&&(m.id=l.id),l.alt&&(m.alt=l.alt),l.title&&(m.title=l.title),l.decorative&&(m.decorative=true),d.src&&(m.src=d.src),d.mimeType&&(m.mimeType=d.mimeType),d.filename&&(m.filename=d.filename),s&&(m.padding=s),g&&(m.transform=g),m}function Nr(e,t,n){let r=B(e,"wp:extent"),o=jt(r),i=B(e,"wp:effectExtent"),s=zt(i),a=B(e,"wp:docPr"),l=Vt(a),f=c(e,null,"behindDoc")==="1",p=Mr(e,Dr),d=Ar(p,f),w=B(e,"wp:positionH"),g=B(e,"wp:positionV"),m=Er(w),b=Ir(g),D;(m||b)&&(D={horizontal:m??{relativeTo:"column"},vertical:b??{relativeTo:"paragraph"}});let k=Wt(e),M=Ut(k),R=Gt(M,t,n),y=qt(e),C=_t(y),x={type:"image",rId:M,size:o,wrap:d};return l.id&&(x.id=l.id),l.alt&&(x.alt=l.alt),l.title&&(x.title=l.title),l.decorative&&(x.decorative=true),R.src&&(x.src=R.src),R.mimeType&&(x.mimeType=R.mimeType),R.filename&&(x.filename=R.filename),D&&(x.position=D),s&&(x.padding=s),C&&(x.transform=C),x}function Xr(e,t,n){let r=N(e);for(let o of r){let i=o.name||"";if(i==="wp:inline")return Lr(o,t,n);if(i==="wp:anchor")return Nr(o,t,n)}return null}function Jt(e,t,n){return Xr(e,t,n)}function Zt(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Hr(e){if(!e)return;let t={},n=c(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=c(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=c(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=c(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=c(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=c(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function Ze(e,t,n){if(!e)return;let r={},o=u(e,"w","b");o&&(r.bold=T(o));let i=u(e,"w","bCs");i&&(r.boldCs=T(i));let s=u(e,"w","i");s&&(r.italic=T(s));let a=u(e,"w","iCs");a&&(r.italicCs=T(a));let l=u(e,"w","u");if(l){let v=c(l,"w","val");if(v){r.underline={style:v};let O=c(l,"w","color"),V=c(l,"w","themeColor");(O||V)&&(r.underline.color=Zt(O,V,c(l,"w","themeTint"),c(l,"w","themeShade")));}}let f=u(e,"w","strike");f&&(r.strike=T(f));let p=u(e,"w","dstrike");p&&(r.doubleStrike=T(p));let d=u(e,"w","vertAlign");if(d){let v=c(d,"w","val");(v==="superscript"||v==="subscript"||v==="baseline")&&(r.vertAlign=v);}let w=u(e,"w","smallCaps");w&&(r.smallCaps=T(w));let g=u(e,"w","caps");g&&(r.allCaps=T(g));let m=u(e,"w","vanish");m&&(r.hidden=T(m));let b=u(e,"w","color");b&&(r.color=Zt(c(b,"w","val"),c(b,"w","themeColor"),c(b,"w","themeTint"),c(b,"w","themeShade")));let D=u(e,"w","highlight");if(D){let v=c(D,"w","val");v&&(r.highlight=v);}let k=u(e,"w","shd");k&&(r.shading=Hr(k));let M=u(e,"w","sz");if(M){let v=h(M,"w","val");v!==void 0&&(r.fontSize=v);}let R=u(e,"w","szCs");if(R){let v=h(R,"w","val");v!==void 0&&(r.fontSizeCs=v);}let y=u(e,"w","rFonts");if(y){r.fontFamily={ascii:c(y,"w","ascii")??void 0,hAnsi:c(y,"w","hAnsi")??void 0,eastAsia:c(y,"w","eastAsia")??void 0,cs:c(y,"w","cs")??void 0};let v=c(y,"w","asciiTheme");v&&(r.fontFamily.asciiTheme=v,t&&!r.fontFamily.ascii&&(r.fontFamily.ascii=_(t,v)));let O=c(y,"w","hAnsiTheme");O&&(r.fontFamily.hAnsiTheme=O,t&&!r.fontFamily.hAnsi&&(r.fontFamily.hAnsi=_(t,O)));let V=c(y,"w","eastAsiaTheme");V&&(r.fontFamily.eastAsiaTheme=V,t&&!r.fontFamily.eastAsia&&(r.fontFamily.eastAsia=_(t,V)));let He=c(y,"w","cstheme");He&&(r.fontFamily.csTheme=He,t&&!r.fontFamily.cs&&(r.fontFamily.cs=_(t,He)));}let C=u(e,"w","spacing");if(C){let v=h(C,"w","val");v!==void 0&&(r.spacing=v);}let x=u(e,"w","position");if(x){let v=h(x,"w","val");v!==void 0&&(r.position=v);}let F=u(e,"w","w");if(F){let v=h(F,"w","val");v!==void 0&&(r.scale=v);}let S=u(e,"w","kern");if(S){let v=h(S,"w","val");v!==void 0&&(r.kerning=v);}let E=u(e,"w","effect");if(E){let v=c(E,"w","val");v&&(r.effect=v);}let I=u(e,"w","em");if(I){let v=c(I,"w","val");v&&(r.emphasisMark=v);}let $=u(e,"w","emboss");$&&(r.emboss=T($));let z=u(e,"w","imprint");z&&(r.imprint=T(z));let le=u(e,"w","outline");le&&(r.outline=T(le));let ce=u(e,"w","shadow");ce&&(r.shadow=T(ce));let ue=u(e,"w","rtl");ue&&(r.rtl=T(ue));let fe=u(e,"w","cs");fe&&(r.cs=T(fe));let P=u(e,"w","rStyle");if(P){let v=c(P,"w","val");v&&(r.styleId=v);}return Object.keys(r).length>0?r:void 0}function Or(e){let t=xe(e),n=c(e,"xml","space")==="preserve";return {type:"text",text:t,preserveSpace:n||void 0}}function jr(){return {type:"tab"}}function zr(e){let t=c(e,"w","type"),n=c(e,"w","clear"),r={type:"break"};return (t==="page"||t==="column"||t==="textWrapping")&&(r.breakType=t),(n==="none"||n==="left"||n==="right"||n==="all")&&(r.clear=n),r}function Vr(e){let t=c(e,"w","font")??"",n=c(e,"w","char")??"";return {type:"symbol",font:t,char:n}}function _r(e){return {type:"footnoteRef",id:h(e,"w","id")??0}}function Wr(e){return {type:"endnoteRef",id:h(e,"w","id")??0}}function Ur(e){let t=c(e,"w","fldCharType"),n=c(e,"w","fldLock")==="true"||c(e,"w","fldLock")==="1",r=c(e,"w","dirty")==="true"||c(e,"w","dirty")==="1",o="begin";return t==="separate"?o="separate":t==="end"&&(o="end"),{type:"fieldChar",charType:o,fldLock:n||void 0,dirty:r||void 0}}function qr(e){return {type:"instrText",text:xe(e)}}function Gr(e,t,n){let r=Jt(e,t??void 0,n??void 0);return r?{type:"drawing",image:r}:null}function Jr(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Zr(e,t,n){let r=[],o=N(e);for(let i of o)switch(Jr(i.name)){case "t":r.push(Or(i));break;case "tab":r.push(jr());break;case "br":r.push(zr(i));break;case "sym":r.push(Vr(i));break;case "footnoteReference":r.push(_r(i));break;case "endnoteReference":r.push(Wr(i));break;case "fldChar":r.push(Ur(i));break;case "instrText":r.push(qr(i));break;case "softHyphen":r.push({type:"softHyphen"});break;case "noBreakHyphen":r.push({type:"noBreakHyphen"});break;case "drawing":let a=Gr(i,t,n);a&&r.push(a);break;case "pict":case "object":break;case "rPr":break;case "lastRenderedPageBreak":break;case "cr":r.push({type:"break",breakType:"textWrapping"});break;}return r}function me(e,t,n,r=null,o=null){let i={type:"run",content:[]},s=u(e,"w","rPr");return s&&(i.formatting=Ze(s,n)),i.content=Zr(e,r,o),i}function Yr(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Kr(e){let t=h(e,"w","id")??0,n=c(e,"w","name")??"",r={type:"bookmarkStart",id:t,name:n},o=h(e,"w","colFirst");o!==void 0&&(r.colFirst=o);let i=h(e,"w","colLast");return i!==void 0&&(r.colLast=i),r}function Qr(e){return {type:"bookmarkEnd",id:h(e,"w","id")??0}}function Yt(e,t,n=null,r=null,o=null){let i={type:"hyperlink",children:[]},s=c(e,"r","id");if(s&&(i.rId=s,t)){let g=t.get(s);g&&(kt(g),i.href=g.target);}let a=c(e,"w","anchor");a&&(i.anchor=a,i.href||(i.href=`#${a}`));let l=c(e,"w","tooltip");l&&(i.tooltip=l);let f=c(e,"w","tgtFrame");f&&(i.target=f);let p=c(e,"w","history");(p==="1"||p==="true")&&(i.history=true);let d=c(e,"w","docLocation");d&&(i.docLocation=d);let w=N(e);for(let g of w)switch(Yr(g.name)){case "r":i.children.push(me(g,n,r,t,o));break;case "bookmarkStart":i.children.push(Kr(g));break;case "bookmarkEnd":i.children.push(Qr(g));break}return i}function Kt(e){let t=h(e,"w","id")??0,n=c(e,"w","name")??"",r={type:"bookmarkStart",id:t,name:n},o=h(e,"w","colFirst");o!==void 0&&(r.colFirst=o);let i=h(e,"w","colLast");return i!==void 0&&(r.colLast=i),r}function Qt(e){return {type:"bookmarkEnd",id:h(e,"w","id")??0}}function eo(e){if(!e)return;let t=h(e,"w","w")??0,n=c(e,"w","type")??"dxa",r="dxa";return (n==="auto"||n==="dxa"||n==="nil"||n==="pct")&&(r=n),{value:t,type:r}}function G(e){return eo(e)}function re(e){if(!e)return;let r={style:c(e,"w","val")??"none"},o=h(e,"w","sz");o!==void 0&&(r.size=o);let i=h(e,"w","space");i!==void 0&&(r.space=i);let s=vt(e);s&&(r.color={rgb:s.val,themeColor:s.themeColor,themeTint:s.themeTint,themeShade:s.themeShade});let a=c(e,"w","shadow");(a==="1"||a==="true")&&(r.shadow=true);let l=c(e,"w","frame");return (l==="1"||l==="true")&&(r.frame=true),r}function en(e){if(!e)return;let t={},n=re(u(e,"w","top"));n&&(t.top=n);let r=re(u(e,"w","bottom"));r&&(t.bottom=r);let o=re(u(e,"w","left")??u(e,"w","start"));o&&(t.left=o);let i=re(u(e,"w","right")??u(e,"w","end"));i&&(t.right=i);let s=re(u(e,"w","insideH"));s&&(t.insideH=s);let a=re(u(e,"w","insideV"));if(a&&(t.insideV=a),Object.keys(t).length!==0)return t}function tn(e){if(!e)return;let t={},n=G(u(e,"w","top"));n&&(t.top=n);let r=G(u(e,"w","bottom"));r&&(t.bottom=r);let o=G(u(e,"w","left")??u(e,"w","start"));o&&(t.left=o);let i=G(u(e,"w","right")??u(e,"w","end"));if(i&&(t.right=i),Object.keys(t).length!==0)return t}function nn(e){if(!e)return;let t={},n=c(e,"w","fill");n&&n!=="auto"&&(t.fill={rgb:n});let r=c(e,"w","themeFill");if(r){t.fill={themeColor:r};let s=c(e,"w","themeFillTint");s&&t.fill&&(t.fill.themeTint=s);let a=c(e,"w","themeFillShade");a&&t.fill&&(t.fill.themeShade=a);}let o=c(e,"w","color");o&&o!=="auto"&&(t.color={rgb:o});let i=c(e,"w","val");if(i&&(t.pattern=i),Object.keys(t).length!==0)return t}function to(e){if(!e)return;let t={},n=c(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let r=c(e,"w","lastRow");(r==="1"||r==="true")&&(t.lastRow=true);let o=c(e,"w","firstColumn");(o==="1"||o==="true")&&(t.firstColumn=true);let i=c(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let s=c(e,"w","noHBand");(s==="1"||s==="true")&&(t.noHBand=true);let a=c(e,"w","noVBand");(a==="1"||a==="true")&&(t.noVBand=true);let l=c(e,"w","val");if(l){let f=parseInt(l,16);isNaN(f)||(f&32&&(t.firstRow=true),f&64&&(t.lastRow=true),f&128&&(t.firstColumn=true),f&256&&(t.lastColumn=true),f&512&&(t.noHBand=true),f&1024&&(t.noVBand=true));}if(Object.keys(t).length!==0)return t}function no(e){if(!e)return;let t={},n=c(e,"w","horzAnchor");(n==="margin"||n==="page"||n==="text")&&(t.horzAnchor=n);let r=c(e,"w","vertAnchor");(r==="margin"||r==="page"||r==="text")&&(t.vertAnchor=r);let o=h(e,"w","tblpX");o!==void 0&&(t.tblpX=o);let i=c(e,"w","tblpXSpec");i&&(t.tblpXSpec=i);let s=h(e,"w","tblpY");s!==void 0&&(t.tblpY=s);let a=c(e,"w","tblpYSpec");a&&(t.tblpYSpec=a);let l=h(e,"w","topFromText");l!==void 0&&(t.topFromText=l);let f=h(e,"w","bottomFromText");f!==void 0&&(t.bottomFromText=f);let p=h(e,"w","leftFromText");p!==void 0&&(t.leftFromText=p);let d=h(e,"w","rightFromText");if(d!==void 0&&(t.rightFromText=d),Object.keys(t).length!==0)return t}function ro(e){if(!e)return;let t={},n=G(u(e,"w","tblW"));n&&(t.width=n);let r=u(e,"w","jc");if(r){let b=c(r,"w","val");(b==="left"||b==="center"||b==="right"||b==="start")&&(t.justification=b==="start"?"left":b);}let o=G(u(e,"w","tblCellSpacing"));o&&(t.cellSpacing=o);let i=G(u(e,"w","tblInd"));i&&(t.indent=i);let s=en(u(e,"w","tblBorders"));s&&(t.borders=s);let a=tn(u(e,"w","tblCellMar"));a&&(t.cellMargins=a);let l=u(e,"w","tblLayout");if(l){let b=c(l,"w","type");(b==="fixed"||b==="autofit")&&(t.layout=b);}let f=u(e,"w","tblStyle");if(f){let b=c(f,"w","val");b&&(t.styleId=b);}let p=to(u(e,"w","tblLook"));p&&(t.look=p);let d=nn(u(e,"w","shd"));d&&(t.shading=d);let w=u(e,"w","tblOverlap");if(w){let b=c(w,"w","val");(b==="never"||b==="overlap")&&(t.overlap=b);}let g=no(u(e,"w","tblpPr"));if(g&&(t.floating=g),T(u(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length!==0)return t}function oo(e){if(!e)return;let t={},n=u(e,"w","trHeight");if(n){let a=G(n);a&&(t.height=a);let l=c(n,"w","hRule");(l==="auto"||l==="atLeast"||l==="exact")&&(t.heightRule=l);}T(u(e,"w","tblHeader"))&&(t.header=true),T(u(e,"w","cantSplit"))&&(t.cantSplit=true);let i=u(e,"w","jc");if(i){let a=c(i,"w","val");(a==="left"||a==="center"||a==="right")&&(t.justification=a);}if(T(u(e,"w","hidden"))&&(t.hidden=true),Object.keys(t).length!==0)return t}function io(e){if(!e)return;let t={},n=c(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let r=c(e,"w","lastRow");(r==="1"||r==="true")&&(t.lastRow=true);let o=c(e,"w","firstColumn");(o==="1"||o==="true")&&(t.firstColumn=true);let i=c(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let s=c(e,"w","oddHBand");(s==="1"||s==="true")&&(t.oddHBand=true);let a=c(e,"w","evenHBand");(a==="1"||a==="true")&&(t.evenHBand=true);let l=c(e,"w","oddVBand");(l==="1"||l==="true")&&(t.oddVBand=true);let f=c(e,"w","evenVBand");(f==="1"||f==="true")&&(t.evenVBand=true);let p=c(e,"w","firstRowFirstColumn");(p==="1"||p==="true")&&(t.nwCell=true);let d=c(e,"w","firstRowLastColumn");(d==="1"||d==="true")&&(t.neCell=true);let w=c(e,"w","lastRowFirstColumn");(w==="1"||w==="true")&&(t.swCell=true);let g=c(e,"w","lastRowLastColumn");(g==="1"||g==="true")&&(t.seCell=true);let m=c(e,"w","val");if(m&&m.length===12&&(m[0]==="1"&&(t.firstRow=true),m[1]==="1"&&(t.lastRow=true),m[2]==="1"&&(t.firstColumn=true),m[3]==="1"&&(t.lastColumn=true),m[4]==="1"&&(t.oddVBand=true),m[5]==="1"&&(t.evenVBand=true),m[6]==="1"&&(t.oddHBand=true),m[7]==="1"&&(t.evenHBand=true),m[8]==="1"&&(t.nwCell=true),m[9]==="1"&&(t.neCell=true),m[10]==="1"&&(t.swCell=true),m[11]==="1"&&(t.seCell=true)),Object.keys(t).length!==0)return t}function so(e){if(!e)return;let t={},n=G(u(e,"w","tcW"));n&&(t.width=n);let r=en(u(e,"w","tcBorders"));r&&(t.borders=r);let o=tn(u(e,"w","tcMar"));o&&(t.margins=o);let i=nn(u(e,"w","shd"));i&&(t.shading=i);let s=u(e,"w","vAlign");if(s){let m=c(s,"w","val");(m==="top"||m==="center"||m==="bottom")&&(t.verticalAlign=m);}let a=u(e,"w","textDirection");if(a){let m=c(a,"w","val");m&&(t.textDirection=m);}let l=u(e,"w","gridSpan");if(l){let m=h(l,"w","val");m!==void 0&&m>1&&(t.gridSpan=m);}let f=u(e,"w","vMerge");f&&(c(f,"w","val")==="restart"?t.vMerge="restart":t.vMerge="continue"),T(u(e,"w","tcFitText"))&&(t.fitText=true),T(u(e,"w","noWrap"))&&(t.noWrap=true),T(u(e,"w","hideMark"))&&(t.hideMark=true);let g=io(u(e,"w","cnfStyle"));if(g&&(t.conditionalFormat=g),Object.keys(t).length!==0)return t}function ao(e,t,n,r,o,i){let s=[],a=e.elements||[];for(let l of a){if(!l.name)continue;let f=l.name.split(":").pop();if(f==="p"){let p=J(l,t,n,r,o,i);s.push(p);}else if(f==="tbl"){let p=ge(l,t,n,r,o,i);s.push(p);}}return s.length===0&&s.push({type:"paragraph",content:[]}),s}function lo(e,t,n,r,o,i){let s={type:"tableCell",content:[]},a=so(u(e,"w","tcPr"));return a&&(s.formatting=a),s.content=ao(e,t,n,r,o,i),s}function co(e,t,n,r,o,i){let s={type:"tableRow",cells:[]},a=oo(u(e,"w","trPr"));a&&(s.formatting=a);let l=A(e,"w","tc");for(let f of l){let p=lo(f,t,n,r,o,i);s.cells.push(p);}return s}function uo(e){if(!e)return;let t=[],n=A(e,"w","gridCol");for(let r of n){let o=h(r,"w","w")??0;t.push(o);}return t.length>0?t:void 0}function ge(e,t,n,r,o,i){let s={type:"table",rows:[]},a=ro(u(e,"w","tblPr"));a&&(s.formatting=a);let l=uo(u(e,"w","tblGrid"));l&&(s.columnWidths=l);let f=A(e,"w","tr");for(let p of f){let d=co(p,t,n,r,o,i);s.rows.push(d);}return s}function rn(e){switch(e){case "first":return "first";case "even":return "even";default:return "default"}}function on(e){let t=c(e,"w","type"),n=c(e,"r","id")??"";return {type:rn(t),rId:n}}function sn(e){let t=c(e,"w","type"),n=c(e,"r","id")??"";return {type:rn(t),rId:n}}function Ye(e,t,n,r,o,i){let s=[],a=e.elements??[];for(let l of a){if(l.type!=="element")continue;let f=l.name??"";if(f==="w:p"||f.endsWith(":p")){let p=J(l,t,n,r,o,i);s.push(p);}else if(f==="w:tbl"||f.endsWith(":tbl")){let p=ge(l,t,n,r,o,i);s.push(p);}else if(f==="w:sdt"||f.endsWith(":sdt")){let p=(l.elements??[]).find(d=>d.type==="element"&&(d.name==="w:sdtContent"||d.name?.endsWith(":sdtContent")));if(p){let d=Ye(p,t,n,r,o,i);s.push(...d);}}}return s}function an(e,t="default",n=null,r=null,o=null,i=null,s=null){let a={type:"header",hdrFtrType:t,content:[]};if(!e)return a;let l=W(e);if(!l)return a;let f=l.elements?.find(p=>p.type==="element"&&(p.name==="w:hdr"||p.name?.endsWith(":hdr")));return f&&(a.content=Ye(f,n,r,o,i,s)),a}function ln(e,t="default",n=null,r=null,o=null,i=null,s=null){let a={type:"footer",hdrFtrType:t,content:[]};if(!e)return a;let l=W(e);if(!l)return a;let f=l.elements?.find(p=>p.type==="element"&&(p.name==="w:ftr"||p.name?.endsWith(":ftr")));return f&&(a.content=Ye(f,n,r,o,i,s)),a}function cn(e){switch(e){case "separator":return "separator";case "continuationSeparator":return "continuationSeparator";case "continuationNotice":return "continuationNotice";default:return "normal"}}function fo(e,t,n,r,o,i){let s=h(e,"w","id")??0,a=c(e,"w","type"),l=cn(a),p=A(e,"w","p").map(d=>J(d,t,n,r,o));return {type:"footnote",id:s,noteType:l,content:p}}function un(e,t=null,n=null,r=null,o=null,i=null){let s=new Map,a=[];if(!e)return ve(s,a);let l=W(e);if(!l)return ve(s,a);let f=l.elements?.find(d=>d.type==="element"&&(d.name==="w:footnotes"||d.name?.endsWith(":footnotes")));if(!f)return ve(s,a);let p=A(f,"w","footnote");for(let d of p){let w=fo(d,t,n,r,o);s.set(w.id,w),a.push(w);}return ve(s,a)}function ve(e,t){return {byId:e,footnotes:t,getFootnote(n){return e.get(n)},hasFootnote(n){return e.has(n)},getNormalFootnotes(){return t.filter(n=>n.noteType==="normal")},getSeparator(){return t.find(n=>n.noteType==="separator")},getContinuationSeparator(){return t.find(n=>n.noteType==="continuationSeparator")}}}function po(e,t,n,r,o,i){let s=h(e,"w","id")??0,a=c(e,"w","type"),l=cn(a),p=A(e,"w","p").map(d=>J(d,t,n,r,o));return {type:"endnote",id:s,noteType:l,content:p}}function fn(e,t=null,n=null,r=null,o=null,i=null){let s=new Map,a=[];if(!e)return ke(s,a);let l=W(e);if(!l)return ke(s,a);let f=l.elements?.find(d=>d.type==="element"&&(d.name==="w:endnotes"||d.name?.endsWith(":endnotes")));if(!f)return ke(s,a);let p=A(f,"w","endnote");for(let d of p){let w=po(d,t,n,r,o);s.set(w.id,w),a.push(w);}return ke(s,a)}function ke(e,t){return {byId:e,endnotes:t,getEndnote(n){return e.get(n)},hasEndnote(n){return e.has(n)},getNormalEndnotes(){return t.filter(n=>n.noteType==="normal")},getSeparator(){return t.find(n=>n.noteType==="separator")},getContinuationSeparator(){return t.find(n=>n.noteType==="continuationSeparator")}}}function pn(e){return e?{decimal:"decimal",upperRoman:"upperRoman",lowerRoman:"lowerRoman",upperLetter:"upperLetter",lowerLetter:"lowerLetter",ordinal:"ordinal",cardinalText:"cardinalText",ordinalText:"ordinalText",bullet:"bullet",chicago:"chicago",none:"none"}[e]:void 0}function mo(e){switch(e){case "pageBottom":return "pageBottom";case "beneathText":return "beneathText";case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function go(e){switch(e){case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function dn(e){switch(e){case "continuous":return "continuous";case "eachSect":return "eachSect";case "eachPage":return "eachPage";default:return}}function mn(e){let t={};if(!e)return t;let n=u(e,"w","pos");if(n){let s=c(n,"w","val");t.position=mo(s);}let r=u(e,"w","numFmt");if(r){let s=c(r,"w","val");t.numFmt=pn(s);}let o=u(e,"w","numStart");o&&(t.numStart=h(o,"w","val")??void 0);let i=u(e,"w","numRestart");if(i){let s=c(i,"w","val");t.numRestart=dn(s);}return t}function gn(e){let t={};if(!e)return t;let n=u(e,"w","pos");if(n){let s=c(n,"w","val");t.position=go(s);}let r=u(e,"w","numFmt");if(r){let s=c(r,"w","val");t.numFmt=pn(s);}let o=u(e,"w","numStart");o&&(t.numStart=h(o,"w","val")??void 0);let i=u(e,"w","numRestart");if(i){let s=c(i,"w","val");t.numRestart=dn(s);}return t}function ho(e,t,n,r){if(!e&&!t)return;let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),Object.keys(o).length>0?o:void 0}function Pe(e){if(!e)return;let r={style:c(e,"w","val")??"none"},o=h(e,"w","sz");o!==void 0&&(r.size=o);let i=h(e,"w","space");i!==void 0&&(r.space=i);let s=c(e,"w","color"),a=c(e,"w","themeColor"),l=c(e,"w","themeTint"),f=c(e,"w","themeShade"),p=ho(s,a,l,f);p&&(r.color=p);let d=c(e,"w","shadow");(d==="1"||d==="true")&&(r.shadow=true);let w=c(e,"w","frame");return (w==="1"||w==="true")&&(r.frame=true),r}function wo(e){switch(e){case "landscape":return "landscape";case "portrait":return "portrait";default:return}}function yo(e){switch(e){case "continuous":return "continuous";case "nextPage":return "nextPage";case "oddPage":return "oddPage";case "evenPage":return "evenPage";case "nextColumn":return "nextColumn";default:return}}function xo(e){switch(e){case "top":return "top";case "center":return "center";case "both":return "both";case "bottom":return "bottom";default:return}}function bo(e){switch(e){case "continuous":return "continuous";case "newPage":return "newPage";case "newSection":return "newSection";default:return}}function Re(e,t){let n={};if(!e)return n;let r=u(e,"w","pgSz");if(r){let y=h(r,"w","w");y!==void 0&&(n.pageWidth=y);let C=h(r,"w","h");C!==void 0&&(n.pageHeight=C);let x=c(r,"w","orient"),F=wo(x);F&&(n.orientation=F);}let o=u(e,"w","pgMar");if(o){let y=h(o,"w","top");y!==void 0&&(n.marginTop=y);let C=h(o,"w","bottom");C!==void 0&&(n.marginBottom=C);let x=h(o,"w","left");x!==void 0&&(n.marginLeft=x);let F=h(o,"w","right");F!==void 0&&(n.marginRight=F);let S=h(o,"w","header");S!==void 0&&(n.headerDistance=S);let E=h(o,"w","footer");E!==void 0&&(n.footerDistance=E);let I=h(o,"w","gutter");I!==void 0&&(n.gutter=I);}let i=u(e,"w","cols");if(i){let y=h(i,"w","num");y!==void 0&&(n.columnCount=y);let C=h(i,"w","space");C!==void 0&&(n.columnSpace=C);let x=c(i,"w","equalWidth");x==="1"||x==="true"?n.equalWidth=true:(x==="0"||x==="false")&&(n.equalWidth=false);let F=c(i,"w","sep");(F==="1"||F==="true")&&(n.separator=true);let S=A(i,"w","col");if(S.length>0){n.columns=[];for(let E of S){let I={},$=h(E,"w","w");$!==void 0&&(I.width=$);let z=h(E,"w","space");z!==void 0&&(I.space=z),n.columns.push(I);}}}let s=u(e,"w","type");if(s){let y=c(s,"w","val"),C=yo(y);C&&(n.sectionStart=C);}let a=u(e,"w","vAlign");if(a){let y=c(a,"w","val"),C=xo(y);C&&(n.verticalAlign=C);}let l=u(e,"w","bidi");l&&(n.bidi=T(l));let f=A(e,"w","headerReference");f.length>0&&(n.headerReferences=f.map(y=>on(y)));let p=A(e,"w","footerReference");p.length>0&&(n.footerReferences=p.map(y=>sn(y)));let d=u(e,"w","titlePg");d&&(n.titlePg=T(d));let w=u(e,"w","evenAndOddHeaders");w&&(n.evenAndOddHeaders=T(w));let g=u(e,"w","lnNumType");if(g){n.lineNumbers={};let y=h(g,"w","start");y!==void 0&&(n.lineNumbers.start=y);let C=h(g,"w","countBy");C!==void 0&&(n.lineNumbers.countBy=C);let x=h(g,"w","distance");x!==void 0&&(n.lineNumbers.distance=x);let F=c(g,"w","restart"),S=bo(F);S&&(n.lineNumbers.restart=S);}let m=u(e,"w","pgBorders");if(m){n.pageBorders={};let y=Pe(u(m,"w","top"));y&&(n.pageBorders.top=y);let C=Pe(u(m,"w","bottom"));C&&(n.pageBorders.bottom=C);let x=Pe(u(m,"w","left"));x&&(n.pageBorders.left=x);let F=Pe(u(m,"w","right"));F&&(n.pageBorders.right=F);let S=c(m,"w","display");(S==="allPages"||S==="firstPage"||S==="notFirstPage")&&(n.pageBorders.display=S);let E=c(m,"w","offsetFrom");(E==="page"||E==="text")&&(n.pageBorders.offsetFrom=E);let I=c(m,"w","zOrder");(I==="front"||I==="back")&&(n.pageBorders.zOrder=I);}let b=u(e,"w","background");if(b){n.background={};let y=c(b,"w","color");y&&y!=="auto"&&(n.background.color={rgb:y});let C=c(b,"w","themeColor");C&&(n.background.themeColor=C);let x=c(b,"w","themeTint");x&&(n.background.themeTint=x);let F=c(b,"w","themeShade");F&&(n.background.themeShade=F);}let D=u(e,"w","footnotePr");if(D){let y=mn(D);Object.keys(y).length>0&&(n.footnotePr=y);}let k=u(e,"w","endnotePr");if(k){let y=gn(k);Object.keys(y).length>0&&(n.endnotePr=y);}let M=u(e,"w","docGrid");if(M){n.docGrid={};let y=c(M,"w","type");(y==="default"||y==="lines"||y==="linesAndChars"||y==="snapToChars")&&(n.docGrid.type=y);let C=h(M,"w","linePitch");C!==void 0&&(n.docGrid.linePitch=C);let x=h(M,"w","charSpace");x!==void 0&&(n.docGrid.charSpace=x);}let R=u(e,"w","paperSrc");if(R){let y=h(R,"w","first");y!==void 0&&(n.paperSrcFirst=y);let C=h(R,"w","other");C!==void 0&&(n.paperSrcOther=C);}return n}function hn(){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 To(e,t){return !e&&!t?true:!(!e||!t||e.bold!==t.bold||e.boldCs!==t.boldCs||e.italic!==t.italic||e.italicCs!==t.italicCs||e.strike!==t.strike||e.doubleStrike!==t.doubleStrike||e.smallCaps!==t.smallCaps||e.allCaps!==t.allCaps||e.hidden!==t.hidden||e.emboss!==t.emboss||e.imprint!==t.imprint||e.outline!==t.outline||e.shadow!==t.shadow||e.rtl!==t.rtl||e.cs!==t.cs||e.fontSize!==t.fontSize||e.fontSizeCs!==t.fontSizeCs||e.spacing!==t.spacing||e.position!==t.position||e.scale!==t.scale||e.kerning!==t.kerning||e.vertAlign!==t.vertAlign||e.highlight!==t.highlight||e.effect!==t.effect||e.emphasisMark!==t.emphasisMark||e.styleId!==t.styleId||!Co(e.underline,t.underline)||!Me(e.color,t.color)||!Fo(e.shading,t.shading)||!So(e.fontFamily,t.fontFamily))}function Co(e,t){return !e&&!t?true:!e||!t||e.style!==t.style?false:Me(e.color,t.color)}function Me(e,t){return !e&&!t?true:!e||!t?false:e.rgb===t.rgb&&e.auto===t.auto&&e.themeColor===t.themeColor&&e.themeTint===t.themeTint&&e.themeShade===t.themeShade}function Fo(e,t){return !e&&!t?true:!(!e||!t||e.pattern!==t.pattern||!Me(e.color,t.color)||!Me(e.fill,t.fill))}function So(e,t){return !e&&!t?true:!e||!t?false:e.ascii===t.ascii&&e.hAnsi===t.hAnsi&&e.eastAsia===t.eastAsia&&e.cs===t.cs&&e.asciiTheme===t.asciiTheme&&e.hAnsiTheme===t.hAnsiTheme&&e.eastAsiaTheme===t.eastAsiaTheme&&e.csTheme===t.csTheme}function vo(e){return e.type==="text"||e.type==="softHyphen"||e.type==="noBreakHyphen"}function wn(e){return e.content.length===0?true:e.content.every(vo)}function ko(e,t){let n=[];for(let r of e)n.push(r);if(n.length>0&&t.length>0&&n[n.length-1].type==="text"&&t[0].type==="text"){let r=n[n.length-1],o=t[0];n[n.length-1]={type:"text",text:r.text+o.text,preserveSpace:r.preserveSpace||o.preserveSpace||void 0};for(let i=1;i<t.length;i++)n.push(t[i]);}else for(let r of t)n.push(r);return n}function Po(e){if(e.length<=1)return e;let t=[],n=null;for(let r of e)if(r.content.length!==0){if(n===null){n={...r,content:[...r.content]};continue}wn(n)&&wn(r)&&To(n.formatting,r.formatting)?n={type:"run",formatting:n.formatting,content:ko(n.content,r.content)}:(t.push(n),n={...r,content:[...r.content]});}return n!==null&&t.push(n),t}function Ke(e){if(e.length<=1)return e;let t=[],n=[];function r(){if(n.length>0){let o=Po(n);t.push(...o),n.length=0;}}for(let o of e)if(o.type==="run")n.push(o);else if(r(),o.type==="hyperlink"){let i={...o,children:Ke(o.children)};t.push(i);}else t.push(o);return r(),t}function Ro(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Mo(e){if(!e)return;let t={},n=c(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=c(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=c(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=c(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=c(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=c(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function oe(e){if(!e)return;let t=c(e,"w","val");if(!t)return;let n={style:t},r=c(e,"w","color"),o=c(e,"w","themeColor");(r||o)&&(n.color=Ro(r,o,c(e,"w","themeTint"),c(e,"w","themeShade")));let i=h(e,"w","sz");i!==void 0&&(n.size=i);let s=h(e,"w","space");s!==void 0&&(n.space=s);let a=c(e,"w","shadow");a&&(n.shadow=a==="1"||a==="true");let l=c(e,"w","frame");return l&&(n.frame=l==="1"||l==="true"),n}function Eo(e){if(!e)return;let t=A(e,"w","tab");if(t.length===0)return;let n=[];for(let r of t){let o=h(r,"w","pos"),i=c(r,"w","val");if(o!==void 0&&i){let s={position:o,alignment:i},a=c(r,"w","leader");a&&(s.leader=a),n.push(s);}}return n.length>0?n:void 0}function Io(e){if(!e)return;let t={},n=h(e,"w","w");n!==void 0&&(t.width=n);let r=h(e,"w","h");r!==void 0&&(t.height=r);let o=c(e,"w","hAnchor");(o==="text"||o==="margin"||o==="page")&&(t.hAnchor=o);let i=c(e,"w","vAnchor");(i==="text"||i==="margin"||i==="page")&&(t.vAnchor=i);let s=h(e,"w","x");s!==void 0&&(t.x=s);let a=h(e,"w","y");a!==void 0&&(t.y=a);let l=c(e,"w","xAlign");l&&(t.xAlign=l);let f=c(e,"w","yAlign");f&&(t.yAlign=f);let p=c(e,"w","wrap");return p&&(t.wrap=p),Object.keys(t).length>0?t:void 0}function Do(e,t,n){if(!e)return;let r={},o=u(e,"w","jc");if(o){let x=c(o,"w","val");x&&(r.alignment=x);}let i=u(e,"w","bidi");i&&(r.bidi=T(i));let s=u(e,"w","spacing");if(s){let x=h(s,"w","before");x!==void 0&&(r.spaceBefore=x);let F=h(s,"w","after");F!==void 0&&(r.spaceAfter=F);let S=h(s,"w","line");S!==void 0&&(r.lineSpacing=S);let E=c(s,"w","lineRule");E&&(r.lineSpacingRule=E);let I=c(s,"w","beforeAutospacing");I&&(r.beforeAutospacing=I==="1"||I==="true");let $=c(s,"w","afterAutospacing");$&&(r.afterAutospacing=$==="1"||$==="true");}let a=u(e,"w","ind");if(a){let x=h(a,"w","left");x!==void 0&&(r.indentLeft=x);let F=h(a,"w","right");F!==void 0&&(r.indentRight=F);let S=h(a,"w","firstLine");S!==void 0&&(r.indentFirstLine=S);let E=h(a,"w","hanging");E!==void 0&&(r.indentFirstLine=-E,r.hangingIndent=true);let I=h(a,"w","start");I!==void 0&&r.indentLeft===void 0&&(r.indentLeft=I);let $=h(a,"w","end");$!==void 0&&r.indentRight===void 0&&(r.indentRight=$);}let l=u(e,"w","pBdr");if(l){let x={},F=oe(u(l,"w","top"));F&&(x.top=F);let S=oe(u(l,"w","bottom"));S&&(x.bottom=S);let E=oe(u(l,"w","left"));E&&(x.left=E);let I=oe(u(l,"w","right"));I&&(x.right=I);let $=oe(u(l,"w","between"));$&&(x.between=$);let z=oe(u(l,"w","bar"));z&&(x.bar=z),Object.keys(x).length>0&&(r.borders=x);}let f=u(e,"w","shd");f&&(r.shading=Mo(f));let p=u(e,"w","tabs");p&&(r.tabs=Eo(p));let d=u(e,"w","keepNext");d&&(r.keepNext=T(d));let w=u(e,"w","keepLines");w&&(r.keepLines=T(w));let g=u(e,"w","widowControl");g&&(r.widowControl=T(g));let m=u(e,"w","pageBreakBefore");m&&(r.pageBreakBefore=T(m));let b=u(e,"w","numPr");if(b){let x=u(b,"w","numId"),F=u(b,"w","ilvl");if(x||F){if(r.numPr={},x){let S=h(x,"w","val");S!==void 0&&(r.numPr.numId=S);}if(F){let S=h(F,"w","val");S!==void 0&&(r.numPr.ilvl=S);}}}let D=u(e,"w","outlineLvl");if(D){let x=h(D,"w","val");x!==void 0&&(r.outlineLevel=x);}let k=u(e,"w","pStyle");if(k){let x=c(k,"w","val");x&&(r.styleId=x);}let M=u(e,"w","framePr");M&&(r.frame=Io(M));let R=u(e,"w","suppressLineNumbers");R&&(r.suppressLineNumbers=T(R));let y=u(e,"w","suppressAutoHyphens");y&&(r.suppressAutoHyphens=T(y));let C=u(e,"w","rPr");return C&&(r.runProperties=Ze(C,t)),Object.keys(r).length>0?r:void 0}function yn(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Ao(e,t,n,r,o){return Yt(e,t,n,r,o)}function Bo(e){return Kt(e)}function $o(e){return Qt(e)}function xn(e){let t=e.trim().match(/^\\?([A-Z]+)/i);if(!t)return "UNKNOWN";let n=t[1].toUpperCase();return ["PAGE","NUMPAGES","NUMWORDS","NUMCHARS","DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","DOCPROPERTY","DOCVARIABLE","REF","PAGEREF","NOTEREF","HYPERLINK","TOC","TOA","INDEX","SEQ","STYLEREF","AUTONUM","AUTONUMLGL","AUTONUMOUT","IF","MERGEFIELD","NEXT","NEXTIF","ASK","SET","QUOTE","INCLUDETEXT","INCLUDEPICTURE","SYMBOL","ADVANCE","EDITTIME","REVNUM","SECTION","SECTIONPAGES","USERADDRESS","USERNAME","USERINITIALS"].includes(n)?n:"UNKNOWN"}function Lo(e,t,n,r,o){let i=c(e,"w","instr")??"",s=xn(i),a={type:"simpleField",instruction:i,fieldType:s,content:[]},l=c(e,"w","fldLock");(l==="1"||l==="true")&&(a.fldLock=true);let f=c(e,"w","dirty");(f==="1"||f==="true")&&(a.dirty=true);let p=N(e);for(let d of p)yn(d.name)==="r"&&a.content.push(me(d,t,n,r,o));return a}function bn(e,t,n,r,o,i){let s=[],a=N(e),l=false,f="",p=[],d=[],w=false,g=false,m=false;for(let b of a)switch(yn(b.name)){case "r":{let k=me(b,t,n,o,i),M=false,R=false,y=false,C="";for(let x of k.content)x.type==="fieldChar"?x.charType==="begin"?(M=true,x.fldLock&&(g=true),x.dirty&&(m=true)):x.charType==="separate"?R=true:x.charType==="end"&&(y=true):x.type==="instrText"&&(C+=x.text);if(M&&(l=true,w=false,f="",p=[],d=[],g=false,m=false),l){if(C&&(f+=C),R&&(w=true),w&&!y?R||d.push(k):!w&&!M&&p.push(k),y){let x={type:"complexField",instruction:f.trim(),fieldType:xn(f),fieldCode:p,fieldResult:d};g&&(x.fldLock=true),m&&(x.dirty=true),s.push(x),l=false;}}else s.push(k);break}case "hyperlink":s.push(Ao(b,o,t,n,i));break;case "bookmarkStart":s.push(Bo(b));break;case "bookmarkEnd":s.push($o(b));break;case "fldSimple":s.push(Lo(b,t,n,o,i));break;case "pPr":break;case "proofErr":case "permStart":case "permEnd":case "customXml":break;case "sdt":{let k=(b.elements??[]).find(M=>M.type==="element"&&(M.name==="w:sdtContent"||M.name?.endsWith(":sdtContent")));if(k){let M=bn(k,t,n,null,o,i);s.push(...M);}break}}return s}function J(e,t,n,r,o=null,i=null){let s={type:"paragraph",content:[]},a=c(e,"w14","paraId")??c(e,"w","paraId");a&&(s.paraId=a);let l=c(e,"w14","textId")??c(e,"w","textId");l&&(s.textId=l);let f=u(e,"w","pPr");if(f){s.formatting=Do(f,n);let d=u(f,"w","sectPr");d&&(s.sectionProperties=Re(d));}let p=bn(e,t,n,r,o,i);if(s.content=Ke(p),s.formatting?.numPr&&r){let{numId:d,ilvl:w=0}=s.formatting.numPr;if(d!==void 0&&d!==0){let g=r.getLevel(d,w);g&&(s.listRendering={level:w,numId:d,marker:g.lvlText,isBullet:g.numFmt==="bullet",numFmt:g.numFmt},g.pPr&&(s.formatting||(s.formatting={}),g.pPr.indentLeft!==void 0&&(s.formatting.indentLeft=g.pPr.indentLeft),g.pPr.indentFirstLine!==void 0&&(s.formatting.indentFirstLine=g.pPr.indentFirstLine),g.pPr.hangingIndent!==void 0&&(s.formatting.hangingIndent=g.pPr.hangingIndent)));}}return s}function Qe(e){let t="";for(let n of e.content)if(n.type==="run")for(let r of n.content)r.type==="text"?t+=r.text:r.type==="tab"?t+=" ":r.type==="break"&&(r.breakType==="page"?t+="\f":t+=`
|
|
3
|
-
`);else if(n.type==="hyperlink"){for(let r of n.children)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}else if(n.type==="simpleField"){for(let r of n.content)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}else if(n.type==="complexField")for(let r of n.fieldResult)for(let o of r.content)o.type==="text"&&(t+=o.text);return t}function No(e){if(!e||e.trim()==="")return "\u2022";let t=e.charCodeAt(0),n={183:"\u2022",111:"\u25CB",167:"\u25A0",252:"\u2713",110:"\u25A0",113:"\u25CB",117:"\u25C6",118:"\u2756",168:"\u2713",251:"\u2713",254:"\u2713",61623:"\u2022",61550:"\u25A0",61551:"\u25CB",61607:"\u25A0",61692:"\u2713",8226:"\u2022",9679:"\u25CF",9675:"\u25CB",9632:"\u25A0",9633:"\u25A1",9670:"\u25C6",9671:"\u25C7",8211:"\u2013",8212:"\u2014",62:">",45:"-"};return n[t]?n[t]:t>=57344&&t<=63743||t<32||t>=127&&t<160?"\u2022":e}function Xo(e,t,n){let r=e.listRendering;if(!r||!t)return;let{numId:o,level:i}=r;if(o===void 0||o===0)return;n.has(o)||n.set(o,new Array(9).fill(0));let s=n.get(o);s[i]=(s[i]||0)+1;for(let f=i+1;f<s.length;f++)s[f]=0;let a=r.marker;if(r.isBullet){let f=a||"";r.marker=No(f);return}let l=a;for(let f=0;f<=i;f++){let p=`%${f+1}`;if(l.includes(p)){let d=s[f],w=t.getLevel(o,f),g=Ho(d,w?.numFmt||"decimal");l=l.replace(p,g);}}r.marker=l;}function Ho(e,t){switch(t){case "decimal":case "decimalZero":return String(e);case "lowerLetter":return String.fromCharCode(96+(e-1)%26+1);case "upperLetter":return String.fromCharCode(64+(e-1)%26+1);case "lowerRoman":return Tn(e).toLowerCase();case "upperRoman":return Tn(e);case "bullet":return "\u2022";default:return String(e)}}function Tn(e){let t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],n="";for(let[r,o]of t)for(;e>=r;)n+=o,e-=r;return n}var Cn=/\{\{([^{}]+)\}\}/g;function Fn(e){let t=[],n;for(Cn.lastIndex=0;(n=Cn.exec(e))!==null;){let r=n[1].trim();r&&!t.includes(r)&&t.push(r);}return t}function Sn(e){let t=[];for(let n of e)if(n.type==="paragraph"){let r=Qe(n),o=Fn(r);for(let i of o)t.includes(i)||t.push(i);}else if(n.type==="table"){let r=vn(n);for(let o of r)t.includes(o)||t.push(o);}return t}function vn(e){let t=[];for(let n of e.rows)for(let r of n.cells)for(let o of r.content)if(o.type==="paragraph"){let i=Qe(o),s=Fn(i);for(let a of s)t.includes(a)||t.push(a);}else if(o.type==="table"){let i=vn(o);for(let s of i)t.includes(s)||t.push(s);}return t}function kn(e,t,n,r,o,i){let s=[],a=N(e),l=new Map;for(let f of a){let p=f.name??"";if(p==="w:p"||p.endsWith(":p")){let d=J(f,t,n,r,o,i);Xo(d,r,l),s.push(d);}else if(p==="w:tbl"||p.endsWith(":tbl")){let d=ge(f,t,n,r,o,i);s.push(d);}else if(p==="w:sdt"||p.endsWith(":sdt")){let d=(f.elements??[]).find(w=>w.type==="element"&&(w.name==="w:sdtContent"||w.name?.endsWith(":sdtContent")));if(d){let w=kn(d,t,n,r,o,i);s.push(...w);}}}return s}function Oo(e,t){let n=[],r=[];for(let o of e)r.push(o),o.type==="paragraph"&&o.sectionProperties&&(n.push({properties:o.sectionProperties,content:r}),r=[]);return (r.length>0||n.length===0)&&n.push({properties:t??hn(),content:r}),n}function Pn(e,t=null,n=null,r=null,o=null,i=null){let s={content:[]};if(!e)return s;let a=W(e);if(!a)return s;let l=(a.elements??[]).find(d=>d.type==="element"&&(d.name==="w:document"||d.name?.endsWith(":document")));if(!l)return s;let f=u(l,"w","body");if(!f)return s;s.content=kn(f,t,n,r,o,i);let p=u(f,"w","sectPr");return p&&(s.finalSectionProperties=Re(p)),s.sections=Oo(s.content,s.finalSectionProperties),s}var Ie=new Set,Ee=new Map,jo=new Set;function Mn(e,t=[400,700],n=["normal","italic"]){let r=encodeURIComponent(e),o=[];for(let s of n){let a=s==="italic"?1:0;for(let l of t)o.push(`${a},${l}`);}o.sort();let i=o.join(";");return `https://fonts.googleapis.com/css2?family=${r}:ital,wght@${i}&display=swap`}async function zo(e,t){let n=e.trim();if(Ie.has(n))return true;let r=Ee.get(n);if(r)return r;let o=(async()=>{try{let i=Mn(n,t?.weights,t?.styles),s=document.createElement("link");return s.rel="stylesheet",s.href=i,await new Promise(l=>{s.onload=()=>l(!0),s.onerror=()=>l(!1),document.head.appendChild(s),setTimeout(()=>l(!1),5e3);})?(await _o(n,3e3),Ie.add(n),Vo([n]),!0):!1}catch(i){return console.warn(`Failed to load font "${n}":`,i),false}finally{Ee.delete(n),Ee.size===0&&(false);}})();return Ee.set(n,o),o}function Vo(e){for(let t of jo)try{t(e);}catch(n){console.warn("Font load callback error:",n);}}async function _o(e,t){if("fonts"in document)try{let n=`400 16px "${e}"`;return await Promise.race([document.fonts.load(n),new Promise(r=>setTimeout(r,t))]),document.fonts.check(n)}catch{}return await new Promise(n=>setTimeout(n,100)),true}var Wo={Calibri:"Carlito",Cambria:"Caladea",Arial:"Arimo","Times New Roman":"Tinos","Courier New":"Cousine",Garamond:"EB Garamond","Book Antiqua":"EB Garamond",Georgia:"Tinos",Verdana:"Open Sans",Tahoma:"Open Sans","Trebuchet MS":"Source Sans Pro","Century Gothic":"Poppins","Franklin Gothic":"Libre Franklin",Palatino:"EB Garamond","Palatino Linotype":"EB Garamond","Lucida Sans":"Open Sans","Segoe UI":"Open Sans",Impact:"Anton","Comic Sans MS":"Comic Neue",Consolas:"Inconsolata","Lucida Console":"Inconsolata",Monaco:"Fira Code"};function Uo(e){let t=e.trim();return Wo[t]||t}async function qo(e){let t=e.trim(),n=Uo(t);return n!==t?(await Go(t,n),Ie.add(t),Ie.add(n),true):zo(n)}async function Go(e,t){let n=`font-alias-${e.toLowerCase().replace(/\s+/g,"-")}`;if(!document.getElementById(n))try{let r=Mn(t,[400,700],["normal","italic"]),o=await fetch(r);if(!o.ok){console.warn(`Failed to fetch Google Fonts CSS for "${t}": ${o.status}`);return}let i=await o.text(),s=new RegExp(`font-family:\\s*['"]${Jo(t)}['"]`,"gi"),a=i.replace(s,`font-family: '${e}'`),l=document.createElement("style");l.id=n,l.textContent=a,document.head.appendChild(l),console.log(`Loaded font: "${e}" (via ${t})`);}catch(r){console.warn(`Failed to create font alias for "${e}":`,r);}}function Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function En(e){let t=[...new Set(e.map(n=>n.trim()))];await Promise.all(t.map(n=>qo(n)));}async function Ae(e,t={}){let{onProgress:n=()=>{},preloadFonts:r=true,parseHeadersFooters:o=true,parseNotes:i=true,detectVariables:s=true}=t,a=[];try{n("Extracting DOCX...",0);let l=await Ft(e);n("Extracted DOCX",10),n("Parsing relationships...",10);let f=l.documentRels?Te(l.documentRels):new Map;n("Parsed relationships",15),n("Parsing theme...",15);let p=Et(l.themeXml);n("Parsed theme",20),n("Parsing styles...",20);let d=null,w;l.stylesXml&&(d=Ge(l.stylesXml,p),w=Xt(l.stylesXml,p)),n("Parsed styles",30),n("Parsing numbering...",30);let g=Ht(l.numberingXml);n("Parsed numbering",35),n("Processing media files...",35);let m=Zo(l,f);n("Processed media",40),n("Parsing document body...",40);let b={content:[]};l.documentXml?b=Pn(l.documentXml,d,p,g,f,m):a.push("No document.xml found in DOCX"),n("Parsed document body",55);let D,k;if(o){n("Parsing headers/footers...",55);let{headers:F,footers:S}=Yo(l,d,p,g,f,m);D=F,k=S,n("Parsed headers/footers",65);}else n("Skipping headers/footers",65);let M,R;if(i){n("Parsing footnotes/endnotes...",65);let{footnotes:F,endnotes:S}=Ko(l,d,p,g,f,m);M=F,R=S,n("Parsed footnotes/endnotes",75);}else n("Skipping footnotes/endnotes",75);let y;s?(n("Detecting template variables...",75),y=Sn(b.content),n("Detected variables",80)):n("Skipping variable detection",80),r?(n("Loading fonts...",80),await Qo(p,w,b),n("Loaded fonts",95)):n("Skipping font loading",95),n("Assembling document...",95);let x={package:{document:b,styles:w,theme:p,numbering:g.definitions,headers:D,footers:k,footnotes:M,endnotes:R,relationships:f,media:m},originalBuffer:e,templateVariables:y,warnings:a.length>0?a:void 0};return n("Complete",100),x}catch(l){let f=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse DOCX: ${f}`)}}function Zo(e,t){let n=new Map;for(let[r,o]of e.media.entries()){let i=r.split("/").pop()||r,s=St(r),a=new Uint8Array(o),l="";for(let g=0;g<a.length;g++)l+=String.fromCharCode(a[g]);let f=btoa(l),p=`data:${s};base64,${f}`,d={path:r,filename:i,mimeType:s,data:o,dataUrl:p};n.set(r,d);let w=r.replace(/^word\//,"");w!==r&&n.set(w,d);}return n}function De(e,t){let n=t.toLowerCase();for(let[r,o]of e.entries())if(r.toLowerCase()===n)return o}function Yo(e,t,n,r,o,i){let s=new Map,a=new Map;for(let[l,f]of o.entries())if(f.type===be.header&&f.target){let p=f.target.split("/").pop()||f.target,d=De(e.headers,p);if(d){let w=`word/_rels/${p}.rels`,g=De(e.allXml,w),m=g?Te(g):o,b=an(d,"default",t,n,r,m,i);s.set(l,b);}}else if(f.type===be.footer&&f.target){let p=f.target.split("/").pop()||f.target,d=De(e.footers,p);if(d){let w=`word/_rels/${p}.rels`,g=De(e.allXml,w),m=g?Te(g):o,b=ln(d,"default",t,n,r,m,i);a.set(l,b);}}return {headers:s,footers:a}}function Ko(e,t,n,r,o,i){let s=un(e.footnotesXml,t,n,r,o,i),a=fn(e.endnotesXml,t,n,r,o,i);return {footnotes:s.getNormalFootnotes(),endnotes:a.getNormalEndnotes()}}async function Qo(e,t,n){let r=new Set;if(e?.fontScheme){let{majorFont:o,minorFont:i}=e.fontScheme;o?.latin&&r.add(o.latin),i?.latin&&r.add(i.latin);}if(t?.docDefaults?.rPr?.fontFamily?.ascii&&r.add(t.docDefaults.rPr.fontFamily.ascii),t?.styles)for(let o of t.styles)o.rPr?.fontFamily?.ascii&&r.add(o.rPr.fontFamily.ascii),o.rPr?.fontFamily?.hAnsi&&r.add(o.rPr.fontFamily.hAnsi);if(n.content){for(let o of n.content)if(o.type==="paragraph")for(let i of o.content)i.type==="run"&&i.formatting?.fontFamily&&(i.formatting.fontFamily.ascii&&r.add(i.formatting.fontFamily.ascii),i.formatting.fontFamily.hAnsi&&r.add(i.formatting.fontFamily.hAnsi));}if(r.size>0)try{await En(Array.from(r));}catch(o){console.warn("Failed to load some fonts:",o);}}var Le={type:"string",description:"Document ID from a previous docx_load call"},hi={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"]},Bn={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
|
|
2
|
+
import yt from'pizzip';import xt from'docxtemplater';import ot from'jszip';import {xml2js}from'xml-js';var ct=Object.defineProperty;var Yn=(e,t,n)=>t in e?ct(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var ut=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ft=(e,t)=>()=>(e&&(t=e(e=0)),t);var Kn=(e,t)=>{for(var n in t)ct(e,n,{get:t[n],enumerable:true});};var pe=(e,t,n)=>Yn(e,typeof t!="symbol"?t+"":t,n);var Oe,re,we=ft(()=>{Oe=class{constructor(){pe(this,"plugins",new Map);pe(this,"commandHandlers",new Map);pe(this,"eventListeners",new Set);pe(this,"initialized",new Set);}register(t,n){let r=[];if(!t.id)return {success:false,error:"Plugin must have an id"};if(this.plugins.has(t.id))return {success:false,error:`Plugin '${t.id}' is already registered`};if(t.dependencies){for(let o of t.dependencies)if(!this.plugins.has(o))return {success:false,error:`Plugin '${t.id}' requires '${o}' which is not registered`}}if(t.commandHandlers)for(let[o,i]of Object.entries(t.commandHandlers)){if(this.commandHandlers.has(o)){let s=this.commandHandlers.get(o);r.push(`Command '${o}' from '${t.id}' overrides handler from '${s.pluginId}'`);}this.commandHandlers.set(o,{pluginId:t.id,handler:i});}if(this.plugins.set(t.id,t),t.initialize&&!this.initialized.has(t.id))try{let o=t.initialize();o instanceof Promise?o.then(()=>{this.initialized.add(t.id);}).catch(i=>{this.emit({type:"error",pluginId:t.id,error:i});}):this.initialized.add(t.id);}catch(o){this.emit({type:"error",pluginId:t.id,error:o});}return n?.debug&&console.log(`[PluginRegistry] Registered plugin: ${t.id}`),this.emit({type:"registered",plugin:t}),{success:true,plugin:t,warnings:r.length>0?r:void 0}}unregister(t){let n=this.plugins.get(t);if(!n)return false;for(let[r,o]of this.plugins)if(o.dependencies?.includes(t))return console.warn(`Cannot unregister '${t}': '${r}' depends on it`),false;for(let[r,{pluginId:o}]of this.commandHandlers)o===t&&this.commandHandlers.delete(r);if(n.destroy)try{let r=n.destroy();r instanceof Promise&&r.catch(o=>{this.emit({type:"error",pluginId:t,error:o});});}catch(r){this.emit({type:"error",pluginId:t,error:r});}return this.plugins.delete(t),this.initialized.delete(t),this.emit({type:"unregistered",pluginId:t}),true}get(t){return this.plugins.get(t)}getAll(){return Array.from(this.plugins.values())}has(t){return this.plugins.has(t)}get size(){return this.plugins.size}getCommandHandler(t){return this.commandHandlers.get(t)?.handler}getCommandTypes(){return Array.from(this.commandHandlers.keys())}hasCommandHandler(t){return this.commandHandlers.has(t)}getMcpTools(){let t=[];for(let n of this.plugins.values())n.mcpTools&&t.push(...n.mcpTools);return t}getMcpToolsForPlugin(t){return this.plugins.get(t)?.mcpTools||[]}getMcpTool(t){for(let n of this.plugins.values())if(n.mcpTools){let r=n.mcpTools.find(o=>o.name===t);if(r)return r}}addEventListener(t){this.eventListeners.add(t);}removeEventListener(t){this.eventListeners.delete(t);}emit(t){for(let n of this.eventListeners)try{n(t);}catch(r){console.error("[PluginRegistry] Event listener error:",r);}}clear(){for(let t of this.plugins.values())if(t.destroy)try{t.destroy();}catch{}this.plugins.clear(),this.commandHandlers.clear(),this.initialized.clear();}getDebugInfo(){return {plugins:Array.from(this.plugins.keys()),commandTypes:Array.from(this.commandHandlers.keys()),mcpTools:this.getMcpTools().map(t=>t.name),initialized:Array.from(this.initialized)}}},re=new Oe;});var An={};Kn(An,{default:()=>gi,executeCommand:()=>ee,executeCommands:()=>ei});function ee(e,t){let n=re.getCommandHandler(t.type);if(n)return n(e,t);switch(t.type){case "insertText":return ti(e,t);case "replaceText":return ni(e,t);case "deleteText":return ri(e,t);case "formatText":return oi(e,t);case "formatParagraph":return ii(e,t);case "applyStyle":return si(e,t);case "insertTable":return ai(e,t);case "insertImage":return li(e,t);case "insertHyperlink":return ci(e,t);case "removeHyperlink":return ui(e,t);case "insertParagraphBreak":return Dn(e,t);case "mergeParagraphs":return fi(e,t);case "splitParagraph":return pi(e,t);case "setVariable":return di(e,t);case "applyVariables":return mi(e,t);default:let r=t;throw new Error(`Unknown command type: ${r.type}`)}}function ei(e,t){return t.reduce((n,r)=>ee(n,r),e)}function j(e){return JSON.parse(JSON.stringify(e))}function N(e,t){let n=0;for(let r=0;r<e.content.length;r++)if(e.content[r].type==="paragraph"){if(n===t)return r;n++;}return -1}function he(e){let t="";for(let n of e.content)if(n.type==="run")for(let r of n.content)r.type==="text"&&(t+=r.text);else if(n.type==="hyperlink"){for(let r of n.children)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}return t}function Be(e,t){return {type:"run",formatting:t,content:[{type:"text",text:e}]}}function $e(e,t,n,r){let o=[],i=0,s=false;for(let a of e.content)if(a.type==="run"){let c=a.content.filter(d=>d.type==="text").map(d=>d.text).join(""),f=i,p=i+c.length;if(!s&&t>=f&&t<=p){let d=t-f;d>0&&o.push({...a,content:[{type:"text",text:c.slice(0,d)}]}),o.push(Be(n,r||a.formatting)),d<c.length&&o.push({...a,content:[{type:"text",text:c.slice(d)}]}),s=true;}else o.push(a);i=p;}else o.push(a);return s||o.push(Be(n,r)),o}function oe(e,t,n){let r=[],o=0;for(let i of e.content)if(i.type==="run"){let s=i.content.filter(f=>f.type==="text").map(f=>f.text).join(""),a=o,c=o+s.length;if(c<=t||a>=n)r.push(i);else {let f="";a<t&&(f+=s.slice(0,t-a)),c>n&&(f+=s.slice(n-a)),f.length>0&&r.push({...i,content:[{type:"text",text:f}]});}o=c;}else r.push(i);return r}function In(e,t,n,r){let o=[],i=0;for(let s of e.content)if(s.type==="run"){let a=s.content.filter(p=>p.type==="text").map(p=>p.text).join(""),c=i,f=i+a.length;if(f<=t||c>=n)o.push(s);else if(c>=t&&f<=n)o.push({...s,formatting:{...s.formatting,...r}});else {let p=Math.max(t,c),d=Math.min(n,f);c<p&&o.push({...s,content:[{type:"text",text:a.slice(0,p-c)}]}),o.push({...s,formatting:{...s.formatting,...r},content:[{type:"text",text:a.slice(p-c,d-c)}]}),f>d&&o.push({...s,content:[{type:"text",text:a.slice(d-c)}]});}i=f;}else o.push(s);return o}function ti(e,t){let n=j(e),r=n.package.document,o=N(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o];return i.content=$e(i,t.position.offset,t.text,t.formatting),n}function ni(e,t){let n=j(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=N(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=oe(a,o.offset,i.offset),a.content=$e(a,o.offset,t.text,t.formatting);}else {let s=N(r,o.paragraphIndex),a=r.content[s],c=he(a);a.content=oe(a,o.offset,c.length),a.content=$e(a,o.offset,t.text,t.formatting);let f=[];for(let p=o.paragraphIndex+1;p<=i.paragraphIndex;p++)f.push(N(r,p));for(let p=f.length-1;p>=0;p--)f[p]!==-1&&r.content.splice(f[p],1);}return n}function ri(e,t){let n=j(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=N(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=oe(a,o.offset,i.offset);}else {let s=N(r,o.paragraphIndex),a=r.content[s],c=he(a);a.content=oe(a,o.offset,c.length);let f=N(r,i.paragraphIndex),p=r.content[f];p.content=oe(p,0,i.offset),a.content.push(...p.content);let d=[];for(let w=o.paragraphIndex+1;w<=i.paragraphIndex;w++)d.push(N(r,w));for(let w=d.length-1;w>=0;w--)d[w]!==-1&&r.content.splice(d[w],1);}return n}function oi(e,t){let n=j(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex===i.paragraphIndex){let s=N(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s];a.content=In(a,o.offset,i.offset,t.formatting);}else for(let s=o.paragraphIndex;s<=i.paragraphIndex;s++){let a=N(r,s);if(a===-1)continue;let c=r.content[a],f=he(c),p=0,d=f.length;s===o.paragraphIndex&&(p=o.offset),s===i.paragraphIndex&&(d=i.offset),c.content=In(c,p,d,t.formatting);}return n}function ii(e,t){let n=j(e),r=n.package.document,o=N(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o];if(i.formatting={...i.formatting,...t.formatting},"numPr"in t.formatting){let s=t.formatting.numPr;if(s&&s.numId!==void 0&&s.numId!==0){let a=s.ilvl??0,c=s.numId===1,f=c?"\u2022":"1.";if(n.package.numbering){let p=n.package.numbering.nums.find(d=>d.numId===s.numId);if(p){let d=n.package.numbering.abstractNums.find(w=>w.abstractNumId===p.abstractNumId);if(d){let w=d.levels.find(g=>g.ilvl===a);w&&(f=w.lvlText||f);}}}i.listRendering={level:a,numId:s.numId,marker:f,isBullet:c};}else delete i.listRendering;}return n}function si(e,t){let n=j(e),r=n.package.document,o=N(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o];return i.formatting={...i.formatting,styleId:t.styleId},n}function ai(e,t){let n=j(e),r=n.package.document,o=[];for(let a=0;a<t.rows;a++){let c=[];for(let f=0;f<t.columns;f++){let p=t.data?.[a]?.[f]||"";c.push({type:"tableCell",content:[{type:"paragraph",content:p?[Be(p)]:[]}]});}o.push({type:"tableRow",formatting:a===0&&t.hasHeader?{header:true}:void 0,cells:c});}let i={type:"table",rows:o},s=N(r,t.position.paragraphIndex);return s===-1?r.content.push(i):r.content.splice(s+1,0,i),n}function li(e,t){let n=j(e),r=n.package.document,o=N(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o],a={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:t.src,alt:t.alt,size:{width:(t.width||100)*914400,height:(t.height||100)*914400},wrap:{type:"inline"}}}]},c=$e(i,t.position.offset,"",void 0),f=false,p=0;for(let d=0;d<c.length;d++){let w=c[d];if(w.type==="run"){let g=w.content.filter(m=>m.type==="text").map(m=>m.text).join("");if(p+=g.length,!f&&p>=t.position.offset){c.splice(d+1,0,a),f=true;break}}}return f||c.push(a),i.content=c,n}function ci(e,t){let n=j(e),r=n.package.document,{start:o,end:i}=t.range;if(o.paragraphIndex!==i.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let s=N(r,o.paragraphIndex);if(s===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let a=r.content[s],c=he(a),f=t.displayText||c.slice(o.offset,i.offset);a.content=oe(a,o.offset,i.offset);let p={type:"hyperlink",href:t.url,tooltip:t.tooltip,children:[Be(f)]},d=false,w=0,g=[];for(let m of a.content)if(m.type==="run"){let b=m.content.filter(P=>P.type==="text").map(P=>P.text).join(""),D=w+b.length;if(!d&&w<=o.offset&&o.offset<=D){let P=o.offset-w;P>0&&g.push({...m,content:[{type:"text",text:b.slice(0,P)}]}),g.push(p),P<b.length&&g.push({...m,content:[{type:"text",text:b.slice(P)}]}),d=true;}else g.push(m);w=D;}else g.push(m);return d||g.push(p),a.content=g,n}function ui(e,t){let n=j(e),r=n.package.document,{start:o}=t.range,i=N(r,o.paragraphIndex);if(i===-1)throw new Error(`Paragraph index ${o.paragraphIndex} not found`);let s=r.content[i],a=[];for(let c of s.content)if(c.type==="hyperlink")for(let f of c.children)f.type==="run"&&a.push(f);else a.push(c);return s.content=a,n}function Dn(e,t){let n=j(e),r=n.package.document,o=N(r,t.position.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let i=r.content[o],s=he(i),a=oe({...i,content:[...i.content]},t.position.offset,s.length),c=oe({...i,content:[...i.content]},0,t.position.offset);i.content=a;let f={type:"paragraph",formatting:i.formatting,content:c};return r.content.splice(o+1,0,f),n}function fi(e,t){let n=j(e),r=n.package.document,o=N(r,t.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let i=r.content[o],s=[];for(let a=1;a<=t.count;a++){let c=N(r,t.paragraphIndex+a);if(c!==-1){let f=r.content[c];i.content.push(...f.content),s.push(c);}}for(let a=s.length-1;a>=0;a--)r.content.splice(s[a],1);return n}function pi(e,t){return Dn(e,{position:t.position})}function di(e,t){let n=j(e);return n.templateVariables||(n.templateVariables=[]),n.templateVariables.includes(t.name)||n.templateVariables.push(t.name),n}function mi(e,t){let n=j(e),r=n.package.document;function o(a){for(let c of a.content)if(c.type==="text")for(let[f,p]of Object.entries(t.values)){let d=new RegExp(`\\{${f}\\}`,"g");c.text=c.text.replace(d,p);}}function i(a){for(let c of a.content)if(c.type==="run")o(c);else if(c.type==="hyperlink")for(let f of c.children)f.type==="run"&&o(f);}function s(a){if(a.type==="paragraph")i(a);else if(a.type==="table")for(let c of a.rows)for(let f of c.cells)for(let p of f.content)s(p);}for(let a of r.content)s(a);return n}var gi,et=ft(()=>{we();gi=ee;});we();function ze(e,t){let n=t,{position:r,variableName:o}=n,i=JSON.parse(JSON.stringify(e)),a=i.package.document.content.filter(p=>p.type==="paragraph");if(r.paragraphIndex>=a.length)throw new Error(`Paragraph index ${r.paragraphIndex} out of bounds`);let c=a[r.paragraphIndex],f=`{{${o}}}`;return pt(c,r.offset,f),i.templateVariables||(i.templateVariables=[]),i.templateVariables.includes(o)||i.templateVariables.push(o),i}function Ve(e,t){let n=t,{range:r,variableName:o}=n,i=JSON.parse(JSON.stringify(e)),a=i.package.document.content.filter(p=>p.type==="paragraph");if(r.start.paragraphIndex!==r.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(r.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${r.start.paragraphIndex} out of bounds`);let c=a[r.start.paragraphIndex];Qn(c,r.start.offset,r.end.offset);let f=`{{${o}}}`;return pt(c,r.start.offset,f),i.templateVariables||(i.templateVariables=[]),i.templateVariables.includes(o)||i.templateVariables.push(o),i}function pt(e,t,n){let r=0,o=false;for(let i=0;i<e.content.length;i++){let s=e.content[i];if(s.type==="run"){let a=je(s),c=r,f=r+a.length;if(!o&&t>=c&&t<=f){let p=t-c,d=a.slice(0,p),w=a.slice(p),g=[];for(let m=0;m<i;m++)g.push(e.content[m]);d&&g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:d}]}),g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:n}]}),w&&g.push({type:"run",formatting:s.formatting,content:[{type:"text",text:w}]});for(let m=i+1;m<e.content.length;m++)g.push(e.content[m]);e.content=g,o=true;break}r=f;}else if(s.type==="hyperlink")for(let a of s.children)a.type==="run"&&(r+=je(a).length);}o||e.content.push({type:"run",content:[{type:"text",text:n}]});}function Qn(e,t,n){let r=[],o=0;for(let i of e.content)if(i.type==="run"){let s=je(i),a=o,c=o+s.length;if(c<=t||a>=n)r.push(i);else {let f="";a<t&&(f+=s.slice(0,t-a)),c>n&&(f+=s.slice(n-a)),f.length>0&&r.push({type:"run",formatting:i.formatting,content:[{type:"text",text:f}]});}o=c;}else r.push(i);e.content=r;}function je(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function gt(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let o=er(e.package.document);o.forEach(i=>{t.push({name:i,location:"body"});}),n.body=Array.from(new Set(o)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((o,i)=>{o.properties.headerReferences&&o.properties.headerReferences.forEach(s=>{});}),e.package?.footnotes){let o=mt(e.package.footnotes);o.forEach(i=>{t.push({name:i,location:"footnote"});}),n.footnotes=Array.from(new Set(o)).sort();}if(e.package?.endnotes){let o=mt(e.package.endnotes);o.forEach(i=>{t.push({name:i,location:"endnote"});}),n.endnotes=Array.from(new Set(o)).sort();}e.templateVariables&&e.templateVariables.forEach(o=>{t.some(i=>i.name===o)||t.push({name:o,location:"body"});});let r=new Set;return t.forEach(o=>r.add(o.name)),{variables:Array.from(r).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function er(e){let t=[];if(e.content&&t.push(...dt(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...dt(n.content));return t}function dt(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(..._e(n)):n.type==="table"&&t.push(...ht(n));return t}function _e(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...de(n)):n.type==="hyperlink"?t.push(...tr(n)):n.type==="simpleField"?t.push(...nr(n)):n.type==="complexField"&&t.push(...rr(n));return t}function de(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...wt(n.text));return t}function tr(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...de(n));return t}function nr(e){let t=[];if(e.instruction&&t.push(...wt(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...de(n));return t}function rr(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...de(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...de(n));return t}function ht(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let r of n.cells)t.push(...or(r));return t}function or(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(..._e(n)):n.type==="table"&&t.push(...ht(n));return t}function mt(e){let t=[];for(let n of e)if(n.content)for(let r of n.content)t.push(..._e(r));return t}var ir=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function wt(e){if(!e)return [];let t=[],n=new RegExp(ir),r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t}function bt(e,t,n={}){let{nullGetter:r="keep",linebreaks:o=true,delimiters:i}=n,s=[],a=[],c=[];try{let f=new yt(e),p=new xt(f,{paragraphLoop:!0,linebreaks:o,nullGetter:w=>{let g=w.value||"";if(r==="error")throw new Error(`Undefined variable: ${g}`);return r==="empty"?(c.push(g),""):(c.push(g),`{${g}}`)},delimiters:i?{start:i.start||"{",end:i.end||"}"}:void 0});return Object.keys(t).forEach(w=>{t[w]!==void 0&&t[w]!==null&&a.push(w);}),p.setData(t),p.render(),{buffer:p.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:a,unreplacedVariables:c,warnings:s}}catch(f){throw Ct(f)}}function Tt(e){let t=[],n=[];try{let r=new yt(e),i=new xt(r,{paragraphLoop:!0,linebreaks:!0}).getFullText();n=sr(i);let s=ar(i);for(let a of s)t.push({message:`Unclosed tag: ${a}`,variable:a,type:"parse"});return {valid:t.length===0,errors:t,tags:n}}catch(r){return t.push(Ct(r)),{valid:false,errors:t,tags:n}}}function sr(e){let t=[],n=/\{([^{}]+)\}/g,r;for(;(r=n.exec(e))!==null;){let o=r[1].trim();o&&!t.includes(o)&&t.push(o);}return t.sort()}function ar(e){let t=[],n=0,r="";for(let o of e)o==="{"?(n++,r=""):o==="}"?(n--,n<0&&(n=0)):n>0&&(r+=o);return n>0&&r.trim()&&t.push(r.trim()),t}function lr(e){return "properties"in e&&typeof e.properties=="object"}function Ct(e){if(e instanceof Error){if(lr(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"}}async function Ft(e){let t=await ot.loadAsync(e),n={documentXml:null,stylesXml:null,themeXml:null,numberingXml:null,fontTableXml:null,settingsXml:null,webSettingsXml:null,headers:new Map,footers:new Map,footnotesXml:null,endnotesXml:null,commentsXml:null,documentRels:null,packageRels:null,contentTypesXml:null,corePropsXml:null,appPropsXml:null,customPropsXml:null,media:new Map,fonts:new Map,allXml:new Map,originalZip:t,originalBuffer:e};for(let[r,o]of Object.entries(t.files)){if(o.dir)continue;let i=r.toLowerCase();if(i.endsWith(".xml")||i.endsWith(".rels")){let s=await o.async("text");if(n.allXml.set(r,s),i==="word/document.xml")n.documentXml=s;else if(i==="word/styles.xml")n.stylesXml=s;else if(i==="word/theme/theme1.xml")n.themeXml=s;else if(i==="word/numbering.xml")n.numberingXml=s;else if(i==="word/fonttable.xml")n.fontTableXml=s;else if(i==="word/settings.xml")n.settingsXml=s;else if(i==="word/websettings.xml")n.webSettingsXml=s;else if(i==="word/footnotes.xml")n.footnotesXml=s;else if(i==="word/endnotes.xml")n.endnotesXml=s;else if(i==="word/comments.xml")n.commentsXml=s;else if(i==="word/_rels/document.xml.rels")n.documentRels=s;else if(i==="_rels/.rels")n.packageRels=s;else if(i==="[content_types].xml")n.contentTypesXml=s;else if(i==="docprops/core.xml")n.corePropsXml=s;else if(i==="docprops/app.xml")n.appPropsXml=s;else if(i==="docprops/custom.xml")n.customPropsXml=s;else if(i.match(/^word\/header\d+\.xml$/)){let a=r.split("/").pop()||r;n.headers.set(a,s);}else if(i.match(/^word\/footer\d+\.xml$/)){let a=r.split("/").pop()||r;n.footers.set(a,s);}}else if(i.startsWith("word/media/")){let s=await o.async("arraybuffer");n.media.set(r,s);}else if(i.startsWith("word/fonts/")){let s=await o.async("arraybuffer");n.fonts.set(r,s);}}return n}function St(e){switch(e.toLowerCase().split(".").pop()){case "png":return "image/png";case "jpg":case "jpeg":return "image/jpeg";case "gif":return "image/gif";case "bmp":return "image/bmp";case "tif":case "tiff":return "image/tiff";case "wmf":return "image/x-wmf";case "emf":return "image/x-emf";case "svg":return "image/svg+xml";case "webp":return "image/webp";default:return "application/octet-stream"}}function J(e){return xml2js(e,{compact:false,ignoreComment:true,ignoreInstruction:true,ignoreDoctype:true,alwaysArray:false,trim:false,attributesKey:"attributes",textKey:"text"})}function Z(e){try{let t=J(e);return t.elements&&t.elements.length>0?t.elements.find(n=>n.type==="element")??null:t}catch(t){return console.warn("Failed to parse XML:",t),null}}function ye(e){let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function u(e,t,n){if(!e||!e.elements)return null;let r=`${t}:${n}`;for(let o of e.elements)if(o.type==="element"&&(o.name===r||ye(o.name||"")===n))return o;return null}function A(e,t,n){if(!e||!e.elements)return [];let r=`${t}:${n}`,o=[];for(let i of e.elements)i.type==="element"&&(i.name===r||ye(i.name||"")===n)&&o.push(i);return o}function X(e){return !e||!e.elements?[]:e.elements.filter(t=>t.type==="element")}function l(e,t,n){if(!e||!e.attributes)return null;let r=e.attributes;if(t){let o=`${t}:${n}`;if(o in r)return r[o]}return n in r?r[n]:null}function xe(e){if(!e)return "";if("text"in e&&typeof e.text=="string")return e.text;if(!e.elements)return "";let t="";for(let n of e.elements)n.type==="text"&&"text"in n?t+=n.text??"":n.type==="element"&&(t+=xe(n));return t}function vt(e){return e?{val:l(e,"w","val")??void 0,themeColor:l(e,"w","themeColor")??void 0,themeTint:l(e,"w","themeTint")??void 0,themeShade:l(e,"w","themeShade")??void 0}:null}function h(e,t,n,r=1){let o=l(e,t,n);if(o===null)return;let i=parseInt(o,10);if(!isNaN(i))return i*r}function T(e,t="w"){if(!e)return false;let n=l(e,t,"val");return n===null?true:!(n==="0"||n==="false"||n==="off")}var be={hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",header:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",footer:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"};function Te(e){let t=new Map;if(!e||e.trim().length===0)return t;let n=Z(e);if(!n)return console.warn("Failed to parse relationships XML"),t;let r=X(n);for(let o of r){let i=o.name||"";if(!i.endsWith("Relationship")&&!i.includes(":Relationship"))continue;let s=l(o,null,"Id"),a=l(o,null,"Type"),c=l(o,null,"Target"),f=l(o,null,"TargetMode");if(!s||!a||!c){console.warn("Relationship missing required attributes:",{id:s,type:a,target:c});continue}let p={id:s,type:a,target:c};f==="External"?p.targetMode="External":f==="Internal"&&(p.targetMode="Internal"),t.set(s,p);}return t}function kt(e){return e.type===be.hyperlink&&e.targetMode==="External"}var Mt={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Ce={majorFont:{latin:"Calibri Light",ea:"",cs:"",fonts:{}},minorFont:{latin:"Calibri",ea:"",cs:"",fonts:{}}},We={name:"Office Theme",colorScheme:Mt,fontScheme:Ce},fr=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function pr(e){if(!e)return null;switch(ye(e.name||"")){case "srgbClr":return l(e,"a","val")??l(e,null,"val")??null;case "sysClr":{let n=l(e,"a","lastClr")??l(e,null,"lastClr");if(n)return n;switch(l(e,"a","val")??l(e,null,"val")){case "windowText":case "menuText":case "captionText":case "btnText":return "000000";case "window":case "menu":case "btnFace":case "btnHighlight":return "FFFFFF";case "highlight":return "0078D7";case "highlightText":return "FFFFFF";case "grayText":return "808080";default:return null}}case "schemeClr":{l(e,"a","val")??l(e,null,"val");return null}default:return null}}function dr(e){let t={...Mt};if(!e)return t;for(let n of fr){let r=u(e,"a",n);if(r){let o=X(r);if(o.length>0){let i=pr(o[0]);i&&(t[n]=i);}}}return t}function Pt(e){let t={latin:"",ea:"",cs:"",fonts:{}};if(!e)return t;let n=u(e,"a","latin");n&&(t.latin=l(n,"a","typeface")??l(n,null,"typeface")??"");let r=u(e,"a","ea");r&&(t.ea=l(r,"a","typeface")??l(r,null,"typeface")??"");let o=u(e,"a","cs");o&&(t.cs=l(o,"a","typeface")??l(o,null,"typeface")??"");let i=A(e,"a","font");for(let s of i){let a=l(s,"a","script")??l(s,null,"script"),c=l(s,"a","typeface")??l(s,null,"typeface");a&&c&&(t.fonts=t.fonts||{},t.fonts[a]=c);}return t}function mr(e){let t={...Ce};if(!e)return t;let n=u(e,"a","majorFont");n&&(t.majorFont=Pt(n));let r=u(e,"a","minorFont");return r&&(t.minorFont=Pt(r)),t}function Et(e){if(!e)return {...We};try{let t=Z(e);if(!t)return {...We};let n=l(t,"a","name")??l(t,null,"name")??"Office Theme",r=u(t,"a","themeElements"),o=u(r,"a","clrScheme"),i=dr(o),s=u(r,"a","fontScheme"),a=mr(s);return {name:n,colorScheme:i,fontScheme:a}}catch(t){return console.warn("Failed to parse theme:",t),{...We}}}function gr(e,t="latin"){if(!e?.fontScheme?.majorFont)return Ce.majorFont?.latin??"Calibri Light";let n=e.fontScheme.majorFont;return t==="latin"?n.latin||"Calibri Light":t==="ea"?n.ea||"":t==="cs"?n.cs||"":n.fonts?.[t]?n.fonts[t]:n.latin||"Calibri Light"}function Rt(e,t="latin"){if(!e?.fontScheme?.minorFont)return Ce.minorFont?.latin??"Calibri";let n=e.fontScheme.minorFont;return t==="latin"?n.latin||"Calibri":t==="ea"?n.ea||"":t==="cs"?n.cs||"":n.fonts?.[t]?n.fonts[t]:n.latin||"Calibri"}function U(e,t){if(!t)return "Calibri";let n=t.toLowerCase().includes("major"),r=t.toLowerCase().includes("minor"),o="latin",i=t.toLowerCase();return i.includes("eastasia")?o="ea":(i.includes("bidi")||i.includes("cs"))&&(o="cs"),n?gr(e,o):r?Rt(e,o):Rt(e,"latin")}function Fe(e,t){if(!e)return;let n={},r=u(e,"w","b");r&&(n.bold=T(r));let o=u(e,"w","bCs");o&&(n.boldCs=T(o));let i=u(e,"w","i");i&&(n.italic=T(i));let s=u(e,"w","iCs");s&&(n.italicCs=T(s));let a=u(e,"w","u");if(a){let F=l(a,"w","val");if(F){n.underline={style:F};let v=l(a,"w","color"),V=l(a,"w","themeColor");(v||V)&&(n.underline.color=Ue(v,V,l(a,"w","themeTint"),l(a,"w","themeShade")));}}let c=u(e,"w","strike");c&&(n.strike=T(c));let f=u(e,"w","dstrike");f&&(n.doubleStrike=T(f));let p=u(e,"w","vertAlign");if(p){let F=l(p,"w","val");(F==="superscript"||F==="subscript"||F==="baseline")&&(n.vertAlign=F);}let d=u(e,"w","smallCaps");d&&(n.smallCaps=T(d));let w=u(e,"w","caps");w&&(n.allCaps=T(w));let g=u(e,"w","vanish");g&&(n.hidden=T(g));let m=u(e,"w","color");m&&(n.color=Ue(l(m,"w","val"),l(m,"w","themeColor"),l(m,"w","themeTint"),l(m,"w","themeShade")));let b=u(e,"w","highlight");if(b){let F=l(b,"w","val");F&&(n.highlight=F);}let D=u(e,"w","shd");D&&(n.shading=Se(D));let P=u(e,"w","sz");if(P){let F=h(P,"w","val");F!==void 0&&(n.fontSize=F);}let M=u(e,"w","szCs");if(M){let F=h(M,"w","val");F!==void 0&&(n.fontSizeCs=F);}let R=u(e,"w","rFonts");if(R){n.fontFamily={ascii:l(R,"w","ascii")??void 0,hAnsi:l(R,"w","hAnsi")??void 0,eastAsia:l(R,"w","eastAsia")??void 0,cs:l(R,"w","cs")??void 0};let F=l(R,"w","asciiTheme");F&&(n.fontFamily.asciiTheme=F,t&&!n.fontFamily.ascii&&(n.fontFamily.ascii=U(t,F)));let v=l(R,"w","hAnsiTheme");v&&(n.fontFamily.hAnsiTheme=v,t&&!n.fontFamily.hAnsi&&(n.fontFamily.hAnsi=U(t,v)));let V=l(R,"w","eastAsiaTheme");V&&(n.fontFamily.eastAsiaTheme=V,t&&!n.fontFamily.eastAsia&&(n.fontFamily.eastAsia=U(t,V)));let W=l(R,"w","cstheme");W&&(n.fontFamily.csTheme=W,t&&!n.fontFamily.cs&&(n.fontFamily.cs=U(t,W)));}let y=u(e,"w","spacing");if(y){let F=h(y,"w","val");F!==void 0&&(n.spacing=F);}let C=u(e,"w","position");if(C){let F=h(C,"w","val");F!==void 0&&(n.position=F);}let x=u(e,"w","w");if(x){let F=h(x,"w","val");F!==void 0&&(n.scale=F);}let S=u(e,"w","kern");if(S){let F=h(S,"w","val");F!==void 0&&(n.kerning=F);}let k=u(e,"w","effect");if(k){let F=l(k,"w","val");F&&(n.effect=F);}let E=u(e,"w","em");if(E){let F=l(E,"w","val");F&&(n.emphasisMark=F);}let I=u(e,"w","emboss");I&&(n.emboss=T(I));let B=u(e,"w","imprint");B&&(n.imprint=T(B));let H=u(e,"w","outline");H&&(n.outline=T(H));let L=u(e,"w","shadow");L&&(n.shadow=T(L));let O=u(e,"w","rtl");O&&(n.rtl=T(O));let q=u(e,"w","cs");q&&(n.cs=T(q));let G=u(e,"w","rStyle");if(G){let F=l(G,"w","val");F&&(n.styleId=F);}return Object.keys(n).length>0?n:void 0}function Ue(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Se(e){if(!e)return;let t={},n=l(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=l(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=l(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=l(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=l(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=l(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function _(e){if(!e)return;let t=l(e,"w","val");if(!t)return;let n={style:t},r=l(e,"w","color"),o=l(e,"w","themeColor");(r||o)&&(n.color=Ue(r,o,l(e,"w","themeTint"),l(e,"w","themeShade")));let i=h(e,"w","sz");i!==void 0&&(n.size=i);let s=h(e,"w","space");s!==void 0&&(n.space=s);let a=l(e,"w","shadow");a&&(n.shadow=a==="1"||a==="true");let c=l(e,"w","frame");return c&&(n.frame=c==="1"||c==="true"),n}function hr(e){if(!e)return;let t=A(e,"w","tab");if(t.length===0)return;let n=[];for(let r of t){let o=h(r,"w","pos"),i=l(r,"w","val");if(o!==void 0&&i){let s={position:o,alignment:i},a=l(r,"w","leader");a&&(s.leader=a),n.push(s);}}return n.length>0?n:void 0}function qe(e,t){if(!e)return;let n={},r=u(e,"w","jc");if(r){let y=l(r,"w","val");y&&(n.alignment=y);}let o=u(e,"w","bidi");o&&(n.bidi=T(o));let i=u(e,"w","spacing");if(i){let y=h(i,"w","before");y!==void 0&&(n.spaceBefore=y);let C=h(i,"w","after");C!==void 0&&(n.spaceAfter=C);let x=h(i,"w","line");x!==void 0&&(n.lineSpacing=x);let S=l(i,"w","lineRule");S&&(n.lineSpacingRule=S);let k=l(i,"w","beforeAutospacing");k&&(n.beforeAutospacing=k==="1"||k==="true");let E=l(i,"w","afterAutospacing");E&&(n.afterAutospacing=E==="1"||E==="true");}let s=u(e,"w","ind");if(s){let y=h(s,"w","left");y!==void 0&&(n.indentLeft=y);let C=h(s,"w","right");C!==void 0&&(n.indentRight=C);let x=h(s,"w","firstLine");x!==void 0&&(n.indentFirstLine=x);let S=h(s,"w","hanging");S!==void 0&&(n.indentFirstLine=-S,n.hangingIndent=true);}let a=u(e,"w","pBdr");if(a){let y={},C=_(u(a,"w","top"));C&&(y.top=C);let x=_(u(a,"w","bottom"));x&&(y.bottom=x);let S=_(u(a,"w","left"));S&&(y.left=S);let k=_(u(a,"w","right"));k&&(y.right=k);let E=_(u(a,"w","between"));E&&(y.between=E);let I=_(u(a,"w","bar"));I&&(y.bar=I),Object.keys(y).length>0&&(n.borders=y);}let c=u(e,"w","shd");c&&(n.shading=Se(c));let f=u(e,"w","tabs");f&&(n.tabs=hr(f));let p=u(e,"w","keepNext");p&&(n.keepNext=T(p));let d=u(e,"w","keepLines");d&&(n.keepLines=T(d));let w=u(e,"w","widowControl");w&&(n.widowControl=T(w));let g=u(e,"w","pageBreakBefore");g&&(n.pageBreakBefore=T(g));let m=u(e,"w","numPr");if(m){let y=u(m,"w","numId"),C=u(m,"w","ilvl");if(y||C){if(n.numPr={},y){let x=h(y,"w","val");x!==void 0&&(n.numPr.numId=x);}if(C){let x=h(C,"w","val");x!==void 0&&(n.numPr.ilvl=x);}}}let b=u(e,"w","outlineLvl");if(b){let y=h(b,"w","val");y!==void 0&&(n.outlineLevel=y);}let D=u(e,"w","pStyle");if(D){let y=l(D,"w","val");y&&(n.styleId=y);}let P=u(e,"w","suppressLineNumbers");P&&(n.suppressLineNumbers=T(P));let M=u(e,"w","suppressAutoHyphens");M&&(n.suppressAutoHyphens=T(M));let R=u(e,"w","rPr");return R&&(n.runProperties=Fe(R,t)),Object.keys(n).length>0?n:void 0}function Y(e){if(!e)return;let t=h(e,"w","w"),n=l(e,"w","type");if(t!==void 0&&n)return {value:t,type:n}}function Bt(e){if(!e)return;let t={},n=_(u(e,"w","top"));n&&(t.top=n);let r=_(u(e,"w","bottom"));r&&(t.bottom=r);let o=_(u(e,"w","left"));o&&(t.left=o);let i=_(u(e,"w","right"));i&&(t.right=i);let s=_(u(e,"w","insideH"));s&&(t.insideH=s);let a=_(u(e,"w","insideV"));return a&&(t.insideV=a),Object.keys(t).length>0?t:void 0}function $t(e){if(!e)return;let t={},n=Y(u(e,"w","top"));n&&(t.top=n);let r=Y(u(e,"w","bottom"));r&&(t.bottom=r);let o=Y(u(e,"w","left"));o&&(t.left=o);let i=Y(u(e,"w","right"));return i&&(t.right=i),Object.keys(t).length>0?t:void 0}function wr(e){if(!e)return;let t={},n=l(e,"w","val");if(n){let f=parseInt(n,16);isNaN(f)||(t.firstRow=(f&32)!==0,t.lastRow=(f&64)!==0,t.firstColumn=(f&128)!==0,t.lastColumn=(f&256)!==0,t.noHBand=(f&512)!==0,t.noVBand=(f&1024)!==0);}let r=l(e,"w","firstColumn");r&&(t.firstColumn=r==="1");let o=l(e,"w","firstRow");o&&(t.firstRow=o==="1");let i=l(e,"w","lastColumn");i&&(t.lastColumn=i==="1");let s=l(e,"w","lastRow");s&&(t.lastRow=s==="1");let a=l(e,"w","noHBand");a&&(t.noHBand=a==="1");let c=l(e,"w","noVBand");return c&&(t.noVBand=c==="1"),Object.keys(t).length>0?t:void 0}function It(e,t){if(!e)return;let n={},r=u(e,"w","tblW");r&&(n.width=Y(r));let o=u(e,"w","jc");if(o){let m=l(o,"w","val");(m==="left"||m==="center"||m==="right")&&(n.justification=m);}let i=u(e,"w","tblCellSpacing");i&&(n.cellSpacing=Y(i));let s=u(e,"w","tblInd");s&&(n.indent=Y(s));let a=u(e,"w","tblBorders");a&&(n.borders=Bt(a));let c=u(e,"w","tblCellMar");c&&(n.cellMargins=$t(c));let f=u(e,"w","tblLayout");if(f){let m=l(f,"w","type");(m==="fixed"||m==="autofit")&&(n.layout=m);}let p=u(e,"w","tblStyle");if(p){let m=l(p,"w","val");m&&(n.styleId=m);}let d=u(e,"w","tblLook");d&&(n.look=wr(d));let w=u(e,"w","shd");w&&(n.shading=Se(w));let g=u(e,"w","bidiVisual");return g&&(n.bidi=T(g)),Object.keys(n).length>0?n:void 0}function Dt(e){if(!e)return;let t={},n=u(e,"w","trHeight");if(n){t.height=Y(n);let a=l(n,"w","hRule");a&&(t.heightRule=a);}let r=u(e,"w","tblHeader");r&&(t.header=T(r));let o=u(e,"w","cantSplit");o&&(t.cantSplit=T(o));let i=u(e,"w","jc");if(i){let a=l(i,"w","val");(a==="left"||a==="center"||a==="right")&&(t.justification=a);}let s=u(e,"w","hidden");return s&&(t.hidden=T(s)),Object.keys(t).length>0?t:void 0}function At(e,t){if(!e)return;let n={},r=u(e,"w","tcW");r&&(n.width=Y(r));let o=u(e,"w","tcBorders");o&&(n.borders=Bt(o));let i=u(e,"w","tcMar");i&&(n.margins=$t(i));let s=u(e,"w","shd");s&&(n.shading=Se(s));let a=u(e,"w","vAlign");if(a){let m=l(a,"w","val");(m==="top"||m==="center"||m==="bottom")&&(n.verticalAlign=m);}let c=u(e,"w","textDirection");if(c){let m=l(c,"w","val");m&&(n.textDirection=m);}let f=u(e,"w","gridSpan");if(f){let m=h(f,"w","val");m!==void 0&&(n.gridSpan=m);}let p=u(e,"w","vMerge");if(p){let m=l(p,"w","val");n.vMerge=m==="restart"?"restart":"continue";}let d=u(e,"w","tcFitText");d&&(n.fitText=T(d));let w=u(e,"w","noWrap");w&&(n.noWrap=T(w));let g=u(e,"w","hideMark");return g&&(n.hideMark=T(g)),Object.keys(n).length>0?n:void 0}function yr(e,t){let n={styleId:l(e,"w","styleId")??"",type:l(e,"w","type")??"paragraph"},r=l(e,"w","default");r&&(n.default=r==="1"||r==="true");let o=u(e,"w","name");o&&(n.name=l(o,"w","val")??void 0);let i=u(e,"w","basedOn");i&&(n.basedOn=l(i,"w","val")??void 0);let s=u(e,"w","next");s&&(n.next=l(s,"w","val")??void 0);let a=u(e,"w","link");a&&(n.link=l(a,"w","val")??void 0);let c=u(e,"w","uiPriority");if(c){let y=h(c,"w","val");y!==void 0&&(n.uiPriority=y);}let f=u(e,"w","hidden");f&&(n.hidden=T(f));let p=u(e,"w","semiHidden");p&&(n.semiHidden=T(p));let d=u(e,"w","unhideWhenUsed");d&&(n.unhideWhenUsed=T(d));let w=u(e,"w","qFormat");w&&(n.qFormat=T(w));let g=u(e,"w","personal");g&&(n.personal=T(g));let m=u(e,"w","pPr");m&&(n.pPr=qe(m,t));let b=u(e,"w","rPr");b&&(n.rPr=Fe(b,t));let D=u(e,"w","tblPr");D&&(n.tblPr=It(D));let P=u(e,"w","trPr");P&&(n.trPr=Dt(P));let M=u(e,"w","tcPr");M&&(n.tcPr=At(M));let R=A(e,"w","tblStylePr");if(R.length>0){n.tblStylePr=[];for(let y of R){let C=l(y,"w","type");if(C){let x={type:C},S=u(y,"w","pPr");S&&(x.pPr=qe(S,t));let k=u(y,"w","rPr");k&&(x.rPr=Fe(k,t));let E=u(y,"w","tblPr");E&&(x.tblPr=It(E));let I=u(y,"w","trPr");I&&(x.trPr=Dt(I));let B=u(y,"w","tcPr");B&&(x.tcPr=At(B)),n.tblStylePr.push(x);}}}return n}function xr(e,t){if(!e)return;let n={},r=u(e,"w","rPrDefault");if(r){let i=u(r,"w","rPr");i&&(n.rPr=Fe(i,t));}let o=u(e,"w","pPrDefault");if(o){let i=u(o,"w","pPr");i&&(n.pPr=qe(i,t));}return n.rPr||n.pPr?n:void 0}function Lt(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let r of Object.keys(t)){let o=t[r];o!==void 0&&(n[r]=typeof o=="object"&&o!==null?{...n[r]||{},...o}:o);}return n}function br(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let r of Object.keys(t)){let o=t[r];if(o!==void 0)if(r==="runProperties")n.runProperties=Lt(n.runProperties,t.runProperties);else if(r==="borders"||r==="numPr"||r==="frame"){let i=n[r],s=o;n[r]={...i||{},...s||{}};}else r==="tabs"&&Array.isArray(o)?n.tabs=[...o]:n[r]=o;}return n}function Nt(e,t,n,r=new Set){if(r.has(e.styleId)||(r.add(e.styleId),!e.basedOn))return e;let o=t.get(e.basedOn);if(!o)return e;let i=Nt(o,t,n,r),s={...e,pPr:br(i.pPr,e.pPr),rPr:Lt(i.rPr,e.rPr)};return e.type==="table"&&((i.tblPr||e.tblPr)&&(s.tblPr={...i.tblPr||{},...e.tblPr||{}}),(i.trPr||e.trPr)&&(s.trPr={...i.trPr||{},...e.trPr||{}}),(i.tcPr||e.tcPr)&&(s.tcPr={...i.tcPr||{},...e.tcPr||{}})),s}function Ge(e,t){let n=new Map;try{let r=Z(e);if(!r)return n;let o=A(r,"w","style");for(let i of o){let s=yr(i,t);s.styleId&&n.set(s.styleId,s);}for(let[i,s]of n){let a=Nt(s,n,t);n.set(i,a);}}catch(r){console.warn("Failed to parse styles:",r);}return n}function Xt(e,t){let n={styles:[]};try{let r=Z(e);if(!r)return n;let o=u(r,"w","docDefaults");n.docDefaults=xr(o,t);let i=u(r,"w","latentStyles");i&&(n.latentStyles={defLockedState:l(i,"w","defLockedState")==="1",defUIPriority:h(i,"w","defUIPriority"),defSemiHidden:l(i,"w","defSemiHidden")==="1",defUnhideWhenUsed:l(i,"w","defUnhideWhenUsed")==="1",defQFormat:l(i,"w","defQFormat")==="1",count:h(i,"w","count")});let s=Ge(e,t);n.styles=Array.from(s.values());}catch(r){console.warn("Failed to parse style definitions:",r);}return n}function Ht(e){let t={abstractNums:[],nums:[]};if(!e)return Je(t);let n=Z(e);if(!n)return Je(t);let r=A(n,"w","abstractNum");for(let i of r){let s=Tr(i);s&&t.abstractNums.push(s);}let o=A(n,"w","num");for(let i of o){let s=Cr(i);s&&t.nums.push(s);}return Je(t)}function Tr(e){let t=l(e,"w","abstractNumId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let r={abstractNumId:n,levels:[]},o=u(e,"w","multiLevelType");if(o){let f=l(o,"w","val");(f==="hybridMultilevel"||f==="multilevel"||f==="singleLevel")&&(r.multiLevelType=f);}let i=u(e,"w","name");i&&(r.name=l(i,"w","val")??void 0);let s=u(e,"w","numStyleLink");s&&(r.numStyleLink=l(s,"w","val")??void 0);let a=u(e,"w","styleLink");a&&(r.styleLink=l(a,"w","val")??void 0);let c=A(e,"w","lvl");for(let f of c){let p=Ot(f);p&&r.levels.push(p);}return r.levels.sort((f,p)=>f.ilvl-p.ilvl),r}function Cr(e){let t=l(e,"w","numId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let r=u(e,"w","abstractNumId");if(!r)return null;let o=l(r,"w","val");if(o===null)return null;let i=parseInt(o,10);if(isNaN(i))return null;let s={numId:n,abstractNumId:i},a=A(e,"w","lvlOverride");if(a.length>0){s.levelOverrides=[];for(let c of a){let f=l(c,"w","ilvl");if(f===null)continue;let p=parseInt(f,10);if(isNaN(p))continue;let d={ilvl:p},w=u(c,"w","startOverride");if(w){let m=l(w,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(d.startOverride=b);}}let g=u(c,"w","lvl");g&&(d.lvl=Ot(g)??void 0),s.levelOverrides.push(d);}}return s}function Ot(e){let t=l(e,"w","ilvl");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n)||n<0||n>8)return null;let r={ilvl:n,numFmt:"decimal",lvlText:""},o=u(e,"w","start");if(o){let m=l(o,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(r.start=b);}}let i=u(e,"w","numFmt");if(i){let m=l(i,"w","val");m&&(r.numFmt=Fr(m));}let s=u(e,"w","lvlText");s&&(r.lvlText=l(s,"w","val")??"");let a=u(e,"w","lvlJc");if(a){let m=l(a,"w","val");(m==="left"||m==="center"||m==="right")&&(r.lvlJc=m);}let c=u(e,"w","suff");if(c){let m=l(c,"w","val");(m==="tab"||m==="space"||m==="nothing")&&(r.suffix=m);}let f=u(e,"w","isLgl");f&&(r.isLgl=T(f));let p=u(e,"w","lvlRestart");if(p){let m=l(p,"w","val");if(m!==null){let b=parseInt(m,10);isNaN(b)||(r.lvlRestart=b);}}let d=u(e,"w","legacy");d&&(r.legacy={legacy:T(d),legacySpace:h(d,"w","legacySpace"),legacyIndent:h(d,"w","legacyIndent")});let w=u(e,"w","pPr");w&&(r.pPr=Sr(w));let g=u(e,"w","rPr");return g&&(r.rPr=Pr(g)),r}function Fr(e){return {decimal:"decimal",upperRoman:"upperRoman",lowerRoman:"lowerRoman",upperLetter:"upperLetter",lowerLetter:"lowerLetter",ordinal:"ordinal",cardinalText:"cardinalText",ordinalText:"ordinalText",hex:"hex",chicago:"chicago",bullet:"bullet",none:"none",decimalZero:"decimalZero",ganada:"ganada",chosung:"chosung",ideographDigital:"ideographDigital",japaneseCounting:"japaneseCounting",aiueo:"aiueo",iroha:"iroha",decimalFullWidth:"decimalFullWidth",decimalHalfWidth:"decimalHalfWidth",japaneseLegal:"japaneseLegal",japaneseDigitalTenThousand:"japaneseDigitalTenThousand",decimalEnclosedCircle:"decimalEnclosedCircle",decimalFullWidth2:"decimalFullWidth2",aiueoFullWidth:"aiueoFullWidth",irohaFullWidth:"irohaFullWidth",decimalEnclosedFullstop:"decimalEnclosedFullstop",decimalEnclosedParen:"decimalEnclosedParen",decimalEnclosedCircleChinese:"decimalEnclosedCircleChinese",ideographEnclosedCircle:"ideographEnclosedCircle",ideographTraditional:"ideographTraditional",ideographZodiac:"ideographZodiac",ideographZodiacTraditional:"ideographZodiacTraditional",taiwaneseCounting:"taiwaneseCounting",ideographLegalTraditional:"ideographLegalTraditional",taiwaneseCountingThousand:"taiwaneseCountingThousand",taiwaneseDigital:"taiwaneseDigital",chineseCounting:"chineseCounting",chineseLegalSimplified:"chineseLegalSimplified",chineseCountingThousand:"chineseCountingThousand",koreanDigital:"koreanDigital",koreanCounting:"koreanCounting",koreanLegal:"koreanLegal",koreanDigital2:"koreanDigital2",vietnameseCounting:"vietnameseCounting",russianLower:"russianLower",russianUpper:"russianUpper",numberInDash:"numberInDash",hebrew1:"hebrew1",hebrew2:"hebrew2",arabicAlpha:"arabicAlpha",arabicAbjad:"arabicAbjad",hindiVowels:"hindiVowels",hindiConsonants:"hindiConsonants",hindiNumbers:"hindiNumbers",hindiCounting:"hindiCounting",thaiLetters:"thaiLetters",thaiNumbers:"thaiNumbers",thaiCounting:"thaiCounting"}[e]??"decimal"}function Sr(e){let t={},n=u(e,"w","ind");if(n){let o=h(n,"w","left"),i=h(n,"w","right"),s=h(n,"w","firstLine"),a=h(n,"w","hanging");o!==void 0&&(t.indentLeft=o),i!==void 0&&(t.indentRight=i),a!==void 0?(t.indentFirstLine=-a,t.hangingIndent=true):s!==void 0&&(t.indentFirstLine=s);}let r=u(e,"w","tabs");if(r){t.tabs=[];let o=A(r,"w","tab");for(let i of o){let s=h(i,"w","pos"),a=l(i,"w","val"),c=l(i,"w","leader");s!==void 0&&a&&t.tabs.push({position:s,alignment:vr(a),leader:kr(c)});}}return t}function vr(e){switch(e){case "left":return "left";case "center":return "center";case "right":return "right";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "num";default:return "left"}}function kr(e){if(e)switch(e){case "none":return "none";case "dot":return "dot";case "hyphen":return "hyphen";case "underscore":return "underscore";case "heavy":return "heavy";case "middleDot":return "middleDot";default:return}}function Pr(e){let t={},n=u(e,"w","rFonts");n&&(t.fontFamily={ascii:l(n,"w","ascii")??void 0,hAnsi:l(n,"w","hAnsi")??void 0,eastAsia:l(n,"w","eastAsia")??void 0,cs:l(n,"w","cs")??void 0});let r=u(e,"w","sz");if(r){let a=h(r,"w","val");a!==void 0&&(t.fontSize=a);}let o=u(e,"w","color");if(o){let a=l(o,"w","val"),c=l(o,"w","themeColor");a==="auto"?t.color={auto:true}:c?t.color={themeColor:c,themeTint:l(o,"w","themeTint")??void 0,themeShade:l(o,"w","themeShade")??void 0}:a&&(t.color={rgb:a});}let i=u(e,"w","b");i&&(t.bold=T(i));let s=u(e,"w","i");return s&&(t.italic=T(s)),t}function Je(e){let t=new Map;for(let r of e.abstractNums)t.set(r.abstractNumId,r);let n=new Map;for(let r of e.nums)n.set(r.numId,r);return {definitions:e,getLevel(r,o){let i=n.get(r);if(!i)return null;if(i.levelOverrides){let a=i.levelOverrides.find(c=>c.ilvl===o);if(a){if(a.lvl)return a.lvl;let c=t.get(i.abstractNumId);if(c){let f=c.levels.find(p=>p.ilvl===o);if(f&&a.startOverride!==void 0)return {...f,start:a.startOverride}}}}let s=t.get(i.abstractNumId);return s?s.levels.find(a=>a.ilvl===o)??null:null},getAbstract(r){return t.get(r)??null},hasNumbering(r){return n.has(r)}}}function Rr(e){if(!e)return;let t=parseInt(e,10);if(!isNaN(t))return t/6e4}function $(e,t){let n=X(e);for(let r of n)if(r.name===t)return r;return null}function Mr(e,t){let n=X(e);for(let r of n)if(t.includes(r.name||""))return r;return null}function jt(e){if(!e)return {width:0,height:0};let t=h(e,null,"cx")??0,n=h(e,null,"cy")??0;return {width:t,height:n}}function zt(e){if(!e)return;let t=h(e,null,"l")??0,n=h(e,null,"t")??0,r=h(e,null,"r")??0,o=h(e,null,"b")??0;if(!(t===0&&n===0&&r===0&&o===0))return {left:t,top:n,right:r,bottom:o}}function Vt(e){if(!e)return {};let t=l(e,null,"id")??void 0,n=l(e,null,"name")??void 0,r=l(e,null,"descr")??void 0,o=l(e,null,"title")??void 0,i=l(e,null,"decorative")==="1";return {id:t,name:n,alt:r,title:o,decorative:i||void 0}}function Er(e){if(!e)return;let t=l(e,null,"relativeFrom")??"column",n=$(e,"wp:align");if(n){let o=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:o}}let r=$(e,"wp:posOffset");if(r){let o=String(r.elements?.[0]?.text??"0"),i=parseInt(o,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}function Ir(e){if(!e)return;let t=l(e,null,"relativeFrom")??"paragraph",n=$(e,"wp:align");if(n){let o=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:o}}let r=$(e,"wp:posOffset");if(r){let o=String(r.elements?.[0]?.text??"0"),i=parseInt(o,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}var Dr=["wp:wrapNone","wp:wrapSquare","wp:wrapTight","wp:wrapThrough","wp:wrapTopAndBottom"];function Ar(e,t){if(!e)return {type:t?"behind":"inFront"};let r=(e.name||"").replace("wp:",""),o=h(e,null,"distT")??void 0,i=h(e,null,"distB")??void 0,s=h(e,null,"distL")??void 0,a=h(e,null,"distR")??void 0,c=l(e,null,"wrapText")??void 0,f;switch(r){case "wrapNone":f=t?"behind":"inFront";break;case "wrapSquare":f="square";break;case "wrapTight":f="tight";break;case "wrapThrough":f="through";break;case "wrapTopAndBottom":f="topAndBottom";break;default:f="square";}let p={type:f};return c&&(p.wrapText=c),o!==void 0&&(p.distT=o),i!==void 0&&(p.distB=i),s!==void 0&&(p.distL=s),a!==void 0&&(p.distR=a),p}function _t(e){if(!e)return;let t=l(e,null,"rot"),n=l(e,null,"flipH")==="1",r=l(e,null,"flipV")==="1",o=Rr(t);if(o===void 0&&!n&&!r)return;let i={};return o!==void 0&&(i.rotation=o),n&&(i.flipH=true),r&&(i.flipV=true),i}function Wt(e){let t=$(e,"a:graphic");if(!t)return null;let n=$(t,"a:graphicData");if(!n)return null;let r=$(n,"pic:pic");if(!r)return null;let o=$(r,"pic:blipFill");return o?$(o,"a:blip"):null}function Ut(e){if(!e)return "";let t=l(e,"r","embed");if(t)return t;let n=l(e,null,"embed");if(n)return n;let r=l(e,"r","link");return r||""}function qt(e){let t=$(e,"a:graphic");if(!t)return null;let n=$(t,"a:graphicData");if(!n)return null;let r=$(n,"pic:pic");if(!r)return null;let o=$(r,"pic:spPr");return o?$(o,"a:xfrm"):null}function Br(e){if(!e)return e;let t=e.replace(/^\/+/,"");return t.startsWith("media/")?t=`word/${t}`:t.startsWith("word/")||(t=`word/${t}`),t}function $r(e){let t=e.split(".").pop()?.toLowerCase()??"";return {png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",webp:"image/webp",svg:"image/svg+xml",emf:"image/x-emf",wmf:"image/x-wmf"}[t]??"application/octet-stream"}function Gt(e,t,n){if(!e||!t)return {};let r=t.get(e);if(!r)return {};let o=r.target;if(!o)return {};let i=Br(o),s=o.split("/").pop(),a=(c,f)=>{let p=f.toLowerCase();for(let[d,w]of c.entries())if(d.toLowerCase()===p)return w};if(n){let c=a(n,i);if(c)return {src:c.dataUrl||c.base64,mimeType:c.mimeType,filename:s};let f=o.replace(/^\/+/,""),p=a(n,f);if(p)return {src:p.dataUrl||p.base64,mimeType:p.mimeType,filename:s};let d=`word/${f}`,w=a(n,d);if(w)return {src:w.dataUrl||w.base64,mimeType:w.mimeType,filename:s}}return {mimeType:$r(o),filename:s}}function Lr(e,t,n){let r=$(e,"wp:extent"),o=jt(r),i=$(e,"wp:effectExtent"),s=zt(i),a=$(e,"wp:docPr"),c=Vt(a),f=Wt(e),p=Ut(f),d=Gt(p,t,n),w=qt(e),g=_t(w),m={type:"image",rId:p,size:o,wrap:{type:"inline"}};return c.id&&(m.id=c.id),c.alt&&(m.alt=c.alt),c.title&&(m.title=c.title),c.decorative&&(m.decorative=true),d.src&&(m.src=d.src),d.mimeType&&(m.mimeType=d.mimeType),d.filename&&(m.filename=d.filename),s&&(m.padding=s),g&&(m.transform=g),m}function Nr(e,t,n){let r=$(e,"wp:extent"),o=jt(r),i=$(e,"wp:effectExtent"),s=zt(i),a=$(e,"wp:docPr"),c=Vt(a),f=l(e,null,"behindDoc")==="1",p=Mr(e,Dr),d=Ar(p,f),w=$(e,"wp:positionH"),g=$(e,"wp:positionV"),m=Er(w),b=Ir(g),D;(m||b)&&(D={horizontal:m??{relativeTo:"column"},vertical:b??{relativeTo:"paragraph"}});let P=Wt(e),M=Ut(P),R=Gt(M,t,n),y=qt(e),C=_t(y),x={type:"image",rId:M,size:o,wrap:d};return c.id&&(x.id=c.id),c.alt&&(x.alt=c.alt),c.title&&(x.title=c.title),c.decorative&&(x.decorative=true),R.src&&(x.src=R.src),R.mimeType&&(x.mimeType=R.mimeType),R.filename&&(x.filename=R.filename),D&&(x.position=D),s&&(x.padding=s),C&&(x.transform=C),x}function Xr(e,t,n){let r=X(e);for(let o of r){let i=o.name||"";if(i==="wp:inline")return Lr(o,t,n);if(i==="wp:anchor")return Nr(o,t,n)}return null}function Jt(e,t,n){return Xr(e,t,n)}function Zt(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Hr(e){if(!e)return;let t={},n=l(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=l(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=l(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=l(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=l(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=l(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function Ze(e,t,n){if(!e)return;let r={},o=u(e,"w","b");o&&(r.bold=T(o));let i=u(e,"w","bCs");i&&(r.boldCs=T(i));let s=u(e,"w","i");s&&(r.italic=T(s));let a=u(e,"w","iCs");a&&(r.italicCs=T(a));let c=u(e,"w","u");if(c){let v=l(c,"w","val");if(v){r.underline={style:v};let V=l(c,"w","color"),W=l(c,"w","themeColor");(V||W)&&(r.underline.color=Zt(V,W,l(c,"w","themeTint"),l(c,"w","themeShade")));}}let f=u(e,"w","strike");f&&(r.strike=T(f));let p=u(e,"w","dstrike");p&&(r.doubleStrike=T(p));let d=u(e,"w","vertAlign");if(d){let v=l(d,"w","val");(v==="superscript"||v==="subscript"||v==="baseline")&&(r.vertAlign=v);}let w=u(e,"w","smallCaps");w&&(r.smallCaps=T(w));let g=u(e,"w","caps");g&&(r.allCaps=T(g));let m=u(e,"w","vanish");m&&(r.hidden=T(m));let b=u(e,"w","color");b&&(r.color=Zt(l(b,"w","val"),l(b,"w","themeColor"),l(b,"w","themeTint"),l(b,"w","themeShade")));let D=u(e,"w","highlight");if(D){let v=l(D,"w","val");v&&(r.highlight=v);}let P=u(e,"w","shd");P&&(r.shading=Hr(P));let M=u(e,"w","sz");if(M){let v=h(M,"w","val");v!==void 0&&(r.fontSize=v);}let R=u(e,"w","szCs");if(R){let v=h(R,"w","val");v!==void 0&&(r.fontSizeCs=v);}let y=u(e,"w","rFonts");if(y){r.fontFamily={ascii:l(y,"w","ascii")??void 0,hAnsi:l(y,"w","hAnsi")??void 0,eastAsia:l(y,"w","eastAsia")??void 0,cs:l(y,"w","cs")??void 0};let v=l(y,"w","asciiTheme");v&&(r.fontFamily.asciiTheme=v,t&&!r.fontFamily.ascii&&(r.fontFamily.ascii=U(t,v)));let V=l(y,"w","hAnsiTheme");V&&(r.fontFamily.hAnsiTheme=V,t&&!r.fontFamily.hAnsi&&(r.fontFamily.hAnsi=U(t,V)));let W=l(y,"w","eastAsiaTheme");W&&(r.fontFamily.eastAsiaTheme=W,t&&!r.fontFamily.eastAsia&&(r.fontFamily.eastAsia=U(t,W)));let He=l(y,"w","cstheme");He&&(r.fontFamily.csTheme=He,t&&!r.fontFamily.cs&&(r.fontFamily.cs=U(t,He)));}let C=u(e,"w","spacing");if(C){let v=h(C,"w","val");v!==void 0&&(r.spacing=v);}let x=u(e,"w","position");if(x){let v=h(x,"w","val");v!==void 0&&(r.position=v);}let S=u(e,"w","w");if(S){let v=h(S,"w","val");v!==void 0&&(r.scale=v);}let k=u(e,"w","kern");if(k){let v=h(k,"w","val");v!==void 0&&(r.kerning=v);}let E=u(e,"w","effect");if(E){let v=l(E,"w","val");v&&(r.effect=v);}let I=u(e,"w","em");if(I){let v=l(I,"w","val");v&&(r.emphasisMark=v);}let B=u(e,"w","emboss");B&&(r.emboss=T(B));let H=u(e,"w","imprint");H&&(r.imprint=T(H));let L=u(e,"w","outline");L&&(r.outline=T(L));let O=u(e,"w","shadow");O&&(r.shadow=T(O));let q=u(e,"w","rtl");q&&(r.rtl=T(q));let G=u(e,"w","cs");G&&(r.cs=T(G));let F=u(e,"w","rStyle");if(F){let v=l(F,"w","val");v&&(r.styleId=v);}return Object.keys(r).length>0?r:void 0}function Or(e){let t=xe(e),n=l(e,"xml","space")==="preserve";return {type:"text",text:t,preserveSpace:n||void 0}}function jr(){return {type:"tab"}}function zr(e){let t=l(e,"w","type"),n=l(e,"w","clear"),r={type:"break"};return (t==="page"||t==="column"||t==="textWrapping")&&(r.breakType=t),(n==="none"||n==="left"||n==="right"||n==="all")&&(r.clear=n),r}function Vr(e){let t=l(e,"w","font")??"",n=l(e,"w","char")??"";return {type:"symbol",font:t,char:n}}function _r(e){return {type:"footnoteRef",id:h(e,"w","id")??0}}function Wr(e){return {type:"endnoteRef",id:h(e,"w","id")??0}}function Ur(e){let t=l(e,"w","fldCharType"),n=l(e,"w","fldLock")==="true"||l(e,"w","fldLock")==="1",r=l(e,"w","dirty")==="true"||l(e,"w","dirty")==="1",o="begin";return t==="separate"?o="separate":t==="end"&&(o="end"),{type:"fieldChar",charType:o,fldLock:n||void 0,dirty:r||void 0}}function qr(e){return {type:"instrText",text:xe(e)}}function Gr(e,t,n){let r=Jt(e,t??void 0,n??void 0);return r?{type:"drawing",image:r}:null}function Jr(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Zr(e,t,n){let r=[],o=X(e);for(let i of o)switch(Jr(i.name)){case "t":r.push(Or(i));break;case "tab":r.push(jr());break;case "br":r.push(zr(i));break;case "sym":r.push(Vr(i));break;case "footnoteReference":r.push(_r(i));break;case "endnoteReference":r.push(Wr(i));break;case "fldChar":r.push(Ur(i));break;case "instrText":r.push(qr(i));break;case "softHyphen":r.push({type:"softHyphen"});break;case "noBreakHyphen":r.push({type:"noBreakHyphen"});break;case "drawing":let a=Gr(i,t,n);a&&r.push(a);break;case "pict":case "object":break;case "rPr":break;case "lastRenderedPageBreak":break;case "cr":r.push({type:"break",breakType:"textWrapping"});break;}return r}function me(e,t,n,r=null,o=null){let i={type:"run",content:[]},s=u(e,"w","rPr");return s&&(i.formatting=Ze(s,n)),i.content=Zr(e,r,o),i}function Yr(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Kr(e){let t=h(e,"w","id")??0,n=l(e,"w","name")??"",r={type:"bookmarkStart",id:t,name:n},o=h(e,"w","colFirst");o!==void 0&&(r.colFirst=o);let i=h(e,"w","colLast");return i!==void 0&&(r.colLast=i),r}function Qr(e){return {type:"bookmarkEnd",id:h(e,"w","id")??0}}function Yt(e,t,n=null,r=null,o=null){let i={type:"hyperlink",children:[]},s=l(e,"r","id");if(s&&(i.rId=s,t)){let g=t.get(s);g&&(kt(g),i.href=g.target);}let a=l(e,"w","anchor");a&&(i.anchor=a,i.href||(i.href=`#${a}`));let c=l(e,"w","tooltip");c&&(i.tooltip=c);let f=l(e,"w","tgtFrame");f&&(i.target=f);let p=l(e,"w","history");(p==="1"||p==="true")&&(i.history=true);let d=l(e,"w","docLocation");d&&(i.docLocation=d);let w=X(e);for(let g of w)switch(Yr(g.name)){case "r":i.children.push(me(g,n,r,t,o));break;case "bookmarkStart":i.children.push(Kr(g));break;case "bookmarkEnd":i.children.push(Qr(g));break}return i}function Kt(e){let t=h(e,"w","id")??0,n=l(e,"w","name")??"",r={type:"bookmarkStart",id:t,name:n},o=h(e,"w","colFirst");o!==void 0&&(r.colFirst=o);let i=h(e,"w","colLast");return i!==void 0&&(r.colLast=i),r}function Qt(e){return {type:"bookmarkEnd",id:h(e,"w","id")??0}}function eo(e){if(!e)return;let t=h(e,"w","w")??0,n=l(e,"w","type")??"dxa",r="dxa";return (n==="auto"||n==="dxa"||n==="nil"||n==="pct")&&(r=n),{value:t,type:r}}function K(e){return eo(e)}function ae(e){if(!e)return;let r={style:l(e,"w","val")??"none"},o=h(e,"w","sz");o!==void 0&&(r.size=o);let i=h(e,"w","space");i!==void 0&&(r.space=i);let s=vt(e);s&&(r.color={rgb:s.val,themeColor:s.themeColor,themeTint:s.themeTint,themeShade:s.themeShade});let a=l(e,"w","shadow");(a==="1"||a==="true")&&(r.shadow=true);let c=l(e,"w","frame");return (c==="1"||c==="true")&&(r.frame=true),r}function en(e){if(!e)return;let t={},n=ae(u(e,"w","top"));n&&(t.top=n);let r=ae(u(e,"w","bottom"));r&&(t.bottom=r);let o=ae(u(e,"w","left")??u(e,"w","start"));o&&(t.left=o);let i=ae(u(e,"w","right")??u(e,"w","end"));i&&(t.right=i);let s=ae(u(e,"w","insideH"));s&&(t.insideH=s);let a=ae(u(e,"w","insideV"));if(a&&(t.insideV=a),Object.keys(t).length!==0)return t}function tn(e){if(!e)return;let t={},n=K(u(e,"w","top"));n&&(t.top=n);let r=K(u(e,"w","bottom"));r&&(t.bottom=r);let o=K(u(e,"w","left")??u(e,"w","start"));o&&(t.left=o);let i=K(u(e,"w","right")??u(e,"w","end"));if(i&&(t.right=i),Object.keys(t).length!==0)return t}function nn(e){if(!e)return;let t={},n=l(e,"w","fill");n&&n!=="auto"&&(t.fill={rgb:n});let r=l(e,"w","themeFill");if(r){t.fill={themeColor:r};let s=l(e,"w","themeFillTint");s&&t.fill&&(t.fill.themeTint=s);let a=l(e,"w","themeFillShade");a&&t.fill&&(t.fill.themeShade=a);}let o=l(e,"w","color");o&&o!=="auto"&&(t.color={rgb:o});let i=l(e,"w","val");if(i&&(t.pattern=i),Object.keys(t).length!==0)return t}function to(e){if(!e)return;let t={},n=l(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let r=l(e,"w","lastRow");(r==="1"||r==="true")&&(t.lastRow=true);let o=l(e,"w","firstColumn");(o==="1"||o==="true")&&(t.firstColumn=true);let i=l(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let s=l(e,"w","noHBand");(s==="1"||s==="true")&&(t.noHBand=true);let a=l(e,"w","noVBand");(a==="1"||a==="true")&&(t.noVBand=true);let c=l(e,"w","val");if(c){let f=parseInt(c,16);isNaN(f)||(f&32&&(t.firstRow=true),f&64&&(t.lastRow=true),f&128&&(t.firstColumn=true),f&256&&(t.lastColumn=true),f&512&&(t.noHBand=true),f&1024&&(t.noVBand=true));}if(Object.keys(t).length!==0)return t}function no(e){if(!e)return;let t={},n=l(e,"w","horzAnchor");(n==="margin"||n==="page"||n==="text")&&(t.horzAnchor=n);let r=l(e,"w","vertAnchor");(r==="margin"||r==="page"||r==="text")&&(t.vertAnchor=r);let o=h(e,"w","tblpX");o!==void 0&&(t.tblpX=o);let i=l(e,"w","tblpXSpec");i&&(t.tblpXSpec=i);let s=h(e,"w","tblpY");s!==void 0&&(t.tblpY=s);let a=l(e,"w","tblpYSpec");a&&(t.tblpYSpec=a);let c=h(e,"w","topFromText");c!==void 0&&(t.topFromText=c);let f=h(e,"w","bottomFromText");f!==void 0&&(t.bottomFromText=f);let p=h(e,"w","leftFromText");p!==void 0&&(t.leftFromText=p);let d=h(e,"w","rightFromText");if(d!==void 0&&(t.rightFromText=d),Object.keys(t).length!==0)return t}function ro(e){if(!e)return;let t={},n=K(u(e,"w","tblW"));n&&(t.width=n);let r=u(e,"w","jc");if(r){let b=l(r,"w","val");(b==="left"||b==="center"||b==="right"||b==="start")&&(t.justification=b==="start"?"left":b);}let o=K(u(e,"w","tblCellSpacing"));o&&(t.cellSpacing=o);let i=K(u(e,"w","tblInd"));i&&(t.indent=i);let s=en(u(e,"w","tblBorders"));s&&(t.borders=s);let a=tn(u(e,"w","tblCellMar"));a&&(t.cellMargins=a);let c=u(e,"w","tblLayout");if(c){let b=l(c,"w","type");(b==="fixed"||b==="autofit")&&(t.layout=b);}let f=u(e,"w","tblStyle");if(f){let b=l(f,"w","val");b&&(t.styleId=b);}let p=to(u(e,"w","tblLook"));p&&(t.look=p);let d=nn(u(e,"w","shd"));d&&(t.shading=d);let w=u(e,"w","tblOverlap");if(w){let b=l(w,"w","val");(b==="never"||b==="overlap")&&(t.overlap=b);}let g=no(u(e,"w","tblpPr"));if(g&&(t.floating=g),T(u(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length!==0)return t}function oo(e){if(!e)return;let t={},n=u(e,"w","trHeight");if(n){let a=K(n);a&&(t.height=a);let c=l(n,"w","hRule");(c==="auto"||c==="atLeast"||c==="exact")&&(t.heightRule=c);}T(u(e,"w","tblHeader"))&&(t.header=true),T(u(e,"w","cantSplit"))&&(t.cantSplit=true);let i=u(e,"w","jc");if(i){let a=l(i,"w","val");(a==="left"||a==="center"||a==="right")&&(t.justification=a);}if(T(u(e,"w","hidden"))&&(t.hidden=true),Object.keys(t).length!==0)return t}function io(e){if(!e)return;let t={},n=l(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let r=l(e,"w","lastRow");(r==="1"||r==="true")&&(t.lastRow=true);let o=l(e,"w","firstColumn");(o==="1"||o==="true")&&(t.firstColumn=true);let i=l(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let s=l(e,"w","oddHBand");(s==="1"||s==="true")&&(t.oddHBand=true);let a=l(e,"w","evenHBand");(a==="1"||a==="true")&&(t.evenHBand=true);let c=l(e,"w","oddVBand");(c==="1"||c==="true")&&(t.oddVBand=true);let f=l(e,"w","evenVBand");(f==="1"||f==="true")&&(t.evenVBand=true);let p=l(e,"w","firstRowFirstColumn");(p==="1"||p==="true")&&(t.nwCell=true);let d=l(e,"w","firstRowLastColumn");(d==="1"||d==="true")&&(t.neCell=true);let w=l(e,"w","lastRowFirstColumn");(w==="1"||w==="true")&&(t.swCell=true);let g=l(e,"w","lastRowLastColumn");(g==="1"||g==="true")&&(t.seCell=true);let m=l(e,"w","val");if(m&&m.length===12&&(m[0]==="1"&&(t.firstRow=true),m[1]==="1"&&(t.lastRow=true),m[2]==="1"&&(t.firstColumn=true),m[3]==="1"&&(t.lastColumn=true),m[4]==="1"&&(t.oddVBand=true),m[5]==="1"&&(t.evenVBand=true),m[6]==="1"&&(t.oddHBand=true),m[7]==="1"&&(t.evenHBand=true),m[8]==="1"&&(t.nwCell=true),m[9]==="1"&&(t.neCell=true),m[10]==="1"&&(t.swCell=true),m[11]==="1"&&(t.seCell=true)),Object.keys(t).length!==0)return t}function so(e){if(!e)return;let t={},n=K(u(e,"w","tcW"));n&&(t.width=n);let r=en(u(e,"w","tcBorders"));r&&(t.borders=r);let o=tn(u(e,"w","tcMar"));o&&(t.margins=o);let i=nn(u(e,"w","shd"));i&&(t.shading=i);let s=u(e,"w","vAlign");if(s){let m=l(s,"w","val");(m==="top"||m==="center"||m==="bottom")&&(t.verticalAlign=m);}let a=u(e,"w","textDirection");if(a){let m=l(a,"w","val");m&&(t.textDirection=m);}let c=u(e,"w","gridSpan");if(c){let m=h(c,"w","val");m!==void 0&&m>1&&(t.gridSpan=m);}let f=u(e,"w","vMerge");f&&(l(f,"w","val")==="restart"?t.vMerge="restart":t.vMerge="continue"),T(u(e,"w","tcFitText"))&&(t.fitText=true),T(u(e,"w","noWrap"))&&(t.noWrap=true),T(u(e,"w","hideMark"))&&(t.hideMark=true);let g=io(u(e,"w","cnfStyle"));if(g&&(t.conditionalFormat=g),Object.keys(t).length!==0)return t}function ao(e,t,n,r,o,i){let s=[],a=e.elements||[];for(let c of a){if(!c.name)continue;let f=c.name.split(":").pop();if(f==="p"){let p=Q(c,t,n,r,o,i);s.push(p);}else if(f==="tbl"){let p=ge(c,t,n,r,o,i);s.push(p);}}return s.length===0&&s.push({type:"paragraph",content:[]}),s}function lo(e,t,n,r,o,i){let s={type:"tableCell",content:[]},a=so(u(e,"w","tcPr"));return a&&(s.formatting=a),s.content=ao(e,t,n,r,o,i),s}function co(e,t,n,r,o,i){let s={type:"tableRow",cells:[]},a=oo(u(e,"w","trPr"));a&&(s.formatting=a);let c=A(e,"w","tc");for(let f of c){let p=lo(f,t,n,r,o,i);s.cells.push(p);}return s}function uo(e){if(!e)return;let t=[],n=A(e,"w","gridCol");for(let r of n){let o=h(r,"w","w")??0;t.push(o);}return t.length>0?t:void 0}function ge(e,t,n,r,o,i){let s={type:"table",rows:[]},a=ro(u(e,"w","tblPr"));a&&(s.formatting=a);let c=uo(u(e,"w","tblGrid"));c&&(s.columnWidths=c);let f=A(e,"w","tr");for(let p of f){let d=co(p,t,n,r,o,i);s.rows.push(d);}return s}function rn(e){switch(e){case "first":return "first";case "even":return "even";default:return "default"}}function on(e){let t=l(e,"w","type"),n=l(e,"r","id")??"";return {type:rn(t),rId:n}}function sn(e){let t=l(e,"w","type"),n=l(e,"r","id")??"";return {type:rn(t),rId:n}}function Ye(e,t,n,r,o,i){let s=[],a=e.elements??[];for(let c of a){if(c.type!=="element")continue;let f=c.name??"";if(f==="w:p"||f.endsWith(":p")){let p=Q(c,t,n,r,o,i);s.push(p);}else if(f==="w:tbl"||f.endsWith(":tbl")){let p=ge(c,t,n,r,o,i);s.push(p);}else if(f==="w:sdt"||f.endsWith(":sdt")){let p=(c.elements??[]).find(d=>d.type==="element"&&(d.name==="w:sdtContent"||d.name?.endsWith(":sdtContent")));if(p){let d=Ye(p,t,n,r,o,i);s.push(...d);}}}return s}function an(e,t="default",n=null,r=null,o=null,i=null,s=null){let a={type:"header",hdrFtrType:t,content:[]};if(!e)return a;let c=J(e);if(!c)return a;let f=c.elements?.find(p=>p.type==="element"&&(p.name==="w:hdr"||p.name?.endsWith(":hdr")));return f&&(a.content=Ye(f,n,r,o,i,s)),a}function ln(e,t="default",n=null,r=null,o=null,i=null,s=null){let a={type:"footer",hdrFtrType:t,content:[]};if(!e)return a;let c=J(e);if(!c)return a;let f=c.elements?.find(p=>p.type==="element"&&(p.name==="w:ftr"||p.name?.endsWith(":ftr")));return f&&(a.content=Ye(f,n,r,o,i,s)),a}function cn(e){switch(e){case "separator":return "separator";case "continuationSeparator":return "continuationSeparator";case "continuationNotice":return "continuationNotice";default:return "normal"}}function fo(e,t,n,r,o,i){let s=h(e,"w","id")??0,a=l(e,"w","type"),c=cn(a),p=A(e,"w","p").map(d=>Q(d,t,n,r,o));return {type:"footnote",id:s,noteType:c,content:p}}function un(e,t=null,n=null,r=null,o=null,i=null){let s=new Map,a=[];if(!e)return ve(s,a);let c=J(e);if(!c)return ve(s,a);let f=c.elements?.find(d=>d.type==="element"&&(d.name==="w:footnotes"||d.name?.endsWith(":footnotes")));if(!f)return ve(s,a);let p=A(f,"w","footnote");for(let d of p){let w=fo(d,t,n,r,o);s.set(w.id,w),a.push(w);}return ve(s,a)}function ve(e,t){return {byId:e,footnotes:t,getFootnote(n){return e.get(n)},hasFootnote(n){return e.has(n)},getNormalFootnotes(){return t.filter(n=>n.noteType==="normal")},getSeparator(){return t.find(n=>n.noteType==="separator")},getContinuationSeparator(){return t.find(n=>n.noteType==="continuationSeparator")}}}function po(e,t,n,r,o,i){let s=h(e,"w","id")??0,a=l(e,"w","type"),c=cn(a),p=A(e,"w","p").map(d=>Q(d,t,n,r,o));return {type:"endnote",id:s,noteType:c,content:p}}function fn(e,t=null,n=null,r=null,o=null,i=null){let s=new Map,a=[];if(!e)return ke(s,a);let c=J(e);if(!c)return ke(s,a);let f=c.elements?.find(d=>d.type==="element"&&(d.name==="w:endnotes"||d.name?.endsWith(":endnotes")));if(!f)return ke(s,a);let p=A(f,"w","endnote");for(let d of p){let w=po(d,t,n,r,o);s.set(w.id,w),a.push(w);}return ke(s,a)}function ke(e,t){return {byId:e,endnotes:t,getEndnote(n){return e.get(n)},hasEndnote(n){return e.has(n)},getNormalEndnotes(){return t.filter(n=>n.noteType==="normal")},getSeparator(){return t.find(n=>n.noteType==="separator")},getContinuationSeparator(){return t.find(n=>n.noteType==="continuationSeparator")}}}function pn(e){return e?{decimal:"decimal",upperRoman:"upperRoman",lowerRoman:"lowerRoman",upperLetter:"upperLetter",lowerLetter:"lowerLetter",ordinal:"ordinal",cardinalText:"cardinalText",ordinalText:"ordinalText",bullet:"bullet",chicago:"chicago",none:"none"}[e]:void 0}function mo(e){switch(e){case "pageBottom":return "pageBottom";case "beneathText":return "beneathText";case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function go(e){switch(e){case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function dn(e){switch(e){case "continuous":return "continuous";case "eachSect":return "eachSect";case "eachPage":return "eachPage";default:return}}function mn(e){let t={};if(!e)return t;let n=u(e,"w","pos");if(n){let s=l(n,"w","val");t.position=mo(s);}let r=u(e,"w","numFmt");if(r){let s=l(r,"w","val");t.numFmt=pn(s);}let o=u(e,"w","numStart");o&&(t.numStart=h(o,"w","val")??void 0);let i=u(e,"w","numRestart");if(i){let s=l(i,"w","val");t.numRestart=dn(s);}return t}function gn(e){let t={};if(!e)return t;let n=u(e,"w","pos");if(n){let s=l(n,"w","val");t.position=go(s);}let r=u(e,"w","numFmt");if(r){let s=l(r,"w","val");t.numFmt=pn(s);}let o=u(e,"w","numStart");o&&(t.numStart=h(o,"w","val")??void 0);let i=u(e,"w","numRestart");if(i){let s=l(i,"w","val");t.numRestart=dn(s);}return t}function ho(e,t,n,r){if(!e&&!t)return;let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),Object.keys(o).length>0?o:void 0}function Pe(e){if(!e)return;let r={style:l(e,"w","val")??"none"},o=h(e,"w","sz");o!==void 0&&(r.size=o);let i=h(e,"w","space");i!==void 0&&(r.space=i);let s=l(e,"w","color"),a=l(e,"w","themeColor"),c=l(e,"w","themeTint"),f=l(e,"w","themeShade"),p=ho(s,a,c,f);p&&(r.color=p);let d=l(e,"w","shadow");(d==="1"||d==="true")&&(r.shadow=true);let w=l(e,"w","frame");return (w==="1"||w==="true")&&(r.frame=true),r}function wo(e){switch(e){case "landscape":return "landscape";case "portrait":return "portrait";default:return}}function yo(e){switch(e){case "continuous":return "continuous";case "nextPage":return "nextPage";case "oddPage":return "oddPage";case "evenPage":return "evenPage";case "nextColumn":return "nextColumn";default:return}}function xo(e){switch(e){case "top":return "top";case "center":return "center";case "both":return "both";case "bottom":return "bottom";default:return}}function bo(e){switch(e){case "continuous":return "continuous";case "newPage":return "newPage";case "newSection":return "newSection";default:return}}function Re(e,t){let n={};if(!e)return n;let r=u(e,"w","pgSz");if(r){let y=h(r,"w","w");y!==void 0&&(n.pageWidth=y);let C=h(r,"w","h");C!==void 0&&(n.pageHeight=C);let x=l(r,"w","orient"),S=wo(x);S&&(n.orientation=S);}let o=u(e,"w","pgMar");if(o){let y=h(o,"w","top");y!==void 0&&(n.marginTop=y);let C=h(o,"w","bottom");C!==void 0&&(n.marginBottom=C);let x=h(o,"w","left");x!==void 0&&(n.marginLeft=x);let S=h(o,"w","right");S!==void 0&&(n.marginRight=S);let k=h(o,"w","header");k!==void 0&&(n.headerDistance=k);let E=h(o,"w","footer");E!==void 0&&(n.footerDistance=E);let I=h(o,"w","gutter");I!==void 0&&(n.gutter=I);}let i=u(e,"w","cols");if(i){let y=h(i,"w","num");y!==void 0&&(n.columnCount=y);let C=h(i,"w","space");C!==void 0&&(n.columnSpace=C);let x=l(i,"w","equalWidth");x==="1"||x==="true"?n.equalWidth=true:(x==="0"||x==="false")&&(n.equalWidth=false);let S=l(i,"w","sep");(S==="1"||S==="true")&&(n.separator=true);let k=A(i,"w","col");if(k.length>0){n.columns=[];for(let E of k){let I={},B=h(E,"w","w");B!==void 0&&(I.width=B);let H=h(E,"w","space");H!==void 0&&(I.space=H),n.columns.push(I);}}}let s=u(e,"w","type");if(s){let y=l(s,"w","val"),C=yo(y);C&&(n.sectionStart=C);}let a=u(e,"w","vAlign");if(a){let y=l(a,"w","val"),C=xo(y);C&&(n.verticalAlign=C);}let c=u(e,"w","bidi");c&&(n.bidi=T(c));let f=A(e,"w","headerReference");f.length>0&&(n.headerReferences=f.map(y=>on(y)));let p=A(e,"w","footerReference");p.length>0&&(n.footerReferences=p.map(y=>sn(y)));let d=u(e,"w","titlePg");d&&(n.titlePg=T(d));let w=u(e,"w","evenAndOddHeaders");w&&(n.evenAndOddHeaders=T(w));let g=u(e,"w","lnNumType");if(g){n.lineNumbers={};let y=h(g,"w","start");y!==void 0&&(n.lineNumbers.start=y);let C=h(g,"w","countBy");C!==void 0&&(n.lineNumbers.countBy=C);let x=h(g,"w","distance");x!==void 0&&(n.lineNumbers.distance=x);let S=l(g,"w","restart"),k=bo(S);k&&(n.lineNumbers.restart=k);}let m=u(e,"w","pgBorders");if(m){n.pageBorders={};let y=Pe(u(m,"w","top"));y&&(n.pageBorders.top=y);let C=Pe(u(m,"w","bottom"));C&&(n.pageBorders.bottom=C);let x=Pe(u(m,"w","left"));x&&(n.pageBorders.left=x);let S=Pe(u(m,"w","right"));S&&(n.pageBorders.right=S);let k=l(m,"w","display");(k==="allPages"||k==="firstPage"||k==="notFirstPage")&&(n.pageBorders.display=k);let E=l(m,"w","offsetFrom");(E==="page"||E==="text")&&(n.pageBorders.offsetFrom=E);let I=l(m,"w","zOrder");(I==="front"||I==="back")&&(n.pageBorders.zOrder=I);}let b=u(e,"w","background");if(b){n.background={};let y=l(b,"w","color");y&&y!=="auto"&&(n.background.color={rgb:y});let C=l(b,"w","themeColor");C&&(n.background.themeColor=C);let x=l(b,"w","themeTint");x&&(n.background.themeTint=x);let S=l(b,"w","themeShade");S&&(n.background.themeShade=S);}let D=u(e,"w","footnotePr");if(D){let y=mn(D);Object.keys(y).length>0&&(n.footnotePr=y);}let P=u(e,"w","endnotePr");if(P){let y=gn(P);Object.keys(y).length>0&&(n.endnotePr=y);}let M=u(e,"w","docGrid");if(M){n.docGrid={};let y=l(M,"w","type");(y==="default"||y==="lines"||y==="linesAndChars"||y==="snapToChars")&&(n.docGrid.type=y);let C=h(M,"w","linePitch");C!==void 0&&(n.docGrid.linePitch=C);let x=h(M,"w","charSpace");x!==void 0&&(n.docGrid.charSpace=x);}let R=u(e,"w","paperSrc");if(R){let y=h(R,"w","first");y!==void 0&&(n.paperSrcFirst=y);let C=h(R,"w","other");C!==void 0&&(n.paperSrcOther=C);}return n}function hn(){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 To(e,t){return !e&&!t?true:!(!e||!t||e.bold!==t.bold||e.boldCs!==t.boldCs||e.italic!==t.italic||e.italicCs!==t.italicCs||e.strike!==t.strike||e.doubleStrike!==t.doubleStrike||e.smallCaps!==t.smallCaps||e.allCaps!==t.allCaps||e.hidden!==t.hidden||e.emboss!==t.emboss||e.imprint!==t.imprint||e.outline!==t.outline||e.shadow!==t.shadow||e.rtl!==t.rtl||e.cs!==t.cs||e.fontSize!==t.fontSize||e.fontSizeCs!==t.fontSizeCs||e.spacing!==t.spacing||e.position!==t.position||e.scale!==t.scale||e.kerning!==t.kerning||e.vertAlign!==t.vertAlign||e.highlight!==t.highlight||e.effect!==t.effect||e.emphasisMark!==t.emphasisMark||e.styleId!==t.styleId||!Co(e.underline,t.underline)||!Me(e.color,t.color)||!Fo(e.shading,t.shading)||!So(e.fontFamily,t.fontFamily))}function Co(e,t){return !e&&!t?true:!e||!t||e.style!==t.style?false:Me(e.color,t.color)}function Me(e,t){return !e&&!t?true:!e||!t?false:e.rgb===t.rgb&&e.auto===t.auto&&e.themeColor===t.themeColor&&e.themeTint===t.themeTint&&e.themeShade===t.themeShade}function Fo(e,t){return !e&&!t?true:!(!e||!t||e.pattern!==t.pattern||!Me(e.color,t.color)||!Me(e.fill,t.fill))}function So(e,t){return !e&&!t?true:!e||!t?false:e.ascii===t.ascii&&e.hAnsi===t.hAnsi&&e.eastAsia===t.eastAsia&&e.cs===t.cs&&e.asciiTheme===t.asciiTheme&&e.hAnsiTheme===t.hAnsiTheme&&e.eastAsiaTheme===t.eastAsiaTheme&&e.csTheme===t.csTheme}function vo(e){return e.type==="text"||e.type==="softHyphen"||e.type==="noBreakHyphen"}function wn(e){return e.content.length===0?true:e.content.every(vo)}function ko(e,t){let n=[];for(let r of e)n.push(r);if(n.length>0&&t.length>0&&n[n.length-1].type==="text"&&t[0].type==="text"){let r=n[n.length-1],o=t[0];n[n.length-1]={type:"text",text:r.text+o.text,preserveSpace:r.preserveSpace||o.preserveSpace||void 0};for(let i=1;i<t.length;i++)n.push(t[i]);}else for(let r of t)n.push(r);return n}function Po(e){if(e.length<=1)return e;let t=[],n=null;for(let r of e)if(r.content.length!==0){if(n===null){n={...r,content:[...r.content]};continue}wn(n)&&wn(r)&&To(n.formatting,r.formatting)?n={type:"run",formatting:n.formatting,content:ko(n.content,r.content)}:(t.push(n),n={...r,content:[...r.content]});}return n!==null&&t.push(n),t}function Ke(e){if(e.length<=1)return e;let t=[],n=[];function r(){if(n.length>0){let o=Po(n);t.push(...o),n.length=0;}}for(let o of e)if(o.type==="run")n.push(o);else if(r(),o.type==="hyperlink"){let i={...o,children:Ke(o.children)};t.push(i);}else t.push(o);return r(),t}function Ro(e,t,n,r){let o={};return e&&e!=="auto"?o.rgb=e:e==="auto"&&(o.auto=true),t&&(o.themeColor=t),n&&(o.themeTint=n),r&&(o.themeShade=r),o}function Mo(e){if(!e)return;let t={},n=l(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let r=l(e,"w","fill");r&&r!=="auto"&&(t.fill={rgb:r});let o=l(e,"w","themeFill");o&&(t.fill=t.fill||{},t.fill.themeColor=o);let i=l(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let s=l(e,"w","themeFillShade");s&&t.fill&&(t.fill.themeShade=s);let a=l(e,"w","val");return a&&(t.pattern=a),Object.keys(t).length>0?t:void 0}function le(e){if(!e)return;let t=l(e,"w","val");if(!t)return;let n={style:t},r=l(e,"w","color"),o=l(e,"w","themeColor");(r||o)&&(n.color=Ro(r,o,l(e,"w","themeTint"),l(e,"w","themeShade")));let i=h(e,"w","sz");i!==void 0&&(n.size=i);let s=h(e,"w","space");s!==void 0&&(n.space=s);let a=l(e,"w","shadow");a&&(n.shadow=a==="1"||a==="true");let c=l(e,"w","frame");return c&&(n.frame=c==="1"||c==="true"),n}function Eo(e){if(!e)return;let t=A(e,"w","tab");if(t.length===0)return;let n=[];for(let r of t){let o=h(r,"w","pos"),i=l(r,"w","val");if(o!==void 0&&i){let s={position:o,alignment:i},a=l(r,"w","leader");a&&(s.leader=a),n.push(s);}}return n.length>0?n:void 0}function Io(e){if(!e)return;let t={},n=h(e,"w","w");n!==void 0&&(t.width=n);let r=h(e,"w","h");r!==void 0&&(t.height=r);let o=l(e,"w","hAnchor");(o==="text"||o==="margin"||o==="page")&&(t.hAnchor=o);let i=l(e,"w","vAnchor");(i==="text"||i==="margin"||i==="page")&&(t.vAnchor=i);let s=h(e,"w","x");s!==void 0&&(t.x=s);let a=h(e,"w","y");a!==void 0&&(t.y=a);let c=l(e,"w","xAlign");c&&(t.xAlign=c);let f=l(e,"w","yAlign");f&&(t.yAlign=f);let p=l(e,"w","wrap");return p&&(t.wrap=p),Object.keys(t).length>0?t:void 0}function Do(e,t,n){if(!e)return;let r={},o=u(e,"w","jc");if(o){let x=l(o,"w","val");x&&(r.alignment=x);}let i=u(e,"w","bidi");i&&(r.bidi=T(i));let s=u(e,"w","spacing");if(s){let x=h(s,"w","before");x!==void 0&&(r.spaceBefore=x);let S=h(s,"w","after");S!==void 0&&(r.spaceAfter=S);let k=h(s,"w","line");k!==void 0&&(r.lineSpacing=k);let E=l(s,"w","lineRule");E&&(r.lineSpacingRule=E);let I=l(s,"w","beforeAutospacing");I&&(r.beforeAutospacing=I==="1"||I==="true");let B=l(s,"w","afterAutospacing");B&&(r.afterAutospacing=B==="1"||B==="true");}let a=u(e,"w","ind");if(a){let x=h(a,"w","left");x!==void 0&&(r.indentLeft=x);let S=h(a,"w","right");S!==void 0&&(r.indentRight=S);let k=h(a,"w","firstLine");k!==void 0&&(r.indentFirstLine=k);let E=h(a,"w","hanging");E!==void 0&&(r.indentFirstLine=-E,r.hangingIndent=true);let I=h(a,"w","start");I!==void 0&&r.indentLeft===void 0&&(r.indentLeft=I);let B=h(a,"w","end");B!==void 0&&r.indentRight===void 0&&(r.indentRight=B);}let c=u(e,"w","pBdr");if(c){let x={},S=le(u(c,"w","top"));S&&(x.top=S);let k=le(u(c,"w","bottom"));k&&(x.bottom=k);let E=le(u(c,"w","left"));E&&(x.left=E);let I=le(u(c,"w","right"));I&&(x.right=I);let B=le(u(c,"w","between"));B&&(x.between=B);let H=le(u(c,"w","bar"));H&&(x.bar=H),Object.keys(x).length>0&&(r.borders=x);}let f=u(e,"w","shd");f&&(r.shading=Mo(f));let p=u(e,"w","tabs");p&&(r.tabs=Eo(p));let d=u(e,"w","keepNext");d&&(r.keepNext=T(d));let w=u(e,"w","keepLines");w&&(r.keepLines=T(w));let g=u(e,"w","widowControl");g&&(r.widowControl=T(g));let m=u(e,"w","pageBreakBefore");m&&(r.pageBreakBefore=T(m));let b=u(e,"w","numPr");if(b){let x=u(b,"w","numId"),S=u(b,"w","ilvl");if(x||S){if(r.numPr={},x){let k=h(x,"w","val");k!==void 0&&(r.numPr.numId=k);}if(S){let k=h(S,"w","val");k!==void 0&&(r.numPr.ilvl=k);}}}let D=u(e,"w","outlineLvl");if(D){let x=h(D,"w","val");x!==void 0&&(r.outlineLevel=x);}let P=u(e,"w","pStyle");if(P){let x=l(P,"w","val");x&&(r.styleId=x);}let M=u(e,"w","framePr");M&&(r.frame=Io(M));let R=u(e,"w","suppressLineNumbers");R&&(r.suppressLineNumbers=T(R));let y=u(e,"w","suppressAutoHyphens");y&&(r.suppressAutoHyphens=T(y));let C=u(e,"w","rPr");return C&&(r.runProperties=Ze(C,t)),Object.keys(r).length>0?r:void 0}function yn(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Ao(e,t,n,r,o){return Yt(e,t,n,r,o)}function Bo(e){return Kt(e)}function $o(e){return Qt(e)}function xn(e){let t=e.trim().match(/^\\?([A-Z]+)/i);if(!t)return "UNKNOWN";let n=t[1].toUpperCase();return ["PAGE","NUMPAGES","NUMWORDS","NUMCHARS","DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","DOCPROPERTY","DOCVARIABLE","REF","PAGEREF","NOTEREF","HYPERLINK","TOC","TOA","INDEX","SEQ","STYLEREF","AUTONUM","AUTONUMLGL","AUTONUMOUT","IF","MERGEFIELD","NEXT","NEXTIF","ASK","SET","QUOTE","INCLUDETEXT","INCLUDEPICTURE","SYMBOL","ADVANCE","EDITTIME","REVNUM","SECTION","SECTIONPAGES","USERADDRESS","USERNAME","USERINITIALS"].includes(n)?n:"UNKNOWN"}function Lo(e,t,n,r,o){let i=l(e,"w","instr")??"",s=xn(i),a={type:"simpleField",instruction:i,fieldType:s,content:[]},c=l(e,"w","fldLock");(c==="1"||c==="true")&&(a.fldLock=true);let f=l(e,"w","dirty");(f==="1"||f==="true")&&(a.dirty=true);let p=X(e);for(let d of p)yn(d.name)==="r"&&a.content.push(me(d,t,n,r,o));return a}function bn(e,t,n,r,o,i){let s=[],a=X(e),c=false,f="",p=[],d=[],w=false,g=false,m=false;for(let b of a)switch(yn(b.name)){case "r":{let P=me(b,t,n,o,i),M=false,R=false,y=false,C="";for(let x of P.content)x.type==="fieldChar"?x.charType==="begin"?(M=true,x.fldLock&&(g=true),x.dirty&&(m=true)):x.charType==="separate"?R=true:x.charType==="end"&&(y=true):x.type==="instrText"&&(C+=x.text);if(M&&(c=true,w=false,f="",p=[],d=[],g=false,m=false),c){if(C&&(f+=C),R&&(w=true),w&&!y?R||d.push(P):!w&&!M&&p.push(P),y){let x={type:"complexField",instruction:f.trim(),fieldType:xn(f),fieldCode:p,fieldResult:d};g&&(x.fldLock=true),m&&(x.dirty=true),s.push(x),c=false;}}else s.push(P);break}case "hyperlink":s.push(Ao(b,o,t,n,i));break;case "bookmarkStart":s.push(Bo(b));break;case "bookmarkEnd":s.push($o(b));break;case "fldSimple":s.push(Lo(b,t,n,o,i));break;case "pPr":break;case "proofErr":case "permStart":case "permEnd":case "customXml":break;case "sdt":{let P=(b.elements??[]).find(M=>M.type==="element"&&(M.name==="w:sdtContent"||M.name?.endsWith(":sdtContent")));if(P){let M=bn(P,t,n,null,o,i);s.push(...M);}break}}return s}function Q(e,t,n,r,o=null,i=null){let s={type:"paragraph",content:[]},a=l(e,"w14","paraId")??l(e,"w","paraId");a&&(s.paraId=a);let c=l(e,"w14","textId")??l(e,"w","textId");c&&(s.textId=c);let f=u(e,"w","pPr");if(f){s.formatting=Do(f,n);let d=u(f,"w","sectPr");d&&(s.sectionProperties=Re(d));}let p=bn(e,t,n,r,o,i);if(s.content=Ke(p),s.formatting?.numPr&&r){let{numId:d,ilvl:w=0}=s.formatting.numPr;if(d!==void 0&&d!==0){let g=r.getLevel(d,w);g&&(s.listRendering={level:w,numId:d,marker:g.lvlText,isBullet:g.numFmt==="bullet",numFmt:g.numFmt},g.pPr&&(s.formatting||(s.formatting={}),g.pPr.indentLeft!==void 0&&(s.formatting.indentLeft=g.pPr.indentLeft),g.pPr.indentFirstLine!==void 0&&(s.formatting.indentFirstLine=g.pPr.indentFirstLine),g.pPr.hangingIndent!==void 0&&(s.formatting.hangingIndent=g.pPr.hangingIndent)));}}return s}function Qe(e){let t="";for(let n of e.content)if(n.type==="run")for(let r of n.content)r.type==="text"?t+=r.text:r.type==="tab"?t+=" ":r.type==="break"&&(r.breakType==="page"?t+="\f":t+=`
|
|
3
|
+
`);else if(n.type==="hyperlink"){for(let r of n.children)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}else if(n.type==="simpleField"){for(let r of n.content)if(r.type==="run")for(let o of r.content)o.type==="text"&&(t+=o.text);}else if(n.type==="complexField")for(let r of n.fieldResult)for(let o of r.content)o.type==="text"&&(t+=o.text);return t}function No(e){if(!e||e.trim()==="")return "\u2022";let t=e.charCodeAt(0),n={183:"\u2022",111:"\u25CB",167:"\u25A0",252:"\u2713",110:"\u25A0",113:"\u25CB",117:"\u25C6",118:"\u2756",168:"\u2713",251:"\u2713",254:"\u2713",61623:"\u2022",61550:"\u25A0",61551:"\u25CB",61607:"\u25A0",61692:"\u2713",8226:"\u2022",9679:"\u25CF",9675:"\u25CB",9632:"\u25A0",9633:"\u25A1",9670:"\u25C6",9671:"\u25C7",8211:"\u2013",8212:"\u2014",62:">",45:"-"};return n[t]?n[t]:t>=57344&&t<=63743||t<32||t>=127&&t<160?"\u2022":e}function Xo(e,t,n){let r=e.listRendering;if(!r||!t)return;let{numId:o,level:i}=r;if(o===void 0||o===0)return;n.has(o)||n.set(o,new Array(9).fill(0));let s=n.get(o);s[i]=(s[i]||0)+1;for(let f=i+1;f<s.length;f++)s[f]=0;let a=r.marker;if(r.isBullet){let f=a||"";r.marker=No(f);return}let c=a;for(let f=0;f<=i;f++){let p=`%${f+1}`;if(c.includes(p)){let d=s[f],w=t.getLevel(o,f),g=Ho(d,w?.numFmt||"decimal");c=c.replace(p,g);}}r.marker=c;}function Ho(e,t){switch(t){case "decimal":case "decimalZero":return String(e);case "lowerLetter":return String.fromCharCode(96+(e-1)%26+1);case "upperLetter":return String.fromCharCode(64+(e-1)%26+1);case "lowerRoman":return Tn(e).toLowerCase();case "upperRoman":return Tn(e);case "bullet":return "\u2022";default:return String(e)}}function Tn(e){let t=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],n="";for(let[r,o]of t)for(;e>=r;)n+=o,e-=r;return n}var Cn=/\{\{([^{}]+)\}\}/g;function Fn(e){let t=[],n;for(Cn.lastIndex=0;(n=Cn.exec(e))!==null;){let r=n[1].trim();r&&!t.includes(r)&&t.push(r);}return t}function Sn(e){let t=[];for(let n of e)if(n.type==="paragraph"){let r=Qe(n),o=Fn(r);for(let i of o)t.includes(i)||t.push(i);}else if(n.type==="table"){let r=vn(n);for(let o of r)t.includes(o)||t.push(o);}return t}function vn(e){let t=[];for(let n of e.rows)for(let r of n.cells)for(let o of r.content)if(o.type==="paragraph"){let i=Qe(o),s=Fn(i);for(let a of s)t.includes(a)||t.push(a);}else if(o.type==="table"){let i=vn(o);for(let s of i)t.includes(s)||t.push(s);}return t}function kn(e,t,n,r,o,i){let s=[],a=X(e),c=new Map;for(let f of a){let p=f.name??"";if(p==="w:p"||p.endsWith(":p")){let d=Q(f,t,n,r,o,i);Xo(d,r,c),s.push(d);}else if(p==="w:tbl"||p.endsWith(":tbl")){let d=ge(f,t,n,r,o,i);s.push(d);}else if(p==="w:sdt"||p.endsWith(":sdt")){let d=(f.elements??[]).find(w=>w.type==="element"&&(w.name==="w:sdtContent"||w.name?.endsWith(":sdtContent")));if(d){let w=kn(d,t,n,r,o,i);s.push(...w);}}}return s}function Oo(e,t){let n=[],r=[];for(let o of e)r.push(o),o.type==="paragraph"&&o.sectionProperties&&(n.push({properties:o.sectionProperties,content:r}),r=[]);return (r.length>0||n.length===0)&&n.push({properties:t??hn(),content:r}),n}function Pn(e,t=null,n=null,r=null,o=null,i=null){let s={content:[]};if(!e)return s;let a=J(e);if(!a)return s;let c=(a.elements??[]).find(d=>d.type==="element"&&(d.name==="w:document"||d.name?.endsWith(":document")));if(!c)return s;let f=u(c,"w","body");if(!f)return s;s.content=kn(f,t,n,r,o,i);let p=u(f,"w","sectPr");return p&&(s.finalSectionProperties=Re(p)),s.sections=Oo(s.content,s.finalSectionProperties),s}var Ie=new Set,Ee=new Map,jo=new Set;function Mn(e,t=[400,700],n=["normal","italic"]){let r=encodeURIComponent(e),o=[];for(let s of n){let a=s==="italic"?1:0;for(let c of t)o.push(`${a},${c}`);}o.sort();let i=o.join(";");return `https://fonts.googleapis.com/css2?family=${r}:ital,wght@${i}&display=swap`}async function zo(e,t){let n=e.trim();if(Ie.has(n))return true;let r=Ee.get(n);if(r)return r;let o=(async()=>{try{let i=Mn(n,t?.weights,t?.styles),s=document.createElement("link");return s.rel="stylesheet",s.href=i,await new Promise(c=>{s.onload=()=>c(!0),s.onerror=()=>c(!1),document.head.appendChild(s),setTimeout(()=>c(!1),5e3);})?(await _o(n,3e3),Ie.add(n),Vo([n]),!0):!1}catch(i){return console.warn(`Failed to load font "${n}":`,i),false}finally{Ee.delete(n),Ee.size===0&&(false);}})();return Ee.set(n,o),o}function Vo(e){for(let t of jo)try{t(e);}catch(n){console.warn("Font load callback error:",n);}}async function _o(e,t){if("fonts"in document)try{let n=`400 16px "${e}"`;return await Promise.race([document.fonts.load(n),new Promise(r=>setTimeout(r,t))]),document.fonts.check(n)}catch{}return await new Promise(n=>setTimeout(n,100)),true}var Wo={Calibri:"Carlito",Cambria:"Caladea",Arial:"Arimo","Times New Roman":"Tinos","Courier New":"Cousine",Garamond:"EB Garamond","Book Antiqua":"EB Garamond",Georgia:"Tinos",Verdana:"Open Sans",Tahoma:"Open Sans","Trebuchet MS":"Source Sans Pro","Century Gothic":"Poppins","Franklin Gothic":"Libre Franklin",Palatino:"EB Garamond","Palatino Linotype":"EB Garamond","Lucida Sans":"Open Sans","Segoe UI":"Open Sans",Impact:"Anton","Comic Sans MS":"Comic Neue",Consolas:"Inconsolata","Lucida Console":"Inconsolata",Monaco:"Fira Code"};function Uo(e){let t=e.trim();return Wo[t]||t}async function qo(e){let t=e.trim(),n=Uo(t);return n!==t?(await Go(t,n),Ie.add(t),Ie.add(n),true):zo(n)}async function Go(e,t){let n=`font-alias-${e.toLowerCase().replace(/\s+/g,"-")}`;if(!document.getElementById(n))try{let r=Mn(t,[400,700],["normal","italic"]),o=await fetch(r);if(!o.ok){console.warn(`Failed to fetch Google Fonts CSS for "${t}": ${o.status}`);return}let i=await o.text(),s=new RegExp(`font-family:\\s*['"]${Jo(t)}['"]`,"gi"),a=i.replace(s,`font-family: '${e}'`),c=document.createElement("style");c.id=n,c.textContent=a,document.head.appendChild(c);}catch(r){console.warn(`Failed to create font alias for "${e}":`,r);}}function Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function En(e){let t=[...new Set(e.map(n=>n.trim()))];await Promise.all(t.map(n=>qo(n)));}async function Ae(e,t={}){let{onProgress:n=()=>{},preloadFonts:r=true,parseHeadersFooters:o=true,parseNotes:i=true,detectVariables:s=true}=t,a=[];try{let d=function(L,O){let q=performance.now(),G=O(),F=performance.now()-q;return p.push({stage:L,ms:F}),F>1e3&&console.warn(`[parseDocx] ${L} took ${Math.round(F)}ms`),G};var c=d;let f=performance.now(),p=[];async function w(L,O){let q=performance.now(),G=await O(),F=performance.now()-q;return p.push({stage:L,ms:F}),F>1e3&&console.warn(`[parseDocx] ${L} took ${Math.round(F)}ms`),G}n("Extracting DOCX...",0);let g=await w("unzip",()=>Ft(e));n("Extracted DOCX",10),n("Parsing relationships...",10);let m=d("relationships",()=>g.documentRels?Te(g.documentRels):new Map);n("Parsed relationships",15),n("Parsing theme...",15);let b=d("theme",()=>Et(g.themeXml));n("Parsed theme",20),n("Parsing styles...",20);let D=null,P;d("styles",()=>{g.stylesXml&&(D=Ge(g.stylesXml,b),P=Xt(g.stylesXml,b));}),n("Parsed styles",30),n("Parsing numbering...",30);let M=d("numbering",()=>Ht(g.numberingXml));n("Parsed numbering",35),n("Processing media files...",35);let R=d("media",()=>Zo(g,m));n("Processed media",40),n("Parsing document body...",40);let y={content:[]};d("documentBody",()=>{g.documentXml?y=Pn(g.documentXml,D,b,M,m,R):a.push("No document.xml found in DOCX");}),n("Parsed document body",55);let C,x;if(o){n("Parsing headers/footers...",55);let L=d("headersFooters",()=>Yo(g,D,b,M,m,R));C=L.headers,x=L.footers,n("Parsed headers/footers",65);}else n("Skipping headers/footers",65);let S,k;if(i){n("Parsing footnotes/endnotes...",65);let L=d("footnotesEndnotes",()=>Ko(g,D,b,M,m,R));S=L.footnotes,k=L.endnotes,n("Parsed footnotes/endnotes",75);}else n("Skipping footnotes/endnotes",75);let E;s?(n("Detecting template variables...",75),E=d("variables",()=>Sn(y.content)),n("Detected variables",80)):n("Skipping variable detection",80),r?(n("Loading fonts...",80),await w("fonts",()=>Qo(b,P,y)),n("Loaded fonts",95)):n("Skipping font loading",95),n("Assembling document...",95);let B={package:{document:y,styles:P,theme:b,numbering:M.definitions,headers:C,footers:x,footnotes:S,endnotes:k,relationships:m,media:R},originalBuffer:e,templateVariables:E,warnings:a.length>0?a:void 0},H=performance.now()-f;if(H>2e3){let L=p.filter(O=>O.ms>100).map(O=>`${O.stage}: ${Math.round(O.ms)}ms`).join(", ");console.warn(`[parseDocx] Total: ${Math.round(H)}ms`+(L?` (${L})`:""));}return n("Complete",100),B}catch(f){let p=f instanceof Error?f.message:String(f);throw console.error("[parseDocx] Failed to parse DOCX:",p,f),new Error(`Failed to parse DOCX: ${p}`)}}function Zo(e,t){let n=new Map;for(let[r,o]of e.media.entries()){let i=r.split("/").pop()||r,s=St(r),a=new Uint8Array(o),c="";for(let g=0;g<a.length;g++)c+=String.fromCharCode(a[g]);let f=btoa(c),p=`data:${s};base64,${f}`,d={path:r,filename:i,mimeType:s,data:o,dataUrl:p};n.set(r,d);let w=r.replace(/^word\//,"");w!==r&&n.set(w,d);}return n}function De(e,t){let n=t.toLowerCase();for(let[r,o]of e.entries())if(r.toLowerCase()===n)return o}function Yo(e,t,n,r,o,i){let s=new Map,a=new Map;for(let[c,f]of o.entries())if(f.type===be.header&&f.target){let p=f.target.split("/").pop()||f.target,d=De(e.headers,p);if(d){let w=`word/_rels/${p}.rels`,g=De(e.allXml,w),m=g?Te(g):o,b=an(d,"default",t,n,r,m,i);s.set(c,b);}}else if(f.type===be.footer&&f.target){let p=f.target.split("/").pop()||f.target,d=De(e.footers,p);if(d){let w=`word/_rels/${p}.rels`,g=De(e.allXml,w),m=g?Te(g):o,b=ln(d,"default",t,n,r,m,i);a.set(c,b);}}return {headers:s,footers:a}}function Ko(e,t,n,r,o,i){let s=un(e.footnotesXml,t,n,r,o,i),a=fn(e.endnotesXml,t,n,r,o,i);return {footnotes:s.getNormalFootnotes(),endnotes:a.getNormalEndnotes()}}async function Qo(e,t,n){let r=new Set;if(e?.fontScheme){let{majorFont:o,minorFont:i}=e.fontScheme;o?.latin&&r.add(o.latin),i?.latin&&r.add(i.latin);}if(t?.docDefaults?.rPr?.fontFamily?.ascii&&r.add(t.docDefaults.rPr.fontFamily.ascii),t?.styles)for(let o of t.styles)o.rPr?.fontFamily?.ascii&&r.add(o.rPr.fontFamily.ascii),o.rPr?.fontFamily?.hAnsi&&r.add(o.rPr.fontFamily.hAnsi);if(n.content){for(let o of n.content)if(o.type==="paragraph")for(let i of o.content)i.type==="run"&&i.formatting?.fontFamily&&(i.formatting.fontFamily.ascii&&r.add(i.formatting.fontFamily.ascii),i.formatting.fontFamily.hAnsi&&r.add(i.formatting.fontFamily.hAnsi));}if(r.size>0)try{await En(Array.from(r));}catch(o){console.warn("Failed to load some fonts:",o);}}var Le={type:"string",description:"Document ID from a previous docx_load call"},hi={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"]},Bn={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
|
|
4
4
|
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
5
5
|
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:Le},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,r=t.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let o=gt(r.document);return {content:[{type:"text",text:JSON.stringify({variables:o.variables,count:o.variables.length,totalOccurrences:o.totalOccurrences,byLocation:o.byLocation},null,2)}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${o.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},$n={name:"docx_insert_variable",description:`Insert a template variable placeholder ({{name}}) at a specific position in the document.
|
|
6
6
|
The variable can later be substituted with actual values using docx_apply_template.
|
|
@@ -9,7 +9,7 @@ Replaces all {variable} placeholders with the corresponding values provided.
|
|
|
9
9
|
Preserves all formatting (fonts, styles, colors, tables).
|
|
10
10
|
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:Le,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:n,variables:r,keepUnmatchedVariables:o=true}=e,i=t.session.documents.get(n);if(!i)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!i.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let s=bt(i.buffer,r,{nullGetter:o?"keep":"empty"}),a=await Ae(s.buffer);return i.document=a,i.buffer=s.buffer,i.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:s.replacedVariables,unreplacedVariables:s.unreplacedVariables,warnings:s.warnings})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${s.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},Nn={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
11
11
|
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
12
|
-
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:Le},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,r=t.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!r.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let o=Tt(r.buffer);return {content:[{type:"text",text:JSON.stringify({valid:o.valid,tags:o.tags,errors:o.errors.map(i=>({message:i.message,variable:i.variable,type:i.type}))},null,2)}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${o.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},tt=[Bn,$n,Ln,Nn];var Xn={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:ze,replaceWithTemplateVariable:Ve},mcpTools:tt,initialize:()=>{try{ut("docxtemplater"),ut("pizzip");}catch{console.warn("[docxtemplater-plugin] Warning: docxtemplater or pizzip not installed. Template features may not work. Install with: npm install docxtemplater pizzip");}}};we();function Y(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function wi(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 yi(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 nt(e){if(!e)return "";let t=[];if(e.styleId&&t.push(`<w:rStyle w:val="${Y(e.styleId)}"/>`),e.fontFamily){let o=[];e.fontFamily.ascii&&o.push(`w:ascii="${Y(e.fontFamily.ascii)}"`),e.fontFamily.hAnsi&&o.push(`w:hAnsi="${Y(e.fontFamily.hAnsi)}"`),e.fontFamily.eastAsia&&o.push(`w:eastAsia="${Y(e.fontFamily.eastAsia)}"`),e.fontFamily.cs&&o.push(`w:cs="${Y(e.fontFamily.cs)}"`),e.fontFamily.asciiTheme&&o.push(`w:asciiTheme="${e.fontFamily.asciiTheme}"`),e.fontFamily.hAnsiTheme&&o.push(`w:hAnsiTheme="${e.fontFamily.hAnsiTheme}"`),e.fontFamily.eastAsiaTheme&&o.push(`w:eastAsiaTheme="${e.fontFamily.eastAsiaTheme}"`),e.fontFamily.csTheme&&o.push(`w:csTheme="${e.fontFamily.csTheme}"`),o.length>0&&t.push(`<w:rFonts ${o.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=wi(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"&&t.push(`<w:highlight w:val="${e.highlight}"/>`),e.underline){let o=[`w:val="${e.underline.style}"`];e.underline.color&&(e.underline.color.rgb&&o.push(`w:color="${e.underline.color.rgb}"`),e.underline.color.themeColor&&o.push(`w:themeColor="${e.underline.color.themeColor}"`)),t.push(`<w:u ${o.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=yi(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 xi(e){return `<w:t${e.preserveSpace||e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${Y(e.text)}</w:t>`}function bi(e){return "<w:tab/>"}function Ti(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 Ci(e){return `<w:sym w:font="${Y(e.font)}" w:char="${Y(e.char)}"/>`}function Fi(e){return e.type==="footnoteRef"?`<w:footnoteReference w:id="${e.id}"/>`:`<w:endnoteReference w:id="${e.id}"/>`}function Si(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 vi(e){return `<w:instrText${e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${Y(e.text)}</w:instrText>`}function ki(e){return "<w:softHyphen/>"}function Pi(e){return "<w:noBreakHyphen/>"}function Ri(e){return e.image.rId?`<!-- Drawing with rId="${e.image.rId}" -->`:"<!-- Drawing placeholder -->"}function Mi(e){return `<!-- Shape: ${e.shape.shapeType||"unknown"} -->`}function Ei(e){switch(e.type){case "text":return xi(e);case "tab":return bi();case "break":return Ti(e);case "symbol":return Ci(e);case "footnoteRef":case "endnoteRef":return Fi(e);case "fieldChar":return Si(e);case "instrText":return vi(e);case "softHyphen":return ki();case "noBreakHyphen":return Pi();case "drawing":return Ri(e);case "shape":return Mi(e);default:return ""}}function ie(e){let t=[],n=nt(e.formatting);n&&t.push(n);for(let r of e.content){let o=Ei(r);o&&t.push(o);}return `<w:r>${t.join("")}</w:r>`}function te(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function se(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 Ii(e){if(!e)return "";let t=[];if(e.top){let n=se(e.top,"top");n&&t.push(n);}if(e.left){let n=se(e.left,"left");n&&t.push(n);}if(e.bottom){let n=se(e.bottom,"bottom");n&&t.push(n);}if(e.right){let n=se(e.right,"right");n&&t.push(n);}if(e.between){let n=se(e.between,"between");n&&t.push(n);}if(e.bar){let n=se(e.bar,"bar");n&&t.push(n);}return t.length===0?"":`<w:pBdr>${t.join("")}</w:pBdr>`}function Di(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 Ai(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 Bi(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 $i(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 Li(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 Ni(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 Xi(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:pStyle w:val="${te(e.styleId)}"/>`),e.keepNext&&t.push("<w:keepNext/>"),e.keepLines&&t.push("<w:keepLines/>"),e.pageBreakBefore&&t.push("<w:pageBreakBefore/>");let n=Ni(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=Li(e.numPr);r&&t.push(r);let o=Ii(e.borders);o&&t.push(o);let i=Di(e.shading);i&&t.push(i);let s=Ai(e.tabs);s&&t.push(s),e.suppressLineNumbers&&t.push("<w:suppressLineNumbers/>"),e.suppressAutoHyphens&&t.push("<w:suppressAutoHyphens/>");let a=Bi(e);a&&t.push(a);let l=$i(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 f=nt(e.runProperties);f&&t.push(f);}return t.length===0?"":`<w:pPr>${t.join("")}</w:pPr>`}function Hn(e){let t=[];e.rId&&t.push(`r:id="${e.rId}"`),e.anchor&&t.push(`w:anchor="${te(e.anchor)}"`),e.tooltip&&t.push(`w:tooltip="${te(e.tooltip)}"`),e.target&&t.push(`w:tgtFrame="${te(e.target)}"`),e.history===false&&t.push('w:history="0"'),e.docLocation&&t.push(`w:docLocation="${te(e.docLocation)}"`);let n=e.children.map(o=>o.type==="run"?ie(o):o.type==="bookmarkStart"?On(o):o.type==="bookmarkEnd"?jn(o):"").join("");return `<w:hyperlink${t.length>0?" "+t.join(" "):""}>${n}</w:hyperlink>`}function On(e){let t=[`w:id="${e.id}"`,`w:name="${te(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 jn(e){return `<w:bookmarkEnd w:id="${e.id}"/>`}function Hi(e){let t=[`w:instr="${te(e.instruction)}"`];e.fldLock&&t.push('w:fldLock="true"'),e.dirty&&t.push('w:dirty="true"');let n=e.content.map(r=>r.type==="run"?ie(r):r.type==="hyperlink"?Hn(r):"").join("");return `<w:fldSimple ${t.join(" ")}>${n}</w:fldSimple>`}function Oi(e){let t=[],n=['w:fldCharType="begin"'];if(e.fldLock&&n.push('w:fldLock="true"'),e.dirty&&n.push('w:dirty="true"'),t.push(`<w:r><w:fldChar ${n.join(" ")}/></w:r>`),e.fieldCode.length>0)t.push(...e.fieldCode.map(r=>ie(r)));else {let o=e.instruction.startsWith(" ")||e.instruction.endsWith(" ")||e.instruction.includes(" ")?' xml:space="preserve"':"";t.push(`<w:r><w:instrText${o}>${te(e.instruction)}</w:instrText></w:r>`);}return t.push('<w:r><w:fldChar w:fldCharType="separate"/></w:r>'),t.push(...e.fieldResult.map(r=>ie(r))),t.push('<w:r><w:fldChar w:fldCharType="end"/></w:r>'),t.join("")}function ji(e){switch(e.type){case "run":return ie(e);case "hyperlink":return Hn(e);case "bookmarkStart":return On(e);case "bookmarkEnd":return jn(e);case "simpleField":return Hi(e);case "complexField":return Oi(e);default:return ""}}function Ne(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(" "):"",o=Xi(e.formatting);o&&t.push(o);for(let i of e.content){let s=ji(i);s&&t.push(s);}return `<w:p${r}>${t.join("")}</w:p>`}function zi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ne(e,t){if(!e)return "";let n=[`w:w="${e.value}"`,`w:type="${e.type}"`];return `<w:${t} ${n.join(" ")}/>`}function ae(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 zn(e,t){if(!e)return "";let n=[];if(e.top){let r=ae(e.top,"top");r&&n.push(r);}if(e.left){let r=ae(e.left,"left");r&&n.push(r);}if(e.bottom){let r=ae(e.bottom,"bottom");r&&n.push(r);}if(e.right){let r=ae(e.right,"right");r&&n.push(r);}if(e.insideH){let r=ae(e.insideH,"insideH");r&&n.push(r);}if(e.insideV){let r=ae(e.insideV,"insideV");r&&n.push(r);}return n.length===0?"":`<w:${t}>${n.join("")}</w:${t}>`}function Vn(e,t){if(!e)return "";let n=[];return e.top&&n.push(ne(e.top,"top")),e.left&&n.push(ne(e.left,"left")),e.bottom&&n.push(ne(e.bottom,"bottom")),e.right&&n.push(ne(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 Vi(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 _i(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 Wi(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:tblStyle w:val="${zi(e.styleId)}"/>`);let n=_i(e.floating);n&&t.push(n),e.bidi&&t.push("<w:bidiVisual/>");let r=ne(e.width,"tblW");r&&t.push(r),e.justification&&t.push(`<w:jc w:val="${e.justification}"/>`);let o=ne(e.cellSpacing,"tblCellSpacing");o&&t.push(o);let i=ne(e.indent,"tblInd");i&&t.push(i);let s=zn(e.borders,"tblBorders");s&&t.push(s);let a=Vn(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 f=Vi(e.look);return f&&t.push(f),e.overlap&&t.push(`<w:tblOverlap w:val="${e.overlap}"/>`),t.length===0?"":`<w:tblPr>${t.join("")}</w:tblPr>`}function Ui(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 qi(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 Gi(e){if(!e)return "";let t=[],n=qi(e.conditionalFormat);n&&t.push(n);let r=ne(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 o=zn(e.borders,"tcBorders");o&&t.push(o);let i=_n(e.shading);i&&t.push(i),e.noWrap&&t.push("<w:noWrap/>");let s=Vn(e.margins,"tcMar");return s&&t.push(s),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 Ji(e){return !e||e.length===0?"":`<w:tblGrid>${e.map(n=>`<w:gridCol w:w="${n}"/>`).join("")}</w:tblGrid>`}function Zi(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(Ne(n)):n.type==="table"&&t.push(rt(n));return t.length===0&&t.push("<w:p/>"),t.join("")}function Yi(e){let t=[],n=Gi(e.formatting);return n&&t.push(n),t.push(Zi(e.content)),`<w:tc>${t.join("")}</w:tc>`}function Ki(e){let t=[],n=Ui(e.formatting);n&&t.push(n);for(let r of e.cells)t.push(Yi(r));return `<w:tr>${t.join("")}</w:tr>`}function rt(e){let t=[],n=Wi(e.formatting);n&&t.push(n);let r=Ji(e.columnWidths);r&&t.push(r);for(let o of e.rows)t.push(Ki(o));return `<w:tbl>${t.join("")}</w:tbl>`}var H={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 Qi(){let e={wpc:H.wpc,mc:H.mc,o:H.o,r:H.r,m:H.m,v:H.v,wp14:H.wp14,wp:H.wp,w10:H.w10,w:H.w,w14:H.w14,w15:H.w15,wpg:H.wpg,wps:H.wps};return Object.entries(e).map(([t,n])=>`xmlns:${t}="${n}"`).join(" ")}function Xe(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 es(e){return `<w:headerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function ts(e){return `<w:footerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function ns(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 rs(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 os(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 is(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 ss(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(o=>{let i=[];return o.width!==void 0&&i.push(`w:w="${o.width}"`),o.space!==void 0&&i.push(`w:space="${o.space}"`),`<w:col ${i.join(" ")}/>`}).join("")),t.length===0&&!n?"":`<w:cols${t.length>0?" "+t.join(" "):""}>${n}</w:cols>`}function as(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 ls(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 i=Xe(t.top,"top");i&&r.push(i);}if(t.left){let i=Xe(t.left,"left");i&&r.push(i);}if(t.bottom){let i=Xe(t.bottom,"bottom");i&&r.push(i);}if(t.right){let i=Xe(t.right,"right");i&&r.push(i);}return r.length===0?"":`<w:pgBorders${n.length>0?" "+n.join(" "):""}>${r.join("")}</w:pgBorders>`}function cs(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 us(e){if(!e)return "";let t=[];if(e.headerReferences)for(let p of e.headerReferences)t.push(es(p));if(e.footerReferences)for(let p of e.footerReferences)t.push(ts(p));let n=ns(e.footnotePr);n&&t.push(n);let r=rs(e.endnotePr);r&&t.push(r),e.sectionStart&&t.push(`<w:type w:val="${e.sectionStart}"/>`);let o=os(e);o&&t.push(o);let i=is(e);if(i&&t.push(i),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 s=ls(e);s&&t.push(s);let a=as(e);a&&t.push(a);let l=ss(e);l&&t.push(l);let f=cs(e);return f&&t.push(f),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 fs(e){return e.type==="paragraph"?Ne(e):e.type==="table"?rt(e):""}function ps(e){return e.map(t=>fs(t)).join("")}function ds(e){let t=[];return t.push(ps(e.content)),e.finalSectionProperties&&t.push(us(e.finalSectionProperties)),t.join("")}function Wn(e){let t=[];t.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');let n=Qi();return t.push(`<w:document ${n} mc:Ignorable="w14 w15 wp14">`),t.push("<w:body>"),t.push(ds(e.package.document)),t.push("</w:body>"),t.push("</w:document>"),t.join("")}async function it(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:o}=t,i=await ot.loadAsync(e.originalBuffer),s=new ot;for(let[f,p]of Object.entries(i.files)){if(p.dir){s.folder(f.replace(/\/$/,""));continue}let d=await p.async("arraybuffer");s.file(f,d,{compression:"DEFLATE",compressionOptions:{level:n}});}let a=Wn(e);if(s.file("word/document.xml",a,{compression:"DEFLATE",compressionOptions:{level:n}}),r){let f="docProps/core.xml",p=i.file(f);if(p){let d=await p.async("text"),w=ms(d,{updateModifiedDate:r,modifiedBy:o});s.file(f,w,{compression:"DEFLATE",compressionOptions:{level:n}});}}return await s.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:n}})}function ms(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>${Un(t.modifiedBy)}</cp:lastModifiedBy>`):n=n.replace("</cp:coreProperties>",`<cp:lastModifiedBy>${Un(t.modifiedBy)}</cp:lastModifiedBy></cp:coreProperties>`)),n}function Un(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}async function gs(){let e=new ot;e.file("[Content_Types].xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
12
|
+
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:Le},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,r=t.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!r.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let o=Tt(r.buffer);return {content:[{type:"text",text:JSON.stringify({valid:o.valid,tags:o.tags,errors:o.errors.map(i=>({message:i.message,variable:i.variable,type:i.type}))},null,2)}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${o.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},tt=[Bn,$n,Ln,Nn];var Xn={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:ze,replaceWithTemplateVariable:Ve},mcpTools:tt,initialize:()=>{try{ut("docxtemplater"),ut("pizzip");}catch{console.warn("[docxtemplater-plugin] Warning: docxtemplater or pizzip not installed. Template features may not work. Install with: npm install docxtemplater pizzip");}}};we();function te(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function wi(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 yi(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 nt(e){if(!e)return "";let t=[];if(e.styleId&&t.push(`<w:rStyle w:val="${te(e.styleId)}"/>`),e.fontFamily){let o=[];e.fontFamily.ascii&&o.push(`w:ascii="${te(e.fontFamily.ascii)}"`),e.fontFamily.hAnsi&&o.push(`w:hAnsi="${te(e.fontFamily.hAnsi)}"`),e.fontFamily.eastAsia&&o.push(`w:eastAsia="${te(e.fontFamily.eastAsia)}"`),e.fontFamily.cs&&o.push(`w:cs="${te(e.fontFamily.cs)}"`),e.fontFamily.asciiTheme&&o.push(`w:asciiTheme="${e.fontFamily.asciiTheme}"`),e.fontFamily.hAnsiTheme&&o.push(`w:hAnsiTheme="${e.fontFamily.hAnsiTheme}"`),e.fontFamily.eastAsiaTheme&&o.push(`w:eastAsiaTheme="${e.fontFamily.eastAsiaTheme}"`),e.fontFamily.csTheme&&o.push(`w:csTheme="${e.fontFamily.csTheme}"`),o.length>0&&t.push(`<w:rFonts ${o.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=wi(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"&&t.push(`<w:highlight w:val="${e.highlight}"/>`),e.underline){let o=[`w:val="${e.underline.style}"`];e.underline.color&&(e.underline.color.rgb&&o.push(`w:color="${e.underline.color.rgb}"`),e.underline.color.themeColor&&o.push(`w:themeColor="${e.underline.color.themeColor}"`)),t.push(`<w:u ${o.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=yi(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 xi(e){return `<w:t${e.preserveSpace||e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${te(e.text)}</w:t>`}function bi(e){return "<w:tab/>"}function Ti(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 Ci(e){return `<w:sym w:font="${te(e.font)}" w:char="${te(e.char)}"/>`}function Fi(e){return e.type==="footnoteRef"?`<w:footnoteReference w:id="${e.id}"/>`:`<w:endnoteReference w:id="${e.id}"/>`}function Si(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 vi(e){return `<w:instrText${e.text.startsWith(" ")||e.text.endsWith(" ")||e.text.includes(" ")?' xml:space="preserve"':""}>${te(e.text)}</w:instrText>`}function ki(e){return "<w:softHyphen/>"}function Pi(e){return "<w:noBreakHyphen/>"}function Ri(e){return e.image.rId?`<!-- Drawing with rId="${e.image.rId}" -->`:"<!-- Drawing placeholder -->"}function Mi(e){return `<!-- Shape: ${e.shape.shapeType||"unknown"} -->`}function Ei(e){switch(e.type){case "text":return xi(e);case "tab":return bi();case "break":return Ti(e);case "symbol":return Ci(e);case "footnoteRef":case "endnoteRef":return Fi(e);case "fieldChar":return Si(e);case "instrText":return vi(e);case "softHyphen":return ki();case "noBreakHyphen":return Pi();case "drawing":return Ri(e);case "shape":return Mi(e);default:return ""}}function ce(e){let t=[],n=nt(e.formatting);n&&t.push(n);for(let r of e.content){let o=Ei(r);o&&t.push(o);}return `<w:r>${t.join("")}</w:r>`}function ie(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(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 Ii(e){if(!e)return "";let t=[];if(e.top){let n=ue(e.top,"top");n&&t.push(n);}if(e.left){let n=ue(e.left,"left");n&&t.push(n);}if(e.bottom){let n=ue(e.bottom,"bottom");n&&t.push(n);}if(e.right){let n=ue(e.right,"right");n&&t.push(n);}if(e.between){let n=ue(e.between,"between");n&&t.push(n);}if(e.bar){let n=ue(e.bar,"bar");n&&t.push(n);}return t.length===0?"":`<w:pBdr>${t.join("")}</w:pBdr>`}function Di(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 Ai(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 Bi(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 $i(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 Li(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 Ni(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 Xi(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:pStyle w:val="${ie(e.styleId)}"/>`),e.keepNext&&t.push("<w:keepNext/>"),e.keepLines&&t.push("<w:keepLines/>"),e.pageBreakBefore&&t.push("<w:pageBreakBefore/>");let n=Ni(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=Li(e.numPr);r&&t.push(r);let o=Ii(e.borders);o&&t.push(o);let i=Di(e.shading);i&&t.push(i);let s=Ai(e.tabs);s&&t.push(s),e.suppressLineNumbers&&t.push("<w:suppressLineNumbers/>"),e.suppressAutoHyphens&&t.push("<w:suppressAutoHyphens/>");let a=Bi(e);a&&t.push(a);let c=$i(e);if(c&&t.push(c),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 f=nt(e.runProperties);f&&t.push(f);}return t.length===0?"":`<w:pPr>${t.join("")}</w:pPr>`}function Hn(e){let t=[];e.rId&&t.push(`r:id="${e.rId}"`),e.anchor&&t.push(`w:anchor="${ie(e.anchor)}"`),e.tooltip&&t.push(`w:tooltip="${ie(e.tooltip)}"`),e.target&&t.push(`w:tgtFrame="${ie(e.target)}"`),e.history===false&&t.push('w:history="0"'),e.docLocation&&t.push(`w:docLocation="${ie(e.docLocation)}"`);let n=e.children.map(o=>o.type==="run"?ce(o):o.type==="bookmarkStart"?On(o):o.type==="bookmarkEnd"?jn(o):"").join("");return `<w:hyperlink${t.length>0?" "+t.join(" "):""}>${n}</w:hyperlink>`}function On(e){let t=[`w:id="${e.id}"`,`w:name="${ie(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 jn(e){return `<w:bookmarkEnd w:id="${e.id}"/>`}function Hi(e){let t=[`w:instr="${ie(e.instruction)}"`];e.fldLock&&t.push('w:fldLock="true"'),e.dirty&&t.push('w:dirty="true"');let n=e.content.map(r=>r.type==="run"?ce(r):r.type==="hyperlink"?Hn(r):"").join("");return `<w:fldSimple ${t.join(" ")}>${n}</w:fldSimple>`}function Oi(e){let t=[],n=['w:fldCharType="begin"'];if(e.fldLock&&n.push('w:fldLock="true"'),e.dirty&&n.push('w:dirty="true"'),t.push(`<w:r><w:fldChar ${n.join(" ")}/></w:r>`),e.fieldCode.length>0)t.push(...e.fieldCode.map(r=>ce(r)));else {let o=e.instruction.startsWith(" ")||e.instruction.endsWith(" ")||e.instruction.includes(" ")?' xml:space="preserve"':"";t.push(`<w:r><w:instrText${o}>${ie(e.instruction)}</w:instrText></w:r>`);}return t.push('<w:r><w:fldChar w:fldCharType="separate"/></w:r>'),t.push(...e.fieldResult.map(r=>ce(r))),t.push('<w:r><w:fldChar w:fldCharType="end"/></w:r>'),t.join("")}function ji(e){switch(e.type){case "run":return ce(e);case "hyperlink":return Hn(e);case "bookmarkStart":return On(e);case "bookmarkEnd":return jn(e);case "simpleField":return Hi(e);case "complexField":return Oi(e);default:return ""}}function Ne(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(" "):"",o=Xi(e.formatting);o&&t.push(o);for(let i of e.content){let s=ji(i);s&&t.push(s);}return `<w:p${r}>${t.join("")}</w:p>`}function zi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function se(e,t){if(!e)return "";let n=[`w:w="${e.value}"`,`w:type="${e.type}"`];return `<w:${t} ${n.join(" ")}/>`}function fe(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 zn(e,t){if(!e)return "";let n=[];if(e.top){let r=fe(e.top,"top");r&&n.push(r);}if(e.left){let r=fe(e.left,"left");r&&n.push(r);}if(e.bottom){let r=fe(e.bottom,"bottom");r&&n.push(r);}if(e.right){let r=fe(e.right,"right");r&&n.push(r);}if(e.insideH){let r=fe(e.insideH,"insideH");r&&n.push(r);}if(e.insideV){let r=fe(e.insideV,"insideV");r&&n.push(r);}return n.length===0?"":`<w:${t}>${n.join("")}</w:${t}>`}function Vn(e,t){if(!e)return "";let n=[];return e.top&&n.push(se(e.top,"top")),e.left&&n.push(se(e.left,"left")),e.bottom&&n.push(se(e.bottom,"bottom")),e.right&&n.push(se(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 Vi(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 _i(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 Wi(e){if(!e)return "";let t=[];e.styleId&&t.push(`<w:tblStyle w:val="${zi(e.styleId)}"/>`);let n=_i(e.floating);n&&t.push(n),e.bidi&&t.push("<w:bidiVisual/>");let r=se(e.width,"tblW");r&&t.push(r),e.justification&&t.push(`<w:jc w:val="${e.justification}"/>`);let o=se(e.cellSpacing,"tblCellSpacing");o&&t.push(o);let i=se(e.indent,"tblInd");i&&t.push(i);let s=zn(e.borders,"tblBorders");s&&t.push(s);let a=Vn(e.cellMargins,"tblCellMar");a&&t.push(a),e.layout&&t.push(`<w:tblLayout w:type="${e.layout}"/>`);let c=_n(e.shading);c&&t.push(c);let f=Vi(e.look);return f&&t.push(f),e.overlap&&t.push(`<w:tblOverlap w:val="${e.overlap}"/>`),t.length===0?"":`<w:tblPr>${t.join("")}</w:tblPr>`}function Ui(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 qi(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 Gi(e){if(!e)return "";let t=[],n=qi(e.conditionalFormat);n&&t.push(n);let r=se(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 o=zn(e.borders,"tcBorders");o&&t.push(o);let i=_n(e.shading);i&&t.push(i),e.noWrap&&t.push("<w:noWrap/>");let s=Vn(e.margins,"tcMar");return s&&t.push(s),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 Ji(e){return !e||e.length===0?"":`<w:tblGrid>${e.map(n=>`<w:gridCol w:w="${n}"/>`).join("")}</w:tblGrid>`}function Zi(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(Ne(n)):n.type==="table"&&t.push(rt(n));return t.length===0&&t.push("<w:p/>"),t.join("")}function Yi(e){let t=[],n=Gi(e.formatting);return n&&t.push(n),t.push(Zi(e.content)),`<w:tc>${t.join("")}</w:tc>`}function Ki(e){let t=[],n=Ui(e.formatting);n&&t.push(n);for(let r of e.cells)t.push(Yi(r));return `<w:tr>${t.join("")}</w:tr>`}function rt(e){let t=[],n=Wi(e.formatting);n&&t.push(n);let r=Ji(e.columnWidths);r&&t.push(r);for(let o of e.rows)t.push(Ki(o));return `<w:tbl>${t.join("")}</w:tbl>`}var z={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 Qi(){let e={wpc:z.wpc,mc:z.mc,o:z.o,r:z.r,m:z.m,v:z.v,wp14:z.wp14,wp:z.wp,w10:z.w10,w:z.w,w14:z.w14,w15:z.w15,wpg:z.wpg,wps:z.wps};return Object.entries(e).map(([t,n])=>`xmlns:${t}="${n}"`).join(" ")}function Xe(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 es(e){return `<w:headerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function ts(e){return `<w:footerReference ${[`w:type="${e.type}"`,`r:id="${e.rId}"`].join(" ")}/>`}function ns(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 rs(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 os(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 is(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 ss(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(o=>{let i=[];return o.width!==void 0&&i.push(`w:w="${o.width}"`),o.space!==void 0&&i.push(`w:space="${o.space}"`),`<w:col ${i.join(" ")}/>`}).join("")),t.length===0&&!n?"":`<w:cols${t.length>0?" "+t.join(" "):""}>${n}</w:cols>`}function as(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 ls(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 i=Xe(t.top,"top");i&&r.push(i);}if(t.left){let i=Xe(t.left,"left");i&&r.push(i);}if(t.bottom){let i=Xe(t.bottom,"bottom");i&&r.push(i);}if(t.right){let i=Xe(t.right,"right");i&&r.push(i);}return r.length===0?"":`<w:pgBorders${n.length>0?" "+n.join(" "):""}>${r.join("")}</w:pgBorders>`}function cs(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 us(e){if(!e)return "";let t=[];if(e.headerReferences)for(let p of e.headerReferences)t.push(es(p));if(e.footerReferences)for(let p of e.footerReferences)t.push(ts(p));let n=ns(e.footnotePr);n&&t.push(n);let r=rs(e.endnotePr);r&&t.push(r),e.sectionStart&&t.push(`<w:type w:val="${e.sectionStart}"/>`);let o=os(e);o&&t.push(o);let i=is(e);if(i&&t.push(i),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 s=ls(e);s&&t.push(s);let a=as(e);a&&t.push(a);let c=ss(e);c&&t.push(c);let f=cs(e);return f&&t.push(f),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 fs(e){return e.type==="paragraph"?Ne(e):e.type==="table"?rt(e):""}function ps(e){return e.map(t=>fs(t)).join("")}function ds(e){let t=[];return t.push(ps(e.content)),e.finalSectionProperties&&t.push(us(e.finalSectionProperties)),t.join("")}function Wn(e){let t=[];t.push('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');let n=Qi();return t.push(`<w:document ${n} mc:Ignorable="w14 w15 wp14">`),t.push("<w:body>"),t.push(ds(e.package.document)),t.push("</w:body>"),t.push("</w:document>"),t.join("")}async function it(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:o}=t,i=await ot.loadAsync(e.originalBuffer),s=new ot;for(let[f,p]of Object.entries(i.files)){if(p.dir){s.folder(f.replace(/\/$/,""));continue}let d=await p.async("arraybuffer");s.file(f,d,{compression:"DEFLATE",compressionOptions:{level:n}});}let a=Wn(e);if(s.file("word/document.xml",a,{compression:"DEFLATE",compressionOptions:{level:n}}),r){let f="docProps/core.xml",p=i.file(f);if(p){let d=await p.async("text"),w=ms(d,{updateModifiedDate:r,modifiedBy:o});s.file(f,w,{compression:"DEFLATE",compressionOptions:{level:n}});}}return await s.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:n}})}function ms(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>${Un(t.modifiedBy)}</cp:lastModifiedBy>`):n=n.replace("</cp:coreProperties>",`<cp:lastModifiedBy>${Un(t.modifiedBy)}</cp:lastModifiedBy></cp:coreProperties>`)),n}function Un(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}async function gs(){let e=new ot;e.file("[Content_Types].xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
13
13
|
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
14
14
|
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
15
15
|
<Default Extension="xml" ContentType="application/xml"/>
|
|
@@ -65,21 +65,21 @@ Returns validation result with any errors found and list of valid tags.`,inputSc
|
|
|
65
65
|
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
|
|
66
66
|
<Application>EigenPal DOCX Editor</Application>
|
|
67
67
|
<AppVersion>1.0.0</AppVersion>
|
|
68
|
-
</Properties>`),e.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}})}async function qn(e){let t=await gs(),n={...e,originalBuffer:t};return it(n)}et();var
|
|
68
|
+
</Properties>`),e.generateAsync({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}})}async function qn(e){let t=await gs(),n={...e,originalBuffer:t};return it(n)}et();var ne={type:"string",description:"Document ID returned from docx_load"},st={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},offset:{type:"number",description:"Character offset within the paragraph",minimum:0}},required:["paragraphIndex","offset"]},at={type:"object",properties:{start:st,end:st},required:["start","end"]},hs={name:"docx_load",description:`Load a DOCX document from base64-encoded content.
|
|
69
69
|
Returns a document ID that can be used with other tools.
|
|
70
|
-
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(e,t)=>{let{content:n,source:r}=e;try{let o=atob(n),i=new Uint8Array(o.length);for(let p=0;p<o.length;p++)i[p]=o.charCodeAt(p);let s=i.buffer,a=await Ae(s),
|
|
71
|
-
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:
|
|
72
|
-
Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:
|
|
73
|
-
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:
|
|
70
|
+
The document remains in session memory until closed.`,inputSchema:{type:"object",properties:{content:{type:"string",description:"Base64-encoded DOCX file content"},source:{type:"string",description:"Optional source filename or identifier for reference"}},required:["content"]},handler:async(e,t)=>{let{content:n,source:r}=e;try{let o=atob(n),i=new Uint8Array(o.length);for(let p=0;p<o.length;p++)i[p]=o.charCodeAt(p);let s=i.buffer,a=await Ae(s),c=`doc_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;t.session.documents.set(c,{id:c,document:a,buffer:s,source:r,lastModified:Date.now()});let f=a.package.document.content.filter(p=>p.type==="paragraph").length;return {content:[{type:"text",text:JSON.stringify({documentId:c,source:r,paragraphCount:f,message:"Document loaded successfully"})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to load document: ${o.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},ws={name:"docx_save",description:`Export the document to base64-encoded DOCX format.
|
|
71
|
+
Returns the document as a base64 string that can be saved to a file.`,inputSchema:{type:"object",properties:{documentId:ne},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,r=t.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let o;r.buffer?o=await it(r.document):o=await qn(r.document);let i=new Uint8Array(o),s="";for(let c=0;c<i.length;c++)s+=String.fromCharCode(i[c]);let a=btoa(s);return {content:[{type:"text",text:JSON.stringify({documentId:n,base64:a,size:o.byteLength,message:"Document exported successfully"})}]}}catch(o){return {isError:true,content:[{type:"text",text:`Failed to save document: ${o.message}`}]}}},annotations:{category:"core",readOnly:true,complexity:"low"}},ys={name:"docx_close",description:`Close a document and free its memory.
|
|
72
|
+
Use this when done working with a document.`,inputSchema:{type:"object",properties:{documentId:ne},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e;return t.session.documents.has(n)?(t.session.documents.delete(n),{content:[{type:"text",text:JSON.stringify({documentId:n,message:"Document closed"})}]}):{isError:true,content:[{type:"text",text:`Document not found: ${n}`}]}},annotations:{category:"core",readOnly:false,complexity:"low"}},xs={name:"docx_get_info",description:`Get metadata and statistics about a document.
|
|
73
|
+
Returns paragraph count, word count, table count, and other useful info.`,inputSchema:{type:"object",properties:{documentId:ne},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,r=t.session.documents.get(n);if(!r)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};let o=r.document,i=o.package.document,s=i.content.filter(f=>f.type==="paragraph"),a=i.content.filter(f=>f.type==="table"),c=0;for(let f of s)if(f.type==="paragraph"){let p=Gn(f);c+=p.split(/\s+/).filter(d=>d.length>0).length;}return {content:[{type:"text",text:JSON.stringify({documentId:n,paragraphCount:s.length,tableCount:a.length,wordCount:c,hasStyles:!!o.package.styles,hasTheme:!!o.package.theme,source:r.source,lastModified:r.lastModified})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},bs={name:"docx_get_text",description:`Get the plain text content of the document.
|
|
74
74
|
Returns all text concatenated with paragraph breaks.
|
|
75
|
-
Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:
|
|
76
|
-
`),
|
|
75
|
+
Useful for understanding document content before making edits.`,inputSchema:{type:"object",properties:{documentId:ne,maxLength:{type:"number",description:"Maximum characters to return (default: 10000)",default:1e4}},required:["documentId"]},handler:async(e,t)=>{let{documentId:n,maxLength:r=1e4}=e,o=t.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};let i=o.document.package.document,s=[];for(let f of i.content)f.type==="paragraph"?s.push(Gn(f)):f.type==="table"&&s.push("[TABLE]");let a=s.join(`
|
|
76
|
+
`),c=a.length>r;return c&&(a=a.slice(0,r)+"..."),{content:[{type:"text",text:JSON.stringify({documentId:n,text:a,truncated:c,totalLength:c?s.join(`
|
|
77
77
|
`).length:a.length})}]}},annotations:{category:"core",readOnly:true,complexity:"low"}},Ts={name:"docx_insert_text",description:`Insert text at a specific position in the document.
|
|
78
|
-
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:
|
|
79
|
-
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:
|
|
80
|
-
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:
|
|
81
|
-
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:
|
|
82
|
-
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:
|
|
78
|
+
Position is specified by paragraph index (0-indexed) and character offset.`,inputSchema:{type:"object",properties:{documentId:ne,position:st,text:{type:"string",description:"Text to insert"}},required:["documentId","position","text"]},handler:async(e,t)=>{let{documentId:n,position:r,text:o}=e,i=t.session.documents.get(n);if(!i)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=ee(i.document,{type:"insertText",position:r,text:o});return i.document=s,i.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,insertedLength:o.length,position:r})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to insert text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Cs={name:"docx_replace_text",description:`Replace text in a range with new text.
|
|
79
|
+
Specify start and end positions to define the range to replace.`,inputSchema:{type:"object",properties:{documentId:ne,range:at,text:{type:"string",description:"Replacement text"}},required:["documentId","range","text"]},handler:async(e,t)=>{let{documentId:n,range:r,text:o}=e,i=t.session.documents.get(n);if(!i)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=ee(i.document,{type:"replaceText",range:r,text:o});return i.document=s,i.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedRange:r,newTextLength:o.length})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to replace text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Fs={name:"docx_delete_text",description:`Delete text in a range.
|
|
80
|
+
Specify start and end positions to define the range to delete.`,inputSchema:{type:"object",properties:{documentId:ne,range:at},required:["documentId","range"]},handler:async(e,t)=>{let{documentId:n,range:r}=e,o=t.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let i=ee(o.document,{type:"deleteText",range:r});return o.document=i,o.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,deletedRange:r})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to delete text: ${i.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}},Ss={name:"docx_format_text",description:`Apply formatting to text in a range.
|
|
81
|
+
Supports bold, italic, underline, font size, font family, color, and highlight.`,inputSchema:{type:"object",properties:{documentId:ne,range:at,formatting:{type:"object",description:"Formatting options to apply",properties:{bold:{type:"boolean"},italic:{type:"boolean"},underline:{type:"boolean"},strikethrough:{type:"boolean"},fontSize:{type:"number",description:"Font size in points"},fontFamily:{type:"string"},color:{type:"string",description:'Hex color (e.g., "#FF0000")'},highlight:{type:"string",description:"Highlight color name"}}}},required:["documentId","range","formatting"]},handler:async(e,t)=>{let{documentId:n,range:r,formatting:o}=e,i=t.session.documents.get(n);if(!i)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=ee(i.document,{type:"formatText",range:r,formatting:o});return i.document=s,i.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,range:r,appliedFormatting:o})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to format text: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"medium"}},vs={name:"docx_apply_style",description:`Apply a named style to a paragraph.
|
|
82
|
+
Use document styles like "Heading1", "Heading2", "Normal", etc.`,inputSchema:{type:"object",properties:{documentId:ne,paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)",minimum:0},styleId:{type:"string",description:'Style ID (e.g., "Heading1", "Normal")'}},required:["documentId","paragraphIndex","styleId"]},handler:async(e,t)=>{let{documentId:n,paragraphIndex:r,styleId:o}=e,i=t.session.documents.get(n);if(!i)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let s=ee(i.document,{type:"applyStyle",paragraphIndex:r,styleId:o});return i.document=s,i.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,paragraphIndex:r,styleId:o})}]}}catch(s){return {isError:true,content:[{type:"text",text:`Failed to apply style: ${s.message}`}]}}},annotations:{category:"core",readOnly:false,complexity:"low"}};function Gn(e){let t=[];for(let n of e.content)n.type==="run"?t.push(Jn(n)):n.type==="hyperlink"&&t.push(ks(n));return t.join("")}function Jn(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function ks(e){let t=[];for(let n of e.children)n.type==="run"&&t.push(Jn(n));return t.join("")}var lt=[hs,ws,ys,xs,bs,Ts,Cs,Fs,Ss,vs];function Ps(e={}){let{name:t="docx-editor",version:n="0.1.0",includeCoreTools:r=true,debug:o=false,additionalTools:i=[]}=e,s=new Map,a={id:`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,documents:new Map,data:new Map};if(r)for(let g of lt)s.set(g.name,g),o&&console.log(`[MCP] Registered core tool: ${g.name}`);let c=re.getMcpTools();for(let g of c)s.has(g.name)&&console.warn(`[MCP] Tool '${g.name}' from plugin overrides existing tool`),s.set(g.name,g),o&&console.log(`[MCP] Registered plugin tool: ${g.name}`);for(let g of i)s.set(g.name,g),o&&console.log(`[MCP] Registered additional tool: ${g.name}`);let f=o?(g,m)=>{console.log(`[MCP] ${g}`,m??"");}:()=>{};async function p(g,m){let b=s.get(g);if(!b)throw new Error(`Unknown tool: ${g}`);f(`Calling tool: ${g}`,m);let D={session:a,log:f};try{let P=await b.handler(m,D);return f(`Tool ${g} completed`,P),P}catch(P){throw f(`Tool ${g} failed`,P),P}}function d(){return Array.from(s.values()).map(g=>({name:g.name,description:g.description,inputSchema:Ms(g.inputSchema),category:g.annotations?.category}))}function w(){return {name:t,version:n,toolCount:s.size}}return {tools:s,session:a,handleToolCall:p,listTools:d,getInfo:w}}async function Rs(e,t){let{id:n,method:r,params:o}=t;try{switch(r){case "initialize":return {jsonrpc:"2.0",id:n,result:{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:e.getInfo()}};case "tools/list":{let i=e.listTools();return {jsonrpc:"2.0",id:n,result:{tools:i.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))}}}case "tools/call":{let{name:i,arguments:s}=o,a=await e.handleToolCall(i,s);return {jsonrpc:"2.0",id:n,result:a}}default:return {jsonrpc:"2.0",id:n,error:{code:-32601,message:`Method not found: ${r}`}}}}catch(i){return {jsonrpc:"2.0",id:n,error:{code:-32e3,message:i.message}}}}async function Zn(e={}){let t=Ps(e);e.debug&&(console.error(`[MCP] Server started: ${t.getInfo().name} v${t.getInfo().version}`),console.error(`[MCP] Tools registered: ${t.tools.size}`));let r=(await import('readline')).createInterface({input:process.stdin,output:process.stdout,terminal:false}),o="";r.on("line",async i=>{o+=i;try{let s=JSON.parse(o);o="";let a=await Rs(t,s);process.stdout.write(JSON.stringify(a)+`
|
|
83
83
|
`);}catch{}}),r.on("close",()=>{e.debug&&console.error("[MCP] Server closed"),process.exit(0);});}function Ms(e){return typeof e=="object"&&e!==null&&("type"in e||"properties"in e)?e:{type:"object",properties:{}}}function Es(){let e=process.argv.slice(2);return {debug:e.includes("--debug")||e.includes("-d"),help:e.includes("--help")||e.includes("-h"),version:e.includes("--version")||e.includes("-v")}}var Is=`
|
|
84
84
|
docx-editor-mcp - MCP server for DOCX document editing
|
|
85
85
|
|
|
@@ -132,4 +132,4 @@ EXAMPLES:
|
|
|
132
132
|
|
|
133
133
|
# Start server with debug logging
|
|
134
134
|
docx-editor-mcp --debug
|
|
135
|
-
`;async function Ds(){let{debug:e,help:t,version:n}=Es();t&&(console.log(Is),process.exit(0)),n&&(console.log("0.1.0"),process.exit(0)),
|
|
135
|
+
`;async function Ds(){let{debug:e,help:t,version:n}=Es();t&&(console.log(Is),process.exit(0)),n&&(console.log("0.1.0"),process.exit(0)),re.register(Xn),e&&(console.error("[MCP CLI] Registered docxtemplater plugin"),console.error(`[MCP CLI] Total plugins: ${re.size}`),console.error(`[MCP CLI] Total MCP tools: ${re.getMcpTools().length}`)),await Zn({name:"docx-editor",version:"0.1.0",debug:e});}Ds().catch(e=>{console.error("[MCP CLI] Fatal error:",e),process.exit(1);});
|