@eigenpal/docx-js-editor 0.0.29 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClipboardManager-D0D4aUKE.d.ts → ClipboardManager-C0rTRkVQ.d.ts} +29 -1
- package/dist/{ClipboardManager-t936d0KD.d.mts → ClipboardManager-CgpKW2At.d.mts} +29 -1
- package/dist/PageSetupDialog-2SKHDRTF.js +1 -0
- package/dist/PageSetupDialog-SMQJXEBL.mjs +1 -0
- package/dist/{chunk-MRWJ3GNH.js → chunk-3Y6ZBC3P.js} +2 -2
- package/dist/{chunk-YGTSQZRK.mjs → chunk-6CSL7T4S.mjs} +1 -1
- package/dist/chunk-A2DPBJHE.mjs +258 -0
- package/dist/chunk-CQR767EJ.mjs +1 -0
- package/dist/{chunk-IRO7KGGC.js → chunk-DJI7XTMH.js} +2 -2
- package/dist/{chunk-Z35FA4M4.mjs → chunk-FFNGY4AB.mjs} +5 -5
- package/dist/chunk-HIITS47V.js +258 -0
- package/dist/{chunk-VHWEKJ35.js → chunk-N2UPYG75.js} +5 -5
- package/dist/{chunk-VR6PT4IZ.js → chunk-NKJBKWYY.js} +13 -13
- package/dist/{chunk-CQRI4YUS.mjs → chunk-OBTGZZLM.mjs} +13 -13
- package/dist/{chunk-I6LFWQFR.mjs → chunk-TQATISQV.mjs} +1 -1
- package/dist/chunk-ZKKL54FH.js +1 -0
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -1
- package/dist/core-reexport.d.mts +2 -2
- package/dist/core-reexport.d.ts +2 -2
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -1
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +1 -1
- package/dist/index.d.mts +10 -27
- package/dist/index.d.ts +10 -27
- package/dist/index.js +23 -66
- package/dist/index.mjs +23 -66
- package/dist/mcp-reexport.js +10 -10
- package/dist/mcp-reexport.mjs +8 -8
- package/dist/{react-C-pJU0Y4.d.mts → react-B2h6vE3D.d.mts} +118 -83
- package/dist/{react-By80Gfi-.d.ts → react-CAc4htNH.d.ts} +118 -83
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/selectionRects-D45BP6HQ.js +1 -0
- package/dist/selectionRects-Z72BKRLU.mjs +1 -0
- package/package.json +1 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +0 -1
- package/dist/PageSetupDialog-ZZTFPZKJ.js +0 -1
- package/dist/chunk-G72SXG7G.js +0 -258
- package/dist/chunk-MVCTPHRR.mjs +0 -258
- package/dist/chunk-QQ63M65M.js +0 -1
- package/dist/chunk-TDEHAPMZ.mjs +0 -1
- package/dist/selectionRects-6TRAXB7D.js +0 -1
- package/dist/selectionRects-IS7ZAS3A.mjs +0 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {e,p,o,m,n,f as f$2,c as c$1,d as d$2,a as a$4,k as k$1,h as h$2,i as i$2,g as g$2,j as j$2,l as l$2}from'./chunk-CQR767EJ.mjs';import {i,z,C,A,d,E,c,Z,ea as ea$1,ma as ma$1,la as la$1,fa as fa$1,ka as ka$1,ia as ia$1,ja as ja$1,ha as ha$1,w,a as a$2,y,L,M,T,O,S,x,e as e$2,f as f$3}from'./chunk-7HZRJTOL.mjs';import {m as m$1,j,l as l$1}from'./chunk-XWBCP563.mjs';import {m as m$2}from'./chunk-AZRYS2WF.mjs';import {J,C as C$1,z as z$1,B,A as A$1,H,I,r,F}from'./chunk-QTSXJRP6.mjs';import {f}from'./chunk-6CSL7T4S.mjs';import {a,n as n$2,c as c$3}from'./chunk-QAZ4233N.mjs';import {a as a$1}from'./chunk-M5F4SK3W.mjs';import {l,n as n$1,h,b}from'./chunk-OBTGZZLM.mjs';import {a as a$3,b as b$1,k,g as g$1,c as c$2,j as j$1,d as d$3,i as i$3,h as h$3}from'./chunk-LYBG4YI7.mjs';import {d as d$1,f as f$1,g,i as i$1,e as e$1,h as h$1}from'./chunk-TAUMSKRE.mjs';import $f,{createContext,forwardRef,useRef,useState,useLayoutEffect,useEffect,useCallback,useImperativeHandle,memo,useMemo,lazy,Suspense,useSyncExternalStore,cloneElement,Component,useContext,Children,isValidElement}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {PluginKey,EditorState,NodeSelection,TextSelection,Plugin,Selection}from'prosemirror-state';import {EditorView,DecorationSet,Decoration}from'prosemirror-view';import {redo,undo,history}from'prosemirror-history';import {Schema,Fragment as Fragment$1}from'prosemirror-model';import {toggleMark,selectParentNode,selectAll,baseKeymap,splitBlock,joinForward,deleteSelection,joinBackward}from'prosemirror-commands';import {CellSelection,splitCell,mergeCells,columnResizing,tableEditing}from'prosemirror-tables';import {dropCursor}from'prosemirror-dropcursor';import {keymap}from'prosemirror-keymap';import'prosemirror-view/style/prosemirror.css';import {toast,Toaster}from'sonner';import {createRoot}from'react-dom/client';function Pm(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Vs({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function Mm(e){return e.replace(/\.docx$/i,"")}function _c({value:e,onChange:t,placeholder:n="Untitled",editable:o=true}){let r=Mm(e);return o?jsx("input",{type:"text",value:r,onChange:i=>{let a=i.target.value;t?.(a.endsWith(".docx")?a:a+".docx");},placeholder:n,className:"text-base font-normal text-slate-800 bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-slate-50 focus:bg-white focus:ring-1 focus:ring-slate-300 min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":"Document name"}):jsx("span",{className:"text-base font-normal text-slate-800 px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:r||n})}function Us({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function js(){let e=x(),{disabled:t=false,onFormat:n,onPrint:o,showPrintButton:r=true,onPageSetup:i,onInsertImage:a,onInsertTable:s,showTableInsert:l=true,onInsertPageBreak:u,onInsertTOC:d,onRefocusEditor:c}=e,p=useCallback(b=>{!t&&n&&n(b);},[t,n]),f=useCallback((b,g)=>{!t&&s&&(s(b,g),requestAnimationFrame(()=>c?.()));},[t,s,c]);return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":"Menu bar",children:[(r&&o||i)&&jsx(e$2,{label:"File",disabled:t,items:[...r&&o?[{icon:"print",label:"Print",shortcut:"Ctrl+P",onClick:o}]:[],...i?[{icon:"settings",label:"Page setup",onClick:i}]:[]]}),jsx(e$2,{label:"Format",disabled:t,items:[{icon:"format_textdirection_l_to_r",label:"Left-to-right text",onClick:()=>p("setLtr")},{icon:"format_textdirection_r_to_l",label:"Right-to-left text",onClick:()=>p("setRtl")}]}),jsx(e$2,{label:"Insert",disabled:t,items:[...a?[{icon:"image",label:"Image",onClick:a}]:[],...l&&s?[{icon:"grid_on",label:"Table",submenuContent:b=>jsx(f$3,{onInsert:(g,x)=>{f(g,x),b();}})}]:[],...a||l&&s?[{type:"separator"}]:[],{icon:"page_break",label:"Page break",onClick:u,disabled:!u},{icon:"format_list_numbered",label:"Table of contents",onClick:d,disabled:!d}]})]})}function Wc({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===Vs?t=a:a.type===Us?n=a:a.type===js?r.push(a):o.push(a));});let i=useCallback(a=>{let s=a.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-white pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(Pm,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}function Im({children:e,className:t,...n}){return jsx(w.Provider,{value:n,children:jsx("div",{className:a$2("flex flex-col bg-white shadow-sm flex-shrink-0",t),"data-testid":"editor-toolbar",children:e})})}var Ht=Im;Ht.TitleBar=Wc;Ht.Logo=Vs;Ht.DocumentName=_c;Ht.MenuBar=js;Ht.TitleBarRight=Us;Ht.FormattingBar=y;var jc=createContext(null);function Lk(){let e=useContext(jc);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function Gc({children:e}){let t=useMemo(()=>new H,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((u,d)=>{t.showError(u,d);},[t]),r=useCallback((u,d)=>{t.showWarning(u,d);},[t]),i=useCallback((u,d)=>{t.showInfo(u,d);},[t]),a=useCallback(u=>{t.dismiss(u);},[t]),s=useCallback(()=>{t.clearAll();},[t]),l=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[n.notifications,o,r,i,a,s]);return jsxs(jc.Provider,{value:l,children:[e,jsx(Hm,{notifications:n.notifications,onDismiss:a})]})}function Hm({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:n.map(r=>jsx(Nm,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function Nm({notification:e,onDismiss:t}){let[n,o]=useState(false),i=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"#f5c6cb",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"#ffeeba",text:"#856404",icon:"var(--doc-warning)"};case "info":return {bg:"#e8f4fd",border:"#b8daff",text:"#0c5460",icon:"var(--doc-primary)"}}})(e.severity),a={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},u={flex:1,minWidth:0},d={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},c={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},f=m=>{switch(m){case "error":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[jsx("style",{children:`
|
|
2
|
+
@keyframes slideIn {
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
transform: translateX(100%);
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateX(0);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`}),jsxs("div",{style:s,children:[jsx("span",{style:l,children:f(e.severity)}),jsxs("div",{style:u,children:[jsx("div",{style:d,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsx("div",{style:c,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var wi=class extends Component{constructor(n){super(n);d$1(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:i}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsx(Om,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function Om({error:e,errorInfo:t,showDetails:n,onReset:o}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},u={padding:"10px 20px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxs("div",{className:"docx-error-fallback",style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:a,children:"Something went wrong"}),jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxs("div",{style:l,children:[jsx("strong",{children:"Error:"})," ",e.message,t&&jsxs(Fragment,{children:[`
|
|
13
|
+
|
|
14
|
+
`,jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:u,children:"Try Again"})]})}function Bk({message:e,details:t,onRetry:n,className:o=""}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border-light)"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"16px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={marginBottom:"16px",padding:"12px",background:"var(--doc-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",maxWidth:"100%",overflow:"auto",textAlign:"left"},u={padding:"8px 16px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"13px",cursor:"pointer"};return jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h3",{style:a,children:"Unable to Parse Document"}),jsx("p",{style:s,children:e}),t&&jsx("div",{style:l,children:t}),n&&jsx("button",{type:"button",onClick:n,style:u,children:"Try Again"})]})}function Ak({feature:e,description:t,className:n=""}){let o={display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--doc-warning-bg)",border:"1px solid #ffeeba",borderRadius:"4px",fontSize:"12px",color:"#856404"},r={flexShrink:0,color:"var(--doc-warning)"};return jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsx("span",{style:r,children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxs("span",{children:[jsx("strong",{children:e}),t&&`: ${t}`]})]})}function Dk(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function Hk(e){let t=e.message.toLowerCase();return t.includes("network")||t.includes("fetch")?"Network error. Please check your internet connection and try again.":t.includes("parse")||t.includes("xml")||t.includes("invalid")?"The document could not be parsed. It may be corrupted or in an unsupported format.":t.includes("permission")||t.includes("access")?"Access denied. You may not have permission to access this file.":t.includes("not found")||t.includes("404")?"The requested file was not found.":t.includes("timeout")?"The operation timed out. Please try again.":"An unexpected error occurred. Please try again."}function Yc({document:e,onChange:t,onSelectionChange:n}){let o=useMemo(()=>new C$1,[]),[r,i]=useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),a=useCallback((d,c,p)=>{if(!e)return;let f=z$1(e,d);if(!f){o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}o.selectCell({tableIndex:d,rowIndex:c,columnIndex:p});let b=ea$1(f,{tableIndex:d,rowIndex:c,columnIndex:p});i({context:b,table:f,tableIndex:d,rowIndex:c,columnIndex:p}),n?.(b);},[e,o,n]),s=useCallback(()=>{o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[o,n]),l=useCallback(d=>{if(!e||!r.context||r.tableIndex===null||r.rowIndex===null||r.columnIndex===null)return;let c=r.table;if(!c)return;let p=null,f=null,m=r.rowIndex,b=r.columnIndex;switch(d){case "addRowAbove":p=ha$1(c,r.rowIndex,"before"),m=r.rowIndex+1;break;case "addRowBelow":p=ha$1(c,r.rowIndex,"after");break;case "addColumnLeft":p=ja$1(c,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=ja$1(c,r.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(p=ia$1(c,r.rowIndex),m>=p.rows.length&&(m=p.rows.length-1));break;case "deleteColumn":{if(fa$1(c)>1){p=ka$1(c,r.columnIndex);let x=fa$1(p);b>=x&&(b=x-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=la$1(c,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=ma$1(c,r.rowIndex,r.columnIndex));break;case "deleteTable":f=B(e,r.tableIndex),s(),t?.(f);return}p&&(f=A$1(e,r.tableIndex,p),t?.(f),f&&a(r.tableIndex,m,b));},[e,r,t,s,a]),u=useCallback((d,c,p)=>o.isCellSelected(d,c,p),[o,r]);return {state:r,handleCellClick:a,handleAction:l,clearSelection:s,isCellSelected:u,tableContext:r.context}}var Xc=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=useState(false);return useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":"Document outline",style:{position:"absolute",top:o,left:30,bottom:0,width:240,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:r?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:a=>a.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsx("button",{onClick:n,"aria-label":"Close outline",style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:"Close outline",children:jsx(d,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?jsx("div",{style:{padding:"8px 16px",color:"#80868b",fontSize:13,lineHeight:"20px"},children:"No headings found. Add headings to your document to see them here."}):e.map((a,s)=>jsx("div",{style:{marginLeft:a.level*12},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(a.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"#1f1f1f",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:a.text,children:a.text})},`${a.pmPos}-${s}`))})]})};function Zc(e,t,n,o,r,i){if(e.length===0)return [];let a=n?.getContainerOffset(),s=[];for(let d of e){let c;if(d.fixedY!=null&&(c=d.fixedY*o),c==null&&d.anchorKey){let p=t.get(d.anchorKey);p!=null&&(c=p*o);}if(c==null&&n){let p=n.getRectsForRange(d.anchorPos,d.anchorPos+1);p.length>0&&a&&(c=(p[0].y+a.y)*o);}if(c==null){let p=i.get(d.id);p!=null&&(c=p);}c!=null&&(s.push({item:d,targetY:c}),i.set(d.id,c));}s.sort((d,c)=>{let p=d.targetY-c.targetY;return p!==0?p:(d.item.priority??0)-(c.item.priority??0)});let l=[],u=0;for(let d of s){let c=r.get(d.item.id)??d.item.estimatedHeight??80,p=Math.max(d.targetY,u+8);l.push({item:d.item,y:p}),u=p+c;}return l}function td({items:e,anchorPositions:t,renderedDomContext:n,pageWidth:o,zoom:r,editorContainerRef:i}){let[a,s]=useState(null),[l,u]=useState(false),d=useRef(new Map),c=useRef(new Map),p=useRef(new Set),f=useRef(null),m=useRef(new Map),b=useRef(new Map),[g,x]=useState(0),k=useMemo(()=>Zc(e,t,n,r,d.current,c.current),[e,t,n,r,g]),S=k.length>0,B=useMemo(()=>{let P=new Map;for(let z of k)P.set(z.item.id,z.y);return P},[k]);useEffect(()=>{for(let P of k)p.current.add(P.item.id);},[k]),useEffect(()=>{let P=setTimeout(()=>x(I=>I+1),50),z=setTimeout(()=>{x(I=>I+1),u(true);},400);return ()=>{clearTimeout(P),clearTimeout(z);}},[e.length]),useEffect(()=>{let P=i?.current;if(!P)return;let z=new ResizeObserver(()=>{requestAnimationFrame(()=>x(I=>I+1));});return z.observe(P),()=>z.disconnect()},[i]),useEffect(()=>{if(!a)return;let P=m.current.get(a);if(!P){let A=requestAnimationFrame(()=>x(Z=>Z+1));return ()=>cancelAnimationFrame(A)}let z,I=new ResizeObserver(()=>{cancelAnimationFrame(z),z=requestAnimationFrame(()=>x(A=>A+1));});return I.observe(P),()=>{cancelAnimationFrame(z),I.disconnect();}},[a]),useEffect(()=>{let P=i?.current;if(!P)return;let z=P.querySelector(".paged-editor__pages");if(!z)return;let I=A=>{let Z=A.target;if(!f.current?.contains(Z)){if(z.contains(Z)){let ce=Z.closest("[data-comment-id]");if(ce?.dataset.commentId){s(`comment-${ce.dataset.commentId}`);return}let ae=Z.closest(".docx-insertion")||Z.closest(".docx-deletion");if(ae?.dataset.revisionId){let $=`tc-${ae.dataset.revisionId}-`,H=e.find(de=>de.id.startsWith($));if(H){s(H.id);return}}}s(null);}};return P.addEventListener("click",I),()=>P.removeEventListener("click",I)},[i,e]);let w=useCallback(P=>{let z=b.current.get(P);return z||(z=I=>{I?(m.current.set(P,I),d.current.set(P,I.offsetHeight)):(m.current.delete(P),d.current.delete(P));},b.current.set(P,z)),z},[]),E=useCallback(P=>{s(z=>z===P?null:P);},[]);return e.length===0?null:jsx("aside",{ref:f,className:"docx-unified-sidebar",role:"complementary","aria-label":"Annotations sidebar",style:{position:"absolute",top:0,left:`calc(50% - ${176}px + ${o*r/2+12}px)`,width:340,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:"visible",overflowX:"visible",opacity:S?1:0,transition:"opacity 0.15s ease"},onMouseDown:P=>P.stopPropagation(),children:jsx("div",{style:{position:"relative"},children:e.map(P=>{let z=B.get(P.id),I=a===P.id,Z=!p.current.has(P.id)&&z!==void 0,ce=S&&!B.has(P.id),ae=S?z!==void 0?{position:"absolute",top:z,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},$=ce?"none":Z||P.isTemporary?"opacity 0.2s ease":l?"opacity 0.2s ease, top 0.15s ease":"none";return jsx("div",{style:{...ae,transition:$},children:P.render({isExpanded:I,onToggleExpand:()=>E(P.id),measureRef:w(P.id)})},P.id)})})})}function Ri(e){return e?.length?e.flatMap(t=>t.content.filter(n=>n.type==="run").flatMap(n=>"content"in n?n.content:[]).filter(n=>n.type==="text").map(n=>"text"in n?n.text:"")).join(""):""}function Vo(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function Uo(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var nd=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function Vm(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return nd[Math.abs(t)%nd.length]}var jo={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},Ei={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"};function Go(e,t=32){return {width:t,height:t,borderRadius:"50%",backgroundColor:Vm(e),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t===32?13:11,fontWeight:500,flexShrink:0}}function Pi(e){return {padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:e?"#1a73e8":"#f1f3f4",color:e?"#fff":"#80868b",cursor:e?"pointer":"default",fontWeight:500,fontFamily:"inherit"}}function Ii({replies:e,isExpanded:t}){return e.length===0?null:jsxs("div",{style:{marginTop:8},children:[(t?e:e.slice(-1)).map(n=>jsxs("div",{style:{marginBottom:t?8:0,paddingTop:8,borderTop:"1px solid #e8eaed"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:Go(n.author||"U",28),children:Uo(n.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:n.author||"Unknown"}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Vo(n.date)})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...t?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:Ri(n.content)})]},n.id)),!t&&e.length>1&&jsxs("div",{style:{fontSize:12,color:"#5f6368",marginTop:4},children:[e.length-1," more ",e.length-1===1?"reply":"replies"]})]})}var Um={width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"},jm={width:"100%",border:"1px solid #dadce0",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",color:"#80868b",cursor:"text",backgroundColor:"#fff",boxSizing:"border-box"};function Fi({onSubmit:e}){let[t,n]=useState(false),[o,r]=useState("");if(!t)return jsx("div",{onClick:a=>a.stopPropagation(),style:{marginTop:12},children:jsx("input",{readOnly:true,onMouseDown:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),n(true);},placeholder:"Reply or add others with @",style:jm})});let i=o.trim();return jsxs("div",{onClick:a=>a.stopPropagation(),style:{marginTop:12},children:[jsx("input",{ref:a=>a?.focus({preventScroll:true}),type:"text",value:o,onChange:a=>r(a.target.value),onMouseDown:a=>a.stopPropagation(),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&(a.preventDefault(),i&&e(i),r(""),n(false)),a.key==="Escape"&&(n(false),r(""));},placeholder:"Reply or add others with @",style:Um}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsx("button",{onClick:a=>{a.stopPropagation(),n(false),r("");},style:Ei,children:"Cancel"}),jsx("button",{onClick:a=>{a.stopPropagation(),i&&e(i),r(""),n(false);},disabled:!i,style:Pi(!!i),children:"Reply"})]})]})}var Li={padding:"8px 10px",borderRadius:8,backgroundColor:"#f8fbff",cursor:"pointer",boxShadow:"0 1px 3px rgba(60,64,67,0.2), 0 2px 6px rgba(60,64,67,0.08)"},Bi={padding:"10px 12px",borderRadius:8,backgroundColor:"#fff",cursor:"pointer",boxShadow:"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)"};function id({comment:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onReply:i,onResolve:a,onDelete:s}){let[l,u]=useState(false);return jsxs("div",{ref:r,"data-comment-id":e.id,className:"docx-comment-card",onClick:o,onMouseDown:d=>d.stopPropagation(),style:{...n?Bi:Li,opacity:e.done?.6:1},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:Go(e.author||"U"),children:Uo(e.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:e.author||"Unknown"}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Vo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsx("button",{onClick:d=>{d.stopPropagation(),a?.(e.id);},title:"Resolve",style:jo,children:jsx(d,{name:"check",size:20})}),jsx("button",{onClick:d=>{d.stopPropagation(),u(!l);},title:"More options",style:jo,children:jsx(d,{name:"more_vert",size:20})}),l&&jsx("div",{onClick:d=>d.stopPropagation(),onMouseDown:d=>d.stopPropagation(),style:{position:"absolute",top:32,right:0,background:"#fff",borderRadius:8,boxShadow:"0 2px 6px rgba(60,64,67,0.3), 0 1px 2px rgba(60,64,67,0.15)",zIndex:100,minWidth:120,padding:"4px 0"},children:jsx("button",{onClick:()=>{u(false),s?.(e.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"#202124",cursor:"pointer",fontFamily:"inherit"},onMouseOver:d=>{d.target.style.backgroundColor="#f1f3f4";},onMouseOut:d=>{d.target.style.backgroundColor="transparent";},children:"Delete"})})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:Ri(e.content)}),jsx(Ii,{replies:t,isExpanded:n}),n&&!e.done&&jsx(Fi,{onSubmit:d=>i?.(e.id,d)})]})}function ad({change:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onAccept:i,onReject:a,onReply:s}){let l=e.author||"Unknown";return jsxs("div",{ref:r,className:"docx-tracked-change-card",onClick:()=>o(),onMouseDown:u=>u.stopPropagation(),style:n?Bi:Li,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:Go(l),children:Uo(l)}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:l}),e.date&&jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Vo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsx("button",{onClick:u=>{u.stopPropagation(),i?.(e.from,e.to);},title:"Accept",style:jo,children:jsx(d,{name:"check",size:20})}),jsx("button",{onClick:u=>{u.stopPropagation(),a?.(e.from,e.to);},title:"Reject",style:jo,children:jsx(d,{name:"close",size:20})})]})]}),jsxs("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:[e.type==="insertion"?"Added":"Deleted"," ",jsxs("span",{style:{color:e.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',e.text.length>50?e.text.slice(0,50)+"...":e.text,'"']})]}),jsx(Ii,{replies:t,isExpanded:n}),n&&jsx(Fi,{onSubmit:u=>s?.(e.revisionId,u)})]})}function ld({measureRef:e,onSubmit:t,onCancel:n}){let[o,r]=useState(""),i=()=>{o.trim()&&(t?.(o.trim()),r(""));};return jsxs("div",{ref:e,onMouseDown:a=>a.stopPropagation(),style:{padding:12,borderRadius:8,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)",zIndex:50},children:[jsx("textarea",{ref:a=>a?.focus({preventScroll:true}),value:o,onChange:a=>r(a.target.value),onMouseDown:a=>a.stopPropagation(),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),i()),a.key==="Escape"&&(n?.(),r(""));},placeholder:"Add a comment...",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"#202124"}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsx("button",{onClick:()=>{n?.(),r("");},style:Ei,children:"Cancel"}),jsx("button",{onClick:i,disabled:!o.trim(),style:Pi(!!o.trim()),children:"Comment"})]})]})}function cd({comments:e,trackedChanges:t,callbacks:n,showResolved:o=false,isAddingComment:r=false,addCommentYPosition:i=null}){let a=useMemo(()=>e.filter(l=>!(l.parentId!=null||l.done&&!o)),[e,o]),s=useMemo(()=>{let l=new Map;for(let u of e)if(u.parentId!=null){let d=l.get(u.parentId);d?d.push(u):l.set(u.parentId,[u]);}return l},[e]);return useMemo(()=>{let l=[];r&&i!=null&&l.push({id:"new-comment-input",anchorPos:0,fixedY:i,priority:-1e3,isTemporary:true,estimatedHeight:120,render:u=>jsx(ld,{...u,onSubmit:n.onAddComment,onCancel:n.onCancelAddComment})});for(let u of a){let d=s.get(u.id)??[];l.push({id:`comment-${u.id}`,anchorPos:0,anchorKey:`comment-${u.id}`,priority:0,estimatedHeight:80,render:c=>jsx(id,{...c,comment:u,replies:d,onReply:n.onCommentReply,onResolve:n.onCommentResolve,onDelete:n.onCommentDelete})});}return t.forEach((u,d)=>{let c=s.get(u.revisionId)??[];l.push({id:`tc-${u.revisionId}-${d}`,anchorPos:u.from,anchorKey:`revision-${u.revisionId}`,priority:1,estimatedHeight:80,render:p=>jsx(ad,{...p,change:u,replies:c,onAccept:n.onAcceptChange,onReject:n.onRejectChange,onReply:n.onTrackedChangeReply})});}),l},[a,t,s,n,r,i])}var Xm=15840,ud=1440,Zm=1440,Jm=567,fd=20,Qm="var(--doc-text-muted)",eg="var(--doc-text-subtle)",tg="var(--doc-primary)",ng="var(--doc-primary)",og="var(--doc-primary-hover)";function md({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=useState(null),[d,c]=useState(null),p=useRef(null),f=e?.pageHeight??Xm,m=e?.marginTop??ud,b=e?.marginBottom??ud,g=a$3(f)*t,x=a$3(m)*t,k$1=a$3(b)*t,S=useCallback((z,I)=>{n&&(z.preventDefault(),u(I));},[n]),B=useCallback(z=>{if(!l||!p.current)return;let I=p.current.getBoundingClientRect(),A=z.clientY-I.top,Z=b$1(A/t);if(l==="topMargin"){let ce=f-b-720,ae=Math.max(0,Math.min(Z,ce));o?.(Math.round(ae));}else if(l==="bottomMargin"){let ce=f-Z,ae=f-m-720,$=Math.max(0,Math.min(ce,ae));r?.(Math.round($));}},[l,t,f,m,b,o,r]),w=useCallback(()=>{u(null);},[]);useEffect(()=>{if(l)return document.addEventListener("mousemove",B),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",w);}},[l,B,w]);let E=ig(f,t,i),P={position:"relative",width:fd,height:k(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:P,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:E.map((z,I)=>jsx(rg,{tick:z},I))}),jsx(pd,{type:"topMargin",position:x,editable:n,isDragging:l==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>c("topMargin"),onMouseLeave:()=>c(null),onMouseDown:z=>S(z,"topMargin")}),jsx(pd,{type:"bottomMargin",position:g-k$1,editable:n,isDragging:l==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>c("bottomMargin"),onMouseLeave:()=>c(null),onMouseDown:z=>S(z,"bottomMargin")})]})}function rg({tick:e}){let t={position:"absolute",top:k(e.position),right:0,height:1,width:e.width,backgroundColor:eg},n={position:"absolute",top:k(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:Qm,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function pd({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?og:r?ng:tg,u={position:"absolute",top:k(t-5),right:0,width:fd,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},d={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:d})})}function ig(e,t,n){let o=[];if(n==="inch"){let r=Zm/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$3(s)*t;if(a%8===0){let u=a/8;o.push({position:l,width:10,label:u>0?String(u):void 0});}else a%4===0?o.push({position:l,width:6}):a%2===0?o.push({position:l,width:4}):o.push({position:l,width:2});}}else {let r=Jm/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$3(s)*t;if(a%10===0){let u=a/10;o.push({position:l,width:10,label:u>0?String(u):void 0});}else a%5===0?o.push({position:l,width:6}):o.push({position:l,width:3});}}return o}var Xt={High:50,Default:100,Low:150};function ht(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??Xt.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function tt(e){return t=>{let n={...e.defaultOptions,...t},o=typeof e.nodeSpec=="function"?e.nodeSpec(n):e.nodeSpec;return {type:"node",config:{name:e.name,priority:e.priority??Xt.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function Le(e){return t=>{let n={...e.defaultOptions,...t},o=typeof e.markSpec=="function"?e.markSpec(n):e.markSpec;return {type:"mark",config:{name:e.name,priority:e.priority??Xt.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var hd=tt({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table | textBox)+"}});var bd=tt({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function yd(e,t){if(!e)return {};let n={};if(e.fontFamily){let a=null;if(e.fontFamily.asciiTheme&&t?.fontScheme,a||(a=e.fontFamily.ascii||e.fontFamily.hAnsi||e.fontFamily.eastAsia||e.fontFamily.cs||null),a){let s=a$4(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${i$3(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=a(e.color,t)),e.highlight&&e.highlight!=="none"&&(n.backgroundColor=n$2(e.highlight)),e.shading){let a=Sd(e.shading,t);a&&!n.backgroundColor&&(n.backgroundColor=a);}let o=[],r=[],i=[];if(e.underline&&e.underline.style!=="none"){o.push("underline");let a$1=sg(e.underline.style);a$1!=="solid"&&r.push(a$1),e.underline.color&&i.push(a(e.underline.color,t));}if(e.strike&&o.push("line-through"),e.doubleStrike&&o.push("line-through"),o.length>0&&(n.textDecoration=o.join(" "),r.length>0&&(n.textDecorationStyle=r[0]),i.length>0&&(n.textDecorationColor=i[0])),e.vertAlign)switch(e.vertAlign){case "superscript":n.verticalAlign="super",n.fontSize||(n.fontSize="0.83em");break;case "subscript":n.verticalAlign="sub",n.fontSize||(n.fontSize="0.83em");break}if(e.position&&e.position!==0){let a=h$3(e.position);n.position="relative",n.top=k(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=k(a$3(e.spacing))),e.scale!==void 0&&e.scale!==100&&(n.transform=`scaleX(${e.scale/100})`,n.display="inline-block"),e.hidden&&(n.display="none"),e.emboss&&(n.textShadow="1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.3)"),e.imprint&&(n.textShadow="-1px -1px 1px rgba(255,255,255,0.5), 1px 1px 1px rgba(0,0,0,0.3)"),e.outline&&(n.WebkitTextStroke="1px currentColor",n.WebkitTextFillColor="transparent"),e.shadow&&!e.emboss&&!e.imprint&&(n.textShadow="1px 1px 2px rgba(0,0,0,0.3)"),e.rtl&&(n.direction="rtl"),n}function xd(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=lg(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=k(a$3(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=k(a$3(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=a$3(e.lineSpacing);o>0&&(n.lineHeight=k(o));break}case "atLeast":{let o=a$3(e.lineSpacing);o>0&&(n.minHeight=k(o),n.lineHeight=k(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=k(a$3(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=k(a$3(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=k(a$3(e.indentFirstLine)):n.textIndent=k(a$3(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,Yo(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,Yo(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,Yo(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,Yo(e.borders.right,"Right",t))),e.shading){let o=Sd(e.shading,t);o&&(n.backgroundColor=o);}return e.bidi&&(n.direction="rtl"),e.pageBreakBefore&&(n.pageBreakBefore="always"),e.keepNext&&(n.pageBreakAfter="avoid"),e.keepLines&&(n.pageBreakInside="avoid"),n}function Yo(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?j$1(e.size):1,i=e.color?a(e.color,n):"#000000",a$1=cg(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=k(Math.max(1,r)),o[l]=a$1,o[u]=i,o}function Sd(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":c$3(e.fill,t):e.pattern==="solid"&&e.color?c$3(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?c$3(e.color,t):""}function sg(e){switch(e){case "double":return "double";case "dotted":case "dottedHeavy":return "dotted";case "dash":case "dashedHeavy":case "dashLong":case "dashLongHeavy":case "dotDash":case "dashDotHeavy":case "dotDotDash":case "dashDotDotHeavy":return "dashed";case "wave":case "wavyHeavy":case "wavyDouble":return "wavy";default:return "solid"}}function lg(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function cg(e){switch(e){case "none":case "nil":return "none";case "double":case "triple":return "double";case "dotted":return "dotted";case "dashed":case "dashSmallGap":return "dashed";case "threeDEmboss":return "ridge";case "threeDEngrave":return "groove";case "outset":return "outset";case "inset":return "inset";default:return "solid"}}function qo(e){let t=[];return e.descendants((n,o)=>{if(n.type.name==="paragraph"){let r=n.attrs.outlineLevel,i=n.attrs.styleId,a=r;if(a==null&&i){let s=i.match(/^[Hh]eading(\d)$/);s&&(a=parseInt(s[1],10)-1);}if(a!=null&&a>=0&&a<=8){let s="";n.forEach(l=>{l.isText&&(s+=l.text||"");}),s.trim()&&t.push({text:s.trim(),level:a,pmPos:o});}}}),t}function ug(e){let t=e.indentLeft;e.numPr?.numId&&t==null&&(t=((e.numPr.ilvl??0)+1)*720);let n={alignment:e.alignment,spaceBefore:e.spaceBefore,spaceAfter:e.spaceAfter,lineSpacing:e.lineSpacing,lineSpacingRule:e.lineSpacingRule,indentLeft:t,indentRight:e.indentRight,indentFirstLine:e.indentFirstLine,hangingIndent:e.hangingIndent,borders:e.borders,shading:e.shading},o=xd(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function pg(e){switch(e){case "upperRoman":return "docx-list-upper-roman";case "lowerRoman":return "docx-list-lower-roman";case "upperLetter":return "docx-list-upper-alpha";case "lowerLetter":return "docx-list-lower-alpha";default:return "docx-list-decimal"}}function fg(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${pg(n)} docx-list-level-${o}`}function Xo(e){if(!e)return;let t=e.trim(),n=parseFloat(t);if(!(isNaN(n)||n===0)){if(t.endsWith("pt"))return Math.round(n*20);if(t.endsWith("px"))return Math.round(n*15);if(t.endsWith("in"))return Math.round(n*1440);if(t.endsWith("mm"))return Math.round(n*(1440/25.4));if(t.endsWith("cm"))return Math.round(n*(1440/2.54));if(/^[\d.]+$/.test(t))return Math.round(n*15)}}function mg(e){switch(e.trim().toLowerCase()){case "left":case "start":return "left";case "center":return "center";case "right":case "end":return "right";case "justify":return "both";default:return}}function gg(e){if(!e||e==="normal")return;let t=e.trim();if(t.endsWith("%")){let o=parseFloat(t);return isNaN(o)||o===0?void 0:{lineSpacing:Math.round(240*(o/100)),lineSpacingRule:"auto"}}if(/[a-z]/i.test(t)){let o=Xo(t);return o==null?void 0:{lineSpacing:o,lineSpacingRule:"exact"}}let n=parseFloat(t);if(!(isNaN(n)||n===0))return {lineSpacing:Math.round(240*n),lineSpacingRule:"auto"}}function kd(e){let t=e.style,n={};if(t.textAlign){let i=mg(t.textAlign);i&&(n.alignment=i);}let o=t.marginLeft||t.paddingLeft;if(o){let i=Xo(o);i!=null&&(n.indentLeft=i);}let r=t.marginRight||t.paddingRight;if(r){let i=Xo(r);i!=null&&(n.indentRight=i);}if(t.textIndent){let i=Xo(t.textIndent);i!=null&&(i<0?(n.indentFirstLine=Math.abs(i),n.hangingIndent=true):n.indentFirstLine=i);}if(t.lineHeight){let i=gg(t.lineHeight);i&&(n.lineSpacing=i.lineSpacing,n.lineSpacingRule=i.lineSpacingRule);}if(t.marginTop){let i=Xo(t.marginTop);i!=null&&(n.spaceBefore=i);}if(t.marginBottom){let i=Xo(t.marginBottom);i!=null&&(n.spaceAfter=i);}return n}var hg={content:"inline*",group:"block",attrs:{paraId:{default:null},textId:{default:null},alignment:{default:null},spaceBefore:{default:null},spaceAfter:{default:null},lineSpacing:{default:null},lineSpacingRule:{default:null},indentLeft:{default:null},indentRight:{default:null},indentFirstLine:{default:null},hangingIndent:{default:false},numPr:{default:null},listNumFmt:{default:null},listIsBullet:{default:null},listMarker:{default:null},listMarkerHidden:{default:null},listMarkerFontFamily:{default:null},listMarkerFontSize:{default:null},styleId:{default:null},borders:{default:null},shading:{default:null},tabs:{default:null},pageBreakBefore:{default:null},keepNext:{default:null},keepLines:{default:null},contextualSpacing:{default:null},defaultTextFormatting:{default:null},sectionBreakType:{default:null},bidi:{default:null},outlineLevel:{default:null},bookmarks:{default:null},_originalFormatting:{default:null},_sectionProperties:{default:null}},parseDOM:[{tag:"p",getAttrs(e){let t=e,n={paraId:t.dataset.paraId||void 0,alignment:t.dataset.alignment,styleId:t.dataset.styleId||void 0,sectionBreakType:t.dataset.sectionBreak||void 0},o=kd(t);return {...o,...n,alignment:n.alignment||o.alignment||void 0}}},...["h1","h2","h3","h4","h5","h6"].map(e=>({tag:e,getAttrs(t){let n=parseInt(e.charAt(1));return {...kd(t),styleId:`Heading${n}`,outlineLevel:n-1}}}))],toDOM(e){let t=e.attrs,n=ug(t),o=fg(t.numPr,t.listIsBullet,t.listNumFmt),r={};return n&&(r.style=n),o&&(r.class=o),t.paraId&&(r["data-para-id"]=t.paraId),t.alignment&&(r["data-alignment"]=t.alignment),t.styleId&&(r["data-style-id"]=t.styleId),t.listMarker&&(r["data-list-marker"]=t.listMarker),t.bidi&&(r.dir="rtl"),t.sectionBreakType&&(r["data-section-break"]=t.sectionBreakType,r.class=(r.class?r.class+" ":"")+"docx-section-break"),["p",r,0]}};function Nt(e,t){return (n,o)=>{let{$from:r,$to:i}=n.selection;if(!o)return true;let a=n.tr,s=new Set;return n.doc.nodesBetween(r.pos,i.pos,(l,u)=>{l.type.name==="paragraph"&&!s.has(u)&&(s.add(u),a=a.setNodeMarkup(u,void 0,{...l.attrs,[e]:t}));}),o(a.scrollIntoView()),true}}function Cd(e){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{s.type.name==="paragraph"&&!a.has(l)&&(a.add(l),i=i.setNodeMarkup(l,void 0,{...s.attrs,...e}));}),n(i.scrollIntoView()),true}}function Er(e){return (t,n)=>Nt("alignment",e)(t,n)}function Di(e,t="auto"){return (n,o)=>Cd({lineSpacing:e,lineSpacingRule:t})(n,o)}function bg(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0;i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:u+e});}}),n(i.scrollIntoView()),true}}function yg(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0,d=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:d>0?d:null});}}),n(i.scrollIntoView()),true}}function xg(e){return (t,n)=>(o,r)=>{let{$from:i,$to:a}=o.selection;if(!r)return true;let s=o.tr,l=new Set,u=[];if(n?.runFormatting){let c=n.runFormatting;c.bold&&u.push(e.marks.bold.create()),c.italic&&u.push(e.marks.italic.create()),c.fontSize&&u.push(e.marks.fontSize.create({size:c.fontSize})),c.fontFamily&&u.push(e.marks.fontFamily.create({ascii:c.fontFamily.ascii,hAnsi:c.fontFamily.hAnsi,asciiTheme:c.fontFamily.asciiTheme})),c.color&&!c.color.auto&&u.push(e.marks.textColor.create({rgb:c.color.rgb,themeColor:c.color.themeColor,themeTint:c.color.themeTint,themeShade:c.color.themeShade})),c.underline&&c.underline.style!=="none"&&u.push(e.marks.underline.create({style:c.underline.style,color:c.underline.color})),(c.strike||c.doubleStrike)&&u.push(e.marks.strike.create({double:c.doubleStrike||false}));}let d=[e.marks.bold,e.marks.italic,e.marks.fontSize,e.marks.fontFamily,e.marks.textColor,e.marks.underline,e.marks.strike].filter(Boolean);return o.doc.nodesBetween(i.pos,a.pos,(c,p)=>{if(c.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...c.attrs,styleId:t};if(n){let m=n.paragraphFormatting;f.alignment=m?.alignment??null,f.spaceBefore=m?.spaceBefore??null,f.spaceAfter=m?.spaceAfter??null,f.lineSpacing=m?.lineSpacing??null,f.lineSpacingRule=m?.lineSpacingRule??null,f.indentLeft=m?.indentLeft??null,f.indentRight=m?.indentRight??null,f.indentFirstLine=m?.indentFirstLine??null,f.hangingIndent=m?.hangingIndent??null,f.contextualSpacing=m?.contextualSpacing??null,f.keepNext=m?.keepNext??null,f.keepLines=m?.keepLines??null,f.pageBreakBefore=m?.pageBreakBefore??null,f.outlineLevel=m?.outlineLevel??null;}if(s=s.setNodeMarkup(p,void 0,f),n){let m=p+1,b=p+c.nodeSize-1;if(b>m){for(let g of d)s=s.removeMark(m,b,g);for(let g of u)s=s.addMark(m,b,g);}}}}),u.length>0&&(s=s.setStoredMarks(u)),r(s.scrollIntoView()),true}}var Td=tt({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:hg,onSchemaReady(e){let t=xg(e.schema);return {commands:{setAlignment:n=>Er(n),alignLeft:()=>Er("left"),alignCenter:()=>Er("center"),alignRight:()=>Er("right"),alignJustify:()=>Er("both"),setLineSpacing:(n,o)=>Di(n,o),singleSpacing:()=>Di(240),oneAndHalfSpacing:()=>Di(360),doubleSpacing:()=>Di(480),setSpaceBefore:n=>Nt("spaceBefore",n),setSpaceAfter:n=>Nt("spaceAfter",n),increaseIndent:n=>bg(n),decreaseIndent:n=>yg(n),setIndentLeft:n=>Nt("indentLeft",n>0?n:null),setIndentRight:n=>Nt("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>Cd({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Nt("styleId",null),insertSectionBreak:n=>Nt("sectionBreakType",n),removeSectionBreak:()=>Nt("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=qo(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let d of r){let c=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:c,level:d.level,text:d.text});let p=a.mapping.map(d.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let x=[...(m.attrs.bookmarks||[]).filter(k=>!k.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:c}];a.setNodeMarkup(p,void 0,{...m.attrs,bookmarks:x});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let d of s){let c=d.level*720,p=`TOC${d.level+1}`,f=i.marks.hyperlink.create({href:`#${d.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:c>0?c:null},[i.text(d.text,[f])]));}let u=a.mapping.map(n.selection.from);return a.insert(u,Fragment$1.from(l)),o(a.scrollIntoView()),true},toggleBidi:()=>(n,o)=>{let{$from:r}=n.selection,i=r.parent;if(i.type.name!=="paragraph")return false;let a=i.attrs.bidi||false;return Nt("bidi",a?null:true)(n,o)},setRtl:()=>Nt("bidi",true),setLtr:()=>Nt("bidi",null),setTabs:n=>Nt("tabs",n.length>0?n:null),addTabStop:(n,o="left",r="none")=>(i,a)=>{let{$from:s}=i.selection,l=s.parent;if(l.type.name!=="paragraph")return false;let c=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return Nt("tabs",c)(i,a)},removeTabStop:n=>(o,r)=>{let{$from:i}=o.selection,a=i.parent;if(a.type.name!=="paragraph")return false;let l=(a.attrs.tabs||[]).filter(u=>u.position!==n);return Nt("tabs",l.length>0?l:null)(o,r)}}}}});var vd=ht({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>undo,redo:()=>redo},keyboardShortcuts:{"Mod-z":undo,"Mod-y":redo,"Mod-Shift-z":redo}}}});var Ed=Le({name:"bold",schemaMarkName:"bold",markSpec:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs(e){let t=e.style?.fontWeight;return t==="normal"||t==="400"?false:null}},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2})$/.test(e)?null:false}],toDOM(){return ["strong",0]}},onSchemaReady(e){return {commands:{toggleBold:()=>toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":toggleMark(e.schema.marks.bold)}}}});var Md=Le({name:"italic",schemaMarkName:"italic",markSpec:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"?null:false}],toDOM(){return ["em",0]}},onSchemaReady(e){return {commands:{toggleItalic:()=>toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":toggleMark(e.schema.marks.italic)}}}});function kg(e){let t={};for(let n of e)switch(n.type.name){case "bold":t.bold=true;break;case "italic":t.italic=true;break;case "underline":t.underline={style:n.attrs.style||"single"};break;case "strike":t.strike=true;break;case "textColor":t.color=n.attrs;break;case "highlight":t.highlight=n.attrs.color;break;case "fontSize":t.fontSize=n.attrs.size;break;case "fontFamily":t.fontFamily={ascii:n.attrs.ascii,hAnsi:n.attrs.hAnsi};break;case "superscript":t.vertAlign="superscript";break;case "subscript":t.vertAlign="subscript";break}return t}function Id(e,t){let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||o.textContent.length>0)return t;let r=t.storedMarks||e.storedMarks||[];if(r.length===0)return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:null});let i=kg(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function hn(e,t){return (n,o)=>{let{from:r,to:i,empty:a}=n.selection,s=e.create(t);if(a){if(o){let l=e.isInSet(n.storedMarks||n.selection.$from.marks())?(n.storedMarks||n.selection.$from.marks()).filter(d=>d.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=Id(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function bn(e){return (t,n)=>{let{from:o,to:r,empty:i}=t.selection;if(i){if(n){let a=(t.storedMarks||t.selection.$from.marks()).filter(l=>l.type!==e),s=t.tr.setStoredMarks(a);s=Id(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function Fd(e,t){let n=[];return e.bold&&n.push(t.marks.bold.create()),e.italic&&n.push(t.marks.italic.create()),e.underline&&n.push(t.marks.underline.create({style:e.underline.style||"single",color:e.underline.color})),e.strike&&n.push(t.marks.strike.create()),e.doubleStrike&&n.push(t.marks.strike.create({double:true})),e.color&&n.push(t.marks.textColor.create({rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&n.push(t.marks.highlight.create({color:e.highlight})),e.fontSize&&n.push(t.marks.fontSize.create({size:e.fontSize})),e.fontFamily&&n.push(t.marks.fontFamily.create({ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"&&n.push(t.marks.superscript.create()),e.vertAlign==="subscript"&&n.push(t.marks.subscript.create()),n}var Pr=(e,t)=>{let{from:n,to:o,empty:r}=e.selection;if(r)return t&&t(e.tr.setStoredMarks([])),true;if(t){let i=e.tr;e.doc.nodesBetween(n,o,(a,s)=>{if(a.isText&&a.marks.length>0){let l=Math.max(n,s),u=Math.min(o,s+a.nodeSize);for(let d of a.marks)i=i.removeMark(l,u,d.type);}}),t(i.scrollIntoView());}return true};var Bd=Le({name:"underline",schemaMarkName:"underline",markSpec:{attrs:{style:{default:"single"},color:{default:null}},parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:e=>e.includes("underline")?{}:false}],toDOM(e){let t=e.attrs,n=["text-decoration: underline"];if(t.style&&t.style!=="single"){let r={double:"double",dotted:"dotted",dash:"dashed",wave:"wavy"}[t.style];r&&n.push(`text-decoration-style: ${r}`);}return t.color?.rgb&&n.push(`text-decoration-color: #${t.color.rgb}`),["span",{style:n.join("; ")},0]}},onSchemaReady(e){return {commands:{toggleUnderline:()=>toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>hn(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":toggleMark(e.schema.marks.underline)}}}});var Ad=Le({name:"strike",schemaMarkName:"strike",markSpec:{attrs:{double:{default:false}},parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:e=>e.includes("line-through")?{}:false}],toDOM(){return ["s",0]}},onSchemaReady(e){return {commands:{toggleStrike:()=>toggleMark(e.schema.marks.strike)}}}});var Dd=Le({name:"textColor",schemaMarkName:"textColor",markSpec:{attrs:{rgb:{default:null},themeColor:{default:null},themeTint:{default:null},themeShade:{default:null}},parseDOM:[{style:"color",getAttrs:e=>{let n=e.match(/#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})/);return n?{rgb:n[1].toUpperCase()}:false}}],toDOM(e){let t=e.attrs,n=yd({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?bn(e.schema.marks.textColor):hn(e.schema.marks.textColor,t),clearTextColor:()=>bn(e.schema.marks.textColor)}}}});var Hd=Le({name:"highlight",schemaMarkName:"highlight",markSpec:{attrs:{color:{default:"yellow"}},parseDOM:[{tag:"mark"},{style:"background-color",getAttrs:e=>e&&e!=="transparent"&&e!=="inherit"?{color:e}:false}],toDOM(e){let t=e.attrs.color;return ["mark",{style:`background-color: ${n$2(t)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?bn(e.schema.marks.highlight):hn(e.schema.marks.highlight,{color:t}),clearHighlight:()=>bn(e.schema.marks.highlight)}}}});var Nd=Le({name:"fontSize",schemaMarkName:"fontSize",markSpec:{attrs:{size:{default:24}},parseDOM:[{style:"font-size",getAttrs:e=>{let t=e,n=t.match(/^([\d.]+)px$/);if(n){let i=parseFloat(n[1])*.75;return {size:Math.round(i*2)}}let o=t.match(/^([\d.]+)pt$/);return o?{size:Math.round(parseFloat(o[1])*2)}:false}}],toDOM(e){let n=e.attrs.size/2,o=(n*1.15).toFixed(2);return ["span",{style:`font-size: ${n}pt; line-height: ${o}pt`},0]}},onSchemaReady(e){return {commands:{setFontSize:t=>hn(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>bn(e.schema.marks.fontSize)}}}});var Od=Le({name:"fontFamily",schemaMarkName:"fontFamily",markSpec:{attrs:{ascii:{default:null},hAnsi:{default:null},eastAsia:{default:null},cs:{default:null},asciiTheme:{default:null},hAnsiTheme:{default:null},eastAsiaTheme:{default:null},csTheme:{default:null}},parseDOM:[{style:"font-family",getAttrs:e=>{let n=e.split(",")[0].trim().replace(/['"]/g,"");return n?{ascii:n}:false}}],toDOM(e){let t=e.attrs,n=t.ascii||t.hAnsi;return n?["span",{style:`font-family: ${n.includes(" ")?`"${n}"`:n}, sans-serif`},0]:["span",0]}},onSchemaReady(e){return {commands:{setFontFamily:t=>hn(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>bn(e.schema.marks.fontFamily)}}}});var zd=Le({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>toggleMark(e.schema.marks.superscript)}}}});var $d=Le({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>toggleMark(e.schema.marks.subscript)}}}});function Zo(e){let t=e.schema.marks.hyperlink;if(!t)return null;let{empty:n,$from:o,from:r,to:i}=e.selection;if(n){let s=e.storedMarks||o.marks();for(let l of s)if(l.type===t)return {href:l.attrs.href,tooltip:l.attrs.tooltip};return null}let a=null;return e.doc.nodesBetween(r,i,s=>{if(s.isText&&a===null){let l=t.isInSet(s.marks);if(l)return a={href:l.attrs.href,tooltip:l.attrs.tooltip},false}return true}),a}function Jo(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var _d=Le({name:"hyperlink",schemaMarkName:"hyperlink",markSpec:{attrs:{href:{},tooltip:{default:null},rId:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return {href:t.getAttribute("href")||"",tooltip:t.getAttribute("title")||void 0}}}],toDOM(e){let t=e.attrs,n={href:t.href,target:"_blank",rel:"noopener noreferrer"};return t.tooltip&&(n.title=t.tooltip),["a",n,0]}},onSchemaReady(e){let t=e.schema.marks.hyperlink,n=(i,a)=>(s,l)=>{let{from:u,to:d,empty:c}=s.selection;if(c)return false;if(l){let p=t.create({href:i,tooltip:a||null}),f=s.tr.addMark(u,d,p),m=s.schema.marks.textColor;m&&(f=f.removeMark(u,d,m)),l(f.scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let d=i.selection.$from;if(!d.marks().find(g=>g.type===t))return false;let f=d.pos,m=d.pos;return d.parent.forEach((g,x)=>{if(g.isText){let k=d.start()+x,S=k+g.nodeSize;k<=d.pos&&d.pos<=S&&g.marks.some(w=>w.type===t)&&(f=Math.min(f,k),m=Math.max(m,S));}}),a&&a(i.tr.removeMark(f,m,t).scrollIntoView()),true}return a&&a(i.tr.removeMark(s,l,t).scrollIntoView()),true};return {commands:{setHyperlink:n,removeHyperlink:()=>o,insertHyperlink:(i,a,s)=>(l,u)=>{if(u){let d=t.create({href:a,tooltip:s||null}),c=l.schema.text(i,[d]);u(l.tr.replaceSelectionWith(c,false).scrollIntoView());}return true}}}}});var Wd=Le({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var Vd=Le({name:"smallCaps",schemaMarkName:"smallCaps",markSpec:{parseDOM:[{style:"font-variant",getAttrs:e=>e==="small-caps"?{}:false}],toDOM(){return ["span",{style:"font-variant: small-caps"},0]}}});var Ud=Le({name:"footnoteRef",schemaMarkName:"footnoteRef",markSpec:{attrs:{id:{},noteType:{default:"footnote"}},parseDOM:[{tag:"sup.docx-footnote-ref",getAttrs:e=>{let t=e;return {id:t.dataset.id||"",noteType:t.dataset.noteType||"footnote"}}}],toDOM(e){let t=e.attrs;return ["sup",{class:`docx-${t.noteType}-ref`,"data-id":t.id,"data-note-type":t.noteType},0]}},onSchemaReady(e){let{schema:t}=e;function n(r){return i=>(a,s)=>{if(!s)return true;let l=t.marks.footnoteRef.create({id:String(i),noteType:r}),u=t.text(String(i),[l]),d=a.tr.replaceSelectionWith(u,false);return s(d.scrollIntoView()),true}}let o=(r,i)=>{let{$from:a,$to:s}=r.selection;if(!i)return true;let l=r.tr,u=t.marks.footnoteRef;return l=l.removeMark(a.pos,s.pos,u),i(l.scrollIntoView()),true};return {commands:{insertFootnote:n("footnote"),insertEndnote:n("endnote"),deleteNoteRef:()=>o}}}});function vg(e){return e/2*(96/72)}var jd=Le({name:"characterSpacing",schemaMarkName:"characterSpacing",markSpec:{attrs:{spacing:{default:null},position:{default:null},scale:{default:null},kerning:{default:null}},parseDOM:[{tag:"span.docx-char-spacing",getAttrs:e=>{let t=e;return {spacing:t.dataset.spacing?Number(t.dataset.spacing):null,position:t.dataset.position?Number(t.dataset.position):null,scale:t.dataset.scale?Number(t.dataset.scale):null,kerning:t.dataset.kerning?Number(t.dataset.kerning):null}}}],toDOM(e){let t=e.attrs,n=[],o={class:"docx-char-spacing"};if(t.spacing!=null&&t.spacing!==0&&(n.push(`letter-spacing: ${k(a$3(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=vg(t.position);n.push(`vertical-align: ${k(r)}`),o["data-position"]=String(t.position);}return t.scale!=null&&t.scale!==100&&(n.push(`transform: scaleX(${t.scale/100})`),n.push("display: inline-block"),o["data-scale"]=String(t.scale)),t.kerning!=null&&(o["data-kerning"]=String(t.kerning)),n.length>0&&(o.style=n.join("; ")),["span",o,0]}}});var Gd=Le({name:"comment",schemaMarkName:"comment",markSpec:{attrs:{commentId:{default:0}},inclusive:false,parseDOM:[{tag:"span.docx-comment",getAttrs(e){return {commentId:parseInt(e.dataset.commentId||"0",10)}}}],toDOM(e){return ["span",{class:"docx-comment","data-comment-id":String(e.attrs.commentId),style:"background-color: rgba(255, 212, 0, 0.25); border-bottom: 2px solid rgba(255, 212, 0, 0.6);"},0]}}});var Kd=Le({name:"insertion",schemaMarkName:"insertion",markSpec:{attrs:{revisionId:{default:0},author:{default:""},date:{default:null}},inclusive:false,parseDOM:[{tag:"span.docx-insertion",getAttrs(e){let t=e;return {revisionId:parseInt(t.dataset.revisionId||"0",10),author:t.dataset.author||"",date:t.dataset.date||null}}}],toDOM(e){return ["span",{class:"docx-insertion","data-revision-id":String(e.attrs.revisionId),"data-author":e.attrs.author,...e.attrs.date?{"data-date":e.attrs.date}:{},style:"color: #2e7d32; text-decoration: underline; text-decoration-color: #2e7d32;"},0]}}}),Yd=Le({name:"deletion",schemaMarkName:"deletion",markSpec:{attrs:{revisionId:{default:0},author:{default:""},date:{default:null}},inclusive:false,parseDOM:[{tag:"span.docx-deletion",getAttrs(e){let t=e;return {revisionId:parseInt(t.dataset.revisionId||"0",10),author:t.dataset.author||"",date:t.dataset.date||null}}}],toDOM(e){return ["span",{class:"docx-deletion","data-revision-id":String(e.attrs.revisionId),"data-author":e.attrs.author,...e.attrs.date?{"data-date":e.attrs.date}:{},style:"color: #c62828; text-decoration: line-through; text-decoration-color: #c62828;"},0]}}});var qd=Le({name:"emboss",schemaMarkName:"emboss",markSpec:{parseDOM:[{tag:"span.docx-emboss"}],toDOM(){return ["span",{class:"docx-emboss",style:"text-shadow: 1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.3)"},0]}}}),Xd=Le({name:"imprint",schemaMarkName:"imprint",markSpec:{parseDOM:[{tag:"span.docx-imprint"}],toDOM(){return ["span",{class:"docx-imprint",style:"-1px -1px 1px rgba(255,255,255,0.5), 1px 1px 1px rgba(0,0,0,0.3)"},0]}}}),Zd=Le({name:"textShadow",schemaMarkName:"textShadow",markSpec:{parseDOM:[{tag:"span.docx-text-shadow"}],toDOM(){return ["span",{class:"docx-text-shadow",style:"text-shadow: 1px 1px 2px rgba(0,0,0,0.3)"},0]}}}),Jd=Le({name:"emphasisMark",schemaMarkName:"emphasisMark",markSpec:{attrs:{type:{default:"dot"}},parseDOM:[{tag:"span.docx-emphasis-mark",getAttrs:e=>({type:e.dataset.emType||"dot"})}],toDOM(e){let t=e.attrs.type,n="filled dot";switch(t){case "dot":n="filled dot";break;case "comma":n="filled sesame";break;case "circle":n="filled circle";break;case "underDot":n="filled dot";break}let o=t==="underDot"?"under right":"over right";return ["span",{class:"docx-emphasis-mark","data-em-type":t,style:`text-emphasis: ${n}; text-emphasis-position: ${o}; -webkit-text-emphasis: ${n}; -webkit-text-emphasis-position: ${o}`},0]}}}),Qd=Le({name:"textOutline",schemaMarkName:"textOutline",markSpec:{parseDOM:[{tag:"span.docx-text-outline"}],toDOM(){return ["span",{class:"docx-text-outline",style:"-webkit-text-stroke: 1px currentColor; -webkit-text-fill-color: transparent"},0]}}});var eu=tt({name:"hardBreak",schemaNodeName:"hardBreak",nodeSpec:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return ["br"]}},onSchemaReady(e){let t=e.schema.nodes.hardBreak;return {keyboardShortcuts:{"Shift-Enter":(n,o)=>(o&&o(n.tr.replaceSelectionWith(t.create()).scrollIntoView()),true)}}}});var tu=tt({name:"tab",schemaNodeName:"tab",nodeSpec:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"span.docx-tab"}],toDOM(){return ["span",{class:"docx-tab",style:"display: inline-block; min-width: 16px; white-space: pre;"}," "]}}});var nu=tt({name:"image",schemaNodeName:"image",nodeSpec:{inline:true,group:"inline",draggable:true,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},rId:{default:null},wrapType:{default:"inline"},displayMode:{default:"inline"},cssFloat:{default:null},transform:{default:null},distTop:{default:null},distBottom:{default:null},distLeft:{default:null},distRight:{default:null},position:{default:null},borderWidth:{default:null},borderColor:{default:null},borderStyle:{default:null},wrapText:{default:null},hlinkHref:{default:null}},parseDOM:[{tag:"img[src]",getAttrs(e){let t=e;return {src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||void 0,title:t.getAttribute("title")||void 0,width:t.width||void 0,height:t.height||void 0,rId:t.dataset.rid||void 0,wrapType:t.dataset.wrapType||"inline",displayMode:t.dataset.displayMode||"inline",cssFloat:t.dataset.cssFloat||void 0,transform:t.dataset.transform||void 0,borderWidth:t.dataset.borderWidth?Number(t.dataset.borderWidth):void 0,borderColor:t.dataset.borderColor||void 0,borderStyle:t.dataset.borderStyle||void 0}}}],toDOM(e){let t=e.attrs,n={src:t.src,class:"docx-image"};t.alt&&(n.alt=t.alt),t.title&&(n.title=t.title),t.rId&&(n["data-rid"]=t.rId),t.wrapType&&(n["data-wrap-type"]=t.wrapType),t.displayMode&&(n["data-display-mode"]=t.displayMode),t.cssFloat&&(n["data-css-float"]=t.cssFloat),t.transform&&(n["data-transform"]=t.transform),t.borderWidth&&(n["data-border-width"]=String(t.borderWidth)),t.borderColor&&(n["data-border-color"]=t.borderColor),t.borderStyle&&(n["data-border-style"]=t.borderStyle);let o=[];if(t.width&&(n.width=String(t.width),o.push(`width: ${t.width}px`)),t.height&&(n.height=String(t.height),o.push(`height: ${t.height}px`)),o.push("max-width: 100%"),t.width&&t.height?o.push("object-fit: contain"):o.push("height: auto"),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"){o.push(`float: ${t.cssFloat}`),n.class+=` docx-image-float docx-image-float-${t.cssFloat}`;let r=t.distTop??0,i=t.distBottom??0,a=t.distLeft??0,s=t.distRight??0;t.cssFloat==="left"?o.push(`margin: ${r}px ${s||12}px ${i}px ${a}px`):o.push(`margin: ${r}px ${s}px ${i}px ${a||12}px`);}else if(t.displayMode==="block"){o.push("display: block"),o.push("margin-left: auto"),o.push("margin-right: auto"),n.class+=" docx-image-block";let r=t.distTop??0,i=t.distBottom??0;r>0&&o.push(`margin-top: ${r}px`),i>0&&o.push(`margin-bottom: ${i}px`);}if(t.transform&&o.push(`transform: ${t.transform}`),t.borderWidth&&t.borderWidth>0){let r=t.borderStyle||"solid",i=t.borderColor||"#000000";o.push(`border: ${t.borderWidth}px ${r} ${i}`);}return n.style=o.join("; "),["img",n]}}});var ou=tt({name:"textBox",schemaNodeName:"textBox",nodeSpec:{group:"block",content:"(paragraph | table)+",isolating:true,draggable:true,attrs:{width:{default:200},height:{default:null},textBoxId:{default:null},fillColor:{default:null},outlineWidth:{default:null},outlineColor:{default:null},outlineStyle:{default:null},marginTop:{default:4},marginBottom:{default:4},marginLeft:{default:7},marginRight:{default:7},verticalAlign:{default:null},displayMode:{default:"inline"},cssFloat:{default:null},wrapType:{default:"inline"}},parseDOM:[{tag:"div.docx-textbox",getAttrs(e){let t=e;return {width:t.dataset.width?Number(t.dataset.width):void 0,height:t.dataset.height?Number(t.dataset.height):void 0,textBoxId:t.dataset.textboxId||void 0,fillColor:t.dataset.fillColor||void 0,outlineWidth:t.dataset.outlineWidth?Number(t.dataset.outlineWidth):void 0,outlineColor:t.dataset.outlineColor||void 0,outlineStyle:t.dataset.outlineStyle||void 0,marginTop:t.dataset.marginTop?Number(t.dataset.marginTop):void 0,marginBottom:t.dataset.marginBottom?Number(t.dataset.marginBottom):void 0,marginLeft:t.dataset.marginLeft?Number(t.dataset.marginLeft):void 0,marginRight:t.dataset.marginRight?Number(t.dataset.marginRight):void 0,verticalAlign:t.dataset.verticalAlign||void 0,displayMode:t.dataset.displayMode||void 0,cssFloat:t.dataset.cssFloat||void 0,wrapType:t.dataset.wrapType||void 0}}}],toDOM(e){let t=e.attrs,n={class:"docx-textbox"};t.width&&(n["data-width"]=String(t.width)),t.height&&(n["data-height"]=String(t.height)),t.textBoxId&&(n["data-textbox-id"]=t.textBoxId),t.fillColor&&(n["data-fill-color"]=t.fillColor),t.outlineWidth&&(n["data-outline-width"]=String(t.outlineWidth)),t.outlineColor&&(n["data-outline-color"]=t.outlineColor),t.outlineStyle&&(n["data-outline-style"]=t.outlineStyle),t.marginTop!=null&&(n["data-margin-top"]=String(t.marginTop)),t.marginBottom!=null&&(n["data-margin-bottom"]=String(t.marginBottom)),t.marginLeft!=null&&(n["data-margin-left"]=String(t.marginLeft)),t.marginRight!=null&&(n["data-margin-right"]=String(t.marginRight)),t.verticalAlign&&(n["data-vertical-align"]=t.verticalAlign),t.displayMode&&(n["data-display-mode"]=t.displayMode),t.cssFloat&&(n["data-css-float"]=t.cssFloat),t.wrapType&&(n["data-wrap-type"]=t.wrapType);let o=[];if(t.width&&o.push(`width: ${t.width}px`),t.height&&o.push(`min-height: ${t.height}px`),t.fillColor&&o.push(`background-color: ${t.fillColor}`),t.outlineWidth&&t.outlineWidth>0){let l=t.outlineStyle||"solid",u=t.outlineColor||"#000000";o.push(`border: ${t.outlineWidth}px ${l} ${u}`);}else o.push("border: 1px solid var(--doc-border, #d1d5db)");let r=t.marginTop??4,i=t.marginBottom??4,a=t.marginLeft??7,s=t.marginRight??7;return o.push(`padding: ${r}px ${s}px ${i}px ${a}px`),t.verticalAlign==="middle"||t.verticalAlign==="center"?(o.push("display: flex"),o.push("flex-direction: column"),o.push("justify-content: center")):t.verticalAlign==="bottom"&&(o.push("display: flex"),o.push("flex-direction: column"),o.push("justify-content: flex-end")),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"?(o.push(`float: ${t.cssFloat}`),o.push("margin: 4px 8px")):t.displayMode==="block"&&(o.push("margin-left: auto"),o.push("margin-right: auto")),o.push("box-sizing: border-box"),o.push("overflow: hidden"),o.push("position: relative"),n.style=o.join("; "),["div",n,0]}}});function Rg(e,t,n){switch(e){case "ellipse":case "oval":return `<ellipse cx="${t/2}" cy="${n/2}" rx="${t/2}" ry="${n/2}" />`;case "roundRect":return `<rect x="0" y="0" width="${t}" height="${n}" rx="${Math.min(t,n)*.1}" />`;case "triangle":case "isosTriangle":return `<polygon points="${t/2},0 ${t},${n} 0,${n}" />`;case "diamond":return `<polygon points="${t/2},0 ${t},${n/2} ${t/2},${n} 0,${n/2}" />`;case "line":case "straightConnector1":return `<line x1="0" y1="${n/2}" x2="${t}" y2="${n/2}" />`;default:return `<rect x="0" y="0" width="${t}" height="${n}" />`}}function Eg(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(c=>`<stop offset="${Math.round(c.position/1e3)}%" stop-color="${c.color}" />`).join("");}catch{return ""}let o=t.gradientType||"linear";if(o==="radial"||o==="rectangular"||o==="path")return `<radialGradient id="${e}" cx="50%" cy="50%" r="50%">${n}</radialGradient>`;let i=((t.gradientAngle||0)-90)*Math.PI/180,a=Math.round(50+50*Math.cos(i+Math.PI)),s=Math.round(50+50*Math.sin(i+Math.PI)),l=Math.round(50+50*Math.cos(i)),u=Math.round(50+50*Math.sin(i));return `<linearGradient id="${e}" x1="${a}%" y1="${s}%" x2="${l}%" y2="${u}%">${n}</linearGradient>`}var ru=tt({name:"shape",schemaNodeName:"shape",nodeSpec:{inline:true,group:"inline",draggable:true,atom:true,attrs:{shapeType:{default:"rect"},shapeId:{default:null},width:{default:100},height:{default:80},fillColor:{default:null},fillType:{default:"solid"},gradientType:{default:null},gradientAngle:{default:null},gradientStops:{default:null},outlineWidth:{default:1},outlineColor:{default:"#000000"},outlineStyle:{default:"solid"},transform:{default:null},displayMode:{default:"inline"},cssFloat:{default:null},wrapType:{default:"inline"},shadowColor:{default:null},shadowBlur:{default:null},shadowOffsetX:{default:null},shadowOffsetY:{default:null},glowColor:{default:null},glowRadius:{default:null}},parseDOM:[{tag:"span.docx-shape",getAttrs(e){let t=e;return {shapeType:t.dataset.shapeType||"rect",shapeId:t.dataset.shapeId||void 0,width:t.dataset.width?Number(t.dataset.width):void 0,height:t.dataset.height?Number(t.dataset.height):void 0,fillColor:t.dataset.fillColor||void 0,fillType:t.dataset.fillType||"solid",gradientType:t.dataset.gradientType||void 0,gradientAngle:t.dataset.gradientAngle?Number(t.dataset.gradientAngle):void 0,gradientStops:t.dataset.gradientStops||void 0,outlineWidth:t.dataset.outlineWidth?Number(t.dataset.outlineWidth):void 0,outlineColor:t.dataset.outlineColor||void 0,outlineStyle:t.dataset.outlineStyle||void 0,transform:t.dataset.transform||void 0,displayMode:t.dataset.displayMode||void 0,cssFloat:t.dataset.cssFloat||void 0,wrapType:t.dataset.wrapType||void 0,shadowColor:t.dataset.shadowColor||void 0,shadowBlur:t.dataset.shadowBlur?Number(t.dataset.shadowBlur):void 0,shadowOffsetX:t.dataset.shadowOffsetX?Number(t.dataset.shadowOffsetX):void 0,shadowOffsetY:t.dataset.shadowOffsetY?Number(t.dataset.shadowOffsetY):void 0,glowColor:t.dataset.glowColor||void 0,glowRadius:t.dataset.glowRadius?Number(t.dataset.glowRadius):void 0}}}],toDOM(e){let t=e.attrs,n=t.width||100,o=t.height||80,r={class:"docx-shape","data-shape-type":t.shapeType||"rect"};t.shapeId&&(r["data-shape-id"]=t.shapeId),r["data-width"]=String(n),r["data-height"]=String(o),t.fillColor&&(r["data-fill-color"]=t.fillColor),t.fillType&&(r["data-fill-type"]=t.fillType),t.gradientType&&(r["data-gradient-type"]=t.gradientType),t.gradientAngle!=null&&(r["data-gradient-angle"]=String(t.gradientAngle)),t.gradientStops&&(r["data-gradient-stops"]=t.gradientStops),t.outlineWidth&&(r["data-outline-width"]=String(t.outlineWidth)),t.outlineColor&&(r["data-outline-color"]=t.outlineColor),t.outlineStyle&&(r["data-outline-style"]=t.outlineStyle),t.transform&&(r["data-transform"]=t.transform),t.displayMode&&(r["data-display-mode"]=t.displayMode),t.cssFloat&&(r["data-css-float"]=t.cssFloat),t.wrapType&&(r["data-wrap-type"]=t.wrapType),t.shadowColor&&(r["data-shadow-color"]=t.shadowColor),t.shadowBlur!=null&&(r["data-shadow-blur"]=String(t.shadowBlur)),t.shadowOffsetX!=null&&(r["data-shadow-offset-x"]=String(t.shadowOffsetX)),t.shadowOffsetY!=null&&(r["data-shadow-offset-y"]=String(t.shadowOffsetY)),t.glowColor&&(r["data-glow-color"]=t.glowColor),t.glowRadius!=null&&(r["data-glow-radius"]=String(t.glowRadius));let i=["display: inline-block",`width: ${n}px`,`height: ${o}px`,"vertical-align: middle","line-height: 0"];if(t.transform&&i.push(`transform: ${t.transform}`),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"?(i.push(`float: ${t.cssFloat}`),i.push("margin: 4px 8px")):t.displayMode==="block"&&(i.push("display: block"),i.push("margin: 4px auto")),t.shadowColor){let m=t.shadowOffsetX||2,b=t.shadowOffsetY||2,g=t.shadowBlur||4;i.push(`filter: drop-shadow(${m}px ${b}px ${g}px ${t.shadowColor})`);}if(t.glowColor&&t.glowRadius){let m=i.find(g=>g.startsWith("filter:")),b=`drop-shadow(0 0 ${t.glowRadius}px ${t.glowColor})`;if(m){let g=i.indexOf(m);i[g]=m+" "+b;}else i.push(`filter: ${b}`);}r.style=i.join("; ");let a="",s;if(t.fillType==="gradient"&&t.gradientStops){let m=`grad-${t.shapeId||Math.random().toString(36).slice(2,8)}`;s=`url(#${m})`,a=Eg(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",d=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",c=Rg(t.shapeType||"rect",n,o),p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${o}" viewBox="0 0 ${n} ${o}" style="fill:${s};stroke:${u};stroke-width:${l}${d}">`+(a?`<defs>${a}</defs>`:"")+c+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var iu=tt({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var au=tt({name:"pageBreak",schemaNodeName:"pageBreak",nodeSpec:{group:"block",atom:true,selectable:true,parseDOM:[{tag:"div.docx-page-break"}],toDOM(){return ["div",{class:"docx-page-break"}]}}});var su=tt({name:"field",schemaNodeName:"field",nodeSpec:{inline:true,group:"inline",atom:true,selectable:true,attrs:{fieldType:{default:"UNKNOWN"},instruction:{default:""},displayText:{default:""},fieldKind:{default:"simple"},fldLock:{default:false},dirty:{default:false}},parseDOM:[{tag:"span.docx-field",getAttrs(e){let t=e;return {fieldType:t.dataset.fieldType||"UNKNOWN",instruction:t.dataset.instruction||"",displayText:t.textContent||"",fieldKind:t.dataset.fieldKind||"simple",fldLock:t.dataset.fldLock==="true",dirty:t.dataset.dirty==="true"}}}],toDOM(e){let{fieldType:t,instruction:n,displayText:o,fieldKind:r,fldLock:i,dirty:a}=e.attrs,s=o||"";if(!s)switch(t){case "PAGE":s="{page}";break;case "NUMPAGES":s="{pages}";break;case "DATE":case "TIME":case "CREATEDATE":case "SAVEDATE":s=new Date().toLocaleDateString();break;case "MERGEFIELD":s=`\xAB${n.replace(/^MERGEFIELD\s+/i,"").replace(/\s*\\.*$/,"")}\xBB`;break;default:s=`{${t}}`;}return ["span",{class:`docx-field docx-field-${t.toLowerCase()}`,"data-field-type":t,"data-instruction":n,"data-field-kind":r,...i?{"data-fld-lock":"true"}:{},...a?{"data-dirty":"true"}:{},style:"outline: 1px solid rgba(200,200,200,0.4); padding: 0 1px; border-radius: 2px;"},s]}}});var lu=tt({name:"sdt",schemaNodeName:"sdt",nodeSpec:{inline:true,group:"inline",content:"inline*",attrs:{sdtType:{default:"richText"},alias:{default:null},tag:{default:null},lock:{default:null},placeholder:{default:null},showingPlaceholder:{default:false},dateFormat:{default:null},listItems:{default:null},checked:{default:null}},parseDOM:[{tag:"span.docx-sdt",getAttrs(e){let t=e;return {sdtType:t.dataset.sdtType||"richText",alias:t.dataset.alias||null,tag:t.dataset.tag||null,lock:t.dataset.lock||null,placeholder:t.dataset.placeholder||null,showingPlaceholder:t.dataset.showingPlaceholder==="true",dateFormat:t.dataset.dateFormat||null,listItems:t.dataset.listItems||null,checked:t.dataset.checked==="true"?true:t.dataset.checked==="false"?false:null}}}],toDOM(e){let t=e.attrs,n={class:`docx-sdt docx-sdt-${t.sdtType}`,"data-sdt-type":String(t.sdtType)};return t.alias&&(n["data-alias"]=String(t.alias)),t.tag&&(n["data-tag"]=String(t.tag)),t.lock&&(n["data-lock"]=String(t.lock)),t.placeholder&&(n["data-placeholder"]=String(t.placeholder)),t.showingPlaceholder&&(n["data-showing-placeholder"]="true"),t.dateFormat&&(n["data-date-format"]=String(t.dateFormat)),t.listItems&&(n["data-list-items"]=String(t.listItems)),t.checked!=null&&(n["data-checked"]=String(t.checked)),t.sdtType==="checkbox"?n.style="border: 1px solid #ccc; border-radius: 3px; padding: 0 2px; display: inline;":n.style="border-bottom: 1px dashed #999; padding: 0 1px; display: inline;",["span",n,0]}}});var cu=tt({name:"math",schemaNodeName:"math",nodeSpec:{inline:true,group:"inline",atom:true,selectable:true,attrs:{display:{default:"inline"},ommlXml:{default:""},plainText:{default:""}},parseDOM:[{tag:"span.docx-math",getAttrs(e){let t=e;return {display:t.dataset.display||"inline",ommlXml:t.dataset.ommlXml||"",plainText:t.textContent||""}}}],toDOM(e){let{display:t,ommlXml:n,plainText:o}=e.attrs,r=o||"[equation]";return ["span",{class:`docx-math docx-math-${t}`,"data-display":t,"data-omml-xml":n,style:'font-style: italic; font-family: "Cambria Math", "Latin Modern Math", serif; background: rgba(200,200,255,0.1); padding: 0 2px; border-radius: 2px;'},r]}}});function Hg(e){switch(e.toLowerCase()){case "solid":return "single";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "groove":return "threeDEngrave";case "ridge":return "threeDEmboss";case "inset":return "inset";case "outset":return "outset";default:return "single"}}function Ng(e){if(!e)return 8;let t=e.trim().toLowerCase();if(t==="thin")return 4;if(t==="medium")return 8;if(t==="thick")return 16;let n=parseFloat(t);return isNaN(n)?8:t.endsWith("pt")?Math.round(n*8):(t.endsWith("px"),Math.round(n*6))}function du(e){if(!e||e==="transparent"||e==="inherit")return null;let t=e.match(/#([0-9a-fA-F]{6})/);if(t)return {rgb:t[1].toUpperCase()};let n=e.match(/#([0-9a-fA-F]{3})$/);if(n){let[r,i,a]=n[1];return {rgb:(r+r+i+i+a+a).toUpperCase()}}let o=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?{rgb:[o[1],o[2],o[3]].map(i=>parseInt(i).toString(16).padStart(2,"0")).join("").toUpperCase()}:null}function Og(e){let t=(a,s,l)=>{if(!(!a||a==="none"||a==="hidden"))return {style:Hg(a),color:du(s)||void 0,size:Ng(l)}},n=t(e.borderTopStyle,e.borderTopColor,e.borderTopWidth),o=t(e.borderBottomStyle,e.borderBottomColor,e.borderBottomWidth),r=t(e.borderLeftStyle,e.borderLeftColor,e.borderLeftWidth),i=t(e.borderRightStyle,e.borderRightColor,e.borderRightWidth);return !n&&!o&&!r&&!i?null:{top:n,bottom:o,left:r,right:i}}function zg(e){let t=a=>{if(!a||a==="0px")return;let s=parseFloat(a);if(!(isNaN(s)||s===0))return a.endsWith("pt")?Math.round(s*20):Math.round(s*15)},n=t(e.paddingTop),o=t(e.paddingRight),r=t(e.paddingBottom),i=t(e.paddingLeft);return n===void 0&&o===void 0&&r===void 0&&i===void 0?null:{top:n,right:o,bottom:r,left:i}}function $g(e){if(e)switch(e.toLowerCase()){case "top":return "top";case "middle":return "center";case "bottom":return "bottom";default:return}}function _g(e){return du(e)?.rgb}function uu(e){let t=e.style,n=Og(t),o=zg(t);return {colspan:e.colSpan||1,rowspan:e.rowSpan||1,verticalAlign:e.dataset.valign||$g(t.verticalAlign)||void 0,backgroundColor:e.dataset.bgcolor||_g(t.backgroundColor)||void 0,borders:n||void 0,margins:o||void 0}}var Wg={content:"tableRow+",group:"block",tableRole:"table",isolating:true,attrs:{styleId:{default:null},width:{default:null},widthType:{default:null},justification:{default:null},columnWidths:{default:null},floating:{default:null},cellMargins:{default:null},look:{default:null},_originalFormatting:{default:null}},parseDOM:[{tag:"table",getAttrs(e){let t=e;return {styleId:t.dataset.styleId||void 0,justification:t.dataset.justification}}}],toDOM(e){let t=e.attrs,n={class:"docx-table"};t.styleId&&(n["data-style-id"]=t.styleId);let o=["border-collapse: collapse"];if(t.width&&t.widthType==="pct")o.push(`width: ${t.width/50}%`),o.push("table-layout: fixed");else if(t.width&&t.widthType==="dxa"){let r=Math.round(t.width/20*1.333);o.push(`width: ${r}px`),o.push("table-layout: fixed");}else o.push("width: 100%"),o.push("table-layout: fixed");return t.justification==="center"?o.push("margin-left: auto","margin-right: auto"):t.justification==="right"&&o.push("margin-left: auto"),n.style=o.join("; "),["table",n,["tbody",0]]}},Vg={content:"(tableCell | tableHeader)+",tableRole:"row",attrs:{height:{default:null},heightRule:{default:null},isHeader:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"tr"}],toDOM(e){let t=e.attrs,n={};if(t.height){let o=Math.round(t.height/20*1.333);n.style=`height: ${o}px`;}return ["tr",n,0]}},Ug={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",thinThickSmallGap:"double",thickThinSmallGap:"double",thinThickThinSmallGap:"double",thinThickMediumGap:"double",thickThinMediumGap:"double",thinThickThinMediumGap:"double",thinThickLargeGap:"double",thickThinLargeGap:"double",thinThickThinLargeGap:"double",wave:"solid",doubleWave:"double",dashDotStroked:"dashed",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function pu(e){let t=[],n=e.borders;if(!n)return t;let o=r=>{if(!r||!r.style||r.style==="none"||r.style==="nil")return "none";let i=r.size?Math.max(1,Math.round(r.size/8*1.333)):1,a=Ug[r.style]||"solid",s=r.color?.rgb?`#${r.color.rgb}`:"#000000";return `${i}px ${a} ${s}`};return t.push(`border-top: ${o(n.top)}`),t.push(`border-bottom: ${o(n.bottom)}`),t.push(`border-left: ${o(n.left)}`),t.push(`border-right: ${o(n.right)}`),t}function fu(e){let t=e.margins;if(!t){let s=Math.round(7.1982);return [`padding: ${s}px ${s}px`]}let n=s=>s?Math.round(s/20*1.333):0,o=n(t.top),r=n(t.right),i=n(t.bottom),a=n(t.left);return [`padding: ${o}px ${r}px ${i}px ${a}px`]}function mu(e){if(!e)return [];let t=[];switch(e){case "tbRl":case "tbRlV":t.push("writing-mode: vertical-rl");break;case "btLr":t.push("writing-mode: vertical-lr","transform: rotate(180deg)");break;case "rl":case "rlV":t.push("direction: rtl");break;case "tb":case "tbV":t.push("writing-mode: vertical-lr");break}return t}function gu(e){let t=[];if(e.colwidth&&e.colwidth.length>0){let n=e.colwidth.reduce((o,r)=>o+r,0);t.push(`width: ${n}px`);}else if(e.width&&e.widthType==="pct")t.push(`width: ${e.width}%`);else if(e.width){let n=Math.round(e.width/20*1.333);t.push(`width: ${n}px`);}return t}var jg={content:"(paragraph | table)+",tableRole:"cell",isolating:true,attrs:{colspan:{default:1},rowspan:{default:1},colwidth:{default:null},width:{default:null},widthType:{default:null},verticalAlign:{default:null},backgroundColor:{default:null},borders:{default:null},margins:{default:null},textDirection:{default:null},noWrap:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"td",getAttrs:e=>uu(e)}],toDOM(e){let t=e.attrs,n={class:"docx-table-cell"};t.colspan>1&&(n.colspan=String(t.colspan)),t.rowspan>1&&(n.rowspan=String(t.rowspan));let o=[];return o.push(...fu(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...gu(t)),o.push(...pu(t)),o.push(...mu(t.textDirection)),t.verticalAlign&&(n["data-valign"]=t.verticalAlign,o.push(`vertical-align: ${t.verticalAlign}`)),t.backgroundColor&&(n["data-bgcolor"]=t.backgroundColor,o.push(`background-color: #${t.backgroundColor}`)),n.style=o.join("; "),["td",n,0]}},Gg={content:"(paragraph | table)+",tableRole:"header_cell",isolating:true,attrs:{colspan:{default:1},rowspan:{default:1},colwidth:{default:null},width:{default:null},widthType:{default:null},verticalAlign:{default:null},backgroundColor:{default:null},borders:{default:null},margins:{default:null},textDirection:{default:null},noWrap:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"th",getAttrs:e=>uu(e)}],toDOM(e){let t=e.attrs,n={class:"docx-table-header"};t.colspan>1&&(n.colspan=String(t.colspan)),t.rowspan>1&&(n.rowspan=String(t.rowspan));let o=["font-weight: bold"];return o.push(...fu(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...gu(t)),o.push(...pu(t)),o.push(...mu(t.textDirection)),t.verticalAlign&&(n["data-valign"]=t.verticalAlign,o.push(`vertical-align: ${t.verticalAlign}`)),t.backgroundColor&&(n["data-bgcolor"]=t.backgroundColor,o.push(`background-color: #${t.backgroundColor}`)),n.style=o.join("; "),["th",n,0]}};function qe(e){let{selection:t}=e,{$from:n}=t,o=t instanceof CellSelection,r,i,a,s,l;for(let m=n.depth;m>0;m--){let b=n.node(m);if(b.type.name==="tableCell"||b.type.name==="tableHeader"){l=b;let g=n.node(m-1);if(g&&g.type.name==="tableRow"){let x=0,k=false;g.forEach((S,B,w)=>{k||(w===n.index(m-1)?(s=x,k=true):x+=S.attrs.colspan||1);});}}else if(b.type.name==="tableRow"){let g=n.node(m-1);g&&g.type.name==="table"&&(a=n.index(m-1));}else if(b.type.name==="table"){r=b,i=n.before(m);break}}if(!r)return {isInTable:false};let u=0,d=0;r.forEach(m=>{if(m.type.name==="tableRow"){u++;let b=0;m.forEach(g=>{b+=g.attrs.colspan||1;}),d=Math.max(d,b);}});let c=l&&((l.attrs.colspan||1)>1||(l.attrs.rowspan||1)>1),p,f;if(l){let m=l.attrs;m.backgroundColor&&typeof m.backgroundColor=="string"&&(f=m.backgroundColor);let b=m.borders;if(b)for(let g of ["top","right","bottom","left"]){let x=b[g];if(x?.color&&x.style&&x.style!=="none"&&x.style!=="nil"){p=x.color;break}}}return {isInTable:true,table:r,tablePos:i,rowIndex:a,columnIndex:s,rowCount:u,columnCount:d,hasMultiCellSelection:o,canSplitCell:!!c,cellBorderColor:p,cellBackgroundColor:f}}function Gn(e){let{$from:t}=e.selection;for(let n=t.depth;n>0;n--){let o=t.node(n);if(o.type.name==="tableCell"||o.type.name==="tableHeader")return true}return false}function hu(e){let{$from:t}=e.selection,n=-1,o=-1,r=-1;for(let i=t.depth;i>0;i--){let a=t.node(i);if(a.type.name==="tableCell"||a.type.name==="tableHeader")n=i;else if(a.type.name==="tableRow")o=i;else if(a.type.name==="table"){r=i;break}}return n===-1||o===-1||r===-1?null:{cellDepth:n,cellPos:t.before(n),rowDepth:o,tableDepth:r}}function bu(){return (e,t)=>{if(!Gn(e))return false;let n=hu(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.node(n.rowDepth),a=o.index(n.rowDepth),s=o.index(n.tableDepth);if(a<i.childCount-1){let l=n.cellPos+o.node(n.cellDepth).nodeSize;if(t){let u=l+1+1,d=e.tr.setSelection(Selection.near(e.doc.resolve(u)));t(d.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let d=u+1+1+1,c=e.tr.setSelection(Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}return false}}function yu(){return (e,t)=>{if(!Gn(e))return false;let n=hu(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.index(n.rowDepth),a=o.index(n.tableDepth);if(i>0){let l=o.node(n.rowDepth).child(i-1),u=n.cellPos-l.nodeSize;if(t){let d=u+l.nodeSize-2,c=e.tr.setSelection(Selection.near(e.doc.resolve(d),-1));t(c.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let c=u+s.nodeSize-1-1,p=e.tr.setSelection(Selection.near(e.doc.resolve(c),-1));t(p.scrollIntoView());}return true}return false}}var Kg=tt({name:"table",schemaNodeName:"table",nodeSpec:Wg}),Yg=tt({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:Vg}),qg=tt({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:jg}),Xg=tt({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:Gg}),Zg=ht({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...R){return (F,C,M)=>{for(let L of R)if(L(F,C,M))return true;return false}}function o(R,F={}){let C=R?.attrs??{};return {colspan:C.colspan||1,rowspan:1,colwidth:C.colwidth,width:C.width,widthType:C.widthType,verticalAlign:C.verticalAlign,backgroundColor:C.backgroundColor,borders:C.borders,margins:C.margins,textDirection:C.textDirection,noWrap:C.noWrap,...F}}function r(R,F,C="000000",M=9360){let L=[],D=Math.floor(M/F),Y=360,se="atLeast",W={style:"single",size:4,color:{rgb:C}},q={top:W,bottom:W,left:W,right:W};for(let we=0;we<R;we++){let oe=[];for(let re=0;re<F;re++){let pe=t.nodes.paragraph.create(),be={colspan:1,rowspan:1,borders:q,width:D,widthType:"dxa"};oe.push(t.nodes.tableCell.create(be,pe));}L.push(t.nodes.tableRow.create({height:Y,heightRule:se},oe));}let Q=Array(F).fill(D);return t.nodes.table.create({columnWidths:Q,width:M,widthType:"dxa"},L)}function i(R,F){return (C,M)=>{let{$from:L}=C.selection,D="000000",Y=C.storedMarks||L.marks();for(let W of Y)if(W.type.name==="textColor"&&W.attrs.rgb){D=W.attrs.rgb;break}let se=L.pos;for(let W=L.depth;W>0;W--){let q=L.node(W);if(q.type.name==="paragraph"||q.type.name==="table"){se=L.after(W);break}}if(M){let W=9360;for(let Ge=L.depth;Ge>0;Ge--){let Oe=L.node(Ge);if(Oe.type.name==="tableCell"||Oe.type.name==="tableHeader"){let Ae=Oe.attrs.width;Ae&&Ae>0&&(W=Math.max(Ae-216,360));break}}let q=r(R,F,D,W),Q=t.nodes.paragraph.create(),oe=C.doc.resolve(se).nodeBefore?.type.name==="table",re=oe?[Q,q,Q]:[q,Q],pe=C.tr.insert(se,re),be=se+1;oe&&(be+=Q.nodeSize);let Be=be+1+1;pe.setSelection(TextSelection.create(pe.doc,Be)),M(pe.scrollIntoView());}return true}}function a(R,F){let C=qe(R);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0)return false;if(F){let M=R.tr,L=C.table.child(C.rowIndex),D=[];L.forEach(W=>{let q=t.nodes.paragraph.create(),Q=o(W);D.push(t.nodes.tableCell.create(Q,q));});let Y=t.nodes.tableRow.create({height:L.attrs.height??360,heightRule:L.attrs.heightRule??"atLeast"},D),se=C.tablePos+1;for(let W=0;W<C.rowIndex;W++)se+=C.table.child(W).nodeSize;M.insert(se,Y),F(M.scrollIntoView());}return true}function s(R,F){let C=qe(R);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0)return false;if(F){let M=R.tr,L=C.table.child(C.rowIndex),D=[];L.forEach(W=>{let q=t.nodes.paragraph.create(),Q=o(W);D.push(t.nodes.tableCell.create(Q,q));});let Y=t.nodes.tableRow.create({height:L.attrs.height??360,heightRule:L.attrs.heightRule??"atLeast"},D),se=C.tablePos+1;for(let W=0;W<=C.rowIndex;W++)se+=C.table.child(W).nodeSize;M.insert(se,Y),F(M.scrollIntoView());}return true}function l(R,F){let C=qe(R);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0||(C.rowCount||0)<=1)return false;if(F){let M=R.tr,L=C.tablePos+1;for(let Y=0;Y<C.rowIndex;Y++)L+=C.table.child(Y).nodeSize;let D=L+C.table.child(C.rowIndex).nodeSize;M.delete(L,D),F(M.scrollIntoView());}return true}function u(R,F){let C=qe(R);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0)return false;if(F){let M=R.tr,L=(C.columnCount||1)+1,D=Math.floor(100/L),Y=C.tablePos+1;C.table.forEach(q=>{if(q.type.name==="tableRow"){let Q=Y+1,we=0;if(q.forEach(oe=>{if(we===C.columnIndex){let re=t.nodes.paragraph.create(),pe=o(oe,{colspan:1,rowspan:1});pe.width=D,pe.widthType="pct";let be=t.nodes.tableCell.create(pe,re);M=M.insert(Q,be);}Q+=oe.nodeSize,we+=oe.attrs.colspan||1;}),we<=C.columnIndex){let oe=t.nodes.paragraph.create(),re=o(q.child(q.childCount-1)??null,{colspan:1,rowspan:1});re.width=D,re.widthType="pct";let pe=t.nodes.tableCell.create(re,oe);M=M.insert(Q,pe);}}Y+=q.nodeSize;});let W=M.doc.nodeAt(C.tablePos);if(W&&W.type.name==="table"){let q=W.child(0);if(q&&q.type.name==="tableRow"){let re=C.tablePos+2;q.forEach(pe=>{(pe.type.name==="tableCell"||pe.type.name==="tableHeader")&&(M=M.setNodeMarkup(re,void 0,{...pe.attrs,width:D,widthType:"pct"})),re+=pe.nodeSize;});}let Q=q?.childCount??L,we=W.attrs.width||9360,oe=Math.floor(we/Math.max(1,Q));M=M.setNodeMarkup(C.tablePos,void 0,{...W.attrs,columnWidths:Array(Q).fill(oe)});}F(M.scrollIntoView());}return true}function d(R,F){let C=qe(R);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0)return false;if(F){let M=R.tr,L=(C.columnCount||1)+1,D=Math.floor(100/L),Y=C.tablePos+1;C.table.forEach(q=>{if(q.type.name==="tableRow"){let Q=Y+1,we=0,oe=false;if(q.forEach(re=>{if(Q+=re.nodeSize,we+=re.attrs.colspan||1,!oe&&we>C.columnIndex){let pe=t.nodes.paragraph.create(),be=o(re,{colspan:1,rowspan:1});be.width=D,be.widthType="pct";let Ue=t.nodes.tableCell.create(be,pe);M=M.insert(Q,Ue),oe=true;}}),!oe){let re=t.nodes.paragraph.create(),pe=o(q.child(q.childCount-1)??null,{colspan:1,rowspan:1});pe.width=D,pe.widthType="pct";let be=t.nodes.tableCell.create(pe,re);M=M.insert(Q,be);}}Y+=q.nodeSize;});let W=M.doc.nodeAt(C.tablePos);if(W&&W.type.name==="table"){let q=W.child(0);if(q&&q.type.name==="tableRow"){let re=C.tablePos+2;q.forEach(pe=>{(pe.type.name==="tableCell"||pe.type.name==="tableHeader")&&(M=M.setNodeMarkup(re,void 0,{...pe.attrs,width:D,widthType:"pct"})),re+=pe.nodeSize;});}let Q=q?.childCount??L,we=W.attrs.width||9360,oe=Math.floor(we/Math.max(1,Q));M=M.setNodeMarkup(C.tablePos,void 0,{...W.attrs,columnWidths:Array(Q).fill(oe)});}F(M.scrollIntoView());}return true}function c(R,F){let C=qe(R);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0||(C.columnCount||0)<=1)return false;if(F){let M=R.tr,L=(C.columnCount||2)-1,D=Math.floor(100/L),Y=[],se=C.tablePos+1;C.table.forEach(q=>{if(q.type.name==="tableRow"){let Q=se+1,we=0;q.forEach(oe=>{let re=Q,pe=Q+oe.nodeSize,be=oe.attrs.colspan||1;we<=C.columnIndex&&C.columnIndex<we+be&&Y.push({start:re,end:pe}),Q=pe,we+=be;});}se+=q.nodeSize;}),Y.reverse().forEach(({start:q,end:Q})=>{M=M.delete(q,Q);});let W=M.doc.nodeAt(C.tablePos);if(W&&W.type.name==="table"){let q=W.child(0);if(q&&q.type.name==="tableRow"){let re=C.tablePos+2;q.forEach(pe=>{(pe.type.name==="tableCell"||pe.type.name==="tableHeader")&&(M=M.setNodeMarkup(re,void 0,{...pe.attrs,width:D,widthType:"pct"})),re+=pe.nodeSize;});}let Q=q?.childCount??L,we=W.attrs.width||9360,oe=Math.floor(we/Math.max(1,Q));M=M.setNodeMarkup(C.tablePos,void 0,{...W.attrs,columnWidths:Array(Q).fill(oe)});}F(M.scrollIntoView());}return true}function p(R,F){let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(F){let M=R.tr;M.delete(C.tablePos,C.tablePos+C.table.nodeSize),F(M.scrollIntoView());}return true}function f(R,F){let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(F){let M=C.tablePos+1,L=R.doc.resolve(M),D=R.doc.resolve(C.tablePos+C.table.nodeSize-2),Y=CellSelection.create(R.doc,L.pos,D.pos);F(R.tr.setSelection(Y));}return true}function m(R,F){let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table||C.rowIndex===void 0)return false;if(F){let L=C.tablePos+1;for(let q=0;q<C.rowIndex;q++){let Q=C.table.child(q);L+=Q.nodeSize;}let D=C.table.child(C.rowIndex),Y=L+1,se=L+D.nodeSize-2,W=CellSelection.create(R.doc,Y,se);F(R.tr.setSelection(W));}return true}function b(R,F){let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table||C.columnIndex===void 0)return false;if(F){let M=C.tablePos+1,L=C.table.child(0),D=C.table.child(C.table.childCount-1),Y=M+1;for(let Q=0;Q<C.columnIndex&&Q<L.childCount;Q++)Y+=L.child(Q).nodeSize;let se=M;for(let Q=0;Q<C.table.childCount-1;Q++)se+=C.table.child(Q).nodeSize;let W=se+1;for(let Q=0;Q<C.columnIndex&&Q<D.childCount;Q++)W+=D.child(Q).nodeSize;let q=CellSelection.create(R.doc,Y,W);F(R.tr.setSelection(q));}return true}function g(R){let F=R.selection,C=[];if(F instanceof CellSelection)return F.forEachCell((L,D)=>{C.push({pos:D,node:L});}),C;let{$from:M}=F;for(let L=M.depth;L>0;L--){let D=M.node(L);if(D.type.name==="tableCell"||D.type.name==="tableHeader"){C.push({pos:M.before(L),node:D});break}}return C}function x(R,F){let C=new Map,M=new Map,L=R.childCount,D=0;return R.forEach((Y,se,W)=>{if(Y.type.name!=="tableRow")return;let q=0;Y.forEach((Q,we)=>{let oe=F+se+we+2,re=Q.attrs.colspan||1;C.set(oe,{rowIdx:W,colIdx:q,colspan:re,pos:oe,node:Q}),M.set(`${W},${q}`,oe),q+=re;}),D=Math.max(D,q);}),{cellByPos:C,cellByRC:M,totalRows:L,totalCols:D}}function k(R,F){return (C,M)=>{let L=qe(C);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(M){let D=C.tr,Y=L.table,se=L.tablePos,W=F??{style:"single",size:4,color:{rgb:"000000"}},q={style:"none"},{cellByPos:Q,cellByRC:we}=x(Y,se),oe=g(C),re=1/0,pe=-1,be=1/0,Ue=-1;for(let{pos:Ae}of oe){let Re=Q.get(Ae);Re&&(re=Math.min(re,Re.rowIdx),pe=Math.max(pe,Re.rowIdx),be=Math.min(be,Re.colIdx),Ue=Math.max(Ue,Re.colIdx+Re.colspan-1));}let Be=new Map,Ge=(Ae,Re)=>Be.get(Ae)??{...Re.attrs},Oe=(Ae,Re)=>{Be.set(Ae,Re);};for(let{pos:Ae}of oe){let Re=Q.get(Ae);if(!Re)continue;let Pe=Re.rowIdx===re,Ke=Re.rowIdx===pe,Ye=Re.colIdx===be,bt=Re.colIdx+Re.colspan-1===Ue,Ze;switch(R){case "all":Ze={top:W,bottom:W,left:W,right:W};break;case "outside":Ze={top:Pe?W:q,bottom:Ke?W:q,left:Ye?W:q,right:bt?W:q};break;case "inside":Ze={top:Pe?q:W,bottom:Ke?q:W,left:Ye?q:W,right:bt?q:W};break;case "none":Ze={top:q,bottom:q,left:q,right:q};break}let ut=Ge(Ae,Re.node),Tt=ut.borders||{};if(Oe(Ae,{...ut,borders:{...Tt,...Ze}}),Ze.top){let Fe=we.get(`${Re.rowIdx-1},${Re.colIdx}`);if(Fe!==void 0){let pt=Q.get(Fe),De=Ge(Fe,pt.node),St=De.borders||{};Oe(Fe,{...De,borders:{...St,bottom:Ze.top}});}}if(Ze.bottom){let Fe=we.get(`${Re.rowIdx+1},${Re.colIdx}`);if(Fe!==void 0){let pt=Q.get(Fe),De=Ge(Fe,pt.node),St=De.borders||{};Oe(Fe,{...De,borders:{...St,top:Ze.bottom}});}}if(Ze.left){let Fe=we.get(`${Re.rowIdx},${Re.colIdx-1}`);if(Fe!==void 0){let pt=Q.get(Fe),De=Ge(Fe,pt.node),St=De.borders||{};Oe(Fe,{...De,borders:{...St,right:Ze.left}});}}if(Ze.right){let Fe=we.get(`${Re.rowIdx},${Re.colIdx+Re.colspan}`);if(Fe!==void 0){let pt=Q.get(Fe),De=Ge(Fe,pt.node),St=De.borders||{};Oe(Fe,{...De,borders:{...St,left:Ze.right}});}}}for(let[Ae,Re]of Be)D.setNodeMarkup(D.mapping.map(Ae),void 0,Re);M(D.scrollIntoView());}return true}}function S(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F),Y=R?R.replace(/^#/,""):null;for(let{pos:se,node:W}of D)L.setNodeMarkup(L.mapping.map(se),void 0,{...W.attrs,backgroundColor:Y});C(L.scrollIntoView());}return true}}function B(R,F,C){return (M,L)=>{let D=qe(M);if(!D.isInTable||D.tablePos===void 0||!D.table)return false;if(L){let Y=M.tr,se=g(M),W=F||{style:"none"},q={style:"none"},Q=["top","bottom","left","right"],{cellByPos:we,cellByRC:oe}=x(D.table,D.tablePos),re=new Map,pe=(Be,Ge)=>re.get(Be)??{...Ge.attrs},be=(Be,Ge)=>re.set(Be,Ge),Ue={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:Be,node:Ge}of se){let Oe=we.get(Be),Ae=pe(Be,Ge),Re=Ae.borders||{},Pe=R==="all"?Q:[R],Ke=C?{top:q,bottom:q,left:q,right:q}:{...Re};for(let Ye of Pe)Ke[Ye]=W;if(Oe){let Ye=C?Q:Pe;for(let bt of Ye){let Ze=Ke[bt],ut=Ue[bt],Tt=bt==="right"?Oe.colIdx+Oe.colspan:Oe.colIdx+ut.dCol,Fe=oe.get(`${Oe.rowIdx+ut.dRow},${Tt}`);if(Fe!==void 0){let pt=we.get(Fe),De=pe(Fe,pt.node),St=De.borders||{};be(Fe,{...De,borders:{...St,[ut.adjSide]:Ze}});}}}be(Be,{...Ae,borders:Ke});}for(let[Be,Ge]of re)Y.setNodeMarkup(Y.mapping.map(Be),void 0,Ge);L(Y.scrollIntoView());}return true}}function w(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F);for(let{pos:Y,node:se}of D)L.setNodeMarkup(L.mapping.map(Y),void 0,{...se.attrs,verticalAlign:R});C(L.scrollIntoView());}return true}}function E(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F);for(let{pos:Y,node:se}of D){let q={...se.attrs.margins||{},...R};L.setNodeMarkup(L.mapping.map(Y),void 0,{...se.attrs,margins:q});}C(L.scrollIntoView());}return true}}function P(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F);for(let{pos:Y,node:se}of D)L.setNodeMarkup(L.mapping.map(Y),void 0,{...se.attrs,textDirection:R});C(L.scrollIntoView());}return true}}function z(){return (R,F)=>{let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(F){let M=R.tr,L=g(R);for(let{pos:D,node:Y}of L)M.setNodeMarkup(M.mapping.map(D),void 0,{...Y.attrs,noWrap:!Y.attrs.noWrap});F(M.scrollIntoView());}return true}}function I(R,F){return (C,M)=>{let L=qe(C);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(M){let D=C.tr,{$from:Y}=C.selection;for(let se=Y.depth;se>0;se--){let W=Y.node(se);if(W.type.name==="tableRow"){let q=Y.before(se),Q={...W.attrs,height:R,heightRule:R?F||"atLeast":null};return D.setNodeMarkup(q,void 0,Q),M(D.scrollIntoView()),true}}}return true}}function A(){return (R,F)=>{let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table||!C.columnCount)return false;if(F){let M=R.tr,L=C.table,D=C.columnCount,Y=L.attrs.columnWidths,se=Y?Y.reduce((we,oe)=>we+oe,0):9360,W=Math.floor(se/D),q=C.tablePos+1;L.forEach(we=>{if(we.type.name==="tableRow"){let oe=q+1;we.forEach(re=>{(re.type.name==="tableCell"||re.type.name==="tableHeader")&&(M=M.setNodeMarkup(oe,void 0,{...re.attrs,width:W,widthType:"dxa",colwidth:null})),oe+=re.nodeSize;});}q+=we.nodeSize;});let Q=Array(D).fill(W);M=M.setNodeMarkup(C.tablePos,void 0,{...L.attrs,columnWidths:Q}),F(M.scrollIntoView());}return true}}function Z(){return (R,F)=>{let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(F){let M=R.tr,L=C.table,D=C.tablePos+1;L.forEach(Y=>{if(Y.type.name==="tableRow"){let se=D+1;Y.forEach(W=>{(W.type.name==="tableCell"||W.type.name==="tableHeader")&&(M=M.setNodeMarkup(se,void 0,{...W.attrs,width:null,widthType:null,colwidth:null})),se+=W.nodeSize;});}D+=Y.nodeSize;}),M=M.setNodeMarkup(C.tablePos,void 0,{...L.attrs,columnWidths:null,width:null,widthType:"auto"}),F(M.scrollIntoView());}return true}}function ce(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=M.table,Y=M.tablePos,se=D.childCount,W=R.look??{firstRow:true,lastRow:false,noHBand:false},q=R.conditionals??{},Q=R.tableBorders;L=L.setNodeMarkup(Y,void 0,{...D.attrs,styleId:R.styleId});let we=0,oe=Y+1;for(let re=0;re<se;re++){let pe=D.child(re),be=re===0&&!!W.firstRow,Ue=re===se-1&&!!W.lastRow,Be=W.noHBand!==true,Ge=pe.childCount,Oe;be?Oe="firstRow":Ue?Oe="lastRow":(Be&&(Oe=we%2===0?"band1Horz":"band2Horz"),we++);let Ae=oe+1;for(let Re=0;Re<Ge;Re++){let Pe=pe.child(Re),Ke=L.mapping.map(Ae),Ye=Oe,bt=Re===0&&!!W.firstCol,Ze=Re===Ge-1&&!!W.lastCol;be&&bt&&q.nwCell?Ye="nwCell":be&&Ze&&q.neCell?Ye="neCell":Ue&&bt&&q.swCell?Ye="swCell":Ue&&Ze&&q.seCell?Ye="seCell":bt?Ye="firstCol":Ze&&(Ye="lastCol");let ut=Ye?q[Ye]:void 0,Tt={...Pe.attrs};ut?.backgroundColor?Tt.backgroundColor=ut.backgroundColor:Tt.backgroundColor=null;let Fe={},pt=["top","bottom","left","right"];for(let De of pt)ut?.borders&&ut.borders[De]!==void 0?Fe[De]=ut.borders[De]:Q&&(De==="top"&&re>0||De==="bottom"&&re<se-1?Fe[De]=Q.insideH??Q[De]:De==="left"&&Re>0||De==="right"&&Re<Ge-1?Fe[De]=Q.insideV??Q[De]:Fe[De]=Q[De]);Object.keys(Fe).length>0?Tt.borders=Fe:Tt.borders=null,L=L.setNodeMarkup(Ke,void 0,Tt),Ae+=Pe.nodeSize;}oe+=pe.nodeSize;}C(L.scrollIntoView());}return true}}function ae(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D={...M.table.attrs};"width"in R&&(D.width=R.width),"widthType"in R&&(D.widthType=R.widthType),"justification"in R&&(D.justification=R.justification),L.setNodeMarkup(M.tablePos,void 0,D),C(L.scrollIntoView());}return true}}function $(){return (R,F)=>{let C=qe(R);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(F){let M=R.tr,{$from:L}=R.selection;for(let D=L.depth;D>0;D--){let Y=L.node(D);if(Y.type.name==="tableRow"){let se=L.before(D),W={...Y.attrs,isHeader:!Y.attrs.isHeader};return M.setNodeMarkup(se,void 0,W),F(M.scrollIntoView()),true}}}return true}}function H(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F),Y=R.replace(/^#/,""),se={style:"single",size:4},{cellByPos:W,cellByRC:q}=x(M.table,M.tablePos),Q=new Map,we=(pe,be)=>Q.get(pe)??{...be.attrs},oe=(pe,be)=>Q.set(pe,be),re={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:pe,node:be}of D){let Ue=W.get(pe),Be=we(pe,be),Ge=Be.borders||{},Oe={};for(let Ae of ["top","bottom","left","right"]){let Re={...se,...Ge[Ae],color:{rgb:Y}};if(Oe[Ae]=Re,Ue){let Pe=re[Ae],Ke=Ae==="right"?Ue.colIdx+Ue.colspan:Ue.colIdx+Pe.dCol,Ye=q.get(`${Ue.rowIdx+Pe.dRow},${Ke}`);if(Ye!==void 0){let bt=W.get(Ye),Ze=we(Ye,bt.node),ut=Ze.borders||{};oe(Ye,{...Ze,borders:{...ut,[Pe.adjSide]:Re}});}}}oe(pe,{...Be,borders:{...Ge,...Oe}});}for(let[pe,be]of Q)L.setNodeMarkup(L.mapping.map(pe),void 0,be);C(L.scrollIntoView());}return true}}function de(R){return (F,C)=>{let M=qe(F);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(C){let L=F.tr,D=g(F),Y={style:"single",color:{rgb:"000000"}},{cellByPos:se,cellByRC:W}=x(M.table,M.tablePos),q=new Map,Q=(re,pe)=>q.get(re)??{...pe.attrs},we=(re,pe)=>q.set(re,pe),oe={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:re,node:pe}of D){let be=se.get(re),Ue=Q(re,pe),Be=Ue.borders||{},Ge={};for(let Oe of ["top","bottom","left","right"]){let Ae={...Y,...Be[Oe],size:R};if(Ge[Oe]=Ae,be){let Re=oe[Oe],Pe=Oe==="right"?be.colIdx+be.colspan:be.colIdx+Re.dCol,Ke=W.get(`${be.rowIdx+Re.dRow},${Pe}`);if(Ke!==void 0){let Ye=se.get(Ke),bt=Q(Ke,Ye.node),Ze=bt.borders||{};we(Ke,{...bt,borders:{...Ze,[Re.adjSide]:Ae}});}}}we(re,{...Ue,borders:{...Be,...Ge}});}for(let[re,pe]of q)L.setNodeMarkup(L.mapping.map(re),void 0,pe);C(L.scrollIntoView());}return true}}function me(){return (R,F)=>{let C=R.selection;if(!("$anchorCell"in C&&typeof C.forEachCell=="function"))return false;let L=qe(R);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;let D=0;L.table.descendants(W=>{(W.type.name==="tableCell"||W.type.name==="tableHeader")&&(D+=1);});let Y=0;if(C.forEachCell(()=>{Y+=1;}),!(D>0&&Y>=D))return false;if(F){let W=R.tr.delete(L.tablePos,L.tablePos+L.table.nodeSize);F(W.scrollIntoView());}return true}}function ue(){return R=>{let{$from:F,empty:C}=R.selection;if(!C)return false;let M=F.parent;if(M.type.name!=="paragraph"||M.textContent.length>0)return false;let L=F.depth;if(L<1)return false;let D=F.node(L-1),Y=F.index(L-1),se=Y>0?D.child(Y-1):null,W=Y+1<D.childCount?D.child(Y+1):null,q=se?.type.name==="table",Q=W?.type.name==="table";return !!(q||Q)}}let N=new PluginKey("activeCell"),Ve=new Plugin({key:N,props:{decorations(R){let{selection:F}=R;if(F instanceof CellSelection)return DecorationSet.empty;let{$from:C}=F;for(let M=C.depth;M>0;M--){let L=C.node(M);if(L.type.name==="tableCell"||L.type.name==="tableHeader"){let D=C.before(M);return DecorationSet.create(R.doc,[Decoration.node(D,D+L.nodeSize,{class:"activeCell"})])}}return DecorationSet.empty}}});return {plugins:[columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),tableEditing(),Ve],keyboardShortcuts:{Backspace:n(me(),ue()),Delete:n(me(),ue())},commands:{insertTable:(R,F)=>i(R,F),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>d,deleteColumn:()=>c,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>mergeCells,splitCell:()=>splitCell,setCellBorder:(R,F,C)=>B(R,F,C),setTableBorders:(R,F)=>k(R,F),setCellVerticalAlign:R=>w(R),setCellMargins:R=>E(R),setCellTextDirection:R=>P(R),toggleNoWrap:()=>z(),setRowHeight:(R,F)=>I(R,F),toggleHeaderRow:()=>$(),distributeColumns:()=>A(),autoFitContents:()=>Z(),setTableProperties:R=>ae(R),applyTableStyle:R=>ce(R),setCellFillColor:R=>S(R),setTableBorderColor:R=>H(R),setTableBorderWidth:R=>de(R),removeTableBorders:()=>k("none"),setAllTableBorders:R=>k("all",R),setOutsideTableBorders:R=>k("outside",R),setInsideTableBorders:R=>k("inside",R)}}}});function xu(){return [Kg(),Yg(),qg(),Xg(),Zg()]}function el(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function Su(e){return (t,n)=>{let{$from:o,$to:r}=t.selection,i=o.parent;if(i.type.name!=="paragraph")return false;let s=i.attrs.numPr?.numId===e;if(!n)return true;let l=t.tr,u=new Set;return t.doc.nodesBetween(o.pos,r.pos,(d,c)=>{if(d.type.name==="paragraph"&&!u.has(c))if(u.add(c),s)l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:{numId:e,ilvl:d.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var Jg=(e,t)=>Su(1)(e,t),Qg=(e,t)=>Su(2)(e,t),eh=(e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||!o.attrs.numPr)return false;let r=o.attrs.numPr.ilvl||0;if(r>=8)return false;if(!t)return true;let i=n.before(n.depth);return t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:{...o.attrs.numPr,ilvl:r+1},indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()),true},th=(e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||!o.attrs.numPr)return false;let r=o.attrs.numPr.ilvl||0;if(!t)return true;let i=n.before(n.depth);return r<=0?t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()):t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:{...o.attrs.numPr,ilvl:r-1},indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()),true},nh=(e,t)=>{let{$from:n,$to:o}=e.selection;if(!t)return true;let r=e.tr,i=new Set;return e.doc.nodesBetween(n.pos,o.pos,(a,s)=>{a.type.name==="paragraph"&&a.attrs.numPr&&!i.has(s)&&(i.add(s),r=r.setNodeMarkup(s,void 0,{...a.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null}));}),t(r.scrollIntoView()),true};function oh(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr||r.textContent.length>0)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...r.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});t(a);}return true}}function rh(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr)return false;if(t){let{tr:a}=e,s=n.pos;a.split(s,1,[{type:e.schema.nodes.paragraph,attrs:{...r.attrs}}]),t(a.scrollIntoView());}return true}}function ih(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o||n.parentOffset!==0)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...r.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});t(a);}return true}}function ah(){return (e,t)=>{let{$from:n,$to:o}=e.selection,r=[];if(e.doc.nodesBetween(n.pos,o.pos,(i,a)=>{i.type.name==="paragraph"&&i.attrs.numPr&&(i.attrs.numPr.ilvl??0)<8&&r.push({pos:a,attrs:i.attrs});}),r.length===0)return false;if(t){let i=e.tr;for(let{pos:a,attrs:s}of r){let l=s.numPr;i=i.setNodeMarkup(a,void 0,{...s,numPr:{...l,ilvl:(l.ilvl??0)+1},indentLeft:null,indentFirstLine:null,hangingIndent:null});}t(i);}return true}}function sh(){return (e,t)=>{let{$from:n,$to:o}=e.selection,r=[];if(e.doc.nodesBetween(n.pos,o.pos,(i,a)=>{i.type.name==="paragraph"&&i.attrs.numPr&&r.push({pos:a,attrs:i.attrs});}),r.length===0)return false;if(t){let i=e.tr;for(let{pos:a,attrs:s}of r){let l=s.numPr,u=l.ilvl??0;u<=0?i=i.setNodeMarkup(a,void 0,{...s,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null}):i=i.setNodeMarkup(a,void 0,{...s,numPr:{...l,ilvl:u-1},indentLeft:null,indentFirstLine:null,hangingIndent:null});}t(i);}return true}}function lh(){return (e,t)=>{let{schema:n}=e,o=n.nodes.tab;if(!o)return false;if(t){let r=e.tr.replaceSelectionWith(o.create());t(r.scrollIntoView());}return true}}var ku=ht({name:"list",priority:Xt.High,onSchemaReady(){return {commands:{toggleBulletList:()=>Jg,toggleNumberedList:()=>Qg,increaseListLevel:()=>eh,decreaseListLevel:()=>th,removeList:()=>nh},keyboardShortcuts:{Tab:el(bu(),ah(),lh()),"Shift-Tab":el(yu(),sh()),"Shift-Enter":()=>false,Enter:el(oh(),rh()),Backspace:ih()}}}});function Tu(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var gh=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parentOffset!==0||n.parent.type.name!=="paragraph")return false;let o=n.parent.attrs,r=o.indentFirstLine!=null&&o.indentFirstLine>0,i=!!o.hangingIndent,a=o.indentLeft!=null&&o.indentLeft>0;if(!r&&!i&&!a)return false;if(t){let s=n.before(),l=e.tr.setNodeMarkup(s,void 0,{...o,indentFirstLine:null,hangingIndent:null,indentLeft:null});t(l.scrollIntoView());}return true},hh=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],wu=new Set(["fontFamily","fontSize","textColor"]),bh=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>wu.has(u.type.name)),s=null;if(!splitBlock(e,t?u=>{s=u;}:void 0,n))return false;if(t&&s!==null){let u=s,{$from:d}=u.selection,c=d.parent;if(c.type.name==="paragraph"){let p={...c.attrs},f=false;if(r)for(let m of hh){let b=r.attrs[m];b!=null&&p[m]==null&&(p[m]=b,f=true);}if(p.borders&&(p.borders=null,f=true),f&&u.setNodeMarkup(d.before(),void 0,p),c.textContent.length===0){let m=a;if(m.length===0&&r){let b=r.attrs.defaultTextFormatting;b&&(m=Fd(b,e.schema).filter(x=>wu.has(x.type.name)));}if(m.length>0){let b={...p.defaultTextFormatting??{}},g=false;for(let x of m)if(x.type.name==="fontSize"&&x.attrs.size!==b.fontSize&&(b.fontSize=x.attrs.size,g=true),x.type.name==="fontFamily"){let k=x.attrs.ascii;k&&(!b.fontFamily||b.fontFamily.ascii!==k)&&(b.fontFamily={...b.fontFamily,ascii:k,hAnsi:x.attrs.hAnsi},g=true);}g&&u.setNodeMarkup(d.before(),void 0,{...p,defaultTextFormatting:b}),u.setStoredMarks(m);}}}t(u.scrollIntoView());}return true},vu=ht({name:"baseKeymap",priority:Xt.Low,onSchemaReady(e){return {keyboardShortcuts:{...baseKeymap,Enter:bh,Backspace:Tu(deleteSelection,gh,joinBackward),Delete:Tu(deleteSelection,joinForward),"Mod-a":selectAll,Escape:selectParentNode}}}});var Ru=new PluginKey("selectionTracker");function Ni(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((B,w,E)=>{if(w>r)return false;w<=o&&(s=E),w<=r&&(l=E);});let u=Sh(e),d=a.parent,c={};d.type.name==="paragraph"&&(d.attrs.alignment&&(c.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(c.lineSpacing=d.attrs.lineSpacing,c.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.indentLeft&&(c.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(c.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(c.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(c.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(c.tabs=d.attrs.tabs),d.attrs.numPr&&(c.numPr=d.attrs.numPr),d.attrs.styleId&&(c.styleId=d.attrs.styleId));let p=d.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl,g=e.storedMarks||(i?a.marks():[]),x=[],k=false,S=false;for(let B of g)B.type.name==="comment"&&B.attrs.commentId&&x.push(B.attrs.commentId),B.type.name==="insertion"&&(k=true),B.type.name==="deletion"&&(S=true);return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:c,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b,activeCommentIds:x,inInsertion:k,inDeletion:S}}function Sh(e){let{selection:t}=e,{empty:n,$from:o}=t,r=e.storedMarks||(n?o.marks():[]),i={};for(let a of r)switch(a.type.name){case "bold":i.bold=true;break;case "italic":i.italic=true;break;case "underline":i.underline={style:a.attrs.style||"single",color:a.attrs.color};break;case "strike":a.attrs.double?i.doubleStrike=true:i.strike=true;break;case "textColor":i.color={rgb:a.attrs.rgb,themeColor:a.attrs.themeColor,themeTint:a.attrs.themeTint,themeShade:a.attrs.themeShade};break;case "highlight":i.highlight=a.attrs.color;break;case "fontSize":i.fontSize=a.attrs.size;break;case "fontFamily":i.fontFamily={ascii:a.attrs.ascii,hAnsi:a.attrs.hAnsi,asciiTheme:a.attrs.asciiTheme};break;case "superscript":i.vertAlign="superscript";break;case "subscript":i.vertAlign="subscript";break}return i}function Eu(e){return new Plugin({key:Ru,state:{init(t,n){return Ni(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=Ni(r);return e&&!Ch(n,i)&&setTimeout(()=>e(i),0),i}},view(){return {update(t,n){if(!e||t.state.selection.eq(n.selection)&&t.state.doc.eq(n.doc))return;let o=Ru.getState(t.state);o&&e(o);}}}})}function kh(e,t){if(e===t)return true;if(!e||!t||e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}function Ch(e,t){return e.hasSelection===t.hasSelection&&e.isMultiParagraph===t.isMultiParagraph&&e.startParagraphIndex===t.startParagraphIndex&&e.endParagraphIndex===t.endParagraphIndex&&e.inList===t.inList&&e.listType===t.listType&&e.listLevel===t.listLevel&&e.inInsertion===t.inInsertion&&e.inDeletion===t.inDeletion&&kh(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var Pu=ht({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[Eu(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(Ni(n),true)}}}});var vh=new PluginKey("imageDrag"),Iu=ht({name:"imageDrag",onSchemaReady(e){return {plugins:[new Plugin({key:vh,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof NodeSelection&&r.node.type.name==="image"){n.dom.classList.add("pm-image-dragging");let i=o;if(i.dataTransfer){i.dataTransfer.effectAllowed="move";let a=document.createElement("div");a.style.cssText="position: fixed; left: -9999px; top: -9999px; opacity: 0.6; pointer-events: none; border: 2px dashed var(--doc-primary, #2563eb); border-radius: 4px; background: rgba(37, 99, 235, 0.08);",a.style.width=`${r.node.attrs.width||100}px`,a.style.height=`${r.node.attrs.height||100}px`,document.body.appendChild(a),i.dataTransfer.setDragImage(a,0,0),requestAnimationFrame(()=>{document.body.removeChild(a);});}}return false},dragend(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false},dragover(n,o){let{selection:r}=n.state;if(r instanceof NodeSelection&&r.node.type.name==="image"){let i=o;i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move");}return false},drop(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false}}}})]}}});var tl=612;async function Ph(e){return await new Promise((t,n)=>{let o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error??new Error("Failed to read image file")),o.readAsDataURL(e);})}async function Mh(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth||1,height:o.naturalHeight||1}),o.onerror=()=>n(new Error("Failed to load pasted image")),o.src=e;})}async function Ih(e,t){let n=e.state.schema.nodes.image;if(!n)return;let o=e.state.selection.from;for(let r of t){let i;try{i=await Ph(r);}catch{continue}let a=1,s=1;try{({width:a,height:s}=await Mh(i));}catch{a=1,s=1;}let l=a,u=s;if(l>tl){let p=tl/l;l=tl,u=Math.max(1,Math.round(u*p));}let d=n.create({src:i,alt:r.name,width:l,height:u,rId:`rId_img_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,wrapType:"inline",displayMode:"inline"}),c=e.state.tr.insert(o,d);o+=d.nodeSize,c.setSelection(TextSelection.create(c.doc,o)),e.dispatch(c.scrollIntoView());}e.focus();}var Fu=ht({name:"imagePaste",onSchemaReady(e){return {plugins:[new Plugin({props:{handleDOMEvents:{paste(n,o){let r=o,i=L(r.clipboardData);return i.length===0||!n.state.schema.nodes.image?false:(r.preventDefault(),Ih(n,i).catch(()=>{}),true)}}}})]}}});var Lu=ht({name:"dropCursor",onSchemaReady(){return {plugins:[dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});var Oi=new PluginKey("paragraphChangeTracker");function Bu(e){let t=0;return e.descendants(n=>{n.type.name==="paragraph"&&t++;}),t}function Ah(e,t,n){let o=new Set,r=false;return e.nodesBetween(t,n,i=>{if(i.type.name==="paragraph"){let a=i.attrs.paraId;a?o.add(a):r=true;}}),{ids:o,hasUntracked:r}}function Dh(){return new Plugin({key:Oi,state:{init(e,t){return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:Bu(t.doc)}},apply(e,t){if(e.getMeta(Oi)==="clear")return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:t.paragraphCount};if(!e.docChanged)return t;let n=Bu(e.doc),o={changedParaIds:new Set(t.changedParaIds),structuralChange:t.structuralChange,hasUntrackedChanges:t.hasUntrackedChanges,paragraphCount:n};t.paragraphCount!==n&&(o.structuralChange=true);for(let r of e.steps)r.getMap().forEach((a,s,l,u)=>{let{ids:d,hasUntracked:c}=Ah(e.doc,l,u);for(let p of d)o.changedParaIds.add(p);c&&(o.hasUntrackedChanges=true);});return o}}})}function nl(e){return Oi.getState(e)}function Au(e){return nl(e)?.changedParaIds??new Set}function Du(e){return nl(e)?.structuralChange??false}function Hu(e){return nl(e)?.hasUntrackedChanges??false}function Nu(e){return e.tr.setMeta(Oi,"clear")}var Ou=ht({name:"paragraphChangeTracker",defaultOptions:{},onSchemaReady(){return {plugins:[Dh()]}}});var zu=ht({name:"bidiShortcut",priority:Xt.High,onSchemaReady(e){return {plugins:[new Plugin({props:{handleKeyDown(t,n){if(n.key!=="Shift"||!(n.metaKey||n.ctrlKey))return false;let r=Kn.getCommands();return n.code==="ShiftLeft"?(n.preventDefault(),r.setLtr()(t.state,t.dispatch),true):n.code==="ShiftRight"?(n.preventDefault(),r.setRtl()(t.state,t.dispatch),true):false}}})]}}});function $u(e){let t={},n=e.split(";");for(let o of n){let r=o.trim();if(!r)continue;let i=r.indexOf(":");if(i<0)continue;let a=r.slice(0,i).trim(),s=r.slice(i+1).trim();a&&s&&(t[a]=s);}return t}function Oh(e,t){let n=e.getAttribute("style")||"",o=$u(n);for(let[r,i]of Object.entries(t))r in o||e.style.setProperty(r,i);}function zh(e){let t=e.querySelectorAll("style");if(t.length===0)return;let n=[];for(let o of t){let r=o.textContent||"";if(r.trim())try{let i=e.createElement("style");i.textContent=r,e.head.appendChild(i);let a=i.sheet;if(a)for(let s=0;s<a.cssRules.length;s++){let l=a.cssRules[s];if(l instanceof CSSStyleRule){let u={},d=l.style;for(let c=0;c<d.length;c++){let p=d[c];u[p]=d.getPropertyValue(p);}Object.keys(u).length>0&&n.push({selector:l.selectorText,declarations:u});}}e.head.removeChild(i);}catch{let i=/([^{]+)\{([^}]+)\}/g,a;for(;(a=i.exec(r))!==null;){let s=a[1].trim(),l=$u(a[2]);Object.keys(l).length>0&&n.push({selector:s,declarations:l});}}}if(n.length!==0)for(let{selector:o,declarations:r}of n)try{let i=e.body.querySelectorAll(o);for(let a of i)Oh(a,r);}catch{}}function $h(e){let t=e.body.querySelectorAll('b[id^="docs-internal-guid-"]');for(let n of t){let o=n.parentNode;if(o){for(;n.firstChild;)o.insertBefore(n.firstChild,n);o.removeChild(n);}}}function _h(e){let t=e.includes("<style"),n=e.includes("docs-internal-guid-");if(!t&&!n)return e;try{let r=new DOMParser().parseFromString(e,"text/html");if(t){zh(r);let i=r.querySelectorAll("style");for(let a of i)a.remove();}return n&&$h(r),r.body.innerHTML}catch{return e}}var _u=ht({name:"pasteStyleInliner",priority:Xt.High,onSchemaReady(){return {plugins:[new Plugin({props:{transformPastedHTML(t){return _h(t)}}})]}}});function er(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",hd()),o("text",bd()),o("paragraph",Td()),o("history",vd({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Ed()),o("italic",Md()),o("underline",Bd()),o("strike",Ad()),o("textColor",Dd()),o("highlight",Hd()),o("fontSize",Nd()),o("fontFamily",Od()),o("superscript",zd()),o("subscript",$d()),o("hyperlink",_d()),o("allCaps",Wd()),o("smallCaps",Vd()),o("footnoteRef",Ud()),o("characterSpacing",jd()),o("emboss",qd()),o("imprint",Xd()),o("textShadow",Zd()),o("emphasisMark",Jd()),o("textOutline",Qd()),o("comment",Gd()),o("insertion",Kd()),o("deletion",Yd()),o("hardBreak",eu()),o("tab",tu()),o("image",nu()),o("textBox",ou()),o("shape",ru()),o("imageDrag",Iu()),o("imagePaste",Fu()),o("dropCursor",Lu()),o("horizontalRule",iu()),o("pageBreak",au()),o("field",su()),o("sdt",lu()),o("math",cu()),t.has("table")||n.push(...xu()),o("pasteStyleInliner",_u()),o("list",ku()),o("baseKeymap",vu()),o("selectionTracker",Pu({onSelectionChange:e.onSelectionChange})),o("paragraphChangeTracker",Ou()),o("bidiShortcut",zu()),n}var Yn=class{constructor(t){d$1(this,"extensions");d$1(this,"schema",null);d$1(this,"plugins",[]);d$1(this,"commands",{});this.extensions=[...t].sort((n,o)=>n.config.priority-o.config.priority);}buildSchema(){let t={},n={};for(let o of this.extensions)o.type==="node"?t[o.config.schemaNodeName]=o.config.nodeSpec:o.type==="mark"&&(n[o.config.schemaMarkName]=o.config.markSpec);this.schema=new Schema({nodes:t,marks:n});}initializeRuntime(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called before initializeRuntime()");let t={schema:this.schema},n=[],o=[],r={};for(let i of this.extensions){let a=i.onSchemaReady(t);a.commands&&Object.assign(r,a.commands),a.keyboardShortcuts&&n.push(a.keyboardShortcuts),a.plugins&&o.push(...a.plugins);}this.plugins=[...o,...n.map(i=>keymap(i))],this.commands=r;}getSchema(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called first");return this.schema}getPlugins(){return this.plugins}getCommands(){return this.commands}getCommand(t){return this.commands[t]}destroy(){this.plugins=[],this.commands={};}};var zi=new Yn(er());zi.buildSchema();zi.initializeRuntime();var Kn=zi,Se=zi.getSchema();var Uh={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},Mr=class{constructor(t){d$1(this,"stylesById");d$1(this,"docDefaults");d$1(this,"defaultParagraphStyle");if(this.stylesById=new Map,this.docDefaults=t?.docDefaults,t?.styles)for(let n of t.styles)n.styleId&&this.stylesById.set(n.styleId,n);this.defaultParagraphStyle=this.findDefaultStyle("paragraph");}getStyle(t){return this.stylesById.get(t)}getParagraphStyles(){let t=[];for(let n of this.stylesById.values())n.type==="paragraph"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveParagraphStyle(t){let n={};if(this.docDefaults?.pPr&&(n.paragraphFormatting={...this.docDefaults.pPr}),this.docDefaults?.rPr&&(n.runFormatting={...this.docDefaults.rPr}),!t)return this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n;let o=this.stylesById.get(t);return o?(this.mergeStyleIntoResult(n,o),n):(this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n)}getTableStyles(){let t=[];for(let n of this.stylesById.values())n.type==="table"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveRunStyle(t){let n={};if(this.docDefaults?.rPr&&(n={...this.docDefaults.rPr}),!t)return Object.keys(n).length>0?n:void 0;let o=this.stylesById.get(t);if(!o?.rPr)return Object.keys(n).length>0?n:void 0;let r=this.mergeTextFormatting(n,o.rPr);return r&&Object.keys(r).length>0?r:void 0}getRunStyleOwnProperties(t){if(!t)return;let n=this.stylesById.get(t);if(n?.rPr)return Object.keys(n.rPr).length>0?{...n.rPr}:void 0}getDocDefaults(){return this.docDefaults}getDefaultParagraphStyle(){return this.defaultParagraphStyle}hasStyle(t){return this.stylesById.has(t)}findDefaultStyle(t){for(let n of this.stylesById.values())if(n.type===t&&n.default)return n;if(t==="paragraph")return this.stylesById.get("Normal")??Uh}mergeStyleIntoResult(t,n){n.pPr&&(t.paragraphFormatting=this.mergeParagraphFormatting(t.paragraphFormatting,n.pPr)),n.rPr&&(t.runFormatting=this.mergeTextFormatting(t.runFormatting,n.rPr));}mergeParagraphFormatting(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let o={...t};for(let r of Object.keys(n)){let i=n[r];if(i!==void 0)if(r==="runProperties")o.runProperties=this.mergeTextFormatting(o.runProperties,n.runProperties);else if(r==="borders"||r==="numPr"||r==="frame"){let a=o[r],s=i;o[r]={...a||{},...s||{}};}else r==="tabs"&&Array.isArray(i)?o.tabs=[...i]:o[r]=i;}return o}mergeTextFormatting(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let o={...t};for(let r of Object.keys(n)){let i=n[r];i!==void 0&&(typeof i=="object"&&i!==null?o[r]={...o[r]||{},...i}:o[r]=i);}return o}};function wo(e){return new Mr(e)}function ol(e,t){let n=e.package.document.content,o=[],r=t?.styles?wo(t.styles):null;for(let i of n)if(i.type==="paragraph")o.push(...Wu(i,r)),rb(i)&&o.push(Se.node("pageBreak"));else if(i.type==="table"){let a=il(i,r);o.push(a);}return o.length===0&&o.push(Se.node("paragraph",{},[])),Se.node("doc",null,o)}function rl(e,t,n,o){let r=Gh(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=xn(l,o);for(let d of e.content){if(d.type==="commentRangeStart")s.add(d.id);else if(d.type==="commentRangeEnd")s.delete(d.id);else if(d.type==="run"){let c=al(d,u,t);s.size>0&&(c=jh(c,s)),i.push(...c);}else if(d.type==="hyperlink"){let c=sl(d,u,t);i.push(...c);}else if(d.type==="simpleField"||d.type==="complexField"){let c=Xh(d,u);c&&i.push(c);}else if(d.type==="inlineSdt"){let c=Jh(d,u,t);c&&i.push(c);}else if(d.type==="insertion"){let c=$i(d,"insertion",u,t);i.push(...c);}else if(d.type==="deletion"){let c=$i(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveFrom"){let c=$i(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveTo"){let c=$i(d,"insertion",u,t);i.push(...c);}else if(d.type==="mathEquation"){let c=Zh(d);c&&i.push(c);}d.type==="bookmarkStart"&&(a||(a=[]),a.push({id:d.id,name:d.name}));}return a&&(r.bookmarks=a),Se.node("paragraph",r,i)}function jh(e,t){if(t.size===0)return e;let n=[...t][0],o=Se.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function $i(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...al(a,n,o)):a.type==="hyperlink"&&r.push(...sl(a,n,o));let i=Se.marks[t].create({revisionId:e.info.id,author:e.info.author,date:e.info.date??null});return r.map(a=>a.isText?a.mark(i.addToSet(a.marks)):a)}function Gh(e,t){let n=e.formatting,o=n?.styleId,r={paraId:e.paraId??void 0,textId:e.textId??void 0,styleId:o,numPr:n?.numPr,listNumFmt:e.listRendering?.numFmt,listIsBullet:e.listRendering?.isBullet,listMarker:e.listRendering?.marker,listMarkerHidden:e.listRendering?.markerHidden||void 0,listMarkerFontFamily:e.listRendering?.markerFontFamily||void 0,listMarkerFontSize:e.listRendering?.markerFontSize||void 0,_originalFormatting:n||void 0};if(t){let i=t.resolveParagraphStyle(o),a=i.paragraphFormatting,s=i.runFormatting;r.alignment=n?.alignment??a?.alignment,r.spaceBefore=n?.spaceBefore??a?.spaceBefore,r.spaceAfter=n?.spaceAfter??a?.spaceAfter,r.lineSpacing=n?.lineSpacing??a?.lineSpacing,r.lineSpacingRule=n?.lineSpacingRule??a?.lineSpacingRule,r.indentLeft=n?.indentLeft??a?.indentLeft,r.indentRight=n?.indentRight??a?.indentRight,r.indentFirstLine=n?.indentFirstLine??a?.indentFirstLine,r.hangingIndent=n?.hangingIndent??a?.hangingIndent,r.borders=n?.borders??a?.borders,r.shading=n?.shading??a?.shading,r.tabs=n?.tabs??a?.tabs,r.pageBreakBefore=n?.pageBreakBefore??a?.pageBreakBefore,r.keepNext=n?.keepNext??a?.keepNext,r.keepLines=n?.keepLines??a?.keepLines,r.contextualSpacing=n?.contextualSpacing??a?.contextualSpacing,r.outlineLevel=n?.outlineLevel??a?.outlineLevel,r.bidi=n?.bidi??a?.bidi;let l=_i(n?.runProperties,t);r.defaultTextFormatting=xn(s,l),!n?.numPr&&a?.numPr&&a.numPr.numId!==0&&(r.numPr=a.numPr);}else r.alignment=n?.alignment,r.spaceBefore=n?.spaceBefore,r.spaceAfter=n?.spaceAfter,r.lineSpacing=n?.lineSpacing,r.lineSpacingRule=n?.lineSpacingRule,r.indentLeft=n?.indentLeft,r.indentRight=n?.indentRight,r.indentFirstLine=n?.indentFirstLine,r.hangingIndent=n?.hangingIndent,r.borders=n?.borders,r.shading=n?.shading,r.tabs=n?.tabs,r.pageBreakBefore=n?.pageBreakBefore,r.keepNext=n?.keepNext,r.keepLines=n?.keepLines,r.outlineLevel=n?.outlineLevel,r.bidi=n?.bidi,r.defaultTextFormatting=_i(n?.runProperties,t);if(e.sectionProperties){r._sectionProperties=e.sectionProperties;let i=e.sectionProperties.sectionStart;(i==="nextPage"||i==="continuous"||i==="oddPage"||i==="evenPage")&&(r.sectionBreakType=i);}return r}function Gt(e,t,n){if(!e||!t)return;let o=e.getStyle(t);if(!o?.tblStylePr)return;let r=o.tblStylePr.find(l=>l.type===n);if(!r)return;let i=_i(r.pPr?.runProperties,e),a=_i(r.rPr,e),s=xn(i,a);return {tcPr:r.tcPr,rPr:s}}function yn(e,t){if(!e&&!t)return;if(!e)return t;if(!t)return e;let n={},o=e.tcPr,r=t.tcPr;if(o||r){let i={...o??{},...r??{}};(o?.borders||r?.borders)&&(i.borders={...o?.borders??{},...r?.borders??{}}),(o?.shading||r?.shading)&&(i.shading={...o?.shading??{},...r?.shading??{}}),(o?.margins||r?.margins)&&(i.margins={...o?.margins??{},...r?.margins??{}}),n.tcPr=i;}return n.rPr=xn(e.rPr,t.rPr),n}function _i(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return xn(n,e)}function Kh(e){let t=new Map,n=e.rows.length,o=new Map;for(let r=0;r<n;r++){let i=e.rows[r],a=0;for(let s=0;s<i.cells.length;s++){let l=i.cells[s],u=l.formatting?.gridSpan??1,d=l.formatting?.vMerge,c=`${r}-${a}`;if(d==="restart")o.set(a,r),t.set(c,{rowSpan:1,skip:false});else if(d==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(c,{rowSpan:1,skip:true});}else o.delete(a),t.set(c,{rowSpan:1,skip:false});a+=u;}}return t}function il(e,t){let n=Kh(e),o=e.columnWidths,r=o?.reduce((S,B)=>S+B,0)??0,i=e.formatting?.styleId,a=e.formatting?.look,s=i?t?.getStyle(i):void 0,l=e.formatting?.borders??s?.tblPr?.borders,u=e.formatting?.cellMargins??s?.tblPr?.cellMargins??void 0,d=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,c={styleId:e.formatting?.styleId,width:e.formatting?.width?.value,widthType:e.formatting?.width?.type,justification:e.formatting?.justification,columnWidths:o,floating:e.formatting?.floating,cellMargins:d,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Gt(t,i,"wholeTable"),firstRow:Gt(t,i,"firstRow"),lastRow:Gt(t,i,"lastRow"),firstCol:Gt(t,i,"firstCol"),lastCol:Gt(t,i,"lastCol"),band1Horz:Gt(t,i,"band1Horz"),band2Horz:Gt(t,i,"band2Horz"),band1Vert:Gt(t,i,"band1Vert"),band2Vert:Gt(t,i,"band2Vert"),nwCell:Gt(t,i,"nwCell"),neCell:Gt(t,i,"neCell"),swCell:Gt(t,i,"swCell"),seCell:Gt(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,g=e.rows.length,x=o?.length??e.rows[0]?.cells.reduce((S,B)=>S+(B.formatting?.gridSpan??1),0)??0,k=e.rows.map((S,B)=>{let w=B===0&&!!a?.firstRow,E=B===g-1&&!!a?.lastRow,P=f&&!w&&!E?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!w&&!E&&b++,Yh(S,t,w,o,r,p,P,m,a,l,B,g,x,n,d)});return Se.node("table",c,k)}function Yh(e,t,n,o,r,i,a,s,l,u,d,c,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header,_originalFormatting:e.formatting||void 0},g=e.cells.length,x=d===0,k=d===(c??1)-1,S=e.formatting?.conditionalFormat,B=S?.firstRow??x,w=S?.lastRow??k,E=p??g,P=0,z=[];for(let I=0;I<e.cells.length;I++){let A=e.cells[I],Z=A.formatting?.gridSpan??1,ce=`${d??0}-${P}`,ae=f?.get(ce),$=ae?.skip??false,H=ae?.rowSpan??1,de;if(o&&r&&r>0){let Y=0;for(let se=0;se<Z&&P+se<o.length;se++)Y+=o[P+se];de=Math.round(Y/r*100);}if(P+=Z,$)continue;let me=P-Z===0,ue=P===E,N=A.formatting?.conditionalFormat,Ve=N?.firstRow??B,R=N?.lastRow??w,F=N?.firstColumn??me,C=N?.lastColumn??ue,M;if(s){let Y=l?.firstColumn?1:0,se=P-Z-Y;se>=0&&!(l?.lastColumn&&C)&&!(l?.firstColumn&&F)&&(M=se%2===0?i?.band1Vert:i?.band2Vert);}N?.oddVBand?M=i?.band1Vert:N?.evenVBand&&(M=i?.band2Vert);let L=a;S?.oddHBand?L=i?.band1Horz:S?.evenHBand&&(L=i?.band2Horz),N?.oddHBand?L=i?.band1Horz:N?.evenHBand&&(L=i?.band2Horz);let D=i?.wholeTable;D=yn(D,L),D=yn(D,M),Ve&&(l?.firstRow||S?.firstRow||N?.firstRow)&&(D=yn(D,i?.firstRow)),R&&(l?.lastRow||S?.lastRow||N?.lastRow)&&(D=yn(D,i?.lastRow)),F&&(l?.firstColumn||S?.firstColumn||N?.firstColumn)&&(D=yn(D,i?.firstCol)),C&&(l?.lastColumn||S?.lastColumn||N?.lastColumn)&&(D=yn(D,i?.lastCol)),Ve&&F&&(l?.firstRow||S?.firstRow||N?.firstRow)&&(l?.firstColumn||S?.firstColumn||N?.firstColumn)&&(D=yn(D,i?.nwCell)),Ve&&C&&(l?.firstRow||S?.firstRow||N?.firstRow)&&(l?.lastColumn||S?.lastColumn||N?.lastColumn)&&(D=yn(D,i?.neCell)),R&&F&&(l?.lastRow||S?.lastRow||N?.lastRow)&&(l?.firstColumn||S?.firstColumn||N?.firstColumn)&&(D=yn(D,i?.swCell)),R&&C&&(l?.lastRow||S?.lastRow||N?.lastRow)&&(l?.lastColumn||S?.lastColumn||N?.lastColumn)&&(D=yn(D,i?.seCell)),z.push(qh(A,t,n,de,D,u,x,k,me,ue,H,m));}return Se.node("tableRow",b,z)}function qh(e,t,n,o,r,i,a,s,l,u,d,c){let p=e.formatting,f=d??1,m=p?.width?.value,b=p?.width?.type;m===void 0&&o!==void 0&&(m=o,b="pct");let g=p?.shading?.fill?.rgb??r?.tcPr?.shading?.fill?.rgb,x=i?{top:a?i.top:i.insideH,bottom:s?i.bottom:i.insideH,left:l?i.left:i.insideV,right:u?i.right:i.insideV}:void 0,k=r?.tcPr?.borders,S=p?.borders,B=x||k||S?{...x??{},...k??{},...S??{}}:void 0,w={colspan:p?.gridSpan??1,rowspan:f,width:m,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:g,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:B,margins:p?.margins?{top:p.margins.top?.value,bottom:p.margins.bottom?.value,left:p.margins.left?.value,right:p.margins.right?.value}:r?.tcPr?.margins?{top:r.tcPr.margins.top?.value,bottom:r.tcPr.margins.bottom?.value,left:r.tcPr.margins.left?.value,right:r.tcPr.margins.right?.value}:c,_originalFormatting:p||void 0},E=[];for(let z of e.content)z.type==="paragraph"?E.push(rl(z,t,void 0,r?.rPr)):z.type==="table"&&E.push(il(z,t));E.length===0&&E.push(Se.node("paragraph",{},[]));let P=n?"tableHeader":"tableCell";return Se.node(P,w,E)}function Xh(e,t){let n="",o,r=e.type==="simpleField"?e.content:e.fieldResult;if(r){for(let s of r)if(s.type==="run"){for(let l of s.content)l.type==="text"&&(n+=l.text);!o&&s.formatting&&(o=s.formatting);}}let i=xn(t,o),a=ll(i);return Se.node("field",{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false},void 0,a)}function Zh(e){return Se.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Jh(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=al(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=sl(i,t,n);r.push(...a);}return Se.node("sdt",{sdtType:o.sdtType,alias:o.alias??null,tag:o.tag??null,lock:o.lock??null,placeholder:o.placeholder??null,showingPlaceholder:o.showingPlaceholder??false,dateFormat:o.dateFormat??null,listItems:o.listItems?JSON.stringify(o.listItems):null,checked:o.checked??null},r.length>0?r:void 0)}function al(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=xn(xn(t,r),e.formatting),a=ll(i);for(let s of e.content){let l=Qh(s,a);o.push(...l);}return o}function xn(e,t){if(!t&&!e)return;if(!t)return e;if(!e)return t;let n={...e};if(t.bold!==void 0&&(n.bold=t.bold),t.italic!==void 0&&(n.italic=t.italic),t.underline!==void 0&&(n.underline=t.underline),t.strike!==void 0&&(n.strike=t.strike),t.doubleStrike!==void 0&&(n.doubleStrike=t.doubleStrike),t.color!==void 0){let o=t.color.rgb||t.color.themeColor||t.color.themeTint||t.color.themeShade;(!t.color.auto||o)&&(n.color=t.color);}return t.highlight!==void 0&&(n.highlight=t.highlight),t.fontSize!==void 0&&(n.fontSize=t.fontSize),t.fontFamily!==void 0&&(n.fontFamily=t.fontFamily),t.vertAlign!==void 0&&(n.vertAlign=t.vertAlign),t.allCaps!==void 0&&(n.allCaps=t.allCaps),t.smallCaps!==void 0&&(n.smallCaps=t.smallCaps),n}function Qh(e,t){switch(e.type){case "text":return e.text?[Se.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[Se.node("hardBreak")]:[];case "tab":return [Se.node("tab")];case "drawing":return e.image?[eb(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[tb(r)]}case "footnoteRef":let n=Se.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [Se.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=Se.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [Se.text(e.id.toString(),[...t,o])];default:return []}}function eb(e){let t=e.size?.width?c$2(e.size.width):void 0,n=e.size?.height?c$2(e.size.height):void 0,o=e.wrap.type,r=e.wrap.wrapText,i=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?r==="left"?a="right":r==="right"||i==="left"?a="left":i==="right"?a="right":a="none":a="none";let s="inline";o==="inline"?s="inline":a&&a!=="none"?s="float":s="block";let l;if(e.transform){let x=[];e.transform.rotation&&x.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&x.push("scaleX(-1)"),e.transform.flipV&&x.push("scaleY(-1)"),x.length>0&&(l=x.join(" "));}let u=e.wrap.distT?c$2(e.wrap.distT):void 0,d=e.wrap.distB?c$2(e.wrap.distB):void 0,c=e.wrap.distL?c$2(e.wrap.distL):void 0,p=e.wrap.distR?c$2(e.wrap.distR):void 0,f;e.position&&(f={horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0});let m,b,g;if(e.outline&&e.outline.width){m=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(b=`#${e.outline.color.rgb}`);let x={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};g=e.outline.style&&x[e.outline.style]||"solid";}return Se.node("image",{src:e.src||"",alt:e.alt,title:e.title,width:t,height:n,rId:e.rId,wrapType:o,displayMode:s,cssFloat:a,transform:l,distTop:u,distBottom:d,distLeft:c,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:g,wrapText:r,hlinkHref:e.hlinkHref})}function sl(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=Se.mark("hyperlink",{href:r,tooltip:e.tooltip,rId:e.rId});for(let a of e.children)if(a.type==="run"){let s=a.formatting?.styleId?n?.resolveRunStyle(a.formatting.styleId):void 0,l=xn(xn(t,s),a.formatting),d=[...ll(l),i];for(let c of a.content)c.type==="text"&&c.text&&o.push(Se.text(c.text,d));}return o}function ll(e){if(!e)return [];let t=[];return e.bold&&t.push(Se.mark("bold")),e.italic&&t.push(Se.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(Se.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(Se.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(Se.mark("textColor",{rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&e.highlight!=="none"&&t.push(Se.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(Se.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(Se.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,eastAsia:e.fontFamily.eastAsia,cs:e.fontFamily.cs,asciiTheme:e.fontFamily.asciiTheme,hAnsiTheme:e.fontFamily.hAnsiTheme,eastAsiaTheme:e.fontFamily.eastAsiaTheme,csTheme:e.fontFamily.csTheme})),e.vertAlign==="superscript"?t.push(Se.mark("superscript")):e.vertAlign==="subscript"&&t.push(Se.mark("subscript")),e.allCaps&&t.push(Se.mark("allCaps")),e.smallCaps&&t.push(Se.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(Se.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(Se.mark("emboss")),e.imprint&&t.push(Se.mark("imprint")),e.shadow&&t.push(Se.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(Se.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(Se.mark("textOutline")),t}function tb(e){let t=e.size?.width?c$2(e.size.width):100,n=e.size?.height?c$2(e.size.height):80,o,r="solid",i,a,s;if(e.fill&&(r=e.fill.type,e.fill.color?.rgb&&(o=`#${e.fill.color.rgb}`),e.fill.type==="gradient"&&e.fill.gradient)){let p=e.fill.gradient;i=p.type,a=p.angle,s=JSON.stringify(p.stops.map(f=>({position:f.position,color:f.color.rgb?`#${f.color.rgb}`:"#000000"})));}let l,u,d;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),d=e.outline.style||"solid");let c;if(e.transform){let p=[];e.transform.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&p.push("scaleX(-1)"),e.transform.flipV&&p.push("scaleY(-1)"),p.length>0&&(c=p.join(" "));}return Se.node("shape",{shapeType:e.shapeType||"rect",shapeId:e.id,width:t,height:n,fillColor:o,fillType:r,gradientType:i,gradientAngle:a,gradientStops:s,outlineWidth:l,outlineColor:u,outlineStyle:d,transform:c})}function Wu(e,t){let n=nb(e),o=rl(e,t),r=[];n.length>0&&o.content.size===0||r.push(o);for(let a of n)r.push(ob(a,t));return r}function nb(e){let t=[];for(let n of e.content)if(n.type==="run"){for(let o of n.content)if(o.type==="shape"&&"shape"in o){let r=o.shape;r.textBody&&r.textBody.content.length>0&&t.push({type:"textBox",id:r.id,size:r.size,position:r.position,wrap:r.wrap,fill:r.fill,outline:r.outline,content:r.textBody.content,margins:r.textBody.margins});}}return t}function ob(e,t){let n=e.size?.width?c$2(e.size.width):200,o=e.size?.height?c$2(e.size.height):void 0,r;e.fill?.color?.rgb&&(r=`#${e.fill.color.rgb}`);let i,a,s;e.outline&&e.outline.width&&(i=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(a=`#${e.outline.color.rgb}`),s=e.outline.style||"solid");let l=e.margins?.top!=null?c$2(e.margins.top):4,u=e.margins?.bottom!=null?c$2(e.margins.bottom):4,d=e.margins?.left!=null?c$2(e.margins.left):7,c=e.margins?.right!=null?c$2(e.margins.right):7,p=[];for(let f of e.content)p.push(rl(f,t));return p.length===0&&p.push(Se.node("paragraph",{},[])),Se.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:d,marginRight:c},p)}function cl(e,t){let n=[],o=t?.styles?wo(t.styles):null;for(let r of e)r.type==="paragraph"?n.push(...Wu(r,o)):r.type==="table"&&n.push(il(r,o));return n.length===0&&n.push(Se.node("paragraph",{},[])),Se.node("doc",null,n)}function rb(e){for(let t of e.content)if(t.type==="run"){for(let n of t.content)if(n.type==="break"&&n.breakType==="page")return true}return false}function dl(){return Se.node("doc",null,[Se.node("paragraph",{},[])])}function Uu(e,t){let o={content:ju(e),finalSectionProperties:t?.package.document.finalSectionProperties,sections:t?.package.document.sections,comments:t?.package.document.comments};return t?{...t,package:{...t.package,document:o}}:{package:{document:o}}}function ju(e){let t=[],n=Ku(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push(ul(o,n)):o.type.name==="table"?t.push(qu(o,n)):o.type.name==="textBox"?t.push(vb(o)):o.type.name==="pageBreak"&&t.push(ib());}),t}function ib(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function ul(e,t){let n=e.attrs,o=ab(Gu(e,t),e),r=n.bookmarks;if(r&&r.length>0){let a=r.map(l=>({type:"bookmarkStart",id:l.id,name:l.name})),s=r.map(l=>({type:"bookmarkEnd",id:l.id}));o=[...a,...o,...s];}let i={type:"paragraph",paraId:n.paraId||void 0,textId:n.textId||void 0,formatting:sb(n),content:o};return n._sectionProperties?i.sectionProperties=n._sectionProperties:n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function ab(e,t){let n=new Set;if(t.forEach(a=>{for(let s of a.marks)s.type.name==="comment"&&n.add(s.attrs.commentId);}),n.size===0)return e;let o=[],r=new Set,i=0;t.forEach(a=>{let s=new Set;for(let l of a.marks)l.type.name==="comment"&&s.add(l.attrs.commentId);for(let l of [...r])s.has(l)||(o.push({type:"commentRangeEnd",id:l}),r.delete(l));for(let l of s)r.has(l)||(o.push({type:"commentRangeStart",id:l}),r.add(l));i<e.length&&o.push(e[i]),i++;});for(let a of r)o.push({type:"commentRangeEnd",id:a});return o}function sb(e){if(e._originalFormatting){let n=e._originalFormatting,o={...n};return e.alignment!==(n.alignment||void 0)&&(o.alignment=e.alignment||void 0),e.numPr!==n.numPr&&JSON.stringify(e.numPr)!==JSON.stringify(n.numPr)&&(o.numPr=e.numPr||void 0),e.styleId!==(n.styleId||void 0)&&(o.styleId=e.styleId||void 0),e.pageBreakBefore!==(n.pageBreakBefore||void 0)&&(o.pageBreakBefore=e.pageBreakBefore||void 0),e.bidi!==(n.bidi||void 0)&&(o.bidi=e.bidi||void 0),o}if(e.alignment||e.spaceBefore||e.spaceAfter||e.lineSpacing||e.indentLeft||e.indentRight||e.indentFirstLine||e.numPr||e.styleId||e.borders||e.shading||e.tabs||e.outlineLevel!=null||e.contextualSpacing||e.bidi)return {alignment:e.alignment||void 0,spaceBefore:e.spaceBefore||void 0,spaceAfter:e.spaceAfter||void 0,lineSpacing:e.lineSpacing||void 0,lineSpacingRule:e.lineSpacingRule||void 0,indentLeft:e.indentLeft||void 0,indentRight:e.indentRight||void 0,indentFirstLine:e.indentFirstLine||void 0,hangingIndent:e.hangingIndent||void 0,numPr:e.numPr||void 0,styleId:e.styleId||void 0,borders:e.borders||void 0,shading:e.shading||void 0,tabs:e.tabs||void 0,outlineLevel:e.outlineLevel??void 0,contextualSpacing:e.contextualSpacing||void 0,bidi:e.bidi||void 0}}function Gu(e,t){let n=[],o=t??Ku(e),r=null,i=null,a=null;return e.forEach(s=>{let l=s.marks.find(p=>p.type.name==="footnoteRef");if(l){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let f={type:l.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(l.attrs.id,10)||0};n.push({type:"run",content:[f]});return}let u=s.marks.find(p=>p.type.name==="insertion"),d=s.marks.find(p=>p.type.name==="deletion");if(u||d){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let p=u||d,f=s.marks.filter(w=>w.type.name!=="insertion"&&w.type.name!=="deletion"),m=pl(f),b={type:"run",content:s.isText&&s.text?[{type:"text",text:s.text}]:[],...Object.keys(m).length>0?{formatting:m}:{}},g={id:p.attrs.revisionId,author:p.attrs.author||"Unknown",date:p.attrs.date||void 0},x=g.id,k=(o.insertionById.get(x)??0)>0,S=(o.deletionById.get(x)??0)>0,B=k&&S;u?B?n.push({type:"moveTo",info:g,content:[b]}):n.push({type:"insertion",info:g,content:[b]}):B?n.push({type:"moveFrom",info:g,content:[b]}):n.push({type:"deletion",info:g,content:[b]});return}let c=s.marks.find(p=>p.type.name==="hyperlink");if(c){let p=lb(c),f=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&f===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=db(c)),Vu(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=cb(s.marks);r&&i===p?ub(r,s.text||""):(r&&n.push(r),r=Yu(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(pb())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(bb(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push(yb(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(fb())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(mb(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(hb(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(gb(s)));}),r&&n.push(r),a&&n.push(a),n}function Ku(e){let t=new Map,n=new Map;return e.descendants(o=>{let r=o.marks.find(a=>a.type.name==="insertion"),i=o.marks.find(a=>a.type.name==="deletion");if(r){let a=Number(r.attrs.revisionId);Number.isFinite(a)&&t.set(a,(t.get(a)??0)+1);}if(i){let a=Number(i.attrs.revisionId);Number.isFinite(a)&&n.set(a,(n.get(a)??0)+1);}}),{insertionById:t,deletionById:n}}function lb(e){return e.attrs.href||""}function cb(e){let t=e.filter(n=>n.type.name!=="hyperlink");return t.length===0?"":t.map(n=>`${n.type.name}:${JSON.stringify(n.attrs)}`).sort().join("|")}function db(e){let t=e.attrs.href;return t?.startsWith("#")?{type:"hyperlink",anchor:t.substring(1),tooltip:e.attrs.tooltip||void 0,children:[]}:{type:"hyperlink",href:t,tooltip:e.attrs.tooltip||void 0,rId:e.attrs.rId||void 0,children:[]}}function Vu(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=Yu(t.text,n);e.children.push(o);}}function Yu(e,t){let n=pl(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function ub(e,t){let n=e.content[e.content.length-1];n&&n.type==="text"?n.text+=t:e.content.push({type:"text",text:t});}function pb(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function fb(){return {type:"run",content:[{type:"tab"}]}}function mb(e,t){let n=e.attrs,o=t&&t.length>0?pl(t):void 0,r=n.displayText||"";if(!r)switch(n.fieldType){case "PAGE":r="1";break;case "NUMPAGES":r="1";break;default:r=" ";break}let i={type:"run",content:[{type:"text",text:r}],...o&&Object.keys(o).length>0?{formatting:o}:{}};return n.fieldKind==="complex"?{type:"complexField",instruction:n.instruction,fieldType:n.fieldType,fieldCode:[],fieldResult:[i],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}:{type:"simpleField",instruction:n.instruction,fieldType:n.fieldType,content:[i],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}}function gb(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function hb(e){let t=e.attrs,n={sdtType:t.sdtType??"richText",alias:t.alias??void 0,tag:t.tag??void 0,lock:t.lock??void 0,placeholder:t.placeholder??void 0,showingPlaceholder:t.showingPlaceholder??void 0,dateFormat:t.dateFormat??void 0,listItems:t.listItems?JSON.parse(t.listItems):void 0,checked:t.checked!=null?t.checked:void 0},r=Gu(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function bb(e){let t=e.attrs,n=t.wrapType||"inline",o=914400/96,r={type:n};t.distTop!==void 0&&(r.distT=Math.round(t.distTop*o)),t.distBottom!==void 0&&(r.distB=Math.round(t.distBottom*o)),t.distLeft!==void 0&&(r.distL=Math.round(t.distLeft*o)),t.distRight!==void 0&&(r.distR=Math.round(t.distRight*o)),t.wrapText&&(r.wrapText=t.wrapText);let i={type:"image",rId:t.rId||"",src:t.src,alt:t.alt||void 0,title:t.title||void 0,size:{width:d$3(t.width||0),height:d$3(t.height||0)},wrap:r};if(t.transform){let s=t.transform,l={},u=s.match(/rotate\(([-\d.]+)deg\)/);u&&(l.rotation=parseFloat(u[1])),s.includes("scaleX(-1)")&&(l.flipH=true),s.includes("scaleY(-1)")&&(l.flipV=true),(l.rotation||l.flipH||l.flipV)&&(i.transform=l);}if(t.position?.horizontal&&t.position?.vertical){let s=t.position;i.position={horizontal:{relativeTo:s.horizontal.relativeTo||"column",alignment:s.horizontal.align,posOffset:s.horizontal.posOffset},vertical:{relativeTo:s.vertical.relativeTo||"paragraph",alignment:s.vertical.align,posOffset:s.vertical.posOffset}};}if(t.borderWidth&&t.borderWidth>0){let s={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};i.outline={width:Math.round(t.borderWidth*(914400/96)),color:t.borderColor?{rgb:t.borderColor.replace("#","")}:void 0,style:t.borderStyle&&s[t.borderStyle]||"solid"};}return t.hlinkHref&&(i.hlinkHref=t.hlinkHref),{type:"run",content:[{type:"drawing",image:i}]}}function yb(e){let t=e.attrs,n={type:"shape",shapeType:t.shapeType||"rect",id:t.shapeId||void 0,size:{width:t.width?Math.round(t.width*(914400/96)):0,height:t.height?Math.round(t.height*(914400/96)):0}};if(t.fillType==="gradient"&&t.gradientStops)try{let r=JSON.parse(t.gradientStops);n.fill={type:"gradient",gradient:{type:t.gradientType||"linear",angle:t.gradientAngle||void 0,stops:r.map(i=>({position:i.position,color:{rgb:i.color.replace("#","")}}))}};}catch{n.fill={type:"solid",color:{rgb:(t.fillColor||"000000").replace("#","")}};}else t.fillColor?n.fill={type:t.fillType||"solid",color:{rgb:t.fillColor.replace("#","")}}:t.fillType==="none"&&(n.fill={type:"none"});if(t.outlineWidth&&t.outlineWidth>0){let r={solid:"solid",dotted:"dot",dashed:"dash"};n.outline={width:Math.round(t.outlineWidth*(914400/96)),color:t.outlineColor?{rgb:t.outlineColor.replace("#","")}:void 0,style:t.outlineStyle&&r[t.outlineStyle]||"solid"};}return {type:"run",content:[{type:"shape",shape:n}]}}function pl(e){let t={};for(let n of e)switch(n.type.name){case "bold":t.bold=true,t.boldCs=true;break;case "italic":t.italic=true,t.italicCs=true;break;case "underline":{let o=n.attrs;t.underline={style:o.style||"single",color:o.color};break}case "strike":n.attrs.double?t.doubleStrike=true:t.strike=true;break;case "textColor":{let o=n.attrs;t.color={rgb:o.rgb,themeColor:o.themeColor,themeTint:o.themeTint,themeShade:o.themeShade};break}case "highlight":t.highlight=n.attrs.color;break;case "fontSize":t.fontSize=n.attrs.size,t.fontSizeCs=n.attrs.size;break;case "fontFamily":{let o=n.attrs;t.fontFamily={ascii:o.ascii,hAnsi:o.hAnsi,eastAsia:o.eastAsia||void 0,cs:o.cs||o.ascii||void 0,asciiTheme:o.asciiTheme,hAnsiTheme:o.hAnsiTheme||void 0,eastAsiaTheme:o.eastAsiaTheme||void 0,csTheme:o.csTheme||void 0};break}case "superscript":t.vertAlign="superscript";break;case "subscript":t.vertAlign="subscript";break;case "allCaps":t.allCaps=true;break;case "smallCaps":t.smallCaps=true;break;case "characterSpacing":{n.attrs.spacing!=null&&(t.spacing=n.attrs.spacing),n.attrs.position!=null&&(t.position=n.attrs.position),n.attrs.scale!=null&&(t.scale=n.attrs.scale),n.attrs.kerning!=null&&(t.kerning=n.attrs.kerning);break}case "emboss":t.emboss=true;break;case "imprint":t.imprint=true;break;case "textShadow":t.shadow=true;break;case "emphasisMark":t.emphasisMark=n.attrs.type||"dot";break;case "textOutline":t.outline=true;break}return t}function xb(e){for(let t of e)for(let n of t.cells){let o=n.formatting?.borders;if(o){let r=o.top||o.left||o.right||o.bottom||o.insideH||o.insideV;return r?{top:o.top??r,bottom:o.bottom??r,left:o.left??r,right:o.right??r,insideH:o.insideH??o.bottom??r,insideV:o.insideV??o.right??r}:void 0}}}function qu(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(kb(i,t));});let r=Sb(n)||void 0;if(!r?.borders){let i=xb(o);if(i)if(r)r.borders=i;else return {type:"table",columnWidths:n.columnWidths||void 0,formatting:{borders:i},rows:o}}return {type:"table",columnWidths:n.columnWidths||void 0,formatting:r,rows:o}}function Sb(e){if(e._originalFormatting){let r=e._originalFormatting,i={...r};e.styleId!==(r.styleId||void 0)&&(i.styleId=e.styleId||void 0),e.justification!==(r.justification||void 0)&&(i.justification=e.justification||void 0),e.floating!==(r.floating||void 0)&&(i.floating=e.floating||void 0),e.look!==(r.look||void 0)&&(i.look=e.look||void 0);let a=r.width?.value,s=r.width?.type;return (e.width!==a||e.widthType!==s)&&(e.width!=null||e.widthType?i.width={value:e.width??0,type:e.widthType||"dxa"}:i.width=void 0),e.cellMargins&&(i.cellMargins={top:e.cellMargins.top!=null?{value:e.cellMargins.top,type:"dxa"}:void 0,bottom:e.cellMargins.bottom!=null?{value:e.cellMargins.bottom,type:"dxa"}:void 0,left:e.cellMargins.left!=null?{value:e.cellMargins.left,type:"dxa"}:void 0,right:e.cellMargins.right!=null?{value:e.cellMargins.right,type:"dxa"}:void 0}),i}if(!(e.styleId||e.width!=null||e.widthType||e.justification||e.floating||e.cellMargins||e.look))return;let n=e.cellMargins?{top:e.cellMargins.top!=null?{value:e.cellMargins.top,type:"dxa"}:void 0,bottom:e.cellMargins.bottom!=null?{value:e.cellMargins.bottom,type:"dxa"}:void 0,left:e.cellMargins.left!=null?{value:e.cellMargins.left,type:"dxa"}:void 0,right:e.cellMargins.right!=null?{value:e.cellMargins.right,type:"dxa"}:void 0}:void 0,o;return (e.width!=null||e.widthType)&&(o={value:e.width??0,type:e.widthType||"dxa"}),{styleId:e.styleId||void 0,width:o,justification:e.justification||void 0,floating:e.floating||void 0,cellMargins:n,look:e.look||void 0}}function kb(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push(Tb(r,t));}),{type:"tableRow",formatting:Cb(n),cells:o}}function Cb(e){if(e._originalFormatting){let n=e._originalFormatting,o={...n};return e.height!==(n.height?.value||void 0)&&(o.height=e.height?{value:e.height,type:"dxa"}:void 0),e.heightRule!==(n.heightRule||void 0)&&(o.heightRule=e.heightRule||void 0),e.isHeader!==(n.header||void 0)&&(o.header=e.isHeader||void 0),o}if(e.height||e.isHeader)return {height:e.height?{value:e.height,type:"dxa"}:void 0,heightRule:e.heightRule||void 0,header:e.isHeader||void 0}}function Tb(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push(ul(r,t)):r.type.name==="table"&&o.push(qu(r,t));}),{type:"tableCell",formatting:wb(n),content:o}}function wb(e){if(e._originalFormatting){let o=e._originalFormatting,r={...o};if(e.colspan>1&&(r.gridSpan=e.colspan),e.width!=null&&(r.width={value:e.width,type:e.widthType||"dxa"}),e.verticalAlign!==(o.verticalAlign||void 0)&&(r.verticalAlign=e.verticalAlign||void 0),e.backgroundColor?r.shading={fill:{rgb:e.backgroundColor}}:!e.backgroundColor&&o.shading&&(r.shading=void 0),e.borders&&(r.borders=e.borders),e.margins){let i=e.margins,a={};i.top!=null&&(a.top={value:i.top,type:"dxa"}),i.bottom!=null&&(a.bottom={value:i.bottom,type:"dxa"}),i.left!=null&&(a.left={value:i.left,type:"dxa"}),i.right!=null&&(a.right={value:i.right,type:"dxa"}),r.margins=a;}return e.textDirection!==(o.textDirection||void 0)&&(r.textDirection=e.textDirection||void 0),r}if(!(e.colspan>1||e.rowspan>1||e.width!=null||e.verticalAlign||e.backgroundColor||e.borders||e.margins||e.textDirection))return;let n;if(e.margins){let o=e.margins;n={},o.top!=null&&(n.top={value:o.top,type:"dxa"}),o.bottom!=null&&(n.bottom={value:o.bottom,type:"dxa"}),o.left!=null&&(n.left={value:o.left,type:"dxa"}),o.right!=null&&(n.right={value:o.right,type:"dxa"});}return {gridSpan:e.colspan>1?e.colspan:void 0,width:e.width!=null?{value:e.width,type:e.widthType||"dxa"}:void 0,verticalAlign:e.verticalAlign||void 0,textDirection:e.textDirection||void 0,shading:e.backgroundColor?{fill:{rgb:e.backgroundColor}}:void 0,borders:e.borders,margins:n}}function vb(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(ul(a));});let o={type:"shape",shapeType:"rect",id:t.textBoxId||void 0,size:{width:t.width?Math.round(t.width*(914400/96)):0,height:t.height?Math.round(t.height*(914400/96)):0},textBody:{content:n.length>0?n:[{type:"paragraph",content:[]}],margins:{top:t.marginTop!=null?Math.round(t.marginTop*(914400/96)):void 0,bottom:t.marginBottom!=null?Math.round(t.marginBottom*(914400/96)):void 0,left:t.marginLeft!=null?Math.round(t.marginLeft*(914400/96)):void 0,right:t.marginRight!=null?Math.round(t.marginRight*(914400/96)):void 0}}};if(t.fillColor&&(o.fill={type:"solid",color:{rgb:t.fillColor.replace("#","")}}),t.outlineWidth&&t.outlineWidth>0){let a={solid:"solid",dotted:"dot",dashed:"dash"};o.outline={width:Math.round(t.outlineWidth*(914400/96)),color:t.outlineColor?{rgb:t.outlineColor.replace("#","")}:void 0,style:t.outlineStyle&&a[t.outlineStyle]||"solid"};}return {type:"paragraph",content:[{type:"run",content:[{type:"shape",shape:o}]}]}}function Wi(e){return ju(e)}function tr(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((g,x,k)=>{x<=o&&(s=k),x<=r&&(l=k);});let u={},d=a.parent,c=d.type.name==="paragraph"&&d.textContent.length===0,p=d.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();c&&f.length===0&&p&&(u={...p});for(let g of f)switch(g.type.name){case "bold":u.bold=true;break;case "italic":u.italic=true;break;case "underline":u.underline={style:g.attrs.style||"single",color:g.attrs.color};break;case "strike":g.attrs.double?u.doubleStrike=true:u.strike=true;break;case "textColor":u.color={rgb:g.attrs.rgb,themeColor:g.attrs.themeColor};break;case "highlight":u.highlight=g.attrs.color;break;case "fontSize":u.fontSize=g.attrs.size;break;case "fontFamily":u.fontFamily={ascii:g.attrs.ascii,hAnsi:g.attrs.hAnsi};break;case "superscript":u.vertAlign="superscript";break;case "subscript":u.vertAlign="subscript";break}let m={},b=null;return d.type.name==="paragraph"&&(d.attrs.alignment&&(m.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(m.lineSpacing=d.attrs.lineSpacing,m.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.numPr&&(m.numPr=d.attrs.numPr),d.attrs.indentLeft&&(m.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(m.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(m.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(m.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(m.tabs=d.attrs.tabs),d.attrs.bidi&&(m.bidi=true),d.attrs.styleId&&(b=d.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var Mt=Kn.getCommands(),Vi=Mt.toggleBold(),Ui=Mt.toggleItalic(),ji=Mt.toggleUnderline(),Gi=Mt.toggleStrike(),Ki=Mt.toggleSuperscript(),Yi=Mt.toggleSubscript();function Ir(e){return Mt.setTextColor(e)}var qi=Mt.clearTextColor();function Xi(e){return Mt.setHighlight(e)}Mt.clearHighlight();function Zi(e){return Mt.setFontSize(e)}Mt.clearFontSize();function Ji(e){return Mt.setFontFamily(e)}Mt.clearFontFamily();function Qi(e,t){return Mt.setHyperlink(e,t)}var ea=Mt.removeHyperlink();function Fr(e,t,n){return Mt.insertHyperlink(e,t,n)}var rt=Kn.getCommands();function ta(e){return rt.setAlignment(e)}rt.alignLeft();rt.alignCenter();rt.alignRight();rt.alignJustify();function na(e,t="auto"){return rt.setLineSpacing(e,t)}rt.singleSpacing();rt.oneAndHalfSpacing();rt.doubleSpacing();function oa(e=720){return rt.increaseIndent(e)}function ra(e=720){return rt.decreaseIndent(e)}function ia(e){return rt.setIndentLeft(e)}function aa(e){return rt.setIndentRight(e)}function Lr(e,t){return rt.setIndentFirstLine(e,t)}var sa=rt.toggleBulletList(),la=rt.toggleNumberedList(),ca=rt.increaseListLevel(),da=rt.decreaseListLevel();rt.removeList();function Br(e,t){return rt.applyStyle(e,t)}rt.clearStyle();rt.removeSectionBreak();function ua(e){return rt.removeTabStop(e)}var pa=rt.setRtl(),fa=rt.setLtr(),ma=rt.generateTOC();var nt=Kn.getCommands();function ga(e,t){return nt.insertTable(e,t)}function Ar(e,t){return nt.addRowAbove()(e,t)}function vo(e,t){return nt.addRowBelow()(e,t)}function Dr(e,t){return nt.deleteRow()(e,t)}function Hr(e,t){return nt.addColumnLeft()(e,t)}function Ro(e,t){return nt.addColumnRight()(e,t)}function Nr(e,t){return nt.deleteColumn()(e,t)}function Or(e,t){return nt.deleteTable()(e,t)}function ha(e,t){return nt.selectTable()(e,t)}function ba(e,t){return nt.selectRow()(e,t)}function ya(e,t){return nt.selectColumn()(e,t)}function xa(e,t){return nt.mergeCells()(e,t)}function Sa(e,t){return nt.splitCell()(e,t)}function qn(e,t,n){return nt.setCellBorder(e,t,n)}function ka(e,t){return nt.removeTableBorders()(e,t)}function Ca(e,t,n){return nt.setAllTableBorders(n)(e,t)}function Ta(e,t,n){return nt.setOutsideTableBorders(n)(e,t)}function wa(e,t,n){return nt.setInsideTableBorders(n)(e,t)}function va(e){return nt.setCellVerticalAlign(e)}function Ra(e){return nt.setCellMargins(e)}function Ea(e){return nt.setCellTextDirection(e)}function Pa(){return nt.toggleNoWrap()}function Ma(e,t){return nt.setRowHeight(e,t)}function Ia(){return nt.toggleHeaderRow()}function Fa(){return nt.distributeColumns()}function La(){return nt.autoFitContents()}function zr(e){return nt.setTableProperties(e)}function Ba(e){return nt.applyTableStyle(e)}function Aa(e){return nt.setCellFillColor(e)}function Da(e){return nt.setTableBorderColor(e)}function Ha(e){return nt.setTableBorderWidth(e)}var Na=(e,t)=>{let{schema:n}=e,o=n.nodes.pageBreak,r=n.nodes.paragraph;if(!o||!r)return false;if(t){let{$from:i}=e.selection,a=e.tr,s=o.create(),l=s.nodeSize,u;if(i.parent.isTextblock)if(i.parentOffset>0&&i.parentOffset<i.parent.content.size){a.split(i.pos);let d=a.mapping.map(i.pos);a.insert(d,Fragment$1.from([s,r.create()])),u=d+l+1;}else if(i.parentOffset===i.parent.content.size){let d=i.after();a.insert(d,Fragment$1.from([s,r.create()])),u=d+l+1;}else {let d=i.before();a.insert(d,s),u=d+l+1;}else {let d=i.pos;a.insert(d,Fragment$1.from([s,r.create()])),u=d+l+1;}a.setSelection(TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function lp(e,t,n){return (o,r)=>{let i=o.schema.marks.insertion,a=o.schema.marks.deletion;if(!i&&!a)return false;let s=n==="accept"?i:a,l=n==="accept"?a:i;if(r){let u=o.tr,d=[];o.doc.nodesBetween(e,t,(c,p)=>{if(!c.isText)return;let f=p+c.nodeSize,m=Math.max(e,p),b=Math.min(t,f);l&&c.marks.some(g=>g.type===l)&&d.push({from:m,to:b}),s&&c.marks.some(g=>g.type===s)&&u.removeMark(m,b,s);});for(let c of d.reverse())u.delete(c.from,c.to);u.steps.length>0&&r(u);}return true}}function cp(e,t){return lp(e,t,"accept")}function dp(e,t){return lp(e,t,"reject")}var pp={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},fp={fontWeight:500,letterSpacing:.3},Gb={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},Kb={position:"absolute",right:0,top:"100%",background:"white",border:"1px solid #dadce0",borderRadius:4,boxShadow:"0 2px 6px rgba(0,0,0,0.15)",zIndex:100,minWidth:160,padding:"4px 0"},Oa={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},gp=forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},d){let c=useRef(null),p=useRef(null),[f,m]=useState(false),[b,g]=useState(false),x=useRef(null),[k,S]=useState(null);useLayoutEffect(()=>{let z=()=>{let A=i.getBoundingClientRect(),Z=r.getBoundingClientRect();S({top:Z.top-A.top+i.scrollTop,left:Z.left-A.left+i.scrollLeft,width:Z.width});};z();let I=i.closest('[style*="overflow"]')||i;return I.addEventListener("scroll",z),window.addEventListener("resize",z),()=>{I.removeEventListener("scroll",z),window.removeEventListener("resize",z);}},[r,i]),useEffect(()=>{if(!c.current||p.current)return;let z=cl(t.content,{styles:o||void 0}),I=new Yn(er());I.buildSchema(),I.initializeRuntime();let A=I.getPlugins(),Z=EditorState.create({doc:z,schema:Se,plugins:A}),ce=new EditorView(c.current,{state:Z,dispatchTransaction(ae){let $=ce.state.apply(ae);if(ce.updateState($),ae.docChanged&&m(true),ae.selectionSet||ae.docChanged){let H=tr($);l?.(H);}}});return p.current=ce,requestAnimationFrame(()=>{ce.focus();let ae=tr(ce.state);l?.(ae);}),()=>{ce.destroy(),p.current=null;}},[k]);let B=useCallback(()=>{if(!p.current)return;let z=Wi(p.current.state.doc);a(z);},[a]),w=useCallback(()=>{f?B():s();},[f,B,s]);useEffect(()=>{function z(I){I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),w());}return document.addEventListener("keydown",z,true),()=>document.removeEventListener("keydown",z,true)},[w]),useEffect(()=>{if(!b)return;function z(I){x.current&&!x.current.contains(I.target)&&g(false);}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[b]),useImperativeHandle(d,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let z=p.current;return z?undo(z.state,z.dispatch):false},redo:()=>{let z=p.current;return z?redo(z.state,z.dispatch):false}}));let E=n==="header"?"Header":"Footer";if(!k)return null;let P={position:"absolute",top:k.top,left:k.left,width:k.width,zIndex:10};return jsxs("div",{className:"hf-inline-editor",style:P,onMouseDown:z=>{z.stopPropagation();},children:[n==="footer"&&jsxs("div",{className:"hf-separator-bar",style:pp,children:[jsx("span",{style:fp,children:E}),jsx(mp,{label:E,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:w,viewRef:p})]}),jsx("div",{ref:c,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxs("div",{className:"hf-separator-bar",style:pp,children:[jsx("span",{style:fp,children:E}),jsx(mp,{label:E,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:w,viewRef:p})]})]})});function mp({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let s=l=>{let u=a.current;if(!u)return;let{$from:d,from:c}=u.state.selection,p=u.state.storedMarks||d.marks(),f=Se.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),m=u.state.tr.insert(c,f.mark(p));u.dispatch(m),u.focus();};return jsxs("div",{style:{position:"relative"},ref:o,children:[jsx("button",{type:"button",style:Gb,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxs("div",{style:Kb,children:[jsx("button",{type:"button",style:Oa,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsx("button",{type:"button",style:Oa,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxs("button",{type:"button",style:Oa,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxs("button",{type:"button",style:Oa,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var xp={position:"fixed",zIndex:1e4,background:"white",borderRadius:"8px",boxShadow:"0 1px 3px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08)",border:"1px solid #dadce0",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px"},qb={...xp,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},Xb={...xp,padding:"12px",width:"320px"},yl={width:"20px",height:"20px",flexShrink:0,color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center"},Zb={color:"#1a73e8",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},Jb={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"#5f6368",padding:0,flexShrink:0},Qb={width:"1px",height:"20px",background:"#dadce0",flexShrink:0},bp={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},yp={flex:1,padding:"6px 8px",border:"1px solid #dadce0",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},ey={color:"#1a73e8",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},nr={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function ty(){return jsxs("svg",{...nr,children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M2 12h20"}),jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function ny(){return jsxs("svg",{...nr,children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function oy(){return jsx("svg",{...nr,children:jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function ry(){return jsxs("svg",{...nr,children:[jsx("path",{d:"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),jsx("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),jsx("line",{x1:"16",y1:"19",x2:"16",y2:"22"}),jsx("line",{x1:"19",y1:"16",x2:"22",y2:"16"})]})}function iy(){return jsxs("svg",{...nr,children:[jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ay(){return jsxs("svg",{...nr,children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function xl({title:e,onClick:t,children:n}){return jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:Jb,title:e,onClick:t,children:n})}function Sp({data:e,onNavigate:t,onCopy:n,onEdit:o,onRemove:r,onClose:i,readOnly:a}){let[s,l]=useState("view"),[u,d]=useState(""),[c,p]=useState(""),f=useRef(null),m=useRef(null);useEffect(()=>{e&&(l("view"),d(e.displayText),p(e.href));},[e]),useEffect(()=>{s==="edit"&&requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();});},[s]),useEffect(()=>{if(!e)return;let E=false,P=I=>{f.current&&!f.current.contains(I.target)&&i();},z=setTimeout(()=>{E||document.addEventListener("mousedown",P);},0);return ()=>{E=true,clearTimeout(z),document.removeEventListener("mousedown",P);}},[e,i]),useEffect(()=>{if(!e)return;let E=P=>{P.key==="Escape"&&(s==="edit"?l("view"):i());};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[e,s,i]);let b=useCallback(()=>{e&&(n(e.href),toast("Link copied to clipboard"));},[e,n]),g=useCallback(()=>{e&&(d(e.displayText),p(e.href),l("edit"));},[e]),x=useCallback(()=>{let E=c.trim();E&&o(u.trim()||E,E);},[u,c,o]),k=useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),x());},[x]);if(!e)return null;let{anchorRect:S}=e,B=S.bottom+4,w=S.left;return s==="edit"?jsxs("div",{ref:f,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{...Xb,top:B,left:w},onMouseDown:E=>E.stopPropagation(),children:[jsxs("div",{style:bp,children:[jsx("span",{style:yl,children:jsx(iy,{})}),jsx("input",{ref:m,type:"text",style:yp,value:u,onChange:E=>d(E.target.value),onKeyDown:k,placeholder:"Display text",onFocus:E=>E.target.style.borderColor="#1a73e8",onBlur:E=>E.target.style.borderColor="#dadce0"})]}),jsxs("div",{style:{...bp,marginBottom:0},children:[jsx("span",{style:yl,children:jsx(ay,{})}),jsx("input",{type:"text",style:yp,value:c,onChange:E=>p(E.target.value),onKeyDown:k,placeholder:"https://example.com",onFocus:E=>E.target.style.borderColor="#1a73e8",onBlur:E=>E.target.style.borderColor="#dadce0"}),jsx("button",{type:"button",style:{...ey,opacity:c.trim()?1:.5,cursor:c.trim()?"pointer":"default"},onClick:x,disabled:!c.trim(),children:"Apply"})]})]}):jsxs("div",{ref:f,className:"ep-hyperlink-popup",style:{...qb,top:B,left:w},onMouseDown:E=>E.stopPropagation(),children:[jsx("span",{style:yl,children:jsx(ty,{})}),jsx("a",{href:e.href,style:Zb,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:E=>{E.preventDefault(),t(e.href);},children:e.href}),jsx("span",{style:Qb}),jsx(xl,{title:"Copy link",onClick:b,children:jsx(ny,{})}),!a&&jsxs(Fragment,{children:[jsx(xl,{title:"Edit link",onClick:g,children:jsx(oy,{})}),jsx(xl,{title:"Remove link",onClick:r,children:jsx(ry,{})})]})]})}var ve=e=>({style:"single",size:4,color:{rgb:e}}),ly=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:ve("000000"),bottom:ve("000000"),left:ve("000000"),right:ve("000000"),insideH:ve("000000"),insideV:ve("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:ve("BFBFBF"),bottom:ve("BFBFBF"),left:ve("BFBFBF"),right:ve("BFBFBF"),insideH:ve("BFBFBF"),insideV:ve("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:ve("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:ve("BFBFBF"),bottom:ve("BFBFBF"),insideH:ve("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true}}},{id:"PlainTable2",name:"Plain Table 2",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:ve("7F7F7F")}},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"PlainTable3",name:"Plain Table 3",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#E7E7E7"}}},{id:"PlainTable4",name:"Plain Table 4",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#000000"},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"GridTable1Light-Accent1",name:"Grid Table 1 Light",tableBorders:{top:ve("B4C6E7"),bottom:ve("B4C6E7"),left:ve("B4C6E7"),right:ve("B4C6E7"),insideH:ve("B4C6E7"),insideV:ve("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:ve("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:ve("4472C4"),bottom:ve("4472C4"),left:ve("4472C4"),right:ve("4472C4"),insideH:ve("4472C4"),insideV:ve("4472C4")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"}}},{id:"GridTable5Dark-Accent1",name:"Grid Table 5 Dark",tableBorders:{top:ve("FFFFFF"),bottom:ve("FFFFFF"),left:ve("FFFFFF"),right:ve("FFFFFF"),insideH:ve("FFFFFF"),insideV:ve("FFFFFF")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"},band2Horz:{backgroundColor:"#B4C6E7"}}},{id:"ListTable3-Accent2",name:"List Table 3 Accent 2",tableBorders:{top:ve("ED7D31"),bottom:ve("ED7D31")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#ED7D31"},band1Horz:{backgroundColor:"#FBE4D5"}}},{id:"ListTable4-Accent3",name:"List Table 4 Accent 3",tableBorders:{top:ve("A5A5A5"),bottom:ve("A5A5A5"),insideH:ve("A5A5A5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#EDEDED"}}},{id:"GridTable4-Accent5",name:"Grid Table 4 Accent 5",tableBorders:{top:ve("5B9BD5"),bottom:ve("5B9BD5"),left:ve("5B9BD5"),right:ve("5B9BD5"),insideH:ve("5B9BD5"),insideV:ve("5B9BD5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#5B9BD5"},band1Horz:{backgroundColor:"#DEEAF6"}}},{id:"GridTable4-Accent6",name:"Grid Table 4 Accent 6",tableBorders:{top:ve("70AD47"),bottom:ve("70AD47"),left:ve("70AD47"),right:ve("70AD47"),insideH:ve("70AD47"),insideV:ve("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function kp(e){return ly.find(t=>t.id===e)}function Cp(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsx("div",{style:{width:"36px",height:"36px",border:"3px solid var(--doc-border)",borderTopColor:"var(--doc-primary)",borderRadius:"50%",animation:"docx-spin 0.8s linear infinite"}}),jsx("style",{children:`
|
|
15
|
+
@keyframes docx-spin {
|
|
16
|
+
to { transform: rotate(360deg); }
|
|
17
|
+
}
|
|
18
|
+
`}),jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function Tp(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsx("div",{style:{marginTop:"16px"},children:"No document loaded"})]})}function wp({message:e}){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:"Failed to Load Document"}),jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function dy(e,t){return JSON.stringify(e)===JSON.stringify(t)}function uy(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=dy,onUndo:a,onRedo:s,containerRef:l}=t,[u,d]=useState(e),[c,p]=useState([]),[f,m]=useState([]),b=useRef(0),g=useRef(false),x=useCallback((I,A)=>{if(i(u,I))return;if(g.current){d(I);return}let Z=Date.now();Z-b.current<o&&c.length>0?p(ae=>{let $=[...ae];return $[$.length-1]={state:u,timestamp:Z,description:A||$[$.length-1].description},$}):p(ae=>{let $={state:u,timestamp:Z,description:A},H=[...ae,$];return H.length>n?H.slice(H.length-n):H}),m([]),d(I),b.current=Z;},[u,i,o,n,c.length]),k=useCallback(()=>{if(c.length===0)return;g.current=true;let I=c[c.length-1];return p(A=>A.slice(0,-1)),m(A=>[...A,{state:u,timestamp:Date.now()}]),d(I.state),setTimeout(()=>{g.current=false;},0),a?.(I.state),I.state},[c,u,a]),S=useCallback(()=>{if(f.length===0)return;g.current=true;let I=f[f.length-1];return m(A=>A.slice(0,-1)),p(A=>[...A,{state:u,timestamp:Date.now()}]),d(I.state),setTimeout(()=>{g.current=false;},0),s?.(I.state),I.state},[f,u,s]),B=useCallback(()=>{p([]),m([]);},[]),w=useCallback(I=>{d(I??e),p([]),m([]),b.current=0;},[e]),E=useCallback(()=>[...c],[c]),P=useCallback(()=>[...f],[f]),z=useCallback(I=>{d(A=>I(A)),p(A=>A.map(Z=>({...Z,state:I(Z.state)}))),m(A=>A.map(Z=>({...Z,state:I(Z.state)})));},[]);return useEffect(()=>{if(!r)return;let I=Z=>{if((Z.ctrlKey||Z.metaKey)&&Z.key==="z"&&!Z.shiftKey){Z.preventDefault(),k();return}if((Z.ctrlKey||Z.metaKey)&&Z.key==="y"||(Z.ctrlKey||Z.metaKey)&&Z.key==="z"&&Z.shiftKey){Z.preventDefault(),S();return}},A=l?.current||document;return A.addEventListener("keydown",I),()=>{A.removeEventListener("keydown",I);}},[r,k,S,l]),{state:u,canUndo:c.length>0,canRedo:f.length>0,undoCount:c.length,redoCount:f.length,push:x,undo:k,redo:S,clear:B,reset:w,getUndoStack:E,getRedoStack:P,transformAll:z}}function Rp(e,t={}){let n=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 uy(e,{...t,isEqual:n})}var Xn=new PluginKey("suggestionMode"),_a="suggestionModeApplied",my=Date.now();function Wa(e){return {revisionId:my++,author:e.author,date:new Date().toISOString()}}function Cl(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 Mp(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,d)=>{if(!u.isText)return;let c=Math.max(d,n),p=Math.min(d+u.nodeSize,o);if(c>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:c,to:p,isOwnInsert:f});}),s.length===0)return;let l=Cl(t,n,"deletion",a.author)||Wa(a);for(let u=s.length-1;u>=0;u--){let d=s[u];d.isOwnInsert?e.delete(d.from,d.to):e.addMark(d.from,d.to,i.create(l));}}function Ep(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(_a,true);let s=Cl(e.state.doc,t,"insertion",r.author)||Wa(r);if(t!==n){let u=e.state.schema.marks.deletion;u&&Mp(a,e.state.doc,t,n,i,u,r);}let l=a.mapping.map(n);return a.insertText(o,l,l),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function Pp(e,t,n){let o=Xn.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(_a,true),!a){Mp(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(TextSelection.near(u.doc.resolve(x))),t(u.scrollIntoView()),true}let d=n==="backward",c=d?r.pos-1:r.pos,p=d?r.pos:r.pos+1;if(c<0||p>e.doc.content.size)return true;let m=e.doc.resolve(c).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=d?c:p;u.setSelection(TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(c,p);else {let x=Cl(e.doc,c,"deletion",o.author)||Wa(o);u.addMark(c,p,l.create(x));let k=d?c:p;u.setSelection(TextSelection.near(u.doc.resolve(k)));}return t(u.scrollIntoView()),true}function Ip(e=false,t="User"){return new Plugin({key:Xn,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(Xn);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=Xn.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 Ep(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return Xn.getState(n.state)?.active?o.key==="Backspace"?Pp(n.state,n.dispatch,"backward"):o.key==="Delete"?Pp(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=Xn.getState(n.state);return a?.active?Ep(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=Xn.getState(r);if(!i?.active)return null;let a=n.find(c=>c.docChanged&&!c.getMeta(_a));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Wa(i),u=r.tr;u.setMeta(_a,true);let d=r.schema.marks.deletion;return a.steps.forEach(c=>{c.getMap().forEach((f,m,b,g)=>{g>b&&r.doc.nodesBetween(b,g,(x,k)=>{if(!x.isText)return;if(!x.marks.some(B=>B.type===s||d&&B.type===d)){let B=Math.max(k,b),w=Math.min(k+x.nodeSize,g);u.addMark(B,w,s.create(l));}});});}),u.steps.length>0?u:null}})}function Fp(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(Xn,r);n(i);}return true}var Ty={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function Dp(e,t,n,o=[]){let r=n?.getSchema()??Se,i=e?ol(e,{styles:t??void 0}):dl(),a=[...o,...n?.getPlugins()??[]];return EditorState.create({doc:i,schema:r,plugins:a})}function wy(e,t){return t?Uu(e.doc,t):null}var vy=forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:d=[],extensionManager:c,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=useRef(null),g=useRef(null),x=useRef(o),k=useRef(false),S=useRef(null),B=useRef(false),w=useRef(l),E=useRef(u),P=useRef(p),z=useRef(f),I=useRef(m);w.current=l,E.current=u,P.current=p,z.current=f,I.current=m,x.current=o;let A=useCallback(()=>{if(!b.current||k.current)return;let ae={state:Dp(o,r,c,d),editable:()=>!s,dispatchTransaction:$=>{if(!g.current||k.current)return;let H=g.current.state.apply($);g.current.updateState(H),w.current?.($,H),($.selectionSet||$.docChanged)&&E.current?.(H);},handleKeyDown:($,H)=>I.current?.($,H)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new EditorView(b.current,ae),P.current?.(g.current);},[o,r,d,c,s]),Z=useCallback(()=>{g.current&&!k.current&&(k.current=true,z.current?.(),g.current.destroy(),g.current=null,k.current=false);},[]);return useEffect(()=>(A(),()=>Z()),[]),useEffect(()=>{if(!g.current||k.current)return;let ae=(H=>{if(!H)return "empty";let de=H.package?.properties;return `${de?.created||""}-${de?.modified||""}-${de?.title||""}`})(o);if(B.current&&ae===S.current)return;B.current=true,S.current=ae;let $=Dp(o,r,c,d);g.current.updateState($),E.current?.($);},[o,r,c,d]),useEffect(()=>{g.current;},[s]),useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?wy(g.current.state,x.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(ce){g.current&&!k.current&&g.current.dispatch(ce);},executeCommand(ce){return g.current?ce(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?undo(g.current.state,g.current.dispatch):false},redo(){return g.current?redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?undo(g.current.state):false},canRedo(){return g.current?redo(g.current.state):false},setSelection(ce,ae){if(!g.current)return;let{state:$,dispatch:H}=g.current,de=$.doc.resolve(ce),me=ae!==void 0?$.doc.resolve(ae):de,ue=TextSelection.between(de,me);H($.tr.setSelection(ue));},setNodeSelection(ce){if(!g.current)return;let{state:ae,dispatch:$}=g.current;try{let H=NodeSelection.create(ae.doc,ce);$(ae.tr.setSelection(H));}catch{this.setSelection(ce);}},setCellSelection(ce,ae){if(!g.current)return;let{state:$,dispatch:H}=g.current;try{let de=CellSelection.create($.doc,ce,ae);H($.tr.setSelection(de));}catch{this.setSelection(ce,ae);}},scrollToSelection(){}}),[]),jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...Ty,width:a>0?`${a}px`:void 0}})}),Hp=memo(vy);var My="#000",Iy="rgba(66, 133, 244, 0.3)",Fy=2,Ly=530,By={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},Ay=(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"}),Dy=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Hy=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=useState(r),s=useRef(null);return 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]),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]),jsx("div",{style:Ay(e,t,n,i),"data-testid":"caret"})},Ny=({rect:e,color:t,index:n})=>jsx("div",{style:Dy(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),Op=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=My,selectionColor:i=Iy,caretWidth:a=Fy,blinkInterval:s=Ly})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxs("div",{style:By,"data-testid":"selection-overlay",children:[l&&e.map((d,c)=>jsx(Ny,{rect:d,color:i,index:c},`sel-${d.pageIndex}-${d.x}-${d.y}-${c}`)),u&&t&&jsx(Hy,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var vl=10,Zn=vl/2,Vr=2,Wp="#2563eb",$p={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},zy={position:"absolute",border:`${Vr}px solid ${Wp}`,pointerEvents:"none",boxSizing:"border-box"},$y={position:"absolute",width:`${vl}px`,height:`${vl}px`,backgroundColor:Wp,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},_y={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%)"},Wy={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Vy(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 d=Math.max(l/o,u/r);l=o*d,u=r*d;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function Vp({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,d]=useState(false),[c,p]=useState(false),[f,m]=useState(0),[b,g]=useState(0),[x,k]=useState(null),S=useRef(null),B=useRef(null),w=useRef(o),E=useRef(r),P=useRef(i),z=useRef(a),I=useRef(s),A=useRef(l);w.current=o,E.current=r,P.current=i,z.current=a,I.current=s,A.current=l;let Z=useRef(e),ce=useRef(t);Z.current=e,ce.current=t;let ae=useCallback(()=>{if(!e||!B.current){k(null);return}let R=B.current.offsetParent;if(!R){k(null);return}let F=R.getBoundingClientRect(),C=e.element.getBoundingClientRect();k({left:(C.left-F.left)/t,top:(C.top-F.top)/t,width:C.width/t,height:C.height/t});},[e,t]);useEffect(()=>{ae();},[ae]),useEffect(()=>{if(!e)return;let R=B.current?.closest('[style*="overflow"]')??B.current?.closest(".paged-editor__container");if(!R)return;let F=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(ae);};return R.addEventListener("scroll",F,{passive:true}),window.addEventListener("resize",F,{passive:true}),()=>{R.removeEventListener("scroll",F),window.removeEventListener("resize",F),S.current&&cancelAnimationFrame(S.current);}},[e,ae]);let $=useCallback((R,F)=>{if(!e||!x)return;F.preventDefault(),F.stopPropagation();let C=x.width,M=x.height,L=F.clientX,D=F.clientY,Y=Math.round(C),se=Math.round(M);d(true),m(Y),g(se),E.current?.();let W=Q=>{let we=ce.current,oe=(Q.clientX-L)/we,re=(Q.clientY-D)/we,pe=!Q.shiftKey,be=Vy(R,oe,re,C,M,pe);Y=Math.round(be.width),se=Math.round(be.height),m(Y),g(se),k(Ue=>{if(!Ue)return Ue;let Be={...Ue};return R.includes("w")&&(Be.left=Ue.left+(Ue.width-be.width)),R.includes("n")&&(Be.top=Ue.top+(Ue.height-be.height)),Be.width=be.width,Be.height=be.height,Be});},q=()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",q),d(false);let Q=Z.current;Q&&w.current?.(Q.pmPos,Y,se),P.current?.();};window.addEventListener("mousemove",W),window.addEventListener("mouseup",q);},[e,x]),H=useCallback(R=>{if(!e||!x)return;R.preventDefault(),R.stopPropagation();let F=4,C=R.clientX,M=R.clientY,L=false,D=null,Y=W=>{let q=W.clientX-C,Q=W.clientY-M;!L&&Math.sqrt(q*q+Q*Q)<F||(L||(L=true,p(true),I.current?.(),D=document.createElement("div"),D.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);",D.style.width=`${x.width}px`,D.style.height=`${x.height}px`,document.body.appendChild(D)),D&&(D.style.left=`${W.clientX-x.width/2}px`,D.style.top=`${W.clientY-x.height/2}px`));},se=W=>{if(window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",se),D&&(D.remove(),D=null),p(false),L){let q=Z.current;q&&z.current?.(q.pmPos,W.clientX,W.clientY),A.current?.();}};window.addEventListener("mousemove",Y),window.addEventListener("mouseup",se);},[e,x]);if(!!!(e&&x&&n))return jsx("div",{ref:B,style:{...$p,visibility:"hidden"},className:"image-selection-overlay"});let{left:me,top:ue,width:N,height:Ve}=x;return jsxs("div",{ref:B,style:$p,className:"image-selection-overlay",children:[jsx("div",{style:{...zy,left:me-Vr,top:ue-Vr,width:N+Vr*2,height:Ve+Vr*2}}),jsx("div",{style:{position:"absolute",left:me,top:ue,width:N,height:Ve,cursor:c?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:H}),jsx(Ua,{handle:"nw",style:{left:me-Zn,top:ue-Zn},onMouseDown:$}),jsx(Ua,{handle:"ne",style:{left:me+N-Zn,top:ue-Zn},onMouseDown:$}),jsx(Ua,{handle:"se",style:{left:me+N-Zn,top:ue+Ve-Zn},onMouseDown:$}),jsx(Ua,{handle:"sw",style:{left:me-Zn,top:ue+Ve-Zn},onMouseDown:$}),u&&jsxs("div",{style:{..._y,left:me+N/2,top:ue+Ve+12},children:[f," \xD7 ",b]})]})}function Ua({handle:e,style:t,onMouseDown:n}){return jsx("div",{style:{...$y,...t,cursor:Wy[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var Uy="Calibri";function Rl(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 jy=11;function ot(e){return e/1440*96}var Gy=0;function Qn(){return `block-${++Gy}`}function Ky(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 ja(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?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=a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=n$2(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 Yy(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=ja(a.marks,i),d={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}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 d={kind:"tab",...ja(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="image"){let u=a.attrs,d=Rl(u.width||100,u.height||100,n.pageContentHeight),c={kind:"image",src:u.src,width:d.width,height:d.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(c);}else if(a.type.name==="field"){let u=a.attrs.fieldType,c={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(c);}else if(a.type.name==="math"){let d={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((d,c)=>{let p=u+c;if(d.isText&&d.text){let f=ja(d.marks,i),m={kind:"text",text:d.text,...f,pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+d.nodeSize};o.push(f);}else if(d.type.name==="tab"){let m={kind:"tab",...ja(d.marks,i),pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="image"){let f=d.attrs,m=Rl(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+d.nodeSize};o.push(b);}});}}),o}function qy(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=ot(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=ot(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=ot(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=ot(o)),e.indentRight!=null&&(n.indent.right=ot(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(ot(r)):n.indent.firstLine=ot(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?Ga(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:Xy(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 Xy(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 El(e,t,n){let o=e.attrs,r=Yy(e,t,n),i=qy(o,n.theme);return {kind:"paragraph",id:Qn(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Zy(e){return Math.max(1,Math.round(e/8*1.333))}var Jy={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 Ga(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Jy[e.style]||"solid",width:Zy(e.size??0),color:e.color?a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=g$1(e.space)),n}function Qy(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?Ga(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function ex(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(El(l,r,n)):l.type.name==="table"&&o.push(Up(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?ot(a.top):1,right:a?.right!=null?ot(a.right):7,bottom:a?.bottom!=null?ot(a.bottom):1,left:a?.left!=null?ot(a.left):7};return {id:Qn(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?ot(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Qy(i,n.theme),padding:s}}function tx(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(ex(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:Qn(),cells:o,height:i.height?ot(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function Up(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(tx(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(ot),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(g=>g.width);b.every(g=>g!==void 0&&g>0)&&(a=b);}let u=e.attrs.justification,d=e.attrs._originalFormatting,c=d?.indent?.value&&d.indent.type==="dxa"?ot(d.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?ot(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?ot(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?ot(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?ot(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?ot(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?ot(p.rightFromText):void 0}:void 0;return {kind:"table",id:Qn(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:c,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function nx(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=Rl(o.width||100,o.height||100,n);return {kind:"image",id:Qn(),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 ox(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=El(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:Qn(),width:o.width??d$2,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??c$1.top,bottom:o.marginBottom??c$1.bottom,left:o.marginLeft??c$1.left,right:o.marginRight??c$1.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function jp(e,t={}){let n={...t,defaultFont:t.defaultFont??Uy,defaultSize:t.defaultSize??jy},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=El(a,l,n),d=a.attrs;if(d.numPr&&!d.listMarker){let p=d.numPr.numId;if(p==null||p===0)break;let f=d.numPr.ilvl??0,m=i.get(p)??new Array(9).fill(0);m[f]=(m[f]??0)+1;for(let g=f+1;g<m.length;g+=1)m[g]=0;i.set(p,m);let b=d.listIsBullet?"\u2022":Ky(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let c=d._sectionProperties;if(c||d.sectionBreakType){let p={kind:"sectionBreak",id:Qn(),type:c?.sectionStart??d.sectionBreakType};if(c){(c.pageWidth||c.pageHeight)&&(p.pageSize={w:ot(c.pageWidth??12240),h:ot(c.pageHeight??15840)}),(c.marginTop!==void 0||c.marginLeft!==void 0)&&(p.margins={top:ot(c.marginTop??1440),bottom:ot(c.marginBottom??1440),left:ot(c.marginLeft??1440),right:ot(c.marginRight??1440)});let f=c.columnCount??1;if(f>1){let m={count:f,gap:ot(c.columnSpace??720),equalWidth:c.equalWidth??true,separator:c.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(Up(a,l,n));break;case "image":o.push(nx(a,l,n.pageContentHeight));break;case "textBox":o.push(ox(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:Qn(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var Hn=11,Ur="Calibri",Ka=1,or=.5;function Gp(e){return {fontFamily:e.fontFamily??Ur,fontSize:e.fontSize??Hn,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Xp(e,t,n){let o=k$1(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*Ka;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*Ka;return {ascent:r,descent:i,lineHeight:l}}function Kp(e,t,n){let o=g$2({fontSize:e,fontFamily:n??Ur});return Xp(e,t,o)}function Yp(e){return e.kind==="text"}function rx(e){return e.kind==="tab"}function ix(e){return e.kind==="image"}function ax(e){return e.kind==="lineBreak"}function sx(e){return e.kind==="field"}function lx(e){return !e.text||e.text.length===0}function cx(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 dx=48;function qp(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 Cn(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,d=l?.right??0,c=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-d),f=Math.max(1,p-c),m=0,b=k$1(Hn)*Ka,g=qp(0,b,a,s),x=Math.max(1,f-g.leftMargin-g.rightMargin),k=[];if(o.length===0){let I=r?.defaultFontSize??Hn,A=r?.defaultFontFamily??Ur,Z=Kp(I,i,A);return k.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...Z}),{kind:"paragraph",lines:k,totalHeight:Z.lineHeight}}if(o.length===1&&Yp(o[0])&&lx(o[0])){let I=o[0],A=I.fontSize??r?.defaultFontSize??Hn,Z=I.fontFamily??r?.defaultFontFamily??Ur,ce=Kp(A,i,Z);return k.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...ce}),{kind:"paragraph",lines:k,totalHeight:ce.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:Hn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:g.leftMargin,rightOffset:g.rightMargin},B=()=>{let I=Xp(S.maxFontSize,i,S.maxFontMetrics),A={...I};S.maxImageHeightPx>A.lineHeight&&(A.lineHeight=S.maxImageHeightPx,A.ascent=S.maxImageHeightPx*.8,A.descent=S.maxImageHeightPx*.2);let Z={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...A};S.leftOffset>0&&(Z.leftOffset=S.leftOffset),S.rightOffset>0&&(Z.rightOffset=S.rightOffset),k.push(Z),m+=I.lineHeight;},w=(I,A)=>{B();let Z=k$1(Hn)*Ka,ce=qp(m,Z,a,s),ae=Math.max(1,p-ce.leftMargin-ce.rightMargin);S={fromRun:I,fromChar:A,toRun:I,toChar:A,width:0,maxFontSize:Hn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:ae,leftOffset:ce.leftMargin,rightOffset:ce.rightMargin};},E=I=>{let A=I.fontSize??Hn;(!S.maxFontMetrics||A>S.maxFontSize)&&(S.maxFontSize=A,S.maxFontMetrics=g$2(I));};for(let I=0;I<o.length;I++){let A=o[I];if(ax(A)){S.toRun=I,S.toChar=0,w(I+1,0);continue}if(rx(A)){let Z=Gp(A);E(Z);let ce=A.width??dx;S.width+ce>S.availableWidth+or&&(w(I,0),E(Z)),S.width+=ce,S.toRun=I,S.toChar=1;continue}if(ix(A)){let Z=A.wrapType,ce=A.displayMode==="float"||Z&&["square","tight","through"].includes(Z);if(A.position&&ce){S.toRun=I,S.toChar=1;continue}if(Z==="topAndBottom"||A.displayMode==="block"){S.width>0&&w(I,0);let H=A.height,de=A.distTop??6,me=A.distBottom??6;S.toRun=I,S.toChar=1,S.maxImageHeightPx=H+de+me,w(I+1,0);continue}let ae=A.width,$=A.height;$>S.maxImageHeightPx&&(S.maxImageHeightPx=$),S.width+ae>S.availableWidth+or&&w(I,0),S.width+=ae,S.toRun=I,S.toChar=1;continue}if(sx(A)){let Z=A.fallback||"1",ce={fontFamily:A.fontFamily??Ur,fontSize:A.fontSize??Hn,bold:A.bold,italic:A.italic};E(ce);let ae=h$2(Z,ce);S.width>0&&S.width+ae>S.availableWidth+or&&(w(I,0),E(ce)),S.width+=ae,S.toRun=I,S.toChar=1;continue}if(Yp(A)){let Z=A,ce=Z.text,ae=Gp(Z);if(E(ae),!ce||ce.length===0){S.toRun=I,S.toChar=0;continue}let $=cx(ce),H=0;for(;H<ce.length;){let de=ce.length;for(let N of $)if(N>H){de=N;break}let me=ce.slice(H,de),ue=h$2(me,ae);if(ue>S.availableWidth+or){S.width>0&&(w(I,H),E(ae));let{charWidths:N}=i$2(me,ae),Ve=0;for(;Ve<me.length;){let R=0,F=Ve;for(;F<me.length;){let C=N[F]??0;if(R+C>S.availableWidth+or)break;R+=C,F+=1;}F===Ve&&(F=Math.min(me.length,Ve+1),R=N[Ve]??0),S.width+=R,S.toRun=I,S.toChar=H+F,Ve=F,Ve<me.length&&(w(I,H+Ve),E(ae));}H=de;continue}S.width>0&&S.width+ue>S.availableWidth+or&&(w(I,H),E(ae)),S.width+=ue,S.toRun=I,S.toChar=de,H=de;}}}B();let z=k.reduce((I,A)=>I+A.lineHeight,0);return i?.before&&(z+=i.before),i?.after&&(z+=i.after),{kind:"paragraph",lines:k,totalHeight:z}}var ux=new Map;function Zp(){ux.clear();}var px=new Map;function Jp(){px.clear();}var fx=5e3,mx=fx,eo=new Map;function Pl(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 gx(){for(;eo.size>mx;){let e=eo.keys().next().value;if(e===void 0)break;eo.delete(e);}}function Ml(e,t){let n=Pl(e),o=eo.get(n);if(o!==void 0&&o.maxWidth===t)return eo.delete(n),eo.set(n,o),o.measure}function Il(e,t,n){let o=Pl(e);eo.set(o,{measure:n,maxWidth:t}),gx();}function Qp(){eo.clear();}function Fl(){Zp(),Jp(),Qp();}function hx(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function bx(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,d=i.slice(l,u);d.length>0&&n.push({...r,text:d});}else n.push(r);}}}return n}function yx(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??"",d=s===t.fromRun?t.fromChar:0,c=s===t.toRun?t.toChar:u.length;a+=c-d;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function xx(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 Sx(e,t,n,o){let{pmStart:r,pmEnd:i}=yx(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=bx(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let d=0,c=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="image"){let m=f.width,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="lineBreak"){if(l>=d)return {charOffset:c,pmPosition:r+c};c+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=hx(f),g=i$2(m,b),x=d+g.width;if(l<=x){let k=l-d,S=j$2(k,g.charWidths),B=c+S;return {charOffset:B,pmPosition:r+B}}d=x,c+=m.length;}}return {charOffset:i-r,pmPosition:i}}function ef(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=xx(l,i,a.fromLine,a.toLine);if(u===null)return null;let d=l.lines[u];if(!d)return null;let c=0;for(let S=a.fromLine;S<u;S++)c+=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),g=r-f,{charOffset:x,pmPosition:k}=Sx(s,d,g,b);return {pmPosition:k,charOffset:x,lineIndex:u}}function kx(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 ef(i)?.pmPosition??null}function Ll(e,t){if(t)return kx(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?ef(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function nf(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(d=>d.classList.contains("layout-page"));if(!i)return null;let a=r.find(d=>d.tagName==="SPAN"&&d.dataset.pmStart!==void 0&&d.dataset.pmEnd!==void 0);if(a)return Bl(a,t);let s=r.find(d=>d.classList.contains("layout-empty-run"));if(s){let d=s.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let l=r.find(d=>d.classList.contains("layout-paragraph")&&d.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let d=tf(l,t,n);return d!==null?d:Number(l.dataset.pmStart)}let u=r.find(d=>d.classList.contains("layout-table-cell"));return u?tf(u,t,n):Cx(e,i,t,n)}function Bl(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let c=e.getBoundingClientRect(),p=(c.left+c.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,d=s;for(;u<d;){let c=Math.floor((u+d)/2),p=l.createRange();p.setStart(a,c),p.setEnd(a,c);let m=p.getBoundingClientRect().left;t<m?d=c:u=c+1;}if(u>0&&u<=s){let c=l.createRange();c.setStart(a,u-1),c.setEnd(a,u-1);let p=c.getBoundingClientRect();c.setStart(a,Math.min(u,s)),c.setEnd(a,Math.min(u,s));let f=c.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 tf(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let c=o.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let c of Array.from(r)){let p=c,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let c=e.querySelector(".layout-paragraph[data-pm-start]");return c?.dataset.pmStart?Number(c.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 c=i.closest(".layout-paragraph");return c?.dataset.pmStart?Number(c.dataset.pmStart):null}let l=null,u=1/0;for(let c of Array.from(s)){let p=c,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return Bl(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let d=l.getBoundingClientRect();return t<d.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function Cx(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(),g=(b.top+b.bottom)/2,x=Math.abs(o-g);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 d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return Bl(m,n);let g=n<b.left?b.left-n:n-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return n<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)}var to={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function Tx(e){return e.kind==="paragraph"}function wx(e){return e.kind==="table"}function vx(e){return e.kind==="image"}function Ya(e){e.style.position="absolute",e.style.overflow="hidden";}function Rx(e,t,n){let o=n.createElement("div");return o.className=`${to.fragment} ${to.paragraph}`,Ya(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 Ex(e,t,n){let o=n.createElement("div");return o.className=`${to.fragment} ${to.table}`,Ya(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 Px(e,t,n){let o=n.createElement("div");return o.className=`${to.fragment} ${to.image}`,Ya(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 jr(e,t,n={}){let o=n.document??document;if(Tx(e))return Rx(e,t,o);if(wx(e))return Ex(e,t,o);if(vx(e))return Px(e,t,o);let r=o.createElement("div");r.className=to.fragment,Ya(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function Al(e){return e/1440*96}function Mx(e){return e/96*1440}function Ix(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(c=>c.val!=="clear").filter(c=>c.pos>=o),i=t.filter(c=>c.val==="clear").map(c=>c.pos),a=r.reduce((c,p)=>Math.max(c,p.pos),0),s=[...r];o>0&&!r.some(c=>c.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,d=o+14400;for(;u<d;){u+=n;let c=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;!c&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((c,p)=>c.pos-p.pos)}function of(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=Mx(e),l=Ix(t).find(c=>c.pos>a);if(!l){let c=Al(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}let d=Al(l.pos)-e;if(l.val==="center"||l.val==="end"){let c=o?o(n):0;l.val==="center"?d-=c/2:d-=c;}else if(l.val==="decimal"){let c=n.indexOf(r);if(c>=0&&o){let p=n.slice(0,c),f=o(p);d-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(d<1){let c=Al(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}return {width:d,leader:l.leader,alignment:l.val}}var Zt={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 Kr(e){return e.kind==="text"}function qa(e){return e.kind==="tab"}function sf(e){return e.kind==="image"}function Dl(e){return e.kind==="lineBreak"}function Hl(e){return e.kind==="field"}function Fx(e,t){if(t.fontFamily&&(e.style.fontFamily=a$4(t.fontFamily).cssFallback),t.fontSize){let o=t.fontSize*96/72;e.style.fontSize=`${o}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 n=[];t.underline&&(n.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&n.push("line-through"),t.commentIds&&t.commentIds.length>0&&(e.style.backgroundColor="rgba(255, 212, 0, 0.25)",e.style.borderBottom="2px solid rgba(255, 212, 0, 0.6)",e.dataset.commentId=String(t.commentIds[0])),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",n.includes("line-through")||n.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))),n.length>0&&(e.style.textDecorationLine=n.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function rr(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Nl(e,t){let n=t.createElement("span");if(n.className=`${Zt.run} ${Zt.text}`,Fx(n,e),rr(n,e.pmStart,e.pmEnd),e.hyperlink){let o=t.createElement("a");o.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(o.target="_blank",o.rel="noopener noreferrer"),e.hyperlink.tooltip&&(o.title=e.hyperlink.tooltip),o.textContent=e.text;let r=e.color||"#0563c1";o.style.color=r,o.style.textDecoration="underline",n.style.color=r,n.appendChild(o);}else n.textContent=e.text;return n}function lf(e,t,n,o){let r=t.createElement("span");if(r.className=`${Zt.run} ${Zt.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",rr(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=Lx(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 Lx(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function Bx(e,t){let n=t.createElement("img");return n.className=`${Zt.run} ${Zt.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",rr(n,e.pmStart,e.pmEnd),n}function rf(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),rr(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function cf(e,t){return ir(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?rf(e,t):Bx(e,t)}function df(e,t){let n=t.createElement("br");return n.className=`${Zt.run} ${Zt.lineBreak}`,rr(n,e.pmStart,e.pmEnd),n}function uf(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 Nl(r,t)}function Ax(e,t,n){if(Kr(e))return Nl(e,t);if(qa(e))return lf(e,t,48,void 0);if(sf(e))return cf(e,t);if(Dl(e))return df(e,t);if(Hl(e)&&n)return uf(e,t,n);let o=t.createElement("span");return o.className=Zt.run,o}function pf(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(Kr(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 Dx(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function Hx(e){return {val:e.val,pos:e.pos,leader:e.leader}}function Nx(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(Kr(i))o+=i.text;else if(Hl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(qa(i)||Dl(i))break}return o}function Ox(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=a$4(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function ff(e,t,n,o,r){let i=o.createElement("div");i.className=Zt.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=pf(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${Zt.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=>Kr(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let d=a.some(qa),c,p=Ox(o);if(d){let b=r?.tabStops?.map(Hx),g=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;c={explicitStops:b,leftIndent:g};}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 g=a[b];if(qa(g)&&c){let x=Nx(a,b,r?.context),k=of(f,c,x,p),S=lf(g,o,k.width,k.leader);i.appendChild(S),f+=k.width;}else if(Kr(g)){let x=Nl(g,o);if(g.highlight){let w=(g.fontSize?g.fontSize*96/72:14.67)*1.2,E=Math.max(0,t.lineHeight-w);if(E>0){let P=E/2;x.style.paddingTop=`${P}px`,x.style.paddingBottom=`${P}px`;}}i.appendChild(x);let k=g.fontSize||11,S=g.fontFamily||"Calibri";f+=p(g.text,k,S);}else if(sf(g)){if(ir(g))continue;let x=Dx(g);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let k=cf(g,o);i.appendChild(k),g.displayMode!=="block"&&g.wrapType!=="topAndBottom"&&(f+=g.width);}else if(Dl(g)){let x=df(g,o);i.appendChild(x);}else if(Hl(g)&&r?.context){let x=uf(g,o,r.context);i.appendChild(x);let k=g.fallback??"";g.fieldType==="PAGE"?k=String(r.context.pageNumber):g.fieldType==="NUMPAGES"&&(k=String(r.context.totalPages));let S=g.fontSize||11,B=g.fontFamily||"Calibri";f+=p(k,S,B);}else {let x=Ax(g,o,r?.context);i.appendChild(x);}}return i}function Gr(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:Gr(e.top,t.top)&&Gr(e.bottom,t.bottom)&&Gr(e.left,t.left)&&Gr(e.right,t.right)&&Gr(e.between,t.between)}function Nn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Zt.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),rr(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 d=t.attrs?.indent,c=0,p=0;d&&(u?(d.left&&d.left>0&&(p=d.left),d.right&&d.right>0&&(c=d.right)):(d.left&&d.left>0&&(c=d.left),d.right&&d.right>0&&(p=d.right)));let f=t.attrs?.borders;if(f){let w=A=>{switch(A){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 E=A=>`${A.width}px ${w(A.style)} ${A.color}`,P=af(r.prevBorders,f),z=af(f,r.nextBorders);if(P&&f.between?a.style.borderTop=E(f.between):f.top&&!P&&(a.style.borderTop=E(f.top)),f.bottom&&!z&&(a.style.borderBottom=E(f.bottom)),f.left&&(a.style.borderLeft=E(f.left)),f.right&&(a.style.borderRight=E(f.right)),f.bar){let A=i.createElement("div");A.style.position="absolute",A.style.left="-8px",A.style.top="0",A.style.bottom="0",A.style.borderLeft=E(f.bar),a.style.position="relative",a.appendChild(A);}if(f.top||f.bottom||f.left||f.right||f.between){let A=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=A?`${A.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-c-p,g=t.runs[t.runs.length-1]?.kind==="lineBreak",x=n.lines.length,k=0;d?.hanging&&d.hanging>0?k=-d.hanging:d?.firstLine&&d.firstLine>0&&(k=d.firstLine);let S=0,B=r.renderedInlineImageKeys??new Set;for(let w=0;w<s.length;w++){let E=s[w],P=e.fromLine+w,z=P===x-1,I=P===0&&!e.continuesFromPrev,A=E.leftOffset??0,Z=E.rightOffset??0,ce=m;if(I){let de=d?.hanging&&d.hanging>0,me=d?.firstLine&&d.firstLine>0;de&&d?.hanging?ce=m+d.hanging:me&&d?.firstLine&&(ce=m-d.firstLine);}let ae=ff(t,E,l,i,{availableWidth:ce-A-Z,isLastLine:z,isFirstLine:I,paragraphEndsWithLineBreak:g,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:I?k:0,context:o,renderedInlineImageKeys:B});if(A>0||Z>0){A>0&&(ae.style.marginLeft=`${A}px`),Z>0&&(ae.style.marginRight=`${Z}px`);let de=ce-A-Z;de>0&&(ae.style.width=`${de}px`);}S+=E.lineHeight;let $=d?.hanging&&d.hanging>0,H=d?.firstLine&&d.firstLine>0;if(I?c>0&&$?(ae.style.paddingLeft=`${c}px`,ae.style.textIndent=`-${d.hanging}px`):c>0&&H?(ae.style.paddingLeft=`${c}px`,ae.style.textIndent=`${d.firstLine}px`):c>0?ae.style.paddingLeft=`${c}px`:H&&(ae.style.textIndent=`${d.firstLine}px`):c>0?ae.style.paddingLeft=`${c}px`:$&&(ae.style.paddingLeft=`${d.hanging}px`),p>0&&(ae.style.paddingRight=`${p}px`),I&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let de=Math.max(0,c-(d?.hanging??0));ae.style.paddingLeft=`${de}px`,ae.style.textIndent="0";let me;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let R=E.fromRun;R<=E.toRun;R++){let F=t.runs[R];if(F&&F.kind==="text"){me=F;break}}let ue=t.attrs.listMarkerFontFamily??me?.fontFamily??t.attrs.defaultFontFamily,N=t.attrs.listMarkerFontSize??me?.fontSize??t.attrs.defaultFontSize,Ve=zx(t.attrs.listMarker,d,i,ue,N);ae.insertBefore(Ve,ae.firstChild);}a.appendChild(ae);}return a}function zx(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=a$4(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 Tn={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 $x(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 d=u;if(!ir(d))continue;let c=d.position,p=d.distTop??0,f=d.distBottom??0,m=d.distLeft??12,b=d.distRight??12,g="left",x=0;if(c?.horizontal){let B=c.horizontal;B.align==="right"?(g="right",x=n-d.width):B.align==="left"?x=0:B.align==="center"?x=(n-d.width)/2:B.posOffset!==void 0&&(x=no(B.posOffset),g=x>n/2?"right":"left");}else d.cssFloat==="right"&&(g="right",x=n-d.width);let k=r;if(c?.vertical){let B=c.vertical;B.posOffset!==void 0?k=r+no(B.posOffset):B.align==="top"&&(k=0);}x=Math.max(0,Math.min(x,n-d.width));let S="bothSides";d.cssFloat==="left"?S="right":d.cssFloat==="right"&&(S="left"),o.push({src:d.src,width:d.width,height:d.height,alt:d.alt,transform:d.transform,x,y:k,side:g,distTop:p,distBottom:f,distLeft:m,distRight:b,wrapText:S,pmStart:d.pmStart,pmEnd:d.pmEnd});}let l=t.blocks[i];l&&l.kind==="paragraph"&&(r+=l.totalHeight);}return o}function _x(e,t,n,o){let r=o.createElement("div");r.className=Tn.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=$x(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,g=0,x=0,k=p.wrapText??"bothSides";return k==="right"?g=f:k==="left"?x=s-(p.x-p.distLeft):p.side==="left"?g=f:x=s-(p.x-p.distLeft),{leftMargin:g,rightMargin:x,topY:m,bottomY:b}});let c=o.createElement("div");c.className="layout-cell-floating-images-layer",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.width="100%",c.style.height="100%",c.style.pointerEvents="none",c.style.zIndex="10",c.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),c.appendChild(f);}r.appendChild(c);}let d=0;for(let c=0;c<e.blocks.length;c++){let p=e.blocks[c],f=t.blocks[c];if(p?.kind==="paragraph"&&f?.kind==="paragraph"){let m=p,b=f;u&&u.length>0&&(b=Cn(m,s,{floatingZones:u,paragraphYOffset:d}));let g={blockId:m.id,width:s,height:b.totalHeight,fromLine:0,toLine:b.lines.length,pmStart:m.pmStart,pmEnd:m.pmEnd},x={...n,insideTableCell:true},k=Nn(g,m,b,x,{document:o});k.style.position="relative",r.appendChild(k),d+=b.totalHeight;}else if(p?.kind==="table"&&f?.kind==="table"){let g=Wx(p,f,n,o);g.style.position="relative",r.appendChild(g),d+=f.totalHeight??0;}}return r}function Wx(e,t,n,o){let r=o.createElement("div");r.className=`${Tn.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 d=e.rows[u],c=t.rows[u];if(!d||!c)continue;let p=Ol(d,c,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=c.height;}return r.style.height=`${l}px`,r}function Xa(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 Vx(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Tn.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,d=e.padding?.bottom??1,c=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${d}px ${c}px`,e.borders&&(r.isFirstRow&&Xa(s,"top",e.borders.top),Xa(s,"right",e.borders.right),Xa(s,"bottom",e.borders.bottom),r.isFirstCol&&Xa(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=_x(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 Ol(e,t,n,o,r,i,a,s,l,u,d){let c=s.createElement("div");c.className=Tn.row,c.style.position="absolute",c.style.left="0",c.style.top=`${o}px`,c.style.width="100%",c.style.height=`${t.height}px`,c.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 g=0;g<b.colSpan;g++)p.add(b.columnIndex+g);}let f=0,m=0;for(;p.has(m);)f+=r[m]??0,m++;for(let b=0;b<e.cells.length;b++){let g=e.cells[b],x=t.cells[b];if(!g||!x)continue;let k=g.colSpan??1,S=g.rowSpan??1,B=t.height;if(S>1&&u){B=0;for(let A=n;A<n+S&&A<u.length-1;A++)B+=(u[A+1]??0)-(u[A]??0);B===0&&(B=t.height*S);}let w=n===0||d===true,P=m===0;m+k>=r.length;let I=Vx(g,x,f,B,{isFirstRow:w,isFirstCol:P},a,s);if(I.dataset.cellIndex=String(b),I.dataset.columnIndex=String(m),S>1&&(I.dataset.rowSpan=String(S)),c.appendChild(I),S>1&&l){let A=`${n}-${m}`;l.set(A,{cell:g,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:k,x:f,totalHeight:B});}for(let A=0;A<k&&m+A<r.length;A++)f+=r[m+A]??0;for(m+=k;p.has(m);)f+=r[m]??0,m++;}return c}function Za(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Tn.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=Tn.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 d=new Map,c=e.headerRowCount??0,p=0;if(c>0&&e.continuesFromPrev)for(let m=0;m<c;m++){let b=t.rows[m],g=n.rows[m];if(!b||!g)continue;let x=Ol(b,g,m,p,n.columnWidths,t.rows.length,o,i,d,l,m===0);x.dataset.repeatedHeader="true",a.appendChild(x),p+=g.height;}for(let m=e.fromRow;m<e.toRow;m++){let b=t.rows[m],g=n.rows[m];if(!b||!g)continue;let x=c>0&&e.continuesFromPrev?false:e.continuesFromPrev&&m===e.fromRow,k=Ol(b,g,m,p,n.columnWidths,t.rows.length,o,i,d,l,x);a.appendChild(k),p+=g.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=Tn.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=Tn.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((g,x)=>g+x,0),b=i.createElement("div");b.className=Tn.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 zl={image:"layout-image",imageAnchored:"layout-image-anchored"};function Ja(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=zl.image,e.isAnchored&&a.classList.add(zl.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 mf={textBox:"layout-textbox"};function Qa(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=mf.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 d=t.outlineStyle||"solid",c=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${d} ${c}`;}let s=t.margins??c$1;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 d=0;d<t.content.length;d++){let c=t.content[d],p=n.innerMeasures[d];if(!p)continue;let f={blockId:c.id,width:l,height:p.totalHeight,pmStart:c.pmStart,pmEnd:c.pmEnd,fromLine:0,toLine:p.lines.length},m=Nn(f,c,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 oo={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function ts(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=Yo(l,a[s],o.theme);for(let[d,c]of Object.entries(u))e.style[d]=String(c);}}}}function Ux(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 bf(e){return e?.align??e?.alignment}function jx(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=bf(n),r=n.posOffset!==void 0?no(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 Gx(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=bf(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${no(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=`${no(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 Kx(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 no(e){return e===void 0?0:Math.round(e*96/914400)}function ir(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function Yx(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!ir(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,d=i.distRight??12,c="left",p=0;if(a?.horizontal){let b=a.horizontal;b.align==="right"?(c="right",p=n-i.width):b.align==="left"?(c="left",p=0):b.align==="center"?(c="left",p=(n-i.width)/2):b.posOffset!==void 0&&(p=no(b.posOffset),c=p>n/2?"right":"left");}else i.cssFloat==="right"&&(c="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=no(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:c,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:d,pmStart:i.pmStart,pmEnd:i.pmEnd,wrapText:m,wrapType:i.wrapType});}return o}function qx(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 Xx(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 gf(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 d=e.blocks[u],c=e.measures[u];if(d?.kind==="paragraph"&&c?.kind==="paragraph"){let p=d,f=c,m=l,b=[];for(let S of p.runs)if(S.kind==="image"&&"position"in S&&S.position){let B=S;s.push({src:B.src,width:B.width,height:B.height,alt:B.alt,paragraphY:m,position:B.position});}else b.push(S);let g={...p,runs:b},x={blockId:p.id,width:a,height:f.totalHeight,fromLine:0,toLine:f.lines.length},k=Nn(x,g,f,t,{document:r});k.style.position="relative",k.style.marginBottom="0",i.appendChild(k),l+=f.totalHeight;}}for(let u of s){let d=r.createElement("img");d.src=u.src,d.width=u.width,d.height=u.height,u.alt&&(d.alt=u.alt),d.style.position="absolute",d.style.display="block",d.style.width=`${u.width}px`,d.style.height=`${u.height}px`,d.style.maxWidth="none",d.style.maxHeight="none",Gx(d,u,o),d.style.top=`${jx(u,o)}px`,i.appendChild(d);}return i}function Zx(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 $l(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??oo.page,r.dataset.pageNumber=String(e.number),ts(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=oo.content,Ux(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,g=f.y-e.margins.top,x=Yx(b,g,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 g=m.block.floating;if(!g)continue;let x=f.x-e.margins.left,k=f.y-e.margins.top,S=g.topFromText??0,B=g.bottomFromText??0,w=g.leftFromText??12,E=g.rightFromText??12,P=x<a/2?"left":"right";l.push({side:P,x,y:k,width:f.width,height:f.height,distTop:S,distBottom:B,distLeft:w,distRight:E});}let u=l.length>0?qx(l,a):[];if(s.length>0){let f=Xx(s,o);i.appendChild(f);}let d=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},c,p=new Map;for(let f=0;f<e.fragments.length;f++){let m=e.fragments[f],b,g={...t,section:"body",contentWidth:a},x=m.y-e.margins.top;if(n.blockLookup&&m.blockId){let k=n.blockLookup.get(String(m.blockId));if(m.kind==="paragraph"&&k?.block.kind==="paragraph"&&k?.measure.kind==="paragraph"){let S=k.block,B=f+1<e.fragments.length?d(e.fragments[f+1]):void 0,w=String(m.blockId),E=p.get(w);E||(E=new Set,p.set(w,E));let P=k.measure;u.length>0&&(P=Cn(S,a,{floatingZones:u,paragraphYOffset:x})),b=Nn(m,S,P,g,{document:o,prevBorders:c,nextBorders:B,renderedInlineImageKeys:E}),c=S.attrs?.borders;}else m.kind==="table"&&k?.block.kind==="table"&&k?.measure.kind==="table"?(b=Za(m,k.block,k.measure,g,{document:o}),c=void 0):m.kind==="image"&&k?.block.kind==="image"&&k?.measure.kind==="image"?(b=Ja(m,k.block,k.measure,g,{document:o}),c=void 0):m.kind==="textBox"&&k?.block.kind==="textBox"&&k?.measure.kind==="textBox"?(b=Qa(m,k.block,k.measure,g,{document:o}),c=void 0):(b=jr(m,g,{document:o}),c=void 0);}else b=jr(m,g,{document:o}),c=void 0;Kx(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,g=e.size.h-e.margins.top-e.margins.bottom;for(let x=0;x<f-1;x++){let k=(x+1)*b+x*m+m/2,S=o.createElement("div");S.style.position="absolute",S.style.left=`${k}px`,S.style.top="0",S.style.height=`${g}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=Zx(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,g=Math.max(e.margins.top-m,48),x=n.headerContent?.visualTop??0,k=n.headerContent?.visualBottom??n.headerContent?.height??0,S=Math.max(k-x,24),B=k>g,w=o.createElement("div");w.className=oo.header,w.style.position="absolute",w.style.top=`${m+x}px`,w.style.left=`${e.margins.left}px`,w.style.right=`${e.margins.right}px`,w.style.width=`${b}px`,w.style.height=`${S}px`,w.style.minHeight=`${S}px`;let E=!B;if(n.headerContent&&n.headerContent.blocks.length>0){let P=gf(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});P.style.top=`${-x}px`,P.querySelector("img")&&(E=false),w.appendChild(P);}E&&(w.style.maxHeight=`${g}px`,w.style.overflow="hidden"),r.appendChild(w);}{let m=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,g=Math.max(e.margins.bottom-m,48),x=n.footerContent?.visualTop??0,k=n.footerContent?.visualBottom??n.footerContent?.height??0,S=Math.max(k-x,24),B=S>g,w=o.createElement("div");w.className=oo.footer,w.style.position="absolute",w.style.top=`${e.size.h-m-S}px`,w.style.left=`${e.margins.left}px`,w.style.right=`${e.margins.right}px`,w.style.width=`${b}px`,w.style.height=`${S}px`,w.style.minHeight=`${S}px`;let E=!B;if(n.footerContent&&n.footerContent.blocks.length>0){let P=gf(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});P.style.top=`${-x}px`,P.querySelector("img")&&(E=false),w.appendChild(P);}E&&(w.style.maxHeight=`${g}px`,w.style.overflow="hidden"),r.appendChild(w);}return r}function _l(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body"},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 hf(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 Jx(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 Qx(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 es=2,eS=8;function yf(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=Jx(n),l=o>=eS;if(a&&a.optionsHash===s&&l){let g=a.pageStates,x=a.pageDataMap,k=i.__pageObserver,S=[];for(let E of e)S.push(hf(E));let B=a.totalPages!==o,w=Math.min(g.length,e.length);for(let E=0;E<w;E++){let P=g[E],z=S[E];if(P.fingerprint===z&&!B){let Z=x.get(P.element);Z&&(Z.page=e[E]);continue}let I=P.element,A=x.get(I);A&&(A.page=e[E],A.rendered&&tS(I,x,o,n)),P.fingerprint=z,ts(I,e[E].size.w,e[E].size.h,n),I.dataset.pageNumber=String(e[E].number);}if(e.length>g.length){let E=n.document??document;for(let P=g.length;P<e.length;P++){let z=e[P],I=E.createElement("div");I.className=n.pageClassName??oo.page,I.dataset.pageNumber=String(z.number),I.dataset.pageIndex=String(P),ts(I,z.size.w,z.size.h,n),t.appendChild(I),g.push({element:I,fingerprint:S[P]}),x.set(I,{page:z,index:P,rendered:false}),k&&k.observe(I);}}if(e.length<g.length){for(let E=g.length-1;E>=e.length;E--){let P=g[E].element;k&&k.unobserve(P),x.delete(P),t.removeChild(P);}g.length=e.length;}for(let E=0;E<g.length;E++){let P=x.get(g[E].element);P&&(P.index=E);}a.totalPages=o,a.currentOptions=n;return}let d=i.__pageObserver;d&&(d.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,Qx(t,r);let c=[],p=[];for(let g=0;g<e.length;g++){let x=e[g];if(p.push(hf(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??oo.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(g),ts(S,x.size.w,x.size.h,n),t.appendChild(S),c.push(S);}else {let{context:k,pageOptions:S}=_l(x,o,n),B=$l(x,k,S);t.appendChild(B),c.push(B);}}if(!l)return;let f=new Map;for(let g=0;g<e.length;g++)f.set(c[g],{page:e[g],index:g,rendered:false});let m=new IntersectionObserver(g=>{let x=i.__pageRenderState;if(!x)return;let{currentOptions:k,totalPages:S,pageDataMap:B}=x;for(let z of g){let I=z.target,A=B.get(I);if(A&&z.isIntersecting){ns(I,B,S,k);for(let Z=-es;Z<=es;Z++){let ce=A.index+Z;ce>=0&&ce<x.pageStates.length&&ce!==A.index&&ns(x.pageStates[ce].element,B,S,k);}}}let w=window.innerHeight,E=w*3,P=new Set;for(let[z,I]of B){if(!I.rendered)continue;let A=z.getBoundingClientRect();A.bottom>-E&&A.top<w+E&&P.add(I.index);}for(let[z,I]of B){if(!I.rendered)continue;let A=false;for(let Z of P)if(Math.abs(I.index-Z)<=es+1){A=true;break}!A&&P.size>0&&nS(z,B);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let g of c)m.observe(g);i.__pageObserver=m,i.__pageRenderState={pageStates:c.map((g,x)=>({element:g,fingerprint:p[x]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,es+3);for(let g=0;g<b;g++)ns(c[g],f,o,n);}function ns(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=_l(r.page,n,o),s=$l(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function tS(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=_l(r.page,n,o),l=$l(r.page,i,a).querySelector(`.${oo.content}`),u=e.querySelector(`.${oo.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,ns(e,t,n,o));}function nS(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var os=class{constructor(t={}){d$1(this,"container",null);d$1(this,"blockLookup",new Map);d$1(this,"pageStates",[]);d$1(this,"totalPages",0);d$1(this,"options");d$1(this,"doc");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"},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 Nn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return Za(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return Ja(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return Qa(t,r,i,n,{document:this.doc})}return jr(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 On,ro,io,zn,ar,Po,xf,Wl,rs=class{constructor(){f$1(this,Po);f$1(this,On,0);f$1(this,ro,0);f$1(this,io,false);f$1(this,zn,null);f$1(this,ar,new Set);}setStateSeq(t){g(this,On,t);}incrementStateSeq(){return ++i$1(this,On)._}getStateSeq(){return e$1(this,On)}getRenderSeq(){return e$1(this,ro)}onLayoutStart(){g(this,io,true);}onLayoutComplete(t){g(this,ro,t),g(this,io,false),h$1(this,Po,xf).call(this);}isSafeToRender(){return !e$1(this,io)&&e$1(this,ro)>=e$1(this,On)}requestRender(){this.isSafeToRender()?h$1(this,Po,Wl).call(this):g(this,zn,()=>h$1(this,Po,Wl).call(this));}onRender(t){return e$1(this,ar).add(t),()=>{e$1(this,ar).delete(t);}}reset(){g(this,On,0),g(this,ro,0),g(this,io,false),g(this,zn,null);}getDebugInfo(){return {stateSeq:e$1(this,On),renderSeq:e$1(this,ro),layoutUpdating:e$1(this,io),hasPendingRender:e$1(this,zn)!==null,isSafe:this.isSafeToRender()}}};On=new WeakMap,ro=new WeakMap,io=new WeakMap,zn=new WeakMap,ar=new WeakMap,Po=new WeakSet,xf=function(){if(e$1(this,zn)&&this.isSafeToRender()){let t=e$1(this,zn);g(this,zn,null),t();}},Wl=function(){for(let t of e$1(this,ar))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var kf=".layout-page-content .layout-line";function oS(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 rS(e){let t=oS(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 Cf({pagesContainerRef:e}){let t=useRef(null),n=useRef(-1),o=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let d of Array.from(l)){let c=d,p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(c.classList.contains("layout-run-tab")){if(s>=p&&s<f)return c.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&d.firstChild?.nodeType===Node.TEXT_NODE){let m=d.firstChild,b=Math.min(s-p,m.length),g=c.ownerDocument;if(!g)continue;let x=g.createRange();return x.setStart(m,b),x.setEnd(m,b),x.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let d of Array.from(u)){let c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f)return d.getBoundingClientRect().left}return null},[e]),r=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(kf);for(let u of Array.from(l)){let d=u,c=d.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(c)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return d}}for(let u of Array.from(l)){let d=u,c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f&&c.querySelector(".layout-line")===d)return d}return null},[e]),i=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(),g=Number(m.dataset.pmStart),x=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let k=(b.left+b.right)/2;return l<k?g:x}continue}if(l>=b.left&&l<=b.right){let k=m.firstChild;if(!k||k.nodeType!==Node.TEXT_NODE)return g;let S=k,B=m.ownerDocument;if(!B)return g;let w=0,E=S.length;for(;w<E;){let P=Math.floor((w+E)/2),z=B.createRange();z.setStart(S,P),z.setEnd(S,P),l<z.getBoundingClientRect().left?E=P:w=P+1;}if(w>0&&w<=S.length){let P=B.createRange();P.setStart(S,w-1),P.setEnd(S,w-1);let z=P.getBoundingClientRect().left;P.setStart(S,Math.min(w,S.length)),P.setEnd(S,Math.min(w,S.length));let I=P.getBoundingClientRect().left;if(Math.abs(l-z)<Math.abs(l-I))return g+(w-1)}return g+Math.min(w,x-g)}}let d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),g=l<b.left?b.left-l:l-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return l<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)},[]),a=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(kf));if(u.length===0)return false;let{from:d,anchor:c}=s.state.selection;if(t.current===null){let S=o(d);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(d);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:g,dispatch:x}=s,k=Math.max(0,Math.min(b,g.doc.content.size));try{let S=l.shiftKey?TextSelection.create(g.doc,c,k):TextSelection.create(g.doc,k);x(g.tr.setSelection(S));}catch{let S=g.doc.resolve(k),B=l.shiftKey?TextSelection.between(g.doc.resolve(c),S):TextSelection.near(S);x(g.tr.setSelection(B));}return rS(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var ao=40,ls=12;function iS(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 Tf({pagesContainerRef:e,onScrollExtendSelection:t}){let n=useRef(null),o=useRef({x:0,y:0}),r=useRef(false),i=useRef(null),a=useCallback(()=>{if(i.current)return i.current;let c=e.current;return c?(i.current=iS(c),i.current):null},[e]),s=useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=useCallback(()=>{if(!r.current)return;let c=a();if(!c)return;let p=c.getBoundingClientRect(),{x:f,y:m}=o.current,b=0;if(m<p.top+ao){let g=Math.max(0,p.top+ao-m);b=-Math.min(ls,g/ao*ls);}else if(m>p.bottom-ao){let g=Math.max(0,m-(p.bottom-ao));b=Math.min(ls,g/ao*ls);}b!==0&&(c.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:useCallback((c,p)=>{if(o.current={x:c,y:p},!r.current){let f=a();if(!f)return;let m=f.getBoundingClientRect();(p<m.top+ao||p>m.bottom-ao)&&u();}},[a,u]),stopAutoScroll:s}}var aS=12,cs=8;function wf(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 Vl(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 sS(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let d={kind:"text",text:`${t} `,fontSize:cs,superscript:true};l.push(d);}for(let d of s.content){let c=d;if(c.type==="run"&&Array.isArray(c.content)){let p=c.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=cs);for(let m of c.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:cs});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:cs}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=Cn(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 vf(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=sS(l,i,n);o.set(s.footnoteId,u),i++;}return o}function Rf(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+=aS,n.set(o,i));}return n}var Ul=class{constructor(t,n=1){d$1(this,"pagesContainer");d$1(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(),d=a.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,d=Math.min(t-s,u.length),c=a.ownerDocument;if(!c)continue;let p=c.createRange();p.setStart(u,d),p.setEnd(u,d);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(),d=i.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/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 d=a.firstChild,c=s.ownerDocument;if(!c)continue;let p=Math.max(0,t-l),f=Math.min(d.length,n-l);if(p<f){let m=c.createRange();m.setStart(d,p),m.setEnd(d,f);let b=m.getClientRects();for(let g of Array.from(b))r.push({x:(g.left-o.left)/this.zoom,y:(g.top-o.top)/this.zoom,width:g.width/this.zoom,height:g.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 Ef(e,t=1){return new Ul(e,t)}var pS=816,If=1056,ds={top:96,right:96,bottom:96,left:96},fS=24,co=30,mS=200,gS=[],hS={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},Ff=24,bS={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:Ff,paddingBottom:24},yS={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},xS={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function SS(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,d=s.marks.deletion;if(!l&&!u&&!d)return i;let c=new Set,p$1=Ff+r;return a.descendants((f,m)=>{if(f.isText)for(let b of f.marks){let g=null;if(l&&b.type===l?g=`comment-${b.attrs.commentId}`:(u&&b.type===u||d&&b.type===d)&&(g=`revision-${b.attrs.revisionId}`),!g||c.has(g))continue;c.add(g);let x=p(t,n,o,m);if(x){i.set(g,x.y+p$1);continue}for(let k=0;k<t.pages.length;k++){let S=t.pages[k],B=false;for(let w of S.fragments){let E=w.pmStart??0,P=w.pmEnd??E;if(m<E||m>P)continue;let z=w.kind==="table"?kS(n,o,w,m):0;i.set(g,w.y+z+l$2(t,k)+p$1),B=true;break}if(B)break}}}),i}function kS(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(c=>c.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 an(e){return Math.round(e/1440*96)}function CS(e){return {w:e?.pageWidth?an(e.pageWidth):pS,h:e?.pageHeight?an(e.pageHeight):If}}function TS(e){let t=e?.marginTop?an(e.marginTop):ds.top,n=e?.marginBottom?an(e.marginBottom):ds.bottom;return {top:t,right:e?.marginRight?an(e.marginRight):ds.right,bottom:n,left:e?.marginLeft?an(e.marginLeft):ds.left,header:e?.headerDistance?an(e.headerDistance):48,footer:e?.footerDistance?an(e.footerDistance):48}}function wS(e){let t=e?.columnCount??1;if(t<=1)return;let n=an(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function vS(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 RS(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function jl(e){return e===void 0?0:Math.round(e*96/914400)}function ES(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 Lf(e,t){let i=e.columnWidths??[],a=ES(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((m,b)=>m+(b.colSpan??1),0),f=(a??t)/Math.max(1,c);i=Array(c).fill(f);}else if(i.length>0&&a){let c=i.reduce((p,f)=>p+f,0);if(c>0&&Math.abs(c-a)>1){let p=a/c;i=i.map(f=>f*p);}}let s=new Map;for(let c=0;c<e.rows.length;c++){let p=e.rows[c];if(!p)continue;let f=0,m=s.get(c)??new Set;for(;m.has(f);)f++;for(let b of p.cells){let g=b.colSpan??1,x=b.rowSpan??1;if(x>1)for(let k=c+1;k<c+x;k++){s.has(k)||s.set(k,new Set);let S=s.get(k);for(let B=0;B<g;B++)S.add(f+B);}for(f+=g;m.has(f);)f++;}}let l=e.rows.map((c,p)=>{let f=0,m=s.get(p)??new Set;for(;m.has(f);)f++;return {cells:c.cells.map(b=>{let g=b.colSpan??1,x=0;for(let w=0;w<g&&f+w<i.length;w++)x+=i[f+w]??0;for(x===0&&(x=b.width??100),f+=g;m.has(f);)f++;let k=b.padding?.left??7,S=b.padding?.right??7,B=Math.max(1,x-k-S);return {blocks:b.blocks.map(w=>Bf(w,B)),width:x,height:0,colSpan:b.colSpan,rowSpan:b.rowSpan}}),height:0}});for(let c=0;c<l.length;c++){let p=l[c],f=e.rows[c]?.cells,m=0;for(let k=0;k<p.cells.length;k++){let S=p.cells[k],B=f?.[k];S.height=S.blocks.reduce((P,z)=>"totalHeight"in z?P+z.totalHeight:P,0);let w=B?.padding?.top??1,E=B?.padding?.bottom??1;S.height+=w+E,m=Math.max(m,S.height);}let b=e.rows[c],g=b?.height,x=b?.heightRule;g&&x==="exact"?p.height=g:g&&x==="atLeast"?p.height=Math.max(m,g):p.height=Math.max(m,24);}let u=l.reduce((c,p)=>c+p.height,0),d=i.reduce((c,p)=>c+p,0)||a||t;return {kind:"table",rows:l,columnWidths:i,totalWidth:d,totalHeight:u}}function PS(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(!RS(s))continue;let l=0,u=s.position,d=s.distTop??0,c=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=jl(x.posOffset));}let m=l+s.height,b=0,g=0;if(u?.horizontal){let x=u.horizontal;if(x.align==="left")b=s.width+f;else if(x.align==="right")g=s.width+p;else if(x.posOffset!==void 0){let k=jl(x.posOffset);k<t/2?b=k+s.width+f:g=t-k+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let x=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-d,bottomY:m+c,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=Lf(i,t),l=s.totalWidth,u=s.totalHeight,d=a.leftFromText??12,c=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,g=0;a.tblpX!==void 0?g=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?g=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?g=t-l:a.tblpXSpec==="center"&&(g=(t-l)/2):i.justification==="center"?g=(t-l)/2:i.justification==="right"&&(g=t-l),g<t/2?m=g+l+c:b=t-g+d;let x=a.tblpY??0,k=x+u;n.push({leftMargin:m,rightMargin:b,topY:x-p,bottomY:k+f,anchorBlockIndex:o});}return n}function Bf(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=Ml(r,t);if(a)return a}let i=Cn(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&Il(r,t,i),i}case "table":return Lf(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??c$1,a=(r.width??d$2)-i.left-i.right,s=r.content.map(d=>Cn(d,a)),l=s.reduce((d,c)=>d+c.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??d$2,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 Af(e,t){let n=Array.isArray(t)?t[0]??0:t,o=PS(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)),d=0,c=[];return e.map((p,f)=>{u.has(f)&&(d=0,c=l.get(f)??[]);let m=c.length>0?c:void 0;try{let b=performance.now(),g=Array.isArray(t)?t[f]??n:t,x=Bf(p,g,m,d),k=performance.now()-b;return k>500&&console.warn(`[measureBlocks] Block ${f} (${p.kind}) took ${Math.round(k)}ms`),"totalHeight"in x&&(p.kind==="table"&&p.floating||(d+=x.totalHeight)),x}catch(b){return console.error(`[measureBlocks] Error measuring block ${f} (${p.kind}):`,b),{totalHeight:20}}})}function ps(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,d=m=>Math.round(m/914400*96),c=u?.width?d(u.width):100,p=u?.height?d(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:c,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=ps(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=ps(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=ps(o.children);t.push(...r);}}return t}function MS(e){return e?.align??e?.alignment}function IS(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=MS(i),s=i.posOffset!==void 0?jl(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 FS(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 d=l,c=a,p=c+u.totalHeight;r=Math.min(r,c),i=Math.max(i,p);for(let f of d.runs){if(f.kind!=="image"||!f.position)continue;let m=f,b=IS(m,c,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function us(e,t,n){if(!e||!e.content||e.content.length===0)return;let o=[];for(let u of e.content){let d=u;if(d.type==="paragraph"&&Array.isArray(d.content)){let c=d.formatting,p={};if(c){if(c.alignment){let m=c.alignment;m==="both"?p.alignment="justify":["left","center","right","justify"].includes(m)&&(p.alignment=m);}if(c.borders){let m=c.borders,b={};for(let g of ["top","bottom","left","right","between"]){let x=m[g];if(x){let k=Ga(x);k&&(b[g]=k);}}Object.keys(b).length>0&&(p.borders=b);}(c.spaceAfter!=null||c.spaceBefore!=null)&&(p.spacing={before:c.spaceBefore,after:c.spaceAfter}),Array.isArray(c.tabs)&&c.tabs.length>0&&(p.tabs=c.tabs.map(m=>({val:m.alignment==="left"?"start":m.alignment==="right"?"end":m.alignment,pos:m.position,leader:m.leader})));}let f=ps(d.content);if(f.length>0){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 d=u;if(!d.runs.some(f=>f.kind==="image"&&"position"in f&&f.position))return u;let p=d.runs.filter(f=>!(f.kind==="image"&&"position"in f&&f.position));return p.length===0&&p.push({kind:"text",text:""}),{...d,runs:p}}),i=Af(r,t),a=i.reduce((u,d)=>d.kind==="paragraph"?u+d.totalHeight:u,0),{visualTop:s,visualBottom:l}=FS(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function LS(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 c=t.get(l)?.displayNumber??0,p=b(u);s.push({displayNumber:String(c),text:p});}s.length>0&&o.set(i,s);}return o}var BS=forwardRef(function(t,n$1){let{document:o$1,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,firstPageHeaderContent:u,firstPageFooterContent:d,readOnly:c=false,pageGap:p$1=fS,zoom:f=1,onDocumentChange:m$1,onSelectionChange:b,externalPlugins:g=gS,extensionManager:x,onReady:k,onRenderedDomContextReady:S,pluginOverlays:B,onHeaderFooterDoubleClick:w,hfEditMode:E,onBodyClick:P,className:z,style:I,commentsSidebarOpen:A=false,sidebarOverlay:Z,scrollContainerRef:ce,onHyperlinkClick:ae,onContextMenu:$,onAnchorPositionsChange:H}=t,de=useCallback(()=>ce&&typeof ce=="object"?ce.current:me.current,[ce]),me=useRef(null),ue=useRef(null),N=useRef(null),Ve=useRef(null),{handlePMKeyDown:R}=Cf({pagesContainerRef:ue}),F=useRef(()=>{}),C=useRef(b),M=useRef(m$1),L=useRef(k),D=useRef(S);C.current=b,M.current=m$1,L.current=k,D.current=S;let[Y,se]=useState(null),[W,q]=useState([]),[Q,we]=useState([]),[oe,re]=useState(false),[pe,be]=useState([]),[Ue,Be]=useState(null),[Ge,Oe]=useState(null),Ae=useRef(false),Re=useCallback((T,V)=>{let U=T.tagName==="IMG"?T:T.querySelector("img"),j=(U??T).getBoundingClientRect();return {element:U??T,pmPos:V,width:Math.round(j.width/f),height:Math.round(j.height/f)}},[f]),Pe=useRef(false),Ke=useRef(null),Ye=useRef(false),bt=useRef(0),Ze=useRef(0),ut=useRef(0),Tt=useRef({left:0,right:0}),Fe=useRef(null),pt=useRef(false),De=useRef(0),St=useRef(0),dn=useRef(0),zt=useRef(0),vn=useRef(null),dr=useRef(false),fo=useRef(false),Bo=useRef(0),mo=useRef(0),Rn=useRef(0),En=useRef(0),$t=useRef(null),Pn=useRef(false),At=useRef(null),go=useRef(null),un=useRef(null),Ao=5,[pn,at]=useState(null),_t=useRef(null),Wt=useCallback(()=>{_t.current&&(clearTimeout(_t.current),_t.current=null);},[]);useEffect(()=>()=>{_t.current&&clearTimeout(_t.current);},[]);let lt=useMemo(()=>new rs,[]),Vt=useMemo(()=>CS(a),[a]),st=useMemo(()=>TS(a),[a]),fn=useMemo(()=>wS(a),[a]),le=Vt.w-st.left-st.right,ur=useMemo(()=>new os({pageGap:p$1,showShadow:true,pageBackground:"#fff"}),[p$1]);Ve.current=ur;let Ut=useCallback(T=>{let V=performance.now(),U=lt.getStateSeq();lt.onLayoutStart();try{let j=performance.now(),ee=Vt.h-st.top-st.bottom,_=jp(T.doc,{theme:i,pageContentHeight:ee}),K=performance.now()-j;K>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(K)}ms (${_.length} blocks)`),q(_),j=performance.now();let te=vS(_,le,fn),ie=Af(_,te);K=performance.now()-j,K>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(K)}ms (${_.length} blocks)`),we(ie);let xe=wf(_),he=xe.length>0&&o$1?.package?.footnotes,ke={section:"header",pageSize:Vt,margins:st},Ee={section:"footer",pageSize:Vt,margins:st},Ce=us(s,le,ke),Me=us(l,le,Ee),We=a?.titlePg===!0,mt=We?us(u,le,ke):void 0,yt=We?us(d,le,Ee):void 0,tn=st.header??48,No=st.footer??48,oi=st.top-tn,ri=st.bottom-No,ii=ct=>ct?ct.visualBottom??ct.height:0,ai=ct=>ct?Math.max((ct.visualBottom??ct.height)-(ct.visualTop??0),ct.height):0,mr=Math.max(ii(Ce),ii(mt)),gr=Math.max(ai(Me),ai(yt)),Oo=st;if(mr>oi||gr>ri){Oo={...st};let ct=8;mr>oi&&(Oo.top=Math.max(st.top,tn+mr+ct)),gr>ri&&(Oo.bottom=Math.max(st.bottom,No+gr+ct));}j=performance.now();let Yt,xo=new Map,hr=new Map,Cs=a?.sectionStart,br={pageSize:Vt,margins:Oo,columns:fn,bodyBreakType:Cs,pageGap:p$1};if(he){let ct=e(_,ie,br);xo=Vl(ct.pages,xe),hr=vf(o$1.package.footnotes,xe,le);let So=Rf(xo,hr);if(So.size>0){Yt=e(_,ie,{...br,footnoteReservedHeights:So}),xo=Vl(Yt.pages,xe);for(let[mn,ko]of xo){let Vn=Yt.pages.find(li=>li.number===mn);Vn&&(Vn.footnoteIds=ko);}}else Yt=ct;}else Yt=e(_,ie,br);if(K=performance.now()-j,K>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(K)}ms (${Yt.pages.length} pages)`),se(Yt),ue.current&&Ve.current){j=performance.now();let ct=new Map;for(let mn=0;mn<_.length;mn++){let ko=_[mn],Vn=ie[mn];ko&&Vn&&ct.set(String(ko.id),{block:ko,measure:Vn});}Ve.current.setBlockLookup(ct);let So=he?LS(xo,hr,o$1):void 0;if(yf(Yt.pages,ue.current,{pageGap:p$1,showShadow:!0,pageBackground:"#fff",blockLookup:ct,headerContent:Ce,footerContent:Me,firstPageHeaderContent:mt,firstPageFooterContent:yt,titlePg:We,headerDistance:a?.headerDistance?an(a.headerDistance):void 0,footerDistance:a?.footerDistance?an(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:So?.size?So:void 0}),K=performance.now()-j,K>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(K)}ms`),S){let mn=Ef(ue.current,f);S(mn);}}if(H){let ct=SS(N.current?.getView()??null,Yt,_,ie,p$1);H(ct);}let si=performance.now()-V;si>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(si)}ms total (${_.length} blocks, ${ie.length} measures)`);}catch(j){console.error("[PagedEditor] Layout pipeline error:",j);}lt.onLayoutComplete(U);},[le,fn,Vt,st,p$1,f,lt,s,l,u,d,a,S,o$1]),Jt=useRef(null),Jr=useCallback(T=>{if(Jt.current){Jt.current.state=T;return}let V=requestAnimationFrame(()=>{let U=Jt.current;Jt.current=null,U&&Ut(U.state);});Jt.current={rafId:V,state:T};},[Ut]);useEffect(()=>()=>{Jt.current&&(cancelAnimationFrame(Jt.current.rafId),Jt.current=null);},[]);let je=useCallback((T,V=1)=>{if(!ue.current)return null;let U=ue.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!U)return null;let j=U.getBoundingClientRect(),ee=ue.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let K of Array.from(ee)){let te=K,ie=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(te.classList.contains("layout-run-tab")){if(T>=ie&&T<xe){let he=te.getBoundingClientRect(),ke=te.closest(".layout-page"),Ee=ke?Number(ke.dataset.pageNumber)-1:0,Ce=te.closest(".layout-line"),Me=Ce?Ce.offsetHeight:16;return {x:(he.left-j.left)/V,y:(he.top-j.top)/V,height:Me,pageIndex:Ee}}continue}if(T>=ie&&T<=xe&&K.firstChild?.nodeType===Node.TEXT_NODE){let he=K.firstChild,ke=Math.min(T-ie,he.length),Ee=te.ownerDocument;if(!Ee)continue;let Ce=Ee.createRange();Ce.setStart(he,ke),Ce.setEnd(he,ke);let Me=Ce.getBoundingClientRect(),We=te.closest(".layout-page"),mt=We?Number(We.dataset.pageNumber)-1:0,yt=te.closest(".layout-line"),tn=yt?yt.offsetHeight:16;return {x:(Me.left-j.left)/V,y:(Me.top-j.top)/V,height:tn,pageIndex:mt}}}let _=ue.current.querySelectorAll(".layout-empty-run");for(let K of Array.from(_)){let te=K.closest(".layout-paragraph");if(!te)continue;let ie=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(T>=ie&&T<=xe){let he=K.getBoundingClientRect(),ke=te.closest(".layout-page"),Ee=ke?Number(ke.dataset.pageNumber)-1:0,Ce=K.closest(".layout-line"),Me=Ce?Ce.offsetHeight:16;return {x:(he.left-j.left)/V,y:(he.top-j.top)/V,height:Me,pageIndex:Ee}}}return null},[]),ft=useCallback(T=>{let{from:V,to:U}=T.selection;if(C.current?.(V,U),ue.current){let j=ue.current.querySelectorAll(".layout-table-cell-selected");for(let K of Array.from(j))K.classList.remove("layout-table-cell-selected");let ee=T.selection;if("$anchorCell"in ee&&typeof ee.forEachCell=="function"){let K=[];ee.forEachCell((ie,xe)=>{K.push([xe,xe+ie.nodeSize]);});let te=ue.current.querySelectorAll(".layout-table-cell");for(let ie of Array.from(te)){let xe=ie,he=xe.dataset.pmStart;if(he!==void 0){let ke=Number(he);for(let[Ee,Ce]of K)if(ke>=Ee&&ke<Ce){xe.classList.add("layout-table-cell-selected");break}}}}}if(!(!Y||W.length===0))if(V===U){let j=je(V,f);if(j)Be(j);else {let ee=ue.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),_=ue.current?.querySelector(".layout-page");if(ee&&_){let K=ee.getBoundingClientRect(),te=_.getBoundingClientRect(),ie=p(Y,W,Q,V);Be(ie?{...ie,x:ie.x+(te.left-K.left)/f,y:ie.y+(te.top-K.top)/f}:null);}else Be(null);}be([]);}else {let j=ue.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(j&&ue.current){let ee=j.getBoundingClientRect(),_=[],K=ue.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let te of Array.from(K)){let ie=te,xe=Number(ie.dataset.pmStart);if(Number(ie.dataset.pmEnd)>V&&xe<U){if(ie.classList.contains("layout-run-tab")){let We=ie.getBoundingClientRect(),mt=ie.closest(".layout-page"),yt=mt?Number(mt.dataset.pageNumber)-1:0;_.push({x:(We.left-ee.left)/f,y:(We.top-ee.top)/f,width:We.width/f,height:We.height/f,pageIndex:yt});continue}let ke=null;if(te.firstChild?.nodeType===Node.TEXT_NODE?ke=te.firstChild:te.firstChild?.nodeType===Node.ELEMENT_NODE&&te.firstChild.tagName==="A"&&te.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(ke=te.firstChild.firstChild),!ke)continue;let Ee=ie.ownerDocument;if(!Ee)continue;let Ce=Math.max(0,V-xe),Me=Math.min(ke.length,U-xe);if(Ce<Me){let We=Ee.createRange();We.setStart(ke,Ce),We.setEnd(ke,Me);let mt=We.getClientRects();for(let yt of Array.from(mt)){let tn=ie.closest(".layout-page"),No=tn?Number(tn.dataset.pageNumber)-1:0;_.push({x:(yt.left-ee.left)/f,y:(yt.top-ee.top)/f,width:yt.width/f,height:yt.height/f,pageIndex:No});}}}}if(_.length>0)be(_);else {let te=ue.current.querySelector(".layout-page");if(te){let ie=te.getBoundingClientRect(),xe=(ie.left-ee.left)/f,he=(ie.top-ee.top)/f,Ee=o(Y,W,Q,V,U).map(Ce=>({...Ce,x:Ce.x+xe,y:Ce.y+he}));be(Ee);}else be([]);}}else be([]);Be(null);}},[Y,W,Q,je,f]),$n=useCallback((T,V)=>{if(T.docChanged){lt.incrementStateSeq(),Jr(V);let U=N.current?.getDocument();U&&M.current?.(U);}lt.requestRender(),T.docChanged||ft(V);},[Jr,ft,lt]),Qt=useCallback(T=>{let{selection:V}=T;V instanceof NodeSelection&&V.node.type.name==="image"?(be([]),Be(null)):lt.isSafeToRender()&&ft(T),requestAnimationFrame(()=>{let U=N.current?.getView();if(!U){Oe(null);return}let{selection:j}=U.state;if(j instanceof NodeSelection&&j.node.type.name==="image"){let ee=j.from,_=ue.current?.querySelector(`[data-pm-start="${ee}"]`);if(_){Oe(Re(_,ee));return}}Ae.current||Oe(null);});},[ft,f,Re,lt]),Ft=useCallback((T,V)=>{if(!ue.current||!Y)return null;let U=nf(ue.current,T,V,f);if(U!==null)return U;let j=ue.current.querySelectorAll(".layout-page"),ee=-1,_=null;for(let ke=0;ke<j.length;ke++){let Ce=j[ke].getBoundingClientRect();if(T>=Ce.left&&T<=Ce.right&&V>=Ce.top&&V<=Ce.bottom){ee=ke,_=Ce;break}}if(ee<0||!_)return null;let K=(T-_.left)/f,te=(V-_.top)/f,ie=Y.pages[ee];if(!ie)return null;let xe={pageIndex:ee,page:ie,pageY:te},he=m(xe,W,Q,{x:K,y:te});if(!he)return null;if(he.fragment.kind==="table"){let ke=n(xe,W,Q,{x:K,y:te});return Ll(he,ke)}return Ll(he)},[Y,W,Q,f]),Mn=useCallback(T=>{let V=N.current?.getView();if(!V)return null;try{let U=V.state.doc.resolve(T);for(let j=U.depth;j>0;j--){let ee=U.node(j);if(ee.type.name==="tableCell"||ee.type.name==="tableHeader")return U.before(j)}}catch{}return null},[]),Do=useCallback(T=>{let V=["layout-block-image","layout-image","layout-page-floating-image"],U=j=>!!j.dataset.pmStart&&V.some(ee=>j.classList.contains(ee));return T.tagName==="IMG"&&T.classList.contains("layout-run-image")?T:T.tagName==="IMG"&&T.parentElement&&U(T.parentElement)?T.parentElement:U(T)?T:null},[]),en=useCallback(T=>{let V=ue.current;if(!V)return;let U=V.querySelector(`[data-pm-start="${T}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"center"});},[]),bs=useCallback(T=>{if(!N.current)return;if(T.button===2){T.preventDefault();return}if(T.button!==0||(at(null),Wt(),T.target.closest("a[href]")&&T.preventDefault(),c))return;if(E&&P){let _=T.target;if(!(_.closest(".layout-page-header")||_.closest(".layout-page-footer")||_.closest(".hf-inline-editor"))){T.preventDefault(),T.stopPropagation(),P();return}}if(!E){let _=T.target;if(_.closest(".layout-page-header")||_.closest(".layout-page-footer")){T.preventDefault(),N.current&&(N.current.setSelection(0),N.current.focus(),re(true));return}}let U=T.target;if(U.classList.contains("layout-table-resize-handle")){T.preventDefault(),T.stopPropagation(),Ye.current=true,bt.current=T.clientX,Fe.current=U,U.classList.add("dragging");let _=parseInt(U.dataset.columnIndex??"0",10);Ze.current=_,ut.current=parseInt(U.dataset.tablePmStart??"0",10);let K=N.current.getView();if(K){let te=K.state.doc.resolve(ut.current+1);for(let ie=te.depth;ie>=0;ie--){let xe=te.node(ie);if(xe.type.name==="table"){let he=xe.attrs.columnWidths;he&&he[_]!==void 0&&he[_+1]!==void 0&&(Tt.current={left:he[_],right:he[_+1]});break}}}return}if(U.classList.contains("layout-table-row-resize-handle")||U.classList.contains("layout-table-edge-handle-bottom")){T.preventDefault(),T.stopPropagation(),pt.current=true,De.current=T.clientY,vn.current=U,dr.current=U.dataset.isEdge==="bottom",U.classList.add("dragging");let _=parseInt(U.dataset.rowIndex??"0",10);St.current=_,dn.current=parseInt(U.dataset.tablePmStart??"0",10);let K=N.current.getView();if(K){let te=K.state.doc.resolve(dn.current+1);for(let ie=te.depth;ie>=0;ie--){let xe=te.node(ie);if(xe.type.name==="table"){let he=null,ke=0;if(xe.forEach(Ee=>{ke===_&&(he=Ee),ke++;}),he){let Ee=he.attrs.height;if(Ee)zt.current=Ee;else {let Me=U.closest(".layout-table")?.querySelector(`[data-row-index="${_}"]`),We=Me?Me.getBoundingClientRect().height:30;zt.current=Math.round(We*15);}}break}}}return}if(U.classList.contains("layout-table-edge-handle-right")){T.preventDefault(),T.stopPropagation(),fo.current=true,Bo.current=T.clientX,$t.current=U,U.classList.add("dragging");let _=parseInt(U.dataset.columnIndex??"0",10);mo.current=_,Rn.current=parseInt(U.dataset.tablePmStart??"0",10);let K=N.current.getView();if(K){let te=K.state.doc.resolve(Rn.current+1);for(let ie=te.depth;ie>=0;ie--){let xe=te.node(ie);if(xe.type.name==="table"){let he=xe.attrs.columnWidths;he&&he[_]!==void 0&&(En.current=he[_]);break}}}return}let j=Do(U);if(j){T.preventDefault(),T.stopPropagation();let _=j.dataset.pmStart;if(_!==void 0){let K=parseInt(_,10);N.current.setNodeSelection(K),Oe(Re(j,K)),be([]),Be(null);}N.current.focus(),re(true);return}Oe(null),T.preventDefault();let ee=Ft(T.clientX,T.clientY);if(ee!==null){let _=Mn(ee);At.current=_,Pn.current=false,go.current=null,un.current=null,Pe.current=true,Ke.current=ee,N.current.setSelection(ee);}else {At.current=null,Pn.current=false;let _=N.current.getView();if(_){let K=Math.max(0,_.state.doc.content.size-1);N.current.setSelection(K),Ke.current=K,Pe.current=true;}}N.current.focus(),re(true);},[Ft,Mn,c,E,P,f,ae,Wt]),ho=useCallback((T,V)=>{F.current(T,V);},[]),{updateMousePosition:pr,stopAutoScroll:Ho}=Tf({pagesContainerRef:ue,onScrollExtendSelection:ho});F.current=(T,V)=>{if(!Pe.current||Ke.current===null||!N.current)return;let U=Ft(T,V);U!==null&&N.current.setSelection(Ke.current,U);};let _n=useCallback(T=>{if(Ye.current){T.preventDefault();let j=T.clientX-bt.current;if(Fe.current){let ee=parseFloat(Fe.current.style.left);Fe.current.style.left=`${ee+j}px`,bt.current=T.clientX;let _=Math.round(j*15),K=300,te=Tt.current.left+_,ie=Tt.current.right-_;te>=K&&ie>=K&&(Tt.current={left:te,right:ie});}return}if(pt.current){T.preventDefault();let j=T.clientY-De.current;if(vn.current){let ee=parseFloat(vn.current.style.top);vn.current.style.top=`${ee+j}px`,De.current=T.clientY;let _=Math.round(j*15),K=200,te=zt.current+_;te>=K&&(zt.current=te);}return}if(fo.current){T.preventDefault();let j=T.clientX-Bo.current;if($t.current){let ee=parseFloat($t.current.style.left);$t.current.style.left=`${ee+j}px`,Bo.current=T.clientX;let _=Math.round(j*15),K=300,te=En.current+_;te>=K&&(En.current=te);}return}if(!Pe.current||Ke.current===null||!N.current||!ue.current)return;pr(T.clientX,T.clientY);let V=Ft(T.clientX,T.clientY);if(V===null)return;if(At.current!==null){if(Pn.current){let ee=Mn(V);if(ee!==null){N.current.setCellSelection(At.current,ee);return}}let j=Mn(V);if(j!==null&&j!==At.current){Pn.current=true,N.current.setCellSelection(At.current,j),un.current=null;return}if(go.current!==null&&V===go.current){if(un.current===null)un.current=T.clientX;else if(Math.abs(T.clientX-un.current)>=Ao){Pn.current=true,N.current.setCellSelection(At.current,At.current),un.current=null;return}}else un.current=null,go.current=V;}let U=Ke.current;N.current.setSelection(U,V);},[Ft,Mn,pr]),Et=useCallback(()=>{if(Ye.current){Ye.current=false,Fe.current&&(Fe.current.classList.remove("dragging"),Fe.current=null);let T=N.current?.getView();if(T){let V=ut.current,U=Ze.current,{left:j,right:ee}=Tt.current,_=T.state.doc.resolve(V+1);for(let K=_.depth;K>=0;K--){let te=_.node(K);if(te.type.name==="table"){let ie=_.before(K),xe=T.state.tr,he=[...te.attrs.columnWidths];he[U]=j,he[U+1]=ee,xe.setNodeMarkup(ie,void 0,{...te.attrs,columnWidths:he});let ke=ie+1;te.forEach(Ee=>{let Ce=ke+1,Me=0;Ee.forEach(We=>{let mt=We.attrs.colspan||1;if(Me===U||Me===U+1){let yt=Me===U?j:ee;xe.setNodeMarkup(xe.mapping.map(Ce),void 0,{...We.attrs,width:yt,widthType:"dxa",colwidth:null});}Ce+=We.nodeSize,Me+=mt;}),ke+=Ee.nodeSize;}),T.dispatch(xe);break}}}return}if(pt.current){pt.current=false,vn.current&&(vn.current.classList.remove("dragging"),vn.current=null);let T=N.current?.getView();if(T){let V=dn.current,U=St.current,j=zt.current,ee=T.state.doc.resolve(V+1);for(let _=ee.depth;_>=0;_--){let K=ee.node(_);if(K.type.name==="table"){let te=ee.before(_),ie=T.state.tr,xe=te+1,he=0;K.forEach(ke=>{he===U&&ie.setNodeMarkup(ie.mapping.map(xe),void 0,{...ke.attrs,height:j,heightRule:"atLeast"}),xe+=ke.nodeSize,he++;}),T.dispatch(ie);break}}}return}if(fo.current){fo.current=false,$t.current&&($t.current.classList.remove("dragging"),$t.current=null);let T=N.current?.getView();if(T){let V=Rn.current,U=mo.current,j=En.current,ee=T.state.doc.resolve(V+1);for(let _=ee.depth;_>=0;_--){let K=ee.node(_);if(K.type.name==="table"){let te=ee.before(_),ie=T.state.tr,xe=[...K.attrs.columnWidths];xe[U]=j,ie.setNodeMarkup(te,void 0,{...K.attrs,columnWidths:xe});let he=te+1;K.forEach(ke=>{let Ee=he+1,Ce=0;ke.forEach(Me=>{let We=Me.attrs.colspan||1;Ce===U&&ie.setNodeMarkup(ie.mapping.map(Ee),void 0,{...Me.attrs,width:j,widthType:"dxa",colwidth:null}),Ee+=Me.nodeSize,Ce+=We;}),he+=ke.nodeSize;}),T.dispatch(ie);break}}}return}Pe.current=false,Pn.current=false,go.current=null,un.current=null,Ho();},[Ho]);useEffect(()=>(window.addEventListener("mousemove",_n),window.addEventListener("mouseup",Et),()=>{window.removeEventListener("mousemove",_n),window.removeEventListener("mouseup",Et);}),[_n,Et]);let Qr=useCallback(T=>{if(c||Pe.current||Ye.current||pt.current||fo.current||Pn.current)return;let V=ue.current;if(!V)return;let U=T.clientX,j=T.clientY,ee=T.target.closest(".layout-table");if(!ee){let Ee=V.querySelectorAll(".layout-table");for(let Ce of Array.from(Ee)){let Me=Ce.getBoundingClientRect(),We=U>=Me.left-co&&U<Me.left,mt=j>=Me.top-co&&j<Me.top,yt=U>=Me.left-co&&U<=Me.right,tn=j>=Me.top-co&&j<=Me.bottom;if(We&&tn||mt&&yt){ee=Ce;break}}}if(!ee){at(null);return}let _=ee.getBoundingClientRect(),K=U<_.left+co&&U>=_.left-co,te=j<_.top+co&&j>=_.top-co;if(!K&&!te){at(null);return}let ie=ee.querySelectorAll(":scope > .layout-table-row");if(ie.length===0){at(null);return}let xe=V.parentElement;if(!xe)return;let he=xe.getBoundingClientRect(),ke=Ee=>Ee&&Number(Ee.dataset.pmStart)||0;if(K)for(let Ee=0;Ee<ie.length;Ee++){let Ce=ie[Ee].getBoundingClientRect();if(j>=Ce.top&&j<=Ce.bottom){let Me=ie[Ee].querySelector(".layout-table-cell"),We=ke(Me);if(!We)break;let mt=Ce.top+Ce.height/2;at({type:"row",x:_.left-he.left-24,y:mt-he.top-10,cellPmPos:We}),Wt();return}}if(te){let Ee=ie[0].querySelectorAll(":scope > .layout-table-cell");for(let Ce=0;Ce<Ee.length;Ce++){let Me=Ee[Ce].getBoundingClientRect();if(U>=Me.left&&U<=Me.right){let We=ke(Ee[Ce]);if(!We)break;let mt=Me.left+Me.width/2;at({type:"column",x:mt-he.left-10,y:_.top-he.top-24,cellPmPos:We}),Wt();return}}}_t.current||(_t.current=setTimeout(()=>{at(null),_t.current=null;},mS));},[c,Wt]),fr=useCallback(T=>{if(T.preventDefault(),T.stopPropagation(),!pn||!N.current)return;let V=N.current.getView();if(!V)return;let{type:U,cellPmPos:j}=pn,ee=V.state.tr.setSelection(TextSelection.create(V.state.doc,j+1));V.dispatch(ee),U==="row"?vo(V.state,V.dispatch):Ro(V.state,V.dispatch),at(null),N.current.focus();},[pn]),In=useCallback(T=>{let V=T.target.closest("a[href]");if(V){T.preventDefault();let U=V.getAttribute("href")||"";if(U.startsWith("#")){let j=U.substring(1);if(j&&N.current){let ee=N.current.getView();if(ee){let _=null;ee.state.doc.descendants((K,te)=>{if(_!==null)return false;if(K.type.name==="paragraph"&&K.attrs.bookmarks?.some(xe=>xe.name===j))return _=te,false}),_!==null&&(en(_),N.current.setSelection(_+1));}}}else if(ae){let j=N.current?.getView();if(!(j&&j.state.selection.from!==j.state.selection.to)){let _=V.textContent||"",K=V.getAttribute("title")||void 0,te=V.getBoundingClientRect();ae({href:U,displayText:_,tooltip:K,anchorRect:te});}}return}if(T.detail===2&&w){let U=T.target,j=U.closest(".layout-page-header"),ee=U.closest(".layout-page-footer");if(j||ee){let _=U.closest("[data-page-number]"),K=_?Number(_.dataset.pageNumber):1;if(j){T.preventDefault(),T.stopPropagation(),w("header",K);return}if(ee){T.preventDefault(),T.stopPropagation(),w("footer",K);return}}}if(T.detail===2&&N.current){let U=Ft(T.clientX,T.clientY);if(U!==null){let j=Mn(U);if(j!==null){T.preventDefault(),T.stopPropagation(),N.current.setCellSelection(j,j);return}let ee=N.current.getView();if(ee){let{doc:_}=ee.state,K=_.resolve(U),te=K.parent;if(te.isTextblock){let ie=te.textContent,xe=K.parentOffset,he=xe;for(;he>0&&/\w/.test(ie[he-1]);)he--;let ke=xe;for(;ke<ie.length&&/\w/.test(ie[ke]);)ke++;let Ee=K.start()+he,Ce=K.start()+ke;Ee<Ce&&N.current.setSelection(Ee,Ce);}}}}if(T.detail===3&&N.current){let U=Ft(T.clientX,T.clientY);if(U!==null){let j=N.current.getView();if(j){let{doc:ee}=j.state,_=ee.resolve(U),K=_.start(_.depth),te=_.end(_.depth);N.current.setSelection(K,te);}}}},[Ft,w,ae]),ei=useCallback(T=>{if(!$)return;T.preventDefault();let V=N.current?.getView();if(!V)return;let{from:U,to:j}=V.state.selection,ee=Ft(T.clientX,T.clientY);ee!==null&&(U===j||ee<U||ee>j)&&(N.current?.setSelection(ee),N.current?.focus(),re(true));let _=N.current?.getState(),K=_?_.selection.from!==_.selection.to:false;$({x:T.clientX,y:T.clientY,hasSelection:K});},[$,Ft]),bo=useCallback(T=>{c||T.target.closest(".docx-comments-sidebar")||(N.current?.focus(),re(true));},[c]),ys=useCallback(T=>{let V=T.relatedTarget;V&&me.current?.contains(V)||V?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||re(false);},[]),Ie=useCallback((T,V,U)=>{let j=N.current?.getView();if(j)try{let ee=j.state.doc.nodeAt(T);if(!ee||ee.type.name!=="image")return;let _=j.state.tr.setNodeMarkup(T,void 0,{...ee.attrs,width:V,height:U});j.dispatch(_),N.current?.setNodeSelection(T);}catch{}},[]),Je=useCallback(()=>{Ae.current=true;},[]),xs=useCallback(()=>{Ae.current=false;},[]),Ss=useCallback((T,V,U)=>{let j=N.current?.getView();if(j)try{let ee=j.state.doc.nodeAt(T);if(!ee||ee.type.name!=="image")return;if(ee.attrs.displayMode==="float"||ee.attrs.wrapType&&["square","tight","through"].includes(ee.attrs.wrapType)){let K=ue.current?.querySelectorAll(".layout-page");if(!K||K.length===0)return;let te=null;for(let mt of K){let yt=mt.getBoundingClientRect();if(U>=yt.top&&U<=yt.bottom){te=mt.querySelector(".layout-page-content");break}}if(te||(te=K[K.length-1].querySelector(".layout-page-content")),!te)return;let ie=te.getBoundingClientRect(),xe=(V-ie.left)/f,he=(U-ie.top)/f,ke=914400/96,Ee=Math.round(xe*ke),Ce=Math.round(he*ke),Me={horizontal:{posOffset:Ee,relativeTo:"margin"},vertical:{posOffset:Ce,relativeTo:"margin"}},We=j.state.tr.setNodeMarkup(T,void 0,{...ee.attrs,position:Me});j.dispatch(We),N.current?.setNodeSelection(T);}else {let K=Ft(V,U);if(K===null||K===T||K===T+1)return;let te=j.state.tr;if(K<=T)te=te.delete(T,T+ee.nodeSize),te=te.insert(K,ee),N.current?.setNodeSelection(K);else {te=te.delete(T,T+ee.nodeSize);let ie=K-ee.nodeSize;te=te.insert(Math.min(ie,te.doc.content.size),ee),N.current?.setNodeSelection(Math.min(ie,te.doc.content.size-1));}j.dispatch(te);}}catch{}},[Ft,f]),kt=useCallback(()=>{Ae.current=true;},[]),wt=useCallback(()=>{Ae.current=false;},[]),ti=useCallback(T=>{if(!c){if(N.current?.isFocused()||(N.current?.focus(),re(true)),T.key===" "&&!T.ctrlKey&&!T.metaKey&&!T.nativeEvent.isComposing){T.preventDefault();let V=N.current?.getView();if(V){let{from:U,to:j}=V.state.selection;V.someProp("handleTextInput",_=>_(V,U,j," "))||V.dispatch(V.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(T.key)&&!T.metaKey&&T.ctrlKey,T.key==="Home"&&(T.metaKey||T.ctrlKey)){let V=de();V&&(V.scrollTop=0);}if(T.key==="End"&&(T.metaKey||T.ctrlKey)){let V=de();V&&(V.scrollTop=V.scrollHeight);}}},[c,de]),ni=useCallback(T=>{c||T.target.closest(".docx-comments-sidebar")||N.current?.isFocused()||(N.current?.focus(),re(true));},[c]),ks=useCallback(T=>{Ut(T.state),ft(T.state),c||requestAnimationFrame(()=>{T.focus(),re(true);});},[Ut,ft,c]);useEffect(()=>{let T=()=>{let V=N.current?.getView();V&&(f$2(),Fl(),Ut(V.state),ft(V.state));};return window.document.fonts.addEventListener("loadingdone",T),()=>{window.document.fonts.removeEventListener("loadingdone",T);}},[]);let yo=useRef(0);useEffect(()=>{if(yo.current===0){yo.current=1;return}let T=N.current?.getView();T&&Ut(T.state);},[s,l,u,d,Ut]),useEffect(()=>{let T=me.current;if(!T)return;let V=new ResizeObserver(()=>{let U=N.current?.getState();U&&ft(U);});return V.observe(T),()=>V.disconnect()},[ft]),useImperativeHandle(n$1,()=>({getDocument(){return N.current?.getDocument()??null},getState(){return N.current?.getState()??null},getView(){return N.current?.getView()??null},focus(){N.current?.focus(),re(true);},blur(){N.current?.blur(),re(false);},isFocused(){return N.current?.isFocused()??false},dispatch(T){N.current?.dispatch(T);},undo(){return N.current?.undo()??false},redo(){return N.current?.redo()??false},setSelection(T,V){N.current?.setSelection(T,V);},getLayout(){return Y},relayout(){let T=N.current?.getState();T&&Ut(T);},scrollToPosition:en}),[Y,Ut,en]),useEffect(()=>{let T=N.current?.getState();Y&&T&&ft(T);},[Y,ft]),useEffect(()=>{L.current&&N.current&&L.current({getDocument:()=>N.current?.getDocument()??null,getState:()=>N.current?.getState()??null,getView:()=>N.current?.getView()??null,focus:()=>{N.current?.focus(),re(true);},blur:()=>{N.current?.blur(),re(false);},isFocused:()=>N.current?.isFocused()??false,dispatch:T=>N.current?.dispatch(T),undo:()=>N.current?.undo()??false,redo:()=>N.current?.redo()??false,setSelection:(T,V)=>N.current?.setSelection(T,V),getLayout:()=>Y,relayout:()=>{let T=N.current?.getState();T&&Ut(T);},scrollToPosition:en});},[Y,Ut]);let Wn=useMemo(()=>{if(!Y)return If+48;let T=Y.pages.length;return T*Vt.h+(T-1)*p$1+48},[Y,Vt.h,p$1]);return jsxs("div",{ref:me,className:`ep-root paged-editor ${z??""}`,style:{...hS,...I},tabIndex:0,onFocus:bo,onBlur:ys,onKeyDown:ti,onMouseDown:ni,children:[jsx(Hp,{ref:N,document:o$1,styles:r,widthPx:le,readOnly:c,onTransaction:$n,onSelectionChange:Qt,externalPlugins:g,extensionManager:x,onEditorViewReady:ks,onKeyDown:R}),jsxs("div",{style:{...bS,minHeight:Wn,marginBottom:f!==1?Wn*(f-1):void 0,transform:(()=>{let T=[];return A&&T.push(`translateX(-${176}px)`),f!==1&&T.push(`scale(${f})`),T.length>0?T.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsx("div",{ref:ue,className:`paged-editor__pages${c?" paged-editor--readonly":""}${E?` paged-editor--hf-editing paged-editor--editing-${E}`:""}`,style:yS,onMouseDown:bs,onMouseMove:Qr,onClick:In,onContextMenu:ei,"aria-hidden":"true"}),jsx(Op,{selectionRects:pe,caretPosition:Ue,isFocused:oe,pageGap:p$1,readOnly:c}),jsx(Vp,{imageInfo:Ge,zoom:f,isFocused:oe,onResize:Ie,onResizeStart:Je,onResizeEnd:xs,onDragMove:Ss,onDragStart:kt,onDragEnd:wt}),pn&&jsx("button",{type:"button",onMouseDown:fr,onMouseEnter:Wt,onMouseLeave:()=>at(null),style:{position:"absolute",left:pn.x,top:pn.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:pn.type==="row"?"Insert row below":"Insert column to the right","aria-label":pn.type==="row"?"Insert row below":"Insert column to the right",children:jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),B&&jsx("div",{className:"paged-editor__plugin-overlays",style:xS,children:B})]}),Z&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Wn*f,pointerEvents:"none",overflow:"visible"},children:jsx("div",{style:{pointerEvents:"auto"},children:Z})})]})}),Df=memo(BS);var NS=lazy(()=>import('./FindReplaceDialog-N4J5OB7O.mjs')),OS=lazy(()=>import('./HyperlinkDialog-YQSQFHOP.mjs')),zS=lazy(()=>import('./TablePropertiesDialog-FI5E3RCB.mjs').then(e=>({default:e.TablePropertiesDialog}))),$S=lazy(()=>import('./ImagePositionDialog-HT6J2SHV.mjs').then(e=>({default:e.ImagePositionDialog}))),_S=lazy(()=>import('./ImagePropertiesDialog-3VK2S2AF.mjs').then(e=>({default:e.ImagePropertiesDialog}))),WS=lazy(()=>import('./FootnotePropertiesDialog-UFUIHLDW.mjs').then(e=>({default:e.FootnotePropertiesDialog}))),VS=lazy(()=>import('./PageSetupDialog-SMQJXEBL.mjs').then(e=>({default:e.PageSetupDialog}))),Hf=[{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 GS({mode:e,onModeChange:t}){let[n,o]=useState(false),[r,i]=useState(false),a=useRef(null),s=useRef(null),[l,u]=useState({top:0,left:0}),d$1=Hf.find(c=>c.value===e);return useEffect(()=>{let c=window.matchMedia("(max-width: 1400px)");i(c.matches);let p=f=>i(f.matches);return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[]),useEffect(()=>{if(!n||!a.current)return;let c=a.current.getBoundingClientRect();u({top:c.bottom+2,left:c.right-220});},[n]),useEffect(()=>{if(!n)return;let c=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",p);}},[n]),jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:a,type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>o(!n),title:`${d$1.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:[jsx(d,{name:d$1.icon,size:18}),!r&&jsx("span",{children:d$1.label}),jsx(d,{name:"arrow_drop_down",size:16})]}),n&&jsx("div",{ref:s,onMouseDown:c=>c.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:Hf.map(c=>jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(c.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:[jsx(d,{name:c.icon,size:20}),jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsx("span",{style:{fontWeight:500},children:c.label}),jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:c.desc})]}),c.value===e&&jsx(d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},c.value))})]})}var KS=Date.now(),fs=-1,Nf=new Map;function Of(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 Gl(e,t,n){return {id:KS++,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 zf=forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i$1,onSelectionChange:a$2,onError:s,onFontsLoaded:l$2,theme:u,showToolbar:d$1=true,showZoomControl:c$1=true,showMarginGuides:p=false,marginGuideColor:f$1,showRuler:m=false,rulerUnit:b="inch",initialZoom:g=1,readOnly:x=false,toolbarExtra:k,className:S="",style:B,placeholder:w,loadingIndicator:E$1,showOutline:P=false,showOutlineButton:z$1=true,showPrintButton:I=true,printOptions:A$1,onPrint:Z$1,onCopy:ce,onCut:ae,onPaste:$,mode:H,onModeChange:de,onCommentAdd:me,onCommentResolve:ue,onCommentDelete:N,onCommentReply:Ve,externalPlugins:R,onEditorViewReady:F,onRenderedDomContextReady:C$1,pluginOverlays:M,pluginSidebarItems:L,pluginRenderedDomContext:D,renderLogo:Y,documentName:se,onDocumentNameChange:W,documentNameEditable:q=true,renderTitleBarRight:Q},we){let[oe,re]=useState({isLoading:!!t,parseError:null,zoom:g,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[pe,be]=useState(false),[Ue,Be]=useState(false),[Ge,Oe]=useState(false),[Ae,Re]=useState(false),[Pe,Ke]=useState(null),[Ye,bt]=useState(false),[Ze,ut]=useState(P),Tt=useRef(false);Tt.current=Ze;let[Fe,pt]=useState([]),[De,St]=useState(false),[dn,zt]=useState([]),[vn,dr]=useState([]),[fo,Bo]=useState(Nf),[mo,Rn]=useState(false),[En,$t]=useState(null),[Pn,At]=useState(null),[go,un]=useState(H??"editing"),Ao=H??go,pn=y=>{H||un(y),de?.(y);},at=x||Ao==="viewing",[_t,Wt]=useState(null),[lt,Vt]=useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),st=useRef(null),fn=useCallback(()=>{let y=je.current?.getView();if(!y)return;let{doc:h,schema:v}=y.state,O=v.marks.insertion,G=v.marks.deletion;if(!O&&!G)return;let X=[];h.descendants((ne,fe)=>{if(ne.isText)for(let ye of ne.marks)(ye.type===O||ye.type===G)&&X.push({type:ye.type===O?"insertion":"deletion",text:ne.text||"",author:ye.attrs.author||"",date:ye.attrs.date,from:fe,to:fe+ne.nodeSize,revisionId:ye.attrs.revisionId});});let J=[];for(let ne of X){let fe=J[J.length-1];fe&&fe.revisionId===ne.revisionId&&fe.type===ne.type&&fe.to===ne.from?(fe.text+=ne.text,fe.to=ne.to):J.push({...ne});}dr(J);},[]);useEffect(()=>()=>{st.current&&clearTimeout(st.current);},[]),useEffect(()=>{if(ut(P),P){let y=je.current?.getView();y&&pt(qo(y.state.doc));}},[P]);let le=Rp(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),ur=useRef(false);useEffect(()=>{if(ur.current)return;let y=le.state;if(!y)return;let h=y.package?.document?.comments;h&&h.length>0&&(zt(h),St(true),ur.current=true);},[le.state]);let Ut=useMemo(()=>{let y=new Yn(er());return y.buildSchema(),y.initializeRuntime(),y},[]),Jt=useMemo(()=>Ip(false,r),[]),Jr=useMemo(()=>[Jt,...R??[]],[Jt,R]),je=useRef(null),ft=useRef(null),$n=useRef(null),Qt=useRef(null),Ft=useRef(null),Mn=useRef(null),Do=useRef(null),en=useRef(null),bs=useRef(null),ho=useRef(null),[pr,Ho]=useState(0),_n=useRef(le.state);_n.current=le.state;let Et=useRef({style:"single",size:4,color:{rgb:"000000"}}),Qr=useRef(null),fr=useCallback(y=>{let h=Qr.current;if(h&&h.styles===y)return h.resolver;let v=wo(y);return Qr.current={styles:y,resolver:v},v},[]),[In,ei]=useState({currentPage:1,totalPages:1,visible:false}),bo=useRef(null),ys=useCallback(y=>{if(bs.current=y,ho.current&&(ho.current.disconnect(),ho.current=null),!y){Ho(0);return}Ho(y.offsetHeight);let h=new ResizeObserver(()=>{Ho(y.offsetHeight);});h.observe(y),ho.current=h;},[]);useEffect(()=>()=>{ho.current?.disconnect();},[]);let Ie=useCallback(()=>Pe&&ft.current?ft.current.getView():je.current?.getView(),[Pe]),Je=useCallback(()=>{Pe&&ft.current?ft.current.focus():je.current?.focus();},[Pe]),xs=useCallback(()=>{Pe&&ft.current?ft.current.undo():je.current?.undo();},[Pe]),Ss=useCallback(()=>{Pe&&ft.current?ft.current.redo():je.current?.redo();},[Pe]),kt=m$1(),wt=m$2(),[ti,ni]=useState(false),ks=useCallback(()=>ni(true),[]),[yo,Wn]=useState(null),T=useRef(0),V=useCallback(()=>{ur.current=false,ee.current=false,zt([]),dr([]),pt([]),St(false),Rn(false),$t(null),At(null),Wt(null),Ke(null),Bo(Nf),kt.setMatches([],0),st.current&&(clearTimeout(st.current),st.current=null);},[kt.setMatches]),U=useCallback(y=>{V(),le.reset(y),re(h=>({...h,isLoading:false,parseError:null})),l(y).catch(h=>{console.warn("Failed to load document fonts:",h);});},[V,le]),j$1=useCallback(async y=>{let h=++T.current;V(),re(v=>({...v,isLoading:true,parseError:null}));try{let v=await n$1(y);if(T.current!==h)return;U(v);}catch(v){if(T.current!==h)return;let O=v instanceof Error?v.message:"Failed to parse document";re(G=>({...G,isLoading:false,parseError:O})),s?.(v instanceof Error?v:new Error(O));}},[V,U,s]);useEffect(()=>{if(!t){n&&U(n);return}j$1(t);},[t,n]),useEffect(()=>{le.state?$n.current=new f(le.state):$n.current=null;},[le.state]);let ee=useRef(false);useEffect(()=>{if(!oe.isLoading&&le.state){let y=setTimeout(()=>{fn(),ee.current||(ee.current=true,dr(h=>(h.length>0&&St(true),h)));},200);return ()=>clearTimeout(y)}},[oe.isLoading,le.state,fn]),useEffect(()=>h(()=>{l$2?.();}),[l$2]),useEffect(()=>{let y=je.current?.getView();y&&Fp(Ao==="suggesting",y.state,y.dispatch,r);},[Ao,r]);let _=useCallback(y=>(le.push(y),y),[le]),K=useCallback(y=>{if(_(y),i$1?.(y),Tt.current){let h=je.current?.getView();h&&pt(qo(h.state.doc));}st.current&&clearTimeout(st.current),st.current=setTimeout(fn,300);},[i$1,_,fn]),te=useCallback(y=>{let h=Ie();if(h){let{from:et,to:_e}=h.state.selection;Ft.current={from:et,to:_e};}let v=null;if(h&&(v=qe(h.state),v.isInTable||(v=null)),v?.cellBorderColor){let et=v.cellBorderColor,_e=et.rgb;(!_e||_e==="auto")&&(_e=a(et,u).replace(/^#/,"")),Et.current={...Et.current,color:{rgb:_e}};}let O=null;if(h){let et=h.state.selection,_e=et.node;_e?.type.name==="image"&&(O={pos:et.from,wrapType:_e.attrs.wrapType??"inline",displayMode:_e.attrs.displayMode??"inline",cssFloat:_e.attrs.cssFloat??null,transform:_e.attrs.transform??null,alt:_e.attrs.alt??null,borderWidth:_e.attrs.borderWidth??null,borderColor:_e.attrs.borderColor??null,borderStyle:_e.attrs.borderStyle??null});}if(!y){Wt(null),re(et=>({...et,selectionFormatting:{},pmTableContext:v,pmImageContext:O}));return}let{textFormatting:G,paragraphFormatting:X}=y,J=G.fontFamily?.ascii||G.fontFamily?.hAnsi,ne=G.fontSize;if(!J||!ne){let et=_n.current,_e=y.styleId;if(et?.package.styles&&_e){let Ct=fr(et.package.styles).resolveParagraphStyle(_e);!J&&Ct.runFormatting?.fontFamily&&(J=Ct.runFormatting.fontFamily.ascii||Ct.runFormatting.fontFamily.hAnsi),!ne&&Ct.runFormatting?.fontSize&&(ne=Ct.runFormatting.fontSize);}}let fe=G.color?.rgb?`#${G.color.rgb}`:void 0,ye=X.numPr,He=ye?{type:ye.numId===1?"bullet":"numbered",level:ye.ilvl??0,isInList:true,numId:ye.numId}:void 0,Qe={bold:G.bold,italic:G.italic,underline:!!G.underline,strike:G.strike,superscript:G.vertAlign==="superscript",subscript:G.vertAlign==="subscript",fontFamily:J,fontSize:ne,color:fe,highlight:G.highlight,alignment:X.alignment,lineSpacing:X.lineSpacing,listState:He,styleId:y.styleId??void 0,indentLeft:X.indentLeft,bidi:!!X.bidi};if(re(et=>({...et,selectionFormatting:Qe,paragraphIndentLeft:X.indentLeft??0,paragraphIndentRight:X.indentRight??0,paragraphFirstLineIndent:X.indentFirstLine??0,paragraphHangingIndent:X.hangingIndent??false,paragraphTabs:X.tabs??null,pmTableContext:v,pmImageContext:O})),h&&y.hasSelection&&!mo&&!at){let et=en.current,_e=Do.current,{from:jt}=h.state.selection,Ct=Of(et,_e,jt);if(Ct!=null&&et&&_e){let xr=et.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),gi=xr?xr.getBoundingClientRect().right-_e.getBoundingClientRect().left:_e.getBoundingClientRect().width/2+408;Wt({top:Ct,left:gi});}}else Wt(null);a$2?.(y);},[a$2,mo,at]),ie=Yc({document:le.state,onChange:K,onSelectionChange:y=>{}});useEffect(()=>{let y=h=>{let O=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!O&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let G=je.current?.getView();if(G){let X=G.state.selection;if("$anchorCell"in X&&typeof X.forEachCell=="function"){let ne=qe(G.state);if(ne.isInTable&&ne.table){let fe=0;ne.table.descendants(He=>{(He.type.name==="tableCell"||He.type.name==="tableHeader")&&(fe+=1);});let ye=0;if(X.forEachCell(()=>{ye+=1;}),fe>0&&ye>=fe){h.preventDefault(),Or(G.state,G.dispatch);return}}}}if(ie.state.tableIndex!==null){h.preventDefault(),ie.handleAction("deleteTable");return}}if(O&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let G=window.getSelection(),X=G&&!G.isCollapsed?G.toString():"";kt.openFind(X);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let G=window.getSelection(),X=G&&!G.isCollapsed?G.toString():"";kt.openReplace(X);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let G=je.current?.getView();if(G){let X=Jo(G.state),J=Zo(G.state);J?wt.openEdit({url:J.href,displayText:X,tooltip:J.tooltip}):wt.openInsert(X);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[kt,wt,ie]);let xe=useCallback((y,h)=>{let v=Ie();v&&(ga(y,h)(v.state,v.dispatch),Je());},[Ie,Je]),he=useCallback(()=>{let y=Ie();y&&(Na(y.state,y.dispatch),Je());},[Ie,Je]),ke=useCallback(()=>{let y=Ie();y&&(ma(y.state,y.dispatch),Je());},[Ie,Je]),Ee=useCallback(()=>{ut(y=>{if(!y){let h=je.current?.getView();h&&pt(qo(h.state.doc));}return !y});},[]),Ce=useCallback(y=>{je.current?.scrollToPosition(y),je.current?.setSelection(y+1),je.current?.focus();},[]),Me=useCallback(()=>{Mn.current?.click();},[]),We=useCallback(y=>{let h=y.target.files?.[0];if(!h)return;let v=Ie();if(!v)return;let O=new FileReader;O.onload=()=>{let G=O.result,X=new Image;X.onload=()=>{let J=X.naturalWidth,ne=X.naturalHeight,fe=612;if(J>fe){let _e=fe/J;J=fe,ne=Math.round(ne*_e);}let ye=`rId_img_${Date.now()}`,He=v.state.schema.nodes.image.create({src:G,alt:h.name,width:J,height:ne,rId:ye,wrapType:"inline",displayMode:"inline"}),{from:Qe}=v.state.selection,et=v.state.tr.insert(Qe,He);v.dispatch(et.scrollIntoView()),Je();},X.src=G;},O.readAsDataURL(h),y.target.value="";},[Ie,Je]),mt=useCallback(y=>{let h=Ie();if(!h||!oe.pmImageContext)return;let v=oe.pmImageContext.pos,O=h.state.doc.nodeAt(v);if(!O||O.type.name!=="image")return;let G="inline",X=null;switch(y){case "inline":G="inline",X=null;break;case "square":case "tight":case "through":G="float",X="left";break;case "topAndBottom":G="block",X=null;break;case "behind":case "inFront":G="float",X="none";break;case "wrapLeft":G="float",X="right",y="square";break;case "wrapRight":G="float",X="left",y="square";break}let J=h.state.tr.setNodeMarkup(v,void 0,{...O.attrs,wrapType:y,displayMode:G,cssFloat:X});h.dispatch(J.scrollIntoView()),Je();},[Ie,Je,oe.pmImageContext]),yt=useCallback(y=>{let h=Ie();if(!h||!oe.pmImageContext)return;let v=oe.pmImageContext.pos,O=h.state.doc.nodeAt(v);if(!O||O.type.name!=="image")return;let G=O.attrs.transform||"",X=G.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),J=X?parseFloat(X[1]):0,ne=/scaleX\(-1\)/.test(G),fe=/scaleY\(-1\)/.test(G);switch(y){case "rotateCW":J=(J+90)%360;break;case "rotateCCW":J=(J-90+360)%360;break;case "flipH":ne=!ne;break;case "flipV":fe=!fe;break}let ye=[];J!==0&&ye.push(`rotate(${J}deg)`),ne&&ye.push("scaleX(-1)"),fe&&ye.push("scaleY(-1)");let He=ye.length>0?ye.join(" "):null,Qe=h.state.tr.setNodeMarkup(v,void 0,{...O.attrs,transform:He});h.dispatch(Qe.scrollIntoView()),Je();},[Ie,Je,oe.pmImageContext]),tn=useCallback(y=>{let h=Ie();if(!h||!oe.pmImageContext)return;let v=oe.pmImageContext.pos,O=h.state.doc.nodeAt(v);if(!O||O.type.name!=="image")return;let G=h.state.tr.setNodeMarkup(v,void 0,{...O.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??O.attrs.distTop,distBottom:y.distBottom??O.attrs.distBottom,distLeft:y.distLeft??O.attrs.distLeft,distRight:y.distRight??O.attrs.distRight});h.dispatch(G.scrollIntoView()),Je();},[Ie,Je,oe.pmImageContext]),No=useCallback(()=>{Oe(true);},[]),oi=useCallback(y=>{let h=Ie();if(!h||!oe.pmImageContext)return;let v=oe.pmImageContext.pos,O=h.state.doc.nodeAt(v);if(!O||O.type.name!=="image")return;let G=h.state.tr.setNodeMarkup(v,void 0,{...O.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});h.dispatch(G.scrollIntoView()),Je();},[Ie,Je,oe.pmImageContext]),ri=useCallback((y,h)=>{if(!le.state?.package)return;let v={...le.state.package.document,finalSectionProperties:{...le.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:h}};_({...le.state,package:{...le.state.package,document:v}});},[le,_]),ii=useCallback(y=>{let h=Ie();if(h){switch(y){case "addRowAbove":Ar(h.state,h.dispatch);break;case "addRowBelow":vo(h.state,h.dispatch);break;case "addColumnLeft":Hr(h.state,h.dispatch);break;case "addColumnRight":Ro(h.state,h.dispatch);break;case "deleteRow":Dr(h.state,h.dispatch);break;case "deleteColumn":Nr(h.state,h.dispatch);break;case "deleteTable":Or(h.state,h.dispatch);break;case "selectTable":ha(h.state,h.dispatch);break;case "selectRow":ba(h.state,h.dispatch);break;case "selectColumn":ya(h.state,h.dispatch);break;case "mergeCells":xa(h.state,h.dispatch);break;case "splitCell":Sa(h.state,h.dispatch);break;case "borderAll":Ca(h.state,h.dispatch,Et.current);break;case "borderOutside":Ta(h.state,h.dispatch,Et.current);break;case "borderInside":wa(h.state,h.dispatch,Et.current);break;case "borderNone":ka(h.state,h.dispatch);break;case "borderTop":qn("top",Et.current,true)(h.state,h.dispatch);break;case "borderBottom":qn("bottom",Et.current,true)(h.state,h.dispatch);break;case "borderLeft":qn("left",Et.current,true)(h.state,h.dispatch);break;case "borderRight":qn("right",Et.current,true)(h.state,h.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")Aa(y.color)(h.state,h.dispatch);else if(y.type==="borderColor"){let v=y.color.replace(/^#/,"");Et.current={...Et.current,color:{rgb:v}},Da(y.color)(h.state,h.dispatch);}else if(y.type==="borderWidth")Et.current={...Et.current,size:y.size},Ha(y.size)(h.state,h.dispatch);else if(y.type==="cellBorder")qn(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(y.type==="cellVerticalAlign")va(y.align)(h.state,h.dispatch);else if(y.type==="cellMargins")Ra(y.margins)(h.state,h.dispatch);else if(y.type==="cellTextDirection")Ea(y.direction)(h.state,h.dispatch);else if(y.type==="toggleNoWrap")Pa()(h.state,h.dispatch);else if(y.type==="rowHeight")Ma(y.height,y.rule)(h.state,h.dispatch);else if(y.type==="toggleHeaderRow")Ia()(h.state,h.dispatch);else if(y.type==="distributeColumns")Fa()(h.state,h.dispatch);else if(y.type==="autoFitContents")La()(h.state,h.dispatch);else if(y.type==="openTableProperties")be(true);else if(y.type==="tableProperties")zr(y.props)(h.state,h.dispatch);else if(y.type==="applyTableStyle"){let v=kp(y.styleId),O=_n.current;if(!v&&O?.package.styles){let X=fr(O.package.styles).getStyle(y.styleId);if(X){if(v={id:X.styleId,name:X.name??X.styleId},X.tblPr?.borders){let J=X.tblPr.borders;v.tableBorders={};for(let ne of ["top","bottom","left","right","insideH","insideV"]){let fe=J[ne];fe&&(v.tableBorders[ne]={style:fe.style,size:fe.size,color:fe.color?.rgb?{rgb:fe.color.rgb}:void 0});}}if(X.tblStylePr){v.conditionals={};for(let J of X.tblStylePr){let ne={};if(J.tcPr?.shading?.fill&&(ne.backgroundColor=`#${J.tcPr.shading.fill}`),J.tcPr?.borders){let fe={};for(let ye of ["top","bottom","left","right"]){let He=J.tcPr.borders[ye];He&&(fe[ye]={style:He.style,size:He.size,color:He.color?.rgb?{rgb:He.color.rgb}:void 0});}ne.borders=fe;}J.rPr?.bold&&(ne.bold=true),J.rPr?.color?.rgb&&(ne.color=`#${J.rPr.color.rgb}`),v.conditionals[J.type]=ne;}}v.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}v&&Ba({styleId:v.id,tableBorders:v.tableBorders,conditionals:v.conditionals,look:v.look})(h.state,h.dispatch);}}else ie.handleAction(y);}Je();}},[ie,Ie,Je]),ai=useCallback(y=>{y.preventDefault(),y.stopPropagation();let h=je.current?.getView(),v=h?Gn(h.state):false,{from:O,to:G}=h?.state.selection??{from:0,to:0},X=O!==G;Vt({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:X,cursorInTable:v});},[]),mr=useCallback(y=>{let h=Ie();if(!h)return;h.focus();let v=h===je.current?.getView(),{from:O,to:G}=h.state.selection,X=Ft.current;if(v&&X&&(O!==X.from||G!==X.to))try{let J=h.state.tr.setSelection(TextSelection.create(h.state.doc,X.from,X.to));h.dispatch(J);}catch(J){console.warn("Could not restore selection:",J);}if(y==="bold"){Vi(h.state,h.dispatch);return}if(y==="italic"){Ui(h.state,h.dispatch);return}if(y==="underline"){ji(h.state,h.dispatch);return}if(y==="strikethrough"){Gi(h.state,h.dispatch);return}if(y==="superscript"){Ki(h.state,h.dispatch);return}if(y==="subscript"){Yi(h.state,h.dispatch);return}if(y==="bulletList"){sa(h.state,h.dispatch);return}if(y==="numberedList"){la(h.state,h.dispatch);return}if(y==="indent"){ca(h.state,h.dispatch)||oa()(h.state,h.dispatch);return}if(y==="outdent"){da(h.state,h.dispatch)||ra()(h.state,h.dispatch);return}if(y==="clearFormatting"){Pr(h.state,h.dispatch);return}if(y==="setRtl"){pa(h.state,h.dispatch);return}if(y==="setLtr"){fa(h.state,h.dispatch);return}if(y==="insertLink"){let J=Jo(h.state),ne=Zo(h.state);ne?wt.openEdit({url:ne.href,displayText:J,tooltip:ne.tooltip}):wt.openInsert(J);return}if(typeof y=="object")switch(y.type){case "alignment":ta(y.value)(h.state,h.dispatch);break;case "textColor":{let J=y.value;typeof J=="string"?Ir({rgb:J.replace("#","")})(h.state,h.dispatch):J.auto?qi(h.state,h.dispatch):Ir(J)(h.state,h.dispatch);break}case "highlightColor":{let J=y.value?z(y.value):"";Xi(J||y.value)(h.state,h.dispatch);break}case "fontSize":Zi(i(y.value))(h.state,h.dispatch);break;case "fontFamily":Ji(y.value)(h.state,h.dispatch);break;case "lineSpacing":na(y.value)(h.state,h.dispatch);break;case "applyStyle":{let J=_n.current,ne=J?.package.styles?fr(J.package.styles):null;if(ne){let fe=ne.resolveParagraphStyle(y.value);Br(y.value,{paragraphFormatting:fe.paragraphFormatting,runFormatting:fe.runFormatting})(h.state,h.dispatch);}else Br(y.value)(h.state,h.dispatch);break}}},[Ie]),gr=useCallback(y=>{re(h=>({...h,zoom:y}));},[]),Oo=useCallback(y=>{let h=Ie();if(!h)return;let v=y.url||"",O=y.tooltip,{empty:G}=h.state.selection;G&&y.displayText?Fr(y.displayText,v,O)(h.state,h.dispatch):G?y.displayText&&Fr(y.displayText,v,O)(h.state,h.dispatch):Qi(v,O)(h.state,h.dispatch),wt.close(),Je();},[wt,Ie,Je]),Yt=useCallback(()=>{let y=Ie();y&&(ea(y.state,y.dispatch),Je());},[Ie,Je]),xo=useCallback(()=>{Yt(),wt.close();},[wt,Yt]),hr=useCallback(y=>Wn(y),[]),Cs=useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),br=useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let h=document.createElement("textarea");h.value=y,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h);});},[]),si=useCallback((y,h)=>{let v=Ie();if(!v)return;let O=v.state.schema.marks.hyperlink;if(!O)return;let{$from:G}=v.state.selection,X=G.marks().find(J=>J.type===O);if(X){let J=G.parent,ne=G.start(),fe=[],ye=null;J.forEach((Ct,yr)=>{let xr=ne+yr,gi=xr+Ct.nodeSize;(Ct.isText?Ct.marks.find(Ql=>Ql.type===O&&Ql.attrs.href===X.attrs.href):null)?ye?ye.end=gi:ye={start:xr,end:gi}:ye&&(fe.push(ye),ye=null);}),ye&&fe.push(ye);let He=G.pos,Qe=fe.find(Ct=>Ct.start<=He&&He<=Ct.end);if(!Qe)return;let et=v.state.tr,_e=O.create({href:h,tooltip:X.attrs.tooltip}),jt=v.state.schema.text(y,[...G.marks().filter(Ct=>Ct.type!==O),_e]);et.replaceWith(Qe.start,Qe.end,jt),v.dispatch(et.scrollIntoView());}Wn(null),Je();},[Ie,Je]),ct=useCallback(()=>{let y=Ie();if(!y)return;let h=y.state.schema.marks.hyperlink;if(!h)return;let{$from:v}=y.state.selection,O=v.marks().find(Qe=>Qe.type===h);if(!O&&v.nodeAfter&&(O=v.nodeAfter.marks.find(Qe=>Qe.type===h)),!O&&v.nodeBefore&&(O=v.nodeBefore.marks.find(Qe=>Qe.type===h)),!O&&yo&&v.parent.forEach(et=>{if(!O&&et.isText){let _e=et.marks.find(jt=>jt.type===h&&jt.attrs.href===yo.href);_e&&(O=_e);}}),!O)return;let G=v.parent,X=v.start(),J=[],ne=null;G.forEach((Qe,et)=>{let _e=X+et,jt=_e+Qe.nodeSize;(Qe.isText?Qe.marks.find(yr=>yr.type===h&&yr.attrs.href===O.attrs.href):null)?ne?ne.end=jt:ne={start:_e,end:jt}:ne&&(J.push(ne),ne=null);}),ne&&J.push(ne);let fe=v.pos,ye=J.find(Qe=>Qe.start<=fe&&fe<=Qe.end);if(!ye)return;let He=y.state.tr;He.removeMark(ye.start,ye.end,h),y.dispatch(He.scrollIntoView()),Wn(null),Je(),toast("Link removed");},[Ie,Je,yo]),So=useCallback(()=>{Wn(null);},[]),mn=useCallback(y=>{let h=je.current?.getView(),v=h?Gn(h.state):false;Vt({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:v});},[]),ko=useCallback(()=>{Vt({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),Vn=useMemo(()=>{let h=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",v=[{action:"cut",label:"Cut",shortcut:`${h}+X`},{action:"copy",label:"Copy",shortcut:`${h}+C`},{action:"paste",label:"Paste",shortcut:`${h}+V`},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:`${h}+Shift+V`,dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:!lt.hasSelection&&!lt.cursorInTable}];return lt.hasSelection&&v.push({action:"addComment",label:"Comment",dividerAfter:!lt.cursorInTable}),lt.cursorInTable&&v.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}),v.push({action:"selectAll",label:"Select All",shortcut:`${h}+A`}),v},[lt.hasSelection,lt.cursorInTable]),li=useCallback(async y=>{let h=Ie();if(h)switch(Je(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let v=await navigator.clipboard.read(),O="",G="";for(let ne of v)ne.types.includes("text/html")&&(O=await(await ne.getType("text/html")).text()),ne.types.includes("text/plain")&&(G=await(await ne.getType("text/plain")).text());let X=new DataTransfer;O&&X.items.add(O,"text/html"),G&&X.items.add(G,"text/plain");let J=new ClipboardEvent("paste",{clipboardData:X,bubbles:!0,cancelable:!0});h.dom.dispatchEvent(J);}catch{try{let v=await navigator.clipboard.readText();v&&h.dispatch(h.state.tr.insertText(v));}catch{}}break}case "pasteAsPlainText":try{let v=await navigator.clipboard.readText();v&&h.dispatch(h.state.tr.insertText(v));}catch{}break;case "delete":{let{from:v,to:O}=h.state.selection;v!==O&&h.dispatch(h.state.tr.deleteRange(v,O));break}case "selectAll":h.dispatch(h.state.tr.setSelection(TextSelection.create(h.state.doc,0,h.state.doc.content.size)));break;case "addRowAbove":Ar(h.state,h.dispatch);break;case "addRowBelow":vo(h.state,h.dispatch);break;case "deleteRow":Dr(h.state,h.dispatch);break;case "addColumnLeft":Hr(h.state,h.dispatch);break;case "addColumnRight":Ro(h.state,h.dispatch);break;case "deleteColumn":Nr(h.state,h.dispatch);break;case "addComment":{let{from:v,to:O}=h.state.selection;if(v===O)break;let G=Of(en.current,Do.current,v);$t({from:v,to:O});let X=h.state.schema.marks.comment.create({commentId:fs}),J=h.state.tr.addMark(v,O,X);J.setSelection(TextSelection.create(J.doc,O)),h.dispatch(J),At(G),St(true),Rn(true),Wt(null);break}}},[Ie,Je]),Un=useCallback(y=>h=>{if(!le.state||at)return;let v={...le.state,package:{...le.state.package,document:{...le.state.package.document,finalSectionProperties:{...le.state.package.document.finalSectionProperties,[y]:h}}}};K(v);},[le.state,at,K]),om=useMemo(()=>Un("marginLeft"),[Un]),rm=useMemo(()=>Un("marginRight"),[Un]),im=useMemo(()=>Un("marginTop"),[Un]),am=useMemo(()=>Un("marginBottom"),[Un]),sm=useCallback(y=>{if(!le.state||at)return;let h={...le.state,package:{...le.state.package,document:{...le.state.package.document,finalSectionProperties:{...le.state.package.document.finalSectionProperties,...y}}}};K(h);},[le.state,at,K]),lm=useCallback(y=>{let h=Ie();h&&ia(y)(h.state,h.dispatch);},[Ie]),cm=useCallback(y=>{let h=Ie();h&&aa(y)(h.state,h.dispatch);},[Ie]),dm=useCallback(y=>{let h=Ie();h&&(y<0?Lr(-y,true)(h.state,h.dispatch):Lr(y,false)(h.state,h.dispatch));},[Ie]),um=useCallback(y=>{let h=Ie();h&&ua(y)(h.state,h.dispatch);},[Ie]),zo=en.current;useEffect(()=>{if(!zo)return;let y=()=>{let h=je.current?.getLayout();if(!h||h.pages.length===0)return;let v=zo.scrollTop,O=h.pages.length,G=24,X=24,J=v+zo.clientHeight/2,ne=X,fe=1;for(let ye=0;ye<h.pages.length;ye++){let He=h.pages[ye].size.h,Qe=ne+He;if(J<Qe){fe=ye+1;break}ne=Qe+G,fe=ye+2;}fe=Math.min(fe,O),ei({currentPage:fe,totalPages:O,visible:true}),bo.current&&clearTimeout(bo.current),bo.current=setTimeout(()=>{ei(ye=>({...ye,visible:false}));},600);};return zo.addEventListener("scroll",y,{passive:true}),()=>{zo.removeEventListener("scroll",y),bo.current&&clearTimeout(bo.current);}},[zo]);let Xl=useCallback(async y=>{if(!$n.current)return null;try{let h=$n.current.getDocument(),v=je.current?.getDocument();v?.package?.document&&(h.package.document.content=v.package.document.content),h.package.document.comments=dn;let O=y?.selective!==!1,G=je.current?.getView(),X;if(O&&G){let ne=G.state;X={selective:{changedParaIds:Au(ne),structuralChange:Du(ne),hasUntrackedChanges:Hu(ne)}};}let J=await $n.current.toBuffer(X);return G&&G.dispatch(Nu(G.state)),o?.(J),J}catch(h){return s?.(h instanceof Error?h:new Error("Failed to save document")),null}},[o,s,dn]),pm=useCallback(y=>{s?.(y);},[s]),ci=useCallback(()=>{let y=Qt.current?.querySelector(".paged-editor__pages");if(!y){window.print(),Z$1?.();return}let h=window.open("","_blank");if(!h){window.print(),Z$1?.();return}let v=[];for(let G of Array.from(document.styleSheets))try{for(let X of Array.from(G.cssRules))X instanceof CSSFontFaceRule&&v.push(X.cssText);}catch{}let O=y.cloneNode(true);O.style.cssText="display: block; margin: 0; padding: 0;";for(let G of Array.from(O.querySelectorAll(".layout-page"))){let X=G;X.style.boxShadow="none",X.style.margin="0";}h.document.write(`<!DOCTYPE html>
|
|
19
|
+
<html><head><title>Print</title>
|
|
20
|
+
<style>
|
|
21
|
+
${v.join(`
|
|
22
|
+
`)}
|
|
23
|
+
* { margin: 0; padding: 0; }
|
|
24
|
+
body { background: white; }
|
|
25
|
+
.layout-page { break-after: page; }
|
|
26
|
+
.layout-page:last-child { break-after: auto; }
|
|
27
|
+
@page { margin: 0; size: auto; }
|
|
28
|
+
</style>
|
|
29
|
+
</head><body>${O.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),Z$1?.();},[Z$1]),Dt=useRef(null),fm=useCallback((y,h)=>{if(!le.state||!y.trim())return Dt.current=null,null;let v=j(le.state,y,h),O={matches:v,totalCount:v.length,currentIndex:0};return Dt.current=O,kt.setMatches(v,0),v.length>0&&Qt.current&&l$1(Qt.current,v[0]),O},[le.state,kt]),mm=useCallback(()=>{if(!Dt.current||Dt.current.matches.length===0)return null;let y=kt.goToNextMatch(),h=Dt.current.matches[y];return h&&Qt.current&&l$1(Qt.current,h),h||null},[kt]),gm=useCallback(()=>{if(!Dt.current||Dt.current.matches.length===0)return null;let y=kt.goToPreviousMatch(),h=Dt.current.matches[y];return h&&Qt.current&&l$1(Qt.current,h),h||null},[kt]),hm=useCallback(y=>{if(!le.state||!Dt.current||Dt.current.matches.length===0)return false;let h=Dt.current.matches[Dt.current.currentIndex];if(!h)return false;try{let v=a$1(le.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:y});return K(v),!0}catch(v){return console.error("Replace failed:",v),false}},[le.state,K]),bm=useCallback((y,h,v)=>{if(!le.state||!y.trim())return 0;let O=j(le.state,y,v);if(O.length===0)return 0;let G=le.state,X=[...O].sort((J,ne)=>J.paragraphIndex!==ne.paragraphIndex?ne.paragraphIndex-J.paragraphIndex:ne.startOffset-J.startOffset);for(let J of X)try{G=a$1(G,{type:"replaceText",range:{start:{paragraphIndex:J.paragraphIndex,offset:J.startOffset},end:{paragraphIndex:J.paragraphIndex,offset:J.endOffset}},text:h});}catch(ne){console.error("Replace failed for match:",J,ne);}return K(G),Dt.current=null,kt.setMatches([],0),O.length},[le.state,K,kt]);useImperativeHandle(we,()=>({getAgent:()=>$n.current,getDocument:()=>le.state,getEditorRef:()=>je.current,save:Xl,setZoom:y=>re(h=>({...h,zoom:y})),getZoom:()=>oe.zoom,focus:()=>{je.current?.focus();},getCurrentPage:()=>In.currentPage,getTotalPages:()=>In.totalPages,scrollToPage:y=>{},openPrintPreview:ci,print:ci,loadDocument:U,loadDocumentBuffer:j$1}),[le.state,oe.zoom,In,Xl,ci,U,j$1]);let{headerContent:di,footerContent:ui,firstPageHeaderContent:pi,firstPageFooterContent:fi}=useMemo(()=>{if(!le.state?.package)return {headerContent:null,footerContent:null,firstPageHeaderContent:null,firstPageFooterContent:null};let y=le.state.package,h=y.document?.finalSectionProperties,v=y.headers,O=y.footers,G=null,X=null,J=null,ne=null;if(v&&h?.headerReferences){let fe=h.headerReferences.find(He=>He.type==="default");fe?.rId&&(G=v.get(fe.rId)??null);let ye=h.headerReferences.find(He=>He.type==="first");ye?.rId&&(J=v.get(ye.rId)??null);}if(O&&h?.footerReferences){let fe=h.footerReferences.find(He=>He.type==="default");fe?.rId&&(X=O.get(fe.rId)??null);let ye=h.footerReferences.find(He=>He.type==="first");ye?.rId&&(ne=O.get(ye.rId)??null);}return h?.titlePg||(!G&&J&&(G=J),!X&&ne&&(X=ne)),{headerContent:G,footerContent:X,firstPageHeaderContent:J,firstPageFooterContent:ne}},[le.state]),ym=useCallback((y,h)=>{let O=le.state?.package?.document?.finalSectionProperties?.titlePg===true&&(h??1)===1,G=O?y==="header"?pi:fi:y==="header"?di:ui;if(bt(O),G){Ke(y);return}if(!le.state?.package)return;let X=le.state.package,J=X.document?.finalSectionProperties;if(!J)return;let ne=O?"first":"default",fe=`rId_new_${y}_${ne}`,ye={type:y==="header"?"header":"footer",hdrFtrType:ne,content:[{type:"paragraph",content:[]}]},He=y==="header"?"headers":"footers",Qe=new Map(X[He]??[]);Qe.set(fe,ye);let et=y==="header"?"headerReferences":"footerReferences",_e=J[et]??[],jt={type:ne,rId:fe},Ct={...le.state,package:{...X,[He]:Qe,document:X.document?{...X.document,finalSectionProperties:{...J,[et]:[..._e,jt]}}:X.document}};_(Ct),Ke(y);},[di,ui,pi,fi,le,_]),Ts=useCallback(y=>{if(!Pe||!le.state?.package){Ke(null);return}let h=le.state.package,v=h.document?.finalSectionProperties,O=Pe==="header"?v?.headerReferences:v?.footerReferences,G=Ye?"first":"default",X=O?.find(fe=>fe.type===G)??O?.find(fe=>fe.type==="default")??O?.find(fe=>fe.type==="first")??O?.[0],J=Pe==="header"?"headers":"footers",ne=h[J];if(X?.rId&&ne){let fe=ne.get(X.rId),ye={type:Pe,hdrFtrType:X.type,...fe,content:y},He=new Map(ne);He.set(X.rId,ye);let Qe={...le.state,package:{...h,[J]:He}};_(Qe);}Ke(null);},[Pe,le,_]),xm=useCallback(()=>{if(!Pe)return;let y=ft.current?.getView();if(y){let h=Wi(y.state.doc);Ts(h);}else Ke(null);},[Pe,Ts]),Sm=useCallback(()=>{if(!Pe||!le.state?.package){Ke(null);return}let y=le.state.package,h=y.document?.finalSectionProperties,v=Pe==="header"?"headerReferences":"footerReferences",O=Pe==="header"?"headers":"footers",G=h?.[v],X=Ye?"first":"default",J=G?.find(ne=>ne.type===X)??G?.find(ne=>ne.type==="default")??G?.find(ne=>ne.type==="first")??G?.[0];if(J?.rId){let ne=new Map(y[O]??[]);ne.delete(J.rId);let fe=(G??[]).filter(He=>He.rId!==J.rId),ye={...le.state,package:{...y,[O]:ne,document:y.document?{...y.document,finalSectionProperties:{...h,[v]:fe}}:y.document}};_(ye);}Ke(null);},[Pe,le,_]),km=useCallback(y=>{let h=Qt.current?.querySelector(".paged-editor__pages");if(!h)return null;let v=y==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(v)},[]),mi={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...B},Cm={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Fn=useRef({});Fn.current={onCommentReply:(y,h)=>{let v=Gl(h,r,y),O=dn.find(G=>G.id===y);zt(G=>[...G,v]),O&&Ve?.(v,O);},onCommentResolve:y=>{let h=dn.find(v=>v.id===y);zt(v=>v.map(O=>O.id===y?{...O,done:true}:O)),h&&ue?.({...h,done:true});},onCommentDelete:y=>{let h=dn.find(v=>v.id===y);zt(v=>v.filter(O=>O.id!==y&&O.parentId!==y)),h&&N?.(h);},onAddComment:y=>{let h=Gl(y,r),v=je.current?.getView();if(v&&En){let{from:O,to:G}=En,X=v.state.schema.marks.comment.create({commentId:fs}),J=v.state.schema.marks.comment.create({commentId:h.id}),ne=v.state.tr.removeMark(O,G,X).addMark(O,G,J);v.dispatch(ne);}zt(O=>[...O,h]),Rn(false),$t(null),At(null),me?.(h);},onCancelAddComment:()=>{let y=je.current?.getView();if(y&&En){let{from:h,to:v}=En,O=y.state.schema.marks.comment.create({commentId:fs});y.dispatch(y.state.tr.removeMark(h,v,O));}Rn(false),$t(null),At(null);},onAcceptChange:(y,h)=>{let v=je.current?.getView();v&&(cp(y,h)(v.state,v.dispatch),fn());},onRejectChange:(y,h)=>{let v=je.current?.getView();v&&(dp(y,h)(v.state,v.dispatch),fn());},onTrackedChangeReply:(y,h)=>{zt(v=>[...v,Gl(h,r,y)]);}};let Tm=useMemo(()=>({onCommentReply:(...y)=>Fn.current.onCommentReply?.(...y),onCommentResolve:(...y)=>Fn.current.onCommentResolve?.(...y),onCommentDelete:(...y)=>Fn.current.onCommentDelete?.(...y),onAddComment:(...y)=>Fn.current.onAddComment?.(...y),onCancelAddComment:(...y)=>Fn.current.onCancelAddComment?.(...y),onAcceptChange:(...y)=>Fn.current.onAcceptChange?.(...y),onRejectChange:(...y)=>Fn.current.onRejectChange?.(...y),onTrackedChangeReply:(...y)=>Fn.current.onTrackedChangeReply?.(...y)}),[]),Zl=cd({comments:dn,trackedChanges:vn,callbacks:Tm,isAddingComment:De?mo:false,addCommentYPosition:Pn}),ws=useMemo(()=>{let y=[];return De&&y.push(...Zl),L&&y.push(...L),y},[De,Zl,L]),Jl=ws.length>0,wm={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};if(oe.isLoading)return jsx("div",{className:`ep-root docx-editor docx-editor-loading ${S}`,style:mi,"data-testid":"docx-editor",children:E$1||jsx(Cp,{})});if(oe.parseError)return jsx("div",{className:`ep-root docx-editor docx-editor-error ${S}`,style:mi,"data-testid":"docx-editor",children:jsx(wp,{message:oe.parseError})});if(!le.state)return jsx("div",{className:`ep-root docx-editor docx-editor-empty ${S}`,style:mi,"data-testid":"docx-editor",children:w||jsx(Tp,{})});let vm=jsxs(Fragment,{children:[jsx(C,{}),jsx(A,{onClick:()=>St(!De),active:De,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsx(d,{name:"comment",size:20})}),jsx(C,{}),jsx(GS,{mode:Ao,onModeChange:y=>{pn(y),y==="suggesting"&&St(true);}}),k]});return jsx(Gc,{children:jsx(wi,{onError:pm,children:jsxs("div",{ref:Qt,className:`ep-root docx-editor ${S}`,style:mi,"data-testid":"docx-editor",children:[jsx("div",{style:Cm,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[d$1&&!x&&jsxs("div",{ref:ys,className:"z-50 flex flex-col gap-0 bg-white shadow-sm flex-shrink-0",children:[jsxs(Ht,{currentFormatting:oe.selectionFormatting,onFormat:mr,onUndo:xs,onRedo:Ss,canUndo:true,canRedo:true,disabled:at,documentStyles:le.state?.package.styles?.styles,theme:le.state?.package.theme||u,showPrintButton:I,onPrint:ci,showZoomControl:c$1,zoom:oe.zoom,onZoomChange:gr,onRefocusEditor:Je,onInsertTable:xe,showTableInsert:true,onInsertImage:Me,onInsertPageBreak:he,onInsertTOC:ke,imageContext:oe.pmImageContext,onImageWrapType:mt,onImageTransform:yt,onOpenImageProperties:No,onPageSetup:ks,tableContext:oe.pmTableContext,onTableAction:ii,children:[jsxs(Ht.TitleBar,{children:[Y&&jsx(Ht.Logo,{children:Y()}),se!==void 0&&jsx(Ht.DocumentName,{value:se,onChange:W,editable:q}),Q&&jsx(Ht.TitleBarRight,{children:Q()}),jsx(Ht.MenuBar,{})]}),jsx(Ht.FormattingBar,{children:vm})]}),m&&jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:Jl?`calc(20px + ${352}px)`:void 0,transition:"padding 0.2s ease"},children:jsx(E,{sectionProps:le.state?.package.document?.finalSectionProperties,zoom:oe.zoom,unit:b,editable:!at,onLeftMarginChange:om,onRightMarginChange:rm,indentLeft:oe.paragraphIndentLeft,indentRight:oe.paragraphIndentRight,onIndentLeftChange:lm,onIndentRightChange:cm,showFirstLineIndent:true,firstLineIndent:oe.paragraphFirstLineIndent,hangingIndent:oe.paragraphHangingIndent,onFirstLineIndentChange:dm,tabStops:oe.paragraphTabs,onTabStopRemove:um})})]}),jsx("div",{ref:en,style:wm,children:jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxs("div",{ref:Do,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y=>{y.target===y.currentTarget&&(y.preventDefault(),je.current?.focus());},onContextMenu:ai,children:[m&&!x&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsx(md,{sectionProps:le.state?.package.document?.finalSectionProperties,zoom:oe.zoom,unit:b,editable:!at,onTopMarginChange:im,onBottomMarginChange:am})}),jsx(Df,{ref:je,document:le.state,styles:le.state?.package.styles,theme:le.state?.package.theme||u,sectionProperties:le.state?.package.document?.finalSectionProperties,headerContent:di,footerContent:ui,firstPageHeaderContent:pi,firstPageFooterContent:fi,onHeaderFooterDoubleClick:ym,hfEditMode:Pe,onBodyClick:xm,zoom:oe.zoom,readOnly:at,extensionManager:Ut,onDocumentChange:K,onSelectionChange:(y,h)=>{let v=je.current?.getView();if(v){let O=tr(v.state);te(O);}else te(null);},externalPlugins:Jr,onReady:y=>{F?.(y.getView());},onRenderedDomContextReady:C$1,pluginOverlays:M,onHyperlinkClick:hr,onContextMenu:mn,commentsSidebarOpen:Jl,onAnchorPositionsChange:Bo,scrollContainerRef:en,sidebarOverlay:ws.length>0?jsx(td,{items:ws,anchorPositions:fo,renderedDomContext:D??null,pageWidth:(()=>{let y=le.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),zoom:oe.zoom,editorContainerRef:en}):void 0}),_t!=null&&!mo&&!at&&jsx(c,{content:"Add comment",side:"bottom",delayMs:300,children:jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),y.stopPropagation();let h=je.current?.getView();if(h){let{from:v,to:O}=h.state.selection;if(v!==O){$t({from:v,to:O});let G=h.state.schema.marks.comment.create({commentId:fs}),X=h.state.tr.addMark(v,O,G);X.setSelection(TextSelection.create(X.doc,O)),h.dispatch(X);}}At(_t.top),St(true),Rn(true),Wt(null);},style:{position:"absolute",top:_t.top,left:_t.left,transform:"translate(-50%, -50%)",zIndex:50,width:28,height:28,borderRadius:6,border:"1px solid rgba(26, 115, 232, 0.3)",backgroundColor:"#fff",color:"#1a73e8",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(60,64,67,0.2)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},onMouseOver:y=>{y.currentTarget.style.backgroundColor="rgba(26, 115, 232, 0.08)",y.currentTarget.style.boxShadow="0 1px 4px rgba(26, 115, 232, 0.3)";},onMouseOut:y=>{y.currentTarget.style.backgroundColor="#fff",y.currentTarget.style.boxShadow="0 1px 3px rgba(60,64,67,0.2)";},children:jsx(d,{name:"add_comment",size:16})})}),jsx(Z,{isOpen:lt.isOpen,position:lt.position,hasSelection:lt.hasSelection,isEditable:!at,items:Vn,onAction:li,onClose:()=>Vt(y=>({...y,isOpen:false}))}),Pe&&(()=>{let y=Ye?Pe==="header"?pi:fi:Pe==="header"?di:ui;if(!y)return null;let h=km(Pe),v=Do.current;return !h||!v?null:jsx(gp,{ref:ft,headerFooter:y,position:Pe,styles:le.state?.package.styles,targetElement:h,parentElement:v,onSave:Ts,onClose:()=>Ke(null),onSelectionChange:te,onRemove:Sm})})()]})})}),In.totalPages>1&&jsxs("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:In.visible?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:[In.currentPage," of ",In.totalPages]}),Ze&&jsx(Xc,{headings:Fe,onHeadingClick:Ce,onClose:()=>ut(false),topOffset:pr}),z$1&&!Ze&&jsx("button",{className:"docx-outline-nav",onClick:Ee,onMouseDown:y=>y.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:pr+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsx(d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]})}),jsx(Sp,{data:yo,onNavigate:Cs,onCopy:br,onEdit:si,onRemove:ct,onClose:So,readOnly:at}),jsx(Z,{isOpen:lt.isOpen,position:lt.position,hasSelection:lt.hasSelection,isEditable:!at,items:Vn,onAction:li,onClose:ko}),jsx(Toaster,{position:"bottom-right"}),jsxs(Suspense,{fallback:null,children:[kt.state.isOpen&&jsx(NS,{isOpen:kt.state.isOpen,onClose:kt.close,onFind:fm,onFindNext:mm,onFindPrevious:gm,onReplace:hm,onReplaceAll:bm,initialSearchText:kt.state.searchText,replaceMode:kt.state.replaceMode,currentResult:Dt.current}),wt.state.isOpen&&jsx(OS,{isOpen:wt.state.isOpen,onClose:wt.close,onSubmit:Oo,onRemove:wt.state.isEditing?xo:void 0,initialData:wt.state.initialData,selectedText:wt.state.selectedText,isEditing:wt.state.isEditing}),pe&&jsx(zS,{isOpen:pe,onClose:()=>be(false),onApply:y=>{let h=Ie();h&&zr(y)(h.state,h.dispatch);},currentProps:oe.pmTableContext?.table?.attrs}),Ue&&jsx($S,{isOpen:Ue,onClose:()=>Be(false),onApply:tn}),Ge&&jsx(_S,{isOpen:Ge,onClose:()=>Oe(false),onApply:oi,currentData:oe.pmImageContext?{alt:oe.pmImageContext.alt??void 0,borderWidth:oe.pmImageContext.borderWidth??void 0,borderColor:oe.pmImageContext.borderColor??void 0,borderStyle:oe.pmImageContext.borderStyle??void 0}:void 0}),ti&&jsx(VS,{isOpen:ti,onClose:()=>ni(false),onApply:sm,currentProps:le.state?.package.document?.finalSectionProperties}),Ae&&jsx(WS,{isOpen:Ae,onClose:()=>Re(false),onApply:ri,footnotePr:le.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:le.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsx("input",{ref:Mn,type:"file",accept:"image/*",style:{display:"none"},onChange:We})]})})})});function WM(e,t,n={}){return new Promise((o,r)=>{let i=$f.createRef(),a=null;try{a=createRoot(t);}catch(d){r(d);return}let s={save:async()=>{let d=await(i.current?.save()??Promise.resolve(null));return d?new Blob([d],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:d=>i.current?.setZoom(d),destroy:()=>{a?.unmount(),a=null;}},l=false,u=$f.createElement(zf,{...n,documentBuffer:e,onError:d=>{n.onError?.(d),l||(l=true,r(d));},onChange:d=>{n.onChange?.(d),l||(l=true,o(s));},ref:i});a.render(u);})}function ZM(e,t={}){let{storageKey:n,interval:o,enabled:r$1=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:d}=t,c=useMemo(()=>new r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:d,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);useEffect(()=>{r$1?(c.enable(),c.startInterval()):c.disable();},[c,r$1]),useEffect(()=>{c.onDocumentChanged(e??null);},[c,e]),useEffect(()=>()=>{c.destroy();},[c]);let p=useSyncExternalStore(c.subscribe,c.getSnapshot),f=useCallback(()=>c.save(),[c]),m=useCallback(()=>c.clear(),[c]),b=useCallback(()=>c.getRecoveryData(),[c]),g=useCallback(()=>c.acceptRecovery(),[c]),x=useCallback(()=>c.dismissRecovery(),[c]),k=useCallback(()=>c.enable(),[c]),S=useCallback(()=>c.disable(),[c]);return {status:p.status,lastSaveTime:p.lastSaveTime,save:f,clearAutoSave:m,hasRecoveryData:p.hasRecoveryData,getRecoveryData:b,acceptRecovery:g,dismissRecovery:x,isEnabled:p.isEnabled,enable:k,disable:S}}var ek=1,_f=.25,Wf=4,tk=.1,ln=[.25,.5,.75,1,1.25,1.5,2,3,4];function Vf(e,t,n){return Math.max(t,Math.min(n,e))}function Uf(e){return Math.round(e*100)/100}function nk(e){let t=ln[0],n=Math.abs(e-t);for(let o of ln){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function ok(e){for(let t of ln)if(t>e+.01)return t;return ln[ln.length-1]}function rk(e){for(let t=ln.length-1;t>=0;t--)if(ln[t]<e-.01)return ln[t];return ln[0]}function eI(e={}){let{initialZoom:t=ek,minZoom:n=_f,maxZoom:o=Wf,zoomStep:r=tk,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[d,c]=useState(t),p=useRef(d);useEffect(()=>{p.current=d;},[d]);let f=useCallback(w=>{let E=Uf(Vf(w,n,o));E!==p.current&&(c(E),s?.(E));},[n,o,s]),m=useCallback(()=>{f(p.current+r);},[r,f]),b=useCallback(()=>{f(p.current-r);},[r,f]),g=useCallback(()=>{f(t);},[t,f]),x=useCallback(()=>{f(1);},[f]),k=useCallback((w,E)=>{if(E>0){let P=w/E;f(P);}},[f]),S=useCallback(w=>{if(!i||!(w.ctrlKey||w.metaKey))return;u&&w.preventDefault();let P=w.deltaY;P<0?f(p.current+r):P>0&&f(p.current-r);},[i,u,r,f]),B=useCallback(w=>{if(!(!i||!l||!(w.ctrlKey||w.metaKey))){if(w.key==="0"){w.preventDefault(),x();return}if(w.key==="+"||w.key==="="){w.preventDefault(),m();return}if(w.key==="-"){w.preventDefault(),b();return}}},[i,l,m,b,x]);return useEffect(()=>{if(!i)return;let w=a?.current;if(w)return w.addEventListener("wheel",S,{passive:false}),()=>{w.removeEventListener("wheel",S);}},[i,a,S]),useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B);}},[i,l,B]),{zoom:d,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:g,zoomTo100:x,zoomToFit:k,isMinZoom:d<=n,isMaxZoom:d>=o,zoomPercent:Math.round(d*100),handleWheel:S,handleKeyDown:B}}function tI(){return [...ln]}function nI(e){return nk(e)}function oI(e){return ok(e)}function rI(e){return rk(e)}function iI(e){return `${Math.round(e*100)}%`}function aI(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function sI(e){return ln.some(t=>Math.abs(t-e)<.01)}function lI(e,t=_f,n=Wf){return Uf(Vf(e,t,n))}var lr={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},dI={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},uI={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function jf(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return [];let n=t.getRangeAt(0);if(e&&!e.contains(n.commonAncestorContainer))return [];let o=n.getClientRects(),r=[],i=0,a=0;if(e){let s=e.getBoundingClientRect();i=s.left+e.scrollLeft,a=s.top+e.scrollTop;}for(let s=0;s<o.length;s++){let l=o[s];l.width===0&&l.height===0||r.push({left:l.left-i,top:l.top-a,width:l.width,height:l.height});}return r}function ik(e,t=2){if(e.length<=1)return e;let n=[...e].sort((i,a)=>Math.abs(i.top-a.top)<t?i.left-a.left:i.top-a.top),o=[],r={...n[0]};for(let i=1;i<n.length;i++){let a=n[i],s=Math.abs(a.top-r.top)<t,l=a.left<=r.left+r.width+t;if(s&&l){let u=Math.max(r.left+r.width,a.left+a.width);r.width=u-r.left,r.height=Math.max(r.height,a.height);}else o.push(r),r={...a};}return o.push(r),o}function ql(e){let t=jf(e);return ik(t)}function pI(e,t=lr){return {position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}function fI(e,t=lr){let n=t.backgroundColor;return `
|
|
30
|
+
${e}::selection,
|
|
31
|
+
${e} *::selection {
|
|
32
|
+
background-color: ${n} !important;
|
|
33
|
+
color: inherit !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${e}::-moz-selection,
|
|
37
|
+
${e} *::-moz-selection {
|
|
38
|
+
background-color: ${n} !important;
|
|
39
|
+
color: inherit !important;
|
|
40
|
+
}
|
|
41
|
+
`}function Gf(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function Kf(){let e=window.getSelection();return e?e.toString():""}function Yf(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function mI(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function gI(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function hI(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function bI(){let e=window.getSelection();e&&e.removeAllRanges();}function ak(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.anchorNode,n=e.focusNode;return !t||!n?false:t===n?e.focusOffset<e.anchorOffset:(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING)!==0}function yI(){let e=window.getSelection();if(!e||e.rangeCount===0||!ak())return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(n);}var po=null;function qf(e=lr){sk();let t=`
|
|
42
|
+
/* DOCX Editor Selection Highlighting */
|
|
43
|
+
|
|
44
|
+
/* Base selection style for all editable content */
|
|
45
|
+
.docx-editor [contenteditable="true"]::selection,
|
|
46
|
+
.docx-editor [contenteditable="true"] *::selection,
|
|
47
|
+
.docx-run-editable::selection,
|
|
48
|
+
.docx-run-editable *::selection {
|
|
49
|
+
background-color: ${e.backgroundColor} !important;
|
|
50
|
+
color: inherit !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Firefox selection */
|
|
54
|
+
.docx-editor [contenteditable="true"]::-moz-selection,
|
|
55
|
+
.docx-editor [contenteditable="true"] *::-moz-selection,
|
|
56
|
+
.docx-run-editable::-moz-selection,
|
|
57
|
+
.docx-run-editable *::-moz-selection {
|
|
58
|
+
background-color: ${e.backgroundColor} !important;
|
|
59
|
+
color: inherit !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Ensure selection is visible against all backgrounds */
|
|
63
|
+
.docx-run-highlighted::selection,
|
|
64
|
+
.docx-run-highlighted *::selection {
|
|
65
|
+
/* For highlighted (yellow background) text, use darker selection */
|
|
66
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.docx-run-highlighted::-moz-selection,
|
|
70
|
+
.docx-run-highlighted *::-moz-selection {
|
|
71
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Selection in dark text */
|
|
75
|
+
.docx-run-dark-bg::selection,
|
|
76
|
+
.docx-run-dark-bg *::selection {
|
|
77
|
+
/* Use lighter selection for dark backgrounds */
|
|
78
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.docx-run-dark-bg::-moz-selection,
|
|
82
|
+
.docx-run-dark-bg *::-moz-selection {
|
|
83
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Programmatic highlight class */
|
|
87
|
+
.docx-selection-highlight {
|
|
88
|
+
background-color: ${e.backgroundColor};
|
|
89
|
+
${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
|
|
90
|
+
${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Find/replace highlight */
|
|
94
|
+
.docx-find-highlight {
|
|
95
|
+
background-color: rgba(255, 235, 59, 0.5);
|
|
96
|
+
border-radius: 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.docx-find-highlight-current {
|
|
100
|
+
background-color: rgba(255, 152, 0, 0.6);
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
outline: 2px solid rgba(255, 152, 0, 0.8);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* AI action selection preview */
|
|
106
|
+
.docx-ai-selection-preview {
|
|
107
|
+
background-color: rgba(156, 39, 176, 0.2);
|
|
108
|
+
border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
|
|
109
|
+
}
|
|
110
|
+
`;po=document.createElement("style"),po.id="docx-selection-styles",po.textContent=t,document.head.appendChild(po);}function sk(){po&&(po.remove(),po=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function Xf(){return po!==null||document.getElementById("docx-selection-styles")!==null}function xI(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?ql(e):jf(e);t(o);}}function vI(e){let{containerRef:t,enabled:n=true,config:o=lr,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=useState(false),[u,d]=useState(""),[c,p]=useState([]),[f,m]=useState(false),b=useRef(null),g=useRef(0),x=useCallback(()=>{let w=t.current,E=Gf(),P=Kf(),z=w?Yf(w):false;if(l(E),d(P),m(z),r&&z){let I=ql(w);p(I);}else p([]);a&&a(E&&z,P);},[t,r,a]),k=useCallback(()=>{let w=performance.now();if(w-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),x(),b.current=null;},i);return}g.current=w,x();},[i,x]),S=useCallback(()=>{x();},[x]),B=useCallback(w=>({position:"absolute",left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,backgroundColor:o.backgroundColor,borderRadius:o.borderRadius?`${o.borderRadius}px`:void 0,border:o.borderColor?`1px solid ${o.borderColor}`:void 0,zIndex:o.zIndex??0,opacity:o.opacity??1,mixBlendMode:o.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[o]);return useEffect(()=>(n&&!Xf()&&qf(o),()=>{}),[n,o]),useEffect(()=>{if(!n)return;let w=()=>{k();};return document.addEventListener("selectionchange",w),document.addEventListener("mouseup",w),x(),()=>{document.removeEventListener("selectionchange",w),document.removeEventListener("mouseup",w),b.current!==null&&clearTimeout(b.current);}},[n,k,x]),{hasSelection:s,selectedText:u,highlightRects:c,isSelectionInContainer:f,refresh:S,getOverlayStyle:B}}function RI(e,t=lr){return e.map((n,o)=>$f.createElement("div",{key:`selection-overlay-${o}`,style:{position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function LI(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=useRef(false),l=useRef(null),u=useCallback(async g=>{if(s.current)return false;s.current=true;try{let x=await M(g.runs,{onError:a});return x&&t?.(g),x}finally{s.current=false;}},[t,a]),d=useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let x=await M(g.runs,{onError:a});return x&&n?.(g),x}finally{s.current=false;}},[n,i,a]),c=useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let x=await navigator.clipboard.read(),k="",S="";for(let w of x)w.types.includes("text/html")&&(k=await(await w.getType("text/html")).text()),w.types.includes("text/plain")&&(S=await(await w.getType("text/plain")).text());g&&(k="");let B=T(k,S,r);return l.current=B,o?.(B,g),B}return null}catch(x){return a?.(x),null}finally{s.current=false;}},[i,r,o,a]),p=useCallback(g=>{let x=F();if(!x)return;g.preventDefault();let k=O(x.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",k.plainText),g.clipboardData.setData("text/html",k.html),k.internal&&g.clipboardData.setData("application/x-docx-editor",k.internal)),t?.(x);},[t]),f=useCallback(g=>{if(!i)return;let x=F();if(!x)return;g.preventDefault();let k=O(x.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",k.plainText),g.clipboardData.setData("text/html",k.html),k.internal&&g.clipboardData.setData("application/x-docx-editor",k.internal)),n?.(x);},[i,n]),m=useCallback(g=>{if(!i)return;g.preventDefault();let x=S(g,{cleanWordFormatting:r});if(x){l.current=x;let k=g.shiftKey??false;o?.(x,k);}},[i,r,o]),b=useCallback(g=>{},[]);return {copy:u,cut:d,paste:c,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var hs={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},tm=I,nm=`
|
|
111
|
+
.plugin-host {
|
|
112
|
+
display: flex;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
overflow: visible;
|
|
116
|
+
position: relative;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.plugin-host-editor {
|
|
120
|
+
flex: 1;
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
min-width: 0;
|
|
124
|
+
overflow: visible;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
.plugin-panels-left,
|
|
129
|
+
.plugin-panels-right {
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
background: #f8f9fa;
|
|
134
|
+
border-color: #e9ecef;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.plugin-panels-left {
|
|
138
|
+
border-right: 1px solid #e9ecef;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.plugin-panels-right {
|
|
142
|
+
border-left: 1px solid #e9ecef;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.plugin-panels-bottom {
|
|
146
|
+
border-top: 1px solid #e9ecef;
|
|
147
|
+
background: #f8f9fa;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.plugin-panel {
|
|
151
|
+
position: relative;
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
transition: width 0.2s ease, height 0.2s ease;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.plugin-panel.collapsed {
|
|
159
|
+
overflow: visible;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.plugin-panel-toggle {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 4px;
|
|
166
|
+
padding: 6px 8px;
|
|
167
|
+
background: transparent;
|
|
168
|
+
border: none;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
font-size: 12px;
|
|
171
|
+
color: #6c757d;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.plugin-panel.collapsed .plugin-panel-toggle {
|
|
176
|
+
writing-mode: vertical-rl;
|
|
177
|
+
text-orientation: mixed;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
height: 100%;
|
|
180
|
+
padding: 8px 6px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.plugin-panel-toggle:hover {
|
|
184
|
+
background: #e9ecef;
|
|
185
|
+
color: #495057;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.plugin-panel-toggle-icon {
|
|
189
|
+
font-weight: bold;
|
|
190
|
+
font-size: 14px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.plugin-panel.collapsed .plugin-panel-toggle-icon {
|
|
194
|
+
transform: rotate(90deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.plugin-panel-toggle-label {
|
|
198
|
+
font-weight: 500;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.plugin-panel-content {
|
|
202
|
+
flex: 1;
|
|
203
|
+
overflow: auto;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Right panel rendered inside viewport - scrolls with content */
|
|
207
|
+
.plugin-panel-in-viewport {
|
|
208
|
+
position: absolute;
|
|
209
|
+
top: 0;
|
|
210
|
+
/* Position is set dynamically via inline styles based on page edge */
|
|
211
|
+
width: 220px;
|
|
212
|
+
pointer-events: auto;
|
|
213
|
+
z-index: 10;
|
|
214
|
+
overflow: visible;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.plugin-panel-in-viewport.collapsed {
|
|
218
|
+
width: 32px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.plugin-panel-in-viewport .plugin-panel-toggle {
|
|
222
|
+
position: sticky;
|
|
223
|
+
top: 0;
|
|
224
|
+
background: rgba(255, 255, 255, 0.95);
|
|
225
|
+
border-radius: 4px;
|
|
226
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.plugin-panel-in-viewport-content {
|
|
230
|
+
overflow: visible;
|
|
231
|
+
position: relative;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Plugin overlay container for rendering highlights/decorations */
|
|
235
|
+
.plugin-overlays-container {
|
|
236
|
+
position: absolute;
|
|
237
|
+
top: 0;
|
|
238
|
+
left: 0;
|
|
239
|
+
right: 0;
|
|
240
|
+
bottom: 0;
|
|
241
|
+
pointer-events: none;
|
|
242
|
+
overflow: visible;
|
|
243
|
+
z-index: 5;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.plugin-overlay {
|
|
247
|
+
position: absolute;
|
|
248
|
+
top: 0;
|
|
249
|
+
left: 0;
|
|
250
|
+
right: 0;
|
|
251
|
+
bottom: 0;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Individual overlay children manage their own pointer-events.
|
|
256
|
+
Do NOT set pointer-events: auto here \u2014 it overrides overlay containers
|
|
257
|
+
that need pointer-events: none to let clicks pass through to the editor. */
|
|
258
|
+
`,mk=forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=useState(null),s=useRef(n.props);s.current=n.props;let[l,u]=useState(null),d=useMemo(()=>new J,[]),c=useSyncExternalStore(d.subscribe,d.getSnapshot),[p,f]=useState(()=>{let $=new Set;for(let H of t)({...hs,...H.panelConfig}).defaultCollapsed&&$.add(H.id);return $}),[m]=useState(()=>{let $=new Map;for(let H of t){let de={...hs,...H.panelConfig};$.set(H.id,de.defaultSize);}return $});useEffect(()=>{if(!i)return;let $=t.map(H=>({id:H.id,styles:H.styles,initialize:H.initialize,onStateChange:H.onStateChange,destroy:H.destroy}));return d.initialize($,i),()=>{d.destroy();}},[d,i,t]),useEffect(()=>{let $=t.filter(H=>H.styles).map(H=>tm(H.id,H.styles));return ()=>$.forEach(H=>H())},[t]),useEffect(()=>{if(!i?.dom)return;let $=()=>{d.updateStates(i);},H=null,de=()=>{H&&cancelAnimationFrame(H),H=requestAnimationFrame($);};$();let me=i.dom;me.addEventListener("input",de),me.addEventListener("focus",$),me.addEventListener("click",$);let ue=i.dispatch.bind(i);return i.dispatch=N=>{ue(N),de();},()=>{me.removeEventListener("input",de),me.removeEventListener("focus",$),me.removeEventListener("click",$),H&&cancelAnimationFrame(H),i.dispatch=ue;}},[i,d]),useEffect(()=>tm("plugin-host-base",nm),[]);let b=useCallback($=>{if(!i)return;if(i.coordsAtPos($)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:de}=i,me=de.doc.resolve(Math.min($,de.doc.content.size)),ue=de.tr.setSelection(TextSelection.near(me));i.dispatch(ue),i.focus();}},[i]),g=useCallback(($,H)=>{if(!i)return;let{state:de}=i,me=de.doc.content.size,ue=Math.max(0,Math.min($,me)),N=Math.max(0,Math.min(H,me)),Ve=de.tr.setSelection(TextSelection.create(de.doc,ue,N));i.dispatch(Ve),i.focus();},[i]),x=useCallback($=>d.getPluginState($),[d]),k=useCallback(($,H)=>{d.setPluginState($,H);},[d]),S=useCallback(()=>{i&&d.updateStates(i);},[i,d]);useImperativeHandle(r,()=>({getPluginState:x,setPluginState:k,getEditorView:()=>i,refreshPluginStates:S}),[x,k,i,S]);let B=useMemo(()=>{let $=[];for(let H of t)H.proseMirrorPlugins&&$.push(...H.proseMirrorPlugins);return $},[t]),w=useCallback($=>{f(H=>{let de=new Set(H);return de.has($)?de.delete($):de.add($),de});},[]),[E,P]=useState(null);useEffect(()=>{if(!l){P(null);return}let $=()=>{let me=l.pagesContainer,ue=me.querySelector(".layout-page");if(!ue){P(null);return}let N=l.getContainerOffset(),Ve=ue.getBoundingClientRect(),R=me.getBoundingClientRect(),F=(Ve.right-R.left)/l.zoom,C=N.x+F+5;P(C);};$();let H=()=>{requestAnimationFrame($);};window.addEventListener("resize",H);let de=new ResizeObserver(()=>{requestAnimationFrame($);});return de.observe(l.pagesContainer),()=>{window.removeEventListener("resize",H),de.disconnect();}},[l]);let z=useMemo(()=>{let $=[];if(l){for(let H of t)if(H.renderOverlay){let de=c.states.get(H.id);$.push(jsx("div",{className:"plugin-overlay","data-plugin-id":H.id,children:H.renderOverlay(l,de,i)},`overlay-${H.id}`));}}for(let H of t){if(!H.Panel||(H.panelConfig?.position??"right")!=="right")continue;let me={...hs,...H.panelConfig},ue=p.has(H.id),N=m.get(H.id)??me.defaultSize,Ve=H.Panel,R=c.states.get(H.id),F=E!==null?`${E}px`:"calc(50% + 428px)";$.push(jsxs("div",{className:`plugin-panel-in-viewport ${ue?"collapsed":""}`,style:{width:ue?"32px":`${N}px`,left:F},"data-plugin-id":H.id,children:[me.collapsible&&jsx("button",{className:"plugin-panel-toggle",onClick:()=>w(H.id),title:ue?`Show ${H.name}`:`Hide ${H.name}`,"aria-label":ue?`Show ${H.name}`:`Hide ${H.name}`,children:jsx("span",{className:"plugin-panel-toggle-icon",children:ue?"\u2039":"\u203A"})}),!ue&&l&&jsx("div",{className:"plugin-panel-in-viewport-content",children:jsx(Ve,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:R,panelWidth:N,renderedDomContext:l})})]},`panel-overlay-${H.id}`));}return $.length>0?$:null},[l,t,c.version,i,p,m,b,g,w,E]),I=useMemo(()=>{let $=[];for(let H of t){if(!H.getSidebarItems)continue;let de=c.states.get(H.id),me={editorView:i,renderedDomContext:l,anchorPositions:new Map,zoom:l?.zoom??1},ue=H.getSidebarItems(de,me);$.push(...ue);}return $},[t,c.version,i,l]),A=useCallback($=>{u($);let H=s.current?.onRenderedDomContextReady;typeof H=="function"&&H($);},[]),Z=useMemo(()=>cloneElement(n,{externalPlugins:B,pluginOverlays:z,pluginSidebarItems:I,pluginRenderedDomContext:l,onRenderedDomContextReady:A,onEditorViewReady:$=>{a($);let H=s.current?.onEditorViewReady;typeof H=="function"&&H($);}}),[n,B,z,I,l,A]),ce=useMemo(()=>{let $=[],H=[],de=[];for(let me of t){if(!me.Panel)continue;let ue=me.panelConfig?.position??"right";ue==="left"?$.push(me):ue==="bottom"?de.push(me):H.push(me);}return {left:$,right:H,bottom:de}},[t]),ae=$=>{if(!$.Panel)return null;let H={...hs,...$.panelConfig},de=p.has($.id),me=m.get($.id)??H.defaultSize,ue=$.Panel,N=c.states.get($.id);return jsxs("div",{className:`plugin-panel plugin-panel-${H.position} ${de?"collapsed":""}`,style:{[H.position==="bottom"?"height":"width"]:de?"32px":`${me}px`,minWidth:H.position!=="bottom"?de?"32px":`${H.minSize}px`:void 0,maxWidth:H.position!=="bottom"?`${H.maxSize}px`:void 0,minHeight:H.position==="bottom"?de?"32px":`${H.minSize}px`:void 0,maxHeight:H.position==="bottom"?`${H.maxSize}px`:void 0},"data-plugin-id":$.id,children:[H.collapsible&&jsxs("button",{className:"plugin-panel-toggle",onClick:()=>w($.id),title:de?`Show ${$.name}`:`Hide ${$.name}`,"aria-label":de?`Show ${$.name}`:`Hide ${$.name}`,children:[jsx("span",{className:"plugin-panel-toggle-icon",children:de?"\u203A":"\u2039"}),de&&jsx("span",{className:"plugin-panel-toggle-label",children:$.name})]}),!de&&jsx("div",{className:"plugin-panel-content",children:jsx(ue,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:N,panelWidth:me,renderedDomContext:l??null})})]},$.id)};return jsxs("div",{className:`plugin-host ${o}`,children:[ce.left.length>0&&jsx("div",{className:"plugin-panels-left",children:ce.left.map(ae)}),jsxs("div",{className:"plugin-host-editor",children:[Z,ce.bottom.length>0&&jsx("div",{className:"plugin-panels-bottom",children:ce.bottom.map(ae)})]})]})});export{ik as A,ql as B,pI as C,fI as D,Gf as E,Kf as F,Yf as G,mI as H,gI as I,hI as J,bI as K,ak as L,yI as M,qf as N,sk as O,Xf as P,xI as Q,vI as R,RI as S,LI as T,nm as U,mk as V,Ht as a,Lk as b,Gc as c,wi as d,Bk as e,Ak as f,Dk as g,Hk as h,Yc as i,zf as j,WM as k,ZM as l,ln as m,eI as n,tI as o,nI as p,oI as q,rI as r,iI as s,aI as t,sI as u,lI as v,lr as w,dI as x,uI as y,jf as z};
|