@postnzt/docx-js-editor 0.1.3 → 0.1.6
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.
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
@keyframes docx-spin {
|
|
16
16
|
to { transform: rotate(360deg); }
|
|
17
17
|
}
|
|
18
|
-
`}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:e("errors.loadingDocument")})]})}function Xp(){let{t:e}=chunkQSUPYUOP_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:e("errors.noDocumentLoaded")})]})}function Zp({message:e}){let{t}=chunkQSUPYUOP_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:t("errors.failedToLoad")}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function tx(e,t){return JSON.stringify(e)===JSON.stringify(t)}function nx(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=tx,onUndo:a,onRedo:s,containerRef:l}=t,[u,c]=gm.useState(e),[d,p]=gm.useState([]),[f,m]=gm.useState([]),b=gm.useRef(0),h=gm.useRef(false),x=gm.useCallback(($,v)=>{if(i(u,$))return;if(h.current){c($);return}let _=Date.now();_-b.current<o&&d.length>0?p(ae=>{let N=[...ae];return N[N.length-1]={state:u,timestamp:_,description:v||N[N.length-1].description},N}):p(ae=>{let N={state:u,timestamp:_,description:v},B=[...ae,N];return B.length>n?B.slice(B.length-n):B}),m([]),c($),b.current=_;},[u,i,o,n,d.length]),T=gm.useCallback(()=>{if(d.length===0)return;h.current=true;let $=d[d.length-1];return p(v=>v.slice(0,-1)),m(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),a?.($.state),$.state},[d,u,a]),S=gm.useCallback(()=>{if(f.length===0)return;h.current=true;let $=f[f.length-1];return m(v=>v.slice(0,-1)),p(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),s?.($.state),$.state},[f,u,s]),I=gm.useCallback(()=>{p([]),m([]);},[]),R=gm.useCallback($=>{c($??e),p([]),m([]),b.current=0;},[e]),D=gm.useCallback(()=>[...d],[d]),L=gm.useCallback(()=>[...f],[f]),pe=gm.useCallback($=>{c(v=>$(v)),p(v=>v.map(_=>({..._,state:$(_.state)}))),m(v=>v.map(_=>({..._,state:$(_.state)})));},[]);return gm.useEffect(()=>{if(!r)return;let $=_=>{if((_.ctrlKey||_.metaKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),T();return}if((_.ctrlKey||_.metaKey)&&_.key==="y"||(_.ctrlKey||_.metaKey)&&_.key==="z"&&_.shiftKey){_.preventDefault(),S();return}},v=l?.current||document;return v.addEventListener("keydown",$),()=>{v.removeEventListener("keydown",$);}},[r,T,S,l]),{state:u,canUndo:d.length>0,canRedo:f.length>0,undoCount:d.length,redoCount:f.length,push:x,undo:T,redo:S,clear:I,reset:R,getUndoStack:D,getRedoStack:L,transformAll:pe}}function Qp(e,t={}){let n=gm.useCallback((o,r)=>!(o?.package?.document!==r?.package?.document&&JSON.stringify(o?.package?.document)!==JSON.stringify(r?.package?.document)||o?.package?.headers!==r?.package?.headers||o?.package?.footers!==r?.package?.footers),[]);return nx(e,{...t,isEqual:n})}var oo=new prosemirrorState.PluginKey("suggestionMode"),Za="suggestionModeApplied",ix=Date.now();function Ja(e){return {revisionId:ix++,author:e.author,date:new Date().toISOString()}}function Nl(e,t,n,o){try{let r=e.resolve(t);for(let i of [r.nodeBefore,r.nodeAfter])if(i?.isText){let a=i.marks.find(s=>s.type.name===n&&s.attrs.author===o);if(a)return a.attrs}}catch{}return null}function nf(e,t,n,o,r){return Nl(e,t,o,r)??Nl(e,n,o,r)}function of(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,c)=>{if(!u.isText)return;let d=Math.max(c,n),p=Math.min(c+u.nodeSize,o);if(d>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:d,to:p,isOwnInsert:f});}),s.length===0)return;let l=nf(t,n,o,"deletion",a.author)||Ja(a);for(let u=s.length-1;u>=0;u--){let c=s[u];c.isOwnInsert?e.delete(c.from,c.to):e.addMark(c.from,c.to,i.create(l));}}function ef(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(Za,true);let s=Nl(e.state.doc,t,"insertion",r.author)||Ja(r);if(t!==n){let c=e.state.schema.marks.deletion;c&&of(a,e.state.doc,t,n,i,c,r);}let l=a.mapping.map(n);a.insertText(o,l,l);let u=e.state.schema.marks.deletion;return u&&a.removeMark(l,l+o.length,u),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function tf(e,t,n){let o=oo.getState(e);if(!o?.active)return false;let{$from:r,$to:i,empty:a}=e.selection,s=e.schema.marks.insertion,l=e.schema.marks.deletion;if(!s||!l)return false;if(!t)return true;let u=e.tr;if(u.setMeta(Za,true),!a){of(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x))),t(u.scrollIntoView()),true}let c=n==="backward",d=c?r.pos-1:r.pos,p=c?r.pos:r.pos+1;if(d<0||p>e.doc.content.size)return true;let m=e.doc.resolve(d).nodeAfter;if(!m?.isText)return false;let b=m.marks.some(x=>x.type===s&&x.attrs.author===o.author);if(m.marks.some(x=>x.type===l)){let x=c?d:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(d,p);else {let x=nf(e.doc,d,p,"deletion",o.author)||Ja(o);u.addMark(d,p,l.create(x));let T=c?d:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function rf(e=false,t="User"){return new prosemirrorState.Plugin({key:oo,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(oo);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=oo.getState(n.state);if(!r?.active)return false;if(o.inputType==="insertText"&&o.data){o.preventDefault();let{from:i,to:a}=n.state.selection;return ef(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return oo.getState(n.state)?.active?o.key==="Backspace"?tf(n.state,n.dispatch,"backward"):o.key==="Delete"?tf(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=oo.getState(n.state);return a?.active?ef(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=oo.getState(r);if(!i?.active)return null;let a=n.find(d=>d.docChanged&&!d.getMeta(Za));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Ja(i),u=r.tr;u.setMeta(Za,true);let c=r.schema.marks.deletion;return a.steps.forEach(d=>{d.getMap().forEach((f,m,b,h)=>{h>b&&r.doc.nodesBetween(b,h,(x,T)=>{if(!x.isText)return;if(!x.marks.some(I=>I.type===s||c&&I.type===c)){let I=Math.max(T,b),R=Math.min(T+x.nodeSize,h);u.addMark(I,R,s.create(l));}});});}),u.steps.length>0?u:null}})}function af(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(oo,r);n(i);}return true}var mx={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function df(e,t,n,o=[]){let r=n?.getSchema()??ve,i=e?yl(e,{styles:t??void 0}):vl(),a=[...o,...n?.getPlugins()??[]];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function gx(e,t){return t?bp(e.doc,t):null}var hx=gm.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:c=[],extensionManager:d,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=gm.useRef(null),h=gm.useRef(null),x=gm.useRef(o),T=gm.useRef(false),S=gm.useRef(null),I=gm.useRef(false),R=gm.useRef(l),D=gm.useRef(u),L=gm.useRef(p),pe=gm.useRef(f),$=gm.useRef(m);R.current=l,D.current=u,L.current=p,pe.current=f,$.current=m,x.current=o;let v=gm.useCallback(()=>{if(!b.current||T.current)return;let ae={state:df(o,r,d,c),editable:()=>!s,dispatchTransaction:N=>{if(!h.current||T.current)return;let B=h.current.state.apply(N);h.current.updateState(B),R.current?.(N,B),(N.selectionSet||N.docChanged)&&D.current?.(B);},handleKeyDown:(N,B)=>$.current?.(N,B)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};h.current=new prosemirrorView.EditorView(b.current,ae),L.current?.(h.current);},[o,r,c,d,s]),_=gm.useCallback(()=>{h.current&&!T.current&&(T.current=true,pe.current?.(),h.current.destroy(),h.current=null,T.current=false);},[]);return gm.useEffect(()=>(v(),()=>_()),[]),gm.useEffect(()=>{if(!h.current||T.current)return;let ae=(B=>{if(!B)return "empty";let de=B.package?.properties;return `${de?.created||""}-${de?.modified||""}-${de?.title||""}`})(o);if(I.current&&ae===S.current)return;I.current=true,S.current=ae;let N=df(o,r,d,c);h.current.updateState(N),D.current?.(N);},[o,r,d,c]),gm.useEffect(()=>{h.current;},[s]),gm.useImperativeHandle(n,()=>({getState(){return h.current?.state??null},getView(){return h.current??null},getDocument(){return h.current?gx(h.current.state,x.current):null},focus(){h.current?.focus();},blur(){h.current?.hasFocus()&&h.current.dom.blur();},isFocused(){return h.current?.hasFocus()??false},dispatch(re){h.current&&!T.current&&h.current.dispatch(re);},executeCommand(re){return h.current?re(h.current.state,h.current.dispatch,h.current):false},undo(){return h.current?prosemirrorHistory.undo(h.current.state,h.current.dispatch):false},redo(){return h.current?prosemirrorHistory.redo(h.current.state,h.current.dispatch):false},canUndo(){return h.current?prosemirrorHistory.undo(h.current.state):false},canRedo(){return h.current?prosemirrorHistory.redo(h.current.state):false},setSelection(re,ae){if(!h.current)return;let{state:N,dispatch:B}=h.current,de=N.doc.resolve(re),ge=ae!==void 0?N.doc.resolve(ae):de,Pe=prosemirrorState.TextSelection.between(de,ge);B(N.tr.setSelection(Pe));},setNodeSelection(re){if(!h.current)return;let{state:ae,dispatch:N}=h.current;try{let B=prosemirrorState.NodeSelection.create(ae.doc,re);N(ae.tr.setSelection(B));}catch{this.setSelection(re);}},setCellSelection(re,ae){if(!h.current)return;let{state:N,dispatch:B}=h.current;try{let de=prosemirrorTables.CellSelection.create(N.doc,re,ae);B(N.tr.setSelection(de));}catch{this.setSelection(re,ae);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...mx,width:a>0?`${a}px`:void 0}})}),uf=gm.memo(hx);var Sx="#000",kx="rgba(66, 133, 244, 0.3)",Cx=2,Tx=530,wx={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},vx=(e,t,n,o)=>({position:"absolute",left:e.x,top:e.y,width:n,height:e.height,backgroundColor:t,opacity:o?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),Rx=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Ex=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=gm.useState(r),s=gm.useRef(null);return gm.useEffect(()=>(s.current&&(window.clearInterval(s.current),s.current=null),r&&o>0?(a(true),s.current=window.setInterval(()=>{a(l=>!l);},o)):a(false),()=>{s.current&&window.clearInterval(s.current);}),[r,o]),gm.useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsxRuntime.jsx("div",{style:vx(e,t,n,i),"data-testid":"caret"})},Px=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:Rx(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),ff=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Sx,selectionColor:i=kx,caretWidth:a=Cx,blinkInterval:s=Tx})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:wx,"data-testid":"selection-overlay",children:[l&&e.map((c,d)=>jsxRuntime.jsx(Px,{rect:c,color:i,index:d},`sel-${c.pageIndex}-${c.x}-${c.y}-${d}`)),u&&t&&jsxRuntime.jsx(Ex,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var $l=10,ro=$l/2,Jr=2,bf="#2563eb",gf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Ix={position:"absolute",border:`${Jr}px solid ${bf}`,pointerEvents:"none",boxSizing:"border-box"},Fx={position:"absolute",width:`${$l}px`,height:`${$l}px`,backgroundColor:bf,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Lx={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"white",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},Bx={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Ax(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let c=Math.max(l/o,u/r);l=o*c,u=r*c;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function yf({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,c]=gm.useState(false),[d,p]=gm.useState(false),[f,m]=gm.useState(0),[b,h]=gm.useState(0),[x,T]=gm.useState(null),S=gm.useRef(null),I=gm.useRef(null),R=gm.useRef(o),D=gm.useRef(r),L=gm.useRef(i),pe=gm.useRef(a),$=gm.useRef(s),v=gm.useRef(l);R.current=o,D.current=r,L.current=i,pe.current=a,$.current=s,v.current=l;let _=gm.useRef(e),re=gm.useRef(t);_.current=e,re.current=t;let ae=gm.useCallback(()=>{if(!e||!I.current){T(null);return}let E=I.current.offsetParent;if(!E){T(null);return}let F=E.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-F.left)/t,top:(k.top-F.top)/t,width:k.width/t,height:k.height/t});},[e,t]);gm.useEffect(()=>{ae();},[ae]),gm.useEffect(()=>{if(!e)return;let E=I.current?.closest('[style*="overflow"]')??I.current?.closest(".paged-editor__container");if(!E)return;let F=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(ae);};return E.addEventListener("scroll",F,{passive:true}),window.addEventListener("resize",F,{passive:true}),()=>{E.removeEventListener("scroll",F),window.removeEventListener("resize",F),S.current&&cancelAnimationFrame(S.current);}},[e,ae]);let N=gm.useCallback((E,F)=>{if(!e||!x)return;F.preventDefault(),F.stopPropagation();let k=x.width,P=x.height,M=F.clientX,H=F.clientY,oe=Math.round(k),Q=Math.round(P);c(true),m(oe),h(Q),D.current?.();let V=ne=>{let Se=re.current,Me=(ne.clientX-M)/Se,Z=(ne.clientY-H)/Se,ie=!ne.shiftKey,Ie=Ax(E,Me,Z,k,P,ie);oe=Math.round(Ie.width),Q=Math.round(Ie.height),m(oe),h(Q),T(He=>{if(!He)return He;let qe={...He};return E.includes("w")&&(qe.left=He.left+(He.width-Ie.width)),E.includes("n")&&(qe.top=He.top+(He.height-Ie.height)),qe.width=Ie.width,qe.height=Ie.height,qe});},Y=()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",Y),c(false);let ne=_.current;ne&&R.current?.(ne.pmPos,oe,Q),L.current?.();};window.addEventListener("mousemove",V),window.addEventListener("mouseup",Y);},[e,x]),B=gm.useCallback(E=>{if(!e||!x)return;E.preventDefault(),E.stopPropagation();let F=4,k=E.clientX,P=E.clientY,M=false,H=null,oe=V=>{let Y=V.clientX-k,ne=V.clientY-P;!M&&Math.sqrt(Y*Y+ne*ne)<F||(M||(M=true,p(true),$.current?.(),H=document.createElement("div"),H.style.cssText="position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);",H.style.width=`${x.width}px`,H.style.height=`${x.height}px`,document.body.appendChild(H)),H&&(H.style.left=`${V.clientX-x.width/2}px`,H.style.top=`${V.clientY-x.height/2}px`));},Q=V=>{if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Q),H&&(H.remove(),H=null),p(false),M){let Y=_.current;Y&&pe.current?.(Y.pmPos,V.clientX,V.clientY),v.current?.();}};window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Q);},[e,x]);if(!!!(e&&x&&n))return jsxRuntime.jsx("div",{ref:I,style:{...gf,visibility:"hidden"},className:"image-selection-overlay"});let{left:ge,top:Pe,width:se,height:q}=x;return jsxRuntime.jsxs("div",{ref:I,style:gf,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...Ix,left:ge-Jr,top:Pe-Jr,width:se+Jr*2,height:q+Jr*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:ge,top:Pe,width:se,height:q,cursor:d?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:B}),jsxRuntime.jsx(es,{handle:"nw",style:{left:ge-ro,top:Pe-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"ne",style:{left:ge+se-ro,top:Pe-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"se",style:{left:ge+se-ro,top:Pe+q-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"sw",style:{left:ge-ro,top:Pe+q-ro},onMouseDown:N}),u&&jsxRuntime.jsxs("div",{style:{...Lx,left:ge+se/2,top:Pe+q+12},children:[f," \xD7 ",b]})]})}function es({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...Fx,...t,cursor:Bx[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var Dx="Calibri";function _l(e,t,n){if(!n||t<=n)return {width:e,height:t};let o=n/t;return {width:Math.round(e*o),height:n}}var Hx=11;function rt(e){return e/1440*96}var Nx=0;function ao(){return `block-${++Nx}`}function zx(e,t){let n=[];for(let o=0;o<=t;o+=1){let r=e[o]??0;if(r<=0)break;n.push(r);}return n.length===0?"1.":`${n.join(".")}.`}function ts(e,t){let n={};for(let o of e)switch(o.type.name){case "bold":n.bold=true;break;case "italic":n.italic=true;break;case "underline":{let r=o.attrs;if(r.style||r.color){let i=r.color?chunk4VUZBV2S_js.a(r.color,t):void 0;n.underline={style:r.style,color:i};}else n.underline=true;break}case "strike":n.strike=true;break;case "textColor":{let r=o.attrs;(r.themeColor||r.rgb)&&(n.color=chunk4VUZBV2S_js.a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=chunk4VUZBV2S_js.n(o.attrs.color);break;case "fontSize":{let r=o.attrs;n.fontSize=r.size/2;break}case "fontFamily":{let r=o.attrs;n.fontFamily=r.ascii||r.hAnsi;break}case "superscript":n.superscript=true;break;case "subscript":n.subscript=true;break;case "hyperlink":{let r=o.attrs;n.hyperlink={href:r.href,tooltip:r.tooltip};break}case "footnoteRef":{let r=o.attrs,i=typeof r.id=="string"?parseInt(r.id,10):r.id;r.noteType==="endnote"?n.endnoteRefId=i:n.footnoteRefId=i;break}case "comment":{let r=o.attrs.commentId;r&&(n.commentIds||(n.commentIds=[]),n.commentIds.push(r));break}case "insertion":n.isInsertion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break;case "deletion":n.isDeletion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break}return n}function Ox(e,t,n){let o=[],r=t+1,i=n.theme;return e.forEach((a,s)=>{let l=r+s;if(a.isText&&a.text){let u=ts(a.marks,i),c={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let c={kind:"tab",...ts(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="image"){let u=a.attrs,c=_l(u.width||100,u.height||100,n.pageContentHeight),d={kind:"image",src:u.src,width:c.width,height:c.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="field"){let u=a.attrs.fieldType,d={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="math"){let c={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((c,d)=>{let p=u+d;if(c.isText&&c.text){let f=ts(c.marks,i),m={kind:"text",text:c.text,...f,pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+c.nodeSize};o.push(f);}else if(c.type.name==="tab"){let m={kind:"tab",...ts(c.marks,i),pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="image"){let f=c.attrs,m=_l(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+c.nodeSize};o.push(b);}});}}),o}function $x(e,t){let n={};if(e.alignment){let s=e.alignment;s==="both"||s==="distribute"?n.alignment="justify":s==="left"?n.alignment="left":s==="center"?n.alignment="center":s==="right"&&(n.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(n.spacing={},e.spaceBefore!=null&&(n.spacing.before=rt(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=rt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=rt(e.lineSpacing),n.spacing.lineUnit="px",n.spacing.lineRule=e.lineSpacingRule):(n.spacing.line=e.lineSpacing/240,n.spacing.lineUnit="multiplier",n.spacing.lineRule="auto")));let o=e.indentLeft,r=e.indentFirstLine,i=e.hangingIndent;if(e.numPr?.numId&&o==null&&(o=((e.numPr.ilvl??0)+1)*720,r==null&&(r=-360,i=true)),(o!=null||e.indentRight!=null||r!=null)&&(n.indent={},o!=null&&(n.indent.left=rt(o)),e.indentRight!=null&&(n.indent.right=rt(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(rt(r)):n.indent.firstLine=rt(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?ns(u,t):void 0;s.top&&(n.borders.top=l(s.top)),s.bottom&&(n.borders.bottom=l(s.bottom)),s.left&&(n.borders.left=l(s.left)),s.right&&(n.borders.right=l(s.right)),s.between&&(n.borders.between=l(s.between)),s.bar&&(n.borders.bar=l(s.bar)),!n.borders.top&&!n.borders.bottom&&!n.borders.left&&!n.borders.right&&!n.borders.between&&!n.borders.bar&&delete n.borders;}e.shading?.fill?.rgb&&(n.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(n.tabs=e.tabs.map(s=>({val:_x(s.alignment),pos:s.position,leader:s.leader}))),e.pageBreakBefore&&(n.pageBreakBefore=true),e.keepNext&&(n.keepNext=true),e.keepLines&&(n.keepLines=true),e.contextualSpacing&&(n.contextualSpacing=true),e.bidi&&(n.bidi=true),e.styleId&&(n.styleId=e.styleId),e.numPr&&(n.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(n.listMarker=e.listMarker),e.listIsBullet!=null&&(n.listIsBullet=e.listIsBullet),e.listMarkerHidden&&(n.listMarkerHidden=true),e.listMarkerFontFamily&&(n.listMarkerFontFamily=e.listMarkerFontFamily),e.listMarkerFontSize&&(n.listMarkerFontSize=e.listMarkerFontSize);let a=e.defaultTextFormatting;return a&&(a.fontSize!=null&&(n.defaultFontSize=a.fontSize/2),a.fontFamily&&(n.defaultFontFamily=a.fontFamily.ascii||a.fontFamily.hAnsi)),n}function _x(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function Wl(e,t,n){let o=e.attrs,r=Ox(e,t,n),i=$x(o,n.theme);return {kind:"paragraph",id:ao(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Wx(e){return Math.max(1,Math.round(e/8*1.333))}var Vx={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",wave:"solid",doubleWave:"double",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function ns(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Vx[e.style]||"solid",width:Wx(e.size??0),color:e.color?chunk4VUZBV2S_js.a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=chunkSE5EN2QL_js.g(e.space)),n}function Ux(e,t){let n=e.borders;if(!n)return;let o={},r=["top","bottom","left","right"];for(let i of r){let a=n[i],s=a?ns(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function jx(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Wl(l,r,n)):l.type.name==="table"&&o.push(xf(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?rt(a.top):0,right:a?.right!=null?rt(a.right):7,bottom:a?.bottom!=null?rt(a.bottom):0,left:a?.left!=null?rt(a.left):7};return {id:ao(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?rt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Ux(i,n.theme),padding:s}}function Kx(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(jx(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:ao(),cells:o,height:i.height?rt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function xf(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(Kx(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(rt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(h=>h.width);b.every(h=>h!==void 0&&h>0)&&(a=b);}let u=e.attrs.justification,c=e.attrs._originalFormatting,d=c?.indent?.value&&c.indent.type==="dxa"?rt(c.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?rt(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?rt(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?rt(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?rt(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?rt(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?rt(p.rightFromText):void 0}:void 0;return {kind:"table",id:ao(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:d,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function Gx(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=_l(o.width||100,o.height||100,n);return {kind:"image",id:ao(),src:o.src,width:a.width,height:a.height,alt:o.alt,transform:o.transform,anchor:i?{isAnchored:true,offsetH:o.distLeft,offsetV:o.distTop,behindDoc:r==="behind"}:void 0,hlinkHref:o.hlinkHref,pmStart:t,pmEnd:t+e.nodeSize}}function Yx(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=Wl(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:ao(),width:o.width??chunkEV3CM6TU_js.d,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??chunkEV3CM6TU_js.c.top,bottom:o.marginBottom??chunkEV3CM6TU_js.c.bottom,left:o.marginLeft??chunkEV3CM6TU_js.c.left,right:o.marginRight??chunkEV3CM6TU_js.c.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function Sf(e,t={}){let n={...t,defaultFont:t.defaultFont??Dx,defaultSize:t.defaultSize??Hx},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=Wl(a,l,n),c=a.attrs;if(c.numPr&&!c.listMarker){let p=c.numPr.numId;if(p==null||p===0)break;let f=c.numPr.ilvl??0,m=i.get(p)??new Array(9).fill(0);m[f]=(m[f]??0)+1;for(let h=f+1;h<m.length;h+=1)m[h]=0;i.set(p,m);let b=c.listIsBullet?"\u2022":zx(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let d=c._sectionProperties;if(d||c.sectionBreakType){let p={kind:"sectionBreak",id:ao(),type:d?.sectionStart??c.sectionBreakType};if(d){(d.pageWidth||d.pageHeight)&&(p.pageSize={w:rt(d.pageWidth??12240),h:rt(d.pageHeight??15840)}),(d.marginTop!==void 0||d.marginLeft!==void 0)&&(p.margins={top:rt(d.marginTop??1440),bottom:rt(d.marginBottom??1440),left:rt(d.marginLeft??1440),right:rt(d.marginRight??1440)});let f=d.columnCount??1;if(f>1){let m={count:f,gap:rt(d.columnSpace??720),equalWidth:d.equalWidth??true,separator:d.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(xf(a,l,n));break;case "image":o.push(Gx(a,l,n.pageContentHeight));break;case "textBox":o.push(Yx(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:ao(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var _n=11,Qr="Calibri",os=1,lr=.5;function qx(e,t){if(t&&t.length>0)for(let o of t){let r=chunkEV3CM6TU_js.k(o.pos);if(r>e+.5)return Math.max(1,r-e)}let n=e%Vl;return Math.max(1,n<.5?Vl:Vl-n)}function Xx(e,t,n,o=false){let r=1,i=e.length,a=0;for(;r<=i;){let s=r+i>>>1;chunkEV3CM6TU_js.h(e.slice(0,s),t)<=n?(a=s,r=s+1):i=s-1;}return o&&a===0?1:a}function kf(e){return {fontFamily:e.fontFamily??Qr,fontSize:e.fontSize??_n,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function vf(e,t,n){let o=chunkEV3CM6TU_js.l(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.singleLineRatio??1.15,s=o*a,l;if(t?.lineRule==="exact"&&t.line!==void 0)l=t.line;else if(t?.lineRule==="atLeast"&&t.line!==void 0){let u=s*os;l=Math.max(t.line,u);}else t?.line!==void 0&&t?.lineUnit==="multiplier"?l=s*t.line:t?.line!==void 0&&t?.lineUnit==="px"?l=t.line:l=s*os;return {ascent:r,descent:i,lineHeight:l}}function Cf(e,t,n){let o=chunkEV3CM6TU_js.g({fontSize:e,fontFamily:n??Qr});return vf(e,t,o)}function Tf(e){return e.kind==="text"}function Zx(e){return e.kind==="tab"}function Jx(e){return e.kind==="image"}function Qx(e){return e.kind==="lineBreak"}function eS(e){return e.kind==="field"}function tS(e){return !e.text||e.text.length===0}function nS(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];(o===" "||o==="-"||o===" ")&&t.push(n+1);}return t}var Vl=48;function wf(e,t,n,o){if(!n||n.length===0)return {leftMargin:0,rightMargin:0};let r=0,i=0,a=o+e,s=a+t;for(let l of n)s>l.topY&&a<l.bottomY&&(r=Math.max(r,l.leftMargin),i=Math.max(i,l.rightMargin));return {leftMargin:r,rightMargin:i}}function In(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,c=l?.right??0,d=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-c),f=Math.max(1,p-d),m=0,b=chunkEV3CM6TU_js.l(_n)*os,h=wf(0,b,a,s),x=Math.max(1,f-h.leftMargin-h.rightMargin),T=[];if(o.length===0){let $=r?.defaultFontSize??_n,v=r?.defaultFontFamily??Qr,_=Cf($,i,v);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,..._}),{kind:"paragraph",lines:T,totalHeight:_.lineHeight}}if(o.length===1&&Tf(o[0])&&tS(o[0])){let $=o[0],v=$.fontSize??r?.defaultFontSize??_n,_=$.fontFamily??r?.defaultFontFamily??Qr,re=Cf(v,i,_);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...re}),{kind:"paragraph",lines:T,totalHeight:re.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:h.leftMargin,rightOffset:h.rightMargin},I=()=>{let $=vf(S.maxFontSize,i,S.maxFontMetrics),v={...$};S.maxImageHeightPx>v.lineHeight&&(v.lineHeight=S.maxImageHeightPx,v.ascent=S.maxImageHeightPx*.8,v.descent=S.maxImageHeightPx*.2);let _={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...v};S.leftOffset>0&&(_.leftOffset=S.leftOffset),S.rightOffset>0&&(_.rightOffset=S.rightOffset),T.push(_),m+=$.lineHeight;},R=($,v)=>{I();let _=chunkEV3CM6TU_js.l(_n)*os,re=wf(m,_,a,s),ae=Math.max(1,p-re.leftMargin-re.rightMargin);S={fromRun:$,fromChar:v,toRun:$,toChar:v,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:ae,leftOffset:re.leftMargin,rightOffset:re.rightMargin};},D=$=>{let v=$.fontSize??_n;(!S.maxFontMetrics||v>S.maxFontSize)&&(S.maxFontSize=v,S.maxFontMetrics=chunkEV3CM6TU_js.g($));};for(let $=0;$<o.length;$++){let v=o[$];if(Qx(v)){S.toRun=$,S.toChar=0,R($+1,0);continue}if(Zx(v)){let _=kf(v);D(_);let re=r?.tabs,ae=l?.left??0,N=S.width+ae+(S.leftOffset??0),B=qx(N,re);S.width+B>S.availableWidth+lr&&(R($,0),D(_)),S.width+=B,S.toRun=$,S.toChar=1;continue}if(Jx(v)){let _=v.wrapType,re=v.displayMode==="float"||_&&["square","tight","through"].includes(_);if(v.position&&re){S.toRun=$,S.toChar=1;continue}if(_==="topAndBottom"||v.displayMode==="block"){S.width>0&&R($,0);let B=v.height,de=v.distTop??6,ge=v.distBottom??6;S.toRun=$,S.toChar=1,S.maxImageHeightPx=B+de+ge,R($+1,0);continue}let ae=v.width,N=v.height;N>S.maxImageHeightPx&&(S.maxImageHeightPx=N),S.width+ae>S.availableWidth+lr&&R($,0),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(eS(v)){let _=v.fallback||"1",re={fontFamily:v.fontFamily??Qr,fontSize:v.fontSize??_n,bold:v.bold,italic:v.italic};D(re);let ae=chunkEV3CM6TU_js.h(_,re);S.width>0&&S.width+ae>S.availableWidth+lr&&(R($,0),D(re)),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(Tf(v)){let _=v,re=_.text,ae=kf(_);if(D(ae),!re||re.length===0){S.toRun=$,S.toChar=0;continue}let N=nS(re),B=0;for(;B<re.length;){let de=re.length;for(let se of N)if(se>B){de=se;break}let ge=re.slice(B,de),Pe=chunkEV3CM6TU_js.h(ge,ae);if(Pe>S.availableWidth+lr){let se=0;for(;se<ge.length;){let q=S.availableWidth-S.width+lr,E=ge.slice(se),F=Xx(E,ae,q);if(F===0){if(S.width>0){R($,B+se),D(ae);continue}F=1;}let k=se+F,P=ge.slice(se,k),M=chunkEV3CM6TU_js.h(P,ae);S.width+=M,S.toRun=$,S.toChar=B+k,se=k,se<ge.length&&(R($,B+se),D(ae));}B=de;continue}S.width>0&&S.width+Pe>S.availableWidth+lr&&(R($,B),D(ae)),S.width+=Pe,S.toRun=$,S.toChar=de,B=de;}}}I();let pe=T.reduce(($,v)=>$+v.lineHeight,0);return i?.before&&(pe+=i.before),i?.after&&(pe+=i.after),{kind:"paragraph",lines:T,totalHeight:pe}}var oS=new Map;function Rf(){oS.clear();}var rS=new Map;function Ef(){rS.clear();}var iS=5e3,aS=iS,so=new Map;function Ul(e){let t=[];for(let o of e.runs)o.kind==="text"?t.push(`t:${o.text}|${o.fontFamily}|${o.fontSize}|${o.bold}|${o.italic}`):o.kind==="tab"?t.push(`tab:${o.width}`):o.kind==="image"?t.push(`img:${o.width}x${o.height}`):o.kind==="lineBreak"&&t.push("br");let n=e.attrs;return n&&(n.alignment&&t.push(`align:${n.alignment}`),n.indent&&t.push(`indent:${n.indent.left}|${n.indent.right}|${n.indent.firstLine}|${n.indent.hanging}`),n.spacing&&t.push(`spacing:${n.spacing.before}|${n.spacing.after}|${n.spacing.line}|${n.spacing.lineRule}`)),t.join("||")}function sS(){for(;so.size>aS;){let e=so.keys().next().value;if(e===void 0)break;so.delete(e);}}function jl(e,t){let n=Ul(e),o=so.get(n);if(o!==void 0&&o.maxWidth===t)return so.delete(n),so.set(n,o),o.measure}function Kl(e,t,n){let o=Ul(e);so.set(o,{measure:n,maxWidth:t}),sS();}function Pf(){so.clear();}function Gl(){Rf(),Ef(),Pf();}function lS(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function cS(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,c=i.slice(l,u);c.length>0&&n.push({...r,text:c});}else n.push(r);}}}return n}function dS(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",c=s===t.fromRun?t.fromChar:0,d=s===t.toRun?t.toChar:u.length;a+=d-c;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function uS(e,t,n,o){let r=0;for(let i=n;i<o&&i<e.lines.length;i++){let s=e.lines[i].lineHeight;if(t>=r&&t<r+s)return i;r+=s;}return o>n?Math.min(o-1,e.lines.length-1):null}function pS(e,t,n,o){let{pmStart:r,pmEnd:i}=dS(e,t);if(r===void 0||i===void 0)return {charOffset:0,pmPosition:e.pmStart??0};let a=e.attrs?.alignment??"left",s=0;a==="center"?s=Math.max(0,(o-t.width)/2):a==="right"&&(s=Math.max(0,o-t.width));let l=Math.max(0,n-s);if(l<=0)return {charOffset:0,pmPosition:r};let u=cS(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let c=0,d=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="image"){let m=f.width,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="lineBreak"){if(l>=c)return {charOffset:d,pmPosition:r+d};d+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=lS(f),h=chunkEV3CM6TU_js.i(m,b),x=c+h.width;if(l<=x){let T=l-c,S=chunkEV3CM6TU_js.j(T,h.charWidths),I=d+S;return {charOffset:I,pmPosition:r+I}}c=x,d+=m.length;}}return {charOffset:i-r,pmPosition:i}}function Mf(e){let{fragment:t,block:n,measure:o,localX:r,localY:i}=e;if(t.kind!=="paragraph"||n.kind!=="paragraph"||o.kind!=="paragraph")return null;let a=t,s=n,l=o,u=uS(l,i,a.fromLine,a.toLine);if(u===null)return null;let c=l.lines[u];if(!c)return null;let d=0;for(let S=a.fromLine;S<u;S++)d+=l.lines[S]?.lineHeight??0;let p=s.attrs?.indent,f=p?.left??0,m=p?.right??0,b=Math.max(0,t.width-f-m),h=r-f,{charOffset:x,pmPosition:T}=pS(s,c,h,b);return {pmPosition:T,charOffset:x,lineIndex:u}}function fS(e){let{cellBlock:t,cellMeasure:n,cellLocalX:o,cellLocalY:r}=e;if(!t||!n)return null;let i={fragment:{kind:"paragraph",blockId:t.id,x:0,y:0,width:n.lines.reduce((s,l)=>Math.max(s,l.width),100),fromLine:0,toLine:n.lines.length,height:n.totalHeight},block:t,measure:n,pageIndex:e.pageIndex,localX:o,localY:r};return Mf(i)?.pmPosition??null}function Yl(e,t){if(t)return fS(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?Mf(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Ff(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(c=>c.classList.contains("layout-page"));if(!i)return null;let a=r.find(c=>c.tagName==="SPAN"&&c.dataset.pmStart!==void 0&&c.dataset.pmEnd!==void 0);if(a)return ql(a,t);let s=r.find(c=>c.classList.contains("layout-empty-run"));if(s){let c=s.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let l=r.find(c=>c.classList.contains("layout-paragraph")&&c.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let c=If(l,t,n);return c!==null?c:Number(l.dataset.pmStart)}let u=r.find(c=>c.classList.contains("layout-table-cell"));return u?If(u,t,n):mS(e,i,t,n)}function ql(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let d=e.getBoundingClientRect(),p=(d.left+d.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,c=s;for(;u<c;){let d=Math.floor((u+c)/2),p=l.createRange();p.setStart(a,d),p.setEnd(a,d);let m=p.getBoundingClientRect().left;t<m?c=d:u=d+1;}if(u>0&&u<=s){let d=l.createRange();d.setStart(a,u-1),d.setEnd(a,u-1);let p=d.getBoundingClientRect();d.setStart(a,Math.min(u,s)),d.setEnd(a,Math.min(u,s));let f=d.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(u-1)}return o+Math.min(u,r-o)}function If(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let d=o.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let d of Array.from(r)){let p=d,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let d=e.querySelector(".layout-paragraph[data-pm-start]");return d?.dataset.pmStart?Number(d.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let d=i.closest(".layout-paragraph");return d?.dataset.pmStart?Number(d.dataset.pmStart):null}let l=null,u=1/0;for(let d of Array.from(s)){let p=d,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return ql(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let c=l.getBoundingClientRect();return t<c.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function mS(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let f=t.querySelectorAll(".layout-paragraph");if(f.length>0){let m=f[0];return Number(m.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let f of Array.from(a)){let m=f,b=m.getBoundingClientRect(),h=(b.top+b.bottom)/2,x=Math.abs(o-h);x<l&&(l=x,s=m);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return ql(m,n);let h=n<b.left?b.left-n:n-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return n<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)}var lo={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function gS(e){return e.kind==="paragraph"}function hS(e){return e.kind==="table"}function bS(e){return e.kind==="image"}function rs(e){e.style.position="absolute",e.style.overflow="hidden";}function yS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.paragraph}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromLine=String(e.fromLine),o.dataset.toLine=String(e.toLine),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.continuesFromPrev&&(o.dataset.continuesFromPrev="true"),e.continuesOnNext&&(o.dataset.continuesOnNext="true"),o}function xS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.table}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromRow=String(e.fromRow),o.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),o}function SS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.image}`,rs(o),o.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.isAnchored&&(o.dataset.anchored="true"),e.zIndex!==void 0&&(o.style.zIndex=String(e.zIndex)),o}function ei(e,t,n={}){let o=n.document??document;if(gS(e))return yS(e,t,o);if(hS(e))return xS(e,t,o);if(bS(e))return SS(e,t,o);let r=o.createElement("div");r.className=lo.fragment,rs(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function Xl(e){return e/1440*96}function kS(e){return e/96*1440}function CS(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(d=>d.val!=="clear").filter(d=>d.pos>=o),i=t.filter(d=>d.val==="clear").map(d=>d.pos),a=r.reduce((d,p)=>Math.max(d,p.pos),0),s=[...r];o>0&&!r.some(d=>d.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,c=o+14400;for(;u<c;){u+=n;let d=r.some(m=>Math.abs(m.pos-u)<20),p=i.some(m=>Math.abs(m-u)<20),f=o>0&&Math.abs(u-o)<20;!d&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((d,p)=>d.pos-p.pos)}function Lf(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=kS(e),l=CS(t).find(d=>d.pos>a);if(!l){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}let c=Xl(l.pos)-e;if(l.val==="center"||l.val==="end"){let d=o?o(n):0;l.val==="center"?c-=d/2:c-=d;}else if(l.val==="decimal"){let d=n.indexOf(r);if(d>=0&&o){let p=n.slice(0,d),f=o(p);c-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(c<1){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}return {width:c,leader:l.leader,alignment:l.val}}function TS(e){switch(e){case "single":case "thick":case "words":return "solid";case "double":return "double";case "dotted":case "dottedHeavy":return "dotted";case "dash":case "dashed":case "dashedHeavy":case "dashLong":case "dashLongHeavy":case "dashDot":case "dashDotHeavy":case "dashDotDot":case "dashDotDotHeavy":return "dashed";case "wave":case "wavyHeavy":case "wavyDouble":return "wavy";default:return "solid"}}var rn={fragment:"layout-paragraph",line:"layout-line",run:"layout-run",text:"layout-run-text",tab:"layout-run-tab",image:"layout-run-image",lineBreak:"layout-run-linebreak"};function ni(e){return e.kind==="text"}function is(e){return e.kind==="tab"}function Df(e){return e.kind==="image"}function Zl(e){return e.kind==="lineBreak"}function Jl(e){return e.kind==="field"}function wS(e,t,n){if(t.fontFamily&&(e.style.fontFamily=chunkEV3CM6TU_js.a(t.fontFamily).cssFallback),t.fontSize){let r=t.fontSize*96/72;e.style.fontSize=`${r}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let o=[];if(t.underline&&(o.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=TS(t.underline.style)),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&o.push("line-through"),t.commentIds&&t.commentIds.length>0){let r=t.commentIds.find(i=>!n||!n.has(i));r!=null&&(e.style.backgroundColor="rgba(255, 212, 0, 0.15)",e.style.borderBottom="1px solid rgba(255, 212, 0, 0.4)",e.dataset.commentId=String(r));}t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",o.includes("line-through")||o.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),o.length>0&&(e.style.textDecorationLine=o.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function cr(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Ql(e,t,n){let o=t.createElement("span");if(o.className=`${rn.run} ${rn.text}`,wS(o,e,n),cr(o,e.pmStart,e.pmEnd),e.hyperlink){let r=t.createElement("a");r.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(r.target="_blank",r.rel="noopener noreferrer"),e.hyperlink.tooltip&&(r.title=e.hyperlink.tooltip),r.textContent=e.text;let i=e.color||"#0563c1";r.style.color=i,r.style.textDecoration="underline",o.style.color=i,o.appendChild(r);}else o.textContent=e.text;return o}function Hf(e,t,n,o){let r=t.createElement("span");if(r.className=`${rn.run} ${rn.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",cr(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=vS(o);i&&(r.style.backgroundImage=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='4' height='16'><text x='0' y='12' font-size='12' fill='%23000'>${i}</text></svg>`)}")`,r.style.backgroundRepeat="repeat-x",r.style.backgroundPosition="bottom");}return r.textContent="\xA0",r}function vS(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function RS(e,t){let n=t.createElement("img");return n.className=`${rn.run} ${rn.image}`,n.src=e.src,n.width=e.width,n.height=e.height,e.alt&&(n.alt=e.alt),e.transform&&(n.style.transform=e.transform),n.style.display="inline",n.style.verticalAlign="middle",cr(n,e.pmStart,e.pmEnd),n}function Bf(e,t){let n=t.createElement("div");n.className="layout-block-image",n.style.display="block",n.style.textAlign="center",n.style.marginTop=`${e.distTop??6}px`,n.style.marginBottom=`${e.distBottom??6}px`;let o=t.createElement("img");return o.src=e.src,o.width=e.width,o.height=e.height,o.style.marginLeft="auto",o.style.marginRight="auto",e.alt&&(o.alt=e.alt),e.transform&&(o.style.transform=e.transform),cr(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function Nf(e,t){return dr(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?Bf(e,t):RS(e,t)}function zf(e,t){let n=t.createElement("br");return n.className=`${rn.run} ${rn.lineBreak}`,cr(n,e.pmStart,e.pmEnd),n}function Of(e,t,n){let o=e.fallback??"";switch(e.fieldType){case "PAGE":o=String(n.pageNumber);break;case "NUMPAGES":o=String(n.totalPages);break;case "DATE":o=new Date().toLocaleDateString();break;case "TIME":o=new Date().toLocaleTimeString();break}let r={text:o,bold:e.bold,italic:e.italic,underline:e.underline,strike:e.strike,color:e.color,highlight:e.highlight,fontFamily:e.fontFamily,fontSize:e.fontSize,pmStart:e.pmStart,pmEnd:e.pmEnd};return Ql(r,t,n?.resolvedCommentIds)}function ES(e,t,n){if(ni(e))return Ql(e,t,n?.resolvedCommentIds);if(is(e))return Hf(e,t,48,void 0);if(Df(e))return Nf(e,t);if(Zl(e))return zf(e,t);if(Jl(e)&&n)return Of(e,t,n);let o=t.createElement("span");return o.className=rn.run,o}function $f(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(ni(i)){let a=r===t.fromRun?t.fromChar:0,s=r===t.toRun?t.toChar:i.text.length;if(a>0||s<i.text.length){let l=i.text.slice(a,s);n.push({...i,text:l,pmStart:i.pmStart!==void 0?i.pmStart+a:void 0,pmEnd:i.pmStart!==void 0?i.pmStart+s:void 0});}else n.push(i);}else n.push(i);}return n}function PS(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function MS(e){return {val:e.val,pos:e.pos,leader:e.leader}}function IS(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(ni(i))o+=i.text;else if(Jl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(is(i)||Zl(i))break}return o}function FS(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=chunkEV3CM6TU_js.a(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function _f(e,t,n,o,r){let i=o.createElement("div");i.className=rn.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=$f(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${rn.run} layout-empty-run`,b.innerHTML=" ",i.appendChild(b),i}let s=n==="justify",l=false;s&&r&&(l=!r.isLastLine||r.paragraphEndsWithLineBreak,l&&(i.style.textAlign="justify",i.style.textAlignLast="justify",i.style.width=`${r.availableWidth}px`)),i.style.whiteSpace="pre";let u=a.some(b=>ni(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let c=a.some(is),d,p=FS(o);if(c){let b=r?.tabStops?.map(MS),h=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;d={explicitStops:b,leftIndent:h};}let f=0,m=r?.leftIndentPx??0;if(r?.isFirstLine){let b=r?.firstLineIndentPx??0;f=m+b;}else f=m;for(let b=0;b<a.length;b++){let h=a[b];if(is(h)&&d){let x=IS(a,b,r?.context),T=Lf(f,d,x,p),S=Hf(h,o,T.width,T.leader);i.appendChild(S),f+=T.width;}else if(ni(h)){let x=Ql(h,o,r?.context?.resolvedCommentIds);if(h.highlight){let R=(h.fontSize?h.fontSize*96/72:14.67)*1.2,D=Math.max(0,t.lineHeight-R);if(D>0){let L=D/2;x.style.paddingTop=`${L}px`,x.style.paddingBottom=`${L}px`;}}i.appendChild(x);let T=h.fontSize||11,S=h.fontFamily||"Calibri";f+=p(h.text,T,S);}else if(Df(h)){if(dr(h))continue;let x=PS(h);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let T=Nf(h,o);i.appendChild(T),h.displayMode!=="block"&&h.wrapType!=="topAndBottom"&&(f+=h.width);}else if(Zl(h)){let x=zf(h,o);i.appendChild(x);}else if(Jl(h)&&r?.context){let x=Of(h,o,r.context);i.appendChild(x);let T=h.fallback??"";h.fieldType==="PAGE"?T=String(r.context.pageNumber):h.fieldType==="NUMPAGES"&&(T=String(r.context.totalPages));let S=h.fontSize||11,I=h.fontFamily||"Calibri";f+=p(T,S,I);}else {let x=ES(h,o,r?.context);i.appendChild(x);}}return i}function ti(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function Af(e,t){return !e&&!t||!e||!t?false:ti(e.top,t.top)&&ti(e.bottom,t.bottom)&&ti(e.left,t.left)&&ti(e.right,t.right)&&ti(e.between,t.between)}function Wn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=rn.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),cr(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId);let u=t.attrs?.bidi;u&&(a.dir="rtl"),l?l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":l==="left"?a.style.textAlign="left":a.style.textAlign=u?"right":"left":u&&(a.style.textAlign="right");let c=t.attrs?.indent,d=0,p=0;c&&(u?(c.left&&c.left>0&&(p=c.left),c.right&&c.right>0&&(d=c.right)):(c.left&&c.left>0&&(d=c.left),c.right&&c.right>0&&(p=c.right)));let f=t.attrs?.borders;if(f){let R=v=>{switch(v){case "single":return "solid";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "thick":return "solid";case "wave":return "wavy";case "dashSmallGap":return "dashed";case "nil":case "none":return "none";default:return "solid"}};a.style.boxSizing="border-box";let D=v=>`${v.width}px ${R(v.style)} ${v.color}`,L=Af(r.prevBorders,f),pe=Af(f,r.nextBorders);if(L&&f.between?a.style.borderTop=D(f.between):f.top&&!L&&(a.style.borderTop=D(f.top)),f.bottom&&!pe&&(a.style.borderBottom=D(f.bottom)),f.left&&(a.style.borderLeft=D(f.left)),f.right&&(a.style.borderRight=D(f.right)),f.bar){let v=i.createElement("div");v.style.position="absolute",v.style.left="-8px",v.style.top="0",v.style.bottom="0",v.style.borderLeft=D(f.bar),a.style.position="relative",a.appendChild(v);}if(f.top||f.bottom||f.left||f.right||f.between){let v=f.top||f.between;a.style.paddingLeft=f.left?`${f.left.space??4}px`:"0",a.style.paddingRight=f.right?`${f.right.space??4}px`:"0",a.style.paddingTop=v?`${v.space??2}px`:"0",a.style.paddingBottom=f.bottom?`${f.bottom.space??6}px`:"0";}}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let m=e.width-d-p,h=t.runs[t.runs.length-1]?.kind==="lineBreak",x=n.lines.length,T=0;c?.hanging&&c.hanging>0?T=-c.hanging:c?.firstLine&&c.firstLine>0&&(T=c.firstLine);let S=0,I=r.renderedInlineImageKeys??new Set;for(let R=0;R<s.length;R++){let D=s[R],L=e.fromLine+R,pe=L===x-1,$=L===0&&!e.continuesFromPrev,v=D.leftOffset??0,_=D.rightOffset??0,re=m;if($){let de=c?.hanging&&c.hanging>0,ge=c?.firstLine&&c.firstLine>0;de&&c?.hanging?re=m+c.hanging:ge&&c?.firstLine&&(re=m-c.firstLine);}let ae=_f(t,D,l,i,{availableWidth:re-v-_,isLastLine:pe,isFirstLine:$,paragraphEndsWithLineBreak:h,tabStops:t.attrs?.tabs,leftIndentPx:d,firstLineIndentPx:$?T:0,context:o,renderedInlineImageKeys:I});if(v>0||_>0){v>0&&(ae.style.marginLeft=`${v}px`),_>0&&(ae.style.marginRight=`${_}px`);let de=re-v-_;de>0&&(ae.style.width=`${de}px`);}S+=D.lineHeight;let N=c?.hanging&&c.hanging>0,B=c?.firstLine&&c.firstLine>0;if($?d>0&&N?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`-${c.hanging}px`):d>0&&B?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:B&&(ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:N&&(ae.style.paddingLeft=`${c.hanging}px`),p>0&&(ae.style.paddingRight=`${p}px`),$&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let de=Math.max(0,d-(c?.hanging??0));ae.style.paddingLeft=`${de}px`,ae.style.textIndent="0";let ge;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let E=D.fromRun;E<=D.toRun;E++){let F=t.runs[E];if(F&&F.kind==="text"){ge=F;break}}let Pe=t.attrs.listMarkerFontFamily??ge?.fontFamily??t.attrs.defaultFontFamily,se=t.attrs.listMarkerFontSize??ge?.fontSize??t.attrs.defaultFontSize,q=LS(t.attrs.listMarker,c,i,Pe,se);ae.insertBefore(q,ae.firstChild);}a.appendChild(ae);}return a}function LS(e,t,n,o,r){let i=n.createElement("span");if(i.className="layout-list-marker",i.style.display="inline-block",o&&(i.style.fontFamily=chunkEV3CM6TU_js.a(o).cssFallback),r){let s=r*96/72;i.style.fontSize=`${s}px`;}i.textContent=e;let a=t?.hanging??24;return i.style.minWidth=`${a}px`,i.style.textAlign="left",i.style.boxSizing="border-box",i}var Fn={table:"layout-table",row:"layout-table-row",cell:"layout-table-cell",cellContent:"layout-table-cell-content",resizeHandle:"layout-table-resize-handle",rowResizeHandle:"layout-table-row-resize-handle",tableEdgeHandleBottom:"layout-table-edge-handle-bottom",tableEdgeHandleRight:"layout-table-edge-handle-right"};function BS(e,t,n){let o=[],r=0;for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i];if(a?.kind!=="paragraph"){let u=t.blocks[i];u&&u.kind==="table"&&(r+=u.totalHeight??0);continue}let s=a;for(let u of s.runs){if(u.kind!=="image")continue;let c=u;if(!dr(c))continue;let d=c.position,p=c.distTop??0,f=c.distBottom??0,m=c.distLeft??12,b=c.distRight??12,h="left",x=0;if(d?.horizontal){let I=d.horizontal;I.align==="right"?(h="right",x=n-c.width):I.align==="left"?x=0:I.align==="center"?x=(n-c.width)/2:I.posOffset!==void 0&&(x=co(I.posOffset),h=x>n/2?"right":"left");}else c.cssFloat==="right"&&(h="right",x=n-c.width);let T=r;if(d?.vertical){let I=d.vertical;I.posOffset!==void 0?T=r+co(I.posOffset):I.align==="top"&&(T=0);}x=Math.max(0,Math.min(x,n-c.width));let S="bothSides";c.cssFloat==="left"?S="right":c.cssFloat==="right"&&(S="left"),o.push({src:c.src,width:c.width,height:c.height,alt:c.alt,transform:c.transform,x,y:T,side:h,distTop:p,distBottom:f,distLeft:m,distRight:b,wrapText:S,pmStart:c.pmStart,pmEnd:c.pmEnd});}let l=t.blocks[i];l&&l.kind==="paragraph"&&(r+=l.totalHeight);}return o}function AS(e,t,n,o){let r=o.createElement("div");r.className=Fn.cellContent,r.style.position="relative";let i=e.padding?.left??7,a=e.padding?.right??7,s=Math.max(0,t.width-i-a);r.style.width=`${s}px`;let l=BS(e,t,s),u;if(l.length>0){u=l.map(p=>{let f=p.x+p.width+p.distRight,m=p.y-p.distTop,b=p.y+p.height+p.distBottom,h=0,x=0,T=p.wrapText??"bothSides";return T==="right"?h=f:T==="left"?x=s-(p.x-p.distLeft):p.side==="left"?h=f:x=s-(p.x-p.distLeft),{leftMargin:h,rightMargin:x,topY:m,bottomY:b}});let d=o.createElement("div");d.className="layout-cell-floating-images-layer",d.style.position="absolute",d.style.top="0",d.style.left="0",d.style.width="100%",d.style.height="100%",d.style.pointerEvents="none",d.style.zIndex="10",d.style.overflow="hidden";for(let p of l){let f=o.createElement("div");f.className="layout-cell-floating-image",f.style.position="absolute",f.style.left=`${p.x}px`,f.style.top=`${p.y}px`,f.style.pointerEvents="auto",p.pmStart!==void 0&&(f.dataset.pmStart=String(p.pmStart)),p.pmEnd!==void 0&&(f.dataset.pmEnd=String(p.pmEnd));let m=o.createElement("img");m.src=p.src,m.style.width=`${p.width}px`,m.style.height=`${p.height}px`,m.style.display="block",p.alt&&(m.alt=p.alt),p.transform&&(m.style.transform=p.transform),f.appendChild(m),d.appendChild(f);}r.appendChild(d);}let c=0;for(let d=0;d<e.blocks.length;d++){let p=e.blocks[d],f=t.blocks[d];if(p?.kind==="paragraph"&&f?.kind==="paragraph"){let m=p,b=f;u&&u.length>0&&(b=In(m,s,{floatingZones:u,paragraphYOffset:c}));let h={blockId:m.id,width:s,height:b.totalHeight,fromLine:0,toLine:b.lines.length,pmStart:m.pmStart,pmEnd:m.pmEnd},x={...n,insideTableCell:true},T=Wn(h,m,b,x,{document:o});T.style.position="relative",r.appendChild(T),c+=b.totalHeight;}else if(p?.kind==="table"&&f?.kind==="table"){let h=DS(p,f,n,o);h.style.position="relative",r.appendChild(h),c+=f.totalHeight??0;}}return r}function DS(e,t,n,o){let r=o.createElement("div");r.className=`${Fn.table} layout-nested-table`,r.style.position="relative",r.style.width=`${t.totalWidth}px`,r.style.display="block",e.justification==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):e.justification==="right"?r.style.marginLeft="auto":e.indent&&(r.style.marginLeft=`${e.indent}px`),r.dataset.blockId=String(e.id),e.pmStart!==void 0&&(r.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(r.dataset.pmEnd=String(e.pmEnd));let i=[],a=0;for(let u=0;u<t.rows.length;u++)i.push(a),a+=t.rows[u]?.height??0;i.push(a);let s=new Map,l=0;for(let u=0;u<e.rows.length;u++){let c=e.rows[u],d=t.rows[u];if(!c||!d)continue;let p=ec(c,d,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=d.height;}return r.style.height=`${l}px`,r}function as(e,t,n){let o=`border${t.charAt(0).toUpperCase()+t.slice(1)}`;if(!n||n.style==="none"||n.style==="nil"||n.width===0)e.style[o]="none";else {let r=n.width??1,i=n.color??"#000000",a=n.style??"solid";e.style[o]=`${r}px ${a} ${i}`;}}function HS(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Fn.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,c=e.padding?.bottom??1,d=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${c}px ${d}px`,e.borders&&(r.isFirstRow&&as(s,"top",e.borders.top),as(s,"right",e.borders.right),as(s,"bottom",e.borders.bottom),r.isFirstCol&&as(s,"left",e.borders.left)),e.background&&(s.style.backgroundColor=e.background),e.verticalAlign)switch(s.style.display="flex",s.style.flexDirection="column",e.verticalAlign){case "top":s.style.justifyContent="flex-start";break;case "center":s.style.justifyContent="center";break;case "bottom":s.style.justifyContent="flex-end";break}let p=AS(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let f=e.blocks[0],m=e.blocks[e.blocks.length-1];f&&"pmStart"in f&&f.pmStart!==void 0&&(s.dataset.pmStart=String(f.pmStart)),m&&"pmEnd"in m&&m.pmEnd!==void 0&&(s.dataset.pmEnd=String(m.pmEnd));}return s}function ec(e,t,n,o,r,i,a,s,l,u,c){let d=s.createElement("div");d.className=Fn.row,d.style.position="absolute",d.style.left="0",d.style.top=`${o}px`,d.style.width="100%",d.style.height=`${t.height}px`,d.dataset.rowIndex=String(n);let p=new Set;if(l){for(let[,b]of l)if(b.startRow<n&&b.startRow+b.rowSpan>n)for(let h=0;h<b.colSpan;h++)p.add(b.columnIndex+h);}let f=0,m=0;for(;p.has(m);)f+=r[m]??0,m++;for(let b=0;b<e.cells.length;b++){let h=e.cells[b],x=t.cells[b];if(!h||!x)continue;let T=h.colSpan??1,S=h.rowSpan??1,I=t.height;if(S>1&&u){I=0;for(let v=n;v<n+S&&v<u.length-1;v++)I+=(u[v+1]??0)-(u[v]??0);I===0&&(I=t.height*S);}let R=n===0||c===true,L=m===0;m+T>=r.length;let $=HS(h,x,f,I,{isFirstRow:R,isFirstCol:L},a,s);if($.dataset.cellIndex=String(b),$.dataset.columnIndex=String(m),S>1&&($.dataset.rowSpan=String(S)),d.appendChild($),S>1&&l){let v=`${n}-${m}`;l.set(v,{cell:h,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:T,x:f,totalHeight:I});}for(let v=0;v<T&&m+v<r.length;v++)f+=r[m+v]??0;for(m+=T;p.has(m);)f+=r[m]??0,m++;}return d}function ss(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Fn.table,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.dataset.blockId=String(e.blockId),a.dataset.fromRow=String(e.fromRow),a.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=0;for(let m=0;m<n.columnWidths.length-1;m++){s+=n.columnWidths[m]??0;let b=i.createElement("div");b.className=Fn.resizeHandle,b.style.position="absolute",b.style.left=`${s-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}let l=[],u=0;for(let m=0;m<n.rows.length;m++)l.push(u),u+=n.rows[m]?.height??0;l.push(u);let c=new Map,d=e.headerRowCount??0,p=0;if(d>0&&e.continuesFromPrev)for(let m=0;m<d;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,m===0);x.dataset.repeatedHeader="true",a.appendChild(x),p+=h.height;}for(let m=e.fromRow;m<e.toRow;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=d>0&&e.continuesFromPrev?false:e.continuesFromPrev&&m===e.fromRow,T=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,x);a.appendChild(T),p+=h.height;}let f=0;for(let m=e.fromRow;m<e.toRow;m++)if(f+=n.rows[m]?.height??0,m<e.toRow-1){let b=i.createElement("div");b.className=Fn.rowResizeHandle,b.style.position="absolute",b.style.left="0",b.style.top=`${f-3}px`,b.style.width="100%",b.style.height="6px",b.style.cursor="row-resize",b.style.zIndex="10",b.dataset.rowIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}if(e.toRow===t.rows.length){let m=i.createElement("div");m.className=Fn.tableEdgeHandleBottom,m.style.position="absolute",m.style.left="0",m.style.top=`${f-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(t.rows.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="bottom",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let m=n.columnWidths.reduce((h,x)=>h+x,0),b=i.createElement("div");b.className=Fn.tableEdgeHandleRight,b.style.position="absolute",b.style.left=`${m-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(n.columnWidths.length-1),b.dataset.tableBlockId=String(e.blockId),b.dataset.isEdge="right",e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}return a}var tc={image:"layout-image",imageAnchored:"layout-image-anchored"};function ls(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=tc.image,e.isAnchored&&a.classList.add(tc.imageAnchored),a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",e.zIndex!==void 0&&(a.style.zIndex=String(e.zIndex)),t.anchor?.behindDoc&&(a.style.zIndex="-1"),a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=i.createElement("img");if(s.src=t.src,s.alt=t.alt??"",s.style.width="100%",s.style.height="100%",s.style.objectFit="contain",s.style.display="block",t.transform&&(s.style.transform=t.transform),s.draggable=false,t.hlinkHref){let l=i.createElement("a");l.href=t.hlinkHref,l.target="_blank",l.rel="noopener noreferrer",l.style.display="block",l.style.width="100%",l.style.height="100%",l.appendChild(s),a.appendChild(l);}else a.appendChild(s);return a}var Wf={textBox:"layout-textbox"};function cs(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=Wf.textBox,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.style.boxSizing="border-box",t.fillColor&&(a.style.backgroundColor=t.fillColor),t.outlineWidth&&t.outlineWidth>0){let c=t.outlineStyle||"solid",d=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${c} ${d}`;}let s=t.margins??chunkEV3CM6TU_js.c;a.style.padding=`${s.top}px ${s.right}px ${s.bottom}px ${s.left}px`,a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let l=e.width-s.left-s.right,u=0;for(let c=0;c<t.content.length;c++){let d=t.content[c],p=n.innerMeasures[c];if(!p)continue;let f={blockId:d.id,width:l,height:p.totalHeight,pmStart:d.pmStart,pmEnd:d.pmEnd,fromLine:0,toLine:p.lines.length},m=Wn(f,d,p,o,{document:i});m.style.position="relative",m.style.left="0",m.style.top="0",a.appendChild(m),u+=p.totalHeight;}return a}var uo={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function us(e,t,n,o){if(e.style.position="relative",e.style.width=`${t}px`,e.style.height=`${n}px`,e.style.backgroundColor=o.backgroundColor??"#ffffff",e.style.overflow="hidden",e.style.fontFamily='Calibri, "Segoe UI", Arial, sans-serif',e.style.fontSize=`${1056/72}px`,e.style.color="#000000",o.showBorders&&(e.style.border="1px solid #ccc"),o.showShadow&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)"),o.pageBorders){let r=o.pageBorders,i=["top","bottom","left","right"],a=["Top","Bottom","Left","Right"];for(let s=0;s<i.length;s++){let l=r[i[s]];if(l&&l.style!=="none"&&l.style!=="nil"){let u=Jo(l,a[s],o.theme);for(let[c,d]of Object.entries(u))e.style[c]=String(d);}}}}function NS(e,t){let n=t.margins;e.style.position="absolute",e.style.top=`${n.top}px`,e.style.left=`${n.left}px`,e.style.right=`${n.right}px`,e.style.bottom=`${n.bottom}px`,e.style.overflow="visible";}function jf(e){return e?.align??e?.alignment}function zS(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=jf(n),r=n.posOffset!==void 0?co(n.posOffset):void 0;if(n.relativeTo==="page"){if(r!==void 0)return r-t.flowTop;if(o==="top")return -t.flowTop;if(o==="bottom")return t.pageHeight-e.height-t.flowTop;if(o==="center")return (t.pageHeight-e.height)/2-t.flowTop}if(n.relativeTo==="margin"){let i=t.margins.top,a=t.pageHeight-t.margins.top-t.margins.bottom;if(r!==void 0)return i+r-t.flowTop;if(o==="top")return i-t.flowTop;if(o==="bottom")return i+a-e.height-t.flowTop;if(o==="center")return i+(a-e.height)/2-t.flowTop}return r!==void 0?e.paragraphY+r:e.paragraphY}function OS(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=jf(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)-n.flowLeft}px`;return}if(r==="right"){e.style.left=`${n.pageWidth-t.width-n.flowLeft}px`;return}if(r==="center"){e.style.left=`${(n.pageWidth-t.width)/2-n.flowLeft}px`;return}if(r==="left"){e.style.left=`${-n.flowLeft}px`;return}}if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)}px`;return}if(r==="right"){e.style.left=`${n.contentWidth-t.width}px`;return}if(r==="center"){e.style.left=`${(n.contentWidth-t.width)/2}px`;return}e.style.left="0";}function $S(e,t,n){e.style.position="absolute",e.style.left=`${t.x-n.left}px`,e.style.top=`${t.y-n.top}px`,e.style.width=`${t.width}px`,"height"in t&&(e.style.height=`${t.height}px`);}function co(e){return e===void 0?0:Math.round(e*96/914400)}function dr(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function _S(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!dr(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,c=i.distRight??12,d="left",p=0;if(a?.horizontal){let b=a.horizontal;b.align==="right"?(d="right",p=n-i.width):b.align==="left"?(d="left",p=0):b.align==="center"?(d="left",p=(n-i.width)/2):b.posOffset!==void 0&&(p=co(b.posOffset),d=p>n/2?"right":"left");}else i.cssFloat==="right"&&(d="right",p=n-i.width);let f=0;if(a?.vertical){let b=a.vertical;b.align==="top"?f=0:b.align==="bottom"?f=t:b.posOffset!==void 0?f=co(b.posOffset):f=t,b.relativeTo==="margin"&&(b.align==="top"||b.posOffset!==void 0)||b.relativeTo==="paragraph"&&(f=t+f);}else f=t;let m="bothSides";i.cssFloat==="left"?m="right":i.cssFloat==="right"&&(m="left"),o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:d,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:c,pmStart:i.pmStart,pmEnd:i.pmEnd,wrapText:m,wrapType:i.wrapType});}return o}function WS(e,t){return e.map(n=>{let o=n.x+n.width+n.distRight,r=n.y-n.distTop,i=n.y+n.height+n.distBottom,a=0,s=0,l=n.wrapText??"bothSides";return l==="right"?a=o:l==="left"?s=t-(n.x-n.distLeft):n.side==="left"?a=o:s=t-(n.x-n.distLeft),{leftMargin:a,rightMargin:s,topY:r,bottomY:i}})}function VS(e,t){let n=t.createElement("div");n.className="layout-floating-images-layer",n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0",n.style.bottom="0",n.style.pointerEvents="none",n.style.zIndex="10";for(let o of e){let r=t.createElement("div");r.className="layout-page-floating-image",r.style.position="absolute",r.style.pointerEvents="auto",r.style.top=`${o.y}px`,r.style.left=`${o.x}px`,o.pmStart!==void 0&&(r.dataset.pmStart=String(o.pmStart)),o.pmEnd!==void 0&&(r.dataset.pmEnd=String(o.pmEnd));let i=t.createElement("img");i.src=o.src,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.display="block",o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function Vf(e,t,n,o){let r=n.document??document,i=r.createElement("div");i.style.position="relative";let a=t.contentWidth??600,s=[],l=0;for(let u=0;u<e.blocks.length;u++){let c=e.blocks[u],d=e.measures[u];if(c?.kind==="paragraph"&&d?.kind==="paragraph"){let p=c,f=d,m=l,b=[];for(let S of p.runs)if(S.kind==="image"&&"position"in S&&S.position){let I=S;s.push({src:I.src,width:I.width,height:I.height,alt:I.alt,paragraphY:m,position:I.position});}else b.push(S);let h={...p,runs:b},x={blockId:p.id,width:a,height:f.totalHeight,fromLine:0,toLine:f.lines.length},T=Wn(x,h,f,t,{document:r});T.style.position="relative",T.style.marginBottom="0",i.appendChild(T),l+=f.totalHeight;}}for(let u of s){let c=r.createElement("img");c.src=u.src,c.width=u.width,c.height=u.height,u.alt&&(c.alt=u.alt),c.style.position="absolute",c.style.display="block",c.style.width=`${u.width}px`,c.style.height=`${u.height}px`,c.style.maxWidth="none",c.style.maxHeight="none",OS(c,u,o),c.style.top=`${zS(u,o)}px`,i.appendChild(c);}return i}function US(e,t,n){let o=n.createElement("div");o.className="layout-footnote-area",o.style.width=`${t}px`;let r=n.createElement("div");r.style.width="33%",r.style.height="0.5px",r.style.backgroundColor="#000",r.style.marginBottom="6px",r.style.marginTop="6px",o.appendChild(r);for(let i of e){let a=n.createElement("div");a.style.fontSize="10px",a.style.lineHeight="1.3",a.style.marginBottom="4px",a.style.color="#000";let s=n.createElement("sup");s.textContent=i.displayNumber,s.style.fontSize="7px",s.style.marginRight="2px",a.appendChild(s);let l=n.createTextNode(" "+i.text);a.appendChild(l),o.appendChild(a);}return o}function nc(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??uo.page,r.dataset.pageNumber=String(e.number),us(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=uo.content,NS(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let f of e.fragments)if(f.kind==="paragraph"&&n.blockLookup){let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph"){let b=m.block,h=f.y-e.margins.top,x=_S(b,h,a);s.push(...x);}}for(let f of s)l.push({side:f.side,x:f.x,y:f.y,width:f.width,height:f.height,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,wrapText:f.wrapText,wrapType:f.wrapType});if(n.blockLookup)for(let f of e.fragments){if(f.kind!=="table")continue;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind!=="table")continue;let h=m.block.floating;if(!h)continue;let x=f.x-e.margins.left,T=f.y-e.margins.top,S=h.topFromText??0,I=h.bottomFromText??0,R=h.leftFromText??12,D=h.rightFromText??12,L=x<a/2?"left":"right";l.push({side:L,x,y:T,width:f.width,height:f.height,distTop:S,distBottom:I,distLeft:R,distRight:D});}let u=l.length>0?WS(l,a):[];if(s.length>0){let f=VS(s,o);i.appendChild(f);}let c=f=>{if(f.kind!=="paragraph"||!n.blockLookup||!f.blockId)return;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph")return m.block.attrs?.borders},d,p=new Map;for(let f=0;f<e.fragments.length;f++){let m=e.fragments[f],b,h={...t,section:"body",contentWidth:a},x=m.y-e.margins.top;if(n.blockLookup&&m.blockId){let T=n.blockLookup.get(String(m.blockId));if(m.kind==="paragraph"&&T?.block.kind==="paragraph"&&T?.measure.kind==="paragraph"){let S=T.block,I=f+1<e.fragments.length?c(e.fragments[f+1]):void 0,R=String(m.blockId),D=p.get(R);D||(D=new Set,p.set(R,D));let L=T.measure;u.length>0&&(L=In(S,a,{floatingZones:u,paragraphYOffset:x})),b=Wn(m,S,L,h,{document:o,prevBorders:d,nextBorders:I,renderedInlineImageKeys:D}),d=S.attrs?.borders;}else m.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=ss(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=ls(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=cs(m,T.block,T.measure,h,{document:o}),d=void 0):(b=ei(m,h,{document:o}),d=void 0);}else b=ei(m,h,{document:o}),d=void 0;$S(b,m,{left:e.margins.left,top:e.margins.top}),i.appendChild(b);}if(e.columns&&e.columns.separator&&e.columns.count>1){let f=e.columns.count,m=e.columns.gap,b=(a-(f-1)*m)/f,h=e.size.h-e.margins.top-e.margins.bottom;for(let x=0;x<f-1;x++){let T=(x+1)*b+x*m+m/2,S=o.createElement("div");S.style.position="absolute",S.style.left=`${T}px`,S.style.top="0",S.style.height=`${h}px`,S.style.width="0.5px",S.style.backgroundColor="#000",S.style.pointerEvents="none",i.appendChild(S);}}if(n.footnoteArea&&n.footnoteArea.length>0){let f=US(n.footnoteArea,a,o);f.style.position="absolute";let m=e.footnoteReservedHeight??0,b=e.size.h-e.margins.bottom-e.margins.top;f.style.top=`${b-m}px`,f.style.left="0",f.style.right="0",i.appendChild(f);}r.appendChild(i);{let m=n.headerDistance??e.margins.header??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.top-m,48),x=n.headerContent?.visualTop??0,T=n.headerContent?.visualBottom??n.headerContent?.height??0,S=Math.max(T-x,24),I=T>h,R=o.createElement("div");R.className=uo.header,R.style.position="absolute",R.style.top=`${m+x}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let D=!I;if(n.headerContent&&n.headerContent.blocks.length>0){let L=Vf(n.headerContent,{...t,section:"header",contentWidth:b},n,{flowTop:m,flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(D=false),R.appendChild(L);}D&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}{let m=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.bottom-m,48),x=n.footerContent?.visualTop??0,T=n.footerContent?.visualBottom??n.footerContent?.height??0,S=Math.max(T-x,24),I=S>h,R=o.createElement("div");R.className=uo.footer,R.style.position="absolute",R.style.top=`${e.size.h-m-S}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let D=!I;if(n.footerContent&&n.footerContent.blocks.length>0){let L=Vf(n.footerContent,{...t,section:"footer",contentWidth:b},n,{flowTop:e.size.h-m-(n.footerContent?.height??0),flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(D=false),R.appendChild(L);}D&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}return r}function oc(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body",resolvedCommentIds:n.resolvedCommentIds},r={...n};if(n.titlePg&&e.number===1&&(r.headerContent=n.firstPageHeaderContent,r.footerContent=n.firstPageFooterContent),n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Uf(e){let t=[];t.push(`s:${e.size.w},${e.size.h}`),t.push(`m:${e.margins.top},${e.margins.right},${e.margins.bottom},${e.margins.left}`),t.push(`n:${e.number}`),e.footnoteReservedHeight&&t.push(`fn:${e.footnoteReservedHeight}`);for(let n of e.fragments){let o=`${n.kind}:${n.blockId},${n.x},${n.y},${n.width},${n.height}`;n.pmStart!==void 0&&(o+=`,ps:${n.pmStart}`),n.pmEnd!==void 0&&(o+=`,pe:${n.pmEnd}`),n.kind==="paragraph"?o+=`,fl:${n.fromLine},tl:${n.toLine}`:n.kind==="table"&&(o+=`,fr:${n.fromRow},tr:${n.toRow}`),t.push(o);}return t.join("|")}function jS(e){let t=[];return e.headerContent&&t.push(`hdr:${e.headerContent.blocks.length},${e.headerContent.height},${e.headerContent.visualTop??0},${e.headerContent.visualBottom??e.headerContent.height}`),e.footerContent&&t.push(`ftr:${e.footerContent.blocks.length},${e.footerContent.height},${e.footerContent.visualTop??0},${e.footerContent.visualBottom??e.footerContent.height}`),e.firstPageHeaderContent&&t.push(`fp-hdr:${e.firstPageHeaderContent.blocks.length},${e.firstPageHeaderContent.height}`),e.firstPageFooterContent&&t.push(`fp-ftr:${e.firstPageFooterContent.blocks.length},${e.firstPageFooterContent.height}`),e.titlePg&&t.push("titlePg"),e.theme&&t.push(`thm:${e.theme.name??"default"}`),e.pageBorders&&t.push(`pb:${JSON.stringify(e.pageBorders)}`),e.headerDistance!==void 0&&t.push(`hd:${e.headerDistance}`),e.footerDistance!==void 0&&t.push(`fd:${e.footerDistance}`),t.join("|")}function KS(e,t){e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.gap=`${t}px`,e.style.padding=`${t}px`,e.style.backgroundColor="var(--doc-bg, #f8f9fa)";}var ds=2,GS=8;function Kf(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=jS(n),l=o>=GS;if(a&&a.optionsHash===s&&l){let h=a.pageStates,x=a.pageDataMap,T=i.__pageObserver,S=[];for(let D of e)S.push(Uf(D));let I=a.totalPages!==o,R=Math.min(h.length,e.length);for(let D=0;D<R;D++){let L=h[D],pe=S[D];if(L.fingerprint===pe&&!I){let _=x.get(L.element);_&&(_.page=e[D]);continue}let $=L.element,v=x.get($);v&&(v.page=e[D],v.rendered&&YS($,x,o,n)),L.fingerprint=pe,us($,e[D].size.w,e[D].size.h,n),$.dataset.pageNumber=String(e[D].number);}if(e.length>h.length){let D=n.document??document;for(let L=h.length;L<e.length;L++){let pe=e[L],$=D.createElement("div");$.className=n.pageClassName??uo.page,$.dataset.pageNumber=String(pe.number),$.dataset.pageIndex=String(L),us($,pe.size.w,pe.size.h,n),t.appendChild($),h.push({element:$,fingerprint:S[L]}),x.set($,{page:pe,index:L,rendered:false}),T&&T.observe($);}}if(e.length<h.length){for(let D=h.length-1;D>=e.length;D--){let L=h[D].element;T&&T.unobserve(L),x.delete(L),t.removeChild(L);}h.length=e.length;}for(let D=0;D<h.length;D++){let L=x.get(h[D].element);L&&(L.index=D);}a.totalPages=o,a.currentOptions=n;return}let c=i.__pageObserver;c&&(c.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,KS(t,r);let d=[],p=[];for(let h=0;h<e.length;h++){let x=e[h];if(p.push(Uf(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??uo.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(h),us(S,x.size.w,x.size.h,n),t.appendChild(S),d.push(S);}else {let{context:T,pageOptions:S}=oc(x,o,n),I=nc(x,T,S);t.appendChild(I),d.push(I);}}if(!l)return;let f=new Map;for(let h=0;h<e.length;h++)f.set(d[h],{page:e[h],index:h,rendered:false});let m=new IntersectionObserver(h=>{let x=i.__pageRenderState;if(!x)return;let{currentOptions:T,totalPages:S,pageDataMap:I}=x;for(let pe of h){let $=pe.target,v=I.get($);if(v&&pe.isIntersecting){ps($,I,S,T);for(let _=-ds;_<=ds;_++){let re=v.index+_;re>=0&&re<x.pageStates.length&&re!==v.index&&ps(x.pageStates[re].element,I,S,T);}}}let R=window.innerHeight,D=R*3,L=new Set;for(let[pe,$]of I){if(!$.rendered)continue;let v=pe.getBoundingClientRect();v.bottom>-D&&v.top<R+D&&L.add($.index);}for(let[pe,$]of I){if(!$.rendered)continue;let v=false;for(let _ of L)if(Math.abs($.index-_)<=ds+1){v=true;break}!v&&L.size>0&&qS(pe,I);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let h of d)m.observe(h);i.__pageObserver=m,i.__pageRenderState={pageStates:d.map((h,x)=>({element:h,fingerprint:p[x]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,ds+3);for(let h=0;h<b;h++)ps(d[h],f,o,n);}function ps(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=oc(r.page,n,o),s=nc(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function YS(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=oc(r.page,n,o),l=nc(r.page,i,a).querySelector(`.${uo.content}`),u=e.querySelector(`.${uo.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,ps(e,t,n,o));}function qS(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var fs=class{constructor(t={}){chunkH5NTJZO4_js.d(this,"container",null);chunkH5NTJZO4_js.d(this,"blockLookup",new Map);chunkH5NTJZO4_js.d(this,"pageStates",[]);chunkH5NTJZO4_js.d(this,"totalPages",0);chunkH5NTJZO4_js.d(this,"options");chunkH5NTJZO4_js.d(this,"doc");chunkH5NTJZO4_js.d(this,"resolvedCommentIds",new Set);this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body",resolvedCommentIds:this.resolvedCommentIds},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return Wn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return ss(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return ls(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return cs(t,r,i,n,{document:this.doc})}return ei(t,n,{document:this.doc})}applyFragmentPosition(t,n){t.style.position="absolute",t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,t.style.width=`${n.width}px`,"height"in n&&(t.style.height=`${n.height}px`);}getPageCount(){return this.totalPages}getPageElement(t){return this.pageStates[t]?.element??null}scrollToPage(t){let n=this.pageStates.find(o=>o.pageNumber===t);n?.element&&n.element.scrollIntoView({behavior:"smooth",block:"start"});}};var Vn,po,fo,Un,ur,Lo,Gf,rc,ms=class{constructor(){chunkH5NTJZO4_js.f(this,Lo);chunkH5NTJZO4_js.f(this,Vn,0);chunkH5NTJZO4_js.f(this,po,0);chunkH5NTJZO4_js.f(this,fo,false);chunkH5NTJZO4_js.f(this,Un,null);chunkH5NTJZO4_js.f(this,ur,new Set);}setStateSeq(t){chunkH5NTJZO4_js.g(this,Vn,t);}incrementStateSeq(){return ++chunkH5NTJZO4_js.i(this,Vn)._}getStateSeq(){return chunkH5NTJZO4_js.e(this,Vn)}getRenderSeq(){return chunkH5NTJZO4_js.e(this,po)}onLayoutStart(){chunkH5NTJZO4_js.g(this,fo,true);}onLayoutComplete(t){chunkH5NTJZO4_js.g(this,po,t),chunkH5NTJZO4_js.g(this,fo,false),chunkH5NTJZO4_js.h(this,Lo,Gf).call(this);}isSafeToRender(){return !chunkH5NTJZO4_js.e(this,fo)&&chunkH5NTJZO4_js.e(this,po)>=chunkH5NTJZO4_js.e(this,Vn)}requestRender(){this.isSafeToRender()?chunkH5NTJZO4_js.h(this,Lo,rc).call(this):chunkH5NTJZO4_js.g(this,Un,()=>chunkH5NTJZO4_js.h(this,Lo,rc).call(this));}onRender(t){return chunkH5NTJZO4_js.e(this,ur).add(t),()=>{chunkH5NTJZO4_js.e(this,ur).delete(t);}}reset(){chunkH5NTJZO4_js.g(this,Vn,0),chunkH5NTJZO4_js.g(this,po,0),chunkH5NTJZO4_js.g(this,fo,false),chunkH5NTJZO4_js.g(this,Un,null);}getDebugInfo(){return {stateSeq:chunkH5NTJZO4_js.e(this,Vn),renderSeq:chunkH5NTJZO4_js.e(this,po),layoutUpdating:chunkH5NTJZO4_js.e(this,fo),hasPendingRender:chunkH5NTJZO4_js.e(this,Un)!==null,isSafe:this.isSafeToRender()}}};Vn=new WeakMap,po=new WeakMap,fo=new WeakMap,Un=new WeakMap,ur=new WeakMap,Lo=new WeakSet,Gf=function(){if(chunkH5NTJZO4_js.e(this,Un)&&this.isSafeToRender()){let t=chunkH5NTJZO4_js.e(this,Un);chunkH5NTJZO4_js.g(this,Un,null),t();}},rc=function(){for(let t of chunkH5NTJZO4_js.e(this,ur))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var qf=".layout-page-content .layout-line";function XS(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function ZS(e){let t=XS(e);if(!t)return;let n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=40;n.bottom>o.bottom-r?t.scrollTop+=n.bottom-o.bottom+r:n.top<o.top+r&&(t.scrollTop-=o.top-n.top+r);}function Xf({pagesContainerRef:e}){let t=gm.useRef(null),n=gm.useRef(-1),o=gm.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let c of Array.from(l)){let d=c,p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(d.classList.contains("layout-run-tab")){if(s>=p&&s<f)return d.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&c.firstChild?.nodeType===Node.TEXT_NODE){let m=c.firstChild,b=Math.min(s-p,m.length),h=d.ownerDocument;if(!h)continue;let x=h.createRange();return x.setStart(m,b),x.setEnd(m,b),x.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let c of Array.from(u)){let d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f)return c.getBoundingClientRect().left}return null},[e]),r=gm.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(qf);for(let u of Array.from(l)){let c=u,d=c.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(d)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return c}}for(let u of Array.from(l)){let c=u,d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f&&d.querySelector(".layout-line")===c)return c}return null},[e]),i=gm.useCallback((s,l)=>{let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart)+1:null}for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=Number(m.dataset.pmStart),x=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let T=(b.left+b.right)/2;return l<T?h:x}continue}if(l>=b.left&&l<=b.right){let T=m.firstChild;if(!T||T.nodeType!==Node.TEXT_NODE)return h;let S=T,I=m.ownerDocument;if(!I)return h;let R=0,D=S.length;for(;R<D;){let L=Math.floor((R+D)/2),pe=I.createRange();pe.setStart(S,L),pe.setEnd(S,L),l<pe.getBoundingClientRect().left?D=L:R=L+1;}if(R>0&&R<=S.length){let L=I.createRange();L.setStart(S,R-1),L.setEnd(S,R-1);let pe=L.getBoundingClientRect().left;L.setStart(S,Math.min(R,S.length)),L.setEnd(S,Math.min(R,S.length));let $=L.getBoundingClientRect().left;if(Math.abs(l-pe)<Math.abs(l-$))return h+(R-1)}return h+Math.min(R,x-h)}}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=l<b.left?b.left-l:l-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return l<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)},[]),a=gm.useCallback((s,l)=>{if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return (["ArrowLeft","ArrowRight","Home","End"].includes(l.key)||l.key.length===1&&!l.ctrlKey&&!l.metaKey)&&(t.current=null,n.current=-1),false;if(l.ctrlKey||l.metaKey)return t.current=null,n.current=-1,false;if(!e.current)return false;let u=Array.from(e.current.querySelectorAll(qf));if(u.length===0)return false;let{from:c,anchor:d}=s.state.selection;if(t.current===null){let S=o(c);if(S===null)return false;t.current=S;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let S=r(c);if(!S||(p=u.indexOf(S),p===-1))return false}let f=l.key==="ArrowUp"?p-1:p+1;if(f<0||f>=u.length)return n.current=-1,false;let m=u[f],b=i(m,t.current);if(b===null)return false;n.current=f;let{state:h,dispatch:x}=s,T=Math.max(0,Math.min(b,h.doc.content.size));try{let S=l.shiftKey?prosemirrorState.TextSelection.create(h.doc,d,T):prosemirrorState.TextSelection.create(h.doc,T);x(h.tr.setSelection(S));}catch{let S=h.doc.resolve(T),I=l.shiftKey?prosemirrorState.TextSelection.between(h.doc.resolve(d),S):prosemirrorState.TextSelection.near(S);x(h.tr.setSelection(I));}return ZS(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var mo=40,ys=12;function JS(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function Zf({pagesContainerRef:e,onScrollExtendSelection:t}){let n=gm.useRef(null),o=gm.useRef({x:0,y:0}),r=gm.useRef(false),i=gm.useRef(null),a=gm.useCallback(()=>{if(i.current)return i.current;let d=e.current;return d?(i.current=JS(d),i.current):null},[e]),s=gm.useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=gm.useCallback(()=>{if(!r.current)return;let d=a();if(!d)return;let p=d.getBoundingClientRect(),{x:f,y:m}=o.current,b=0;if(m<p.top+mo){let h=Math.max(0,p.top+mo-m);b=-Math.min(ys,h/mo*ys);}else if(m>p.bottom-mo){let h=Math.max(0,m-(p.bottom-mo));b=Math.min(ys,h/mo*ys);}b!==0&&(d.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=gm.useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:gm.useCallback((d,p)=>{if(o.current={x:d,y:p},!r.current){let f=a();if(!f)return;let m=f.getBoundingClientRect();(p<m.top+mo||p>m.bottom-mo)&&u();}},[a,u]),stopAutoScroll:s}}var QS=12,xs=8;function Jf(e){let t=[];for(let n of e)if(n.kind==="paragraph")for(let o of n.runs)o.kind==="text"&&o.footnoteRefId!=null&&t.push({footnoteId:o.footnoteRefId,pmPos:o.pmStart??0});return t}function ic(e,t){let n=new Map;if(t.length===0)return n;for(let o of t)for(let r of e){let i=false;for(let a of r.fragments){let s=a.pmStart??-1,l=a.pmEnd??-1;if(s>=0&&l>=0&&o.pmPos>=s&&o.pmPos<l){let u=n.get(r.number)??[];u.includes(o.footnoteId)||u.push(o.footnoteId),n.set(r.number,u),i=true;break}}if(i)break}return n}function ek(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let c={kind:"text",text:`${t} `,fontSize:xs,superscript:true};l.push(c);}for(let c of s.content){let d=c;if(d.type==="run"&&Array.isArray(d.content)){let p=d.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=xs);for(let m of d.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:xs});let u={kind:"paragraph",id:`fn-${e.id}-p${a}`,runs:l};o.push(u);}o.length===0&&o.push({kind:"paragraph",id:`fn-${e.id}-empty`,runs:[{kind:"text",text:"",fontSize:xs}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=In(a,n);r.push(s);}let i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {id:e.id,displayNumber:t,blocks:o,measures:r,height:i}}function Qf(e,t,n){let o=new Map,r=new Map;for(let s of e)(s.noteType==="normal"||s.noteType==null)&&r.set(s.id,s);let i=1,a=new Set;for(let s of t){if(a.has(s.footnoteId))continue;a.add(s.footnoteId);let l=r.get(s.footnoteId);if(!l)continue;let u=ek(l,i,n);o.set(s.footnoteId,u),i++;}return o}function em(e,t){let n=new Map;for(let[o,r]of e){let i=0;for(let a of r){let s=t.get(a);s&&(i+=s.height);}i>0&&(i+=QS,n.set(o,i));}return n}var ac=class{constructor(t,n=1){chunkH5NTJZO4_js.d(this,"pagesContainer");chunkH5NTJZO4_js.d(this,"zoom");this.pagesContainer=t,this.zoom=n;}getCoordinatesForPosition(t){let n=this.pagesContainer.getBoundingClientRect(),o=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(o)){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(a.classList.contains("layout-run-tab")){if(t>=s&&t<l){let u=a.getBoundingClientRect(),c=a.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,c=Math.min(t-s,u.length),d=a.ownerDocument;if(!d)continue;let p=d.createRange();p.setStart(u,c),p.setEnd(u,c);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),c=i.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let c=a.firstChild,d=s.ownerDocument;if(!d)continue;let p=Math.max(0,t-l),f=Math.min(c.length,n-l);if(p<f){let m=d.createRange();m.setStart(c,p),m.setEnd(c,f);let b=m.getClientRects();for(let h of Array.from(b))r.push({x:(h.left-o.left)/this.zoom,y:(h.top-o.top)/this.zoom,width:h.width/this.zoom,height:h.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function tm(e,t=1){return new ac(e,t)}var ik=816,rm=1056,Ss={top:96,right:96,bottom:96,left:96},ak=24,bo=30,sk=200,lk=[],ck={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},im=24,dk={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:im,paddingBottom:24},uk={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},pk={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function fk(e,t,n,o,r){let i=new Map;if(!e?.state)return i;let{doc:a,schema:s}=e.state,l=s.marks.comment,u=s.marks.insertion,c=s.marks.deletion;if(!l&&!u&&!c)return i;let d=new Set,p=im+r;return a.descendants((f,m)=>{if(f.isText)for(let b of f.marks){let h=null;if(l&&b.type===l?h=`comment-${b.attrs.commentId}`:(u&&b.type===u||c&&b.type===c)&&(h=`revision-${b.attrs.revisionId}`),!h||d.has(h))continue;d.add(h);let x=chunkEV3CM6TU_js.q(t,n,o,m);if(x){i.set(h,x.y+p);continue}for(let T=0;T<t.pages.length;T++){let S=t.pages[T],I=false;for(let R of S.fragments){let D=R.pmStart??0,L=R.pmEnd??D;if(m<D||m>L)continue;let pe=R.kind==="table"?mk(n,o,R,m):0;i.set(h,R.y+pe+chunkEV3CM6TU_js.m(t,T)+p),I=true;break}if(I)break}}}),i}function mk(e,t,n,o){let r=e.findIndex(l=>l.id===n.blockId);if(r===-1)return 0;let i=e[r],a=t[r];if(i.kind!=="table"||a.kind!=="table")return 0;let s=0;for(let l=n.fromRow;l<n.toRow;l++){let u=i.rows[l];if(!u||u.cells.some(d=>d.blocks.some(p=>{let f=p.pmStart??0,m=p.pmEnd??f;return o>=f&&o<=m})))break;s+=a.rows[l]?.height??0;}return s}function Zt(e){return Math.round(e/1440*96)}function gk(e){return {w:e?.pageWidth?Zt(e.pageWidth):ik,h:e?.pageHeight?Zt(e.pageHeight):rm}}function hk(e){let t=e?.marginTop?Zt(e.marginTop):Ss.top,n=e?.marginBottom?Zt(e.marginBottom):Ss.bottom;return {top:t,right:e?.marginRight?Zt(e.marginRight):Ss.right,bottom:n,left:e?.marginLeft?Zt(e.marginLeft):Ss.left,header:e?.headerDistance?Zt(e.headerDistance):48,footer:e?.footerDistance?Zt(e.footerDistance):48}}function bk(e){let t=e?.columnCount??1;if(t<=1)return;let n=Zt(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function yk(e,t,n){function o(l,u){return u.count<=1?l:Math.floor((l-(u.count-1)*u.gap)/u.count)}let r=[],i=[];for(let l=0;l<e.length;l++)if(e[l].kind==="sectionBreak"){r.push(l);let u=e[l];i.push(u.columns??{count:1,gap:0});}i.push(n??{count:1,gap:0});let a=0,s=[];for(let l=0;l<e.length;l++){let u=i[a];s.push(o(t,u)),a<r.length&&l===r[a]&&a++;}return s}function xk(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function sc(e){return e===void 0?0:Math.round(e*96/914400)}function Sk(e,t,n){if(e){if(t==="pct")return n*e/5e3;if(t==="dxa"||!t||t==="auto")return Math.round(e/20*1.333)}}function am(e,t){let r=e.columnWidths??[],i=Sk(e.width,e.widthType,t);if(r.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((f,m)=>f+(m.colSpan??1),0),p=(i??t)/Math.max(1,c);r=Array(c).fill(p);}else if(r.length>0&&i){let c=r.reduce((d,p)=>d+p,0);if(c>0&&Math.abs(c-i)>1){let d=i/c;r=r.map(p=>p*d);}}let a=new Map;for(let c=0;c<e.rows.length;c++){let d=e.rows[c];if(!d)continue;let p=0,f=a.get(c)??new Set;for(;f.has(p);)p++;for(let m of d.cells){let b=m.colSpan??1,h=m.rowSpan??1;if(h>1)for(let x=c+1;x<c+h;x++){a.has(x)||a.set(x,new Set);let T=a.get(x);for(let S=0;S<b;S++)T.add(p+S);}for(p+=b;f.has(p);)p++;}}let s=e.rows.map((c,d)=>{let p=0,f=a.get(d)??new Set;for(;f.has(p);)p++;return {cells:c.cells.map(m=>{let b=m.colSpan??1,h=0;for(let I=0;I<b&&p+I<r.length;I++)h+=r[p+I]??0;for(h===0&&(h=m.width??100),p+=b;f.has(p);)p++;let x=m.padding?.left??7,T=m.padding?.right??7,S=Math.max(1,h-x-T);return {blocks:m.blocks.map(I=>sm(I,S)),width:h,height:0,colSpan:m.colSpan,rowSpan:m.rowSpan}}),height:0}});for(let c=0;c<s.length;c++){let d=s[c],p=e.rows[c]?.cells,f=0;for(let x=0;x<d.cells.length;x++){let T=d.cells[x],S=p?.[x];T.height=T.blocks.reduce((D,L)=>"totalHeight"in L?D+L.totalHeight:D,0);let I=S?.padding?.top??0,R=S?.padding?.bottom??0;T.height+=I+R,f=Math.max(f,T.height);}let m=e.rows[c],b=m?.height,h=m?.heightRule;b&&h==="exact"?d.height=b:b?d.height=Math.max(f,b):d.height=f;}let l=s.reduce((c,d)=>c+d.height,0),u=r.reduce((c,d)=>c+d,0)||i||t;return {kind:"table",rows:s,columnWidths:r,totalWidth:u,totalHeight:l}}function kk(e,t){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="paragraph")continue;let i=r;for(let a of i.runs){if(a.kind!=="image")continue;let s=a;if(!xk(s))continue;let l=0,u=s.position,c=s.distTop??0,d=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let x=u.vertical;x.align==="top"&&x.relativeTo==="margin"?l=0:x.posOffset!==void 0&&(l=sc(x.posOffset));}let m=l+s.height,b=0,h=0;if(u?.horizontal){let x=u.horizontal;if(x.align==="left")b=s.width+f;else if(x.align==="right")h=s.width+p;else if(x.posOffset!==void 0){let T=sc(x.posOffset);T<t/2?b=T+s.width+f:h=t-T+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(h=s.width+p);if(b>0||h>0){let x=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:h,topY:l-c,bottomY:m+d,anchorBlockIndex:o,isMarginRelative:x});}}}for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="table")continue;let i=r,a=i.floating;if(!a)continue;let s=am(i,t),l=s.totalWidth,u=s.totalHeight,c=a.leftFromText??12,d=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,h=0;a.tblpX!==void 0?h=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?h=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?h=t-l:a.tblpXSpec==="center"&&(h=(t-l)/2):i.justification==="center"?h=(t-l)/2:i.justification==="right"&&(h=t-l),h<t/2?m=h+l+d:b=t-h+c;let x=a.tblpY??0,T=x+u;n.push({leftMargin:m,rightMargin:b,topY:x-p,bottomY:T+f,anchorBlockIndex:o});}return n}function sm(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=jl(r,t);if(a)return a}let i=In(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&Kl(r,t,i),i}case "table":return am(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "textBox":{let r=e,i=r.margins??chunkEV3CM6TU_js.c,a=(r.width??chunkEV3CM6TU_js.d)-i.left-i.right,s=r.content.map(c=>In(c,a)),l=s.reduce((c,d)=>c+d.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??chunkEV3CM6TU_js.d,height:u,innerMeasures:s}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function lm(e,t){let n=Array.isArray(t)?t[0]??0:t,o=kk(e,n),r=o.filter(p=>p.isMarginRelative),i=o.filter(p=>!p.isMarginRelative),a=new Map;for(let p of r){let f=a.get(p.topY)??[];f.push(p),a.set(p.topY,f);}let s=[...i];for(let p of a.values()){let f=Math.min(...p.map(m=>m.anchorBlockIndex));for(let m of p)s.push({...m,anchorBlockIndex:f});}let l=new Map;for(let p of s){let f=l.get(p.anchorBlockIndex)??[];f.push({leftMargin:p.leftMargin,rightMargin:p.rightMargin,topY:p.topY,bottomY:p.bottomY}),l.set(p.anchorBlockIndex,f);}let u=new Set(s.map(p=>p.anchorBlockIndex)),c=0,d=[];return e.map((p,f)=>{u.has(f)&&(c=0,d=l.get(f)??[]);let m=d.length>0?d:void 0;try{let b=performance.now(),h=Array.isArray(t)?t[f]??n:t,x=sm(p,h,m,c),T=performance.now()-b;return T>500&&console.warn(`[measureBlocks] Block ${f} (${p.kind}) took ${Math.round(T)}ms`),"totalHeight"in x&&(p.kind==="table"&&p.floating||(c+=x.totalHeight)),x}catch(b){return console.error(`[measureBlocks] Error measuring block ${f} (${p.kind}):`,b),{totalHeight:20}}})}function Cs(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,c=m=>Math.round(m/914400*96),d=u?.width?c(u.width):100,p=u?.height?c(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:d,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.content)){let a=Cs(o.content);t.push(...a);}continue}if(o.type==="complexField"){let r=o.fieldType,i={};if(Array.isArray(o.fieldResult)&&o.fieldResult.length>0){let a=o.fieldResult[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.fieldResult)){let a=Cs(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=Cs(o.children);t.push(...r);}}return t}function Ck(e){return e?.align??e?.alignment}function Tk(e,t,n,o){let r=o.section==="header"?o.margins.header??48:o.pageSize.h-(o.margins.footer??48)-n,i=e.position?.vertical;if(!i)return t;let a=Ck(i),s=i.posOffset!==void 0?sc(i.posOffset):void 0;if(i.relativeTo==="page"){if(s!==void 0)return s-r;if(a==="top")return -r;if(a==="bottom")return o.pageSize.h-e.height-r;if(a==="center")return (o.pageSize.h-e.height)/2-r}if(i.relativeTo==="margin"){let l=o.margins.top,u=o.pageSize.h-o.margins.top-o.margins.bottom;if(s!==void 0)return l+s-r;if(a==="top")return l-r;if(a==="bottom")return l+u-e.height-r;if(a==="center")return l+(u-e.height)/2-r}return s!==void 0?t+s:t}function wk(e,t,n,o){let r=0,i=n,a=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s];if(l?.kind!=="paragraph"||u?.kind!=="paragraph")continue;let c=l,d=a,p=d+u.totalHeight;r=Math.min(r,d),i=Math.max(i,p);for(let f of c.runs){if(f.kind!=="image"||!f.position)continue;let m=f,b=Tk(m,d,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function ks(e,t,n){if(!e||!e.content||e.content.length===0)return;let o=[];for(let u of e.content){let c=u;if(c.type==="paragraph"&&Array.isArray(c.content)){let d=c.formatting,p={};if(d){if(d.alignment){let b=d.alignment;b==="both"?p.alignment="justify":["left","center","right","justify"].includes(b)&&(p.alignment=b);}if(d.borders){let b=d.borders,h={};for(let x of ["top","bottom","left","right","between"]){let T=b[x];if(T){let S=ns(T);S&&(h[x]=S);}}Object.keys(h).length>0&&(p.borders=h);}if(d.lineSpacing!=null){let b={},h=d.lineSpacingRule;h==="exact"||h==="atLeast"?(b.line=Zt(d.lineSpacing),b.lineUnit="px",b.lineRule=h):(b.line=d.lineSpacing/240,b.lineUnit="multiplier",b.lineRule="auto"),p.spacing=b;}Array.isArray(d.tabs)&&d.tabs.length>0&&(p.tabs=d.tabs.map(b=>({val:b.alignment==="left"?"start":b.alignment==="right"?"end":b.alignment,pos:Zt(b.position),leader:b.leader})));}let f=Cs(c.content);f.length===0&&f.push({kind:"text",text:""});let m={kind:"paragraph",id:String(o.length),runs:f,attrs:Object.keys(p).length>0?p:void 0};o.push(m);}}if(o.length===0)return;let r=o.map(u=>{if(u.kind!=="paragraph")return u;let c=u;if(!c.runs.some(f=>f.kind==="image"&&"position"in f&&f.position))return u;let p=c.runs.filter(f=>!(f.kind==="image"&&"position"in f&&f.position));return p.length===0&&p.push({kind:"text",text:""}),{...c,runs:p}}),i=lm(r,t),a=i.reduce((u,c)=>c.kind==="paragraph"?u+c.totalHeight:u,0),{visualTop:s,visualBottom:l}=wk(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function vk(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let d=t.get(l)?.displayNumber??0,p=chunkKUL2SDYC_js.b(u);s.push({displayNumber:String(d),text:p});}s.length>0&&o.set(i,s);}return o}var Rk=gm.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,firstPageHeaderContent:u,firstPageFooterContent:c,readOnly:d=false,pageGap:p=ak,zoom:f=1,onDocumentChange:m,onSelectionChange:b,externalPlugins:h=lk,extensionManager:x,onReady:T,onRenderedDomContextReady:S,pluginOverlays:I,onHeaderFooterDoubleClick:R,hfEditMode:D,onBodyClick:L,className:pe,style:$,commentsSidebarOpen:v=false,sidebarOverlay:_,scrollContainerRef:re,onHyperlinkClick:ae,onContextMenu:N,onAnchorPositionsChange:B,resolvedCommentIds:de}=t,ge=gm.useCallback(()=>re&&typeof re=="object"?re.current:Pe.current,[re]),Pe=gm.useRef(null),se=gm.useRef(null),q=gm.useRef(null),E=gm.useRef(null),{handlePMKeyDown:F}=Xf({pagesContainerRef:se}),k=gm.useRef(()=>{}),P=gm.useRef(b),M=gm.useRef(m),H=gm.useRef(T),oe=gm.useRef(S);P.current=b,M.current=m,H.current=T,oe.current=S;let[Q,V]=gm.useState(null),[Y,ne]=gm.useState([]),[Se,Me]=gm.useState([]),[Z,ie]=gm.useState(false),[Ie,He]=gm.useState([]),[qe,je]=gm.useState(null),[Xe,_e]=gm.useState(null),we=gm.useRef(false),xt=gm.useCallback((C,O)=>{let K=C.tagName==="IMG"?C:C.querySelector("img"),G=(K??C).getBoundingClientRect();return {element:K??C,pmPos:O,width:Math.round(G.width/f),height:Math.round(G.height/f)}},[f]),Le=gm.useRef(false),ze=gm.useRef(null),lt=gm.useRef(false),nt=gm.useRef(0),ft=gm.useRef(0),Rt=gm.useRef(0),Ne=gm.useRef({left:0,right:0}),mt=gm.useRef(null),Oe=gm.useRef(false),St=gm.useRef(0),Jt=gm.useRef(0),Gt=gm.useRef(0),jn=gm.useRef(0),dt=gm.useRef(null),Qt=gm.useRef(false),gn=gm.useRef(false),So=gm.useRef(0),gr=gm.useRef(0),No=gm.useRef(0),an=gm.useRef(0),Yt=gm.useRef(null),en=gm.useRef(false),Dt=gm.useRef(null),ko=gm.useRef(null),Ht=gm.useRef(null),Rs=5,[hn,It]=gm.useState(null),bn=gm.useRef(null),gt=gm.useCallback(()=>{bn.current&&(clearTimeout(bn.current),bn.current=null);},[]);gm.useEffect(()=>()=>{bn.current&&clearTimeout(bn.current);},[]);let Nt=gm.useMemo(()=>new ms,[]),Ft=gm.useMemo(()=>gk(a),[a]),ot=gm.useMemo(()=>hk(a),[a]),Kn=gm.useMemo(()=>bk(a),[a]),Et=Ft.w-ot.left-ot.right,yn=gm.useMemo(()=>new fs({pageGap:p,showShadow:true,pageBackground:"#fff"}),[p]);E.current=yn;let zt=gm.useCallback(C=>{let O=performance.now(),K=Nt.getStateSeq();Nt.onLayoutStart();try{let G=performance.now(),ee=Ft.h-ot.top-ot.bottom,W=Sf(C.doc,{theme:i,pageContentHeight:ee}),J=performance.now()-G;J>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(J)}ms (${W.length} blocks)`),ne(W),G=performance.now();let te=yk(W,Et,Kn),le=lm(W,te);J=performance.now()-G,J>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(J)}ms (${W.length} blocks)`),Me(le);let xe=Jf(W),ye=xe.length>0&&o?.package?.footnotes,Re={section:"header",pageSize:Ft,margins:ot},ke={section:"footer",pageSize:Ft,margins:ot},he=ks(s,Et,Re),Be=ks(l,Et,ke),$e=a?.titlePg===!0,ut=$e?ks(u,Et,Re):void 0,ht=$e?ks(c,Et,ke):void 0,ln=ot.header??48,$o=ot.footer??48,pi=ot.top-ln,fi=ot.bottom-$o,mi=kt=>kt?kt.visualBottom??kt.height:0,gi=kt=>kt?Math.max((kt.visualBottom??kt.height)-(kt.visualTop??0),kt.height):0,Cr=Math.max(mi(he),mi(ut)),Tr=Math.max(gi(Be),gi(ht)),_o=ot;(Cr>pi||Tr>fi)&&(_o={...ot},Cr>pi&&(_o.top=Math.max(ot.top,ln+Cr)),Tr>fi&&(_o.bottom=Math.max(ot.bottom,$o+Tr))),G=performance.now();let cn,wo=new Map,wr=new Map,Is=a?.sectionStart,vr={pageSize:Ft,margins:_o,columns:Kn,bodyBreakType:Is,pageGap:p};if(ye){let kt=chunkEV3CM6TU_js.e(W,le,vr);wo=ic(kt.pages,xe),wr=Qf(o.package.footnotes,xe,Et);let Xn=em(wo,wr);if(Xn.size>0){cn=chunkEV3CM6TU_js.e(W,le,{...vr,footnoteReservedHeights:Xn}),wo=ic(cn.pages,xe);for(let[xn,vo]of wo){let Ro=cn.pages.find(Fs=>Fs.number===xn);Ro&&(Ro.footnoteIds=vo);}}else cn=kt;}else cn=chunkEV3CM6TU_js.e(W,le,vr);if(J=performance.now()-G,J>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(J)}ms (${cn.pages.length} pages)`),V(cn),se.current&&E.current){G=performance.now();let kt=new Map;for(let xn=0;xn<W.length;xn++){let vo=W[xn],Ro=le[xn];vo&&Ro&&kt.set(String(vo.id),{block:vo,measure:Ro});}E.current.setBlockLookup(kt);let Xn=ye?vk(wo,wr,o):void 0;if(Kf(cn.pages,se.current,{pageGap:p,showShadow:!0,pageBackground:"#fff",blockLookup:kt,headerContent:he,footerContent:Be,firstPageHeaderContent:ut,firstPageFooterContent:ht,titlePg:$e,headerDistance:a?.headerDistance?Zt(a.headerDistance):void 0,footerDistance:a?.footerDistance?Zt(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:Xn?.size?Xn:void 0,resolvedCommentIds:de}),J=performance.now()-G,J>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(J)}ms`),S){let xn=tm(se.current,f);S(xn);}}if(B){let kt=fk(q.current?.getView()??null,cn,W,le,p);B(kt);}let hi=performance.now()-O;hi>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(hi)}ms total (${W.length} blocks, ${le.length} measures)`);}catch(G){console.error("[PagedEditor] Layout pipeline error:",G);}Nt.onLayoutComplete(K);},[Et,Kn,Ft,ot,p,f,Nt,s,l,u,c,a,S,o,de]),sn=gm.useRef(null),hr=gm.useCallback(C=>{if(sn.current){sn.current.state=C;return}let O=requestAnimationFrame(()=>{let K=sn.current;sn.current=null,K&&zt(K.state);});sn.current={rafId:O,state:C};},[zt]);gm.useEffect(()=>()=>{sn.current&&(cancelAnimationFrame(sn.current.rafId),sn.current=null);},[]);let Bn=gm.useCallback((C,O=1)=>{if(!se.current)return null;let K=se.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!K)return null;let G=K.getBoundingClientRect(),ee=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let J of Array.from(ee)){let te=J,le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(te.classList.contains("layout-run-tab")){if(C>=le&&C<xe){let ye=te.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=te.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}continue}if(C>=le&&C<=xe&&J.firstChild?.nodeType===Node.TEXT_NODE){let ye=J.firstChild,Re=Math.min(C-le,ye.length),ke=te.ownerDocument;if(!ke)continue;let he=ke.createRange();he.setStart(ye,Re),he.setEnd(ye,Re);let Be=he.getBoundingClientRect(),$e=te.closest(".layout-page"),ut=$e?Number($e.dataset.pageNumber)-1:0,ht=te.closest(".layout-line"),ln=ht?ht.offsetHeight:16;return {x:(Be.left-G.left)/O,y:(Be.top-G.top)/O,height:ln,pageIndex:ut}}}let W=se.current.querySelectorAll(".layout-empty-run");for(let J of Array.from(W)){let te=J.closest(".layout-paragraph");if(!te)continue;let le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(C>=le&&C<=xe){let ye=J.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=J.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}}return null},[]),Ot=gm.useCallback(C=>{let{from:O,to:K}=C.selection;if(P.current?.(O,K),se.current){let G=se.current.querySelectorAll(".layout-table-cell-selected");for(let J of Array.from(G))J.classList.remove("layout-table-cell-selected");let ee=C.selection;if("$anchorCell"in ee&&typeof ee.forEachCell=="function"){let J=[];ee.forEachCell((le,xe)=>{J.push([xe,xe+le.nodeSize]);});let te=se.current.querySelectorAll(".layout-table-cell");for(let le of Array.from(te)){let xe=le,ye=xe.dataset.pmStart;if(ye!==void 0){let Re=Number(ye);for(let[ke,he]of J)if(Re>=ke&&Re<he){xe.classList.add("layout-table-cell-selected");break}}}}}if(!(!Q||Y.length===0))if(O===K){let G=Bn(O,f);if(G)je(G);else {let ee=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),W=se.current?.querySelector(".layout-page");if(ee&&W){let J=ee.getBoundingClientRect(),te=W.getBoundingClientRect(),le=chunkEV3CM6TU_js.q(Q,Y,Se,O);je(le?{...le,x:le.x+(te.left-J.left)/f,y:le.y+(te.top-J.top)/f}:null);}else je(null);}He([]);}else {let G=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(G&&se.current){let ee=G.getBoundingClientRect(),W=[],J=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let te of Array.from(J)){let le=te,xe=Number(le.dataset.pmStart);if(Number(le.dataset.pmEnd)>O&&xe<K){if(le.classList.contains("layout-run-tab")){let $e=le.getBoundingClientRect(),ut=le.closest(".layout-page"),ht=ut?Number(ut.dataset.pageNumber)-1:0;W.push({x:($e.left-ee.left)/f,y:($e.top-ee.top)/f,width:$e.width/f,height:$e.height/f,pageIndex:ht});continue}let Re=null;if(te.firstChild?.nodeType===Node.TEXT_NODE?Re=te.firstChild:te.firstChild?.nodeType===Node.ELEMENT_NODE&&te.firstChild.tagName==="A"&&te.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(Re=te.firstChild.firstChild),!Re)continue;let ke=le.ownerDocument;if(!ke)continue;let he=Math.max(0,O-xe),Be=Math.min(Re.length,K-xe);if(he<Be){let $e=ke.createRange();$e.setStart(Re,he),$e.setEnd(Re,Be);let ut=$e.getClientRects();for(let ht of Array.from(ut)){let ln=le.closest(".layout-page"),$o=ln?Number(ln.dataset.pageNumber)-1:0;W.push({x:(ht.left-ee.left)/f,y:(ht.top-ee.top)/f,width:ht.width/f,height:ht.height/f,pageIndex:$o});}}}}if(W.length>0)He(W);else {let te=se.current.querySelector(".layout-page");if(te){let le=te.getBoundingClientRect(),xe=(le.left-ee.left)/f,ye=(le.top-ee.top)/f,ke=chunkEV3CM6TU_js.p(Q,Y,Se,O,K).map(he=>({...he,x:he.x+xe,y:he.y+ye}));He(ke);}else He([]);}}else He([]);je(null);}},[Q,Y,Se,Bn,f]),ue=gm.useCallback((C,O)=>{if(C.docChanged){Nt.incrementStateSeq(),hr(O);let K=q.current?.getDocument();K&&M.current?.(K);}Nt.requestRender(),C.docChanged||Ot(O);},[hr,Ot,Nt]),br=gm.useCallback(C=>{let{selection:O}=C;O instanceof prosemirrorState.NodeSelection&&O.node.type.name==="image"?(He([]),je(null)):Nt.isSafeToRender()&&Ot(C),requestAnimationFrame(()=>{let K=q.current?.getView();if(!K){_e(null);return}let{selection:G}=K.state;if(G instanceof prosemirrorState.NodeSelection&&G.node.type.name==="image"){let ee=G.from,W=se.current?.querySelector(`[data-pm-start="${ee}"]`);if(W){_e(xt(W,ee));return}}we.current||_e(null);});},[Ot,f,xt,Nt]),$t=gm.useCallback((C,O)=>{if(!se.current||!Q)return null;let K=Ff(se.current,C,O,f);if(K!==null)return K;let G=se.current.querySelectorAll(".layout-page"),ee=-1,W=null;for(let Re=0;Re<G.length;Re++){let he=G[Re].getBoundingClientRect();if(C>=he.left&&C<=he.right&&O>=he.top&&O<=he.bottom){ee=Re,W=he;break}}if(ee<0||!W)return null;let J=(C-W.left)/f,te=(O-W.top)/f,le=Q.pages[ee];if(!le)return null;let xe={pageIndex:ee,page:le,pageY:te},ye=chunkEV3CM6TU_js.n(xe,Y,Se,{x:J,y:te});if(!ye)return null;if(ye.fragment.kind==="table"){let Re=chunkEV3CM6TU_js.o(xe,Y,Se,{x:J,y:te});return Yl(ye,Re)}return Yl(ye)},[Q,Y,Se,f]),An=gm.useCallback(C=>{let O=q.current?.getView();if(!O)return null;try{let K=O.state.doc.resolve(C);for(let G=K.depth;G>0;G--){let ee=K.node(G);if(ee.type.name==="tableCell"||ee.type.name==="tableHeader")return K.before(G)}}catch{}return null},[]),Es=gm.useCallback(C=>{let O=["layout-block-image","layout-image","layout-page-floating-image"],K=G=>!!G.dataset.pmStart&&O.some(ee=>G.classList.contains(ee));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&K(C.parentElement)?C.parentElement:K(C)?C:null},[]),We=gm.useCallback(C=>{let O=se.current;if(!O)return;let K=O.querySelector(`[data-pm-start="${C}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"center"});},[]),tn=gm.useCallback(C=>{if(!q.current)return;if(C.button===2){C.preventDefault();return}if(C.button!==0||(It(null),gt(),C.target.closest("a[href]")&&C.preventDefault(),d))return;if(D&&L){let W=C.target;if(!(W.closest(".layout-page-header")||W.closest(".layout-page-footer")||W.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),L();return}}if(!D){let W=C.target;if(W.closest(".layout-page-header")||W.closest(".layout-page-footer")){C.preventDefault(),q.current&&(q.current.setSelection(0),q.current.focus(),ie(true));return}}let K=C.target;if(K.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),lt.current=true,nt.current=C.clientX,mt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);ft.current=W,Rt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(Rt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&ye[W+1]!==void 0&&(Ne.current={left:ye[W],right:ye[W+1]});break}}}return}if(K.classList.contains("layout-table-row-resize-handle")||K.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),Oe.current=true,St.current=C.clientY,dt.current=K,Qt.current=K.dataset.isEdge==="bottom",K.classList.add("dragging");let W=parseInt(K.dataset.rowIndex??"0",10);Jt.current=W,Gt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(Gt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=null,Re=0;if(xe.forEach(ke=>{Re===W&&(ye=ke),Re++;}),ye){let ke=ye.attrs.height;if(ke)jn.current=ke;else {let Be=K.closest(".layout-table")?.querySelector(`[data-row-index="${W}"]`),$e=Be?Be.getBoundingClientRect().height:30;jn.current=Math.round($e*15);}}break}}}return}if(K.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),gn.current=true,So.current=C.clientX,Yt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);gr.current=W,No.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(No.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&(an.current=ye[W]);break}}}return}let G=Es(K);if(G){C.preventDefault(),C.stopPropagation();let W=G.dataset.pmStart;if(W!==void 0){let J=parseInt(W,10);q.current.setNodeSelection(J),_e(xt(G,J)),He([]),je(null);}q.current.focus(),ie(true);return}_e(null),C.preventDefault();let ee=$t(C.clientX,C.clientY);if(ee!==null){let W=An(ee);Dt.current=W,en.current=false,ko.current=null,Ht.current=null,Le.current=true,ze.current=ee,q.current.setSelection(ee);}else {Dt.current=null,en.current=false;let W=q.current.getView();if(W){let J=Math.max(0,W.state.doc.content.size-1);q.current.setSelection(J),ze.current=J,Le.current=true;}}q.current.focus(),ie(true);},[$t,An,d,D,L,f,ae,gt]),Gn=gm.useCallback((C,O)=>{k.current(C,O);},[]),{updateMousePosition:nn,stopAutoScroll:yr}=Zf({pagesContainerRef:se,onScrollExtendSelection:Gn});k.current=(C,O)=>{if(!Le.current||ze.current===null||!q.current)return;let K=$t(C,O);K!==null&&q.current.setSelection(ze.current,K);};let zo=gm.useCallback(C=>{if(lt.current){C.preventDefault();let G=C.clientX-nt.current;if(mt.current){let ee=parseFloat(mt.current.style.left);mt.current.style.left=`${ee+G}px`,nt.current=C.clientX;let W=Math.round(G*15),J=300,te=Ne.current.left+W,le=Ne.current.right-W;te>=J&&le>=J&&(Ne.current={left:te,right:le});}return}if(Oe.current){C.preventDefault();let G=C.clientY-St.current;if(dt.current){let ee=parseFloat(dt.current.style.top);dt.current.style.top=`${ee+G}px`,St.current=C.clientY;let W=Math.round(G*15),J=200,te=jn.current+W;te>=J&&(jn.current=te);}return}if(gn.current){C.preventDefault();let G=C.clientX-So.current;if(Yt.current){let ee=parseFloat(Yt.current.style.left);Yt.current.style.left=`${ee+G}px`,So.current=C.clientX;let W=Math.round(G*15),J=300,te=an.current+W;te>=J&&(an.current=te);}return}if(!Le.current||ze.current===null||!q.current||!se.current)return;nn(C.clientX,C.clientY);let O=$t(C.clientX,C.clientY);if(O===null)return;if(Dt.current!==null){if(en.current){let ee=An(O);if(ee!==null){q.current.setCellSelection(Dt.current,ee);return}}let G=An(O);if(G!==null&&G!==Dt.current){en.current=true,q.current.setCellSelection(Dt.current,G),Ht.current=null;return}if(ko.current!==null&&O===ko.current){if(Ht.current===null)Ht.current=C.clientX;else if(Math.abs(C.clientX-Ht.current)>=Rs){en.current=true,q.current.setCellSelection(Dt.current,Dt.current),Ht.current=null;return}}else Ht.current=null,ko.current=O;}let K=ze.current;q.current.setSelection(K,O);},[$t,An,nn]),Yn=gm.useCallback(()=>{if(lt.current){lt.current=false,mt.current&&(mt.current.classList.remove("dragging"),mt.current=null);let C=q.current?.getView();if(C){let O=Rt.current,K=ft.current,{left:G,right:ee}=Ne.current,W=C.state.doc.resolve(O+1);for(let J=W.depth;J>=0;J--){let te=W.node(J);if(te.type.name==="table"){let le=W.before(J),xe=C.state.tr,ye=[...te.attrs.columnWidths];ye[K]=G,ye[K+1]=ee,xe.setNodeMarkup(le,void 0,{...te.attrs,columnWidths:ye});let Re=le+1;te.forEach(ke=>{let he=Re+1,Be=0;ke.forEach($e=>{let ut=$e.attrs.colspan||1;if(Be===K||Be===K+1){let ht=Be===K?G:ee;xe.setNodeMarkup(xe.mapping.map(he),void 0,{...$e.attrs,width:ht,widthType:"dxa",colwidth:null});}he+=$e.nodeSize,Be+=ut;}),Re+=ke.nodeSize;}),C.dispatch(xe);break}}}return}if(Oe.current){Oe.current=false,dt.current&&(dt.current.classList.remove("dragging"),dt.current=null);let C=q.current?.getView();if(C){let O=Gt.current,K=Jt.current,G=jn.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=te+1,ye=0;J.forEach(Re=>{ye===K&&le.setNodeMarkup(le.mapping.map(xe),void 0,{...Re.attrs,height:G,heightRule:"atLeast"}),xe+=Re.nodeSize,ye++;}),C.dispatch(le);break}}}return}if(gn.current){gn.current=false,Yt.current&&(Yt.current.classList.remove("dragging"),Yt.current=null);let C=q.current?.getView();if(C){let O=No.current,K=gr.current,G=an.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=[...J.attrs.columnWidths];xe[K]=G,le.setNodeMarkup(te,void 0,{...J.attrs,columnWidths:xe});let ye=te+1;J.forEach(Re=>{let ke=ye+1,he=0;Re.forEach(Be=>{let $e=Be.attrs.colspan||1;he===K&&le.setNodeMarkup(le.mapping.map(ke),void 0,{...Be.attrs,width:G,widthType:"dxa",colwidth:null}),ke+=Be.nodeSize,he+=$e;}),ye+=Re.nodeSize;}),C.dispatch(le);break}}}return}Le.current=false,en.current=false,ko.current=null,Ht.current=null,yr();},[yr]);gm.useEffect(()=>(window.addEventListener("mousemove",zo),window.addEventListener("mouseup",Yn),()=>{window.removeEventListener("mousemove",zo),window.removeEventListener("mouseup",Yn);}),[zo,Yn]);let qn=gm.useCallback(C=>{if(d||Le.current||lt.current||Oe.current||gn.current||en.current)return;let O=se.current;if(!O)return;let K=C.clientX,G=C.clientY,ee=C.target.closest(".layout-table");if(!ee){let ke=O.querySelectorAll(".layout-table");for(let he of Array.from(ke)){let Be=he.getBoundingClientRect(),$e=K>=Be.left-bo&&K<Be.left,ut=G>=Be.top-bo&&G<Be.top,ht=K>=Be.left-bo&&K<=Be.right,ln=G>=Be.top-bo&&G<=Be.bottom;if($e&&ln||ut&&ht){ee=he;break}}}if(!ee){It(null);return}let W=ee.getBoundingClientRect(),J=K<W.left+bo&&K>=W.left-bo,te=G<W.top+bo&&G>=W.top-bo;if(!J&&!te){It(null);return}let le=ee.querySelectorAll(":scope > .layout-table-row");if(le.length===0){It(null);return}let xe=O.parentElement;if(!xe)return;let ye=xe.getBoundingClientRect(),Re=ke=>ke&&Number(ke.dataset.pmStart)||0;if(J)for(let ke=0;ke<le.length;ke++){let he=le[ke].getBoundingClientRect();if(G>=he.top&&G<=he.bottom){let Be=le[ke].querySelector(".layout-table-cell"),$e=Re(Be);if(!$e)break;let ut=he.top+he.height/2;It({type:"row",x:W.left-ye.left-24,y:ut-ye.top-10,cellPmPos:$e}),gt();return}}if(te){let ke=le[0].querySelectorAll(":scope > .layout-table-cell");for(let he=0;he<ke.length;he++){let Be=ke[he].getBoundingClientRect();if(K>=Be.left&&K<=Be.right){let $e=Re(ke[he]);if(!$e)break;let ut=Be.left+Be.width/2;It({type:"column",x:ut-ye.left-10,y:W.top-ye.top-24,cellPmPos:$e}),gt();return}}}bn.current||(bn.current=setTimeout(()=>{It(null),bn.current=null;},sk));},[d,gt]),Ps=gm.useCallback(C=>{if(C.preventDefault(),C.stopPropagation(),!hn||!q.current)return;let O=q.current.getView();if(!O)return;let{type:K,cellPmPos:G}=hn,ee=O.state.tr.setSelection(prosemirrorState.TextSelection.create(O.state.doc,G+1));O.dispatch(ee),K==="row"?Io(O.state,O.dispatch):Fo(O.state,O.dispatch),It(null),q.current.focus();},[hn]),Co=gm.useCallback(C=>{let O=C.target.closest("a[href]");if(O){C.preventDefault();let K=O.getAttribute("href")||"";if(K.startsWith("#")){let G=K.substring(1);if(G&&q.current){let ee=q.current.getView();if(ee){let W=null;ee.state.doc.descendants((J,te)=>{if(W!==null)return false;if(J.type.name==="paragraph"&&J.attrs.bookmarks?.some(xe=>xe.name===G))return W=te,false}),W!==null&&(We(W),q.current.setSelection(W+1));}}}else if(ae){let G=q.current?.getView();if(!(G&&G.state.selection.from!==G.state.selection.to)){let W=O.textContent||"",J=O.getAttribute("title")||void 0,te=O.getBoundingClientRect();ae({href:K,displayText:W,tooltip:J,anchorRect:te});}}return}if(C.detail===2&&R){let K=C.target,G=K.closest(".layout-page-header"),ee=K.closest(".layout-page-footer");if(G||ee){let W=K.closest("[data-page-number]"),J=W?Number(W.dataset.pageNumber):1;if(G){C.preventDefault(),C.stopPropagation(),R("header",J);return}if(ee){C.preventDefault(),C.stopPropagation(),R("footer",J);return}}}if(C.detail===2&&q.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=An(K);if(G!==null){C.preventDefault(),C.stopPropagation(),q.current.setCellSelection(G,G);return}let ee=q.current.getView();if(ee){let{doc:W}=ee.state,J=W.resolve(K),te=J.parent;if(te.isTextblock){let le=te.textContent,xe=J.parentOffset,[ye,Re]=Nn(le,xe),ke=J.start()+ye,he=J.start()+Re;ke<he&&q.current.setSelection(ke,he);}}}}if(C.detail===3&&q.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=q.current.getView();if(G){let{doc:ee}=G.state,W=ee.resolve(K),J=W.start(W.depth),te=W.end(W.depth);q.current.setSelection(J,te);}}}},[$t,R,ae]),li=gm.useCallback(C=>{if(!N)return;C.preventDefault();let O=q.current?.getView();if(!O)return;let{from:K,to:G}=O.state.selection,ee=$t(C.clientX,C.clientY);ee!==null&&(K===G||ee<K||ee>G)&&(q.current?.setSelection(ee),q.current?.focus(),ie(true));let W=q.current?.getState(),J=W?W.selection.from!==W.selection.to:false;N({x:C.clientX,y:C.clientY,hasSelection:J});},[N,$t]),xr=gm.useCallback(C=>{if(d)return;let O=C.target;O.closest(".docx-comments-sidebar")||O.closest(".docx-unified-sidebar")||(q.current?.focus(),ie(true));},[d]),Oo=gm.useCallback(C=>{let O=C.relatedTarget;O&&Pe.current?.contains(O)||O?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||ie(false);},[]),Lt=gm.useCallback((C,O,K)=>{let G=q.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;let W=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,width:O,height:K});G.dispatch(W),q.current?.setNodeSelection(C);}catch{}},[]),ci=gm.useCallback(()=>{we.current=true;},[]),Sr=gm.useCallback(()=>{we.current=false;},[]),Dn=gm.useCallback((C,O,K)=>{let G=q.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;if(ee.attrs.displayMode==="float"||ee.attrs.wrapType&&["square","tight","through"].includes(ee.attrs.wrapType)){let J=se.current?.querySelectorAll(".layout-page");if(!J||J.length===0)return;let te=null;for(let ut of J){let ht=ut.getBoundingClientRect();if(K>=ht.top&&K<=ht.bottom){te=ut.querySelector(".layout-page-content");break}}if(te||(te=J[J.length-1].querySelector(".layout-page-content")),!te)return;let le=te.getBoundingClientRect(),xe=(O-le.left)/f,ye=(K-le.top)/f,Re=914400/96,ke=Math.round(xe*Re),he=Math.round(ye*Re),Be={horizontal:{posOffset:ke,relativeTo:"margin"},vertical:{posOffset:he,relativeTo:"margin"}},$e=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,position:Be});G.dispatch($e),q.current?.setNodeSelection(C);}else {let J=$t(O,K);if(J===null||J===C||J===C+1)return;let te=G.state.tr;if(J<=C)te=te.delete(C,C+ee.nodeSize),te=te.insert(J,ee),q.current?.setNodeSelection(J);else {te=te.delete(C,C+ee.nodeSize);let le=J-ee.nodeSize;te=te.insert(Math.min(le,te.doc.content.size),ee),q.current?.setNodeSelection(Math.min(le,te.doc.content.size-1));}G.dispatch(te);}}catch{}},[$t,f]),di=gm.useCallback(()=>{we.current=true;},[]),To=gm.useCallback(()=>{we.current=false;},[]),Ms=gm.useCallback(C=>{if(!d){if(q.current?.isFocused()||(q.current?.focus(),ie(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey&&!C.nativeEvent.isComposing){C.preventDefault();let O=q.current?.getView();if(O){let{from:K,to:G}=O.state.selection;O.someProp("handleTextInput",W=>W(O,K,G," "))||O.dispatch(O.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=0);}if(C.key==="End"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=O.scrollHeight);}}},[d,ge]),Ae=gm.useCallback(C=>{d||C.target.closest(".docx-comments-sidebar")||C.target.closest(".docx-unified-sidebar")||q.current?.isFocused()||(q.current?.focus(),ie(true));},[d]),Qe=gm.useCallback(C=>{zt(C.state),Ot(C.state),d||requestAnimationFrame(()=>{C.focus(),ie(true);});},[zt,Ot,d]);gm.useEffect(()=>{let C=()=>{let O=q.current?.getView();O&&(chunkEV3CM6TU_js.f(),Gl(),zt(O.state),Ot(O.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let ui=gm.useRef(0);gm.useEffect(()=>{if(ui.current===0){ui.current=1;return}let C=q.current?.getView();C&&zt(C.state);},[s,l,u,c,zt]),gm.useEffect(()=>{let C=Pe.current;if(!C)return;let O=new ResizeObserver(()=>{let K=q.current?.getState();K&&Ot(K);});return O.observe(C),()=>O.disconnect()},[Ot]),gm.useImperativeHandle(n,()=>({getDocument(){return q.current?.getDocument()??null},getState(){return q.current?.getState()??null},getView(){return q.current?.getView()??null},focus(){q.current?.focus(),ie(true);},blur(){q.current?.blur(),ie(false);},isFocused(){return q.current?.isFocused()??false},dispatch(C){q.current?.dispatch(C);},undo(){return q.current?.undo()??false},redo(){return q.current?.redo()??false},setSelection(C,O){q.current?.setSelection(C,O);},getLayout(){return Q},relayout(){let C=q.current?.getState();C&&zt(C);},scrollToPosition:We}),[Q,zt,We]),gm.useEffect(()=>{let C=q.current?.getState();Q&&C&&Ot(C);},[Q,Ot]),gm.useEffect(()=>{H.current&&q.current&&H.current({getDocument:()=>q.current?.getDocument()??null,getState:()=>q.current?.getState()??null,getView:()=>q.current?.getView()??null,focus:()=>{q.current?.focus(),ie(true);},blur:()=>{q.current?.blur(),ie(false);},isFocused:()=>q.current?.isFocused()??false,dispatch:C=>q.current?.dispatch(C),undo:()=>q.current?.undo()??false,redo:()=>q.current?.redo()??false,setSelection:(C,O)=>q.current?.setSelection(C,O),getLayout:()=>Q,relayout:()=>{let C=q.current?.getState();C&&zt(C);},scrollToPosition:We});},[Q,zt]);let kr=gm.useMemo(()=>{if(!Q)return rm+48;let C=Q.pages.length;return C*Ft.h+(C-1)*p+48},[Q,Ft.h,p]);return jsxRuntime.jsxs("div",{ref:Pe,className:`ep-root paged-editor ${pe??""}`,style:{...ck,...$},tabIndex:0,onFocus:xr,onBlur:Oo,onKeyDown:Ms,onMouseDown:Ae,children:[jsxRuntime.jsx(uf,{ref:q,document:o,styles:r,widthPx:Et,readOnly:d,onTransaction:ue,onSelectionChange:br,externalPlugins:h,extensionManager:x,onEditorViewReady:Qe,onKeyDown:F}),jsxRuntime.jsxs("div",{style:{...dk,minHeight:kr,marginBottom:f!==1?kr*(f-1):void 0,transform:(()=>{let C=[];return v&&C.push(`translateX(-${176}px)`),f!==1&&C.push(`scale(${f})`),C.length>0?C.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:se,className:`paged-editor__pages${d?" paged-editor--readonly":""}${D?` paged-editor--hf-editing paged-editor--editing-${D}`:""}`,style:uk,onMouseDown:tn,onMouseMove:qn,onClick:Co,onContextMenu:li,"aria-hidden":"true"}),jsxRuntime.jsx(ff,{selectionRects:Ie,caretPosition:qe,isFocused:Z,pageGap:p,readOnly:d}),jsxRuntime.jsx(yf,{imageInfo:Xe,zoom:f,isFocused:Z,onResize:Lt,onResizeStart:ci,onResizeEnd:Sr,onDragMove:Dn,onDragStart:di,onDragEnd:To}),hn&&jsxRuntime.jsx("button",{type:"button",onMouseDown:Ps,onMouseEnter:gt,onMouseLeave:()=>It(null),style:{position:"absolute",left:hn.x,top:hn.y,width:20,height:20,borderRadius:"4px",border:"1px solid #dadce0",backgroundColor:"#f8f9fa",color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:hn.type==="row"?"Insert row below":"Insert column to the right","aria-label":hn.type==="row"?"Insert row below":"Insert column to the right",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),I&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:pk,children:I})]}),_&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:kr*f,pointerEvents:"none",overflow:"visible"},children:jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:_})})]})}),cm=gm.memo(Rk);var Ik=gm.lazy(()=>import('./FindReplaceDialog-KNJETYJX.js')),Fk=gm.lazy(()=>import('./HyperlinkDialog-GBAYMTUE.js')),Lk=gm.lazy(()=>import('./TablePropertiesDialog-WOZ4ES3H.js').then(e=>({default:e.TablePropertiesDialog}))),Bk=gm.lazy(()=>import('./ImagePositionDialog-M65BYQQE.js').then(e=>({default:e.ImagePositionDialog}))),Ak=gm.lazy(()=>import('./ImagePropertiesDialog-O4WQSF5M.js').then(e=>({default:e.ImagePropertiesDialog}))),Dk=gm.lazy(()=>import('./FootnotePropertiesDialog-452A4UT5.js').then(e=>({default:e.FootnotePropertiesDialog}))),Hk=gm.lazy(()=>import('./PageSetupDialog-2GIBTKMJ.js').then(e=>({default:e.PageSetupDialog}))),dm=[{value:"editing",label:"Editing",icon:"edit_note",desc:"Edit document directly"},{value:"suggesting",label:"Suggesting",icon:"rate_review",desc:"Edits become suggestions"},{value:"viewing",label:"Viewing",icon:"visibility",desc:"Read-only, no edits"}];function Ok({mode:e,onModeChange:t}){let[n,o]=gm.useState(false),[r,i]=gm.useState(false),a=gm.useRef(null),s=gm.useRef(null),[l,u]=gm.useState({top:0,left:0}),c=dm.find(d=>d.value===e);return gm.useEffect(()=>{let d=window.matchMedia("(max-width: 1400px)");i(d.matches);let p=f=>i(f.matches);return d.addEventListener("change",p),()=>d.removeEventListener("change",p)},[]),gm.useEffect(()=>{if(!n||!a.current)return;let d=a.current.getBoundingClientRect();u({top:d.bottom+2,left:d.right-220});},[n]),gm.useEffect(()=>{if(!n)return;let d=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p);}},[n]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:a,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(!n),title:`${c.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:c.icon,size:18}),!r&&jsxRuntime.jsx("span",{children:c.label}),jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:"arrow_drop_down",size:16})]}),n&&jsxRuntime.jsx("div",{ref:s,onMouseDown:d=>d.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:dm.map(d=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(d.value),o(false);},onMouseOver:p=>{p.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)";},onMouseOut:p=>{p.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text, #374151)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:d.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:d.label}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:d.desc})]}),d.value===e&&jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},d.value))})]})}var cc=1,ri=-1;function $k(e,t){let n=t.filter(i=>i.parentId!=null);if(n.length===0)return;let o=new Map;for(let i of n){let a=o.get(i.parentId);a?a.push(i.id):o.set(i.parentId,[i.id]);}function r(i){for(let a of i)if(a.type==="paragraph"){if(!a.content.some(l=>l.type==="commentRangeStart"||l.type==="commentRangeEnd"))continue;let s=[];for(let l of a.content)if(l.type==="commentRangeStart"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeStart",id:c});}else if(l.type==="commentRangeEnd"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeEnd",id:c});}else s.push(l);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let l of s.cells)r(l.content);}r(e);}function _k(e,t){let n=new Set(t.map(a=>a.id)),o=t.filter(a=>a.parentId!=null&&!n.has(a.parentId));if(o.length===0)return;let r=new Map;for(let a of o){let s=r.get(a.parentId);s?s.push(a.id):r.set(a.parentId,[a.id]);}function i(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(d=>(d.type==="insertion"||d.type==="deletion")&&r.has(d.info.id)))continue;let u=[],c=s.content;for(let d=0;d<c.length;d++){let p=c[d];if((p.type==="insertion"||p.type==="deletion")&&r.has(p.info.id)){let f=r.get(p.info.id);for(let b of f)u.push({type:"commentRangeStart",id:b});u.push(p);let m=c[d+1];m&&(m.type==="insertion"||m.type==="deletion")&&m.type!==p.type&&m.info.author===p.info.author&&m.info.date===p.info.date&&(u.push(m),d++);for(let b of f)u.push({type:"commentRangeEnd",id:b});}else u.push(p);}s.content=u;}else if(s.type==="table")for(let l of s.rows)for(let u of l.cells)i(u.content);}i(e);}var um=new Map;function pm(e,t,n){if(!e||!t)return null;let o=e.querySelector(".paged-editor__pages");if(!o)return null;let r=o.querySelectorAll("[data-pm-start]");for(let i of r){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(n>=s&&n<=l)return a.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function lc(e,t,n){return {id:cc++,author:t,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:e}]}]}],...n!==void 0&&{parentId:n}}}var mm=gm.forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i,onSelectionChange:a,onError:s,onFontsLoaded:l,theme:u,showToolbar:c=true,showZoomControl:d=true,showMarginGuides:p=false,marginGuideColor:f,showRuler:m=false,rulerUnit:b="inch",initialZoom:h=1,readOnly:x=false,toolbarExtra:T,className:S="",style:I,placeholder:R,loadingIndicator:D,showOutline:L=false,showOutlineButton:pe=true,showPrintButton:$=true,printOptions:v,onPrint:_,onCopy:re,onCut:ae,onPaste:N,mode:B,onModeChange:de,onCommentAdd:ge,onCommentResolve:Pe,onCommentDelete:se,onCommentReply:q,externalPlugins:E,onEditorViewReady:F,onRenderedDomContextReady:k,pluginOverlays:P,pluginSidebarItems:M,pluginRenderedDomContext:H,renderLogo:oe,documentName:Q,onDocumentNameChange:V,documentNameEditable:Y=true,renderTitleBarRight:ne,i18n:Se},Me){let[Z,ie]=gm.useState({isLoading:!!t,parseError:null,zoom:h,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Ie,He]=gm.useState(false),[qe,je]=gm.useState(false),[Xe,_e]=gm.useState(false),[we,xt]=gm.useState(false),[Le,ze]=gm.useState(null),[lt,nt]=gm.useState(false),[ft,Rt]=gm.useState(L),Ne=gm.useRef(false);Ne.current=ft;let[mt,Oe]=gm.useState([]),[St,Jt]=gm.useState(false),[Gt,jn]=gm.useState(null),[dt,Qt]=gm.useState([]),[gn,So]=gm.useState([]),[gr,No]=gm.useState(um),[an,Yt]=gm.useState(false),[en,Dt]=gm.useState(null),[ko,Ht]=gm.useState(null),[Rs,hn]=gm.useState(B??"editing"),It=B??Rs,bn=y=>{B||hn(y),de?.(y);},gt=x||It==="viewing",[Nt,Ft]=gm.useState(null),[ot,Kn]=gm.useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),Et=gm.useRef(null),yn=gm.useRef(null),zt=gm.useRef(dt);zt.current=dt;let sn=gm.useRef(an);sn.current=an;let hr=gm.useRef(se);hr.current=se;let Bn=gm.useCallback(()=>{let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,A=w.marks.insertion,z=w.marks.deletion;if(!A&&!z)return;let U=[];g.descendants((ce,me)=>{if(ce.isText)for(let Ce of ce.marks)(Ce.type===A||Ce.type===z)&&U.push({type:Ce.type===A?"insertion":"deletion",text:ce.text||"",author:Ce.attrs.author||"",date:Ce.attrs.date,from:me,to:me+ce.nodeSize,revisionId:Ce.attrs.revisionId});});let j=[];for(let ce of U){let me=j[j.length-1];me&&me.revisionId===ce.revisionId&&me.type===ce.type&&me.to===ce.from?(me.text+=ce.text,me.to=ce.to):j.push({...ce});}let X=[];for(let ce=0;ce<j.length;ce++){let me=j[ce],Ce=j[ce+1];me.type==="deletion"&&Ce&&Ce.type==="insertion"&&me.author===Ce.author&&me.date===Ce.date&&me.to===Ce.from?(X.push({type:"replacement",text:Ce.text,deletedText:me.text,author:me.author,date:me.date,from:me.from,to:Ce.to,revisionId:me.revisionId,insertionRevisionId:Ce.revisionId}),ce++):X.push(me);}So(X);let fe=w.marks.comment;if(fe&&X.length>0){let ce=new Map;g.descendants(me=>{if(!me.isText)return;let Ce=me.marks.find(Fe=>Fe.type===fe),Ve=me.marks.find(Fe=>Fe.type===A||Fe.type===z);if(Ce&&Ve){let Fe=Ce.attrs.commentId,Tt=Ve.attrs.revisionId;ce.has(Fe)||ce.set(Fe,Tt);}}),ce.size>0&&Qt(me=>{let Ce=false,Ve=me.map(Fe=>{if(Fe.parentId!=null)return Fe;let Tt=ce.get(Fe.id);return Tt!=null?(Ce=true,{...Fe,parentId:Tt}):Fe});return Ce?Ve:me});}},[]),Ot=gm.useCallback(()=>{if(sn.current)return;let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,A=w.marks.comment;if(!A)return;let z=new Set;g.descendants(X=>{for(let fe of X.marks)if(fe.type===A){let ce=fe.attrs.commentId;ce!==ri&&z.add(ce);}});let U=zt.current,j=new Set;for(let X of U)X.parentId==null&&!z.has(X.id)&&j.add(X.id);if(j.size!==0){for(let X of U)j.has(X.id)&&hr.current?.(X);Qt(X=>X.filter(fe=>!j.has(fe.id)&&!j.has(fe.parentId)));}},[]);gm.useEffect(()=>()=>{Et.current&&clearTimeout(Et.current),yn.current&&clearTimeout(yn.current);},[]),gm.useEffect(()=>{if(Rt(L),L){let y=We.current?.getView();y&&Oe(Qo(y.state.doc));}},[L]);let ue=Qp(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),br=gm.useRef(false);gm.useEffect(()=>{if(br.current)return;let y=ue.state;if(!y)return;let g=y.package?.document?.comments;if(g&&g.length>0){Qt(g),Jt(true),br.current=true;let w=g.reduce((z,U)=>Math.max(z,U.id),0),A=We.current?.getView();A&&A.state.doc.descendants(z=>{for(let U of z.marks)U.attrs.revisionId!=null&&(w=Math.max(w,U.attrs.revisionId));}),w>=cc&&(cc=w+1);}},[ue.state]);let $t=gm.useMemo(()=>{let y=new to(rr());return y.buildSchema(),y.initializeRuntime(),y},[]),An=gm.useMemo(()=>rf(It==="suggesting",r),[]),Es=gm.useMemo(()=>[An,...E??[]],[An,E]),We=gm.useRef(null),tn=gm.useRef(null),Gn=gm.useRef(null),nn=gm.useRef(null),yr=gm.useRef(null),zo=gm.useRef(null),Yn=gm.useRef(null),qn=gm.useRef(null),Ps=gm.useRef(null),Co=gm.useRef(null),[li,xr]=gm.useState(0),Oo=gm.useRef(ue.state);Oo.current=ue.state;let Lt=gm.useRef({style:"single",size:4,color:{rgb:"000000"}}),ci=gm.useRef(null),Sr=gm.useCallback(y=>{let g=ci.current;if(g&&g.styles===y)return g.resolver;let w=On(y);return ci.current={styles:y,resolver:w},w},[]),[Dn,di]=gm.useState({currentPage:1,totalPages:1,visible:false}),To=gm.useRef(null),Ms=gm.useCallback(y=>{if(Ps.current=y,Co.current&&(Co.current.disconnect(),Co.current=null),!y){xr(0);return}xr(y.offsetHeight);let g=new ResizeObserver(()=>{xr(y.offsetHeight);});g.observe(y),Co.current=g;},[]);gm.useEffect(()=>()=>{Co.current?.disconnect();},[]);let Ae=gm.useCallback(()=>Le&&tn.current?tn.current.getView():We.current?.getView(),[Le]),Qe=gm.useCallback(()=>{Le&&tn.current?tn.current.focus():We.current?.focus();},[Le]),ui=gm.useCallback(()=>{Le&&tn.current?tn.current.undo():We.current?.undo();},[Le]),kr=gm.useCallback(()=>{Le&&tn.current?tn.current.redo():We.current?.redo();},[Le]),C=chunkAU5NVRHP_js.m(),O=chunk377ZVTSE_js.m(),[K,G]=gm.useState(false),ee=gm.useCallback(()=>G(true),[]),[W,J]=gm.useState(null),te=gm.useRef(0),le=gm.useCallback(()=>{br.current=false,Re.current=false,Qt([]),So([]),Oe([]),Jt(false),Yt(false),Dt(null),Ht(null),Ft(null),ze(null),No(um),C.setMatches([],0),Et.current&&(clearTimeout(Et.current),Et.current=null),yn.current&&(clearTimeout(yn.current),yn.current=null);},[C.setMatches]),xe=gm.useCallback(y=>{le(),ue.reset(y),ie(g=>({...g,isLoading:false,parseError:null})),chunkKUL2SDYC_js.l(y).catch(g=>{console.warn("Failed to load document fonts:",g);});},[le,ue]),ye=gm.useCallback(async y=>{let g=++te.current;le(),ie(w=>({...w,isLoading:true,parseError:null}));try{let w=await chunkKUL2SDYC_js.n(y);if(te.current!==g)return;xe(w);}catch(w){if(te.current!==g)return;let A=w instanceof Error?w.message:"Failed to parse document";ie(z=>({...z,isLoading:false,parseError:A})),s?.(w instanceof Error?w:new Error(A));}},[le,xe,s]);gm.useEffect(()=>{if(!t){n&&xe(n);return}ye(t);},[t,n]),gm.useEffect(()=>{ue.state?Gn.current=new chunkP7WEP4JU_js.f(ue.state):Gn.current=null;},[ue.state]);let Re=gm.useRef(false);gm.useEffect(()=>{if(!Z.isLoading&&ue.state){let y=setTimeout(()=>{Bn(),Re.current||(Re.current=true,So(g=>(g.length>0&&Jt(true),g)));},200);return ()=>clearTimeout(y)}},[Z.isLoading,ue.state,Bn]),gm.useEffect(()=>chunkKUL2SDYC_js.h(()=>{l?.();}),[l]),gm.useEffect(()=>{let y=We.current?.getView();y&&af(It==="suggesting",y.state,y.dispatch,r);},[It,r]);let ke=gm.useCallback(y=>(ue.push(y),y),[ue]),he=gm.useCallback(y=>{if(ke(y),i?.(y),Ne.current){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}Et.current&&clearTimeout(Et.current),Et.current=setTimeout(Bn,300),yn.current&&clearTimeout(yn.current),yn.current=setTimeout(Ot,300);},[i,ke,Bn,Ot]),Be=gm.useCallback(y=>{let g=Ae();if(g){let{from:Ve,to:Fe}=g.state.selection;yr.current={from:Ve,to:Fe};}let w=null;if(g&&(w=Ze(g.state),w.isInTable||(w=null)),w?.cellBorderColor){let Ve=w.cellBorderColor,Fe=Ve.rgb;(!Fe||Fe==="auto")&&(Fe=chunk4VUZBV2S_js.a(Ve,u).replace(/^#/,"")),Lt.current={...Lt.current,color:{rgb:Fe}};}let A=null;if(g){let Ve=g.state.selection,Fe=Ve.node;Fe?.type.name==="image"&&(A={pos:Ve.from,wrapType:Fe.attrs.wrapType??"inline",displayMode:Fe.attrs.displayMode??"inline",cssFloat:Fe.attrs.cssFloat??null,transform:Fe.attrs.transform??null,alt:Fe.attrs.alt??null,borderWidth:Fe.attrs.borderWidth??null,borderColor:Fe.attrs.borderColor??null,borderStyle:Fe.attrs.borderStyle??null});}if(!y){Ft(null),ie(Ve=>({...Ve,selectionFormatting:{},pmTableContext:w,pmImageContext:A}));return}let{textFormatting:z,paragraphFormatting:U}=y,j=z.fontFamily?.ascii||z.fontFamily?.hAnsi,X=z.fontSize;if(!j||!X){let Ve=Oo.current,Fe=y.styleId;if(Ve?.package.styles&&Fe){let Ct=Sr(Ve.package.styles).resolveParagraphStyle(Fe);!j&&Ct.runFormatting?.fontFamily&&(j=Ct.runFormatting.fontFamily.ascii||Ct.runFormatting.fontFamily.hAnsi),!X&&Ct.runFormatting?.fontSize&&(X=Ct.runFormatting.fontSize);}}let fe=z.color?.rgb?`#${z.color.rgb}`:void 0,ce=U.numPr,me=ce?{type:ce.numId===1?"bullet":"numbered",level:ce.ilvl??0,isInList:true,numId:ce.numId}:void 0,Ce={bold:z.bold,italic:z.italic,underline:!!z.underline,strike:z.strike,superscript:z.vertAlign==="superscript",subscript:z.vertAlign==="subscript",fontFamily:j,fontSize:X,color:fe,highlight:z.highlight,alignment:U.alignment,lineSpacing:U.lineSpacing,listState:me,styleId:y.styleId??void 0,indentLeft:U.indentLeft,bidi:!!U.bidi};if(ie(Ve=>({...Ve,selectionFormatting:Ce,paragraphIndentLeft:U.indentLeft??0,paragraphIndentRight:U.indentRight??0,paragraphFirstLineIndent:U.indentFirstLine??0,paragraphHangingIndent:U.hangingIndent??false,paragraphTabs:U.tabs??null,pmTableContext:w,pmImageContext:A})),g&&y.hasSelection&&!an&&!gt){let Ve=qn.current,Fe=Yn.current,{from:Tt}=g.state.selection,Ct=pm(Ve,Fe,Tt);if(Ct!=null&&Ve&&Fe){let Er=Ve.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),wi=Er?Er.getBoundingClientRect().right-Fe.getBoundingClientRect().left:Fe.getBoundingClientRect().width/2+408;Ft({top:Ct,left:wi});}}else Ft(null);a?.(y);},[a,an,gt]),$e=fd({document:ue.state,onChange:he,onSelectionChange:y=>{}});gm.useEffect(()=>{let y=g=>{let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey;if(!A&&!g.shiftKey&&!g.altKey&&(g.key==="Delete"||g.key==="Backspace")){let z=We.current?.getView();if(z){let U=z.state.selection;if("$anchorCell"in U&&typeof U.forEachCell=="function"){let X=Ze(z.state);if(X.isInTable&&X.table){let fe=0;X.table.descendants(me=>{(me.type.name==="tableCell"||me.type.name==="tableHeader")&&(fe+=1);});let ce=0;if(U.forEachCell(()=>{ce+=1;}),fe>0&&ce>=fe){g.preventDefault(),Gr(z.state,z.dispatch);return}}}}if($e.state.tableIndex!==null){g.preventDefault(),$e.handleAction("deleteTable");return}}if(A&&!g.shiftKey&&!g.altKey){if(g.key.toLowerCase()==="f"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C.openFind(U);}else if(g.key.toLowerCase()==="h"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C.openReplace(U);}else if(g.key.toLowerCase()==="k"){g.preventDefault();let z=We.current?.getView();if(z){let U=nr(z.state),j=tr(z.state);j?O.openEdit({url:j.href,displayText:U,tooltip:j.tooltip}):O.openInsert(U);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[C,O,$e]);let ut=gm.useCallback((y,g)=>{let w=Ae();w&&(va(y,g)(w.state,w.dispatch),Qe());},[Ae,Qe]),ht=gm.useCallback(()=>{let y=Ae();y&&(Ga(y.state,y.dispatch),Qe());},[Ae,Qe]),ln=gm.useCallback(()=>{let y=Ae();y&&(wa(y.state,y.dispatch),Qe());},[Ae,Qe]),$o=gm.useCallback(()=>{Rt(y=>{if(!y){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}return !y});},[]),pi=gm.useCallback(y=>{We.current?.scrollToPosition(y),We.current?.setSelection(y+1),We.current?.focus();},[]),fi=gm.useCallback(()=>{zo.current?.click();},[]),mi=gm.useCallback(y=>{let g=y.target.files?.[0];if(!g)return;let w=Ae();if(!w)return;let A=new FileReader;A.onload=()=>{let z=A.result,U=new Image;U.onload=()=>{let j=U.naturalWidth,X=U.naturalHeight,fe=612;if(j>fe){let Fe=fe/j;j=fe,X=Math.round(X*Fe);}let ce=`rId_img_${Date.now()}`,me=w.state.schema.nodes.image.create({src:z,alt:g.name,width:j,height:X,rId:ce,wrapType:"inline",displayMode:"inline"}),{from:Ce}=w.state.selection,Ve=w.state.tr.insert(Ce,me);w.dispatch(Ve.scrollIntoView()),Qe();},U.src=z;},A.readAsDataURL(g),y.target.value="";},[Ae,Qe]),gi=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z="inline",U=null;switch(y){case "inline":z="inline",U=null;break;case "square":case "tight":case "through":z="float",U="left";break;case "topAndBottom":z="block",U=null;break;case "behind":case "inFront":z="float",U="none";break;case "wrapLeft":z="float",U="right",y="square";break;case "wrapRight":z="float",U="left",y="square";break}let j=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,wrapType:y,displayMode:z,cssFloat:U});g.dispatch(j.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),Cr=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=A.attrs.transform||"",U=z.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),j=U?parseFloat(U[1]):0,X=/scaleX\(-1\)/.test(z),fe=/scaleY\(-1\)/.test(z);switch(y){case "rotateCW":j=(j+90)%360;break;case "rotateCCW":j=(j-90+360)%360;break;case "flipH":X=!X;break;case "flipV":fe=!fe;break}let ce=[];j!==0&&ce.push(`rotate(${j}deg)`),X&&ce.push("scaleX(-1)"),fe&&ce.push("scaleY(-1)");let me=ce.length>0?ce.join(" "):null,Ce=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,transform:me});g.dispatch(Ce.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),Tr=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??A.attrs.distTop,distBottom:y.distBottom??A.attrs.distBottom,distLeft:y.distLeft??A.attrs.distLeft,distRight:y.distRight??A.attrs.distRight});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),_o=gm.useCallback(()=>{_e(true);},[]),cn=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),wo=gm.useCallback((y,g)=>{if(!ue.state?.package)return;let w={...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:g}};ke({...ue.state,package:{...ue.state.package,document:w}});},[ue,ke]),wr=gm.useCallback(y=>{let g=Ae();if(g){switch(y){case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "deleteTable":Gr(g.state,g.dispatch);break;case "selectTable":Ra(g.state,g.dispatch);break;case "selectRow":Ea(g.state,g.dispatch);break;case "selectColumn":Pa(g.state,g.dispatch);break;case "mergeCells":Ma(g.state,g.dispatch);break;case "splitCell":Ia(g.state,g.dispatch);break;case "borderAll":La(g.state,g.dispatch,Lt.current);break;case "borderOutside":Ba(g.state,g.dispatch,Lt.current);break;case "borderInside":Aa(g.state,g.dispatch,Lt.current);break;case "borderNone":Fa(g.state,g.dispatch);break;case "borderTop":no("top",Lt.current,true)(g.state,g.dispatch);break;case "borderBottom":no("bottom",Lt.current,true)(g.state,g.dispatch);break;case "borderLeft":no("left",Lt.current,true)(g.state,g.dispatch);break;case "borderRight":no("right",Lt.current,true)(g.state,g.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")Ua(y.color)(g.state,g.dispatch);else if(y.type==="borderColor"){let w=y.color.replace(/^#/,"");Lt.current={...Lt.current,color:{rgb:w}},ja(y.color)(g.state,g.dispatch);}else if(y.type==="borderWidth")Lt.current={...Lt.current,size:y.size},Ka(y.size)(g.state,g.dispatch);else if(y.type==="cellBorder")no(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(g.state,g.dispatch);else if(y.type==="cellVerticalAlign")Da(y.align)(g.state,g.dispatch);else if(y.type==="cellMargins")Ha(y.margins)(g.state,g.dispatch);else if(y.type==="cellTextDirection")Na(y.direction)(g.state,g.dispatch);else if(y.type==="toggleNoWrap")za()(g.state,g.dispatch);else if(y.type==="rowHeight")Oa(y.height,y.rule)(g.state,g.dispatch);else if(y.type==="toggleHeaderRow")$a()(g.state,g.dispatch);else if(y.type==="distributeColumns")_a()(g.state,g.dispatch);else if(y.type==="autoFitContents")Wa()(g.state,g.dispatch);else if(y.type==="openTableProperties")He(true);else if(y.type==="tableProperties")Yr(y.props)(g.state,g.dispatch);else if(y.type==="applyTableStyle"){let w=Yp(y.styleId),A=Oo.current;if(!w&&A?.package.styles){let U=Sr(A.package.styles).getStyle(y.styleId);if(U){if(w={id:U.styleId,name:U.name??U.styleId},U.tblPr?.borders){let j=U.tblPr.borders;w.tableBorders={};for(let X of ["top","bottom","left","right","insideH","insideV"]){let fe=j[X];fe&&(w.tableBorders[X]={style:fe.style,size:fe.size,color:fe.color?.rgb?{rgb:fe.color.rgb}:void 0});}}if(U.tblStylePr){w.conditionals={};for(let j of U.tblStylePr){let X={};if(j.tcPr?.shading?.fill&&(X.backgroundColor=`#${j.tcPr.shading.fill}`),j.tcPr?.borders){let fe={};for(let ce of ["top","bottom","left","right"]){let me=j.tcPr.borders[ce];me&&(fe[ce]={style:me.style,size:me.size,color:me.color?.rgb?{rgb:me.color.rgb}:void 0});}X.borders=fe;}j.rPr?.bold&&(X.bold=true),j.rPr?.color?.rgb&&(X.color=`#${j.rPr.color.rgb}`),w.conditionals[j.type]=X;}}w.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}w&&Va({styleId:w.id,tableBorders:w.tableBorders,conditionals:w.conditionals,look:w.look})(g.state,g.dispatch);}}else $e.handleAction(y);}Qe();}},[$e,Ae,Qe]),Is=gm.useCallback(y=>{y.preventDefault(),y.stopPropagation();let g=We.current?.getView(),w=g?Qn(g.state):false,{from:A,to:z}=g?.state.selection??{from:0,to:0},U=A!==z;Kn({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:U,cursorInTable:w});},[]),vr=gm.useCallback(y=>{let g=Ae();if(!g)return;g.focus();let w=g===We.current?.getView(),{from:A,to:z}=g.state.selection,U=yr.current;if(w&&U&&(A!==U.from||z!==U.to))try{let j=g.state.tr.setSelection(prosemirrorState.TextSelection.create(g.state.doc,U.from,U.to));g.dispatch(j);}catch(j){console.warn("Could not restore selection:",j);}if(y==="bold"){Qi(g.state,g.dispatch);return}if(y==="italic"){ea(g.state,g.dispatch);return}if(y==="underline"){ta(g.state,g.dispatch);return}if(y==="strikethrough"){na(g.state,g.dispatch);return}if(y==="superscript"){oa(g.state,g.dispatch);return}if(y==="subscript"){ra(g.state,g.dispatch);return}if(y==="bulletList"){ba(g.state,g.dispatch);return}if(y==="numberedList"){ya(g.state,g.dispatch);return}if(y==="indent"){xa(g.state,g.dispatch)||fa()(g.state,g.dispatch);return}if(y==="outdent"){Sa(g.state,g.dispatch)||ma()(g.state,g.dispatch);return}if(y==="clearFormatting"){Hr(g.state,g.dispatch);return}if(y==="setRtl"){Ca(g.state,g.dispatch);return}if(y==="setLtr"){Ta(g.state,g.dispatch);return}if(y==="insertLink"){let j=nr(g.state),X=tr(g.state);X?O.openEdit({url:X.href,displayText:j,tooltip:X.tooltip}):O.openInsert(j);return}if(typeof y=="object")switch(y.type){case "alignment":ua(y.value)(g.state,g.dispatch);break;case "textColor":{let j=y.value;typeof j=="string"?Or({rgb:j.replace("#","")})(g.state,g.dispatch):j.auto?ia(g.state,g.dispatch):Or(j)(g.state,g.dispatch);break}case "highlightColor":{let j=y.value?chunkDC65PJYE_js.z(y.value):"";aa(j||y.value)(g.state,g.dispatch);break}case "fontSize":sa(chunkDC65PJYE_js.i(y.value))(g.state,g.dispatch);break;case "fontFamily":la(y.value)(g.state,g.dispatch);break;case "lineSpacing":pa(y.value)(g.state,g.dispatch);break;case "applyStyle":{let j=Oo.current,X=j?.package.styles?Sr(j.package.styles):null;if(X){let fe=X.resolveParagraphStyle(y.value);Wr(y.value,{paragraphFormatting:fe.paragraphFormatting,runFormatting:fe.runFormatting})(g.state,g.dispatch);}else Wr(y.value)(g.state,g.dispatch);break}}},[Ae]),hi=gm.useCallback(y=>{ie(g=>({...g,zoom:y}));},[]),kt=gm.useCallback(y=>{let g=Ae();if(!g)return;let w=y.url||"",A=y.tooltip,{empty:z}=g.state.selection;z&&y.displayText?$r(y.displayText,w,A)(g.state,g.dispatch):z?y.displayText&&$r(y.displayText,w,A)(g.state,g.dispatch):ca(w,A)(g.state,g.dispatch),O.close(),Qe();},[O,Ae,Qe]),Xn=gm.useCallback(()=>{let y=Ae();y&&(da(y.state,y.dispatch),Qe());},[Ae,Qe]),xn=gm.useCallback(()=>{Xn(),O.close();},[O,Xn]),vo=gm.useCallback(y=>J(y),[]),Ro=gm.useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),Fs=gm.useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let g=document.createElement("textarea");g.value=y,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g);});},[]),Lm=gm.useCallback((y,g)=>{let w=Ae();if(!w)return;let A=w.state.schema.marks.hyperlink;if(!A)return;let{$from:z}=w.state.selection,U=z.marks().find(j=>j.type===A);if(U){let j=z.parent,X=z.start(),fe=[],ce=null;j.forEach((Ct,Rr)=>{let Er=X+Rr,wi=Er+Ct.nodeSize;(Ct.isText?Ct.marks.find(bc=>bc.type===A&&bc.attrs.href===U.attrs.href):null)?ce?ce.end=wi:ce={start:Er,end:wi}:ce&&(fe.push(ce),ce=null);}),ce&&fe.push(ce);let me=z.pos,Ce=fe.find(Ct=>Ct.start<=me&&me<=Ct.end);if(!Ce)return;let Ve=w.state.tr,Fe=A.create({href:g,tooltip:U.attrs.tooltip}),Tt=w.state.schema.text(y,[...z.marks().filter(Ct=>Ct.type!==A),Fe]);Ve.replaceWith(Ce.start,Ce.end,Tt),w.dispatch(Ve.scrollIntoView());}J(null),Qe();},[Ae,Qe]),Bm=gm.useCallback(()=>{let y=Ae();if(!y)return;let g=y.state.schema.marks.hyperlink;if(!g)return;let{$from:w}=y.state.selection,A=w.marks().find(Ce=>Ce.type===g);if(!A&&w.nodeAfter&&(A=w.nodeAfter.marks.find(Ce=>Ce.type===g)),!A&&w.nodeBefore&&(A=w.nodeBefore.marks.find(Ce=>Ce.type===g)),!A&&W&&w.parent.forEach(Ve=>{if(!A&&Ve.isText){let Fe=Ve.marks.find(Tt=>Tt.type===g&&Tt.attrs.href===W.href);Fe&&(A=Fe);}}),!A)return;let z=w.parent,U=w.start(),j=[],X=null;z.forEach((Ce,Ve)=>{let Fe=U+Ve,Tt=Fe+Ce.nodeSize;(Ce.isText?Ce.marks.find(Rr=>Rr.type===g&&Rr.attrs.href===A.attrs.href):null)?X?X.end=Tt:X={start:Fe,end:Tt}:X&&(j.push(X),X=null);}),X&&j.push(X);let fe=w.pos,ce=j.find(Ce=>Ce.start<=fe&&fe<=Ce.end);if(!ce)return;let me=y.state.tr;me.removeMark(ce.start,ce.end,g),y.dispatch(me.scrollIntoView()),J(null),Qe(),sonner.toast("Link removed");},[Ae,Qe,W]),Am=gm.useCallback(()=>{J(null);},[]),Dm=gm.useCallback(y=>{let g=We.current?.getView(),w=g?Qn(g.state):false;Kn({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:w});},[]),Hm=gm.useCallback(()=>{Kn({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),fc=gm.useMemo(()=>{let g=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",w=[{action:"cut",label:"Cut",shortcut:`${g}+X`},{action:"copy",label:"Copy",shortcut:`${g}+C`},{action:"paste",label:"Paste",shortcut:`${g}+V`},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:`${g}+Shift+V`,dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:!ot.hasSelection&&!ot.cursorInTable}];return ot.hasSelection&&w.push({action:"addComment",label:"Comment",dividerAfter:!ot.cursorInTable}),ot.cursorInTable&&w.push({action:"addRowAbove",label:"Insert row above"},{action:"addRowBelow",label:"Insert row below"},{action:"deleteRow",label:"Delete row",dividerAfter:true},{action:"addColumnLeft",label:"Insert column left"},{action:"addColumnRight",label:"Insert column right"},{action:"deleteColumn",label:"Delete column",dividerAfter:true}),w.push({action:"selectAll",label:"Select All",shortcut:`${g}+A`}),w},[ot.hasSelection,ot.cursorInTable]),mc=gm.useCallback(async y=>{let g=Ae();if(g)switch(Qe(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let w=await navigator.clipboard.read(),A="",z="";for(let X of w)X.types.includes("text/html")&&(A=await(await X.getType("text/html")).text()),X.types.includes("text/plain")&&(z=await(await X.getType("text/plain")).text());let U=new DataTransfer;A&&U.items.add(A,"text/html"),z&&U.items.add(z,"text/plain");let j=new ClipboardEvent("paste",{clipboardData:U,bubbles:!0,cancelable:!0});g.dom.dispatchEvent(j);}catch{try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}}break}case "pasteAsPlainText":try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}break;case "delete":{let{from:w,to:A}=g.state.selection;w!==A&&g.dispatch(g.state.tr.deleteRange(w,A));break}case "selectAll":g.dispatch(g.state.tr.setSelection(prosemirrorState.TextSelection.create(g.state.doc,0,g.state.doc.content.size)));break;case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "addComment":{let{from:w,to:A}=g.state.selection;if(w===A)break;let z=pm(qn.current,Yn.current,w);Dt({from:w,to:A});let U=g.state.schema.marks.comment.create({commentId:ri}),j=g.state.tr.addMark(w,A,U);j.setSelection(prosemirrorState.TextSelection.create(j.doc,A)),g.dispatch(j),Ht(z),Jt(true),Yt(true),Ft(null);break}}},[Ae,Qe]),Zn=gm.useCallback(y=>g=>{if(!ue.state||gt)return;let w={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,[y]:g}}}};he(w);},[ue.state,gt,he]),Nm=gm.useMemo(()=>Zn("marginLeft"),[Zn]),zm=gm.useMemo(()=>Zn("marginRight"),[Zn]),Om=gm.useMemo(()=>Zn("marginTop"),[Zn]),$m=gm.useMemo(()=>Zn("marginBottom"),[Zn]),_m=gm.useCallback(y=>{if(!ue.state||gt)return;let g={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,...y}}}};he(g);},[ue.state,gt,he]),Wm=gm.useCallback(y=>{let g=Ae();g&&ga(y)(g.state,g.dispatch);},[Ae]),Vm=gm.useCallback(y=>{let g=Ae();g&&ha(y)(g.state,g.dispatch);},[Ae]),Um=gm.useCallback(y=>{let g=Ae();g&&(y<0?_r(-y,true)(g.state,g.dispatch):_r(y,false)(g.state,g.dispatch));},[Ae]),jm=gm.useCallback(y=>{let g=Ae();g&&ka(y)(g.state,g.dispatch);},[Ae]),Wo=qn.current;gm.useEffect(()=>{if(!Wo)return;let y=()=>{let g=We.current?.getLayout();if(!g||g.pages.length===0)return;let w=Wo.scrollTop,A=g.pages.length,z=24,U=24,j=w+Wo.clientHeight/2,X=U,fe=1;for(let ce=0;ce<g.pages.length;ce++){let me=g.pages[ce].size.h,Ce=X+me;if(j<Ce){fe=ce+1;break}X=Ce+z,fe=ce+2;}fe=Math.min(fe,A),di({currentPage:fe,totalPages:A,visible:true}),To.current&&clearTimeout(To.current),To.current=setTimeout(()=>{di(ce=>({...ce,visible:false}));},600);};return Wo.addEventListener("scroll",y,{passive:true}),()=>{Wo.removeEventListener("scroll",y),To.current&&clearTimeout(To.current);}},[Wo]);let gc=gm.useCallback(async y=>{if(!Gn.current)return null;try{let g=Gn.current.getDocument(),w=We.current?.getDocument();w?.package?.document&&(g.package.document.content=w.package.document.content),g.package.document.comments=dt,$k(g.package.document.content,dt),_k(g.package.document.content,dt);let A=y?.selective!==!1,z=We.current?.getView(),U;if(A&&z){let X=z.state,fe=dt.some(ce=>ce.parentId!=null);U={selective:{changedParaIds:sp(X),structuralChange:lp(X)||fe,hasUntrackedChanges:cp(X)}};}let j=await Gn.current.toBuffer(U);return z&&z.dispatch(dp(z.state)),o?.(j),j}catch(g){return s?.(g instanceof Error?g:new Error("Failed to save document")),null}},[o,s,dt]),Km=gm.useCallback(y=>{s?.(y);},[s]),bi=gm.useCallback(()=>{let y=nn.current?.querySelector(".paged-editor__pages");if(!y){window.print(),_?.();return}let g=window.open("","_blank");if(!g){window.print(),_?.();return}let w=[];for(let z of Array.from(document.styleSheets))try{for(let U of Array.from(z.cssRules))U instanceof CSSFontFaceRule&&w.push(U.cssText);}catch{}let A=y.cloneNode(true);A.style.cssText="display: block; margin: 0; padding: 0;";for(let z of Array.from(A.querySelectorAll(".layout-page"))){let U=z;U.style.boxShadow="none",U.style.margin="0";}g.document.write(`<!DOCTYPE html>
|
|
18
|
+
`}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:e("errors.loadingDocument")})]})}function Xp(){let{t:e}=chunkQSUPYUOP_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:e("errors.noDocumentLoaded")})]})}function Zp({message:e}){let{t}=chunkQSUPYUOP_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:t("errors.failedToLoad")}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function tx(e,t){return JSON.stringify(e)===JSON.stringify(t)}function nx(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=tx,onUndo:a,onRedo:s,containerRef:l}=t,[u,c]=gm.useState(e),[d,p]=gm.useState([]),[f,m]=gm.useState([]),b=gm.useRef(0),h=gm.useRef(false),x=gm.useCallback(($,v)=>{if(i(u,$))return;if(h.current){c($);return}let _=Date.now();_-b.current<o&&d.length>0?p(ae=>{let N=[...ae];return N[N.length-1]={state:u,timestamp:_,description:v||N[N.length-1].description},N}):p(ae=>{let N={state:u,timestamp:_,description:v},B=[...ae,N];return B.length>n?B.slice(B.length-n):B}),m([]),c($),b.current=_;},[u,i,o,n,d.length]),T=gm.useCallback(()=>{if(d.length===0)return;h.current=true;let $=d[d.length-1];return p(v=>v.slice(0,-1)),m(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),a?.($.state),$.state},[d,u,a]),S=gm.useCallback(()=>{if(f.length===0)return;h.current=true;let $=f[f.length-1];return m(v=>v.slice(0,-1)),p(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),s?.($.state),$.state},[f,u,s]),I=gm.useCallback(()=>{p([]),m([]);},[]),R=gm.useCallback($=>{c($??e),p([]),m([]),b.current=0;},[e]),D=gm.useCallback(()=>[...d],[d]),L=gm.useCallback(()=>[...f],[f]),pe=gm.useCallback($=>{c(v=>$(v)),p(v=>v.map(_=>({..._,state:$(_.state)}))),m(v=>v.map(_=>({..._,state:$(_.state)})));},[]);return gm.useEffect(()=>{if(!r)return;let $=_=>{if((_.ctrlKey||_.metaKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),T();return}if((_.ctrlKey||_.metaKey)&&_.key==="y"||(_.ctrlKey||_.metaKey)&&_.key==="z"&&_.shiftKey){_.preventDefault(),S();return}},v=l?.current||document;return v.addEventListener("keydown",$),()=>{v.removeEventListener("keydown",$);}},[r,T,S,l]),{state:u,canUndo:d.length>0,canRedo:f.length>0,undoCount:d.length,redoCount:f.length,push:x,undo:T,redo:S,clear:I,reset:R,getUndoStack:D,getRedoStack:L,transformAll:pe}}function Qp(e,t={}){let n=gm.useCallback((o,r)=>!(o?.package?.document!==r?.package?.document&&JSON.stringify(o?.package?.document)!==JSON.stringify(r?.package?.document)||o?.package?.headers!==r?.package?.headers||o?.package?.footers!==r?.package?.footers),[]);return nx(e,{...t,isEqual:n})}var oo=new prosemirrorState.PluginKey("suggestionMode"),Za="suggestionModeApplied",ix=Date.now();function Ja(e){return {revisionId:ix++,author:e.author,date:new Date().toISOString()}}function Nl(e,t,n,o){try{let r=e.resolve(t);for(let i of [r.nodeBefore,r.nodeAfter])if(i?.isText){let a=i.marks.find(s=>s.type.name===n&&s.attrs.author===o);if(a)return a.attrs}}catch{}return null}function nf(e,t,n,o,r){return Nl(e,t,o,r)??Nl(e,n,o,r)}function of(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,c)=>{if(!u.isText)return;let d=Math.max(c,n),p=Math.min(c+u.nodeSize,o);if(d>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:d,to:p,isOwnInsert:f});}),s.length===0)return;let l=nf(t,n,o,"deletion",a.author)||Ja(a);for(let u=s.length-1;u>=0;u--){let c=s[u];c.isOwnInsert?e.delete(c.from,c.to):e.addMark(c.from,c.to,i.create(l));}}function ef(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(Za,true);let s=Nl(e.state.doc,t,"insertion",r.author)||Ja(r);if(t!==n){let c=e.state.schema.marks.deletion;c&&of(a,e.state.doc,t,n,i,c,r);}let l=a.mapping.map(n);a.insertText(o,l,l);let u=e.state.schema.marks.deletion;return u&&a.removeMark(l,l+o.length,u),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function tf(e,t,n){let o=oo.getState(e);if(!o?.active)return false;let{$from:r,$to:i,empty:a}=e.selection,s=e.schema.marks.insertion,l=e.schema.marks.deletion;if(!s||!l)return false;if(!t)return true;let u=e.tr;if(u.setMeta(Za,true),!a){of(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x))),t(u.scrollIntoView()),true}let c=n==="backward",d=c?r.pos-1:r.pos,p=c?r.pos:r.pos+1;if(d<0||p>e.doc.content.size)return true;let m=e.doc.resolve(d).nodeAfter;if(!m?.isText)return false;let b=m.marks.some(x=>x.type===s&&x.attrs.author===o.author);if(m.marks.some(x=>x.type===l)){let x=c?d:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(d,p);else {let x=nf(e.doc,d,p,"deletion",o.author)||Ja(o);u.addMark(d,p,l.create(x));let T=c?d:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function rf(e=false,t="User"){return new prosemirrorState.Plugin({key:oo,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(oo);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=oo.getState(n.state);if(!r?.active)return false;if(o.inputType==="insertText"&&o.data){o.preventDefault();let{from:i,to:a}=n.state.selection;return ef(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return oo.getState(n.state)?.active?o.key==="Backspace"?tf(n.state,n.dispatch,"backward"):o.key==="Delete"?tf(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=oo.getState(n.state);return a?.active?ef(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=oo.getState(r);if(!i?.active)return null;let a=n.find(d=>d.docChanged&&!d.getMeta(Za));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Ja(i),u=r.tr;u.setMeta(Za,true);let c=r.schema.marks.deletion;return a.steps.forEach(d=>{d.getMap().forEach((f,m,b,h)=>{h>b&&r.doc.nodesBetween(b,h,(x,T)=>{if(!x.isText)return;if(!x.marks.some(I=>I.type===s||c&&I.type===c)){let I=Math.max(T,b),R=Math.min(T+x.nodeSize,h);u.addMark(I,R,s.create(l));}});});}),u.steps.length>0?u:null}})}function af(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(oo,r);n(i);}return true}var mx={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function df(e,t,n,o=[]){let r=n?.getSchema()??ve,i=e?yl(e,{styles:t??void 0}):vl(),a=[...o,...n?.getPlugins()??[]];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function gx(e,t){return t?bp(e.doc,t):null}var hx=gm.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:c=[],extensionManager:d,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=gm.useRef(null),h=gm.useRef(null),x=gm.useRef(o),T=gm.useRef(false),S=gm.useRef(null),I=gm.useRef(false),R=gm.useRef(l),D=gm.useRef(u),L=gm.useRef(p),pe=gm.useRef(f),$=gm.useRef(m);R.current=l,D.current=u,L.current=p,pe.current=f,$.current=m,x.current=o;let v=gm.useCallback(()=>{if(!b.current||T.current)return;let ae={state:df(o,r,d,c),editable:()=>!s,dispatchTransaction:N=>{if(!h.current||T.current)return;let B=h.current.state.apply(N);h.current.updateState(B),R.current?.(N,B),(N.selectionSet||N.docChanged)&&D.current?.(B);},handleKeyDown:(N,B)=>$.current?.(N,B)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};h.current=new prosemirrorView.EditorView(b.current,ae),L.current?.(h.current);},[o,r,c,d,s]),_=gm.useCallback(()=>{h.current&&!T.current&&(T.current=true,pe.current?.(),h.current.destroy(),h.current=null,T.current=false);},[]);return gm.useEffect(()=>(v(),()=>_()),[]),gm.useEffect(()=>{if(!h.current||T.current)return;let ae=(B=>{if(!B)return "empty";let de=B.package?.properties;return `${de?.created||""}-${de?.modified||""}-${de?.title||""}`})(o);if(I.current&&ae===S.current)return;I.current=true,S.current=ae;let N=df(o,r,d,c);h.current.updateState(N),D.current?.(N);},[o,r,d,c]),gm.useEffect(()=>{h.current;},[s]),gm.useImperativeHandle(n,()=>({getState(){return h.current?.state??null},getView(){return h.current??null},getDocument(){return h.current?gx(h.current.state,x.current):null},focus(){h.current?.focus();},blur(){h.current?.hasFocus()&&h.current.dom.blur();},isFocused(){return h.current?.hasFocus()??false},dispatch(re){h.current&&!T.current&&h.current.dispatch(re);},executeCommand(re){return h.current?re(h.current.state,h.current.dispatch,h.current):false},undo(){return h.current?prosemirrorHistory.undo(h.current.state,h.current.dispatch):false},redo(){return h.current?prosemirrorHistory.redo(h.current.state,h.current.dispatch):false},canUndo(){return h.current?prosemirrorHistory.undo(h.current.state):false},canRedo(){return h.current?prosemirrorHistory.redo(h.current.state):false},setSelection(re,ae){if(!h.current)return;let{state:N,dispatch:B}=h.current,de=N.doc.resolve(re),ge=ae!==void 0?N.doc.resolve(ae):de,Pe=prosemirrorState.TextSelection.between(de,ge);B(N.tr.setSelection(Pe));},setNodeSelection(re){if(!h.current)return;let{state:ae,dispatch:N}=h.current;try{let B=prosemirrorState.NodeSelection.create(ae.doc,re);N(ae.tr.setSelection(B));}catch{this.setSelection(re);}},setCellSelection(re,ae){if(!h.current)return;let{state:N,dispatch:B}=h.current;try{let de=prosemirrorTables.CellSelection.create(N.doc,re,ae);B(N.tr.setSelection(de));}catch{this.setSelection(re,ae);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...mx,width:a>0?`${a}px`:void 0}})}),uf=gm.memo(hx);var Sx="#000",kx="rgba(66, 133, 244, 0.3)",Cx=2,Tx=530,wx={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},vx=(e,t,n,o)=>({position:"absolute",left:e.x,top:e.y,width:n,height:e.height,backgroundColor:t,opacity:o?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),Rx=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Ex=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=gm.useState(r),s=gm.useRef(null);return gm.useEffect(()=>(s.current&&(window.clearInterval(s.current),s.current=null),r&&o>0?(a(true),s.current=window.setInterval(()=>{a(l=>!l);},o)):a(false),()=>{s.current&&window.clearInterval(s.current);}),[r,o]),gm.useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsxRuntime.jsx("div",{style:vx(e,t,n,i),"data-testid":"caret"})},Px=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:Rx(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),ff=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Sx,selectionColor:i=kx,caretWidth:a=Cx,blinkInterval:s=Tx})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:wx,"data-testid":"selection-overlay",children:[l&&e.map((c,d)=>jsxRuntime.jsx(Px,{rect:c,color:i,index:d},`sel-${c.pageIndex}-${c.x}-${c.y}-${d}`)),u&&t&&jsxRuntime.jsx(Ex,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var $l=10,ro=$l/2,Jr=2,bf="#2563eb",gf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Ix={position:"absolute",border:`${Jr}px solid ${bf}`,pointerEvents:"none",boxSizing:"border-box"},Fx={position:"absolute",width:`${$l}px`,height:`${$l}px`,backgroundColor:bf,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Lx={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"white",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},Bx={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Ax(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let c=Math.max(l/o,u/r);l=o*c,u=r*c;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function yf({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,c]=gm.useState(false),[d,p]=gm.useState(false),[f,m]=gm.useState(0),[b,h]=gm.useState(0),[x,T]=gm.useState(null),S=gm.useRef(null),I=gm.useRef(null),R=gm.useRef(o),D=gm.useRef(r),L=gm.useRef(i),pe=gm.useRef(a),$=gm.useRef(s),v=gm.useRef(l);R.current=o,D.current=r,L.current=i,pe.current=a,$.current=s,v.current=l;let _=gm.useRef(e),re=gm.useRef(t);_.current=e,re.current=t;let ae=gm.useCallback(()=>{if(!e||!I.current){T(null);return}let E=I.current.offsetParent;if(!E){T(null);return}let F=E.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-F.left)/t,top:(k.top-F.top)/t,width:k.width/t,height:k.height/t});},[e,t]);gm.useEffect(()=>{ae();},[ae]),gm.useEffect(()=>{if(!e)return;let E=I.current?.closest('[style*="overflow"]')??I.current?.closest(".paged-editor__container");if(!E)return;let F=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(ae);};return E.addEventListener("scroll",F,{passive:true}),window.addEventListener("resize",F,{passive:true}),()=>{E.removeEventListener("scroll",F),window.removeEventListener("resize",F),S.current&&cancelAnimationFrame(S.current);}},[e,ae]);let N=gm.useCallback((E,F)=>{if(!e||!x)return;F.preventDefault(),F.stopPropagation();let k=x.width,P=x.height,M=F.clientX,H=F.clientY,oe=Math.round(k),Q=Math.round(P);c(true),m(oe),h(Q),D.current?.();let V=ne=>{let Se=re.current,Me=(ne.clientX-M)/Se,Z=(ne.clientY-H)/Se,ie=!ne.shiftKey,Ie=Ax(E,Me,Z,k,P,ie);oe=Math.round(Ie.width),Q=Math.round(Ie.height),m(oe),h(Q),T(He=>{if(!He)return He;let qe={...He};return E.includes("w")&&(qe.left=He.left+(He.width-Ie.width)),E.includes("n")&&(qe.top=He.top+(He.height-Ie.height)),qe.width=Ie.width,qe.height=Ie.height,qe});},Y=()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",Y),c(false);let ne=_.current;ne&&R.current?.(ne.pmPos,oe,Q),L.current?.();};window.addEventListener("mousemove",V),window.addEventListener("mouseup",Y);},[e,x]),B=gm.useCallback(E=>{if(!e||!x)return;E.preventDefault(),E.stopPropagation();let F=4,k=E.clientX,P=E.clientY,M=false,H=null,oe=V=>{let Y=V.clientX-k,ne=V.clientY-P;!M&&Math.sqrt(Y*Y+ne*ne)<F||(M||(M=true,p(true),$.current?.(),H=document.createElement("div"),H.style.cssText="position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);",H.style.width=`${x.width}px`,H.style.height=`${x.height}px`,document.body.appendChild(H)),H&&(H.style.left=`${V.clientX-x.width/2}px`,H.style.top=`${V.clientY-x.height/2}px`));},Q=V=>{if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Q),H&&(H.remove(),H=null),p(false),M){let Y=_.current;Y&&pe.current?.(Y.pmPos,V.clientX,V.clientY),v.current?.();}};window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Q);},[e,x]);if(!!!(e&&x&&n))return jsxRuntime.jsx("div",{ref:I,style:{...gf,visibility:"hidden"},className:"image-selection-overlay"});let{left:ge,top:Pe,width:se,height:q}=x;return jsxRuntime.jsxs("div",{ref:I,style:gf,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...Ix,left:ge-Jr,top:Pe-Jr,width:se+Jr*2,height:q+Jr*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:ge,top:Pe,width:se,height:q,cursor:d?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:B}),jsxRuntime.jsx(es,{handle:"nw",style:{left:ge-ro,top:Pe-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"ne",style:{left:ge+se-ro,top:Pe-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"se",style:{left:ge+se-ro,top:Pe+q-ro},onMouseDown:N}),jsxRuntime.jsx(es,{handle:"sw",style:{left:ge-ro,top:Pe+q-ro},onMouseDown:N}),u&&jsxRuntime.jsxs("div",{style:{...Lx,left:ge+se/2,top:Pe+q+12},children:[f," \xD7 ",b]})]})}function es({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...Fx,...t,cursor:Bx[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var Dx="Calibri";function _l(e,t,n){if(!n||t<=n)return {width:e,height:t};let o=n/t;return {width:Math.round(e*o),height:n}}var Hx=11;function rt(e){return e/1440*96}var Nx=0;function ao(){return `block-${++Nx}`}function zx(e,t){let n=[];for(let o=0;o<=t;o+=1){let r=e[o]??0;if(r<=0)break;n.push(r);}return n.length===0?"1.":`${n.join(".")}.`}function ts(e,t){let n={};for(let o of e)switch(o.type.name){case "bold":n.bold=true;break;case "italic":n.italic=true;break;case "underline":{let r=o.attrs;if(r.style||r.color){let i=r.color?chunk4VUZBV2S_js.a(r.color,t):void 0;n.underline={style:r.style,color:i};}else n.underline=true;break}case "strike":n.strike=true;break;case "textColor":{let r=o.attrs;(r.themeColor||r.rgb)&&(n.color=chunk4VUZBV2S_js.a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=chunk4VUZBV2S_js.n(o.attrs.color);break;case "fontSize":{let r=o.attrs;n.fontSize=r.size/2;break}case "fontFamily":{let r=o.attrs;n.fontFamily=r.ascii||r.hAnsi;break}case "superscript":n.superscript=true;break;case "subscript":n.subscript=true;break;case "hyperlink":{let r=o.attrs;n.hyperlink={href:r.href,tooltip:r.tooltip};break}case "footnoteRef":{let r=o.attrs,i=typeof r.id=="string"?parseInt(r.id,10):r.id;r.noteType==="endnote"?n.endnoteRefId=i:n.footnoteRefId=i;break}case "comment":{let r=o.attrs.commentId;r&&(n.commentIds||(n.commentIds=[]),n.commentIds.push(r));break}case "insertion":n.isInsertion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break;case "deletion":n.isDeletion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break}return n}function Ox(e,t,n){let o=[],r=t+1,i=n.theme;return e.forEach((a,s)=>{let l=r+s;if(a.isText&&a.text){let u=ts(a.marks,i),c={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let c={kind:"tab",...ts(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="image"){let u=a.attrs,c=_l(u.width||100,u.height||100,n.pageContentHeight),d={kind:"image",src:u.src,width:c.width,height:c.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="field"){let u=a.attrs.fieldType,d={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="math"){let c={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((c,d)=>{let p=u+d;if(c.isText&&c.text){let f=ts(c.marks,i),m={kind:"text",text:c.text,...f,pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+c.nodeSize};o.push(f);}else if(c.type.name==="tab"){let m={kind:"tab",...ts(c.marks,i),pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="image"){let f=c.attrs,m=_l(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+c.nodeSize};o.push(b);}});}}),o}function $x(e,t){let n={};if(e.alignment){let s=e.alignment;s==="both"||s==="distribute"?n.alignment="justify":s==="left"?n.alignment="left":s==="center"?n.alignment="center":s==="right"&&(n.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(n.spacing={},e.spaceBefore!=null&&(n.spacing.before=rt(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=rt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=rt(e.lineSpacing),n.spacing.lineUnit="px",n.spacing.lineRule=e.lineSpacingRule):(n.spacing.line=e.lineSpacing/240,n.spacing.lineUnit="multiplier",n.spacing.lineRule="auto")));let o=e.indentLeft,r=e.indentFirstLine,i=e.hangingIndent;if(e.numPr?.numId&&o==null&&(o=((e.numPr.ilvl??0)+1)*720,r==null&&(r=-360,i=true)),(o!=null||e.indentRight!=null||r!=null)&&(n.indent={},o!=null&&(n.indent.left=rt(o)),e.indentRight!=null&&(n.indent.right=rt(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(rt(r)):n.indent.firstLine=rt(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?ns(u,t):void 0;s.top&&(n.borders.top=l(s.top)),s.bottom&&(n.borders.bottom=l(s.bottom)),s.left&&(n.borders.left=l(s.left)),s.right&&(n.borders.right=l(s.right)),s.between&&(n.borders.between=l(s.between)),s.bar&&(n.borders.bar=l(s.bar)),!n.borders.top&&!n.borders.bottom&&!n.borders.left&&!n.borders.right&&!n.borders.between&&!n.borders.bar&&delete n.borders;}e.shading?.fill?.rgb&&(n.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(n.tabs=e.tabs.map(s=>({val:_x(s.alignment),pos:s.position,leader:s.leader}))),e.pageBreakBefore&&(n.pageBreakBefore=true),e.keepNext&&(n.keepNext=true),e.keepLines&&(n.keepLines=true),e.contextualSpacing&&(n.contextualSpacing=true),e.bidi&&(n.bidi=true),e.styleId&&(n.styleId=e.styleId),e.numPr&&(n.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(n.listMarker=e.listMarker),e.listIsBullet!=null&&(n.listIsBullet=e.listIsBullet),e.listMarkerHidden&&(n.listMarkerHidden=true),e.listMarkerFontFamily&&(n.listMarkerFontFamily=e.listMarkerFontFamily),e.listMarkerFontSize&&(n.listMarkerFontSize=e.listMarkerFontSize);let a=e.defaultTextFormatting;return a&&(a.fontSize!=null&&(n.defaultFontSize=a.fontSize/2),a.fontFamily&&(n.defaultFontFamily=a.fontFamily.ascii||a.fontFamily.hAnsi)),n}function _x(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function Wl(e,t,n){let o=e.attrs,r=Ox(e,t,n),i=$x(o,n.theme);return {kind:"paragraph",id:ao(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Wx(e){return Math.max(1,Math.round(e/8*1.333))}var Vx={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",wave:"solid",doubleWave:"double",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function ns(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Vx[e.style]||"solid",width:Wx(e.size??0),color:e.color?chunk4VUZBV2S_js.a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=chunkSE5EN2QL_js.g(e.space)),n}function Ux(e,t){let n=e.borders;if(!n)return;let o={},r=["top","bottom","left","right"];for(let i of r){let a=n[i],s=a?ns(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function jx(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Wl(l,r,n)):l.type.name==="table"&&o.push(xf(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?rt(a.top):0,right:a?.right!=null?rt(a.right):7,bottom:a?.bottom!=null?rt(a.bottom):0,left:a?.left!=null?rt(a.left):7};return {id:ao(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?rt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Ux(i,n.theme),padding:s}}function Kx(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(jx(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:ao(),cells:o,height:i.height?rt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function xf(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(Kx(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(rt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(h=>h.width);b.every(h=>h!==void 0&&h>0)&&(a=b);}let u=e.attrs.justification,c=e.attrs._originalFormatting,d=c?.indent?.value&&c.indent.type==="dxa"?rt(c.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?rt(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?rt(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?rt(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?rt(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?rt(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?rt(p.rightFromText):void 0}:void 0;return {kind:"table",id:ao(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:d,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function Gx(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=_l(o.width||100,o.height||100,n);return {kind:"image",id:ao(),src:o.src,width:a.width,height:a.height,alt:o.alt,transform:o.transform,anchor:i?{isAnchored:true,offsetH:o.distLeft,offsetV:o.distTop,behindDoc:r==="behind"}:void 0,hlinkHref:o.hlinkHref,pmStart:t,pmEnd:t+e.nodeSize}}function Yx(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=Wl(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:ao(),width:o.width??chunkEV3CM6TU_js.d,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??chunkEV3CM6TU_js.c.top,bottom:o.marginBottom??chunkEV3CM6TU_js.c.bottom,left:o.marginLeft??chunkEV3CM6TU_js.c.left,right:o.marginRight??chunkEV3CM6TU_js.c.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function Sf(e,t={}){let n={...t,defaultFont:t.defaultFont??Dx,defaultSize:t.defaultSize??Hx},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=Wl(a,l,n),c=a.attrs;if(c.numPr&&!c.listMarker){let p=c.numPr.numId;if(p==null||p===0)break;let f=c.numPr.ilvl??0,m=i.get(p)??new Array(9).fill(0);m[f]=(m[f]??0)+1;for(let h=f+1;h<m.length;h+=1)m[h]=0;i.set(p,m);let b=c.listIsBullet?"\u2022":zx(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let d=c._sectionProperties;if(d||c.sectionBreakType){let p={kind:"sectionBreak",id:ao(),type:d?.sectionStart??c.sectionBreakType};if(d){(d.pageWidth||d.pageHeight)&&(p.pageSize={w:rt(d.pageWidth??12240),h:rt(d.pageHeight??15840)}),(d.marginTop!==void 0||d.marginLeft!==void 0)&&(p.margins={top:rt(d.marginTop??1440),bottom:rt(d.marginBottom??1440),left:rt(d.marginLeft??1440),right:rt(d.marginRight??1440)});let f=d.columnCount??1;if(f>1){let m={count:f,gap:rt(d.columnSpace??720),equalWidth:d.equalWidth??true,separator:d.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(xf(a,l,n));break;case "image":o.push(Gx(a,l,n.pageContentHeight));break;case "textBox":o.push(Yx(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:ao(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var _n=11,Qr="Calibri",os=1,lr=2;function qx(e,t){if(t&&t.length>0)for(let o of t){let r=chunkEV3CM6TU_js.k(o.pos);if(r>e+.5)return Math.max(1,r-e)}let n=e%Vl;return Math.max(1,n<.5?Vl:Vl-n)}function Xx(e,t,n,o=false){let r=1,i=e.length,a=0;for(;r<=i;){let s=r+i>>>1;chunkEV3CM6TU_js.h(e.slice(0,s),t)<=n?(a=s,r=s+1):i=s-1;}return o&&a===0?1:a}function kf(e){return {fontFamily:e.fontFamily??Qr,fontSize:e.fontSize??_n,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function vf(e,t,n){let o=chunkEV3CM6TU_js.l(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.singleLineRatio??1.15,s=o*a,l;if(t?.lineRule==="exact"&&t.line!==void 0)l=t.line;else if(t?.lineRule==="atLeast"&&t.line!==void 0){let u=s*os;l=Math.max(t.line,u);}else t?.line!==void 0&&t?.lineUnit==="multiplier"?l=s*t.line:t?.line!==void 0&&t?.lineUnit==="px"?l=t.line:l=s*os;return {ascent:r,descent:i,lineHeight:l}}function Cf(e,t,n){let o=chunkEV3CM6TU_js.g({fontSize:e,fontFamily:n??Qr});return vf(e,t,o)}function Tf(e){return e.kind==="text"}function Zx(e){return e.kind==="tab"}function Jx(e){return e.kind==="image"}function Qx(e){return e.kind==="lineBreak"}function eS(e){return e.kind==="field"}function tS(e){return !e.text||e.text.length===0}function nS(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];(o===" "||o==="-"||o===" ")&&t.push(n+1);}return t}var Vl=48;function wf(e,t,n,o){if(!n||n.length===0)return {leftMargin:0,rightMargin:0};let r=0,i=0,a=o+e,s=a+t;for(let l of n)s>l.topY&&a<l.bottomY&&(r=Math.max(r,l.leftMargin),i=Math.max(i,l.rightMargin));return {leftMargin:r,rightMargin:i}}function In(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,c=l?.right??0,d=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-c),f=Math.max(1,p-d),m=0,b=chunkEV3CM6TU_js.l(_n)*os,h=wf(0,b,a,s),x=Math.max(1,f-h.leftMargin-h.rightMargin),T=[];if(o.length===0){let $=r?.defaultFontSize??_n,v=r?.defaultFontFamily??Qr,_=Cf($,i,v);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,..._}),{kind:"paragraph",lines:T,totalHeight:_.lineHeight}}if(o.length===1&&Tf(o[0])&&tS(o[0])){let $=o[0],v=$.fontSize??r?.defaultFontSize??_n,_=$.fontFamily??r?.defaultFontFamily??Qr,re=Cf(v,i,_);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...re}),{kind:"paragraph",lines:T,totalHeight:re.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:h.leftMargin,rightOffset:h.rightMargin},I=()=>{let $=vf(S.maxFontSize,i,S.maxFontMetrics),v={...$};S.maxImageHeightPx>v.lineHeight&&(v.lineHeight=S.maxImageHeightPx,v.ascent=S.maxImageHeightPx*.8,v.descent=S.maxImageHeightPx*.2);let _={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...v};S.leftOffset>0&&(_.leftOffset=S.leftOffset),S.rightOffset>0&&(_.rightOffset=S.rightOffset),T.push(_),m+=$.lineHeight;},R=($,v)=>{I();let _=chunkEV3CM6TU_js.l(_n)*os,re=wf(m,_,a,s),ae=Math.max(1,p-re.leftMargin-re.rightMargin);S={fromRun:$,fromChar:v,toRun:$,toChar:v,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:ae,leftOffset:re.leftMargin,rightOffset:re.rightMargin};},D=$=>{let v=$.fontSize??_n;(!S.maxFontMetrics||v>S.maxFontSize)&&(S.maxFontSize=v,S.maxFontMetrics=chunkEV3CM6TU_js.g($));};for(let $=0;$<o.length;$++){let v=o[$];if(Qx(v)){S.toRun=$,S.toChar=0,R($+1,0);continue}if(Zx(v)){let _=kf(v);D(_);let re=r?.tabs,ae=l?.left??0,N=S.width+ae+(S.leftOffset??0),B=qx(N,re);S.width+B>S.availableWidth+lr&&(R($,0),D(_)),S.width+=B,S.toRun=$,S.toChar=1;continue}if(Jx(v)){let _=v.wrapType,re=v.displayMode==="float"||_&&["square","tight","through"].includes(_);if(v.position&&re){S.toRun=$,S.toChar=1;continue}if(_==="topAndBottom"||v.displayMode==="block"){S.width>0&&R($,0);let B=v.height,de=v.distTop??6,ge=v.distBottom??6;S.toRun=$,S.toChar=1,S.maxImageHeightPx=B+de+ge,R($+1,0);continue}let ae=v.width,N=v.height;N>S.maxImageHeightPx&&(S.maxImageHeightPx=N),S.width+ae>S.availableWidth+lr&&R($,0),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(eS(v)){let _=v.fallback||"1",re={fontFamily:v.fontFamily??Qr,fontSize:v.fontSize??_n,bold:v.bold,italic:v.italic};D(re);let ae=chunkEV3CM6TU_js.h(_,re);S.width>0&&S.width+ae>S.availableWidth+lr&&(R($,0),D(re)),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(Tf(v)){let _=v,re=_.text,ae=kf(_);if(D(ae),!re||re.length===0){S.toRun=$,S.toChar=0;continue}let N=nS(re),B=0;for(;B<re.length;){let de=re.length;for(let se of N)if(se>B){de=se;break}let ge=re.slice(B,de),Pe=chunkEV3CM6TU_js.h(ge,ae);if(Pe>S.availableWidth+lr){let se=0;for(;se<ge.length;){let q=S.availableWidth-S.width+lr,E=ge.slice(se),F=Xx(E,ae,q);if(F===0){if(S.width>0){R($,B+se),D(ae);continue}F=1;}let k=se+F,P=ge.slice(se,k),M=chunkEV3CM6TU_js.h(P,ae);S.width+=M,S.toRun=$,S.toChar=B+k,se=k,se<ge.length&&(R($,B+se),D(ae));}B=de;continue}S.width>0&&S.width+Pe>S.availableWidth+lr&&(R($,B),D(ae)),S.width+=Pe,S.toRun=$,S.toChar=de,B=de;}}}I();let pe=T.reduce(($,v)=>$+v.lineHeight,0);return i?.before&&(pe+=i.before),i?.after&&(pe+=i.after),{kind:"paragraph",lines:T,totalHeight:pe}}var oS=new Map;function Rf(){oS.clear();}var rS=new Map;function Ef(){rS.clear();}var iS=5e3,aS=iS,so=new Map;function Ul(e){let t=[];for(let o of e.runs)o.kind==="text"?t.push(`t:${o.text}|${o.fontFamily}|${o.fontSize}|${o.bold}|${o.italic}`):o.kind==="tab"?t.push(`tab:${o.width}`):o.kind==="image"?t.push(`img:${o.width}x${o.height}`):o.kind==="lineBreak"&&t.push("br");let n=e.attrs;return n&&(n.alignment&&t.push(`align:${n.alignment}`),n.indent&&t.push(`indent:${n.indent.left}|${n.indent.right}|${n.indent.firstLine}|${n.indent.hanging}`),n.spacing&&t.push(`spacing:${n.spacing.before}|${n.spacing.after}|${n.spacing.line}|${n.spacing.lineRule}`)),t.join("||")}function sS(){for(;so.size>aS;){let e=so.keys().next().value;if(e===void 0)break;so.delete(e);}}function jl(e,t){let n=Ul(e),o=so.get(n);if(o!==void 0&&o.maxWidth===t)return so.delete(n),so.set(n,o),o.measure}function Kl(e,t,n){let o=Ul(e);so.set(o,{measure:n,maxWidth:t}),sS();}function Pf(){so.clear();}function Gl(){Rf(),Ef(),Pf();}function lS(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function cS(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,c=i.slice(l,u);c.length>0&&n.push({...r,text:c});}else n.push(r);}}}return n}function dS(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",c=s===t.fromRun?t.fromChar:0,d=s===t.toRun?t.toChar:u.length;a+=d-c;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function uS(e,t,n,o){let r=0;for(let i=n;i<o&&i<e.lines.length;i++){let s=e.lines[i].lineHeight;if(t>=r&&t<r+s)return i;r+=s;}return o>n?Math.min(o-1,e.lines.length-1):null}function pS(e,t,n,o){let{pmStart:r,pmEnd:i}=dS(e,t);if(r===void 0||i===void 0)return {charOffset:0,pmPosition:e.pmStart??0};let a=e.attrs?.alignment??"left",s=0;a==="center"?s=Math.max(0,(o-t.width)/2):a==="right"&&(s=Math.max(0,o-t.width));let l=Math.max(0,n-s);if(l<=0)return {charOffset:0,pmPosition:r};let u=cS(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let c=0,d=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="image"){let m=f.width,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="lineBreak"){if(l>=c)return {charOffset:d,pmPosition:r+d};d+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=lS(f),h=chunkEV3CM6TU_js.i(m,b),x=c+h.width;if(l<=x){let T=l-c,S=chunkEV3CM6TU_js.j(T,h.charWidths),I=d+S;return {charOffset:I,pmPosition:r+I}}c=x,d+=m.length;}}return {charOffset:i-r,pmPosition:i}}function Mf(e){let{fragment:t,block:n,measure:o,localX:r,localY:i}=e;if(t.kind!=="paragraph"||n.kind!=="paragraph"||o.kind!=="paragraph")return null;let a=t,s=n,l=o,u=uS(l,i,a.fromLine,a.toLine);if(u===null)return null;let c=l.lines[u];if(!c)return null;let d=0;for(let S=a.fromLine;S<u;S++)d+=l.lines[S]?.lineHeight??0;let p=s.attrs?.indent,f=p?.left??0,m=p?.right??0,b=Math.max(0,t.width-f-m),h=r-f,{charOffset:x,pmPosition:T}=pS(s,c,h,b);return {pmPosition:T,charOffset:x,lineIndex:u}}function fS(e){let{cellBlock:t,cellMeasure:n,cellLocalX:o,cellLocalY:r}=e;if(!t||!n)return null;let i={fragment:{kind:"paragraph",blockId:t.id,x:0,y:0,width:n.lines.reduce((s,l)=>Math.max(s,l.width),100),fromLine:0,toLine:n.lines.length,height:n.totalHeight},block:t,measure:n,pageIndex:e.pageIndex,localX:o,localY:r};return Mf(i)?.pmPosition??null}function Yl(e,t){if(t)return fS(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?Mf(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Ff(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(c=>c.classList.contains("layout-page"));if(!i)return null;let a=r.find(c=>c.tagName==="SPAN"&&c.dataset.pmStart!==void 0&&c.dataset.pmEnd!==void 0);if(a)return ql(a,t);let s=r.find(c=>c.classList.contains("layout-empty-run"));if(s){let c=s.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let l=r.find(c=>c.classList.contains("layout-paragraph")&&c.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let c=If(l,t,n);return c!==null?c:Number(l.dataset.pmStart)}let u=r.find(c=>c.classList.contains("layout-table-cell"));return u?If(u,t,n):mS(e,i,t,n)}function ql(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let d=e.getBoundingClientRect(),p=(d.left+d.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,c=s;for(;u<c;){let d=Math.floor((u+c)/2),p=l.createRange();p.setStart(a,d),p.setEnd(a,d);let m=p.getBoundingClientRect().left;t<m?c=d:u=d+1;}if(u>0&&u<=s){let d=l.createRange();d.setStart(a,u-1),d.setEnd(a,u-1);let p=d.getBoundingClientRect();d.setStart(a,Math.min(u,s)),d.setEnd(a,Math.min(u,s));let f=d.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(u-1)}return o+Math.min(u,r-o)}function If(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let d=o.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let d of Array.from(r)){let p=d,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let d=e.querySelector(".layout-paragraph[data-pm-start]");return d?.dataset.pmStart?Number(d.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let d=i.closest(".layout-paragraph");return d?.dataset.pmStart?Number(d.dataset.pmStart):null}let l=null,u=1/0;for(let d of Array.from(s)){let p=d,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return ql(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let c=l.getBoundingClientRect();return t<c.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function mS(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let f=t.querySelectorAll(".layout-paragraph");if(f.length>0){let m=f[0];return Number(m.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let f of Array.from(a)){let m=f,b=m.getBoundingClientRect(),h=(b.top+b.bottom)/2,x=Math.abs(o-h);x<l&&(l=x,s=m);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return ql(m,n);let h=n<b.left?b.left-n:n-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return n<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)}var lo={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function gS(e){return e.kind==="paragraph"}function hS(e){return e.kind==="table"}function bS(e){return e.kind==="image"}function rs(e){e.style.position="absolute",e.style.overflow="hidden";}function yS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.paragraph}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromLine=String(e.fromLine),o.dataset.toLine=String(e.toLine),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.continuesFromPrev&&(o.dataset.continuesFromPrev="true"),e.continuesOnNext&&(o.dataset.continuesOnNext="true"),o}function xS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.table}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromRow=String(e.fromRow),o.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),o}function SS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.image}`,rs(o),o.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.isAnchored&&(o.dataset.anchored="true"),e.zIndex!==void 0&&(o.style.zIndex=String(e.zIndex)),o}function ei(e,t,n={}){let o=n.document??document;if(gS(e))return yS(e,t,o);if(hS(e))return xS(e,t,o);if(bS(e))return SS(e,t,o);let r=o.createElement("div");r.className=lo.fragment,rs(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function Xl(e){return e/1440*96}function kS(e){return e/96*1440}function CS(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(d=>d.val!=="clear").filter(d=>d.pos>=o),i=t.filter(d=>d.val==="clear").map(d=>d.pos),a=r.reduce((d,p)=>Math.max(d,p.pos),0),s=[...r];o>0&&!r.some(d=>d.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,c=o+14400;for(;u<c;){u+=n;let d=r.some(m=>Math.abs(m.pos-u)<20),p=i.some(m=>Math.abs(m-u)<20),f=o>0&&Math.abs(u-o)<20;!d&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((d,p)=>d.pos-p.pos)}function Lf(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=kS(e),l=CS(t).find(d=>d.pos>a);if(!l){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}let c=Xl(l.pos)-e;if(l.val==="center"||l.val==="end"){let d=o?o(n):0;l.val==="center"?c-=d/2:c-=d;}else if(l.val==="decimal"){let d=n.indexOf(r);if(d>=0&&o){let p=n.slice(0,d),f=o(p);c-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(c<1){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}return {width:c,leader:l.leader,alignment:l.val}}function TS(e){switch(e){case "single":case "thick":case "words":return "solid";case "double":return "double";case "dotted":case "dottedHeavy":return "dotted";case "dash":case "dashed":case "dashedHeavy":case "dashLong":case "dashLongHeavy":case "dashDot":case "dashDotHeavy":case "dashDotDot":case "dashDotDotHeavy":return "dashed";case "wave":case "wavyHeavy":case "wavyDouble":return "wavy";default:return "solid"}}var rn={fragment:"layout-paragraph",line:"layout-line",run:"layout-run",text:"layout-run-text",tab:"layout-run-tab",image:"layout-run-image",lineBreak:"layout-run-linebreak"};function ni(e){return e.kind==="text"}function is(e){return e.kind==="tab"}function Df(e){return e.kind==="image"}function Zl(e){return e.kind==="lineBreak"}function Jl(e){return e.kind==="field"}function wS(e,t,n){if(t.fontFamily&&(e.style.fontFamily=chunkEV3CM6TU_js.a(t.fontFamily).cssFallback),t.fontSize){let r=t.fontSize*96/72;e.style.fontSize=`${r}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let o=[];if(t.underline&&(o.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=TS(t.underline.style)),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&o.push("line-through"),t.commentIds&&t.commentIds.length>0){let r=t.commentIds.find(i=>!n||!n.has(i));r!=null&&(e.style.backgroundColor="rgba(255, 212, 0, 0.15)",e.style.borderBottom="1px solid rgba(255, 212, 0, 0.4)",e.dataset.commentId=String(r));}t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",o.includes("line-through")||o.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),o.length>0&&(e.style.textDecorationLine=o.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function cr(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Ql(e,t,n){let o=t.createElement("span");if(o.className=`${rn.run} ${rn.text}`,wS(o,e,n),cr(o,e.pmStart,e.pmEnd),e.hyperlink){let r=t.createElement("a");r.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(r.target="_blank",r.rel="noopener noreferrer"),e.hyperlink.tooltip&&(r.title=e.hyperlink.tooltip),r.textContent=e.text;let i=e.color||"#0563c1";r.style.color=i,r.style.textDecoration="underline",o.style.color=i,o.appendChild(r);}else o.textContent=e.text;return o}function Hf(e,t,n,o){let r=t.createElement("span");if(r.className=`${rn.run} ${rn.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",cr(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=vS(o);i&&(r.style.backgroundImage=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='4' height='16'><text x='0' y='12' font-size='12' fill='%23000'>${i}</text></svg>`)}")`,r.style.backgroundRepeat="repeat-x",r.style.backgroundPosition="bottom");}return r.textContent="\xA0",r}function vS(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function RS(e,t){let n=t.createElement("img");return n.className=`${rn.run} ${rn.image}`,n.src=e.src,n.width=e.width,n.height=e.height,e.alt&&(n.alt=e.alt),e.transform&&(n.style.transform=e.transform),n.style.display="inline",n.style.verticalAlign="middle",cr(n,e.pmStart,e.pmEnd),n}function Bf(e,t){let n=t.createElement("div");n.className="layout-block-image",n.style.display="block",n.style.textAlign="center",n.style.marginTop=`${e.distTop??6}px`,n.style.marginBottom=`${e.distBottom??6}px`;let o=t.createElement("img");return o.src=e.src,o.width=e.width,o.height=e.height,o.style.marginLeft="auto",o.style.marginRight="auto",e.alt&&(o.alt=e.alt),e.transform&&(o.style.transform=e.transform),cr(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function Nf(e,t){return dr(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?Bf(e,t):RS(e,t)}function zf(e,t){let n=t.createElement("br");return n.className=`${rn.run} ${rn.lineBreak}`,cr(n,e.pmStart,e.pmEnd),n}function Of(e,t,n){let o=e.fallback??"";switch(e.fieldType){case "PAGE":o=String(n.pageNumber);break;case "NUMPAGES":o=String(n.totalPages);break;case "DATE":o=new Date().toLocaleDateString();break;case "TIME":o=new Date().toLocaleTimeString();break}let r={text:o,bold:e.bold,italic:e.italic,underline:e.underline,strike:e.strike,color:e.color,highlight:e.highlight,fontFamily:e.fontFamily,fontSize:e.fontSize,pmStart:e.pmStart,pmEnd:e.pmEnd};return Ql(r,t,n?.resolvedCommentIds)}function ES(e,t,n){if(ni(e))return Ql(e,t,n?.resolvedCommentIds);if(is(e))return Hf(e,t,48,void 0);if(Df(e))return Nf(e,t);if(Zl(e))return zf(e,t);if(Jl(e)&&n)return Of(e,t,n);let o=t.createElement("span");return o.className=rn.run,o}function $f(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(ni(i)){let a=r===t.fromRun?t.fromChar:0,s=r===t.toRun?t.toChar:i.text.length;if(a>0||s<i.text.length){let l=i.text.slice(a,s);n.push({...i,text:l,pmStart:i.pmStart!==void 0?i.pmStart+a:void 0,pmEnd:i.pmStart!==void 0?i.pmStart+s:void 0});}else n.push(i);}else n.push(i);}return n}function PS(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function MS(e){return {val:e.val,pos:e.pos,leader:e.leader}}function IS(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(ni(i))o+=i.text;else if(Jl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(is(i)||Zl(i))break}return o}function FS(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=chunkEV3CM6TU_js.a(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function _f(e,t,n,o,r){let i=o.createElement("div");i.className=rn.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=$f(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${rn.run} layout-empty-run`,b.innerHTML=" ",i.appendChild(b),i}let s=n==="justify",l=false;s&&r&&(l=!r.isLastLine||r.paragraphEndsWithLineBreak,l&&(i.style.textAlign="justify",i.style.textAlignLast="justify",i.style.width=`${r.availableWidth}px`)),i.style.whiteSpace="pre";let u=a.some(b=>ni(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let c=a.some(is),d,p=FS(o);if(c){let b=r?.tabStops?.map(MS),h=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;d={explicitStops:b,leftIndent:h};}let f=0,m=r?.leftIndentPx??0;if(r?.isFirstLine){let b=r?.firstLineIndentPx??0;f=m+b;}else f=m;for(let b=0;b<a.length;b++){let h=a[b];if(is(h)&&d){let x=IS(a,b,r?.context),T=Lf(f,d,x,p),S=Hf(h,o,T.width,T.leader);i.appendChild(S),f+=T.width;}else if(ni(h)){let x=Ql(h,o,r?.context?.resolvedCommentIds);if(h.highlight){let R=(h.fontSize?h.fontSize*96/72:14.67)*1.2,D=Math.max(0,t.lineHeight-R);if(D>0){let L=D/2;x.style.paddingTop=`${L}px`,x.style.paddingBottom=`${L}px`;}}i.appendChild(x);let T=h.fontSize||11,S=h.fontFamily||"Calibri";f+=p(h.text,T,S);}else if(Df(h)){if(dr(h))continue;let x=PS(h);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let T=Nf(h,o);i.appendChild(T),h.displayMode!=="block"&&h.wrapType!=="topAndBottom"&&(f+=h.width);}else if(Zl(h)){let x=zf(h,o);i.appendChild(x);}else if(Jl(h)&&r?.context){let x=Of(h,o,r.context);i.appendChild(x);let T=h.fallback??"";h.fieldType==="PAGE"?T=String(r.context.pageNumber):h.fieldType==="NUMPAGES"&&(T=String(r.context.totalPages));let S=h.fontSize||11,I=h.fontFamily||"Calibri";f+=p(T,S,I);}else {let x=ES(h,o,r?.context);i.appendChild(x);}}return i}function ti(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function Af(e,t){return !e&&!t||!e||!t?false:ti(e.top,t.top)&&ti(e.bottom,t.bottom)&&ti(e.left,t.left)&&ti(e.right,t.right)&&ti(e.between,t.between)}function Wn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=rn.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),cr(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId);let u=t.attrs?.bidi;u&&(a.dir="rtl"),l?l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":l==="left"?a.style.textAlign="left":a.style.textAlign=u?"right":"left":u&&(a.style.textAlign="right");let c=t.attrs?.indent,d=0,p=0;c&&(u?(c.left&&c.left>0&&(p=c.left),c.right&&c.right>0&&(d=c.right)):(c.left&&c.left>0&&(d=c.left),c.right&&c.right>0&&(p=c.right)));let f=t.attrs?.borders;if(f){let R=v=>{switch(v){case "single":return "solid";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "thick":return "solid";case "wave":return "wavy";case "dashSmallGap":return "dashed";case "nil":case "none":return "none";default:return "solid"}};a.style.boxSizing="border-box";let D=v=>`${v.width}px ${R(v.style)} ${v.color}`,L=Af(r.prevBorders,f),pe=Af(f,r.nextBorders);if(L&&f.between?a.style.borderTop=D(f.between):f.top&&!L&&(a.style.borderTop=D(f.top)),f.bottom&&!pe&&(a.style.borderBottom=D(f.bottom)),f.left&&(a.style.borderLeft=D(f.left)),f.right&&(a.style.borderRight=D(f.right)),f.bar){let v=i.createElement("div");v.style.position="absolute",v.style.left="-8px",v.style.top="0",v.style.bottom="0",v.style.borderLeft=D(f.bar),a.style.position="relative",a.appendChild(v);}if(f.top||f.bottom||f.left||f.right||f.between){let v=f.top||f.between;a.style.paddingLeft=f.left?`${f.left.space??4}px`:"0",a.style.paddingRight=f.right?`${f.right.space??4}px`:"0",a.style.paddingTop=v?`${v.space??2}px`:"0",a.style.paddingBottom=f.bottom?`${f.bottom.space??6}px`:"0";}}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let m=e.width-d-p,h=t.runs[t.runs.length-1]?.kind==="lineBreak",x=n.lines.length,T=0;c?.hanging&&c.hanging>0?T=-c.hanging:c?.firstLine&&c.firstLine>0&&(T=c.firstLine);let S=0,I=r.renderedInlineImageKeys??new Set;for(let R=0;R<s.length;R++){let D=s[R],L=e.fromLine+R,pe=L===x-1,$=L===0&&!e.continuesFromPrev,v=D.leftOffset??0,_=D.rightOffset??0,re=m;if($){let de=c?.hanging&&c.hanging>0,ge=c?.firstLine&&c.firstLine>0;de&&c?.hanging?re=m+c.hanging:ge&&c?.firstLine&&(re=m-c.firstLine);}let ae=_f(t,D,l,i,{availableWidth:re-v-_,isLastLine:pe,isFirstLine:$,paragraphEndsWithLineBreak:h,tabStops:t.attrs?.tabs,leftIndentPx:d,firstLineIndentPx:$?T:0,context:o,renderedInlineImageKeys:I});if(v>0||_>0){v>0&&(ae.style.marginLeft=`${v}px`),_>0&&(ae.style.marginRight=`${_}px`);let de=re-v-_;de>0&&(ae.style.width=`${de}px`);}S+=D.lineHeight;let N=c?.hanging&&c.hanging>0,B=c?.firstLine&&c.firstLine>0;if($?d>0&&N?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`-${c.hanging}px`):d>0&&B?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:B&&(ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:N&&(ae.style.paddingLeft=`${c.hanging}px`),p>0&&(ae.style.paddingRight=`${p}px`),$&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let de=Math.max(0,d-(c?.hanging??0));ae.style.paddingLeft=`${de}px`,ae.style.textIndent="0";let ge;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let E=D.fromRun;E<=D.toRun;E++){let F=t.runs[E];if(F&&F.kind==="text"){ge=F;break}}let Pe=t.attrs.listMarkerFontFamily??ge?.fontFamily??t.attrs.defaultFontFamily,se=t.attrs.listMarkerFontSize??ge?.fontSize??t.attrs.defaultFontSize,q=LS(t.attrs.listMarker,c,i,Pe,se);ae.insertBefore(q,ae.firstChild);}a.appendChild(ae);}return a}function LS(e,t,n,o,r){let i=n.createElement("span");if(i.className="layout-list-marker",i.style.display="inline-block",o&&(i.style.fontFamily=chunkEV3CM6TU_js.a(o).cssFallback),r){let s=r*96/72;i.style.fontSize=`${s}px`;}i.textContent=e;let a=t?.hanging??24;return i.style.minWidth=`${a}px`,i.style.textAlign="left",i.style.boxSizing="border-box",i}var Fn={table:"layout-table",row:"layout-table-row",cell:"layout-table-cell",cellContent:"layout-table-cell-content",resizeHandle:"layout-table-resize-handle",rowResizeHandle:"layout-table-row-resize-handle",tableEdgeHandleBottom:"layout-table-edge-handle-bottom",tableEdgeHandleRight:"layout-table-edge-handle-right"};function BS(e,t,n){let o=[],r=0;for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i];if(a?.kind!=="paragraph"){let u=t.blocks[i];u&&u.kind==="table"&&(r+=u.totalHeight??0);continue}let s=a;for(let u of s.runs){if(u.kind!=="image")continue;let c=u;if(!dr(c))continue;let d=c.position,p=c.distTop??0,f=c.distBottom??0,m=c.distLeft??12,b=c.distRight??12,h="left",x=0;if(d?.horizontal){let I=d.horizontal;I.align==="right"?(h="right",x=n-c.width):I.align==="left"?x=0:I.align==="center"?x=(n-c.width)/2:I.posOffset!==void 0&&(x=co(I.posOffset),h=x>n/2?"right":"left");}else c.cssFloat==="right"&&(h="right",x=n-c.width);let T=r;if(d?.vertical){let I=d.vertical;I.posOffset!==void 0?T=r+co(I.posOffset):I.align==="top"&&(T=0);}x=Math.max(0,Math.min(x,n-c.width));let S="bothSides";c.cssFloat==="left"?S="right":c.cssFloat==="right"&&(S="left"),o.push({src:c.src,width:c.width,height:c.height,alt:c.alt,transform:c.transform,x,y:T,side:h,distTop:p,distBottom:f,distLeft:m,distRight:b,wrapText:S,pmStart:c.pmStart,pmEnd:c.pmEnd});}let l=t.blocks[i];l&&l.kind==="paragraph"&&(r+=l.totalHeight);}return o}function AS(e,t,n,o){let r=o.createElement("div");r.className=Fn.cellContent,r.style.position="relative";let i=e.padding?.left??7,a=e.padding?.right??7,s=Math.max(0,t.width-i-a);r.style.width=`${s}px`;let l=BS(e,t,s),u;if(l.length>0){u=l.map(p=>{let f=p.x+p.width+p.distRight,m=p.y-p.distTop,b=p.y+p.height+p.distBottom,h=0,x=0,T=p.wrapText??"bothSides";return T==="right"?h=f:T==="left"?x=s-(p.x-p.distLeft):p.side==="left"?h=f:x=s-(p.x-p.distLeft),{leftMargin:h,rightMargin:x,topY:m,bottomY:b}});let d=o.createElement("div");d.className="layout-cell-floating-images-layer",d.style.position="absolute",d.style.top="0",d.style.left="0",d.style.width="100%",d.style.height="100%",d.style.pointerEvents="none",d.style.zIndex="10",d.style.overflow="hidden";for(let p of l){let f=o.createElement("div");f.className="layout-cell-floating-image",f.style.position="absolute",f.style.left=`${p.x}px`,f.style.top=`${p.y}px`,f.style.pointerEvents="auto",p.pmStart!==void 0&&(f.dataset.pmStart=String(p.pmStart)),p.pmEnd!==void 0&&(f.dataset.pmEnd=String(p.pmEnd));let m=o.createElement("img");m.src=p.src,m.style.width=`${p.width}px`,m.style.height=`${p.height}px`,m.style.display="block",p.alt&&(m.alt=p.alt),p.transform&&(m.style.transform=p.transform),f.appendChild(m),d.appendChild(f);}r.appendChild(d);}let c=0;for(let d=0;d<e.blocks.length;d++){let p=e.blocks[d],f=t.blocks[d];if(p?.kind==="paragraph"&&f?.kind==="paragraph"){let m=p,b=f;u&&u.length>0&&(b=In(m,s,{floatingZones:u,paragraphYOffset:c}));let h={blockId:m.id,width:s,height:b.totalHeight,fromLine:0,toLine:b.lines.length,pmStart:m.pmStart,pmEnd:m.pmEnd},x={...n,insideTableCell:true},T=Wn(h,m,b,x,{document:o});T.style.position="relative",r.appendChild(T),c+=b.totalHeight;}else if(p?.kind==="table"&&f?.kind==="table"){let h=DS(p,f,n,o);h.style.position="relative",r.appendChild(h),c+=f.totalHeight??0;}}return r}function DS(e,t,n,o){let r=o.createElement("div");r.className=`${Fn.table} layout-nested-table`,r.style.position="relative",r.style.width=`${t.totalWidth}px`,r.style.display="block",e.justification==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):e.justification==="right"?r.style.marginLeft="auto":e.indent&&(r.style.marginLeft=`${e.indent}px`),r.dataset.blockId=String(e.id),e.pmStart!==void 0&&(r.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(r.dataset.pmEnd=String(e.pmEnd));let i=[],a=0;for(let u=0;u<t.rows.length;u++)i.push(a),a+=t.rows[u]?.height??0;i.push(a);let s=new Map,l=0;for(let u=0;u<e.rows.length;u++){let c=e.rows[u],d=t.rows[u];if(!c||!d)continue;let p=ec(c,d,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=d.height;}return r.style.height=`${l}px`,r}function as(e,t,n){let o=`border${t.charAt(0).toUpperCase()+t.slice(1)}`;if(!n||n.style==="none"||n.style==="nil"||n.width===0)e.style[o]="none";else {let r=n.width??1,i=n.color??"#000000",a=n.style??"solid";e.style[o]=`${r}px ${a} ${i}`;}}function HS(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Fn.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,c=e.padding?.bottom??1,d=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${c}px ${d}px`,e.borders&&(r.isFirstRow&&as(s,"top",e.borders.top),as(s,"right",e.borders.right),as(s,"bottom",e.borders.bottom),r.isFirstCol&&as(s,"left",e.borders.left)),e.background&&(s.style.backgroundColor=e.background),e.verticalAlign)switch(s.style.display="flex",s.style.flexDirection="column",e.verticalAlign){case "top":s.style.justifyContent="flex-start";break;case "center":s.style.justifyContent="center";break;case "bottom":s.style.justifyContent="flex-end";break}let p=AS(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let f=e.blocks[0],m=e.blocks[e.blocks.length-1];f&&"pmStart"in f&&f.pmStart!==void 0&&(s.dataset.pmStart=String(f.pmStart)),m&&"pmEnd"in m&&m.pmEnd!==void 0&&(s.dataset.pmEnd=String(m.pmEnd));}return s}function ec(e,t,n,o,r,i,a,s,l,u,c){let d=s.createElement("div");d.className=Fn.row,d.style.position="absolute",d.style.left="0",d.style.top=`${o}px`,d.style.width="100%",d.style.height=`${t.height}px`,d.dataset.rowIndex=String(n);let p=new Set;if(l){for(let[,b]of l)if(b.startRow<n&&b.startRow+b.rowSpan>n)for(let h=0;h<b.colSpan;h++)p.add(b.columnIndex+h);}let f=0,m=0;for(;p.has(m);)f+=r[m]??0,m++;for(let b=0;b<e.cells.length;b++){let h=e.cells[b],x=t.cells[b];if(!h||!x)continue;let T=h.colSpan??1,S=h.rowSpan??1,I=t.height;if(S>1&&u){I=0;for(let v=n;v<n+S&&v<u.length-1;v++)I+=(u[v+1]??0)-(u[v]??0);I===0&&(I=t.height*S);}let R=n===0||c===true,L=m===0;m+T>=r.length;let $=HS(h,x,f,I,{isFirstRow:R,isFirstCol:L},a,s);if($.dataset.cellIndex=String(b),$.dataset.columnIndex=String(m),S>1&&($.dataset.rowSpan=String(S)),d.appendChild($),S>1&&l){let v=`${n}-${m}`;l.set(v,{cell:h,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:T,x:f,totalHeight:I});}for(let v=0;v<T&&m+v<r.length;v++)f+=r[m+v]??0;for(m+=T;p.has(m);)f+=r[m]??0,m++;}return d}function ss(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Fn.table,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.dataset.blockId=String(e.blockId),a.dataset.fromRow=String(e.fromRow),a.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=0;for(let m=0;m<n.columnWidths.length-1;m++){s+=n.columnWidths[m]??0;let b=i.createElement("div");b.className=Fn.resizeHandle,b.style.position="absolute",b.style.left=`${s-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}let l=[],u=0;for(let m=0;m<n.rows.length;m++)l.push(u),u+=n.rows[m]?.height??0;l.push(u);let c=new Map,d=e.headerRowCount??0,p=0;if(d>0&&e.continuesFromPrev)for(let m=0;m<d;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,m===0);x.dataset.repeatedHeader="true",a.appendChild(x),p+=h.height;}for(let m=e.fromRow;m<e.toRow;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=d>0&&e.continuesFromPrev?false:e.continuesFromPrev&&m===e.fromRow,T=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,x);a.appendChild(T),p+=h.height;}let f=0;for(let m=e.fromRow;m<e.toRow;m++)if(f+=n.rows[m]?.height??0,m<e.toRow-1){let b=i.createElement("div");b.className=Fn.rowResizeHandle,b.style.position="absolute",b.style.left="0",b.style.top=`${f-3}px`,b.style.width="100%",b.style.height="6px",b.style.cursor="row-resize",b.style.zIndex="10",b.dataset.rowIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}if(e.toRow===t.rows.length){let m=i.createElement("div");m.className=Fn.tableEdgeHandleBottom,m.style.position="absolute",m.style.left="0",m.style.top=`${f-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(t.rows.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="bottom",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let m=n.columnWidths.reduce((h,x)=>h+x,0),b=i.createElement("div");b.className=Fn.tableEdgeHandleRight,b.style.position="absolute",b.style.left=`${m-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(n.columnWidths.length-1),b.dataset.tableBlockId=String(e.blockId),b.dataset.isEdge="right",e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}return a}var tc={image:"layout-image",imageAnchored:"layout-image-anchored"};function ls(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=tc.image,e.isAnchored&&a.classList.add(tc.imageAnchored),a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",e.zIndex!==void 0&&(a.style.zIndex=String(e.zIndex)),t.anchor?.behindDoc&&(a.style.zIndex="-1"),a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=i.createElement("img");if(s.src=t.src,s.alt=t.alt??"",s.style.width="100%",s.style.height="100%",s.style.objectFit="contain",s.style.display="block",t.transform&&(s.style.transform=t.transform),s.draggable=false,t.hlinkHref){let l=i.createElement("a");l.href=t.hlinkHref,l.target="_blank",l.rel="noopener noreferrer",l.style.display="block",l.style.width="100%",l.style.height="100%",l.appendChild(s),a.appendChild(l);}else a.appendChild(s);return a}var Wf={textBox:"layout-textbox"};function cs(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=Wf.textBox,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.style.boxSizing="border-box",t.fillColor&&(a.style.backgroundColor=t.fillColor),t.outlineWidth&&t.outlineWidth>0){let c=t.outlineStyle||"solid",d=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${c} ${d}`;}let s=t.margins??chunkEV3CM6TU_js.c;a.style.padding=`${s.top}px ${s.right}px ${s.bottom}px ${s.left}px`,a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let l=e.width-s.left-s.right,u=0;for(let c=0;c<t.content.length;c++){let d=t.content[c],p=n.innerMeasures[c];if(!p)continue;let f={blockId:d.id,width:l,height:p.totalHeight,pmStart:d.pmStart,pmEnd:d.pmEnd,fromLine:0,toLine:p.lines.length},m=Wn(f,d,p,o,{document:i});m.style.position="relative",m.style.left="0",m.style.top="0",a.appendChild(m),u+=p.totalHeight;}return a}var uo={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function us(e,t,n,o){if(e.style.position="relative",e.style.width=`${t}px`,e.style.height=`${n}px`,e.style.backgroundColor=o.backgroundColor??"#ffffff",e.style.overflow="hidden",e.style.fontFamily='Calibri, "Segoe UI", Arial, sans-serif',e.style.fontSize=`${1056/72}px`,e.style.color="#000000",o.showBorders&&(e.style.border="1px solid #ccc"),o.showShadow&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)"),o.pageBorders){let r=o.pageBorders,i=["top","bottom","left","right"],a=["Top","Bottom","Left","Right"];for(let s=0;s<i.length;s++){let l=r[i[s]];if(l&&l.style!=="none"&&l.style!=="nil"){let u=Jo(l,a[s],o.theme);for(let[c,d]of Object.entries(u))e.style[c]=String(d);}}}}function NS(e,t){let n=t.margins;e.style.position="absolute",e.style.top=`${n.top}px`,e.style.left=`${n.left}px`,e.style.right=`${n.right}px`,e.style.bottom=`${n.bottom}px`,e.style.overflow="visible";}function jf(e){return e?.align??e?.alignment}function zS(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=jf(n),r=n.posOffset!==void 0?co(n.posOffset):void 0;if(n.relativeTo==="page"){if(r!==void 0)return r-t.flowTop;if(o==="top")return -t.flowTop;if(o==="bottom")return t.pageHeight-e.height-t.flowTop;if(o==="center")return (t.pageHeight-e.height)/2-t.flowTop}if(n.relativeTo==="margin"){let i=t.margins.top,a=t.pageHeight-t.margins.top-t.margins.bottom;if(r!==void 0)return i+r-t.flowTop;if(o==="top")return i-t.flowTop;if(o==="bottom")return i+a-e.height-t.flowTop;if(o==="center")return i+(a-e.height)/2-t.flowTop}return r!==void 0?e.paragraphY+r:e.paragraphY}function OS(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=jf(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)-n.flowLeft}px`;return}if(r==="right"){e.style.left=`${n.pageWidth-t.width-n.flowLeft}px`;return}if(r==="center"){e.style.left=`${(n.pageWidth-t.width)/2-n.flowLeft}px`;return}if(r==="left"){e.style.left=`${-n.flowLeft}px`;return}}if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)}px`;return}if(r==="right"){e.style.left=`${n.contentWidth-t.width}px`;return}if(r==="center"){e.style.left=`${(n.contentWidth-t.width)/2}px`;return}e.style.left="0";}function $S(e,t,n){e.style.position="absolute",e.style.left=`${t.x-n.left}px`,e.style.top=`${t.y-n.top}px`,e.style.width=`${t.width}px`,"height"in t&&(e.style.height=`${t.height}px`);}function co(e){return e===void 0?0:Math.round(e*96/914400)}function dr(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function _S(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!dr(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,c=i.distRight??12,d="left",p=0;if(a?.horizontal){let b=a.horizontal;b.align==="right"?(d="right",p=n-i.width):b.align==="left"?(d="left",p=0):b.align==="center"?(d="left",p=(n-i.width)/2):b.posOffset!==void 0&&(p=co(b.posOffset),d=p>n/2?"right":"left");}else i.cssFloat==="right"&&(d="right",p=n-i.width);let f=0;if(a?.vertical){let b=a.vertical;b.align==="top"?f=0:b.align==="bottom"?f=t:b.posOffset!==void 0?f=co(b.posOffset):f=t,b.relativeTo==="margin"&&(b.align==="top"||b.posOffset!==void 0)||b.relativeTo==="paragraph"&&(f=t+f);}else f=t;let m="bothSides";i.cssFloat==="left"?m="right":i.cssFloat==="right"&&(m="left"),o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:d,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:c,pmStart:i.pmStart,pmEnd:i.pmEnd,wrapText:m,wrapType:i.wrapType});}return o}function WS(e,t){return e.map(n=>{let o=n.x+n.width+n.distRight,r=n.y-n.distTop,i=n.y+n.height+n.distBottom,a=0,s=0,l=n.wrapText??"bothSides";return l==="right"?a=o:l==="left"?s=t-(n.x-n.distLeft):n.side==="left"?a=o:s=t-(n.x-n.distLeft),{leftMargin:a,rightMargin:s,topY:r,bottomY:i}})}function VS(e,t){let n=t.createElement("div");n.className="layout-floating-images-layer",n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0",n.style.bottom="0",n.style.pointerEvents="none",n.style.zIndex="10";for(let o of e){let r=t.createElement("div");r.className="layout-page-floating-image",r.style.position="absolute",r.style.pointerEvents="auto",r.style.top=`${o.y}px`,r.style.left=`${o.x}px`,o.pmStart!==void 0&&(r.dataset.pmStart=String(o.pmStart)),o.pmEnd!==void 0&&(r.dataset.pmEnd=String(o.pmEnd));let i=t.createElement("img");i.src=o.src,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.display="block",o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function Vf(e,t,n,o){let r=n.document??document,i=r.createElement("div");i.style.position="relative";let a=t.contentWidth??600,s=[],l=0;for(let u=0;u<e.blocks.length;u++){let c=e.blocks[u],d=e.measures[u];if(c?.kind==="paragraph"&&d?.kind==="paragraph"){let p=c,f=d,m=l,b=[];for(let S of p.runs)if(S.kind==="image"&&"position"in S&&S.position){let I=S;s.push({src:I.src,width:I.width,height:I.height,alt:I.alt,paragraphY:m,position:I.position});}else b.push(S);let h={...p,runs:b},x={blockId:p.id,width:a,height:f.totalHeight,fromLine:0,toLine:f.lines.length},T=Wn(x,h,f,t,{document:r});T.style.position="relative",T.style.marginBottom="0",i.appendChild(T),l+=f.totalHeight;}}for(let u of s){let c=r.createElement("img");c.src=u.src,c.width=u.width,c.height=u.height,u.alt&&(c.alt=u.alt),c.style.position="absolute",c.style.display="block",c.style.width=`${u.width}px`,c.style.height=`${u.height}px`,c.style.maxWidth="none",c.style.maxHeight="none",OS(c,u,o),c.style.top=`${zS(u,o)}px`,i.appendChild(c);}return i}function US(e,t,n){let o=n.createElement("div");o.className="layout-footnote-area",o.style.width=`${t}px`;let r=n.createElement("div");r.style.width="33%",r.style.height="0.5px",r.style.backgroundColor="#000",r.style.marginBottom="6px",r.style.marginTop="6px",o.appendChild(r);for(let i of e){let a=n.createElement("div");a.style.fontSize="10px",a.style.lineHeight="1.3",a.style.marginBottom="4px",a.style.color="#000";let s=n.createElement("sup");s.textContent=i.displayNumber,s.style.fontSize="7px",s.style.marginRight="2px",a.appendChild(s);let l=n.createTextNode(" "+i.text);a.appendChild(l),o.appendChild(a);}return o}function nc(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??uo.page,r.dataset.pageNumber=String(e.number),us(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=uo.content,NS(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let f of e.fragments)if(f.kind==="paragraph"&&n.blockLookup){let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph"){let b=m.block,h=f.y-e.margins.top,x=_S(b,h,a);s.push(...x);}}for(let f of s)l.push({side:f.side,x:f.x,y:f.y,width:f.width,height:f.height,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,wrapText:f.wrapText,wrapType:f.wrapType});if(n.blockLookup)for(let f of e.fragments){if(f.kind!=="table")continue;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind!=="table")continue;let h=m.block.floating;if(!h)continue;let x=f.x-e.margins.left,T=f.y-e.margins.top,S=h.topFromText??0,I=h.bottomFromText??0,R=h.leftFromText??12,D=h.rightFromText??12,L=x<a/2?"left":"right";l.push({side:L,x,y:T,width:f.width,height:f.height,distTop:S,distBottom:I,distLeft:R,distRight:D});}let u=l.length>0?WS(l,a):[];if(s.length>0){let f=VS(s,o);i.appendChild(f);}let c=f=>{if(f.kind!=="paragraph"||!n.blockLookup||!f.blockId)return;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph")return m.block.attrs?.borders},d,p=new Map;for(let f=0;f<e.fragments.length;f++){let m=e.fragments[f],b,h={...t,section:"body",contentWidth:a},x=m.y-e.margins.top;if(n.blockLookup&&m.blockId){let T=n.blockLookup.get(String(m.blockId));if(m.kind==="paragraph"&&T?.block.kind==="paragraph"&&T?.measure.kind==="paragraph"){let S=T.block,I=f+1<e.fragments.length?c(e.fragments[f+1]):void 0,R=String(m.blockId),D=p.get(R);D||(D=new Set,p.set(R,D));let L=T.measure;u.length>0&&(L=In(S,a,{floatingZones:u,paragraphYOffset:x})),b=Wn(m,S,L,h,{document:o,prevBorders:d,nextBorders:I,renderedInlineImageKeys:D}),d=S.attrs?.borders;}else m.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=ss(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=ls(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=cs(m,T.block,T.measure,h,{document:o}),d=void 0):(b=ei(m,h,{document:o}),d=void 0);}else b=ei(m,h,{document:o}),d=void 0;$S(b,m,{left:e.margins.left,top:e.margins.top}),i.appendChild(b);}if(e.columns&&e.columns.separator&&e.columns.count>1){let f=e.columns.count,m=e.columns.gap,b=(a-(f-1)*m)/f,h=e.size.h-e.margins.top-e.margins.bottom;for(let x=0;x<f-1;x++){let T=(x+1)*b+x*m+m/2,S=o.createElement("div");S.style.position="absolute",S.style.left=`${T}px`,S.style.top="0",S.style.height=`${h}px`,S.style.width="0.5px",S.style.backgroundColor="#000",S.style.pointerEvents="none",i.appendChild(S);}}if(n.footnoteArea&&n.footnoteArea.length>0){let f=US(n.footnoteArea,a,o);f.style.position="absolute";let m=e.footnoteReservedHeight??0,b=e.size.h-e.margins.bottom-e.margins.top;f.style.top=`${b-m}px`,f.style.left="0",f.style.right="0",i.appendChild(f);}r.appendChild(i);{let m=n.headerDistance??e.margins.header??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.top-m,48),x=n.headerContent?.visualTop??0,T=n.headerContent?.visualBottom??n.headerContent?.height??0,S=Math.max(T-x,24),I=T>h,R=o.createElement("div");R.className=uo.header,R.style.position="absolute",R.style.top=`${m+x}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let D=!I;if(n.headerContent&&n.headerContent.blocks.length>0){let L=Vf(n.headerContent,{...t,section:"header",contentWidth:b},n,{flowTop:m,flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(D=false),R.appendChild(L);}D&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}{let m=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.bottom-m,48),x=n.footerContent?.visualTop??0,T=n.footerContent?.visualBottom??n.footerContent?.height??0,S=Math.max(T-x,24),I=S>h,R=o.createElement("div");R.className=uo.footer,R.style.position="absolute",R.style.top=`${e.size.h-m-S}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let D=!I;if(n.footerContent&&n.footerContent.blocks.length>0){let L=Vf(n.footerContent,{...t,section:"footer",contentWidth:b},n,{flowTop:e.size.h-m-(n.footerContent?.height??0),flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(D=false),R.appendChild(L);}D&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}return r}function oc(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body",resolvedCommentIds:n.resolvedCommentIds},r={...n};if(n.titlePg&&e.number===1&&(r.headerContent=n.firstPageHeaderContent,r.footerContent=n.firstPageFooterContent),n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Uf(e){let t=[];t.push(`s:${e.size.w},${e.size.h}`),t.push(`m:${e.margins.top},${e.margins.right},${e.margins.bottom},${e.margins.left}`),t.push(`n:${e.number}`),e.footnoteReservedHeight&&t.push(`fn:${e.footnoteReservedHeight}`);for(let n of e.fragments){let o=`${n.kind}:${n.blockId},${n.x},${n.y},${n.width},${n.height}`;n.pmStart!==void 0&&(o+=`,ps:${n.pmStart}`),n.pmEnd!==void 0&&(o+=`,pe:${n.pmEnd}`),n.kind==="paragraph"?o+=`,fl:${n.fromLine},tl:${n.toLine}`:n.kind==="table"&&(o+=`,fr:${n.fromRow},tr:${n.toRow}`),t.push(o);}return t.join("|")}function jS(e){let t=[];return e.headerContent&&t.push(`hdr:${e.headerContent.blocks.length},${e.headerContent.height},${e.headerContent.visualTop??0},${e.headerContent.visualBottom??e.headerContent.height}`),e.footerContent&&t.push(`ftr:${e.footerContent.blocks.length},${e.footerContent.height},${e.footerContent.visualTop??0},${e.footerContent.visualBottom??e.footerContent.height}`),e.firstPageHeaderContent&&t.push(`fp-hdr:${e.firstPageHeaderContent.blocks.length},${e.firstPageHeaderContent.height}`),e.firstPageFooterContent&&t.push(`fp-ftr:${e.firstPageFooterContent.blocks.length},${e.firstPageFooterContent.height}`),e.titlePg&&t.push("titlePg"),e.theme&&t.push(`thm:${e.theme.name??"default"}`),e.pageBorders&&t.push(`pb:${JSON.stringify(e.pageBorders)}`),e.headerDistance!==void 0&&t.push(`hd:${e.headerDistance}`),e.footerDistance!==void 0&&t.push(`fd:${e.footerDistance}`),t.join("|")}function KS(e,t){e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.gap=`${t}px`,e.style.padding=`${t}px`,e.style.backgroundColor="var(--doc-bg, #f8f9fa)";}var ds=2,GS=8;function Kf(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=jS(n),l=o>=GS;if(a&&a.optionsHash===s&&l){let h=a.pageStates,x=a.pageDataMap,T=i.__pageObserver,S=[];for(let D of e)S.push(Uf(D));let I=a.totalPages!==o,R=Math.min(h.length,e.length);for(let D=0;D<R;D++){let L=h[D],pe=S[D];if(L.fingerprint===pe&&!I){let _=x.get(L.element);_&&(_.page=e[D]);continue}let $=L.element,v=x.get($);v&&(v.page=e[D],v.rendered&&YS($,x,o,n)),L.fingerprint=pe,us($,e[D].size.w,e[D].size.h,n),$.dataset.pageNumber=String(e[D].number);}if(e.length>h.length){let D=n.document??document;for(let L=h.length;L<e.length;L++){let pe=e[L],$=D.createElement("div");$.className=n.pageClassName??uo.page,$.dataset.pageNumber=String(pe.number),$.dataset.pageIndex=String(L),us($,pe.size.w,pe.size.h,n),t.appendChild($),h.push({element:$,fingerprint:S[L]}),x.set($,{page:pe,index:L,rendered:false}),T&&T.observe($);}}if(e.length<h.length){for(let D=h.length-1;D>=e.length;D--){let L=h[D].element;T&&T.unobserve(L),x.delete(L),t.removeChild(L);}h.length=e.length;}for(let D=0;D<h.length;D++){let L=x.get(h[D].element);L&&(L.index=D);}a.totalPages=o,a.currentOptions=n;return}let c=i.__pageObserver;c&&(c.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,KS(t,r);let d=[],p=[];for(let h=0;h<e.length;h++){let x=e[h];if(p.push(Uf(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??uo.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(h),us(S,x.size.w,x.size.h,n),t.appendChild(S),d.push(S);}else {let{context:T,pageOptions:S}=oc(x,o,n),I=nc(x,T,S);t.appendChild(I),d.push(I);}}if(!l)return;let f=new Map;for(let h=0;h<e.length;h++)f.set(d[h],{page:e[h],index:h,rendered:false});let m=new IntersectionObserver(h=>{let x=i.__pageRenderState;if(!x)return;let{currentOptions:T,totalPages:S,pageDataMap:I}=x;for(let pe of h){let $=pe.target,v=I.get($);if(v&&pe.isIntersecting){ps($,I,S,T);for(let _=-ds;_<=ds;_++){let re=v.index+_;re>=0&&re<x.pageStates.length&&re!==v.index&&ps(x.pageStates[re].element,I,S,T);}}}let R=window.innerHeight,D=R*3,L=new Set;for(let[pe,$]of I){if(!$.rendered)continue;let v=pe.getBoundingClientRect();v.bottom>-D&&v.top<R+D&&L.add($.index);}for(let[pe,$]of I){if(!$.rendered)continue;let v=false;for(let _ of L)if(Math.abs($.index-_)<=ds+1){v=true;break}!v&&L.size>0&&qS(pe,I);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let h of d)m.observe(h);i.__pageObserver=m,i.__pageRenderState={pageStates:d.map((h,x)=>({element:h,fingerprint:p[x]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,ds+3);for(let h=0;h<b;h++)ps(d[h],f,o,n);}function ps(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=oc(r.page,n,o),s=nc(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function YS(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=oc(r.page,n,o),l=nc(r.page,i,a).querySelector(`.${uo.content}`),u=e.querySelector(`.${uo.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,ps(e,t,n,o));}function qS(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var fs=class{constructor(t={}){chunkH5NTJZO4_js.d(this,"container",null);chunkH5NTJZO4_js.d(this,"blockLookup",new Map);chunkH5NTJZO4_js.d(this,"pageStates",[]);chunkH5NTJZO4_js.d(this,"totalPages",0);chunkH5NTJZO4_js.d(this,"options");chunkH5NTJZO4_js.d(this,"doc");chunkH5NTJZO4_js.d(this,"resolvedCommentIds",new Set);this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body",resolvedCommentIds:this.resolvedCommentIds},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return Wn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return ss(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return ls(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return cs(t,r,i,n,{document:this.doc})}return ei(t,n,{document:this.doc})}applyFragmentPosition(t,n){t.style.position="absolute",t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,t.style.width=`${n.width}px`,"height"in n&&(t.style.height=`${n.height}px`);}getPageCount(){return this.totalPages}getPageElement(t){return this.pageStates[t]?.element??null}scrollToPage(t){let n=this.pageStates.find(o=>o.pageNumber===t);n?.element&&n.element.scrollIntoView({behavior:"smooth",block:"start"});}};var Vn,po,fo,Un,ur,Lo,Gf,rc,ms=class{constructor(){chunkH5NTJZO4_js.f(this,Lo);chunkH5NTJZO4_js.f(this,Vn,0);chunkH5NTJZO4_js.f(this,po,0);chunkH5NTJZO4_js.f(this,fo,false);chunkH5NTJZO4_js.f(this,Un,null);chunkH5NTJZO4_js.f(this,ur,new Set);}setStateSeq(t){chunkH5NTJZO4_js.g(this,Vn,t);}incrementStateSeq(){return ++chunkH5NTJZO4_js.i(this,Vn)._}getStateSeq(){return chunkH5NTJZO4_js.e(this,Vn)}getRenderSeq(){return chunkH5NTJZO4_js.e(this,po)}onLayoutStart(){chunkH5NTJZO4_js.g(this,fo,true);}onLayoutComplete(t){chunkH5NTJZO4_js.g(this,po,t),chunkH5NTJZO4_js.g(this,fo,false),chunkH5NTJZO4_js.h(this,Lo,Gf).call(this);}isSafeToRender(){return !chunkH5NTJZO4_js.e(this,fo)&&chunkH5NTJZO4_js.e(this,po)>=chunkH5NTJZO4_js.e(this,Vn)}requestRender(){this.isSafeToRender()?chunkH5NTJZO4_js.h(this,Lo,rc).call(this):chunkH5NTJZO4_js.g(this,Un,()=>chunkH5NTJZO4_js.h(this,Lo,rc).call(this));}onRender(t){return chunkH5NTJZO4_js.e(this,ur).add(t),()=>{chunkH5NTJZO4_js.e(this,ur).delete(t);}}reset(){chunkH5NTJZO4_js.g(this,Vn,0),chunkH5NTJZO4_js.g(this,po,0),chunkH5NTJZO4_js.g(this,fo,false),chunkH5NTJZO4_js.g(this,Un,null);}getDebugInfo(){return {stateSeq:chunkH5NTJZO4_js.e(this,Vn),renderSeq:chunkH5NTJZO4_js.e(this,po),layoutUpdating:chunkH5NTJZO4_js.e(this,fo),hasPendingRender:chunkH5NTJZO4_js.e(this,Un)!==null,isSafe:this.isSafeToRender()}}};Vn=new WeakMap,po=new WeakMap,fo=new WeakMap,Un=new WeakMap,ur=new WeakMap,Lo=new WeakSet,Gf=function(){if(chunkH5NTJZO4_js.e(this,Un)&&this.isSafeToRender()){let t=chunkH5NTJZO4_js.e(this,Un);chunkH5NTJZO4_js.g(this,Un,null),t();}},rc=function(){for(let t of chunkH5NTJZO4_js.e(this,ur))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var qf=".layout-page-content .layout-line";function XS(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function ZS(e){let t=XS(e);if(!t)return;let n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=40;n.bottom>o.bottom-r?t.scrollTop+=n.bottom-o.bottom+r:n.top<o.top+r&&(t.scrollTop-=o.top-n.top+r);}function Xf({pagesContainerRef:e}){let t=gm.useRef(null),n=gm.useRef(-1),o=gm.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let c of Array.from(l)){let d=c,p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(d.classList.contains("layout-run-tab")){if(s>=p&&s<f)return d.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&c.firstChild?.nodeType===Node.TEXT_NODE){let m=c.firstChild,b=Math.min(s-p,m.length),h=d.ownerDocument;if(!h)continue;let x=h.createRange();return x.setStart(m,b),x.setEnd(m,b),x.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let c of Array.from(u)){let d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f)return c.getBoundingClientRect().left}return null},[e]),r=gm.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(qf);for(let u of Array.from(l)){let c=u,d=c.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(d)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return c}}for(let u of Array.from(l)){let c=u,d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f&&d.querySelector(".layout-line")===c)return c}return null},[e]),i=gm.useCallback((s,l)=>{let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart)+1:null}for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=Number(m.dataset.pmStart),x=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let T=(b.left+b.right)/2;return l<T?h:x}continue}if(l>=b.left&&l<=b.right){let T=m.firstChild;if(!T||T.nodeType!==Node.TEXT_NODE)return h;let S=T,I=m.ownerDocument;if(!I)return h;let R=0,D=S.length;for(;R<D;){let L=Math.floor((R+D)/2),pe=I.createRange();pe.setStart(S,L),pe.setEnd(S,L),l<pe.getBoundingClientRect().left?D=L:R=L+1;}if(R>0&&R<=S.length){let L=I.createRange();L.setStart(S,R-1),L.setEnd(S,R-1);let pe=L.getBoundingClientRect().left;L.setStart(S,Math.min(R,S.length)),L.setEnd(S,Math.min(R,S.length));let $=L.getBoundingClientRect().left;if(Math.abs(l-pe)<Math.abs(l-$))return h+(R-1)}return h+Math.min(R,x-h)}}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=l<b.left?b.left-l:l-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return l<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)},[]),a=gm.useCallback((s,l)=>{if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return (["ArrowLeft","ArrowRight","Home","End"].includes(l.key)||l.key.length===1&&!l.ctrlKey&&!l.metaKey)&&(t.current=null,n.current=-1),false;if(l.ctrlKey||l.metaKey)return t.current=null,n.current=-1,false;if(!e.current)return false;let u=Array.from(e.current.querySelectorAll(qf));if(u.length===0)return false;let{from:c,anchor:d}=s.state.selection;if(t.current===null){let S=o(c);if(S===null)return false;t.current=S;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let S=r(c);if(!S||(p=u.indexOf(S),p===-1))return false}let f=l.key==="ArrowUp"?p-1:p+1;if(f<0||f>=u.length)return n.current=-1,false;let m=u[f],b=i(m,t.current);if(b===null)return false;n.current=f;let{state:h,dispatch:x}=s,T=Math.max(0,Math.min(b,h.doc.content.size));try{let S=l.shiftKey?prosemirrorState.TextSelection.create(h.doc,d,T):prosemirrorState.TextSelection.create(h.doc,T);x(h.tr.setSelection(S));}catch{let S=h.doc.resolve(T),I=l.shiftKey?prosemirrorState.TextSelection.between(h.doc.resolve(d),S):prosemirrorState.TextSelection.near(S);x(h.tr.setSelection(I));}return ZS(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var mo=40,ys=12;function JS(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function Zf({pagesContainerRef:e,onScrollExtendSelection:t}){let n=gm.useRef(null),o=gm.useRef({x:0,y:0}),r=gm.useRef(false),i=gm.useRef(null),a=gm.useCallback(()=>{if(i.current)return i.current;let d=e.current;return d?(i.current=JS(d),i.current):null},[e]),s=gm.useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=gm.useCallback(()=>{if(!r.current)return;let d=a();if(!d)return;let p=d.getBoundingClientRect(),{x:f,y:m}=o.current,b=0;if(m<p.top+mo){let h=Math.max(0,p.top+mo-m);b=-Math.min(ys,h/mo*ys);}else if(m>p.bottom-mo){let h=Math.max(0,m-(p.bottom-mo));b=Math.min(ys,h/mo*ys);}b!==0&&(d.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=gm.useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:gm.useCallback((d,p)=>{if(o.current={x:d,y:p},!r.current){let f=a();if(!f)return;let m=f.getBoundingClientRect();(p<m.top+mo||p>m.bottom-mo)&&u();}},[a,u]),stopAutoScroll:s}}var QS=12,xs=8;function Jf(e){let t=[];for(let n of e)if(n.kind==="paragraph")for(let o of n.runs)o.kind==="text"&&o.footnoteRefId!=null&&t.push({footnoteId:o.footnoteRefId,pmPos:o.pmStart??0});return t}function ic(e,t){let n=new Map;if(t.length===0)return n;for(let o of t)for(let r of e){let i=false;for(let a of r.fragments){let s=a.pmStart??-1,l=a.pmEnd??-1;if(s>=0&&l>=0&&o.pmPos>=s&&o.pmPos<l){let u=n.get(r.number)??[];u.includes(o.footnoteId)||u.push(o.footnoteId),n.set(r.number,u),i=true;break}}if(i)break}return n}function ek(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let c={kind:"text",text:`${t} `,fontSize:xs,superscript:true};l.push(c);}for(let c of s.content){let d=c;if(d.type==="run"&&Array.isArray(d.content)){let p=d.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=xs);for(let m of d.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:xs});let u={kind:"paragraph",id:`fn-${e.id}-p${a}`,runs:l};o.push(u);}o.length===0&&o.push({kind:"paragraph",id:`fn-${e.id}-empty`,runs:[{kind:"text",text:"",fontSize:xs}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=In(a,n);r.push(s);}let i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {id:e.id,displayNumber:t,blocks:o,measures:r,height:i}}function Qf(e,t,n){let o=new Map,r=new Map;for(let s of e)(s.noteType==="normal"||s.noteType==null)&&r.set(s.id,s);let i=1,a=new Set;for(let s of t){if(a.has(s.footnoteId))continue;a.add(s.footnoteId);let l=r.get(s.footnoteId);if(!l)continue;let u=ek(l,i,n);o.set(s.footnoteId,u),i++;}return o}function em(e,t){let n=new Map;for(let[o,r]of e){let i=0;for(let a of r){let s=t.get(a);s&&(i+=s.height);}i>0&&(i+=QS,n.set(o,i));}return n}var ac=class{constructor(t,n=1){chunkH5NTJZO4_js.d(this,"pagesContainer");chunkH5NTJZO4_js.d(this,"zoom");this.pagesContainer=t,this.zoom=n;}getCoordinatesForPosition(t){let n=this.pagesContainer.getBoundingClientRect(),o=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(o)){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(a.classList.contains("layout-run-tab")){if(t>=s&&t<l){let u=a.getBoundingClientRect(),c=a.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,c=Math.min(t-s,u.length),d=a.ownerDocument;if(!d)continue;let p=d.createRange();p.setStart(u,c),p.setEnd(u,c);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),c=i.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let c=a.firstChild,d=s.ownerDocument;if(!d)continue;let p=Math.max(0,t-l),f=Math.min(c.length,n-l);if(p<f){let m=d.createRange();m.setStart(c,p),m.setEnd(c,f);let b=m.getClientRects();for(let h of Array.from(b))r.push({x:(h.left-o.left)/this.zoom,y:(h.top-o.top)/this.zoom,width:h.width/this.zoom,height:h.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function tm(e,t=1){return new ac(e,t)}var ik=816,rm=1056,Ss={top:96,right:96,bottom:96,left:96},ak=24,bo=30,sk=200,lk=[],ck={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},im=24,dk={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:im,paddingBottom:24},uk={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},pk={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function fk(e,t,n,o,r){let i=new Map;if(!e?.state)return i;let{doc:a,schema:s}=e.state,l=s.marks.comment,u=s.marks.insertion,c=s.marks.deletion;if(!l&&!u&&!c)return i;let d=new Set,p=im+r;return a.descendants((f,m)=>{if(f.isText)for(let b of f.marks){let h=null;if(l&&b.type===l?h=`comment-${b.attrs.commentId}`:(u&&b.type===u||c&&b.type===c)&&(h=`revision-${b.attrs.revisionId}`),!h||d.has(h))continue;d.add(h);let x=chunkEV3CM6TU_js.q(t,n,o,m);if(x){i.set(h,x.y+p);continue}for(let T=0;T<t.pages.length;T++){let S=t.pages[T],I=false;for(let R of S.fragments){let D=R.pmStart??0,L=R.pmEnd??D;if(m<D||m>L)continue;let pe=R.kind==="table"?mk(n,o,R,m):0;i.set(h,R.y+pe+chunkEV3CM6TU_js.m(t,T)+p),I=true;break}if(I)break}}}),i}function mk(e,t,n,o){let r=e.findIndex(l=>l.id===n.blockId);if(r===-1)return 0;let i=e[r],a=t[r];if(i.kind!=="table"||a.kind!=="table")return 0;let s=0;for(let l=n.fromRow;l<n.toRow;l++){let u=i.rows[l];if(!u||u.cells.some(d=>d.blocks.some(p=>{let f=p.pmStart??0,m=p.pmEnd??f;return o>=f&&o<=m})))break;s+=a.rows[l]?.height??0;}return s}function Zt(e){return Math.round(e/1440*96)}function gk(e){return {w:e?.pageWidth?Zt(e.pageWidth):ik,h:e?.pageHeight?Zt(e.pageHeight):rm}}function hk(e){return {top:e?.marginTop!==void 0?Zt(e.marginTop):Ss.top,right:e?.marginRight!==void 0?Zt(e.marginRight):Ss.right,bottom:e?.marginBottom!==void 0?Zt(e.marginBottom):Ss.bottom,left:e?.marginLeft!==void 0?Zt(e.marginLeft):Ss.left,header:e?.headerDistance!==void 0?Zt(e.headerDistance):48,footer:e?.footerDistance!==void 0?Zt(e.footerDistance):48}}function bk(e){let t=e?.columnCount??1;if(t<=1)return;let n=Zt(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function yk(e,t,n){function o(l,u){return u.count<=1?l:Math.floor((l-(u.count-1)*u.gap)/u.count)}let r=[],i=[];for(let l=0;l<e.length;l++)if(e[l].kind==="sectionBreak"){r.push(l);let u=e[l];i.push(u.columns??{count:1,gap:0});}i.push(n??{count:1,gap:0});let a=0,s=[];for(let l=0;l<e.length;l++){let u=i[a];s.push(o(t,u)),a<r.length&&l===r[a]&&a++;}return s}function xk(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function sc(e){return e===void 0?0:Math.round(e*96/914400)}function Sk(e,t,n){if(e){if(t==="pct")return n*e/5e3;if(t==="dxa"||!t||t==="auto")return Math.round(e/20*1.333)}}function am(e,t){let r=e.columnWidths??[],i=Sk(e.width,e.widthType,t);if(r.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((f,m)=>f+(m.colSpan??1),0),p=(i??t)/Math.max(1,c);r=Array(c).fill(p);}else if(r.length>0&&i){let c=r.reduce((d,p)=>d+p,0);if(c>0&&Math.abs(c-i)>1){let d=i/c;r=r.map(p=>p*d);}}let a=new Map;for(let c=0;c<e.rows.length;c++){let d=e.rows[c];if(!d)continue;let p=0,f=a.get(c)??new Set;for(;f.has(p);)p++;for(let m of d.cells){let b=m.colSpan??1,h=m.rowSpan??1;if(h>1)for(let x=c+1;x<c+h;x++){a.has(x)||a.set(x,new Set);let T=a.get(x);for(let S=0;S<b;S++)T.add(p+S);}for(p+=b;f.has(p);)p++;}}let s=e.rows.map((c,d)=>{let p=0,f=a.get(d)??new Set;for(;f.has(p);)p++;return {cells:c.cells.map(m=>{let b=m.colSpan??1,h=0;for(let I=0;I<b&&p+I<r.length;I++)h+=r[p+I]??0;for(h===0&&(h=m.width??100),p+=b;f.has(p);)p++;let x=m.padding?.left??7,T=m.padding?.right??7,S=Math.max(1,h-x-T);return {blocks:m.blocks.map(I=>sm(I,S)),width:h,height:0,colSpan:m.colSpan,rowSpan:m.rowSpan}}),height:0}});for(let c=0;c<s.length;c++){let d=s[c],p=e.rows[c]?.cells,f=0;for(let x=0;x<d.cells.length;x++){let T=d.cells[x],S=p?.[x];T.height=T.blocks.reduce((D,L)=>"totalHeight"in L?D+L.totalHeight:D,0);let I=S?.padding?.top??0,R=S?.padding?.bottom??0;T.height+=I+R,f=Math.max(f,T.height);}let m=e.rows[c],b=m?.height,h=m?.heightRule;b&&h==="exact"?d.height=b:b?d.height=Math.max(f,b):d.height=f;}let l=s.reduce((c,d)=>c+d.height,0),u=r.reduce((c,d)=>c+d,0)||i||t;return {kind:"table",rows:s,columnWidths:r,totalWidth:u,totalHeight:l}}function kk(e,t){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="paragraph")continue;let i=r;for(let a of i.runs){if(a.kind!=="image")continue;let s=a;if(!xk(s))continue;let l=0,u=s.position,c=s.distTop??0,d=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let x=u.vertical;x.align==="top"&&x.relativeTo==="margin"?l=0:x.posOffset!==void 0&&(l=sc(x.posOffset));}let m=l+s.height,b=0,h=0;if(u?.horizontal){let x=u.horizontal;if(x.align==="left")b=s.width+f;else if(x.align==="right")h=s.width+p;else if(x.posOffset!==void 0){let T=sc(x.posOffset);T<t/2?b=T+s.width+f:h=t-T+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(h=s.width+p);if(b>0||h>0){let x=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:h,topY:l-c,bottomY:m+d,anchorBlockIndex:o,isMarginRelative:x});}}}for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="table")continue;let i=r,a=i.floating;if(!a)continue;let s=am(i,t),l=s.totalWidth,u=s.totalHeight,c=a.leftFromText??12,d=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,h=0;a.tblpX!==void 0?h=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?h=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?h=t-l:a.tblpXSpec==="center"&&(h=(t-l)/2):i.justification==="center"?h=(t-l)/2:i.justification==="right"&&(h=t-l),h<t/2?m=h+l+d:b=t-h+c;let x=a.tblpY??0,T=x+u;n.push({leftMargin:m,rightMargin:b,topY:x-p,bottomY:T+f,anchorBlockIndex:o});}return n}function sm(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=jl(r,t);if(a)return a}let i=In(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&Kl(r,t,i),i}case "table":return am(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "textBox":{let r=e,i=r.margins??chunkEV3CM6TU_js.c,a=(r.width??chunkEV3CM6TU_js.d)-i.left-i.right,s=r.content.map(c=>In(c,a)),l=s.reduce((c,d)=>c+d.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??chunkEV3CM6TU_js.d,height:u,innerMeasures:s}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function lm(e,t){let n=Array.isArray(t)?t[0]??0:t,o=kk(e,n),r=o.filter(p=>p.isMarginRelative),i=o.filter(p=>!p.isMarginRelative),a=new Map;for(let p of r){let f=a.get(p.topY)??[];f.push(p),a.set(p.topY,f);}let s=[...i];for(let p of a.values()){let f=Math.min(...p.map(m=>m.anchorBlockIndex));for(let m of p)s.push({...m,anchorBlockIndex:f});}let l=new Map;for(let p of s){let f=l.get(p.anchorBlockIndex)??[];f.push({leftMargin:p.leftMargin,rightMargin:p.rightMargin,topY:p.topY,bottomY:p.bottomY}),l.set(p.anchorBlockIndex,f);}let u=new Set(s.map(p=>p.anchorBlockIndex)),c=0,d=[];return e.map((p,f)=>{u.has(f)&&(c=0,d=l.get(f)??[]);let m=d.length>0?d:void 0;try{let b=performance.now(),h=Array.isArray(t)?t[f]??n:t,x=sm(p,h,m,c),T=performance.now()-b;return T>500&&console.warn(`[measureBlocks] Block ${f} (${p.kind}) took ${Math.round(T)}ms`),"totalHeight"in x&&(p.kind==="table"&&p.floating||(c+=x.totalHeight)),x}catch(b){return console.error(`[measureBlocks] Error measuring block ${f} (${p.kind}):`,b),{totalHeight:20}}})}function Cs(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,c=m=>Math.round(m/914400*96),d=u?.width?c(u.width):100,p=u?.height?c(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:d,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.content)){let a=Cs(o.content);t.push(...a);}continue}if(o.type==="complexField"){let r=o.fieldType,i={};if(Array.isArray(o.fieldResult)&&o.fieldResult.length>0){let a=o.fieldResult[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.fieldResult)){let a=Cs(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=Cs(o.children);t.push(...r);}}return t}function Ck(e){return e?.align??e?.alignment}function Tk(e,t,n,o){let r=o.section==="header"?o.margins.header??48:o.pageSize.h-(o.margins.footer??48)-n,i=e.position?.vertical;if(!i)return t;let a=Ck(i),s=i.posOffset!==void 0?sc(i.posOffset):void 0;if(i.relativeTo==="page"){if(s!==void 0)return s-r;if(a==="top")return -r;if(a==="bottom")return o.pageSize.h-e.height-r;if(a==="center")return (o.pageSize.h-e.height)/2-r}if(i.relativeTo==="margin"){let l=o.margins.top,u=o.pageSize.h-o.margins.top-o.margins.bottom;if(s!==void 0)return l+s-r;if(a==="top")return l-r;if(a==="bottom")return l+u-e.height-r;if(a==="center")return l+(u-e.height)/2-r}return s!==void 0?t+s:t}function wk(e,t,n,o){let r=0,i=n,a=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s];if(l?.kind!=="paragraph"||u?.kind!=="paragraph")continue;let c=l,d=a,p=d+u.totalHeight;r=Math.min(r,d),i=Math.max(i,p);for(let f of c.runs){if(f.kind!=="image"||!f.position)continue;let m=f,b=Tk(m,d,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function ks(e,t,n){if(!e||!e.content||e.content.length===0)return;let o=[];for(let u of e.content){let c=u;if(c.type==="paragraph"&&Array.isArray(c.content)){let d=c.formatting,p={};if(d){if(d.alignment){let b=d.alignment;b==="both"?p.alignment="justify":["left","center","right","justify"].includes(b)&&(p.alignment=b);}if(d.borders){let b=d.borders,h={};for(let x of ["top","bottom","left","right","between"]){let T=b[x];if(T){let S=ns(T);S&&(h[x]=S);}}Object.keys(h).length>0&&(p.borders=h);}if(d.lineSpacing!=null){let b={},h=d.lineSpacingRule;h==="exact"||h==="atLeast"?(b.line=Zt(d.lineSpacing),b.lineUnit="px",b.lineRule=h):(b.line=d.lineSpacing/240,b.lineUnit="multiplier",b.lineRule="auto"),p.spacing=b;}Array.isArray(d.tabs)&&d.tabs.length>0&&(p.tabs=d.tabs.map(b=>({val:b.alignment==="left"?"start":b.alignment==="right"?"end":b.alignment,pos:Zt(b.position),leader:b.leader})));}let f=Cs(c.content);f.length===0&&f.push({kind:"text",text:""});let m={kind:"paragraph",id:String(o.length),runs:f,attrs:Object.keys(p).length>0?p:void 0};o.push(m);}}if(o.length===0)return;let r=o.map(u=>{if(u.kind!=="paragraph")return u;let c=u;if(!c.runs.some(f=>f.kind==="image"&&"position"in f&&f.position))return u;let p=c.runs.filter(f=>!(f.kind==="image"&&"position"in f&&f.position));return p.length===0&&p.push({kind:"text",text:""}),{...c,runs:p}}),i=lm(r,t),a=i.reduce((u,c)=>c.kind==="paragraph"?u+c.totalHeight:u,0),{visualTop:s,visualBottom:l}=wk(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function vk(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let d=t.get(l)?.displayNumber??0,p=chunkKUL2SDYC_js.b(u);s.push({displayNumber:String(d),text:p});}s.length>0&&o.set(i,s);}return o}var Rk=gm.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,firstPageHeaderContent:u,firstPageFooterContent:c,readOnly:d=false,pageGap:p=ak,zoom:f=1,onDocumentChange:m,onSelectionChange:b,externalPlugins:h=lk,extensionManager:x,onReady:T,onRenderedDomContextReady:S,pluginOverlays:I,onHeaderFooterDoubleClick:R,hfEditMode:D,onBodyClick:L,className:pe,style:$,commentsSidebarOpen:v=false,sidebarOverlay:_,scrollContainerRef:re,onHyperlinkClick:ae,onContextMenu:N,onAnchorPositionsChange:B,resolvedCommentIds:de}=t,ge=gm.useCallback(()=>re&&typeof re=="object"?re.current:Pe.current,[re]),Pe=gm.useRef(null),se=gm.useRef(null),q=gm.useRef(null),E=gm.useRef(null),{handlePMKeyDown:F}=Xf({pagesContainerRef:se}),k=gm.useRef(()=>{}),P=gm.useRef(b),M=gm.useRef(m),H=gm.useRef(T),oe=gm.useRef(S);P.current=b,M.current=m,H.current=T,oe.current=S;let[Q,V]=gm.useState(null),[Y,ne]=gm.useState([]),[Se,Me]=gm.useState([]),[Z,ie]=gm.useState(false),[Ie,He]=gm.useState([]),[qe,je]=gm.useState(null),[Xe,_e]=gm.useState(null),we=gm.useRef(false),xt=gm.useCallback((C,O)=>{let K=C.tagName==="IMG"?C:C.querySelector("img"),G=(K??C).getBoundingClientRect();return {element:K??C,pmPos:O,width:Math.round(G.width/f),height:Math.round(G.height/f)}},[f]),Le=gm.useRef(false),ze=gm.useRef(null),lt=gm.useRef(false),nt=gm.useRef(0),ft=gm.useRef(0),Rt=gm.useRef(0),Ne=gm.useRef({left:0,right:0}),mt=gm.useRef(null),Oe=gm.useRef(false),St=gm.useRef(0),Jt=gm.useRef(0),Gt=gm.useRef(0),jn=gm.useRef(0),dt=gm.useRef(null),Qt=gm.useRef(false),gn=gm.useRef(false),So=gm.useRef(0),gr=gm.useRef(0),No=gm.useRef(0),an=gm.useRef(0),Yt=gm.useRef(null),en=gm.useRef(false),Dt=gm.useRef(null),ko=gm.useRef(null),Ht=gm.useRef(null),Rs=5,[hn,It]=gm.useState(null),bn=gm.useRef(null),gt=gm.useCallback(()=>{bn.current&&(clearTimeout(bn.current),bn.current=null);},[]);gm.useEffect(()=>()=>{bn.current&&clearTimeout(bn.current);},[]);let Nt=gm.useMemo(()=>new ms,[]),Ft=gm.useMemo(()=>gk(a),[a]),ot=gm.useMemo(()=>hk(a),[a]),Kn=gm.useMemo(()=>bk(a),[a]),Et=Ft.w-ot.left-ot.right,yn=gm.useMemo(()=>new fs({pageGap:p,showShadow:true,pageBackground:"#fff"}),[p]);E.current=yn;let zt=gm.useCallback(C=>{let O=performance.now(),K=Nt.getStateSeq();Nt.onLayoutStart();try{let G=performance.now(),ee=Ft.h-ot.top-ot.bottom,W=Sf(C.doc,{theme:i,pageContentHeight:ee}),J=performance.now()-G;J>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(J)}ms (${W.length} blocks)`),ne(W),G=performance.now();let te=yk(W,Et,Kn),le=lm(W,te);J=performance.now()-G,J>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(J)}ms (${W.length} blocks)`),Me(le);let xe=Jf(W),ye=xe.length>0&&o?.package?.footnotes,Re={section:"header",pageSize:Ft,margins:ot},ke={section:"footer",pageSize:Ft,margins:ot},he=ks(s,Et,Re),Be=ks(l,Et,ke),$e=a?.titlePg===!0,ut=$e?ks(u,Et,Re):void 0,ht=$e?ks(c,Et,ke):void 0,ln=ot.header??48,$o=ot.footer??48,pi=ot.top-ln,fi=ot.bottom-$o,mi=kt=>kt?kt.visualBottom??kt.height:0,gi=kt=>kt?Math.max((kt.visualBottom??kt.height)-(kt.visualTop??0),kt.height):0,Cr=Math.max(mi(he),mi(ut)),Tr=Math.max(gi(Be),gi(ht)),_o=ot;(Cr>pi||Tr>fi)&&(_o={...ot},Cr>pi&&(_o.top=Math.max(ot.top,ln+Cr)),Tr>fi&&(_o.bottom=Math.max(ot.bottom,$o+Tr))),G=performance.now();let cn,wo=new Map,wr=new Map,Is=a?.sectionStart,vr={pageSize:Ft,margins:_o,columns:Kn,bodyBreakType:Is,pageGap:p};if(ye){let kt=chunkEV3CM6TU_js.e(W,le,vr);wo=ic(kt.pages,xe),wr=Qf(o.package.footnotes,xe,Et);let Xn=em(wo,wr);if(Xn.size>0){cn=chunkEV3CM6TU_js.e(W,le,{...vr,footnoteReservedHeights:Xn}),wo=ic(cn.pages,xe);for(let[xn,vo]of wo){let Ro=cn.pages.find(Fs=>Fs.number===xn);Ro&&(Ro.footnoteIds=vo);}}else cn=kt;}else cn=chunkEV3CM6TU_js.e(W,le,vr);if(J=performance.now()-G,J>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(J)}ms (${cn.pages.length} pages)`),V(cn),se.current&&E.current){G=performance.now();let kt=new Map;for(let xn=0;xn<W.length;xn++){let vo=W[xn],Ro=le[xn];vo&&Ro&&kt.set(String(vo.id),{block:vo,measure:Ro});}E.current.setBlockLookup(kt);let Xn=ye?vk(wo,wr,o):void 0;if(Kf(cn.pages,se.current,{pageGap:p,showShadow:!0,pageBackground:"#fff",blockLookup:kt,headerContent:he,footerContent:Be,firstPageHeaderContent:ut,firstPageFooterContent:ht,titlePg:$e,headerDistance:a?.headerDistance?Zt(a.headerDistance):void 0,footerDistance:a?.footerDistance?Zt(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:Xn?.size?Xn:void 0,resolvedCommentIds:de}),J=performance.now()-G,J>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(J)}ms`),S){let xn=tm(se.current,f);S(xn);}}if(B){let kt=fk(q.current?.getView()??null,cn,W,le,p);B(kt);}let hi=performance.now()-O;hi>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(hi)}ms total (${W.length} blocks, ${le.length} measures)`);}catch(G){console.error("[PagedEditor] Layout pipeline error:",G);}Nt.onLayoutComplete(K);},[Et,Kn,Ft,ot,p,f,Nt,s,l,u,c,a,S,o,de]),sn=gm.useRef(null),hr=gm.useCallback(C=>{if(sn.current){sn.current.state=C;return}let O=requestAnimationFrame(()=>{let K=sn.current;sn.current=null,K&&zt(K.state);});sn.current={rafId:O,state:C};},[zt]);gm.useEffect(()=>()=>{sn.current&&(cancelAnimationFrame(sn.current.rafId),sn.current=null);},[]);let Bn=gm.useCallback((C,O=1)=>{if(!se.current)return null;let K=se.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!K)return null;let G=K.getBoundingClientRect(),ee=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let J of Array.from(ee)){let te=J,le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(te.classList.contains("layout-run-tab")){if(C>=le&&C<xe){let ye=te.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=te.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}continue}if(C>=le&&C<=xe&&J.firstChild?.nodeType===Node.TEXT_NODE){let ye=J.firstChild,Re=Math.min(C-le,ye.length),ke=te.ownerDocument;if(!ke)continue;let he=ke.createRange();he.setStart(ye,Re),he.setEnd(ye,Re);let Be=he.getBoundingClientRect(),$e=te.closest(".layout-page"),ut=$e?Number($e.dataset.pageNumber)-1:0,ht=te.closest(".layout-line"),ln=ht?ht.offsetHeight:16;return {x:(Be.left-G.left)/O,y:(Be.top-G.top)/O,height:ln,pageIndex:ut}}}let W=se.current.querySelectorAll(".layout-empty-run");for(let J of Array.from(W)){let te=J.closest(".layout-paragraph");if(!te)continue;let le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(C>=le&&C<=xe){let ye=J.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=J.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}}return null},[]),Ot=gm.useCallback(C=>{let{from:O,to:K}=C.selection;if(P.current?.(O,K),se.current){let G=se.current.querySelectorAll(".layout-table-cell-selected");for(let J of Array.from(G))J.classList.remove("layout-table-cell-selected");let ee=C.selection;if("$anchorCell"in ee&&typeof ee.forEachCell=="function"){let J=[];ee.forEachCell((le,xe)=>{J.push([xe,xe+le.nodeSize]);});let te=se.current.querySelectorAll(".layout-table-cell");for(let le of Array.from(te)){let xe=le,ye=xe.dataset.pmStart;if(ye!==void 0){let Re=Number(ye);for(let[ke,he]of J)if(Re>=ke&&Re<he){xe.classList.add("layout-table-cell-selected");break}}}}}if(!(!Q||Y.length===0))if(O===K){let G=Bn(O,f);if(G)je(G);else {let ee=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),W=se.current?.querySelector(".layout-page");if(ee&&W){let J=ee.getBoundingClientRect(),te=W.getBoundingClientRect(),le=chunkEV3CM6TU_js.q(Q,Y,Se,O);je(le?{...le,x:le.x+(te.left-J.left)/f,y:le.y+(te.top-J.top)/f}:null);}else je(null);}He([]);}else {let G=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(G&&se.current){let ee=G.getBoundingClientRect(),W=[],J=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let te of Array.from(J)){let le=te,xe=Number(le.dataset.pmStart);if(Number(le.dataset.pmEnd)>O&&xe<K){if(le.classList.contains("layout-run-tab")){let $e=le.getBoundingClientRect(),ut=le.closest(".layout-page"),ht=ut?Number(ut.dataset.pageNumber)-1:0;W.push({x:($e.left-ee.left)/f,y:($e.top-ee.top)/f,width:$e.width/f,height:$e.height/f,pageIndex:ht});continue}let Re=null;if(te.firstChild?.nodeType===Node.TEXT_NODE?Re=te.firstChild:te.firstChild?.nodeType===Node.ELEMENT_NODE&&te.firstChild.tagName==="A"&&te.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(Re=te.firstChild.firstChild),!Re)continue;let ke=le.ownerDocument;if(!ke)continue;let he=Math.max(0,O-xe),Be=Math.min(Re.length,K-xe);if(he<Be){let $e=ke.createRange();$e.setStart(Re,he),$e.setEnd(Re,Be);let ut=$e.getClientRects();for(let ht of Array.from(ut)){let ln=le.closest(".layout-page"),$o=ln?Number(ln.dataset.pageNumber)-1:0;W.push({x:(ht.left-ee.left)/f,y:(ht.top-ee.top)/f,width:ht.width/f,height:ht.height/f,pageIndex:$o});}}}}if(W.length>0)He(W);else {let te=se.current.querySelector(".layout-page");if(te){let le=te.getBoundingClientRect(),xe=(le.left-ee.left)/f,ye=(le.top-ee.top)/f,ke=chunkEV3CM6TU_js.p(Q,Y,Se,O,K).map(he=>({...he,x:he.x+xe,y:he.y+ye}));He(ke);}else He([]);}}else He([]);je(null);}},[Q,Y,Se,Bn,f]),ue=gm.useCallback((C,O)=>{if(C.docChanged){Nt.incrementStateSeq(),hr(O);let K=q.current?.getDocument();K&&M.current?.(K);}Nt.requestRender(),C.docChanged||Ot(O);},[hr,Ot,Nt]),br=gm.useCallback(C=>{let{selection:O}=C;O instanceof prosemirrorState.NodeSelection&&O.node.type.name==="image"?(He([]),je(null)):Nt.isSafeToRender()&&Ot(C),requestAnimationFrame(()=>{let K=q.current?.getView();if(!K){_e(null);return}let{selection:G}=K.state;if(G instanceof prosemirrorState.NodeSelection&&G.node.type.name==="image"){let ee=G.from,W=se.current?.querySelector(`[data-pm-start="${ee}"]`);if(W){_e(xt(W,ee));return}}we.current||_e(null);});},[Ot,f,xt,Nt]),$t=gm.useCallback((C,O)=>{if(!se.current||!Q)return null;let K=Ff(se.current,C,O,f);if(K!==null)return K;let G=se.current.querySelectorAll(".layout-page"),ee=-1,W=null;for(let Re=0;Re<G.length;Re++){let he=G[Re].getBoundingClientRect();if(C>=he.left&&C<=he.right&&O>=he.top&&O<=he.bottom){ee=Re,W=he;break}}if(ee<0||!W)return null;let J=(C-W.left)/f,te=(O-W.top)/f,le=Q.pages[ee];if(!le)return null;let xe={pageIndex:ee,page:le,pageY:te},ye=chunkEV3CM6TU_js.n(xe,Y,Se,{x:J,y:te});if(!ye)return null;if(ye.fragment.kind==="table"){let Re=chunkEV3CM6TU_js.o(xe,Y,Se,{x:J,y:te});return Yl(ye,Re)}return Yl(ye)},[Q,Y,Se,f]),An=gm.useCallback(C=>{let O=q.current?.getView();if(!O)return null;try{let K=O.state.doc.resolve(C);for(let G=K.depth;G>0;G--){let ee=K.node(G);if(ee.type.name==="tableCell"||ee.type.name==="tableHeader")return K.before(G)}}catch{}return null},[]),Es=gm.useCallback(C=>{let O=["layout-block-image","layout-image","layout-page-floating-image"],K=G=>!!G.dataset.pmStart&&O.some(ee=>G.classList.contains(ee));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&K(C.parentElement)?C.parentElement:K(C)?C:null},[]),We=gm.useCallback(C=>{let O=se.current;if(!O)return;let K=O.querySelector(`[data-pm-start="${C}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"center"});},[]),tn=gm.useCallback(C=>{if(!q.current)return;if(C.button===2){C.preventDefault();return}if(C.button!==0||(It(null),gt(),C.target.closest("a[href]")&&C.preventDefault(),d))return;if(D&&L){let W=C.target;if(!(W.closest(".layout-page-header")||W.closest(".layout-page-footer")||W.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),L();return}}if(!D){let W=C.target;if(W.closest(".layout-page-header")||W.closest(".layout-page-footer")){C.preventDefault(),q.current&&(q.current.setSelection(0),q.current.focus(),ie(true));return}}let K=C.target;if(K.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),lt.current=true,nt.current=C.clientX,mt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);ft.current=W,Rt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(Rt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&ye[W+1]!==void 0&&(Ne.current={left:ye[W],right:ye[W+1]});break}}}return}if(K.classList.contains("layout-table-row-resize-handle")||K.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),Oe.current=true,St.current=C.clientY,dt.current=K,Qt.current=K.dataset.isEdge==="bottom",K.classList.add("dragging");let W=parseInt(K.dataset.rowIndex??"0",10);Jt.current=W,Gt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(Gt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=null,Re=0;if(xe.forEach(ke=>{Re===W&&(ye=ke),Re++;}),ye){let ke=ye.attrs.height;if(ke)jn.current=ke;else {let Be=K.closest(".layout-table")?.querySelector(`[data-row-index="${W}"]`),$e=Be?Be.getBoundingClientRect().height:30;jn.current=Math.round($e*15);}}break}}}return}if(K.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),gn.current=true,So.current=C.clientX,Yt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);gr.current=W,No.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q.current.getView();if(J){let te=J.state.doc.resolve(No.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&(an.current=ye[W]);break}}}return}let G=Es(K);if(G){C.preventDefault(),C.stopPropagation();let W=G.dataset.pmStart;if(W!==void 0){let J=parseInt(W,10);q.current.setNodeSelection(J),_e(xt(G,J)),He([]),je(null);}q.current.focus(),ie(true);return}_e(null),C.preventDefault();let ee=$t(C.clientX,C.clientY);if(ee!==null){let W=An(ee);Dt.current=W,en.current=false,ko.current=null,Ht.current=null,Le.current=true,ze.current=ee,q.current.setSelection(ee);}else {Dt.current=null,en.current=false;let W=q.current.getView();if(W){let J=Math.max(0,W.state.doc.content.size-1);q.current.setSelection(J),ze.current=J,Le.current=true;}}q.current.focus(),ie(true);},[$t,An,d,D,L,f,ae,gt]),Gn=gm.useCallback((C,O)=>{k.current(C,O);},[]),{updateMousePosition:nn,stopAutoScroll:yr}=Zf({pagesContainerRef:se,onScrollExtendSelection:Gn});k.current=(C,O)=>{if(!Le.current||ze.current===null||!q.current)return;let K=$t(C,O);K!==null&&q.current.setSelection(ze.current,K);};let zo=gm.useCallback(C=>{if(lt.current){C.preventDefault();let G=C.clientX-nt.current;if(mt.current){let ee=parseFloat(mt.current.style.left);mt.current.style.left=`${ee+G}px`,nt.current=C.clientX;let W=Math.round(G*15),J=300,te=Ne.current.left+W,le=Ne.current.right-W;te>=J&&le>=J&&(Ne.current={left:te,right:le});}return}if(Oe.current){C.preventDefault();let G=C.clientY-St.current;if(dt.current){let ee=parseFloat(dt.current.style.top);dt.current.style.top=`${ee+G}px`,St.current=C.clientY;let W=Math.round(G*15),J=200,te=jn.current+W;te>=J&&(jn.current=te);}return}if(gn.current){C.preventDefault();let G=C.clientX-So.current;if(Yt.current){let ee=parseFloat(Yt.current.style.left);Yt.current.style.left=`${ee+G}px`,So.current=C.clientX;let W=Math.round(G*15),J=300,te=an.current+W;te>=J&&(an.current=te);}return}if(!Le.current||ze.current===null||!q.current||!se.current)return;nn(C.clientX,C.clientY);let O=$t(C.clientX,C.clientY);if(O===null)return;if(Dt.current!==null){if(en.current){let ee=An(O);if(ee!==null){q.current.setCellSelection(Dt.current,ee);return}}let G=An(O);if(G!==null&&G!==Dt.current){en.current=true,q.current.setCellSelection(Dt.current,G),Ht.current=null;return}if(ko.current!==null&&O===ko.current){if(Ht.current===null)Ht.current=C.clientX;else if(Math.abs(C.clientX-Ht.current)>=Rs){en.current=true,q.current.setCellSelection(Dt.current,Dt.current),Ht.current=null;return}}else Ht.current=null,ko.current=O;}let K=ze.current;q.current.setSelection(K,O);},[$t,An,nn]),Yn=gm.useCallback(()=>{if(lt.current){lt.current=false,mt.current&&(mt.current.classList.remove("dragging"),mt.current=null);let C=q.current?.getView();if(C){let O=Rt.current,K=ft.current,{left:G,right:ee}=Ne.current,W=C.state.doc.resolve(O+1);for(let J=W.depth;J>=0;J--){let te=W.node(J);if(te.type.name==="table"){let le=W.before(J),xe=C.state.tr,ye=[...te.attrs.columnWidths];ye[K]=G,ye[K+1]=ee,xe.setNodeMarkup(le,void 0,{...te.attrs,columnWidths:ye});let Re=le+1;te.forEach(ke=>{let he=Re+1,Be=0;ke.forEach($e=>{let ut=$e.attrs.colspan||1;if(Be===K||Be===K+1){let ht=Be===K?G:ee;xe.setNodeMarkup(xe.mapping.map(he),void 0,{...$e.attrs,width:ht,widthType:"dxa",colwidth:null});}he+=$e.nodeSize,Be+=ut;}),Re+=ke.nodeSize;}),C.dispatch(xe);break}}}return}if(Oe.current){Oe.current=false,dt.current&&(dt.current.classList.remove("dragging"),dt.current=null);let C=q.current?.getView();if(C){let O=Gt.current,K=Jt.current,G=jn.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=te+1,ye=0;J.forEach(Re=>{ye===K&&le.setNodeMarkup(le.mapping.map(xe),void 0,{...Re.attrs,height:G,heightRule:"atLeast"}),xe+=Re.nodeSize,ye++;}),C.dispatch(le);break}}}return}if(gn.current){gn.current=false,Yt.current&&(Yt.current.classList.remove("dragging"),Yt.current=null);let C=q.current?.getView();if(C){let O=No.current,K=gr.current,G=an.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=[...J.attrs.columnWidths];xe[K]=G,le.setNodeMarkup(te,void 0,{...J.attrs,columnWidths:xe});let ye=te+1;J.forEach(Re=>{let ke=ye+1,he=0;Re.forEach(Be=>{let $e=Be.attrs.colspan||1;he===K&&le.setNodeMarkup(le.mapping.map(ke),void 0,{...Be.attrs,width:G,widthType:"dxa",colwidth:null}),ke+=Be.nodeSize,he+=$e;}),ye+=Re.nodeSize;}),C.dispatch(le);break}}}return}Le.current=false,en.current=false,ko.current=null,Ht.current=null,yr();},[yr]);gm.useEffect(()=>(window.addEventListener("mousemove",zo),window.addEventListener("mouseup",Yn),()=>{window.removeEventListener("mousemove",zo),window.removeEventListener("mouseup",Yn);}),[zo,Yn]);let qn=gm.useCallback(C=>{if(d||Le.current||lt.current||Oe.current||gn.current||en.current)return;let O=se.current;if(!O)return;let K=C.clientX,G=C.clientY,ee=C.target.closest(".layout-table");if(!ee){let ke=O.querySelectorAll(".layout-table");for(let he of Array.from(ke)){let Be=he.getBoundingClientRect(),$e=K>=Be.left-bo&&K<Be.left,ut=G>=Be.top-bo&&G<Be.top,ht=K>=Be.left-bo&&K<=Be.right,ln=G>=Be.top-bo&&G<=Be.bottom;if($e&&ln||ut&&ht){ee=he;break}}}if(!ee){It(null);return}let W=ee.getBoundingClientRect(),J=K<W.left+bo&&K>=W.left-bo,te=G<W.top+bo&&G>=W.top-bo;if(!J&&!te){It(null);return}let le=ee.querySelectorAll(":scope > .layout-table-row");if(le.length===0){It(null);return}let xe=O.parentElement;if(!xe)return;let ye=xe.getBoundingClientRect(),Re=ke=>ke&&Number(ke.dataset.pmStart)||0;if(J)for(let ke=0;ke<le.length;ke++){let he=le[ke].getBoundingClientRect();if(G>=he.top&&G<=he.bottom){let Be=le[ke].querySelector(".layout-table-cell"),$e=Re(Be);if(!$e)break;let ut=he.top+he.height/2;It({type:"row",x:W.left-ye.left-24,y:ut-ye.top-10,cellPmPos:$e}),gt();return}}if(te){let ke=le[0].querySelectorAll(":scope > .layout-table-cell");for(let he=0;he<ke.length;he++){let Be=ke[he].getBoundingClientRect();if(K>=Be.left&&K<=Be.right){let $e=Re(ke[he]);if(!$e)break;let ut=Be.left+Be.width/2;It({type:"column",x:ut-ye.left-10,y:W.top-ye.top-24,cellPmPos:$e}),gt();return}}}bn.current||(bn.current=setTimeout(()=>{It(null),bn.current=null;},sk));},[d,gt]),Ps=gm.useCallback(C=>{if(C.preventDefault(),C.stopPropagation(),!hn||!q.current)return;let O=q.current.getView();if(!O)return;let{type:K,cellPmPos:G}=hn,ee=O.state.tr.setSelection(prosemirrorState.TextSelection.create(O.state.doc,G+1));O.dispatch(ee),K==="row"?Io(O.state,O.dispatch):Fo(O.state,O.dispatch),It(null),q.current.focus();},[hn]),Co=gm.useCallback(C=>{let O=C.target.closest("a[href]");if(O){C.preventDefault();let K=O.getAttribute("href")||"";if(K.startsWith("#")){let G=K.substring(1);if(G&&q.current){let ee=q.current.getView();if(ee){let W=null;ee.state.doc.descendants((J,te)=>{if(W!==null)return false;if(J.type.name==="paragraph"&&J.attrs.bookmarks?.some(xe=>xe.name===G))return W=te,false}),W!==null&&(We(W),q.current.setSelection(W+1));}}}else if(ae){let G=q.current?.getView();if(!(G&&G.state.selection.from!==G.state.selection.to)){let W=O.textContent||"",J=O.getAttribute("title")||void 0,te=O.getBoundingClientRect();ae({href:K,displayText:W,tooltip:J,anchorRect:te});}}return}if(C.detail===2&&R){let K=C.target,G=K.closest(".layout-page-header"),ee=K.closest(".layout-page-footer");if(G||ee){let W=K.closest("[data-page-number]"),J=W?Number(W.dataset.pageNumber):1;if(G){C.preventDefault(),C.stopPropagation(),R("header",J);return}if(ee){C.preventDefault(),C.stopPropagation(),R("footer",J);return}}}if(C.detail===2&&q.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=An(K);if(G!==null){C.preventDefault(),C.stopPropagation(),q.current.setCellSelection(G,G);return}let ee=q.current.getView();if(ee){let{doc:W}=ee.state,J=W.resolve(K),te=J.parent;if(te.isTextblock){let le=te.textContent,xe=J.parentOffset,[ye,Re]=Nn(le,xe),ke=J.start()+ye,he=J.start()+Re;ke<he&&q.current.setSelection(ke,he);}}}}if(C.detail===3&&q.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=q.current.getView();if(G){let{doc:ee}=G.state,W=ee.resolve(K),J=W.start(W.depth),te=W.end(W.depth);q.current.setSelection(J,te);}}}},[$t,R,ae]),li=gm.useCallback(C=>{if(!N)return;C.preventDefault();let O=q.current?.getView();if(!O)return;let{from:K,to:G}=O.state.selection,ee=$t(C.clientX,C.clientY);ee!==null&&(K===G||ee<K||ee>G)&&(q.current?.setSelection(ee),q.current?.focus(),ie(true));let W=q.current?.getState(),J=W?W.selection.from!==W.selection.to:false;N({x:C.clientX,y:C.clientY,hasSelection:J});},[N,$t]),xr=gm.useCallback(C=>{if(d)return;let O=C.target;O.closest(".docx-comments-sidebar")||O.closest(".docx-unified-sidebar")||(q.current?.focus(),ie(true));},[d]),Oo=gm.useCallback(C=>{let O=C.relatedTarget;O&&Pe.current?.contains(O)||O?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||ie(false);},[]),Lt=gm.useCallback((C,O,K)=>{let G=q.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;let W=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,width:O,height:K});G.dispatch(W),q.current?.setNodeSelection(C);}catch{}},[]),ci=gm.useCallback(()=>{we.current=true;},[]),Sr=gm.useCallback(()=>{we.current=false;},[]),Dn=gm.useCallback((C,O,K)=>{let G=q.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;if(ee.attrs.displayMode==="float"||ee.attrs.wrapType&&["square","tight","through"].includes(ee.attrs.wrapType)){let J=se.current?.querySelectorAll(".layout-page");if(!J||J.length===0)return;let te=null;for(let ut of J){let ht=ut.getBoundingClientRect();if(K>=ht.top&&K<=ht.bottom){te=ut.querySelector(".layout-page-content");break}}if(te||(te=J[J.length-1].querySelector(".layout-page-content")),!te)return;let le=te.getBoundingClientRect(),xe=(O-le.left)/f,ye=(K-le.top)/f,Re=914400/96,ke=Math.round(xe*Re),he=Math.round(ye*Re),Be={horizontal:{posOffset:ke,relativeTo:"margin"},vertical:{posOffset:he,relativeTo:"margin"}},$e=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,position:Be});G.dispatch($e),q.current?.setNodeSelection(C);}else {let J=$t(O,K);if(J===null||J===C||J===C+1)return;let te=G.state.tr;if(J<=C)te=te.delete(C,C+ee.nodeSize),te=te.insert(J,ee),q.current?.setNodeSelection(J);else {te=te.delete(C,C+ee.nodeSize);let le=J-ee.nodeSize;te=te.insert(Math.min(le,te.doc.content.size),ee),q.current?.setNodeSelection(Math.min(le,te.doc.content.size-1));}G.dispatch(te);}}catch{}},[$t,f]),di=gm.useCallback(()=>{we.current=true;},[]),To=gm.useCallback(()=>{we.current=false;},[]),Ms=gm.useCallback(C=>{if(!d){if(q.current?.isFocused()||(q.current?.focus(),ie(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey&&!C.nativeEvent.isComposing){C.preventDefault();let O=q.current?.getView();if(O){let{from:K,to:G}=O.state.selection;O.someProp("handleTextInput",W=>W(O,K,G," "))||O.dispatch(O.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=0);}if(C.key==="End"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=O.scrollHeight);}}},[d,ge]),Ae=gm.useCallback(C=>{d||C.target.closest(".docx-comments-sidebar")||C.target.closest(".docx-unified-sidebar")||q.current?.isFocused()||(q.current?.focus(),ie(true));},[d]),Qe=gm.useCallback(C=>{zt(C.state),Ot(C.state),d||requestAnimationFrame(()=>{C.focus(),ie(true);});},[zt,Ot,d]);gm.useEffect(()=>{let C=()=>{let O=q.current?.getView();O&&(chunkEV3CM6TU_js.f(),Gl(),zt(O.state),Ot(O.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let ui=gm.useRef(0);gm.useEffect(()=>{if(ui.current===0){ui.current=1;return}let C=q.current?.getView();C&&zt(C.state);},[s,l,u,c,zt]),gm.useEffect(()=>{let C=Pe.current;if(!C)return;let O=new ResizeObserver(()=>{let K=q.current?.getState();K&&Ot(K);});return O.observe(C),()=>O.disconnect()},[Ot]),gm.useImperativeHandle(n,()=>({getDocument(){return q.current?.getDocument()??null},getState(){return q.current?.getState()??null},getView(){return q.current?.getView()??null},focus(){q.current?.focus(),ie(true);},blur(){q.current?.blur(),ie(false);},isFocused(){return q.current?.isFocused()??false},dispatch(C){q.current?.dispatch(C);},undo(){return q.current?.undo()??false},redo(){return q.current?.redo()??false},setSelection(C,O){q.current?.setSelection(C,O);},getLayout(){return Q},relayout(){let C=q.current?.getState();C&&zt(C);},scrollToPosition:We}),[Q,zt,We]),gm.useEffect(()=>{let C=q.current?.getState();Q&&C&&Ot(C);},[Q,Ot]),gm.useEffect(()=>{H.current&&q.current&&H.current({getDocument:()=>q.current?.getDocument()??null,getState:()=>q.current?.getState()??null,getView:()=>q.current?.getView()??null,focus:()=>{q.current?.focus(),ie(true);},blur:()=>{q.current?.blur(),ie(false);},isFocused:()=>q.current?.isFocused()??false,dispatch:C=>q.current?.dispatch(C),undo:()=>q.current?.undo()??false,redo:()=>q.current?.redo()??false,setSelection:(C,O)=>q.current?.setSelection(C,O),getLayout:()=>Q,relayout:()=>{let C=q.current?.getState();C&&zt(C);},scrollToPosition:We});},[Q,zt]);let kr=gm.useMemo(()=>{if(!Q)return rm+48;let C=Q.pages.length;return C*Ft.h+(C-1)*p+48},[Q,Ft.h,p]);return jsxRuntime.jsxs("div",{ref:Pe,className:`ep-root paged-editor ${pe??""}`,style:{...ck,...$},tabIndex:0,onFocus:xr,onBlur:Oo,onKeyDown:Ms,onMouseDown:Ae,children:[jsxRuntime.jsx(uf,{ref:q,document:o,styles:r,widthPx:Et,readOnly:d,onTransaction:ue,onSelectionChange:br,externalPlugins:h,extensionManager:x,onEditorViewReady:Qe,onKeyDown:F}),jsxRuntime.jsxs("div",{style:{...dk,minHeight:kr,marginBottom:f!==1?kr*(f-1):void 0,transform:(()=>{let C=[];return v&&C.push(`translateX(-${176}px)`),f!==1&&C.push(`scale(${f})`),C.length>0?C.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:se,className:`paged-editor__pages${d?" paged-editor--readonly":""}${D?` paged-editor--hf-editing paged-editor--editing-${D}`:""}`,style:uk,onMouseDown:tn,onMouseMove:qn,onClick:Co,onContextMenu:li,"aria-hidden":"true"}),jsxRuntime.jsx(ff,{selectionRects:Ie,caretPosition:qe,isFocused:Z,pageGap:p,readOnly:d}),jsxRuntime.jsx(yf,{imageInfo:Xe,zoom:f,isFocused:Z,onResize:Lt,onResizeStart:ci,onResizeEnd:Sr,onDragMove:Dn,onDragStart:di,onDragEnd:To}),hn&&jsxRuntime.jsx("button",{type:"button",onMouseDown:Ps,onMouseEnter:gt,onMouseLeave:()=>It(null),style:{position:"absolute",left:hn.x,top:hn.y,width:20,height:20,borderRadius:"4px",border:"1px solid #dadce0",backgroundColor:"#f8f9fa",color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:hn.type==="row"?"Insert row below":"Insert column to the right","aria-label":hn.type==="row"?"Insert row below":"Insert column to the right",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),I&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:pk,children:I})]}),_&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:kr*f,pointerEvents:"none",overflow:"visible"},children:jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:_})})]})}),cm=gm.memo(Rk);var Ik=gm.lazy(()=>import('./FindReplaceDialog-KNJETYJX.js')),Fk=gm.lazy(()=>import('./HyperlinkDialog-GBAYMTUE.js')),Lk=gm.lazy(()=>import('./TablePropertiesDialog-WOZ4ES3H.js').then(e=>({default:e.TablePropertiesDialog}))),Bk=gm.lazy(()=>import('./ImagePositionDialog-M65BYQQE.js').then(e=>({default:e.ImagePositionDialog}))),Ak=gm.lazy(()=>import('./ImagePropertiesDialog-O4WQSF5M.js').then(e=>({default:e.ImagePropertiesDialog}))),Dk=gm.lazy(()=>import('./FootnotePropertiesDialog-452A4UT5.js').then(e=>({default:e.FootnotePropertiesDialog}))),Hk=gm.lazy(()=>import('./PageSetupDialog-2GIBTKMJ.js').then(e=>({default:e.PageSetupDialog}))),dm=[{value:"editing",label:"Editing",icon:"edit_note",desc:"Edit document directly"},{value:"suggesting",label:"Suggesting",icon:"rate_review",desc:"Edits become suggestions"},{value:"viewing",label:"Viewing",icon:"visibility",desc:"Read-only, no edits"}];function Ok({mode:e,onModeChange:t}){let[n,o]=gm.useState(false),[r,i]=gm.useState(false),a=gm.useRef(null),s=gm.useRef(null),[l,u]=gm.useState({top:0,left:0}),c=dm.find(d=>d.value===e);return gm.useEffect(()=>{let d=window.matchMedia("(max-width: 1400px)");i(d.matches);let p=f=>i(f.matches);return d.addEventListener("change",p),()=>d.removeEventListener("change",p)},[]),gm.useEffect(()=>{if(!n||!a.current)return;let d=a.current.getBoundingClientRect();u({top:d.bottom+2,left:d.right-220});},[n]),gm.useEffect(()=>{if(!n)return;let d=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p);}},[n]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:a,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(!n),title:`${c.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:c.icon,size:18}),!r&&jsxRuntime.jsx("span",{children:c.label}),jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:"arrow_drop_down",size:16})]}),n&&jsxRuntime.jsx("div",{ref:s,onMouseDown:d=>d.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:dm.map(d=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(d.value),o(false);},onMouseOver:p=>{p.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)";},onMouseOut:p=>{p.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text, #374151)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:d.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:d.label}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:d.desc})]}),d.value===e&&jsxRuntime.jsx(chunkDC65PJYE_js.d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},d.value))})]})}var cc=1,ri=-1;function $k(e,t){let n=t.filter(i=>i.parentId!=null);if(n.length===0)return;let o=new Map;for(let i of n){let a=o.get(i.parentId);a?a.push(i.id):o.set(i.parentId,[i.id]);}function r(i){for(let a of i)if(a.type==="paragraph"){if(!a.content.some(l=>l.type==="commentRangeStart"||l.type==="commentRangeEnd"))continue;let s=[];for(let l of a.content)if(l.type==="commentRangeStart"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeStart",id:c});}else if(l.type==="commentRangeEnd"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeEnd",id:c});}else s.push(l);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let l of s.cells)r(l.content);}r(e);}function _k(e,t){let n=new Set(t.map(a=>a.id)),o=t.filter(a=>a.parentId!=null&&!n.has(a.parentId));if(o.length===0)return;let r=new Map;for(let a of o){let s=r.get(a.parentId);s?s.push(a.id):r.set(a.parentId,[a.id]);}function i(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(d=>(d.type==="insertion"||d.type==="deletion")&&r.has(d.info.id)))continue;let u=[],c=s.content;for(let d=0;d<c.length;d++){let p=c[d];if((p.type==="insertion"||p.type==="deletion")&&r.has(p.info.id)){let f=r.get(p.info.id);for(let b of f)u.push({type:"commentRangeStart",id:b});u.push(p);let m=c[d+1];m&&(m.type==="insertion"||m.type==="deletion")&&m.type!==p.type&&m.info.author===p.info.author&&m.info.date===p.info.date&&(u.push(m),d++);for(let b of f)u.push({type:"commentRangeEnd",id:b});}else u.push(p);}s.content=u;}else if(s.type==="table")for(let l of s.rows)for(let u of l.cells)i(u.content);}i(e);}var um=new Map;function pm(e,t,n){if(!e||!t)return null;let o=e.querySelector(".paged-editor__pages");if(!o)return null;let r=o.querySelectorAll("[data-pm-start]");for(let i of r){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(n>=s&&n<=l)return a.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function lc(e,t,n){return {id:cc++,author:t,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:e}]}]}],...n!==void 0&&{parentId:n}}}var mm=gm.forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i,onSelectionChange:a,onError:s,onFontsLoaded:l,theme:u,showToolbar:c=true,showZoomControl:d=true,showMarginGuides:p=false,marginGuideColor:f,showRuler:m=false,rulerUnit:b="inch",initialZoom:h=1,readOnly:x=false,toolbarExtra:T,className:S="",style:I,placeholder:R,loadingIndicator:D,showOutline:L=false,showOutlineButton:pe=true,showPrintButton:$=true,printOptions:v,onPrint:_,onCopy:re,onCut:ae,onPaste:N,mode:B,onModeChange:de,onCommentAdd:ge,onCommentResolve:Pe,onCommentDelete:se,onCommentReply:q,externalPlugins:E,onEditorViewReady:F,onRenderedDomContextReady:k,pluginOverlays:P,pluginSidebarItems:M,pluginRenderedDomContext:H,renderLogo:oe,documentName:Q,onDocumentNameChange:V,documentNameEditable:Y=true,renderTitleBarRight:ne,i18n:Se},Me){let[Z,ie]=gm.useState({isLoading:!!t,parseError:null,zoom:h,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Ie,He]=gm.useState(false),[qe,je]=gm.useState(false),[Xe,_e]=gm.useState(false),[we,xt]=gm.useState(false),[Le,ze]=gm.useState(null),[lt,nt]=gm.useState(false),[ft,Rt]=gm.useState(L),Ne=gm.useRef(false);Ne.current=ft;let[mt,Oe]=gm.useState([]),[St,Jt]=gm.useState(false),[Gt,jn]=gm.useState(null),[dt,Qt]=gm.useState([]),[gn,So]=gm.useState([]),[gr,No]=gm.useState(um),[an,Yt]=gm.useState(false),[en,Dt]=gm.useState(null),[ko,Ht]=gm.useState(null),[Rs,hn]=gm.useState(B??"editing"),It=B??Rs,bn=y=>{B||hn(y),de?.(y);},gt=x||It==="viewing",[Nt,Ft]=gm.useState(null),[ot,Kn]=gm.useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),Et=gm.useRef(null),yn=gm.useRef(null),zt=gm.useRef(dt);zt.current=dt;let sn=gm.useRef(an);sn.current=an;let hr=gm.useRef(se);hr.current=se;let Bn=gm.useCallback(()=>{let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,A=w.marks.insertion,z=w.marks.deletion;if(!A&&!z)return;let U=[];g.descendants((ce,me)=>{if(ce.isText)for(let Ce of ce.marks)(Ce.type===A||Ce.type===z)&&U.push({type:Ce.type===A?"insertion":"deletion",text:ce.text||"",author:Ce.attrs.author||"",date:Ce.attrs.date,from:me,to:me+ce.nodeSize,revisionId:Ce.attrs.revisionId});});let j=[];for(let ce of U){let me=j[j.length-1];me&&me.revisionId===ce.revisionId&&me.type===ce.type&&me.to===ce.from?(me.text+=ce.text,me.to=ce.to):j.push({...ce});}let X=[];for(let ce=0;ce<j.length;ce++){let me=j[ce],Ce=j[ce+1];me.type==="deletion"&&Ce&&Ce.type==="insertion"&&me.author===Ce.author&&me.date===Ce.date&&me.to===Ce.from?(X.push({type:"replacement",text:Ce.text,deletedText:me.text,author:me.author,date:me.date,from:me.from,to:Ce.to,revisionId:me.revisionId,insertionRevisionId:Ce.revisionId}),ce++):X.push(me);}So(X);let fe=w.marks.comment;if(fe&&X.length>0){let ce=new Map;g.descendants(me=>{if(!me.isText)return;let Ce=me.marks.find(Fe=>Fe.type===fe),Ve=me.marks.find(Fe=>Fe.type===A||Fe.type===z);if(Ce&&Ve){let Fe=Ce.attrs.commentId,Tt=Ve.attrs.revisionId;ce.has(Fe)||ce.set(Fe,Tt);}}),ce.size>0&&Qt(me=>{let Ce=false,Ve=me.map(Fe=>{if(Fe.parentId!=null)return Fe;let Tt=ce.get(Fe.id);return Tt!=null?(Ce=true,{...Fe,parentId:Tt}):Fe});return Ce?Ve:me});}},[]),Ot=gm.useCallback(()=>{if(sn.current)return;let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,A=w.marks.comment;if(!A)return;let z=new Set;g.descendants(X=>{for(let fe of X.marks)if(fe.type===A){let ce=fe.attrs.commentId;ce!==ri&&z.add(ce);}});let U=zt.current,j=new Set;for(let X of U)X.parentId==null&&!z.has(X.id)&&j.add(X.id);if(j.size!==0){for(let X of U)j.has(X.id)&&hr.current?.(X);Qt(X=>X.filter(fe=>!j.has(fe.id)&&!j.has(fe.parentId)));}},[]);gm.useEffect(()=>()=>{Et.current&&clearTimeout(Et.current),yn.current&&clearTimeout(yn.current);},[]),gm.useEffect(()=>{if(Rt(L),L){let y=We.current?.getView();y&&Oe(Qo(y.state.doc));}},[L]);let ue=Qp(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),br=gm.useRef(false);gm.useEffect(()=>{if(br.current)return;let y=ue.state;if(!y)return;let g=y.package?.document?.comments;if(g&&g.length>0){Qt(g),Jt(true),br.current=true;let w=g.reduce((z,U)=>Math.max(z,U.id),0),A=We.current?.getView();A&&A.state.doc.descendants(z=>{for(let U of z.marks)U.attrs.revisionId!=null&&(w=Math.max(w,U.attrs.revisionId));}),w>=cc&&(cc=w+1);}},[ue.state]);let $t=gm.useMemo(()=>{let y=new to(rr());return y.buildSchema(),y.initializeRuntime(),y},[]),An=gm.useMemo(()=>rf(It==="suggesting",r),[]),Es=gm.useMemo(()=>[An,...E??[]],[An,E]),We=gm.useRef(null),tn=gm.useRef(null),Gn=gm.useRef(null),nn=gm.useRef(null),yr=gm.useRef(null),zo=gm.useRef(null),Yn=gm.useRef(null),qn=gm.useRef(null),Ps=gm.useRef(null),Co=gm.useRef(null),[li,xr]=gm.useState(0),Oo=gm.useRef(ue.state);Oo.current=ue.state;let Lt=gm.useRef({style:"single",size:4,color:{rgb:"000000"}}),ci=gm.useRef(null),Sr=gm.useCallback(y=>{let g=ci.current;if(g&&g.styles===y)return g.resolver;let w=On(y);return ci.current={styles:y,resolver:w},w},[]),[Dn,di]=gm.useState({currentPage:1,totalPages:1,visible:false}),To=gm.useRef(null),Ms=gm.useCallback(y=>{if(Ps.current=y,Co.current&&(Co.current.disconnect(),Co.current=null),!y){xr(0);return}xr(y.offsetHeight);let g=new ResizeObserver(()=>{xr(y.offsetHeight);});g.observe(y),Co.current=g;},[]);gm.useEffect(()=>()=>{Co.current?.disconnect();},[]);let Ae=gm.useCallback(()=>Le&&tn.current?tn.current.getView():We.current?.getView(),[Le]),Qe=gm.useCallback(()=>{Le&&tn.current?tn.current.focus():We.current?.focus();},[Le]),ui=gm.useCallback(()=>{Le&&tn.current?tn.current.undo():We.current?.undo();},[Le]),kr=gm.useCallback(()=>{Le&&tn.current?tn.current.redo():We.current?.redo();},[Le]),C=chunkAU5NVRHP_js.m(),O=chunk377ZVTSE_js.m(),[K,G]=gm.useState(false),ee=gm.useCallback(()=>G(true),[]),[W,J]=gm.useState(null),te=gm.useRef(0),le=gm.useCallback(()=>{br.current=false,Re.current=false,Qt([]),So([]),Oe([]),Jt(false),Yt(false),Dt(null),Ht(null),Ft(null),ze(null),No(um),C.setMatches([],0),Et.current&&(clearTimeout(Et.current),Et.current=null),yn.current&&(clearTimeout(yn.current),yn.current=null);},[C.setMatches]),xe=gm.useCallback(y=>{le(),ue.reset(y),ie(g=>({...g,isLoading:false,parseError:null})),chunkKUL2SDYC_js.l(y).catch(g=>{console.warn("Failed to load document fonts:",g);});},[le,ue]),ye=gm.useCallback(async y=>{let g=++te.current;le(),ie(w=>({...w,isLoading:true,parseError:null}));try{let w=await chunkKUL2SDYC_js.n(y);if(te.current!==g)return;xe(w);}catch(w){if(te.current!==g)return;let A=w instanceof Error?w.message:"Failed to parse document";ie(z=>({...z,isLoading:false,parseError:A})),s?.(w instanceof Error?w:new Error(A));}},[le,xe,s]);gm.useEffect(()=>{if(!t){n&&xe(n);return}ye(t);},[t,n]),gm.useEffect(()=>{ue.state?Gn.current=new chunkP7WEP4JU_js.f(ue.state):Gn.current=null;},[ue.state]);let Re=gm.useRef(false);gm.useEffect(()=>{if(!Z.isLoading&&ue.state){let y=setTimeout(()=>{Bn(),Re.current||(Re.current=true,So(g=>(g.length>0&&Jt(true),g)));},200);return ()=>clearTimeout(y)}},[Z.isLoading,ue.state,Bn]),gm.useEffect(()=>chunkKUL2SDYC_js.h(()=>{l?.();}),[l]),gm.useEffect(()=>{let y=We.current?.getView();y&&af(It==="suggesting",y.state,y.dispatch,r);},[It,r]);let ke=gm.useCallback(y=>(ue.push(y),y),[ue]),he=gm.useCallback(y=>{if(ke(y),i?.(y),Ne.current){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}Et.current&&clearTimeout(Et.current),Et.current=setTimeout(Bn,300),yn.current&&clearTimeout(yn.current),yn.current=setTimeout(Ot,300);},[i,ke,Bn,Ot]),Be=gm.useCallback(y=>{let g=Ae();if(g){let{from:Ve,to:Fe}=g.state.selection;yr.current={from:Ve,to:Fe};}let w=null;if(g&&(w=Ze(g.state),w.isInTable||(w=null)),w?.cellBorderColor){let Ve=w.cellBorderColor,Fe=Ve.rgb;(!Fe||Fe==="auto")&&(Fe=chunk4VUZBV2S_js.a(Ve,u).replace(/^#/,"")),Lt.current={...Lt.current,color:{rgb:Fe}};}let A=null;if(g){let Ve=g.state.selection,Fe=Ve.node;Fe?.type.name==="image"&&(A={pos:Ve.from,wrapType:Fe.attrs.wrapType??"inline",displayMode:Fe.attrs.displayMode??"inline",cssFloat:Fe.attrs.cssFloat??null,transform:Fe.attrs.transform??null,alt:Fe.attrs.alt??null,borderWidth:Fe.attrs.borderWidth??null,borderColor:Fe.attrs.borderColor??null,borderStyle:Fe.attrs.borderStyle??null});}if(!y){Ft(null),ie(Ve=>({...Ve,selectionFormatting:{},pmTableContext:w,pmImageContext:A}));return}let{textFormatting:z,paragraphFormatting:U}=y,j=z.fontFamily?.ascii||z.fontFamily?.hAnsi,X=z.fontSize;if(!j||!X){let Ve=Oo.current,Fe=y.styleId;if(Ve?.package.styles&&Fe){let Ct=Sr(Ve.package.styles).resolveParagraphStyle(Fe);!j&&Ct.runFormatting?.fontFamily&&(j=Ct.runFormatting.fontFamily.ascii||Ct.runFormatting.fontFamily.hAnsi),!X&&Ct.runFormatting?.fontSize&&(X=Ct.runFormatting.fontSize);}}let fe=z.color?.rgb?`#${z.color.rgb}`:void 0,ce=U.numPr,me=ce?{type:ce.numId===1?"bullet":"numbered",level:ce.ilvl??0,isInList:true,numId:ce.numId}:void 0,Ce={bold:z.bold,italic:z.italic,underline:!!z.underline,strike:z.strike,superscript:z.vertAlign==="superscript",subscript:z.vertAlign==="subscript",fontFamily:j,fontSize:X,color:fe,highlight:z.highlight,alignment:U.alignment,lineSpacing:U.lineSpacing,listState:me,styleId:y.styleId??void 0,indentLeft:U.indentLeft,bidi:!!U.bidi};if(ie(Ve=>({...Ve,selectionFormatting:Ce,paragraphIndentLeft:U.indentLeft??0,paragraphIndentRight:U.indentRight??0,paragraphFirstLineIndent:U.indentFirstLine??0,paragraphHangingIndent:U.hangingIndent??false,paragraphTabs:U.tabs??null,pmTableContext:w,pmImageContext:A})),g&&y.hasSelection&&!an&&!gt){let Ve=qn.current,Fe=Yn.current,{from:Tt}=g.state.selection,Ct=pm(Ve,Fe,Tt);if(Ct!=null&&Ve&&Fe){let Er=Ve.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),wi=Er?Er.getBoundingClientRect().right-Fe.getBoundingClientRect().left:Fe.getBoundingClientRect().width/2+408;Ft({top:Ct,left:wi});}}else Ft(null);a?.(y);},[a,an,gt]),$e=fd({document:ue.state,onChange:he,onSelectionChange:y=>{}});gm.useEffect(()=>{let y=g=>{let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey;if(!A&&!g.shiftKey&&!g.altKey&&(g.key==="Delete"||g.key==="Backspace")){let z=We.current?.getView();if(z){let U=z.state.selection;if("$anchorCell"in U&&typeof U.forEachCell=="function"){let X=Ze(z.state);if(X.isInTable&&X.table){let fe=0;X.table.descendants(me=>{(me.type.name==="tableCell"||me.type.name==="tableHeader")&&(fe+=1);});let ce=0;if(U.forEachCell(()=>{ce+=1;}),fe>0&&ce>=fe){g.preventDefault(),Gr(z.state,z.dispatch);return}}}}if($e.state.tableIndex!==null){g.preventDefault(),$e.handleAction("deleteTable");return}}if(A&&!g.shiftKey&&!g.altKey){if(g.key.toLowerCase()==="f"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C.openFind(U);}else if(g.key.toLowerCase()==="h"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C.openReplace(U);}else if(g.key.toLowerCase()==="k"){g.preventDefault();let z=We.current?.getView();if(z){let U=nr(z.state),j=tr(z.state);j?O.openEdit({url:j.href,displayText:U,tooltip:j.tooltip}):O.openInsert(U);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[C,O,$e]);let ut=gm.useCallback((y,g)=>{let w=Ae();w&&(va(y,g)(w.state,w.dispatch),Qe());},[Ae,Qe]),ht=gm.useCallback(()=>{let y=Ae();y&&(Ga(y.state,y.dispatch),Qe());},[Ae,Qe]),ln=gm.useCallback(()=>{let y=Ae();y&&(wa(y.state,y.dispatch),Qe());},[Ae,Qe]),$o=gm.useCallback(()=>{Rt(y=>{if(!y){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}return !y});},[]),pi=gm.useCallback(y=>{We.current?.scrollToPosition(y),We.current?.setSelection(y+1),We.current?.focus();},[]),fi=gm.useCallback(()=>{zo.current?.click();},[]),mi=gm.useCallback(y=>{let g=y.target.files?.[0];if(!g)return;let w=Ae();if(!w)return;let A=new FileReader;A.onload=()=>{let z=A.result,U=new Image;U.onload=()=>{let j=U.naturalWidth,X=U.naturalHeight,fe=612;if(j>fe){let Fe=fe/j;j=fe,X=Math.round(X*Fe);}let ce=`rId_img_${Date.now()}`,me=w.state.schema.nodes.image.create({src:z,alt:g.name,width:j,height:X,rId:ce,wrapType:"inline",displayMode:"inline"}),{from:Ce}=w.state.selection,Ve=w.state.tr.insert(Ce,me);w.dispatch(Ve.scrollIntoView()),Qe();},U.src=z;},A.readAsDataURL(g),y.target.value="";},[Ae,Qe]),gi=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z="inline",U=null;switch(y){case "inline":z="inline",U=null;break;case "square":case "tight":case "through":z="float",U="left";break;case "topAndBottom":z="block",U=null;break;case "behind":case "inFront":z="float",U="none";break;case "wrapLeft":z="float",U="right",y="square";break;case "wrapRight":z="float",U="left",y="square";break}let j=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,wrapType:y,displayMode:z,cssFloat:U});g.dispatch(j.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),Cr=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=A.attrs.transform||"",U=z.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),j=U?parseFloat(U[1]):0,X=/scaleX\(-1\)/.test(z),fe=/scaleY\(-1\)/.test(z);switch(y){case "rotateCW":j=(j+90)%360;break;case "rotateCCW":j=(j-90+360)%360;break;case "flipH":X=!X;break;case "flipV":fe=!fe;break}let ce=[];j!==0&&ce.push(`rotate(${j}deg)`),X&&ce.push("scaleX(-1)"),fe&&ce.push("scaleY(-1)");let me=ce.length>0?ce.join(" "):null,Ce=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,transform:me});g.dispatch(Ce.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),Tr=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??A.attrs.distTop,distBottom:y.distBottom??A.attrs.distBottom,distLeft:y.distLeft??A.attrs.distLeft,distRight:y.distRight??A.attrs.distRight});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),_o=gm.useCallback(()=>{_e(true);},[]),cn=gm.useCallback(y=>{let g=Ae();if(!g||!Z.pmImageContext)return;let w=Z.pmImageContext.pos,A=g.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...A.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z.pmImageContext]),wo=gm.useCallback((y,g)=>{if(!ue.state?.package)return;let w={...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:g}};ke({...ue.state,package:{...ue.state.package,document:w}});},[ue,ke]),wr=gm.useCallback(y=>{let g=Ae();if(g){switch(y){case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "deleteTable":Gr(g.state,g.dispatch);break;case "selectTable":Ra(g.state,g.dispatch);break;case "selectRow":Ea(g.state,g.dispatch);break;case "selectColumn":Pa(g.state,g.dispatch);break;case "mergeCells":Ma(g.state,g.dispatch);break;case "splitCell":Ia(g.state,g.dispatch);break;case "borderAll":La(g.state,g.dispatch,Lt.current);break;case "borderOutside":Ba(g.state,g.dispatch,Lt.current);break;case "borderInside":Aa(g.state,g.dispatch,Lt.current);break;case "borderNone":Fa(g.state,g.dispatch);break;case "borderTop":no("top",Lt.current,true)(g.state,g.dispatch);break;case "borderBottom":no("bottom",Lt.current,true)(g.state,g.dispatch);break;case "borderLeft":no("left",Lt.current,true)(g.state,g.dispatch);break;case "borderRight":no("right",Lt.current,true)(g.state,g.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")Ua(y.color)(g.state,g.dispatch);else if(y.type==="borderColor"){let w=y.color.replace(/^#/,"");Lt.current={...Lt.current,color:{rgb:w}},ja(y.color)(g.state,g.dispatch);}else if(y.type==="borderWidth")Lt.current={...Lt.current,size:y.size},Ka(y.size)(g.state,g.dispatch);else if(y.type==="cellBorder")no(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(g.state,g.dispatch);else if(y.type==="cellVerticalAlign")Da(y.align)(g.state,g.dispatch);else if(y.type==="cellMargins")Ha(y.margins)(g.state,g.dispatch);else if(y.type==="cellTextDirection")Na(y.direction)(g.state,g.dispatch);else if(y.type==="toggleNoWrap")za()(g.state,g.dispatch);else if(y.type==="rowHeight")Oa(y.height,y.rule)(g.state,g.dispatch);else if(y.type==="toggleHeaderRow")$a()(g.state,g.dispatch);else if(y.type==="distributeColumns")_a()(g.state,g.dispatch);else if(y.type==="autoFitContents")Wa()(g.state,g.dispatch);else if(y.type==="openTableProperties")He(true);else if(y.type==="tableProperties")Yr(y.props)(g.state,g.dispatch);else if(y.type==="applyTableStyle"){let w=Yp(y.styleId),A=Oo.current;if(!w&&A?.package.styles){let U=Sr(A.package.styles).getStyle(y.styleId);if(U){if(w={id:U.styleId,name:U.name??U.styleId},U.tblPr?.borders){let j=U.tblPr.borders;w.tableBorders={};for(let X of ["top","bottom","left","right","insideH","insideV"]){let fe=j[X];fe&&(w.tableBorders[X]={style:fe.style,size:fe.size,color:fe.color?.rgb?{rgb:fe.color.rgb}:void 0});}}if(U.tblStylePr){w.conditionals={};for(let j of U.tblStylePr){let X={};if(j.tcPr?.shading?.fill&&(X.backgroundColor=`#${j.tcPr.shading.fill}`),j.tcPr?.borders){let fe={};for(let ce of ["top","bottom","left","right"]){let me=j.tcPr.borders[ce];me&&(fe[ce]={style:me.style,size:me.size,color:me.color?.rgb?{rgb:me.color.rgb}:void 0});}X.borders=fe;}j.rPr?.bold&&(X.bold=true),j.rPr?.color?.rgb&&(X.color=`#${j.rPr.color.rgb}`),w.conditionals[j.type]=X;}}w.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}w&&Va({styleId:w.id,tableBorders:w.tableBorders,conditionals:w.conditionals,look:w.look})(g.state,g.dispatch);}}else $e.handleAction(y);}Qe();}},[$e,Ae,Qe]),Is=gm.useCallback(y=>{y.preventDefault(),y.stopPropagation();let g=We.current?.getView(),w=g?Qn(g.state):false,{from:A,to:z}=g?.state.selection??{from:0,to:0},U=A!==z;Kn({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:U,cursorInTable:w});},[]),vr=gm.useCallback(y=>{let g=Ae();if(!g)return;g.focus();let w=g===We.current?.getView(),{from:A,to:z}=g.state.selection,U=yr.current;if(w&&U&&(A!==U.from||z!==U.to))try{let j=g.state.tr.setSelection(prosemirrorState.TextSelection.create(g.state.doc,U.from,U.to));g.dispatch(j);}catch(j){console.warn("Could not restore selection:",j);}if(y==="bold"){Qi(g.state,g.dispatch);return}if(y==="italic"){ea(g.state,g.dispatch);return}if(y==="underline"){ta(g.state,g.dispatch);return}if(y==="strikethrough"){na(g.state,g.dispatch);return}if(y==="superscript"){oa(g.state,g.dispatch);return}if(y==="subscript"){ra(g.state,g.dispatch);return}if(y==="bulletList"){ba(g.state,g.dispatch);return}if(y==="numberedList"){ya(g.state,g.dispatch);return}if(y==="indent"){xa(g.state,g.dispatch)||fa()(g.state,g.dispatch);return}if(y==="outdent"){Sa(g.state,g.dispatch)||ma()(g.state,g.dispatch);return}if(y==="clearFormatting"){Hr(g.state,g.dispatch);return}if(y==="setRtl"){Ca(g.state,g.dispatch);return}if(y==="setLtr"){Ta(g.state,g.dispatch);return}if(y==="insertLink"){let j=nr(g.state),X=tr(g.state);X?O.openEdit({url:X.href,displayText:j,tooltip:X.tooltip}):O.openInsert(j);return}if(typeof y=="object")switch(y.type){case "alignment":ua(y.value)(g.state,g.dispatch);break;case "textColor":{let j=y.value;typeof j=="string"?Or({rgb:j.replace("#","")})(g.state,g.dispatch):j.auto?ia(g.state,g.dispatch):Or(j)(g.state,g.dispatch);break}case "highlightColor":{let j=y.value?chunkDC65PJYE_js.z(y.value):"";aa(j||y.value)(g.state,g.dispatch);break}case "fontSize":sa(chunkDC65PJYE_js.i(y.value))(g.state,g.dispatch);break;case "fontFamily":la(y.value)(g.state,g.dispatch);break;case "lineSpacing":pa(y.value)(g.state,g.dispatch);break;case "applyStyle":{let j=Oo.current,X=j?.package.styles?Sr(j.package.styles):null;if(X){let fe=X.resolveParagraphStyle(y.value);Wr(y.value,{paragraphFormatting:fe.paragraphFormatting,runFormatting:fe.runFormatting})(g.state,g.dispatch);}else Wr(y.value)(g.state,g.dispatch);break}}},[Ae]),hi=gm.useCallback(y=>{ie(g=>({...g,zoom:y}));},[]),kt=gm.useCallback(y=>{let g=Ae();if(!g)return;let w=y.url||"",A=y.tooltip,{empty:z}=g.state.selection;z&&y.displayText?$r(y.displayText,w,A)(g.state,g.dispatch):z?y.displayText&&$r(y.displayText,w,A)(g.state,g.dispatch):ca(w,A)(g.state,g.dispatch),O.close(),Qe();},[O,Ae,Qe]),Xn=gm.useCallback(()=>{let y=Ae();y&&(da(y.state,y.dispatch),Qe());},[Ae,Qe]),xn=gm.useCallback(()=>{Xn(),O.close();},[O,Xn]),vo=gm.useCallback(y=>J(y),[]),Ro=gm.useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),Fs=gm.useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let g=document.createElement("textarea");g.value=y,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g);});},[]),Lm=gm.useCallback((y,g)=>{let w=Ae();if(!w)return;let A=w.state.schema.marks.hyperlink;if(!A)return;let{$from:z}=w.state.selection,U=z.marks().find(j=>j.type===A);if(U){let j=z.parent,X=z.start(),fe=[],ce=null;j.forEach((Ct,Rr)=>{let Er=X+Rr,wi=Er+Ct.nodeSize;(Ct.isText?Ct.marks.find(bc=>bc.type===A&&bc.attrs.href===U.attrs.href):null)?ce?ce.end=wi:ce={start:Er,end:wi}:ce&&(fe.push(ce),ce=null);}),ce&&fe.push(ce);let me=z.pos,Ce=fe.find(Ct=>Ct.start<=me&&me<=Ct.end);if(!Ce)return;let Ve=w.state.tr,Fe=A.create({href:g,tooltip:U.attrs.tooltip}),Tt=w.state.schema.text(y,[...z.marks().filter(Ct=>Ct.type!==A),Fe]);Ve.replaceWith(Ce.start,Ce.end,Tt),w.dispatch(Ve.scrollIntoView());}J(null),Qe();},[Ae,Qe]),Bm=gm.useCallback(()=>{let y=Ae();if(!y)return;let g=y.state.schema.marks.hyperlink;if(!g)return;let{$from:w}=y.state.selection,A=w.marks().find(Ce=>Ce.type===g);if(!A&&w.nodeAfter&&(A=w.nodeAfter.marks.find(Ce=>Ce.type===g)),!A&&w.nodeBefore&&(A=w.nodeBefore.marks.find(Ce=>Ce.type===g)),!A&&W&&w.parent.forEach(Ve=>{if(!A&&Ve.isText){let Fe=Ve.marks.find(Tt=>Tt.type===g&&Tt.attrs.href===W.href);Fe&&(A=Fe);}}),!A)return;let z=w.parent,U=w.start(),j=[],X=null;z.forEach((Ce,Ve)=>{let Fe=U+Ve,Tt=Fe+Ce.nodeSize;(Ce.isText?Ce.marks.find(Rr=>Rr.type===g&&Rr.attrs.href===A.attrs.href):null)?X?X.end=Tt:X={start:Fe,end:Tt}:X&&(j.push(X),X=null);}),X&&j.push(X);let fe=w.pos,ce=j.find(Ce=>Ce.start<=fe&&fe<=Ce.end);if(!ce)return;let me=y.state.tr;me.removeMark(ce.start,ce.end,g),y.dispatch(me.scrollIntoView()),J(null),Qe(),sonner.toast("Link removed");},[Ae,Qe,W]),Am=gm.useCallback(()=>{J(null);},[]),Dm=gm.useCallback(y=>{let g=We.current?.getView(),w=g?Qn(g.state):false;Kn({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:w});},[]),Hm=gm.useCallback(()=>{Kn({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),fc=gm.useMemo(()=>{let g=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",w=[{action:"cut",label:"Cut",shortcut:`${g}+X`},{action:"copy",label:"Copy",shortcut:`${g}+C`},{action:"paste",label:"Paste",shortcut:`${g}+V`},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:`${g}+Shift+V`,dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:!ot.hasSelection&&!ot.cursorInTable}];return ot.hasSelection&&w.push({action:"addComment",label:"Comment",dividerAfter:!ot.cursorInTable}),ot.cursorInTable&&w.push({action:"addRowAbove",label:"Insert row above"},{action:"addRowBelow",label:"Insert row below"},{action:"deleteRow",label:"Delete row",dividerAfter:true},{action:"addColumnLeft",label:"Insert column left"},{action:"addColumnRight",label:"Insert column right"},{action:"deleteColumn",label:"Delete column",dividerAfter:true}),w.push({action:"selectAll",label:"Select All",shortcut:`${g}+A`}),w},[ot.hasSelection,ot.cursorInTable]),mc=gm.useCallback(async y=>{let g=Ae();if(g)switch(Qe(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let w=await navigator.clipboard.read(),A="",z="";for(let X of w)X.types.includes("text/html")&&(A=await(await X.getType("text/html")).text()),X.types.includes("text/plain")&&(z=await(await X.getType("text/plain")).text());let U=new DataTransfer;A&&U.items.add(A,"text/html"),z&&U.items.add(z,"text/plain");let j=new ClipboardEvent("paste",{clipboardData:U,bubbles:!0,cancelable:!0});g.dom.dispatchEvent(j);}catch{try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}}break}case "pasteAsPlainText":try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}break;case "delete":{let{from:w,to:A}=g.state.selection;w!==A&&g.dispatch(g.state.tr.deleteRange(w,A));break}case "selectAll":g.dispatch(g.state.tr.setSelection(prosemirrorState.TextSelection.create(g.state.doc,0,g.state.doc.content.size)));break;case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "addComment":{let{from:w,to:A}=g.state.selection;if(w===A)break;let z=pm(qn.current,Yn.current,w);Dt({from:w,to:A});let U=g.state.schema.marks.comment.create({commentId:ri}),j=g.state.tr.addMark(w,A,U);j.setSelection(prosemirrorState.TextSelection.create(j.doc,A)),g.dispatch(j),Ht(z),Jt(true),Yt(true),Ft(null);break}}},[Ae,Qe]),Zn=gm.useCallback(y=>g=>{if(!ue.state||gt)return;let w={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,[y]:g}}}};he(w);},[ue.state,gt,he]),Nm=gm.useMemo(()=>Zn("marginLeft"),[Zn]),zm=gm.useMemo(()=>Zn("marginRight"),[Zn]),Om=gm.useMemo(()=>Zn("marginTop"),[Zn]),$m=gm.useMemo(()=>Zn("marginBottom"),[Zn]),_m=gm.useCallback(y=>{if(!ue.state||gt)return;let g={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,...y}}}};he(g);},[ue.state,gt,he]),Wm=gm.useCallback(y=>{let g=Ae();g&&ga(y)(g.state,g.dispatch);},[Ae]),Vm=gm.useCallback(y=>{let g=Ae();g&&ha(y)(g.state,g.dispatch);},[Ae]),Um=gm.useCallback(y=>{let g=Ae();g&&(y<0?_r(-y,true)(g.state,g.dispatch):_r(y,false)(g.state,g.dispatch));},[Ae]),jm=gm.useCallback(y=>{let g=Ae();g&&ka(y)(g.state,g.dispatch);},[Ae]),Wo=qn.current;gm.useEffect(()=>{if(!Wo)return;let y=()=>{let g=We.current?.getLayout();if(!g||g.pages.length===0)return;let w=Wo.scrollTop,A=g.pages.length,z=24,U=24,j=w+Wo.clientHeight/2,X=U,fe=1;for(let ce=0;ce<g.pages.length;ce++){let me=g.pages[ce].size.h,Ce=X+me;if(j<Ce){fe=ce+1;break}X=Ce+z,fe=ce+2;}fe=Math.min(fe,A),di({currentPage:fe,totalPages:A,visible:true}),To.current&&clearTimeout(To.current),To.current=setTimeout(()=>{di(ce=>({...ce,visible:false}));},600);};return Wo.addEventListener("scroll",y,{passive:true}),()=>{Wo.removeEventListener("scroll",y),To.current&&clearTimeout(To.current);}},[Wo]);let gc=gm.useCallback(async y=>{if(!Gn.current)return null;try{let g=Gn.current.getDocument(),w=We.current?.getDocument();w?.package?.document&&(g.package.document.content=w.package.document.content),g.package.document.comments=dt,$k(g.package.document.content,dt),_k(g.package.document.content,dt);let A=y?.selective!==!1,z=We.current?.getView(),U;if(A&&z){let X=z.state,fe=dt.some(ce=>ce.parentId!=null);U={selective:{changedParaIds:sp(X),structuralChange:lp(X)||fe,hasUntrackedChanges:cp(X)}};}let j=await Gn.current.toBuffer(U);return z&&z.dispatch(dp(z.state)),o?.(j),j}catch(g){return s?.(g instanceof Error?g:new Error("Failed to save document")),null}},[o,s,dt]),Km=gm.useCallback(y=>{s?.(y);},[s]),bi=gm.useCallback(()=>{let y=nn.current?.querySelector(".paged-editor__pages");if(!y){window.print(),_?.();return}let g=window.open("","_blank");if(!g){window.print(),_?.();return}let w=[];for(let z of Array.from(document.styleSheets))try{for(let U of Array.from(z.cssRules))U instanceof CSSFontFaceRule&&w.push(U.cssText);}catch{}let A=y.cloneNode(true);A.style.cssText="display: block; margin: 0; padding: 0;";for(let z of Array.from(A.querySelectorAll(".layout-page"))){let U=z;U.style.boxShadow="none",U.style.margin="0";}g.document.write(`<!DOCTYPE html>
|
|
19
19
|
<html><head><title>Print</title>
|
|
20
20
|
<style>
|
|
21
21
|
${w.join(`
|