@eigenpal/docx-js-editor 0.0.3 → 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 +25 -25
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -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 -9
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K="Calibri";var O=null;function W(){if(!O){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(O=e.getContext("2d"),!O)throw new Error("Failed to get 2D context from canvas")}return O}var oe='"Segoe UI", Arial, sans-serif';function U(e){let n=[];e.italic&&n.push("italic"),e.bold&&n.push("bold");let c=e.fontSize??11,r=J(c);n.push(`${r}px`);let o=e.fontFamily??K,t=o.includes(" ")?`"${o}"`:o;return n.push(`${t}, ${oe}`),n.join(" ")}function ae(e){let n=e.fontSize??11,c=e.fontFamily??K,r=J(n),o=r*.8,t=r*.2;try{let i=W();i.font=U(e);let a=i.measureText("Hg");typeof a.actualBoundingBoxAscent=="number"&&typeof a.actualBoundingBoxDescent=="number"&&(o=a.actualBoundingBoxAscent,t=a.actualBoundingBoxDescent);}catch{}let s=r*1.15;return {fontSize:n,ascent:o,descent:t,lineHeight:s,fontFamily:c}}function ce(e,n){if(!e)return 0;let c=W();c.font=U(n);let r=c.measureText(e),o=r.width,t=(r.actualBoundingBoxLeft||0)+(r.actualBoundingBoxRight||0),s=Math.max(o,t);return n.letterSpacing&&e.length>1&&(s+=n.letterSpacing*(e.length-1)),s}function G(e,n){let c=ae(n);if(!e)return {width:0,charWidths:[],metrics:c};let r=W();r.font=U(n);let o=n.letterSpacing??0,t=[],s=0;for(let i=0;i<e.length;i++){let a=e[i],m=r.measureText(a).width;o&&i<e.length-1&&(m+=o),t.push(m),s+=m;}return {width:s,charWidths:t,metrics:c}}function se(e,n){if(n.length===0||e<=0)return 0;let c=0;for(let r=0;r<n.length;r++){let o=n[r],t=c+o/2;if(e<=t)return r;c+=o;}return n.length}function J(e){return e*96/72}function $(e,n){let c=e.pageGap??0,r=0;for(let o=0;o<n&&o<e.pages.length;o++){let s=e.pages[o].size?.h??e.pageSize.h;r+=s+c;}return r}function Q(e,n){return e.findIndex(c=>c.id===n)}function ie(e,n){let c=0;for(let r=e.fromLine;r<e.toLine&&r<n.lines.length;r++)c+=n.lines[r].lineHeight;return c}function ue(e,n,c,r){let o=[...e.page.fragments].sort((t,s)=>{let i=t.y-s.y;return Math.abs(i)>.5?i:t.x-s.x});for(let t of o){let s=Q(n,t.blockId);if(s===-1)continue;let i=n[s],a=c[s];if(!i||!a)continue;let g;if(t.kind==="paragraph"){if(i.kind!=="paragraph"||a.kind!=="paragraph")continue;g=ie(t,a);}else if(t.kind==="table")g=t.height;else if(t.kind==="image")g=t.height;else continue;let m=r.x>=t.x&&r.x<=t.x+t.width,l=r.y>=t.y&&r.y<=t.y+g;if(m&&l)return {fragment:t,block:i,measure:a,pageIndex:e.pageIndex,localX:r.x-t.x,localY:r.y-t.y}}return null}function ge(e,n,c,r){for(let o of e.page.fragments){if(o.kind!=="table")continue;let t=o,s=r.x>=t.x&&r.x<=t.x+t.width,i=r.y>=t.y&&r.y<=t.y+t.height;if(!s||!i)continue;let a=Q(n,t.blockId);if(a===-1)continue;let g=n[a],m=c[a];if(!g||g.kind!=="table"||!m||m.kind!=="table")continue;let l=g,f=m,p=r.x-t.x,M=r.y-t.y,b=0,d=-1;if(f.rows.length===0||l.rows.length===0)continue;for(let u=t.fromRow;u<t.toRow&&u<f.rows.length;u++){let w=f.rows[u];if(M>=b&&M<b+w.height){d=u;break}b+=w.height;}if(d===-1&&(d=Math.min(t.toRow-1,f.rows.length-1),d<t.fromRow))continue;let h=f.rows[d],T=l.rows[d];if(!h||!T)continue;let x=0,k=-1;if(h.cells.length===0||T.cells.length===0)continue;for(let u=0;u<h.cells.length;u++){let w=h.cells[u];if(p>=x&&p<x+w.width){k=u;break}x+=w.width;}if(k===-1&&(k=h.cells.length-1,k<0))continue;let I=h.cells[k],y=T.cells[k];if(!I||!y)continue;let F=0;for(let u=t.fromRow;u<d;u++)F+=f.rows[u]?.height??0;let B=0;for(let u=0;u<k;u++)B+=h.cells[u]?.width??0;let S,P;if(y.blocks&&y.blocks.length>0){let u=y.blocks[0],w=I.blocks[0];u.kind==="paragraph"&&w?.kind==="paragraph"&&(S=u,P=w);}let R=p-B,H=M-F;return {fragment:t,block:l,measure:f,pageIndex:e.pageIndex,rowIndex:d,colIndex:k,cellBlock:S,cellMeasure:P,cellLocalX:Math.max(0,R),cellLocalY:Math.max(0,H)}}return null}function V(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Z(e,n){return e.findIndex(c=>c.id===n)}function Y(e,n){let r=(e.pmStart??0)+1,o=0,t;for(let a=0;a<e.runs.length&&a<=n.toRun;a++){let g=e.runs[a];if(g){if(a<n.fromRun)g.kind==="text"?o+=(g.text??"").length:o+=1;else if(a===n.fromRun){o+=n.fromChar,t=r+o;break}}}t===void 0&&(t=r);let s=0;for(let a=n.fromRun;a<=n.toRun&&a<e.runs.length;a++){let g=e.runs[a];if(g)if(g.kind==="text"){let m=g.text??"",l=a===n.fromRun?n.fromChar:0,f=a===n.toRun?n.toChar:m.length;s+=f-l;}else s+=1;}let i=t+s;return {pmStart:t,pmEnd:i}}function ee(e,n,c,r){let o=[];for(let t=0;t<n.lines.length;t++){let s=n.lines[t],i=Y(e,s);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>c&&i.pmStart<r&&o.push({line:s,index:t});}return o}function _(e,n,c){let r=Y(e,n);return r.pmStart===void 0?0:Math.max(0,c-r.pmStart)}function X(e,n,c,r){let o=0,t=0;for(let s=n.fromRun;s<=n.toRun&&s<e.runs.length;s++){let i=e.runs[s];if(i){if(i.kind==="tab"){let a=i.width??48;if(t+1>=c)return c<=t?o:o+a;o+=a,t+=1;continue}if(i.kind==="image"){let a=i.width;if(t+1>=c)return c<=t?o:o+a;o+=a,t+=1;continue}if(i.kind==="lineBreak"){if(c<=t)return o;t+=1;continue}if(i.kind==="text"){let a=i.text??"",g=s===n.fromRun,m=s===n.toRun,l=g?n.fromChar:0,f=m?n.toChar:a.length,p=a.slice(l,f);if(t+p.length>=c){let d=c-t,h=V(i),T=G(p.slice(0,d),h);return o+T.width}let M=V(i),b=G(p,M);o+=b.width,t+=p.length;}}}return o}function A(e,n){let c=0;for(let r=0;r<n&&r<e.lines.length;r++)c+=e.lines[r].lineHeight;return c}function pe(e,n,c,r,o){if(r===o)return [];let t=Math.min(r,o),s=Math.max(r,o),i=[];for(let a=0;a<e.pages.length;a++){let g=e.pages[a],m=$(e,a);for(let l of g.fragments){if(l.kind==="paragraph"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="paragraph"||!M||M.kind!=="paragraph")continue;let b=p,d=M,h=l,T=ee(b,d,t,s);for(let{line:x,index:k}of T){if(k<h.fromLine||k>=h.toLine)continue;let I=Y(b,x);if(I.pmStart===void 0||I.pmEnd===void 0)continue;let y=Math.max(I.pmStart,t),F=Math.min(I.pmEnd,s);if(y>=F)continue;let B=_(b,x,y),S=_(b,x,F),P=b.attrs?.indent,R=P?.left??0,H=P?.right??0,u=Math.max(0,l.width-R-H),w=X(b,x,B),z=X(b,x,S),C=b.attrs?.alignment??"left",L=0;C==="center"?L=Math.max(0,(u-x.width)/2):C==="right"&&(L=Math.max(0,u-x.width));let v=A(d,k)-A(d,h.fromLine),E=l.x+R+L+Math.min(w,z),D=Math.max(1,Math.abs(z-w)),N=l.y+v;i.push({x:E,y:N+m,width:D,height:x.lineHeight,pageIndex:a});}}if(l.kind==="table"){let f=Z(n,l.blockId);if(f===-1)continue;let p=n[f],M=c[f];if(!p||p.kind!=="table"||!M||M.kind!=="table")continue;let b=p,d=M,h=l,T=0;for(let x=h.fromRow;x<h.toRow&&x<b.rows.length;x++){let k=b.rows[x],I=d.rows[x];if(!k||!I)continue;let y=0;for(let F=0;F<k.cells.length;F++){let B=k.cells[F],S=I.cells[F];if(!(!B||!S)){for(let P=0;P<B.blocks.length;P++){let R=B.blocks[P],H=S.blocks[P];if(!R||R.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let u=R,w=H,z=ee(u,w,t,s),C=0;for(let{line:L,index:v}of z){let E=Y(u,L);if(E.pmStart===void 0||E.pmEnd===void 0)continue;let D=Math.max(E.pmStart,t),N=Math.min(E.pmEnd,s);if(D>=N)continue;let te=_(u,L,D),ne=_(u,L,N),j=X(u,L,te,S.width),q=X(u,L,ne,S.width),re=A(w,v);i.push({x:h.x+y+Math.min(j,q),y:h.y+T+C+re+m,width:Math.max(1,Math.abs(q-j)),height:L.lineHeight,pageIndex:a});}C+=w.totalHeight;}y+=S.width;}}T+=I.height;}}if(l.kind==="image"){let f=l.pmStart??0;(l.pmEnd??f+1)>t&&f<s&&i.push({x:l.x,y:l.y+m,width:l.width,height:l.height,pageIndex:a});}}}return i}function de(e,n,c,r){for(let o=0;o<e.pages.length;o++){let t=e.pages[o],s=$(e,o);for(let i of t.fragments){if(i.kind==="paragraph"){let a=Z(n,i.blockId);if(a===-1)continue;let g=n[a],m=c[a];if(!g||g.kind!=="paragraph"||!m||m.kind!=="paragraph")continue;let l=g,f=m,p=i,M=l.pmStart??0,b=l.pmEnd??M;if(r<M||r>b)continue;for(let d=p.fromLine;d<p.toLine;d++){let h=f.lines[d];if(!h)continue;let T=Y(l,h);if(!(T.pmStart===void 0||T.pmEnd===void 0)&&r>=T.pmStart&&r<=T.pmEnd){let x=_(l,h,r),k=l.attrs?.indent,I=k?.left??0,y=k?.right??0,F=Math.max(0,i.width-I-y),B=X(l,h,x),S=l.attrs?.alignment??"left",P=0;S==="center"?P=Math.max(0,(F-h.width)/2):S==="right"&&(P=Math.max(0,F-h.width));let R=A(f,d)-A(f,p.fromLine);return {x:i.x+I+P+B,y:i.y+R+s,height:h.lineHeight,pageIndex:o}}}}if(i.kind==="image"){let a=i.pmStart??0,g=i.pmEnd??a+1;if(r>=a&&r<=g){let m=r===a?0:i.width;return {x:i.x+m,y:i.y+s,height:i.height,pageIndex:o}}}}}return null}function xe(e){return e.length<=1?false:new Set(e.map(c=>c.pageIndex)).size>1}function be(e){let n=new Map;for(let c of e){let r=n.get(c.pageIndex)??[];r.push(c),n.set(c.pageIndex,r);}return n}export{ae as a,ce as b,G as c,se as d,J as e,ue as f,ge as g,pe as h,de as i,xe as j,be as k};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {l}from'./chunk-
|
|
1
|
+
import {l}from'./chunk-ZMWEAP5S.js';import {a}from'./chunk-3IYNTJO5.js';import g from'pizzip';import b from'docxtemplater';function J(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function v(e,t){let r=t,{position:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.paragraphIndex} out of bounds`);let c=s[o.paragraphIndex],l=`{{${n}}}`;return k(c,o.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function w(e,t){let r=t,{range:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.start.paragraphIndex!==o.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(o.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.start.paragraphIndex} out of bounds`);let c=s[o.start.paragraphIndex];Z(c,o.start.offset,o.end.offset);let l=`{{${n}}}`;return k(c,o.start.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function k(e,t,r){let o=0,n=false;for(let a=0;a<e.content.length;a++){let i=e.content[a];if(i.type==="run"){let s=T(i),c=o,l=o+s.length;if(!n&&t>=c&&t<=l){let u=t-c,y=s.slice(0,u),m=s.slice(u),p=[];for(let d=0;d<a;d++)p.push(e.content[d]);y&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:y}]}),p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:r}]}),m&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:m}]});for(let d=a+1;d<e.content.length;d++)p.push(e.content[d]);e.content=p,n=true;break}o=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(o+=T(s).length);}n||e.content.push({type:"run",content:[{type:"text",text:r}]});}function Z(e,t,r){let o=[],n=0;for(let a of e.content)if(a.type==="run"){let i=T(a),s=n,c=n+i.length;if(c<=t||s>=r)o.push(a);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>r&&(l+=i.slice(r-s)),l.length>0&&o.push({type:"run",formatting:a.formatting,content:[{type:"text",text:l}]});}n=c;}else o.push(a);e.content=o;}function T(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function U(e){return V(e).variables}function V(e){let t=[],r={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let n=j(e.package.document);n.forEach(a=>{t.push({name:a,location:"body"});}),r.body=Array.from(new Set(n)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((n,a)=>{n.properties.headerReferences&&n.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let n=A(e.package.footnotes);n.forEach(a=>{t.push({name:a,location:"footnote"});}),r.footnotes=Array.from(new Set(n)).sort();}if(e.package?.endnotes){let n=A(e.package.endnotes);n.forEach(a=>{t.push({name:a,location:"endnote"});}),r.endnotes=Array.from(new Set(n)).sort();}e.templateVariables&&e.templateVariables.forEach(n=>{t.some(a=>a.name===n)||t.push({name:n,location:"body"});});let o=new Set;return t.forEach(n=>o.add(n.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:r,occurrences:t}}function j(e){let t=[];if(e.content&&t.push(...I(e.content)),e.sections)for(let r of e.sections)r.content&&t.push(...I(r.content));return t}function I(e){let t=[];for(let r of e)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function R(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="run"?t.push(...f(r)):r.type==="hyperlink"?t.push(...q(r)):r.type==="simpleField"?t.push(...W(r)):r.type==="complexField"&&t.push(...G(r));return t}function f(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="text"&&r.text&&t.push(...B(r.text));return t}function q(e){let t=[];if(!e.children)return t;for(let r of e.children)r.type==="run"&&t.push(...f(r));return t}function W(e){let t=[];if(e.instruction&&t.push(...B(e.instruction)),e.content)for(let r of e.content)r.type==="run"&&t.push(...f(r));return t}function G(e){let t=[];if(e.fieldCode)for(let r of e.fieldCode)r.type==="run"&&t.push(...f(r));if(e.fieldResult)for(let r of e.fieldResult)r.type==="run"&&t.push(...f(r));return t}function M(e){let t=[];if(!e.rows)return t;for(let r of e.rows)if(r.cells)for(let o of r.cells)t.push(...X(o));return t}function X(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function A(e){let t=[];for(let r of e)if(r.content)for(let o of r.content)t.push(...R(o));return t}var S=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,_=/\{(.+?)\}/g;function B(e){if(!e)return [];let t=[],r=new RegExp(S),o;for(;(o=r.exec(e))!==null;)t.push(o[1]);return t}function oe(e){return S.test(e)}function ae(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function ie(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function se(e){return `{${e}}`}function ce(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function le(e,t){return e&&e.replace(_,(r,o)=>{let n=o.trim();return n in t?t[n]:r})}function pe(e,t=""){return e&&e.replace(_,t)}function ue(e){return U(e).length>0}function O(e,t,r={}){return E(e,t,r).buffer}function E(e,t,r={}){let{nullGetter:o="keep",linebreaks:n=true,delimiters:a}=r,i=[],s=[],c=[];try{let l=new g(e),u=new b(l,{paragraphLoop:!0,linebreaks:n,nullGetter:m=>{let p=m.value||"";if(o==="error")throw new Error(`Undefined variable: ${p}`);return o==="empty"?(c.push(p),""):(c.push(p),`{${p}}`)},delimiters:a?{start:a.start||"{",end:a.end||"}"}:void 0});return Object.keys(t).forEach(m=>{t[m]!==void 0&&t[m]!==null&&s.push(m);}),u.setData(t),u.render(),{buffer:u.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:s,unreplacedVariables:c,warnings:i}}catch(l){throw x(l)}}function ge(e,t,r={}){let o=O(e,t,r);return new Blob([o],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function be(e){try{let t=new g(e),o=new b(t,{paragraphLoop:!0,linebreaks:!0}).getFullText();return $(o)}catch(t){throw x(t)}}function L(e){let t=[],r=[];try{let o=new g(e),a=new b(o,{paragraphLoop:!0,linebreaks:!0}).getFullText();r=$(a);let i=K(a);for(let s of i)t.push({message:`Unclosed tag: ${s}`,variable:s,type:"parse"});return {valid:t.length===0,errors:t,tags:r}}catch(o){return t.push(x(o)),{valid:false,errors:t,tags:r}}}function xe(e,t){return e.filter(r=>!(r in t)||t[r]===void 0||t[r]===null)}function he(e,t){try{let r=new g(e),o=new b(r,{paragraphLoop:!0,linebreaks:!0,nullGetter:n=>`[${n.value||""}]`});return o.setData(t),o.render(),o.getFullText()}catch(r){throw x(r)}}function $(e){let t=[],r=/\{([^{}]+)\}/g,o;for(;(o=r.exec(e))!==null;){let n=o[1].trim();n&&!t.includes(n)&&t.push(n);}return t.sort()}function K(e){let t=[],r=0,o="";for(let n of e)n==="{"?(r++,o=""):n==="}"?(r--,r<0&&(r=0)):r>0&&(o+=n);return r>0&&o.trim()&&t.push(o.trim()),t}function Q(e){return "properties"in e&&typeof e.properties=="object"}function x(e){if(e instanceof Error){if(Q(e)&&e.properties?.errors){let t=e.properties.errors[0];return {message:t?.message||"Template processing error",variable:t?.properties?.tag,type:"render",originalError:e}}if(e.message.includes("undefined")){let t=e.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:e.message,variable:t?t[1]:void 0,type:"undefined",originalError:e}}return e.message.includes("parse")||e.message.includes("unclosed")||e.message.includes("syntax")?{message:e.message,type:"parse",originalError:e}:{message:e.message,type:"unknown",originalError:e}}return {message:String(e),type:"unknown"}}function ye(e,t,r={}){let{linebreaks:o=true,delimiters:n}=r;try{let a=new g(e),i=new b(a,{paragraphLoop:!0,linebreaks:o,delimiters:n?{start:n.start||"{",end:n.end||"}"}:void 0});return i.setData(t),i.render(),i.getZip().generate({type:"arraybuffer",compression:"DEFLATE"})}catch(a){throw x(a)}}function Te(e={}){return (t,r)=>O(t,r,e)}var h={type:"string",description:"Document ID from a previous docx_load call"},Y={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},N={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
|
|
2
2
|
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
3
|
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:h},required:["documentId"]},handler:async(e,t)=>{let{documentId:r}=e,o=t.session.documents.get(r);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};try{let n=V(o.document);return {content:[{type:"text",text:JSON.stringify({variables:n.variables,count:n.variables.length,totalOccurrences:n.totalOccurrences,byLocation:n.byLocation},null,2)}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${n.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},F={name:"docx_insert_variable",description:`Insert a template variable placeholder ({{name}}) at a specific position in the document.
|
|
4
4
|
The variable can later be substituted with actual values using docx_apply_template.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a,n}from'./chunk-YJJ7HRPG.js';import {d,e as e$1}from'./chunk-NI5OFVY2.js';import {l}from'./chunk-EU5LN2WS.js';import {b,a as a$1}from'./chunk-AQ35GWDV.js';import {e}from'./chunk-3IYNTJO5.js';var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Y={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function U(n){if(!n)return 1;let e=parseInt(n,16);return isNaN(e)?1:e/255}function C(n){let e=n.padStart(6,"0").slice(0,6),t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return {r:isNaN(t)?0:t,g:isNaN(r)?0:r,b:isNaN(o)?0:o}}function D(n,e,t){let r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return `${r(n)}${r(e)}${r(t)}`.toUpperCase()}function $(n,e,t){n/=255,e/=255,t/=255;let r=Math.max(n,e,t),o=Math.min(n,e,t),a=(r+o)/2;if(r===o)return {h:0,s:0,l:a};let i=r-o,s=a>.5?i/(2-r-o):i/(r+o),u;switch(r){case n:u=((e-t)/i+(e<t?6:0))/6;break;case e:u=((t-n)/i+2)/6;break;case t:u=((n-e)/i+4)/6;break;default:u=0;}return {h:u*360,s,l:a}}function G(n,e,t){if(n=n/360,e===0){let i=Math.round(t*255);return {r:i,g:i,b:i}}let r=(i,s,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(s-i)*6*u:u<1/2?s:u<2/3?i+(s-i)*(2/3-u)*6:i),o=t<.5?t*(1+e):t+e-t*e,a=2*t-o;return {r:Math.round(r(a,o,n+1/3)*255),g:Math.round(r(a,o,n)*255),b:Math.round(r(a,o,n-1/3)*255)}}function q(n,e){if(e<=0||e>=1)return e>=1?"FFFFFF":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l+(1-r.l)*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function X(n,e){if(e<=0||e>=1)return e<=0?"000000":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function J(n,e){let t=w[e]??e,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],o=a=>r.includes(a);return n?.colorScheme?o(t)?n.colorScheme[t]??W[t]??"000000":"000000":o(t)?W[t]??"000000":"000000"}function K(n){if(!n)return null;let e=n.toLowerCase();return w[n]??w[e]??null}function g(n,e,t="000000"){if(!n)return `#${t}`;if(n.auto)return `#${t}`;let r;if(n.themeColor){let o=K(n.themeColor);if(o?r=J(e,o):r=n.rgb??t,n.themeTint){let a=U(n.themeTint);r=q(r,a);}else if(n.themeShade){let a=U(n.themeShade);r=X(r,a);}}else n.rgb?r=n.rgb:r=t;return `#${r.toUpperCase().replace(/^#/,"")}`}function De(n){if(!n||n==="none")return "";let e=Y[n];return e?`#${e}`:""}function Be(n,e){return n?n.auto?"transparent":g(n,e):""}function ve(n,e){if(!n)return false;if(n.auto)return true;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3<20}function Oe(n,e){if(!n)return false;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3>235}function Ne(n,e){if(!n)return "#000000";let r=g(n,e).replace(/^#/,""),o=C(r);return (.299*o.r+.587*o.g+.114*o.b)/255>.5?"#000000":"#FFFFFF"}function Le(n){if(!n)return;let e=n.trim();if(e.toLowerCase()==="auto")return {auto:true};let t=K(e);if(t)return {themeColor:t};let r=e.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(a=>a+a).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Me(n,e,t){let r={themeColor:n};return e!==void 0&&e>0&&e<1&&(r.themeTint=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(r.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),r}function Ve(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function ze(n,e,t){let o=g(n,e).replace(/^#/,""),a=1-t/100;return `#${X(o,a)}`}function je(n,e,t){let o=g(n,e).replace(/^#/,""),a=t/100;return `#${q(o,a)}`}function We(n,e,t,r){let o=g(n,r).replace(/^#/,""),a=g(e,r).replace(/^#/,""),i=C(o),s=C(a),u={r:Math.round(i.r*(1-t)+s.r*t),g:Math.round(i.g*(1-t)+s.g*t),b:Math.round(i.b*(1-t)+s.b*t)};return `#${D(u.r,u.g,u.b)}`}function Ue(n,e,t){if(!n&&!e)return true;if(!n||!e)return false;let r=g(n,t).toUpperCase(),o=g(e,t).toUpperCase();return r===o}function Ge(n){return n/1440*96}function qe(n){return n/96*1440}function Xe(n){return n/914400*96}function Ke(n){return n/96*914400}function Ze(n){return n/914400*1440}function Ye(n){return n/1440*914400}function Je(n){return n/72*96}function Qe(n){return n/144*96}function et(n){return n/2}function tt(n){return n/576*96}function Q(n,e=2){let t=Math.pow(10,e);return Math.round(n*t)/t}function nt(n){return `${Q(n)}px`}var S=class n$1{constructor(e$1){e(this,"_document");e(this,"_pendingVariables");e$1 instanceof ArrayBuffer||ArrayBuffer.isView(e$1)?this._document={package:{document:{content:[]}},originalBuffer:e$1 instanceof ArrayBuffer?e$1:e$1.buffer}:this._document=e$1,this._pendingVariables={};}static async fromBuffer(e){let t=await l(e);return new n$1(t)}static fromDocument(e){return new n$1(e)}getDocument(){return this._document}getText(){let e=this._document.package.document;return this._getBodyText(e)}getFormattedText(){let e=[],t=this._document.package.document;for(let r of t.content)r.type==="paragraph"&&this._extractParagraphSegments(r,e);return e}getVariables(){return a(this._document)}getStyles(){let e=this._document.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}getPageCount(){let e=this.getWordCount();return Math.max(1,Math.ceil(e/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(e=true){let t=this.getText();return e?t.length:t.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(e=>e.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(e=>e.type==="table").length}getAgentContext(e=100){let t=this._document.package.document,r=t.content.filter(i=>i.type==="paragraph"),o=r.map((i,s)=>{let u=this._getParagraphText(i),c=i.formatting?.styleId;return {index:s,preview:u.slice(0,e),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!i.listRendering,isEmpty:u.trim().length===0}}),a=(t.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:o,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(e,t,r={}){let o={type:"insertText",position:e,text:t,formatting:r.formatting};return this._executeCommand(o)}replaceRange(e,t,r={}){let o={type:"replaceText",range:e,text:t,formatting:r.formatting};return this._executeCommand(o)}deleteRange(e){let t={type:"deleteText",range:e};return this._executeCommand(t)}applyFormatting(e,t){let r={type:"formatText",range:e,formatting:t};return this._executeCommand(r)}applyStyle(e,t){let r={type:"applyStyle",paragraphIndex:e,styleId:t};return this._executeCommand(r)}applyParagraphFormatting(e,t){let r={type:"formatParagraph",paragraphIndex:e,formatting:t};return this._executeCommand(r)}insertTable(e,t,r,o={}){let a={type:"insertTable",position:e,rows:t,columns:r,data:o.data,hasHeader:o.hasHeader};return this._executeCommand(a)}insertImage(e,t,r={}){let o={type:"insertImage",position:e,src:t,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(o)}insertHyperlink(e,t,r={}){let o={type:"insertHyperlink",range:e,url:t,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(o)}removeHyperlink(e){let t={type:"removeHyperlink",range:e};return this._executeCommand(t)}insertParagraphBreak(e){let t={type:"insertParagraphBreak",position:e};return this._executeCommand(t)}mergeParagraphs(e,t){let r={type:"mergeParagraphs",paragraphIndex:e,count:t};return this._executeCommand(r)}setVariable(e,t){return this._pendingVariables[e]=t,this}setVariables(e){for(let[t,r]of Object.entries(e))this._pendingVariables[t]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(e){let t={...this._pendingVariables,...e};if(Object.keys(t).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let o=n(r,t),a=await l(o),i=new n$1(a);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(e="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let t=await this.toBuffer();return new Blob([t],{type:e})}executeCommands(e){let t=b(this._document,e);return new n$1(t)}_executeCommand(e){let t=a$1(this._document,e),r=new n$1(t);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(e){let t=[];for(let r of e.content)r.type==="paragraph"?t.push(this._getParagraphText(r)):r.type==="table"&&t.push(this._getTableText(r));return t.join(`
|
|
1
|
+
import {a,n}from'./chunk-BQWGTYDH.js';import {d,e as e$1}from'./chunk-NI5OFVY2.js';import {l}from'./chunk-ZMWEAP5S.js';import {b,a as a$1}from'./chunk-AQ35GWDV.js';import {e}from'./chunk-3IYNTJO5.js';var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Y={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function U(n){if(!n)return 1;let e=parseInt(n,16);return isNaN(e)?1:e/255}function C(n){let e=n.padStart(6,"0").slice(0,6),t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return {r:isNaN(t)?0:t,g:isNaN(r)?0:r,b:isNaN(o)?0:o}}function D(n,e,t){let r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return `${r(n)}${r(e)}${r(t)}`.toUpperCase()}function $(n,e,t){n/=255,e/=255,t/=255;let r=Math.max(n,e,t),o=Math.min(n,e,t),a=(r+o)/2;if(r===o)return {h:0,s:0,l:a};let i=r-o,s=a>.5?i/(2-r-o):i/(r+o),u;switch(r){case n:u=((e-t)/i+(e<t?6:0))/6;break;case e:u=((t-n)/i+2)/6;break;case t:u=((n-e)/i+4)/6;break;default:u=0;}return {h:u*360,s,l:a}}function G(n,e,t){if(n=n/360,e===0){let i=Math.round(t*255);return {r:i,g:i,b:i}}let r=(i,s,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(s-i)*6*u:u<1/2?s:u<2/3?i+(s-i)*(2/3-u)*6:i),o=t<.5?t*(1+e):t+e-t*e,a=2*t-o;return {r:Math.round(r(a,o,n+1/3)*255),g:Math.round(r(a,o,n)*255),b:Math.round(r(a,o,n-1/3)*255)}}function q(n,e){if(e<=0||e>=1)return e>=1?"FFFFFF":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l+(1-r.l)*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function X(n,e){if(e<=0||e>=1)return e<=0?"000000":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function J(n,e){let t=w[e]??e,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],o=a=>r.includes(a);return n?.colorScheme?o(t)?n.colorScheme[t]??W[t]??"000000":"000000":o(t)?W[t]??"000000":"000000"}function K(n){if(!n)return null;let e=n.toLowerCase();return w[n]??w[e]??null}function g(n,e,t="000000"){if(!n)return `#${t}`;if(n.auto)return `#${t}`;let r;if(n.themeColor){let o=K(n.themeColor);if(o?r=J(e,o):r=n.rgb??t,n.themeTint){let a=U(n.themeTint);r=q(r,a);}else if(n.themeShade){let a=U(n.themeShade);r=X(r,a);}}else n.rgb?r=n.rgb:r=t;return `#${r.toUpperCase().replace(/^#/,"")}`}function De(n){if(!n||n==="none")return "";let e=Y[n];return e?`#${e}`:""}function Be(n,e){return n?n.auto?"transparent":g(n,e):""}function ve(n,e){if(!n)return false;if(n.auto)return true;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3<20}function Oe(n,e){if(!n)return false;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3>235}function Ne(n,e){if(!n)return "#000000";let r=g(n,e).replace(/^#/,""),o=C(r);return (.299*o.r+.587*o.g+.114*o.b)/255>.5?"#000000":"#FFFFFF"}function Le(n){if(!n)return;let e=n.trim();if(e.toLowerCase()==="auto")return {auto:true};let t=K(e);if(t)return {themeColor:t};let r=e.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(a=>a+a).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Me(n,e,t){let r={themeColor:n};return e!==void 0&&e>0&&e<1&&(r.themeTint=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(r.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),r}function Ve(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function ze(n,e,t){let o=g(n,e).replace(/^#/,""),a=1-t/100;return `#${X(o,a)}`}function je(n,e,t){let o=g(n,e).replace(/^#/,""),a=t/100;return `#${q(o,a)}`}function We(n,e,t,r){let o=g(n,r).replace(/^#/,""),a=g(e,r).replace(/^#/,""),i=C(o),s=C(a),u={r:Math.round(i.r*(1-t)+s.r*t),g:Math.round(i.g*(1-t)+s.g*t),b:Math.round(i.b*(1-t)+s.b*t)};return `#${D(u.r,u.g,u.b)}`}function Ue(n,e,t){if(!n&&!e)return true;if(!n||!e)return false;let r=g(n,t).toUpperCase(),o=g(e,t).toUpperCase();return r===o}function Ge(n){return n/1440*96}function qe(n){return n/96*1440}function Xe(n){return n/914400*96}function Ke(n){return n/96*914400}function Ze(n){return n/914400*1440}function Ye(n){return n/1440*914400}function Je(n){return n/72*96}function Qe(n){return n/144*96}function et(n){return n/2}function tt(n){return n/576*96}function Q(n,e=2){let t=Math.pow(10,e);return Math.round(n*t)/t}function nt(n){return `${Q(n)}px`}var S=class n$1{constructor(e$1){e(this,"_document");e(this,"_pendingVariables");e$1 instanceof ArrayBuffer||ArrayBuffer.isView(e$1)?this._document={package:{document:{content:[]}},originalBuffer:e$1 instanceof ArrayBuffer?e$1:e$1.buffer}:this._document=e$1,this._pendingVariables={};}static async fromBuffer(e){let t=await l(e);return new n$1(t)}static fromDocument(e){return new n$1(e)}getDocument(){return this._document}getText(){let e=this._document.package.document;return this._getBodyText(e)}getFormattedText(){let e=[],t=this._document.package.document;for(let r of t.content)r.type==="paragraph"&&this._extractParagraphSegments(r,e);return e}getVariables(){return a(this._document)}getStyles(){let e=this._document.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}getPageCount(){let e=this.getWordCount();return Math.max(1,Math.ceil(e/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(e=true){let t=this.getText();return e?t.length:t.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(e=>e.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(e=>e.type==="table").length}getAgentContext(e=100){let t=this._document.package.document,r=t.content.filter(i=>i.type==="paragraph"),o=r.map((i,s)=>{let u=this._getParagraphText(i),c=i.formatting?.styleId;return {index:s,preview:u.slice(0,e),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!i.listRendering,isEmpty:u.trim().length===0}}),a=(t.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:o,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(e,t,r={}){let o={type:"insertText",position:e,text:t,formatting:r.formatting};return this._executeCommand(o)}replaceRange(e,t,r={}){let o={type:"replaceText",range:e,text:t,formatting:r.formatting};return this._executeCommand(o)}deleteRange(e){let t={type:"deleteText",range:e};return this._executeCommand(t)}applyFormatting(e,t){let r={type:"formatText",range:e,formatting:t};return this._executeCommand(r)}applyStyle(e,t){let r={type:"applyStyle",paragraphIndex:e,styleId:t};return this._executeCommand(r)}applyParagraphFormatting(e,t){let r={type:"formatParagraph",paragraphIndex:e,formatting:t};return this._executeCommand(r)}insertTable(e,t,r,o={}){let a={type:"insertTable",position:e,rows:t,columns:r,data:o.data,hasHeader:o.hasHeader};return this._executeCommand(a)}insertImage(e,t,r={}){let o={type:"insertImage",position:e,src:t,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(o)}insertHyperlink(e,t,r={}){let o={type:"insertHyperlink",range:e,url:t,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(o)}removeHyperlink(e){let t={type:"removeHyperlink",range:e};return this._executeCommand(t)}insertParagraphBreak(e){let t={type:"insertParagraphBreak",position:e};return this._executeCommand(t)}mergeParagraphs(e,t){let r={type:"mergeParagraphs",paragraphIndex:e,count:t};return this._executeCommand(r)}setVariable(e,t){return this._pendingVariables[e]=t,this}setVariables(e){for(let[t,r]of Object.entries(e))this._pendingVariables[t]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(e){let t={...this._pendingVariables,...e};if(Object.keys(t).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let o=n(r,t),a=await l(o),i=new n$1(a);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(e="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let t=await this.toBuffer();return new Blob([t],{type:e})}executeCommands(e){let t=b(this._document,e);return new n$1(t)}_executeCommand(e){let t=a$1(this._document,e),r=new n$1(t);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(e){let t=[];for(let r of e.content)r.type==="paragraph"?t.push(this._getParagraphText(r)):r.type==="table"&&t.push(this._getTableText(r));return t.join(`
|
|
2
2
|
`)}_getParagraphText(e){let t=[];for(let r of e.content)r.type==="run"?t.push(this._getRunText(r)):r.type==="hyperlink"&&t.push(this._getHyperlinkText(r));return t.join("")}_getRunText(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}_getHyperlinkText(e){let t=[];for(let r of e.children)r.type==="run"&&t.push(this._getRunText(r));return t.join("")}_getTableText(e){let t=[];for(let r of e.rows)for(let o of r.cells)for(let a of o.content)a.type==="paragraph"&&t.push(this._getParagraphText(a));return t.join(" ")}_extractParagraphSegments(e,t){for(let r of e.content)if(r.type==="run"){let o=this._getRunText(r);o&&t.push({text:o,formatting:r.formatting});}else if(r.type==="hyperlink"){let o=r.href||"";for(let a of r.children)if(a.type==="run"){let i=this._getRunText(a);i&&t.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:o});}}}_parseHeadingLevel(e){if(!e)return;let t=e.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}_hasImages(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="run"){for(let o of r.content)if(o.type==="drawing")return true}}return false}_hasHyperlinks(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="hyperlink")return true}return false}};async function ct(n){return S.fromBuffer(n)}function pt(n){return S.fromDocument(n)}function ee(n,e={}){let{outlineMaxChars:t=100,maxOutlineParagraphs:r=50}=e,o=n.package.document,a$1=o.content.filter(y=>y.type==="paragraph"),i=te(a$1,t,r),s=a(n),u=ne(n),c=re(o),p=oe(o),x=ae(o),d=o.content.some(y=>y.type==="table"),b=ue(o),l=ce(o);return {paragraphCount:a$1.length,wordCount:p,characterCount:x,variables:s,variableCount:s.length,availableStyles:u,outline:i,sections:c,hasTables:d,hasImages:b,hasHyperlinks:l}}function dt(n,e,t={}){let{contextChars:r=200,includeSuggestions:o=true}=t,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[e.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${e.start.paragraphIndex}`);let u=m(s),c="";if(e.start.paragraphIndex===e.end.paragraphIndex)c=u.slice(e.start.offset,e.end.offset);else {let f=[];for(let P=e.start.paragraphIndex;P<=e.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===e.start.paragraphIndex?f.push(R.slice(e.start.offset)):P===e.end.paragraphIndex?f.push(R.slice(0,e.end.offset)):f.push(R);}c=f.join(`
|
|
3
3
|
`);}let p=me(i,e.start.paragraphIndex,e.start.offset,r),x=ge(i,e.end.paragraphIndex,e.end.offset,r),d=de(s,e.start.offset),b=s.formatting||{},l={index:e.start.paragraphIndex,fullText:u,style:s.formatting?.styleId,wordCount:B(u)},y=false,_=fe(s,e.start.offset),F=o?he(c):[];return {selectedText:c,range:e,formatting:d,paragraphFormatting:b,textBefore:p,textAfter:x,paragraph:l,inTable:y,inHyperlink:_,suggestedActions:F}}function Z(n){let e=ee(n,{outlineMaxChars:50,maxOutlineParagraphs:10}),t=[`Document with ${e.paragraphCount} paragraphs, ${e.wordCount} words.`];e.hasTables&&t.push("Contains tables."),e.hasImages&&t.push("Contains images."),e.hasHyperlinks&&t.push("Contains hyperlinks."),e.variableCount>0&&t.push(`Has ${e.variableCount} template variables: ${e.variables.join(", ")}`);let r=e.outline.filter(o=>o.isHeading);if(r.length>0){t.push(`
|
|
4
4
|
Headings:`);for(let o of r.slice(0,5)){let a=o.headingLevel||1;t.push(`${" ".repeat(a-1)}- ${o.preview}`);}r.length>5&&t.push(` ... and ${r.length-5} more headings`);}return t.join(" ")}function te(n,e,t){let r=[];for(let o=0;o<Math.min(n.length,t);o++){let a=n[o],i=m(a),s=a.formatting?.styleId;r.push({index:o,preview:i.slice(0,e),style:s,isHeading:pe(s),headingLevel:le(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return r}function ne(n){let e=n.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}function re(n){return n.sections?n.sections.map((e,t)=>({index:t,paragraphCount:e.content?.length||0,pageSize:e.properties?.pageWidth&&e.properties?.pageHeight?{width:e.properties.pageWidth,height:e.properties.pageHeight}:void 0,isLandscape:e.properties?.orientation==="landscape",hasHeader:!!e.properties?.headerReferences?.length,hasFooter:!!e.properties?.footerReferences?.length})):[]}function oe(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=B(r);}else t.type==="table"&&(e+=ie(t));return e}function B(n){return n.split(/\s+/).filter(t=>t.length>0).length}function ae(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=r.length;}else t.type==="table"&&(e+=se(t));return e}function ie(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=B(a);}return e}function se(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=a.length;}return e}function m(n){let e=[];for(let t of n.content)t.type==="run"?e.push(A(t)):t.type==="hyperlink"&&e.push(v(t));return e.join("")}function A(n){return n.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function v(n){let e=[];for(let t of n.children)t.type==="run"&&e.push(A(t));return e.join("")}function ue(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="run"){for(let r of t.content)if(r.type==="drawing")return true}}return false}function ce(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="hyperlink")return true}return false}function pe(n){return n?n.toLowerCase().includes("heading"):false}function le(n){if(!n)return;let e=n.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function me(n,e,t,r){let o=[],a=0,i=n[e];if(i){let c=m(i).slice(0,t);o.unshift(c),a+=c.length;}for(let u=e-1;u>=0&&a<r;u--){let c=n[u];if(!c)continue;let p=m(c);o.unshift(p),a+=p.length;}let s=o.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var chunkCM5WP7HZ_cjs=require('./chunk-CM5WP7HZ.cjs'),chunkRGYAPHXT_cjs=require('./chunk-RGYAPHXT.cjs'),chunkG4AXMTQY_cjs=require('./chunk-G4AXMTQY.cjs'),chunkFOU7PS3K_cjs=require('./chunk-FOU7PS3K.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs');var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Y={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function U(n){if(!n)return 1;let e=parseInt(n,16);return isNaN(e)?1:e/255}function C(n){let e=n.padStart(6,"0").slice(0,6),t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return {r:isNaN(t)?0:t,g:isNaN(r)?0:r,b:isNaN(o)?0:o}}function D(n,e,t){let r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return `${r(n)}${r(e)}${r(t)}`.toUpperCase()}function $(n,e,t){n/=255,e/=255,t/=255;let r=Math.max(n,e,t),o=Math.min(n,e,t),a=(r+o)/2;if(r===o)return {h:0,s:0,l:a};let i=r-o,s=a>.5?i/(2-r-o):i/(r+o),u;switch(r){case n:u=((e-t)/i+(e<t?6:0))/6;break;case e:u=((t-n)/i+2)/6;break;case t:u=((n-e)/i+4)/6;break;default:u=0;}return {h:u*360,s,l:a}}function G(n,e,t){if(n=n/360,e===0){let i=Math.round(t*255);return {r:i,g:i,b:i}}let r=(i,s,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(s-i)*6*u:u<1/2?s:u<2/3?i+(s-i)*(2/3-u)*6:i),o=t<.5?t*(1+e):t+e-t*e,a=2*t-o;return {r:Math.round(r(a,o,n+1/3)*255),g:Math.round(r(a,o,n)*255),b:Math.round(r(a,o,n-1/3)*255)}}function q(n,e){if(e<=0||e>=1)return e>=1?"FFFFFF":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l+(1-r.l)*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function X(n,e){if(e<=0||e>=1)return e<=0?"000000":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function J(n,e){let t=w[e]??e,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],o=a=>r.includes(a);return n?.colorScheme?o(t)?n.colorScheme[t]??W[t]??"000000":"000000":o(t)?W[t]??"000000":"000000"}function K(n){if(!n)return null;let e=n.toLowerCase();return w[n]??w[e]??null}function g(n,e,t="000000"){if(!n)return `#${t}`;if(n.auto)return `#${t}`;let r;if(n.themeColor){let o=K(n.themeColor);if(o?r=J(e,o):r=n.rgb??t,n.themeTint){let a=U(n.themeTint);r=q(r,a);}else if(n.themeShade){let a=U(n.themeShade);r=X(r,a);}}else n.rgb?r=n.rgb:r=t;return `#${r.toUpperCase().replace(/^#/,"")}`}function De(n){if(!n||n==="none")return "";let e=Y[n];return e?`#${e}`:""}function Be(n,e){return n?n.auto?"transparent":g(n,e):""}function ve(n,e){if(!n)return false;if(n.auto)return true;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3<20}function Oe(n,e){if(!n)return false;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3>235}function Ne(n,e){if(!n)return "#000000";let r=g(n,e).replace(/^#/,""),o=C(r);return (.299*o.r+.587*o.g+.114*o.b)/255>.5?"#000000":"#FFFFFF"}function Le(n){if(!n)return;let e=n.trim();if(e.toLowerCase()==="auto")return {auto:true};let t=K(e);if(t)return {themeColor:t};let r=e.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(a=>a+a).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Me(n,e,t){let r={themeColor:n};return e!==void 0&&e>0&&e<1&&(r.themeTint=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(r.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),r}function Ve(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function ze(n,e,t){let o=g(n,e).replace(/^#/,""),a=1-t/100;return `#${X(o,a)}`}function je(n,e,t){let o=g(n,e).replace(/^#/,""),a=t/100;return `#${q(o,a)}`}function We(n,e,t,r){let o=g(n,r).replace(/^#/,""),a=g(e,r).replace(/^#/,""),i=C(o),s=C(a),u={r:Math.round(i.r*(1-t)+s.r*t),g:Math.round(i.g*(1-t)+s.g*t),b:Math.round(i.b*(1-t)+s.b*t)};return `#${D(u.r,u.g,u.b)}`}function Ue(n,e,t){if(!n&&!e)return true;if(!n||!e)return false;let r=g(n,t).toUpperCase(),o=g(e,t).toUpperCase();return r===o}function Ge(n){return n/1440*96}function qe(n){return n/96*1440}function Xe(n){return n/914400*96}function Ke(n){return n/96*914400}function Ze(n){return n/914400*1440}function Ye(n){return n/1440*914400}function Je(n){return n/72*96}function Qe(n){return n/144*96}function et(n){return n/2}function tt(n){return n/576*96}function Q(n,e=2){let t=Math.pow(10,e);return Math.round(n*t)/t}function nt(n){return `${Q(n)}px`}var S=class n{constructor(e){chunkRTESADL3_cjs.e(this,"_document");chunkRTESADL3_cjs.e(this,"_pendingVariables");e instanceof ArrayBuffer||ArrayBuffer.isView(e)?this._document={package:{document:{content:[]}},originalBuffer:e instanceof ArrayBuffer?e:e.buffer}:this._document=e,this._pendingVariables={};}static async fromBuffer(e){let t=await chunkG4AXMTQY_cjs.l(e);return new n(t)}static fromDocument(e){return new n(e)}getDocument(){return this._document}getText(){let e=this._document.package.document;return this._getBodyText(e)}getFormattedText(){let e=[],t=this._document.package.document;for(let r of t.content)r.type==="paragraph"&&this._extractParagraphSegments(r,e);return e}getVariables(){return chunkCM5WP7HZ_cjs.a(this._document)}getStyles(){let e=this._document.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}getPageCount(){let e=this.getWordCount();return Math.max(1,Math.ceil(e/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(e=true){let t=this.getText();return e?t.length:t.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(e=>e.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(e=>e.type==="table").length}getAgentContext(e=100){let t=this._document.package.document,r=t.content.filter(i=>i.type==="paragraph"),o=r.map((i,s)=>{let u=this._getParagraphText(i),c=i.formatting?.styleId;return {index:s,preview:u.slice(0,e),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!i.listRendering,isEmpty:u.trim().length===0}}),a=(t.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:o,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(e,t,r={}){let o={type:"insertText",position:e,text:t,formatting:r.formatting};return this._executeCommand(o)}replaceRange(e,t,r={}){let o={type:"replaceText",range:e,text:t,formatting:r.formatting};return this._executeCommand(o)}deleteRange(e){let t={type:"deleteText",range:e};return this._executeCommand(t)}applyFormatting(e,t){let r={type:"formatText",range:e,formatting:t};return this._executeCommand(r)}applyStyle(e,t){let r={type:"applyStyle",paragraphIndex:e,styleId:t};return this._executeCommand(r)}applyParagraphFormatting(e,t){let r={type:"formatParagraph",paragraphIndex:e,formatting:t};return this._executeCommand(r)}insertTable(e,t,r,o={}){let a={type:"insertTable",position:e,rows:t,columns:r,data:o.data,hasHeader:o.hasHeader};return this._executeCommand(a)}insertImage(e,t,r={}){let o={type:"insertImage",position:e,src:t,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(o)}insertHyperlink(e,t,r={}){let o={type:"insertHyperlink",range:e,url:t,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(o)}removeHyperlink(e){let t={type:"removeHyperlink",range:e};return this._executeCommand(t)}insertParagraphBreak(e){let t={type:"insertParagraphBreak",position:e};return this._executeCommand(t)}mergeParagraphs(e,t){let r={type:"mergeParagraphs",paragraphIndex:e,count:t};return this._executeCommand(r)}setVariable(e,t){return this._pendingVariables[e]=t,this}setVariables(e){for(let[t,r]of Object.entries(e))this._pendingVariables[t]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(e){let t={...this._pendingVariables,...e};if(Object.keys(t).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let o=chunkCM5WP7HZ_cjs.n(r,t),a=await chunkG4AXMTQY_cjs.l(o),i=new n(a);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?chunkRGYAPHXT_cjs.d(this._document):chunkRGYAPHXT_cjs.e(this._document)}async toBlob(e="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let t=await this.toBuffer();return new Blob([t],{type:e})}executeCommands(e){let t=chunkFOU7PS3K_cjs.b(this._document,e);return new n(t)}_executeCommand(e){let t=chunkFOU7PS3K_cjs.a(this._document,e),r=new n(t);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(e){let t=[];for(let r of e.content)r.type==="paragraph"?t.push(this._getParagraphText(r)):r.type==="table"&&t.push(this._getTableText(r));return t.join(`
|
|
2
|
-
`)}_getParagraphText(e){let t=[];for(let r of e.content)r.type==="run"?t.push(this._getRunText(r)):r.type==="hyperlink"&&t.push(this._getHyperlinkText(r));return t.join("")}_getRunText(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}_getHyperlinkText(e){let t=[];for(let r of e.children)r.type==="run"&&t.push(this._getRunText(r));return t.join("")}_getTableText(e){let t=[];for(let r of e.rows)for(let o of r.cells)for(let a of o.content)a.type==="paragraph"&&t.push(this._getParagraphText(a));return t.join(" ")}_extractParagraphSegments(e,t){for(let r of e.content)if(r.type==="run"){let o=this._getRunText(r);o&&t.push({text:o,formatting:r.formatting});}else if(r.type==="hyperlink"){let o=r.href||"";for(let a of r.children)if(a.type==="run"){let i=this._getRunText(a);i&&t.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:o});}}}_parseHeadingLevel(e){if(!e)return;let t=e.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}_hasImages(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="run"){for(let o of r.content)if(o.type==="drawing")return true}}return false}_hasHyperlinks(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="hyperlink")return true}return false}};async function ct(n){return S.fromBuffer(n)}function pt(n){return S.fromDocument(n)}function ee(n,e={}){let{outlineMaxChars:t=100,maxOutlineParagraphs:r=50}=e,o=n.package.document,a=o.content.filter(y=>y.type==="paragraph"),i=te(a,t,r),s=
|
|
1
|
+
'use strict';var chunkEUHVOGCB_cjs=require('./chunk-EUHVOGCB.cjs'),chunkRGYAPHXT_cjs=require('./chunk-RGYAPHXT.cjs'),chunkFFPSMP4Q_cjs=require('./chunk-FFPSMP4Q.cjs'),chunkFOU7PS3K_cjs=require('./chunk-FOU7PS3K.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs');var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},Y={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},w={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function U(n){if(!n)return 1;let e=parseInt(n,16);return isNaN(e)?1:e/255}function C(n){let e=n.padStart(6,"0").slice(0,6),t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return {r:isNaN(t)?0:t,g:isNaN(r)?0:r,b:isNaN(o)?0:o}}function D(n,e,t){let r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return `${r(n)}${r(e)}${r(t)}`.toUpperCase()}function $(n,e,t){n/=255,e/=255,t/=255;let r=Math.max(n,e,t),o=Math.min(n,e,t),a=(r+o)/2;if(r===o)return {h:0,s:0,l:a};let i=r-o,s=a>.5?i/(2-r-o):i/(r+o),u;switch(r){case n:u=((e-t)/i+(e<t?6:0))/6;break;case e:u=((t-n)/i+2)/6;break;case t:u=((n-e)/i+4)/6;break;default:u=0;}return {h:u*360,s,l:a}}function G(n,e,t){if(n=n/360,e===0){let i=Math.round(t*255);return {r:i,g:i,b:i}}let r=(i,s,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(s-i)*6*u:u<1/2?s:u<2/3?i+(s-i)*(2/3-u)*6:i),o=t<.5?t*(1+e):t+e-t*e,a=2*t-o;return {r:Math.round(r(a,o,n+1/3)*255),g:Math.round(r(a,o,n)*255),b:Math.round(r(a,o,n-1/3)*255)}}function q(n,e){if(e<=0||e>=1)return e>=1?"FFFFFF":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l+(1-r.l)*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function X(n,e){if(e<=0||e>=1)return e<=0?"000000":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function J(n,e){let t=w[e]??e,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],o=a=>r.includes(a);return n?.colorScheme?o(t)?n.colorScheme[t]??W[t]??"000000":"000000":o(t)?W[t]??"000000":"000000"}function K(n){if(!n)return null;let e=n.toLowerCase();return w[n]??w[e]??null}function g(n,e,t="000000"){if(!n)return `#${t}`;if(n.auto)return `#${t}`;let r;if(n.themeColor){let o=K(n.themeColor);if(o?r=J(e,o):r=n.rgb??t,n.themeTint){let a=U(n.themeTint);r=q(r,a);}else if(n.themeShade){let a=U(n.themeShade);r=X(r,a);}}else n.rgb?r=n.rgb:r=t;return `#${r.toUpperCase().replace(/^#/,"")}`}function De(n){if(!n||n==="none")return "";let e=Y[n];return e?`#${e}`:""}function Be(n,e){return n?n.auto?"transparent":g(n,e):""}function ve(n,e){if(!n)return false;if(n.auto)return true;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3<20}function Oe(n,e){if(!n)return false;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3>235}function Ne(n,e){if(!n)return "#000000";let r=g(n,e).replace(/^#/,""),o=C(r);return (.299*o.r+.587*o.g+.114*o.b)/255>.5?"#000000":"#FFFFFF"}function Le(n){if(!n)return;let e=n.trim();if(e.toLowerCase()==="auto")return {auto:true};let t=K(e);if(t)return {themeColor:t};let r=e.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(a=>a+a).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Me(n,e,t){let r={themeColor:n};return e!==void 0&&e>0&&e<1&&(r.themeTint=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(r.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),r}function Ve(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function ze(n,e,t){let o=g(n,e).replace(/^#/,""),a=1-t/100;return `#${X(o,a)}`}function je(n,e,t){let o=g(n,e).replace(/^#/,""),a=t/100;return `#${q(o,a)}`}function We(n,e,t,r){let o=g(n,r).replace(/^#/,""),a=g(e,r).replace(/^#/,""),i=C(o),s=C(a),u={r:Math.round(i.r*(1-t)+s.r*t),g:Math.round(i.g*(1-t)+s.g*t),b:Math.round(i.b*(1-t)+s.b*t)};return `#${D(u.r,u.g,u.b)}`}function Ue(n,e,t){if(!n&&!e)return true;if(!n||!e)return false;let r=g(n,t).toUpperCase(),o=g(e,t).toUpperCase();return r===o}function Ge(n){return n/1440*96}function qe(n){return n/96*1440}function Xe(n){return n/914400*96}function Ke(n){return n/96*914400}function Ze(n){return n/914400*1440}function Ye(n){return n/1440*914400}function Je(n){return n/72*96}function Qe(n){return n/144*96}function et(n){return n/2}function tt(n){return n/576*96}function Q(n,e=2){let t=Math.pow(10,e);return Math.round(n*t)/t}function nt(n){return `${Q(n)}px`}var S=class n{constructor(e){chunkRTESADL3_cjs.e(this,"_document");chunkRTESADL3_cjs.e(this,"_pendingVariables");e instanceof ArrayBuffer||ArrayBuffer.isView(e)?this._document={package:{document:{content:[]}},originalBuffer:e instanceof ArrayBuffer?e:e.buffer}:this._document=e,this._pendingVariables={};}static async fromBuffer(e){let t=await chunkFFPSMP4Q_cjs.l(e);return new n(t)}static fromDocument(e){return new n(e)}getDocument(){return this._document}getText(){let e=this._document.package.document;return this._getBodyText(e)}getFormattedText(){let e=[],t=this._document.package.document;for(let r of t.content)r.type==="paragraph"&&this._extractParagraphSegments(r,e);return e}getVariables(){return chunkEUHVOGCB_cjs.a(this._document)}getStyles(){let e=this._document.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}getPageCount(){let e=this.getWordCount();return Math.max(1,Math.ceil(e/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(e=true){let t=this.getText();return e?t.length:t.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(e=>e.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(e=>e.type==="table").length}getAgentContext(e=100){let t=this._document.package.document,r=t.content.filter(i=>i.type==="paragraph"),o=r.map((i,s)=>{let u=this._getParagraphText(i),c=i.formatting?.styleId;return {index:s,preview:u.slice(0,e),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!i.listRendering,isEmpty:u.trim().length===0}}),a=(t.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:o,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(e,t,r={}){let o={type:"insertText",position:e,text:t,formatting:r.formatting};return this._executeCommand(o)}replaceRange(e,t,r={}){let o={type:"replaceText",range:e,text:t,formatting:r.formatting};return this._executeCommand(o)}deleteRange(e){let t={type:"deleteText",range:e};return this._executeCommand(t)}applyFormatting(e,t){let r={type:"formatText",range:e,formatting:t};return this._executeCommand(r)}applyStyle(e,t){let r={type:"applyStyle",paragraphIndex:e,styleId:t};return this._executeCommand(r)}applyParagraphFormatting(e,t){let r={type:"formatParagraph",paragraphIndex:e,formatting:t};return this._executeCommand(r)}insertTable(e,t,r,o={}){let a={type:"insertTable",position:e,rows:t,columns:r,data:o.data,hasHeader:o.hasHeader};return this._executeCommand(a)}insertImage(e,t,r={}){let o={type:"insertImage",position:e,src:t,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(o)}insertHyperlink(e,t,r={}){let o={type:"insertHyperlink",range:e,url:t,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(o)}removeHyperlink(e){let t={type:"removeHyperlink",range:e};return this._executeCommand(t)}insertParagraphBreak(e){let t={type:"insertParagraphBreak",position:e};return this._executeCommand(t)}mergeParagraphs(e,t){let r={type:"mergeParagraphs",paragraphIndex:e,count:t};return this._executeCommand(r)}setVariable(e,t){return this._pendingVariables[e]=t,this}setVariables(e){for(let[t,r]of Object.entries(e))this._pendingVariables[t]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(e){let t={...this._pendingVariables,...e};if(Object.keys(t).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let o=chunkEUHVOGCB_cjs.n(r,t),a=await chunkFFPSMP4Q_cjs.l(o),i=new n(a);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?chunkRGYAPHXT_cjs.d(this._document):chunkRGYAPHXT_cjs.e(this._document)}async toBlob(e="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let t=await this.toBuffer();return new Blob([t],{type:e})}executeCommands(e){let t=chunkFOU7PS3K_cjs.b(this._document,e);return new n(t)}_executeCommand(e){let t=chunkFOU7PS3K_cjs.a(this._document,e),r=new n(t);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(e){let t=[];for(let r of e.content)r.type==="paragraph"?t.push(this._getParagraphText(r)):r.type==="table"&&t.push(this._getTableText(r));return t.join(`
|
|
2
|
+
`)}_getParagraphText(e){let t=[];for(let r of e.content)r.type==="run"?t.push(this._getRunText(r)):r.type==="hyperlink"&&t.push(this._getHyperlinkText(r));return t.join("")}_getRunText(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}_getHyperlinkText(e){let t=[];for(let r of e.children)r.type==="run"&&t.push(this._getRunText(r));return t.join("")}_getTableText(e){let t=[];for(let r of e.rows)for(let o of r.cells)for(let a of o.content)a.type==="paragraph"&&t.push(this._getParagraphText(a));return t.join(" ")}_extractParagraphSegments(e,t){for(let r of e.content)if(r.type==="run"){let o=this._getRunText(r);o&&t.push({text:o,formatting:r.formatting});}else if(r.type==="hyperlink"){let o=r.href||"";for(let a of r.children)if(a.type==="run"){let i=this._getRunText(a);i&&t.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:o});}}}_parseHeadingLevel(e){if(!e)return;let t=e.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}_hasImages(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="run"){for(let o of r.content)if(o.type==="drawing")return true}}return false}_hasHyperlinks(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="hyperlink")return true}return false}};async function ct(n){return S.fromBuffer(n)}function pt(n){return S.fromDocument(n)}function ee(n,e={}){let{outlineMaxChars:t=100,maxOutlineParagraphs:r=50}=e,o=n.package.document,a=o.content.filter(y=>y.type==="paragraph"),i=te(a,t,r),s=chunkEUHVOGCB_cjs.a(n),u=ne(n),c=re(o),p=oe(o),x=ae(o),d=o.content.some(y=>y.type==="table"),b=ue(o),l=ce(o);return {paragraphCount:a.length,wordCount:p,characterCount:x,variables:s,variableCount:s.length,availableStyles:u,outline:i,sections:c,hasTables:d,hasImages:b,hasHyperlinks:l}}function dt(n,e,t={}){let{contextChars:r=200,includeSuggestions:o=true}=t,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[e.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${e.start.paragraphIndex}`);let u=m(s),c="";if(e.start.paragraphIndex===e.end.paragraphIndex)c=u.slice(e.start.offset,e.end.offset);else {let f=[];for(let P=e.start.paragraphIndex;P<=e.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===e.start.paragraphIndex?f.push(R.slice(e.start.offset)):P===e.end.paragraphIndex?f.push(R.slice(0,e.end.offset)):f.push(R);}c=f.join(`
|
|
3
3
|
`);}let p=me(i,e.start.paragraphIndex,e.start.offset,r),x=ge(i,e.end.paragraphIndex,e.end.offset,r),d=de(s,e.start.offset),b=s.formatting||{},l={index:e.start.paragraphIndex,fullText:u,style:s.formatting?.styleId,wordCount:B(u)},y=false,_=fe(s,e.start.offset),F=o?he(c):[];return {selectedText:c,range:e,formatting:d,paragraphFormatting:b,textBefore:p,textAfter:x,paragraph:l,inTable:y,inHyperlink:_,suggestedActions:F}}function Z(n){let e=ee(n,{outlineMaxChars:50,maxOutlineParagraphs:10}),t=[`Document with ${e.paragraphCount} paragraphs, ${e.wordCount} words.`];e.hasTables&&t.push("Contains tables."),e.hasImages&&t.push("Contains images."),e.hasHyperlinks&&t.push("Contains hyperlinks."),e.variableCount>0&&t.push(`Has ${e.variableCount} template variables: ${e.variables.join(", ")}`);let r=e.outline.filter(o=>o.isHeading);if(r.length>0){t.push(`
|
|
4
4
|
Headings:`);for(let o of r.slice(0,5)){let a=o.headingLevel||1;t.push(`${" ".repeat(a-1)}- ${o.preview}`);}r.length>5&&t.push(` ... and ${r.length-5} more headings`);}return t.join(" ")}function te(n,e,t){let r=[];for(let o=0;o<Math.min(n.length,t);o++){let a=n[o],i=m(a),s=a.formatting?.styleId;r.push({index:o,preview:i.slice(0,e),style:s,isHeading:pe(s),headingLevel:le(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return r}function ne(n){let e=n.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}function re(n){return n.sections?n.sections.map((e,t)=>({index:t,paragraphCount:e.content?.length||0,pageSize:e.properties?.pageWidth&&e.properties?.pageHeight?{width:e.properties.pageWidth,height:e.properties.pageHeight}:void 0,isLandscape:e.properties?.orientation==="landscape",hasHeader:!!e.properties?.headerReferences?.length,hasFooter:!!e.properties?.footerReferences?.length})):[]}function oe(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=B(r);}else t.type==="table"&&(e+=ie(t));return e}function B(n){return n.split(/\s+/).filter(t=>t.length>0).length}function ae(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=r.length;}else t.type==="table"&&(e+=se(t));return e}function ie(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=B(a);}return e}function se(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=a.length;}return e}function m(n){let e=[];for(let t of n.content)t.type==="run"?e.push(A(t)):t.type==="hyperlink"&&e.push(v(t));return e.join("")}function A(n){return n.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function v(n){let e=[];for(let t of n.children)t.type==="run"&&e.push(A(t));return e.join("")}function ue(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="run"){for(let r of t.content)if(r.type==="drawing")return true}}return false}function ce(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="hyperlink")return true}return false}function pe(n){return n?n.toLowerCase().includes("heading"):false}function le(n){if(!n)return;let e=n.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function me(n,e,t,r){let o=[],a=0,i=n[e];if(i){let c=m(i).slice(0,t);o.unshift(c),a+=c.length;}for(let u=e-1;u>=0&&a<r;u--){let c=n[u];if(!c)continue;let p=m(c);o.unshift(p),a+=p.length;}let s=o.join(`
|
|
5
5
|
`);return s.length>r?"..."+s.slice(-r):s}function ge(n,e,t,r){let o=[],a=0,i=n[e];if(i){let c=m(i).slice(t);o.push(c),a+=c.length;}for(let u=e+1;u<n.length&&a<r;u++){let c=n[u];if(!c)continue;let p=m(c);o.push(p),a+=p.length;}let s=o.join(`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFFPSMP4Q_cjs=require('./chunk-FFPSMP4Q.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs'),g=require('pizzip'),b=require('docxtemplater');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);var b__default=/*#__PURE__*/_interopDefault(b);function J(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function v(e,t){let r=t,{position:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.paragraphIndex} out of bounds`);let c=s[o.paragraphIndex],l=`{{${n}}}`;return k(c,o.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function w(e,t){let r=t,{range:o,variableName:n}=r,a=JSON.parse(JSON.stringify(e)),s=a.package.document.content.filter(u=>u.type==="paragraph");if(o.start.paragraphIndex!==o.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(o.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${o.start.paragraphIndex} out of bounds`);let c=s[o.start.paragraphIndex];Z(c,o.start.offset,o.end.offset);let l=`{{${n}}}`;return k(c,o.start.offset,l),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(n)||a.templateVariables.push(n),a}function k(e,t,r){let o=0,n=false;for(let a=0;a<e.content.length;a++){let i=e.content[a];if(i.type==="run"){let s=T(i),c=o,l=o+s.length;if(!n&&t>=c&&t<=l){let u=t-c,y=s.slice(0,u),m=s.slice(u),p=[];for(let d=0;d<a;d++)p.push(e.content[d]);y&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:y}]}),p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:r}]}),m&&p.push({type:"run",formatting:i.formatting,content:[{type:"text",text:m}]});for(let d=a+1;d<e.content.length;d++)p.push(e.content[d]);e.content=p,n=true;break}o=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(o+=T(s).length);}n||e.content.push({type:"run",content:[{type:"text",text:r}]});}function Z(e,t,r){let o=[],n=0;for(let a of e.content)if(a.type==="run"){let i=T(a),s=n,c=n+i.length;if(c<=t||s>=r)o.push(a);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>r&&(l+=i.slice(r-s)),l.length>0&&o.push({type:"run",formatting:a.formatting,content:[{type:"text",text:l}]});}n=c;}else o.push(a);e.content=o;}function T(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function U(e){return V(e).variables}function V(e){let t=[],r={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let n=j(e.package.document);n.forEach(a=>{t.push({name:a,location:"body"});}),r.body=Array.from(new Set(n)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((n,a)=>{n.properties.headerReferences&&n.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let n=A(e.package.footnotes);n.forEach(a=>{t.push({name:a,location:"footnote"});}),r.footnotes=Array.from(new Set(n)).sort();}if(e.package?.endnotes){let n=A(e.package.endnotes);n.forEach(a=>{t.push({name:a,location:"endnote"});}),r.endnotes=Array.from(new Set(n)).sort();}e.templateVariables&&e.templateVariables.forEach(n=>{t.some(a=>a.name===n)||t.push({name:n,location:"body"});});let o=new Set;return t.forEach(n=>o.add(n.name)),{variables:Array.from(o).sort(),totalOccurrences:t.length,byLocation:r,occurrences:t}}function j(e){let t=[];if(e.content&&t.push(...I(e.content)),e.sections)for(let r of e.sections)r.content&&t.push(...I(r.content));return t}function I(e){let t=[];for(let r of e)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function R(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="run"?t.push(...f(r)):r.type==="hyperlink"?t.push(...q(r)):r.type==="simpleField"?t.push(...W(r)):r.type==="complexField"&&t.push(...G(r));return t}function f(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="text"&&r.text&&t.push(...B(r.text));return t}function q(e){let t=[];if(!e.children)return t;for(let r of e.children)r.type==="run"&&t.push(...f(r));return t}function W(e){let t=[];if(e.instruction&&t.push(...B(e.instruction)),e.content)for(let r of e.content)r.type==="run"&&t.push(...f(r));return t}function G(e){let t=[];if(e.fieldCode)for(let r of e.fieldCode)r.type==="run"&&t.push(...f(r));if(e.fieldResult)for(let r of e.fieldResult)r.type==="run"&&t.push(...f(r));return t}function M(e){let t=[];if(!e.rows)return t;for(let r of e.rows)if(r.cells)for(let o of r.cells)t.push(...X(o));return t}function X(e){let t=[];if(!e.content)return t;for(let r of e.content)r.type==="paragraph"?t.push(...R(r)):r.type==="table"&&t.push(...M(r));return t}function A(e){let t=[];for(let r of e)if(r.content)for(let o of r.content)t.push(...R(o));return t}var S=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,_=/\{(.+?)\}/g;function B(e){if(!e)return [];let t=[],r=new RegExp(S),o;for(;(o=r.exec(e))!==null;)t.push(o[1]);return t}function oe(e){return S.test(e)}function ae(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function ie(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function se(e){return `{${e}}`}function ce(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function le(e,t){return e&&e.replace(_,(r,o)=>{let n=o.trim();return n in t?t[n]:r})}function pe(e,t=""){return e&&e.replace(_,t)}function ue(e){return U(e).length>0}function O(e,t,r={}){return E(e,t,r).buffer}function E(e,t,r={}){let{nullGetter:o="keep",linebreaks:n=true,delimiters:a}=r,i=[],s=[],c=[];try{let l=new g__default.default(e),u=new b__default.default(l,{paragraphLoop:!0,linebreaks:n,nullGetter:m=>{let p=m.value||"";if(o==="error")throw new Error(`Undefined variable: ${p}`);return o==="empty"?(c.push(p),""):(c.push(p),`{${p}}`)},delimiters:a?{start:a.start||"{",end:a.end||"}"}:void 0});return Object.keys(t).forEach(m=>{t[m]!==void 0&&t[m]!==null&&s.push(m);}),u.setData(t),u.render(),{buffer:u.getZip().generate({type:"arraybuffer",compression:"DEFLATE",compressionOptions:{level:6}}),replacedVariables:s,unreplacedVariables:c,warnings:i}}catch(l){throw x(l)}}function ge(e,t,r={}){let o=O(e,t,r);return new Blob([o],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function be(e){try{let t=new g__default.default(e),o=new b__default.default(t,{paragraphLoop:!0,linebreaks:!0}).getFullText();return $(o)}catch(t){throw x(t)}}function L(e){let t=[],r=[];try{let o=new g__default.default(e),a=new b__default.default(o,{paragraphLoop:!0,linebreaks:!0}).getFullText();r=$(a);let i=K(a);for(let s of i)t.push({message:`Unclosed tag: ${s}`,variable:s,type:"parse"});return {valid:t.length===0,errors:t,tags:r}}catch(o){return t.push(x(o)),{valid:false,errors:t,tags:r}}}function xe(e,t){return e.filter(r=>!(r in t)||t[r]===void 0||t[r]===null)}function he(e,t){try{let r=new g__default.default(e),o=new b__default.default(r,{paragraphLoop:!0,linebreaks:!0,nullGetter:n=>`[${n.value||""}]`});return o.setData(t),o.render(),o.getFullText()}catch(r){throw x(r)}}function $(e){let t=[],r=/\{([^{}]+)\}/g,o;for(;(o=r.exec(e))!==null;){let n=o[1].trim();n&&!t.includes(n)&&t.push(n);}return t.sort()}function K(e){let t=[],r=0,o="";for(let n of e)n==="{"?(r++,o=""):n==="}"?(r--,r<0&&(r=0)):r>0&&(o+=n);return r>0&&o.trim()&&t.push(o.trim()),t}function Q(e){return "properties"in e&&typeof e.properties=="object"}function x(e){if(e instanceof Error){if(Q(e)&&e.properties?.errors){let t=e.properties.errors[0];return {message:t?.message||"Template processing error",variable:t?.properties?.tag,type:"render",originalError:e}}if(e.message.includes("undefined")){let t=e.message.match(/undefined (?:variable|tag):\s*(\S+)/i);return {message:e.message,variable:t?t[1]:void 0,type:"undefined",originalError:e}}return e.message.includes("parse")||e.message.includes("unclosed")||e.message.includes("syntax")?{message:e.message,type:"parse",originalError:e}:{message:e.message,type:"unknown",originalError:e}}return {message:String(e),type:"unknown"}}function ye(e,t,r={}){let{linebreaks:o=true,delimiters:n}=r;try{let a=new g__default.default(e),i=new b__default.default(a,{paragraphLoop:!0,linebreaks:o,delimiters:n?{start:n.start||"{",end:n.end||"}"}:void 0});return i.setData(t),i.render(),i.getZip().generate({type:"arraybuffer",compression:"DEFLATE"})}catch(a){throw x(a)}}function Te(e={}){return (t,r)=>O(t,r,e)}var h={type:"string",description:"Document ID from a previous docx_load call"},Y={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},N={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
|
|
2
2
|
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
3
|
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:h},required:["documentId"]},handler:async(e,t)=>{let{documentId:r}=e,o=t.session.documents.get(r);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};try{let n=V(o.document);return {content:[{type:"text",text:JSON.stringify({variables:n.variables,count:n.variables.length,totalOccurrences:n.totalOccurrences,byLocation:n.byLocation},null,2)}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${n.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},F={name:"docx_insert_variable",description:`Insert a template variable placeholder ({{name}}) at a specific position in the document.
|
|
4
4
|
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
5
|
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:h,position:Y,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {{customer_name}}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(e,t)=>{let{documentId:r,position:o,variableName:n}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(n))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${n}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:i}=await import('./executor-FSMRGT73.cjs'),s=i(a.document,{type:"insertText",position:o,text:`{{${n}}}`});return a.document=s,a.lastModified=Date.now(),s.templateVariables||(s.templateVariables=[]),s.templateVariables.includes(n)||s.templateVariables.push(n),{content:[{type:"text",text:JSON.stringify({success:!0,variable:n,insertedAs:`{{${n}}}`,position:o})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${i.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},z={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
6
|
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
7
|
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
|
-
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:h,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(e,t)=>{let{documentId:r,variables:o,keepUnmatchedVariables:n=true}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let i=E(a.buffer,o,{nullGetter:n?"keep":"empty"}),s=await
|
|
8
|
+
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:h,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(e,t)=>{let{documentId:r,variables:o,keepUnmatchedVariables:n=true}=e,a=t.session.documents.get(r);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let i=E(a.buffer,o,{nullGetter:n?"keep":"empty"}),s=await chunkFFPSMP4Q_cjs.l(i.buffer);return a.document=s,a.buffer=i.buffer,a.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:i.replacedVariables,unreplacedVariables:i.unreplacedVariables,warnings:i.warnings})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${i.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},H={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
9
9
|
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
10
10
|
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:h},required:["documentId"]},handler:async(e,t)=>{let{documentId:r}=e,o=t.session.documents.get(r);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${r}`}]};if(!o.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let n=L(o.buffer);return {content:[{type:"text",text:JSON.stringify({valid:n.valid,tags:n.tags,errors:n.errors.map(a=>({message:a.message,variable:a.variable,type:a.type}))},null,2)}]}}catch(n){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${n.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},D=[N,F,z,H];var ee={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:v,replaceWithTemplateVariable:w},mcpTools:D,initialize:()=>{try{chunkRTESADL3_cjs.a("docxtemplater"),chunkRTESADL3_cjs.a("pizzip");}catch{console.warn("[docxtemplater-plugin] Warning: docxtemplater or pizzip not installed. Template features may not work. Install with: npm install docxtemplater pizzip");}}};exports.a=U;exports.b=V;exports.c=j;exports.d=R;exports.e=B;exports.f=oe;exports.g=ae;exports.h=ie;exports.i=se;exports.j=ce;exports.k=le;exports.l=pe;exports.m=ue;exports.n=O;exports.o=E;exports.p=ge;exports.q=be;exports.r=L;exports.s=xe;exports.t=he;exports.u=ye;exports.v=Te;exports.w=J;exports.x=ee;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';var $t=require('jszip'),xmlJs=require('xml-js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var $t__default=/*#__PURE__*/_interopDefault($t);var _=new Set,ne=new Map,we=new Set,be=false;function Ee(e,t=[400,700],n=["normal","italic"]){let o=encodeURIComponent(e),r=[];for(let a of n){let f=a==="italic"?1:0;for(let u of t)r.push(`${f},${u}`);}r.sort();let i=r.join(";");return `https://fonts.googleapis.com/css2?family=${o}:ital,wght@${i}&display=swap`}async function Pe(e,t){let n=e.trim();if(_.has(n))return true;let o=ne.get(n);if(o)return o;let r=(async()=>{be=true;try{let i=Ee(n,t?.weights,t?.styles),a=document.createElement("link");return a.rel="stylesheet",a.href=i,await new Promise(u=>{a.onload=()=>u(!0),a.onerror=()=>u(!1),document.head.appendChild(a),setTimeout(()=>u(!1),5e3);})?(await Be(n,3e3),_.add(n),Ae([n]),!0):!1}catch(i){return console.warn(`Failed to load font "${n}":`,i),false}finally{ne.delete(n),ne.size===0&&(be=false);}})();return ne.set(n,r),r}async function Dt(e,t){let n=e.filter(o=>!_.has(o.trim()));n.length!==0&&await Promise.all(n.map(o=>Pe(o,t)));}function Eo(e){return _.has(e.trim())}function Po(){return be}function Ao(){return Array.from(_)}function Bo(e){return we.add(e),()=>{we.delete(e);}}function Ae(e){for(let t of we)try{t(e);}catch(n){console.warn("Font load callback error:",n);}}async function Be(e,t){if("fonts"in document)try{let n=`400 16px "${e}"`;return await Promise.race([document.fonts.load(n),new Promise(o=>setTimeout(o,t))]),document.fonts.check(n)}catch{}return await new Promise(n=>setTimeout(n,100)),true}function No(e,t="sans-serif"){if(typeof document>"u")return false;let n=(r,i)=>{let f=document.createElement("canvas").getContext("2d");if(!f)return false;f.textBaseline="top";let u="abcdefghijklmnopqrstuvwxyz0123456789";f.font=`72px ${i}`;let c=f.measureText(u).width;return f.font=`72px "${r}", ${i}`,f.measureText(u).width!==c};return n(e,t)?true:n(e,t==="sans-serif"?"serif":"sans-serif")}async function Xo(e,t,n){let o=e.trim();if(_.has(o))return true;try{let r=new Blob([t],{type:"font/ttf"}),i=URL.createObjectURL(r),a=document.createElement("style");return a.textContent=`
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: "${o}";
|
|
4
|
+
src: url(${i}) format('truetype');
|
|
5
|
+
font-weight: ${n?.weight??"normal"};
|
|
6
|
+
font-style: ${n?.style??"normal"};
|
|
7
|
+
font-display: swap;
|
|
8
|
+
}
|
|
9
|
+
`,document.head.appendChild(a),await Be(o,3e3),_.add(o),Ae([o]),!0}catch(r){return console.warn(`Failed to load font "${o}" from buffer:`,r),false}}var Ht={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 Ot(e){let t=e.trim();return Ht[t]||t}async function jt(e){let t=e.trim(),n=Ot(t);return n!==t?(await Wt(t,n),_.add(t),_.add(n),true):Pe(n)}async function Wt(e,t){let n=`font-alias-${e.toLowerCase().replace(/\s+/g,"-")}`;if(!document.getElementById(n))try{let o=Ee(t,[400,700],["normal","italic"]),r=await fetch(o);if(!r.ok){console.warn(`Failed to fetch Google Fonts CSS for "${t}": ${r.status}`);return}let i=await r.text(),a=new RegExp(`font-family:\\s*['"]${Vt(t)}['"]`,"gi"),f=i.replace(a,`font-family: '${e}'`),u=document.createElement("style");u.id=n,u.textContent=f,document.head.appendChild(u);}catch(o){console.warn(`Failed to create font alias for "${e}":`,o);}}function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function ye(e){let t=[...new Set(e.map(n=>n.trim()))];await Promise.all(t.map(n=>jt(n)));}async function Lo(){await Dt(["Carlito","Caladea","Arimo","Tinos","Cousine","EB Garamond"]);}function zt(e){let t=new Set,n=e;if(!n?.package)return t;let o=n.package?.document?.content;if(Array.isArray(o)){for(let i of o)if(i?.type==="paragraph"&&Array.isArray(i.content)){for(let a of i.content)if(a?.type==="run"&&a.formatting?.fontFamily){let{ascii:f,hAnsi:u}=a.formatting.fontFamily;f&&t.add(f),u&&u!==f&&t.add(u);}}}let r=n.package?.styles?.styles;if(Array.isArray(r)){for(let i of r)if(i?.runProperties?.fontFamily){let{ascii:a,hAnsi:f}=i.runProperties.fontFamily;a&&t.add(a),f&&f!==a&&t.add(f);}}return t}async function Io(e){let t=zt(e);t.size!==0&&await ye(Array.from(t));}async function Ne(e){let t=await $t__default.default.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[o,r]of Object.entries(t.files)){if(r.dir)continue;let i=o.toLowerCase();if(i.endsWith(".xml")||i.endsWith(".rels")){let a=await r.async("text");if(n.allXml.set(o,a),i==="word/document.xml")n.documentXml=a;else if(i==="word/styles.xml")n.stylesXml=a;else if(i==="word/theme/theme1.xml")n.themeXml=a;else if(i==="word/numbering.xml")n.numberingXml=a;else if(i==="word/fonttable.xml")n.fontTableXml=a;else if(i==="word/settings.xml")n.settingsXml=a;else if(i==="word/websettings.xml")n.webSettingsXml=a;else if(i==="word/footnotes.xml")n.footnotesXml=a;else if(i==="word/endnotes.xml")n.endnotesXml=a;else if(i==="word/comments.xml")n.commentsXml=a;else if(i==="word/_rels/document.xml.rels")n.documentRels=a;else if(i==="_rels/.rels")n.packageRels=a;else if(i==="[content_types].xml")n.contentTypesXml=a;else if(i==="docprops/core.xml")n.corePropsXml=a;else if(i==="docprops/app.xml")n.appPropsXml=a;else if(i==="docprops/custom.xml")n.customPropsXml=a;else if(i.match(/^word\/header\d+\.xml$/)){let f=o.split("/").pop()||o;n.headers.set(f,a);}else if(i.match(/^word\/footer\d+\.xml$/)){let f=o.split("/").pop()||o;n.footers.set(f,a);}}else if(i.startsWith("word/media/")){let a=await r.async("arraybuffer");n.media.set(o,a);}else if(i.startsWith("word/fonts/")){let a=await r.async("arraybuffer");n.fonts.set(o,a);}}return n}function Xe(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 G(e){return xmlJs.xml2js(e,{compact:false,ignoreComment:true,ignoreInstruction:true,ignoreDoctype:true,alwaysArray:false,trim:false,attributesKey:"attributes",textKey:"text"})}function q(e){try{let t=G(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 oe(e){let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function l(e,t,n){if(!e||!e.elements)return null;let o=`${t}:${n}`;for(let r of e.elements)if(r.type==="element"&&(r.name===o||oe(r.name||"")===n))return r;return null}function B(e,t,n){if(!e||!e.elements)return [];let o=`${t}:${n}`,r=[];for(let i of e.elements)i.type==="element"&&(i.name===o||oe(i.name||"")===n)&&r.push(i);return r}function D(e){return !e||!e.elements?[]:e.elements.filter(t=>t.type==="element")}function s(e,t,n){if(!e||!e.attributes)return null;let o=e.attributes;if(t){let r=`${t}:${n}`;if(r in o)return o[r]}return n in o?o[n]:null}function re(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+=re(n));return t}function Le(e){return e?{val:s(e,"w","val")??void 0,themeColor:s(e,"w","themeColor")??void 0,themeTint:s(e,"w","themeTint")??void 0,themeShade:s(e,"w","themeShade")??void 0}:null}function g(e,t,n,o=1){let r=s(e,t,n);if(r===null)return;let i=parseInt(r,10);if(!isNaN(i))return i*o}function x(e,t="w"){if(!e)return false;let n=s(e,t,"val");return n===null?true:!(n==="0"||n==="false"||n==="off")}var ie={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 ae(e){let t=new Map;if(!e||e.trim().length===0)return t;let n=q(e);if(!n)return console.warn("Failed to parse relationships XML"),t;let o=D(n);for(let r of o){let i=r.name||"";if(!i.endsWith("Relationship")&&!i.includes(":Relationship"))continue;let a=s(r,null,"Id"),f=s(r,null,"Type"),u=s(r,null,"Target"),c=s(r,null,"TargetMode");if(!a||!f||!u){console.warn("Relationship missing required attributes:",{id:a,type:f,target:u});continue}let d={id:a,type:f,target:u};c==="External"?d.targetMode="External":c==="Internal"&&(d.targetMode="Internal"),t.set(a,d);}return t}function Ie(e){return e.type===ie.hyperlink&&e.targetMode==="External"}var Oe={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},se={majorFont:{latin:"Calibri Light",ea:"",cs:"",fonts:{}},minorFont:{latin:"Calibri",ea:"",cs:"",fonts:{}}},xe={name:"Office Theme",colorScheme:Oe,fontScheme:se},_t=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function Gt(e){if(!e)return null;switch(oe(e.name||"")){case "srgbClr":return s(e,"a","val")??s(e,null,"val")??null;case "sysClr":{let n=s(e,"a","lastClr")??s(e,null,"lastClr");if(n)return n;switch(s(e,"a","val")??s(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":{s(e,"a","val")??s(e,null,"val");return null}default:return null}}function qt(e){let t={...Oe};if(!e)return t;for(let n of _t){let o=l(e,"a",n);if(o){let r=D(o);if(r.length>0){let i=Gt(r[0]);i&&(t[n]=i);}}}return t}function De(e){let t={latin:"",ea:"",cs:"",fonts:{}};if(!e)return t;let n=l(e,"a","latin");n&&(t.latin=s(n,"a","typeface")??s(n,null,"typeface")??"");let o=l(e,"a","ea");o&&(t.ea=s(o,"a","typeface")??s(o,null,"typeface")??"");let r=l(e,"a","cs");r&&(t.cs=s(r,"a","typeface")??s(r,null,"typeface")??"");let i=B(e,"a","font");for(let a of i){let f=s(a,"a","script")??s(a,null,"script"),u=s(a,"a","typeface")??s(a,null,"typeface");f&&u&&(t.fonts=t.fonts||{},t.fonts[f]=u);}return t}function Zt(e){let t={...se};if(!e)return t;let n=l(e,"a","majorFont");n&&(t.majorFont=De(n));let o=l(e,"a","minorFont");return o&&(t.minorFont=De(o)),t}function je(e){if(!e)return {...xe};try{let t=q(e);if(!t)return {...xe};let n=s(t,"a","name")??s(t,null,"name")??"Office Theme",o=l(t,"a","themeElements"),r=l(o,"a","clrScheme"),i=qt(r),a=l(o,"a","fontScheme"),f=Zt(a);return {name:n,colorScheme:i,fontScheme:f}}catch(t){return console.warn("Failed to parse theme:",t),{...xe}}}function Yt(e,t="latin"){if(!e?.fontScheme?.majorFont)return se.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 He(e,t="latin"){if(!e?.fontScheme?.minorFont)return se.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 z(e,t){if(!t)return "Calibri";let n=t.toLowerCase().includes("major"),o=t.toLowerCase().includes("minor"),r="latin",i=t.toLowerCase();return i.includes("eastasia")?r="ea":(i.includes("bidi")||i.includes("cs"))&&(r="cs"),n?Yt(e,r):o?He(e,r):He(e,"latin")}function le(e,t){if(!e)return;let n={},o=l(e,"w","b");o&&(n.bold=x(o));let r=l(e,"w","bCs");r&&(n.boldCs=x(r));let i=l(e,"w","i");i&&(n.italic=x(i));let a=l(e,"w","iCs");a&&(n.italicCs=x(a));let f=l(e,"w","u");if(f){let C=s(f,"w","val");if(C){n.underline={style:C};let k=s(f,"w","color"),j=s(f,"w","themeColor");(k||j)&&(n.underline.color=Te(k,j,s(f,"w","themeTint"),s(f,"w","themeShade")));}}let u=l(e,"w","strike");u&&(n.strike=x(u));let c=l(e,"w","dstrike");c&&(n.doubleStrike=x(c));let d=l(e,"w","vertAlign");if(d){let C=s(d,"w","val");(C==="superscript"||C==="subscript"||C==="baseline")&&(n.vertAlign=C);}let p=l(e,"w","smallCaps");p&&(n.smallCaps=x(p));let y=l(e,"w","caps");y&&(n.allCaps=x(y));let b=l(e,"w","vanish");b&&(n.hidden=x(b));let m=l(e,"w","color");m&&(n.color=Te(s(m,"w","val"),s(m,"w","themeColor"),s(m,"w","themeTint"),s(m,"w","themeShade")));let T=l(e,"w","highlight");if(T){let C=s(T,"w","val");C&&(n.highlight=C);}let N=l(e,"w","shd");N&&(n.shading=fe(N));let A=l(e,"w","sz");if(A){let C=g(A,"w","val");C!==void 0&&(n.fontSize=C);}let R=l(e,"w","szCs");if(R){let C=g(R,"w","val");C!==void 0&&(n.fontSizeCs=C);}let v=l(e,"w","rFonts");if(v){n.fontFamily={ascii:s(v,"w","ascii")??void 0,hAnsi:s(v,"w","hAnsi")??void 0,eastAsia:s(v,"w","eastAsia")??void 0,cs:s(v,"w","cs")??void 0};let C=s(v,"w","asciiTheme");C&&(n.fontFamily.asciiTheme=C,t&&!n.fontFamily.ascii&&(n.fontFamily.ascii=z(t,C)));let k=s(v,"w","hAnsiTheme");k&&(n.fontFamily.hAnsiTheme=k,t&&!n.fontFamily.hAnsi&&(n.fontFamily.hAnsi=z(t,k)));let j=s(v,"w","eastAsiaTheme");j&&(n.fontFamily.eastAsiaTheme=j,t&&!n.fontFamily.eastAsia&&(n.fontFamily.eastAsia=z(t,j)));let V=s(v,"w","cstheme");V&&(n.fontFamily.csTheme=V,t&&!n.fontFamily.cs&&(n.fontFamily.cs=z(t,V)));}let h=l(e,"w","spacing");if(h){let C=g(h,"w","val");C!==void 0&&(n.spacing=C);}let F=l(e,"w","position");if(F){let C=g(F,"w","val");C!==void 0&&(n.position=C);}let w=l(e,"w","w");if(w){let C=g(w,"w","val");C!==void 0&&(n.scale=C);}let S=l(e,"w","kern");if(S){let C=g(S,"w","val");C!==void 0&&(n.kerning=C);}let M=l(e,"w","effect");if(M){let C=s(M,"w","val");C&&(n.effect=C);}let E=l(e,"w","em");if(E){let C=s(E,"w","val");C&&(n.emphasisMark=C);}let P=l(e,"w","emboss");P&&(n.emboss=x(P));let X=l(e,"w","imprint");X&&(n.imprint=x(X));let H=l(e,"w","outline");H&&(n.outline=x(H));let I=l(e,"w","shadow");I&&(n.shadow=x(I));let O=l(e,"w","rtl");O&&(n.rtl=x(O));let $=l(e,"w","cs");$&&(n.cs=x($));let U=l(e,"w","rStyle");if(U){let C=s(U,"w","val");C&&(n.styleId=C);}return Object.keys(n).length>0?n:void 0}function Te(e,t,n,o){let r={};return e&&e!=="auto"?r.rgb=e:e==="auto"&&(r.auto=true),t&&(r.themeColor=t),n&&(r.themeTint=n),o&&(r.themeShade=o),r}function fe(e){if(!e)return;let t={},n=s(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let o=s(e,"w","fill");o&&o!=="auto"&&(t.fill={rgb:o});let r=s(e,"w","themeFill");r&&(t.fill=t.fill||{},t.fill.themeColor=r);let i=s(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let a=s(e,"w","themeFillShade");a&&t.fill&&(t.fill.themeShade=a);let f=s(e,"w","val");return f&&(t.pattern=f),Object.keys(t).length>0?t:void 0}function W(e){if(!e)return;let t=s(e,"w","val");if(!t)return;let n={style:t},o=s(e,"w","color"),r=s(e,"w","themeColor");(o||r)&&(n.color=Te(o,r,s(e,"w","themeTint"),s(e,"w","themeShade")));let i=g(e,"w","sz");i!==void 0&&(n.size=i);let a=g(e,"w","space");a!==void 0&&(n.space=a);let f=s(e,"w","shadow");f&&(n.shadow=f==="1"||f==="true");let u=s(e,"w","frame");return u&&(n.frame=u==="1"||u==="true"),n}function Kt(e){if(!e)return;let t=B(e,"w","tab");if(t.length===0)return;let n=[];for(let o of t){let r=g(o,"w","pos"),i=s(o,"w","val");if(r!==void 0&&i){let a={position:r,alignment:i},f=s(o,"w","leader");f&&(a.leader=f),n.push(a);}}return n.length>0?n:void 0}function Fe(e,t){if(!e)return;let n={},o=l(e,"w","jc");if(o){let h=s(o,"w","val");h&&(n.alignment=h);}let r=l(e,"w","bidi");r&&(n.bidi=x(r));let i=l(e,"w","spacing");if(i){let h=g(i,"w","before");h!==void 0&&(n.spaceBefore=h);let F=g(i,"w","after");F!==void 0&&(n.spaceAfter=F);let w=g(i,"w","line");w!==void 0&&(n.lineSpacing=w);let S=s(i,"w","lineRule");S&&(n.lineSpacingRule=S);let M=s(i,"w","beforeAutospacing");M&&(n.beforeAutospacing=M==="1"||M==="true");let E=s(i,"w","afterAutospacing");E&&(n.afterAutospacing=E==="1"||E==="true");}let a=l(e,"w","ind");if(a){let h=g(a,"w","left");h!==void 0&&(n.indentLeft=h);let F=g(a,"w","right");F!==void 0&&(n.indentRight=F);let w=g(a,"w","firstLine");w!==void 0&&(n.indentFirstLine=w);let S=g(a,"w","hanging");S!==void 0&&(n.indentFirstLine=-S,n.hangingIndent=true);}let f=l(e,"w","pBdr");if(f){let h={},F=W(l(f,"w","top"));F&&(h.top=F);let w=W(l(f,"w","bottom"));w&&(h.bottom=w);let S=W(l(f,"w","left"));S&&(h.left=S);let M=W(l(f,"w","right"));M&&(h.right=M);let E=W(l(f,"w","between"));E&&(h.between=E);let P=W(l(f,"w","bar"));P&&(h.bar=P),Object.keys(h).length>0&&(n.borders=h);}let u=l(e,"w","shd");u&&(n.shading=fe(u));let c=l(e,"w","tabs");c&&(n.tabs=Kt(c));let d=l(e,"w","keepNext");d&&(n.keepNext=x(d));let p=l(e,"w","keepLines");p&&(n.keepLines=x(p));let y=l(e,"w","widowControl");y&&(n.widowControl=x(y));let b=l(e,"w","pageBreakBefore");b&&(n.pageBreakBefore=x(b));let m=l(e,"w","numPr");if(m){let h=l(m,"w","numId"),F=l(m,"w","ilvl");if(h||F){if(n.numPr={},h){let w=g(h,"w","val");w!==void 0&&(n.numPr.numId=w);}if(F){let w=g(F,"w","val");w!==void 0&&(n.numPr.ilvl=w);}}}let T=l(e,"w","outlineLvl");if(T){let h=g(T,"w","val");h!==void 0&&(n.outlineLevel=h);}let N=l(e,"w","pStyle");if(N){let h=s(N,"w","val");h&&(n.styleId=h);}let A=l(e,"w","suppressLineNumbers");A&&(n.suppressLineNumbers=x(A));let R=l(e,"w","suppressAutoHyphens");R&&(n.suppressAutoHyphens=x(R));let v=l(e,"w","rPr");return v&&(n.runProperties=le(v,t)),Object.keys(n).length>0?n:void 0}function Z(e){if(!e)return;let t=g(e,"w","w"),n=s(e,"w","type");if(t!==void 0&&n)return {value:t,type:n}}function $e(e){if(!e)return;let t={},n=W(l(e,"w","top"));n&&(t.top=n);let o=W(l(e,"w","bottom"));o&&(t.bottom=o);let r=W(l(e,"w","left"));r&&(t.left=r);let i=W(l(e,"w","right"));i&&(t.right=i);let a=W(l(e,"w","insideH"));a&&(t.insideH=a);let f=W(l(e,"w","insideV"));return f&&(t.insideV=f),Object.keys(t).length>0?t:void 0}function Ue(e){if(!e)return;let t={},n=Z(l(e,"w","top"));n&&(t.top=n);let o=Z(l(e,"w","bottom"));o&&(t.bottom=o);let r=Z(l(e,"w","left"));r&&(t.left=r);let i=Z(l(e,"w","right"));return i&&(t.right=i),Object.keys(t).length>0?t:void 0}function Jt(e){if(!e)return;let t={},n=s(e,"w","val");if(n){let c=parseInt(n,16);isNaN(c)||(t.firstRow=(c&32)!==0,t.lastRow=(c&64)!==0,t.firstColumn=(c&128)!==0,t.lastColumn=(c&256)!==0,t.noHBand=(c&512)!==0,t.noVBand=(c&1024)!==0);}let o=s(e,"w","firstColumn");o&&(t.firstColumn=o==="1");let r=s(e,"w","firstRow");r&&(t.firstRow=r==="1");let i=s(e,"w","lastColumn");i&&(t.lastColumn=i==="1");let a=s(e,"w","lastRow");a&&(t.lastRow=a==="1");let f=s(e,"w","noHBand");f&&(t.noHBand=f==="1");let u=s(e,"w","noVBand");return u&&(t.noVBand=u==="1"),Object.keys(t).length>0?t:void 0}function We(e,t){if(!e)return;let n={},o=l(e,"w","tblW");o&&(n.width=Z(o));let r=l(e,"w","jc");if(r){let m=s(r,"w","val");(m==="left"||m==="center"||m==="right")&&(n.justification=m);}let i=l(e,"w","tblCellSpacing");i&&(n.cellSpacing=Z(i));let a=l(e,"w","tblInd");a&&(n.indent=Z(a));let f=l(e,"w","tblBorders");f&&(n.borders=$e(f));let u=l(e,"w","tblCellMar");u&&(n.cellMargins=Ue(u));let c=l(e,"w","tblLayout");if(c){let m=s(c,"w","type");(m==="fixed"||m==="autofit")&&(n.layout=m);}let d=l(e,"w","tblStyle");if(d){let m=s(d,"w","val");m&&(n.styleId=m);}let p=l(e,"w","tblLook");p&&(n.look=Jt(p));let y=l(e,"w","shd");y&&(n.shading=fe(y));let b=l(e,"w","bidiVisual");return b&&(n.bidi=x(b)),Object.keys(n).length>0?n:void 0}function Ve(e){if(!e)return;let t={},n=l(e,"w","trHeight");if(n){t.height=Z(n);let f=s(n,"w","hRule");f&&(t.heightRule=f);}let o=l(e,"w","tblHeader");o&&(t.header=x(o));let r=l(e,"w","cantSplit");r&&(t.cantSplit=x(r));let i=l(e,"w","jc");if(i){let f=s(i,"w","val");(f==="left"||f==="center"||f==="right")&&(t.justification=f);}let a=l(e,"w","hidden");return a&&(t.hidden=x(a)),Object.keys(t).length>0?t:void 0}function ze(e,t){if(!e)return;let n={},o=l(e,"w","tcW");o&&(n.width=Z(o));let r=l(e,"w","tcBorders");r&&(n.borders=$e(r));let i=l(e,"w","tcMar");i&&(n.margins=Ue(i));let a=l(e,"w","shd");a&&(n.shading=fe(a));let f=l(e,"w","vAlign");if(f){let m=s(f,"w","val");(m==="top"||m==="center"||m==="bottom")&&(n.verticalAlign=m);}let u=l(e,"w","textDirection");if(u){let m=s(u,"w","val");m&&(n.textDirection=m);}let c=l(e,"w","gridSpan");if(c){let m=g(c,"w","val");m!==void 0&&(n.gridSpan=m);}let d=l(e,"w","vMerge");if(d){let m=s(d,"w","val");n.vMerge=m==="restart"?"restart":"continue";}let p=l(e,"w","tcFitText");p&&(n.fitText=x(p));let y=l(e,"w","noWrap");y&&(n.noWrap=x(y));let b=l(e,"w","hideMark");return b&&(n.hideMark=x(b)),Object.keys(n).length>0?n:void 0}function Qt(e,t){let n={styleId:s(e,"w","styleId")??"",type:s(e,"w","type")??"paragraph"},o=s(e,"w","default");o&&(n.default=o==="1"||o==="true");let r=l(e,"w","name");r&&(n.name=s(r,"w","val")??void 0);let i=l(e,"w","basedOn");i&&(n.basedOn=s(i,"w","val")??void 0);let a=l(e,"w","next");a&&(n.next=s(a,"w","val")??void 0);let f=l(e,"w","link");f&&(n.link=s(f,"w","val")??void 0);let u=l(e,"w","uiPriority");if(u){let h=g(u,"w","val");h!==void 0&&(n.uiPriority=h);}let c=l(e,"w","hidden");c&&(n.hidden=x(c));let d=l(e,"w","semiHidden");d&&(n.semiHidden=x(d));let p=l(e,"w","unhideWhenUsed");p&&(n.unhideWhenUsed=x(p));let y=l(e,"w","qFormat");y&&(n.qFormat=x(y));let b=l(e,"w","personal");b&&(n.personal=x(b));let m=l(e,"w","pPr");m&&(n.pPr=Fe(m,t));let T=l(e,"w","rPr");T&&(n.rPr=le(T,t));let N=l(e,"w","tblPr");N&&(n.tblPr=We(N));let A=l(e,"w","trPr");A&&(n.trPr=Ve(A));let R=l(e,"w","tcPr");R&&(n.tcPr=ze(R));let v=B(e,"w","tblStylePr");if(v.length>0){n.tblStylePr=[];for(let h of v){let F=s(h,"w","type");if(F){let w={type:F},S=l(h,"w","pPr");S&&(w.pPr=Fe(S,t));let M=l(h,"w","rPr");M&&(w.rPr=le(M,t));let E=l(h,"w","tblPr");E&&(w.tblPr=We(E));let P=l(h,"w","trPr");P&&(w.trPr=Ve(P));let X=l(h,"w","tcPr");X&&(w.tcPr=ze(X)),n.tblStylePr.push(w);}}}return n}function en(e,t){if(!e)return;let n={},o=l(e,"w","rPrDefault");if(o){let i=l(o,"w","rPr");i&&(n.rPr=le(i,t));}let r=l(e,"w","pPrDefault");if(r){let i=l(r,"w","pPr");i&&(n.pPr=Fe(i,t));}return n.rPr||n.pPr?n:void 0}function _e(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let o of Object.keys(t)){let r=t[o];r!==void 0&&(n[o]=typeof r=="object"&&r!==null?{...n[o]||{},...r}:r);}return n}function tn(e,t){if(!t)return e;if(!e)return t?{...t}:void 0;let n={...e};for(let o of Object.keys(t)){let r=t[o];if(r!==void 0)if(o==="runProperties")n.runProperties=_e(n.runProperties,t.runProperties);else if(o==="borders"||o==="numPr"||o==="frame"){let i=n[o],a=r;n[o]={...i||{},...a||{}};}else o==="tabs"&&Array.isArray(r)?n.tabs=[...r]:n[o]=r;}return n}function Ge(e,t,n,o=new Set){if(o.has(e.styleId)||(o.add(e.styleId),!e.basedOn))return e;let r=t.get(e.basedOn);if(!r)return e;let i=Ge(r,t,n,o),a={...e,pPr:tn(i.pPr,e.pPr),rPr:_e(i.rPr,e.rPr)};return e.type==="table"&&((i.tblPr||e.tblPr)&&(a.tblPr={...i.tblPr||{},...e.tblPr||{}}),(i.trPr||e.trPr)&&(a.trPr={...i.trPr||{},...e.trPr||{}}),(i.tcPr||e.tcPr)&&(a.tcPr={...i.tcPr||{},...e.tcPr||{}})),a}function Ce(e,t){let n=new Map;try{let o=q(e);if(!o)return n;let r=B(o,"w","style");for(let i of r){let a=Qt(i,t);a.styleId&&n.set(a.styleId,a);}for(let[i,a]of n){let f=Ge(a,n,t);n.set(i,f);}}catch(o){console.warn("Failed to parse styles:",o);}return n}function qe(e,t){let n={styles:[]};try{let o=q(e);if(!o)return n;let r=l(o,"w","docDefaults");n.docDefaults=en(r,t);let i=l(o,"w","latentStyles");i&&(n.latentStyles={defLockedState:s(i,"w","defLockedState")==="1",defUIPriority:g(i,"w","defUIPriority"),defSemiHidden:s(i,"w","defSemiHidden")==="1",defUnhideWhenUsed:s(i,"w","defUnhideWhenUsed")==="1",defQFormat:s(i,"w","defQFormat")==="1",count:g(i,"w","count")});let a=Ce(e,t);n.styles=Array.from(a.values());}catch(o){console.warn("Failed to parse style definitions:",o);}return n}function Ze(e){let t={abstractNums:[],nums:[]};if(!e)return Se(t);let n=q(e);if(!n)return Se(t);let o=B(n,"w","abstractNum");for(let i of o){let a=nn(i);a&&t.abstractNums.push(a);}let r=B(n,"w","num");for(let i of r){let a=on(i);a&&t.nums.push(a);}return Se(t)}function nn(e){let t=s(e,"w","abstractNumId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let o={abstractNumId:n,levels:[]},r=l(e,"w","multiLevelType");if(r){let c=s(r,"w","val");(c==="hybridMultilevel"||c==="multilevel"||c==="singleLevel")&&(o.multiLevelType=c);}let i=l(e,"w","name");i&&(o.name=s(i,"w","val")??void 0);let a=l(e,"w","numStyleLink");a&&(o.numStyleLink=s(a,"w","val")??void 0);let f=l(e,"w","styleLink");f&&(o.styleLink=s(f,"w","val")??void 0);let u=B(e,"w","lvl");for(let c of u){let d=Ye(c);d&&o.levels.push(d);}return o.levels.sort((c,d)=>c.ilvl-d.ilvl),o}function on(e){let t=s(e,"w","numId");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n))return null;let o=l(e,"w","abstractNumId");if(!o)return null;let r=s(o,"w","val");if(r===null)return null;let i=parseInt(r,10);if(isNaN(i))return null;let a={numId:n,abstractNumId:i},f=B(e,"w","lvlOverride");if(f.length>0){a.levelOverrides=[];for(let u of f){let c=s(u,"w","ilvl");if(c===null)continue;let d=parseInt(c,10);if(isNaN(d))continue;let p={ilvl:d},y=l(u,"w","startOverride");if(y){let m=s(y,"w","val");if(m!==null){let T=parseInt(m,10);isNaN(T)||(p.startOverride=T);}}let b=l(u,"w","lvl");b&&(p.lvl=Ye(b)??void 0),a.levelOverrides.push(p);}}return a}function Ye(e){let t=s(e,"w","ilvl");if(t===null)return null;let n=parseInt(t,10);if(isNaN(n)||n<0||n>8)return null;let o={ilvl:n,numFmt:"decimal",lvlText:""},r=l(e,"w","start");if(r){let m=s(r,"w","val");if(m!==null){let T=parseInt(m,10);isNaN(T)||(o.start=T);}}let i=l(e,"w","numFmt");if(i){let m=s(i,"w","val");m&&(o.numFmt=rn(m));}let a=l(e,"w","lvlText");a&&(o.lvlText=s(a,"w","val")??"");let f=l(e,"w","lvlJc");if(f){let m=s(f,"w","val");(m==="left"||m==="center"||m==="right")&&(o.lvlJc=m);}let u=l(e,"w","suff");if(u){let m=s(u,"w","val");(m==="tab"||m==="space"||m==="nothing")&&(o.suffix=m);}let c=l(e,"w","isLgl");c&&(o.isLgl=x(c));let d=l(e,"w","lvlRestart");if(d){let m=s(d,"w","val");if(m!==null){let T=parseInt(m,10);isNaN(T)||(o.lvlRestart=T);}}let p=l(e,"w","legacy");p&&(o.legacy={legacy:x(p),legacySpace:g(p,"w","legacySpace"),legacyIndent:g(p,"w","legacyIndent")});let y=l(e,"w","pPr");y&&(o.pPr=an(y));let b=l(e,"w","rPr");return b&&(o.rPr=fn(b)),o}function rn(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 an(e){let t={},n=l(e,"w","ind");if(n){let r=g(n,"w","left"),i=g(n,"w","right"),a=g(n,"w","firstLine"),f=g(n,"w","hanging");r!==void 0&&(t.indentLeft=r),i!==void 0&&(t.indentRight=i),f!==void 0?(t.indentFirstLine=-f,t.hangingIndent=true):a!==void 0&&(t.indentFirstLine=a);}let o=l(e,"w","tabs");if(o){t.tabs=[];let r=B(o,"w","tab");for(let i of r){let a=g(i,"w","pos"),f=s(i,"w","val"),u=s(i,"w","leader");a!==void 0&&f&&t.tabs.push({position:a,alignment:sn(f),leader:ln(u)});}}return t}function sn(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 ln(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 fn(e){let t={},n=l(e,"w","rFonts");n&&(t.fontFamily={ascii:s(n,"w","ascii")??void 0,hAnsi:s(n,"w","hAnsi")??void 0,eastAsia:s(n,"w","eastAsia")??void 0,cs:s(n,"w","cs")??void 0});let o=l(e,"w","sz");if(o){let f=g(o,"w","val");f!==void 0&&(t.fontSize=f);}let r=l(e,"w","color");if(r){let f=s(r,"w","val"),u=s(r,"w","themeColor");f==="auto"?t.color={auto:true}:u?t.color={themeColor:u,themeTint:s(r,"w","themeTint")??void 0,themeShade:s(r,"w","themeShade")??void 0}:f&&(t.color={rgb:f});}let i=l(e,"w","b");i&&(t.bold=x(i));let a=l(e,"w","i");return a&&(t.italic=x(a)),t}function Se(e){let t=new Map;for(let o of e.abstractNums)t.set(o.abstractNumId,o);let n=new Map;for(let o of e.nums)n.set(o.numId,o);return {definitions:e,getLevel(o,r){let i=n.get(o);if(!i)return null;if(i.levelOverrides){let f=i.levelOverrides.find(u=>u.ilvl===r);if(f){if(f.lvl)return f.lvl;let u=t.get(i.abstractNumId);if(u){let c=u.levels.find(d=>d.ilvl===r);if(c&&f.startOverride!==void 0)return {...c,start:f.startOverride}}}}let a=t.get(i.abstractNumId);return a?a.levels.find(f=>f.ilvl===r)??null:null},getAbstract(o){return t.get(o)??null},hasNumbering(o){return n.has(o)}}}var un=914400,cn=96;function Jo(e){return e==null||isNaN(e)?0:Math.round(e*cn/un)}function dn(e){if(!e)return;let t=parseInt(e,10);if(!isNaN(t))return t/6e4}function L(e,t){let n=D(e);for(let o of n)if(o.name===t)return o;return null}function pn(e,t){let n=D(e);for(let o of n)if(t.includes(o.name||""))return o;return null}function Ke(e){if(!e)return {width:0,height:0};let t=g(e,null,"cx")??0,n=g(e,null,"cy")??0;return {width:t,height:n}}function Je(e){if(!e)return;let t=g(e,null,"l")??0,n=g(e,null,"t")??0,o=g(e,null,"r")??0,r=g(e,null,"b")??0;if(!(t===0&&n===0&&o===0&&r===0))return {left:t,top:n,right:o,bottom:r}}function Qe(e){if(!e)return {};let t=s(e,null,"id")??void 0,n=s(e,null,"name")??void 0,o=s(e,null,"descr")??void 0,r=s(e,null,"title")??void 0,i=s(e,null,"decorative")==="1";return {id:t,name:n,alt:o,title:r,decorative:i||void 0}}function mn(e){if(!e)return;let t=s(e,null,"relativeFrom")??"column",n=L(e,"wp:align");if(n){let r=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:r}}let o=L(e,"wp:posOffset");if(o){let r=String(o.elements?.[0]?.text??"0"),i=parseInt(r,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}function gn(e){if(!e)return;let t=s(e,null,"relativeFrom")??"paragraph",n=L(e,"wp:align");if(n){let r=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:r}}let o=L(e,"wp:posOffset");if(o){let r=String(o.elements?.[0]?.text??"0"),i=parseInt(r,10);return {relativeTo:t,posOffset:isNaN(i)?0:i}}return {relativeTo:t}}var hn=["wp:wrapNone","wp:wrapSquare","wp:wrapTight","wp:wrapThrough","wp:wrapTopAndBottom"];function wn(e,t){if(!e)return {type:t?"behind":"inFront"};let o=(e.name||"").replace("wp:",""),r=g(e,null,"distT")??void 0,i=g(e,null,"distB")??void 0,a=g(e,null,"distL")??void 0,f=g(e,null,"distR")??void 0,u=s(e,null,"wrapText")??void 0,c;switch(o){case "wrapNone":c=t?"behind":"inFront";break;case "wrapSquare":c="square";break;case "wrapTight":c="tight";break;case "wrapThrough":c="through";break;case "wrapTopAndBottom":c="topAndBottom";break;default:c="square";}let d={type:c};return u&&(d.wrapText=u),r!==void 0&&(d.distT=r),i!==void 0&&(d.distB=i),a!==void 0&&(d.distL=a),f!==void 0&&(d.distR=f),d}function et(e){if(!e)return;let t=s(e,null,"rot"),n=s(e,null,"flipH")==="1",o=s(e,null,"flipV")==="1",r=dn(t);if(r===void 0&&!n&&!o)return;let i={};return r!==void 0&&(i.rotation=r),n&&(i.flipH=true),o&&(i.flipV=true),i}function tt(e){let t=L(e,"a:graphic");if(!t)return null;let n=L(t,"a:graphicData");if(!n)return null;let o=L(n,"pic:pic");if(!o)return null;let r=L(o,"pic:blipFill");return r?L(r,"a:blip"):null}function nt(e){if(!e)return "";let t=s(e,"r","embed");if(t)return t;let n=s(e,null,"embed");if(n)return n;let o=s(e,"r","link");return o||""}function ot(e){let t=L(e,"a:graphic");if(!t)return null;let n=L(t,"a:graphicData");if(!n)return null;let o=L(n,"pic:pic");if(!o)return null;let r=L(o,"pic:spPr");return r?L(r,"a:xfrm"):null}function bn(e){if(!e)return e;let t=e.replace(/^\/+/,"");return t.startsWith("media/")?t=`word/${t}`:t.startsWith("word/")||(t=`word/${t}`),t}function yn(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 rt(e,t,n){if(!e||!t)return {};let o=t.get(e);if(!o)return {};let r=o.target;if(!r)return {};let i=bn(r),a=r.split("/").pop(),f=(u,c)=>{let d=c.toLowerCase();for(let[p,y]of u.entries())if(p.toLowerCase()===d)return y};if(n){let u=f(n,i);if(u)return {src:u.dataUrl||u.base64,mimeType:u.mimeType,filename:a};let c=r.replace(/^\/+/,""),d=f(n,c);if(d)return {src:d.dataUrl||d.base64,mimeType:d.mimeType,filename:a};let p=`word/${c}`,y=f(n,p);if(y)return {src:y.dataUrl||y.base64,mimeType:y.mimeType,filename:a}}return {mimeType:yn(r),filename:a}}function xn(e,t,n){let o=L(e,"wp:extent"),r=Ke(o),i=L(e,"wp:effectExtent"),a=Je(i),f=L(e,"wp:docPr"),u=Qe(f),c=tt(e),d=nt(c),p=rt(d,t,n),y=ot(e),b=et(y),m={type:"image",rId:d,size:r,wrap:{type:"inline"}};return u.id&&(m.id=u.id),u.alt&&(m.alt=u.alt),u.title&&(m.title=u.title),u.decorative&&(m.decorative=true),p.src&&(m.src=p.src),p.mimeType&&(m.mimeType=p.mimeType),p.filename&&(m.filename=p.filename),a&&(m.padding=a),b&&(m.transform=b),m}function Tn(e,t,n){let o=L(e,"wp:extent"),r=Ke(o),i=L(e,"wp:effectExtent"),a=Je(i),f=L(e,"wp:docPr"),u=Qe(f),c=s(e,null,"behindDoc")==="1",d=pn(e,hn),p=wn(d,c),y=L(e,"wp:positionH"),b=L(e,"wp:positionV"),m=mn(y),T=gn(b),N;(m||T)&&(N={horizontal:m??{relativeTo:"column"},vertical:T??{relativeTo:"paragraph"}});let A=tt(e),R=nt(A),v=rt(R,t,n),h=ot(e),F=et(h),w={type:"image",rId:R,size:r,wrap:p};return u.id&&(w.id=u.id),u.alt&&(w.alt=u.alt),u.title&&(w.title=u.title),u.decorative&&(w.decorative=true),v.src&&(w.src=v.src),v.mimeType&&(w.mimeType=v.mimeType),v.filename&&(w.filename=v.filename),N&&(w.position=N),a&&(w.padding=a),F&&(w.transform=F),w}function Fn(e,t,n){let o=D(e);for(let r of o){let i=r.name||"";if(i==="wp:inline")return xn(r,t,n);if(i==="wp:anchor")return Tn(r,t,n)}return null}function it(e,t,n){return Fn(e,t,n)}function at(e,t,n,o){let r={};return e&&e!=="auto"?r.rgb=e:e==="auto"&&(r.auto=true),t&&(r.themeColor=t),n&&(r.themeTint=n),o&&(r.themeShade=o),r}function Cn(e){if(!e)return;let t={},n=s(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let o=s(e,"w","fill");o&&o!=="auto"&&(t.fill={rgb:o});let r=s(e,"w","themeFill");r&&(t.fill=t.fill||{},t.fill.themeColor=r);let i=s(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let a=s(e,"w","themeFillShade");a&&t.fill&&(t.fill.themeShade=a);let f=s(e,"w","val");return f&&(t.pattern=f),Object.keys(t).length>0?t:void 0}function ke(e,t,n){if(!e)return;let o={},r=l(e,"w","b");r&&(o.bold=x(r));let i=l(e,"w","bCs");i&&(o.boldCs=x(i));let a=l(e,"w","i");a&&(o.italic=x(a));let f=l(e,"w","iCs");f&&(o.italicCs=x(f));let u=l(e,"w","u");if(u){let k=s(u,"w","val");if(k){o.underline={style:k};let j=s(u,"w","color"),V=s(u,"w","themeColor");(j||V)&&(o.underline.color=at(j,V,s(u,"w","themeTint"),s(u,"w","themeShade")));}}let c=l(e,"w","strike");c&&(o.strike=x(c));let d=l(e,"w","dstrike");d&&(o.doubleStrike=x(d));let p=l(e,"w","vertAlign");if(p){let k=s(p,"w","val");(k==="superscript"||k==="subscript"||k==="baseline")&&(o.vertAlign=k);}let y=l(e,"w","smallCaps");y&&(o.smallCaps=x(y));let b=l(e,"w","caps");b&&(o.allCaps=x(b));let m=l(e,"w","vanish");m&&(o.hidden=x(m));let T=l(e,"w","color");T&&(o.color=at(s(T,"w","val"),s(T,"w","themeColor"),s(T,"w","themeTint"),s(T,"w","themeShade")));let N=l(e,"w","highlight");if(N){let k=s(N,"w","val");k&&(o.highlight=k);}let A=l(e,"w","shd");A&&(o.shading=Cn(A));let R=l(e,"w","sz");if(R){let k=g(R,"w","val");k!==void 0&&(o.fontSize=k);}let v=l(e,"w","szCs");if(v){let k=g(v,"w","val");k!==void 0&&(o.fontSizeCs=k);}let h=l(e,"w","rFonts");if(h){o.fontFamily={ascii:s(h,"w","ascii")??void 0,hAnsi:s(h,"w","hAnsi")??void 0,eastAsia:s(h,"w","eastAsia")??void 0,cs:s(h,"w","cs")??void 0};let k=s(h,"w","asciiTheme");k&&(o.fontFamily.asciiTheme=k,t&&!o.fontFamily.ascii&&(o.fontFamily.ascii=z(t,k)));let j=s(h,"w","hAnsiTheme");j&&(o.fontFamily.hAnsiTheme=j,t&&!o.fontFamily.hAnsi&&(o.fontFamily.hAnsi=z(t,j)));let V=s(h,"w","eastAsiaTheme");V&&(o.fontFamily.eastAsiaTheme=V,t&&!o.fontFamily.eastAsia&&(o.fontFamily.eastAsia=z(t,V)));let he=s(h,"w","cstheme");he&&(o.fontFamily.csTheme=he,t&&!o.fontFamily.cs&&(o.fontFamily.cs=z(t,he)));}let F=l(e,"w","spacing");if(F){let k=g(F,"w","val");k!==void 0&&(o.spacing=k);}let w=l(e,"w","position");if(w){let k=g(w,"w","val");k!==void 0&&(o.position=k);}let S=l(e,"w","w");if(S){let k=g(S,"w","val");k!==void 0&&(o.scale=k);}let M=l(e,"w","kern");if(M){let k=g(M,"w","val");k!==void 0&&(o.kerning=k);}let E=l(e,"w","effect");if(E){let k=s(E,"w","val");k&&(o.effect=k);}let P=l(e,"w","em");if(P){let k=s(P,"w","val");k&&(o.emphasisMark=k);}let X=l(e,"w","emboss");X&&(o.emboss=x(X));let H=l(e,"w","imprint");H&&(o.imprint=x(H));let I=l(e,"w","outline");I&&(o.outline=x(I));let O=l(e,"w","shadow");O&&(o.shadow=x(O));let $=l(e,"w","rtl");$&&(o.rtl=x($));let U=l(e,"w","cs");U&&(o.cs=x(U));let C=l(e,"w","rStyle");if(C){let k=s(C,"w","val");k&&(o.styleId=k);}return Object.keys(o).length>0?o:void 0}function Sn(e){let t=re(e),n=s(e,"xml","space")==="preserve";return {type:"text",text:t,preserveSpace:n||void 0}}function kn(){return {type:"tab"}}function Mn(e){let t=s(e,"w","type"),n=s(e,"w","clear"),o={type:"break"};return (t==="page"||t==="column"||t==="textWrapping")&&(o.breakType=t),(n==="none"||n==="left"||n==="right"||n==="all")&&(o.clear=n),o}function vn(e){let t=s(e,"w","font")??"",n=s(e,"w","char")??"";return {type:"symbol",font:t,char:n}}function Rn(e){return {type:"footnoteRef",id:g(e,"w","id")??0}}function En(e){return {type:"endnoteRef",id:g(e,"w","id")??0}}function Pn(e){let t=s(e,"w","fldCharType"),n=s(e,"w","fldLock")==="true"||s(e,"w","fldLock")==="1",o=s(e,"w","dirty")==="true"||s(e,"w","dirty")==="1",r="begin";return t==="separate"?r="separate":t==="end"&&(r="end"),{type:"fieldChar",charType:r,fldLock:n||void 0,dirty:o||void 0}}function An(e){return {type:"instrText",text:re(e)}}function Bn(e,t,n){let o=it(e,t??void 0,n??void 0);return o?{type:"drawing",image:o}:null}function Nn(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Xn(e,t,n){let o=[],r=D(e);for(let i of r)switch(Nn(i.name)){case "t":o.push(Sn(i));break;case "tab":o.push(kn());break;case "br":o.push(Mn(i));break;case "sym":o.push(vn(i));break;case "footnoteReference":o.push(Rn(i));break;case "endnoteReference":o.push(En(i));break;case "fldChar":o.push(Pn(i));break;case "instrText":o.push(An(i));break;case "softHyphen":o.push({type:"softHyphen"});break;case "noBreakHyphen":o.push({type:"noBreakHyphen"});break;case "drawing":let f=Bn(i,t,n);f&&o.push(f);break;case "pict":case "object":break;case "rPr":break;case "lastRenderedPageBreak":break;case "cr":o.push({type:"break",breakType:"textWrapping"});break;}return o}function ee(e,t,n,o=null,r=null){let i={type:"run",content:[]},a=l(e,"w","rPr");return a&&(i.formatting=ke(a,n)),i.content=Xn(e,o,r),i}function Ln(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function In(e){let t=g(e,"w","id")??0,n=s(e,"w","name")??"",o={type:"bookmarkStart",id:t,name:n},r=g(e,"w","colFirst");r!==void 0&&(o.colFirst=r);let i=g(e,"w","colLast");return i!==void 0&&(o.colLast=i),o}function Dn(e){return {type:"bookmarkEnd",id:g(e,"w","id")??0}}function st(e,t,n=null,o=null,r=null){let i={type:"hyperlink",children:[]},a=s(e,"r","id");if(a&&(i.rId=a,t)){let b=t.get(a);b&&(Ie(b),i.href=b.target);}let f=s(e,"w","anchor");f&&(i.anchor=f,i.href||(i.href=`#${f}`));let u=s(e,"w","tooltip");u&&(i.tooltip=u);let c=s(e,"w","tgtFrame");c&&(i.target=c);let d=s(e,"w","history");(d==="1"||d==="true")&&(i.history=true);let p=s(e,"w","docLocation");p&&(i.docLocation=p);let y=D(e);for(let b of y)switch(Ln(b.name)){case "r":i.children.push(ee(b,n,o,t,r));break;case "bookmarkStart":i.children.push(In(b));break;case "bookmarkEnd":i.children.push(Dn(b));break}return i}function lt(e){let t=g(e,"w","id")??0,n=s(e,"w","name")??"",o={type:"bookmarkStart",id:t,name:n},r=g(e,"w","colFirst");r!==void 0&&(o.colFirst=r);let i=g(e,"w","colLast");return i!==void 0&&(o.colLast=i),o}function ft(e){return {type:"bookmarkEnd",id:g(e,"w","id")??0}}function Hn(e){if(!e)return;let t=g(e,"w","w")??0,n=s(e,"w","type")??"dxa",o="dxa";return (n==="auto"||n==="dxa"||n==="nil"||n==="pct")&&(o=n),{value:t,type:o}}function Y(e){return Hn(e)}function J(e){if(!e)return;let o={style:s(e,"w","val")??"none"},r=g(e,"w","sz");r!==void 0&&(o.size=r);let i=g(e,"w","space");i!==void 0&&(o.space=i);let a=Le(e);a&&(o.color={rgb:a.val,themeColor:a.themeColor,themeTint:a.themeTint,themeShade:a.themeShade});let f=s(e,"w","shadow");(f==="1"||f==="true")&&(o.shadow=true);let u=s(e,"w","frame");return (u==="1"||u==="true")&&(o.frame=true),o}function ut(e){if(!e)return;let t={},n=J(l(e,"w","top"));n&&(t.top=n);let o=J(l(e,"w","bottom"));o&&(t.bottom=o);let r=J(l(e,"w","left")??l(e,"w","start"));r&&(t.left=r);let i=J(l(e,"w","right")??l(e,"w","end"));i&&(t.right=i);let a=J(l(e,"w","insideH"));a&&(t.insideH=a);let f=J(l(e,"w","insideV"));if(f&&(t.insideV=f),Object.keys(t).length!==0)return t}function ct(e){if(!e)return;let t={},n=Y(l(e,"w","top"));n&&(t.top=n);let o=Y(l(e,"w","bottom"));o&&(t.bottom=o);let r=Y(l(e,"w","left")??l(e,"w","start"));r&&(t.left=r);let i=Y(l(e,"w","right")??l(e,"w","end"));if(i&&(t.right=i),Object.keys(t).length!==0)return t}function dt(e){if(!e)return;let t={},n=s(e,"w","fill");n&&n!=="auto"&&(t.fill={rgb:n});let o=s(e,"w","themeFill");if(o){t.fill={themeColor:o};let a=s(e,"w","themeFillTint");a&&t.fill&&(t.fill.themeTint=a);let f=s(e,"w","themeFillShade");f&&t.fill&&(t.fill.themeShade=f);}let r=s(e,"w","color");r&&r!=="auto"&&(t.color={rgb:r});let i=s(e,"w","val");if(i&&(t.pattern=i),Object.keys(t).length!==0)return t}function On(e){if(!e)return;let t={},n=s(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let o=s(e,"w","lastRow");(o==="1"||o==="true")&&(t.lastRow=true);let r=s(e,"w","firstColumn");(r==="1"||r==="true")&&(t.firstColumn=true);let i=s(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let a=s(e,"w","noHBand");(a==="1"||a==="true")&&(t.noHBand=true);let f=s(e,"w","noVBand");(f==="1"||f==="true")&&(t.noVBand=true);let u=s(e,"w","val");if(u){let c=parseInt(u,16);isNaN(c)||(c&32&&(t.firstRow=true),c&64&&(t.lastRow=true),c&128&&(t.firstColumn=true),c&256&&(t.lastColumn=true),c&512&&(t.noHBand=true),c&1024&&(t.noVBand=true));}if(Object.keys(t).length!==0)return t}function jn(e){if(!e)return;let t={},n=s(e,"w","horzAnchor");(n==="margin"||n==="page"||n==="text")&&(t.horzAnchor=n);let o=s(e,"w","vertAnchor");(o==="margin"||o==="page"||o==="text")&&(t.vertAnchor=o);let r=g(e,"w","tblpX");r!==void 0&&(t.tblpX=r);let i=s(e,"w","tblpXSpec");i&&(t.tblpXSpec=i);let a=g(e,"w","tblpY");a!==void 0&&(t.tblpY=a);let f=s(e,"w","tblpYSpec");f&&(t.tblpYSpec=f);let u=g(e,"w","topFromText");u!==void 0&&(t.topFromText=u);let c=g(e,"w","bottomFromText");c!==void 0&&(t.bottomFromText=c);let d=g(e,"w","leftFromText");d!==void 0&&(t.leftFromText=d);let p=g(e,"w","rightFromText");if(p!==void 0&&(t.rightFromText=p),Object.keys(t).length!==0)return t}function Wn(e){if(!e)return;let t={},n=Y(l(e,"w","tblW"));n&&(t.width=n);let o=l(e,"w","jc");if(o){let T=s(o,"w","val");(T==="left"||T==="center"||T==="right"||T==="start")&&(t.justification=T==="start"?"left":T);}let r=Y(l(e,"w","tblCellSpacing"));r&&(t.cellSpacing=r);let i=Y(l(e,"w","tblInd"));i&&(t.indent=i);let a=ut(l(e,"w","tblBorders"));a&&(t.borders=a);let f=ct(l(e,"w","tblCellMar"));f&&(t.cellMargins=f);let u=l(e,"w","tblLayout");if(u){let T=s(u,"w","type");(T==="fixed"||T==="autofit")&&(t.layout=T);}let c=l(e,"w","tblStyle");if(c){let T=s(c,"w","val");T&&(t.styleId=T);}let d=On(l(e,"w","tblLook"));d&&(t.look=d);let p=dt(l(e,"w","shd"));p&&(t.shading=p);let y=l(e,"w","tblOverlap");if(y){let T=s(y,"w","val");(T==="never"||T==="overlap")&&(t.overlap=T);}let b=jn(l(e,"w","tblpPr"));if(b&&(t.floating=b),x(l(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length!==0)return t}function Vn(e){if(!e)return;let t={},n=l(e,"w","trHeight");if(n){let f=Y(n);f&&(t.height=f);let u=s(n,"w","hRule");(u==="auto"||u==="atLeast"||u==="exact")&&(t.heightRule=u);}x(l(e,"w","tblHeader"))&&(t.header=true),x(l(e,"w","cantSplit"))&&(t.cantSplit=true);let i=l(e,"w","jc");if(i){let f=s(i,"w","val");(f==="left"||f==="center"||f==="right")&&(t.justification=f);}if(x(l(e,"w","hidden"))&&(t.hidden=true),Object.keys(t).length!==0)return t}function zn(e){if(!e)return;let t={},n=s(e,"w","firstRow");(n==="1"||n==="true")&&(t.firstRow=true);let o=s(e,"w","lastRow");(o==="1"||o==="true")&&(t.lastRow=true);let r=s(e,"w","firstColumn");(r==="1"||r==="true")&&(t.firstColumn=true);let i=s(e,"w","lastColumn");(i==="1"||i==="true")&&(t.lastColumn=true);let a=s(e,"w","oddHBand");(a==="1"||a==="true")&&(t.oddHBand=true);let f=s(e,"w","evenHBand");(f==="1"||f==="true")&&(t.evenHBand=true);let u=s(e,"w","oddVBand");(u==="1"||u==="true")&&(t.oddVBand=true);let c=s(e,"w","evenVBand");(c==="1"||c==="true")&&(t.evenVBand=true);let d=s(e,"w","firstRowFirstColumn");(d==="1"||d==="true")&&(t.nwCell=true);let p=s(e,"w","firstRowLastColumn");(p==="1"||p==="true")&&(t.neCell=true);let y=s(e,"w","lastRowFirstColumn");(y==="1"||y==="true")&&(t.swCell=true);let b=s(e,"w","lastRowLastColumn");(b==="1"||b==="true")&&(t.seCell=true);let m=s(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 $n(e){if(!e)return;let t={},n=Y(l(e,"w","tcW"));n&&(t.width=n);let o=ut(l(e,"w","tcBorders"));o&&(t.borders=o);let r=ct(l(e,"w","tcMar"));r&&(t.margins=r);let i=dt(l(e,"w","shd"));i&&(t.shading=i);let a=l(e,"w","vAlign");if(a){let m=s(a,"w","val");(m==="top"||m==="center"||m==="bottom")&&(t.verticalAlign=m);}let f=l(e,"w","textDirection");if(f){let m=s(f,"w","val");m&&(t.textDirection=m);}let u=l(e,"w","gridSpan");if(u){let m=g(u,"w","val");m!==void 0&&m>1&&(t.gridSpan=m);}let c=l(e,"w","vMerge");c&&(s(c,"w","val")==="restart"?t.vMerge="restart":t.vMerge="continue"),x(l(e,"w","tcFitText"))&&(t.fitText=true),x(l(e,"w","noWrap"))&&(t.noWrap=true),x(l(e,"w","hideMark"))&&(t.hideMark=true);let b=zn(l(e,"w","cnfStyle"));if(b&&(t.conditionalFormat=b),Object.keys(t).length!==0)return t}function Un(e,t,n,o,r,i){let a=[],f=e.elements||[];for(let u of f){if(!u.name)continue;let c=u.name.split(":").pop();if(c==="p"){let d=K(u,t,n,o,r,i);a.push(d);}else if(c==="tbl"){let d=te(u,t,n,o,r,i);a.push(d);}}return a.length===0&&a.push({type:"paragraph",content:[]}),a}function _n(e,t,n,o,r,i){let a={type:"tableCell",content:[]},f=$n(l(e,"w","tcPr"));return f&&(a.formatting=f),a.content=Un(e,t,n,o,r,i),a}function Gn(e,t,n,o,r,i){let a={type:"tableRow",cells:[]},f=Vn(l(e,"w","trPr"));f&&(a.formatting=f);let u=B(e,"w","tc");for(let c of u){let d=_n(c,t,n,o,r,i);a.cells.push(d);}return a}function qn(e){if(!e)return;let t=[],n=B(e,"w","gridCol");for(let o of n){let r=g(o,"w","w")??0;t.push(r);}return t.length>0?t:void 0}function te(e,t,n,o,r,i){let a={type:"table",rows:[]},f=Wn(l(e,"w","tblPr"));f&&(a.formatting=f);let u=qn(l(e,"w","tblGrid"));u&&(a.columnWidths=u);let c=B(e,"w","tr");for(let d of c){let p=Gn(d,t,n,o,r,i);a.rows.push(p);}return a}function pt(e){switch(e){case "first":return "first";case "even":return "even";default:return "default"}}function mt(e){let t=s(e,"w","type"),n=s(e,"r","id")??"";return {type:pt(t),rId:n}}function gt(e){let t=s(e,"w","type"),n=s(e,"r","id")??"";return {type:pt(t),rId:n}}function Me(e,t,n,o,r,i){let a=[],f=e.elements??[];for(let u of f){if(u.type!=="element")continue;let c=u.name??"";if(c==="w:p"||c.endsWith(":p")){let d=K(u,t,n,o,r,i);a.push(d);}else if(c==="w:tbl"||c.endsWith(":tbl")){let d=te(u,t,n,o,r,i);a.push(d);}else if(c==="w:sdt"||c.endsWith(":sdt")){let d=(u.elements??[]).find(p=>p.type==="element"&&(p.name==="w:sdtContent"||p.name?.endsWith(":sdtContent")));if(d){let p=Me(d,t,n,o,r,i);a.push(...p);}}}return a}function ht(e,t="default",n=null,o=null,r=null,i=null,a=null){let f={type:"header",hdrFtrType:t,content:[]};if(!e)return f;let u=G(e);if(!u)return f;let c=u.elements?.find(d=>d.type==="element"&&(d.name==="w:hdr"||d.name?.endsWith(":hdr")));return c&&(f.content=Me(c,n,o,r,i,a)),f}function wt(e,t="default",n=null,o=null,r=null,i=null,a=null){let f={type:"footer",hdrFtrType:t,content:[]};if(!e)return f;let u=G(e);if(!u)return f;let c=u.elements?.find(d=>d.type==="element"&&(d.name==="w:ftr"||d.name?.endsWith(":ftr")));return c&&(f.content=Me(c,n,o,r,i,a)),f}function bt(e){switch(e){case "separator":return "separator";case "continuationSeparator":return "continuationSeparator";case "continuationNotice":return "continuationNotice";default:return "normal"}}function Zn(e,t,n,o,r,i){let a=g(e,"w","id")??0,f=s(e,"w","type"),u=bt(f),d=B(e,"w","p").map(p=>K(p,t,n,o,r));return {type:"footnote",id:a,noteType:u,content:d}}function yt(e,t=null,n=null,o=null,r=null,i=null){let a=new Map,f=[];if(!e)return ue(a,f);let u=G(e);if(!u)return ue(a,f);let c=u.elements?.find(p=>p.type==="element"&&(p.name==="w:footnotes"||p.name?.endsWith(":footnotes")));if(!c)return ue(a,f);let d=B(c,"w","footnote");for(let p of d){let y=Zn(p,t,n,o,r);a.set(y.id,y),f.push(y);}return ue(a,f)}function ue(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 Yn(e,t,n,o,r,i){let a=g(e,"w","id")??0,f=s(e,"w","type"),u=bt(f),d=B(e,"w","p").map(p=>K(p,t,n,o,r));return {type:"endnote",id:a,noteType:u,content:d}}function xt(e,t=null,n=null,o=null,r=null,i=null){let a=new Map,f=[];if(!e)return ce(a,f);let u=G(e);if(!u)return ce(a,f);let c=u.elements?.find(p=>p.type==="element"&&(p.name==="w:endnotes"||p.name?.endsWith(":endnotes")));if(!c)return ce(a,f);let d=B(c,"w","endnote");for(let p of d){let y=Yn(p,t,n,o,r);a.set(y.id,y),f.push(y);}return ce(a,f)}function ce(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 Tt(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 Kn(e){switch(e){case "pageBottom":return "pageBottom";case "beneathText":return "beneathText";case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function Jn(e){switch(e){case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function Ft(e){switch(e){case "continuous":return "continuous";case "eachSect":return "eachSect";case "eachPage":return "eachPage";default:return}}function Ct(e){let t={};if(!e)return t;let n=l(e,"w","pos");if(n){let a=s(n,"w","val");t.position=Kn(a);}let o=l(e,"w","numFmt");if(o){let a=s(o,"w","val");t.numFmt=Tt(a);}let r=l(e,"w","numStart");r&&(t.numStart=g(r,"w","val")??void 0);let i=l(e,"w","numRestart");if(i){let a=s(i,"w","val");t.numRestart=Ft(a);}return t}function St(e){let t={};if(!e)return t;let n=l(e,"w","pos");if(n){let a=s(n,"w","val");t.position=Jn(a);}let o=l(e,"w","numFmt");if(o){let a=s(o,"w","val");t.numFmt=Tt(a);}let r=l(e,"w","numStart");r&&(t.numStart=g(r,"w","val")??void 0);let i=l(e,"w","numRestart");if(i){let a=s(i,"w","val");t.numRestart=Ft(a);}return t}function Qn(e,t,n,o){if(!e&&!t)return;let r={};return e&&e!=="auto"?r.rgb=e:e==="auto"&&(r.auto=true),t&&(r.themeColor=t),n&&(r.themeTint=n),o&&(r.themeShade=o),Object.keys(r).length>0?r:void 0}function de(e){if(!e)return;let o={style:s(e,"w","val")??"none"},r=g(e,"w","sz");r!==void 0&&(o.size=r);let i=g(e,"w","space");i!==void 0&&(o.space=i);let a=s(e,"w","color"),f=s(e,"w","themeColor"),u=s(e,"w","themeTint"),c=s(e,"w","themeShade"),d=Qn(a,f,u,c);d&&(o.color=d);let p=s(e,"w","shadow");(p==="1"||p==="true")&&(o.shadow=true);let y=s(e,"w","frame");return (y==="1"||y==="true")&&(o.frame=true),o}function eo(e){switch(e){case "landscape":return "landscape";case "portrait":return "portrait";default:return}}function to(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 no(e){switch(e){case "top":return "top";case "center":return "center";case "both":return "both";case "bottom":return "bottom";default:return}}function oo(e){switch(e){case "continuous":return "continuous";case "newPage":return "newPage";case "newSection":return "newSection";default:return}}function pe(e,t){let n={};if(!e)return n;let o=l(e,"w","pgSz");if(o){let h=g(o,"w","w");h!==void 0&&(n.pageWidth=h);let F=g(o,"w","h");F!==void 0&&(n.pageHeight=F);let w=s(o,"w","orient"),S=eo(w);S&&(n.orientation=S);}let r=l(e,"w","pgMar");if(r){let h=g(r,"w","top");h!==void 0&&(n.marginTop=h);let F=g(r,"w","bottom");F!==void 0&&(n.marginBottom=F);let w=g(r,"w","left");w!==void 0&&(n.marginLeft=w);let S=g(r,"w","right");S!==void 0&&(n.marginRight=S);let M=g(r,"w","header");M!==void 0&&(n.headerDistance=M);let E=g(r,"w","footer");E!==void 0&&(n.footerDistance=E);let P=g(r,"w","gutter");P!==void 0&&(n.gutter=P);}let i=l(e,"w","cols");if(i){let h=g(i,"w","num");h!==void 0&&(n.columnCount=h);let F=g(i,"w","space");F!==void 0&&(n.columnSpace=F);let w=s(i,"w","equalWidth");w==="1"||w==="true"?n.equalWidth=true:(w==="0"||w==="false")&&(n.equalWidth=false);let S=s(i,"w","sep");(S==="1"||S==="true")&&(n.separator=true);let M=B(i,"w","col");if(M.length>0){n.columns=[];for(let E of M){let P={},X=g(E,"w","w");X!==void 0&&(P.width=X);let H=g(E,"w","space");H!==void 0&&(P.space=H),n.columns.push(P);}}}let a=l(e,"w","type");if(a){let h=s(a,"w","val"),F=to(h);F&&(n.sectionStart=F);}let f=l(e,"w","vAlign");if(f){let h=s(f,"w","val"),F=no(h);F&&(n.verticalAlign=F);}let u=l(e,"w","bidi");u&&(n.bidi=x(u));let c=B(e,"w","headerReference");c.length>0&&(n.headerReferences=c.map(h=>mt(h)));let d=B(e,"w","footerReference");d.length>0&&(n.footerReferences=d.map(h=>gt(h)));let p=l(e,"w","titlePg");p&&(n.titlePg=x(p));let y=l(e,"w","evenAndOddHeaders");y&&(n.evenAndOddHeaders=x(y));let b=l(e,"w","lnNumType");if(b){n.lineNumbers={};let h=g(b,"w","start");h!==void 0&&(n.lineNumbers.start=h);let F=g(b,"w","countBy");F!==void 0&&(n.lineNumbers.countBy=F);let w=g(b,"w","distance");w!==void 0&&(n.lineNumbers.distance=w);let S=s(b,"w","restart"),M=oo(S);M&&(n.lineNumbers.restart=M);}let m=l(e,"w","pgBorders");if(m){n.pageBorders={};let h=de(l(m,"w","top"));h&&(n.pageBorders.top=h);let F=de(l(m,"w","bottom"));F&&(n.pageBorders.bottom=F);let w=de(l(m,"w","left"));w&&(n.pageBorders.left=w);let S=de(l(m,"w","right"));S&&(n.pageBorders.right=S);let M=s(m,"w","display");(M==="allPages"||M==="firstPage"||M==="notFirstPage")&&(n.pageBorders.display=M);let E=s(m,"w","offsetFrom");(E==="page"||E==="text")&&(n.pageBorders.offsetFrom=E);let P=s(m,"w","zOrder");(P==="front"||P==="back")&&(n.pageBorders.zOrder=P);}let T=l(e,"w","background");if(T){n.background={};let h=s(T,"w","color");h&&h!=="auto"&&(n.background.color={rgb:h});let F=s(T,"w","themeColor");F&&(n.background.themeColor=F);let w=s(T,"w","themeTint");w&&(n.background.themeTint=w);let S=s(T,"w","themeShade");S&&(n.background.themeShade=S);}let N=l(e,"w","footnotePr");if(N){let h=Ct(N);Object.keys(h).length>0&&(n.footnotePr=h);}let A=l(e,"w","endnotePr");if(A){let h=St(A);Object.keys(h).length>0&&(n.endnotePr=h);}let R=l(e,"w","docGrid");if(R){n.docGrid={};let h=s(R,"w","type");(h==="default"||h==="lines"||h==="linesAndChars"||h==="snapToChars")&&(n.docGrid.type=h);let F=g(R,"w","linePitch");F!==void 0&&(n.docGrid.linePitch=F);let w=g(R,"w","charSpace");w!==void 0&&(n.docGrid.charSpace=w);}let v=l(e,"w","paperSrc");if(v){let h=g(v,"w","first");h!==void 0&&(n.paperSrcFirst=h);let F=g(v,"w","other");F!==void 0&&(n.paperSrcOther=F);}return n}function kt(){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 ro(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||!io(e.underline,t.underline)||!me(e.color,t.color)||!ao(e.shading,t.shading)||!so(e.fontFamily,t.fontFamily))}function io(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 ao(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 lo(e){return e.type==="text"||e.type==="softHyphen"||e.type==="noBreakHyphen"}function Mt(e){return e.content.length===0?true:e.content.every(lo)}function fo(e,t){let n=[];for(let o of e)n.push(o);if(n.length>0&&t.length>0&&n[n.length-1].type==="text"&&t[0].type==="text"){let o=n[n.length-1],r=t[0];n[n.length-1]={type:"text",text:o.text+r.text,preserveSpace:o.preserveSpace||r.preserveSpace||void 0};for(let i=1;i<t.length;i++)n.push(t[i]);}else for(let o of t)n.push(o);return n}function uo(e){if(e.length<=1)return e;let t=[],n=null;for(let o of e)if(o.content.length!==0){if(n===null){n={...o,content:[...o.content]};continue}Mt(n)&&Mt(o)&&ro(n.formatting,o.formatting)?n={type:"run",formatting:n.formatting,content:fo(n.content,o.content)}:(t.push(n),n={...o,content:[...o.content]});}return n!==null&&t.push(n),t}function ve(e){if(e.length<=1)return e;let t=[],n=[];function o(){if(n.length>0){let r=uo(n);t.push(...r),n.length=0;}}for(let r of e)if(r.type==="run")n.push(r);else if(o(),r.type==="hyperlink"){let i={...r,children:ve(r.children)};t.push(i);}else t.push(r);return o(),t}function co(e,t,n,o){let r={};return e&&e!=="auto"?r.rgb=e:e==="auto"&&(r.auto=true),t&&(r.themeColor=t),n&&(r.themeTint=n),o&&(r.themeShade=o),r}function po(e){if(!e)return;let t={},n=s(e,"w","color");n&&n!=="auto"&&(t.color={rgb:n});let o=s(e,"w","fill");o&&o!=="auto"&&(t.fill={rgb:o});let r=s(e,"w","themeFill");r&&(t.fill=t.fill||{},t.fill.themeColor=r);let i=s(e,"w","themeFillTint");i&&t.fill&&(t.fill.themeTint=i);let a=s(e,"w","themeFillShade");a&&t.fill&&(t.fill.themeShade=a);let f=s(e,"w","val");return f&&(t.pattern=f),Object.keys(t).length>0?t:void 0}function Q(e){if(!e)return;let t=s(e,"w","val");if(!t)return;let n={style:t},o=s(e,"w","color"),r=s(e,"w","themeColor");(o||r)&&(n.color=co(o,r,s(e,"w","themeTint"),s(e,"w","themeShade")));let i=g(e,"w","sz");i!==void 0&&(n.size=i);let a=g(e,"w","space");a!==void 0&&(n.space=a);let f=s(e,"w","shadow");f&&(n.shadow=f==="1"||f==="true");let u=s(e,"w","frame");return u&&(n.frame=u==="1"||u==="true"),n}function mo(e){if(!e)return;let t=B(e,"w","tab");if(t.length===0)return;let n=[];for(let o of t){let r=g(o,"w","pos"),i=s(o,"w","val");if(r!==void 0&&i){let a={position:r,alignment:i},f=s(o,"w","leader");f&&(a.leader=f),n.push(a);}}return n.length>0?n:void 0}function go(e){if(!e)return;let t={},n=g(e,"w","w");n!==void 0&&(t.width=n);let o=g(e,"w","h");o!==void 0&&(t.height=o);let r=s(e,"w","hAnchor");(r==="text"||r==="margin"||r==="page")&&(t.hAnchor=r);let i=s(e,"w","vAnchor");(i==="text"||i==="margin"||i==="page")&&(t.vAnchor=i);let a=g(e,"w","x");a!==void 0&&(t.x=a);let f=g(e,"w","y");f!==void 0&&(t.y=f);let u=s(e,"w","xAlign");u&&(t.xAlign=u);let c=s(e,"w","yAlign");c&&(t.yAlign=c);let d=s(e,"w","wrap");return d&&(t.wrap=d),Object.keys(t).length>0?t:void 0}function ho(e,t,n){if(!e)return;let o={},r=l(e,"w","jc");if(r){let w=s(r,"w","val");w&&(o.alignment=w);}let i=l(e,"w","bidi");i&&(o.bidi=x(i));let a=l(e,"w","spacing");if(a){let w=g(a,"w","before");w!==void 0&&(o.spaceBefore=w);let S=g(a,"w","after");S!==void 0&&(o.spaceAfter=S);let M=g(a,"w","line");M!==void 0&&(o.lineSpacing=M);let E=s(a,"w","lineRule");E&&(o.lineSpacingRule=E);let P=s(a,"w","beforeAutospacing");P&&(o.beforeAutospacing=P==="1"||P==="true");let X=s(a,"w","afterAutospacing");X&&(o.afterAutospacing=X==="1"||X==="true");}let f=l(e,"w","ind");if(f){let w=g(f,"w","left");w!==void 0&&(o.indentLeft=w);let S=g(f,"w","right");S!==void 0&&(o.indentRight=S);let M=g(f,"w","firstLine");M!==void 0&&(o.indentFirstLine=M);let E=g(f,"w","hanging");E!==void 0&&(o.indentFirstLine=-E,o.hangingIndent=true);let P=g(f,"w","start");P!==void 0&&o.indentLeft===void 0&&(o.indentLeft=P);let X=g(f,"w","end");X!==void 0&&o.indentRight===void 0&&(o.indentRight=X);}let u=l(e,"w","pBdr");if(u){let w={},S=Q(l(u,"w","top"));S&&(w.top=S);let M=Q(l(u,"w","bottom"));M&&(w.bottom=M);let E=Q(l(u,"w","left"));E&&(w.left=E);let P=Q(l(u,"w","right"));P&&(w.right=P);let X=Q(l(u,"w","between"));X&&(w.between=X);let H=Q(l(u,"w","bar"));H&&(w.bar=H),Object.keys(w).length>0&&(o.borders=w);}let c=l(e,"w","shd");c&&(o.shading=po(c));let d=l(e,"w","tabs");d&&(o.tabs=mo(d));let p=l(e,"w","keepNext");p&&(o.keepNext=x(p));let y=l(e,"w","keepLines");y&&(o.keepLines=x(y));let b=l(e,"w","widowControl");b&&(o.widowControl=x(b));let m=l(e,"w","pageBreakBefore");m&&(o.pageBreakBefore=x(m));let T=l(e,"w","numPr");if(T){let w=l(T,"w","numId"),S=l(T,"w","ilvl");if(w||S){if(o.numPr={},w){let M=g(w,"w","val");M!==void 0&&(o.numPr.numId=M);}if(S){let M=g(S,"w","val");M!==void 0&&(o.numPr.ilvl=M);}}}let N=l(e,"w","outlineLvl");if(N){let w=g(N,"w","val");w!==void 0&&(o.outlineLevel=w);}let A=l(e,"w","pStyle");if(A){let w=s(A,"w","val");w&&(o.styleId=w);}let R=l(e,"w","framePr");R&&(o.frame=go(R));let v=l(e,"w","suppressLineNumbers");v&&(o.suppressLineNumbers=x(v));let h=l(e,"w","suppressAutoHyphens");h&&(o.suppressAutoHyphens=x(h));let F=l(e,"w","rPr");return F&&(o.runProperties=ke(F,t)),Object.keys(o).length>0?o:void 0}function vt(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function wo(e,t,n,o,r){return st(e,t,n,o,r)}function bo(e){return lt(e)}function yo(e){return ft(e)}function Rt(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 xo(e,t,n,o,r){let i=s(e,"w","instr")??"",a=Rt(i),f={type:"simpleField",instruction:i,fieldType:a,content:[]},u=s(e,"w","fldLock");(u==="1"||u==="true")&&(f.fldLock=true);let c=s(e,"w","dirty");(c==="1"||c==="true")&&(f.dirty=true);let d=D(e);for(let p of d)vt(p.name)==="r"&&f.content.push(ee(p,t,n,o,r));return f}function Et(e,t,n,o,r,i){let a=[],f=D(e),u=false,c="",d=[],p=[],y=false,b=false,m=false;for(let T of f)switch(vt(T.name)){case "r":{let A=ee(T,t,n,r,i),R=false,v=false,h=false,F="";for(let w of A.content)w.type==="fieldChar"?w.charType==="begin"?(R=true,w.fldLock&&(b=true),w.dirty&&(m=true)):w.charType==="separate"?v=true:w.charType==="end"&&(h=true):w.type==="instrText"&&(F+=w.text);if(R&&(u=true,y=false,c="",d=[],p=[],b=false,m=false),u){if(F&&(c+=F),v&&(y=true),y&&!h?v||p.push(A):!y&&!R&&d.push(A),h){let w={type:"complexField",instruction:c.trim(),fieldType:Rt(c),fieldCode:d,fieldResult:p};b&&(w.fldLock=true),m&&(w.dirty=true),a.push(w),u=false;}}else a.push(A);break}case "hyperlink":a.push(wo(T,r,t,n,i));break;case "bookmarkStart":a.push(bo(T));break;case "bookmarkEnd":a.push(yo(T));break;case "fldSimple":a.push(xo(T,t,n,r,i));break;case "pPr":break;case "proofErr":case "permStart":case "permEnd":case "customXml":break;case "sdt":{let A=(T.elements??[]).find(R=>R.type==="element"&&(R.name==="w:sdtContent"||R.name?.endsWith(":sdtContent")));if(A){let R=Et(A,t,n,null,r,i);a.push(...R);}break}}return a}function K(e,t,n,o,r=null,i=null){let a={type:"paragraph",content:[]},f=s(e,"w14","paraId")??s(e,"w","paraId");f&&(a.paraId=f);let u=s(e,"w14","textId")??s(e,"w","textId");u&&(a.textId=u);let c=l(e,"w","pPr");if(c){a.formatting=ho(c,n);let p=l(c,"w","sectPr");p&&(a.sectionProperties=pe(p));}let d=Et(e,t,n,o,r,i);if(a.content=ve(d),a.formatting?.numPr&&o){let{numId:p,ilvl:y=0}=a.formatting.numPr;if(p!==void 0&&p!==0){let b=o.getLevel(p,y);b&&(a.listRendering={level:y,numId:p,marker:b.lvlText,isBullet:b.numFmt==="bullet",numFmt:b.numFmt},b.pPr&&(a.formatting||(a.formatting={}),b.pPr.indentLeft!==void 0&&(a.formatting.indentLeft=b.pPr.indentLeft),b.pPr.indentFirstLine!==void 0&&(a.formatting.indentFirstLine=b.pPr.indentFirstLine),b.pPr.hangingIndent!==void 0&&(a.formatting.hangingIndent=b.pPr.hangingIndent)));}}return a}function Re(e){let t="";for(let n of e.content)if(n.type==="run")for(let o of n.content)o.type==="text"?t+=o.text:o.type==="tab"?t+=" ":o.type==="break"&&(o.breakType==="page"?t+="\f":t+=`
|
|
10
|
+
`);else if(n.type==="hyperlink"){for(let o of n.children)if(o.type==="run")for(let r of o.content)r.type==="text"&&(t+=r.text);}else if(n.type==="simpleField"){for(let o of n.content)if(o.type==="run")for(let r of o.content)r.type==="text"&&(t+=r.text);}else if(n.type==="complexField")for(let o of n.fieldResult)for(let r of o.content)r.type==="text"&&(t+=r.text);return t}function To(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 Fo(e,t,n){let o=e.listRendering;if(!o||!t)return;let{numId:r,level:i}=o;if(r===void 0||r===0)return;n.has(r)||n.set(r,new Array(9).fill(0));let a=n.get(r);a[i]=(a[i]||0)+1;for(let c=i+1;c<a.length;c++)a[c]=0;let f=o.marker;if(o.isBullet){let c=f||"";o.marker=To(c);return}let u=f;for(let c=0;c<=i;c++){let d=`%${c+1}`;if(u.includes(d)){let p=a[c],y=t.getLevel(r,c),b=Co(p,y?.numFmt||"decimal");u=u.replace(d,b);}}o.marker=u;}function Co(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 Pt(e).toLowerCase();case "upperRoman":return Pt(e);case "bullet":return "\u2022";default:return String(e)}}function Pt(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[o,r]of t)for(;e>=o;)n+=r,e-=o;return n}var At=/\{\{([^{}]+)\}\}/g;function Bt(e){let t=[],n;for(At.lastIndex=0;(n=At.exec(e))!==null;){let o=n[1].trim();o&&!t.includes(o)&&t.push(o);}return t}function Nt(e){let t=[];for(let n of e)if(n.type==="paragraph"){let o=Re(n),r=Bt(o);for(let i of r)t.includes(i)||t.push(i);}else if(n.type==="table"){let o=Xt(n);for(let r of o)t.includes(r)||t.push(r);}return t}function Xt(e){let t=[];for(let n of e.rows)for(let o of n.cells)for(let r of o.content)if(r.type==="paragraph"){let i=Re(r),a=Bt(i);for(let f of a)t.includes(f)||t.push(f);}else if(r.type==="table"){let i=Xt(r);for(let a of i)t.includes(a)||t.push(a);}return t}function Lt(e,t,n,o,r,i){let a=[],f=D(e),u=new Map;for(let c of f){let d=c.name??"";if(d==="w:p"||d.endsWith(":p")){let p=K(c,t,n,o,r,i);Fo(p,o,u),a.push(p);}else if(d==="w:tbl"||d.endsWith(":tbl")){let p=te(c,t,n,o,r,i);a.push(p);}else if(d==="w:sdt"||d.endsWith(":sdt")){let p=(c.elements??[]).find(y=>y.type==="element"&&(y.name==="w:sdtContent"||y.name?.endsWith(":sdtContent")));if(p){let y=Lt(p,t,n,o,r,i);a.push(...y);}}}return a}function So(e,t){let n=[],o=[];for(let r of e)o.push(r),r.type==="paragraph"&&r.sectionProperties&&(n.push({properties:r.sectionProperties,content:o}),o=[]);return (o.length>0||n.length===0)&&n.push({properties:t??kt(),content:o}),n}function It(e,t=null,n=null,o=null,r=null,i=null){let a={content:[]};if(!e)return a;let f=G(e);if(!f)return a;let u=(f.elements??[]).find(p=>p.type==="element"&&(p.name==="w:document"||p.name?.endsWith(":document")));if(!u)return a;let c=l(u,"w","body");if(!c)return a;a.content=Lt(c,t,n,o,r,i);let d=l(c,"w","sectPr");return d&&(a.finalSectionProperties=pe(d)),a.sections=So(a.content,a.finalSectionProperties),a}async function _r(e,t={}){let{onProgress:n=()=>{},preloadFonts:o=true,parseHeadersFooters:r=true,parseNotes:i=true,detectVariables:a=true}=t,f=[];try{let p=function(I,O){let $=performance.now(),U=O(),C=performance.now()-$;return d.push({stage:I,ms:C}),C>1e3&&console.warn(`[parseDocx] ${I} took ${Math.round(C)}ms`),U};var u=p;let c=performance.now(),d=[];async function y(I,O){let $=performance.now(),U=await O(),C=performance.now()-$;return d.push({stage:I,ms:C}),C>1e3&&console.warn(`[parseDocx] ${I} took ${Math.round(C)}ms`),U}n("Extracting DOCX...",0);let b=await y("unzip",()=>Ne(e));n("Extracted DOCX",10),n("Parsing relationships...",10);let m=p("relationships",()=>b.documentRels?ae(b.documentRels):new Map);n("Parsed relationships",15),n("Parsing theme...",15);let T=p("theme",()=>je(b.themeXml));n("Parsed theme",20),n("Parsing styles...",20);let N=null,A;p("styles",()=>{b.stylesXml&&(N=Ce(b.stylesXml,T),A=qe(b.stylesXml,T));}),n("Parsed styles",30),n("Parsing numbering...",30);let R=p("numbering",()=>Ze(b.numberingXml));n("Parsed numbering",35),n("Processing media files...",35);let v=p("media",()=>ko(b,m));n("Processed media",40),n("Parsing document body...",40);let h={content:[]};p("documentBody",()=>{b.documentXml?h=It(b.documentXml,N,T,R,m,v):f.push("No document.xml found in DOCX");}),n("Parsed document body",55);let F,w;if(r){n("Parsing headers/footers...",55);let I=p("headersFooters",()=>Mo(b,N,T,R,m,v));F=I.headers,w=I.footers,n("Parsed headers/footers",65);}else n("Skipping headers/footers",65);let S,M;if(i){n("Parsing footnotes/endnotes...",65);let I=p("footnotesEndnotes",()=>vo(b,N,T,R,m,v));S=I.footnotes,M=I.endnotes,n("Parsed footnotes/endnotes",75);}else n("Skipping footnotes/endnotes",75);let E;a?(n("Detecting template variables...",75),E=p("variables",()=>Nt(h.content)),n("Detected variables",80)):n("Skipping variable detection",80),o?(n("Loading fonts...",80),await y("fonts",()=>Ro(T,A,h)),n("Loaded fonts",95)):n("Skipping font loading",95),n("Assembling document...",95);let X={package:{document:h,styles:A,theme:T,numbering:R.definitions,headers:F,footers:w,footnotes:S,endnotes:M,relationships:m,media:v},originalBuffer:e,templateVariables:E,warnings:f.length>0?f:void 0},H=performance.now()-c;if(H>2e3){let I=d.filter(O=>O.ms>100).map(O=>`${O.stage}: ${Math.round(O.ms)}ms`).join(", ");console.warn(`[parseDocx] Total: ${Math.round(H)}ms`+(I?` (${I})`:""));}return n("Complete",100),X}catch(c){let d=c instanceof Error?c.message:String(c);throw console.error("[parseDocx] Failed to parse DOCX:",d,c),new Error(`Failed to parse DOCX: ${d}`)}}function ko(e,t){let n=new Map;for(let[o,r]of e.media.entries()){let i=o.split("/").pop()||o,a=Xe(o),f=new Uint8Array(r),u="";for(let b=0;b<f.length;b++)u+=String.fromCharCode(f[b]);let c=btoa(u),d=`data:${a};base64,${c}`,p={path:o,filename:i,mimeType:a,data:r,dataUrl:d};n.set(o,p);let y=o.replace(/^word\//,"");y!==o&&n.set(y,p);}return n}function ge(e,t){let n=t.toLowerCase();for(let[o,r]of e.entries())if(o.toLowerCase()===n)return r}function Mo(e,t,n,o,r,i){let a=new Map,f=new Map;for(let[u,c]of r.entries())if(c.type===ie.header&&c.target){let d=c.target.split("/").pop()||c.target,p=ge(e.headers,d);if(p){let y=`word/_rels/${d}.rels`,b=ge(e.allXml,y),m=b?ae(b):r,T=ht(p,"default",t,n,o,m,i);a.set(u,T);}}else if(c.type===ie.footer&&c.target){let d=c.target.split("/").pop()||c.target,p=ge(e.footers,d);if(p){let y=`word/_rels/${d}.rels`,b=ge(e.allXml,y),m=b?ae(b):r,T=wt(p,"default",t,n,o,m,i);f.set(u,T);}}return {headers:a,footers:f}}function vo(e,t,n,o,r,i){let a=yt(e.footnotesXml,t,n,o,r,i),f=xt(e.endnotesXml,t,n,o,r,i);return {footnotes:a.getNormalFootnotes(),endnotes:f.getNormalEndnotes()}}async function Ro(e,t,n){let o=new Set;if(e?.fontScheme){let{majorFont:r,minorFont:i}=e.fontScheme;r?.latin&&o.add(r.latin),i?.latin&&o.add(i.latin);}if(t?.docDefaults?.rPr?.fontFamily?.ascii&&o.add(t.docDefaults.rPr.fontFamily.ascii),t?.styles)for(let r of t.styles)r.rPr?.fontFamily?.ascii&&o.add(r.rPr.fontFamily.ascii),r.rPr?.fontFamily?.hAnsi&&o.add(r.rPr.fontFamily.hAnsi);if(n.content){for(let r of n.content)if(r.type==="paragraph")for(let i of r.content)i.type==="run"&&i.formatting?.fontFamily&&(i.formatting.fontFamily.ascii&&o.add(i.formatting.fontFamily.ascii),i.formatting.fontFamily.hAnsi&&o.add(i.formatting.fontFamily.hAnsi));}if(o.size>0)try{await ye(Array.from(o));}catch(r){console.warn("Failed to load some fonts:",r);}}
|
|
11
|
+
exports.a=Pe;exports.b=Dt;exports.c=Eo;exports.d=Po;exports.e=Ao;exports.f=Bo;exports.g=No;exports.h=Xo;exports.i=Lo;exports.j=Io;exports.k=Jo;exports.l=_r;
|