@eigenpal/docx-js-editor 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/dist/FindReplaceDialog-46BE7Q2G.cjs +1 -0
- package/dist/{FindReplaceDialog-RWYDRWHF.js → FindReplaceDialog-UMXCBBST.js} +1 -1
- package/dist/{FootnotePropertiesDialog-BC6JIPDA.cjs → FootnotePropertiesDialog-OBQXOBJE.cjs} +1 -1
- package/dist/{FootnotePropertiesDialog-CWQF5EBK.js → FootnotePropertiesDialog-TYQGPWPX.js} +1 -1
- package/dist/{HyperlinkDialog-EG2BSLPD.cjs → HyperlinkDialog-22NH7ZLP.cjs} +1 -1
- package/dist/{HyperlinkDialog-YAVK64F4.js → HyperlinkDialog-UOERZIBM.js} +1 -1
- package/dist/{ImagePositionDialog-S6SMH7XH.js → ImagePositionDialog-52FDANUK.js} +1 -1
- package/dist/{ImagePositionDialog-IGYS5KMK.cjs → ImagePositionDialog-ZK5WFBRC.cjs} +1 -1
- package/dist/{ImagePropertiesDialog-VGV4E4SN.cjs → ImagePropertiesDialog-LU44RDIY.cjs} +1 -1
- package/dist/{ImagePropertiesDialog-UO5QUIBS.js → ImagePropertiesDialog-YPSLPSF6.js} +1 -1
- package/dist/{TablePropertiesDialog-WRM47JI6.cjs → TablePropertiesDialog-KMOYHPGF.cjs} +1 -1
- package/dist/{TablePropertiesDialog-VBOU4DID.js → TablePropertiesDialog-OUUJAA7D.js} +1 -1
- package/dist/{chunk-M7F2CUUD.js → chunk-3VOXZKGT.js} +1 -1
- package/dist/{chunk-OTG4NABM.js → chunk-5MWH4N7I.js} +1 -1
- package/dist/chunk-5WBRHVOE.js +258 -0
- package/dist/chunk-6YFGCUHU.js +4 -0
- package/dist/{chunk-MDPDH7KS.js → chunk-7H2HP242.js} +1 -1
- package/dist/{chunk-KVAT5SVD.js → chunk-CTYOM6BE.js} +1 -1
- package/dist/{chunk-A7VY2V4X.cjs → chunk-FYAWM7MP.cjs} +1 -1
- package/dist/{chunk-EPCZ24TY.cjs → chunk-IHZIA6JP.cjs} +1 -1
- package/dist/{chunk-PNMZPPPI.cjs → chunk-JGPRSZPI.cjs} +1 -1
- package/dist/chunk-JS7TPZTF.cjs +10 -0
- package/dist/chunk-L7UKJGRK.js +10 -0
- package/dist/{chunk-6MBDPZVD.js → chunk-MLSHZVL7.js} +2 -2
- package/dist/chunk-O7QVCJN6.cjs +4 -0
- package/dist/{chunk-W4DUKACP.cjs → chunk-OEOUMSWH.cjs} +3 -3
- package/dist/chunk-OWMXCVKB.js +1 -0
- package/dist/{chunk-XVFMG77A.cjs → chunk-PXC7ARQB.cjs} +1 -1
- package/dist/chunk-QVVLXLRZ.cjs +258 -0
- package/dist/{chunk-QHWHCIUW.js → chunk-R5SKERM2.js} +1 -1
- package/dist/{chunk-FLECKDK4.cjs → chunk-UAME5JHZ.cjs} +2 -2
- package/dist/chunk-VOWKSURW.cjs +1 -0
- package/dist/{chunk-CZ7W7MCM.cjs → chunk-VTAS7VZ6.cjs} +1 -1
- package/dist/{chunk-MMJD2DLL.js → chunk-WFWLPKQA.js} +1 -1
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.d.cts +7 -4
- package/dist/core-plugins.d.ts +7 -4
- package/dist/core-plugins.js +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/executor-ITYZTNSH.cjs +1 -0
- package/dist/executor-TC7CLATE.js +1 -0
- package/dist/headless.cjs +2 -2
- package/dist/headless.js +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/mcp-cli.js +21 -21
- package/dist/mcp.cjs +8 -8
- package/dist/mcp.js +1 -1
- package/dist/{processTemplate-QOEAXCKA.cjs → processTemplate-525HZL4S.cjs} +1 -1
- package/dist/{processTemplate-BHBTDAIC.js → processTemplate-RJN6452W.js} +1 -1
- package/dist/{react-Be1YOl4z.d.ts → react-BZxD04XV.d.ts} +2 -8
- package/dist/{react-DPuSVbgY.d.cts → react-D8eAYckC.d.cts} +2 -8
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/{selectionRects-LO3FJT47.js → selectionRects-42JURU6D.js} +1 -1
- package/dist/{selectionRects-I5JVL73G.cjs → selectionRects-XGMQBMC5.cjs} +1 -1
- package/dist/styles.css +1 -1
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.cts +1 -53
- package/dist/ui.d.ts +1 -53
- package/dist/ui.js +1 -1
- package/package.json +1 -2
- package/dist/FindReplaceDialog-BAACAU67.cjs +0 -1
- package/dist/chunk-3IYNTJO5.js +0 -1
- package/dist/chunk-6YLNNCRZ.cjs +0 -10
- package/dist/chunk-BVQ2QRHA.cjs +0 -4
- package/dist/chunk-COP5BIBZ.js +0 -10
- package/dist/chunk-E6XDMUAM.js +0 -4
- package/dist/chunk-MTX3EEBJ.js +0 -258
- package/dist/chunk-RTESADL3.cjs +0 -1
- package/dist/chunk-VN7XH644.cjs +0 -258
- package/dist/executor-44OB3DFD.js +0 -1
- package/dist/executor-U3BZPPGN.cjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import {useState,useCallback,useRef,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function _(){return {matchCase:false,matchWholeWord:false,useRegex:false}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function X(e,n){if(!e)return null;try{let t;n.useRegex?t=e:t=H(e),n.matchWholeWord&&(t=`\\b${t}\\b`);let c=n.matchCase?"g":"gi";return new RegExp(t,c)}catch{return null}}function D(e,n,t){if(!e||!n)return [];let c=[],i=n;t.matchCase||(i=n.toLowerCase());let f=v=>v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d;t.matchWholeWord?d=`\\b${f(i)}\\b`:d=f(i);let s=t.matchCase?"g":"gi",p=new RegExp(d,s),h;for(;(h=p.exec(e))!==null;)c.push({start:h.index,end:h.index+h[0].length}),h[0].length===0&&p.lastIndex++;return c}function me(e,n,t,c){let i=X(n,c);return i?e.replace(i,t):e}function be(e,n,t,c,i=0){let f=D(e,n,c),d=f.find(p=>p.start>=i)||f[0];return d?{content:e.substring(0,d.start)+t+e.substring(d.end),replaced:true,matchStart:d.start,matchEnd:d.start+t.length}:{content:e,replaced:false,matchStart:-1,matchEnd:-1}}function Se(e){return e?e.totalCount===0?"No results":e.totalCount===1?"1 match":`${e.currentIndex+1} of ${e.totalCount} matches`:""}function ye(e){return !e||e.trim()===""}function Ce(){return {currentMatchColor:"#FFFF00",otherMatchColor:"#FFFFAA"}}function k(e){if(!e||!e.content)return "";let n="";for(let t of e.content)t.type==="text"?n+=t.text||"":t.type==="tab"?n+=" ":t.type==="break"&&t.breakType==="textWrapping"&&(n+=`
|
|
2
|
-
`);return n}function Fe(e){if(!e||!e.content)return "";let n="";for(let t of e.content)if(t.type==="run")n+=k(t);else if(t.type==="hyperlink")for(let c of t.children||[])c.type==="run"&&(n+=k(c));return n}function Re(e,n,t){if(!e||!n)return [];let c=[],i=e.package?.document||e.package?.document;if(!i||!i.content)return c;let f=0;for(let d of i.content)if(d.type==="paragraph"){let s=q(d,n,t,f);c.push(...s),f++;}else if(d.type==="table")for(let s of d.rows||[])for(let p of s.cells||[])for(let h of p.content||[])h.type;return c}function q(e,n,t,c){let i=[],f=Fe(e);if(!f)return i;let d=D(f,n,t);for(let s of d){let p=Te(e,s.start);i.push({paragraphIndex:c,contentIndex:p.contentIndex,startOffset:p.offsetInContent,endOffset:p.offsetInContent+(s.end-s.start),text:f.substring(s.start,s.end)});}return i}function Te(e,n){if(!e||!e.content)return {contentIndex:0,runIndex:0,offsetInContent:n};let t=0,c=0;for(let i of e.content){let f="";if(i.type==="run")f=k(i);else if(i.type==="hyperlink")for(let s of i.children||[])s.type==="run"&&(f+=k(s));let d=f.length;if(t+d>n)return {contentIndex:c,runIndex:c,offsetInContent:n-t};t+=d,c++;}return {contentIndex:Math.max(0,e.content.length-1),runIndex:Math.max(0,e.content.length-1),offsetInContent:0}}function Ie(e,n){if(!e||!n)return;let t=e.querySelector(`[data-paragraph-index="${n.paragraphIndex}"]`);t&&t.scrollIntoView({behavior:"smooth",block:"center"});}function Ee(e){let[n,t]=useState({isOpen:false,searchText:"",replaceText:"",options:_(),matches:[],currentIndex:0,replaceMode:e?.initialReplaceMode??false}),c=useCallback(o=>{t(r=>({...r,isOpen:true,replaceMode:false,searchText:o||r.searchText,matches:[],currentIndex:0}));},[]),i=useCallback(o=>{t(r=>({...r,isOpen:true,replaceMode:true,searchText:o||r.searchText,matches:[],currentIndex:0}));},[]),f=useCallback(()=>{t(o=>({...o,isOpen:false}));},[]),d=useCallback(()=>{t(o=>({...o,isOpen:!o.isOpen}));},[]),s=useCallback(o=>{t(r=>({...r,searchText:o}));},[]),p=useCallback(o=>{t(r=>({...r,replaceText:o}));},[]),h=useCallback(o=>{t(r=>({...r,options:{...r.options,...o}}));},[]),v=useCallback((o,r=0)=>{let E=Math.max(0,Math.min(r,o.length-1));t(L=>({...L,matches:o,currentIndex:o.length>0?E:0})),e?.onMatchesChange?.(o),o.length>0?e?.onCurrentMatchChange?.(o[E],E):e?.onCurrentMatchChange?.(null,-1);},[e]),M=useCallback(()=>{let o=0;return t(r=>r.matches.length===0?r:(o=(r.currentIndex+1)%r.matches.length,{...r,currentIndex:o})),o},[]),N=useCallback(()=>{let o=0;return t(r=>r.matches.length===0?r:(o=r.currentIndex===0?r.matches.length-1:r.currentIndex-1,{...r,currentIndex:o})),o},[]),w=useCallback(o=>{t(r=>r.matches.length===0||o<0||o>=r.matches.length?r:{...r,currentIndex:o});},[]),x=useCallback(()=>n.matches.length===0?null:n.matches[n.currentIndex]||null,[n.matches,n.currentIndex]),O=useCallback(()=>n.matches.length>0,[n.matches.length]);return {state:n,openFind:c,openReplace:i,close:f,toggle:d,setSearchText:s,setReplaceText:p,setOptions:h,setMatches:v,goToNextMatch:M,goToPreviousMatch:N,goToMatch:w,getCurrentMatch:x,hasMatches:O}}var Me={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent",display:"flex",alignItems:"flex-start",justifyContent:"flex-end",zIndex:1e4,pointerEvents:"none"},Oe={backgroundColor:"white",borderRadius:"4px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.2)",minWidth:"360px",maxWidth:"440px",width:"100%",margin:"60px 20px 20px 20px",pointerEvents:"auto"},Le={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg-subtle)",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},ke={margin:0,fontSize:"14px",fontWeight:600,color:"var(--doc-text)"},Ne={background:"none",border:"none",fontSize:"18px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"2px 6px",lineHeight:1},we={padding:"16px"},Q={display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px"},Z={width:"60px",fontSize:"13px",color:"var(--doc-text)",flexShrink:0},Y={flex:1,padding:"8px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"13px",boxSizing:"border-box",outline:"none"},ee={...Y,borderColor:"var(--doc-link)",boxShadow:"0 0 0 2px rgba(5, 99, 193, 0.1)"},Pe={display:"flex",flexDirection:"column",gap:"6px",marginLeft:"8px"},B={padding:"6px 12px",borderRadius:"3px",fontSize:"12px",fontWeight:500,cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)",minWidth:"80px",textAlign:"center"},te={...B,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text-placeholder)",cursor:"not-allowed"},U={padding:"6px 10px",borderRadius:"3px",fontSize:"14px",cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)"},ne={...U,color:"var(--doc-border-input)",cursor:"not-allowed"},_e={display:"flex",gap:"16px",marginTop:"4px",marginLeft:"68px"},W={display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--doc-text-muted)",cursor:"pointer"},oe={width:"14px",height:"14px",cursor:"pointer"},re={marginLeft:"68px",fontSize:"12px",color:"var(--doc-text-muted)",marginBottom:"8px"},De={...re,color:"var(--doc-error)"},Ae=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"18 15 12 9 6 15"})}),We=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"6 9 12 15 18 9"})});function Ye({isOpen:e,onClose:n,onFind:t,onFindNext:c,onFindPrevious:i,onReplace:f,onReplaceAll:d,onHighlightMatches:s,onClearHighlights:p,initialSearchText:h="",replaceMode:v=false,currentResult:M,className:N,style:w}){let[x,O]=useState(""),[o,r]=useState(""),[E,L]=useState(v),[C,ae]=useState(false),[F,ce]=useState(false),[l,R]=useState(null),[ie,K]=useState(false),[se,z]=useState(false),P=useRef(null),$=useRef(null);useEffect(()=>{M!==void 0&&R(M);},[M]),useEffect(()=>{if(e){if(O(h),r(""),L(v),R(null),setTimeout(()=>{P.current?.focus(),P.current?.select();},100),h){let a=t(h,{matchCase:C,matchWholeWord:F});R(a),a?.matches&&s&&s(a.matches);}}else p&&p();},[e,h,v]);let S=useCallback(()=>{if(!x.trim()){R(null),p&&p();return}let a=t(x,{matchCase:C,matchWholeWord:F});R(a),a?.matches&&s?s(a.matches):p&&p();},[x,C,F,t,s,p]);useEffect(()=>{e&&x.trim()&&S();},[C,F]);let le=useCallback(a=>{O(a.target.value);},[]),de=useCallback(a=>{a.key==="Enter"?(a.preventDefault(),a.shiftKey?V():l?G():S()):a.key==="Escape"&&n();},[l,S,n]),pe=useCallback(a=>{a.key==="Enter"?(a.preventDefault(),j()):a.key==="Escape"&&n();},[n]),G=useCallback(()=>{if(!x.trim()){S();return}if(!l){S();return}if(c()&&l){let y=(l.currentIndex+1)%l.totalCount;R({...l,currentIndex:y});}},[x,l,S,c]),V=useCallback(()=>{if(!x.trim()){S();return}if(!l){S();return}if(i()&&l){let y=l.currentIndex===0?l.totalCount-1:l.currentIndex-1;R({...l,currentIndex:y});}},[x,l,S,i]),j=useCallback(()=>{if(!l||l.totalCount===0)return;if(f(o)){let y=t(x,{matchCase:C,matchWholeWord:F});R(y),y?.matches&&s&&s(y.matches);}},[l,o,x,C,F,f,t,s]),ue=useCallback(()=>{if(!x.trim())return;d(x,o,{matchCase:C,matchWholeWord:F})>0&&(R({matches:[],totalCount:0,currentIndex:-1}),p&&p());},[x,o,C,F,d,p]),fe=useCallback(()=>{L(a=>{let y=!a;return y&&setTimeout(()=>$.current?.focus(),100),y});},[]),xe=useCallback(a=>{a.target,a.currentTarget;},[]),he=useCallback(a=>{a.key==="Escape"&&n();},[n]);if(!e)return null;let T=l&&l.totalCount>0,ge=l&&l.totalCount===0&&x.trim();return jsx("div",{className:`docx-find-replace-dialog-overlay ${N||""}`,style:{...Me,...w},onClick:xe,onKeyDown:he,children:jsxs("div",{className:"docx-find-replace-dialog",style:Oe,role:"dialog","aria-modal":"false","aria-labelledby":"find-replace-dialog-title",children:[jsxs("div",{className:"docx-find-replace-dialog-header",style:Le,children:[jsx("h2",{id:"find-replace-dialog-title",style:ke,children:E?"Find and Replace":"Find"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-close",style:Ne,onClick:n,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-find-replace-dialog-body",style:we,children:[jsxs("div",{className:"docx-find-replace-dialog-row",style:Q,children:[jsx("label",{htmlFor:"find-text",style:Z,children:"Find:"}),jsx("input",{ref:P,id:"find-text",type:"text",className:"docx-find-replace-dialog-input",style:ie?ee:Y,value:x,onChange:le,onKeyDown:de,onFocus:()=>K(true),onBlur:()=>{K(false),x.trim()&&!l&&S();},placeholder:"Enter text to find...","aria-label":"Find text"}),jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:T?U:ne,onClick:V,disabled:!T,"aria-label":"Find previous",title:"Find Previous (Shift+Enter)",children:jsx(Ae,{})}),jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:T?U:ne,onClick:G,disabled:!T,"aria-label":"Find next",title:"Find Next (Enter)",children:jsx(We,{})})]})]}),T&&jsxs("div",{className:"docx-find-replace-dialog-status",style:re,children:[l.currentIndex+1," of ",l.totalCount," matches"]}),ge&&jsx("div",{className:"docx-find-replace-dialog-status",style:De,children:"No results found"}),E&&jsx(Fragment,{children:jsxs("div",{className:"docx-find-replace-dialog-row",style:Q,children:[jsx("label",{htmlFor:"replace-text",style:Z,children:"Replace:"}),jsx("input",{ref:$,id:"replace-text",type:"text",className:"docx-find-replace-dialog-input",style:se?ee:Y,value:o,onChange:a=>r(a.target.value),onKeyDown:pe,onFocus:()=>z(true),onBlur:()=>z(false),placeholder:"Enter replacement text...","aria-label":"Replace text"}),jsxs("div",{style:Pe,children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:T?B:te,onClick:j,disabled:!T,title:"Replace current match",children:"Replace"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:T?B:te,onClick:ue,disabled:!T,title:"Replace all matches",children:"Replace All"})]})]})}),jsxs("div",{className:"docx-find-replace-dialog-options",style:_e,children:[jsxs("label",{className:"docx-find-replace-dialog-option",style:W,children:[jsx("input",{type:"checkbox",style:oe,checked:C,onChange:a=>ae(a.target.checked)}),"Match case"]}),jsxs("label",{className:"docx-find-replace-dialog-option",style:W,children:[jsx("input",{type:"checkbox",style:oe,checked:F,onChange:a=>ce(a.target.checked)}),"Whole words"]}),!E&&jsx("button",{type:"button",style:{...W,background:"none",border:"none",cursor:"pointer",color:"var(--doc-link)",padding:0},onClick:fe,children:"+ Replace"})]})]})]})})}var je=Ye;export{_ as a,H as b,X as c,D as d,me as e,be as f,Se as g,ye as h,Ce as i,Re as j,q as k,Ie as l,Ee as m,Ye as n,je as o};
|
|
2
|
+
`);return n}function Fe(e){if(!e||!e.content)return "";let n="";for(let t of e.content)if(t.type==="run")n+=k(t);else if(t.type==="hyperlink")for(let c of t.children||[])c.type==="run"&&(n+=k(c));return n}function Re(e,n,t){if(!e||!n)return [];let c=[],i=e.package?.document||e.package?.document;if(!i||!i.content)return c;let f=0;for(let d of i.content)if(d.type==="paragraph"){let s=q(d,n,t,f);c.push(...s),f++;}else if(d.type==="table")for(let s of d.rows||[])for(let p of s.cells||[])for(let h of p.content||[])h.type;return c}function q(e,n,t,c){let i=[],f=Fe(e);if(!f)return i;let d=D(f,n,t);for(let s of d){let p=Te(e,s.start);i.push({paragraphIndex:c,contentIndex:p.contentIndex,startOffset:p.offsetInContent,endOffset:p.offsetInContent+(s.end-s.start),text:f.substring(s.start,s.end)});}return i}function Te(e,n){if(!e||!e.content)return {contentIndex:0,runIndex:0,offsetInContent:n};let t=0,c=0;for(let i of e.content){let f="";if(i.type==="run")f=k(i);else if(i.type==="hyperlink")for(let s of i.children||[])s.type==="run"&&(f+=k(s));let d=f.length;if(t+d>n)return {contentIndex:c,runIndex:c,offsetInContent:n-t};t+=d,c++;}return {contentIndex:Math.max(0,e.content.length-1),runIndex:Math.max(0,e.content.length-1),offsetInContent:0}}function Ie(e,n){if(!e||!n)return;let t=e.querySelector(`[data-paragraph-index="${n.paragraphIndex}"]`);t&&t.scrollIntoView({behavior:"smooth",block:"center"});}function Ee(e){let[n,t]=useState({isOpen:false,searchText:"",replaceText:"",options:_(),matches:[],currentIndex:0,replaceMode:e?.initialReplaceMode??false}),c=useCallback(o=>{t(r=>({...r,isOpen:true,replaceMode:false,searchText:o||r.searchText,matches:[],currentIndex:0}));},[]),i=useCallback(o=>{t(r=>({...r,isOpen:true,replaceMode:true,searchText:o||r.searchText,matches:[],currentIndex:0}));},[]),f=useCallback(()=>{t(o=>({...o,isOpen:false}));},[]),d=useCallback(()=>{t(o=>({...o,isOpen:!o.isOpen}));},[]),s=useCallback(o=>{t(r=>({...r,searchText:o}));},[]),p=useCallback(o=>{t(r=>({...r,replaceText:o}));},[]),h=useCallback(o=>{t(r=>({...r,options:{...r.options,...o}}));},[]),v=useCallback((o,r=0)=>{let E=Math.max(0,Math.min(r,o.length-1));t(L=>({...L,matches:o,currentIndex:o.length>0?E:0})),e?.onMatchesChange?.(o),o.length>0?e?.onCurrentMatchChange?.(o[E],E):e?.onCurrentMatchChange?.(null,-1);},[e]),M=useCallback(()=>{let o=0;return t(r=>r.matches.length===0?r:(o=(r.currentIndex+1)%r.matches.length,{...r,currentIndex:o})),o},[]),N=useCallback(()=>{let o=0;return t(r=>r.matches.length===0?r:(o=r.currentIndex===0?r.matches.length-1:r.currentIndex-1,{...r,currentIndex:o})),o},[]),w=useCallback(o=>{t(r=>r.matches.length===0||o<0||o>=r.matches.length?r:{...r,currentIndex:o});},[]),x=useCallback(()=>n.matches.length===0?null:n.matches[n.currentIndex]||null,[n.matches,n.currentIndex]),O=useCallback(()=>n.matches.length>0,[n.matches.length]);return {state:n,openFind:c,openReplace:i,close:f,toggle:d,setSearchText:s,setReplaceText:p,setOptions:h,setMatches:v,goToNextMatch:M,goToPreviousMatch:N,goToMatch:w,getCurrentMatch:x,hasMatches:O}}var Me={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent",display:"flex",alignItems:"flex-start",justifyContent:"flex-end",zIndex:1e4,pointerEvents:"none"},Oe={backgroundColor:"white",borderRadius:"4px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.2)",minWidth:"360px",maxWidth:"440px",width:"100%",margin:"60px 20px 20px 20px",pointerEvents:"auto"},Le={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg-subtle)",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},ke={margin:0,fontSize:"14px",fontWeight:600,color:"var(--doc-text)"},Ne={background:"none",border:"none",fontSize:"18px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"2px 6px",lineHeight:1},we={padding:"16px"},Q={display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px"},Z={width:"60px",fontSize:"13px",color:"var(--doc-text)",flexShrink:0},Y={flex:1,padding:"8px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"13px",boxSizing:"border-box",outline:"none"},ee={...Y,borderColor:"var(--doc-link)",boxShadow:"0 0 0 2px rgba(5, 99, 193, 0.1)"},Pe={display:"flex",flexDirection:"column",gap:"6px",marginLeft:"8px"},B={padding:"6px 12px",borderRadius:"3px",fontSize:"12px",fontWeight:500,cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)",minWidth:"80px",textAlign:"center"},te={...B,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text-placeholder)",cursor:"not-allowed"},U={padding:"6px 10px",borderRadius:"3px",fontSize:"14px",cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)"},ne={...U,color:"var(--doc-border-input)",cursor:"not-allowed"},_e={display:"flex",gap:"16px",marginTop:"4px",marginLeft:"68px"},W={display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--doc-text-muted)",cursor:"pointer"},oe={width:"14px",height:"14px",cursor:"pointer"},re={marginLeft:"68px",fontSize:"12px",color:"var(--doc-text-muted)",marginBottom:"8px"},De={...re,color:"var(--doc-error)"},Ae=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"18 15 12 9 6 15"})}),We=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"6 9 12 15 18 9"})});function Ye({isOpen:e,onClose:n,onFind:t,onFindNext:c,onFindPrevious:i,onReplace:f,onReplaceAll:d,onHighlightMatches:s,onClearHighlights:p,initialSearchText:h="",replaceMode:v=false,currentResult:M,className:N,style:w}){let[x,O]=useState(""),[o,r]=useState(""),[E,L]=useState(v),[C,ae]=useState(false),[F,ce]=useState(false),[l,R]=useState(null),[ie,K]=useState(false),[se,z]=useState(false),P=useRef(null),$=useRef(null);useEffect(()=>{M!==void 0&&R(M);},[M]),useEffect(()=>{if(e){if(O(h),r(""),L(v),R(null),setTimeout(()=>{P.current?.focus(),P.current?.select();},100),h){let a=t(h,{matchCase:C,matchWholeWord:F});R(a),a?.matches&&s&&s(a.matches);}}else p&&p();},[e,h,v]);let S=useCallback(()=>{if(!x.trim()){R(null),p&&p();return}let a=t(x,{matchCase:C,matchWholeWord:F});R(a),a?.matches&&s?s(a.matches):p&&p();},[x,C,F,t,s,p]);useEffect(()=>{e&&x.trim()&&S();},[C,F]);let le=useCallback(a=>{O(a.target.value);},[]),de=useCallback(a=>{a.key==="Enter"?(a.preventDefault(),a.shiftKey?V():l?G():S()):a.key==="Escape"&&n();},[l,S,n]),pe=useCallback(a=>{a.key==="Enter"?(a.preventDefault(),j()):a.key==="Escape"&&n();},[n]),G=useCallback(()=>{if(!x.trim()){S();return}if(!l){S();return}if(c()&&l){let y=(l.currentIndex+1)%l.totalCount;R({...l,currentIndex:y});}},[x,l,S,c]),V=useCallback(()=>{if(!x.trim()){S();return}if(!l){S();return}if(i()&&l){let y=l.currentIndex===0?l.totalCount-1:l.currentIndex-1;R({...l,currentIndex:y});}},[x,l,S,i]),j=useCallback(()=>{if(!l||l.totalCount===0)return;if(f(o)){let y=t(x,{matchCase:C,matchWholeWord:F});R(y),y?.matches&&s&&s(y.matches);}},[l,o,x,C,F,f,t,s]),ue=useCallback(()=>{if(!x.trim())return;d(x,o,{matchCase:C,matchWholeWord:F})>0&&(R({matches:[],totalCount:0,currentIndex:-1}),p&&p());},[x,o,C,F,d,p]),fe=useCallback(()=>{L(a=>{let y=!a;return y&&setTimeout(()=>$.current?.focus(),100),y});},[]),xe=useCallback(a=>{a.target,a.currentTarget;},[]),he=useCallback(a=>{a.key==="Escape"&&n();},[n]);if(!e)return null;let T=l&&l.totalCount>0,ge=l&&l.totalCount===0&&x.trim();return jsx("div",{className:`docx-find-replace-dialog-overlay ${N||""}`,style:{...Me,...w},onClick:xe,onKeyDown:he,children:jsxs("div",{className:"docx-find-replace-dialog","data-testid":"find-replace-dialog",style:Oe,role:"dialog","aria-modal":"false","aria-labelledby":"find-replace-dialog-title",children:[jsxs("div",{className:"docx-find-replace-dialog-header",style:Le,children:[jsx("h2",{id:"find-replace-dialog-title",style:ke,children:E?"Find and Replace":"Find"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-close",style:Ne,onClick:n,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-find-replace-dialog-body",style:we,children:[jsxs("div",{className:"docx-find-replace-dialog-row",style:Q,children:[jsx("label",{htmlFor:"find-text",style:Z,children:"Find:"}),jsx("input",{ref:P,id:"find-text",type:"text",className:"docx-find-replace-dialog-input",style:ie?ee:Y,value:x,onChange:le,onKeyDown:de,onFocus:()=>K(true),onBlur:()=>{K(false),x.trim()&&!l&&S();},placeholder:"Enter text to find...","aria-label":"Find text"}),jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:T?U:ne,onClick:V,disabled:!T,"aria-label":"Find previous",title:"Find Previous (Shift+Enter)",children:jsx(Ae,{})}),jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:T?U:ne,onClick:G,disabled:!T,"aria-label":"Find next",title:"Find Next (Enter)",children:jsx(We,{})})]})]}),T&&jsxs("div",{className:"docx-find-replace-dialog-status",style:re,children:[l.currentIndex+1," of ",l.totalCount," matches"]}),ge&&jsx("div",{className:"docx-find-replace-dialog-status",style:De,children:"No results found"}),E&&jsx(Fragment,{children:jsxs("div",{className:"docx-find-replace-dialog-row",style:Q,children:[jsx("label",{htmlFor:"replace-text",style:Z,children:"Replace:"}),jsx("input",{ref:$,id:"replace-text",type:"text",className:"docx-find-replace-dialog-input",style:se?ee:Y,value:o,onChange:a=>r(a.target.value),onKeyDown:pe,onFocus:()=>z(true),onBlur:()=>z(false),placeholder:"Enter replacement text...","aria-label":"Replace text"}),jsxs("div",{style:Pe,children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:T?B:te,onClick:j,disabled:!T,title:"Replace current match",children:"Replace"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:T?B:te,onClick:ue,disabled:!T,title:"Replace all matches",children:"Replace All"})]})]})}),jsxs("div",{className:"docx-find-replace-dialog-options",style:_e,children:[jsxs("label",{className:"docx-find-replace-dialog-option",style:W,children:[jsx("input",{type:"checkbox",style:oe,checked:C,onChange:a=>ae(a.target.checked)}),"Match case"]}),jsxs("label",{className:"docx-find-replace-dialog-option",style:W,children:[jsx("input",{type:"checkbox",style:oe,checked:F,onChange:a=>ce(a.target.checked)}),"Whole words"]}),!E&&jsx("button",{type:"button",style:{...W,background:"none",border:"none",cursor:"pointer",color:"var(--doc-link)",padding:0},onClick:fe,children:"+ Replace"})]})]})]})})}var je=Ye;export{_ as a,H as b,X as c,D as d,me as e,be as f,Se as g,ye as h,Ce as i,Re as j,q as k,Ie as l,Ee as m,Ye as n,je as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkPXC7ARQB_cjs=require('./chunk-PXC7ARQB.cjs');function v(s,t){let a=chunkPXC7ARQB_cjs.b.getCommandHandler(t.type);if(a)return a(s,t);switch(t.type){case "insertText":return R(s,t);case "replaceText":return E(s,t);case "deleteText":return B(s,t);case "formatText":return S(s,t);case "formatParagraph":return V(s,t);case "applyStyle":return $(s,t);case "insertTable":return H(s,t);case "insertImage":return A(s,t);case "insertHyperlink":return F(s,t);case "removeHyperlink":return j(s,t);case "insertParagraphBreak":return T(s,t);case "mergeParagraphs":return N(s,t);case "splitParagraph":return M(s,t);case "setVariable":return O(s,t);case "applyVariables":return _(s,t);default:let r=t;throw new Error(`Unknown command type: ${r.type}`)}}function z(s,t){return t.reduce((a,r)=>v(a,r),s)}function h(s){return JSON.parse(JSON.stringify(s))}function g(s,t){let a=0;for(let r=0;r<s.content.length;r++)if(s.content[r].type==="paragraph"){if(a===t)return r;a++;}return -1}function I(s){let t="";for(let a of s.content)if(a.type==="run")for(let r of a.content)r.type==="text"&&(t+=r.text);else if(a.type==="hyperlink"){for(let r of a.children)if(r.type==="run")for(let e of r.content)e.type==="text"&&(t+=e.text);}return t}function b(s,t){return {type:"run",formatting:t,content:[{type:"text",text:s}]}}function C(s,t,a,r){let e=[],o=0,p=false;for(let n of s.content)if(n.type==="run"){let c=n.content.filter(l=>l.type==="text").map(l=>l.text).join(""),i=o,u=o+c.length;if(!p&&t>=i&&t<=u){let l=t-i;l>0&&e.push({...n,content:[{type:"text",text:c.slice(0,l)}]}),e.push(b(a,r||n.formatting)),l<c.length&&e.push({...n,content:[{type:"text",text:c.slice(l)}]}),p=true;}else e.push(n);o=u;}else e.push(n);return p||e.push(b(a,r)),e}function y(s,t,a){let r=[],e=0;for(let o of s.content)if(o.type==="run"){let p=o.content.filter(i=>i.type==="text").map(i=>i.text).join(""),n=e,c=e+p.length;if(c<=t||n>=a)r.push(o);else {let i="";n<t&&(i+=p.slice(0,t-n)),c>a&&(i+=p.slice(a-n)),i.length>0&&r.push({...o,content:[{type:"text",text:i}]});}e=c;}else r.push(o);return r}function D(s,t,a,r){let e=[],o=0;for(let p of s.content)if(p.type==="run"){let n=p.content.filter(u=>u.type==="text").map(u=>u.text).join(""),c=o,i=o+n.length;if(i<=t||c>=a)e.push(p);else if(c>=t&&i<=a)e.push({...p,formatting:{...p.formatting,...r}});else {let u=Math.max(t,c),l=Math.min(a,i);c<u&&e.push({...p,content:[{type:"text",text:n.slice(0,u-c)}]}),e.push({...p,formatting:{...p.formatting,...r},content:[{type:"text",text:n.slice(u-c,l-c)}]}),i>l&&e.push({...p,content:[{type:"text",text:n.slice(l-c)}]});}o=i;}else e.push(p);return e}function R(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e];return o.content=C(o,t.position.offset,t.text,t.formatting),a}function E(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=y(n,e.offset,o.offset),n.content=C(n,e.offset,t.text,t.formatting);}else {let p=g(r,e.paragraphIndex),n=r.content[p],c=I(n);n.content=y(n,e.offset,c.length),n.content=C(n,e.offset,t.text,t.formatting);let i=[];for(let u=e.paragraphIndex+1;u<=o.paragraphIndex;u++)i.push(g(r,u));for(let u=i.length-1;u>=0;u--)i[u]!==-1&&r.content.splice(i[u],1);}return a}function B(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=y(n,e.offset,o.offset);}else {let p=g(r,e.paragraphIndex),n=r.content[p],c=I(n);n.content=y(n,e.offset,c.length);let i=g(r,o.paragraphIndex),u=r.content[i];u.content=y(u,0,o.offset),n.content.push(...u.content);let l=[];for(let f=e.paragraphIndex+1;f<=o.paragraphIndex;f++)l.push(g(r,f));for(let f=l.length-1;f>=0;f--)l[f]!==-1&&r.content.splice(l[f],1);}return a}function S(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex===o.paragraphIndex){let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p];n.content=D(n,e.offset,o.offset,t.formatting);}else for(let p=e.paragraphIndex;p<=o.paragraphIndex;p++){let n=g(r,p);if(n===-1)continue;let c=r.content[n],i=I(c),u=0,l=i.length;p===e.paragraphIndex&&(u=e.offset),p===o.paragraphIndex&&(l=o.offset),c.content=D(c,u,l,t.formatting);}return a}function V(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e];if(o.formatting={...o.formatting,...t.formatting},"numPr"in t.formatting){let p=t.formatting.numPr;if(p&&p.numId!==void 0&&p.numId!==0){let n=p.ilvl??0,c=p.numId===1,i=c?"\u2022":"1.";if(a.package.numbering){let u=a.package.numbering.nums.find(l=>l.numId===p.numId);if(u){let l=a.package.numbering.abstractNums.find(f=>f.abstractNumId===u.abstractNumId);if(l){let f=l.levels.find(x=>x.ilvl===n);f&&(i=f.lvlText||i);}}}o.listRendering={level:n,numId:p.numId,marker:i,isBullet:c};}else delete o.listRendering;}return a}function $(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e];return o.formatting={...o.formatting,styleId:t.styleId},a}function H(s,t){let a=h(s),r=a.package.document,e=[];for(let n=0;n<t.rows;n++){let c=[];for(let i=0;i<t.columns;i++){let u=t.data?.[n]?.[i]||"";c.push({type:"tableCell",content:[{type:"paragraph",content:u?[b(u)]:[]}]});}e.push({type:"tableRow",formatting:n===0&&t.hasHeader?{header:true}:void 0,cells:c});}let o={type:"table",rows:e},p=g(r,t.position.paragraphIndex);return p===-1?r.content.push(o):r.content.splice(p+1,0,o),a}function A(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e],n={type:"run",content:[{type:"drawing",image:{type:"image",rId:`rId_img_${Date.now()}`,src:t.src,alt:t.alt,size:{width:(t.width||100)*914400,height:(t.height||100)*914400},wrap:{type:"inline"}}}]},c=C(o,t.position.offset,"",void 0),i=false,u=0;for(let l=0;l<c.length;l++){let f=c[l];if(f.type==="run"){let x=f.content.filter(d=>d.type==="text").map(d=>d.text).join("");if(u+=x.length,!i&&u>=t.position.offset){c.splice(l+1,0,n),i=true;break}}}return i||c.push(n),o.content=c,a}function F(s,t){let a=h(s),r=a.package.document,{start:e,end:o}=t.range;if(e.paragraphIndex!==o.paragraphIndex)throw new Error("Hyperlinks cannot span multiple paragraphs");let p=g(r,e.paragraphIndex);if(p===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let n=r.content[p],c=I(n),i=t.displayText||c.slice(e.offset,o.offset);n.content=y(n,e.offset,o.offset);let u={type:"hyperlink",href:t.url,tooltip:t.tooltip,children:[b(i)]},l=false,f=0,x=[];for(let d of n.content)if(d.type==="run"){let P=d.content.filter(m=>m.type==="text").map(m=>m.text).join(""),w=f+P.length;if(!l&&f<=e.offset&&e.offset<=w){let m=e.offset-f;m>0&&x.push({...d,content:[{type:"text",text:P.slice(0,m)}]}),x.push(u),m<P.length&&x.push({...d,content:[{type:"text",text:P.slice(m)}]}),l=true;}else x.push(d);f=w;}else x.push(d);return l||x.push(u),n.content=x,a}function j(s,t){let a=h(s),r=a.package.document,{start:e}=t.range,o=g(r,e.paragraphIndex);if(o===-1)throw new Error(`Paragraph index ${e.paragraphIndex} not found`);let p=r.content[o],n=[];for(let c of p.content)if(c.type==="hyperlink")for(let i of c.children)i.type==="run"&&n.push(i);else n.push(c);return p.content=n,a}function T(s,t){let a=h(s),r=a.package.document,e=g(r,t.position.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.position.paragraphIndex} not found`);let o=r.content[e],p=I(o),n=y({...o,content:[...o.content]},t.position.offset,p.length),c=y({...o,content:[...o.content]},0,t.position.offset);o.content=n;let i={type:"paragraph",formatting:o.formatting,content:c};return r.content.splice(e+1,0,i),a}function N(s,t){let a=h(s),r=a.package.document,e=g(r,t.paragraphIndex);if(e===-1)throw new Error(`Paragraph index ${t.paragraphIndex} not found`);let o=r.content[e],p=[];for(let n=1;n<=t.count;n++){let c=g(r,t.paragraphIndex+n);if(c!==-1){let i=r.content[c];o.content.push(...i.content),p.push(c);}}for(let n=p.length-1;n>=0;n--)r.content.splice(p[n],1);return a}function M(s,t){return T(s,{position:t.position})}function O(s,t){let a=h(s);return a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t.name)||a.templateVariables.push(t.name),a}function _(s,t){let a=h(s),r=a.package.document;function e(n){for(let c of n.content)if(c.type==="text")for(let[i,u]of Object.entries(t.values)){let l=new RegExp(`\\{${i}\\}`,"g");c.text=c.text.replace(l,u);}}function o(n){for(let c of n.content)if(c.type==="run")e(c);else if(c.type==="hyperlink")for(let i of c.children)i.type==="run"&&e(i);}function p(n){if(n.type==="paragraph")o(n);else if(n.type==="table")for(let c of n.rows)for(let i of c.cells)for(let u of i.content)p(u);}for(let n of r.content)p(n);return a}exports.a=v;exports.b=z;
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
}
|
|
9
9
|
`,document.head.appendChild(a),await Ne(o,3e3),G.add(o),Ae([o]),!0}catch(r){return console.warn(`Failed to load font "${o}" from buffer:`,r),false}}var $t={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 _t(e){let t=e.trim();return $t[t]||t}async function Gt(e){let t=e.trim(),n=_t(t);return n!==t?(await qt(t,n),G.add(t),G.add(n),true):Be(n)}async function qt(e,t){let n=`font-alias-${e.toLowerCase().replace(/\s+/g,"-")}`;if(!document.getElementById(n))try{let o=Pe(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*['"]${Zt(t)}['"]`,"gi"),c=i.replace(a,`font-family: '${e}'`),f=document.createElement("style");f.id=n,f.textContent=c,document.head.appendChild(f);}catch(o){console.warn(`Failed to create font alias for "${e}":`,o);}}function Zt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function xe(e){let t=[...new Set(e.map(n=>n.trim()))];await Promise.all(t.map(n=>Gt(n)));}async function Vo(){await Ut(["Carlito","Caladea","Arimo","Tinos","Cousine","EB Garamond"]);}function Yt(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:c,hAnsi:f}=a.formatting.fontFamily;c&&t.add(c),f&&f!==c&&t.add(f);}}}let r=n.package?.styles?.styles;if(Array.isArray(r)){for(let i of r)if(i?.runProperties?.fontFamily){let{ascii:a,hAnsi:c}=i.runProperties.fontFamily;a&&t.add(a),c&&c!==a&&t.add(c);}}return t}async function zo(e){let t=Yt(e);t.size!==0&&await xe(Array.from(t));}async function Ie(e){if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array){let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t}if(e instanceof Blob)return e.arrayBuffer();throw new TypeError(`Unsupported DocxInput type: ${typeof e}`)}async function Xe(e){let t=await Kt__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,commentsExtensibleXml: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/commentsextensible.xml"||i==="word/commentsextended.xml")n.commentsExtensibleXml||(n.commentsExtensibleXml=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 c=o.split("/").pop()||o;n.headers.set(c,a);}else if(i.match(/^word\/footer\d+\.xml$/)){let c=o.split("/").pop()||o;n.footers.set(c,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 Le(e){switch(e.toLowerCase().split(".").pop()){case "png":return "image/png";case "jpg":case "jpeg":return "image/jpeg";case "gif":return "image/gif";case "bmp":return "image/bmp";case "tif":case "tiff":return "image/tiff";case "wmf":return "image/x-wmf";case "emf":return "image/x-emf";case "svg":return "image/svg+xml";case "webp":return "image/webp";default:return "application/octet-stream"}}function j(e){return xmlJs.xml2js(e,{compact:false,ignoreComment:true,ignoreInstruction:true,ignoreDoctype:true,alwaysArray:false,trim:false,captureSpacesBetweenElements:true,attributesKey:"attributes",textKey:"text"})}function De(e){return xmlJs.js2xml({elements:[e]},{compact:false,spaces:0})}function q(e){try{let t=j(e);return t.elements&&t.elements.length>0?t.elements.find(n=>n.type==="element")??null:t}catch(t){return console.warn("Failed to parse XML:",t),null}}function 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 N(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 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 F(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={image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",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",footnotes:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",endnotes:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",fontTable:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",webSettings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",oleObject:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",diagramData:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",officeDocument:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",customProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",customXml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"};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"),c=s(r,null,"Type"),f=s(r,null,"Target"),u=s(r,null,"TargetMode");if(!a||!c||!f){console.warn("Relationship missing required attributes:",{id:a,type:c,target:f});continue}let p={id:a,type:c,target:f};u==="External"?p.targetMode="External":u==="Internal"&&(p.targetMode="Internal"),t.set(a,p);}return t}function He(e){return e.type===ie.hyperlink&&e.targetMode==="External"}var je={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:{}}},Te={name:"Office Theme",colorScheme:je,fontScheme:se},en=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function tn(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 nn(e){let t={...je};if(!e)return t;for(let n of en){let o=l(e,"a",n);if(o){let r=D(o);if(r.length>0){let i=tn(r[0]);i&&(t[n]=i);}}}return t}function Oe(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=N(e,"a","font");for(let a of i){let c=s(a,"a","script")??s(a,null,"script"),f=s(a,"a","typeface")??s(a,null,"typeface");c&&f&&(t.fonts=t.fonts||{},t.fonts[c]=f);}return t}function on(e){let t={...se};if(!e)return t;let n=l(e,"a","majorFont");n&&(t.majorFont=Oe(n));let o=l(e,"a","minorFont");return o&&(t.minorFont=Oe(o)),t}function Ve(e){if(!e)return {...Te};try{let t=q(e);if(!t)return {...Te};let n=s(t,"a","name")??s(t,null,"name")??"Office Theme",o=l(t,"a","themeElements"),r=l(o,"a","clrScheme"),i=nn(r),a=l(o,"a","fontScheme"),c=on(a);return {name:n,colorScheme:i,fontScheme:c}}catch(t){return console.warn("Failed to parse theme:",t),{...Te}}}function rn(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 We(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 _(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?rn(e,r):o?We(e,r):We(e,"latin")}function le(e,t){if(!e)return;let n={},o=l(e,"w","b");o&&(n.bold=F(o));let r=l(e,"w","bCs");r&&(n.boldCs=F(r));let i=l(e,"w","i");i&&(n.italic=F(i));let a=l(e,"w","iCs");a&&(n.italicCs=F(a));let c=l(e,"w","u");if(c){let R=s(c,"w","val");if(R){n.underline={style:R};let M=s(c,"w","color"),L=s(c,"w","themeColor");(M||L)&&(n.underline.color=Fe(M,L,s(c,"w","themeTint"),s(c,"w","themeShade")));}}let f=l(e,"w","strike");f&&(n.strike=F(f));let u=l(e,"w","dstrike");u&&(n.doubleStrike=F(u));let p=l(e,"w","vertAlign");if(p){let R=s(p,"w","val");(R==="superscript"||R==="subscript"||R==="baseline")&&(n.vertAlign=R);}let m=l(e,"w","smallCaps");m&&(n.smallCaps=F(m));let h=l(e,"w","caps");h&&(n.allCaps=F(h));let T=l(e,"w","vanish");T&&(n.hidden=F(T));let d=l(e,"w","color");d&&(n.color=Fe(s(d,"w","val"),s(d,"w","themeColor"),s(d,"w","themeTint"),s(d,"w","themeShade")));let w=l(e,"w","highlight");if(w){let R=s(w,"w","val");R&&(n.highlight=R);}let E=l(e,"w","shd");E&&(n.shading=ce(E));let k=l(e,"w","sz");if(k){let R=g(k,"w","val");R!==void 0&&(n.fontSize=R);}let P=l(e,"w","szCs");if(P){let R=g(P,"w","val");R!==void 0&&(n.fontSizeCs=R);}let C=l(e,"w","rFonts");if(C){n.fontFamily={ascii:s(C,"w","ascii")??void 0,hAnsi:s(C,"w","hAnsi")??void 0,eastAsia:s(C,"w","eastAsia")??void 0,cs:s(C,"w","cs")??void 0};let R=s(C,"w","asciiTheme");R&&(n.fontFamily.asciiTheme=R,t&&!n.fontFamily.ascii&&(n.fontFamily.ascii=_(t,R)));let M=s(C,"w","hAnsiTheme");M&&(n.fontFamily.hAnsiTheme=M,t&&!n.fontFamily.hAnsi&&(n.fontFamily.hAnsi=_(t,M)));let L=s(C,"w","eastAsiaTheme");L&&(n.fontFamily.eastAsiaTheme=L,t&&!n.fontFamily.eastAsia&&(n.fontFamily.eastAsia=_(t,L)));let $=s(C,"w","cstheme");$&&(n.fontFamily.csTheme=$,t&&!n.fontFamily.cs&&(n.fontFamily.cs=_(t,$)));}let y=l(e,"w","spacing");if(y){let R=g(y,"w","val");R!==void 0&&(n.spacing=R);}let x=l(e,"w","position");if(x){let R=g(x,"w","val");R!==void 0&&(n.position=R);}let S=l(e,"w","w");if(S){let R=g(S,"w","val");R!==void 0&&(n.scale=R);}let b=l(e,"w","kern");if(b){let R=g(b,"w","val");R!==void 0&&(n.kerning=R);}let v=l(e,"w","effect");if(v){let R=s(v,"w","val");R&&(n.effect=R);}let B=l(e,"w","em");if(B){let R=s(B,"w","val");R&&(n.emphasisMark=R);}let A=l(e,"w","emboss");A&&(n.emboss=F(A));let I=l(e,"w","imprint");I&&(n.imprint=F(I));let O=l(e,"w","outline");O&&(n.outline=F(O));let U=l(e,"w","shadow");U&&(n.shadow=F(U));let K=l(e,"w","rtl");K&&(n.rtl=F(K));let H=l(e,"w","cs");H&&(n.cs=F(H));let W=l(e,"w","rStyle");if(W){let R=s(W,"w","val");R&&(n.styleId=R);}return Object.keys(n).length>0?n:void 0}function Fe(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 ce(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 c=s(e,"w","val");return c&&(t.pattern=c),Object.keys(t).length>0?t:void 0}function V(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=Fe(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 c=s(e,"w","shadow");c&&(n.shadow=c==="1"||c==="true");let f=s(e,"w","frame");return f&&(n.frame=f==="1"||f==="true"),n}function an(e){if(!e)return;let t=N(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},c=s(o,"w","leader");c&&(a.leader=c),n.push(a);}}return n.length>0?n:void 0}function Se(e,t){if(!e)return;let n={},o=l(e,"w","jc");if(o){let x=s(o,"w","val");x&&(n.alignment=x);}let r=l(e,"w","bidi");r&&(n.bidi=F(r));let i=l(e,"w","spacing");if(i){let x=g(i,"w","before");x!==void 0&&(n.spaceBefore=x);let S=g(i,"w","after");S!==void 0&&(n.spaceAfter=S);let b=g(i,"w","line");b!==void 0&&(n.lineSpacing=b);let v=s(i,"w","lineRule");v&&(n.lineSpacingRule=v);let B=s(i,"w","beforeAutospacing");B&&(n.beforeAutospacing=B==="1"||B==="true");let A=s(i,"w","afterAutospacing");A&&(n.afterAutospacing=A==="1"||A==="true");}let a=l(e,"w","ind");if(a){let x=g(a,"w","left");x!==void 0&&(n.indentLeft=x);let S=g(a,"w","right");S!==void 0&&(n.indentRight=S);let b=g(a,"w","firstLine");b!==void 0&&(n.indentFirstLine=b);let v=g(a,"w","hanging");v!==void 0&&(n.indentFirstLine=-v,n.hangingIndent=true);}let c=l(e,"w","pBdr");if(c){let x={},S=V(l(c,"w","top"));S&&(x.top=S);let b=V(l(c,"w","bottom"));b&&(x.bottom=b);let v=V(l(c,"w","left"));v&&(x.left=v);let B=V(l(c,"w","right"));B&&(x.right=B);let A=V(l(c,"w","between"));A&&(x.between=A);let I=V(l(c,"w","bar"));I&&(x.bar=I),Object.keys(x).length>0&&(n.borders=x);}let f=l(e,"w","shd");f&&(n.shading=ce(f));let u=l(e,"w","tabs");u&&(n.tabs=an(u));let p=l(e,"w","keepNext");p&&(n.keepNext=F(p));let m=l(e,"w","keepLines");m&&(n.keepLines=F(m));let h=l(e,"w","widowControl");h&&(n.widowControl=F(h));let T=l(e,"w","pageBreakBefore");T&&(n.pageBreakBefore=F(T));let d=l(e,"w","contextualSpacing");d&&(n.contextualSpacing=F(d));let w=l(e,"w","numPr");if(w){let x=l(w,"w","numId"),S=l(w,"w","ilvl");if(x||S){if(n.numPr={},x){let b=g(x,"w","val");b!==void 0&&(n.numPr.numId=b);}if(S){let b=g(S,"w","val");b!==void 0&&(n.numPr.ilvl=b);}}}let E=l(e,"w","outlineLvl");if(E){let x=g(E,"w","val");x!==void 0&&(n.outlineLevel=x);}let k=l(e,"w","pStyle");if(k){let x=s(k,"w","val");x&&(n.styleId=x);}let P=l(e,"w","suppressLineNumbers");P&&(n.suppressLineNumbers=F(P));let C=l(e,"w","suppressAutoHyphens");C&&(n.suppressAutoHyphens=F(C));let y=l(e,"w","rPr");return y&&(n.runProperties=le(y,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=V(l(e,"w","top"));n&&(t.top=n);let o=V(l(e,"w","bottom"));o&&(t.bottom=o);let r=V(l(e,"w","left"));r&&(t.left=r);let i=V(l(e,"w","right"));i&&(t.right=i);let a=V(l(e,"w","insideH"));a&&(t.insideH=a);let c=V(l(e,"w","insideV"));return c&&(t.insideV=c),Object.keys(t).length>0?t:void 0}function Ge(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 sn(e){if(!e)return;let t={},n=s(e,"w","val");if(n){let u=parseInt(n,16);isNaN(u)||(t.firstRow=(u&32)!==0,t.lastRow=(u&64)!==0,t.firstColumn=(u&128)!==0,t.lastColumn=(u&256)!==0,t.noHBand=(u&512)!==0,t.noVBand=(u&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 c=s(e,"w","noHBand");c&&(t.noHBand=c==="1");let f=s(e,"w","noVBand");return f&&(t.noVBand=f==="1"),Object.keys(t).length>0?t:void 0}function ze(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 d=s(r,"w","val");(d==="left"||d==="center"||d==="right")&&(n.justification=d);}let i=l(e,"w","tblCellSpacing");i&&(n.cellSpacing=Z(i));let a=l(e,"w","tblInd");a&&(n.indent=Z(a));let c=l(e,"w","tblBorders");c&&(n.borders=_e(c));let f=l(e,"w","tblCellMar");f&&(n.cellMargins=Ge(f));let u=l(e,"w","tblLayout");if(u){let d=s(u,"w","type");(d==="fixed"||d==="autofit")&&(n.layout=d);}let p=l(e,"w","tblStyle");if(p){let d=s(p,"w","val");d&&(n.styleId=d);}let m=l(e,"w","tblLook");m&&(n.look=sn(m));let h=l(e,"w","shd");h&&(n.shading=ce(h));let T=l(e,"w","bidiVisual");return T&&(n.bidi=F(T)),Object.keys(n).length>0?n:void 0}function Ue(e){if(!e)return;let t={},n=l(e,"w","trHeight");if(n){t.height=Z(n);let c=s(n,"w","hRule");c&&(t.heightRule=c);}let o=l(e,"w","tblHeader");o&&(t.header=F(o));let r=l(e,"w","cantSplit");r&&(t.cantSplit=F(r));let i=l(e,"w","jc");if(i){let c=s(i,"w","val");(c==="left"||c==="center"||c==="right")&&(t.justification=c);}let a=l(e,"w","hidden");return a&&(t.hidden=F(a)),Object.keys(t).length>0?t:void 0}function $e(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=Ge(i));let a=l(e,"w","shd");a&&(n.shading=ce(a));let c=l(e,"w","vAlign");if(c){let d=s(c,"w","val");(d==="top"||d==="center"||d==="bottom")&&(n.verticalAlign=d);}let f=l(e,"w","textDirection");if(f){let d=s(f,"w","val");d&&(n.textDirection=d);}let u=l(e,"w","gridSpan");if(u){let d=g(u,"w","val");d!==void 0&&(n.gridSpan=d);}let p=l(e,"w","vMerge");if(p){let d=s(p,"w","val");n.vMerge=d==="restart"?"restart":"continue";}let m=l(e,"w","tcFitText");m&&(n.fitText=F(m));let h=l(e,"w","noWrap");h&&(n.noWrap=F(h));let T=l(e,"w","hideMark");return T&&(n.hideMark=F(T)),Object.keys(n).length>0?n:void 0}function ln(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 c=l(e,"w","link");c&&(n.link=s(c,"w","val")??void 0);let f=l(e,"w","uiPriority");if(f){let y=g(f,"w","val");y!==void 0&&(n.uiPriority=y);}let u=l(e,"w","hidden");u&&(n.hidden=F(u));let p=l(e,"w","semiHidden");p&&(n.semiHidden=F(p));let m=l(e,"w","unhideWhenUsed");m&&(n.unhideWhenUsed=F(m));let h=l(e,"w","qFormat");h&&(n.qFormat=F(h));let T=l(e,"w","personal");T&&(n.personal=F(T));let d=l(e,"w","pPr");d&&(n.pPr=Se(d,t));let w=l(e,"w","rPr");w&&(n.rPr=le(w,t));let E=l(e,"w","tblPr");E&&(n.tblPr=ze(E));let k=l(e,"w","trPr");k&&(n.trPr=Ue(k));let P=l(e,"w","tcPr");P&&(n.tcPr=$e(P));let C=N(e,"w","tblStylePr");if(C.length>0){n.tblStylePr=[];for(let y of C){let x=s(y,"w","type");if(x){let S={type:x},b=l(y,"w","pPr");b&&(S.pPr=Se(b,t));let v=l(y,"w","rPr");v&&(S.rPr=le(v,t));let B=l(y,"w","tblPr");B&&(S.tblPr=ze(B));let A=l(y,"w","trPr");A&&(S.trPr=Ue(A));let I=l(y,"w","tcPr");I&&(S.tcPr=$e(I)),n.tblStylePr.push(S);}}}return n}function cn(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=Se(i,t));}return n.rPr||n.pPr?n:void 0}function qe(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 fn(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=qe(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 Ze(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=Ze(r,t,n,o),a={...e,pPr:fn(i.pPr,e.pPr),rPr:qe(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=N(o,"w","style");for(let i of r){let a=ln(i,t);a.styleId&&n.set(a.styleId,a);}for(let[i,a]of n){let c=Ze(a,n,t);n.set(i,c);}}catch(o){console.warn("Failed to parse styles:",o);}return n}function Ye(e,t){let n={styles:[]};try{let o=q(e);if(!o)return n;let r=l(o,"w","docDefaults");n.docDefaults=cn(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 Ke(e){let t={abstractNums:[],nums:[]};if(!e)return ke(t);let n=q(e);if(!n)return ke(t);let o=N(n,"w","abstractNum");for(let i of o){let a=un(i);a&&t.abstractNums.push(a);}let r=N(n,"w","num");for(let i of r){let a=dn(i);a&&t.nums.push(a);}return ke(t)}function un(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 u=s(r,"w","val");(u==="hybridMultilevel"||u==="multilevel"||u==="singleLevel")&&(o.multiLevelType=u);}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 c=l(e,"w","styleLink");c&&(o.styleLink=s(c,"w","val")??void 0);let f=N(e,"w","lvl");for(let u of f){let p=Je(u);p&&o.levels.push(p);}return o.levels.sort((u,p)=>u.ilvl-p.ilvl),o}function dn(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},c=N(e,"w","lvlOverride");if(c.length>0){a.levelOverrides=[];for(let f of c){let u=s(f,"w","ilvl");if(u===null)continue;let p=parseInt(u,10);if(isNaN(p))continue;let m={ilvl:p},h=l(f,"w","startOverride");if(h){let d=s(h,"w","val");if(d!==null){let w=parseInt(d,10);isNaN(w)||(m.startOverride=w);}}let T=l(f,"w","lvl");T&&(m.lvl=Je(T)??void 0),a.levelOverrides.push(m);}}return a}function Je(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 d=s(r,"w","val");if(d!==null){let w=parseInt(d,10);isNaN(w)||(o.start=w);}}let i=l(e,"w","numFmt");if(i){let d=s(i,"w","val");d&&(o.numFmt=pn(d));}let a=l(e,"w","lvlText");a&&(o.lvlText=s(a,"w","val")??"");let c=l(e,"w","lvlJc");if(c){let d=s(c,"w","val");(d==="left"||d==="center"||d==="right")&&(o.lvlJc=d);}let f=l(e,"w","suff");if(f){let d=s(f,"w","val");(d==="tab"||d==="space"||d==="nothing")&&(o.suffix=d);}let u=l(e,"w","isLgl");u&&(o.isLgl=F(u));let p=l(e,"w","lvlRestart");if(p){let d=s(p,"w","val");if(d!==null){let w=parseInt(d,10);isNaN(w)||(o.lvlRestart=w);}}let m=l(e,"w","legacy");m&&(o.legacy={legacy:F(m),legacySpace:g(m,"w","legacySpace"),legacyIndent:g(m,"w","legacyIndent")});let h=l(e,"w","pPr");h&&(o.pPr=mn(h));let T=l(e,"w","rPr");return T&&(o.rPr=wn(T)),o}function pn(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 mn(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"),c=g(n,"w","hanging");r!==void 0&&(t.indentLeft=r),i!==void 0&&(t.indentRight=i),c!==void 0?(t.indentFirstLine=-c,t.hangingIndent=true):a!==void 0&&(t.indentFirstLine=a);}let o=l(e,"w","tabs");if(o){t.tabs=[];let r=N(o,"w","tab");for(let i of r){let a=g(i,"w","pos"),c=s(i,"w","val"),f=s(i,"w","leader");a!==void 0&&c&&t.tabs.push({position:a,alignment:gn(c),leader:hn(f)});}}return t}function gn(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 hn(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 wn(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 c=g(o,"w","val");c!==void 0&&(t.fontSize=c);}let r=l(e,"w","color");if(r){let c=s(r,"w","val"),f=s(r,"w","themeColor");c==="auto"?t.color={auto:true}:f?t.color={themeColor:f,themeTint:s(r,"w","themeTint")??void 0,themeShade:s(r,"w","themeShade")??void 0}:c&&(t.color={rgb:c});}let i=l(e,"w","b");i&&(t.bold=F(i));let a=l(e,"w","i");return a&&(t.italic=F(a)),t}function ke(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 c=i.levelOverrides.find(f=>f.ilvl===r);if(c){if(c.lvl)return c.lvl;let f=t.get(i.abstractNumId);if(f){let u=f.levels.find(p=>p.ilvl===r);if(u&&c.startOverride!==void 0)return {...u,start:c.startOverride}}}}let a=t.get(i.abstractNumId);if(!a)return null;if(a.numStyleLink&&a.levels.length===0){for(let c of t.values())if(c.styleLink===a.numStyleLink&&c.levels.length>0){a=c;break}}return a.levels.find(c=>c.ilvl===r)??null},getAbstract(o){return t.get(o)??null},hasNumbering(o){return n.has(o)}}}var Qe=914400,et=96;function ar(e){return e==null||isNaN(e)?0:Math.round(e*et/Qe)}function sr(e){return Math.round(e*Qe/et)}function yn(e){if(!e)return;let t=parseInt(e,10);if(!isNaN(t))return t/6e4}function X(e,t){let n=D(e);for(let o of n)if(o.name===t)return o;return null}function bn(e,t){let n=D(e);for(let o of n)if(t.includes(o.name||""))return o;return null}function tt(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 nt(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 ot(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 xn(e){if(!e)return;let t=s(e,null,"relativeFrom")??"column",n=X(e,"wp:align");if(n){let r=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:r}}let o=X(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 Tn(e){if(!e)return;let t=s(e,null,"relativeFrom")??"paragraph",n=X(e,"wp:align");if(n){let r=n.elements?.[0]?.text??null;return {relativeTo:t,alignment:r}}let o=X(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 Fn=["wp:wrapNone","wp:wrapSquare","wp:wrapTight","wp:wrapThrough","wp:wrapTopAndBottom"];function Sn(e,t,n){if(!e){let E={type:t?"behind":"inFront"};return n?.distT!==void 0&&(E.distT=n.distT),n?.distB!==void 0&&(E.distB=n.distB),n?.distL!==void 0&&(E.distL=n.distL),n?.distR!==void 0&&(E.distR=n.distR),E}let r=(e.name||"").replace("wp:",""),i=g(e,null,"distT")??void 0,a=g(e,null,"distB")??void 0,c=g(e,null,"distL")??void 0,f=g(e,null,"distR")??void 0,u=i??n?.distT,p=a??n?.distB,m=c??n?.distL,h=f??n?.distR,T=s(e,null,"wrapText")??void 0,d;switch(r){case "wrapNone":d=t?"behind":"inFront";break;case "wrapSquare":d="square";break;case "wrapTight":d="tight";break;case "wrapThrough":d="through";break;case "wrapTopAndBottom":d="topAndBottom";break;default:d="square";}let w={type:d};return T&&(w.wrapText=T),u!==void 0&&(w.distT=u),p!==void 0&&(w.distB=p),m!==void 0&&(w.distL=m),h!==void 0&&(w.distR=h),w}function rt(e){if(!e)return;let t=s(e,null,"rot"),n=s(e,null,"flipH")==="1",o=s(e,null,"flipV")==="1",r=yn(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 it(e){let t=X(e,"a:graphic");if(!t)return null;let n=X(t,"a:graphicData");if(!n)return null;let o=X(n,"pic:pic");if(!o)return null;let r=X(o,"pic:blipFill");return r?X(r,"a:blip"):null}function at(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 st(e){let t=X(e,"a:graphic");if(!t)return null;let n=X(t,"a:graphicData");if(!n)return null;let o=X(n,"pic:pic");if(!o)return null;let r=X(o,"pic:spPr");return r?X(r,"a:xfrm"):null}function Cn(e){if(!e)return e;let t=e.replace(/^\/+/,"");return t.startsWith("media/")?t=`word/${t}`:t.startsWith("word/")||(t=`word/${t}`),t}function kn(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 lt(e,t,n){if(!e||!t)return {};let o=t.get(e);if(!o)return {};let r=o.target;if(!r)return {};let i=Cn(r),a=r.split("/").pop(),c=(f,u)=>{let p=u.toLowerCase();for(let[m,h]of f.entries())if(m.toLowerCase()===p)return h};if(n){let f=c(n,i);if(f)return {src:f.dataUrl||f.base64,mimeType:f.mimeType,filename:a};let u=r.replace(/^\/+/,""),p=c(n,u);if(p)return {src:p.dataUrl||p.base64,mimeType:p.mimeType,filename:a};let m=`word/${u}`,h=c(n,m);if(h)return {src:h.dataUrl||h.base64,mimeType:h.mimeType,filename:a}}return {mimeType:kn(r),filename:a}}function Mn(e,t,n){let o=X(e,"wp:extent"),r=tt(o),i=X(e,"wp:effectExtent"),a=nt(i),c=X(e,"wp:docPr"),f=ot(c),u=it(e),p=at(u),m=lt(p,t,n),h=st(e),T=rt(h),d=g(e,null,"distT")??void 0,w=g(e,null,"distB")??void 0,E=g(e,null,"distL")??void 0,k=g(e,null,"distR")??void 0,P={type:"inline"};d!==void 0&&(P.distT=d),w!==void 0&&(P.distB=w),E!==void 0&&(P.distL=E),k!==void 0&&(P.distR=k);let C={type:"image",rId:p,size:r,wrap:P};return f.id&&(C.id=f.id),f.alt&&(C.alt=f.alt),f.title&&(C.title=f.title),f.decorative&&(C.decorative=true),m.src&&(C.src=m.src),m.mimeType&&(C.mimeType=m.mimeType),m.filename&&(C.filename=m.filename),a&&(C.padding=a),T&&(C.transform=T),C}function vn(e,t,n){let o=X(e,"wp:extent"),r=tt(o),i=X(e,"wp:effectExtent"),a=nt(i),c=X(e,"wp:docPr"),f=ot(c),u=s(e,null,"behindDoc")==="1",p={distT:g(e,null,"distT")??void 0,distB:g(e,null,"distB")??void 0,distL:g(e,null,"distL")??void 0,distR:g(e,null,"distR")??void 0},m=bn(e,Fn),h=Sn(m,u,p),T=X(e,"wp:positionH"),d=X(e,"wp:positionV"),w=xn(T),E=Tn(d),k;(w||E)&&(k={horizontal:w??{relativeTo:"column"},vertical:E??{relativeTo:"paragraph"}});let P=it(e),C=at(P),y=lt(C,t,n),x=st(e),S=rt(x),b={type:"image",rId:C,size:r,wrap:h};return f.id&&(b.id=f.id),f.alt&&(b.alt=f.alt),f.title&&(b.title=f.title),f.decorative&&(b.decorative=true),y.src&&(b.src=y.src),y.mimeType&&(b.mimeType=y.mimeType),y.filename&&(b.filename=y.filename),k&&(b.position=k),a&&(b.padding=a),S&&(b.transform=S),b}function Rn(e,t,n){let o=D(e);for(let r of o){let i=r.name||"";if(i==="wp:inline")return Mn(r,t,n);if(i==="wp:anchor")return vn(r,t,n)}return null}function ct(e,t,n){return Rn(e,t,n)}function ft(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 En(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 c=s(e,"w","val");return c&&(t.pattern=c),Object.keys(t).length>0?t:void 0}function Me(e,t,n){if(!e)return;let o={},r=l(e,"w","b");r&&(o.bold=F(r));let i=l(e,"w","bCs");i&&(o.boldCs=F(i));let a=l(e,"w","i");a&&(o.italic=F(a));let c=l(e,"w","iCs");c&&(o.italicCs=F(c));let f=l(e,"w","u");if(f){let M=s(f,"w","val");if(M){o.underline={style:M};let L=s(f,"w","color"),$=s(f,"w","themeColor");(L||$)&&(o.underline.color=ft(L,$,s(f,"w","themeTint"),s(f,"w","themeShade")));}}let u=l(e,"w","strike");u&&(o.strike=F(u));let p=l(e,"w","dstrike");p&&(o.doubleStrike=F(p));let m=l(e,"w","vertAlign");if(m){let M=s(m,"w","val");(M==="superscript"||M==="subscript"||M==="baseline")&&(o.vertAlign=M);}let h=l(e,"w","smallCaps");h&&(o.smallCaps=F(h));let T=l(e,"w","caps");T&&(o.allCaps=F(T));let d=l(e,"w","vanish");d&&(o.hidden=F(d));let w=l(e,"w","color");w&&(o.color=ft(s(w,"w","val"),s(w,"w","themeColor"),s(w,"w","themeTint"),s(w,"w","themeShade")));let E=l(e,"w","highlight");if(E){let M=s(E,"w","val");M&&(o.highlight=M);}let k=l(e,"w","shd");k&&(o.shading=En(k));let P=l(e,"w","sz");if(P){let M=g(P,"w","val");M!==void 0&&(o.fontSize=M);}let C=l(e,"w","szCs");if(C){let M=g(C,"w","val");M!==void 0&&(o.fontSizeCs=M);}let y=l(e,"w","rFonts");if(y){o.fontFamily={ascii:s(y,"w","ascii")??void 0,hAnsi:s(y,"w","hAnsi")??void 0,eastAsia:s(y,"w","eastAsia")??void 0,cs:s(y,"w","cs")??void 0};let M=s(y,"w","asciiTheme");M&&(o.fontFamily.asciiTheme=M,t&&!o.fontFamily.ascii&&(o.fontFamily.ascii=_(t,M)));let L=s(y,"w","hAnsiTheme");L&&(o.fontFamily.hAnsiTheme=L,t&&!o.fontFamily.hAnsi&&(o.fontFamily.hAnsi=_(t,L)));let $=s(y,"w","eastAsiaTheme");$&&(o.fontFamily.eastAsiaTheme=$,t&&!o.fontFamily.eastAsia&&(o.fontFamily.eastAsia=_(t,$)));let we=s(y,"w","cstheme");we&&(o.fontFamily.csTheme=we,t&&!o.fontFamily.cs&&(o.fontFamily.cs=_(t,we)));}let x=l(e,"w","spacing");if(x){let M=g(x,"w","val");M!==void 0&&(o.spacing=M);}let S=l(e,"w","position");if(S){let M=g(S,"w","val");M!==void 0&&(o.position=M);}let b=l(e,"w","w");if(b){let M=g(b,"w","val");M!==void 0&&(o.scale=M);}let v=l(e,"w","kern");if(v){let M=g(v,"w","val");M!==void 0&&(o.kerning=M);}let B=l(e,"w","effect");if(B){let M=s(B,"w","val");M&&(o.effect=M);}let A=l(e,"w","em");if(A){let M=s(A,"w","val");M&&(o.emphasisMark=M);}let I=l(e,"w","emboss");I&&(o.emboss=F(I));let O=l(e,"w","imprint");O&&(o.imprint=F(O));let U=l(e,"w","outline");U&&(o.outline=F(U));let K=l(e,"w","shadow");K&&(o.shadow=F(K));let H=l(e,"w","rtl");H&&(o.rtl=F(H));let W=l(e,"w","cs");W&&(o.cs=F(W));let R=l(e,"w","rStyle");if(R){let M=s(R,"w","val");M&&(o.styleId=M);}return Object.keys(o).length>0?o:void 0}function Pn(e){let t=re(e),n=s(e,"xml","space")==="preserve";return {type:"text",text:t,preserveSpace:n||void 0}}function Bn(){return {type:"tab"}}function An(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 Nn(e){let t=s(e,"w","font")??"",n=s(e,"w","char")??"";return {type:"symbol",font:t,char:n}}function In(e){return {type:"footnoteRef",id:g(e,"w","id")??0}}function Xn(e){return {type:"endnoteRef",id:g(e,"w","id")??0}}function Ln(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 Dn(e){return {type:"instrText",text:re(e)}}function Hn(e,t,n){let o=ct(e,t??void 0,n??void 0);return o?{type:"drawing",image:o}:null}function On(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Wn(e,t,n){let o=[],r=D(e);for(let i of r)switch(On(i.name)){case "t":o.push(Pn(i));break;case "tab":o.push(Bn());break;case "br":o.push(An(i));break;case "sym":o.push(Nn(i));break;case "footnoteReference":o.push(In(i));break;case "endnoteReference":o.push(Xn(i));break;case "fldChar":o.push(Ln(i));break;case "instrText":o.push(Dn(i));break;case "softHyphen":o.push({type:"softHyphen"});break;case "noBreakHyphen":o.push({type:"noBreakHyphen"});break;case "drawing":let c=Hn(i,t,n);c&&o.push(c);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=Me(a,n)),i.content=Wn(e,o,r),i}function jn(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function Vn(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 zn(e){return {type:"bookmarkEnd",id:g(e,"w","id")??0}}function ut(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 T=t.get(a);T&&(He(T),i.href=T.target);}let c=s(e,"w","anchor");c&&(i.anchor=c,i.href||(i.href=`#${c}`));let f=s(e,"w","tooltip");f&&(i.tooltip=f);let u=s(e,"w","tgtFrame");u&&(i.target=u);let p=s(e,"w","history");(p==="1"||p==="true")&&(i.history=true);let m=s(e,"w","docLocation");m&&(i.docLocation=m);let h=D(e);for(let T of h)switch(jn(T.name)){case "r":i.children.push(ee(T,n,o,t,r));break;case "bookmarkStart":i.children.push(Vn(T));break;case "bookmarkEnd":i.children.push(zn(T));break}return i}function dt(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 pt(e){return {type:"bookmarkEnd",id:g(e,"w","id")??0}}function Un(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 Un(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=s(e,"w","color"),c=s(e,"w","themeColor"),f=s(e,"w","themeTint"),u=s(e,"w","themeShade");(a||c||f||u)&&(o.color={rgb:a??void 0,themeColor:c,themeTint:f??void 0,themeShade:u??void 0});let p=s(e,"w","shadow");(p==="1"||p==="true")&&(o.shadow=true);let m=s(e,"w","frame");return (m==="1"||m==="true")&&(o.frame=true),o}function mt(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 c=J(l(e,"w","insideV"));if(c&&(t.insideV=c),Object.keys(t).length!==0)return t}function gt(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 ht(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 c=s(e,"w","themeFillShade");c&&t.fill&&(t.fill.themeShade=c);}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 $n(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 c=s(e,"w","noVBand");(c==="1"||c==="true")&&(t.noVBand=true);let f=s(e,"w","val");if(f){let u=parseInt(f,16);isNaN(u)||(u&32&&(t.firstRow=true),u&64&&(t.lastRow=true),u&128&&(t.firstColumn=true),u&256&&(t.lastColumn=true),u&512&&(t.noHBand=true),u&1024&&(t.noVBand=true));}if(Object.keys(t).length!==0)return t}function _n(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 c=s(e,"w","tblpYSpec");c&&(t.tblpYSpec=c);let f=g(e,"w","topFromText");f!==void 0&&(t.topFromText=f);let u=g(e,"w","bottomFromText");u!==void 0&&(t.bottomFromText=u);let p=g(e,"w","leftFromText");p!==void 0&&(t.leftFromText=p);let m=g(e,"w","rightFromText");if(m!==void 0&&(t.rightFromText=m),Object.keys(t).length!==0)return t}function Gn(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 w=s(o,"w","val");(w==="left"||w==="center"||w==="right"||w==="start")&&(t.justification=w==="start"?"left":w);}let r=Y(l(e,"w","tblCellSpacing"));r&&(t.cellSpacing=r);let i=Y(l(e,"w","tblInd"));i&&(t.indent=i);let a=mt(l(e,"w","tblBorders"));a&&(t.borders=a);let c=gt(l(e,"w","tblCellMar"));c&&(t.cellMargins=c);let f=l(e,"w","tblLayout");if(f){let w=s(f,"w","type");(w==="fixed"||w==="autofit")&&(t.layout=w);}let u=l(e,"w","tblStyle");if(u){let w=s(u,"w","val");w&&(t.styleId=w);}let p=$n(l(e,"w","tblLook"));p&&(t.look=p);let m=ht(l(e,"w","shd"));m&&(t.shading=m);let h=l(e,"w","tblOverlap");if(h){let w=s(h,"w","val");(w==="never"||w==="overlap")&&(t.overlap=w);}let T=_n(l(e,"w","tblpPr"));if(T&&(t.floating=T),F(l(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length!==0)return t}function qn(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);}F(l(e,"w","tblHeader"))&&(t.header=true),F(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);}F(l(e,"w","hidden"))&&(t.hidden=true);let c=wt(l(e,"w","cnfStyle"));if(c&&(t.conditionalFormat=c),Object.keys(t).length!==0)return t}function wt(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 c=s(e,"w","evenHBand");(c==="1"||c==="true")&&(t.evenHBand=true);let f=s(e,"w","oddVBand");(f==="1"||f==="true")&&(t.oddVBand=true);let u=s(e,"w","evenVBand");(u==="1"||u==="true")&&(t.evenVBand=true);let p=s(e,"w","firstRowFirstColumn");(p==="1"||p==="true")&&(t.nwCell=true);let m=s(e,"w","firstRowLastColumn");(m==="1"||m==="true")&&(t.neCell=true);let h=s(e,"w","lastRowFirstColumn");(h==="1"||h==="true")&&(t.swCell=true);let T=s(e,"w","lastRowLastColumn");(T==="1"||T==="true")&&(t.seCell=true);let d=s(e,"w","val");if(d&&d.length===12&&(d[0]==="1"&&(t.firstRow=true),d[1]==="1"&&(t.lastRow=true),d[2]==="1"&&(t.firstColumn=true),d[3]==="1"&&(t.lastColumn=true),d[4]==="1"&&(t.oddVBand=true),d[5]==="1"&&(t.evenVBand=true),d[6]==="1"&&(t.oddHBand=true),d[7]==="1"&&(t.evenHBand=true),d[8]==="1"&&(t.nwCell=true),d[9]==="1"&&(t.neCell=true),d[10]==="1"&&(t.swCell=true),d[11]==="1"&&(t.seCell=true)),Object.keys(t).length!==0)return t}function Zn(e){if(!e)return;let t={},n=Y(l(e,"w","tcW"));n&&(t.width=n);let o=mt(l(e,"w","tcBorders"));o&&(t.borders=o);let r=gt(l(e,"w","tcMar"));r&&(t.margins=r);let i=ht(l(e,"w","shd"));i&&(t.shading=i);let a=l(e,"w","vAlign");if(a){let d=s(a,"w","val");(d==="top"||d==="center"||d==="bottom")&&(t.verticalAlign=d);}let c=l(e,"w","textDirection");if(c){let d=s(c,"w","val");d&&(t.textDirection=d);}let f=l(e,"w","gridSpan");if(f){let d=g(f,"w","val");d!==void 0&&d>1&&(t.gridSpan=d);}let u=l(e,"w","vMerge");u&&(s(u,"w","val")==="restart"?t.vMerge="restart":t.vMerge="continue"),F(l(e,"w","tcFitText"))&&(t.fitText=true),F(l(e,"w","noWrap"))&&(t.noWrap=true),F(l(e,"w","hideMark"))&&(t.hideMark=true);let T=wt(l(e,"w","cnfStyle"));if(T&&(t.conditionalFormat=T),Object.keys(t).length!==0)return t}function Yn(e,t,n,o,r,i){let a=[],c=e.elements||[];for(let f of c){if(!f.name)continue;let u=f.name.split(":").pop();if(u==="p"){let p=z(f,t,n,o,r,i);a.push(p);}else if(u==="tbl"){let p=te(f,t,n,o,r,i);a.push(p);}}return a.length===0&&a.push({type:"paragraph",content:[]}),a}function Kn(e,t,n,o,r,i){let a={type:"tableCell",content:[]},c=Zn(l(e,"w","tcPr"));return c&&(a.formatting=c),a.content=Yn(e,t,n,o,r,i),a}function Jn(e,t,n,o,r,i){let a={type:"tableRow",cells:[]},c=qn(l(e,"w","trPr"));c&&(a.formatting=c);let f=N(e,"w","tc");for(let u of f){let p=Kn(u,t,n,o,r,i);a.cells.push(p);}return a}function Qn(e){if(!e)return;let t=[],n=N(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:[]},c=Gn(l(e,"w","tblPr"));c&&(a.formatting=c);let f=Qn(l(e,"w","tblGrid"));f&&(a.columnWidths=f);let u=N(e,"w","tr");for(let p of u){let m=Jn(p,t,n,o,r,i);a.rows.push(m);}return a}function yt(e){switch(e){case "first":return "first";case "even":return "even";default:return "default"}}function bt(e){let t=s(e,"w","type"),n=s(e,"r","id")??"";return {type:yt(t),rId:n}}function xt(e){let t=s(e,"w","type"),n=s(e,"r","id")??"";return {type:yt(t),rId:n}}function ve(e,t,n,o,r,i){let a=[],c=e.elements??[];for(let f of c){if(f.type!=="element")continue;let u=f.name??"";if(u==="w:p"||u.endsWith(":p")){let p=z(f,t,n,o,r,i);a.push(p);}else if(u==="w:tbl"||u.endsWith(":tbl")){let p=te(f,t,n,o,r,i);a.push(p);}else if(u==="w:sdt"||u.endsWith(":sdt")){let p=(f.elements??[]).find(m=>m.type==="element"&&(m.name==="w:sdtContent"||m.name?.endsWith(":sdtContent")));if(p){let m=ve(p,t,n,o,r,i);a.push(...m);}}}return a}function Tt(e,t="default",n=null,o=null,r=null,i=null,a=null){let c={type:"header",hdrFtrType:t,content:[]};if(!e)return c;let f=j(e);if(!f)return c;let u=f.elements?.find(p=>p.type==="element"&&(p.name==="w:hdr"||p.name?.endsWith(":hdr")));return u&&(c.content=ve(u,n,o,r,i,a)),c}function Ft(e,t="default",n=null,o=null,r=null,i=null,a=null){let c={type:"footer",hdrFtrType:t,content:[]};if(!e)return c;let f=j(e);if(!f)return c;let u=f.elements?.find(p=>p.type==="element"&&(p.name==="w:ftr"||p.name?.endsWith(":ftr")));return u&&(c.content=ve(u,n,o,r,i,a)),c}function St(e){switch(e){case "separator":return "separator";case "continuationSeparator":return "continuationSeparator";case "continuationNotice":return "continuationNotice";default:return "normal"}}function eo(e,t,n,o,r,i){let a=g(e,"w","id")??0,c=s(e,"w","type"),f=St(c),p=N(e,"w","p").map(m=>z(m,t,n,o,r));return {type:"footnote",id:a,noteType:f,content:p}}function Ct(e,t=null,n=null,o=null,r=null,i=null){let a=new Map,c=[];if(!e)return fe(a,c);let f=j(e);if(!f)return fe(a,c);let u=f.elements?.find(m=>m.type==="element"&&(m.name==="w:footnotes"||m.name?.endsWith(":footnotes")));if(!u)return fe(a,c);let p=N(u,"w","footnote");for(let m of p){let h=eo(m,t,n,o,r);a.set(h.id,h),c.push(h);}return fe(a,c)}function fe(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 to(e,t,n,o,r,i){let a=g(e,"w","id")??0,c=s(e,"w","type"),f=St(c),p=N(e,"w","p").map(m=>z(m,t,n,o,r));return {type:"endnote",id:a,noteType:f,content:p}}function kt(e,t=null,n=null,o=null,r=null,i=null){let a=new Map,c=[];if(!e)return ue(a,c);let f=j(e);if(!f)return ue(a,c);let u=f.elements?.find(m=>m.type==="element"&&(m.name==="w:endnotes"||m.name?.endsWith(":endnotes")));if(!u)return ue(a,c);let p=N(u,"w","endnote");for(let m of p){let h=to(m,t,n,o,r);a.set(h.id,h),c.push(h);}return ue(a,c)}function ue(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 Mt(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 no(e){switch(e){case "pageBottom":return "pageBottom";case "beneathText":return "beneathText";case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function oo(e){switch(e){case "sectEnd":return "sectEnd";case "docEnd":return "docEnd";default:return}}function vt(e){switch(e){case "continuous":return "continuous";case "eachSect":return "eachSect";case "eachPage":return "eachPage";default:return}}function Rt(e){let t={};if(!e)return t;let n=l(e,"w","pos");if(n){let a=s(n,"w","val");t.position=no(a);}let o=l(e,"w","numFmt");if(o){let a=s(o,"w","val");t.numFmt=Mt(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=vt(a);}return t}function Et(e){let t={};if(!e)return t;let n=l(e,"w","pos");if(n){let a=s(n,"w","val");t.position=oo(a);}let o=l(e,"w","numFmt");if(o){let a=s(o,"w","val");t.numFmt=Mt(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=vt(a);}return t}function Rr(e){let t=[];for(let n of e.content){let o=[];for(let r of n.content)if(r.type==="run")for(let i of r.content)i.type==="text"&&o.push(i.text);t.push(o.join(""));}return t.join(`
|
|
10
10
|
`)}function ro(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"),c=s(e,"w","themeColor"),f=s(e,"w","themeTint"),u=s(e,"w","themeShade"),p=ro(a,c,f,u);p&&(o.color=p);let m=s(e,"w","shadow");(m==="1"||m==="true")&&(o.shadow=true);let h=s(e,"w","frame");return (h==="1"||h==="true")&&(o.frame=true),o}function io(e){switch(e){case "landscape":return "landscape";case "portrait":return "portrait";default:return}}function ao(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 so(e){switch(e){case "top":return "top";case "center":return "center";case "both":return "both";case "bottom":return "bottom";default:return}}function lo(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 y=g(o,"w","w");y!==void 0&&(n.pageWidth=y);let x=g(o,"w","h");x!==void 0&&(n.pageHeight=x);let S=s(o,"w","orient"),b=io(S);b&&(n.orientation=b);}let r=l(e,"w","pgMar");if(r){let y=g(r,"w","top");y!==void 0&&(n.marginTop=y);let x=g(r,"w","bottom");x!==void 0&&(n.marginBottom=x);let S=g(r,"w","left");S!==void 0&&(n.marginLeft=S);let b=g(r,"w","right");b!==void 0&&(n.marginRight=b);let v=g(r,"w","header");v!==void 0&&(n.headerDistance=v);let B=g(r,"w","footer");B!==void 0&&(n.footerDistance=B);let A=g(r,"w","gutter");A!==void 0&&(n.gutter=A);}let i=l(e,"w","cols");if(i){let y=g(i,"w","num");y!==void 0&&(n.columnCount=y);let x=g(i,"w","space");x!==void 0&&(n.columnSpace=x);let S=s(i,"w","equalWidth");S==="1"||S==="true"?n.equalWidth=true:(S==="0"||S==="false")&&(n.equalWidth=false);let b=s(i,"w","sep");(b==="1"||b==="true")&&(n.separator=true);let v=N(i,"w","col");if(v.length>0){n.columns=[];for(let B of v){let A={},I=g(B,"w","w");I!==void 0&&(A.width=I);let O=g(B,"w","space");O!==void 0&&(A.space=O),n.columns.push(A);}}}let a=l(e,"w","type");if(a){let y=s(a,"w","val"),x=ao(y);x&&(n.sectionStart=x);}let c=l(e,"w","vAlign");if(c){let y=s(c,"w","val"),x=so(y);x&&(n.verticalAlign=x);}let f=l(e,"w","bidi");f&&(n.bidi=F(f));let u=N(e,"w","headerReference");u.length>0&&(n.headerReferences=u.map(y=>bt(y)));let p=N(e,"w","footerReference");p.length>0&&(n.footerReferences=p.map(y=>xt(y)));let m=l(e,"w","titlePg");m&&(n.titlePg=F(m));let h=l(e,"w","evenAndOddHeaders");h&&(n.evenAndOddHeaders=F(h));let T=l(e,"w","lnNumType");if(T){n.lineNumbers={};let y=g(T,"w","start");y!==void 0&&(n.lineNumbers.start=y);let x=g(T,"w","countBy");x!==void 0&&(n.lineNumbers.countBy=x);let S=g(T,"w","distance");S!==void 0&&(n.lineNumbers.distance=S);let b=s(T,"w","restart"),v=lo(b);v&&(n.lineNumbers.restart=v);}let d=l(e,"w","pgBorders");if(d){n.pageBorders={};let y=de(l(d,"w","top"));y&&(n.pageBorders.top=y);let x=de(l(d,"w","bottom"));x&&(n.pageBorders.bottom=x);let S=de(l(d,"w","left"));S&&(n.pageBorders.left=S);let b=de(l(d,"w","right"));b&&(n.pageBorders.right=b);let v=s(d,"w","display");(v==="allPages"||v==="firstPage"||v==="notFirstPage")&&(n.pageBorders.display=v);let B=s(d,"w","offsetFrom");(B==="page"||B==="text")&&(n.pageBorders.offsetFrom=B);let A=s(d,"w","zOrder");(A==="front"||A==="back")&&(n.pageBorders.zOrder=A);}let w=l(e,"w","background");if(w){n.background={};let y=s(w,"w","color");y&&y!=="auto"&&(n.background.color={rgb:y});let x=s(w,"w","themeColor");x&&(n.background.themeColor=x);let S=s(w,"w","themeTint");S&&(n.background.themeTint=S);let b=s(w,"w","themeShade");b&&(n.background.themeShade=b);}let E=l(e,"w","footnotePr");if(E){let y=Rt(E);Object.keys(y).length>0&&(n.footnotePr=y);}let k=l(e,"w","endnotePr");if(k){let y=Et(k);Object.keys(y).length>0&&(n.endnotePr=y);}let P=l(e,"w","docGrid");if(P){n.docGrid={};let y=s(P,"w","type");(y==="default"||y==="lines"||y==="linesAndChars"||y==="snapToChars")&&(n.docGrid.type=y);let x=g(P,"w","linePitch");x!==void 0&&(n.docGrid.linePitch=x);let S=g(P,"w","charSpace");S!==void 0&&(n.docGrid.charSpace=S);}let C=l(e,"w","paperSrc");if(C){let y=g(C,"w","first");y!==void 0&&(n.paperSrcFirst=y);let x=g(C,"w","other");x!==void 0&&(n.paperSrcOther=x);}return n}function Pt(){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 co(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||!fo(e.underline,t.underline)||!me(e.color,t.color)||!uo(e.shading,t.shading)||!po(e.fontFamily,t.fontFamily))}function fo(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 uo(e,t){return !e&&!t?true:!(!e||!t||e.pattern!==t.pattern||!me(e.color,t.color)||!me(e.fill,t.fill))}function po(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 mo(e){return e.type==="text"||e.type==="softHyphen"||e.type==="noBreakHyphen"}function Bt(e){return e.content.length===0?true:e.content.every(mo)}function go(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 ho(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}Bt(n)&&Bt(o)&&co(n.formatting,o.formatting)?n={type:"run",formatting:n.formatting,content:go(n.content,o.content)}:(t.push(n),n={...o,content:[...o.content]});}return n!==null&&t.push(n),t}function Re(e){if(e.length<=1)return e;let t=[],n=[];function o(){if(n.length>0){let r=ho(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:Re(r.children)};t.push(i);}else t.push(r);return o(),t}function wo(e){let t={sdtType:"richText"};if(!e||!e.elements)return t;for(let n of e.elements){if(n.type!=="element")continue;switch(n.name?.replace(/^w:/,"")??""){case "alias":t.alias=s(n,"w","val")??void 0;break;case "tag":t.tag=s(n,"w","val")??void 0;break;case "lock":t.lock=s(n,"w","val")??"unlocked";break;case "placeholder":{let r=l(n,"w","docPart");if(r){let i=l(r,"w","val");t.placeholder=i?s(i,"w","val")??void 0:void 0;}break}case "showingPlcHdr":t.showingPlaceholder=true;break;case "text":t.sdtType="plainText";break;case "date":t.sdtType="date",t.dateFormat=s(n,"w","fullDate")??void 0;break;case "dropDownList":t.sdtType="dropdown",t.listItems=At(n);break;case "comboBox":t.sdtType="comboBox",t.listItems=At(n);break;case "checkbox":{t.sdtType="checkbox";let r=l(n,"w14","checked")??l(n,"w","checked");t.checked=r?s(r,"w14","val")==="1"||s(r,"w","val")==="1":false;break}case "picture":t.sdtType="picture";break;case "docPartObj":t.sdtType="buildingBlockGallery";break;case "group":t.sdtType="group";break}}return t}function At(e){let t=[];for(let n of e.elements??[])n.type==="element"&&(n.name==="w:listItem"||n.name?.endsWith(":listItem"))&&t.push({displayText:s(n,"w","displayText")??"",value:s(n,"w","value")??""});return t}function Nt(e){let t="";if(e.type==="text"&&typeof e.text=="string")return e.text;if(e.elements)for(let n of e.elements)if((n.name?.replace(/^.*:/,"")??"")==="t"&&n.elements)for(let r of n.elements)r.type==="text"&&typeof r.text=="string"&&(t+=r.text);else t+=Nt(n);return t}function yo(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 bo(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 c=s(e,"w","val");return c&&(t.pattern=c),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=yo(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 c=s(e,"w","shadow");c&&(n.shadow=c==="1"||c==="true");let f=s(e,"w","frame");return f&&(n.frame=f==="1"||f==="true"),n}function xo(e){if(!e)return;let t=N(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},c=s(o,"w","leader");c&&(a.leader=c),n.push(a);}}return n.length>0?n:void 0}function To(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 c=g(e,"w","y");c!==void 0&&(t.y=c);let f=s(e,"w","xAlign");f&&(t.xAlign=f);let u=s(e,"w","yAlign");u&&(t.yAlign=u);let p=s(e,"w","wrap");return p&&(t.wrap=p),Object.keys(t).length>0?t:void 0}function Fo(e,t,n){if(!e)return;let o={},r=l(e,"w","jc");if(r){let b=s(r,"w","val");b&&(o.alignment=b);}let i=l(e,"w","bidi");i&&(o.bidi=F(i));let a=l(e,"w","spacing");if(a){let b=g(a,"w","before");b!==void 0&&(o.spaceBefore=b);let v=g(a,"w","after");v!==void 0&&(o.spaceAfter=v);let B=g(a,"w","line");B!==void 0&&(o.lineSpacing=B);let A=s(a,"w","lineRule");A&&(o.lineSpacingRule=A);let I=s(a,"w","beforeAutospacing");I&&(o.beforeAutospacing=I==="1"||I==="true");let O=s(a,"w","afterAutospacing");O&&(o.afterAutospacing=O==="1"||O==="true");}let c=l(e,"w","ind");if(c){let b=g(c,"w","left");b!==void 0&&(o.indentLeft=b);let v=g(c,"w","right");v!==void 0&&(o.indentRight=v);let B=g(c,"w","firstLine");B!==void 0&&(o.indentFirstLine=B);let A=g(c,"w","hanging");A!==void 0&&(o.indentFirstLine=-A,o.hangingIndent=true);let I=g(c,"w","start");I!==void 0&&o.indentLeft===void 0&&(o.indentLeft=I);let O=g(c,"w","end");O!==void 0&&o.indentRight===void 0&&(o.indentRight=O);}let f=l(e,"w","pBdr");if(f){let b={},v=Q(l(f,"w","top"));v&&(b.top=v);let B=Q(l(f,"w","bottom"));B&&(b.bottom=B);let A=Q(l(f,"w","left"));A&&(b.left=A);let I=Q(l(f,"w","right"));I&&(b.right=I);let O=Q(l(f,"w","between"));O&&(b.between=O);let U=Q(l(f,"w","bar"));U&&(b.bar=U),Object.keys(b).length>0&&(o.borders=b);}let u=l(e,"w","shd");u&&(o.shading=bo(u));let p=l(e,"w","tabs");p&&(o.tabs=xo(p));let m=l(e,"w","keepNext");m&&(o.keepNext=F(m));let h=l(e,"w","keepLines");h&&(o.keepLines=F(h));let T=l(e,"w","widowControl");T&&(o.widowControl=F(T));let d=l(e,"w","pageBreakBefore");d&&(o.pageBreakBefore=F(d));let w=l(e,"w","contextualSpacing");w&&(o.contextualSpacing=F(w));let E=l(e,"w","numPr");if(E){let b=l(E,"w","numId"),v=l(E,"w","ilvl");if(b||v){if(o.numPr={},b){let B=g(b,"w","val");B!==void 0&&(o.numPr.numId=B);}if(v){let B=g(v,"w","val");B!==void 0&&(o.numPr.ilvl=B);}}}let k=l(e,"w","outlineLvl");if(k){let b=g(k,"w","val");b!==void 0&&(o.outlineLevel=b);}let P=l(e,"w","pStyle");if(P){let b=s(P,"w","val");b&&(o.styleId=b);}let C=l(e,"w","framePr");C&&(o.frame=To(C));let y=l(e,"w","suppressLineNumbers");y&&(o.suppressLineNumbers=F(y));let x=l(e,"w","suppressAutoHyphens");x&&(o.suppressAutoHyphens=F(x));let S=l(e,"w","rPr");return S&&(o.runProperties=Me(S,t)),Object.keys(o).length>0?o:void 0}function It(e){if(!e)return "";let t=e.indexOf(":");return t>=0?e.substring(t+1):e}function So(e,t,n,o,r){return ut(e,t,n,o,r)}function Co(e){return dt(e)}function ko(e){return pt(e)}function Xt(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 Mo(e,t,n,o,r){let i=s(e,"w","instr")??"",a=Xt(i),c={type:"simpleField",instruction:i,fieldType:a,content:[]},f=s(e,"w","fldLock");(f==="1"||f==="true")&&(c.fldLock=true);let u=s(e,"w","dirty");(u==="1"||u==="true")&&(c.dirty=true);let p=D(e);for(let m of p)It(m.name)==="r"&&c.content.push(ee(m,t,n,o,r));return c}function ge(e,t,n,o,r,i){let a=[],c=D(e),f=false,u="",p=[],m=[],h=false,T=false,d=false;for(let w of c){let E=It(w.name);switch(E){case "r":{let k=ee(w,t,n,r,i),P=false,C=false,y=false,x="";for(let S of k.content)S.type==="fieldChar"?S.charType==="begin"?(P=true,S.fldLock&&(T=true),S.dirty&&(d=true)):S.charType==="separate"?C=true:S.charType==="end"&&(y=true):S.type==="instrText"&&(x+=S.text);if(P&&(f=true,h=false,u="",p=[],m=[],T=false,d=false),f){if(x&&(u+=x),C&&(h=true),h&&!y?C||m.push(k):!h&&!P&&p.push(k),y){let S={type:"complexField",instruction:u.trim(),fieldType:Xt(u),fieldCode:p,fieldResult:m};T&&(S.fldLock=true),d&&(S.dirty=true),a.push(S),f=false;}}else a.push(k);break}case "hyperlink":a.push(So(w,r,t,n,i));break;case "bookmarkStart":a.push(Co(w));break;case "bookmarkEnd":a.push(ko(w));break;case "fldSimple":a.push(Mo(w,t,n,r,i));break;case "pPr":break;case "proofErr":case "permStart":case "permEnd":case "customXml":break;case "sdt":{let k=(w.elements??[]).find(C=>C.type==="element"&&(C.name==="w:sdtPr"||C.name?.endsWith(":sdtPr"))),P=(w.elements??[]).find(C=>C.type==="element"&&(C.name==="w:sdtContent"||C.name?.endsWith(":sdtContent")));if(P){let C=ge(P,t,n,null,r,i),x={type:"inlineSdt",properties:wo(k??null),content:C.filter(S=>S.type==="run"||S.type==="hyperlink")};a.push(x);}break}case "ins":{let k={id:parseInt(s(w,"w","id")??"0",10),author:s(w,"w","author")??"Unknown",date:s(w,"w","date")??void 0},P=ge(w,t,n,null,r,i),C={type:"insertion",info:k,content:P.filter(y=>y.type==="run"||y.type==="hyperlink")};a.push(C);break}case "del":{let k={id:parseInt(s(w,"w","id")??"0",10),author:s(w,"w","author")??"Unknown",date:s(w,"w","date")??void 0},P=ge(w,t,n,null,r,i),C={type:"deletion",info:k,content:P.filter(y=>y.type==="run"||y.type==="hyperlink")};a.push(C);break}case "smartTag":case "moveTo":case "moveFrom":break;case "commentRangeStart":{let k=parseInt(s(w,"w","id")??"0",10);a.push({type:"commentRangeStart",id:k});break}case "commentRangeEnd":{let k=parseInt(s(w,"w","id")??"0",10);a.push({type:"commentRangeEnd",id:k});break}case "oMath":case "oMathPara":{let k=E==="oMathPara",P=De(w),C=Nt(w),y={type:"mathEquation",display:k?"block":"inline",ommlXml:P,plainText:C||void 0};a.push(y);break}}}return a}function z(e,t,n,o,r=null,i=null){let a={type:"paragraph",content:[]},c=s(e,"w14","paraId")??s(e,"w","paraId");c&&(a.paraId=c);let f=s(e,"w14","textId")??s(e,"w","textId");f&&(a.textId=f);let u=l(e,"w","pPr");if(u){a.formatting=Fo(u,n);let h=l(u,"w","sectPr");h&&(a.sectionProperties=pe(h));}let p=ge(e,t,n,o,r,i);a.content=Re(p);let m=a.formatting?.numPr;if(!m&&a.formatting?.styleId&&t){let h=t.get(a.formatting.styleId);h?.pPr?.numPr&&(m=h.pPr.numPr,a.formatting||(a.formatting={}),a.formatting.numPr=m);}if(m&&o){let{numId:h,ilvl:T=0}=m;if(h!==void 0&&h!==0){let d=o.getLevel(h,T);if(d&&(a.listRendering={level:T,numId:h,marker:d.lvlText,isBullet:d.numFmt==="bullet",numFmt:d.numFmt},d.pPr)){a.formatting||(a.formatting={});let w=u?l(u,"w","ind"):null,E=w!=null&&(s(w,"w","left")!==null||s(w,"w","start")!==null),k=w!=null&&(s(w,"w","firstLine")!==null||s(w,"w","hanging")!==null);!E&&d.pPr.indentLeft!==void 0&&(a.formatting.indentLeft=d.pPr.indentLeft),k||(d.pPr.indentFirstLine!==void 0&&(a.formatting.indentFirstLine=d.pPr.indentFirstLine),d.pPr.hangingIndent!==void 0&&(a.formatting.hangingIndent=d.pPr.hangingIndent));}}}return a}function Ee(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+=`
|
|
11
|
-
`);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 vo(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 Ro(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 u=i+1;u<a.length;u++)a[u]=0;let c=o.marker;if(o.isBullet){let u=c||"";o.marker=vo(u);return}let f=c;for(let u=0;u<=i;u++){let p=`%${u+1}`;if(f.includes(p)){let m=a[u],h=t.getLevel(r,u),T=Eo(m,h?.numFmt||"decimal");f=f.replace(p,T);}}o.marker=f;}function Eo(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 Lt(e).toLowerCase();case "upperRoman":return Lt(e);case "bullet":return "\u2022";default:return String(e)}}function Lt(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 Dt=/\{
|
|
11
|
+
`);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 vo(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 Ro(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 u=i+1;u<a.length;u++)a[u]=0;let c=o.marker;if(o.isBullet){let u=c||"";o.marker=vo(u);return}let f=c;for(let u=0;u<=i;u++){let p=`%${u+1}`;if(f.includes(p)){let m=a[u],h=t.getLevel(r,u),T=Eo(m,h?.numFmt||"decimal");f=f.replace(p,T);}}o.marker=f;}function Eo(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 Lt(e).toLowerCase();case "upperRoman":return Lt(e);case "bullet":return "\u2022";default:return String(e)}}function Lt(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 Dt=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g;function Ht(e){let t=[],n;for(Dt.lastIndex=0;(n=Dt.exec(e))!==null;){let o=n[1].trim();o&&!t.includes(o)&&t.push(o);}return t}function Ot(e){let t=[];for(let n of e)if(n.type==="paragraph"){let o=Ee(n),r=Ht(o);for(let i of r)t.includes(i)||t.push(i);}else if(n.type==="table"){let o=Wt(n);for(let r of o)t.includes(r)||t.push(r);}return t}function Wt(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=Ee(r),a=Ht(i);for(let c of a)t.includes(c)||t.push(c);}else if(r.type==="table"){let i=Wt(r);for(let a of i)t.includes(a)||t.push(a);}return t}function jt(e,t,n,o,r,i){let a=[],c=D(e),f=new Map;for(let u of c){let p=u.name??"";if(p==="w:p"||p.endsWith(":p")){let m=z(u,t,n,o,r,i);Ro(m,o,f),a.push(m);}else if(p==="w:tbl"||p.endsWith(":tbl")){let m=te(u,t,n,o,r,i);a.push(m);}else if(p==="w:sdt"||p.endsWith(":sdt")){let m=(u.elements??[]).find(h=>h.type==="element"&&(h.name==="w:sdtContent"||h.name?.endsWith(":sdtContent")));if(m){let h=jt(m,t,n,o,r,i);a.push(...h);}}}return a}function Po(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??Pt(),content:o}),n}function Vt(e,t=null,n=null,o=null,r=null,i=null){let a={content:[]};if(!e)return a;let c=j(e);if(!c)return a;let f=(c.elements??[]).find(m=>m.type==="element"&&(m.name==="w:document"||m.name?.endsWith(":document")));if(!f)return a;let u=l(f,"w","body");if(!u)return a;a.content=jt(u,t,n,o,r,i);let p=l(u,"w","sectPr");return p&&(a.finalSectionProperties=pe(p)),a.sections=Po(a.content,a.finalSectionProperties),a}function Bo(e){let t=new Map,n=j(e);if(!n)return t;let o=l(n,"w16cex","commentsExtensible")??n;for(let r of D(o)){if((r.name?.replace(/^.*:/,"")??"")!=="comment")continue;let a=s(r,"w16cex","paraId")??s(r,"w15","paraId")??r.attributes?.["w16cex:paraId"]??r.attributes?.["w15:paraId"],c=s(r,"w16cex","dateUtc")??s(r,"w15","dateUtc")??r.attributes?.["w16cex:dateUtc"]??r.attributes?.["w15:dateUtc"];a&&c&&t.set(String(a).toUpperCase(),String(c));}return t}function zt(e,t,n,o,r,i){if(!e)return [];let a=j(e);if(!a)return [];let c=i?Bo(i):new Map,f=l(a,"w","comments")??a,u=D(f),p=[];for(let m of u){if((m.name?.replace(/^.*:/,"")??"")!=="comment")continue;let T=parseInt(s(m,"w","id")??"0",10),d=s(m,"w","author")??"Unknown",w=s(m,"w","initials"),E=w!=null?String(w):void 0,k=s(m,"w","date"),P=k!=null?String(k):void 0,C=s(m,"w14","paraId")??m.attributes?.["w14:paraId"]??s(m,"w","paraId"),x=(C?c.get(String(C).toUpperCase()):void 0)??P,S=[];for(let b of D(m))if((b.name?.replace(/^.*:/,"")??"")==="p"){let B=z(b,t,n,null,o,r);S.push(B);}p.push({id:T,author:d,initials:E,date:x,content:S});}return p}async function si(e,t={}){let n=e instanceof ArrayBuffer?e:await Ie(e),{onProgress:o=()=>{},preloadFonts:r=true,parseHeadersFooters:i=true,parseNotes:a=true,detectVariables:c=true}=t,f=[];try{let h=function(H,W){let R=performance.now(),M=W(),L=performance.now()-R;return m.push({stage:H,ms:L}),L>1e3&&console.warn(`[parseDocx] ${H} took ${Math.round(L)}ms`),M};var u=h;let p=performance.now(),m=[];async function T(H,W){let R=performance.now(),M=await W(),L=performance.now()-R;return m.push({stage:H,ms:L}),L>1e3&&console.warn(`[parseDocx] ${H} took ${Math.round(L)}ms`),M}o("Extracting DOCX...",0);let d=await T("unzip",()=>Xe(n));o("Extracted DOCX",10),o("Parsing relationships...",10);let w=h("relationships",()=>d.documentRels?ae(d.documentRels):new Map);o("Parsed relationships",15),o("Parsing theme...",15);let E=h("theme",()=>Ve(d.themeXml));o("Parsed theme",20),o("Parsing styles...",20);let k=null,P;h("styles",()=>{d.stylesXml&&(k=Ce(d.stylesXml,E),P=Ye(d.stylesXml,E));}),o("Parsed styles",30),o("Parsing numbering...",30);let C=h("numbering",()=>Ke(d.numberingXml));o("Parsed numbering",35),o("Processing media files...",35);let y=h("media",()=>Ao(d,w));o("Processed media",40),o("Parsing document body...",40);let x={content:[]};h("documentBody",()=>{d.documentXml?x=Vt(d.documentXml,k,E,C,w,y):f.push("No document.xml found in DOCX");}),o("Parsed document body",55);let S,b;if(i){o("Parsing headers/footers...",55);let H=h("headersFooters",()=>No(d,k,E,C,w,y));S=H.headers,b=H.footers,o("Parsed headers/footers",65);}else o("Skipping headers/footers",65);let v,B;if(a){o("Parsing footnotes/endnotes...",65);let H=h("footnotesEndnotes",()=>Io(d,k,E,C,w,y));v=H.footnotes,B=H.endnotes,o("Parsed footnotes/endnotes",75);}else o("Skipping footnotes/endnotes",75);o("Parsing comments...",75);let A=h("comments",()=>zt(d.commentsXml,k,E,w,y,d.commentsExtensibleXml));A.length>0&&(x.comments=A);let I;c?(o("Detecting template variables...",75),I=h("variables",()=>Ot(x.content)),o("Detected variables",80)):o("Skipping variable detection",80),r?(o("Loading fonts...",80),await T("fonts",()=>Xo(E,P,x)),o("Loaded fonts",95)):o("Skipping font loading",95),o("Assembling document...",95);let U={package:{document:x,styles:P,theme:E,numbering:C.definitions,headers:S,footers:b,footnotes:v,endnotes:B,relationships:w,media:y},originalBuffer:n,templateVariables:I,warnings:f.length>0?f:void 0},K=performance.now()-p;if(K>2e3){let H=m.filter(W=>W.ms>100).map(W=>`${W.stage}: ${Math.round(W.ms)}ms`).join(", ");console.warn(`[parseDocx] Total: ${Math.round(K)}ms`+(H?` (${H})`:""));}return o("Complete",100),U}catch(p){let m=p instanceof Error?p.message:String(p);throw console.error("[parseDocx] Failed to parse DOCX:",m,p),new Error(`Failed to parse DOCX: ${m}`)}}function Ao(e,t){let n=new Map;for(let[o,r]of e.media.entries()){let i=o.split("/").pop()||o,a=Le(o),c=new Uint8Array(r),f="";for(let T=0;T<c.length;T++)f+=String.fromCharCode(c[T]);let u=btoa(f),p=`data:${a};base64,${u}`,m={path:o,filename:i,mimeType:a,data:r,dataUrl:p};n.set(o,m);let h=o.replace(/^word\//,"");h!==o&&n.set(h,m);}return n}function he(e,t){let n=t.toLowerCase();for(let[o,r]of e.entries())if(o.toLowerCase()===n)return r}function No(e,t,n,o,r,i){let a=new Map,c=new Map;for(let[f,u]of r.entries())if(u.type===ie.header&&u.target){let p=u.target.split("/").pop()||u.target,m=he(e.headers,p);if(m){let h=`word/_rels/${p}.rels`,T=he(e.allXml,h),d=T?ae(T):r,w=Tt(m,"default",t,n,o,d,i);a.set(f,w);}}else if(u.type===ie.footer&&u.target){let p=u.target.split("/").pop()||u.target,m=he(e.footers,p);if(m){let h=`word/_rels/${p}.rels`,T=he(e.allXml,h),d=T?ae(T):r,w=Ft(m,"default",t,n,o,d,i);c.set(f,w);}}return {headers:a,footers:c}}function Io(e,t,n,o,r,i){let a=Ct(e.footnotesXml,t,n,o,r,i),c=kt(e.endnotesXml,t,n,o,r,i);return {footnotes:a.getNormalFootnotes(),endnotes:c.getNormalEndnotes()}}async function Xo(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 xe(Array.from(o));}catch(r){console.warn("Failed to load some fonts:",r);}}
|
|
12
12
|
exports.a=ar;exports.b=sr;exports.c=ie;exports.d=Rr;exports.e=Be;exports.f=Ut;exports.g=Lo;exports.h=Do;exports.i=Ho;exports.j=Oo;exports.k=Wo;exports.l=jo;exports.m=Vo;exports.n=zo;exports.o=Ie;exports.p=si;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkNT2REEAA_cjs=require('./chunk-NT2REEAA.cjs'),
|
|
1
|
+
'use strict';var chunkNT2REEAA_cjs=require('./chunk-NT2REEAA.cjs'),chunkUAME5JHZ_cjs=require('./chunk-UAME5JHZ.cjs'),chunkFYAWM7MP_cjs=require('./chunk-FYAWM7MP.cjs'),chunkIHZIA6JP_cjs=require('./chunk-IHZIA6JP.cjs'),chunkVOWKSURW_cjs=require('./chunk-VOWKSURW.cjs');var m=class i{constructor(t){chunkVOWKSURW_cjs.d(this,"_document");chunkVOWKSURW_cjs.d(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await chunkIHZIA6JP_cjs.p(t);return new i(e)}static fromDocument(t){return new i(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let n of e.content)n.type==="paragraph"&&this._extractParagraphSegments(n,t);return t}getVariables(){return chunkNT2REEAA_cjs.a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[n,r]of Object.entries(t.styles))if(typeof r=="object"&&r!==null){let o=r;e.push({id:n,name:o.name||n,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(n=>n.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,n=e.content.filter(a=>a.type==="paragraph"),r=n.map((a,s)=>{let u=this._getParagraphText(a),c=a.formatting?.styleId;return {index:s,preview:u.slice(0,t),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!a.listRendering,isEmpty:u.trim().length===0}}),o=(e.sections||[]).map((a,s)=>({index:s,paragraphCount:a.content?.length||0,pageSize:a.properties?.pageWidth&&a.properties?.pageHeight?{width:a.properties.pageWidth,height:a.properties.pageHeight}:void 0,isLandscape:a.properties?.orientation==="landscape",hasHeader:!!a.properties?.headerReferences?.length,hasFooter:!!a.properties?.footerReferences?.length}));return {paragraphCount:n.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:r,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,n={}){let r={type:"insertText",position:t,text:e,formatting:n.formatting};return this._executeCommand(r)}replaceRange(t,e,n={}){let r={type:"replaceText",range:t,text:e,formatting:n.formatting};return this._executeCommand(r)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let n={type:"formatText",range:t,formatting:e};return this._executeCommand(n)}applyStyle(t,e){let n={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(n)}applyParagraphFormatting(t,e){let n={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(n)}insertTable(t,e,n,r={}){let o={type:"insertTable",position:t,rows:e,columns:n,data:r.data,hasHeader:r.hasHeader};return this._executeCommand(o)}insertImage(t,e,n={}){let r={type:"insertImage",position:t,src:e,width:n.width,height:n.height,alt:n.alt};return this._executeCommand(r)}insertHyperlink(t,e,n={}){let r={type:"insertHyperlink",range:t,url:e,displayText:n.displayText,tooltip:n.tooltip};return this._executeCommand(r)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let n={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(n)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,n]of Object.entries(t))this._pendingVariables[e]=n;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let n=this._document.originalBuffer;if(!n)throw new Error("Cannot apply variables: no original buffer for processing");let{processTemplate:r}=await import('./processTemplate-525HZL4S.cjs'),o=r(n,e),a=await chunkIHZIA6JP_cjs.p(o),s=new i(a);return s._pendingVariables={},s}async toBuffer(){return this._document.originalBuffer?chunkUAME5JHZ_cjs.d(this._document):chunkUAME5JHZ_cjs.e(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){let e=chunkFYAWM7MP_cjs.b(this._document,t);return new i(e)}_executeCommand(t){let e=chunkFYAWM7MP_cjs.a(this._document,t),n=new i(e);return n._pendingVariables={...this._pendingVariables},n}_getBodyText(t){let e=[];for(let n of t.content)n.type==="paragraph"?e.push(this._getParagraphText(n)):n.type==="table"&&e.push(this._getTableText(n));return e.join(`
|
|
2
2
|
`)}_getParagraphText(t){let e=[];for(let n of t.content)n.type==="run"?e.push(this._getRunText(n)):n.type==="hyperlink"&&e.push(this._getHyperlinkText(n));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let n of t.children)n.type==="run"&&e.push(this._getRunText(n));return e.join("")}_getTableText(t){let e=[];for(let n of t.rows)for(let r of n.cells)for(let o of r.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let n of t.content)if(n.type==="run"){let r=this._getRunText(n);r&&e.push({text:r,formatting:n.formatting});}else if(n.type==="hyperlink"){let r=n.href||"";for(let o of n.children)if(o.type==="run"){let a=this._getRunText(o);a&&e.push({text:a,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:r});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="run"){for(let r of n.content)if(r.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let n of e.content)if(n.type==="hyperlink")return true}return false}};async function A(i){return m.fromBuffer(i)}function T(i){return m.fromDocument(i)}exports.a=m;exports.b=A;exports.c=T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';var chunkITWEFKGQ_cjs=require('./chunk-ITWEFKGQ.cjs'),chunkNT2REEAA_cjs=require('./chunk-NT2REEAA.cjs'),chunkIHZIA6JP_cjs=require('./chunk-IHZIA6JP.cjs');function M(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function v(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{${t}}`;return C(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function w(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];I(l,n.start.offset,n.end.offset);let p=`{${t}}`;return C(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function C(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=g(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,f=a.slice(0,m),x=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);f&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:f}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),x&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:x}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=g(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function I(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=g(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function g(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var u={type:"string",description:"Document ID from a previous docx_load call"},D={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"]},V={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
2
|
+
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
|
+
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=chunkNT2REEAA_cjs.b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},R={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
4
|
+
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
|
+
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:u,position:D,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-ITYZTNSH.cjs'),a=r(e.document,{type:"insertText",position:n,text:`{${t}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{${t}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},S={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
|
+
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
|
+
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
|
+
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:u,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=chunkITWEFKGQ_cjs.b(e.buffer,n,{nullGetter:t?"keep":"empty"}),a=await chunkIHZIA6JP_cjs.p(r.buffer);return e.document=a,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},k={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
9
|
+
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
10
|
+
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!n.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let t=chunkITWEFKGQ_cjs.f(n.buffer);return {content:[{type:"text",text:JSON.stringify({valid:t.valid,tags:t.tags,errors:t.errors.map(e=>({message:e.message,variable:e.variable,type:e.type}))},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},P=[V,R,S,k];var E={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:v,replaceWithTemplateVariable:w},mcpTools:P};exports.a=M;exports.b=E;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {b as b$1,f}from'./chunk-ESI4BSBF.js';import {b}from'./chunk-2ASOEN3V.js';import {p}from'./chunk-5MWH4N7I.js';function M(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function v(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{${t}}`;return C(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function w(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];I(l,n.start.offset,n.end.offset);let p=`{${t}}`;return C(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function C(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=g(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,f=a.slice(0,m),x=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);f&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:f}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),x&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:x}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=g(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function I(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=g(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function g(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var u={type:"string",description:"Document ID from a previous docx_load call"},D={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"]},V={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
2
|
+
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
|
+
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},R={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
4
|
+
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
|
+
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:u,position:D,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-TC7CLATE.js'),a=r(e.document,{type:"insertText",position:n,text:`{${t}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{${t}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},S={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
|
+
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
|
+
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
|
+
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:u,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=b$1(e.buffer,n,{nullGetter:t?"keep":"empty"}),a=await p(r.buffer);return e.document=a,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},k={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
9
|
+
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
10
|
+
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!n.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let t=f(n.buffer);return {content:[{type:"text",text:JSON.stringify({valid:t.valid,tags:t.tags,errors:t.errors.map(e=>({message:e.message,variable:e.variable,type:e.type}))},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},P=[V,R,S,k];var E={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:v,replaceWithTemplateVariable:w},mcpTools:P};export{M as a,E as b};
|