@postnzt/docx-js-editor 0.0.33

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.
Files changed (117) hide show
  1. package/dist/ClipboardManager-C0rTRkVQ.d.ts +464 -0
  2. package/dist/ClipboardManager-CgpKW2At.d.mts +464 -0
  3. package/dist/DocumentAgent-BqA9EJ3F.d.mts +442 -0
  4. package/dist/DocumentAgent-CRCXiBT7.d.ts +442 -0
  5. package/dist/FindReplaceDialog-KNJETYJX.js +1 -0
  6. package/dist/FindReplaceDialog-YW3R4FHM.mjs +1 -0
  7. package/dist/FootnotePropertiesDialog-452A4UT5.js +1 -0
  8. package/dist/FootnotePropertiesDialog-H24AC5XK.mjs +1 -0
  9. package/dist/HyperlinkDialog-GBAYMTUE.js +1 -0
  10. package/dist/HyperlinkDialog-HNYTXDCB.mjs +1 -0
  11. package/dist/ImagePositionDialog-B4RLP2W5.mjs +1 -0
  12. package/dist/ImagePositionDialog-M65BYQQE.js +1 -0
  13. package/dist/ImagePropertiesDialog-JOGW3WDU.mjs +1 -0
  14. package/dist/ImagePropertiesDialog-O4WQSF5M.js +1 -0
  15. package/dist/PageSetupDialog-2GIBTKMJ.js +1 -0
  16. package/dist/PageSetupDialog-Q7SHEZIJ.mjs +1 -0
  17. package/dist/TablePropertiesDialog-LMXWX3FI.mjs +1 -0
  18. package/dist/TablePropertiesDialog-WOZ4ES3H.js +1 -0
  19. package/dist/agentApi-BVHzyk2l.d.mts +2239 -0
  20. package/dist/agentApi-BVHzyk2l.d.ts +2239 -0
  21. package/dist/chunk-2HDYCD2Q.mjs +1 -0
  22. package/dist/chunk-377ZVTSE.js +2 -0
  23. package/dist/chunk-37SLIJPH.mjs +58 -0
  24. package/dist/chunk-4VUZBV2S.js +1 -0
  25. package/dist/chunk-6WPRCJ5A.mjs +1 -0
  26. package/dist/chunk-7MGFEP2R.mjs +26 -0
  27. package/dist/chunk-7QTNB64A.mjs +9 -0
  28. package/dist/chunk-AARNCPWR.js +1 -0
  29. package/dist/chunk-AU5NVRHP.js +2 -0
  30. package/dist/chunk-BP3V2HDD.js +261 -0
  31. package/dist/chunk-BUEMG4NW.js +1 -0
  32. package/dist/chunk-DC65PJYE.js +4 -0
  33. package/dist/chunk-DLVLK5FT.mjs +24 -0
  34. package/dist/chunk-EV3CM6TU.js +1 -0
  35. package/dist/chunk-FVUGBRDD.js +1 -0
  36. package/dist/chunk-GZOCOWWB.mjs +2 -0
  37. package/dist/chunk-H5NTJZO4.js +1 -0
  38. package/dist/chunk-IFPN3NT3.js +3 -0
  39. package/dist/chunk-KCOGY3V2.js +10 -0
  40. package/dist/chunk-KUL2SDYC.js +26 -0
  41. package/dist/chunk-LFZXSNOF.mjs +261 -0
  42. package/dist/chunk-LYBG4YI7.mjs +1 -0
  43. package/dist/chunk-M5F4SK3W.mjs +1 -0
  44. package/dist/chunk-P7WEP4JU.js +9 -0
  45. package/dist/chunk-PB7VMDDP.js +24 -0
  46. package/dist/chunk-QAZ4233N.mjs +1 -0
  47. package/dist/chunk-QSUPYUOP.js +2 -0
  48. package/dist/chunk-QTSXJRP6.mjs +1 -0
  49. package/dist/chunk-QVPR2W5S.js +1 -0
  50. package/dist/chunk-RTFUE3KK.mjs +10 -0
  51. package/dist/chunk-SCYTWBF5.mjs +111 -0
  52. package/dist/chunk-SE5EN2QL.js +1 -0
  53. package/dist/chunk-T6X4C2QO.js +111 -0
  54. package/dist/chunk-TAUMSKRE.mjs +1 -0
  55. package/dist/chunk-W53SI3XW.mjs +1 -0
  56. package/dist/chunk-WOHFANC5.mjs +3 -0
  57. package/dist/chunk-X5A54T6S.mjs +4 -0
  58. package/dist/chunk-YKBSKEBS.mjs +2 -0
  59. package/dist/chunk-Z26WOH6R.mjs +2 -0
  60. package/dist/chunk-ZJNGMDRE.js +58 -0
  61. package/dist/clipboard-Cu80iVDh.d.ts +1181 -0
  62. package/dist/clipboard-dFROLI95.d.mts +1181 -0
  63. package/dist/colorResolver-BwI_Uxp3.d.mts +662 -0
  64. package/dist/colorResolver-Dlmk3itT.d.ts +662 -0
  65. package/dist/core-plugins-reexport.d.mts +31 -0
  66. package/dist/core-plugins-reexport.d.ts +31 -0
  67. package/dist/core-plugins-reexport.js +1 -0
  68. package/dist/core-plugins-reexport.mjs +1 -0
  69. package/dist/core-reexport.d.mts +309 -0
  70. package/dist/core-reexport.d.ts +309 -0
  71. package/dist/core-reexport.js +1 -0
  72. package/dist/core-reexport.mjs +1 -0
  73. package/dist/executor-L2MVKMXO.js +1 -0
  74. package/dist/executor-XKBCCVNY.mjs +1 -0
  75. package/dist/fontLoader-BI9ZoACv.d.ts +176 -0
  76. package/dist/fontLoader-DicgJidU.d.mts +176 -0
  77. package/dist/headless-reexport.d.mts +195 -0
  78. package/dist/headless-reexport.d.ts +195 -0
  79. package/dist/headless-reexport.js +4 -0
  80. package/dist/headless-reexport.mjs +4 -0
  81. package/dist/index.css +1 -0
  82. package/dist/index.d.mts +480 -0
  83. package/dist/index.d.ts +480 -0
  84. package/dist/index.js +112 -0
  85. package/dist/index.mjs +112 -0
  86. package/dist/lib-BCT2DRYI.mjs +1 -0
  87. package/dist/lib-U35UU4OU.js +1 -0
  88. package/dist/mcp-reexport.d.mts +156 -0
  89. package/dist/mcp-reexport.d.ts +156 -0
  90. package/dist/mcp-reexport.js +16 -0
  91. package/dist/mcp-reexport.mjs +16 -0
  92. package/dist/processTemplate-5ZST2Q5L.js +1 -0
  93. package/dist/processTemplate-LRHXOWMZ.mjs +1 -0
  94. package/dist/react-Cl2n0F5S.d.ts +1091 -0
  95. package/dist/react-DZlAKNXg.d.mts +1091 -0
  96. package/dist/react.css +1 -0
  97. package/dist/react.d.mts +10 -0
  98. package/dist/react.d.ts +10 -0
  99. package/dist/react.js +1 -0
  100. package/dist/react.mjs +1 -0
  101. package/dist/registry-D4FQ9aKX.d.mts +165 -0
  102. package/dist/registry-DrYyUXQr.d.ts +165 -0
  103. package/dist/selectionRects-DEX5THEG.js +1 -0
  104. package/dist/selectionRects-SQTAHMCH.mjs +1 -0
  105. package/dist/styles.css +1 -0
  106. package/dist/types-B3LkfO0u.d.mts +310 -0
  107. package/dist/types-igZ1x_e4.d.ts +310 -0
  108. package/dist/ui.d.mts +2005 -0
  109. package/dist/ui.d.ts +2005 -0
  110. package/dist/ui.js +1 -0
  111. package/dist/ui.mjs +1 -0
  112. package/dist/variableDetector-CIqTek7A.d.mts +204 -0
  113. package/dist/variableDetector-CkYvLv62.d.ts +204 -0
  114. package/i18n/de.json +745 -0
  115. package/i18n/en.json +745 -0
  116. package/i18n/pl.json +745 -0
  117. package/package.json +127 -0
@@ -0,0 +1,261 @@
1
+ import {e,q,p,n,o,f as f$2,c as c$1,d as d$2,a as a$5,l as l$2,h as h$2,g as g$2,k as k$1,i as i$2,j as j$2,m as m$2}from'./chunk-2HDYCD2Q.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$3,y,L,M,T,O,S,x,e as e$2,f as f$3}from'./chunk-X5A54T6S.mjs';import {m,j,l as l$1}from'./chunk-Z26WOH6R.mjs';import {m as m$1}from'./chunk-YKBSKEBS.mjs';import {b,a as a$2}from'./chunk-GZOCOWWB.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-7QTNB64A.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 as b$1}from'./chunk-7MGFEP2R.mjs';import {a as a$4,b as b$2,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 gm,{createContext,forwardRef,useRef,useState,useMemo,useLayoutEffect,useEffect,useCallback,useImperativeHandle,memo,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 {AddMarkStep,RemoveMarkStep,AddNodeMarkStep,RemoveNodeMarkStep}from'prosemirror-transform';import {keymap}from'prosemirror-keymap';import'prosemirror-view/style/prosemirror.css';import {toast,Toaster}from'sonner';import {createRoot}from'react-dom/client';function cg(){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 el({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function dg(e){return e.replace(/\.docx$/i,"")}function ad({value:e,onChange:t,placeholder:n,editable:o=true}){let{t:r}=b(),i=n??r("titleBar.untitled"),a=dg(e)??"";return o?jsx("input",{type:"text",value:a,onChange:s=>{let l=s.target.value;t?.(l.endsWith(".docx")?l:l+".docx");},placeholder:i,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":r("titleBar.documentNameAriaLabel")}):jsx("span",{className:"text-base font-normal text-slate-800 px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:a||i})}function tl({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function nl(){let{t:e}=b(),t=x(),{disabled:n=false,onFormat:o,onPrint:r,showPrintButton:i=true,onPageSetup:a,onInsertImage:s,onInsertTable:l,showTableInsert:u=true,onInsertPageBreak:c,onInsertTOC:d,onRefocusEditor:p}=t,f=useCallback(h=>{!n&&o&&o(h);},[n,o]),m=useCallback((h,x)=>{!n&&l&&(l(h,x),requestAnimationFrame(()=>p?.()));},[n,l,p]),b$1=i&&r||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[b$1&&jsx(e$2,{label:e("toolbar.file"),disabled:n,items:[...i&&r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...a?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:a}]:[]]}),jsx(e$2,{label:e("toolbar.format"),disabled:n,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>f("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>f("setRtl")}]}),jsx(e$2,{label:e("toolbar.insert"),disabled:n,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...u&&l?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:h=>jsx(f$3,{onInsert:(x,T)=>{m(x,T),h();}})}]:[],...s||u&&l?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.pageBreak"),onClick:c,disabled:!c},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:d,disabled:!d}]})]})}function sd({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===el?t=a:a.type===tl?n=a:a.type===nl?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(cg,{})}),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 ug({children:e,className:t,...n}){return jsx(w.Provider,{value:n,children:jsx("div",{className:a$3("flex flex-col bg-white shadow-sm flex-shrink-0",t),"data-testid":"editor-toolbar",children:e})})}var Wt=ug;Wt.TitleBar=sd;Wt.Logo=el;Wt.DocumentName=ad;Wt.MenuBar=nl;Wt.TitleBarRight=tl;Wt.FormattingBar=y;var dd=createContext(null);function RC(){let e=useContext(dd);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function ud({children:e}){let t=useMemo(()=>new H,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((u,c)=>{t.showError(u,c);},[t]),r=useCallback((u,c)=>{t.showWarning(u,c);},[t]),i=useCallback((u,c)=>{t.showInfo(u,c);},[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(dd.Provider,{value:l,children:[e,jsx(bg,{notifications:n.notifications,onDismiss:a})]})}function bg({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(yg,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function yg({notification:e,onDismiss:t}){let{t:n}=b(),[o,r]=useState(false),a=(b=>{switch(b){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),s={background:a.bg,border:`1px solid ${a.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},l={display:"flex",alignItems:"flex-start",gap:"8px"},u={color:a.icon,flexShrink:0},c={flex:1,minWidth:0},d={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},p={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:a.text,maxHeight:"200px",overflow:"auto"},f={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:a.text},m=b=>{switch(b){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:s,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:l,children:[jsx("span",{style:u,children:m(e.severity)}),jsxs("div",{style:c,children:[jsx("div",{style:d,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>r(!o),style:{...f,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n(o?"errors.hideDetails":"errors.showDetails")}),o&&jsx("div",{style:p,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:f,title:n("common.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 Bi=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(xg,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function xg({error:e,errorInfo:t,showDetails:n,onReset:o}){let{t:r}=b(),i={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"},a={color:"var(--doc-error)",marginBottom:"16px"},s={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},l={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},u={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"},c={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:i,children:[jsx("div",{style:a,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:s,children:r("errors.somethingWentWrong")}),jsx("p",{style:l,children:r("errors.errorDescription")}),n&&jsxs("div",{style:u,children:[jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxs(Fragment,{children:[`
13
+
14
+ `,jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:c,children:r("errors.tryAgain")})]})}function EC({message:e,details:t,onRetry:n,className:o=""}){let{t:r}=b(),i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border-light)"},a={color:"var(--doc-error)",marginBottom:"16px"},s={fontSize:"16px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},l={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},u={marginBottom:"16px",padding:"12px",background:"var(--doc-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",maxWidth:"100%",overflow:"auto",textAlign:"left"},c={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:i,children:[jsx("div",{style:a,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:s,children:r("errors.unableToParse")}),jsx("p",{style:l,children:e}),t&&jsx("div",{style:u,children:t}),n&&jsx("button",{type:"button",onClick:n,style:c,children:r("errors.tryAgain")})]})}function PC({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 MC(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function IC(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 fd({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((c,d,p)=>{if(!e)return;let f=z$1(e,c);if(!f){o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}o.selectCell({tableIndex:c,rowIndex:d,columnIndex:p});let b=ea$1(f,{tableIndex:c,rowIndex:d,columnIndex:p});i({context:b,table:f,tableIndex:c,rowIndex:d,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(c=>{if(!e||!r.context||r.tableIndex===null||r.rowIndex===null||r.columnIndex===null)return;let d=r.table;if(!d)return;let p=null,f=null,m=r.rowIndex,b=r.columnIndex;switch(c){case "addRowAbove":p=ha$1(d,r.rowIndex,"before"),m=r.rowIndex+1;break;case "addRowBelow":p=ha$1(d,r.rowIndex,"after");break;case "addColumnLeft":p=ja$1(d,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=ja$1(d,r.columnIndex,"after");break;case "deleteRow":d.rows.length>1&&(p=ia$1(d,r.rowIndex),m>=p.rows.length&&(m=p.rows.length-1));break;case "deleteColumn":{if(fa$1(d)>1){p=ka$1(d,r.columnIndex);let x=fa$1(p);b>=x&&(b=x-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=la$1(d,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=ma$1(d,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((c,d,p)=>o.isCellSelected(c,d,p),[o,r]);return {state:r,handleCellClick:a,handleAction:l,clearSelection:s,isCellSelected:u,tableContext:r.context}}var Cg=/[\p{L}\p{N}\p{M}_''\-]/u,Tg=/\s/;function ol(e){return !e||e.length===0?false:Cg.test(e)}function rl(e){return !e||e.length===0?false:Tg.test(e)}function Nn(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let n=e[t];if(rl(n)){let o=t,r=t;for(;o>0&&rl(e[o-1]);)o--;for(;r<e.length&&rl(e[r]);)r++;return [o,r]}if(ol(n)){let o=t,r=t;for(;o>0&&ol(e[o-1]);)o--;for(;r<e.length&&ol(e[r]);)r++;return [o,r]}return [t,t+1]}function _C(e,t){let[n,o]=Nn(e,t);return e.slice(n,o)}function WC(e,t){let[n,o]=Nn(e,t);return {word:e.slice(n,o),startIndex:n,endIndex:o}}function hd(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),n=t.startContainer;if(n.nodeType===Node.TEXT_NODE){let o=n.textContent||"",r=t.startOffset,[i,a]=Nn(o,r);if(a>i)return t.setStart(n,i),t.setEnd(n,a),e.removeAllRanges(),e.addRange(t),true}if(n.nodeType===Node.ELEMENT_NODE){let o=n,r=md(o);if(r.length>0){let i=t.startOffset,a=null,s=i;if(i<o.childNodes.length){let l=o.childNodes[i];if(l.nodeType===Node.TEXT_NODE)a=l,s=0;else if(l instanceof Element){let u=md(l);u.length>0&&(a=u[0],s=0);}}if(!a&&r.length>0&&(a=r[0],s=0),a){let l=a.textContent||"",[u,c]=Nn(l,s);if(c>u){let d=document.createRange();return d.setStart(a,u),d.setEnd(a,c),e.removeAllRanges(),e.addRange(d),true}}}}return false}function VC(e,t){let n=window.getSelection();if(!n)return false;let o=e.textContent||"",[r,i]=Nn(o,t);if(i>r){let a=document.createRange();return a.setStart(e,r),a.setEnd(e,i),n.removeAllRanges(),n.addRange(a),true}return false}function UC(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return hd();let n=t.startContainer,o=t.endContainer,r=t.startOffset,i=t.endOffset;if(n.nodeType===Node.TEXT_NODE){let a=n.textContent||"",[s]=Nn(a,t.startOffset);r=s;}if(o.nodeType===Node.TEXT_NODE){let a=o.textContent||"",s=Math.max(0,t.endOffset-1),[,l]=Nn(a,s);i=l;}try{return t.setStart(n,r),t.setEnd(o,i),e.removeAllRanges(),e.addRange(t),!0}catch(a){return console.warn("Could not expand selection to word boundaries:",a),false}}function wg(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let n=e.getRangeAt(0).commonAncestorContainer,o=vg(n);if(o){let r=document.createRange();return r.selectNodeContents(o),e.removeAllRanges(),e.addRange(r),true}return false}function vg(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function md(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),o;for(;o=n.nextNode();)o.nodeType===Node.TEXT_NODE&&t.push(o);return t}var il=0,Go=null,al=null,Rg=500;function gd(){il=0,al=null,Go&&(clearTimeout(Go),Go=null);}function Eg(e){return e.target!==al&&gd(),il++,al=e.target,Go&&clearTimeout(Go),Go=setTimeout(gd,Rg),Math.min(il,3)}function jC(){return e=>{e.ctrlKey||e.metaKey||e.altKey||hd();}}function KC(){return e=>{if(Eg(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;wg();}}}var yd=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let{t:r}=b(),[i,a]=useState(false);return useEffect(()=>{requestAnimationFrame(()=>a(true));},[]),jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":r("documentOutline.ariaLabel"),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:i?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:s=>s.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsx("button",{onClick:n,"aria-label":r("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:r("documentOutline.closeTitle"),children:jsx(d,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:r("documentOutline.title")})]}),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:r("documentOutline.noHeadings")}):e.map((s,l)=>jsx("div",{style:{marginLeft:s.level*12},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(s.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:s.text,children:s.text})},`${s.pmPos}-${l}`))})]})};function xd(e,t,n,o,r,i){if(e.length===0)return [];let a=n?.getContainerOffset(),s=[];for(let c of e){let d;if(c.fixedY!=null&&(d=c.fixedY*o),d==null&&c.anchorKey){let p=t.get(c.anchorKey);p!=null&&(d=p*o);}if(d==null&&n){let p=n.getRectsForRange(c.anchorPos,c.anchorPos+1);p.length>0&&a&&(d=(p[0].y+a.y)*o);}if(d==null){let p=i.get(c.id);p!=null&&(d=p);}d!=null&&(s.push({item:c,targetY:d}),i.set(c.id,d));}s.sort((c,d)=>{let p=c.targetY-d.targetY;return p!==0?p:(c.item.priority??0)-(d.item.priority??0)});let l=[],u=0;for(let c of s){let d=r.get(c.item.id)??c.item.estimatedHeight??80,p=Math.max(c.targetY,u+8);l.push({item:c.item,y:p}),u=p+d;}return l}function wd({items:e,anchorPositions:t,renderedDomContext:n,pageWidth:o,zoom:r,editorContainerRef:i,onExpandedItemChange:a,activeItemId:s}){let{t:l}=b(),u=s??null,c=useRef(u);c.current=u;let[d,p]=useState(false),f=useRef(new Map),m=useRef(new Map),b$1=useRef(new Set),h=useRef(null),x=useRef(new Map),T=useRef(new Map),[S,I]=useState(0),R=useMemo(()=>xd(e,t,n,r,f.current,m.current),[e,t,n,r,S]),A=R.length>0,L=useMemo(()=>{let v=new Map;for(let _ of R)v.set(_.item.id,_.y);return v},[R]);useEffect(()=>{for(let v of R)b$1.current.add(v.item.id);},[R]),useEffect(()=>{let v=setTimeout(()=>I(re=>re+1),50),_=setTimeout(()=>{I(re=>re+1),p(true);},400);return ()=>{clearTimeout(v),clearTimeout(_);}},[e.length]),useEffect(()=>{let v=i?.current;if(!v)return;let _=new ResizeObserver(()=>{requestAnimationFrame(()=>I(re=>re+1));});return _.observe(v),()=>_.disconnect()},[i]),useEffect(()=>{let v=requestAnimationFrame(()=>{for(let[_,re]of x.current)f.current.set(_,re.offsetHeight);I(_=>_+1);});return ()=>cancelAnimationFrame(v)},[u]),useEffect(()=>{if(!u)return;let v=x.current.get(u);if(!v){let ae=requestAnimationFrame(()=>I(N=>N+1));return ()=>cancelAnimationFrame(ae)}let _,re=new ResizeObserver(()=>{cancelAnimationFrame(_),_=requestAnimationFrame(()=>{f.current.set(u,v.offsetHeight),I(ae=>ae+1);});});return re.observe(v),()=>{cancelAnimationFrame(_),re.disconnect();}},[u]);let pe=useCallback(v=>{let _=T.current.get(v);return _||(_=re=>{re?(x.current.set(v,re),f.current.set(v,re.offsetHeight)):(x.current.delete(v),f.current.delete(v));},T.current.set(v,_)),_},[]),$=useCallback(v=>{a?.(c.current===v?null:v);},[a]);return e.length===0?null:jsx("aside",{ref:h,className:"docx-unified-sidebar",role:"complementary","aria-label":l("sidebar.ariaLabel"),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:A?1:0,transition:"opacity 0.15s ease"},onMouseDown:v=>v.stopPropagation(),children:jsx("div",{style:{position:"relative"},children:e.map(v=>{let _=L.get(v.id),re=u===v.id,N=!b$1.current.has(v.id)&&_!==void 0,D=A&&!L.has(v.id),de=A?_!==void 0?{position:"absolute",top:_,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},ge=D?"none":N||v.isTemporary?"opacity 0.2s ease":d?"opacity 0.2s ease, top 0.15s ease":"none";return jsx("div",{style:{...de,transition:ge},children:v.render({isExpanded:re,onToggleExpand:()=>$(v.id),measureRef:pe(v.id)})},v.id)})})})}function vd({comments:e,anchorPositions:t,zoom:n,pageWidth:o,sidebarOpen:r,resolvedCommentIds:i,onMarkerClick:a}){let{t:s}=b(),u=e.filter(c=>c.parentId==null).map(c=>{let d=i.has(c.id);if(!d&&r||d&&r)return null;let p=t.get(`comment-${c.id}`);return p==null?null:{comment:c,isResolved:d,y:p}}).filter(Boolean);return u.length===0?null:jsx("div",{className:"docx-comment-margin-markers",style:{position:"absolute",top:0,left:`calc(50% + ${o*n/2+6}px)`,zIndex:30,pointerEvents:"none"},onMouseDown:c=>c.stopPropagation(),children:u.map(({comment:c,isResolved:d$1,y:p})=>jsx("button",{onClick:()=>a(c.id),title:s(d$1?"commentMarkers.resolvedComment":"commentMarkers.comment"),style:{position:"absolute",top:p*n,left:0,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",cursor:"pointer",pointerEvents:"auto",color:"#5f6368",padding:0,fontFamily:"inherit"},onMouseOver:f=>{f.currentTarget.style.opacity="0.7";},onMouseOut:f=>{f.currentTarget.style.opacity="1";},children:jsx(d,{name:d$1?"chat_bubble_check":"chat_bubble_outline",size:18})},c.id))})}function Di(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 Yo(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function qo(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var Rd=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function Ig(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Rd[Math.abs(t)%Rd.length]}var Xo={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},Hi={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"};function Zo(e,t=32){return {width:t,height:t,borderRadius:"50%",backgroundColor:Ig(e),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t===32?13:11,fontWeight:500,flexShrink:0}}function Ni(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 zi(e,t=50){return e.length>t?e.slice(0,t)+"...":e}function $i({replies:e,isExpanded:t}){let{t:n}=b();if(e.length===0)return null;let o=t?e:e.slice(-1),r=t?0:e.length-1;return jsxs("div",{style:{marginTop:8},children:[r>0&&jsx("div",{style:{fontSize:12,fontWeight:500,color:"#1a73e8",paddingTop:6,paddingBottom:6,borderTop:"1px solid #e8eaed"},children:n("comments.replyCount",{count:r})}),o.map(i=>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:Zo(i.author||"U",28),children:qo(i.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:i.author||n("comments.unknown")}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Yo(i.date)})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...t?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:Di(i.content)})]},i.id))]})}var Fg={width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"},Lg={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 _i({onSubmit:e}){let[t,n]=useState(false),[o,r]=useState(""),{t:i}=b();if(!t)return jsx("div",{onClick:s=>s.stopPropagation(),style:{marginTop:12},children:jsx("input",{readOnly:true,onMouseDown:s=>s.stopPropagation(),onClick:s=>{s.stopPropagation(),n(true);},placeholder:i("comments.replyPlaceholder"),style:Lg})});let a=o.trim();return jsxs("div",{onClick:s=>s.stopPropagation(),style:{marginTop:12},children:[jsx("input",{ref:s=>s?.focus({preventScroll:true}),type:"text",value:o,onChange:s=>r(s.target.value),onMouseDown:s=>s.stopPropagation(),onKeyDown:s=>{s.stopPropagation(),s.key==="Enter"&&(s.preventDefault(),a&&e(a),r(""),n(false)),s.key==="Escape"&&(n(false),r(""));},placeholder:i("comments.replyPlaceholder"),style:Fg}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsx("button",{onClick:s=>{s.stopPropagation(),n(false),r("");},style:Hi,children:i("common.cancel")}),jsx("button",{onClick:s=>{s.stopPropagation(),a&&e(a),r(""),n(false);},disabled:!a,style:Ni(!!a),children:i("common.reply")})]})]})}var Wi={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)"},Vi={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 Md({comment:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onReply:i,onResolve:a,onUnresolve:s,onDelete:l}){let[u,c]=useState(false),{t:d$1}=b();return jsxs("div",{ref:r,"data-comment-id":e.id,className:"docx-comment-card",onClick:o,onMouseDown:p=>p.stopPropagation(),style:{...n?Vi:Wi},children:[e.done&&jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",marginBottom:8,fontSize:11,fontWeight:500,color:"#188038",backgroundColor:"#e6f4ea",borderRadius:10},children:[jsx(d,{name:"check",size:12}),d$1("comments.resolved")]}),jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:Zo(e.author||"U"),children:qo(e.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:e.author||d$1("comments.unknown")}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Yo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsx("button",{onClick:p=>{p.stopPropagation(),e.done?s?.(e.id):a?.(e.id);},title:e.done?d$1("comments.reopen"):d$1("comments.resolve"),style:Xo,children:jsx(d,{name:e.done?"undo":"check",size:20})}),jsx("button",{onClick:p=>{p.stopPropagation(),c(!u);},title:d$1("comments.moreOptions"),style:Xo,children:jsx(d,{name:"more_vert",size:20})}),u&&jsx("div",{onClick:p=>p.stopPropagation(),onMouseDown:p=>p.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:()=>{c(false),l?.(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:p=>{p.target.style.backgroundColor="#f1f3f4";},onMouseOut:p=>{p.target.style.backgroundColor="transparent";},children:d$1("common.delete")})})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:Di(e.content)}),jsx($i,{replies:t,isExpanded:n}),n&&!e.done&&jsx(_i,{onSubmit:p=>i?.(e.id,p)})]})}function Fd({change:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onAccept:i,onReject:a,onReply:s}){let{t:l}=b(),u=e.author||l("trackedChanges.unknown");return jsxs("div",{ref:r,className:"docx-tracked-change-card",onClick:()=>o(),onMouseDown:c=>c.stopPropagation(),style:n?Vi:Wi,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:Zo(u),children:qo(u)}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:u}),e.date&&jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Yo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsx("button",{onClick:c=>{c.stopPropagation(),i?.(e.from,e.to);},title:l("common.accept"),style:Xo,children:jsx(d,{name:"check",size:20})}),jsx("button",{onClick:c=>{c.stopPropagation(),a?.(e.from,e.to);},title:l("common.reject"),style:Xo,children:jsx(d,{name:"close",size:20})})]})]}),jsx("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:e.type==="replacement"?jsxs(Fragment,{children:[l("trackedChanges.replaced")," ",jsxs("span",{style:{color:"#c5221f",fontWeight:500},children:['"',zi(e.deletedText||""),'"']})," ",l("trackedChanges.with")," ",jsxs("span",{style:{color:"#137333",fontWeight:500},children:['"',zi(e.text),'"']})]}):jsxs(Fragment,{children:[e.type==="insertion"?l("trackedChanges.added"):l("trackedChanges.deleted")," ",jsxs("span",{style:{color:e.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',zi(e.text),'"']})]})}),jsx($i,{replies:t,isExpanded:n}),n&&jsx(_i,{onSubmit:c=>s?.(e.revisionId,c)})]})}function Bd({measureRef:e,onSubmit:t,onCancel:n}){let[o,r]=useState(""),{t:i}=b(),a=()=>{o.trim()&&(t?.(o.trim()),r(""));};return jsxs("div",{ref:e,onMouseDown:s=>s.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:s=>s?.focus({preventScroll:true}),value:o,onChange:s=>r(s.target.value),onMouseDown:s=>s.stopPropagation(),onKeyDown:s=>{s.stopPropagation(),s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),a()),s.key==="Escape"&&(n?.(),r(""));},placeholder:i("comments.addComment"),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:Hi,children:i("common.cancel")}),jsx("button",{onClick:a,disabled:!o.trim(),style:Ni(!!o.trim()),children:i("common.comment")})]})]})}function Dd({measureRef:e,onToggleExpand:t}){return jsx("div",{ref:e,onClick:t,onMouseDown:n=>n.stopPropagation(),style:{display:"inline-flex",alignItems:"center",cursor:"pointer",color:"#5f6368",padding:2},onMouseOver:n=>{n.currentTarget.style.opacity="0.7";},onMouseOut:n=>{n.currentTarget.style.opacity="1";},children:jsx(d,{name:"chat_bubble_check",size:20})})}function Hd({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 c=l.get(u.parentId);c?c.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(Bd,{...u,onSubmit:n.onAddComment,onCancel:n.onCancelAddComment})});for(let u of a){let c=s.get(u.id)??[];l.push({id:`comment-${u.id}`,anchorPos:0,anchorKey:`comment-${u.id}`,priority:0,estimatedHeight:u.done?28:80,render:d=>u.done&&!d.isExpanded?jsx(Dd,{...d,comment:u}):jsx(Md,{...d,comment:u,replies:c,onReply:n.onCommentReply,onResolve:n.onCommentResolve,onUnresolve:n.onCommentUnresolve,onDelete:n.onCommentDelete})});}return t.forEach((u,c)=>{let d=s.get(u.revisionId)??[];l.push({id:`tc-${u.revisionId}-${c}`,anchorPos:u.from,anchorKey:`revision-${u.revisionId}`,priority:1,estimatedHeight:80,render:p=>jsx(Fd,{...p,change:u,replies:d,onAccept:n.onAcceptChange,onReject:n.onRejectChange,onReply:n.onTrackedChangeReply})});}),l},[a,t,s,n,r,i])}var Ng=15840,zd=1440,zg=1440,Og=567,$d=20,$g="var(--doc-text-muted)",_g="var(--doc-text-subtle)",Wg="var(--doc-primary)",Vg="var(--doc-primary)",Ug="var(--doc-primary-hover)";function _d({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let{t:l}=b(),[u,c]=useState(null),[d,p]=useState(null),f=useRef(null),m=e?.pageHeight??Ng,b$1=e?.marginTop??zd,h=e?.marginBottom??zd,x=a$4(m)*t,T=a$4(b$1)*t,S=a$4(h)*t,I=useCallback(($,v)=>{n&&($.preventDefault(),c(v));},[n]),R=useCallback($=>{if(!u||!f.current)return;let v=f.current.getBoundingClientRect(),_=$.clientY-v.top,re=b$2(_/t);if(u==="topMargin"){let ae=m-h-720,N=Math.max(0,Math.min(re,ae));o?.(Math.round(N));}else if(u==="bottomMargin"){let ae=m-re,N=m-b$1-720,D=Math.max(0,Math.min(ae,N));r?.(Math.round(D));}},[u,t,m,b$1,h,o,r]),A=useCallback(()=>{c(null);},[]);useEffect(()=>{if(u)return document.addEventListener("mousemove",R),document.addEventListener("mouseup",A),()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",A);}},[u,R,A]);let L=Kg(m,t,i),pe={position:"relative",width:$d,height:k(x),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:u?"ns-resize":"default",...s};return jsxs("div",{ref:f,className:`docx-vertical-ruler ${a}`,style:pe,role:"slider","aria-label":l("ruler.vertical"),"aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:L.map(($,v)=>jsx(jg,{tick:$},v))}),jsx(Od,{type:"topMargin",position:T,editable:n,isDragging:u==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:$=>I($,"topMargin")}),jsx(Od,{type:"bottomMargin",position:x-S,editable:n,isDragging:u==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:$=>I($,"bottomMargin")})]})}function jg({tick:e}){let t={position:"absolute",top:k(e.position),right:0,height:1,width:e.width,backgroundColor:_g},n={position:"absolute",top:k(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:$g,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function Od({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let{t:l}=b(),u=o?Ug:r?Vg:Wg,c={position:"absolute",top:k(t-5),right:0,width:$d,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 ${u}`,transition:"border-right-color 0.1s"};return jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:c,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":l(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:d})})}function Kg(e,t,n){let o=[];if(n==="inch"){let r=zg/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$4(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=Og/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$4(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 on={High:50,Default:100,Low:150};function pt(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??on.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function et(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??on.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function De(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??on.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var Vd=et({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table | textBox)+"}});var Ud=et({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function jd(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$5(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=Gd(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=Yg(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$4(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 Kd(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=qg(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=k(a$4(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=k(a$4(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=a$4(e.lineSpacing);o>0&&(n.lineHeight=k(o));break}case "atLeast":{let o=a$4(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$4(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=k(a$4(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=k(a$4(e.indentFirstLine)):n.textIndent=k(a$4(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,Jo(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,Jo(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,Jo(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,Jo(e.borders.right,"Right",t))),e.shading){let o=Gd(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 Jo(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=Xg(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 Gd(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 Yg(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 qg(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function Xg(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 Jg(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=Kd(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function Qg(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 eh(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${Qg(n)} docx-list-level-${o}`}function er(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 th(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 nh(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=er(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 Yd(e){let t=e.style,n={};if(t.textAlign){let i=th(t.textAlign);i&&(n.alignment=i);}let o=t.marginLeft||t.paddingLeft;if(o){let i=er(o);i!=null&&(n.indentLeft=i);}let r=t.marginRight||t.paddingRight;if(r){let i=er(r);i!=null&&(n.indentRight=i);}if(t.textIndent){let i=er(t.textIndent);i!=null&&(i<0?(n.indentFirstLine=Math.abs(i),n.hangingIndent=true):n.indentFirstLine=i);}if(t.lineHeight){let i=nh(t.lineHeight);i&&(n.lineSpacing=i.lineSpacing,n.lineSpacingRule=i.lineSpacingRule);}if(t.marginTop){let i=er(t.marginTop);i!=null&&(n.spaceBefore=i);}if(t.marginBottom){let i=er(t.marginBottom);i!=null&&(n.spaceAfter=i);}return n}var oh={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=Yd(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 {...Yd(t),styleId:`Heading${n}`,outlineLevel:n-1}}}))],toDOM(e){let t=e.attrs,n=Jg(t),o=eh(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 Vt(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 qd(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 Dr(e){return (t,n)=>Vt("alignment",e)(t,n)}function ji(e,t="auto"){return (n,o)=>qd({lineSpacing:e,lineSpacingRule:t})(n,o)}function rh(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 ih(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,c=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:c>0?c:null});}}),n(i.scrollIntoView()),true}}function ah(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 d=n.runFormatting;d.bold&&u.push(e.marks.bold.create()),d.italic&&u.push(e.marks.italic.create()),d.fontSize&&u.push(e.marks.fontSize.create({size:d.fontSize})),d.fontFamily&&u.push(e.marks.fontFamily.create({ascii:d.fontFamily.ascii,hAnsi:d.fontFamily.hAnsi,asciiTheme:d.fontFamily.asciiTheme})),d.color&&!d.color.auto&&u.push(e.marks.textColor.create({rgb:d.color.rgb,themeColor:d.color.themeColor,themeTint:d.color.themeTint,themeShade:d.color.themeShade})),d.underline&&d.underline.style!=="none"&&u.push(e.marks.underline.create({style:d.underline.style,color:d.underline.color})),(d.strike||d.doubleStrike)&&u.push(e.marks.strike.create({double:d.doubleStrike||false}));}let c=[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,(d,p)=>{if(d.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...d.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+d.nodeSize-1;if(b>m){for(let h of c)s=s.removeMark(m,b,h);for(let h of u)s=s.addMark(m,b,h);}}}}),u.length>0&&(s=s.setStoredMarks(u)),r(s.scrollIntoView()),true}}var Xd=et({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:oh,onSchemaReady(e){let t=ah(e.schema);return {commands:{setAlignment:n=>Dr(n),alignLeft:()=>Dr("left"),alignCenter:()=>Dr("center"),alignRight:()=>Dr("right"),alignJustify:()=>Dr("both"),setLineSpacing:(n,o)=>ji(n,o),singleSpacing:()=>ji(240),oneAndHalfSpacing:()=>ji(360),doubleSpacing:()=>ji(480),setSpaceBefore:n=>Vt("spaceBefore",n),setSpaceAfter:n=>Vt("spaceAfter",n),increaseIndent:n=>rh(n),decreaseIndent:n=>ih(n),setIndentLeft:n=>Vt("indentLeft",n>0?n:null),setIndentRight:n=>Vt("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>qd({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Vt("styleId",null),insertSectionBreak:n=>Vt("sectionBreakType",n),removeSectionBreak:()=>Vt("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 c of r){let d=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:d,level:c.level,text:c.text});let p=a.mapping.map(c.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let x=[...(m.attrs.bookmarks||[]).filter(T=>!T.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:d}];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 c of s){let d=c.level*720,p=`TOC${c.level+1}`,f=i.marks.hyperlink.create({href:`#${c.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:d>0?d:null},[i.text(c.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 Vt("bidi",a?null:true)(n,o)},setRtl:()=>Vt("bidi",true),setLtr:()=>Vt("bidi",null),setTabs:n=>Vt("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 d=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return Vt("tabs",d)(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 Vt("tabs",l.length>0?l:null)(o,r)}}}}});var Jd=pt({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 eu=De({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 nu=De({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 lh(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 ou(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=lh(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function Tn(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(c=>c.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=ou(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function wn(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=ou(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function ru(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 Hr=(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 c of a.marks)i=i.removeMark(l,u,c.type);}}),t(i.scrollIntoView());}return true};var au=De({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)=>Tn(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":toggleMark(e.schema.marks.underline)}}}});var su=De({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 lu=De({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=jd({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?wn(e.schema.marks.textColor):Tn(e.schema.marks.textColor,t),clearTextColor:()=>wn(e.schema.marks.textColor)}}}});var cu=De({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"?wn(e.schema.marks.highlight):Tn(e.schema.marks.highlight,{color:t}),clearHighlight:()=>wn(e.schema.marks.highlight)}}}});var du=De({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=>Tn(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>wn(e.schema.marks.fontSize)}}}});var uu=De({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=>Tn(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>wn(e.schema.marks.fontFamily)}}}});var pu=De({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 fu=De({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 tr(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 nr(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var mu=De({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:c,empty:d}=s.selection;if(d)return false;if(l){let p=t.create({href:i,tooltip:a||null}),f=s.tr.addMark(u,c,p),m=s.schema.marks.textColor;m&&(f=f.removeMark(u,c,m)),l(f.scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let c=i.selection.$from;if(!c.marks().find(h=>h.type===t))return false;let f=c.pos,m=c.pos;return c.parent.forEach((h,x)=>{if(h.isText){let T=c.start()+x,S=T+h.nodeSize;T<=c.pos&&c.pos<=S&&h.marks.some(R=>R.type===t)&&(f=Math.min(f,T),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 c=t.create({href:a,tooltip:s||null}),d=l.schema.text(i,[c]);u(l.tr.replaceSelectionWith(d,false).scrollIntoView());}return true}}}}});var gu=De({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var hu=De({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 bu=De({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]),c=a.tr.replaceSelectionWith(u,false);return s(c.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 ph(e){return e/2*(96/72)}var yu=De({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$4(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=ph(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 xu=De({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 Su=De({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;"},0]}}}),ku=De({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;"},0]}}});var Cu=De({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]}}}),Tu=De({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]}}}),wu=De({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]}}}),vu=De({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]}}}),Ru=De({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=et({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 Pu=et({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 Mu=et({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 Iu=et({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 fh(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 mh(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(d=>`<stop offset="${Math.round(d.position/1e3)}%" stop-color="${d.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 Fu=et({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,h=t.shadowBlur||4;i.push(`filter: drop-shadow(${m}px ${b}px ${h}px ${t.shadowColor})`);}if(t.glowColor&&t.glowRadius){let m=i.find(h=>h.startsWith("filter:")),b=`drop-shadow(0 0 ${t.glowRadius}px ${t.glowColor})`;if(m){let h=i.indexOf(m);i[h]=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=mh(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",c=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",d=fh(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}${c}">`+(a?`<defs>${a}</defs>`:"")+d+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var Lu=et({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var Bu=et({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 Au=et({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 Du=et({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 Hu=et({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 Th(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 wh(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 Nu(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 vh(e){let t=(a,s,l)=>{if(!(!a||a==="none"||a==="hidden"))return {style:Th(a),color:Nu(s)||void 0,size:wh(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 Rh(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 Eh(e){if(e)switch(e.toLowerCase()){case "top":return "top";case "middle":return "center";case "bottom":return "bottom";default:return}}function Ph(e){return Nu(e)?.rgb}function zu(e){let t=e.style,n=vh(t),o=Rh(t);return {colspan:e.colSpan||1,rowspan:e.rowSpan||1,verticalAlign:e.dataset.valign||Eh(t.verticalAlign)||void 0,backgroundColor:e.dataset.bgcolor||Ph(t.backgroundColor)||void 0,borders:n||void 0,margins:o||void 0}}var Mh={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]]}},Ih={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]}},Fh={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 Ou(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=Fh[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 $u(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 _u(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 Wu(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 Lh={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=>zu(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(...$u(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Wu(t)),o.push(...Ou(t)),o.push(..._u(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]}},Bh={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=>zu(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(...$u(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Wu(t)),o.push(...Ou(t)),o.push(..._u(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 Ze(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 h=n.node(m-1);if(h&&h.type.name==="tableRow"){let x=0,T=false;h.forEach((S,I,R)=>{T||(R===n.index(m-1)?(s=x,T=true):x+=S.attrs.colspan||1);});}}else if(b.type.name==="tableRow"){let h=n.node(m-1);h&&h.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,c=0;r.forEach(m=>{if(m.type.name==="tableRow"){u++;let b=0;m.forEach(h=>{b+=h.attrs.colspan||1;}),c=Math.max(c,b);}});let d=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 h of ["top","right","bottom","left"]){let x=b[h];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:c,hasMultiCellSelection:o,canSplitCell:!!d,cellBorderColor:p,cellBackgroundColor:f}}function Qn(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 Vu(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 Uu(){return (e,t)=>{if(!Qn(e))return false;let n=Vu(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,c=e.tr.setSelection(Selection.near(e.doc.resolve(u)));t(c.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let c=u+1+1+1,d=e.tr.setSelection(Selection.near(e.doc.resolve(c)));t(d.scrollIntoView());}return true}return false}}function ju(){return (e,t)=>{if(!Qn(e))return false;let n=Vu(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 c=u+l.nodeSize-2,d=e.tr.setSelection(Selection.near(e.doc.resolve(c),-1));t(d.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let d=u+s.nodeSize-1-1,p=e.tr.setSelection(Selection.near(e.doc.resolve(d),-1));t(p.scrollIntoView());}return true}return false}}var Ah=et({name:"table",schemaNodeName:"table",nodeSpec:Mh}),Dh=et({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:Ih}),Hh=et({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:Lh}),Nh=et({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:Bh}),zh=pt({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...E){return (F,k,P)=>{for(let M of E)if(M(F,k,P))return true;return false}}function o(E,F={}){let k=E?.attrs??{};return {colspan:k.colspan||1,rowspan:1,colwidth:k.colwidth,width:k.width,widthType:k.widthType,verticalAlign:k.verticalAlign,backgroundColor:k.backgroundColor,borders:k.borders,margins:k.margins,textDirection:k.textDirection,noWrap:k.noWrap,...F}}function r(E,F,k="000000",P=9360){let M=[],H=Math.floor(P/F),oe=360,Q="atLeast",V={style:"single",size:4,color:{rgb:k}},Y={top:V,bottom:V,left:V,right:V};for(let Se=0;Se<E;Se++){let Me=[];for(let Z=0;Z<F;Z++){let ie=t.nodes.paragraph.create(),Ie={colspan:1,rowspan:1,borders:Y,width:H,widthType:"dxa"};Me.push(t.nodes.tableCell.create(Ie,ie));}M.push(t.nodes.tableRow.create({height:oe,heightRule:Q},Me));}let ne=Array(F).fill(H);return t.nodes.table.create({columnWidths:ne,width:P,widthType:"dxa"},M)}function i(E,F){return (k,P)=>{let{$from:M}=k.selection,H="000000",oe=k.storedMarks||M.marks();for(let V of oe)if(V.type.name==="textColor"&&V.attrs.rgb){H=V.attrs.rgb;break}let Q=M.pos;for(let V=M.depth;V>0;V--){let Y=M.node(V);if(Y.type.name==="paragraph"||Y.type.name==="table"){Q=M.after(V);break}}if(P){let V=9360;for(let je=M.depth;je>0;je--){let Xe=M.node(je);if(Xe.type.name==="tableCell"||Xe.type.name==="tableHeader"){let _e=Xe.attrs.width;_e&&_e>0&&(V=Math.max(_e-216,360));break}}let Y=r(E,F,H,V),ne=t.nodes.paragraph.create(),Me=k.doc.resolve(Q).nodeBefore?.type.name==="table",Z=Me?[ne,Y,ne]:[Y,ne],ie=k.tr.insert(Q,Z),Ie=Q+1;Me&&(Ie+=ne.nodeSize);let qe=Ie+1+1;ie.setSelection(TextSelection.create(ie.doc,qe)),P(ie.scrollIntoView());}return true}}function a(E,F){let k=Ze(E);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let P=E.tr,M=k.table.child(k.rowIndex),H=[];M.forEach(V=>{let Y=t.nodes.paragraph.create(),ne=o(V);H.push(t.nodes.tableCell.create(ne,Y));});let oe=t.nodes.tableRow.create({height:M.attrs.height??360,heightRule:M.attrs.heightRule??"atLeast"},H),Q=k.tablePos+1;for(let V=0;V<k.rowIndex;V++)Q+=k.table.child(V).nodeSize;P.insert(Q,oe),F(P.scrollIntoView());}return true}function s(E,F){let k=Ze(E);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let P=E.tr,M=k.table.child(k.rowIndex),H=[];M.forEach(V=>{let Y=t.nodes.paragraph.create(),ne=o(V);H.push(t.nodes.tableCell.create(ne,Y));});let oe=t.nodes.tableRow.create({height:M.attrs.height??360,heightRule:M.attrs.heightRule??"atLeast"},H),Q=k.tablePos+1;for(let V=0;V<=k.rowIndex;V++)Q+=k.table.child(V).nodeSize;P.insert(Q,oe),F(P.scrollIntoView());}return true}function l(E,F){let k=Ze(E);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0||(k.rowCount||0)<=1)return false;if(F){let P=E.tr,M=k.tablePos+1;for(let oe=0;oe<k.rowIndex;oe++)M+=k.table.child(oe).nodeSize;let H=M+k.table.child(k.rowIndex).nodeSize;P.delete(M,H),F(P.scrollIntoView());}return true}function u(E,F){let k=Ze(E);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let P=E.tr,M=(k.columnCount||1)+1,H=Math.floor(100/M),oe=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=oe+1,Se=0;if(Y.forEach(Me=>{if(Se===k.columnIndex){let Z=t.nodes.paragraph.create(),ie=o(Me,{colspan:1,rowspan:1});ie.width=H,ie.widthType="pct";let Ie=t.nodes.tableCell.create(ie,Z);P=P.insert(ne,Ie);}ne+=Me.nodeSize,Se+=Me.attrs.colspan||1;}),Se<=k.columnIndex){let Me=t.nodes.paragraph.create(),Z=o(Y.child(Y.childCount-1)??null,{colspan:1,rowspan:1});Z.width=H,Z.widthType="pct";let ie=t.nodes.tableCell.create(Z,Me);P=P.insert(ne,ie);}}oe+=Y.nodeSize;});let V=P.doc.nodeAt(k.tablePos);if(V&&V.type.name==="table"){let Y=V.child(0);if(Y&&Y.type.name==="tableRow"){let Z=k.tablePos+2;Y.forEach(ie=>{(ie.type.name==="tableCell"||ie.type.name==="tableHeader")&&(P=P.setNodeMarkup(Z,void 0,{...ie.attrs,width:H,widthType:"pct"})),Z+=ie.nodeSize;});}let ne=Y?.childCount??M,Se=V.attrs.width||9360,Me=Math.floor(Se/Math.max(1,ne));P=P.setNodeMarkup(k.tablePos,void 0,{...V.attrs,columnWidths:Array(ne).fill(Me)});}F(P.scrollIntoView());}return true}function c(E,F){let k=Ze(E);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let P=E.tr,M=(k.columnCount||1)+1,H=Math.floor(100/M),oe=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=oe+1,Se=0,Me=false;if(Y.forEach(Z=>{if(ne+=Z.nodeSize,Se+=Z.attrs.colspan||1,!Me&&Se>k.columnIndex){let ie=t.nodes.paragraph.create(),Ie=o(Z,{colspan:1,rowspan:1});Ie.width=H,Ie.widthType="pct";let He=t.nodes.tableCell.create(Ie,ie);P=P.insert(ne,He),Me=true;}}),!Me){let Z=t.nodes.paragraph.create(),ie=o(Y.child(Y.childCount-1)??null,{colspan:1,rowspan:1});ie.width=H,ie.widthType="pct";let Ie=t.nodes.tableCell.create(ie,Z);P=P.insert(ne,Ie);}}oe+=Y.nodeSize;});let V=P.doc.nodeAt(k.tablePos);if(V&&V.type.name==="table"){let Y=V.child(0);if(Y&&Y.type.name==="tableRow"){let Z=k.tablePos+2;Y.forEach(ie=>{(ie.type.name==="tableCell"||ie.type.name==="tableHeader")&&(P=P.setNodeMarkup(Z,void 0,{...ie.attrs,width:H,widthType:"pct"})),Z+=ie.nodeSize;});}let ne=Y?.childCount??M,Se=V.attrs.width||9360,Me=Math.floor(Se/Math.max(1,ne));P=P.setNodeMarkup(k.tablePos,void 0,{...V.attrs,columnWidths:Array(ne).fill(Me)});}F(P.scrollIntoView());}return true}function d(E,F){let k=Ze(E);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0||(k.columnCount||0)<=1)return false;if(F){let P=E.tr,M=(k.columnCount||2)-1,H=Math.floor(100/M),oe=[],Q=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=Q+1,Se=0;Y.forEach(Me=>{let Z=ne,ie=ne+Me.nodeSize,Ie=Me.attrs.colspan||1;Se<=k.columnIndex&&k.columnIndex<Se+Ie&&oe.push({start:Z,end:ie}),ne=ie,Se+=Ie;});}Q+=Y.nodeSize;}),oe.reverse().forEach(({start:Y,end:ne})=>{P=P.delete(Y,ne);});let V=P.doc.nodeAt(k.tablePos);if(V&&V.type.name==="table"){let Y=V.child(0);if(Y&&Y.type.name==="tableRow"){let Z=k.tablePos+2;Y.forEach(ie=>{(ie.type.name==="tableCell"||ie.type.name==="tableHeader")&&(P=P.setNodeMarkup(Z,void 0,{...ie.attrs,width:H,widthType:"pct"})),Z+=ie.nodeSize;});}let ne=Y?.childCount??M,Se=V.attrs.width||9360,Me=Math.floor(Se/Math.max(1,ne));P=P.setNodeMarkup(k.tablePos,void 0,{...V.attrs,columnWidths:Array(ne).fill(Me)});}F(P.scrollIntoView());}return true}function p(E,F){let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let P=E.tr;P.delete(k.tablePos,k.tablePos+k.table.nodeSize),F(P.scrollIntoView());}return true}function f(E,F){let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let P=k.tablePos+1,M=E.doc.resolve(P),H=E.doc.resolve(k.tablePos+k.table.nodeSize-2),oe=CellSelection.create(E.doc,M.pos,H.pos);F(E.tr.setSelection(oe));}return true}function m(E,F){let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table||k.rowIndex===void 0)return false;if(F){let M=k.tablePos+1;for(let Y=0;Y<k.rowIndex;Y++){let ne=k.table.child(Y);M+=ne.nodeSize;}let H=k.table.child(k.rowIndex),oe=M+1,Q=M+H.nodeSize-2,V=CellSelection.create(E.doc,oe,Q);F(E.tr.setSelection(V));}return true}function b(E,F){let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table||k.columnIndex===void 0)return false;if(F){let P=k.tablePos+1,M=k.table.child(0),H=k.table.child(k.table.childCount-1),oe=P+1;for(let ne=0;ne<k.columnIndex&&ne<M.childCount;ne++)oe+=M.child(ne).nodeSize;let Q=P;for(let ne=0;ne<k.table.childCount-1;ne++)Q+=k.table.child(ne).nodeSize;let V=Q+1;for(let ne=0;ne<k.columnIndex&&ne<H.childCount;ne++)V+=H.child(ne).nodeSize;let Y=CellSelection.create(E.doc,oe,V);F(E.tr.setSelection(Y));}return true}function h(E){let F=E.selection,k=[];if(F instanceof CellSelection)return F.forEachCell((M,H)=>{k.push({pos:H,node:M});}),k;let{$from:P}=F;for(let M=P.depth;M>0;M--){let H=P.node(M);if(H.type.name==="tableCell"||H.type.name==="tableHeader"){k.push({pos:P.before(M),node:H});break}}return k}function x(E,F){let k=new Map,P=new Map,M=E.childCount,H=0;return E.forEach((oe,Q,V)=>{if(oe.type.name!=="tableRow")return;let Y=0;oe.forEach((ne,Se)=>{let Me=F+Q+Se+2,Z=ne.attrs.colspan||1;k.set(Me,{rowIdx:V,colIdx:Y,colspan:Z,pos:Me,node:ne}),P.set(`${V},${Y}`,Me),Y+=Z;}),H=Math.max(H,Y);}),{cellByPos:k,cellByRC:P,totalRows:M,totalCols:H}}function T(E,F){return (k,P)=>{let M=Ze(k);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(P){let H=k.tr,oe=M.table,Q=M.tablePos,V=F??{style:"single",size:4,color:{rgb:"000000"}},Y={style:"none"},{cellByPos:ne,cellByRC:Se}=x(oe,Q),Me=h(k),Z=1/0,ie=-1,Ie=1/0,He=-1;for(let{pos:_e}of Me){let we=ne.get(_e);we&&(Z=Math.min(Z,we.rowIdx),ie=Math.max(ie,we.rowIdx),Ie=Math.min(Ie,we.colIdx),He=Math.max(He,we.colIdx+we.colspan-1));}let qe=new Map,je=(_e,we)=>qe.get(_e)??{...we.attrs},Xe=(_e,we)=>{qe.set(_e,we);};for(let{pos:_e}of Me){let we=ne.get(_e);if(!we)continue;let xt=we.rowIdx===Z,Le=we.rowIdx===ie,ze=we.colIdx===Ie,lt=we.colIdx+we.colspan-1===He,nt;switch(E){case "all":nt={top:V,bottom:V,left:V,right:V};break;case "outside":nt={top:xt?V:Y,bottom:Le?V:Y,left:ze?V:Y,right:lt?V:Y};break;case "inside":nt={top:xt?Y:V,bottom:Le?Y:V,left:ze?Y:V,right:lt?Y:V};break;case "none":nt={top:Y,bottom:Y,left:Y,right:Y};break}let ft=je(_e,we.node),Rt=ft.borders||{};if(Xe(_e,{...ft,borders:{...Rt,...nt}}),nt.top){let Ne=Se.get(`${we.rowIdx-1},${we.colIdx}`);if(Ne!==void 0){let mt=ne.get(Ne),Oe=je(Ne,mt.node),St=Oe.borders||{};Xe(Ne,{...Oe,borders:{...St,bottom:nt.top}});}}if(nt.bottom){let Ne=Se.get(`${we.rowIdx+1},${we.colIdx}`);if(Ne!==void 0){let mt=ne.get(Ne),Oe=je(Ne,mt.node),St=Oe.borders||{};Xe(Ne,{...Oe,borders:{...St,top:nt.bottom}});}}if(nt.left){let Ne=Se.get(`${we.rowIdx},${we.colIdx-1}`);if(Ne!==void 0){let mt=ne.get(Ne),Oe=je(Ne,mt.node),St=Oe.borders||{};Xe(Ne,{...Oe,borders:{...St,right:nt.left}});}}if(nt.right){let Ne=Se.get(`${we.rowIdx},${we.colIdx+we.colspan}`);if(Ne!==void 0){let mt=ne.get(Ne),Oe=je(Ne,mt.node),St=Oe.borders||{};Xe(Ne,{...Oe,borders:{...St,left:nt.right}});}}}for(let[_e,we]of qe)H.setNodeMarkup(H.mapping.map(_e),void 0,we);P(H.scrollIntoView());}return true}}function S(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F),oe=E?E.replace(/^#/,""):null;for(let{pos:Q,node:V}of H)M.setNodeMarkup(M.mapping.map(Q),void 0,{...V.attrs,backgroundColor:oe});k(M.scrollIntoView());}return true}}function I(E,F,k){return (P,M)=>{let H=Ze(P);if(!H.isInTable||H.tablePos===void 0||!H.table)return false;if(M){let oe=P.tr,Q=h(P),V=F||{style:"none"},Y={style:"none"},ne=["top","bottom","left","right"],{cellByPos:Se,cellByRC:Me}=x(H.table,H.tablePos),Z=new Map,ie=(qe,je)=>Z.get(qe)??{...je.attrs},Ie=(qe,je)=>Z.set(qe,je),He={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:qe,node:je}of Q){let Xe=Se.get(qe),_e=ie(qe,je),we=_e.borders||{},xt=E==="all"?ne:[E],Le=k?{top:Y,bottom:Y,left:Y,right:Y}:{...we};for(let ze of xt)Le[ze]=V;if(Xe){let ze=k?ne:xt;for(let lt of ze){let nt=Le[lt],ft=He[lt],Rt=lt==="right"?Xe.colIdx+Xe.colspan:Xe.colIdx+ft.dCol,Ne=Me.get(`${Xe.rowIdx+ft.dRow},${Rt}`);if(Ne!==void 0){let mt=Se.get(Ne),Oe=ie(Ne,mt.node),St=Oe.borders||{};Ie(Ne,{...Oe,borders:{...St,[ft.adjSide]:nt}});}}}Ie(qe,{..._e,borders:Le});}for(let[qe,je]of Z)oe.setNodeMarkup(oe.mapping.map(qe),void 0,je);M(oe.scrollIntoView());}return true}}function R(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F);for(let{pos:oe,node:Q}of H)M.setNodeMarkup(M.mapping.map(oe),void 0,{...Q.attrs,verticalAlign:E});k(M.scrollIntoView());}return true}}function A(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F);for(let{pos:oe,node:Q}of H){let Y={...Q.attrs.margins||{},...E};M.setNodeMarkup(M.mapping.map(oe),void 0,{...Q.attrs,margins:Y});}k(M.scrollIntoView());}return true}}function L(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F);for(let{pos:oe,node:Q}of H)M.setNodeMarkup(M.mapping.map(oe),void 0,{...Q.attrs,textDirection:E});k(M.scrollIntoView());}return true}}function pe(){return (E,F)=>{let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let P=E.tr,M=h(E);for(let{pos:H,node:oe}of M)P.setNodeMarkup(P.mapping.map(H),void 0,{...oe.attrs,noWrap:!oe.attrs.noWrap});F(P.scrollIntoView());}return true}}function $(E,F){return (k,P)=>{let M=Ze(k);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(P){let H=k.tr,{$from:oe}=k.selection;for(let Q=oe.depth;Q>0;Q--){let V=oe.node(Q);if(V.type.name==="tableRow"){let Y=oe.before(Q),ne={...V.attrs,height:E,heightRule:E?F||"atLeast":null};return H.setNodeMarkup(Y,void 0,ne),P(H.scrollIntoView()),true}}}return true}}function v(){return (E,F)=>{let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table||!k.columnCount)return false;if(F){let P=E.tr,M=k.table,H=k.columnCount,oe=M.attrs.columnWidths,Q=oe?oe.reduce((Se,Me)=>Se+Me,0):9360,V=Math.floor(Q/H),Y=k.tablePos+1;M.forEach(Se=>{if(Se.type.name==="tableRow"){let Me=Y+1;Se.forEach(Z=>{(Z.type.name==="tableCell"||Z.type.name==="tableHeader")&&(P=P.setNodeMarkup(Me,void 0,{...Z.attrs,width:V,widthType:"dxa",colwidth:null})),Me+=Z.nodeSize;});}Y+=Se.nodeSize;});let ne=Array(H).fill(V);P=P.setNodeMarkup(k.tablePos,void 0,{...M.attrs,columnWidths:ne}),F(P.scrollIntoView());}return true}}function _(){return (E,F)=>{let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let P=E.tr,M=k.table,H=k.tablePos+1;M.forEach(oe=>{if(oe.type.name==="tableRow"){let Q=H+1;oe.forEach(V=>{(V.type.name==="tableCell"||V.type.name==="tableHeader")&&(P=P.setNodeMarkup(Q,void 0,{...V.attrs,width:null,widthType:null,colwidth:null})),Q+=V.nodeSize;});}H+=oe.nodeSize;}),P=P.setNodeMarkup(k.tablePos,void 0,{...M.attrs,columnWidths:null,width:null,widthType:"auto"}),F(P.scrollIntoView());}return true}}function re(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=P.table,oe=P.tablePos,Q=H.childCount,V=E.look??{firstRow:true,lastRow:false,noHBand:false},Y=E.conditionals??{},ne=E.tableBorders;M=M.setNodeMarkup(oe,void 0,{...H.attrs,styleId:E.styleId});let Se=0,Me=oe+1;for(let Z=0;Z<Q;Z++){let ie=H.child(Z),Ie=Z===0&&!!V.firstRow,He=Z===Q-1&&!!V.lastRow,qe=V.noHBand!==true,je=ie.childCount,Xe;Ie?Xe="firstRow":He?Xe="lastRow":(qe&&(Xe=Se%2===0?"band1Horz":"band2Horz"),Se++);let _e=Me+1;for(let we=0;we<je;we++){let xt=ie.child(we),Le=M.mapping.map(_e),ze=Xe,lt=we===0&&!!V.firstCol,nt=we===je-1&&!!V.lastCol;Ie&&lt&&Y.nwCell?ze="nwCell":Ie&&nt&&Y.neCell?ze="neCell":He&&lt&&Y.swCell?ze="swCell":He&&nt&&Y.seCell?ze="seCell":lt?ze="firstCol":nt&&(ze="lastCol");let ft=ze?Y[ze]:void 0,Rt={...xt.attrs};ft?.backgroundColor?Rt.backgroundColor=ft.backgroundColor:Rt.backgroundColor=null;let Ne={},mt=["top","bottom","left","right"];for(let Oe of mt)ft?.borders&&ft.borders[Oe]!==void 0?Ne[Oe]=ft.borders[Oe]:ne&&(Oe==="top"&&Z>0||Oe==="bottom"&&Z<Q-1?Ne[Oe]=ne.insideH??ne[Oe]:Oe==="left"&&we>0||Oe==="right"&&we<je-1?Ne[Oe]=ne.insideV??ne[Oe]:Ne[Oe]=ne[Oe]);Object.keys(Ne).length>0?Rt.borders=Ne:Rt.borders=null,M=M.setNodeMarkup(Le,void 0,Rt),_e+=xt.nodeSize;}Me+=ie.nodeSize;}k(M.scrollIntoView());}return true}}function ae(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H={...P.table.attrs};"width"in E&&(H.width=E.width),"widthType"in E&&(H.widthType=E.widthType),"justification"in E&&(H.justification=E.justification),M.setNodeMarkup(P.tablePos,void 0,H),k(M.scrollIntoView());}return true}}function N(){return (E,F)=>{let k=Ze(E);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let P=E.tr,{$from:M}=E.selection;for(let H=M.depth;H>0;H--){let oe=M.node(H);if(oe.type.name==="tableRow"){let Q=M.before(H),V={...oe.attrs,isHeader:!oe.attrs.isHeader};return P.setNodeMarkup(Q,void 0,V),F(P.scrollIntoView()),true}}}return true}}function D(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F),oe=E.replace(/^#/,""),Q={style:"single",size:4},{cellByPos:V,cellByRC:Y}=x(P.table,P.tablePos),ne=new Map,Se=(ie,Ie)=>ne.get(ie)??{...Ie.attrs},Me=(ie,Ie)=>ne.set(ie,Ie),Z={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:ie,node:Ie}of H){let He=V.get(ie),qe=Se(ie,Ie),je=qe.borders||{},Xe={};for(let _e of ["top","bottom","left","right"]){let we={...Q,...je[_e],color:{rgb:oe}};if(Xe[_e]=we,He){let xt=Z[_e],Le=_e==="right"?He.colIdx+He.colspan:He.colIdx+xt.dCol,ze=Y.get(`${He.rowIdx+xt.dRow},${Le}`);if(ze!==void 0){let lt=V.get(ze),nt=Se(ze,lt.node),ft=nt.borders||{};Me(ze,{...nt,borders:{...ft,[xt.adjSide]:we}});}}}Me(ie,{...qe,borders:{...je,...Xe}});}for(let[ie,Ie]of ne)M.setNodeMarkup(M.mapping.map(ie),void 0,Ie);k(M.scrollIntoView());}return true}}function de(E){return (F,k)=>{let P=Ze(F);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(k){let M=F.tr,H=h(F),oe={style:"single",color:{rgb:"000000"}},{cellByPos:Q,cellByRC:V}=x(P.table,P.tablePos),Y=new Map,ne=(Z,ie)=>Y.get(Z)??{...ie.attrs},Se=(Z,ie)=>Y.set(Z,ie),Me={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:Z,node:ie}of H){let Ie=Q.get(Z),He=ne(Z,ie),qe=He.borders||{},je={};for(let Xe of ["top","bottom","left","right"]){let _e={...oe,...qe[Xe],size:E};if(je[Xe]=_e,Ie){let we=Me[Xe],xt=Xe==="right"?Ie.colIdx+Ie.colspan:Ie.colIdx+we.dCol,Le=V.get(`${Ie.rowIdx+we.dRow},${xt}`);if(Le!==void 0){let ze=Q.get(Le),lt=ne(Le,ze.node),nt=lt.borders||{};Se(Le,{...lt,borders:{...nt,[we.adjSide]:_e}});}}}Se(Z,{...He,borders:{...qe,...je}});}for(let[Z,ie]of Y)M.setNodeMarkup(M.mapping.map(Z),void 0,ie);k(M.scrollIntoView());}return true}}function ge(){return (E,F)=>{let k=E.selection;if(!("$anchorCell"in k&&typeof k.forEachCell=="function"))return false;let M=Ze(E);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;let H=0;M.table.descendants(V=>{(V.type.name==="tableCell"||V.type.name==="tableHeader")&&(H+=1);});let oe=0;if(k.forEachCell(()=>{oe+=1;}),!(H>0&&oe>=H))return false;if(F){let V=E.tr.delete(M.tablePos,M.tablePos+M.table.nodeSize);F(V.scrollIntoView());}return true}}function Pe(){return E=>{let{$from:F,empty:k}=E.selection;if(!k)return false;let P=F.parent;if(P.type.name!=="paragraph"||P.textContent.length>0)return false;let M=F.depth;if(M<1)return false;let H=F.node(M-1),oe=F.index(M-1),Q=oe>0?H.child(oe-1):null,V=oe+1<H.childCount?H.child(oe+1):null,Y=Q?.type.name==="table",ne=V?.type.name==="table";return !!(Y||ne)}}let se=new PluginKey("activeCell"),q=new Plugin({key:se,props:{decorations(E){let{selection:F}=E;if(F instanceof CellSelection)return DecorationSet.empty;let{$from:k}=F;for(let P=k.depth;P>0;P--){let M=k.node(P);if(M.type.name==="tableCell"||M.type.name==="tableHeader"){let H=k.before(P);return DecorationSet.create(E.doc,[Decoration.node(H,H+M.nodeSize,{class:"activeCell"})])}}return DecorationSet.empty}}});return {plugins:[columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),tableEditing(),q],keyboardShortcuts:{Backspace:n(ge(),Pe()),Delete:n(ge(),Pe())},commands:{insertTable:(E,F)=>i(E,F),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>c,deleteColumn:()=>d,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>mergeCells,splitCell:()=>splitCell,setCellBorder:(E,F,k)=>I(E,F,k),setTableBorders:(E,F)=>T(E,F),setCellVerticalAlign:E=>R(E),setCellMargins:E=>A(E),setCellTextDirection:E=>L(E),toggleNoWrap:()=>pe(),setRowHeight:(E,F)=>$(E,F),toggleHeaderRow:()=>N(),distributeColumns:()=>v(),autoFitContents:()=>_(),setTableProperties:E=>ae(E),applyTableStyle:E=>re(E),setCellFillColor:E=>S(E),setTableBorderColor:E=>D(E),setTableBorderWidth:E=>de(E),removeTableBorders:()=>T("none"),setAllTableBorders:E=>T("all",E),setOutsideTableBorders:E=>T("outside",E),setInsideTableBorders:E=>T("inside",E)}}}});function Ku(){return [Ah(),Dh(),Hh(),Nh(),zh()]}function ml(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function Gu(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,(c,d)=>{if(c.type.name==="paragraph"&&!u.has(d))if(u.add(d),s)l=l.setNodeMarkup(d,void 0,{...c.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(d,void 0,{...c.attrs,numPr:{numId:e,ilvl:c.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var Oh=(e,t)=>Gu(1)(e,t),$h=(e,t)=>Gu(2)(e,t),_h=(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},Wh=(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},Vh=(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 Uh(){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 jh(){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 Kh(){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 Gh(){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 Yh(){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 qh(){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 Yu=pt({name:"list",priority:on.High,onSchemaReady(){return {commands:{toggleBulletList:()=>Oh,toggleNumberedList:()=>$h,increaseListLevel:()=>_h,decreaseListLevel:()=>Wh,removeList:()=>Vh},keyboardShortcuts:{Tab:ml(Uu(),Gh(),qh()),"Shift-Tab":ml(ju(),Yh()),"Shift-Enter":()=>false,Enter:ml(Uh(),jh()),Backspace:Kh()}}}});function Xu(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var nb=(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},ob=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],Zu=new Set(["fontFamily","fontSize","textColor"]),rb=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>Zu.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:c}=u.selection,d=c.parent;if(d.type.name==="paragraph"){let p={...d.attrs},f=false;if(r)for(let m of ob){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(c.before(),void 0,p),d.textContent.length===0){let m=a;if(m.length===0&&r){let b=r.attrs.defaultTextFormatting;b&&(m=ru(b,e.schema).filter(x=>Zu.has(x.type.name)));}if(m.length>0){let b={...p.defaultTextFormatting??{}},h=false;for(let x of m)if(x.type.name==="fontSize"&&x.attrs.size!==b.fontSize&&(b.fontSize=x.attrs.size,h=true),x.type.name==="fontFamily"){let T=x.attrs.ascii;T&&(!b.fontFamily||b.fontFamily.ascii!==T)&&(b.fontFamily={...b.fontFamily,ascii:T,hAnsi:x.attrs.hAnsi},h=true);}h&&u.setNodeMarkup(c.before(),void 0,{...p,defaultTextFormatting:b}),u.setStoredMarks(m);}}}t(u.scrollIntoView());}return true},Ju=pt({name:"baseKeymap",priority:on.Low,onSchemaReady(e){return {keyboardShortcuts:{...baseKeymap,Enter:rb,Backspace:Xu(deleteSelection,nb,joinBackward),Delete:Xu(deleteSelection,joinForward),"Mod-a":selectAll,Escape:selectParentNode}}}});var Qu=new PluginKey("selectionTracker");function Gi(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((I,R,A)=>{if(R>r)return false;R<=o&&(s=A),R<=r&&(l=A);});let u=sb(e),c=a.parent,d={};c.type.name==="paragraph"&&(c.attrs.alignment&&(d.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(d.lineSpacing=c.attrs.lineSpacing,d.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.indentLeft&&(d.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(d.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(d.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(d.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(d.tabs=c.attrs.tabs),c.attrs.numPr&&(d.numPr=c.attrs.numPr),c.attrs.styleId&&(d.styleId=c.attrs.styleId));let p=c.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl,h=e.storedMarks||(i?a.marks():[]),x=[],T=false,S=false;for(let I of h)I.type.name==="comment"&&I.attrs.commentId&&x.push(I.attrs.commentId),I.type.name==="insertion"&&(T=true),I.type.name==="deletion"&&(S=true);return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:d,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b,activeCommentIds:x,inInsertion:T,inDeletion:S}}function sb(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 ep(e){return new Plugin({key:Qu,state:{init(t,n){return Gi(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=Gi(r);return e&&!cb(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=Qu.getState(t.state);o&&e(o);}}}})}function lb(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 cb(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&&lb(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var tp=pt({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[ep(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(Gi(n),true)}}}});var pb=new PluginKey("imageDrag"),op=pt({name:"imageDrag",onSchemaReady(e){return {plugins:[new Plugin({key:pb,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 gl=612;async function gb(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 hb(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 bb(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 gb(r);}catch{continue}let a=1,s=1;try{({width:a,height:s}=await hb(i));}catch{a=1,s=1;}let l=a,u=s;if(l>gl){let p=gl/l;l=gl,u=Math.max(1,Math.round(u*p));}let c=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"}),d=e.state.tr.insert(o,c);o+=c.nodeSize,d.setSelection(TextSelection.create(d.doc,o)),e.dispatch(d.scrollIntoView());}e.focus();}var rp=pt({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(),bb(n,i).catch(()=>{}),true)}}}})]}}});var ip=pt({name:"dropCursor",onSchemaReady(){return {plugins:[dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});var Yi=new PluginKey("paragraphChangeTracker");function ap(e){let t=0;return e.descendants(n=>{n.type.name==="paragraph"&&t++;}),t}function hl(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 vb(e,t,n){let o=Math.min(t,n),r=Math.max(t,n),i=r>o?r:o+1,a=hl(e,o,i);if(a.ids.size>0||a.hasUntracked)return a;try{let s=e.resolve(o);for(let l=s.depth;l>=0;l--){let u=s.node(l);if(u.type.name==="paragraph"){let c=u.attrs.paraId;return c?{ids:new Set([c]),hasUntracked:!1}:{ids:new Set,hasUntracked:!0}}}}catch{}return {ids:new Set,hasUntracked:false}}function Rb(){return new Plugin({key:Yi,state:{init(e,t){return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:ap(t.doc)}},apply(e,t){if(e.getMeta(Yi)==="clear")return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:t.paragraphCount};if(!e.docChanged)return t;let n=ap(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){if(r instanceof AddMarkStep||r instanceof RemoveMarkStep){let{ids:a,hasUntracked:s}=vb(e.doc,r.from,r.to);for(let l of a)o.changedParaIds.add(l);s&&(o.hasUntrackedChanges=true);continue}if(r instanceof AddNodeMarkStep||r instanceof RemoveNodeMarkStep){let a=r.pos,s=e.doc.nodeAt(a),l=s?a+s.nodeSize:a+1,{ids:u,hasUntracked:c}=hl(e.doc,a,l);for(let d of u)o.changedParaIds.add(d);c&&(o.hasUntrackedChanges=true);continue}r.getMap().forEach((a,s,l,u)=>{let{ids:c,hasUntracked:d}=hl(e.doc,l,u);for(let p of c)o.changedParaIds.add(p);d&&(o.hasUntrackedChanges=true);});}return o}}})}function bl(e){return Yi.getState(e)}function sp(e){return bl(e)?.changedParaIds??new Set}function lp(e){return bl(e)?.structuralChange??false}function cp(e){return bl(e)?.hasUntrackedChanges??false}function dp(e){return e.tr.setMeta(Yi,"clear")}var up=pt({name:"paragraphChangeTracker",defaultOptions:{},onSchemaReady(){return {plugins:[Rb()]}}});var pp=pt({name:"bidiShortcut",priority:on.High,onSchemaReady(e){return {plugins:[new Plugin({props:{handleKeyDown(t,n){if(n.key!=="Shift"||!(n.metaKey||n.ctrlKey))return false;let r=eo.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 fp(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 Mb(e,t){let n=e.getAttribute("style")||"",o=fp(n);for(let[r,i]of Object.entries(t))r in o||e.style.setProperty(r,i);}function Ib(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={},c=l.style;for(let d=0;d<c.length;d++){let p=c[d];u[p]=c.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=fp(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)Mb(a,r);}catch{}}function Fb(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 Lb(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){Ib(r);let i=r.querySelectorAll("style");for(let a of i)a.remove();}return n&&Fb(r),r.body.innerHTML}catch{return e}}var mp=pt({name:"pasteStyleInliner",priority:on.High,onSchemaReady(){return {plugins:[new Plugin({props:{transformPastedHTML(t){return Lb(t)}}})]}}});function rr(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",Vd()),o("text",Ud()),o("paragraph",Xd()),o("history",Jd({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",eu()),o("italic",nu()),o("underline",au()),o("strike",su()),o("textColor",lu()),o("highlight",cu()),o("fontSize",du()),o("fontFamily",uu()),o("superscript",pu()),o("subscript",fu()),o("hyperlink",mu()),o("allCaps",gu()),o("smallCaps",hu()),o("footnoteRef",bu()),o("characterSpacing",yu()),o("emboss",Cu()),o("imprint",Tu()),o("textShadow",wu()),o("emphasisMark",vu()),o("textOutline",Ru()),o("comment",xu()),o("insertion",Su()),o("deletion",ku()),o("hardBreak",Eu()),o("tab",Pu()),o("image",Mu()),o("textBox",Iu()),o("shape",Fu()),o("imageDrag",op()),o("imagePaste",rp()),o("dropCursor",ip()),o("horizontalRule",Lu()),o("pageBreak",Bu()),o("field",Au()),o("sdt",Du()),o("math",Hu()),t.has("table")||n.push(...Ku()),o("pasteStyleInliner",mp()),o("list",Yu()),o("baseKeymap",Ju()),o("selectionTracker",tp({onSelectionChange:e.onSelectionChange})),o("paragraphChangeTracker",up()),o("bidiShortcut",pp()),n}var to=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 qi=new to(rr());qi.buildSchema();qi.initializeRuntime();var eo=qi,ve=qi.getSchema();var Db={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},Nr=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")??Db}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 On(e){return new Nr(e)}function yl(e,t){let n=e.package.document.content,o=[],r=t?.styles?On(t.styles):null;for(let i of n)if(i.type==="paragraph")o.push(...gp(i,r)),Yb(i)&&o.push(ve.node("pageBreak"));else if(i.type==="table"){let a=Sl(i,r);o.push(a);}return o.length===0&&o.push(ve.node("paragraph",{},[])),ve.node("doc",null,o)}function xl(e,t,n,o){let r=Hb(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=Rn(l,o);for(let c of e.content){if(c.type==="commentRangeStart")s.add(c.id);else if(c.type==="commentRangeEnd")s.delete(c.id);else if(c.type==="run"){let d=kl(c,u,t);s.size>0&&(d=zr(d,s)),i.push(...d);}else if(c.type==="hyperlink"){let d=Cl(c,u,t);i.push(...d);}else if(c.type==="simpleField"||c.type==="complexField"){let d=$b(c,u);d&&i.push(d);}else if(c.type==="inlineSdt"){let d=Wb(c,u,t);d&&i.push(d);}else if(c.type==="insertion"){let d=Xi(c,"insertion",u,t);s.size>0&&(d=zr(d,s)),i.push(...d);}else if(c.type==="deletion"){let d=Xi(c,"deletion",u,t);s.size>0&&(d=zr(d,s)),i.push(...d);}else if(c.type==="moveFrom"){let d=Xi(c,"deletion",u,t);s.size>0&&(d=zr(d,s)),i.push(...d);}else if(c.type==="moveTo"){let d=Xi(c,"insertion",u,t);s.size>0&&(d=zr(d,s)),i.push(...d);}else if(c.type==="mathEquation"){let d=_b(c);d&&i.push(d);}c.type==="bookmarkStart"&&(a||(a=[]),a.push({id:c.id,name:c.name}));}return a&&(r.bookmarks=a),ve.node("paragraph",r,i)}function zr(e,t){if(t.size===0)return e;let n=[...t][0],o=ve.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function Xi(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...kl(a,n,o)):a.type==="hyperlink"&&r.push(...Cl(a,n,o));let i=ve.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 Hb(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=Zi(n?.runProperties,t);r.defaultTextFormatting=Rn(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=Zi(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 Xt(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=Zi(r.pPr?.runProperties,e),a=Zi(r.rPr,e),s=Rn(i,a);return {tcPr:r.tcPr,rPr:s}}function vn(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=Rn(e.rPr,t.rPr),n}function Zi(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return Rn(n,e)}function Nb(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,c=l.formatting?.vMerge,d=`${r}-${a}`;if(c==="restart")o.set(a,r),t.set(d,{rowSpan:1,skip:false});else if(c==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(d,{rowSpan:1,skip:true});}else o.delete(a),t.set(d,{rowSpan:1,skip:false});a+=u;}}return t}function Sl(e,t){let n=Nb(e),o=e.columnWidths,r=o?.reduce((S,I)=>S+I,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,c=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,d={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:c,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Xt(t,i,"wholeTable"),firstRow:Xt(t,i,"firstRow"),lastRow:Xt(t,i,"lastRow"),firstCol:Xt(t,i,"firstCol"),lastCol:Xt(t,i,"lastCol"),band1Horz:Xt(t,i,"band1Horz"),band2Horz:Xt(t,i,"band2Horz"),band1Vert:Xt(t,i,"band1Vert"),band2Vert:Xt(t,i,"band2Vert"),nwCell:Xt(t,i,"nwCell"),neCell:Xt(t,i,"neCell"),swCell:Xt(t,i,"swCell"),seCell:Xt(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,h=e.rows.length,x=o?.length??e.rows[0]?.cells.reduce((S,I)=>S+(I.formatting?.gridSpan??1),0)??0,T=e.rows.map((S,I)=>{let R=I===0&&!!a?.firstRow,A=I===h-1&&!!a?.lastRow,L=f&&!R&&!A?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!R&&!A&&b++,zb(S,t,R,o,r,p,L,m,a,l,I,h,x,n,c)});return ve.node("table",d,T)}function zb(e,t,n,o,r,i,a,s,l,u,c,d,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:!!e.formatting?.header,_originalFormatting:e.formatting||void 0},h=e.cells.length,x=c===0,T=c===(d??1)-1,S=e.formatting?.conditionalFormat,I=S?.firstRow??x,R=S?.lastRow??T,A=p??h,L=0,pe=[];for(let $=0;$<e.cells.length;$++){let v=e.cells[$],_=v.formatting?.gridSpan??1,re=`${c??0}-${L}`,ae=f?.get(re),N=ae?.skip??false,D=ae?.rowSpan??1,de;if(o&&r&&r>0){let oe=0;for(let Q=0;Q<_&&L+Q<o.length;Q++)oe+=o[L+Q];de=Math.round(oe/r*100);}if(L+=_,N)continue;let ge=L-_===0,Pe=L===A,se=v.formatting?.conditionalFormat,q=se?.firstRow??I,E=se?.lastRow??R,F=se?.firstColumn??ge,k=se?.lastColumn??Pe,P;if(s){let oe=l?.firstColumn?1:0,Q=L-_-oe;Q>=0&&!(l?.lastColumn&&k)&&!(l?.firstColumn&&F)&&(P=Q%2===0?i?.band1Vert:i?.band2Vert);}se?.oddVBand?P=i?.band1Vert:se?.evenVBand&&(P=i?.band2Vert);let M=a;S?.oddHBand?M=i?.band1Horz:S?.evenHBand&&(M=i?.band2Horz),se?.oddHBand?M=i?.band1Horz:se?.evenHBand&&(M=i?.band2Horz);let H=i?.wholeTable;H=vn(H,M),H=vn(H,P),q&&(l?.firstRow||S?.firstRow||se?.firstRow)&&(H=vn(H,i?.firstRow)),E&&(l?.lastRow||S?.lastRow||se?.lastRow)&&(H=vn(H,i?.lastRow)),F&&(l?.firstColumn||S?.firstColumn||se?.firstColumn)&&(H=vn(H,i?.firstCol)),k&&(l?.lastColumn||S?.lastColumn||se?.lastColumn)&&(H=vn(H,i?.lastCol)),q&&F&&(l?.firstRow||S?.firstRow||se?.firstRow)&&(l?.firstColumn||S?.firstColumn||se?.firstColumn)&&(H=vn(H,i?.nwCell)),q&&k&&(l?.firstRow||S?.firstRow||se?.firstRow)&&(l?.lastColumn||S?.lastColumn||se?.lastColumn)&&(H=vn(H,i?.neCell)),E&&F&&(l?.lastRow||S?.lastRow||se?.lastRow)&&(l?.firstColumn||S?.firstColumn||se?.firstColumn)&&(H=vn(H,i?.swCell)),E&&k&&(l?.lastRow||S?.lastRow||se?.lastRow)&&(l?.lastColumn||S?.lastColumn||se?.lastColumn)&&(H=vn(H,i?.seCell)),pe.push(Ob(v,t,n,de,H,u,x,T,ge,Pe,D,m));}return ve.node("tableRow",b,pe)}function Ob(e,t,n,o,r,i,a,s,l,u,c,d){let p=e.formatting,f=c??1,m=p?.width?.value,b=p?.width?.type;m===void 0&&o!==void 0&&(m=o,b="pct");let h=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,T=r?.tcPr?.borders,S=p?.borders,I=x||T||S?{...x??{},...T??{},...S??{}}:void 0,R={colspan:p?.gridSpan??1,rowspan:f,width:m,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:h,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:I,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}:d,_originalFormatting:p||void 0},A=[];for(let pe of e.content)pe.type==="paragraph"?A.push(xl(pe,t,void 0,r?.rPr)):pe.type==="table"&&A.push(Sl(pe,t));A.length===0&&A.push(ve.node("paragraph",{},[]));let L=n?"tableHeader":"tableCell";return ve.node(L,R,A)}function $b(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=Rn(t,o),a=Tl(i);return ve.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 _b(e){return ve.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Wb(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=kl(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Cl(i,t,n);r.push(...a);}return ve.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 kl(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=Rn(Rn(t,r),e.formatting),a=Tl(i);for(let s of e.content){let l=Vb(s,a);o.push(...l);}return o}function Rn(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 Vb(e,t){switch(e.type){case "text":return e.text?[ve.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[ve.node("hardBreak")]:[];case "tab":return [ve.node("tab")];case "drawing":return e.image?[Ub(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[jb(r)]}case "footnoteRef":let n=ve.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [ve.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=ve.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [ve.text(e.id.toString(),[...t,o])];default:return []}}function Ub(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,c=e.wrap.distB?c$2(e.wrap.distB):void 0,d=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,h;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"};h=e.outline.style&&x[e.outline.style]||"solid";}return ve.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:c,distLeft:d,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:h,wrapText:r,hlinkHref:e.hlinkHref})}function Cl(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=ve.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=Rn(Rn(t,s),a.formatting),c=[...Tl(l),i];for(let d of a.content)d.type==="text"&&d.text&&o.push(ve.text(d.text,c));}return o}function Tl(e){if(!e)return [];let t=[];return e.bold&&t.push(ve.mark("bold")),e.italic&&t.push(ve.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(ve.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(ve.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(ve.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(ve.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(ve.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(ve.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(ve.mark("superscript")):e.vertAlign==="subscript"&&t.push(ve.mark("subscript")),e.allCaps&&t.push(ve.mark("allCaps")),e.smallCaps&&t.push(ve.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(ve.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(ve.mark("emboss")),e.imprint&&t.push(ve.mark("imprint")),e.shadow&&t.push(ve.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(ve.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(ve.mark("textOutline")),t}function jb(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,c;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),c=e.outline.style||"solid");let d;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&&(d=p.join(" "));}return ve.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:c,transform:d})}function gp(e,t){let n=Kb(e),o=xl(e,t),r=[];n.length>0&&o.content.size===0||r.push(o);for(let a of n)r.push(Gb(a,t));return r}function Kb(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 Gb(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,c=e.margins?.left!=null?c$2(e.margins.left):7,d=e.margins?.right!=null?c$2(e.margins.right):7,p=[];for(let f of e.content)p.push(xl(f,t));return p.length===0&&p.push(ve.node("paragraph",{},[])),ve.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:c,marginRight:d},p)}function wl(e,t){let n=[],o=t?.styles?On(t.styles):null;for(let r of e)r.type==="paragraph"?n.push(...gp(r,o)):r.type==="table"&&n.push(Sl(r,o));return n.length===0&&n.push(ve.node("paragraph",{},[])),ve.node("doc",null,n)}function Yb(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 vl(){return ve.node("doc",null,[ve.node("paragraph",{},[])])}function bp(e,t){let o={content:yp(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 yp(e){let t=[],n=Sp(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push(Rl(o,n)):o.type.name==="table"?t.push(Cp(o,n)):o.type.name==="textBox"?t.push(gy(o)):o.type.name==="pageBreak"&&t.push(qb());}),t}function qb(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Rl(e,t){let n=e.attrs,o=Xb(xp(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:Zb(n),content:o};return n._sectionProperties?i.sectionProperties=n._sectionProperties:n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function Xb(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 Zb(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 xp(e,t){let n=[],o=t??Sp(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"),c=s.marks.find(p=>p.type.name==="deletion");if(u||c){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let p=u||c,f=s.marks.filter(R=>R.type.name!=="insertion"&&R.type.name!=="deletion"),m=El(f),b={type:"run",content:s.isText&&s.text?[{type:"text",text:s.text}]:[],...Object.keys(m).length>0?{formatting:m}:{}},h={id:p.attrs.revisionId,author:p.attrs.author||"Unknown",date:p.attrs.date||void 0},x=h.id,T=(o.insertionById.get(x)??0)>0,S=(o.deletionById.get(x)??0)>0,I=T&&S;u?I?n.push({type:"moveTo",info:h,content:[b]}):n.push({type:"insertion",info:h,content:[b]}):I?n.push({type:"moveFrom",info:h,content:[b]}):n.push({type:"deletion",info:h,content:[b]});return}let d=s.marks.find(p=>p.type.name==="hyperlink");if(d){let p=Jb(d),f=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&f===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=ey(d)),hp(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=Qb(s.marks);r&&i===p?ty(r,s.text||""):(r&&n.push(r),r=kp(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(ny())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(sy(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push(ly(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(oy())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(ry(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(ay(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(iy(s)));}),r&&n.push(r),a&&n.push(a),n}function Sp(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 Jb(e){return e.attrs.href||""}function Qb(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 ey(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 hp(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=kp(t.text,n);e.children.push(o);}}function kp(e,t){let n=El(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function ty(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 ny(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function oy(){return {type:"run",content:[{type:"tab"}]}}function ry(e,t){let n=e.attrs,o=t&&t.length>0?El(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 iy(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function ay(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=xp(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function sy(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 ly(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 El(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 cy(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 Cp(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(uy(i,t));});let r=dy(n)||void 0;if(!r?.borders){let i=cy(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 dy(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 uy(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push(fy(r,t));}),{type:"tableRow",formatting:py(n),cells:o}}function py(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 fy(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push(Rl(r,t)):r.type.name==="table"&&o.push(Cp(r,t));}),{type:"tableCell",formatting:my(n),content:o}}function my(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 gy(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(Rl(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 Ji(e){return yp(e)}function ir(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((h,x,T)=>{x<=o&&(s=T),x<=r&&(l=T);});let u={},c=a.parent,d=c.type.name==="paragraph"&&c.textContent.length===0,p=c.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();d&&f.length===0&&p&&(u={...p});for(let h of f)switch(h.type.name){case "bold":u.bold=true;break;case "italic":u.italic=true;break;case "underline":u.underline={style:h.attrs.style||"single",color:h.attrs.color};break;case "strike":h.attrs.double?u.doubleStrike=true:u.strike=true;break;case "textColor":u.color={rgb:h.attrs.rgb,themeColor:h.attrs.themeColor};break;case "highlight":u.highlight=h.attrs.color;break;case "fontSize":u.fontSize=h.attrs.size;break;case "fontFamily":u.fontFamily={ascii:h.attrs.ascii,hAnsi:h.attrs.hAnsi};break;case "superscript":u.vertAlign="superscript";break;case "subscript":u.vertAlign="subscript";break}let m={},b=null;return c.type.name==="paragraph"&&(c.attrs.alignment&&(m.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(m.lineSpacing=c.attrs.lineSpacing,m.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.numPr&&(m.numPr=c.attrs.numPr),c.attrs.indentLeft&&(m.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(m.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(m.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(m.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(m.tabs=c.attrs.tabs),c.attrs.bidi&&(m.bidi=true),c.attrs.styleId&&(b=c.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var Mt=eo.getCommands(),Qi=Mt.toggleBold(),ea=Mt.toggleItalic(),ta=Mt.toggleUnderline(),na=Mt.toggleStrike(),oa=Mt.toggleSuperscript(),ra=Mt.toggleSubscript();function Or(e){return Mt.setTextColor(e)}var ia=Mt.clearTextColor();function aa(e){return Mt.setHighlight(e)}Mt.clearHighlight();function sa(e){return Mt.setFontSize(e)}Mt.clearFontSize();function la(e){return Mt.setFontFamily(e)}Mt.clearFontFamily();function ca(e,t){return Mt.setHyperlink(e,t)}var da=Mt.removeHyperlink();function $r(e,t,n){return Mt.insertHyperlink(e,t,n)}var st=eo.getCommands();function ua(e){return st.setAlignment(e)}st.alignLeft();st.alignCenter();st.alignRight();st.alignJustify();function pa(e,t="auto"){return st.setLineSpacing(e,t)}st.singleSpacing();st.oneAndHalfSpacing();st.doubleSpacing();function fa(e=720){return st.increaseIndent(e)}function ma(e=720){return st.decreaseIndent(e)}function ga(e){return st.setIndentLeft(e)}function ha(e){return st.setIndentRight(e)}function _r(e,t){return st.setIndentFirstLine(e,t)}var ba=st.toggleBulletList(),ya=st.toggleNumberedList(),xa=st.increaseListLevel(),Sa=st.decreaseListLevel();st.removeList();function Wr(e,t){return st.applyStyle(e,t)}st.clearStyle();st.removeSectionBreak();function ka(e){return st.removeTabStop(e)}var Ca=st.setRtl(),Ta=st.setLtr(),wa=st.generateTOC();var tt=eo.getCommands();function va(e,t){return tt.insertTable(e,t)}function Vr(e,t){return tt.addRowAbove()(e,t)}function Io(e,t){return tt.addRowBelow()(e,t)}function Ur(e,t){return tt.deleteRow()(e,t)}function jr(e,t){return tt.addColumnLeft()(e,t)}function Fo(e,t){return tt.addColumnRight()(e,t)}function Kr(e,t){return tt.deleteColumn()(e,t)}function Gr(e,t){return tt.deleteTable()(e,t)}function Ra(e,t){return tt.selectTable()(e,t)}function Ea(e,t){return tt.selectRow()(e,t)}function Pa(e,t){return tt.selectColumn()(e,t)}function Ma(e,t){return tt.mergeCells()(e,t)}function Ia(e,t){return tt.splitCell()(e,t)}function no(e,t,n){return tt.setCellBorder(e,t,n)}function Fa(e,t){return tt.removeTableBorders()(e,t)}function La(e,t,n){return tt.setAllTableBorders(n)(e,t)}function Ba(e,t,n){return tt.setOutsideTableBorders(n)(e,t)}function Aa(e,t,n){return tt.setInsideTableBorders(n)(e,t)}function Da(e){return tt.setCellVerticalAlign(e)}function Ha(e){return tt.setCellMargins(e)}function Na(e){return tt.setCellTextDirection(e)}function za(){return tt.toggleNoWrap()}function Oa(e,t){return tt.setRowHeight(e,t)}function $a(){return tt.toggleHeaderRow()}function _a(){return tt.distributeColumns()}function Wa(){return tt.autoFitContents()}function Yr(e){return tt.setTableProperties(e)}function Va(e){return tt.applyTableStyle(e)}function Ua(e){return tt.setCellFillColor(e)}function ja(e){return tt.setTableBorderColor(e)}function Ka(e){return tt.setTableBorderWidth(e)}var Ga=(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 c=a.mapping.map(i.pos);a.insert(c,Fragment$1.from([s,r.create()])),u=c+l+1;}else if(i.parentOffset===i.parent.content.size){let c=i.after();a.insert(c,Fragment$1.from([s,r.create()])),u=c+l+1;}else {let c=i.before();a.insert(c,s),u=c+l+1;}else {let c=i.pos;a.insert(c,Fragment$1.from([s,r.create()])),u=c+l+1;}a.setSelection(TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function Dp(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,c=[];o.doc.nodesBetween(e,t,(d,p)=>{if(!d.isText)return;let f=p+d.nodeSize,m=Math.max(e,p),b=Math.min(t,f);l&&d.marks.some(h=>h.type===l)&&c.push({from:m,to:b}),s&&d.marks.some(h=>h.type===s)&&u.removeMark(m,b,s);});for(let d of c.reverse())u.delete(d.from,d.to);u.steps.length>0&&r(u);}return true}}function Hp(e,t){return Dp(e,t,"accept")}function Np(e,t){return Dp(e,t,"reject")}var Op={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},$p={fontWeight:500,letterSpacing:.3},Ny={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},zy={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"},Ya={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},Wp=forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},c){let d=useRef(null),p=useRef(null),[f,m]=useState(false),b$1=useMemo(()=>{if(!o)return 11;let _=On(o).resolveParagraphStyle(void 0);return _.runFormatting?.fontSize?_.runFormatting.fontSize/2:11},[o]),[h,x]=useState(false),T=useRef(null),[S,I]=useState(null);useLayoutEffect(()=>{let v=()=>{let re=i.getBoundingClientRect(),ae=r.getBoundingClientRect();I({top:ae.top-re.top+i.scrollTop,left:ae.left-re.left+i.scrollLeft,width:ae.width});};v();let _=i.closest('[style*="overflow"]')||i;return _.addEventListener("scroll",v),window.addEventListener("resize",v),()=>{_.removeEventListener("scroll",v),window.removeEventListener("resize",v);}},[r,i]),useEffect(()=>{if(!d.current||p.current)return;let v=wl(t.content,{styles:o||void 0}),_=new to(rr());_.buildSchema(),_.initializeRuntime();let re=_.getPlugins(),ae=EditorState.create({doc:v,schema:ve,plugins:re}),N=new EditorView(d.current,{state:ae,dispatchTransaction(D){let de=N.state.apply(D);if(N.updateState(de),D.docChanged&&m(true),D.selectionSet||D.docChanged){let ge=ir(de);l?.(ge);}}});return p.current=N,requestAnimationFrame(()=>{N.focus();let D=ir(N.state);l?.(D);}),()=>{N.destroy(),p.current=null;}},[S]);let R=useCallback(()=>{if(!p.current)return;let v=Ji(p.current.state.doc);a(v);},[a]),A=useCallback(()=>{f?R():s();},[f,R,s]);useEffect(()=>{function v(_){_.key==="Escape"&&(_.preventDefault(),_.stopPropagation(),A());}return document.addEventListener("keydown",v,true),()=>document.removeEventListener("keydown",v,true)},[A]),useEffect(()=>{if(!h)return;function v(_){T.current&&!T.current.contains(_.target)&&x(false);}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[h]),useImperativeHandle(c,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let v=p.current;return v?undo(v.state,v.dispatch):false},redo:()=>{let v=p.current;return v?redo(v.state,v.dispatch):false}}));let{t:L}=b(),pe=L(n==="header"?"headerFooter.header":"headerFooter.footer");if(!S)return null;let $={position:"absolute",top:S.top,left:S.left,width:S.width,zIndex:10};return jsxs("div",{className:"hf-inline-editor",style:$,onMouseDown:v=>{v.stopPropagation();},children:[n==="footer"&&jsxs("div",{className:"hf-separator-bar",style:Op,children:[jsx("span",{style:$p,children:pe}),jsx(_p,{label:pe,showOptions:h,setShowOptions:x,optionsRef:T,onRemove:u,onClose:A,viewRef:p})]}),jsx("div",{ref:d,className:"hf-editor-pm",style:{minHeight:40,outline:"none",fontSize:`${b$1}pt`}}),n==="header"&&jsxs("div",{className:"hf-separator-bar",style:Op,children:[jsx("span",{style:$p,children:pe}),jsx(_p,{label:pe,showOptions:h,setShowOptions:x,optionsRef:T,onRemove:u,onClose:A,viewRef:p})]})]})});function _p({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let{t:s}=b(),l=u=>{let c=a.current;if(!c)return;let{$from:d,from:p}=c.state.selection,f=c.state.storedMarks||d.marks(),m=ve.nodes.field.create({fieldType:u,instruction:` ${u} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),b=c.state.tr.insert(p,m.mark(f));c.dispatch(b),c.focus();};return jsxs("div",{style:{position:"relative"},ref:o,children:[jsxs("button",{type:"button",style:Ny,onClick:u=>{u.stopPropagation(),n(c=>!c);},onMouseDown:u=>u.stopPropagation(),children:[s("headerFooter.options")," \u25BE"]}),t&&jsxs("div",{style:zy,children:[jsx("button",{type:"button",style:Ya,onClick:()=>{n(false),l("PAGE");},onMouseOver:u=>{u.target.style.backgroundColor="#f1f3f4";},onMouseOut:u=>{u.target.style.backgroundColor="transparent";},children:s("headerFooter.insertPageNumber")}),jsx("button",{type:"button",style:Ya,onClick:()=>{n(false),l("NUMPAGES");},onMouseOver:u=>{u.target.style.backgroundColor="#f1f3f4";},onMouseOut:u=>{u.target.style.backgroundColor="transparent";},children:s("headerFooter.insertTotalPages")}),jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsx("button",{type:"button",style:Ya,onClick:()=>{n(false),r();},onMouseOver:u=>{u.target.style.backgroundColor="#f1f3f4";},onMouseOut:u=>{u.target.style.backgroundColor="transparent";},children:s("headerFooter.remove",{label:e.toLowerCase()})}),jsx("button",{type:"button",style:Ya,onClick:()=>{n(false),i();},onMouseOver:u=>{u.target.style.backgroundColor="#f1f3f4";},onMouseOut:u=>{u.target.style.backgroundColor="transparent";},children:s("headerFooter.closeEditing",{label:e.toLowerCase()})})]})]})}var Kp={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"},$y={...Kp,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},_y={...Kp,padding:"12px",width:"320px"},Bl={width:"20px",height:"20px",flexShrink:0,color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center"},Wy={color:"#1a73e8",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},Vy={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"#5f6368",padding:0,flexShrink:0},Uy={width:"1px",height:"20px",background:"#dadce0",flexShrink:0},Up={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},jp={flex:1,padding:"6px 8px",border:"1px solid #dadce0",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},jy={color:"#1a73e8",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},sr={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function Ky(){return jsxs("svg",{...sr,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 Gy(){return jsxs("svg",{...sr,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 Yy(){return jsx("svg",{...sr,children:jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function qy(){return jsxs("svg",{...sr,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 Xy(){return jsxs("svg",{...sr,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 Zy(){return jsxs("svg",{...sr,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 Al({title:e,onClick:t,children:n}){return jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:Vy,title:e,onClick:t,children:n})}function Gp({data:e,onNavigate:t,onCopy:n,onEdit:o,onRemove:r,onClose:i,readOnly:a}){let{t:s}=b(),[l,u]=useState("view"),[c,d]=useState(""),[p,f]=useState(""),m=useRef(null),b$1=useRef(null);useEffect(()=>{e&&(u("view"),d(e.displayText),f(e.href));},[e]),useEffect(()=>{l==="edit"&&requestAnimationFrame(()=>{b$1.current?.focus(),b$1.current?.select();});},[l]),useEffect(()=>{if(!e)return;let L=false,pe=v=>{m.current&&!m.current.contains(v.target)&&i();},$=setTimeout(()=>{L||document.addEventListener("mousedown",pe);},0);return ()=>{L=true,clearTimeout($),document.removeEventListener("mousedown",pe);}},[e,i]),useEffect(()=>{if(!e)return;let L=pe=>{pe.key==="Escape"&&(l==="edit"?u("view"):i());};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[e,l,i]);let h=useCallback(()=>{e&&(n(e.href),toast("Link copied to clipboard"));},[e,n]),x=useCallback(()=>{e&&(d(e.displayText),f(e.href),u("edit"));},[e]),T=useCallback(()=>{let L=p.trim();L&&o(c.trim()||L,L);},[c,p,o]),S=useCallback(L=>{L.key==="Enter"&&(L.preventDefault(),T());},[T]);if(!e)return null;let{anchorRect:I}=e,R=I.bottom+4,A=I.left;return l==="edit"?jsxs("div",{ref:m,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{..._y,top:R,left:A},onMouseDown:L=>L.stopPropagation(),children:[jsxs("div",{style:Up,children:[jsx("span",{style:Bl,children:jsx(Xy,{})}),jsx("input",{ref:b$1,type:"text",style:jp,value:c,onChange:L=>d(L.target.value),onKeyDown:S,placeholder:s("hyperlinkPopup.displayTextPlaceholder"),onFocus:L=>L.target.style.borderColor="#1a73e8",onBlur:L=>L.target.style.borderColor="#dadce0"})]}),jsxs("div",{style:{...Up,marginBottom:0},children:[jsx("span",{style:Bl,children:jsx(Zy,{})}),jsx("input",{type:"text",style:jp,value:p,onChange:L=>f(L.target.value),onKeyDown:S,placeholder:s("hyperlinkPopup.urlPlaceholder"),onFocus:L=>L.target.style.borderColor="#1a73e8",onBlur:L=>L.target.style.borderColor="#dadce0"}),jsx("button",{type:"button",style:{...jy,opacity:p.trim()?1:.5,cursor:p.trim()?"pointer":"default"},onClick:T,disabled:!p.trim(),children:s("common.apply")})]})]}):jsxs("div",{ref:m,className:"ep-hyperlink-popup",style:{...$y,top:R,left:A},onMouseDown:L=>L.stopPropagation(),children:[jsx("span",{style:Bl,children:jsx(Ky,{})}),jsx("a",{href:e.href,style:Wy,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:L=>{L.preventDefault(),t(e.href);},children:e.href}),jsx("span",{style:Uy}),jsx(Al,{title:s("hyperlinkPopup.copyLink"),onClick:h,children:jsx(Gy,{})}),!a&&jsxs(Fragment,{children:[jsx(Al,{title:s("hyperlinkPopup.editLink"),onClick:x,children:jsx(Yy,{})}),jsx(Al,{title:s("hyperlinkPopup.removeLink"),onClick:r,children:jsx(qy,{})})]})]})}var Ee=e=>({style:"single",size:4,color:{rgb:e}}),Qy=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:Ee("000000"),bottom:Ee("000000"),left:Ee("000000"),right:Ee("000000"),insideH:Ee("000000"),insideV:Ee("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:Ee("BFBFBF"),bottom:Ee("BFBFBF"),left:Ee("BFBFBF"),right:Ee("BFBFBF"),insideH:Ee("BFBFBF"),insideV:Ee("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Ee("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:Ee("BFBFBF"),bottom:Ee("BFBFBF"),insideH:Ee("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:Ee("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:Ee("B4C6E7"),bottom:Ee("B4C6E7"),left:Ee("B4C6E7"),right:Ee("B4C6E7"),insideH:Ee("B4C6E7"),insideV:Ee("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Ee("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:Ee("4472C4"),bottom:Ee("4472C4"),left:Ee("4472C4"),right:Ee("4472C4"),insideH:Ee("4472C4"),insideV:Ee("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:Ee("FFFFFF"),bottom:Ee("FFFFFF"),left:Ee("FFFFFF"),right:Ee("FFFFFF"),insideH:Ee("FFFFFF"),insideV:Ee("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:Ee("ED7D31"),bottom:Ee("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:Ee("A5A5A5"),bottom:Ee("A5A5A5"),insideH:Ee("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:Ee("5B9BD5"),bottom:Ee("5B9BD5"),left:Ee("5B9BD5"),right:Ee("5B9BD5"),insideH:Ee("5B9BD5"),insideV:Ee("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:Ee("70AD47"),bottom:Ee("70AD47"),left:Ee("70AD47"),right:Ee("70AD47"),insideH:Ee("70AD47"),insideV:Ee("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Yp(e){return Qy.find(t=>t.id===e)}function qp(){let{t:e}=b();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:e("errors.loadingDocument")})]})}function Xp(){let{t:e}=b();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:e("errors.noDocumentLoaded")})]})}function Zp({message:e}){let{t}=b();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:t("errors.failedToLoad")}),jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function tx(e,t){return JSON.stringify(e)===JSON.stringify(t)}function nx(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=tx,onUndo:a,onRedo:s,containerRef:l}=t,[u,c]=useState(e),[d,p]=useState([]),[f,m]=useState([]),b=useRef(0),h=useRef(false),x=useCallback(($,v)=>{if(i(u,$))return;if(h.current){c($);return}let _=Date.now();_-b.current<o&&d.length>0?p(ae=>{let N=[...ae];return N[N.length-1]={state:u,timestamp:_,description:v||N[N.length-1].description},N}):p(ae=>{let N={state:u,timestamp:_,description:v},D=[...ae,N];return D.length>n?D.slice(D.length-n):D}),m([]),c($),b.current=_;},[u,i,o,n,d.length]),T=useCallback(()=>{if(d.length===0)return;h.current=true;let $=d[d.length-1];return p(v=>v.slice(0,-1)),m(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),a?.($.state),$.state},[d,u,a]),S=useCallback(()=>{if(f.length===0)return;h.current=true;let $=f[f.length-1];return m(v=>v.slice(0,-1)),p(v=>[...v,{state:u,timestamp:Date.now()}]),c($.state),setTimeout(()=>{h.current=false;},0),s?.($.state),$.state},[f,u,s]),I=useCallback(()=>{p([]),m([]);},[]),R=useCallback($=>{c($??e),p([]),m([]),b.current=0;},[e]),A=useCallback(()=>[...d],[d]),L=useCallback(()=>[...f],[f]),pe=useCallback($=>{c(v=>$(v)),p(v=>v.map(_=>({..._,state:$(_.state)}))),m(v=>v.map(_=>({..._,state:$(_.state)})));},[]);return useEffect(()=>{if(!r)return;let $=_=>{if((_.ctrlKey||_.metaKey)&&_.key==="z"&&!_.shiftKey){_.preventDefault(),T();return}if((_.ctrlKey||_.metaKey)&&_.key==="y"||(_.ctrlKey||_.metaKey)&&_.key==="z"&&_.shiftKey){_.preventDefault(),S();return}},v=l?.current||document;return v.addEventListener("keydown",$),()=>{v.removeEventListener("keydown",$);}},[r,T,S,l]),{state:u,canUndo:d.length>0,canRedo:f.length>0,undoCount:d.length,redoCount:f.length,push:x,undo:T,redo:S,clear:I,reset:R,getUndoStack:A,getRedoStack:L,transformAll:pe}}function Qp(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 nx(e,{...t,isEqual:n})}var oo=new PluginKey("suggestionMode"),Za="suggestionModeApplied",ix=Date.now();function Ja(e){return {revisionId:ix++,author:e.author,date:new Date().toISOString()}}function Nl(e,t,n,o){try{let r=e.resolve(t);for(let i of [r.nodeBefore,r.nodeAfter])if(i?.isText){let a=i.marks.find(s=>s.type.name===n&&s.attrs.author===o);if(a)return a.attrs}}catch{}return null}function nf(e,t,n,o,r){return Nl(e,t,o,r)??Nl(e,n,o,r)}function of(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,c)=>{if(!u.isText)return;let d=Math.max(c,n),p=Math.min(c+u.nodeSize,o);if(d>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:d,to:p,isOwnInsert:f});}),s.length===0)return;let l=nf(t,n,o,"deletion",a.author)||Ja(a);for(let u=s.length-1;u>=0;u--){let c=s[u];c.isOwnInsert?e.delete(c.from,c.to):e.addMark(c.from,c.to,i.create(l));}}function ef(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(Za,true);let s=Nl(e.state.doc,t,"insertion",r.author)||Ja(r);if(t!==n){let c=e.state.schema.marks.deletion;c&&of(a,e.state.doc,t,n,i,c,r);}let l=a.mapping.map(n);a.insertText(o,l,l);let u=e.state.schema.marks.deletion;return u&&a.removeMark(l,l+o.length,u),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function tf(e,t,n){let o=oo.getState(e);if(!o?.active)return false;let{$from:r,$to:i,empty:a}=e.selection,s=e.schema.marks.insertion,l=e.schema.marks.deletion;if(!s||!l)return false;if(!t)return true;let u=e.tr;if(u.setMeta(Za,true),!a){of(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(TextSelection.near(u.doc.resolve(x))),t(u.scrollIntoView()),true}let c=n==="backward",d=c?r.pos-1:r.pos,p=c?r.pos:r.pos+1;if(d<0||p>e.doc.content.size)return true;let m=e.doc.resolve(d).nodeAfter;if(!m?.isText)return false;let b=m.marks.some(x=>x.type===s&&x.attrs.author===o.author);if(m.marks.some(x=>x.type===l)){let x=c?d:p;u.setSelection(TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(d,p);else {let x=nf(e.doc,d,p,"deletion",o.author)||Ja(o);u.addMark(d,p,l.create(x));let T=c?d:p;u.setSelection(TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function rf(e=false,t="User"){return new Plugin({key:oo,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(oo);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=oo.getState(n.state);if(!r?.active)return false;if(o.inputType==="insertText"&&o.data){o.preventDefault();let{from:i,to:a}=n.state.selection;return ef(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return oo.getState(n.state)?.active?o.key==="Backspace"?tf(n.state,n.dispatch,"backward"):o.key==="Delete"?tf(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=oo.getState(n.state);return a?.active?ef(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=oo.getState(r);if(!i?.active)return null;let a=n.find(d=>d.docChanged&&!d.getMeta(Za));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Ja(i),u=r.tr;u.setMeta(Za,true);let c=r.schema.marks.deletion;return a.steps.forEach(d=>{d.getMap().forEach((f,m,b,h)=>{h>b&&r.doc.nodesBetween(b,h,(x,T)=>{if(!x.isText)return;if(!x.marks.some(I=>I.type===s||c&&I.type===c)){let I=Math.max(T,b),R=Math.min(T+x.nodeSize,h);u.addMark(I,R,s.create(l));}});});}),u.steps.length>0?u:null}})}function af(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(oo,r);n(i);}return true}var mx={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function df(e,t,n,o=[]){let r=n?.getSchema()??ve,i=e?yl(e,{styles:t??void 0}):vl(),a=[...o,...n?.getPlugins()??[]];return EditorState.create({doc:i,schema:r,plugins:a})}function gx(e,t){return t?bp(e.doc,t):null}var hx=forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:c=[],extensionManager:d,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=useRef(null),h=useRef(null),x=useRef(o),T=useRef(false),S=useRef(null),I=useRef(false),R=useRef(l),A=useRef(u),L=useRef(p),pe=useRef(f),$=useRef(m);R.current=l,A.current=u,L.current=p,pe.current=f,$.current=m,x.current=o;let v=useCallback(()=>{if(!b.current||T.current)return;let ae={state:df(o,r,d,c),editable:()=>!s,dispatchTransaction:N=>{if(!h.current||T.current)return;let D=h.current.state.apply(N);h.current.updateState(D),R.current?.(N,D),(N.selectionSet||N.docChanged)&&A.current?.(D);},handleKeyDown:(N,D)=>$.current?.(N,D)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};h.current=new EditorView(b.current,ae),L.current?.(h.current);},[o,r,c,d,s]),_=useCallback(()=>{h.current&&!T.current&&(T.current=true,pe.current?.(),h.current.destroy(),h.current=null,T.current=false);},[]);return useEffect(()=>(v(),()=>_()),[]),useEffect(()=>{if(!h.current||T.current)return;let ae=(D=>{if(!D)return "empty";let de=D.package?.properties;return `${de?.created||""}-${de?.modified||""}-${de?.title||""}`})(o);if(I.current&&ae===S.current)return;I.current=true,S.current=ae;let N=df(o,r,d,c);h.current.updateState(N),A.current?.(N);},[o,r,d,c]),useEffect(()=>{h.current;},[s]),useImperativeHandle(n,()=>({getState(){return h.current?.state??null},getView(){return h.current??null},getDocument(){return h.current?gx(h.current.state,x.current):null},focus(){h.current?.focus();},blur(){h.current?.hasFocus()&&h.current.dom.blur();},isFocused(){return h.current?.hasFocus()??false},dispatch(re){h.current&&!T.current&&h.current.dispatch(re);},executeCommand(re){return h.current?re(h.current.state,h.current.dispatch,h.current):false},undo(){return h.current?undo(h.current.state,h.current.dispatch):false},redo(){return h.current?redo(h.current.state,h.current.dispatch):false},canUndo(){return h.current?undo(h.current.state):false},canRedo(){return h.current?redo(h.current.state):false},setSelection(re,ae){if(!h.current)return;let{state:N,dispatch:D}=h.current,de=N.doc.resolve(re),ge=ae!==void 0?N.doc.resolve(ae):de,Pe=TextSelection.between(de,ge);D(N.tr.setSelection(Pe));},setNodeSelection(re){if(!h.current)return;let{state:ae,dispatch:N}=h.current;try{let D=NodeSelection.create(ae.doc,re);N(ae.tr.setSelection(D));}catch{this.setSelection(re);}},setCellSelection(re,ae){if(!h.current)return;let{state:N,dispatch:D}=h.current;try{let de=CellSelection.create(N.doc,re,ae);D(N.tr.setSelection(de));}catch{this.setSelection(re,ae);}},scrollToSelection(){}}),[]),jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...mx,width:a>0?`${a}px`:void 0}})}),uf=memo(hx);var Sx="#000",kx="rgba(66, 133, 244, 0.3)",Cx=2,Tx=530,wx={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},vx=(e,t,n,o)=>({position:"absolute",left:e.x,top:e.y,width:n,height:e.height,backgroundColor:t,opacity:o?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),Rx=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Ex=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=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:vx(e,t,n,i),"data-testid":"caret"})},Px=({rect:e,color:t,index:n})=>jsx("div",{style:Rx(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),ff=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Sx,selectionColor:i=kx,caretWidth:a=Cx,blinkInterval:s=Tx})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxs("div",{style:wx,"data-testid":"selection-overlay",children:[l&&e.map((c,d)=>jsx(Px,{rect:c,color:i,index:d},`sel-${c.pageIndex}-${c.x}-${c.y}-${d}`)),u&&t&&jsx(Ex,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var $l=10,ro=$l/2,Jr=2,bf="#2563eb",gf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Ix={position:"absolute",border:`${Jr}px solid ${bf}`,pointerEvents:"none",boxSizing:"border-box"},Fx={position:"absolute",width:`${$l}px`,height:`${$l}px`,backgroundColor:bf,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Lx={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"white",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},Bx={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Ax(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let c=Math.max(l/o,u/r);l=o*c,u=r*c;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function yf({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,c]=useState(false),[d,p]=useState(false),[f,m]=useState(0),[b,h]=useState(0),[x,T]=useState(null),S=useRef(null),I=useRef(null),R=useRef(o),A=useRef(r),L=useRef(i),pe=useRef(a),$=useRef(s),v=useRef(l);R.current=o,A.current=r,L.current=i,pe.current=a,$.current=s,v.current=l;let _=useRef(e),re=useRef(t);_.current=e,re.current=t;let ae=useCallback(()=>{if(!e||!I.current){T(null);return}let E=I.current.offsetParent;if(!E){T(null);return}let F=E.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-F.left)/t,top:(k.top-F.top)/t,width:k.width/t,height:k.height/t});},[e,t]);useEffect(()=>{ae();},[ae]),useEffect(()=>{if(!e)return;let E=I.current?.closest('[style*="overflow"]')??I.current?.closest(".paged-editor__container");if(!E)return;let F=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(ae);};return E.addEventListener("scroll",F,{passive:true}),window.addEventListener("resize",F,{passive:true}),()=>{E.removeEventListener("scroll",F),window.removeEventListener("resize",F),S.current&&cancelAnimationFrame(S.current);}},[e,ae]);let N=useCallback((E,F)=>{if(!e||!x)return;F.preventDefault(),F.stopPropagation();let k=x.width,P=x.height,M=F.clientX,H=F.clientY,oe=Math.round(k),Q=Math.round(P);c(true),m(oe),h(Q),A.current?.();let V=ne=>{let Se=re.current,Me=(ne.clientX-M)/Se,Z=(ne.clientY-H)/Se,ie=!ne.shiftKey,Ie=Ax(E,Me,Z,k,P,ie);oe=Math.round(Ie.width),Q=Math.round(Ie.height),m(oe),h(Q),T(He=>{if(!He)return He;let qe={...He};return E.includes("w")&&(qe.left=He.left+(He.width-Ie.width)),E.includes("n")&&(qe.top=He.top+(He.height-Ie.height)),qe.width=Ie.width,qe.height=Ie.height,qe});},Y=()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",Y),c(false);let ne=_.current;ne&&R.current?.(ne.pmPos,oe,Q),L.current?.();};window.addEventListener("mousemove",V),window.addEventListener("mouseup",Y);},[e,x]),D=useCallback(E=>{if(!e||!x)return;E.preventDefault(),E.stopPropagation();let F=4,k=E.clientX,P=E.clientY,M=false,H=null,oe=V=>{let Y=V.clientX-k,ne=V.clientY-P;!M&&Math.sqrt(Y*Y+ne*ne)<F||(M||(M=true,p(true),$.current?.(),H=document.createElement("div"),H.style.cssText="position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);",H.style.width=`${x.width}px`,H.style.height=`${x.height}px`,document.body.appendChild(H)),H&&(H.style.left=`${V.clientX-x.width/2}px`,H.style.top=`${V.clientY-x.height/2}px`));},Q=V=>{if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Q),H&&(H.remove(),H=null),p(false),M){let Y=_.current;Y&&pe.current?.(Y.pmPos,V.clientX,V.clientY),v.current?.();}};window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Q);},[e,x]);if(!!!(e&&x&&n))return jsx("div",{ref:I,style:{...gf,visibility:"hidden"},className:"image-selection-overlay"});let{left:ge,top:Pe,width:se,height:q}=x;return jsxs("div",{ref:I,style:gf,className:"image-selection-overlay",children:[jsx("div",{style:{...Ix,left:ge-Jr,top:Pe-Jr,width:se+Jr*2,height:q+Jr*2}}),jsx("div",{style:{position:"absolute",left:ge,top:Pe,width:se,height:q,cursor:d?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:D}),jsx(es,{handle:"nw",style:{left:ge-ro,top:Pe-ro},onMouseDown:N}),jsx(es,{handle:"ne",style:{left:ge+se-ro,top:Pe-ro},onMouseDown:N}),jsx(es,{handle:"se",style:{left:ge+se-ro,top:Pe+q-ro},onMouseDown:N}),jsx(es,{handle:"sw",style:{left:ge-ro,top:Pe+q-ro},onMouseDown:N}),u&&jsxs("div",{style:{...Lx,left:ge+se/2,top:Pe+q+12},children:[f," \xD7 ",b]})]})}function es({handle:e,style:t,onMouseDown:n}){return jsx("div",{style:{...Fx,...t,cursor:Bx[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var Dx="Calibri";function _l(e,t,n){if(!n||t<=n)return {width:e,height:t};let o=n/t;return {width:Math.round(e*o),height:n}}var Hx=11;function rt(e){return e/1440*96}var Nx=0;function ao(){return `block-${++Nx}`}function zx(e,t){let n=[];for(let o=0;o<=t;o+=1){let r=e[o]??0;if(r<=0)break;n.push(r);}return n.length===0?"1.":`${n.join(".")}.`}function ts(e,t){let n={};for(let o of e)switch(o.type.name){case "bold":n.bold=true;break;case "italic":n.italic=true;break;case "underline":{let r=o.attrs;if(r.style||r.color){let i=r.color?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 Ox(e,t,n){let o=[],r=t+1,i=n.theme;return e.forEach((a,s)=>{let l=r+s;if(a.isText&&a.text){let u=ts(a.marks,i),c={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let c={kind:"tab",...ts(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="image"){let u=a.attrs,c=_l(u.width||100,u.height||100,n.pageContentHeight),d={kind:"image",src:u.src,width:c.width,height:c.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="field"){let u=a.attrs.fieldType,d={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="math"){let c={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((c,d)=>{let p=u+d;if(c.isText&&c.text){let f=ts(c.marks,i),m={kind:"text",text:c.text,...f,pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+c.nodeSize};o.push(f);}else if(c.type.name==="tab"){let m={kind:"tab",...ts(c.marks,i),pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="image"){let f=c.attrs,m=_l(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+c.nodeSize};o.push(b);}});}}),o}function $x(e,t){let n={};if(e.alignment){let s=e.alignment;s==="both"||s==="distribute"?n.alignment="justify":s==="left"?n.alignment="left":s==="center"?n.alignment="center":s==="right"&&(n.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(n.spacing={},e.spaceBefore!=null&&(n.spacing.before=rt(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=rt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=rt(e.lineSpacing),n.spacing.lineUnit="px",n.spacing.lineRule=e.lineSpacingRule):(n.spacing.line=e.lineSpacing/240,n.spacing.lineUnit="multiplier",n.spacing.lineRule="auto")));let o=e.indentLeft,r=e.indentFirstLine,i=e.hangingIndent;if(e.numPr?.numId&&o==null&&(o=((e.numPr.ilvl??0)+1)*720,r==null&&(r=-360,i=true)),(o!=null||e.indentRight!=null||r!=null)&&(n.indent={},o!=null&&(n.indent.left=rt(o)),e.indentRight!=null&&(n.indent.right=rt(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(rt(r)):n.indent.firstLine=rt(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?ns(u,t):void 0;s.top&&(n.borders.top=l(s.top)),s.bottom&&(n.borders.bottom=l(s.bottom)),s.left&&(n.borders.left=l(s.left)),s.right&&(n.borders.right=l(s.right)),s.between&&(n.borders.between=l(s.between)),s.bar&&(n.borders.bar=l(s.bar)),!n.borders.top&&!n.borders.bottom&&!n.borders.left&&!n.borders.right&&!n.borders.between&&!n.borders.bar&&delete n.borders;}e.shading?.fill?.rgb&&(n.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(n.tabs=e.tabs.map(s=>({val:_x(s.alignment),pos:s.position,leader:s.leader}))),e.pageBreakBefore&&(n.pageBreakBefore=true),e.keepNext&&(n.keepNext=true),e.keepLines&&(n.keepLines=true),e.contextualSpacing&&(n.contextualSpacing=true),e.bidi&&(n.bidi=true),e.styleId&&(n.styleId=e.styleId),e.numPr&&(n.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(n.listMarker=e.listMarker),e.listIsBullet!=null&&(n.listIsBullet=e.listIsBullet),e.listMarkerHidden&&(n.listMarkerHidden=true),e.listMarkerFontFamily&&(n.listMarkerFontFamily=e.listMarkerFontFamily),e.listMarkerFontSize&&(n.listMarkerFontSize=e.listMarkerFontSize);let a=e.defaultTextFormatting;return a&&(a.fontSize!=null&&(n.defaultFontSize=a.fontSize/2),a.fontFamily&&(n.defaultFontFamily=a.fontFamily.ascii||a.fontFamily.hAnsi)),n}function _x(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function Wl(e,t,n){let o=e.attrs,r=Ox(e,t,n),i=$x(o,n.theme);return {kind:"paragraph",id:ao(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Wx(e){return Math.max(1,Math.round(e/8*1.333))}var Vx={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",wave:"solid",doubleWave:"double",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function ns(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Vx[e.style]||"solid",width:Wx(e.size??0),color:e.color?a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=g$1(e.space)),n}function Ux(e,t){let n=e.borders;if(!n)return;let o={},r=["top","bottom","left","right"];for(let i of r){let a=n[i],s=a?ns(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function jx(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Wl(l,r,n)):l.type.name==="table"&&o.push(xf(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?rt(a.top):0,right:a?.right!=null?rt(a.right):7,bottom:a?.bottom!=null?rt(a.bottom):0,left:a?.left!=null?rt(a.left):7};return {id:ao(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?rt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Ux(i,n.theme),padding:s}}function Kx(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(jx(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:ao(),cells:o,height:i.height?rt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function xf(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(Kx(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(rt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(h=>h.width);b.every(h=>h!==void 0&&h>0)&&(a=b);}let u=e.attrs.justification,c=e.attrs._originalFormatting,d=c?.indent?.value&&c.indent.type==="dxa"?rt(c.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?rt(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?rt(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?rt(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?rt(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?rt(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?rt(p.rightFromText):void 0}:void 0;return {kind:"table",id:ao(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:d,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function Gx(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=_l(o.width||100,o.height||100,n);return {kind:"image",id:ao(),src:o.src,width:a.width,height:a.height,alt:o.alt,transform:o.transform,anchor:i?{isAnchored:true,offsetH:o.distLeft,offsetV:o.distTop,behindDoc:r==="behind"}:void 0,hlinkHref:o.hlinkHref,pmStart:t,pmEnd:t+e.nodeSize}}function Yx(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=Wl(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:ao(),width:o.width??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 Sf(e,t={}){let n={...t,defaultFont:t.defaultFont??Dx,defaultSize:t.defaultSize??Hx},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=Wl(a,l,n),c=a.attrs;if(c.numPr&&!c.listMarker){let p=c.numPr.numId;if(p==null||p===0)break;let f=c.numPr.ilvl??0,m=i.get(p)??new Array(9).fill(0);m[f]=(m[f]??0)+1;for(let h=f+1;h<m.length;h+=1)m[h]=0;i.set(p,m);let b=c.listIsBullet?"\u2022":zx(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let d=c._sectionProperties;if(d||c.sectionBreakType){let p={kind:"sectionBreak",id:ao(),type:d?.sectionStart??c.sectionBreakType};if(d){(d.pageWidth||d.pageHeight)&&(p.pageSize={w:rt(d.pageWidth??12240),h:rt(d.pageHeight??15840)}),(d.marginTop!==void 0||d.marginLeft!==void 0)&&(p.margins={top:rt(d.marginTop??1440),bottom:rt(d.marginBottom??1440),left:rt(d.marginLeft??1440),right:rt(d.marginRight??1440)});let f=d.columnCount??1;if(f>1){let m={count:f,gap:rt(d.columnSpace??720),equalWidth:d.equalWidth??true,separator:d.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(xf(a,l,n));break;case "image":o.push(Gx(a,l,n.pageContentHeight));break;case "textBox":o.push(Yx(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:ao(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var _n=11,Qr="Calibri",os=1,lr=.5;function qx(e,t){if(t&&t.length>0)for(let o of t){let r=k$1(o.pos);if(r>e+.5)return Math.max(1,r-e)}let n=e%Vl;return Math.max(1,n<.5?Vl:Vl-n)}function Xx(e,t,n,o=false){let r=1,i=e.length,a=0;for(;r<=i;){let s=r+i>>>1;h$2(e.slice(0,s),t)<=n?(a=s,r=s+1):i=s-1;}return o&&a===0?1:a}function kf(e){return {fontFamily:e.fontFamily??Qr,fontSize:e.fontSize??_n,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function vf(e,t,n){let o=l$2(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.singleLineRatio??1.15,s=o*a,l;if(t?.lineRule==="exact"&&t.line!==void 0)l=t.line;else if(t?.lineRule==="atLeast"&&t.line!==void 0){let u=s*os;l=Math.max(t.line,u);}else t?.line!==void 0&&t?.lineUnit==="multiplier"?l=s*t.line:t?.line!==void 0&&t?.lineUnit==="px"?l=t.line:l=s*os;return {ascent:r,descent:i,lineHeight:l}}function Cf(e,t,n){let o=g$2({fontSize:e,fontFamily:n??Qr});return vf(e,t,o)}function Tf(e){return e.kind==="text"}function Zx(e){return e.kind==="tab"}function Jx(e){return e.kind==="image"}function Qx(e){return e.kind==="lineBreak"}function eS(e){return e.kind==="field"}function tS(e){return !e.text||e.text.length===0}function nS(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];(o===" "||o==="-"||o===" ")&&t.push(n+1);}return t}var Vl=48;function wf(e,t,n,o){if(!n||n.length===0)return {leftMargin:0,rightMargin:0};let r=0,i=0,a=o+e,s=a+t;for(let l of n)s>l.topY&&a<l.bottomY&&(r=Math.max(r,l.leftMargin),i=Math.max(i,l.rightMargin));return {leftMargin:r,rightMargin:i}}function In(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,c=l?.right??0,d=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-c),f=Math.max(1,p-d),m=0,b=l$2(_n)*os,h=wf(0,b,a,s),x=Math.max(1,f-h.leftMargin-h.rightMargin),T=[];if(o.length===0){let $=r?.defaultFontSize??_n,v=r?.defaultFontFamily??Qr,_=Cf($,i,v);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,..._}),{kind:"paragraph",lines:T,totalHeight:_.lineHeight}}if(o.length===1&&Tf(o[0])&&tS(o[0])){let $=o[0],v=$.fontSize??r?.defaultFontSize??_n,_=$.fontFamily??r?.defaultFontFamily??Qr,re=Cf(v,i,_);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...re}),{kind:"paragraph",lines:T,totalHeight:re.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:h.leftMargin,rightOffset:h.rightMargin},I=()=>{let $=vf(S.maxFontSize,i,S.maxFontMetrics),v={...$};S.maxImageHeightPx>v.lineHeight&&(v.lineHeight=S.maxImageHeightPx,v.ascent=S.maxImageHeightPx*.8,v.descent=S.maxImageHeightPx*.2);let _={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...v};S.leftOffset>0&&(_.leftOffset=S.leftOffset),S.rightOffset>0&&(_.rightOffset=S.rightOffset),T.push(_),m+=$.lineHeight;},R=($,v)=>{I();let _=l$2(_n)*os,re=wf(m,_,a,s),ae=Math.max(1,p-re.leftMargin-re.rightMargin);S={fromRun:$,fromChar:v,toRun:$,toChar:v,width:0,maxFontSize:_n,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:ae,leftOffset:re.leftMargin,rightOffset:re.rightMargin};},A=$=>{let v=$.fontSize??_n;(!S.maxFontMetrics||v>S.maxFontSize)&&(S.maxFontSize=v,S.maxFontMetrics=g$2($));};for(let $=0;$<o.length;$++){let v=o[$];if(Qx(v)){S.toRun=$,S.toChar=0,R($+1,0);continue}if(Zx(v)){let _=kf(v);A(_);let re=r?.tabs,ae=S.width+(S.leftOffset??0),N=qx(ae,re);S.width+N>S.availableWidth+lr&&(R($,0),A(_)),S.width+=N,S.toRun=$,S.toChar=1;continue}if(Jx(v)){let _=v.wrapType,re=v.displayMode==="float"||_&&["square","tight","through"].includes(_);if(v.position&&re){S.toRun=$,S.toChar=1;continue}if(_==="topAndBottom"||v.displayMode==="block"){S.width>0&&R($,0);let D=v.height,de=v.distTop??6,ge=v.distBottom??6;S.toRun=$,S.toChar=1,S.maxImageHeightPx=D+de+ge,R($+1,0);continue}let ae=v.width,N=v.height;N>S.maxImageHeightPx&&(S.maxImageHeightPx=N),S.width+ae>S.availableWidth+lr&&R($,0),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(eS(v)){let _=v.fallback||"1",re={fontFamily:v.fontFamily??Qr,fontSize:v.fontSize??_n,bold:v.bold,italic:v.italic};A(re);let ae=h$2(_,re);S.width>0&&S.width+ae>S.availableWidth+lr&&(R($,0),A(re)),S.width+=ae,S.toRun=$,S.toChar=1;continue}if(Tf(v)){let _=v,re=_.text,ae=kf(_);if(A(ae),!re||re.length===0){S.toRun=$,S.toChar=0;continue}let N=nS(re),D=0;for(;D<re.length;){let de=re.length;for(let se of N)if(se>D){de=se;break}let ge=re.slice(D,de),Pe=h$2(ge,ae);if(Pe>S.availableWidth+lr){let se=0;for(;se<ge.length;){let q=S.availableWidth-S.width+lr,E=ge.slice(se),F=Xx(E,ae,q);if(F===0){if(S.width>0){R($,D+se),A(ae);continue}F=1;}let k=se+F,P=ge.slice(se,k),M=h$2(P,ae);S.width+=M,S.toRun=$,S.toChar=D+k,se=k,se<ge.length&&(R($,D+se),A(ae));}D=de;continue}S.width>0&&S.width+Pe>S.availableWidth+lr&&(R($,D),A(ae)),S.width+=Pe,S.toRun=$,S.toChar=de,D=de;}}}I();let pe=T.reduce(($,v)=>$+v.lineHeight,0);return i?.before&&(pe+=i.before),i?.after&&(pe+=i.after),{kind:"paragraph",lines:T,totalHeight:pe}}var oS=new Map;function Rf(){oS.clear();}var rS=new Map;function Ef(){rS.clear();}var iS=5e3,aS=iS,so=new Map;function Ul(e){let t=[];for(let o of e.runs)o.kind==="text"?t.push(`t:${o.text}|${o.fontFamily}|${o.fontSize}|${o.bold}|${o.italic}`):o.kind==="tab"?t.push(`tab:${o.width}`):o.kind==="image"?t.push(`img:${o.width}x${o.height}`):o.kind==="lineBreak"&&t.push("br");let n=e.attrs;return n&&(n.alignment&&t.push(`align:${n.alignment}`),n.indent&&t.push(`indent:${n.indent.left}|${n.indent.right}|${n.indent.firstLine}|${n.indent.hanging}`),n.spacing&&t.push(`spacing:${n.spacing.before}|${n.spacing.after}|${n.spacing.line}|${n.spacing.lineRule}`)),t.join("||")}function sS(){for(;so.size>aS;){let e=so.keys().next().value;if(e===void 0)break;so.delete(e);}}function jl(e,t){let n=Ul(e),o=so.get(n);if(o!==void 0&&o.maxWidth===t)return so.delete(n),so.set(n,o),o.measure}function Kl(e,t,n){let o=Ul(e);so.set(o,{measure:n,maxWidth:t}),sS();}function Pf(){so.clear();}function Gl(){Rf(),Ef(),Pf();}function lS(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function cS(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,c=i.slice(l,u);c.length>0&&n.push({...r,text:c});}else n.push(r);}}}return n}function dS(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",c=s===t.fromRun?t.fromChar:0,d=s===t.toRun?t.toChar:u.length;a+=d-c;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function uS(e,t,n,o){let r=0;for(let i=n;i<o&&i<e.lines.length;i++){let s=e.lines[i].lineHeight;if(t>=r&&t<r+s)return i;r+=s;}return o>n?Math.min(o-1,e.lines.length-1):null}function pS(e,t,n,o){let{pmStart:r,pmEnd:i}=dS(e,t);if(r===void 0||i===void 0)return {charOffset:0,pmPosition:e.pmStart??0};let a=e.attrs?.alignment??"left",s=0;a==="center"?s=Math.max(0,(o-t.width)/2):a==="right"&&(s=Math.max(0,o-t.width));let l=Math.max(0,n-s);if(l<=0)return {charOffset:0,pmPosition:r};let u=cS(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let c=0,d=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="image"){let m=f.width,b=c+m;if(l<=b){let h=c+m/2;return l<h?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="lineBreak"){if(l>=c)return {charOffset:d,pmPosition:r+d};d+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=lS(f),h=i$2(m,b),x=c+h.width;if(l<=x){let T=l-c,S=j$2(T,h.charWidths),I=d+S;return {charOffset:I,pmPosition:r+I}}c=x,d+=m.length;}}return {charOffset:i-r,pmPosition:i}}function Mf(e){let{fragment:t,block:n,measure:o,localX:r,localY:i}=e;if(t.kind!=="paragraph"||n.kind!=="paragraph"||o.kind!=="paragraph")return null;let a=t,s=n,l=o,u=uS(l,i,a.fromLine,a.toLine);if(u===null)return null;let c=l.lines[u];if(!c)return null;let d=0;for(let S=a.fromLine;S<u;S++)d+=l.lines[S]?.lineHeight??0;let p=s.attrs?.indent,f=p?.left??0,m=p?.right??0,b=Math.max(0,t.width-f-m),h=r-f,{charOffset:x,pmPosition:T}=pS(s,c,h,b);return {pmPosition:T,charOffset:x,lineIndex:u}}function fS(e){let{cellBlock:t,cellMeasure:n,cellLocalX:o,cellLocalY:r}=e;if(!t||!n)return null;let i={fragment:{kind:"paragraph",blockId:t.id,x:0,y:0,width:n.lines.reduce((s,l)=>Math.max(s,l.width),100),fromLine:0,toLine:n.lines.length,height:n.totalHeight},block:t,measure:n,pageIndex:e.pageIndex,localX:o,localY:r};return Mf(i)?.pmPosition??null}function Yl(e,t){if(t)return fS(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?Mf(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Ff(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(c=>c.classList.contains("layout-page"));if(!i)return null;let a=r.find(c=>c.tagName==="SPAN"&&c.dataset.pmStart!==void 0&&c.dataset.pmEnd!==void 0);if(a)return ql(a,t);let s=r.find(c=>c.classList.contains("layout-empty-run"));if(s){let c=s.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let l=r.find(c=>c.classList.contains("layout-paragraph")&&c.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let c=If(l,t,n);return c!==null?c:Number(l.dataset.pmStart)}let u=r.find(c=>c.classList.contains("layout-table-cell"));return u?If(u,t,n):mS(e,i,t,n)}function ql(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let d=e.getBoundingClientRect(),p=(d.left+d.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,c=s;for(;u<c;){let d=Math.floor((u+c)/2),p=l.createRange();p.setStart(a,d),p.setEnd(a,d);let m=p.getBoundingClientRect().left;t<m?c=d:u=d+1;}if(u>0&&u<=s){let d=l.createRange();d.setStart(a,u-1),d.setEnd(a,u-1);let p=d.getBoundingClientRect();d.setStart(a,Math.min(u,s)),d.setEnd(a,Math.min(u,s));let f=d.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(u-1)}return o+Math.min(u,r-o)}function If(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let d=o.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let d of Array.from(r)){let p=d,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let d=e.querySelector(".layout-paragraph[data-pm-start]");return d?.dataset.pmStart?Number(d.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let d=i.closest(".layout-paragraph");return d?.dataset.pmStart?Number(d.dataset.pmStart):null}let l=null,u=1/0;for(let d of Array.from(s)){let p=d,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return ql(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let c=l.getBoundingClientRect();return t<c.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function mS(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let f=t.querySelectorAll(".layout-paragraph");if(f.length>0){let m=f[0];return Number(m.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let f of Array.from(a)){let m=f,b=m.getBoundingClientRect(),h=(b.top+b.bottom)/2,x=Math.abs(o-h);x<l&&(l=x,s=m);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return ql(m,n);let h=n<b.left?b.left-n:n-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return n<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)}var lo={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function gS(e){return e.kind==="paragraph"}function hS(e){return e.kind==="table"}function bS(e){return e.kind==="image"}function rs(e){e.style.position="absolute",e.style.overflow="hidden";}function yS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.paragraph}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromLine=String(e.fromLine),o.dataset.toLine=String(e.toLine),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.continuesFromPrev&&(o.dataset.continuesFromPrev="true"),e.continuesOnNext&&(o.dataset.continuesOnNext="true"),o}function xS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.table}`,rs(o),o.dataset.blockId=String(e.blockId),o.dataset.fromRow=String(e.fromRow),o.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),o}function SS(e,t,n){let o=n.createElement("div");return o.className=`${lo.fragment} ${lo.image}`,rs(o),o.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.isAnchored&&(o.dataset.anchored="true"),e.zIndex!==void 0&&(o.style.zIndex=String(e.zIndex)),o}function ei(e,t,n={}){let o=n.document??document;if(gS(e))return yS(e,t,o);if(hS(e))return xS(e,t,o);if(bS(e))return SS(e,t,o);let r=o.createElement("div");r.className=lo.fragment,rs(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function Xl(e){return e/1440*96}function kS(e){return e/96*1440}function CS(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(d=>d.val!=="clear").filter(d=>d.pos>=o),i=t.filter(d=>d.val==="clear").map(d=>d.pos),a=r.reduce((d,p)=>Math.max(d,p.pos),0),s=[...r];o>0&&!r.some(d=>d.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,c=o+14400;for(;u<c;){u+=n;let d=r.some(m=>Math.abs(m.pos-u)<20),p=i.some(m=>Math.abs(m-u)<20),f=o>0&&Math.abs(u-o)<20;!d&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((d,p)=>d.pos-p.pos)}function Lf(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=kS(e),l=CS(t).find(d=>d.pos>a);if(!l){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}let c=Xl(l.pos)-e;if(l.val==="center"||l.val==="end"){let d=o?o(n):0;l.val==="center"?c-=d/2:c-=d;}else if(l.val==="decimal"){let d=n.indexOf(r);if(d>=0&&o){let p=n.slice(0,d),f=o(p);c-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(c<1){let d=Xl(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}return {width:c,leader:l.leader,alignment:l.val}}var rn={fragment:"layout-paragraph",line:"layout-line",run:"layout-run",text:"layout-run-text",tab:"layout-run-tab",image:"layout-run-image",lineBreak:"layout-run-linebreak"};function ni(e){return e.kind==="text"}function is(e){return e.kind==="tab"}function Df(e){return e.kind==="image"}function Zl(e){return e.kind==="lineBreak"}function Jl(e){return e.kind==="field"}function TS(e,t,n){if(t.fontFamily&&(e.style.fontFamily=a$5(t.fontFamily).cssFallback),t.fontSize){let r=t.fontSize*96/72;e.style.fontSize=`${r}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let o=[];if(t.underline&&(o.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&o.push("line-through"),t.commentIds&&t.commentIds.length>0){let r=t.commentIds.find(i=>!n||!n.has(i));r!=null&&(e.style.backgroundColor="rgba(255, 212, 0, 0.15)",e.style.borderBottom="1px solid rgba(255, 212, 0, 0.4)",e.dataset.commentId=String(r));}t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",o.includes("line-through")||o.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),o.length>0&&(e.style.textDecorationLine=o.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function cr(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Ql(e,t,n){let o=t.createElement("span");if(o.className=`${rn.run} ${rn.text}`,TS(o,e,n),cr(o,e.pmStart,e.pmEnd),e.hyperlink){let r=t.createElement("a");r.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(r.target="_blank",r.rel="noopener noreferrer"),e.hyperlink.tooltip&&(r.title=e.hyperlink.tooltip),r.textContent=e.text;let i=e.color||"#0563c1";r.style.color=i,r.style.textDecoration="underline",o.style.color=i,o.appendChild(r);}else o.textContent=e.text;return o}function Hf(e,t,n,o){let r=t.createElement("span");if(r.className=`${rn.run} ${rn.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",cr(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=wS(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 wS(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function vS(e,t){let n=t.createElement("img");return n.className=`${rn.run} ${rn.image}`,n.src=e.src,n.width=e.width,n.height=e.height,e.alt&&(n.alt=e.alt),e.transform&&(n.style.transform=e.transform),n.style.display="inline",n.style.verticalAlign="middle",cr(n,e.pmStart,e.pmEnd),n}function Bf(e,t){let n=t.createElement("div");n.className="layout-block-image",n.style.display="block",n.style.textAlign="center",n.style.marginTop=`${e.distTop??6}px`,n.style.marginBottom=`${e.distBottom??6}px`;let o=t.createElement("img");return o.src=e.src,o.width=e.width,o.height=e.height,o.style.marginLeft="auto",o.style.marginRight="auto",e.alt&&(o.alt=e.alt),e.transform&&(o.style.transform=e.transform),cr(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function Nf(e,t){return dr(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?Bf(e,t):vS(e,t)}function zf(e,t){let n=t.createElement("br");return n.className=`${rn.run} ${rn.lineBreak}`,cr(n,e.pmStart,e.pmEnd),n}function Of(e,t,n){let o=e.fallback??"";switch(e.fieldType){case "PAGE":o=String(n.pageNumber);break;case "NUMPAGES":o=String(n.totalPages);break;case "DATE":o=new Date().toLocaleDateString();break;case "TIME":o=new Date().toLocaleTimeString();break}let r={text:o,bold:e.bold,italic:e.italic,underline:e.underline,strike:e.strike,color:e.color,highlight:e.highlight,fontFamily:e.fontFamily,fontSize:e.fontSize,pmStart:e.pmStart,pmEnd:e.pmEnd};return Ql(r,t,n?.resolvedCommentIds)}function RS(e,t,n){if(ni(e))return Ql(e,t,n?.resolvedCommentIds);if(is(e))return Hf(e,t,48,void 0);if(Df(e))return Nf(e,t);if(Zl(e))return zf(e,t);if(Jl(e)&&n)return Of(e,t,n);let o=t.createElement("span");return o.className=rn.run,o}function $f(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(ni(i)){let a=r===t.fromRun?t.fromChar:0,s=r===t.toRun?t.toChar:i.text.length;if(a>0||s<i.text.length){let l=i.text.slice(a,s);n.push({...i,text:l,pmStart:i.pmStart!==void 0?i.pmStart+a:void 0,pmEnd:i.pmStart!==void 0?i.pmStart+s:void 0});}else n.push(i);}else n.push(i);}return n}function ES(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function PS(e){return {val:e.val,pos:e.pos,leader:e.leader}}function MS(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(ni(i))o+=i.text;else if(Jl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(is(i)||Zl(i))break}return o}function IS(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=a$5(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function _f(e,t,n,o,r){let i=o.createElement("div");i.className=rn.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=$f(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${rn.run} layout-empty-run`,b.innerHTML="&nbsp;",i.appendChild(b),i}let s=n==="justify",l=false;s&&r&&(l=!r.isLastLine||r.paragraphEndsWithLineBreak,l&&(i.style.textAlign="justify",i.style.textAlignLast="justify",i.style.width=`${r.availableWidth}px`)),i.style.whiteSpace="pre";let u=a.some(b=>ni(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let c=a.some(is),d,p=IS(o);if(c){let b=r?.tabStops?.map(PS),h=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;d={explicitStops:b,leftIndent:h};}let f=0,m=r?.leftIndentPx??0;if(r?.isFirstLine){let b=r?.firstLineIndentPx??0;f=m+b;}else f=m;for(let b=0;b<a.length;b++){let h=a[b];if(is(h)&&d){let x=MS(a,b,r?.context),T=Lf(f,d,x,p),S=Hf(h,o,T.width,T.leader);i.appendChild(S),f+=T.width;}else if(ni(h)){let x=Ql(h,o,r?.context?.resolvedCommentIds);if(h.highlight){let R=(h.fontSize?h.fontSize*96/72:14.67)*1.2,A=Math.max(0,t.lineHeight-R);if(A>0){let L=A/2;x.style.paddingTop=`${L}px`,x.style.paddingBottom=`${L}px`;}}i.appendChild(x);let T=h.fontSize||11,S=h.fontFamily||"Calibri";f+=p(h.text,T,S);}else if(Df(h)){if(dr(h))continue;let x=ES(h);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let T=Nf(h,o);i.appendChild(T),h.displayMode!=="block"&&h.wrapType!=="topAndBottom"&&(f+=h.width);}else if(Zl(h)){let x=zf(h,o);i.appendChild(x);}else if(Jl(h)&&r?.context){let x=Of(h,o,r.context);i.appendChild(x);let T=h.fallback??"";h.fieldType==="PAGE"?T=String(r.context.pageNumber):h.fieldType==="NUMPAGES"&&(T=String(r.context.totalPages));let S=h.fontSize||11,I=h.fontFamily||"Calibri";f+=p(T,S,I);}else {let x=RS(h,o,r?.context);i.appendChild(x);}}return i}function ti(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function Af(e,t){return !e&&!t||!e||!t?false:ti(e.top,t.top)&&ti(e.bottom,t.bottom)&&ti(e.left,t.left)&&ti(e.right,t.right)&&ti(e.between,t.between)}function Wn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=rn.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),cr(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId);let u=t.attrs?.bidi;u&&(a.dir="rtl"),l?l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":l==="left"?a.style.textAlign="left":a.style.textAlign=u?"right":"left":u&&(a.style.textAlign="right");let c=t.attrs?.indent,d=0,p=0;c&&(u?(c.left&&c.left>0&&(p=c.left),c.right&&c.right>0&&(d=c.right)):(c.left&&c.left>0&&(d=c.left),c.right&&c.right>0&&(p=c.right)));let f=t.attrs?.borders;if(f){let R=v=>{switch(v){case "single":return "solid";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "thick":return "solid";case "wave":return "wavy";case "dashSmallGap":return "dashed";case "nil":case "none":return "none";default:return "solid"}};a.style.boxSizing="border-box";let A=v=>`${v.width}px ${R(v.style)} ${v.color}`,L=Af(r.prevBorders,f),pe=Af(f,r.nextBorders);if(L&&f.between?a.style.borderTop=A(f.between):f.top&&!L&&(a.style.borderTop=A(f.top)),f.bottom&&!pe&&(a.style.borderBottom=A(f.bottom)),f.left&&(a.style.borderLeft=A(f.left)),f.right&&(a.style.borderRight=A(f.right)),f.bar){let v=i.createElement("div");v.style.position="absolute",v.style.left="-8px",v.style.top="0",v.style.bottom="0",v.style.borderLeft=A(f.bar),a.style.position="relative",a.appendChild(v);}if(f.top||f.bottom||f.left||f.right||f.between){let v=f.top||f.between;a.style.paddingLeft=f.left?`${f.left.space??4}px`:"0",a.style.paddingRight=f.right?`${f.right.space??4}px`:"0",a.style.paddingTop=v?`${v.space??2}px`:"0",a.style.paddingBottom=f.bottom?`${f.bottom.space??6}px`:"0";}}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let m=e.width-d-p,h=t.runs[t.runs.length-1]?.kind==="lineBreak",x=n.lines.length,T=0;c?.hanging&&c.hanging>0?T=-c.hanging:c?.firstLine&&c.firstLine>0&&(T=c.firstLine);let S=0,I=r.renderedInlineImageKeys??new Set;for(let R=0;R<s.length;R++){let A=s[R],L=e.fromLine+R,pe=L===x-1,$=L===0&&!e.continuesFromPrev,v=A.leftOffset??0,_=A.rightOffset??0,re=m;if($){let de=c?.hanging&&c.hanging>0,ge=c?.firstLine&&c.firstLine>0;de&&c?.hanging?re=m+c.hanging:ge&&c?.firstLine&&(re=m-c.firstLine);}let ae=_f(t,A,l,i,{availableWidth:re-v-_,isLastLine:pe,isFirstLine:$,paragraphEndsWithLineBreak:h,tabStops:t.attrs?.tabs,leftIndentPx:d,firstLineIndentPx:$?T:0,context:o,renderedInlineImageKeys:I});if(v>0||_>0){v>0&&(ae.style.marginLeft=`${v}px`),_>0&&(ae.style.marginRight=`${_}px`);let de=re-v-_;de>0&&(ae.style.width=`${de}px`);}S+=A.lineHeight;let N=c?.hanging&&c.hanging>0,D=c?.firstLine&&c.firstLine>0;if($?d>0&&N?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`-${c.hanging}px`):d>0&&D?(ae.style.paddingLeft=`${d}px`,ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:D&&(ae.style.textIndent=`${c.firstLine}px`):d>0?ae.style.paddingLeft=`${d}px`:N&&(ae.style.paddingLeft=`${c.hanging}px`),p>0&&(ae.style.paddingRight=`${p}px`),$&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let de=Math.max(0,d-(c?.hanging??0));ae.style.paddingLeft=`${de}px`,ae.style.textIndent="0";let ge;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let E=A.fromRun;E<=A.toRun;E++){let F=t.runs[E];if(F&&F.kind==="text"){ge=F;break}}let Pe=t.attrs.listMarkerFontFamily??ge?.fontFamily??t.attrs.defaultFontFamily,se=t.attrs.listMarkerFontSize??ge?.fontSize??t.attrs.defaultFontSize,q=FS(t.attrs.listMarker,c,i,Pe,se);ae.insertBefore(q,ae.firstChild);}a.appendChild(ae);}return a}function FS(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$5(o).cssFallback),r){let s=r*96/72;i.style.fontSize=`${s}px`;}i.textContent=e;let a=t?.hanging??24;return i.style.minWidth=`${a}px`,i.style.textAlign="left",i.style.boxSizing="border-box",i}var Fn={table:"layout-table",row:"layout-table-row",cell:"layout-table-cell",cellContent:"layout-table-cell-content",resizeHandle:"layout-table-resize-handle",rowResizeHandle:"layout-table-row-resize-handle",tableEdgeHandleBottom:"layout-table-edge-handle-bottom",tableEdgeHandleRight:"layout-table-edge-handle-right"};function LS(e,t,n){let o=[],r=0;for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i];if(a?.kind!=="paragraph"){let u=t.blocks[i];u&&u.kind==="table"&&(r+=u.totalHeight??0);continue}let s=a;for(let u of s.runs){if(u.kind!=="image")continue;let c=u;if(!dr(c))continue;let d=c.position,p=c.distTop??0,f=c.distBottom??0,m=c.distLeft??12,b=c.distRight??12,h="left",x=0;if(d?.horizontal){let I=d.horizontal;I.align==="right"?(h="right",x=n-c.width):I.align==="left"?x=0:I.align==="center"?x=(n-c.width)/2:I.posOffset!==void 0&&(x=co(I.posOffset),h=x>n/2?"right":"left");}else c.cssFloat==="right"&&(h="right",x=n-c.width);let T=r;if(d?.vertical){let I=d.vertical;I.posOffset!==void 0?T=r+co(I.posOffset):I.align==="top"&&(T=0);}x=Math.max(0,Math.min(x,n-c.width));let S="bothSides";c.cssFloat==="left"?S="right":c.cssFloat==="right"&&(S="left"),o.push({src:c.src,width:c.width,height:c.height,alt:c.alt,transform:c.transform,x,y:T,side:h,distTop:p,distBottom:f,distLeft:m,distRight:b,wrapText:S,pmStart:c.pmStart,pmEnd:c.pmEnd});}let l=t.blocks[i];l&&l.kind==="paragraph"&&(r+=l.totalHeight);}return o}function BS(e,t,n,o){let r=o.createElement("div");r.className=Fn.cellContent,r.style.position="relative";let i=e.padding?.left??7,a=e.padding?.right??7,s=Math.max(0,t.width-i-a);r.style.width=`${s}px`;let l=LS(e,t,s),u;if(l.length>0){u=l.map(p=>{let f=p.x+p.width+p.distRight,m=p.y-p.distTop,b=p.y+p.height+p.distBottom,h=0,x=0,T=p.wrapText??"bothSides";return T==="right"?h=f:T==="left"?x=s-(p.x-p.distLeft):p.side==="left"?h=f:x=s-(p.x-p.distLeft),{leftMargin:h,rightMargin:x,topY:m,bottomY:b}});let d=o.createElement("div");d.className="layout-cell-floating-images-layer",d.style.position="absolute",d.style.top="0",d.style.left="0",d.style.width="100%",d.style.height="100%",d.style.pointerEvents="none",d.style.zIndex="10",d.style.overflow="hidden";for(let p of l){let f=o.createElement("div");f.className="layout-cell-floating-image",f.style.position="absolute",f.style.left=`${p.x}px`,f.style.top=`${p.y}px`,f.style.pointerEvents="auto",p.pmStart!==void 0&&(f.dataset.pmStart=String(p.pmStart)),p.pmEnd!==void 0&&(f.dataset.pmEnd=String(p.pmEnd));let m=o.createElement("img");m.src=p.src,m.style.width=`${p.width}px`,m.style.height=`${p.height}px`,m.style.display="block",p.alt&&(m.alt=p.alt),p.transform&&(m.style.transform=p.transform),f.appendChild(m),d.appendChild(f);}r.appendChild(d);}let c=0;for(let d=0;d<e.blocks.length;d++){let p=e.blocks[d],f=t.blocks[d];if(p?.kind==="paragraph"&&f?.kind==="paragraph"){let m=p,b=f;u&&u.length>0&&(b=In(m,s,{floatingZones:u,paragraphYOffset:c}));let h={blockId:m.id,width:s,height:b.totalHeight,fromLine:0,toLine:b.lines.length,pmStart:m.pmStart,pmEnd:m.pmEnd},x={...n,insideTableCell:true},T=Wn(h,m,b,x,{document:o});T.style.position="relative",r.appendChild(T),c+=b.totalHeight;}else if(p?.kind==="table"&&f?.kind==="table"){let h=AS(p,f,n,o);h.style.position="relative",r.appendChild(h),c+=f.totalHeight??0;}}return r}function AS(e,t,n,o){let r=o.createElement("div");r.className=`${Fn.table} layout-nested-table`,r.style.position="relative",r.style.width=`${t.totalWidth}px`,r.style.display="block",e.justification==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):e.justification==="right"?r.style.marginLeft="auto":e.indent&&(r.style.marginLeft=`${e.indent}px`),r.dataset.blockId=String(e.id),e.pmStart!==void 0&&(r.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(r.dataset.pmEnd=String(e.pmEnd));let i=[],a=0;for(let u=0;u<t.rows.length;u++)i.push(a),a+=t.rows[u]?.height??0;i.push(a);let s=new Map,l=0;for(let u=0;u<e.rows.length;u++){let c=e.rows[u],d=t.rows[u];if(!c||!d)continue;let p=ec(c,d,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=d.height;}return r.style.height=`${l}px`,r}function as(e,t,n){let o=`border${t.charAt(0).toUpperCase()+t.slice(1)}`;if(!n||n.style==="none"||n.style==="nil"||n.width===0)e.style[o]="none";else {let r=n.width??1,i=n.color??"#000000",a=n.style??"solid";e.style[o]=`${r}px ${a} ${i}`;}}function DS(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Fn.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,c=e.padding?.bottom??1,d=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${c}px ${d}px`,e.borders&&(r.isFirstRow&&as(s,"top",e.borders.top),as(s,"right",e.borders.right),as(s,"bottom",e.borders.bottom),r.isFirstCol&&as(s,"left",e.borders.left)),e.background&&(s.style.backgroundColor=e.background),e.verticalAlign)switch(s.style.display="flex",s.style.flexDirection="column",e.verticalAlign){case "top":s.style.justifyContent="flex-start";break;case "center":s.style.justifyContent="center";break;case "bottom":s.style.justifyContent="flex-end";break}let p=BS(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let f=e.blocks[0],m=e.blocks[e.blocks.length-1];f&&"pmStart"in f&&f.pmStart!==void 0&&(s.dataset.pmStart=String(f.pmStart)),m&&"pmEnd"in m&&m.pmEnd!==void 0&&(s.dataset.pmEnd=String(m.pmEnd));}return s}function ec(e,t,n,o,r,i,a,s,l,u,c){let d=s.createElement("div");d.className=Fn.row,d.style.position="absolute",d.style.left="0",d.style.top=`${o}px`,d.style.width="100%",d.style.height=`${t.height}px`,d.dataset.rowIndex=String(n);let p=new Set;if(l){for(let[,b]of l)if(b.startRow<n&&b.startRow+b.rowSpan>n)for(let h=0;h<b.colSpan;h++)p.add(b.columnIndex+h);}let f=0,m=0;for(;p.has(m);)f+=r[m]??0,m++;for(let b=0;b<e.cells.length;b++){let h=e.cells[b],x=t.cells[b];if(!h||!x)continue;let T=h.colSpan??1,S=h.rowSpan??1,I=t.height;if(S>1&&u){I=0;for(let v=n;v<n+S&&v<u.length-1;v++)I+=(u[v+1]??0)-(u[v]??0);I===0&&(I=t.height*S);}let R=n===0||c===true,L=m===0;m+T>=r.length;let $=DS(h,x,f,I,{isFirstRow:R,isFirstCol:L},a,s);if($.dataset.cellIndex=String(b),$.dataset.columnIndex=String(m),S>1&&($.dataset.rowSpan=String(S)),d.appendChild($),S>1&&l){let v=`${n}-${m}`;l.set(v,{cell:h,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:T,x:f,totalHeight:I});}for(let v=0;v<T&&m+v<r.length;v++)f+=r[m+v]??0;for(m+=T;p.has(m);)f+=r[m]??0,m++;}return d}function ss(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Fn.table,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.dataset.blockId=String(e.blockId),a.dataset.fromRow=String(e.fromRow),a.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=0;for(let m=0;m<n.columnWidths.length-1;m++){s+=n.columnWidths[m]??0;let b=i.createElement("div");b.className=Fn.resizeHandle,b.style.position="absolute",b.style.left=`${s-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}let l=[],u=0;for(let m=0;m<n.rows.length;m++)l.push(u),u+=n.rows[m]?.height??0;l.push(u);let c=new Map,d=e.headerRowCount??0,p=0;if(d>0&&e.continuesFromPrev)for(let m=0;m<d;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,m===0);x.dataset.repeatedHeader="true",a.appendChild(x),p+=h.height;}for(let m=e.fromRow;m<e.toRow;m++){let b=t.rows[m],h=n.rows[m];if(!b||!h)continue;let x=d>0&&e.continuesFromPrev?false:e.continuesFromPrev&&m===e.fromRow,T=ec(b,h,m,p,n.columnWidths,t.rows.length,o,i,c,l,x);a.appendChild(T),p+=h.height;}let f=0;for(let m=e.fromRow;m<e.toRow;m++)if(f+=n.rows[m]?.height??0,m<e.toRow-1){let b=i.createElement("div");b.className=Fn.rowResizeHandle,b.style.position="absolute",b.style.left="0",b.style.top=`${f-3}px`,b.style.width="100%",b.style.height="6px",b.style.cursor="row-resize",b.style.zIndex="10",b.dataset.rowIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}if(e.toRow===t.rows.length){let m=i.createElement("div");m.className=Fn.tableEdgeHandleBottom,m.style.position="absolute",m.style.left="0",m.style.top=`${f-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(t.rows.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="bottom",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let m=n.columnWidths.reduce((h,x)=>h+x,0),b=i.createElement("div");b.className=Fn.tableEdgeHandleRight,b.style.position="absolute",b.style.left=`${m-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(n.columnWidths.length-1),b.dataset.tableBlockId=String(e.blockId),b.dataset.isEdge="right",e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}return a}var tc={image:"layout-image",imageAnchored:"layout-image-anchored"};function ls(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=tc.image,e.isAnchored&&a.classList.add(tc.imageAnchored),a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",e.zIndex!==void 0&&(a.style.zIndex=String(e.zIndex)),t.anchor?.behindDoc&&(a.style.zIndex="-1"),a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=i.createElement("img");if(s.src=t.src,s.alt=t.alt??"",s.style.width="100%",s.style.height="100%",s.style.objectFit="contain",s.style.display="block",t.transform&&(s.style.transform=t.transform),s.draggable=false,t.hlinkHref){let l=i.createElement("a");l.href=t.hlinkHref,l.target="_blank",l.rel="noopener noreferrer",l.style.display="block",l.style.width="100%",l.style.height="100%",l.appendChild(s),a.appendChild(l);}else a.appendChild(s);return a}var Wf={textBox:"layout-textbox"};function cs(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=Wf.textBox,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.style.boxSizing="border-box",t.fillColor&&(a.style.backgroundColor=t.fillColor),t.outlineWidth&&t.outlineWidth>0){let c=t.outlineStyle||"solid",d=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${c} ${d}`;}let s=t.margins??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 c=0;c<t.content.length;c++){let d=t.content[c],p=n.innerMeasures[c];if(!p)continue;let f={blockId:d.id,width:l,height:p.totalHeight,pmStart:d.pmStart,pmEnd:d.pmEnd,fromLine:0,toLine:p.lines.length},m=Wn(f,d,p,o,{document:i});m.style.position="relative",m.style.left="0",m.style.top="0",a.appendChild(m),u+=p.totalHeight;}return a}var uo={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function us(e,t,n,o){if(e.style.position="relative",e.style.width=`${t}px`,e.style.height=`${n}px`,e.style.backgroundColor=o.backgroundColor??"#ffffff",e.style.overflow="hidden",e.style.fontFamily='Calibri, "Segoe UI", Arial, sans-serif',e.style.fontSize=`${1056/72}px`,e.style.color="#000000",o.showBorders&&(e.style.border="1px solid #ccc"),o.showShadow&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)"),o.pageBorders){let r=o.pageBorders,i=["top","bottom","left","right"],a=["Top","Bottom","Left","Right"];for(let s=0;s<i.length;s++){let l=r[i[s]];if(l&&l.style!=="none"&&l.style!=="nil"){let u=Jo(l,a[s],o.theme);for(let[c,d]of Object.entries(u))e.style[c]=String(d);}}}}function HS(e,t){let n=t.margins;e.style.position="absolute",e.style.top=`${n.top}px`,e.style.left=`${n.left}px`,e.style.right=`${n.right}px`,e.style.bottom=`${n.bottom}px`,e.style.overflow="visible";}function jf(e){return e?.align??e?.alignment}function NS(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=jf(n),r=n.posOffset!==void 0?co(n.posOffset):void 0;if(n.relativeTo==="page"){if(r!==void 0)return r-t.flowTop;if(o==="top")return -t.flowTop;if(o==="bottom")return t.pageHeight-e.height-t.flowTop;if(o==="center")return (t.pageHeight-e.height)/2-t.flowTop}if(n.relativeTo==="margin"){let i=t.margins.top,a=t.pageHeight-t.margins.top-t.margins.bottom;if(r!==void 0)return i+r-t.flowTop;if(o==="top")return i-t.flowTop;if(o==="bottom")return i+a-e.height-t.flowTop;if(o==="center")return i+(a-e.height)/2-t.flowTop}return r!==void 0?e.paragraphY+r:e.paragraphY}function zS(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=jf(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)-n.flowLeft}px`;return}if(r==="right"){e.style.left=`${n.pageWidth-t.width-n.flowLeft}px`;return}if(r==="center"){e.style.left=`${(n.pageWidth-t.width)/2-n.flowLeft}px`;return}if(r==="left"){e.style.left=`${-n.flowLeft}px`;return}}if(o.posOffset!==void 0){e.style.left=`${co(o.posOffset)}px`;return}if(r==="right"){e.style.left=`${n.contentWidth-t.width}px`;return}if(r==="center"){e.style.left=`${(n.contentWidth-t.width)/2}px`;return}e.style.left="0";}function OS(e,t,n){e.style.position="absolute",e.style.left=`${t.x-n.left}px`,e.style.top=`${t.y-n.top}px`,e.style.width=`${t.width}px`,"height"in t&&(e.style.height=`${t.height}px`);}function co(e){return e===void 0?0:Math.round(e*96/914400)}function dr(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function $S(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!dr(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,c=i.distRight??12,d="left",p=0;if(a?.horizontal){let b=a.horizontal;b.align==="right"?(d="right",p=n-i.width):b.align==="left"?(d="left",p=0):b.align==="center"?(d="left",p=(n-i.width)/2):b.posOffset!==void 0&&(p=co(b.posOffset),d=p>n/2?"right":"left");}else i.cssFloat==="right"&&(d="right",p=n-i.width);let f=0;if(a?.vertical){let b=a.vertical;b.align==="top"?f=0:b.align==="bottom"?f=t:b.posOffset!==void 0?f=co(b.posOffset):f=t,b.relativeTo==="margin"&&(b.align==="top"||b.posOffset!==void 0)||b.relativeTo==="paragraph"&&(f=t+f);}else f=t;let m="bothSides";i.cssFloat==="left"?m="right":i.cssFloat==="right"&&(m="left"),o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:d,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:c,pmStart:i.pmStart,pmEnd:i.pmEnd,wrapText:m,wrapType:i.wrapType});}return o}function _S(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 WS(e,t){let n=t.createElement("div");n.className="layout-floating-images-layer",n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0",n.style.bottom="0",n.style.pointerEvents="none",n.style.zIndex="10";for(let o of e){let r=t.createElement("div");r.className="layout-page-floating-image",r.style.position="absolute",r.style.pointerEvents="auto",r.style.top=`${o.y}px`,r.style.left=`${o.x}px`,o.pmStart!==void 0&&(r.dataset.pmStart=String(o.pmStart)),o.pmEnd!==void 0&&(r.dataset.pmEnd=String(o.pmEnd));let i=t.createElement("img");i.src=o.src,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.display="block",o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function Vf(e,t,n,o){let r=n.document??document,i=r.createElement("div");i.style.position="relative";let a=t.contentWidth??600,s=[],l=0;for(let u=0;u<e.blocks.length;u++){let c=e.blocks[u],d=e.measures[u];if(c?.kind==="paragraph"&&d?.kind==="paragraph"){let p=c,f=d,m=l,b=[];for(let S of p.runs)if(S.kind==="image"&&"position"in S&&S.position){let I=S;s.push({src:I.src,width:I.width,height:I.height,alt:I.alt,paragraphY:m,position:I.position});}else b.push(S);let h={...p,runs:b},x={blockId:p.id,width:a,height:f.totalHeight,fromLine:0,toLine:f.lines.length},T=Wn(x,h,f,t,{document:r});T.style.position="relative",T.style.marginBottom="0",i.appendChild(T),l+=f.totalHeight;}}for(let u of s){let c=r.createElement("img");c.src=u.src,c.width=u.width,c.height=u.height,u.alt&&(c.alt=u.alt),c.style.position="absolute",c.style.display="block",c.style.width=`${u.width}px`,c.style.height=`${u.height}px`,c.style.maxWidth="none",c.style.maxHeight="none",zS(c,u,o),c.style.top=`${NS(u,o)}px`,i.appendChild(c);}return i}function VS(e,t,n){let o=n.createElement("div");o.className="layout-footnote-area",o.style.width=`${t}px`;let r=n.createElement("div");r.style.width="33%",r.style.height="0.5px",r.style.backgroundColor="#000",r.style.marginBottom="6px",r.style.marginTop="6px",o.appendChild(r);for(let i of e){let a=n.createElement("div");a.style.fontSize="10px",a.style.lineHeight="1.3",a.style.marginBottom="4px",a.style.color="#000";let s=n.createElement("sup");s.textContent=i.displayNumber,s.style.fontSize="7px",s.style.marginRight="2px",a.appendChild(s);let l=n.createTextNode(" "+i.text);a.appendChild(l),o.appendChild(a);}return o}function nc(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??uo.page,r.dataset.pageNumber=String(e.number),us(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=uo.content,HS(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let f of e.fragments)if(f.kind==="paragraph"&&n.blockLookup){let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph"){let b=m.block,h=f.y-e.margins.top,x=$S(b,h,a);s.push(...x);}}for(let f of s)l.push({side:f.side,x:f.x,y:f.y,width:f.width,height:f.height,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,wrapText:f.wrapText,wrapType:f.wrapType});if(n.blockLookup)for(let f of e.fragments){if(f.kind!=="table")continue;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind!=="table")continue;let h=m.block.floating;if(!h)continue;let x=f.x-e.margins.left,T=f.y-e.margins.top,S=h.topFromText??0,I=h.bottomFromText??0,R=h.leftFromText??12,A=h.rightFromText??12,L=x<a/2?"left":"right";l.push({side:L,x,y:T,width:f.width,height:f.height,distTop:S,distBottom:I,distLeft:R,distRight:A});}let u=l.length>0?_S(l,a):[];if(s.length>0){let f=WS(s,o);i.appendChild(f);}let c=f=>{if(f.kind!=="paragraph"||!n.blockLookup||!f.blockId)return;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph")return m.block.attrs?.borders},d,p=new Map;for(let f=0;f<e.fragments.length;f++){let m=e.fragments[f],b,h={...t,section:"body",contentWidth:a},x=m.y-e.margins.top;if(n.blockLookup&&m.blockId){let T=n.blockLookup.get(String(m.blockId));if(m.kind==="paragraph"&&T?.block.kind==="paragraph"&&T?.measure.kind==="paragraph"){let S=T.block,I=f+1<e.fragments.length?c(e.fragments[f+1]):void 0,R=String(m.blockId),A=p.get(R);A||(A=new Set,p.set(R,A));let L=T.measure;u.length>0&&(L=In(S,a,{floatingZones:u,paragraphYOffset:x})),b=Wn(m,S,L,h,{document:o,prevBorders:d,nextBorders:I,renderedInlineImageKeys:A}),d=S.attrs?.borders;}else m.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=ss(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=ls(m,T.block,T.measure,h,{document:o}),d=void 0):m.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=cs(m,T.block,T.measure,h,{document:o}),d=void 0):(b=ei(m,h,{document:o}),d=void 0);}else b=ei(m,h,{document:o}),d=void 0;OS(b,m,{left:e.margins.left,top:e.margins.top}),i.appendChild(b);}if(e.columns&&e.columns.separator&&e.columns.count>1){let f=e.columns.count,m=e.columns.gap,b=(a-(f-1)*m)/f,h=e.size.h-e.margins.top-e.margins.bottom;for(let x=0;x<f-1;x++){let T=(x+1)*b+x*m+m/2,S=o.createElement("div");S.style.position="absolute",S.style.left=`${T}px`,S.style.top="0",S.style.height=`${h}px`,S.style.width="0.5px",S.style.backgroundColor="#000",S.style.pointerEvents="none",i.appendChild(S);}}if(n.footnoteArea&&n.footnoteArea.length>0){let f=VS(n.footnoteArea,a,o);f.style.position="absolute";let m=e.footnoteReservedHeight??0,b=e.size.h-e.margins.bottom-e.margins.top;f.style.top=`${b-m}px`,f.style.left="0",f.style.right="0",i.appendChild(f);}r.appendChild(i);{let m=n.headerDistance??e.margins.header??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.top-m,48),x=n.headerContent?.visualTop??0,T=n.headerContent?.visualBottom??n.headerContent?.height??0,S=Math.max(T-x,24),I=T>h,R=o.createElement("div");R.className=uo.header,R.style.position="absolute",R.style.top=`${m+x}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let A=!I;if(n.headerContent&&n.headerContent.blocks.length>0){let L=Vf(n.headerContent,{...t,section:"header",contentWidth:b},n,{flowTop:m,flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(A=false),R.appendChild(L);}A&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}{let m=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,h=Math.max(e.margins.bottom-m,48),x=n.footerContent?.visualTop??0,T=n.footerContent?.visualBottom??n.footerContent?.height??0,S=Math.max(T-x,24),I=S>h,R=o.createElement("div");R.className=uo.footer,R.style.position="absolute",R.style.top=`${e.size.h-m-S}px`,R.style.left=`${e.margins.left}px`,R.style.right=`${e.margins.right}px`,R.style.width=`${b}px`,R.style.height=`${S}px`,R.style.minHeight=`${S}px`;let A=!I;if(n.footerContent&&n.footerContent.blocks.length>0){let L=Vf(n.footerContent,{...t,section:"footer",contentWidth:b},n,{flowTop:e.size.h-m-(n.footerContent?.height??0),flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});L.style.top=`${-x}px`,L.querySelector("img")&&(A=false),R.appendChild(L);}A&&(R.style.maxHeight=`${h}px`,R.style.overflow="hidden"),r.appendChild(R);}return r}function oc(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body",resolvedCommentIds:n.resolvedCommentIds},r={...n};if(n.titlePg&&e.number===1&&(r.headerContent=n.firstPageHeaderContent,r.footerContent=n.firstPageFooterContent),n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Uf(e){let t=[];t.push(`s:${e.size.w},${e.size.h}`),t.push(`m:${e.margins.top},${e.margins.right},${e.margins.bottom},${e.margins.left}`),t.push(`n:${e.number}`),e.footnoteReservedHeight&&t.push(`fn:${e.footnoteReservedHeight}`);for(let n of e.fragments){let o=`${n.kind}:${n.blockId},${n.x},${n.y},${n.width},${n.height}`;n.pmStart!==void 0&&(o+=`,ps:${n.pmStart}`),n.pmEnd!==void 0&&(o+=`,pe:${n.pmEnd}`),n.kind==="paragraph"?o+=`,fl:${n.fromLine},tl:${n.toLine}`:n.kind==="table"&&(o+=`,fr:${n.fromRow},tr:${n.toRow}`),t.push(o);}return t.join("|")}function US(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 jS(e,t){e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.gap=`${t}px`,e.style.padding=`${t}px`,e.style.backgroundColor="var(--doc-bg, #f8f9fa)";}var ds=2,KS=8;function Kf(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=US(n),l=o>=KS;if(a&&a.optionsHash===s&&l){let h=a.pageStates,x=a.pageDataMap,T=i.__pageObserver,S=[];for(let A of e)S.push(Uf(A));let I=a.totalPages!==o,R=Math.min(h.length,e.length);for(let A=0;A<R;A++){let L=h[A],pe=S[A];if(L.fingerprint===pe&&!I){let _=x.get(L.element);_&&(_.page=e[A]);continue}let $=L.element,v=x.get($);v&&(v.page=e[A],v.rendered&&GS($,x,o,n)),L.fingerprint=pe,us($,e[A].size.w,e[A].size.h,n),$.dataset.pageNumber=String(e[A].number);}if(e.length>h.length){let A=n.document??document;for(let L=h.length;L<e.length;L++){let pe=e[L],$=A.createElement("div");$.className=n.pageClassName??uo.page,$.dataset.pageNumber=String(pe.number),$.dataset.pageIndex=String(L),us($,pe.size.w,pe.size.h,n),t.appendChild($),h.push({element:$,fingerprint:S[L]}),x.set($,{page:pe,index:L,rendered:false}),T&&T.observe($);}}if(e.length<h.length){for(let A=h.length-1;A>=e.length;A--){let L=h[A].element;T&&T.unobserve(L),x.delete(L),t.removeChild(L);}h.length=e.length;}for(let A=0;A<h.length;A++){let L=x.get(h[A].element);L&&(L.index=A);}a.totalPages=o,a.currentOptions=n;return}let c=i.__pageObserver;c&&(c.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,jS(t,r);let d=[],p=[];for(let h=0;h<e.length;h++){let x=e[h];if(p.push(Uf(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??uo.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(h),us(S,x.size.w,x.size.h,n),t.appendChild(S),d.push(S);}else {let{context:T,pageOptions:S}=oc(x,o,n),I=nc(x,T,S);t.appendChild(I),d.push(I);}}if(!l)return;let f=new Map;for(let h=0;h<e.length;h++)f.set(d[h],{page:e[h],index:h,rendered:false});let m=new IntersectionObserver(h=>{let x=i.__pageRenderState;if(!x)return;let{currentOptions:T,totalPages:S,pageDataMap:I}=x;for(let pe of h){let $=pe.target,v=I.get($);if(v&&pe.isIntersecting){ps($,I,S,T);for(let _=-ds;_<=ds;_++){let re=v.index+_;re>=0&&re<x.pageStates.length&&re!==v.index&&ps(x.pageStates[re].element,I,S,T);}}}let R=window.innerHeight,A=R*3,L=new Set;for(let[pe,$]of I){if(!$.rendered)continue;let v=pe.getBoundingClientRect();v.bottom>-A&&v.top<R+A&&L.add($.index);}for(let[pe,$]of I){if(!$.rendered)continue;let v=false;for(let _ of L)if(Math.abs($.index-_)<=ds+1){v=true;break}!v&&L.size>0&&YS(pe,I);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let h of d)m.observe(h);i.__pageObserver=m,i.__pageRenderState={pageStates:d.map((h,x)=>({element:h,fingerprint:p[x]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,ds+3);for(let h=0;h<b;h++)ps(d[h],f,o,n);}function ps(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=oc(r.page,n,o),s=nc(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function GS(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=oc(r.page,n,o),l=nc(r.page,i,a).querySelector(`.${uo.content}`),u=e.querySelector(`.${uo.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,ps(e,t,n,o));}function YS(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var fs=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");d$1(this,"resolvedCommentIds",new Set);this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body",resolvedCommentIds:this.resolvedCommentIds},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return Wn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return ss(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return ls(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return cs(t,r,i,n,{document:this.doc})}return ei(t,n,{document:this.doc})}applyFragmentPosition(t,n){t.style.position="absolute",t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,t.style.width=`${n.width}px`,"height"in n&&(t.style.height=`${n.height}px`);}getPageCount(){return this.totalPages}getPageElement(t){return this.pageStates[t]?.element??null}scrollToPage(t){let n=this.pageStates.find(o=>o.pageNumber===t);n?.element&&n.element.scrollIntoView({behavior:"smooth",block:"start"});}};var Vn,po,fo,Un,ur,Lo,Gf,rc,ms=class{constructor(){f$1(this,Lo);f$1(this,Vn,0);f$1(this,po,0);f$1(this,fo,false);f$1(this,Un,null);f$1(this,ur,new Set);}setStateSeq(t){g(this,Vn,t);}incrementStateSeq(){return ++i$1(this,Vn)._}getStateSeq(){return e$1(this,Vn)}getRenderSeq(){return e$1(this,po)}onLayoutStart(){g(this,fo,true);}onLayoutComplete(t){g(this,po,t),g(this,fo,false),h$1(this,Lo,Gf).call(this);}isSafeToRender(){return !e$1(this,fo)&&e$1(this,po)>=e$1(this,Vn)}requestRender(){this.isSafeToRender()?h$1(this,Lo,rc).call(this):g(this,Un,()=>h$1(this,Lo,rc).call(this));}onRender(t){return e$1(this,ur).add(t),()=>{e$1(this,ur).delete(t);}}reset(){g(this,Vn,0),g(this,po,0),g(this,fo,false),g(this,Un,null);}getDebugInfo(){return {stateSeq:e$1(this,Vn),renderSeq:e$1(this,po),layoutUpdating:e$1(this,fo),hasPendingRender:e$1(this,Un)!==null,isSafe:this.isSafeToRender()}}};Vn=new WeakMap,po=new WeakMap,fo=new WeakMap,Un=new WeakMap,ur=new WeakMap,Lo=new WeakSet,Gf=function(){if(e$1(this,Un)&&this.isSafeToRender()){let t=e$1(this,Un);g(this,Un,null),t();}},rc=function(){for(let t of e$1(this,ur))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var qf=".layout-page-content .layout-line";function qS(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 XS(e){let t=qS(e);if(!t)return;let n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=40;n.bottom>o.bottom-r?t.scrollTop+=n.bottom-o.bottom+r:n.top<o.top+r&&(t.scrollTop-=o.top-n.top+r);}function Xf({pagesContainerRef:e}){let t=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 c of Array.from(l)){let d=c,p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(d.classList.contains("layout-run-tab")){if(s>=p&&s<f)return d.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&c.firstChild?.nodeType===Node.TEXT_NODE){let m=c.firstChild,b=Math.min(s-p,m.length),h=d.ownerDocument;if(!h)continue;let x=h.createRange();return x.setStart(m,b),x.setEnd(m,b),x.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let c of Array.from(u)){let d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f)return c.getBoundingClientRect().left}return null},[e]),r=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(qf);for(let u of Array.from(l)){let c=u,d=c.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(d)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return c}}for(let u of Array.from(l)){let c=u,d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f&&d.querySelector(".layout-line")===c)return c}return null},[e]),i=useCallback((s,l)=>{let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart)+1:null}for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=Number(m.dataset.pmStart),x=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let T=(b.left+b.right)/2;return l<T?h:x}continue}if(l>=b.left&&l<=b.right){let T=m.firstChild;if(!T||T.nodeType!==Node.TEXT_NODE)return h;let S=T,I=m.ownerDocument;if(!I)return h;let R=0,A=S.length;for(;R<A;){let L=Math.floor((R+A)/2),pe=I.createRange();pe.setStart(S,L),pe.setEnd(S,L),l<pe.getBoundingClientRect().left?A=L:R=L+1;}if(R>0&&R<=S.length){let L=I.createRange();L.setStart(S,R-1),L.setEnd(S,R-1);let pe=L.getBoundingClientRect().left;L.setStart(S,Math.min(R,S.length)),L.setEnd(S,Math.min(R,S.length));let $=L.getBoundingClientRect().left;if(Math.abs(l-pe)<Math.abs(l-$))return h+(R-1)}return h+Math.min(R,x-h)}}let c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),h=l<b.left?b.left-l:l-b.right;h<d&&(d=h,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return l<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)},[]),a=useCallback((s,l)=>{if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return (["ArrowLeft","ArrowRight","Home","End"].includes(l.key)||l.key.length===1&&!l.ctrlKey&&!l.metaKey)&&(t.current=null,n.current=-1),false;if(l.ctrlKey||l.metaKey)return t.current=null,n.current=-1,false;if(!e.current)return false;let u=Array.from(e.current.querySelectorAll(qf));if(u.length===0)return false;let{from:c,anchor:d}=s.state.selection;if(t.current===null){let S=o(c);if(S===null)return false;t.current=S;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let S=r(c);if(!S||(p=u.indexOf(S),p===-1))return false}let f=l.key==="ArrowUp"?p-1:p+1;if(f<0||f>=u.length)return n.current=-1,false;let m=u[f],b=i(m,t.current);if(b===null)return false;n.current=f;let{state:h,dispatch:x}=s,T=Math.max(0,Math.min(b,h.doc.content.size));try{let S=l.shiftKey?TextSelection.create(h.doc,d,T):TextSelection.create(h.doc,T);x(h.tr.setSelection(S));}catch{let S=h.doc.resolve(T),I=l.shiftKey?TextSelection.between(h.doc.resolve(d),S):TextSelection.near(S);x(h.tr.setSelection(I));}return XS(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var mo=40,ys=12;function ZS(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function Zf({pagesContainerRef:e,onScrollExtendSelection:t}){let n=useRef(null),o=useRef({x:0,y:0}),r=useRef(false),i=useRef(null),a=useCallback(()=>{if(i.current)return i.current;let d=e.current;return d?(i.current=ZS(d),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 d=a();if(!d)return;let p=d.getBoundingClientRect(),{x:f,y:m}=o.current,b=0;if(m<p.top+mo){let h=Math.max(0,p.top+mo-m);b=-Math.min(ys,h/mo*ys);}else if(m>p.bottom-mo){let h=Math.max(0,m-(p.bottom-mo));b=Math.min(ys,h/mo*ys);}b!==0&&(d.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:useCallback((d,p)=>{if(o.current={x:d,y:p},!r.current){let f=a();if(!f)return;let m=f.getBoundingClientRect();(p<m.top+mo||p>m.bottom-mo)&&u();}},[a,u]),stopAutoScroll:s}}var JS=12,xs=8;function Jf(e){let t=[];for(let n of e)if(n.kind==="paragraph")for(let o of n.runs)o.kind==="text"&&o.footnoteRefId!=null&&t.push({footnoteId:o.footnoteRefId,pmPos:o.pmStart??0});return t}function ic(e,t){let n=new Map;if(t.length===0)return n;for(let o of t)for(let r of e){let i=false;for(let a of r.fragments){let s=a.pmStart??-1,l=a.pmEnd??-1;if(s>=0&&l>=0&&o.pmPos>=s&&o.pmPos<l){let u=n.get(r.number)??[];u.includes(o.footnoteId)||u.push(o.footnoteId),n.set(r.number,u),i=true;break}}if(i)break}return n}function QS(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let c={kind:"text",text:`${t} `,fontSize:xs,superscript:true};l.push(c);}for(let c of s.content){let d=c;if(d.type==="run"&&Array.isArray(d.content)){let p=d.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=xs);for(let m of d.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:xs});let u={kind:"paragraph",id:`fn-${e.id}-p${a}`,runs:l};o.push(u);}o.length===0&&o.push({kind:"paragraph",id:`fn-${e.id}-empty`,runs:[{kind:"text",text:"",fontSize:xs}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=In(a,n);r.push(s);}let i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {id:e.id,displayNumber:t,blocks:o,measures:r,height:i}}function Qf(e,t,n){let o=new Map,r=new Map;for(let s of e)(s.noteType==="normal"||s.noteType==null)&&r.set(s.id,s);let i=1,a=new Set;for(let s of t){if(a.has(s.footnoteId))continue;a.add(s.footnoteId);let l=r.get(s.footnoteId);if(!l)continue;let u=QS(l,i,n);o.set(s.footnoteId,u),i++;}return o}function em(e,t){let n=new Map;for(let[o,r]of e){let i=0;for(let a of r){let s=t.get(a);s&&(i+=s.height);}i>0&&(i+=JS,n.set(o,i));}return n}var ac=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(),c=a.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,c=Math.min(t-s,u.length),d=a.ownerDocument;if(!d)continue;let p=d.createRange();p.setStart(u,c),p.setEnd(u,c);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),c=i.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let c=a.firstChild,d=s.ownerDocument;if(!d)continue;let p=Math.max(0,t-l),f=Math.min(c.length,n-l);if(p<f){let m=d.createRange();m.setStart(c,p),m.setEnd(c,f);let b=m.getClientRects();for(let h of Array.from(b))r.push({x:(h.left-o.left)/this.zoom,y:(h.top-o.top)/this.zoom,width:h.width/this.zoom,height:h.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function tm(e,t=1){return new ac(e,t)}var rk=816,rm=1056,Ss={top:96,right:96,bottom:96,left:96},ik=24,bo=30,ak=200,sk=[],lk={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},im=24,ck={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:im,paddingBottom:24},dk={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},uk={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function pk(e,t,n,o,r){let i=new Map;if(!e?.state)return i;let{doc:a,schema:s}=e.state,l=s.marks.comment,u=s.marks.insertion,c=s.marks.deletion;if(!l&&!u&&!c)return i;let d=new Set,p=im+r;return a.descendants((f,m)=>{if(f.isText)for(let b of f.marks){let h=null;if(l&&b.type===l?h=`comment-${b.attrs.commentId}`:(u&&b.type===u||c&&b.type===c)&&(h=`revision-${b.attrs.revisionId}`),!h||d.has(h))continue;d.add(h);let x=q(t,n,o,m);if(x){i.set(h,x.y+p);continue}for(let T=0;T<t.pages.length;T++){let S=t.pages[T],I=false;for(let R of S.fragments){let A=R.pmStart??0,L=R.pmEnd??A;if(m<A||m>L)continue;let pe=R.kind==="table"?fk(n,o,R,m):0;i.set(h,R.y+pe+m$2(t,T)+p),I=true;break}if(I)break}}}),i}function fk(e,t,n,o){let r=e.findIndex(l=>l.id===n.blockId);if(r===-1)return 0;let i=e[r],a=t[r];if(i.kind!=="table"||a.kind!=="table")return 0;let s=0;for(let l=n.fromRow;l<n.toRow;l++){let u=i.rows[l];if(!u||u.cells.some(d=>d.blocks.some(p=>{let f=p.pmStart??0,m=p.pmEnd??f;return o>=f&&o<=m})))break;s+=a.rows[l]?.height??0;}return s}function Zt(e){return Math.round(e/1440*96)}function mk(e){return {w:e?.pageWidth?Zt(e.pageWidth):rk,h:e?.pageHeight?Zt(e.pageHeight):rm}}function gk(e){let t=e?.marginTop?Zt(e.marginTop):Ss.top,n=e?.marginBottom?Zt(e.marginBottom):Ss.bottom;return {top:t,right:e?.marginRight?Zt(e.marginRight):Ss.right,bottom:n,left:e?.marginLeft?Zt(e.marginLeft):Ss.left,header:e?.headerDistance?Zt(e.headerDistance):48,footer:e?.footerDistance?Zt(e.footerDistance):48}}function hk(e){let t=e?.columnCount??1;if(t<=1)return;let n=Zt(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function bk(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 yk(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function sc(e){return e===void 0?0:Math.round(e*96/914400)}function xk(e,t,n){if(e){if(t==="pct")return n*e/5e3;if(t==="dxa"||!t||t==="auto")return Math.round(e/20*1.333)}}function am(e,t){let r=e.columnWidths??[],i=xk(e.width,e.widthType,t);if(r.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((f,m)=>f+(m.colSpan??1),0),p=(i??t)/Math.max(1,c);r=Array(c).fill(p);}else if(r.length>0&&i){let c=r.reduce((d,p)=>d+p,0);if(c>0&&Math.abs(c-i)>1){let d=i/c;r=r.map(p=>p*d);}}let a=new Map;for(let c=0;c<e.rows.length;c++){let d=e.rows[c];if(!d)continue;let p=0,f=a.get(c)??new Set;for(;f.has(p);)p++;for(let m of d.cells){let b=m.colSpan??1,h=m.rowSpan??1;if(h>1)for(let x=c+1;x<c+h;x++){a.has(x)||a.set(x,new Set);let T=a.get(x);for(let S=0;S<b;S++)T.add(p+S);}for(p+=b;f.has(p);)p++;}}let s=e.rows.map((c,d)=>{let p=0,f=a.get(d)??new Set;for(;f.has(p);)p++;return {cells:c.cells.map(m=>{let b=m.colSpan??1,h=0;for(let I=0;I<b&&p+I<r.length;I++)h+=r[p+I]??0;for(h===0&&(h=m.width??100),p+=b;f.has(p);)p++;let x=m.padding?.left??7,T=m.padding?.right??7,S=Math.max(1,h-x-T);return {blocks:m.blocks.map(I=>sm(I,S)),width:h,height:0,colSpan:m.colSpan,rowSpan:m.rowSpan}}),height:0}});for(let c=0;c<s.length;c++){let d=s[c],p=e.rows[c]?.cells,f=0;for(let x=0;x<d.cells.length;x++){let T=d.cells[x],S=p?.[x];T.height=T.blocks.reduce((A,L)=>"totalHeight"in L?A+L.totalHeight:A,0);let I=S?.padding?.top??0,R=S?.padding?.bottom??0;T.height+=I+R,f=Math.max(f,T.height);}let m=e.rows[c],b=m?.height,h=m?.heightRule;b&&h==="exact"?d.height=b:b?d.height=Math.max(f,b):d.height=f;}let l=s.reduce((c,d)=>c+d.height,0),u=r.reduce((c,d)=>c+d,0)||i||t;return {kind:"table",rows:s,columnWidths:r,totalWidth:u,totalHeight:l}}function Sk(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(!yk(s))continue;let l=0,u=s.position,c=s.distTop??0,d=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let x=u.vertical;x.align==="top"&&x.relativeTo==="margin"?l=0:x.posOffset!==void 0&&(l=sc(x.posOffset));}let m=l+s.height,b=0,h=0;if(u?.horizontal){let x=u.horizontal;if(x.align==="left")b=s.width+f;else if(x.align==="right")h=s.width+p;else if(x.posOffset!==void 0){let T=sc(x.posOffset);T<t/2?b=T+s.width+f:h=t-T+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(h=s.width+p);if(b>0||h>0){let x=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:h,topY:l-c,bottomY:m+d,anchorBlockIndex:o,isMarginRelative:x});}}}for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="table")continue;let i=r,a=i.floating;if(!a)continue;let s=am(i,t),l=s.totalWidth,u=s.totalHeight,c=a.leftFromText??12,d=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,h=0;a.tblpX!==void 0?h=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?h=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?h=t-l:a.tblpXSpec==="center"&&(h=(t-l)/2):i.justification==="center"?h=(t-l)/2:i.justification==="right"&&(h=t-l),h<t/2?m=h+l+d:b=t-h+c;let x=a.tblpY??0,T=x+u;n.push({leftMargin:m,rightMargin:b,topY:x-p,bottomY:T+f,anchorBlockIndex:o});}return n}function sm(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=jl(r,t);if(a)return a}let i=In(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&Kl(r,t,i),i}case "table":return am(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "textBox":{let r=e,i=r.margins??c$1,a=(r.width??d$2)-i.left-i.right,s=r.content.map(c=>In(c,a)),l=s.reduce((c,d)=>c+d.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??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 lm(e,t){let n=Array.isArray(t)?t[0]??0:t,o=Sk(e,n),r=o.filter(p=>p.isMarginRelative),i=o.filter(p=>!p.isMarginRelative),a=new Map;for(let p of r){let f=a.get(p.topY)??[];f.push(p),a.set(p.topY,f);}let s=[...i];for(let p of a.values()){let f=Math.min(...p.map(m=>m.anchorBlockIndex));for(let m of p)s.push({...m,anchorBlockIndex:f});}let l=new Map;for(let p of s){let f=l.get(p.anchorBlockIndex)??[];f.push({leftMargin:p.leftMargin,rightMargin:p.rightMargin,topY:p.topY,bottomY:p.bottomY}),l.set(p.anchorBlockIndex,f);}let u=new Set(s.map(p=>p.anchorBlockIndex)),c=0,d=[];return e.map((p,f)=>{u.has(f)&&(c=0,d=l.get(f)??[]);let m=d.length>0?d:void 0;try{let b=performance.now(),h=Array.isArray(t)?t[f]??n:t,x=sm(p,h,m,c),T=performance.now()-b;return T>500&&console.warn(`[measureBlocks] Block ${f} (${p.kind}) took ${Math.round(T)}ms`),"totalHeight"in x&&(p.kind==="table"&&p.floating||(c+=x.totalHeight)),x}catch(b){return console.error(`[measureBlocks] Error measuring block ${f} (${p.kind}):`,b),{totalHeight:20}}})}function Cs(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,c=m=>Math.round(m/914400*96),d=u?.width?c(u.width):100,p=u?.height?c(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:d,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.content)){let a=Cs(o.content);t.push(...a);}continue}if(o.type==="complexField"){let r=o.fieldType,i={};if(Array.isArray(o.fieldResult)&&o.fieldResult.length>0){let a=o.fieldResult[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.fieldResult)){let a=Cs(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=Cs(o.children);t.push(...r);}}return t}function kk(e){return e?.align??e?.alignment}function Ck(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=kk(i),s=i.posOffset!==void 0?sc(i.posOffset):void 0;if(i.relativeTo==="page"){if(s!==void 0)return s-r;if(a==="top")return -r;if(a==="bottom")return o.pageSize.h-e.height-r;if(a==="center")return (o.pageSize.h-e.height)/2-r}if(i.relativeTo==="margin"){let l=o.margins.top,u=o.pageSize.h-o.margins.top-o.margins.bottom;if(s!==void 0)return l+s-r;if(a==="top")return l-r;if(a==="bottom")return l+u-e.height-r;if(a==="center")return l+(u-e.height)/2-r}return s!==void 0?t+s:t}function Tk(e,t,n,o){let r=0,i=n,a=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s];if(l?.kind!=="paragraph"||u?.kind!=="paragraph")continue;let c=l,d=a,p=d+u.totalHeight;r=Math.min(r,d),i=Math.max(i,p);for(let f of c.runs){if(f.kind!=="image"||!f.position)continue;let m=f,b=Ck(m,d,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function ks(e,t,n){if(!e||!e.content||e.content.length===0)return;let o=[];for(let u of e.content){let c=u;if(c.type==="paragraph"&&Array.isArray(c.content)){let d=c.formatting,p={};if(d){if(d.alignment){let b=d.alignment;b==="both"?p.alignment="justify":["left","center","right","justify"].includes(b)&&(p.alignment=b);}if(d.borders){let b=d.borders,h={};for(let x of ["top","bottom","left","right","between"]){let T=b[x];if(T){let S=ns(T);S&&(h[x]=S);}}Object.keys(h).length>0&&(p.borders=h);}if(d.lineSpacing!=null){let b={},h=d.lineSpacingRule;h==="exact"||h==="atLeast"?(b.line=Zt(d.lineSpacing),b.lineUnit="px",b.lineRule=h):(b.line=d.lineSpacing/240,b.lineUnit="multiplier",b.lineRule="auto"),p.spacing=b;}Array.isArray(d.tabs)&&d.tabs.length>0&&(p.tabs=d.tabs.map(b=>({val:b.alignment==="left"?"start":b.alignment==="right"?"end":b.alignment,pos:Zt(b.position),leader:b.leader})));}let f=Cs(c.content);f.length===0&&f.push({kind:"text",text:""});let m={kind:"paragraph",id:String(o.length),runs:f,attrs:Object.keys(p).length>0?p:void 0};o.push(m);}}if(o.length===0)return;let r=o.map(u=>{if(u.kind!=="paragraph")return u;let c=u;if(!c.runs.some(f=>f.kind==="image"&&"position"in f&&f.position))return u;let p=c.runs.filter(f=>!(f.kind==="image"&&"position"in f&&f.position));return p.length===0&&p.push({kind:"text",text:""}),{...c,runs:p}}),i=lm(r,t),a=i.reduce((u,c)=>c.kind==="paragraph"?u+c.totalHeight:u,0),{visualTop:s,visualBottom:l}=Tk(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function wk(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let d=t.get(l)?.displayNumber??0,p=b$1(u);s.push({displayNumber:String(d),text:p});}s.length>0&&o.set(i,s);}return o}var vk=forwardRef(function(t,n$1){let{document:o$1,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,firstPageHeaderContent:u,firstPageFooterContent:c,readOnly:d=false,pageGap:p$1=ik,zoom:f=1,onDocumentChange:m,onSelectionChange:b,externalPlugins:h=sk,extensionManager:x,onReady:T,onRenderedDomContextReady:S,pluginOverlays:I,onHeaderFooterDoubleClick:R,hfEditMode:A,onBodyClick:L,className:pe,style:$,commentsSidebarOpen:v=false,sidebarOverlay:_,scrollContainerRef:re,onHyperlinkClick:ae,onContextMenu:N,onAnchorPositionsChange:D,resolvedCommentIds:de}=t,ge=useCallback(()=>re&&typeof re=="object"?re.current:Pe.current,[re]),Pe=useRef(null),se=useRef(null),q$1=useRef(null),E=useRef(null),{handlePMKeyDown:F}=Xf({pagesContainerRef:se}),k=useRef(()=>{}),P=useRef(b),M=useRef(m),H=useRef(T),oe=useRef(S);P.current=b,M.current=m,H.current=T,oe.current=S;let[Q,V]=useState(null),[Y,ne]=useState([]),[Se,Me]=useState([]),[Z,ie]=useState(false),[Ie,He]=useState([]),[qe,je]=useState(null),[Xe,_e]=useState(null),we=useRef(false),xt=useCallback((C,O)=>{let K=C.tagName==="IMG"?C:C.querySelector("img"),G=(K??C).getBoundingClientRect();return {element:K??C,pmPos:O,width:Math.round(G.width/f),height:Math.round(G.height/f)}},[f]),Le=useRef(false),ze=useRef(null),lt=useRef(false),nt=useRef(0),ft=useRef(0),Rt=useRef(0),Ne=useRef({left:0,right:0}),mt=useRef(null),Oe=useRef(false),St=useRef(0),Jt=useRef(0),Gt=useRef(0),jn=useRef(0),dt=useRef(null),Qt=useRef(false),gn=useRef(false),So=useRef(0),gr=useRef(0),No=useRef(0),an=useRef(0),Yt=useRef(null),en=useRef(false),Dt=useRef(null),ko=useRef(null),Ht=useRef(null),Rs=5,[hn,It]=useState(null),bn=useRef(null),gt=useCallback(()=>{bn.current&&(clearTimeout(bn.current),bn.current=null);},[]);useEffect(()=>()=>{bn.current&&clearTimeout(bn.current);},[]);let Nt=useMemo(()=>new ms,[]),Ft=useMemo(()=>mk(a),[a]),ot=useMemo(()=>gk(a),[a]),Kn=useMemo(()=>hk(a),[a]),Et=Ft.w-ot.left-ot.right,yn=useMemo(()=>new fs({pageGap:p$1,showShadow:true,pageBackground:"#fff"}),[p$1]);E.current=yn;let zt=useCallback(C=>{let O=performance.now(),K=Nt.getStateSeq();Nt.onLayoutStart();try{let G=performance.now(),ee=Ft.h-ot.top-ot.bottom,W=Sf(C.doc,{theme:i,pageContentHeight:ee}),J=performance.now()-G;J>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(J)}ms (${W.length} blocks)`),ne(W),G=performance.now();let te=bk(W,Et,Kn),le=lm(W,te);J=performance.now()-G,J>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(J)}ms (${W.length} blocks)`),Me(le);let xe=Jf(W),ye=xe.length>0&&o$1?.package?.footnotes,Re={section:"header",pageSize:Ft,margins:ot},ke={section:"footer",pageSize:Ft,margins:ot},he=ks(s,Et,Re),Be=ks(l,Et,ke),$e=a?.titlePg===!0,ut=$e?ks(u,Et,Re):void 0,ht=$e?ks(c,Et,ke):void 0,ln=ot.header??48,$o=ot.footer??48,pi=ot.top-ln,fi=ot.bottom-$o,mi=kt=>kt?kt.visualBottom??kt.height:0,gi=kt=>kt?Math.max((kt.visualBottom??kt.height)-(kt.visualTop??0),kt.height):0,Cr=Math.max(mi(he),mi(ut)),Tr=Math.max(gi(Be),gi(ht)),_o=ot;(Cr>pi||Tr>fi)&&(_o={...ot},Cr>pi&&(_o.top=Math.max(ot.top,ln+Cr)),Tr>fi&&(_o.bottom=Math.max(ot.bottom,$o+Tr))),G=performance.now();let cn,wo=new Map,wr=new Map,Is=a?.sectionStart,vr={pageSize:Ft,margins:_o,columns:Kn,bodyBreakType:Is,pageGap:p$1};if(ye){let kt=e(W,le,vr);wo=ic(kt.pages,xe),wr=Qf(o$1.package.footnotes,xe,Et);let Xn=em(wo,wr);if(Xn.size>0){cn=e(W,le,{...vr,footnoteReservedHeights:Xn}),wo=ic(cn.pages,xe);for(let[xn,vo]of wo){let Ro=cn.pages.find(Fs=>Fs.number===xn);Ro&&(Ro.footnoteIds=vo);}}else cn=kt;}else cn=e(W,le,vr);if(J=performance.now()-G,J>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(J)}ms (${cn.pages.length} pages)`),V(cn),se.current&&E.current){G=performance.now();let kt=new Map;for(let xn=0;xn<W.length;xn++){let vo=W[xn],Ro=le[xn];vo&&Ro&&kt.set(String(vo.id),{block:vo,measure:Ro});}E.current.setBlockLookup(kt);let Xn=ye?wk(wo,wr,o$1):void 0;if(Kf(cn.pages,se.current,{pageGap:p$1,showShadow:!0,pageBackground:"#fff",blockLookup:kt,headerContent:he,footerContent:Be,firstPageHeaderContent:ut,firstPageFooterContent:ht,titlePg:$e,headerDistance:a?.headerDistance?Zt(a.headerDistance):void 0,footerDistance:a?.footerDistance?Zt(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:Xn?.size?Xn:void 0,resolvedCommentIds:de}),J=performance.now()-G,J>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(J)}ms`),S){let xn=tm(se.current,f);S(xn);}}if(D){let kt=pk(q$1.current?.getView()??null,cn,W,le,p$1);D(kt);}let hi=performance.now()-O;hi>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(hi)}ms total (${W.length} blocks, ${le.length} measures)`);}catch(G){console.error("[PagedEditor] Layout pipeline error:",G);}Nt.onLayoutComplete(K);},[Et,Kn,Ft,ot,p$1,f,Nt,s,l,u,c,a,S,o$1,de]),sn=useRef(null),hr=useCallback(C=>{if(sn.current){sn.current.state=C;return}let O=requestAnimationFrame(()=>{let K=sn.current;sn.current=null,K&&zt(K.state);});sn.current={rafId:O,state:C};},[zt]);useEffect(()=>()=>{sn.current&&(cancelAnimationFrame(sn.current.rafId),sn.current=null);},[]);let Bn=useCallback((C,O=1)=>{if(!se.current)return null;let K=se.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!K)return null;let G=K.getBoundingClientRect(),ee=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let J of Array.from(ee)){let te=J,le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(te.classList.contains("layout-run-tab")){if(C>=le&&C<xe){let ye=te.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=te.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}continue}if(C>=le&&C<=xe&&J.firstChild?.nodeType===Node.TEXT_NODE){let ye=J.firstChild,Re=Math.min(C-le,ye.length),ke=te.ownerDocument;if(!ke)continue;let he=ke.createRange();he.setStart(ye,Re),he.setEnd(ye,Re);let Be=he.getBoundingClientRect(),$e=te.closest(".layout-page"),ut=$e?Number($e.dataset.pageNumber)-1:0,ht=te.closest(".layout-line"),ln=ht?ht.offsetHeight:16;return {x:(Be.left-G.left)/O,y:(Be.top-G.top)/O,height:ln,pageIndex:ut}}}let W=se.current.querySelectorAll(".layout-empty-run");for(let J of Array.from(W)){let te=J.closest(".layout-paragraph");if(!te)continue;let le=Number(te.dataset.pmStart),xe=Number(te.dataset.pmEnd);if(C>=le&&C<=xe){let ye=J.getBoundingClientRect(),Re=te.closest(".layout-page"),ke=Re?Number(Re.dataset.pageNumber)-1:0,he=J.closest(".layout-line"),Be=he?he.offsetHeight:16;return {x:(ye.left-G.left)/O,y:(ye.top-G.top)/O,height:Be,pageIndex:ke}}}return null},[]),Ot=useCallback(C=>{let{from:O,to:K}=C.selection;if(P.current?.(O,K),se.current){let G=se.current.querySelectorAll(".layout-table-cell-selected");for(let J of Array.from(G))J.classList.remove("layout-table-cell-selected");let ee=C.selection;if("$anchorCell"in ee&&typeof ee.forEachCell=="function"){let J=[];ee.forEachCell((le,xe)=>{J.push([xe,xe+le.nodeSize]);});let te=se.current.querySelectorAll(".layout-table-cell");for(let le of Array.from(te)){let xe=le,ye=xe.dataset.pmStart;if(ye!==void 0){let Re=Number(ye);for(let[ke,he]of J)if(Re>=ke&&Re<he){xe.classList.add("layout-table-cell-selected");break}}}}}if(!(!Q||Y.length===0))if(O===K){let G=Bn(O,f);if(G)je(G);else {let ee=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),W=se.current?.querySelector(".layout-page");if(ee&&W){let J=ee.getBoundingClientRect(),te=W.getBoundingClientRect(),le=q(Q,Y,Se,O);je(le?{...le,x:le.x+(te.left-J.left)/f,y:le.y+(te.top-J.top)/f}:null);}else je(null);}He([]);}else {let G=se.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(G&&se.current){let ee=G.getBoundingClientRect(),W=[],J=se.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let te of Array.from(J)){let le=te,xe=Number(le.dataset.pmStart);if(Number(le.dataset.pmEnd)>O&&xe<K){if(le.classList.contains("layout-run-tab")){let $e=le.getBoundingClientRect(),ut=le.closest(".layout-page"),ht=ut?Number(ut.dataset.pageNumber)-1:0;W.push({x:($e.left-ee.left)/f,y:($e.top-ee.top)/f,width:$e.width/f,height:$e.height/f,pageIndex:ht});continue}let Re=null;if(te.firstChild?.nodeType===Node.TEXT_NODE?Re=te.firstChild:te.firstChild?.nodeType===Node.ELEMENT_NODE&&te.firstChild.tagName==="A"&&te.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(Re=te.firstChild.firstChild),!Re)continue;let ke=le.ownerDocument;if(!ke)continue;let he=Math.max(0,O-xe),Be=Math.min(Re.length,K-xe);if(he<Be){let $e=ke.createRange();$e.setStart(Re,he),$e.setEnd(Re,Be);let ut=$e.getClientRects();for(let ht of Array.from(ut)){let ln=le.closest(".layout-page"),$o=ln?Number(ln.dataset.pageNumber)-1:0;W.push({x:(ht.left-ee.left)/f,y:(ht.top-ee.top)/f,width:ht.width/f,height:ht.height/f,pageIndex:$o});}}}}if(W.length>0)He(W);else {let te=se.current.querySelector(".layout-page");if(te){let le=te.getBoundingClientRect(),xe=(le.left-ee.left)/f,ye=(le.top-ee.top)/f,ke=p(Q,Y,Se,O,K).map(he=>({...he,x:he.x+xe,y:he.y+ye}));He(ke);}else He([]);}}else He([]);je(null);}},[Q,Y,Se,Bn,f]),ue=useCallback((C,O)=>{if(C.docChanged){Nt.incrementStateSeq(),hr(O);let K=q$1.current?.getDocument();K&&M.current?.(K);}Nt.requestRender(),C.docChanged||Ot(O);},[hr,Ot,Nt]),br=useCallback(C=>{let{selection:O}=C;O instanceof NodeSelection&&O.node.type.name==="image"?(He([]),je(null)):Nt.isSafeToRender()&&Ot(C),requestAnimationFrame(()=>{let K=q$1.current?.getView();if(!K){_e(null);return}let{selection:G}=K.state;if(G instanceof NodeSelection&&G.node.type.name==="image"){let ee=G.from,W=se.current?.querySelector(`[data-pm-start="${ee}"]`);if(W){_e(xt(W,ee));return}}we.current||_e(null);});},[Ot,f,xt,Nt]),$t=useCallback((C,O)=>{if(!se.current||!Q)return null;let K=Ff(se.current,C,O,f);if(K!==null)return K;let G=se.current.querySelectorAll(".layout-page"),ee=-1,W=null;for(let Re=0;Re<G.length;Re++){let he=G[Re].getBoundingClientRect();if(C>=he.left&&C<=he.right&&O>=he.top&&O<=he.bottom){ee=Re,W=he;break}}if(ee<0||!W)return null;let J=(C-W.left)/f,te=(O-W.top)/f,le=Q.pages[ee];if(!le)return null;let xe={pageIndex:ee,page:le,pageY:te},ye=n(xe,Y,Se,{x:J,y:te});if(!ye)return null;if(ye.fragment.kind==="table"){let Re=o(xe,Y,Se,{x:J,y:te});return Yl(ye,Re)}return Yl(ye)},[Q,Y,Se,f]),An=useCallback(C=>{let O=q$1.current?.getView();if(!O)return null;try{let K=O.state.doc.resolve(C);for(let G=K.depth;G>0;G--){let ee=K.node(G);if(ee.type.name==="tableCell"||ee.type.name==="tableHeader")return K.before(G)}}catch{}return null},[]),Es=useCallback(C=>{let O=["layout-block-image","layout-image","layout-page-floating-image"],K=G=>!!G.dataset.pmStart&&O.some(ee=>G.classList.contains(ee));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&K(C.parentElement)?C.parentElement:K(C)?C:null},[]),We=useCallback(C=>{let O=se.current;if(!O)return;let K=O.querySelector(`[data-pm-start="${C}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"center"});},[]),tn=useCallback(C=>{if(!q$1.current)return;if(C.button===2){C.preventDefault();return}if(C.button!==0||(It(null),gt(),C.target.closest("a[href]")&&C.preventDefault(),d))return;if(A&&L){let W=C.target;if(!(W.closest(".layout-page-header")||W.closest(".layout-page-footer")||W.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),L();return}}if(!A){let W=C.target;if(W.closest(".layout-page-header")||W.closest(".layout-page-footer")){C.preventDefault(),q$1.current&&(q$1.current.setSelection(0),q$1.current.focus(),ie(true));return}}let K=C.target;if(K.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),lt.current=true,nt.current=C.clientX,mt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);ft.current=W,Rt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q$1.current.getView();if(J){let te=J.state.doc.resolve(Rt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&ye[W+1]!==void 0&&(Ne.current={left:ye[W],right:ye[W+1]});break}}}return}if(K.classList.contains("layout-table-row-resize-handle")||K.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),Oe.current=true,St.current=C.clientY,dt.current=K,Qt.current=K.dataset.isEdge==="bottom",K.classList.add("dragging");let W=parseInt(K.dataset.rowIndex??"0",10);Jt.current=W,Gt.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q$1.current.getView();if(J){let te=J.state.doc.resolve(Gt.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=null,Re=0;if(xe.forEach(ke=>{Re===W&&(ye=ke),Re++;}),ye){let ke=ye.attrs.height;if(ke)jn.current=ke;else {let Be=K.closest(".layout-table")?.querySelector(`[data-row-index="${W}"]`),$e=Be?Be.getBoundingClientRect().height:30;jn.current=Math.round($e*15);}}break}}}return}if(K.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),gn.current=true,So.current=C.clientX,Yt.current=K,K.classList.add("dragging");let W=parseInt(K.dataset.columnIndex??"0",10);gr.current=W,No.current=parseInt(K.dataset.tablePmStart??"0",10);let J=q$1.current.getView();if(J){let te=J.state.doc.resolve(No.current+1);for(let le=te.depth;le>=0;le--){let xe=te.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[W]!==void 0&&(an.current=ye[W]);break}}}return}let G=Es(K);if(G){C.preventDefault(),C.stopPropagation();let W=G.dataset.pmStart;if(W!==void 0){let J=parseInt(W,10);q$1.current.setNodeSelection(J),_e(xt(G,J)),He([]),je(null);}q$1.current.focus(),ie(true);return}_e(null),C.preventDefault();let ee=$t(C.clientX,C.clientY);if(ee!==null){let W=An(ee);Dt.current=W,en.current=false,ko.current=null,Ht.current=null,Le.current=true,ze.current=ee,q$1.current.setSelection(ee);}else {Dt.current=null,en.current=false;let W=q$1.current.getView();if(W){let J=Math.max(0,W.state.doc.content.size-1);q$1.current.setSelection(J),ze.current=J,Le.current=true;}}q$1.current.focus(),ie(true);},[$t,An,d,A,L,f,ae,gt]),Gn=useCallback((C,O)=>{k.current(C,O);},[]),{updateMousePosition:nn,stopAutoScroll:yr}=Zf({pagesContainerRef:se,onScrollExtendSelection:Gn});k.current=(C,O)=>{if(!Le.current||ze.current===null||!q$1.current)return;let K=$t(C,O);K!==null&&q$1.current.setSelection(ze.current,K);};let zo=useCallback(C=>{if(lt.current){C.preventDefault();let G=C.clientX-nt.current;if(mt.current){let ee=parseFloat(mt.current.style.left);mt.current.style.left=`${ee+G}px`,nt.current=C.clientX;let W=Math.round(G*15),J=300,te=Ne.current.left+W,le=Ne.current.right-W;te>=J&&le>=J&&(Ne.current={left:te,right:le});}return}if(Oe.current){C.preventDefault();let G=C.clientY-St.current;if(dt.current){let ee=parseFloat(dt.current.style.top);dt.current.style.top=`${ee+G}px`,St.current=C.clientY;let W=Math.round(G*15),J=200,te=jn.current+W;te>=J&&(jn.current=te);}return}if(gn.current){C.preventDefault();let G=C.clientX-So.current;if(Yt.current){let ee=parseFloat(Yt.current.style.left);Yt.current.style.left=`${ee+G}px`,So.current=C.clientX;let W=Math.round(G*15),J=300,te=an.current+W;te>=J&&(an.current=te);}return}if(!Le.current||ze.current===null||!q$1.current||!se.current)return;nn(C.clientX,C.clientY);let O=$t(C.clientX,C.clientY);if(O===null)return;if(Dt.current!==null){if(en.current){let ee=An(O);if(ee!==null){q$1.current.setCellSelection(Dt.current,ee);return}}let G=An(O);if(G!==null&&G!==Dt.current){en.current=true,q$1.current.setCellSelection(Dt.current,G),Ht.current=null;return}if(ko.current!==null&&O===ko.current){if(Ht.current===null)Ht.current=C.clientX;else if(Math.abs(C.clientX-Ht.current)>=Rs){en.current=true,q$1.current.setCellSelection(Dt.current,Dt.current),Ht.current=null;return}}else Ht.current=null,ko.current=O;}let K=ze.current;q$1.current.setSelection(K,O);},[$t,An,nn]),Yn=useCallback(()=>{if(lt.current){lt.current=false,mt.current&&(mt.current.classList.remove("dragging"),mt.current=null);let C=q$1.current?.getView();if(C){let O=Rt.current,K=ft.current,{left:G,right:ee}=Ne.current,W=C.state.doc.resolve(O+1);for(let J=W.depth;J>=0;J--){let te=W.node(J);if(te.type.name==="table"){let le=W.before(J),xe=C.state.tr,ye=[...te.attrs.columnWidths];ye[K]=G,ye[K+1]=ee,xe.setNodeMarkup(le,void 0,{...te.attrs,columnWidths:ye});let Re=le+1;te.forEach(ke=>{let he=Re+1,Be=0;ke.forEach($e=>{let ut=$e.attrs.colspan||1;if(Be===K||Be===K+1){let ht=Be===K?G:ee;xe.setNodeMarkup(xe.mapping.map(he),void 0,{...$e.attrs,width:ht,widthType:"dxa",colwidth:null});}he+=$e.nodeSize,Be+=ut;}),Re+=ke.nodeSize;}),C.dispatch(xe);break}}}return}if(Oe.current){Oe.current=false,dt.current&&(dt.current.classList.remove("dragging"),dt.current=null);let C=q$1.current?.getView();if(C){let O=Gt.current,K=Jt.current,G=jn.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=te+1,ye=0;J.forEach(Re=>{ye===K&&le.setNodeMarkup(le.mapping.map(xe),void 0,{...Re.attrs,height:G,heightRule:"atLeast"}),xe+=Re.nodeSize,ye++;}),C.dispatch(le);break}}}return}if(gn.current){gn.current=false,Yt.current&&(Yt.current.classList.remove("dragging"),Yt.current=null);let C=q$1.current?.getView();if(C){let O=No.current,K=gr.current,G=an.current,ee=C.state.doc.resolve(O+1);for(let W=ee.depth;W>=0;W--){let J=ee.node(W);if(J.type.name==="table"){let te=ee.before(W),le=C.state.tr,xe=[...J.attrs.columnWidths];xe[K]=G,le.setNodeMarkup(te,void 0,{...J.attrs,columnWidths:xe});let ye=te+1;J.forEach(Re=>{let ke=ye+1,he=0;Re.forEach(Be=>{let $e=Be.attrs.colspan||1;he===K&&le.setNodeMarkup(le.mapping.map(ke),void 0,{...Be.attrs,width:G,widthType:"dxa",colwidth:null}),ke+=Be.nodeSize,he+=$e;}),ye+=Re.nodeSize;}),C.dispatch(le);break}}}return}Le.current=false,en.current=false,ko.current=null,Ht.current=null,yr();},[yr]);useEffect(()=>(window.addEventListener("mousemove",zo),window.addEventListener("mouseup",Yn),()=>{window.removeEventListener("mousemove",zo),window.removeEventListener("mouseup",Yn);}),[zo,Yn]);let qn=useCallback(C=>{if(d||Le.current||lt.current||Oe.current||gn.current||en.current)return;let O=se.current;if(!O)return;let K=C.clientX,G=C.clientY,ee=C.target.closest(".layout-table");if(!ee){let ke=O.querySelectorAll(".layout-table");for(let he of Array.from(ke)){let Be=he.getBoundingClientRect(),$e=K>=Be.left-bo&&K<Be.left,ut=G>=Be.top-bo&&G<Be.top,ht=K>=Be.left-bo&&K<=Be.right,ln=G>=Be.top-bo&&G<=Be.bottom;if($e&&ln||ut&&ht){ee=he;break}}}if(!ee){It(null);return}let W=ee.getBoundingClientRect(),J=K<W.left+bo&&K>=W.left-bo,te=G<W.top+bo&&G>=W.top-bo;if(!J&&!te){It(null);return}let le=ee.querySelectorAll(":scope > .layout-table-row");if(le.length===0){It(null);return}let xe=O.parentElement;if(!xe)return;let ye=xe.getBoundingClientRect(),Re=ke=>ke&&Number(ke.dataset.pmStart)||0;if(J)for(let ke=0;ke<le.length;ke++){let he=le[ke].getBoundingClientRect();if(G>=he.top&&G<=he.bottom){let Be=le[ke].querySelector(".layout-table-cell"),$e=Re(Be);if(!$e)break;let ut=he.top+he.height/2;It({type:"row",x:W.left-ye.left-24,y:ut-ye.top-10,cellPmPos:$e}),gt();return}}if(te){let ke=le[0].querySelectorAll(":scope > .layout-table-cell");for(let he=0;he<ke.length;he++){let Be=ke[he].getBoundingClientRect();if(K>=Be.left&&K<=Be.right){let $e=Re(ke[he]);if(!$e)break;let ut=Be.left+Be.width/2;It({type:"column",x:ut-ye.left-10,y:W.top-ye.top-24,cellPmPos:$e}),gt();return}}}bn.current||(bn.current=setTimeout(()=>{It(null),bn.current=null;},ak));},[d,gt]),Ps=useCallback(C=>{if(C.preventDefault(),C.stopPropagation(),!hn||!q$1.current)return;let O=q$1.current.getView();if(!O)return;let{type:K,cellPmPos:G}=hn,ee=O.state.tr.setSelection(TextSelection.create(O.state.doc,G+1));O.dispatch(ee),K==="row"?Io(O.state,O.dispatch):Fo(O.state,O.dispatch),It(null),q$1.current.focus();},[hn]),Co=useCallback(C=>{let O=C.target.closest("a[href]");if(O){C.preventDefault();let K=O.getAttribute("href")||"";if(K.startsWith("#")){let G=K.substring(1);if(G&&q$1.current){let ee=q$1.current.getView();if(ee){let W=null;ee.state.doc.descendants((J,te)=>{if(W!==null)return false;if(J.type.name==="paragraph"&&J.attrs.bookmarks?.some(xe=>xe.name===G))return W=te,false}),W!==null&&(We(W),q$1.current.setSelection(W+1));}}}else if(ae){let G=q$1.current?.getView();if(!(G&&G.state.selection.from!==G.state.selection.to)){let W=O.textContent||"",J=O.getAttribute("title")||void 0,te=O.getBoundingClientRect();ae({href:K,displayText:W,tooltip:J,anchorRect:te});}}return}if(C.detail===2&&R){let K=C.target,G=K.closest(".layout-page-header"),ee=K.closest(".layout-page-footer");if(G||ee){let W=K.closest("[data-page-number]"),J=W?Number(W.dataset.pageNumber):1;if(G){C.preventDefault(),C.stopPropagation(),R("header",J);return}if(ee){C.preventDefault(),C.stopPropagation(),R("footer",J);return}}}if(C.detail===2&&q$1.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=An(K);if(G!==null){C.preventDefault(),C.stopPropagation(),q$1.current.setCellSelection(G,G);return}let ee=q$1.current.getView();if(ee){let{doc:W}=ee.state,J=W.resolve(K),te=J.parent;if(te.isTextblock){let le=te.textContent,xe=J.parentOffset,[ye,Re]=Nn(le,xe),ke=J.start()+ye,he=J.start()+Re;ke<he&&q$1.current.setSelection(ke,he);}}}}if(C.detail===3&&q$1.current){let K=$t(C.clientX,C.clientY);if(K!==null){let G=q$1.current.getView();if(G){let{doc:ee}=G.state,W=ee.resolve(K),J=W.start(W.depth),te=W.end(W.depth);q$1.current.setSelection(J,te);}}}},[$t,R,ae]),li=useCallback(C=>{if(!N)return;C.preventDefault();let O=q$1.current?.getView();if(!O)return;let{from:K,to:G}=O.state.selection,ee=$t(C.clientX,C.clientY);ee!==null&&(K===G||ee<K||ee>G)&&(q$1.current?.setSelection(ee),q$1.current?.focus(),ie(true));let W=q$1.current?.getState(),J=W?W.selection.from!==W.selection.to:false;N({x:C.clientX,y:C.clientY,hasSelection:J});},[N,$t]),xr=useCallback(C=>{if(d)return;let O=C.target;O.closest(".docx-comments-sidebar")||O.closest(".docx-unified-sidebar")||(q$1.current?.focus(),ie(true));},[d]),Oo=useCallback(C=>{let O=C.relatedTarget;O&&Pe.current?.contains(O)||O?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||ie(false);},[]),Lt=useCallback((C,O,K)=>{let G=q$1.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;let W=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,width:O,height:K});G.dispatch(W),q$1.current?.setNodeSelection(C);}catch{}},[]),ci=useCallback(()=>{we.current=true;},[]),Sr=useCallback(()=>{we.current=false;},[]),Dn=useCallback((C,O,K)=>{let G=q$1.current?.getView();if(G)try{let ee=G.state.doc.nodeAt(C);if(!ee||ee.type.name!=="image")return;if(ee.attrs.displayMode==="float"||ee.attrs.wrapType&&["square","tight","through"].includes(ee.attrs.wrapType)){let J=se.current?.querySelectorAll(".layout-page");if(!J||J.length===0)return;let te=null;for(let ut of J){let ht=ut.getBoundingClientRect();if(K>=ht.top&&K<=ht.bottom){te=ut.querySelector(".layout-page-content");break}}if(te||(te=J[J.length-1].querySelector(".layout-page-content")),!te)return;let le=te.getBoundingClientRect(),xe=(O-le.left)/f,ye=(K-le.top)/f,Re=914400/96,ke=Math.round(xe*Re),he=Math.round(ye*Re),Be={horizontal:{posOffset:ke,relativeTo:"margin"},vertical:{posOffset:he,relativeTo:"margin"}},$e=G.state.tr.setNodeMarkup(C,void 0,{...ee.attrs,position:Be});G.dispatch($e),q$1.current?.setNodeSelection(C);}else {let J=$t(O,K);if(J===null||J===C||J===C+1)return;let te=G.state.tr;if(J<=C)te=te.delete(C,C+ee.nodeSize),te=te.insert(J,ee),q$1.current?.setNodeSelection(J);else {te=te.delete(C,C+ee.nodeSize);let le=J-ee.nodeSize;te=te.insert(Math.min(le,te.doc.content.size),ee),q$1.current?.setNodeSelection(Math.min(le,te.doc.content.size-1));}G.dispatch(te);}}catch{}},[$t,f]),di=useCallback(()=>{we.current=true;},[]),To=useCallback(()=>{we.current=false;},[]),Ms=useCallback(C=>{if(!d){if(q$1.current?.isFocused()||(q$1.current?.focus(),ie(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey&&!C.nativeEvent.isComposing){C.preventDefault();let O=q$1.current?.getView();if(O){let{from:K,to:G}=O.state.selection;O.someProp("handleTextInput",W=>W(O,K,G," "))||O.dispatch(O.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=0);}if(C.key==="End"&&(C.metaKey||C.ctrlKey)){let O=ge();O&&(O.scrollTop=O.scrollHeight);}}},[d,ge]),Ae=useCallback(C=>{d||C.target.closest(".docx-comments-sidebar")||C.target.closest(".docx-unified-sidebar")||q$1.current?.isFocused()||(q$1.current?.focus(),ie(true));},[d]),Qe=useCallback(C=>{zt(C.state),Ot(C.state),d||requestAnimationFrame(()=>{C.focus(),ie(true);});},[zt,Ot,d]);useEffect(()=>{let C=()=>{let O=q$1.current?.getView();O&&(f$2(),Gl(),zt(O.state),Ot(O.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let ui=useRef(0);useEffect(()=>{if(ui.current===0){ui.current=1;return}let C=q$1.current?.getView();C&&zt(C.state);},[s,l,u,c,zt]),useEffect(()=>{let C=Pe.current;if(!C)return;let O=new ResizeObserver(()=>{let K=q$1.current?.getState();K&&Ot(K);});return O.observe(C),()=>O.disconnect()},[Ot]),useImperativeHandle(n$1,()=>({getDocument(){return q$1.current?.getDocument()??null},getState(){return q$1.current?.getState()??null},getView(){return q$1.current?.getView()??null},focus(){q$1.current?.focus(),ie(true);},blur(){q$1.current?.blur(),ie(false);},isFocused(){return q$1.current?.isFocused()??false},dispatch(C){q$1.current?.dispatch(C);},undo(){return q$1.current?.undo()??false},redo(){return q$1.current?.redo()??false},setSelection(C,O){q$1.current?.setSelection(C,O);},getLayout(){return Q},relayout(){let C=q$1.current?.getState();C&&zt(C);},scrollToPosition:We}),[Q,zt,We]),useEffect(()=>{let C=q$1.current?.getState();Q&&C&&Ot(C);},[Q,Ot]),useEffect(()=>{H.current&&q$1.current&&H.current({getDocument:()=>q$1.current?.getDocument()??null,getState:()=>q$1.current?.getState()??null,getView:()=>q$1.current?.getView()??null,focus:()=>{q$1.current?.focus(),ie(true);},blur:()=>{q$1.current?.blur(),ie(false);},isFocused:()=>q$1.current?.isFocused()??false,dispatch:C=>q$1.current?.dispatch(C),undo:()=>q$1.current?.undo()??false,redo:()=>q$1.current?.redo()??false,setSelection:(C,O)=>q$1.current?.setSelection(C,O),getLayout:()=>Q,relayout:()=>{let C=q$1.current?.getState();C&&zt(C);},scrollToPosition:We});},[Q,zt]);let kr=useMemo(()=>{if(!Q)return rm+48;let C=Q.pages.length;return C*Ft.h+(C-1)*p$1+48},[Q,Ft.h,p$1]);return jsxs("div",{ref:Pe,className:`ep-root paged-editor ${pe??""}`,style:{...lk,...$},tabIndex:0,onFocus:xr,onBlur:Oo,onKeyDown:Ms,onMouseDown:Ae,children:[jsx(uf,{ref:q$1,document:o$1,styles:r,widthPx:Et,readOnly:d,onTransaction:ue,onSelectionChange:br,externalPlugins:h,extensionManager:x,onEditorViewReady:Qe,onKeyDown:F}),jsxs("div",{style:{...ck,minHeight:kr,marginBottom:f!==1?kr*(f-1):void 0,transform:(()=>{let C=[];return v&&C.push(`translateX(-${176}px)`),f!==1&&C.push(`scale(${f})`),C.length>0?C.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsx("div",{ref:se,className:`paged-editor__pages${d?" paged-editor--readonly":""}${A?` paged-editor--hf-editing paged-editor--editing-${A}`:""}`,style:dk,onMouseDown:tn,onMouseMove:qn,onClick:Co,onContextMenu:li,"aria-hidden":"true"}),jsx(ff,{selectionRects:Ie,caretPosition:qe,isFocused:Z,pageGap:p$1,readOnly:d}),jsx(yf,{imageInfo:Xe,zoom:f,isFocused:Z,onResize:Lt,onResizeStart:ci,onResizeEnd:Sr,onDragMove:Dn,onDragStart:di,onDragEnd:To}),hn&&jsx("button",{type:"button",onMouseDown:Ps,onMouseEnter:gt,onMouseLeave:()=>It(null),style:{position:"absolute",left:hn.x,top:hn.y,width:20,height:20,borderRadius:"4px",border:"1px solid #dadce0",backgroundColor:"#f8f9fa",color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:hn.type==="row"?"Insert row below":"Insert column to the right","aria-label":hn.type==="row"?"Insert row below":"Insert column to the right",children: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"})})}),I&&jsx("div",{className:"paged-editor__plugin-overlays",style:uk,children:I})]}),_&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:kr*f,pointerEvents:"none",overflow:"visible"},children:jsx("div",{style:{pointerEvents:"auto"},children:_})})]})}),cm=memo(vk);var Mk=lazy(()=>import('./FindReplaceDialog-YW3R4FHM.mjs')),Ik=lazy(()=>import('./HyperlinkDialog-HNYTXDCB.mjs')),Fk=lazy(()=>import('./TablePropertiesDialog-LMXWX3FI.mjs').then(e=>({default:e.TablePropertiesDialog}))),Lk=lazy(()=>import('./ImagePositionDialog-B4RLP2W5.mjs').then(e=>({default:e.ImagePositionDialog}))),Bk=lazy(()=>import('./ImagePropertiesDialog-JOGW3WDU.mjs').then(e=>({default:e.ImagePropertiesDialog}))),Ak=lazy(()=>import('./FootnotePropertiesDialog-H24AC5XK.mjs').then(e=>({default:e.FootnotePropertiesDialog}))),Dk=lazy(()=>import('./PageSetupDialog-Q7SHEZIJ.mjs').then(e=>({default:e.PageSetupDialog}))),dm=[{value:"editing",label:"Editing",icon:"edit_note",desc:"Edit document directly"},{value:"suggesting",label:"Suggesting",icon:"rate_review",desc:"Edits become suggestions"},{value:"viewing",label:"Viewing",icon:"visibility",desc:"Read-only, no edits"}];function zk({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}),c=dm.find(d=>d.value===e);return useEffect(()=>{let d=window.matchMedia("(max-width: 1400px)");i(d.matches);let p=f=>i(f.matches);return d.addEventListener("change",p),()=>d.removeEventListener("change",p)},[]),useEffect(()=>{if(!n||!a.current)return;let d=a.current.getBoundingClientRect();u({top:d.bottom+2,left:d.right-220});},[n]),useEffect(()=>{if(!n)return;let d=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p);}},[n]),jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:a,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(!n),title:`${c.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsx(d,{name:c.icon,size:18}),!r&&jsx("span",{children:c.label}),jsx(d,{name:"arrow_drop_down",size:16})]}),n&&jsx("div",{ref:s,onMouseDown:d=>d.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:dm.map(d$1=>jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(d$1.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:d$1.icon,size:20}),jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsx("span",{style:{fontWeight:500},children:d$1.label}),jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:d$1.desc})]}),d$1.value===e&&jsx(d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},d$1.value))})]})}var cc=1,ri=-1;function Ok(e,t){let n=t.filter(i=>i.parentId!=null);if(n.length===0)return;let o=new Map;for(let i of n){let a=o.get(i.parentId);a?a.push(i.id):o.set(i.parentId,[i.id]);}function r(i){for(let a of i)if(a.type==="paragraph"){if(!a.content.some(l=>l.type==="commentRangeStart"||l.type==="commentRangeEnd"))continue;let s=[];for(let l of a.content)if(l.type==="commentRangeStart"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeStart",id:c});}else if(l.type==="commentRangeEnd"){s.push(l);let u=o.get(l.id);if(u)for(let c of u)s.push({type:"commentRangeEnd",id:c});}else s.push(l);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let l of s.cells)r(l.content);}r(e);}function $k(e,t){let n=new Set(t.map(a=>a.id)),o=t.filter(a=>a.parentId!=null&&!n.has(a.parentId));if(o.length===0)return;let r=new Map;for(let a of o){let s=r.get(a.parentId);s?s.push(a.id):r.set(a.parentId,[a.id]);}function i(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(d=>(d.type==="insertion"||d.type==="deletion")&&r.has(d.info.id)))continue;let u=[],c=s.content;for(let d=0;d<c.length;d++){let p=c[d];if((p.type==="insertion"||p.type==="deletion")&&r.has(p.info.id)){let f=r.get(p.info.id);for(let b of f)u.push({type:"commentRangeStart",id:b});u.push(p);let m=c[d+1];m&&(m.type==="insertion"||m.type==="deletion")&&m.type!==p.type&&m.info.author===p.info.author&&m.info.date===p.info.date&&(u.push(m),d++);for(let b of f)u.push({type:"commentRangeEnd",id:b});}else u.push(p);}s.content=u;}else if(s.type==="table")for(let l of s.rows)for(let u of l.cells)i(u.content);}i(e);}var um=new Map;function pm(e,t,n){if(!e||!t)return null;let o=e.querySelector(".paged-editor__pages");if(!o)return null;let r=o.querySelectorAll("[data-pm-start]");for(let i of r){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(n>=s&&n<=l)return a.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function lc(e,t,n){return {id:cc++,author:t,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:e}]}]}],...n!==void 0&&{parentId:n}}}var mm=forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i$1,onSelectionChange:a$3,onError:s,onFontsLoaded:l$2,theme:u,showToolbar:c$1=true,showZoomControl:d$1=true,showMarginGuides:p=false,marginGuideColor:f$1,showRuler:m$2=false,rulerUnit:b="inch",initialZoom:h$1=1,readOnly:x=false,toolbarExtra:T,className:S="",style:I,placeholder:R,loadingIndicator:A$1,showOutline:L=false,showOutlineButton:pe=true,showPrintButton:$=true,printOptions:v,onPrint:_,onCopy:re,onCut:ae,onPaste:N,mode:D,onModeChange:de,onCommentAdd:ge,onCommentResolve:Pe,onCommentDelete:se,onCommentReply:q,externalPlugins:E$1,onEditorViewReady:F,onRenderedDomContextReady:k,pluginOverlays:P,pluginSidebarItems:M,pluginRenderedDomContext:H,renderLogo:oe,documentName:Q,onDocumentNameChange:V,documentNameEditable:Y=true,renderTitleBarRight:ne,i18n:Se},Me){let[Z$1,ie]=useState({isLoading:!!t,parseError:null,zoom:h$1,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Ie,He]=useState(false),[qe,je]=useState(false),[Xe,_e]=useState(false),[we,xt]=useState(false),[Le,ze]=useState(null),[lt,nt]=useState(false),[ft,Rt]=useState(L),Ne=useRef(false);Ne.current=ft;let[mt,Oe]=useState([]),[St,Jt]=useState(false),[Gt,jn]=useState(null),[dt,Qt]=useState([]),[gn,So]=useState([]),[gr,No]=useState(um),[an,Yt]=useState(false),[en,Dt]=useState(null),[ko,Ht]=useState(null),[Rs,hn]=useState(D??"editing"),It=D??Rs,bn=y=>{D||hn(y),de?.(y);},gt=x||It==="viewing",[Nt,Ft]=useState(null),[ot,Kn]=useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),Et=useRef(null),yn=useRef(null),zt=useRef(dt);zt.current=dt;let sn=useRef(an);sn.current=an;let hr=useRef(se);hr.current=se;let Bn=useCallback(()=>{let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,B=w.marks.insertion,z=w.marks.deletion;if(!B&&!z)return;let U=[];g.descendants((ce,me)=>{if(ce.isText)for(let Ce of ce.marks)(Ce.type===B||Ce.type===z)&&U.push({type:Ce.type===B?"insertion":"deletion",text:ce.text||"",author:Ce.attrs.author||"",date:Ce.attrs.date,from:me,to:me+ce.nodeSize,revisionId:Ce.attrs.revisionId});});let j=[];for(let ce of U){let me=j[j.length-1];me&&me.revisionId===ce.revisionId&&me.type===ce.type&&me.to===ce.from?(me.text+=ce.text,me.to=ce.to):j.push({...ce});}let X=[];for(let ce=0;ce<j.length;ce++){let me=j[ce],Ce=j[ce+1];me.type==="deletion"&&Ce&&Ce.type==="insertion"&&me.author===Ce.author&&me.date===Ce.date&&me.to===Ce.from?(X.push({type:"replacement",text:Ce.text,deletedText:me.text,author:me.author,date:me.date,from:me.from,to:Ce.to,revisionId:me.revisionId,insertionRevisionId:Ce.revisionId}),ce++):X.push(me);}So(X);let fe=w.marks.comment;if(fe&&X.length>0){let ce=new Map;g.descendants(me=>{if(!me.isText)return;let Ce=me.marks.find(Fe=>Fe.type===fe),Ve=me.marks.find(Fe=>Fe.type===B||Fe.type===z);if(Ce&&Ve){let Fe=Ce.attrs.commentId,Tt=Ve.attrs.revisionId;ce.has(Fe)||ce.set(Fe,Tt);}}),ce.size>0&&Qt(me=>{let Ce=false,Ve=me.map(Fe=>{if(Fe.parentId!=null)return Fe;let Tt=ce.get(Fe.id);return Tt!=null?(Ce=true,{...Fe,parentId:Tt}):Fe});return Ce?Ve:me});}},[]),Ot=useCallback(()=>{if(sn.current)return;let y=We.current?.getView();if(!y)return;let{doc:g,schema:w}=y.state,B=w.marks.comment;if(!B)return;let z=new Set;g.descendants(X=>{for(let fe of X.marks)if(fe.type===B){let ce=fe.attrs.commentId;ce!==ri&&z.add(ce);}});let U=zt.current,j=new Set;for(let X of U)X.parentId==null&&!z.has(X.id)&&j.add(X.id);if(j.size!==0){for(let X of U)j.has(X.id)&&hr.current?.(X);Qt(X=>X.filter(fe=>!j.has(fe.id)&&!j.has(fe.parentId)));}},[]);useEffect(()=>()=>{Et.current&&clearTimeout(Et.current),yn.current&&clearTimeout(yn.current);},[]),useEffect(()=>{if(Rt(L),L){let y=We.current?.getView();y&&Oe(Qo(y.state.doc));}},[L]);let ue=Qp(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),br=useRef(false);useEffect(()=>{if(br.current)return;let y=ue.state;if(!y)return;let g=y.package?.document?.comments;if(g&&g.length>0){Qt(g),Jt(true),br.current=true;let w=g.reduce((z,U)=>Math.max(z,U.id),0),B=We.current?.getView();B&&B.state.doc.descendants(z=>{for(let U of z.marks)U.attrs.revisionId!=null&&(w=Math.max(w,U.attrs.revisionId));}),w>=cc&&(cc=w+1);}},[ue.state]);let $t=useMemo(()=>{let y=new to(rr());return y.buildSchema(),y.initializeRuntime(),y},[]),An=useMemo(()=>rf(It==="suggesting",r),[]),Es=useMemo(()=>[An,...E$1??[]],[An,E$1]),We=useRef(null),tn=useRef(null),Gn=useRef(null),nn=useRef(null),yr=useRef(null),zo=useRef(null),Yn=useRef(null),qn=useRef(null),Ps=useRef(null),Co=useRef(null),[li,xr]=useState(0),Oo=useRef(ue.state);Oo.current=ue.state;let Lt=useRef({style:"single",size:4,color:{rgb:"000000"}}),ci=useRef(null),Sr=useCallback(y=>{let g=ci.current;if(g&&g.styles===y)return g.resolver;let w=On(y);return ci.current={styles:y,resolver:w},w},[]),[Dn,di]=useState({currentPage:1,totalPages:1,visible:false}),To=useRef(null),Ms=useCallback(y=>{if(Ps.current=y,Co.current&&(Co.current.disconnect(),Co.current=null),!y){xr(0);return}xr(y.offsetHeight);let g=new ResizeObserver(()=>{xr(y.offsetHeight);});g.observe(y),Co.current=g;},[]);useEffect(()=>()=>{Co.current?.disconnect();},[]);let Ae=useCallback(()=>Le&&tn.current?tn.current.getView():We.current?.getView(),[Le]),Qe=useCallback(()=>{Le&&tn.current?tn.current.focus():We.current?.focus();},[Le]),ui=useCallback(()=>{Le&&tn.current?tn.current.undo():We.current?.undo();},[Le]),kr=useCallback(()=>{Le&&tn.current?tn.current.redo():We.current?.redo();},[Le]),C$1=m(),O=m$1(),[K,G]=useState(false),ee=useCallback(()=>G(true),[]),[W,J]=useState(null),te=useRef(0),le=useCallback(()=>{br.current=false,Re.current=false,Qt([]),So([]),Oe([]),Jt(false),Yt(false),Dt(null),Ht(null),Ft(null),ze(null),No(um),C$1.setMatches([],0),Et.current&&(clearTimeout(Et.current),Et.current=null),yn.current&&(clearTimeout(yn.current),yn.current=null);},[C$1.setMatches]),xe=useCallback(y=>{le(),ue.reset(y),ie(g=>({...g,isLoading:false,parseError:null})),l(y).catch(g=>{console.warn("Failed to load document fonts:",g);});},[le,ue]),ye=useCallback(async y=>{let g=++te.current;le(),ie(w=>({...w,isLoading:true,parseError:null}));try{let w=await n$1(y);if(te.current!==g)return;xe(w);}catch(w){if(te.current!==g)return;let B=w instanceof Error?w.message:"Failed to parse document";ie(z=>({...z,isLoading:false,parseError:B})),s?.(w instanceof Error?w:new Error(B));}},[le,xe,s]);useEffect(()=>{if(!t){n&&xe(n);return}ye(t);},[t,n]),useEffect(()=>{ue.state?Gn.current=new f(ue.state):Gn.current=null;},[ue.state]);let Re=useRef(false);useEffect(()=>{if(!Z$1.isLoading&&ue.state){let y=setTimeout(()=>{Bn(),Re.current||(Re.current=true,So(g=>(g.length>0&&Jt(true),g)));},200);return ()=>clearTimeout(y)}},[Z$1.isLoading,ue.state,Bn]),useEffect(()=>h(()=>{l$2?.();}),[l$2]),useEffect(()=>{let y=We.current?.getView();y&&af(It==="suggesting",y.state,y.dispatch,r);},[It,r]);let ke=useCallback(y=>(ue.push(y),y),[ue]),he=useCallback(y=>{if(ke(y),i$1?.(y),Ne.current){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}Et.current&&clearTimeout(Et.current),Et.current=setTimeout(Bn,300),yn.current&&clearTimeout(yn.current),yn.current=setTimeout(Ot,300);},[i$1,ke,Bn,Ot]),Be=useCallback(y=>{let g=Ae();if(g){let{from:Ve,to:Fe}=g.state.selection;yr.current={from:Ve,to:Fe};}let w=null;if(g&&(w=Ze(g.state),w.isInTable||(w=null)),w?.cellBorderColor){let Ve=w.cellBorderColor,Fe=Ve.rgb;(!Fe||Fe==="auto")&&(Fe=a(Ve,u).replace(/^#/,"")),Lt.current={...Lt.current,color:{rgb:Fe}};}let B=null;if(g){let Ve=g.state.selection,Fe=Ve.node;Fe?.type.name==="image"&&(B={pos:Ve.from,wrapType:Fe.attrs.wrapType??"inline",displayMode:Fe.attrs.displayMode??"inline",cssFloat:Fe.attrs.cssFloat??null,transform:Fe.attrs.transform??null,alt:Fe.attrs.alt??null,borderWidth:Fe.attrs.borderWidth??null,borderColor:Fe.attrs.borderColor??null,borderStyle:Fe.attrs.borderStyle??null});}if(!y){Ft(null),ie(Ve=>({...Ve,selectionFormatting:{},pmTableContext:w,pmImageContext:B}));return}let{textFormatting:z,paragraphFormatting:U}=y,j=z.fontFamily?.ascii||z.fontFamily?.hAnsi,X=z.fontSize;if(!j||!X){let Ve=Oo.current,Fe=y.styleId;if(Ve?.package.styles&&Fe){let Ct=Sr(Ve.package.styles).resolveParagraphStyle(Fe);!j&&Ct.runFormatting?.fontFamily&&(j=Ct.runFormatting.fontFamily.ascii||Ct.runFormatting.fontFamily.hAnsi),!X&&Ct.runFormatting?.fontSize&&(X=Ct.runFormatting.fontSize);}}let fe=z.color?.rgb?`#${z.color.rgb}`:void 0,ce=U.numPr,me=ce?{type:ce.numId===1?"bullet":"numbered",level:ce.ilvl??0,isInList:true,numId:ce.numId}:void 0,Ce={bold:z.bold,italic:z.italic,underline:!!z.underline,strike:z.strike,superscript:z.vertAlign==="superscript",subscript:z.vertAlign==="subscript",fontFamily:j,fontSize:X,color:fe,highlight:z.highlight,alignment:U.alignment,lineSpacing:U.lineSpacing,listState:me,styleId:y.styleId??void 0,indentLeft:U.indentLeft,bidi:!!U.bidi};if(ie(Ve=>({...Ve,selectionFormatting:Ce,paragraphIndentLeft:U.indentLeft??0,paragraphIndentRight:U.indentRight??0,paragraphFirstLineIndent:U.indentFirstLine??0,paragraphHangingIndent:U.hangingIndent??false,paragraphTabs:U.tabs??null,pmTableContext:w,pmImageContext:B})),g&&y.hasSelection&&!an&&!gt){let Ve=qn.current,Fe=Yn.current,{from:Tt}=g.state.selection,Ct=pm(Ve,Fe,Tt);if(Ct!=null&&Ve&&Fe){let Er=Ve.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),wi=Er?Er.getBoundingClientRect().right-Fe.getBoundingClientRect().left:Fe.getBoundingClientRect().width/2+408;Ft({top:Ct,left:wi});}}else Ft(null);a$3?.(y);},[a$3,an,gt]),$e=fd({document:ue.state,onChange:he,onSelectionChange:y=>{}});useEffect(()=>{let y=g=>{let B=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey;if(!B&&!g.shiftKey&&!g.altKey&&(g.key==="Delete"||g.key==="Backspace")){let z=We.current?.getView();if(z){let U=z.state.selection;if("$anchorCell"in U&&typeof U.forEachCell=="function"){let X=Ze(z.state);if(X.isInTable&&X.table){let fe=0;X.table.descendants(me=>{(me.type.name==="tableCell"||me.type.name==="tableHeader")&&(fe+=1);});let ce=0;if(U.forEachCell(()=>{ce+=1;}),fe>0&&ce>=fe){g.preventDefault(),Gr(z.state,z.dispatch);return}}}}if($e.state.tableIndex!==null){g.preventDefault(),$e.handleAction("deleteTable");return}}if(B&&!g.shiftKey&&!g.altKey){if(g.key.toLowerCase()==="f"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C$1.openFind(U);}else if(g.key.toLowerCase()==="h"){g.preventDefault();let z=window.getSelection(),U=z&&!z.isCollapsed?z.toString():"";C$1.openReplace(U);}else if(g.key.toLowerCase()==="k"){g.preventDefault();let z=We.current?.getView();if(z){let U=nr(z.state),j=tr(z.state);j?O.openEdit({url:j.href,displayText:U,tooltip:j.tooltip}):O.openInsert(U);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[C$1,O,$e]);let ut=useCallback((y,g)=>{let w=Ae();w&&(va(y,g)(w.state,w.dispatch),Qe());},[Ae,Qe]),ht=useCallback(()=>{let y=Ae();y&&(Ga(y.state,y.dispatch),Qe());},[Ae,Qe]),ln=useCallback(()=>{let y=Ae();y&&(wa(y.state,y.dispatch),Qe());},[Ae,Qe]),$o=useCallback(()=>{Rt(y=>{if(!y){let g=We.current?.getView();g&&Oe(Qo(g.state.doc));}return !y});},[]),pi=useCallback(y=>{We.current?.scrollToPosition(y),We.current?.setSelection(y+1),We.current?.focus();},[]),fi=useCallback(()=>{zo.current?.click();},[]),mi=useCallback(y=>{let g=y.target.files?.[0];if(!g)return;let w=Ae();if(!w)return;let B=new FileReader;B.onload=()=>{let z=B.result,U=new Image;U.onload=()=>{let j=U.naturalWidth,X=U.naturalHeight,fe=612;if(j>fe){let Fe=fe/j;j=fe,X=Math.round(X*Fe);}let ce=`rId_img_${Date.now()}`,me=w.state.schema.nodes.image.create({src:z,alt:g.name,width:j,height:X,rId:ce,wrapType:"inline",displayMode:"inline"}),{from:Ce}=w.state.selection,Ve=w.state.tr.insert(Ce,me);w.dispatch(Ve.scrollIntoView()),Qe();},U.src=z;},B.readAsDataURL(g),y.target.value="";},[Ae,Qe]),gi=useCallback(y=>{let g=Ae();if(!g||!Z$1.pmImageContext)return;let w=Z$1.pmImageContext.pos,B=g.state.doc.nodeAt(w);if(!B||B.type.name!=="image")return;let z="inline",U=null;switch(y){case "inline":z="inline",U=null;break;case "square":case "tight":case "through":z="float",U="left";break;case "topAndBottom":z="block",U=null;break;case "behind":case "inFront":z="float",U="none";break;case "wrapLeft":z="float",U="right",y="square";break;case "wrapRight":z="float",U="left",y="square";break}let j=g.state.tr.setNodeMarkup(w,void 0,{...B.attrs,wrapType:y,displayMode:z,cssFloat:U});g.dispatch(j.scrollIntoView()),Qe();},[Ae,Qe,Z$1.pmImageContext]),Cr=useCallback(y=>{let g=Ae();if(!g||!Z$1.pmImageContext)return;let w=Z$1.pmImageContext.pos,B=g.state.doc.nodeAt(w);if(!B||B.type.name!=="image")return;let z=B.attrs.transform||"",U=z.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),j=U?parseFloat(U[1]):0,X=/scaleX\(-1\)/.test(z),fe=/scaleY\(-1\)/.test(z);switch(y){case "rotateCW":j=(j+90)%360;break;case "rotateCCW":j=(j-90+360)%360;break;case "flipH":X=!X;break;case "flipV":fe=!fe;break}let ce=[];j!==0&&ce.push(`rotate(${j}deg)`),X&&ce.push("scaleX(-1)"),fe&&ce.push("scaleY(-1)");let me=ce.length>0?ce.join(" "):null,Ce=g.state.tr.setNodeMarkup(w,void 0,{...B.attrs,transform:me});g.dispatch(Ce.scrollIntoView()),Qe();},[Ae,Qe,Z$1.pmImageContext]),Tr=useCallback(y=>{let g=Ae();if(!g||!Z$1.pmImageContext)return;let w=Z$1.pmImageContext.pos,B=g.state.doc.nodeAt(w);if(!B||B.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...B.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??B.attrs.distTop,distBottom:y.distBottom??B.attrs.distBottom,distLeft:y.distLeft??B.attrs.distLeft,distRight:y.distRight??B.attrs.distRight});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z$1.pmImageContext]),_o=useCallback(()=>{_e(true);},[]),cn=useCallback(y=>{let g=Ae();if(!g||!Z$1.pmImageContext)return;let w=Z$1.pmImageContext.pos,B=g.state.doc.nodeAt(w);if(!B||B.type.name!=="image")return;let z=g.state.tr.setNodeMarkup(w,void 0,{...B.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});g.dispatch(z.scrollIntoView()),Qe();},[Ae,Qe,Z$1.pmImageContext]),wo=useCallback((y,g)=>{if(!ue.state?.package)return;let w={...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:g}};ke({...ue.state,package:{...ue.state.package,document:w}});},[ue,ke]),wr=useCallback(y=>{let g=Ae();if(g){switch(y){case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "deleteTable":Gr(g.state,g.dispatch);break;case "selectTable":Ra(g.state,g.dispatch);break;case "selectRow":Ea(g.state,g.dispatch);break;case "selectColumn":Pa(g.state,g.dispatch);break;case "mergeCells":Ma(g.state,g.dispatch);break;case "splitCell":Ia(g.state,g.dispatch);break;case "borderAll":La(g.state,g.dispatch,Lt.current);break;case "borderOutside":Ba(g.state,g.dispatch,Lt.current);break;case "borderInside":Aa(g.state,g.dispatch,Lt.current);break;case "borderNone":Fa(g.state,g.dispatch);break;case "borderTop":no("top",Lt.current,true)(g.state,g.dispatch);break;case "borderBottom":no("bottom",Lt.current,true)(g.state,g.dispatch);break;case "borderLeft":no("left",Lt.current,true)(g.state,g.dispatch);break;case "borderRight":no("right",Lt.current,true)(g.state,g.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")Ua(y.color)(g.state,g.dispatch);else if(y.type==="borderColor"){let w=y.color.replace(/^#/,"");Lt.current={...Lt.current,color:{rgb:w}},ja(y.color)(g.state,g.dispatch);}else if(y.type==="borderWidth")Lt.current={...Lt.current,size:y.size},Ka(y.size)(g.state,g.dispatch);else if(y.type==="cellBorder")no(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(g.state,g.dispatch);else if(y.type==="cellVerticalAlign")Da(y.align)(g.state,g.dispatch);else if(y.type==="cellMargins")Ha(y.margins)(g.state,g.dispatch);else if(y.type==="cellTextDirection")Na(y.direction)(g.state,g.dispatch);else if(y.type==="toggleNoWrap")za()(g.state,g.dispatch);else if(y.type==="rowHeight")Oa(y.height,y.rule)(g.state,g.dispatch);else if(y.type==="toggleHeaderRow")$a()(g.state,g.dispatch);else if(y.type==="distributeColumns")_a()(g.state,g.dispatch);else if(y.type==="autoFitContents")Wa()(g.state,g.dispatch);else if(y.type==="openTableProperties")He(true);else if(y.type==="tableProperties")Yr(y.props)(g.state,g.dispatch);else if(y.type==="applyTableStyle"){let w=Yp(y.styleId),B=Oo.current;if(!w&&B?.package.styles){let U=Sr(B.package.styles).getStyle(y.styleId);if(U){if(w={id:U.styleId,name:U.name??U.styleId},U.tblPr?.borders){let j=U.tblPr.borders;w.tableBorders={};for(let X of ["top","bottom","left","right","insideH","insideV"]){let fe=j[X];fe&&(w.tableBorders[X]={style:fe.style,size:fe.size,color:fe.color?.rgb?{rgb:fe.color.rgb}:void 0});}}if(U.tblStylePr){w.conditionals={};for(let j of U.tblStylePr){let X={};if(j.tcPr?.shading?.fill&&(X.backgroundColor=`#${j.tcPr.shading.fill}`),j.tcPr?.borders){let fe={};for(let ce of ["top","bottom","left","right"]){let me=j.tcPr.borders[ce];me&&(fe[ce]={style:me.style,size:me.size,color:me.color?.rgb?{rgb:me.color.rgb}:void 0});}X.borders=fe;}j.rPr?.bold&&(X.bold=true),j.rPr?.color?.rgb&&(X.color=`#${j.rPr.color.rgb}`),w.conditionals[j.type]=X;}}w.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}w&&Va({styleId:w.id,tableBorders:w.tableBorders,conditionals:w.conditionals,look:w.look})(g.state,g.dispatch);}}else $e.handleAction(y);}Qe();}},[$e,Ae,Qe]),Is=useCallback(y=>{y.preventDefault(),y.stopPropagation();let g=We.current?.getView(),w=g?Qn(g.state):false,{from:B,to:z}=g?.state.selection??{from:0,to:0},U=B!==z;Kn({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:U,cursorInTable:w});},[]),vr=useCallback(y=>{let g=Ae();if(!g)return;g.focus();let w=g===We.current?.getView(),{from:B,to:z$1}=g.state.selection,U=yr.current;if(w&&U&&(B!==U.from||z$1!==U.to))try{let j=g.state.tr.setSelection(TextSelection.create(g.state.doc,U.from,U.to));g.dispatch(j);}catch(j){console.warn("Could not restore selection:",j);}if(y==="bold"){Qi(g.state,g.dispatch);return}if(y==="italic"){ea(g.state,g.dispatch);return}if(y==="underline"){ta(g.state,g.dispatch);return}if(y==="strikethrough"){na(g.state,g.dispatch);return}if(y==="superscript"){oa(g.state,g.dispatch);return}if(y==="subscript"){ra(g.state,g.dispatch);return}if(y==="bulletList"){ba(g.state,g.dispatch);return}if(y==="numberedList"){ya(g.state,g.dispatch);return}if(y==="indent"){xa(g.state,g.dispatch)||fa()(g.state,g.dispatch);return}if(y==="outdent"){Sa(g.state,g.dispatch)||ma()(g.state,g.dispatch);return}if(y==="clearFormatting"){Hr(g.state,g.dispatch);return}if(y==="setRtl"){Ca(g.state,g.dispatch);return}if(y==="setLtr"){Ta(g.state,g.dispatch);return}if(y==="insertLink"){let j=nr(g.state),X=tr(g.state);X?O.openEdit({url:X.href,displayText:j,tooltip:X.tooltip}):O.openInsert(j);return}if(typeof y=="object")switch(y.type){case "alignment":ua(y.value)(g.state,g.dispatch);break;case "textColor":{let j=y.value;typeof j=="string"?Or({rgb:j.replace("#","")})(g.state,g.dispatch):j.auto?ia(g.state,g.dispatch):Or(j)(g.state,g.dispatch);break}case "highlightColor":{let j=y.value?z(y.value):"";aa(j||y.value)(g.state,g.dispatch);break}case "fontSize":sa(i(y.value))(g.state,g.dispatch);break;case "fontFamily":la(y.value)(g.state,g.dispatch);break;case "lineSpacing":pa(y.value)(g.state,g.dispatch);break;case "applyStyle":{let j=Oo.current,X=j?.package.styles?Sr(j.package.styles):null;if(X){let fe=X.resolveParagraphStyle(y.value);Wr(y.value,{paragraphFormatting:fe.paragraphFormatting,runFormatting:fe.runFormatting})(g.state,g.dispatch);}else Wr(y.value)(g.state,g.dispatch);break}}},[Ae]),hi=useCallback(y=>{ie(g=>({...g,zoom:y}));},[]),kt=useCallback(y=>{let g=Ae();if(!g)return;let w=y.url||"",B=y.tooltip,{empty:z}=g.state.selection;z&&y.displayText?$r(y.displayText,w,B)(g.state,g.dispatch):z?y.displayText&&$r(y.displayText,w,B)(g.state,g.dispatch):ca(w,B)(g.state,g.dispatch),O.close(),Qe();},[O,Ae,Qe]),Xn=useCallback(()=>{let y=Ae();y&&(da(y.state,y.dispatch),Qe());},[Ae,Qe]),xn=useCallback(()=>{Xn(),O.close();},[O,Xn]),vo=useCallback(y=>J(y),[]),Ro=useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),Fs=useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let g=document.createElement("textarea");g.value=y,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g);});},[]),Lm=useCallback((y,g)=>{let w=Ae();if(!w)return;let B=w.state.schema.marks.hyperlink;if(!B)return;let{$from:z}=w.state.selection,U=z.marks().find(j=>j.type===B);if(U){let j=z.parent,X=z.start(),fe=[],ce=null;j.forEach((Ct,Rr)=>{let Er=X+Rr,wi=Er+Ct.nodeSize;(Ct.isText?Ct.marks.find(bc=>bc.type===B&&bc.attrs.href===U.attrs.href):null)?ce?ce.end=wi:ce={start:Er,end:wi}:ce&&(fe.push(ce),ce=null);}),ce&&fe.push(ce);let me=z.pos,Ce=fe.find(Ct=>Ct.start<=me&&me<=Ct.end);if(!Ce)return;let Ve=w.state.tr,Fe=B.create({href:g,tooltip:U.attrs.tooltip}),Tt=w.state.schema.text(y,[...z.marks().filter(Ct=>Ct.type!==B),Fe]);Ve.replaceWith(Ce.start,Ce.end,Tt),w.dispatch(Ve.scrollIntoView());}J(null),Qe();},[Ae,Qe]),Bm=useCallback(()=>{let y=Ae();if(!y)return;let g=y.state.schema.marks.hyperlink;if(!g)return;let{$from:w}=y.state.selection,B=w.marks().find(Ce=>Ce.type===g);if(!B&&w.nodeAfter&&(B=w.nodeAfter.marks.find(Ce=>Ce.type===g)),!B&&w.nodeBefore&&(B=w.nodeBefore.marks.find(Ce=>Ce.type===g)),!B&&W&&w.parent.forEach(Ve=>{if(!B&&Ve.isText){let Fe=Ve.marks.find(Tt=>Tt.type===g&&Tt.attrs.href===W.href);Fe&&(B=Fe);}}),!B)return;let z=w.parent,U=w.start(),j=[],X=null;z.forEach((Ce,Ve)=>{let Fe=U+Ve,Tt=Fe+Ce.nodeSize;(Ce.isText?Ce.marks.find(Rr=>Rr.type===g&&Rr.attrs.href===B.attrs.href):null)?X?X.end=Tt:X={start:Fe,end:Tt}:X&&(j.push(X),X=null);}),X&&j.push(X);let fe=w.pos,ce=j.find(Ce=>Ce.start<=fe&&fe<=Ce.end);if(!ce)return;let me=y.state.tr;me.removeMark(ce.start,ce.end,g),y.dispatch(me.scrollIntoView()),J(null),Qe(),toast("Link removed");},[Ae,Qe,W]),Am=useCallback(()=>{J(null);},[]),Dm=useCallback(y=>{let g=We.current?.getView(),w=g?Qn(g.state):false;Kn({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:w});},[]),Hm=useCallback(()=>{Kn({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),fc=useMemo(()=>{let g=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",w=[{action:"cut",label:"Cut",shortcut:`${g}+X`},{action:"copy",label:"Copy",shortcut:`${g}+C`},{action:"paste",label:"Paste",shortcut:`${g}+V`},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:`${g}+Shift+V`,dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:!ot.hasSelection&&!ot.cursorInTable}];return ot.hasSelection&&w.push({action:"addComment",label:"Comment",dividerAfter:!ot.cursorInTable}),ot.cursorInTable&&w.push({action:"addRowAbove",label:"Insert row above"},{action:"addRowBelow",label:"Insert row below"},{action:"deleteRow",label:"Delete row",dividerAfter:true},{action:"addColumnLeft",label:"Insert column left"},{action:"addColumnRight",label:"Insert column right"},{action:"deleteColumn",label:"Delete column",dividerAfter:true}),w.push({action:"selectAll",label:"Select All",shortcut:`${g}+A`}),w},[ot.hasSelection,ot.cursorInTable]),mc=useCallback(async y=>{let g=Ae();if(g)switch(Qe(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let w=await navigator.clipboard.read(),B="",z="";for(let X of w)X.types.includes("text/html")&&(B=await(await X.getType("text/html")).text()),X.types.includes("text/plain")&&(z=await(await X.getType("text/plain")).text());let U=new DataTransfer;B&&U.items.add(B,"text/html"),z&&U.items.add(z,"text/plain");let j=new ClipboardEvent("paste",{clipboardData:U,bubbles:!0,cancelable:!0});g.dom.dispatchEvent(j);}catch{try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}}break}case "pasteAsPlainText":try{let w=await navigator.clipboard.readText();w&&g.dispatch(g.state.tr.insertText(w));}catch{}break;case "delete":{let{from:w,to:B}=g.state.selection;w!==B&&g.dispatch(g.state.tr.deleteRange(w,B));break}case "selectAll":g.dispatch(g.state.tr.setSelection(TextSelection.create(g.state.doc,0,g.state.doc.content.size)));break;case "addRowAbove":Vr(g.state,g.dispatch);break;case "addRowBelow":Io(g.state,g.dispatch);break;case "deleteRow":Ur(g.state,g.dispatch);break;case "addColumnLeft":jr(g.state,g.dispatch);break;case "addColumnRight":Fo(g.state,g.dispatch);break;case "deleteColumn":Kr(g.state,g.dispatch);break;case "addComment":{let{from:w,to:B}=g.state.selection;if(w===B)break;let z=pm(qn.current,Yn.current,w);Dt({from:w,to:B});let U=g.state.schema.marks.comment.create({commentId:ri}),j=g.state.tr.addMark(w,B,U);j.setSelection(TextSelection.create(j.doc,B)),g.dispatch(j),Ht(z),Jt(true),Yt(true),Ft(null);break}}},[Ae,Qe]),Zn=useCallback(y=>g=>{if(!ue.state||gt)return;let w={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,[y]:g}}}};he(w);},[ue.state,gt,he]),Nm=useMemo(()=>Zn("marginLeft"),[Zn]),zm=useMemo(()=>Zn("marginRight"),[Zn]),Om=useMemo(()=>Zn("marginTop"),[Zn]),$m=useMemo(()=>Zn("marginBottom"),[Zn]),_m=useCallback(y=>{if(!ue.state||gt)return;let g={...ue.state,package:{...ue.state.package,document:{...ue.state.package.document,finalSectionProperties:{...ue.state.package.document.finalSectionProperties,...y}}}};he(g);},[ue.state,gt,he]),Wm=useCallback(y=>{let g=Ae();g&&ga(y)(g.state,g.dispatch);},[Ae]),Vm=useCallback(y=>{let g=Ae();g&&ha(y)(g.state,g.dispatch);},[Ae]),Um=useCallback(y=>{let g=Ae();g&&(y<0?_r(-y,true)(g.state,g.dispatch):_r(y,false)(g.state,g.dispatch));},[Ae]),jm=useCallback(y=>{let g=Ae();g&&ka(y)(g.state,g.dispatch);},[Ae]),Wo=qn.current;useEffect(()=>{if(!Wo)return;let y=()=>{let g=We.current?.getLayout();if(!g||g.pages.length===0)return;let w=Wo.scrollTop,B=g.pages.length,z=24,U=24,j=w+Wo.clientHeight/2,X=U,fe=1;for(let ce=0;ce<g.pages.length;ce++){let me=g.pages[ce].size.h,Ce=X+me;if(j<Ce){fe=ce+1;break}X=Ce+z,fe=ce+2;}fe=Math.min(fe,B),di({currentPage:fe,totalPages:B,visible:true}),To.current&&clearTimeout(To.current),To.current=setTimeout(()=>{di(ce=>({...ce,visible:false}));},600);};return Wo.addEventListener("scroll",y,{passive:true}),()=>{Wo.removeEventListener("scroll",y),To.current&&clearTimeout(To.current);}},[Wo]);let gc=useCallback(async y=>{if(!Gn.current)return null;try{let g=Gn.current.getDocument(),w=We.current?.getDocument();w?.package?.document&&(g.package.document.content=w.package.document.content),g.package.document.comments=dt,Ok(g.package.document.content,dt),$k(g.package.document.content,dt);let B=y?.selective!==!1,z=We.current?.getView(),U;if(B&&z){let X=z.state,fe=dt.some(ce=>ce.parentId!=null);U={selective:{changedParaIds:sp(X),structuralChange:lp(X)||fe,hasUntrackedChanges:cp(X)}};}let j=await Gn.current.toBuffer(U);return z&&z.dispatch(dp(z.state)),o?.(j),j}catch(g){return s?.(g instanceof Error?g:new Error("Failed to save document")),null}},[o,s,dt]),Km=useCallback(y=>{s?.(y);},[s]),bi=useCallback(()=>{let y=nn.current?.querySelector(".paged-editor__pages");if(!y){window.print(),_?.();return}let g=window.open("","_blank");if(!g){window.print(),_?.();return}let w=[];for(let z of Array.from(document.styleSheets))try{for(let U of Array.from(z.cssRules))U instanceof CSSFontFaceRule&&w.push(U.cssText);}catch{}let B=y.cloneNode(true);B.style.cssText="display: block; margin: 0; padding: 0;";for(let z of Array.from(B.querySelectorAll(".layout-page"))){let U=z;U.style.boxShadow="none",U.style.margin="0";}g.document.write(`<!DOCTYPE html>
19
+ <html><head><title>Print</title>
20
+ <style>
21
+ ${w.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>${B.outerHTML}</body></html>`),g.document.close(),g.onload=()=>{g.print(),g.close();},setTimeout(()=>{g.closed||(g.print(),g.close());},1e3),_?.();},[_]),_t=useRef(null),Gm=useCallback((y,g)=>{if(!ue.state||!y.trim())return _t.current=null,null;let w=j(ue.state,y,g),B={matches:w,totalCount:w.length,currentIndex:0};return _t.current=B,C$1.setMatches(w,0),w.length>0&&nn.current&&l$1(nn.current,w[0]),B},[ue.state,C$1]),Ym=useCallback(()=>{if(!_t.current||_t.current.matches.length===0)return null;let y=C$1.goToNextMatch(),g=_t.current.matches[y];return g&&nn.current&&l$1(nn.current,g),g||null},[C$1]),qm=useCallback(()=>{if(!_t.current||_t.current.matches.length===0)return null;let y=C$1.goToPreviousMatch(),g=_t.current.matches[y];return g&&nn.current&&l$1(nn.current,g),g||null},[C$1]),Xm=useCallback(y=>{if(!ue.state||!_t.current||_t.current.matches.length===0)return false;let g=_t.current.matches[_t.current.currentIndex];if(!g)return false;try{let w=a$1(ue.state,{type:"replaceText",range:{start:{paragraphIndex:g.paragraphIndex,offset:g.startOffset},end:{paragraphIndex:g.paragraphIndex,offset:g.endOffset}},text:y});return he(w),!0}catch(w){return console.error("Replace failed:",w),false}},[ue.state,he]),Zm=useCallback((y,g,w)=>{if(!ue.state||!y.trim())return 0;let B=j(ue.state,y,w);if(B.length===0)return 0;let z=ue.state,U=[...B].sort((j,X)=>j.paragraphIndex!==X.paragraphIndex?X.paragraphIndex-j.paragraphIndex:X.startOffset-j.startOffset);for(let j of U)try{z=a$1(z,{type:"replaceText",range:{start:{paragraphIndex:j.paragraphIndex,offset:j.startOffset},end:{paragraphIndex:j.paragraphIndex,offset:j.endOffset}},text:g});}catch(X){console.error("Replace failed for match:",j,X);}return he(z),_t.current=null,C$1.setMatches([],0),B.length},[ue.state,he,C$1]);useImperativeHandle(Me,()=>({getAgent:()=>Gn.current,getDocument:()=>ue.state,getEditorRef:()=>We.current,save:gc,setZoom:y=>ie(g=>({...g,zoom:y})),getZoom:()=>Z$1.zoom,focus:()=>{We.current?.focus();},getCurrentPage:()=>Dn.currentPage,getTotalPages:()=>Dn.totalPages,scrollToPage:y=>{},openPrintPreview:bi,print:bi,loadDocument:xe,loadDocumentBuffer:ye}),[ue.state,Z$1.zoom,Dn,gc,bi,xe,ye]);let{headerContent:yi,footerContent:xi,firstPageHeaderContent:Si,firstPageFooterContent:ki}=useMemo(()=>{if(!ue.state?.package)return {headerContent:null,footerContent:null,firstPageHeaderContent:null,firstPageFooterContent:null};let y=ue.state.package,g=y.document?.finalSectionProperties,w=y.headers,B=y.footers,z=null,U=null,j=null,X=null;if(w&&g?.headerReferences){let fe=g.headerReferences.find(me=>me.type==="default");fe?.rId&&(z=w.get(fe.rId)??null);let ce=g.headerReferences.find(me=>me.type==="first");ce?.rId&&(j=w.get(ce.rId)??null);}if(B&&g?.footerReferences){let fe=g.footerReferences.find(me=>me.type==="default");fe?.rId&&(U=B.get(fe.rId)??null);let ce=g.footerReferences.find(me=>me.type==="first");ce?.rId&&(X=B.get(ce.rId)??null);}return g?.titlePg||(!z&&j&&(z=j),!U&&X&&(U=X)),{headerContent:z,footerContent:U,firstPageHeaderContent:j,firstPageFooterContent:X}},[ue.state]),Jm=useCallback((y,g)=>{let B=ue.state?.package?.document?.finalSectionProperties?.titlePg===true&&(g??1)===1,z=B?y==="header"?Si:ki:y==="header"?yi:xi;if(nt(B),z){ze(y);return}if(!ue.state?.package)return;let U=ue.state.package,j=U.document?.finalSectionProperties;if(!j)return;let X=B?"first":"default",fe=`rId_new_${y}_${X}`,ce={type:y==="header"?"header":"footer",hdrFtrType:X,content:[{type:"paragraph",content:[]}]},me=y==="header"?"headers":"footers",Ce=new Map(U[me]??[]);Ce.set(fe,ce);let Ve=y==="header"?"headerReferences":"footerReferences",Fe=j[Ve]??[],Tt={type:X,rId:fe},Ct={...ue.state,package:{...U,[me]:Ce,document:U.document?{...U.document,finalSectionProperties:{...j,[Ve]:[...Fe,Tt]}}:U.document}};ke(Ct),ze(y);},[yi,xi,Si,ki,ue,ke]),Ls=useCallback(y=>{if(!Le||!ue.state?.package){ze(null);return}let g=ue.state.package,w=g.document?.finalSectionProperties,B=Le==="header"?w?.headerReferences:w?.footerReferences,z=lt?"first":"default",U=B?.find(fe=>fe.type===z)??B?.find(fe=>fe.type==="default")??B?.find(fe=>fe.type==="first")??B?.[0],j=Le==="header"?"headers":"footers",X=g[j];if(U?.rId&&X){let fe=X.get(U.rId),ce={type:Le,hdrFtrType:U.type,...fe,content:y},me=new Map(X);me.set(U.rId,ce);let Ce={...ue.state,package:{...g,[j]:me}};ke(Ce);}ze(null);},[Le,ue,ke]),Qm=useCallback(()=>{if(!Le)return;let y=tn.current?.getView();if(y){let g=Ji(y.state.doc);Ls(g);}else ze(null);},[Le,Ls]),eg=useCallback(()=>{if(!Le||!ue.state?.package){ze(null);return}let y=ue.state.package,g=y.document?.finalSectionProperties,w=Le==="header"?"headerReferences":"footerReferences",B=Le==="header"?"headers":"footers",z=g?.[w],U=lt?"first":"default",j=z?.find(X=>X.type===U)??z?.find(X=>X.type==="default")??z?.find(X=>X.type==="first")??z?.[0];if(j?.rId){let X=new Map(y[B]??[]);X.delete(j.rId);let fe=(z??[]).filter(me=>me.rId!==j.rId),ce={...ue.state,package:{...y,[B]:X,document:y.document?{...y.document,finalSectionProperties:{...g,[w]:fe}}:y.document}};ke(ce);}ze(null);},[Le,ue,ke]),tg=useCallback(y=>{let g=nn.current?.querySelector(".paged-editor__pages");if(!g)return null;let w=y==="header"?".layout-page-header":".layout-page-footer";return g.querySelector(w)},[]),Ci={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...I},ng={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Sn=useRef({});Sn.current={onCommentReply:(y,g)=>{let w=lc(g,r,y),B=dt.find(z=>z.id===y);Qt(z=>[...z,w]),B&&q?.(w,B);},onCommentResolve:y=>{let g=dt.find(w=>w.id===y);Qt(w=>w.map(B=>B.id===y?{...B,done:true}:B)),g&&Pe?.({...g,done:true});},onCommentUnresolve:y=>{Qt(g=>g.map(w=>w.id===y?{...w,done:void 0}:w));},onCommentDelete:y=>{let g=dt.find(B=>B.id===y);Qt(B=>B.filter(z=>z.id!==y&&z.parentId!==y));let w=We.current?.getView();if(w){let B=w.state.schema.marks.comment?.create({commentId:y});if(B){let z=w.state.tr.removeMark(0,w.state.doc.content.size,B);z.docChanged&&w.dispatch(z);}}g&&se?.(g);},onAddComment:y=>{let g=lc(y,r),w=We.current?.getView();if(w&&en){let{from:B,to:z}=en,U=w.state.schema.marks.comment.create({commentId:ri}),j=w.state.schema.marks.comment.create({commentId:g.id}),X=w.state.tr.removeMark(B,z,U).addMark(B,z,j);w.dispatch(X);}Qt(B=>[...B,g]),Yt(false),Dt(null),Ht(null),ge?.(g);},onCancelAddComment:()=>{let y=We.current?.getView();if(y&&en){let{from:g,to:w}=en,B=y.state.schema.marks.comment.create({commentId:ri});y.dispatch(y.state.tr.removeMark(g,w,B));}Yt(false),Dt(null),Ht(null);},onAcceptChange:(y,g)=>{let w=We.current?.getView();w&&(Hp(y,g)(w.state,w.dispatch),Bn());},onRejectChange:(y,g)=>{let w=We.current?.getView();w&&(Np(y,g)(w.state,w.dispatch),Bn());},onTrackedChangeReply:(y,g)=>{Qt(w=>[...w,lc(g,r,y)]);}};let og=useMemo(()=>({onCommentReply:(...y)=>Sn.current.onCommentReply?.(...y),onCommentResolve:(...y)=>Sn.current.onCommentResolve?.(...y),onCommentUnresolve:(...y)=>Sn.current.onCommentUnresolve?.(...y),onCommentDelete:(...y)=>Sn.current.onCommentDelete?.(...y),onAddComment:(...y)=>Sn.current.onAddComment?.(...y),onCancelAddComment:(...y)=>Sn.current.onCancelAddComment?.(...y),onAcceptChange:(...y)=>Sn.current.onAcceptChange?.(...y),onRejectChange:(...y)=>Sn.current.onRejectChange?.(...y),onTrackedChangeReply:(...y)=>Sn.current.onTrackedChangeReply?.(...y)}),[]),Ti=Hd({comments:dt,trackedChanges:gn,callbacks:og,showResolved:St,isAddingComment:St?an:false,addCommentYPosition:ko}),Bs=useMemo(()=>{let y=[];return St&&y.push(...Ti),M&&y.push(...M),y},[St,Ti,M]),hc=useMemo(()=>{let y=new Map;return gn.forEach((g,w)=>{g.type==="replacement"&&g.insertionRevisionId!=null&&y.set(String(g.insertionRevisionId),`tc-${g.revisionId}-${w}`);}),y},[gn]),As=Bs.length>0,Vo=useMemo(()=>{let y=new Set;for(let g of dt)g.done&&g.parentId==null&&y.add(g.id);return y},[dt]),rg=useMemo(()=>{if(!Gt?.startsWith("comment-"))return Vo;let y=parseInt(Gt.slice(8),10);if(isNaN(y)||!Vo.has(y))return Vo;let g=new Set(Vo);return g.delete(y),g},[Vo,Gt]),ig={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};if(Z$1.isLoading)return jsx("div",{className:`ep-root docx-editor docx-editor-loading ${S}`,style:Ci,"data-testid":"docx-editor",children:A$1||jsx(qp,{})});if(Z$1.parseError)return jsx("div",{className:`ep-root docx-editor docx-editor-error ${S}`,style:Ci,"data-testid":"docx-editor",children:jsx(Zp,{message:Z$1.parseError})});if(!ue.state)return jsx("div",{className:`ep-root docx-editor docx-editor-empty ${S}`,style:Ci,"data-testid":"docx-editor",children:R||jsx(Xp,{})});let ag=jsxs(Fragment,{children:[jsx(C,{}),jsx(A,{onClick:()=>Jt(!St),active:St,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsx(d,{name:"comment",size:20})}),jsx(C,{}),jsx(zk,{mode:It,onModeChange:y=>{bn(y),y==="suggesting"&&Jt(true);}}),T]});return jsx(a$2,{i18n:Se,children:jsx(ud,{children:jsx(Bi,{onError:Km,children:jsxs("div",{ref:nn,className:`ep-root docx-editor ${S}`,style:Ci,"data-testid":"docx-editor",children:[jsx("div",{style:ng,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[c$1&&!x&&jsxs("div",{ref:Ms,className:"z-50 flex flex-col gap-0 bg-white shadow-sm flex-shrink-0",children:[jsxs(Wt,{currentFormatting:Z$1.selectionFormatting,onFormat:vr,onUndo:ui,onRedo:kr,canUndo:true,canRedo:true,disabled:gt,documentStyles:ue.state?.package.styles?.styles,theme:ue.state?.package.theme||u,showPrintButton:$,onPrint:bi,showZoomControl:d$1,zoom:Z$1.zoom,onZoomChange:hi,onRefocusEditor:Qe,onInsertTable:ut,showTableInsert:true,onInsertImage:fi,onInsertPageBreak:ht,onInsertTOC:ln,imageContext:Z$1.pmImageContext,onImageWrapType:gi,onImageTransform:Cr,onOpenImageProperties:_o,onPageSetup:ee,tableContext:Z$1.pmTableContext,onTableAction:wr,children:[jsxs(Wt.TitleBar,{children:[oe&&jsx(Wt.Logo,{children:oe()}),Q!==void 0&&jsx(Wt.DocumentName,{value:Q,onChange:V,editable:Y}),ne&&jsx(Wt.TitleBarRight,{children:ne()}),jsx(Wt.MenuBar,{})]}),jsx(Wt.FormattingBar,{children:ag})]}),m$2&&jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:As?`calc(20px + ${352}px)`:void 0,transition:"padding 0.2s ease"},children:jsx(E,{sectionProps:ue.state?.package.document?.finalSectionProperties,zoom:Z$1.zoom,unit:b,editable:!gt,onLeftMarginChange:Nm,onRightMarginChange:zm,indentLeft:Z$1.paragraphIndentLeft,indentRight:Z$1.paragraphIndentRight,onIndentLeftChange:Wm,onIndentRightChange:Vm,showFirstLineIndent:true,firstLineIndent:Z$1.paragraphFirstLineIndent,hangingIndent:Z$1.paragraphHangingIndent,onFirstLineIndentChange:Um,tabStops:Z$1.paragraphTabs,onTabStopRemove:jm})})]}),jsx("div",{ref:qn,style:ig,children:jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxs("div",{ref:Yn,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y=>{y.target===y.currentTarget&&(y.preventDefault(),We.current?.focus());},onContextMenu:Is,children:[m$2&&!x&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsx(_d,{sectionProps:ue.state?.package.document?.finalSectionProperties,zoom:Z$1.zoom,unit:b,editable:!gt,onTopMarginChange:Om,onBottomMarginChange:$m})}),Gt&&Gt.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${Gt.replace("comment-","")}"] { background-color: rgba(255, 212, 0, 0.35) !important; border-bottom: 2px solid rgba(255, 212, 0, 0.7) !important; }`}),Gt?.startsWith("tc-")&&(()=>{let y=Gt.split("-")[1],w=gn.find(B=>String(B.revisionId)===y)?.insertionRevisionId;return jsx("style",{children:`
30
+ .paged-editor__pages .docx-insertion[data-revision-id="${w??y}"] { background-color: rgba(52, 168, 83, 0.2) !important; border-bottom: 2px solid #2e7d32 !important; }
31
+ .paged-editor__pages .docx-deletion[data-revision-id="${y}"] { background-color: rgba(211, 47, 47, 0.2) !important; text-decoration-thickness: 2px !important; }
32
+ `})})(),jsx(cm,{ref:We,document:ue.state,styles:ue.state?.package.styles,theme:ue.state?.package.theme||u,sectionProperties:ue.state?.package.document?.finalSectionProperties,headerContent:yi,footerContent:xi,firstPageHeaderContent:Si,firstPageFooterContent:ki,onHeaderFooterDoubleClick:Jm,hfEditMode:Le,onBodyClick:Qm,zoom:Z$1.zoom,readOnly:gt,extensionManager:$t,onDocumentChange:he,onSelectionChange:(y,g)=>{let w=We.current?.getView();if(w){let B=ir(w.state);Be(B);let z=w.state.selection.$from,U=[...w.state.storedMarks??[],...z.nodeAfter?.marks??[],...z.nodeBefore?.marks??[],...z.marks()],j=null;for(let X of U){if(X.type.name==="comment"&&X.attrs.commentId!=null){j=`comment-${X.attrs.commentId}`;break}if((X.type.name==="insertion"||X.type.name==="deletion")&&X.attrs.revisionId!=null){let fe=String(X.attrs.revisionId),ce=`tc-${fe}-`,me=Ti.find(Ce=>Ce.id.startsWith(ce));if(!me&&hc){let Ce=hc.get(fe);Ce&&(me=Ti.find(Ve=>Ve.id===Ce));}if(me){j=me.id;break}}}j&&Jt(true),jn(j);}else Be(null);},externalPlugins:Es,onReady:y=>{F?.(y.getView());},onRenderedDomContextReady:k,pluginOverlays:P,onHyperlinkClick:vo,onContextMenu:Dm,commentsSidebarOpen:As,onAnchorPositionsChange:No,resolvedCommentIds:rg,scrollContainerRef:qn,sidebarOverlay:jsxs(Fragment,{children:[Bs.length>0&&jsx(wd,{items:Bs,anchorPositions:gr,renderedDomContext:H??null,pageWidth:(()=>{let y=ue.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),zoom:Z$1.zoom,editorContainerRef:qn,onExpandedItemChange:jn,activeItemId:Gt}),jsx(vd,{comments:dt,anchorPositions:gr,zoom:Z$1.zoom,pageWidth:(()=>{let y=ue.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),sidebarOpen:As,resolvedCommentIds:Vo,onMarkerClick:()=>{Jt(true);}})]})}),Nt!=null&&!an&&!gt&&jsx(c,{content:"Add comment",side:"bottom",delayMs:300,children:jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),y.stopPropagation();let g=We.current?.getView();if(g){let{from:w,to:B}=g.state.selection;if(w!==B){Dt({from:w,to:B});let z=g.state.schema.marks.comment.create({commentId:ri}),U=g.state.tr.addMark(w,B,z);U.setSelection(TextSelection.create(U.doc,B)),g.dispatch(U);}}Ht(Nt.top),Jt(true),Yt(true),Ft(null);},style:{position:"absolute",top:Nt.top,left:Nt.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:ot.isOpen,position:ot.position,hasSelection:ot.hasSelection,isEditable:!gt,items:fc,onAction:mc,onClose:()=>Kn(y=>({...y,isOpen:false}))}),Le&&(()=>{let y=lt?Le==="header"?Si:ki:Le==="header"?yi:xi;if(!y)return null;let g=tg(Le),w=Yn.current;return !g||!w?null:jsx(Wp,{ref:tn,headerFooter:y,position:Le,styles:ue.state?.package.styles,targetElement:g,parentElement:w,onSave:Ls,onClose:()=>ze(null),onSelectionChange:Be,onRemove:eg})})()]})})}),Dn.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:Dn.visible?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:[Dn.currentPage," of ",Dn.totalPages]}),ft&&jsx(yd,{headings:mt,onHeadingClick:pi,onClose:()=>Rt(false),topOffset:li}),pe&&!ft&&jsx("button",{className:"docx-outline-nav",onClick:$o,onMouseDown:y=>y.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:li+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(Gp,{data:W,onNavigate:Ro,onCopy:Fs,onEdit:Lm,onRemove:Bm,onClose:Am,readOnly:gt}),jsx(Z,{isOpen:ot.isOpen,position:ot.position,hasSelection:ot.hasSelection,isEditable:!gt,items:fc,onAction:mc,onClose:Hm}),jsx(Toaster,{position:"bottom-right"}),jsxs(Suspense,{fallback:null,children:[C$1.state.isOpen&&jsx(Mk,{isOpen:C$1.state.isOpen,onClose:C$1.close,onFind:Gm,onFindNext:Ym,onFindPrevious:qm,onReplace:Xm,onReplaceAll:Zm,initialSearchText:C$1.state.searchText,replaceMode:C$1.state.replaceMode,currentResult:_t.current}),O.state.isOpen&&jsx(Ik,{isOpen:O.state.isOpen,onClose:O.close,onSubmit:kt,onRemove:O.state.isEditing?xn:void 0,initialData:O.state.initialData,selectedText:O.state.selectedText,isEditing:O.state.isEditing}),Ie&&jsx(Fk,{isOpen:Ie,onClose:()=>He(false),onApply:y=>{let g=Ae();g&&Yr(y)(g.state,g.dispatch);},currentProps:Z$1.pmTableContext?.table?.attrs}),qe&&jsx(Lk,{isOpen:qe,onClose:()=>je(false),onApply:Tr}),Xe&&jsx(Bk,{isOpen:Xe,onClose:()=>_e(false),onApply:cn,currentData:Z$1.pmImageContext?{alt:Z$1.pmImageContext.alt??void 0,borderWidth:Z$1.pmImageContext.borderWidth??void 0,borderColor:Z$1.pmImageContext.borderColor??void 0,borderStyle:Z$1.pmImageContext.borderStyle??void 0}:void 0}),K&&jsx(Dk,{isOpen:K,onClose:()=>G(false),onApply:_m,currentProps:ue.state?.package.document?.finalSectionProperties}),we&&jsx(Ak,{isOpen:we,onClose:()=>xt(false),onApply:wo,footnotePr:ue.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:ue.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsx("input",{ref:zo,type:"file",accept:"image/*",style:{display:"none"},onChange:mi})]})})})})});function pF(e,t,n={}){return new Promise((o,r)=>{let i=gm.createRef(),a=null;try{a=createRoot(t);}catch(c){r(c);return}let s={save:async()=>{let c=await(i.current?.save()??Promise.resolve(null));return c?new Blob([c],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:c=>i.current?.setZoom(c),destroy:()=>{a?.unmount(),a=null;}},l=false,u=gm.createElement(mm,{...n,documentBuffer:e,onError:c=>{n.onError?.(c),l||(l=true,r(c));},onChange:c=>{n.onChange?.(c),l||(l=true,o(s));},ref:i});a.render(u);})}function kF(e,t={}){let{storageKey:n,interval:o,enabled:r$1=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:c}=t,d=useMemo(()=>new r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:c,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);useEffect(()=>{r$1?(d.enable(),d.startInterval()):d.disable();},[d,r$1]),useEffect(()=>{d.onDocumentChanged(e??null);},[d,e]),useEffect(()=>()=>{d.destroy();},[d]);let p=useSyncExternalStore(d.subscribe,d.getSnapshot),f=useCallback(()=>d.save(),[d]),m=useCallback(()=>d.clear(),[d]),b=useCallback(()=>d.getRecoveryData(),[d]),h=useCallback(()=>d.acceptRecovery(),[d]),x=useCallback(()=>d.dismissRecovery(),[d]),T=useCallback(()=>d.enable(),[d]),S=useCallback(()=>d.disable(),[d]);return {status:p.status,lastSaveTime:p.lastSaveTime,save:f,clearAutoSave:m,hasRecoveryData:p.hasRecoveryData,getRecoveryData:b,acceptRecovery:h,dismissRecovery:x,isEnabled:p.isEnabled,enable:T,disable:S}}var Kk=1,hm=.25,bm=4,Gk=.1,fn=[.25,.5,.75,1,1.25,1.5,2,3,4];function ym(e,t,n){return Math.max(t,Math.min(n,e))}function xm(e){return Math.round(e*100)/100}function Yk(e){let t=fn[0],n=Math.abs(e-t);for(let o of fn){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function qk(e){for(let t of fn)if(t>e+.01)return t;return fn[fn.length-1]}function Xk(e){for(let t=fn.length-1;t>=0;t--)if(fn[t]<e-.01)return fn[t];return fn[0]}function wF(e={}){let{initialZoom:t=Kk,minZoom:n=hm,maxZoom:o=bm,zoomStep:r=Gk,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[c,d]=useState(t),p=useRef(c);useEffect(()=>{p.current=c;},[c]);let f=useCallback(R=>{let A=xm(ym(R,n,o));A!==p.current&&(d(A),s?.(A));},[n,o,s]),m=useCallback(()=>{f(p.current+r);},[r,f]),b=useCallback(()=>{f(p.current-r);},[r,f]),h=useCallback(()=>{f(t);},[t,f]),x=useCallback(()=>{f(1);},[f]),T=useCallback((R,A)=>{if(A>0){let L=R/A;f(L);}},[f]),S=useCallback(R=>{if(!i||!(R.ctrlKey||R.metaKey))return;u&&R.preventDefault();let L=R.deltaY;L<0?f(p.current+r):L>0&&f(p.current-r);},[i,u,r,f]),I=useCallback(R=>{if(!(!i||!l||!(R.ctrlKey||R.metaKey))){if(R.key==="0"){R.preventDefault(),x();return}if(R.key==="+"||R.key==="="){R.preventDefault(),m();return}if(R.key==="-"){R.preventDefault(),b();return}}},[i,l,m,b,x]);return useEffect(()=>{if(!i)return;let R=a?.current;if(R)return R.addEventListener("wheel",S,{passive:false}),()=>{R.removeEventListener("wheel",S);}},[i,a,S]),useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",I),()=>{document.removeEventListener("keydown",I);}},[i,l,I]),{zoom:c,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:h,zoomTo100:x,zoomToFit:T,isMinZoom:c<=n,isMaxZoom:c>=o,zoomPercent:Math.round(c*100),handleWheel:S,handleKeyDown:I}}function vF(){return [...fn]}function RF(e){return Yk(e)}function EF(e){return qk(e)}function PF(e){return Xk(e)}function MF(e){return `${Math.round(e*100)}%`}function IF(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function FF(e){return fn.some(t=>Math.abs(t-e)<.01)}function LF(e,t=hm,n=bm){return xm(ym(e,t,n))}var fr={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},AF={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},DF={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function Sm(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 Zk(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 pc(e){let t=Sm(e);return Zk(t)}function HF(e,t=fr){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 NF(e,t=fr){let n=t.backgroundColor;return `
33
+ ${e}::selection,
34
+ ${e} *::selection {
35
+ background-color: ${n} !important;
36
+ color: inherit !important;
37
+ }
38
+
39
+ ${e}::-moz-selection,
40
+ ${e} *::-moz-selection {
41
+ background-color: ${n} !important;
42
+ color: inherit !important;
43
+ }
44
+ `}function km(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function Cm(){let e=window.getSelection();return e?e.toString():""}function Tm(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function zF(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function OF(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function $F(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function _F(){let e=window.getSelection();e&&e.removeAllRanges();}function Jk(){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 WF(){let e=window.getSelection();if(!e||e.rangeCount===0||!Jk())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 xo=null;function wm(e=fr){Qk();let t=`
45
+ /* DOCX Editor Selection Highlighting */
46
+
47
+ /* Base selection style for all editable content */
48
+ .docx-editor [contenteditable="true"]::selection,
49
+ .docx-editor [contenteditable="true"] *::selection,
50
+ .docx-run-editable::selection,
51
+ .docx-run-editable *::selection {
52
+ background-color: ${e.backgroundColor} !important;
53
+ color: inherit !important;
54
+ }
55
+
56
+ /* Firefox selection */
57
+ .docx-editor [contenteditable="true"]::-moz-selection,
58
+ .docx-editor [contenteditable="true"] *::-moz-selection,
59
+ .docx-run-editable::-moz-selection,
60
+ .docx-run-editable *::-moz-selection {
61
+ background-color: ${e.backgroundColor} !important;
62
+ color: inherit !important;
63
+ }
64
+
65
+ /* Ensure selection is visible against all backgrounds */
66
+ .docx-run-highlighted::selection,
67
+ .docx-run-highlighted *::selection {
68
+ /* For highlighted (yellow background) text, use darker selection */
69
+ background-color: rgba(26, 115, 232, 0.5) !important;
70
+ }
71
+
72
+ .docx-run-highlighted::-moz-selection,
73
+ .docx-run-highlighted *::-moz-selection {
74
+ background-color: rgba(26, 115, 232, 0.5) !important;
75
+ }
76
+
77
+ /* Selection in dark text */
78
+ .docx-run-dark-bg::selection,
79
+ .docx-run-dark-bg *::selection {
80
+ /* Use lighter selection for dark backgrounds */
81
+ background-color: rgba(100, 181, 246, 0.5) !important;
82
+ }
83
+
84
+ .docx-run-dark-bg::-moz-selection,
85
+ .docx-run-dark-bg *::-moz-selection {
86
+ background-color: rgba(100, 181, 246, 0.5) !important;
87
+ }
88
+
89
+ /* Programmatic highlight class */
90
+ .docx-selection-highlight {
91
+ background-color: ${e.backgroundColor};
92
+ ${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
93
+ ${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
94
+ }
95
+
96
+ /* Find/replace highlight */
97
+ .docx-find-highlight {
98
+ background-color: rgba(255, 235, 59, 0.5);
99
+ border-radius: 2px;
100
+ }
101
+
102
+ .docx-find-highlight-current {
103
+ background-color: rgba(255, 152, 0, 0.6);
104
+ border-radius: 2px;
105
+ outline: 2px solid rgba(255, 152, 0, 0.8);
106
+ }
107
+
108
+ /* AI action selection preview */
109
+ .docx-ai-selection-preview {
110
+ background-color: rgba(156, 39, 176, 0.2);
111
+ border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
112
+ }
113
+ `;xo=document.createElement("style"),xo.id="docx-selection-styles",xo.textContent=t,document.head.appendChild(xo);}function Qk(){xo&&(xo.remove(),xo=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function vm(){return xo!==null||document.getElementById("docx-selection-styles")!==null}function VF(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?pc(e):Sm(e);t(o);}}function qF(e){let{containerRef:t,enabled:n=true,config:o=fr,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=useState(false),[u,c]=useState(""),[d,p]=useState([]),[f,m]=useState(false),b=useRef(null),h=useRef(0),x=useCallback(()=>{let R=t.current,A=km(),L=Cm(),pe=R?Tm(R):false;if(l(A),c(L),m(pe),r&&pe){let $=pc(R);p($);}else p([]);a&&a(A&&pe,L);},[t,r,a]),T=useCallback(()=>{let R=performance.now();if(R-h.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{h.current=performance.now(),x(),b.current=null;},i);return}h.current=R,x();},[i,x]),S=useCallback(()=>{x();},[x]),I=useCallback(R=>({position:"absolute",left:`${R.left}px`,top:`${R.top}px`,width:`${R.width}px`,height:`${R.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&&!vm()&&wm(o),()=>{}),[n,o]),useEffect(()=>{if(!n)return;let R=()=>{T();};return document.addEventListener("selectionchange",R),document.addEventListener("mouseup",R),x(),()=>{document.removeEventListener("selectionchange",R),document.removeEventListener("mouseup",R),b.current!==null&&clearTimeout(b.current);}},[n,T,x]),{hasSelection:s,selectedText:u,highlightRects:d,isSelectionInContainer:f,refresh:S,getOverlayStyle:I}}function XF(e,t=fr){return e.map((n,o)=>gm.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 n1(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 h=>{if(s.current)return false;s.current=true;try{let x=await M(h.runs,{onError:a});return x&&t?.(h),x}finally{s.current=false;}},[t,a]),c=useCallback(async h=>{if(s.current||!i)return false;s.current=true;try{let x=await M(h.runs,{onError:a});return x&&n?.(h),x}finally{s.current=false;}},[n,i,a]),d=useCallback(async(h=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let x=await navigator.clipboard.read(),T$1="",S="";for(let R of x)R.types.includes("text/html")&&(T$1=await(await R.getType("text/html")).text()),R.types.includes("text/plain")&&(S=await(await R.getType("text/plain")).text());h&&(T$1="");let I=T(T$1,S,r);return l.current=I,o?.(I,h),I}return null}catch(x){return a?.(x),null}finally{s.current=false;}},[i,r,o,a]),p=useCallback(h=>{let x=F();if(!x)return;h.preventDefault();let T=O(x.runs);h.clipboardData&&(h.clipboardData.setData("text/plain",T.plainText),h.clipboardData.setData("text/html",T.html),T.internal&&h.clipboardData.setData("application/x-docx-editor",T.internal)),t?.(x);},[t]),f=useCallback(h=>{if(!i)return;let x=F();if(!x)return;h.preventDefault();let T=O(x.runs);h.clipboardData&&(h.clipboardData.setData("text/plain",T.plainText),h.clipboardData.setData("text/html",T.html),T.internal&&h.clipboardData.setData("application/x-docx-editor",T.internal)),n?.(x);},[i,n]),m=useCallback(h=>{if(!i)return;h.preventDefault();let x=S(h,{cleanWordFormatting:r});if(x){l.current=x;let T=h.shiftKey??false;o?.(x,T);}},[i,r,o]),b=useCallback(h=>{},[]);return {copy:u,cut:c,paste:d,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var vs={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},Im=I,Fm=`
114
+ .plugin-host {
115
+ display: flex;
116
+ width: 100%;
117
+ height: 100%;
118
+ overflow: visible;
119
+ position: relative;
120
+ }
121
+
122
+ .plugin-host-editor {
123
+ flex: 1;
124
+ display: flex;
125
+ flex-direction: column;
126
+ min-width: 0;
127
+ overflow: visible;
128
+ }
129
+
130
+
131
+ .plugin-panels-left,
132
+ .plugin-panels-right {
133
+ display: flex;
134
+ flex-direction: column;
135
+ flex-shrink: 0;
136
+ background: #f8f9fa;
137
+ border-color: #e9ecef;
138
+ }
139
+
140
+ .plugin-panels-left {
141
+ border-right: 1px solid #e9ecef;
142
+ }
143
+
144
+ .plugin-panels-right {
145
+ border-left: 1px solid #e9ecef;
146
+ }
147
+
148
+ .plugin-panels-bottom {
149
+ border-top: 1px solid #e9ecef;
150
+ background: #f8f9fa;
151
+ }
152
+
153
+ .plugin-panel {
154
+ position: relative;
155
+ display: flex;
156
+ flex-direction: column;
157
+ overflow: hidden;
158
+ transition: width 0.2s ease, height 0.2s ease;
159
+ }
160
+
161
+ .plugin-panel.collapsed {
162
+ overflow: visible;
163
+ }
164
+
165
+ .plugin-panel-toggle {
166
+ display: flex;
167
+ align-items: center;
168
+ gap: 4px;
169
+ padding: 6px 8px;
170
+ background: transparent;
171
+ border: none;
172
+ cursor: pointer;
173
+ font-size: 12px;
174
+ color: #6c757d;
175
+ white-space: nowrap;
176
+ }
177
+
178
+ .plugin-panel.collapsed .plugin-panel-toggle {
179
+ writing-mode: vertical-rl;
180
+ text-orientation: mixed;
181
+ flex-direction: column;
182
+ height: 100%;
183
+ padding: 8px 6px;
184
+ }
185
+
186
+ .plugin-panel-toggle:hover {
187
+ background: #e9ecef;
188
+ color: #495057;
189
+ }
190
+
191
+ .plugin-panel-toggle-icon {
192
+ font-weight: bold;
193
+ font-size: 14px;
194
+ }
195
+
196
+ .plugin-panel.collapsed .plugin-panel-toggle-icon {
197
+ transform: rotate(90deg);
198
+ }
199
+
200
+ .plugin-panel-toggle-label {
201
+ font-weight: 500;
202
+ }
203
+
204
+ .plugin-panel-content {
205
+ flex: 1;
206
+ overflow: auto;
207
+ }
208
+
209
+ /* Right panel rendered inside viewport - scrolls with content */
210
+ .plugin-panel-in-viewport {
211
+ position: absolute;
212
+ top: 0;
213
+ /* Position is set dynamically via inline styles based on page edge */
214
+ width: 220px;
215
+ pointer-events: auto;
216
+ z-index: 10;
217
+ overflow: visible;
218
+ }
219
+
220
+ .plugin-panel-in-viewport.collapsed {
221
+ width: 32px;
222
+ }
223
+
224
+ .plugin-panel-in-viewport .plugin-panel-toggle {
225
+ position: sticky;
226
+ top: 0;
227
+ background: rgba(255, 255, 255, 0.95);
228
+ border-radius: 4px;
229
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
230
+ }
231
+
232
+ .plugin-panel-in-viewport-content {
233
+ overflow: visible;
234
+ position: relative;
235
+ }
236
+
237
+ /* Plugin overlay container for rendering highlights/decorations */
238
+ .plugin-overlays-container {
239
+ position: absolute;
240
+ top: 0;
241
+ left: 0;
242
+ right: 0;
243
+ bottom: 0;
244
+ pointer-events: none;
245
+ overflow: visible;
246
+ z-index: 5;
247
+ }
248
+
249
+ .plugin-overlay {
250
+ position: absolute;
251
+ top: 0;
252
+ left: 0;
253
+ right: 0;
254
+ bottom: 0;
255
+ pointer-events: none;
256
+ }
257
+
258
+ /* Individual overlay children manage their own pointer-events.
259
+ Do NOT set pointer-events: auto here \u2014 it overrides overlay containers
260
+ that need pointer-events: none to let clicks pass through to the editor. */
261
+ `,aC=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),c=useMemo(()=>new J,[]),d=useSyncExternalStore(c.subscribe,c.getSnapshot),[p,f]=useState(()=>{let N=new Set;for(let D of t)({...vs,...D.panelConfig}).defaultCollapsed&&N.add(D.id);return N}),[m]=useState(()=>{let N=new Map;for(let D of t){let de={...vs,...D.panelConfig};N.set(D.id,de.defaultSize);}return N});useEffect(()=>{if(!i)return;let N=t.map(D=>({id:D.id,styles:D.styles,initialize:D.initialize,onStateChange:D.onStateChange,destroy:D.destroy}));return c.initialize(N,i),()=>{c.destroy();}},[c,i,t]),useEffect(()=>{let N=t.filter(D=>D.styles).map(D=>Im(D.id,D.styles));return ()=>N.forEach(D=>D())},[t]),useEffect(()=>{if(!i?.dom)return;let N=()=>{c.updateStates(i);},D=null,de=()=>{D&&cancelAnimationFrame(D),D=requestAnimationFrame(N);};N();let ge=i.dom;ge.addEventListener("input",de),ge.addEventListener("focus",N),ge.addEventListener("click",N);let Pe=i.dispatch.bind(i);return i.dispatch=se=>{Pe(se),de();},()=>{ge.removeEventListener("input",de),ge.removeEventListener("focus",N),ge.removeEventListener("click",N),D&&cancelAnimationFrame(D),i.dispatch=Pe;}},[i,c]),useEffect(()=>Im("plugin-host-base",Fm),[]);let b=useCallback(N=>{if(!i)return;if(i.coordsAtPos(N)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:de}=i,ge=de.doc.resolve(Math.min(N,de.doc.content.size)),Pe=de.tr.setSelection(TextSelection.near(ge));i.dispatch(Pe),i.focus();}},[i]),h=useCallback((N,D)=>{if(!i)return;let{state:de}=i,ge=de.doc.content.size,Pe=Math.max(0,Math.min(N,ge)),se=Math.max(0,Math.min(D,ge)),q=de.tr.setSelection(TextSelection.create(de.doc,Pe,se));i.dispatch(q),i.focus();},[i]),x=useCallback(N=>c.getPluginState(N),[c]),T=useCallback((N,D)=>{c.setPluginState(N,D);},[c]),S=useCallback(()=>{i&&c.updateStates(i);},[i,c]);useImperativeHandle(r,()=>({getPluginState:x,setPluginState:T,getEditorView:()=>i,refreshPluginStates:S}),[x,T,i,S]);let I=useMemo(()=>{let N=[];for(let D of t)D.proseMirrorPlugins&&N.push(...D.proseMirrorPlugins);return N},[t]),R=useCallback(N=>{f(D=>{let de=new Set(D);return de.has(N)?de.delete(N):de.add(N),de});},[]),[A,L]=useState(null);useEffect(()=>{if(!l){L(null);return}let N=()=>{let ge=l.pagesContainer,Pe=ge.querySelector(".layout-page");if(!Pe){L(null);return}let se=l.getContainerOffset(),q=Pe.getBoundingClientRect(),E=ge.getBoundingClientRect(),F=(q.right-E.left)/l.zoom,k=se.x+F+5;L(k);};N();let D=()=>{requestAnimationFrame(N);};window.addEventListener("resize",D);let de=new ResizeObserver(()=>{requestAnimationFrame(N);});return de.observe(l.pagesContainer),()=>{window.removeEventListener("resize",D),de.disconnect();}},[l]);let pe=useMemo(()=>{let N=[];if(l){for(let D of t)if(D.renderOverlay){let de=d.states.get(D.id);N.push(jsx("div",{className:"plugin-overlay","data-plugin-id":D.id,children:D.renderOverlay(l,de,i)},`overlay-${D.id}`));}}for(let D of t){if(!D.Panel||(D.panelConfig?.position??"right")!=="right")continue;let ge={...vs,...D.panelConfig},Pe=p.has(D.id),se=m.get(D.id)??ge.defaultSize,q=D.Panel,E=d.states.get(D.id),F=A!==null?`${A}px`:"calc(50% + 428px)";N.push(jsxs("div",{className:`plugin-panel-in-viewport ${Pe?"collapsed":""}`,style:{width:Pe?"32px":`${se}px`,left:F},"data-plugin-id":D.id,children:[ge.collapsible&&jsx("button",{className:"plugin-panel-toggle",onClick:()=>R(D.id),title:Pe?`Show ${D.name}`:`Hide ${D.name}`,"aria-label":Pe?`Show ${D.name}`:`Hide ${D.name}`,children:jsx("span",{className:"plugin-panel-toggle-icon",children:Pe?"\u2039":"\u203A"})}),!Pe&&l&&jsx("div",{className:"plugin-panel-in-viewport-content",children:jsx(q,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:h,pluginState:E,panelWidth:se,renderedDomContext:l})})]},`panel-overlay-${D.id}`));}return N.length>0?N:null},[l,t,d.version,i,p,m,b,h,R,A]),$=useMemo(()=>{let N=[];for(let D of t){if(!D.getSidebarItems)continue;let de=d.states.get(D.id),ge={editorView:i,renderedDomContext:l,anchorPositions:new Map,zoom:l?.zoom??1},Pe=D.getSidebarItems(de,ge);N.push(...Pe);}return N},[t,d.version,i,l]),v=useCallback(N=>{u(N);let D=s.current?.onRenderedDomContextReady;typeof D=="function"&&D(N);},[]),_=useMemo(()=>cloneElement(n,{externalPlugins:I,pluginOverlays:pe,pluginSidebarItems:$,pluginRenderedDomContext:l,onRenderedDomContextReady:v,onEditorViewReady:N=>{a(N);let D=s.current?.onEditorViewReady;typeof D=="function"&&D(N);}}),[n,I,pe,$,l,v]),re=useMemo(()=>{let N=[],D=[],de=[];for(let ge of t){if(!ge.Panel)continue;let Pe=ge.panelConfig?.position??"right";Pe==="left"?N.push(ge):Pe==="bottom"?de.push(ge):D.push(ge);}return {left:N,right:D,bottom:de}},[t]),ae=N=>{if(!N.Panel)return null;let D={...vs,...N.panelConfig},de=p.has(N.id),ge=m.get(N.id)??D.defaultSize,Pe=N.Panel,se=d.states.get(N.id);return jsxs("div",{className:`plugin-panel plugin-panel-${D.position} ${de?"collapsed":""}`,style:{[D.position==="bottom"?"height":"width"]:de?"32px":`${ge}px`,minWidth:D.position!=="bottom"?de?"32px":`${D.minSize}px`:void 0,maxWidth:D.position!=="bottom"?`${D.maxSize}px`:void 0,minHeight:D.position==="bottom"?de?"32px":`${D.minSize}px`:void 0,maxHeight:D.position==="bottom"?`${D.maxSize}px`:void 0},"data-plugin-id":N.id,children:[D.collapsible&&jsxs("button",{className:"plugin-panel-toggle",onClick:()=>R(N.id),title:de?`Show ${N.name}`:`Hide ${N.name}`,"aria-label":de?`Show ${N.name}`:`Hide ${N.name}`,children:[jsx("span",{className:"plugin-panel-toggle-icon",children:de?"\u203A":"\u2039"}),de&&jsx("span",{className:"plugin-panel-toggle-label",children:N.name})]}),!de&&jsx("div",{className:"plugin-panel-content",children:jsx(Pe,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:h,pluginState:se,panelWidth:ge,renderedDomContext:l??null})})]},N.id)};return jsxs("div",{className:`plugin-host ${o}`,children:[re.left.length>0&&jsx("div",{className:"plugin-panels-left",children:re.left.map(ae)}),jsxs("div",{className:"plugin-host-editor",children:[_,re.bottom.length>0&&jsx("div",{className:"plugin-panels-bottom",children:re.bottom.map(ae)})]})]})});export{vm as $,vF as A,RF as B,EF as C,PF as D,MF as E,IF as F,FF as G,LF as H,fr as I,AF as J,DF as K,Sm as L,Zk as M,pc as N,HF as O,NF as P,km as Q,Cm as R,Tm as S,zF as T,OF as U,$F as V,_F as W,Jk as X,WF as Y,wm as Z,Qk as _,Wt as a,VF as aa,RC as b,qF as ba,ud as c,XF as ca,Bi as d,n1 as da,EC as e,Fm as ea,PC as f,aC as fa,MC as g,IC as h,fd as i,ol as j,rl as k,Nn as l,_C as m,WC as n,hd as o,VC as p,UC as q,wg as r,Eg as s,jC as t,KC as u,mm as v,pF as w,kF as x,fn as y,wF as z};