@eigenpal/docx-js-editor 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/{ClipboardManager-Bbo5MM_U.d.cts → ClipboardManager-BYO62Qs5.d.cts} +1 -1
- package/dist/{ClipboardManager-CR843H7H.d.ts → ClipboardManager-YQYq5X_Z.d.ts} +1 -1
- package/dist/{DocumentAgent-lHtXgMFN.d.ts → DocumentAgent-BW1-gnqM.d.ts} +1 -1
- package/dist/{DocumentAgent-cHf96hwL.d.cts → DocumentAgent-ZcA8CUmC.d.cts} +1 -1
- package/dist/{agentApi-DmDuQm0e.d.cts → agentApi-B0688ssC.d.cts} +6 -0
- package/dist/{agentApi-DmDuQm0e.d.ts → agentApi-B0688ssC.d.ts} +6 -0
- package/dist/{chunk-FUK46DWH.js → chunk-4XF5YD4I.js} +2 -2
- package/dist/chunk-76GITSCY.cjs +258 -0
- package/dist/{chunk-OWMG5MW5.cjs → chunk-7YCCCWUZ.cjs} +3 -3
- package/dist/{chunk-6TUCNECX.js → chunk-ABNIHWGF.js} +1 -1
- package/dist/{chunk-PIVLDW7B.cjs → chunk-CL62W2HQ.cjs} +7 -7
- package/dist/chunk-E7U5ZBOK.js +3 -0
- package/dist/{chunk-Y62HOQL2.cjs → chunk-EUH3GF72.cjs} +4 -4
- package/dist/chunk-H7AKDCWH.js +258 -0
- package/dist/{chunk-5ILXHRJS.cjs → chunk-J5YOIHCW.cjs} +2 -2
- package/dist/chunk-JO2CKU4O.js +1 -0
- package/dist/chunk-MHUCHYNM.cjs +59 -0
- package/dist/{chunk-KL2RYY6G.cjs → chunk-NKW2UER2.cjs} +2 -2
- package/dist/chunk-OJ7NJK46.cjs +1 -0
- package/dist/chunk-PP54GVGD.js +59 -0
- package/dist/{chunk-JIKVCUR6.js → chunk-T2SRPPZY.js} +1 -1
- package/dist/{chunk-3X3LTNK4.js → chunk-YP3CXYSU.js} +7 -7
- package/dist/{clipboard-CU-zASXS.d.ts → clipboard-D0EG6AxE.d.ts} +1 -1
- package/dist/{clipboard-DBabJ6mU.d.cts → clipboard-Da1iPK0O.d.cts} +1 -1
- package/dist/{colorResolver-yl7Xh_Qg.d.cts → colorResolver-DR1p8Eg-.d.cts} +2 -2
- package/dist/{colorResolver-BTTqW66Q.d.ts → colorResolver-Dk7bMHIa.d.ts} +2 -2
- package/dist/core-plugins-reexport.cjs +1 -1
- package/dist/core-plugins-reexport.d.cts +4 -4
- package/dist/core-plugins-reexport.d.ts +4 -4
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-reexport.cjs +1 -1
- package/dist/core-reexport.d.cts +10 -10
- package/dist/core-reexport.d.ts +10 -10
- package/dist/core-reexport.js +1 -1
- package/dist/{fontLoader-Daq8y8C2.d.cts → fontLoader-54sS8rtN.d.cts} +1 -1
- package/dist/{fontLoader-DQJOS1sb.d.ts → fontLoader-C7RvUiHx.d.ts} +1 -1
- package/dist/headless-reexport.cjs +2 -2
- package/dist/headless-reexport.d.cts +7 -7
- package/dist/headless-reexport.d.ts +7 -7
- package/dist/headless-reexport.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +1 -1
- package/dist/mcp-reexport.cjs +3 -3
- package/dist/mcp-reexport.d.cts +2 -2
- package/dist/mcp-reexport.d.ts +2 -2
- package/dist/mcp-reexport.js +1 -1
- package/dist/{react-CFPWe7nV.d.ts → react-C_O0Z9ci.d.ts} +10 -4
- package/dist/{react-CKqhN17E.d.cts → react-XjilVrXZ.d.cts} +10 -4
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +5 -5
- package/dist/react.d.ts +5 -5
- package/dist/react.js +1 -1
- package/dist/{registry-C2DPl-QW.d.ts → registry-BHOeZbR9.d.ts} +1 -1
- package/dist/{registry-CXGC344v.d.cts → registry-CqFFeBgF.d.cts} +1 -1
- package/dist/selectionRects-BMXJJCPJ.cjs +1 -0
- package/dist/selectionRects-TWK7CAC3.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/{types-BpokDLqL.d.ts → types-BwCYaZKB.d.ts} +1 -1
- package/dist/{types-COQvtZji.d.cts → types-DAxXgYu5.d.cts} +1 -1
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.cts +3 -3
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +1 -1
- package/dist/{variableDetector-BYzE_RXw.d.ts → variableDetector-B2FHghLx.d.ts} +1 -1
- package/dist/{variableDetector-C8ST_dnq.d.cts → variableDetector-DIeB1Nxd.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-4CUGBNL2.cjs +0 -1
- package/dist/chunk-5GFXHUMP.js +0 -1
- package/dist/chunk-MUIREXKH.js +0 -3
- package/dist/chunk-PGEORVCG.js +0 -59
- package/dist/chunk-PUVSVHHB.cjs +0 -59
- package/dist/chunk-S36T7OK5.cjs +0 -258
- package/dist/chunk-YYBSUBRG.js +0 -258
- package/dist/selectionRects-7QU337P5.cjs +0 -1
- package/dist/selectionRects-V5RC2BYX.js +0 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
'use strict';var chunkOJ7NJK46_cjs=require('./chunk-OJ7NJK46.cjs'),chunk7YCCCWUZ_cjs=require('./chunk-7YCCCWUZ.cjs'),chunkVTAS7VZ6_cjs=require('./chunk-VTAS7VZ6.cjs'),chunkXS2AQFMF_cjs=require('./chunk-XS2AQFMF.cjs'),chunk2VHQ7YOQ_cjs=require('./chunk-2VHQ7YOQ.cjs'),chunkNKW2UER2_cjs=require('./chunk-NKW2UER2.cjs'),chunkIA4LPH2A_cjs=require('./chunk-IA4LPH2A.cjs'),chunkP7ZF45KZ_cjs=require('./chunk-P7ZF45KZ.cjs'),chunkCL62W2HQ_cjs=require('./chunk-CL62W2HQ.cjs'),chunkKR32M3S4_cjs=require('./chunk-KR32M3S4.cjs'),chunkPCJ5ACUV_cjs=require('./chunk-PCJ5ACUV.cjs'),Gp=require('react'),jsxRuntime=require('react/jsx-runtime'),prosemirrorState=require('prosemirror-state'),prosemirrorView=require('prosemirror-view'),prosemirrorHistory=require('prosemirror-history'),prosemirrorModel=require('prosemirror-model'),prosemirrorCommands=require('prosemirror-commands'),prosemirrorTables=require('prosemirror-tables'),prosemirrorDropcursor=require('prosemirror-dropcursor'),prosemirrorKeymap=require('prosemirror-keymap');require('prosemirror-view/style/prosemirror.css');var sonner=require('sonner'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Gp__default=/*#__PURE__*/_interopDefault(Gp);function If(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function gs({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function Ff(e){return e.replace(/\.docx$/i,"")}function uc({value:e,onChange:t,placeholder:n="Untitled",editable:o=true}){let r=Ff(e);return o?jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>{let a=i.target.value;t?.(a.endsWith(".docx")?a:a+".docx");},placeholder:n,className:"text-base font-normal text-slate-800 bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-slate-50 focus:bg-white focus:ring-1 focus:ring-slate-300 min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":"Document name"}):jsxRuntime.jsx("span",{className:"text-base font-normal text-slate-800 px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:r||n})}function hs({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function bs(){let e=chunk7YCCCWUZ_cjs.x(),{disabled:t=false,onFormat:n,onPrint:o,showPrintButton:r=true,onPageSetup:i,onInsertImage:a,onInsertTable:s,showTableInsert:l=true,onInsertPageBreak:u,onInsertTOC:d,onRefocusEditor:c}=e,p=Gp.useCallback(b=>{!t&&n&&n(b);},[t,n]),m=Gp.useCallback((b,g)=>{!t&&s&&(s(b,g),requestAnimationFrame(()=>c?.()));},[t,s,c]);return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":"Menu bar",children:[(r&&o||i)&&jsxRuntime.jsx(chunk7YCCCWUZ_cjs.e,{label:"File",disabled:t,items:[...r&&o?[{icon:"print",label:"Print",shortcut:"Ctrl+P",onClick:o}]:[],...i?[{icon:"settings",label:"Page setup",onClick:i}]:[]]}),jsxRuntime.jsx(chunk7YCCCWUZ_cjs.e,{label:"Format",disabled:t,items:[{icon:"format_textdirection_l_to_r",label:"Left-to-right text",onClick:()=>p("setLtr")},{icon:"format_textdirection_r_to_l",label:"Right-to-left text",onClick:()=>p("setRtl")}]}),jsxRuntime.jsx(chunk7YCCCWUZ_cjs.e,{label:"Insert",disabled:t,items:[...a?[{icon:"image",label:"Image",onClick:a}]:[],...l&&s?[{icon:"grid_on",label:"Table",submenuContent:b=>jsxRuntime.jsx(chunk7YCCCWUZ_cjs.f,{onInsert:(g,S)=>{m(g,S),b();}})}]:[],...a||l&&s?[{type:"separator"}]:[],{icon:"page_break",label:"Page break",onClick:u,disabled:!u},{icon:"format_list_numbered",label:"Table of contents",onClick:d,disabled:!d}]})]})}function pc({children:e}){let t=null,n=null,o=[],r=[];Gp.Children.forEach(e,a=>{Gp.isValidElement(a)&&(a.type===gs?t=a:a.type===hs?n=a:a.type===bs?r.push(a):o.push(a));});let i=Gp.useCallback(a=>{let s=a.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-white pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(If,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}function Lf({children:e,className:t,...n}){return jsxRuntime.jsx(chunk7YCCCWUZ_cjs.w.Provider,{value:n,children:jsxRuntime.jsx("div",{className:chunk7YCCCWUZ_cjs.a("flex flex-col bg-white shadow-sm flex-shrink-0",t),"data-testid":"editor-toolbar",children:e})})}var zt=Lf;zt.TitleBar=pc;zt.Logo=gs;zt.DocumentName=uc;zt.MenuBar=bs;zt.TitleBarRight=hs;zt.FormattingBar=chunk7YCCCWUZ_cjs.y;var gc=Gp.createContext(null);function hS(){let e=Gp.useContext(gc);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function hc({children:e}){let t=Gp.useMemo(()=>new chunk2VHQ7YOQ_cjs.H,[]),n=Gp.useSyncExternalStore(t.subscribe,t.getSnapshot),o=Gp.useCallback((u,d)=>{t.showError(u,d);},[t]),r=Gp.useCallback((u,d)=>{t.showWarning(u,d);},[t]),i=Gp.useCallback((u,d)=>{t.showInfo(u,d);},[t]),a=Gp.useCallback(u=>{t.dismiss(u);},[t]),s=Gp.useCallback(()=>{t.clearAll();},[t]),l=Gp.useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[n.notifications,o,r,i,a,s]);return jsxRuntime.jsxs(gc.Provider,{value:l,children:[e,jsxRuntime.jsx(zf,{notifications:n.notifications,onDismiss:a})]})}function zf({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsxRuntime.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=>jsxRuntime.jsx(Of,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function Of({notification:e,onDismiss:t}){let[n,o]=Gp.useState(false),i=(f=>{switch(f){case "error":return {bg:"var(--doc-error-bg)",border:"#f5c6cb",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"#ffeeba",text:"#856404",icon:"var(--doc-warning)"};case "info":return {bg:"#e8f4fd",border:"#b8daff",text:"#0c5460",icon:"var(--doc-primary)"}}})(e.severity),a={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},u={flex:1,minWidth:0},d={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},c={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},m=f=>{switch(f){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[jsxRuntime.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
|
+
`}),jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:l,children:m(e.severity)}),jsxRuntime.jsxs("div",{style:u,children:[jsxRuntime.jsx("div",{style:d,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsxRuntime.jsx("div",{style:c,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Zr=class extends Gp.Component{constructor(n){super(n);chunkPCJ5ACUV_cjs.d(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:jsxRuntime.jsx($f,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function $f({error:e,errorInfo:t,showDetails:n,onReset:o}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},u={padding:"10px 20px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:r,children:[jsxRuntime.jsx("div",{style:i,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:a,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxRuntime.jsxs("div",{style:l,children:[jsxRuntime.jsx("strong",{children:"Error:"})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
13
|
+
|
|
14
|
+
`,jsxRuntime.jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:o,style:u,children:"Try Again"})]})}function bS({message:e,details:t,onRetry:n,className:o=""}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border-light)"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"16px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={marginBottom:"16px",padding:"12px",background:"var(--doc-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",maxWidth:"100%",overflow:"auto",textAlign:"left"},u={padding:"8px 16px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"13px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsxRuntime.jsx("div",{style:i,children:jsxRuntime.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h3",{style:a,children:"Unable to Parse Document"}),jsxRuntime.jsx("p",{style:s,children:e}),t&&jsxRuntime.jsx("div",{style:l,children:t}),n&&jsxRuntime.jsx("button",{type:"button",onClick:n,style:u,children:"Try Again"})]})}function yS({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 jsxRuntime.jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsxRuntime.jsx("span",{style:r,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("strong",{children:e}),t&&`: ${t}`]})]})}function xS(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function SS(e){let t=e.message.toLowerCase();return t.includes("network")||t.includes("fetch")?"Network error. Please check your internet connection and try again.":t.includes("parse")||t.includes("xml")||t.includes("invalid")?"The document could not be parsed. It may be corrupted or in an unsupported format.":t.includes("permission")||t.includes("access")?"Access denied. You may not have permission to access this file.":t.includes("not found")||t.includes("404")?"The requested file was not found.":t.includes("timeout")?"The operation timed out. Please try again.":"An unexpected error occurred. Please try again."}function yc({document:e,onChange:t,onSelectionChange:n}){let o=Gp.useMemo(()=>new chunk2VHQ7YOQ_cjs.C,[]),[r,i]=Gp.useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),a=Gp.useCallback((d,c,p)=>{if(!e)return;let m=chunk2VHQ7YOQ_cjs.z(e,d);if(!m){o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}o.selectCell({tableIndex:d,rowIndex:c,columnIndex:p});let b=chunk7YCCCWUZ_cjs._(m,{tableIndex:d,rowIndex:c,columnIndex:p});i({context:b,table:m,tableIndex:d,rowIndex:c,columnIndex:p}),n?.(b);},[e,o,n]),s=Gp.useCallback(()=>{o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[o,n]),l=Gp.useCallback(d=>{if(!e||!r.context||r.tableIndex===null||r.rowIndex===null||r.columnIndex===null)return;let c=r.table;if(!c)return;let p=null,m=null,f=r.rowIndex,b=r.columnIndex;switch(d){case "addRowAbove":p=chunk7YCCCWUZ_cjs.ba(c,r.rowIndex,"before"),f=r.rowIndex+1;break;case "addRowBelow":p=chunk7YCCCWUZ_cjs.ba(c,r.rowIndex,"after");break;case "addColumnLeft":p=chunk7YCCCWUZ_cjs.da(c,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=chunk7YCCCWUZ_cjs.da(c,r.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(p=chunk7YCCCWUZ_cjs.ca(c,r.rowIndex),f>=p.rows.length&&(f=p.rows.length-1));break;case "deleteColumn":{if(chunk7YCCCWUZ_cjs.$(c)>1){p=chunk7YCCCWUZ_cjs.ea(c,r.columnIndex);let S=chunk7YCCCWUZ_cjs.$(p);b>=S&&(b=S-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=chunk7YCCCWUZ_cjs.fa(c,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=chunk7YCCCWUZ_cjs.ga(c,r.rowIndex,r.columnIndex));break;case "deleteTable":m=chunk2VHQ7YOQ_cjs.B(e,r.tableIndex),s(),t?.(m);return}p&&(m=chunk2VHQ7YOQ_cjs.A(e,r.tableIndex,p),t?.(m),m&&a(r.tableIndex,f,b));},[e,r,t,s,a]),u=Gp.useCallback((d,c,p)=>o.isCellSelected(d,c,p),[o,r]);return {state:r,handleCellClick:a,handleAction:l,clearSelection:s,isCellSelected:u,tableContext:r.context}}var Sc=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=Gp.useState(false);return Gp.useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":"Document outline",style:{position:"absolute",top:o,left:30,bottom:0,width:240,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:r?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:a=>a.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close outline",style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:"Close outline",children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"#80868b",fontSize:13,lineHeight:"20px"},children:"No headings found. Add headings to your document to see them here."}):e.map((a,s)=>jsxRuntime.jsx("div",{style:{marginLeft:a.level*12},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(a.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"#1f1f1f",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:a.text,children:a.text})},`${a.pmPos}-${s}`))})]})};function Tc(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 xs(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function Ss(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var Cc=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function Kf(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Cc[Math.abs(t)%Cc.length]}var Gf=340,qf=8,ei={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},wc={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"},vc=({comments:e,trackedChanges:t,onCommentClick:n,onCommentReply:o,onCommentResolve:r,onCommentDelete:i,onAddComment:a,onCancelAddComment:s,onAcceptChange:l,onRejectChange:u,onTrackedChangeReply:d,topOffset:c=0,showResolved:p=false,isAddingComment:m=false,addCommentYPosition:f=null,pageWidth:b=816,editorContainerRef:g})=>{let[S,T]=Gp.useState(null),[x,z]=Gp.useState(""),[E,F]=Gp.useState(""),[G,Y]=Gp.useState(null),[N,H]=Gp.useState(null),[J,de]=Gp.useState(new Map),[D,P]=Gp.useState(false),R=Gp.useRef(new Set),me=Gp.useRef(null),pe=Gp.useRef(new Map),Be=Gp.useMemo(()=>e.filter(I=>!(I.parentId!=null||I.done&&!p)),[e,p]),Me=Gp.useMemo(()=>{let I=new Map;for(let W of e)if(W.parentId!=null){let O=I.get(W.parentId);O?O.push(W):I.set(W.parentId,[W]);}return I},[e]),We=I=>Me.get(I)??[],w=Gp.useCallback(()=>{let I=g?.current;if(!I)return;let W=I.querySelector(".paged-editor__pages");if(!W)return;let O=I.getBoundingClientRect(),X=I.scrollTop,ue=[];for(let he of Be){let Pe=W.querySelector(`[data-comment-id="${he.id}"]`);if(Pe){let be=Pe.getBoundingClientRect();ue.push({id:`comment-${he.id}`,targetY:be.top-O.top+X,height:pe.current.get(`comment-${he.id}`)?.offsetHeight||80});}}t.forEach((he,Pe)=>{let be=`tc-${he.revisionId}-${Pe}`,ot=W.querySelector(`[data-revision-id="${he.revisionId}"]`);if(ot){let rt=ot.getBoundingClientRect();ue.push({id:be,targetY:rt.top-O.top+X,height:pe.current.get(be)?.offsetHeight||80});}}),m&&f!=null&&ue.push({id:"new-comment-input",targetY:f,height:pe.current.get("new-comment-input")?.offsetHeight||120}),ue.sort((he,Pe)=>he.targetY-Pe.targetY);let fe=new Map,Fe=0;for(let he of ue){let Pe=Math.max(he.targetY,Fe+qf);fe.set(he.id,Pe),Fe=Pe+he.height;}de(fe);},[Be,t,g,m,f]);Gp.useEffect(()=>{let I=g?.current;if(!I)return;let W=I.querySelector(".paged-editor__pages");if(!W)return;let O=X=>{let ue=X.target;if(!me.current?.contains(ue)){if(W.contains(ue)){let fe=ue.closest("[data-comment-id]");if(fe?.dataset.commentId){Y(`comment-${fe.dataset.commentId}`),n?.(Number(fe.dataset.commentId));return}let Fe=ue.closest(".docx-insertion")||ue.closest(".docx-deletion");if(Fe?.dataset.revisionId){let he=Number(Fe.dataset.revisionId),Pe=t.findIndex(be=>be.revisionId===he);if(Pe>=0){Y(`tc-${t[Pe].revisionId}-${Pe}`);return}}}Y(null),H(null);}};return I.addEventListener("click",O),()=>I.removeEventListener("click",O)},[g,t,n]),Gp.useEffect(()=>{let I=g?.current;if(!I)return;let W=setTimeout(w,50),O=setTimeout(()=>{w(),P(true);},400),X=new ResizeObserver(()=>{requestAnimationFrame(w);});return X.observe(I),()=>{clearTimeout(W),clearTimeout(O),X.disconnect();}},[w,g]),Gp.useEffect(()=>{let I=requestAnimationFrame(w);return ()=>cancelAnimationFrame(I)},[G,m,w]),Gp.useEffect(()=>{let I=[];if(G){let ue=pe.current.get(G);ue&&I.push(ue);}let W=pe.current.get("new-comment-input");if(W&&I.push(W),I.length===0)return;let O,X=new ResizeObserver(()=>{cancelAnimationFrame(O),O=requestAnimationFrame(w);});for(let ue of I)X.observe(ue);return ()=>{cancelAnimationFrame(O),X.disconnect();}},[G,w]);let A=()=>{E.trim()&&(a?.(E.trim()),F(""));},k=(I,W)=>{Y(G===I?null:I),H(null),W!==void 0&&n?.(W);},M=J.size>0,B=(I,W=32)=>({width:W,height:W,borderRadius:"50%",backgroundColor:Kf(I),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:W===32?13:11,fontWeight:500,flexShrink:0}),v=I=>({padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:I?"#1a73e8":"#f1f3f4",color:I?"#fff":"#80868b",cursor:I?"pointer":"default",fontWeight:500,fontFamily:"inherit"}),q=(I,W,O)=>{let X=R.current.has(I);return O!==void 0&&R.current.add(I),{...M?O!==void 0?{position:"absolute",top:O,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},padding:W?"10px 12px":"8px 10px",borderRadius:8,backgroundColor:W?"#fff":"#f8fbff",cursor:"pointer",boxShadow:W?"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)":"0 1px 3px rgba(60,64,67,0.2), 0 2px 6px rgba(60,64,67,0.08)",transition:M&&O===void 0?"none":!X&&O!==void 0?"opacity 0.2s ease, box-shadow 0.2s ease":D?"opacity 0.2s ease, box-shadow 0.2s ease, top 0.15s ease":"none"}},ae=(I,W)=>I.length===0?null:jsxRuntime.jsxs("div",{style:{marginTop:8},children:[(W?I:I.slice(-1)).map(O=>jsxRuntime.jsxs("div",{style:{marginBottom:W?8:0,paddingTop:8,borderTop:"1px solid #e8eaed"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:B(O.author||"U",28),children:Ss(O.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:O.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:xs(O.date)})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...W?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:Tc(O.content)})]},O.id)),!W&&I.length>1&&jsxRuntime.jsxs("div",{style:{fontSize:12,color:"#5f6368",marginTop:4},children:[I.length-1," more ",I.length-1===1?"reply":"replies"]})]}),$=(I,W)=>jsxRuntime.jsx("div",{onClick:O=>O.stopPropagation(),style:{marginTop:12},children:S===I?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{ref:O=>O?.focus({preventScroll:true}),type:"text",value:x,onChange:O=>z(O.target.value),onMouseDown:O=>O.stopPropagation(),onKeyDown:O=>{O.stopPropagation(),O.key==="Enter"&&(O.preventDefault(),x.trim()&&W&&W(I,x.trim()),z(""),T(null)),O.key==="Escape"&&(T(null),z(""));},placeholder:"Reply or add others with @",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:O=>{O.stopPropagation(),T(null),z("");},style:wc,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:O=>{O.stopPropagation(),x.trim()&&W&&W(I,x.trim()),z(""),T(null);},disabled:!x.trim(),style:v(!!x.trim()),children:"Reply"})]})]}):jsxRuntime.jsx("input",{readOnly:true,onMouseDown:O=>O.stopPropagation(),onClick:O=>{O.stopPropagation(),T(I);},placeholder:"Reply or add others with @",style:{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"}})}),_=I=>{let W=We(I.id),O=`comment-${I.id}`,X=G===O,ue=J.get(O);return jsxRuntime.jsxs("div",{ref:fe=>{fe?pe.current.set(O,fe):pe.current.delete(O);},"data-comment-id":I.id,className:"docx-comment-card",onClick:()=>k(O,I.id),onMouseDown:fe=>fe.stopPropagation(),style:{...q(O,X,ue),opacity:M&&ue===void 0?0:I.done?.6:1},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:B(I.author||"U"),children:Ss(I.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:I.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:xs(I.date)})]}),X&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsxRuntime.jsx("button",{onClick:fe=>{fe.stopPropagation(),r?.(I.id);},title:"Resolve",style:ei,children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:fe=>{fe.stopPropagation(),H(N===O?null:O);},title:"More options",style:ei,children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"more_vert",size:20})}),N===O&&jsxRuntime.jsx("div",{onClick:fe=>fe.stopPropagation(),onMouseDown:fe=>fe.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:jsxRuntime.jsx("button",{onClick:()=>{H(null),i?.(I.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"#202124",cursor:"pointer",fontFamily:"inherit"},onMouseOver:fe=>{fe.target.style.backgroundColor="#f1f3f4";},onMouseOut:fe=>{fe.target.style.backgroundColor="transparent";},children:"Delete"})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:Tc(I.content)}),ae(W,X),X&&!I.done&&$(I.id,o)]},I.id)},ne=I=>Me.get(I)??[],ge=(I,W)=>{let O=I.author||"Unknown",X=`tc-${I.revisionId}-${W}`,ue=G===X,fe=J.get(X),Fe=ne(I.revisionId);return jsxRuntime.jsxs("div",{ref:he=>{he?pe.current.set(X,he):pe.current.delete(X);},className:"docx-tracked-change-card",onClick:()=>k(X),onMouseDown:he=>he.stopPropagation(),style:q(X,ue,fe),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:B(O),children:Ss(O)}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:O}),I.date&&jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:xs(I.date)})]}),ue&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),l?.(I.from,I.to);},title:"Accept",style:ei,children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),u?.(I.from,I.to);},title:"Reject",style:ei,children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"close",size:20})})]})]}),jsxRuntime.jsxs("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:[I.type==="insertion"?"Added":"Deleted"," ",jsxRuntime.jsxs("span",{style:{color:I.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',I.text.length>50?I.text.slice(0,50)+"...":I.text,'"']})]}),ae(Fe,ue),ue&&$(I.revisionId,d)]},X)};return jsxRuntime.jsx("aside",{ref:me,className:"docx-comments-sidebar",role:"complementary","aria-label":"Comments and changes",style:{position:"absolute",top:c,left:`calc(50% - 120px + ${b/2+12}px)`,bottom:0,width:Gf,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:M?"visible":"auto",overflowX:"visible",opacity:M?1:0,transition:"opacity 0.15s ease"},onMouseDown:I=>I.stopPropagation(),children:jsxRuntime.jsxs("div",{style:{position:"relative"},children:[m&&jsxRuntime.jsxs("div",{ref:I=>{I?pe.current.set("new-comment-input",I):pe.current.delete("new-comment-input");},style:{...M?J.get("new-comment-input")!==void 0?{position:"absolute",top:J.get("new-comment-input"),left:0,right:0}:{position:"absolute",top:0,left:0,right:0,visibility:"hidden"}:{marginBottom:8},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:[jsxRuntime.jsx("textarea",{ref:I=>I?.focus({preventScroll:true}),value:E,onChange:I=>F(I.target.value),onMouseDown:I=>I.stopPropagation(),onKeyDown:I=>{I.stopPropagation(),I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),A()),I.key==="Escape"&&(s?.(),F(""));},placeholder:"Add a comment...",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:()=>{s?.(),F("");},style:wc,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:A,disabled:!E.trim(),style:v(!!E.trim()),children:"Comment"})]})]}),Be.map(I=>_(I)),t.map((I,W)=>ge(I,W)),Be.length===0&&t.length===0&&!m&&jsxRuntime.jsx("div",{style:{padding:"24px 16px",textAlign:"center",color:"#80868b",fontSize:13},children:"No comments or changes yet."})]})})};var Zf=15840,Ec=1440,Jf=1440,Qf=567,Mc=20,em="var(--doc-text-muted)",tm="var(--doc-text-subtle)",nm="var(--doc-primary)",om="var(--doc-primary)",rm="var(--doc-primary-hover)";function Ic({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=Gp.useState(null),[d,c]=Gp.useState(null),p=Gp.useRef(null),m=e?.pageHeight??Zf,f=e?.marginTop??Ec,b=e?.marginBottom??Ec,g=chunkKR32M3S4_cjs.a(m)*t,S=chunkKR32M3S4_cjs.a(f)*t,T=chunkKR32M3S4_cjs.a(b)*t,x=Gp.useCallback((Y,N)=>{n&&(Y.preventDefault(),u(N));},[n]),z=Gp.useCallback(Y=>{if(!l||!p.current)return;let N=p.current.getBoundingClientRect(),H=Y.clientY-N.top,J=chunkKR32M3S4_cjs.b(H/t);if(l==="topMargin"){let de=m-b-720,D=Math.max(0,Math.min(J,de));o?.(Math.round(D));}else if(l==="bottomMargin"){let de=m-J,D=m-f-720,P=Math.max(0,Math.min(de,D));r?.(Math.round(P));}},[l,t,m,f,b,o,r]),E=Gp.useCallback(()=>{u(null);},[]);Gp.useEffect(()=>{if(l)return document.addEventListener("mousemove",z),document.addEventListener("mouseup",E),()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",E);}},[l,z,E]);let F=am(m,t,i),G={position:"relative",width:Mc,height:chunkKR32M3S4_cjs.k(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:G,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:F.map((Y,N)=>jsxRuntime.jsx(im,{tick:Y},N))}),jsxRuntime.jsx(Pc,{type:"topMargin",position:S,editable:n,isDragging:l==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>c("topMargin"),onMouseLeave:()=>c(null),onMouseDown:Y=>x(Y,"topMargin")}),jsxRuntime.jsx(Pc,{type:"bottomMargin",position:g-T,editable:n,isDragging:l==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>c("bottomMargin"),onMouseLeave:()=>c(null),onMouseDown:Y=>x(Y,"bottomMargin")})]})}function im({tick:e}){let t={position:"absolute",top:chunkKR32M3S4_cjs.k(e.position),right:0,height:1,width:e.width,backgroundColor:tm},n={position:"absolute",top:chunkKR32M3S4_cjs.k(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:em,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:n,children:e.label})]})}function Pc({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?rm:r?om:nm,u={position:"absolute",top:chunkKR32M3S4_cjs.k(t-5),right:0,width:Mc,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},d={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsxRuntime.jsx("div",{style:d})})}function am(e,t,n){let o=[];if(n==="inch"){let r=Jf/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkKR32M3S4_cjs.a(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=Qf/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkKR32M3S4_cjs.a(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 Jt={High:50,Default:100,Low:150};function ft(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??Jt.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function Xe(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??Jt.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??Jt.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var Lc=Xe({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table | textBox)+"}});var Bc=Xe({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function Ac(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=chunkOJ7NJK46_cjs.a(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${chunkKR32M3S4_cjs.i(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=chunkIA4LPH2A_cjs.a(e.color,t)),e.highlight&&e.highlight!=="none"&&(n.backgroundColor=chunkIA4LPH2A_cjs.n(e.highlight)),e.shading){let a=Hc(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=lm(e.underline.style);a!=="solid"&&r.push(a),e.underline.color&&i.push(chunkIA4LPH2A_cjs.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=chunkKR32M3S4_cjs.h(e.position);n.position="relative",n.top=chunkKR32M3S4_cjs.k(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(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 Dc(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=cm(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=chunkKR32M3S4_cjs.a(e.lineSpacing);o>0&&(n.lineHeight=chunkKR32M3S4_cjs.k(o));break}case "atLeast":{let o=chunkKR32M3S4_cjs.a(e.lineSpacing);o>0&&(n.minHeight=chunkKR32M3S4_cjs.k(o),n.lineHeight=chunkKR32M3S4_cjs.k(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.indentFirstLine)):n.textIndent=chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,Po(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,Po(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,Po(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,Po(e.borders.right,"Right",t))),e.shading){let o=Hc(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 Po(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?chunkKR32M3S4_cjs.j(e.size):1,i=e.color?chunkIA4LPH2A_cjs.a(e.color,n):"#000000",a=dm(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=chunkKR32M3S4_cjs.k(Math.max(1,r)),o[l]=a,o[u]=i,o}function Hc(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":chunkIA4LPH2A_cjs.c(e.fill,t):e.pattern==="solid"&&e.color?chunkIA4LPH2A_cjs.c(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?chunkIA4LPH2A_cjs.c(e.color,t):""}function lm(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 cm(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function dm(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 Mo(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 pm(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=Dc(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function fm(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 mm(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${fm(n)} docx-list-level-${o}`}function Io(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 gm(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 hm(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=Io(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 Nc(e){let t=e.style,n={};if(t.textAlign){let i=gm(t.textAlign);i&&(n.alignment=i);}let o=t.marginLeft||t.paddingLeft;if(o){let i=Io(o);i!=null&&(n.indentLeft=i);}let r=t.marginRight||t.paddingRight;if(r){let i=Io(r);i!=null&&(n.indentRight=i);}if(t.textIndent){let i=Io(t.textIndent);i!=null&&(i<0?(n.indentFirstLine=Math.abs(i),n.hangingIndent=true):n.indentFirstLine=i);}if(t.lineHeight){let i=hm(t.lineHeight);i&&(n.lineSpacing=i.lineSpacing,n.lineSpacingRule=i.lineSpacingRule);}if(t.marginTop){let i=Io(t.marginTop);i!=null&&(n.spaceBefore=i);}if(t.marginBottom){let i=Io(t.marginBottom);i!=null&&(n.spaceAfter=i);}return n}var bm={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=Nc(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 {...Nc(t),styleId:`Heading${n}`,outlineLevel:n-1}}}))],toDOM(e){let t=e.attrs,n=pm(t),o=mm(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 Ot(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 zc(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 rr(e){return (t,n)=>Ot("alignment",e)(t,n)}function ti(e,t="auto"){return (n,o)=>zc({lineSpacing:e,lineSpacingRule:t})(n,o)}function ym(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 xm(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0,d=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:d>0?d:null});}}),n(i.scrollIntoView()),true}}function Sm(e){return (t,n)=>(o,r)=>{let{$from:i,$to:a}=o.selection;if(!r)return true;let s=o.tr,l=new Set,u=[];if(n?.runFormatting){let c=n.runFormatting;c.bold&&u.push(e.marks.bold.create()),c.italic&&u.push(e.marks.italic.create()),c.fontSize&&u.push(e.marks.fontSize.create({size:c.fontSize})),c.fontFamily&&u.push(e.marks.fontFamily.create({ascii:c.fontFamily.ascii,hAnsi:c.fontFamily.hAnsi,asciiTheme:c.fontFamily.asciiTheme})),c.color&&!c.color.auto&&u.push(e.marks.textColor.create({rgb:c.color.rgb,themeColor:c.color.themeColor,themeTint:c.color.themeTint,themeShade:c.color.themeShade})),c.underline&&c.underline.style!=="none"&&u.push(e.marks.underline.create({style:c.underline.style,color:c.underline.color})),(c.strike||c.doubleStrike)&&u.push(e.marks.strike.create({double:c.doubleStrike||false}));}let d=[e.marks.bold,e.marks.italic,e.marks.fontSize,e.marks.fontFamily,e.marks.textColor,e.marks.underline,e.marks.strike].filter(Boolean);return o.doc.nodesBetween(i.pos,a.pos,(c,p)=>{if(c.type.name==="paragraph"&&!l.has(p)){l.add(p);let m={...c.attrs,styleId:t};if(n?.paragraphFormatting){let f=n.paragraphFormatting;f.alignment!==void 0&&(m.alignment=f.alignment),f.spaceBefore!==void 0&&(m.spaceBefore=f.spaceBefore),f.spaceAfter!==void 0&&(m.spaceAfter=f.spaceAfter),f.lineSpacing!==void 0&&(m.lineSpacing=f.lineSpacing),f.lineSpacingRule!==void 0&&(m.lineSpacingRule=f.lineSpacingRule),f.indentLeft!==void 0&&(m.indentLeft=f.indentLeft),f.indentRight!==void 0&&(m.indentRight=f.indentRight),f.indentFirstLine!==void 0&&(m.indentFirstLine=f.indentFirstLine);}if(s=s.setNodeMarkup(p,void 0,m),n){let f=p+1,b=p+c.nodeSize-1;if(b>f){for(let g of d)s=s.removeMark(f,b,g);for(let g of u)s=s.addMark(f,b,g);}}}}),u.length>0&&(s=s.setStoredMarks(u)),r(s.scrollIntoView()),true}}var Oc=Xe({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:bm,onSchemaReady(e){let t=Sm(e.schema);return {commands:{setAlignment:n=>rr(n),alignLeft:()=>rr("left"),alignCenter:()=>rr("center"),alignRight:()=>rr("right"),alignJustify:()=>rr("both"),setLineSpacing:(n,o)=>ti(n,o),singleSpacing:()=>ti(240),oneAndHalfSpacing:()=>ti(360),doubleSpacing:()=>ti(480),setSpaceBefore:n=>Ot("spaceBefore",n),setSpaceAfter:n=>Ot("spaceAfter",n),increaseIndent:n=>ym(n),decreaseIndent:n=>xm(n),setIndentLeft:n=>Ot("indentLeft",n>0?n:null),setIndentRight:n=>Ot("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>zc({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Ot("styleId",null),insertSectionBreak:n=>Ot("sectionBreakType",n),removeSectionBreak:()=>Ot("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=Mo(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let d of r){let c=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:c,level:d.level,text:d.text});let p=a.mapping.map(d.pmPos),f=a.doc.resolve(p).nodeAfter;if(f&&f.type.name==="paragraph"){let S=[...(f.attrs.bookmarks||[]).filter(T=>!T.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:c}];a.setNodeMarkup(p,void 0,{...f.attrs,bookmarks:S});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let d of s){let c=d.level*720,p=`TOC${d.level+1}`,m=i.marks.hyperlink.create({href:`#${d.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:c>0?c:null},[i.text(d.text,[m])]));}let u=a.mapping.map(n.selection.from);return a.insert(u,prosemirrorModel.Fragment.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 Ot("bidi",a?null:true)(n,o)},setRtl:()=>Ot("bidi",true),setLtr:()=>Ot("bidi",null),setTabs:n=>Ot("tabs",n.length>0?n:null),addTabStop:(n,o="left",r="none")=>(i,a)=>{let{$from:s}=i.selection,l=s.parent;if(l.type.name!=="paragraph")return false;let c=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,m)=>p.position-m.position);return Ot("tabs",c)(i,a)},removeTabStop:n=>(o,r)=>{let{$from:i}=o.selection,a=i.parent;if(a.type.name!=="paragraph")return false;let l=(a.attrs.tabs||[]).filter(u=>u.position!==n);return Ot("tabs",l.length>0?l:null)(o,r)}}}}});var _c=ft({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[prosemirrorHistory.history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>prosemirrorHistory.undo,redo:()=>prosemirrorHistory.redo},keyboardShortcuts:{"Mod-z":prosemirrorHistory.undo,"Mod-y":prosemirrorHistory.redo,"Mod-Shift-z":prosemirrorHistory.redo}}}});var Vc=De({name:"bold",schemaMarkName:"bold",markSpec:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2})$/.test(e)?null:false}],toDOM(){return ["strong",0]}},onSchemaReady(e){return {commands:{toggleBold:()=>prosemirrorCommands.toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":prosemirrorCommands.toggleMark(e.schema.marks.bold)}}}});var Uc=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:()=>prosemirrorCommands.toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":prosemirrorCommands.toggleMark(e.schema.marks.italic)}}}});function Tm(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 Kc(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=Tm(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function gn(e,t){return (n,o)=>{let{from:r,to:i,empty:a}=n.selection,s=e.create(t);if(a){if(o){let l=e.isInSet(n.storedMarks||n.selection.$from.marks())?(n.storedMarks||n.selection.$from.marks()).filter(d=>d.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=Kc(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function hn(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=Kc(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function Cs(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 ir=(e,t)=>{let{from:n,to:o,empty:r}=e.selection;if(r)return t&&t(e.tr.setStoredMarks([])),true;if(t){let i=e.tr;e.doc.nodesBetween(n,o,(a,s)=>{if(a.isText&&a.marks.length>0){let l=Math.max(n,s),u=Math.min(o,s+a.nodeSize);for(let d of a.marks)i=i.removeMark(l,u,d.type);}}),t(i.scrollIntoView());}return true};var qc=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:()=>prosemirrorCommands.toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>gn(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":prosemirrorCommands.toggleMark(e.schema.marks.underline)}}}});var Yc=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:()=>prosemirrorCommands.toggleMark(e.schema.marks.strike)}}}});var Xc=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=Ac({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?hn(e.schema.marks.textColor):gn(e.schema.marks.textColor,t),clearTextColor:()=>hn(e.schema.marks.textColor)}}}});var Zc=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: ${chunkIA4LPH2A_cjs.n(t)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?hn(e.schema.marks.highlight):gn(e.schema.marks.highlight,{color:t}),clearHighlight:()=>hn(e.schema.marks.highlight)}}}});var Jc=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=>gn(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>hn(e.schema.marks.fontSize)}}}});var Qc=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=>gn(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>hn(e.schema.marks.fontFamily)}}}});var ed=De({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.superscript)}}}});var td=De({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.subscript)}}}});function Fo(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 Lo(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var nd=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:d,empty:c}=s.selection;if(c)return false;if(l){let p=t.create({href:i,tooltip:a||null}),m=s.tr.addMark(u,d,p),f=s.schema.marks.textColor;f&&(m=m.removeMark(u,d,f)),l(m.scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let d=i.selection.$from;if(!d.marks().find(g=>g.type===t))return false;let m=d.pos,f=d.pos;return d.parent.forEach((g,S)=>{if(g.isText){let T=d.start()+S,x=T+g.nodeSize;T<=d.pos&&d.pos<=x&&g.marks.some(E=>E.type===t)&&(m=Math.min(m,T),f=Math.max(f,x));}}),a&&a(i.tr.removeMark(m,f,t).scrollIntoView()),true}return a&&a(i.tr.removeMark(s,l,t).scrollIntoView()),true};return {commands:{setHyperlink:n,removeHyperlink:()=>o,insertHyperlink:(i,a,s)=>(l,u)=>{if(u){let d=t.create({href:a,tooltip:s||null}),c=l.schema.text(i,[d]);u(l.tr.replaceSelectionWith(c,false).scrollIntoView());}return true}}}}});var od=De({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var rd=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 id=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]),d=a.tr.replaceSelectionWith(u,false);return s(d.scrollIntoView()),true}}let o=(r,i)=>{let{$from:a,$to:s}=r.selection;if(!i)return true;let l=r.tr,u=t.marks.footnoteRef;return l=l.removeMark(a.pos,s.pos,u),i(l.scrollIntoView()),true};return {commands:{insertFootnote:n("footnote"),insertEndnote:n("endnote"),deleteNoteRef:()=>o}}}});function Rm(e){return e/2*(96/72)}var ad=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: ${chunkKR32M3S4_cjs.k(chunkKR32M3S4_cjs.a(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=Rm(t.position);n.push(`vertical-align: ${chunkKR32M3S4_cjs.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 sd=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 ld=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; text-decoration: underline; text-decoration-color: #2e7d32;"},0]}}}),cd=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; text-decoration: line-through; text-decoration-color: #c62828;"},0]}}});var dd=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]}}}),ud=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]}}}),pd=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]}}}),fd=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]}}}),md=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 gd=Xe({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 hd=Xe({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 bd=Xe({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 yd=Xe({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 Em(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 Pm(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(c=>`<stop offset="${Math.round(c.position/1e3)}%" stop-color="${c.color}" />`).join("");}catch{return ""}let o=t.gradientType||"linear";if(o==="radial"||o==="rectangular"||o==="path")return `<radialGradient id="${e}" cx="50%" cy="50%" r="50%">${n}</radialGradient>`;let i=((t.gradientAngle||0)-90)*Math.PI/180,a=Math.round(50+50*Math.cos(i+Math.PI)),s=Math.round(50+50*Math.sin(i+Math.PI)),l=Math.round(50+50*Math.cos(i)),u=Math.round(50+50*Math.sin(i));return `<linearGradient id="${e}" x1="${a}%" y1="${s}%" x2="${l}%" y2="${u}%">${n}</linearGradient>`}var xd=Xe({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 f=t.shadowOffsetX||2,b=t.shadowOffsetY||2,g=t.shadowBlur||4;i.push(`filter: drop-shadow(${f}px ${b}px ${g}px ${t.shadowColor})`);}if(t.glowColor&&t.glowRadius){let f=i.find(g=>g.startsWith("filter:")),b=`drop-shadow(0 0 ${t.glowRadius}px ${t.glowColor})`;if(f){let g=i.indexOf(f);i[g]=f+" "+b;}else i.push(`filter: ${b}`);}r.style=i.join("; ");let a="",s;if(t.fillType==="gradient"&&t.gradientStops){let f=`grad-${t.shapeId||Math.random().toString(36).slice(2,8)}`;s=`url(#${f})`,a=Pm(f,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",d=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",c=Em(t.shapeType||"rect",n,o),p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${o}" viewBox="0 0 ${n} ${o}" style="fill:${s};stroke:${u};stroke-width:${l}${d}">`+(a?`<defs>${a}</defs>`:"")+c+"</svg>",m=document.createElement("span");return Object.entries(r).forEach(([f,b])=>{m.setAttribute(f,b);}),m.innerHTML=p,{dom:m}}}});var Sd=Xe({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var kd=Xe({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 Td=Xe({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 Cd=Xe({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 wd=Xe({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]}}});var Nm={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]]}},zm={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]}},Om={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 vd(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=Om[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 Rd(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 Ed(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 Pd(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 $m={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){let t=e;return {colspan:t.colSpan||1,rowspan:t.rowSpan||1,verticalAlign:t.dataset.valign,backgroundColor:t.dataset.bgcolor||void 0}}}],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(...Rd(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Pd(t)),o.push(...vd(t)),o.push(...Ed(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]}},_m={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){let t=e;return {colspan:t.colSpan||1,rowspan:t.rowSpan||1,verticalAlign:t.dataset.valign,backgroundColor:t.dataset.bgcolor||void 0}}}],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(...Rd(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Pd(t)),o.push(...vd(t)),o.push(...Ed(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 Ge(e){let{selection:t}=e,{$from:n}=t,o=t instanceof prosemirrorTables.CellSelection,r,i,a,s,l;for(let f=n.depth;f>0;f--){let b=n.node(f);if(b.type.name==="tableCell"||b.type.name==="tableHeader"){l=b;let g=n.node(f-1);if(g&&g.type.name==="tableRow"){let S=0,T=false;g.forEach((x,z,E)=>{T||(E===n.index(f-1)?(s=S,T=true):S+=x.attrs.colspan||1);});}}else if(b.type.name==="tableRow"){let g=n.node(f-1);g&&g.type.name==="table"&&(a=n.index(f-1));}else if(b.type.name==="table"){r=b,i=n.before(f);break}}if(!r)return {isInTable:false};let u=0,d=0;r.forEach(f=>{if(f.type.name==="tableRow"){u++;let b=0;f.forEach(g=>{b+=g.attrs.colspan||1;}),d=Math.max(d,b);}});let c=l&&((l.attrs.colspan||1)>1||(l.attrs.rowspan||1)>1),p,m;if(l){let f=l.attrs;f.backgroundColor&&typeof f.backgroundColor=="string"&&(m=f.backgroundColor);let b=f.borders;if(b)for(let g of ["top","right","bottom","left"]){let S=b[g];if(S?.color&&S.style&&S.style!=="none"&&S.style!=="nil"){p=S.color;break}}}return {isInTable:true,table:r,tablePos:i,rowIndex:a,columnIndex:s,rowCount:u,columnCount:d,hasMultiCellSelection:o,canSplitCell:!!c,cellBorderColor:p,cellBackgroundColor:m}}function ar(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 Md(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 Id(){return (e,t)=>{if(!ar(e))return false;let n=Md(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.node(n.rowDepth),a=o.index(n.rowDepth),s=o.index(n.tableDepth);if(a<i.childCount-1){let l=n.cellPos+o.node(n.cellDepth).nodeSize;if(t){let u=l+1+1,d=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(u)));t(d.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let d=u+1+1+1,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}return false}}function Fd(){return (e,t)=>{if(!ar(e))return false;let n=Md(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.index(n.rowDepth),a=o.index(n.tableDepth);if(i>0){let l=o.node(n.rowDepth).child(i-1),u=n.cellPos-l.nodeSize;if(t){let d=u+l.nodeSize-2,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d),-1));t(c.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let c=u+s.nodeSize-1-1,p=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(c),-1));t(p.scrollIntoView());}return true}return false}}var Wm=Xe({name:"table",schemaNodeName:"table",nodeSpec:Nm}),Vm=Xe({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:zm}),jm=Xe({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:$m}),Um=Xe({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:_m}),Km=ft({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...w){return (A,k,M)=>{for(let B of w)if(B(A,k,M))return true;return false}}function o(w,A={}){let k=w?.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,...A}}function r(w,A,k="000000",M=9360){let B=[],v=Math.floor(M/A),q=360,ae="atLeast",$={style:"single",size:4,color:{rgb:k}},_={top:$,bottom:$,left:$,right:$};for(let ge=0;ge<w;ge++){let I=[];for(let W=0;W<A;W++){let O=t.nodes.paragraph.create(),X={colspan:1,rowspan:1,borders:_,width:v,widthType:"dxa"};I.push(t.nodes.tableCell.create(X,O));}B.push(t.nodes.tableRow.create({height:q,heightRule:ae},I));}let ne=Array(A).fill(v);return t.nodes.table.create({columnWidths:ne,width:M,widthType:"dxa"},B)}function i(w,A){return (k,M)=>{let{$from:B}=k.selection,v="000000",q=k.storedMarks||B.marks();for(let $ of q)if($.type.name==="textColor"&&$.attrs.rgb){v=$.attrs.rgb;break}let ae=B.pos;for(let $=B.depth;$>0;$--){let _=B.node($);if(_.type.name==="paragraph"||_.type.name==="table"){ae=B.after($);break}}if(M){let $=9360;for(let Fe=B.depth;Fe>0;Fe--){let he=B.node(Fe);if(he.type.name==="tableCell"||he.type.name==="tableHeader"){let Pe=he.attrs.width;Pe&&Pe>0&&($=Math.max(Pe-216,360));break}}let _=r(w,A,v,$),ne=t.nodes.paragraph.create(),I=k.doc.resolve(ae).nodeBefore?.type.name==="table",W=I?[ne,_,ne]:[_,ne],O=k.tr.insert(ae,W),X=ae+1;I&&(X+=ne.nodeSize);let fe=X+1+1;O.setSelection(prosemirrorState.TextSelection.create(O.doc,fe)),M(O.scrollIntoView());}return true}}function a(w,A){let k=Ge(w);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(A){let M=w.tr,B=k.table.child(k.rowIndex),v=[];B.forEach($=>{let _=t.nodes.paragraph.create(),ne=o($);v.push(t.nodes.tableCell.create(ne,_));});let q=t.nodes.tableRow.create({height:B.attrs.height??360,heightRule:B.attrs.heightRule??"atLeast"},v),ae=k.tablePos+1;for(let $=0;$<k.rowIndex;$++)ae+=k.table.child($).nodeSize;M.insert(ae,q),A(M.scrollIntoView());}return true}function s(w,A){let k=Ge(w);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(A){let M=w.tr,B=k.table.child(k.rowIndex),v=[];B.forEach($=>{let _=t.nodes.paragraph.create(),ne=o($);v.push(t.nodes.tableCell.create(ne,_));});let q=t.nodes.tableRow.create({height:B.attrs.height??360,heightRule:B.attrs.heightRule??"atLeast"},v),ae=k.tablePos+1;for(let $=0;$<=k.rowIndex;$++)ae+=k.table.child($).nodeSize;M.insert(ae,q),A(M.scrollIntoView());}return true}function l(w,A){let k=Ge(w);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0||(k.rowCount||0)<=1)return false;if(A){let M=w.tr,B=k.tablePos+1;for(let q=0;q<k.rowIndex;q++)B+=k.table.child(q).nodeSize;let v=B+k.table.child(k.rowIndex).nodeSize;M.delete(B,v),A(M.scrollIntoView());}return true}function u(w,A){let k=Ge(w);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(A){let M=w.tr,B=(k.columnCount||1)+1,v=Math.floor(100/B),q=k.tablePos+1;k.table.forEach(_=>{if(_.type.name==="tableRow"){let ne=q+1,ge=0;if(_.forEach(I=>{if(ge===k.columnIndex){let W=t.nodes.paragraph.create(),O=o(I,{colspan:1,rowspan:1});O.width=v,O.widthType="pct";let X=t.nodes.tableCell.create(O,W);M=M.insert(ne,X);}ne+=I.nodeSize,ge+=I.attrs.colspan||1;}),ge<=k.columnIndex){let I=t.nodes.paragraph.create(),W=o(_.child(_.childCount-1)??null,{colspan:1,rowspan:1});W.width=v,W.widthType="pct";let O=t.nodes.tableCell.create(W,I);M=M.insert(ne,O);}}q+=_.nodeSize;});let $=M.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let _=$.child(0);if(_&&_.type.name==="tableRow"){let W=k.tablePos+2;_.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(M=M.setNodeMarkup(W,void 0,{...O.attrs,width:v,widthType:"pct"})),W+=O.nodeSize;});}let ne=_?.childCount??B,ge=$.attrs.width||9360,I=Math.floor(ge/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(I)});}A(M.scrollIntoView());}return true}function d(w,A){let k=Ge(w);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(A){let M=w.tr,B=(k.columnCount||1)+1,v=Math.floor(100/B),q=k.tablePos+1;k.table.forEach(_=>{if(_.type.name==="tableRow"){let ne=q+1,ge=0,I=false;if(_.forEach(W=>{if(ne+=W.nodeSize,ge+=W.attrs.colspan||1,!I&&ge>k.columnIndex){let O=t.nodes.paragraph.create(),X=o(W,{colspan:1,rowspan:1});X.width=v,X.widthType="pct";let ue=t.nodes.tableCell.create(X,O);M=M.insert(ne,ue),I=true;}}),!I){let W=t.nodes.paragraph.create(),O=o(_.child(_.childCount-1)??null,{colspan:1,rowspan:1});O.width=v,O.widthType="pct";let X=t.nodes.tableCell.create(O,W);M=M.insert(ne,X);}}q+=_.nodeSize;});let $=M.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let _=$.child(0);if(_&&_.type.name==="tableRow"){let W=k.tablePos+2;_.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(M=M.setNodeMarkup(W,void 0,{...O.attrs,width:v,widthType:"pct"})),W+=O.nodeSize;});}let ne=_?.childCount??B,ge=$.attrs.width||9360,I=Math.floor(ge/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(I)});}A(M.scrollIntoView());}return true}function c(w,A){let k=Ge(w);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0||(k.columnCount||0)<=1)return false;if(A){let M=w.tr,B=(k.columnCount||2)-1,v=Math.floor(100/B),q=[],ae=k.tablePos+1;k.table.forEach(_=>{if(_.type.name==="tableRow"){let ne=ae+1,ge=0;_.forEach(I=>{let W=ne,O=ne+I.nodeSize,X=I.attrs.colspan||1;ge<=k.columnIndex&&k.columnIndex<ge+X&&q.push({start:W,end:O}),ne=O,ge+=X;});}ae+=_.nodeSize;}),q.reverse().forEach(({start:_,end:ne})=>{M=M.delete(_,ne);});let $=M.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let _=$.child(0);if(_&&_.type.name==="tableRow"){let W=k.tablePos+2;_.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(M=M.setNodeMarkup(W,void 0,{...O.attrs,width:v,widthType:"pct"})),W+=O.nodeSize;});}let ne=_?.childCount??B,ge=$.attrs.width||9360,I=Math.floor(ge/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(I)});}A(M.scrollIntoView());}return true}function p(w,A){let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(A){let M=w.tr;M.delete(k.tablePos,k.tablePos+k.table.nodeSize),A(M.scrollIntoView());}return true}function m(w,A){let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(A){let M=k.tablePos+1,B=w.doc.resolve(M),v=w.doc.resolve(k.tablePos+k.table.nodeSize-2),q=prosemirrorTables.CellSelection.create(w.doc,B.pos,v.pos);A(w.tr.setSelection(q));}return true}function f(w,A){let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table||k.rowIndex===void 0)return false;if(A){let B=k.tablePos+1;for(let _=0;_<k.rowIndex;_++){let ne=k.table.child(_);B+=ne.nodeSize;}let v=k.table.child(k.rowIndex),q=B+1,ae=B+v.nodeSize-2,$=prosemirrorTables.CellSelection.create(w.doc,q,ae);A(w.tr.setSelection($));}return true}function b(w,A){let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table||k.columnIndex===void 0)return false;if(A){let M=k.tablePos+1,B=k.table.child(0),v=k.table.child(k.table.childCount-1),q=M+1;for(let ne=0;ne<k.columnIndex&&ne<B.childCount;ne++)q+=B.child(ne).nodeSize;let ae=M;for(let ne=0;ne<k.table.childCount-1;ne++)ae+=k.table.child(ne).nodeSize;let $=ae+1;for(let ne=0;ne<k.columnIndex&&ne<v.childCount;ne++)$+=v.child(ne).nodeSize;let _=prosemirrorTables.CellSelection.create(w.doc,q,$);A(w.tr.setSelection(_));}return true}function g(w){let A=w.selection,k=[];if(A instanceof prosemirrorTables.CellSelection)return A.forEachCell((B,v)=>{k.push({pos:v,node:B});}),k;let{$from:M}=A;for(let B=M.depth;B>0;B--){let v=M.node(B);if(v.type.name==="tableCell"||v.type.name==="tableHeader"){k.push({pos:M.before(B),node:v});break}}return k}function S(w,A){let k=new Map,M=new Map,B=w.childCount,v=0;return w.forEach((q,ae,$)=>{if(q.type.name!=="tableRow")return;let _=0;q.forEach((ne,ge)=>{let I=A+ae+ge+2,W=ne.attrs.colspan||1;k.set(I,{rowIdx:$,colIdx:_,colspan:W,pos:I,node:ne}),M.set(`${$},${_}`,I),_+=W;}),v=Math.max(v,_);}),{cellByPos:k,cellByRC:M,totalRows:B,totalCols:v}}function T(w,A){return (k,M)=>{let B=Ge(k);if(!B.isInTable||B.tablePos===void 0||!B.table)return false;if(M){let v=k.tr,q=B.table,ae=B.tablePos,$=A??{style:"single",size:4,color:{rgb:"000000"}},_={style:"none"},{cellByPos:ne,cellByRC:ge}=S(q,ae),I=g(k),W=1/0,O=-1,X=1/0,ue=-1;for(let{pos:Pe}of I){let be=ne.get(Pe);be&&(W=Math.min(W,be.rowIdx),O=Math.max(O,be.rowIdx),X=Math.min(X,be.colIdx),ue=Math.max(ue,be.colIdx+be.colspan-1));}let fe=new Map,Fe=(Pe,be)=>fe.get(Pe)??{...be.attrs},he=(Pe,be)=>{fe.set(Pe,be);};for(let{pos:Pe}of I){let be=ne.get(Pe);if(!be)continue;let ot=be.rowIdx===W,rt=be.rowIdx===O,je=be.colIdx===X,Qe=be.colIdx+be.colspan-1===ue,Ue;switch(w){case "all":Ue={top:$,bottom:$,left:$,right:$};break;case "outside":Ue={top:ot?$:_,bottom:rt?$:_,left:je?$:_,right:Qe?$:_};break;case "inside":Ue={top:ot?_:$,bottom:rt?_:$,left:je?_:$,right:Qe?_:$};break;case "none":Ue={top:_,bottom:_,left:_,right:_};break}let mt=Fe(Pe,be.node),vt=mt.borders||{};if(he(Pe,{...mt,borders:{...vt,...Ue}}),Ue.top){let Ne=ge.get(`${be.rowIdx-1},${be.colIdx}`);if(Ne!==void 0){let ct=ne.get(Ne),He=Fe(Ne,ct.node),$t=He.borders||{};he(Ne,{...He,borders:{...$t,bottom:Ue.top}});}}if(Ue.bottom){let Ne=ge.get(`${be.rowIdx+1},${be.colIdx}`);if(Ne!==void 0){let ct=ne.get(Ne),He=Fe(Ne,ct.node),$t=He.borders||{};he(Ne,{...He,borders:{...$t,top:Ue.bottom}});}}if(Ue.left){let Ne=ge.get(`${be.rowIdx},${be.colIdx-1}`);if(Ne!==void 0){let ct=ne.get(Ne),He=Fe(Ne,ct.node),$t=He.borders||{};he(Ne,{...He,borders:{...$t,right:Ue.left}});}}if(Ue.right){let Ne=ge.get(`${be.rowIdx},${be.colIdx+be.colspan}`);if(Ne!==void 0){let ct=ne.get(Ne),He=Fe(Ne,ct.node),$t=He.borders||{};he(Ne,{...He,borders:{...$t,left:Ue.right}});}}}for(let[Pe,be]of fe)v.setNodeMarkup(v.mapping.map(Pe),void 0,be);M(v.scrollIntoView());}return true}}function x(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A),q=w?w.replace(/^#/,""):null;for(let{pos:ae,node:$}of v)B.setNodeMarkup(B.mapping.map(ae),void 0,{...$.attrs,backgroundColor:q});k(B.scrollIntoView());}return true}}function z(w,A,k){return (M,B)=>{let v=Ge(M);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(B){let q=M.tr,ae=g(M),$=A||{style:"none"},_={style:"none"},ne=["top","bottom","left","right"],{cellByPos:ge,cellByRC:I}=S(v.table,v.tablePos),W=new Map,O=(fe,Fe)=>W.get(fe)??{...Fe.attrs},X=(fe,Fe)=>W.set(fe,Fe),ue={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:fe,node:Fe}of ae){let he=ge.get(fe),Pe=O(fe,Fe),be=Pe.borders||{},ot=w==="all"?ne:[w],rt=k?{top:_,bottom:_,left:_,right:_}:{...be};for(let je of ot)rt[je]=$;if(he){let je=k?ne:ot;for(let Qe of je){let Ue=rt[Qe],mt=ue[Qe],vt=Qe==="right"?he.colIdx+he.colspan:he.colIdx+mt.dCol,Ne=I.get(`${he.rowIdx+mt.dRow},${vt}`);if(Ne!==void 0){let ct=ge.get(Ne),He=O(Ne,ct.node),$t=He.borders||{};X(Ne,{...He,borders:{...$t,[mt.adjSide]:Ue}});}}}X(fe,{...Pe,borders:rt});}for(let[fe,Fe]of W)q.setNodeMarkup(q.mapping.map(fe),void 0,Fe);B(q.scrollIntoView());}return true}}function E(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A);for(let{pos:q,node:ae}of v)B.setNodeMarkup(B.mapping.map(q),void 0,{...ae.attrs,verticalAlign:w});k(B.scrollIntoView());}return true}}function F(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A);for(let{pos:q,node:ae}of v){let _={...ae.attrs.margins||{},...w};B.setNodeMarkup(B.mapping.map(q),void 0,{...ae.attrs,margins:_});}k(B.scrollIntoView());}return true}}function G(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A);for(let{pos:q,node:ae}of v)B.setNodeMarkup(B.mapping.map(q),void 0,{...ae.attrs,textDirection:w});k(B.scrollIntoView());}return true}}function Y(){return (w,A)=>{let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(A){let M=w.tr,B=g(w);for(let{pos:v,node:q}of B)M.setNodeMarkup(M.mapping.map(v),void 0,{...q.attrs,noWrap:!q.attrs.noWrap});A(M.scrollIntoView());}return true}}function N(w,A){return (k,M)=>{let B=Ge(k);if(!B.isInTable||B.tablePos===void 0||!B.table)return false;if(M){let v=k.tr,{$from:q}=k.selection;for(let ae=q.depth;ae>0;ae--){let $=q.node(ae);if($.type.name==="tableRow"){let _=q.before(ae),ne={...$.attrs,height:w,heightRule:w?A||"atLeast":null};return v.setNodeMarkup(_,void 0,ne),M(v.scrollIntoView()),true}}}return true}}function H(){return (w,A)=>{let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table||!k.columnCount)return false;if(A){let M=w.tr,B=k.table,v=k.columnCount,q=B.attrs.columnWidths,ae=q?q.reduce((ge,I)=>ge+I,0):9360,$=Math.floor(ae/v),_=k.tablePos+1;B.forEach(ge=>{if(ge.type.name==="tableRow"){let I=_+1;ge.forEach(W=>{(W.type.name==="tableCell"||W.type.name==="tableHeader")&&(M=M.setNodeMarkup(I,void 0,{...W.attrs,width:$,widthType:"dxa",colwidth:null})),I+=W.nodeSize;});}_+=ge.nodeSize;});let ne=Array(v).fill($);M=M.setNodeMarkup(k.tablePos,void 0,{...B.attrs,columnWidths:ne}),A(M.scrollIntoView());}return true}}function J(){return (w,A)=>{let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(A){let M=w.tr,B=k.table,v=k.tablePos+1;B.forEach(q=>{if(q.type.name==="tableRow"){let ae=v+1;q.forEach($=>{($.type.name==="tableCell"||$.type.name==="tableHeader")&&(M=M.setNodeMarkup(ae,void 0,{...$.attrs,width:null,widthType:null,colwidth:null})),ae+=$.nodeSize;});}v+=q.nodeSize;}),M=M.setNodeMarkup(k.tablePos,void 0,{...B.attrs,columnWidths:null,width:null,widthType:"auto"}),A(M.scrollIntoView());}return true}}function de(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=M.table,q=M.tablePos,ae=v.childCount,$=w.look??{firstRow:true,lastRow:false,noHBand:false},_=w.conditionals??{},ne=w.tableBorders;B=B.setNodeMarkup(q,void 0,{...v.attrs,styleId:w.styleId});let ge=0,I=q+1;for(let W=0;W<ae;W++){let O=v.child(W),X=W===0&&!!$.firstRow,ue=W===ae-1&&!!$.lastRow,fe=$.noHBand!==true,Fe=O.childCount,he;X?he="firstRow":ue?he="lastRow":(fe&&(he=ge%2===0?"band1Horz":"band2Horz"),ge++);let Pe=I+1;for(let be=0;be<Fe;be++){let ot=O.child(be),rt=B.mapping.map(Pe),je=he,Qe=be===0&&!!$.firstCol,Ue=be===Fe-1&&!!$.lastCol;X&&Qe&&_.nwCell?je="nwCell":X&&Ue&&_.neCell?je="neCell":ue&&Qe&&_.swCell?je="swCell":ue&&Ue&&_.seCell?je="seCell":Qe?je="firstCol":Ue&&(je="lastCol");let mt=je?_[je]:void 0,vt={...ot.attrs};mt?.backgroundColor?vt.backgroundColor=mt.backgroundColor:vt.backgroundColor=null;let Ne={},ct=["top","bottom","left","right"];for(let He of ct)mt?.borders&&mt.borders[He]!==void 0?Ne[He]=mt.borders[He]:ne&&(He==="top"&&W>0||He==="bottom"&&W<ae-1?Ne[He]=ne.insideH??ne[He]:He==="left"&&be>0||He==="right"&&be<Fe-1?Ne[He]=ne.insideV??ne[He]:Ne[He]=ne[He]);Object.keys(Ne).length>0?vt.borders=Ne:vt.borders=null,B=B.setNodeMarkup(rt,void 0,vt),Pe+=ot.nodeSize;}I+=O.nodeSize;}k(B.scrollIntoView());}return true}}function D(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v={...M.table.attrs};"width"in w&&(v.width=w.width),"widthType"in w&&(v.widthType=w.widthType),"justification"in w&&(v.justification=w.justification),B.setNodeMarkup(M.tablePos,void 0,v),k(B.scrollIntoView());}return true}}function P(){return (w,A)=>{let k=Ge(w);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(A){let M=w.tr,{$from:B}=w.selection;for(let v=B.depth;v>0;v--){let q=B.node(v);if(q.type.name==="tableRow"){let ae=B.before(v),$={...q.attrs,isHeader:!q.attrs.isHeader};return M.setNodeMarkup(ae,void 0,$),A(M.scrollIntoView()),true}}}return true}}function R(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A),q=w.replace(/^#/,""),ae={style:"single",size:4},{cellByPos:$,cellByRC:_}=S(M.table,M.tablePos),ne=new Map,ge=(O,X)=>ne.get(O)??{...X.attrs},I=(O,X)=>ne.set(O,X),W={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:O,node:X}of v){let ue=$.get(O),fe=ge(O,X),Fe=fe.borders||{},he={};for(let Pe of ["top","bottom","left","right"]){let be={...ae,...Fe[Pe],color:{rgb:q}};if(he[Pe]=be,ue){let ot=W[Pe],rt=Pe==="right"?ue.colIdx+ue.colspan:ue.colIdx+ot.dCol,je=_.get(`${ue.rowIdx+ot.dRow},${rt}`);if(je!==void 0){let Qe=$.get(je),Ue=ge(je,Qe.node),mt=Ue.borders||{};I(je,{...Ue,borders:{...mt,[ot.adjSide]:be}});}}}I(O,{...fe,borders:{...Fe,...he}});}for(let[O,X]of ne)B.setNodeMarkup(B.mapping.map(O),void 0,X);k(B.scrollIntoView());}return true}}function me(w){return (A,k)=>{let M=Ge(A);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let B=A.tr,v=g(A),q={style:"single",color:{rgb:"000000"}},{cellByPos:ae,cellByRC:$}=S(M.table,M.tablePos),_=new Map,ne=(W,O)=>_.get(W)??{...O.attrs},ge=(W,O)=>_.set(W,O),I={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:W,node:O}of v){let X=ae.get(W),ue=ne(W,O),fe=ue.borders||{},Fe={};for(let he of ["top","bottom","left","right"]){let Pe={...q,...fe[he],size:w};if(Fe[he]=Pe,X){let be=I[he],ot=he==="right"?X.colIdx+X.colspan:X.colIdx+be.dCol,rt=$.get(`${X.rowIdx+be.dRow},${ot}`);if(rt!==void 0){let je=ae.get(rt),Qe=ne(rt,je.node),Ue=Qe.borders||{};ge(rt,{...Qe,borders:{...Ue,[be.adjSide]:Pe}});}}}ge(W,{...ue,borders:{...fe,...Fe}});}for(let[W,O]of _)B.setNodeMarkup(B.mapping.map(W),void 0,O);k(B.scrollIntoView());}return true}}function pe(){return (w,A)=>{let k=w.selection;if(!("$anchorCell"in k&&typeof k.forEachCell=="function"))return false;let B=Ge(w);if(!B.isInTable||B.tablePos===void 0||!B.table)return false;let v=0;B.table.descendants($=>{($.type.name==="tableCell"||$.type.name==="tableHeader")&&(v+=1);});let q=0;if(k.forEachCell(()=>{q+=1;}),!(v>0&&q>=v))return false;if(A){let $=w.tr.delete(B.tablePos,B.tablePos+B.table.nodeSize);A($.scrollIntoView());}return true}}function Be(){return w=>{let{$from:A,empty:k}=w.selection;if(!k)return false;let M=A.parent;if(M.type.name!=="paragraph"||M.textContent.length>0)return false;let B=A.depth;if(B<1)return false;let v=A.node(B-1),q=A.index(B-1),ae=q>0?v.child(q-1):null,$=q+1<v.childCount?v.child(q+1):null,_=ae?.type.name==="table",ne=$?.type.name==="table";return !!(_||ne)}}let Me=new prosemirrorState.PluginKey("activeCell"),We=new prosemirrorState.Plugin({key:Me,props:{decorations(w){let{selection:A}=w;if(A instanceof prosemirrorTables.CellSelection)return prosemirrorView.DecorationSet.empty;let{$from:k}=A;for(let M=k.depth;M>0;M--){let B=k.node(M);if(B.type.name==="tableCell"||B.type.name==="tableHeader"){let v=k.before(M);return prosemirrorView.DecorationSet.create(w.doc,[prosemirrorView.Decoration.node(v,v+B.nodeSize,{class:"activeCell"})])}}return prosemirrorView.DecorationSet.empty}}});return {plugins:[prosemirrorTables.columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),prosemirrorTables.tableEditing(),We],keyboardShortcuts:{Backspace:n(pe(),Be()),Delete:n(pe(),Be())},commands:{insertTable:(w,A)=>i(w,A),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>d,deleteColumn:()=>c,deleteTable:()=>p,selectTable:()=>m,selectRow:()=>f,selectColumn:()=>b,mergeCells:()=>prosemirrorTables.mergeCells,splitCell:()=>prosemirrorTables.splitCell,setCellBorder:(w,A,k)=>z(w,A,k),setTableBorders:(w,A)=>T(w,A),setCellVerticalAlign:w=>E(w),setCellMargins:w=>F(w),setCellTextDirection:w=>G(w),toggleNoWrap:()=>Y(),setRowHeight:(w,A)=>N(w,A),toggleHeaderRow:()=>P(),distributeColumns:()=>H(),autoFitContents:()=>J(),setTableProperties:w=>D(w),applyTableStyle:w=>de(w),setCellFillColor:w=>x(w),setTableBorderColor:w=>R(w),setTableBorderWidth:w=>me(w),removeTableBorders:()=>T("none"),setAllTableBorders:w=>T("all",w),setOutsideTableBorders:w=>T("outside",w),setInsideTableBorders:w=>T("inside",w)}}}});function Ld(){return [Wm(),Vm(),jm(),Um(),Km()]}function Rs(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function Bd(e){return (t,n)=>{let{$from:o,$to:r}=t.selection,i=o.parent;if(i.type.name!=="paragraph")return false;let s=i.attrs.numPr?.numId===e;if(!n)return true;let l=t.tr,u=new Set;return t.doc.nodesBetween(o.pos,r.pos,(d,c)=>{if(d.type.name==="paragraph"&&!u.has(c))if(u.add(c),s)l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:{numId:e,ilvl:d.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var Gm=(e,t)=>Bd(1)(e,t),qm=(e,t)=>Bd(2)(e,t),Ym=(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},Xm=(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},Zm=(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 Jm(){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 Qm(){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 eg(){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 tg(){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 ng(){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 og(){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 Ad=ft({name:"list",priority:Jt.High,onSchemaReady(){return {commands:{toggleBulletList:()=>Gm,toggleNumberedList:()=>qm,increaseListLevel:()=>Ym,decreaseListLevel:()=>Xm,removeList:()=>Zm},keyboardShortcuts:{Tab:Rs(Id(),tg(),og()),"Shift-Tab":Rs(Fd(),ng()),"Shift-Enter":()=>false,Enter:Rs(Jm(),Qm()),Backspace:eg()}}}});function Hd(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var dg=(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},ug=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],Nd=new Set(["fontFamily","fontSize","textColor"]),pg=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>Nd.has(u.type.name)),s=null;if(!prosemirrorCommands.splitBlock(e,t?u=>{s=u;}:void 0,n))return false;if(t&&s!==null){let u=s,{$from:d}=u.selection,c=d.parent;if(c.type.name==="paragraph"){let p={...c.attrs},m=false;if(r)for(let f of ug){let b=r.attrs[f];b!=null&&p[f]==null&&(p[f]=b,m=true);}if(p.borders&&(p.borders=null,m=true),m&&u.setNodeMarkup(d.before(),void 0,p),c.textContent.length===0){let f=a;if(f.length===0&&r){let b=r.attrs.defaultTextFormatting;b&&(f=Cs(b,e.schema).filter(S=>Nd.has(S.type.name)));}if(f.length>0){let b={...p.defaultTextFormatting??{}},g=false;for(let S of f)if(S.type.name==="fontSize"&&S.attrs.size!==b.fontSize&&(b.fontSize=S.attrs.size,g=true),S.type.name==="fontFamily"){let T=S.attrs.ascii;T&&(!b.fontFamily||b.fontFamily.ascii!==T)&&(b.fontFamily={...b.fontFamily,ascii:T,hAnsi:S.attrs.hAnsi},g=true);}g&&u.setNodeMarkup(d.before(),void 0,{...p,defaultTextFormatting:b}),u.setStoredMarks(f);}}}t(u.scrollIntoView());}return true},zd=ft({name:"baseKeymap",priority:Jt.Low,onSchemaReady(e){return {keyboardShortcuts:{...prosemirrorCommands.baseKeymap,Enter:pg,Backspace:Hd(prosemirrorCommands.deleteSelection,dg,prosemirrorCommands.joinBackward),Delete:Hd(prosemirrorCommands.deleteSelection,prosemirrorCommands.joinForward),"Mod-a":prosemirrorCommands.selectAll,Escape:prosemirrorCommands.selectParentNode}}}});var oi=new prosemirrorState.PluginKey("selectionTracker");function Ao(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((z,E,F)=>{if(E>r)return false;E<=o&&(s=F),E<=r&&(l=F);});let u=gg(e),d=a.parent,c={};d.type.name==="paragraph"&&(d.attrs.alignment&&(c.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(c.lineSpacing=d.attrs.lineSpacing,c.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.indentLeft&&(c.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(c.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(c.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(c.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(c.tabs=d.attrs.tabs),d.attrs.numPr&&(c.numPr=d.attrs.numPr),d.attrs.styleId&&(c.styleId=d.attrs.styleId));let p=d.attrs?.numPr,m=!!p?.numId,f=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl,g=e.storedMarks||(i?a.marks():[]),S=[],T=false,x=false;for(let z of g)z.type.name==="comment"&&z.attrs.commentId&&S.push(z.attrs.commentId),z.type.name==="insertion"&&(T=true),z.type.name==="deletion"&&(x=true);return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:c,startParagraphIndex:s,endParagraphIndex:l,inList:m,listType:f,listLevel:b,activeCommentIds:S,inInsertion:T,inDeletion:x}}function gg(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 ri(e){return new prosemirrorState.Plugin({key:oi,state:{init(t,n){return Ao(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=Ao(r);return e&&!bg(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=oi.getState(t.state);o&&e(o);}}}})}function hg(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 bg(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&&hg(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var Od=ft({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[ri(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(Ao(n),true)}}}});var Sg=new prosemirrorState.PluginKey("imageDrag"),_d=ft({name:"imageDrag",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({key:Sg,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof prosemirrorState.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 prosemirrorState.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 Es=612;async function Cg(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 wg(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 vg(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 Cg(r);}catch{continue}let a=1,s=1;try{({width:a,height:s}=await wg(i));}catch{a=1,s=1;}let l=a,u=s;if(l>Es){let p=Es/l;l=Es,u=Math.max(1,Math.round(u*p));}let d=n.create({src:i,alt:r.name,width:l,height:u,rId:`rId_img_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,wrapType:"inline",displayMode:"inline"}),c=e.state.tr.insert(o,d);o+=d.nodeSize,c.setSelection(prosemirrorState.TextSelection.create(c.doc,o)),e.dispatch(c.scrollIntoView());}e.focus();}var Wd=ft({name:"imagePaste",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({props:{handleDOMEvents:{paste(n,o){let r=o,i=chunk7YCCCWUZ_cjs.L(r.clipboardData);return i.length===0||!n.state.schema.nodes.image?false:(r.preventDefault(),vg(n,i).catch(()=>{}),true)}}}})]}}});var Vd=ft({name:"dropCursor",onSchemaReady(){return {plugins:[prosemirrorDropcursor.dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});var ii=new prosemirrorState.PluginKey("paragraphChangeTracker");function jd(e){let t=0;return e.descendants(n=>{n.type.name==="paragraph"&&t++;}),t}function Mg(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 Ig(){return new prosemirrorState.Plugin({key:ii,state:{init(e,t){return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:jd(t.doc)}},apply(e,t){if(e.getMeta(ii)==="clear")return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:t.paragraphCount};if(!e.docChanged)return t;let n=jd(e.doc),o={changedParaIds:new Set(t.changedParaIds),structuralChange:t.structuralChange,hasUntrackedChanges:t.hasUntrackedChanges,paragraphCount:n};t.paragraphCount!==n&&(o.structuralChange=true);for(let r of e.steps)r.getMap().forEach((a,s,l,u)=>{let{ids:d,hasUntracked:c}=Mg(e.doc,l,u);for(let p of d)o.changedParaIds.add(p);c&&(o.hasUntrackedChanges=true);});return o}}})}function Ps(e){return ii.getState(e)}function Ud(e){return Ps(e)?.changedParaIds??new Set}function Kd(e){return Ps(e)?.structuralChange??false}function Gd(e){return Ps(e)?.hasUntrackedChanges??false}function qd(e){return e.tr.setMeta(ii,"clear")}var Yd=ft({name:"paragraphChangeTracker",defaultOptions:{},onSchemaReady(){return {plugins:[Ig()]}}});var Xd=ft({name:"bidiShortcut",priority:Jt.High,onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({props:{handleKeyDown(t,n){if(n.key!=="Shift"||!(n.metaKey||n.ctrlKey))return false;let r=Rn.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 Zd(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 Bg(e,t){let n=e.getAttribute("style")||"",o=Zd(n);for(let[r,i]of Object.entries(t))r in o||e.style.setProperty(r,i);}function Ag(e){let t=e.querySelectorAll("style");if(t.length===0)return;let n=[];for(let o of t){let r=o.textContent||"";if(r.trim())try{let i=e.createElement("style");i.textContent=r,e.head.appendChild(i);let a=i.sheet;if(a)for(let s=0;s<a.cssRules.length;s++){let l=a.cssRules[s];if(l instanceof CSSStyleRule){let u={},d=l.style;for(let c=0;c<d.length;c++){let p=d[c];u[p]=d.getPropertyValue(p);}Object.keys(u).length>0&&n.push({selector:l.selectorText,declarations:u});}}e.head.removeChild(i);}catch{let i=/([^{]+)\{([^}]+)\}/g,a;for(;(a=i.exec(r))!==null;){let s=a[1].trim(),l=Zd(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)Bg(a,r);}catch{}}function Dg(e){if(!e.includes("<style"))return e;try{let n=new DOMParser().parseFromString(e,"text/html");Ag(n);let o=n.querySelectorAll("style");for(let r of o)r.remove();return n.body.innerHTML}catch{return e}}var Jd=ft({name:"pasteStyleInliner",priority:Jt.High,onSchemaReady(){return {plugins:[new prosemirrorState.Plugin({props:{transformPastedHTML(t){return Dg(t)}}})]}}});function Do(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",Lc()),o("text",Bc()),o("paragraph",Oc()),o("history",_c({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Vc()),o("italic",Uc()),o("underline",qc()),o("strike",Yc()),o("textColor",Xc()),o("highlight",Zc()),o("fontSize",Jc()),o("fontFamily",Qc()),o("superscript",ed()),o("subscript",td()),o("hyperlink",nd()),o("allCaps",od()),o("smallCaps",rd()),o("footnoteRef",id()),o("characterSpacing",ad()),o("emboss",dd()),o("imprint",ud()),o("textShadow",pd()),o("emphasisMark",fd()),o("textOutline",md()),o("comment",sd()),o("insertion",ld()),o("deletion",cd()),o("hardBreak",gd()),o("tab",hd()),o("image",bd()),o("textBox",yd()),o("shape",xd()),o("imageDrag",_d()),o("imagePaste",Wd()),o("dropCursor",Vd()),o("horizontalRule",Sd()),o("pageBreak",kd()),o("field",Td()),o("sdt",Cd()),o("math",wd()),t.has("table")||n.push(...Ld()),o("pasteStyleInliner",Jd()),o("list",Ad()),o("baseKeymap",zd()),o("selectionTracker",Od({onSelectionChange:e.onSelectionChange})),o("paragraphChangeTracker",Yd()),o("bidiShortcut",Xd()),n}var zn=class{constructor(t){chunkPCJ5ACUV_cjs.d(this,"extensions");chunkPCJ5ACUV_cjs.d(this,"schema",null);chunkPCJ5ACUV_cjs.d(this,"plugins",[]);chunkPCJ5ACUV_cjs.d(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 prosemirrorModel.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=>prosemirrorKeymap.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 ai=new zn(Do());ai.buildSchema();ai.initializeRuntime();var Rn=ai,Se=ai.getSchema();var zg={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},sr=class{constructor(t){chunkPCJ5ACUV_cjs.d(this,"stylesById");chunkPCJ5ACUV_cjs.d(this,"docDefaults");chunkPCJ5ACUV_cjs.d(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")??zg}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 mo(e){return new sr(e)}function ci(e,t){let n=e.package.document.content,o=[],r=t?.styles?mo(t.styles):null;for(let i of n)if(i.type==="paragraph")o.push(...Qd(i,r)),Jg(i)&&o.push(Se.node("pageBreak"));else if(i.type==="table"){let a=Is(i,r);o.push(a);}return o.length===0&&o.push(Se.node("paragraph",{},[])),Se.node("doc",null,o)}function Ms(e,t,n,o){let r=$g(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=yn(l,o);for(let d of e.content){if(d.type==="commentRangeStart")s.add(d.id);else if(d.type==="commentRangeEnd")s.delete(d.id);else if(d.type==="run"){let c=Fs(d,u,t);s.size>0&&(c=Og(c,s)),i.push(...c);}else if(d.type==="hyperlink"){let c=Ls(d,u,t);i.push(...c);}else if(d.type==="simpleField"||d.type==="complexField"){let c=jg(d,u);c&&i.push(c);}else if(d.type==="inlineSdt"){let c=Kg(d,u,t);c&&i.push(c);}else if(d.type==="insertion"){let c=si(d,"insertion",u,t);i.push(...c);}else if(d.type==="deletion"){let c=si(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveFrom"){let c=si(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveTo"){let c=si(d,"insertion",u,t);i.push(...c);}else if(d.type==="mathEquation"){let c=Ug(d);c&&i.push(c);}d.type==="bookmarkStart"&&(a||(a=[]),a.push({id:d.id,name:d.name}));}return a&&(r.bookmarks=a),Se.node("paragraph",r,i)}function Og(e,t){if(t.size===0)return e;let n=[...t][0],o=Se.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function si(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...Fs(a,n,o)):a.type==="hyperlink"&&r.push(...Ls(a,n,o));let i=Se.marks[t].create({revisionId:e.info.id,author:e.info.author,date:e.info.date??null});return r.map(a=>a.isText?a.mark(i.addToSet(a.marks)):a)}function $g(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=li(n?.runProperties,t);r.defaultTextFormatting=yn(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=li(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 Vt(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=li(r.pPr?.runProperties,e),a=li(r.rPr,e),s=yn(i,a);return {tcPr:r.tcPr,rPr:s}}function bn(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=yn(e.rPr,t.rPr),n}function li(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return yn(n,e)}function _g(e){let t=new Map,n=e.rows.length,o=new Map;for(let r=0;r<n;r++){let i=e.rows[r],a=0;for(let s=0;s<i.cells.length;s++){let l=i.cells[s],u=l.formatting?.gridSpan??1,d=l.formatting?.vMerge,c=`${r}-${a}`;if(d==="restart")o.set(a,r),t.set(c,{rowSpan:1,skip:false});else if(d==="continue"){let p=o.get(a);if(p!==void 0){let m=`${p}-${a}`,f=t.get(m);f&&f.rowSpan++;}t.set(c,{rowSpan:1,skip:true});}else o.delete(a),t.set(c,{rowSpan:1,skip:false});a+=u;}}return t}function Is(e,t){let n=_g(e),o=e.columnWidths,r=o?.reduce((x,z)=>x+z,0)??0,i=e.formatting?.styleId,a=e.formatting?.look,s=i?t?.getStyle(i):void 0,l=e.formatting?.borders??s?.tblPr?.borders,u=e.formatting?.cellMargins??s?.tblPr?.cellMargins??void 0,d=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,c={styleId:e.formatting?.styleId,width:e.formatting?.width?.value,widthType:e.formatting?.width?.type,justification:e.formatting?.justification,columnWidths:o,floating:e.formatting?.floating,cellMargins:d,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Vt(t,i,"wholeTable"),firstRow:Vt(t,i,"firstRow"),lastRow:Vt(t,i,"lastRow"),firstCol:Vt(t,i,"firstCol"),lastCol:Vt(t,i,"lastCol"),band1Horz:Vt(t,i,"band1Horz"),band2Horz:Vt(t,i,"band2Horz"),band1Vert:Vt(t,i,"band1Vert"),band2Vert:Vt(t,i,"band2Vert"),nwCell:Vt(t,i,"nwCell"),neCell:Vt(t,i,"neCell"),swCell:Vt(t,i,"swCell"),seCell:Vt(t,i,"seCell")},m=a?.noHBand!==true,f=a?.noVBand!==true,b=0,g=e.rows.length,S=o?.length??e.rows[0]?.cells.reduce((x,z)=>x+(z.formatting?.gridSpan??1),0)??0,T=e.rows.map((x,z)=>{let E=z===0&&!!a?.firstRow,F=z===g-1&&!!a?.lastRow,G=m&&!E&&!F?b%2===0?p.band1Horz:p.band2Horz:void 0;return m&&!E&&!F&&b++,Wg(x,t,E,o,r,p,G,f,a,l,z,g,S,n,d)});return Se.node("table",c,T)}function Wg(e,t,n,o,r,i,a,s,l,u,d,c,p,m,f){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header,_originalFormatting:e.formatting||void 0},g=e.cells.length,S=d===0,T=d===(c??1)-1,x=e.formatting?.conditionalFormat,z=x?.firstRow??S,E=x?.lastRow??T,F=p??g,G=0,Y=[];for(let N=0;N<e.cells.length;N++){let H=e.cells[N],J=H.formatting?.gridSpan??1,de=`${d??0}-${G}`,D=m?.get(de),P=D?.skip??false,R=D?.rowSpan??1,me;if(o&&r&&r>0){let q=0;for(let ae=0;ae<J&&G+ae<o.length;ae++)q+=o[G+ae];me=Math.round(q/r*100);}if(G+=J,P)continue;let pe=G-J===0,Be=G===F,Me=H.formatting?.conditionalFormat,We=Me?.firstRow??z,w=Me?.lastRow??E,A=Me?.firstColumn??pe,k=Me?.lastColumn??Be,M;if(s){let q=l?.firstColumn?1:0,ae=G-J-q;ae>=0&&!(l?.lastColumn&&k)&&!(l?.firstColumn&&A)&&(M=ae%2===0?i?.band1Vert:i?.band2Vert);}Me?.oddVBand?M=i?.band1Vert:Me?.evenVBand&&(M=i?.band2Vert);let B=a;x?.oddHBand?B=i?.band1Horz:x?.evenHBand&&(B=i?.band2Horz),Me?.oddHBand?B=i?.band1Horz:Me?.evenHBand&&(B=i?.band2Horz);let v=i?.wholeTable;v=bn(v,B),v=bn(v,M),We&&(l?.firstRow||x?.firstRow||Me?.firstRow)&&(v=bn(v,i?.firstRow)),w&&(l?.lastRow||x?.lastRow||Me?.lastRow)&&(v=bn(v,i?.lastRow)),A&&(l?.firstColumn||x?.firstColumn||Me?.firstColumn)&&(v=bn(v,i?.firstCol)),k&&(l?.lastColumn||x?.lastColumn||Me?.lastColumn)&&(v=bn(v,i?.lastCol)),We&&A&&(l?.firstRow||x?.firstRow||Me?.firstRow)&&(l?.firstColumn||x?.firstColumn||Me?.firstColumn)&&(v=bn(v,i?.nwCell)),We&&k&&(l?.firstRow||x?.firstRow||Me?.firstRow)&&(l?.lastColumn||x?.lastColumn||Me?.lastColumn)&&(v=bn(v,i?.neCell)),w&&A&&(l?.lastRow||x?.lastRow||Me?.lastRow)&&(l?.firstColumn||x?.firstColumn||Me?.firstColumn)&&(v=bn(v,i?.swCell)),w&&k&&(l?.lastRow||x?.lastRow||Me?.lastRow)&&(l?.lastColumn||x?.lastColumn||Me?.lastColumn)&&(v=bn(v,i?.seCell)),Y.push(Vg(H,t,n,me,v,u,S,T,pe,Be,R,f));}return Se.node("tableRow",b,Y)}function Vg(e,t,n,o,r,i,a,s,l,u,d,c){let p=e.formatting,m=d??1,f=p?.width?.value,b=p?.width?.type;f===void 0&&o!==void 0&&(f=o,b="pct");let g=p?.shading?.fill?.rgb??r?.tcPr?.shading?.fill?.rgb,S=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,x=p?.borders,z=S||T||x?{...S??{},...T??{},...x??{}}:void 0,E={colspan:p?.gridSpan??1,rowspan:m,width:f,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:g,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:z,margins:p?.margins?{top:p.margins.top?.value,bottom:p.margins.bottom?.value,left:p.margins.left?.value,right:p.margins.right?.value}:r?.tcPr?.margins?{top:r.tcPr.margins.top?.value,bottom:r.tcPr.margins.bottom?.value,left:r.tcPr.margins.left?.value,right:r.tcPr.margins.right?.value}:c,_originalFormatting:p||void 0},F=[];for(let Y of e.content)Y.type==="paragraph"?F.push(Ms(Y,t,void 0,r?.rPr)):Y.type==="table"&&F.push(Is(Y,t));F.length===0&&F.push(Se.node("paragraph",{},[]));let G=n?"tableHeader":"tableCell";return Se.node(G,E,F)}function jg(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=yn(t,o),a=Bs(i);return Se.node("field",{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false},void 0,a)}function Ug(e){return Se.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Kg(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=Fs(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Ls(i,t,n);r.push(...a);}return Se.node("sdt",{sdtType:o.sdtType,alias:o.alias??null,tag:o.tag??null,lock:o.lock??null,placeholder:o.placeholder??null,showingPlaceholder:o.showingPlaceholder??false,dateFormat:o.dateFormat??null,listItems:o.listItems?JSON.stringify(o.listItems):null,checked:o.checked??null},r.length>0?r:void 0)}function Fs(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=yn(yn(t,r),e.formatting),a=Bs(i);for(let s of e.content){let l=Gg(s,a);o.push(...l);}return o}function yn(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 Gg(e,t){switch(e.type){case "text":return e.text?[Se.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[Se.node("hardBreak")]:[];case "tab":return [Se.node("tab")];case "drawing":return e.image?[qg(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[Yg(r)]}case "footnoteRef":let n=Se.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [Se.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=Se.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [Se.text(e.id.toString(),[...t,o])];default:return []}}function qg(e){let t=e.size?.width?chunkKR32M3S4_cjs.c(e.size.width):void 0,n=e.size?.height?chunkKR32M3S4_cjs.c(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 S=[];e.transform.rotation&&S.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&S.push("scaleX(-1)"),e.transform.flipV&&S.push("scaleY(-1)"),S.length>0&&(l=S.join(" "));}let u=e.wrap.distT?chunkKR32M3S4_cjs.c(e.wrap.distT):void 0,d=e.wrap.distB?chunkKR32M3S4_cjs.c(e.wrap.distB):void 0,c=e.wrap.distL?chunkKR32M3S4_cjs.c(e.wrap.distL):void 0,p=e.wrap.distR?chunkKR32M3S4_cjs.c(e.wrap.distR):void 0,m;e.position&&(m={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 f,b,g;if(e.outline&&e.outline.width){f=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(b=`#${e.outline.color.rgb}`);let S={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};g=e.outline.style&&S[e.outline.style]||"solid";}return Se.node("image",{src:e.src||"",alt:e.alt,title:e.title,width:t,height:n,rId:e.rId,wrapType:o,displayMode:s,cssFloat:a,transform:l,distTop:u,distBottom:d,distLeft:c,distRight:p,position:m,borderWidth:f,borderColor:b,borderStyle:g,wrapText:r,hlinkHref:e.hlinkHref})}function Ls(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=Se.mark("hyperlink",{href:r,tooltip:e.tooltip,rId:e.rId});for(let a of e.children)if(a.type==="run"){let s=a.formatting?.styleId?n?.resolveRunStyle(a.formatting.styleId):void 0,l=yn(yn(t,s),a.formatting),d=[...Bs(l),i];for(let c of a.content)c.type==="text"&&c.text&&o.push(Se.text(c.text,d));}return o}function Bs(e){if(!e)return [];let t=[];return e.bold&&t.push(Se.mark("bold")),e.italic&&t.push(Se.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(Se.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(Se.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(Se.mark("textColor",{rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&e.highlight!=="none"&&t.push(Se.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(Se.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(Se.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,eastAsia:e.fontFamily.eastAsia,cs:e.fontFamily.cs,asciiTheme:e.fontFamily.asciiTheme,hAnsiTheme:e.fontFamily.hAnsiTheme,eastAsiaTheme:e.fontFamily.eastAsiaTheme,csTheme:e.fontFamily.csTheme})),e.vertAlign==="superscript"?t.push(Se.mark("superscript")):e.vertAlign==="subscript"&&t.push(Se.mark("subscript")),e.allCaps&&t.push(Se.mark("allCaps")),e.smallCaps&&t.push(Se.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(Se.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(Se.mark("emboss")),e.imprint&&t.push(Se.mark("imprint")),e.shadow&&t.push(Se.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(Se.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(Se.mark("textOutline")),t}function Yg(e){let t=e.size?.width?chunkKR32M3S4_cjs.c(e.size.width):100,n=e.size?.height?chunkKR32M3S4_cjs.c(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(m=>({position:m.position,color:m.color.rgb?`#${m.color.rgb}`:"#000000"})));}let l,u,d;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),d=e.outline.style||"solid");let c;if(e.transform){let p=[];e.transform.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&p.push("scaleX(-1)"),e.transform.flipV&&p.push("scaleY(-1)"),p.length>0&&(c=p.join(" "));}return Se.node("shape",{shapeType:e.shapeType||"rect",shapeId:e.id,width:t,height:n,fillColor:o,fillType:r,gradientType:i,gradientAngle:a,gradientStops:s,outlineWidth:l,outlineColor:u,outlineStyle:d,transform:c})}function Qd(e,t){let n=Xg(e),o=Ms(e,t),r=[];n.length>0&&o.content.size===0||r.push(o);for(let a of n)r.push(Zg(a,t));return r}function Xg(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 Zg(e,t){let n=e.size?.width?chunkKR32M3S4_cjs.c(e.size.width):200,o=e.size?.height?chunkKR32M3S4_cjs.c(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?chunkKR32M3S4_cjs.c(e.margins.top):4,u=e.margins?.bottom!=null?chunkKR32M3S4_cjs.c(e.margins.bottom):4,d=e.margins?.left!=null?chunkKR32M3S4_cjs.c(e.margins.left):7,c=e.margins?.right!=null?chunkKR32M3S4_cjs.c(e.margins.right):7,p=[];for(let m of e.content)p.push(Ms(m,t));return p.length===0&&p.push(Se.node("paragraph",{},[])),Se.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:d,marginRight:c},p)}function As(e,t){let n=[],o=t?.styles?mo(t.styles):null;for(let r of e)r.type==="paragraph"?n.push(...Qd(r,o)):r.type==="table"&&n.push(Is(r,o));return n.length===0&&n.push(Se.node("paragraph",{},[])),Se.node("doc",null,n)}function Jg(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 di(){return Se.node("doc",null,[Se.node("paragraph",{},[])])}function ui(e,t){let o={content:tu(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 tu(e){let t=[],n=ou(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push(Ds(o,n)):o.type.name==="table"?t.push(iu(o,n)):o.type.name==="textBox"?t.push(xh(o)):o.type.name==="pageBreak"&&t.push(Qg());}),t}function Qg(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Ds(e,t){let n=e.attrs,o=eh(nu(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:th(n),content:o};return n._sectionProperties?i.sectionProperties=n._sectionProperties:n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function eh(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 th(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 nu(e,t){let n=[],o=t??ou(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 m={type:l.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(l.attrs.id,10)||0};n.push({type:"run",content:[m]});return}let u=s.marks.find(p=>p.type.name==="insertion"),d=s.marks.find(p=>p.type.name==="deletion");if(u||d){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let p=u||d,m=s.marks.filter(E=>E.type.name!=="insertion"&&E.type.name!=="deletion"),f=Hs(m),b={type:"run",content:s.isText&&s.text?[{type:"text",text:s.text}]:[],...Object.keys(f).length>0?{formatting:f}:{}},g={id:p.attrs.revisionId,author:p.attrs.author||"Unknown",date:p.attrs.date||void 0},S=g.id,T=(o.insertionById.get(S)??0)>0,x=(o.deletionById.get(S)??0)>0,z=T&&x;u?z?n.push({type:"moveTo",info:g,content:[b]}):n.push({type:"insertion",info:g,content:[b]}):z?n.push({type:"moveFrom",info:g,content:[b]}):n.push({type:"deletion",info:g,content:[b]});return}let c=s.marks.find(p=>p.type.name==="hyperlink");if(c){let p=nh(c),m=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&m===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=rh(c)),eu(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=oh(s.marks);r&&i===p?ih(r,s.text||""):(r&&n.push(r),r=ru(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(ah())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(uh(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push(ph(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(sh())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(lh(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(dh(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(ch(s)));}),r&&n.push(r),a&&n.push(a),n}function ou(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 nh(e){return e.attrs.href||""}function oh(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 rh(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 eu(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=ru(t.text,n);e.children.push(o);}}function ru(e,t){let n=Hs(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function ih(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 ah(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function sh(){return {type:"run",content:[{type:"tab"}]}}function lh(e,t){let n=e.attrs,o=t&&t.length>0?Hs(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 ch(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function dh(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=nu(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function uh(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:chunkKR32M3S4_cjs.d(t.width||0),height:chunkKR32M3S4_cjs.d(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 ph(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 Hs(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 fh(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 iu(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(gh(i,t));});let r=mh(n)||void 0;if(!r?.borders){let i=fh(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 mh(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 gh(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push(bh(r,t));}),{type:"tableRow",formatting:hh(n),cells:o}}function hh(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 bh(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push(Ds(r,t)):r.type.name==="table"&&o.push(iu(r,t));}),{type:"tableCell",formatting:yh(n),content:o}}function yh(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 xh(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(Ds(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 lr(e){return tu(e)}function Ho(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((g,S,T)=>{S<=o&&(s=T),S<=r&&(l=T);});let u={},d=a.parent,c=d.type.name==="paragraph"&&d.textContent.length===0,p=d.attrs?.defaultTextFormatting,m=e.storedMarks||t.$from.marks();c&&m.length===0&&p&&(u={...p});for(let g of m)switch(g.type.name){case "bold":u.bold=true;break;case "italic":u.italic=true;break;case "underline":u.underline={style:g.attrs.style||"single",color:g.attrs.color};break;case "strike":g.attrs.double?u.doubleStrike=true:u.strike=true;break;case "textColor":u.color={rgb:g.attrs.rgb,themeColor:g.attrs.themeColor};break;case "highlight":u.highlight=g.attrs.color;break;case "fontSize":u.fontSize=g.attrs.size;break;case "fontFamily":u.fontFamily={ascii:g.attrs.ascii,hAnsi:g.attrs.hAnsi};break;case "superscript":u.vertAlign="superscript";break;case "subscript":u.vertAlign="subscript";break}let f={},b=null;return d.type.name==="paragraph"&&(d.attrs.alignment&&(f.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(f.lineSpacing=d.attrs.lineSpacing,f.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.numPr&&(f.numPr=d.attrs.numPr),d.attrs.indentLeft&&(f.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(f.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(f.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(f.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(f.tabs=d.attrs.tabs),d.attrs.bidi&&(f.bidi=true),d.attrs.styleId&&(b=d.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:f,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var Pt=Rn.getCommands(),pi=Pt.toggleBold(),fi=Pt.toggleItalic(),mi=Pt.toggleUnderline(),gi=Pt.toggleStrike(),hi=Pt.toggleSuperscript(),bi=Pt.toggleSubscript();function cr(e){return Pt.setTextColor(e)}var yi=Pt.clearTextColor();function xi(e){return Pt.setHighlight(e)}Pt.clearHighlight();function Si(e){return Pt.setFontSize(e)}Pt.clearFontSize();function ki(e){return Pt.setFontFamily(e)}Pt.clearFontFamily();function Ti(e,t){return Pt.setHyperlink(e,t)}var Ci=Pt.removeHyperlink();function dr(e,t,n){return Pt.insertHyperlink(e,t,n)}var at=Rn.getCommands();function wi(e){return at.setAlignment(e)}at.alignLeft();at.alignCenter();at.alignRight();at.alignJustify();function vi(e,t="auto"){return at.setLineSpacing(e,t)}at.singleSpacing();at.oneAndHalfSpacing();at.doubleSpacing();function Ri(e=720){return at.increaseIndent(e)}function Ei(e=720){return at.decreaseIndent(e)}function Pi(e){return at.setIndentLeft(e)}function Mi(e){return at.setIndentRight(e)}function ur(e,t){return at.setIndentFirstLine(e,t)}var Ii=at.toggleBulletList(),Fi=at.toggleNumberedList(),Li=at.increaseListLevel(),Bi=at.decreaseListLevel();at.removeList();function pr(e,t){return at.applyStyle(e,t)}at.clearStyle();at.removeSectionBreak();function Ai(e){return at.removeTabStop(e)}var Di=at.setRtl(),Hi=at.setLtr(),Ni=at.generateTOC();var Ze=Rn.getCommands();function zi(e,t){return Ze.insertTable(e,t)}function Oi(e,t){return Ze.addRowAbove()(e,t)}function No(e,t){return Ze.addRowBelow()(e,t)}function $i(e,t){return Ze.deleteRow()(e,t)}function _i(e,t){return Ze.addColumnLeft()(e,t)}function zo(e,t){return Ze.addColumnRight()(e,t)}function Wi(e,t){return Ze.deleteColumn()(e,t)}function fr(e,t){return Ze.deleteTable()(e,t)}function Vi(e,t){return Ze.selectTable()(e,t)}function ji(e,t){return Ze.selectRow()(e,t)}function Ui(e,t){return Ze.selectColumn()(e,t)}function Ki(e,t){return Ze.mergeCells()(e,t)}function Gi(e,t){return Ze.splitCell()(e,t)}function On(e,t,n){return Ze.setCellBorder(e,t,n)}function qi(e,t){return Ze.removeTableBorders()(e,t)}function Yi(e,t,n){return Ze.setAllTableBorders(n)(e,t)}function Xi(e,t,n){return Ze.setOutsideTableBorders(n)(e,t)}function Zi(e,t,n){return Ze.setInsideTableBorders(n)(e,t)}function Ji(e){return Ze.setCellVerticalAlign(e)}function Qi(e){return Ze.setCellMargins(e)}function ea(e){return Ze.setCellTextDirection(e)}function ta(){return Ze.toggleNoWrap()}function na(e,t){return Ze.setRowHeight(e,t)}function oa(){return Ze.toggleHeaderRow()}function ra(){return Ze.distributeColumns()}function ia(){return Ze.autoFitContents()}function mr(e){return Ze.setTableProperties(e)}function aa(e){return Ze.applyTableStyle(e)}function sa(e){return Ze.setCellFillColor(e)}function la(e){return Ze.setTableBorderColor(e)}function ca(e){return Ze.setTableBorderWidth(e)}var da=(e,t)=>{let{schema:n}=e,o=n.nodes.pageBreak,r=n.nodes.paragraph;if(!o||!r)return false;if(t){let{$from:i}=e.selection,a=e.tr,s=o.create(),l=s.nodeSize,u;if(i.parent.isTextblock)if(i.parentOffset>0&&i.parentOffset<i.parent.content.size){a.split(i.pos);let d=a.mapping.map(i.pos);a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else if(i.parentOffset===i.parent.content.size){let d=i.after();a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else {let d=i.before();a.insert(d,s),u=d+l+1;}else {let d=i.pos;a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}a.setSelection(prosemirrorState.TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function Tu(e,t,n){return (o,r)=>{let i=o.schema.marks.insertion,a=o.schema.marks.deletion;if(!i&&!a)return false;let s=n==="accept"?i:a,l=n==="accept"?a:i;if(r){let u=o.tr,d=[];o.doc.nodesBetween(e,t,(c,p)=>{if(!c.isText)return;let m=p+c.nodeSize,f=Math.max(e,p),b=Math.min(t,m);l&&c.marks.some(g=>g.type===l)&&d.push({from:f,to:b}),s&&c.marks.some(g=>g.type===s)&&u.removeMark(f,b,s);});for(let c of d.reverse())u.delete(c.from,c.to);u.steps.length>0&&r(u);}return true}}function zs(e,t){return Tu(e,t,"accept")}function Os(e,t){return Tu(e,t,"reject")}var wu={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},vu={fontWeight:500,letterSpacing:.3},Nh={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},zh={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"},ua={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},Eu=Gp.forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},d){let c=Gp.useRef(null),p=Gp.useRef(null),[m,f]=Gp.useState(false),[b,g]=Gp.useState(false),S=Gp.useRef(null),[T,x]=Gp.useState(null);Gp.useLayoutEffect(()=>{let Y=()=>{let H=i.getBoundingClientRect(),J=r.getBoundingClientRect();x({top:J.top-H.top+i.scrollTop,left:J.left-H.left+i.scrollLeft,width:J.width});};Y();let N=i.closest('[style*="overflow"]')||i;return N.addEventListener("scroll",Y),window.addEventListener("resize",Y),()=>{N.removeEventListener("scroll",Y),window.removeEventListener("resize",Y);}},[r,i]),Gp.useEffect(()=>{if(!c.current||p.current)return;let Y=As(t.content,{styles:o||void 0}),N=new zn(Do());N.buildSchema(),N.initializeRuntime();let H=N.getPlugins(),J=prosemirrorState.EditorState.create({doc:Y,schema:Se,plugins:H}),de=new prosemirrorView.EditorView(c.current,{state:J,dispatchTransaction(D){let P=de.state.apply(D);if(de.updateState(P),D.docChanged&&f(true),D.selectionSet||D.docChanged){let R=Ho(P);l?.(R);}}});return p.current=de,requestAnimationFrame(()=>{de.focus();let D=Ho(de.state);l?.(D);}),()=>{de.destroy(),p.current=null;}},[T]);let z=Gp.useCallback(()=>{if(!p.current)return;let Y=lr(p.current.state.doc);a(Y);},[a]),E=Gp.useCallback(()=>{m?z():s();},[m,z,s]);Gp.useEffect(()=>{function Y(N){N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),E());}return document.addEventListener("keydown",Y,true),()=>document.removeEventListener("keydown",Y,true)},[E]),Gp.useEffect(()=>{if(!b)return;function Y(N){S.current&&!S.current.contains(N.target)&&g(false);}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[b]),Gp.useImperativeHandle(d,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let Y=p.current;return Y?prosemirrorHistory.undo(Y.state,Y.dispatch):false},redo:()=>{let Y=p.current;return Y?prosemirrorHistory.redo(Y.state,Y.dispatch):false}}));let F=n==="header"?"Header":"Footer";if(!T)return null;let G={position:"absolute",top:T.top,left:T.left,width:T.width,zIndex:10};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:G,onMouseDown:Y=>{Y.stopPropagation();},children:[n==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:wu,children:[jsxRuntime.jsx("span",{style:vu,children:F}),jsxRuntime.jsx(Ru,{label:F,showOptions:b,setShowOptions:g,optionsRef:S,onRemove:u,onClose:E,viewRef:p})]}),jsxRuntime.jsx("div",{ref:c,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:wu,children:[jsxRuntime.jsx("span",{style:vu,children:F}),jsxRuntime.jsx(Ru,{label:F,showOptions:b,setShowOptions:g,optionsRef:S,onRemove:u,onClose:E,viewRef:p})]})]})});function Ru({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let s=l=>{let u=a.current;if(!u)return;let{$from:d,from:c}=u.state.selection,p=u.state.storedMarks||d.marks(),m=Se.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),f=u.state.tr.insert(c,m.mark(p));u.dispatch(f),u.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:o,children:[jsxRuntime.jsx("button",{type:"button",style:Nh,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxRuntime.jsxs("div",{style:zh,children:[jsxRuntime.jsx("button",{type:"button",style:ua,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsxRuntime.jsx("button",{type:"button",style:ua,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsxRuntime.jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxRuntime.jsxs("button",{type:"button",style:ua,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxRuntime.jsxs("button",{type:"button",style:ua,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var Fu={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"},$h={...Fu,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},_h={...Fu,padding:"12px",width:"320px"},Us={width:"20px",height:"20px",flexShrink:0,color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center"},Wh={color:"#1a73e8",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},Vh={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"#5f6368",padding:0,flexShrink:0},jh={width:"1px",height:"20px",background:"#dadce0",flexShrink:0},Mu={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},Iu={flex:1,padding:"6px 8px",border:"1px solid #dadce0",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},Uh={color:"#1a73e8",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},Oo={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function Kh(){return jsxRuntime.jsxs("svg",{...Oo,children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M2 12h20"}),jsxRuntime.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 Gh(){return jsxRuntime.jsxs("svg",{...Oo,children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function qh(){return jsxRuntime.jsx("svg",{...Oo,children:jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Yh(){return jsxRuntime.jsxs("svg",{...Oo,children:[jsxRuntime.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"}),jsxRuntime.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"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),jsxRuntime.jsx("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),jsxRuntime.jsx("line",{x1:"16",y1:"19",x2:"16",y2:"22"}),jsxRuntime.jsx("line",{x1:"19",y1:"16",x2:"22",y2:"16"})]})}function Xh(){return jsxRuntime.jsxs("svg",{...Oo,children:[jsxRuntime.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),jsxRuntime.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),jsxRuntime.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),jsxRuntime.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function Zh(){return jsxRuntime.jsxs("svg",{...Oo,children:[jsxRuntime.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"}),jsxRuntime.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 Ks({title:e,onClick:t,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:Vh,title:e,onClick:t,children:n})}function Lu({data:e,onNavigate:t,onCopy:n,onEdit:o,onRemove:r,onClose:i,readOnly:a}){let[s,l]=Gp.useState("view"),[u,d]=Gp.useState(""),[c,p]=Gp.useState(""),m=Gp.useRef(null),f=Gp.useRef(null);Gp.useEffect(()=>{e&&(l("view"),d(e.displayText),p(e.href));},[e]),Gp.useEffect(()=>{s==="edit"&&requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();});},[s]),Gp.useEffect(()=>{if(!e)return;let F=false,G=N=>{m.current&&!m.current.contains(N.target)&&i();},Y=setTimeout(()=>{F||document.addEventListener("mousedown",G);},0);return ()=>{F=true,clearTimeout(Y),document.removeEventListener("mousedown",G);}},[e,i]),Gp.useEffect(()=>{if(!e)return;let F=G=>{G.key==="Escape"&&(s==="edit"?l("view"):i());};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[e,s,i]);let b=Gp.useCallback(()=>{e&&(n(e.href),sonner.toast("Link copied to clipboard"));},[e,n]),g=Gp.useCallback(()=>{e&&(d(e.displayText),p(e.href),l("edit"));},[e]),S=Gp.useCallback(()=>{let F=c.trim();F&&o(u.trim()||F,F);},[u,c,o]),T=Gp.useCallback(F=>{F.key==="Enter"&&(F.preventDefault(),S());},[S]);if(!e)return null;let{anchorRect:x}=e,z=x.bottom+4,E=x.left;return s==="edit"?jsxRuntime.jsxs("div",{ref:m,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{..._h,top:z,left:E},onMouseDown:F=>F.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:Mu,children:[jsxRuntime.jsx("span",{style:Us,children:jsxRuntime.jsx(Xh,{})}),jsxRuntime.jsx("input",{ref:f,type:"text",style:Iu,value:u,onChange:F=>d(F.target.value),onKeyDown:T,placeholder:"Display text",onFocus:F=>F.target.style.borderColor="#1a73e8",onBlur:F=>F.target.style.borderColor="#dadce0"})]}),jsxRuntime.jsxs("div",{style:{...Mu,marginBottom:0},children:[jsxRuntime.jsx("span",{style:Us,children:jsxRuntime.jsx(Zh,{})}),jsxRuntime.jsx("input",{type:"text",style:Iu,value:c,onChange:F=>p(F.target.value),onKeyDown:T,placeholder:"https://example.com",onFocus:F=>F.target.style.borderColor="#1a73e8",onBlur:F=>F.target.style.borderColor="#dadce0"}),jsxRuntime.jsx("button",{type:"button",style:{...Uh,opacity:c.trim()?1:.5,cursor:c.trim()?"pointer":"default"},onClick:S,disabled:!c.trim(),children:"Apply"})]})]}):jsxRuntime.jsxs("div",{ref:m,className:"ep-hyperlink-popup",style:{...$h,top:z,left:E},onMouseDown:F=>F.stopPropagation(),children:[jsxRuntime.jsx("span",{style:Us,children:jsxRuntime.jsx(Kh,{})}),jsxRuntime.jsx("a",{href:e.href,style:Wh,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:F=>{F.preventDefault(),t(e.href);},children:e.href}),jsxRuntime.jsx("span",{style:jh}),jsxRuntime.jsx(Ks,{title:"Copy link",onClick:b,children:jsxRuntime.jsx(Gh,{})}),!a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ks,{title:"Edit link",onClick:g,children:jsxRuntime.jsx(qh,{})}),jsxRuntime.jsx(Ks,{title:"Remove link",onClick:r,children:jsxRuntime.jsx(Yh,{})})]})]})}var Re=e=>({style:"single",size:4,color:{rgb:e}}),Qh=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:Re("000000"),bottom:Re("000000"),left:Re("000000"),right:Re("000000"),insideH:Re("000000"),insideV:Re("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:Re("BFBFBF"),bottom:Re("BFBFBF"),left:Re("BFBFBF"),right:Re("BFBFBF"),insideH:Re("BFBFBF"),insideV:Re("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Re("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:Re("BFBFBF"),bottom:Re("BFBFBF"),insideH:Re("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:Re("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:Re("B4C6E7"),bottom:Re("B4C6E7"),left:Re("B4C6E7"),right:Re("B4C6E7"),insideH:Re("B4C6E7"),insideV:Re("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Re("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:Re("4472C4"),bottom:Re("4472C4"),left:Re("4472C4"),right:Re("4472C4"),insideH:Re("4472C4"),insideV:Re("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:Re("FFFFFF"),bottom:Re("FFFFFF"),left:Re("FFFFFF"),right:Re("FFFFFF"),insideH:Re("FFFFFF"),insideV:Re("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:Re("ED7D31"),bottom:Re("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:Re("A5A5A5"),bottom:Re("A5A5A5"),insideH:Re("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:Re("5B9BD5"),bottom:Re("5B9BD5"),left:Re("5B9BD5"),right:Re("5B9BD5"),insideH:Re("5B9BD5"),insideV:Re("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:Re("70AD47"),bottom:Re("70AD47"),left:Re("70AD47"),right:Re("70AD47"),insideH:Re("70AD47"),insideV:Re("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Bu(e){return Qh.find(t=>t.id===e)}function Au(){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsxRuntime.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"}}),jsxRuntime.jsx("style",{children:`
|
|
15
|
+
@keyframes docx-spin {
|
|
16
|
+
to { transform: rotate(360deg); }
|
|
17
|
+
}
|
|
18
|
+
`}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function Du(){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:"No document loaded"})]})}function Hu({message:e}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:"Failed to Load Document"}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function tb(e,t){return JSON.stringify(e)===JSON.stringify(t)}function nb(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=tb,onUndo:a,onRedo:s,containerRef:l}=t,[u,d]=Gp.useState(e),[c,p]=Gp.useState([]),[m,f]=Gp.useState([]),b=Gp.useRef(0),g=Gp.useRef(false),S=Gp.useCallback((N,H)=>{if(i(u,N))return;if(g.current){d(N);return}let J=Date.now();J-b.current<o&&c.length>0?p(D=>{let P=[...D];return P[P.length-1]={state:u,timestamp:J,description:H||P[P.length-1].description},P}):p(D=>{let P={state:u,timestamp:J,description:H},R=[...D,P];return R.length>n?R.slice(R.length-n):R}),f([]),d(N),b.current=J;},[u,i,o,n,c.length]),T=Gp.useCallback(()=>{if(c.length===0)return;g.current=true;let N=c[c.length-1];return p(H=>H.slice(0,-1)),f(H=>[...H,{state:u,timestamp:Date.now()}]),d(N.state),setTimeout(()=>{g.current=false;},0),a?.(N.state),N.state},[c,u,a]),x=Gp.useCallback(()=>{if(m.length===0)return;g.current=true;let N=m[m.length-1];return f(H=>H.slice(0,-1)),p(H=>[...H,{state:u,timestamp:Date.now()}]),d(N.state),setTimeout(()=>{g.current=false;},0),s?.(N.state),N.state},[m,u,s]),z=Gp.useCallback(()=>{p([]),f([]);},[]),E=Gp.useCallback(N=>{d(N??e),p([]),f([]),b.current=0;},[e]),F=Gp.useCallback(()=>[...c],[c]),G=Gp.useCallback(()=>[...m],[m]),Y=Gp.useCallback(N=>{d(H=>N(H)),p(H=>H.map(J=>({...J,state:N(J.state)}))),f(H=>H.map(J=>({...J,state:N(J.state)})));},[]);return Gp.useEffect(()=>{if(!r)return;let N=J=>{if((J.ctrlKey||J.metaKey)&&J.key==="z"&&!J.shiftKey){J.preventDefault(),T();return}if((J.ctrlKey||J.metaKey)&&J.key==="y"||(J.ctrlKey||J.metaKey)&&J.key==="z"&&J.shiftKey){J.preventDefault(),x();return}},H=l?.current||document;return H.addEventListener("keydown",N),()=>{H.removeEventListener("keydown",N);}},[r,T,x,l]),{state:u,canUndo:c.length>0,canRedo:m.length>0,undoCount:c.length,redoCount:m.length,push:S,undo:T,redo:x,clear:z,reset:E,getUndoStack:F,getRedoStack:G,transformAll:Y}}function zu(e,t={}){let n=Gp.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 nb(e,{...t,isEqual:n})}var $n=new prosemirrorState.PluginKey("suggestionMode"),ma="suggestionModeApplied",ib=Date.now();function ga(e){return {revisionId:ib++,author:e.author,date:new Date().toISOString()}}function Ys(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 _u(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,d)=>{if(!u.isText)return;let c=Math.max(d,n),p=Math.min(d+u.nodeSize,o);if(c>=p)return;let m=u.marks.some(f=>f.type===r&&f.attrs.author===a.author);s.push({from:c,to:p,isOwnInsert:m});}),s.length===0)return;let l=Ys(t,n,"deletion",a.author)||ga(a);for(let u=s.length-1;u>=0;u--){let d=s[u];d.isOwnInsert?e.delete(d.from,d.to):e.addMark(d.from,d.to,i.create(l));}}function Ou(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(ma,true);let s=Ys(e.state.doc,t,"insertion",r.author)||ga(r);if(t!==n){let u=e.state.schema.marks.deletion;u&&_u(a,e.state.doc,t,n,i,u,r);}let l=a.mapping.map(n);return a.insertText(o,l,l),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function $u(e,t,n){let o=$n.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(ma,true),!a){_u(u,e.doc,r.pos,i.pos,s,l,o);let S=u.mapping.map(i.pos);return u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(S))),t(u.scrollIntoView()),true}let d=n==="backward",c=d?r.pos-1:r.pos,p=d?r.pos:r.pos+1;if(c<0||p>e.doc.content.size)return true;let f=e.doc.resolve(c).nodeAfter;if(!f?.isText)return false;let b=f.marks.some(S=>S.type===s&&S.attrs.author===o.author);if(f.marks.some(S=>S.type===l)){let S=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(S)));}else if(b)u.delete(c,p);else {let S=Ys(e.doc,c,"deletion",o.author)||ga(o);u.addMark(c,p,l.create(S));let T=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function Wu(e=false,t="User"){return new prosemirrorState.Plugin({key:$n,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta($n);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=$n.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 Ou(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return $n.getState(n.state)?.active?o.key==="Backspace"?$u(n.state,n.dispatch,"backward"):o.key==="Delete"?$u(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=$n.getState(n.state);return a?.active?Ou(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=$n.getState(r);if(!i?.active)return null;let a=n.find(c=>c.docChanged&&!c.getMeta(ma));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=ga(i),u=r.tr;u.setMeta(ma,true);let d=r.schema.marks.deletion;return a.steps.forEach(c=>{c.getMap().forEach((m,f,b,g)=>{g>b&&r.doc.nodesBetween(b,g,(S,T)=>{if(!S.isText)return;if(!S.marks.some(z=>z.type===s||d&&z.type===d)){let z=Math.max(T,b),E=Math.min(T+S.nodeSize,g);u.addMark(z,E,s.create(l));}});});}),u.steps.length>0?u:null}})}function Vu(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta($n,r);n(i);}return true}var mb={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function Gu(e,t,n,o=[]){let r=n?.getSchema()??Se,i=e?ci(e,{styles:t??void 0}):di(),a=[...o,...n?.getPlugins()??[]];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function gb(e,t){return t?ui(e.doc,t):null}var hb=Gp.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:d=[],extensionManager:c,onEditorViewReady:p,onEditorViewDestroy:m,onKeyDown:f}=t,b=Gp.useRef(null),g=Gp.useRef(null),S=Gp.useRef(o),T=Gp.useRef(false),x=Gp.useRef(null),z=Gp.useRef(false),E=Gp.useRef(l),F=Gp.useRef(u),G=Gp.useRef(p),Y=Gp.useRef(m),N=Gp.useRef(f);E.current=l,F.current=u,G.current=p,Y.current=m,N.current=f,S.current=o;let H=Gp.useCallback(()=>{if(!b.current||T.current)return;let D={state:Gu(o,r,c,d),editable:()=>!s,dispatchTransaction:P=>{if(!g.current||T.current)return;let R=g.current.state.apply(P);g.current.updateState(R),E.current?.(P,R),(P.selectionSet||P.docChanged)&&F.current?.(R);},handleKeyDown:(P,R)=>N.current?.(P,R)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(b.current,D),G.current?.(g.current);},[o,r,d,c,s]),J=Gp.useCallback(()=>{g.current&&!T.current&&(T.current=true,Y.current?.(),g.current.destroy(),g.current=null,T.current=false);},[]);return Gp.useEffect(()=>(H(),()=>J()),[]),Gp.useEffect(()=>{if(!g.current||T.current)return;let D=(R=>{if(!R)return "empty";let me=R.package?.properties;return `${me?.created||""}-${me?.modified||""}-${me?.title||""}`})(o);if(z.current&&D===x.current)return;z.current=true,x.current=D;let P=Gu(o,r,c,d);g.current.updateState(P),F.current?.(P);},[o,r,c,d]),Gp.useEffect(()=>{g.current;},[s]),Gp.useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?gb(g.current.state,S.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(de){g.current&&!T.current&&g.current.dispatch(de);},executeCommand(de){return g.current?de(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?prosemirrorHistory.undo(g.current.state,g.current.dispatch):false},redo(){return g.current?prosemirrorHistory.redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?prosemirrorHistory.undo(g.current.state):false},canRedo(){return g.current?prosemirrorHistory.redo(g.current.state):false},setSelection(de,D){if(!g.current)return;let{state:P,dispatch:R}=g.current,me=P.doc.resolve(de),pe=D!==void 0?P.doc.resolve(D):me,Be=prosemirrorState.TextSelection.between(me,pe);R(P.tr.setSelection(Be));},setNodeSelection(de){if(!g.current)return;let{state:D,dispatch:P}=g.current;try{let R=prosemirrorState.NodeSelection.create(D.doc,de);P(D.tr.setSelection(R));}catch{this.setSelection(de);}},setCellSelection(de,D){if(!g.current)return;let{state:P,dispatch:R}=g.current;try{let me=prosemirrorTables.CellSelection.create(P.doc,de,D);R(P.tr.setSelection(me));}catch{this.setSelection(de,D);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...mb,width:a>0?`${a}px`:void 0}})}),qu=Gp.memo(hb);var Sb="#000",kb="rgba(66, 133, 244, 0.3)",Tb=2,Cb=530,wb={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},vb=(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"}),Rb=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Eb=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=Gp.useState(r),s=Gp.useRef(null);return Gp.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]),Gp.useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsxRuntime.jsx("div",{style:vb(e,t,n,i),"data-testid":"caret"})},Pb=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:Rb(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),Xu=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Sb,selectionColor:i=kb,caretWidth:a=Tb,blinkInterval:s=Cb})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:wb,"data-testid":"selection-overlay",children:[l&&e.map((d,c)=>jsxRuntime.jsx(Pb,{rect:d,color:i,index:c},`sel-${d.pageIndex}-${d.x}-${d.y}-${c}`)),u&&t&&jsxRuntime.jsx(Eb,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var Js=10,_n=Js/2,br=2,ep="#2563eb",Ju={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Ib={position:"absolute",border:`${br}px solid ${ep}`,pointerEvents:"none",boxSizing:"border-box"},Fb={position:"absolute",width:`${Js}px`,height:`${Js}px`,backgroundColor:ep,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Lb={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%)"},Bb={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Ab(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let d=Math.max(l/o,u/r);l=o*d,u=r*d;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function tp({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,d]=Gp.useState(false),[c,p]=Gp.useState(false),[m,f]=Gp.useState(0),[b,g]=Gp.useState(0),[S,T]=Gp.useState(null),x=Gp.useRef(null),z=Gp.useRef(null),E=Gp.useRef(o),F=Gp.useRef(r),G=Gp.useRef(i),Y=Gp.useRef(a),N=Gp.useRef(s),H=Gp.useRef(l);E.current=o,F.current=r,G.current=i,Y.current=a,N.current=s,H.current=l;let J=Gp.useRef(e),de=Gp.useRef(t);J.current=e,de.current=t;let D=Gp.useCallback(()=>{if(!e||!z.current){T(null);return}let w=z.current.offsetParent;if(!w){T(null);return}let A=w.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-A.left)/t,top:(k.top-A.top)/t,width:k.width/t,height:k.height/t});},[e,t]);Gp.useEffect(()=>{D();},[D]),Gp.useEffect(()=>{if(!e)return;let w=z.current?.closest('[style*="overflow"]')??z.current?.closest(".paged-editor__container");if(!w)return;let A=()=>{x.current&&cancelAnimationFrame(x.current),x.current=requestAnimationFrame(D);};return w.addEventListener("scroll",A,{passive:true}),window.addEventListener("resize",A,{passive:true}),()=>{w.removeEventListener("scroll",A),window.removeEventListener("resize",A),x.current&&cancelAnimationFrame(x.current);}},[e,D]);let P=Gp.useCallback((w,A)=>{if(!e||!S)return;A.preventDefault(),A.stopPropagation();let k=S.width,M=S.height,B=A.clientX,v=A.clientY,q=Math.round(k),ae=Math.round(M);d(true),f(q),g(ae),F.current?.();let $=ne=>{let ge=de.current,I=(ne.clientX-B)/ge,W=(ne.clientY-v)/ge,O=!ne.shiftKey,X=Ab(w,I,W,k,M,O);q=Math.round(X.width),ae=Math.round(X.height),f(q),g(ae),T(ue=>{if(!ue)return ue;let fe={...ue};return w.includes("w")&&(fe.left=ue.left+(ue.width-X.width)),w.includes("n")&&(fe.top=ue.top+(ue.height-X.height)),fe.width=X.width,fe.height=X.height,fe});},_=()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",_),d(false);let ne=J.current;ne&&E.current?.(ne.pmPos,q,ae),G.current?.();};window.addEventListener("mousemove",$),window.addEventListener("mouseup",_);},[e,S]),R=Gp.useCallback(w=>{if(!e||!S)return;w.preventDefault(),w.stopPropagation();let A=4,k=w.clientX,M=w.clientY,B=false,v=null,q=$=>{let _=$.clientX-k,ne=$.clientY-M;!B&&Math.sqrt(_*_+ne*ne)<A||(B||(B=true,p(true),N.current?.(),v=document.createElement("div"),v.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);",v.style.width=`${S.width}px`,v.style.height=`${S.height}px`,document.body.appendChild(v)),v&&(v.style.left=`${$.clientX-S.width/2}px`,v.style.top=`${$.clientY-S.height/2}px`));},ae=$=>{if(window.removeEventListener("mousemove",q),window.removeEventListener("mouseup",ae),v&&(v.remove(),v=null),p(false),B){let _=J.current;_&&Y.current?.(_.pmPos,$.clientX,$.clientY),H.current?.();}};window.addEventListener("mousemove",q),window.addEventListener("mouseup",ae);},[e,S]);if(!!!(e&&S&&n))return jsxRuntime.jsx("div",{ref:z,style:{...Ju,visibility:"hidden"},className:"image-selection-overlay"});let{left:pe,top:Be,width:Me,height:We}=S;return jsxRuntime.jsxs("div",{ref:z,style:Ju,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...Ib,left:pe-br,top:Be-br,width:Me+br*2,height:We+br*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:pe,top:Be,width:Me,height:We,cursor:c?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:R}),jsxRuntime.jsx(ba,{handle:"nw",style:{left:pe-_n,top:Be-_n},onMouseDown:P}),jsxRuntime.jsx(ba,{handle:"ne",style:{left:pe+Me-_n,top:Be-_n},onMouseDown:P}),jsxRuntime.jsx(ba,{handle:"se",style:{left:pe+Me-_n,top:Be+We-_n},onMouseDown:P}),jsxRuntime.jsx(ba,{handle:"sw",style:{left:pe-_n,top:Be+We-_n},onMouseDown:P}),u&&jsxRuntime.jsxs("div",{style:{...Lb,left:pe+Me/2,top:Be+We+12},children:[m," \xD7 ",b]})]})}function ba({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...Fb,...t,cursor:Bb[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var Db="Calibri";function Qs(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 Hb=11;function nt(e){return e/1440*96}var Nb=0;function Vn(){return `block-${++Nb}`}function zb(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 ya(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?chunkIA4LPH2A_cjs.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=chunkIA4LPH2A_cjs.a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=chunkIA4LPH2A_cjs.n(o.attrs.color);break;case "fontSize":{let r=o.attrs;n.fontSize=r.size/2;break}case "fontFamily":{let r=o.attrs;n.fontFamily=r.ascii||r.hAnsi;break}case "superscript":n.superscript=true;break;case "subscript":n.subscript=true;break;case "hyperlink":{let r=o.attrs;n.hyperlink={href:r.href,tooltip:r.tooltip};break}case "footnoteRef":{let r=o.attrs,i=typeof r.id=="string"?parseInt(r.id,10):r.id;r.noteType==="endnote"?n.endnoteRefId=i:n.footnoteRefId=i;break}case "comment":{let r=o.attrs.commentId;r&&(n.commentIds||(n.commentIds=[]),n.commentIds.push(r));break}case "insertion":n.isInsertion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break;case "deletion":n.isDeletion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break}return n}function Ob(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=ya(a.marks,i),d={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let d={kind:"tab",...ya(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="image"){let u=a.attrs,d=Qs(u.width||100,u.height||100,n.pageContentHeight),c={kind:"image",src:u.src,width:d.width,height:d.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="field"){let u=a.attrs.fieldType,c={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="math"){let d={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((d,c)=>{let p=u+c;if(d.isText&&d.text){let m=ya(d.marks,i),f={kind:"text",text:d.text,...m,pmStart:p,pmEnd:p+d.nodeSize};o.push(f);}else if(d.type.name==="hardBreak"){let m={kind:"lineBreak",pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="tab"){let f={kind:"tab",...ya(d.marks,i),pmStart:p,pmEnd:p+d.nodeSize};o.push(f);}else if(d.type.name==="image"){let m=d.attrs,f=Qs(m.width||100,m.height||100,n.pageContentHeight),b={kind:"image",src:m.src,width:f.width,height:f.height,alt:m.alt,transform:m.transform,wrapType:m.wrapType,displayMode:m.displayMode,cssFloat:m.cssFloat,distTop:m.distTop,distBottom:m.distBottom,distLeft:m.distLeft,distRight:m.distRight,position:m.position,pmStart:p,pmEnd:p+d.nodeSize};o.push(b);}});}}),o}function $b(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=nt(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=nt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=nt(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=nt(o)),e.indentRight!=null&&(n.indent.right=nt(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(nt(r)):n.indent.firstLine=nt(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?xa(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:_b(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 _b(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function el(e,t,n){let o=e.attrs,r=Ob(e,t,n),i=$b(o,n.theme);return {kind:"paragraph",id:Vn(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Wb(e){return Math.max(1,Math.round(e/8*1.333))}var Vb={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 xa(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Vb[e.style]||"solid",width:Wb(e.size??0),color:e.color?chunkIA4LPH2A_cjs.a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=chunkKR32M3S4_cjs.g(e.space)),n}function jb(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?xa(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function Ub(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(el(l,r,n)):l.type.name==="table"&&o.push(np(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?nt(a.top):1,right:a?.right!=null?nt(a.right):7,bottom:a?.bottom!=null?nt(a.bottom):1,left:a?.left!=null?nt(a.left):7};return {id:Vn(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?nt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:jb(i,n.theme),padding:s}}function Kb(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(Ub(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:Vn(),cells:o,height:i.height?nt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function np(e,t,n){let o=[],r=t+1;e.forEach(f=>{f.type.name==="tableRow"&&o.push(Kb(f,r,n)),r+=f.nodeSize;});let a=e.attrs.columnWidths?.map(nt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(g=>g.width);b.every(g=>g!==void 0&&g>0)&&(a=b);}let u=e.attrs.justification,d=e.attrs._originalFormatting,c=d?.indent?.value&&d.indent.type==="dxa"?nt(d.indent.value):void 0,p=e.attrs.floating,m=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?nt(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?nt(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?nt(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?nt(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?nt(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?nt(p.rightFromText):void 0}:void 0;return {kind:"table",id:Vn(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:c,floating:m,pmStart:t,pmEnd:t+e.nodeSize}}function Gb(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=Qs(o.width||100,o.height||100,n);return {kind:"image",id:Vn(),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 qb(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=el(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:Vn(),width:o.width??chunkOJ7NJK46_cjs.d,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??chunkOJ7NJK46_cjs.c.top,bottom:o.marginBottom??chunkOJ7NJK46_cjs.c.bottom,left:o.marginLeft??chunkOJ7NJK46_cjs.c.left,right:o.marginRight??chunkOJ7NJK46_cjs.c.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function op(e,t={}){let n={...t,defaultFont:t.defaultFont??Db,defaultSize:t.defaultSize??Hb},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=el(a,l,n),d=a.attrs;if(d.numPr&&!d.listMarker){let p=d.numPr.numId;if(p==null||p===0)break;let m=d.numPr.ilvl??0,f=i.get(p)??new Array(9).fill(0);f[m]=(f[m]??0)+1;for(let g=m+1;g<f.length;g+=1)f[g]=0;i.set(p,f);let b=d.listIsBullet?"\u2022":zb(f,m);u.attrs={...u.attrs,listMarker:b};}o.push(u);let c=d._sectionProperties;if(c||d.sectionBreakType){let p={kind:"sectionBreak",id:Vn(),type:c?.sectionStart??d.sectionBreakType};if(c){(c.pageWidth||c.pageHeight)&&(p.pageSize={w:nt(c.pageWidth??12240),h:nt(c.pageHeight??15840)}),(c.marginTop!==void 0||c.marginLeft!==void 0)&&(p.margins={top:nt(c.marginTop??1440),bottom:nt(c.marginBottom??1440),left:nt(c.marginLeft??1440),right:nt(c.marginRight??1440)});let m=c.columnCount??1;if(m>1){let f={count:m,gap:nt(c.columnSpace??720),equalWidth:c.equalWidth??true,separator:c.separator};p.columns=f;}}o.push(p);}}break;case "table":o.push(np(a,l,n));break;case "image":o.push(Gb(a,l,n.pageContentHeight));break;case "textBox":o.push(qb(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:Vn(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var Mn=11,yr="Calibri",Sa=1,$o=.5;function rp(e){return {fontFamily:e.fontFamily??yr,fontSize:e.fontSize??Mn,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function lp(e,t,n){let o=chunkOJ7NJK46_cjs.k(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*Sa;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*Sa;return {ascent:r,descent:i,lineHeight:l}}function ip(e,t,n){let o=chunkOJ7NJK46_cjs.g({fontSize:e,fontFamily:n??yr});return lp(e,t,o)}function ap(e){return e.kind==="text"}function Xb(e){return e.kind==="tab"}function Zb(e){return e.kind==="image"}function Jb(e){return e.kind==="lineBreak"}function Qb(e){return e.kind==="field"}function ey(e){return !e.text||e.text.length===0}function ty(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 ny=48;function sp(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 _o(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,d=l?.right??0,c=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-d),m=Math.max(1,p-c),f=0,b=chunkOJ7NJK46_cjs.k(Mn)*Sa,g=sp(0,b,a,s),S=Math.max(1,m-g.leftMargin-g.rightMargin),T=[];if(o.length===0){let N=r?.defaultFontSize??Mn,H=r?.defaultFontFamily??yr,J=ip(N,i,H);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...J}),{kind:"paragraph",lines:T,totalHeight:J.lineHeight}}if(o.length===1&&ap(o[0])&&ey(o[0])){let N=o[0],H=N.fontSize??r?.defaultFontSize??Mn,J=N.fontFamily??r?.defaultFontFamily??yr,de=ip(H,i,J);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...de}),{kind:"paragraph",lines:T,totalHeight:de.lineHeight}}let x={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:Mn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:S,leftOffset:g.leftMargin,rightOffset:g.rightMargin},z=()=>{let N=lp(x.maxFontSize,i,x.maxFontMetrics),H={...N};x.maxImageHeightPx>H.lineHeight&&(H.lineHeight=x.maxImageHeightPx,H.ascent=x.maxImageHeightPx*.8,H.descent=x.maxImageHeightPx*.2);let J={fromRun:x.fromRun,fromChar:x.fromChar,toRun:x.toRun,toChar:x.toChar,width:x.width,...H};x.leftOffset>0&&(J.leftOffset=x.leftOffset),x.rightOffset>0&&(J.rightOffset=x.rightOffset),T.push(J),f+=N.lineHeight;},E=(N,H)=>{z();let J=chunkOJ7NJK46_cjs.k(Mn)*Sa,de=sp(f,J,a,s),D=Math.max(1,p-de.leftMargin-de.rightMargin);x={fromRun:N,fromChar:H,toRun:N,toChar:H,width:0,maxFontSize:Mn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:D,leftOffset:de.leftMargin,rightOffset:de.rightMargin};},F=N=>{let H=N.fontSize??Mn;(!x.maxFontMetrics||H>x.maxFontSize)&&(x.maxFontSize=H,x.maxFontMetrics=chunkOJ7NJK46_cjs.g(N));};for(let N=0;N<o.length;N++){let H=o[N];if(Jb(H)){x.toRun=N,x.toChar=0,E(N+1,0);continue}if(Xb(H)){let J=rp(H);F(J);let de=H.width??ny;x.width+de>x.availableWidth+$o&&(E(N,0),F(J)),x.width+=de,x.toRun=N,x.toChar=1;continue}if(Zb(H)){let J=H.wrapType,de=H.displayMode==="float"||J&&["square","tight","through"].includes(J);if(H.position&&de){x.toRun=N,x.toChar=1;continue}if(J==="topAndBottom"||H.displayMode==="block"){x.width>0&&E(N,0);let R=H.height,me=H.distTop??6,pe=H.distBottom??6;x.toRun=N,x.toChar=1,x.maxImageHeightPx=R+me+pe,E(N+1,0);continue}let D=H.width,P=H.height;P>x.maxImageHeightPx&&(x.maxImageHeightPx=P),x.width+D>x.availableWidth+$o&&E(N,0),x.width+=D,x.toRun=N,x.toChar=1;continue}if(Qb(H)){let J=H.fallback||"1",de={fontFamily:H.fontFamily??yr,fontSize:H.fontSize??Mn,bold:H.bold,italic:H.italic};F(de);let D=chunkOJ7NJK46_cjs.h(J,de);x.width>0&&x.width+D>x.availableWidth+$o&&(E(N,0),F(de)),x.width+=D,x.toRun=N,x.toChar=1;continue}if(ap(H)){let J=H,de=J.text,D=rp(J);if(F(D),!de||de.length===0){x.toRun=N,x.toChar=0;continue}let P=ty(de),R=0;for(;R<de.length;){let me=de.length;for(let Me of P)if(Me>R){me=Me;break}let pe=de.slice(R,me),Be=chunkOJ7NJK46_cjs.h(pe,D);if(Be>x.availableWidth+$o){x.width>0&&(E(N,R),F(D));let{charWidths:Me}=chunkOJ7NJK46_cjs.i(pe,D),We=0;for(;We<pe.length;){let w=0,A=We;for(;A<pe.length;){let k=Me[A]??0;if(w+k>x.availableWidth+$o)break;w+=k,A+=1;}A===We&&(A=Math.min(pe.length,We+1),w=Me[We]??0),x.width+=w,x.toRun=N,x.toChar=R+A,We=A,We<pe.length&&(E(N,R+We),F(D));}R=me;continue}x.width>0&&x.width+Be>x.availableWidth+$o&&(E(N,R),F(D)),x.width+=Be,x.toRun=N,x.toChar=me,R=me;}}}z();let Y=T.reduce((N,H)=>N+H.lineHeight,0);return i?.before&&(Y+=i.before),i?.after&&(Y+=i.after),{kind:"paragraph",lines:T,totalHeight:Y}}var oy=new Map;function cp(){oy.clear();}var ry=new Map;function dp(){ry.clear();}var iy=5e3,ay=iy,jn=new Map;function tl(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 sy(){for(;jn.size>ay;){let e=jn.keys().next().value;if(e===void 0)break;jn.delete(e);}}function nl(e,t){let n=tl(e),o=jn.get(n);if(o!==void 0&&o.maxWidth===t)return jn.delete(n),jn.set(n,o),o.measure}function ol(e,t,n){let o=tl(e);jn.set(o,{measure:n,maxWidth:t}),sy();}function up(){jn.clear();}function rl(){cp(),dp(),up();}function ly(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function cy(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,d=i.slice(l,u);d.length>0&&n.push({...r,text:d});}else n.push(r);}}}return n}function dy(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",d=s===t.fromRun?t.fromChar:0,c=s===t.toRun?t.toChar:u.length;a+=c-d;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function uy(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 py(e,t,n,o){let{pmStart:r,pmEnd:i}=dy(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=cy(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let d=0,c=0;for(let m of u){if(m.kind==="tab"){let f=m.width??48,b=d+f;if(l<=b){let g=d+f/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(m.kind==="image"){let f=m.width,b=d+f;if(l<=b){let g=d+f/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(m.kind==="lineBreak"){if(l>=d)return {charOffset:c,pmPosition:r+c};c+=1;continue}if(m.kind==="text"){let f=m.text??"";if(f.length===0)continue;let b=ly(m),g=chunkOJ7NJK46_cjs.i(f,b),S=d+g.width;if(l<=S){let T=l-d,x=chunkOJ7NJK46_cjs.j(T,g.charWidths),z=c+x;return {charOffset:z,pmPosition:r+z}}d=S,c+=f.length;}}return {charOffset:i-r,pmPosition:i}}function pp(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=uy(l,i,a.fromLine,a.toLine);if(u===null)return null;let d=l.lines[u];if(!d)return null;let c=0;for(let x=a.fromLine;x<u;x++)c+=l.lines[x]?.lineHeight??0;let p=s.attrs?.indent,m=p?.left??0,f=p?.right??0,b=Math.max(0,t.width-m-f),g=r-m,{charOffset:S,pmPosition:T}=py(s,d,g,b);return {pmPosition:T,charOffset:S,lineIndex:u}}function fy(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 pp(i)?.pmPosition??null}function il(e,t){if(t)return fy(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?pp(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function mp(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(d=>d.classList.contains("layout-page"));if(!i)return null;let a=r.find(d=>d.tagName==="SPAN"&&d.dataset.pmStart!==void 0&&d.dataset.pmEnd!==void 0);if(a)return al(a,t);let s=r.find(d=>d.classList.contains("layout-empty-run"));if(s){let d=s.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let l=r.find(d=>d.classList.contains("layout-paragraph")&&d.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let d=fp(l,t,n);return d!==null?d:Number(l.dataset.pmStart)}let u=r.find(d=>d.classList.contains("layout-table-cell"));return u?fp(u,t,n):my(e,i,t,n)}function al(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let c=e.getBoundingClientRect(),p=(c.left+c.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,d=s;for(;u<d;){let c=Math.floor((u+d)/2),p=l.createRange();p.setStart(a,c),p.setEnd(a,c);let f=p.getBoundingClientRect().left;t<f?d=c:u=c+1;}if(u>0&&u<=s){let c=l.createRange();c.setStart(a,u-1),c.setEnd(a,u-1);let p=c.getBoundingClientRect();c.setStart(a,Math.min(u,s)),c.setEnd(a,Math.min(u,s));let m=c.getBoundingClientRect(),f=Math.abs(t-p.left),b=Math.abs(t-m.left);if(f<b)return o+(u-1)}return o+Math.min(u,r-o)}function fp(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let c=o.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let c of Array.from(r)){let p=c,m=p.getBoundingClientRect(),f=(m.top+m.bottom)/2,b=Math.abs(n-f);b<a&&(a=b,i=p);}if(!i){let c=e.querySelector(".layout-paragraph[data-pm-start]");return c?.dataset.pmStart?Number(c.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let c=i.closest(".layout-paragraph");return c?.dataset.pmStart?Number(c.dataset.pmStart):null}let l=null,u=1/0;for(let c of Array.from(s)){let p=c,m=p.getBoundingClientRect();if(t>=m.left&&t<=m.right)return al(p,t);let f=t<m.left?m.left-t:t-m.right;f<u&&(u=f,l=p);}if(!l)return null;let d=l.getBoundingClientRect();return t<d.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function my(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let m=t.querySelectorAll(".layout-paragraph");if(m.length>0){let f=m[0];return Number(f.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let m of Array.from(a)){let f=m,b=f.getBoundingClientRect(),g=(b.top+b.bottom)/2,S=Math.abs(o-g);S<l&&(l=S,s=f);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let m=s.closest(".layout-paragraph");return m?.dataset.pmStart?Number(m.dataset.pmStart):null}let d=null,c=1/0;for(let m of Array.from(u)){let f=m,b=f.getBoundingClientRect();if(n>=b.left&&n<=b.right)return al(f,n);let g=n<b.left?b.left-n:n-b.right;g<c&&(c=g,d=f);}if(!d)return null;let p=d.getBoundingClientRect();return n<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)}var Un={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function gy(e){return e.kind==="paragraph"}function hy(e){return e.kind==="table"}function by(e){return e.kind==="image"}function ka(e){e.style.position="absolute",e.style.overflow="hidden";}function yy(e,t,n){let o=n.createElement("div");return o.className=`${Un.fragment} ${Un.paragraph}`,ka(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 xy(e,t,n){let o=n.createElement("div");return o.className=`${Un.fragment} ${Un.table}`,ka(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 Sy(e,t,n){let o=n.createElement("div");return o.className=`${Un.fragment} ${Un.image}`,ka(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 xr(e,t,n={}){let o=n.document??document;if(gy(e))return yy(e,t,o);if(hy(e))return xy(e,t,o);if(by(e))return Sy(e,t,o);let r=o.createElement("div");r.className=Un.fragment,ka(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function sl(e){return e/1440*96}function ky(e){return e/96*1440}function Ty(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(c=>c.val!=="clear").filter(c=>c.pos>=o),i=t.filter(c=>c.val==="clear").map(c=>c.pos),a=r.reduce((c,p)=>Math.max(c,p.pos),0),s=[...r];o>0&&!r.some(c=>c.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,d=o+14400;for(;u<d;){u+=n;let c=r.some(f=>Math.abs(f.pos-u)<20),p=i.some(f=>Math.abs(f-u)<20),m=o>0&&Math.abs(u-o)<20;!c&&!p&&!m&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((c,p)=>c.pos-p.pos)}function gp(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=ky(e),l=Ty(t).find(c=>c.pos>a);if(!l){let c=sl(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}let d=sl(l.pos)-e;if(l.val==="center"||l.val==="end"){let c=o?o(n):0;l.val==="center"?d-=c/2:d-=c;}else if(l.val==="decimal"){let c=n.indexOf(r);if(c>=0&&o){let p=n.slice(0,c),m=o(p);d-=m;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(d<1){let c=sl(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}return {width:d,leader:l.leader,alignment:l.val}}var Qt={fragment:"layout-paragraph",line:"layout-line",run:"layout-run",text:"layout-run-text",tab:"layout-run-tab",image:"layout-run-image",lineBreak:"layout-run-linebreak"};function kr(e){return e.kind==="text"}function Ta(e){return e.kind==="tab"}function ll(e){return e.kind==="image"}function cl(e){return e.kind==="lineBreak"}function dl(e){return e.kind==="field"}function Cy(e,t){if(t.fontFamily&&(e.style.fontFamily=chunkOJ7NJK46_cjs.a(t.fontFamily).cssFallback),t.fontSize){let o=t.fontSize*96/72;e.style.fontSize=`${o}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let n=[];t.underline&&(n.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&n.push("line-through"),t.commentIds&&t.commentIds.length>0&&(e.style.backgroundColor="rgba(255, 212, 0, 0.25)",e.style.borderBottom="2px solid rgba(255, 212, 0, 0.6)",e.dataset.commentId=String(t.commentIds[0])),t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",n.includes("line-through")||n.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),n.length>0&&(e.style.textDecorationLine=n.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function Wo(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function ul(e,t){let n=t.createElement("span");if(n.className=`${Qt.run} ${Qt.text}`,Cy(n,e),Wo(n,e.pmStart,e.pmEnd),e.hyperlink){let o=t.createElement("a");o.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(o.target="_blank",o.rel="noopener noreferrer"),e.hyperlink.tooltip&&(o.title=e.hyperlink.tooltip),o.textContent=e.text;let r=e.color||"#0563c1";o.style.color=r,o.style.textDecoration="underline",n.style.color=r,n.appendChild(o);}else n.textContent=e.text;return n}function yp(e,t,n,o){let r=t.createElement("span");if(r.className=`${Qt.run} ${Qt.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",Wo(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=wy(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 wy(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function vy(e,t){let n=t.createElement("img");return n.className=`${Qt.run} ${Qt.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",Wo(n,e.pmStart,e.pmEnd),n}function hp(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),Wo(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function xp(e,t){let n=e.displayMode,o=e.wrapType;return n==="float"||o&&["square","tight","through"].includes(o)||n==="block"||o==="topAndBottom"?hp(e,t):vy(e,t)}function Sp(e,t){let n=t.createElement("br");return n.className=`${Qt.run} ${Qt.lineBreak}`,Wo(n,e.pmStart,e.pmEnd),n}function kp(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 ul(r,t)}function Ry(e,t,n){if(kr(e))return ul(e,t);if(Ta(e))return yp(e,t,48,void 0);if(ll(e))return xp(e,t);if(cl(e))return Sp(e,t);if(dl(e)&&n)return kp(e,t,n);let o=t.createElement("span");return o.className=Qt.run,o}function Tp(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(kr(i)){let a=r===t.fromRun?t.fromChar:0,s=r===t.toRun?t.toChar:i.text.length;if(a>0||s<i.text.length){let l=i.text.slice(a,s);n.push({...i,text:l,pmStart:i.pmStart!==void 0?i.pmStart+a:void 0,pmEnd:i.pmStart!==void 0?i.pmStart+s:void 0});}else n.push(i);}else n.push(i);}return n}function Ey(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function Py(e){return {val:e.val,pos:e.pos,leader:e.leader}}function My(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(kr(i))o+=i.text;else if(dl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(Ta(i)||cl(i))break}return o}function Iy(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=chunkOJ7NJK46_cjs.a(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function Cp(e,t,n,o,r){let i=o.createElement("div");i.className=Qt.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=Tp(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${Qt.run} layout-empty-run`,b.innerHTML=" ",i.appendChild(b),i}let s=n==="justify",l=false;s&&r&&(l=!r.isLastLine||r.paragraphEndsWithLineBreak,l&&(i.style.textAlign="justify",i.style.textAlignLast="justify",i.style.width=`${r.availableWidth}px`)),i.style.whiteSpace="pre";let u=a.some(b=>kr(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let d=a.some(Ta),c,p=Iy(o);if(d){let b=r?.tabStops?.map(Py),g=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;c={explicitStops:b,leftIndent:g};}let m=0,f=r?.leftIndentPx??0;if(r?.isFirstLine){let b=r?.firstLineIndentPx??0;m=f+b;}else m=f;for(let b=0;b<a.length;b++){let g=a[b];if(Ta(g)&&c){let S=My(a,b,r?.context),T=gp(m,c,S,p),x=yp(g,o,T.width,T.leader);i.appendChild(x),m+=T.width;}else if(kr(g)){let S=ul(g,o);if(g.highlight){let E=(g.fontSize?g.fontSize*96/72:14.67)*1.2,F=Math.max(0,t.lineHeight-E);if(F>0){let G=F/2;S.style.paddingTop=`${G}px`,S.style.paddingBottom=`${G}px`;}}i.appendChild(S);let T=g.fontSize||11,x=g.fontFamily||"Calibri";m+=p(g.text,T,x);}else if(ll(g)){if(g.displayMode==="float"||g.wrapType&&["square","tight","through"].includes(g.wrapType))continue;let T=Ey(g);if(r?.renderedInlineImageKeys?.has(T))continue;r?.renderedInlineImageKeys?.add(T);let x=xp(g,o);i.appendChild(x),g.displayMode!=="block"&&g.wrapType!=="topAndBottom"&&(m+=g.width);}else if(cl(g)){let S=Sp(g,o);i.appendChild(S);}else if(dl(g)&&r?.context){let S=kp(g,o,r.context);i.appendChild(S);let T=g.fallback??"";g.fieldType==="PAGE"?T=String(r.context.pageNumber):g.fieldType==="NUMPAGES"&&(T=String(r.context.totalPages));let x=g.fontSize||11,z=g.fontFamily||"Calibri";m+=p(T,x,z);}else {let S=Ry(g,o,r?.context);i.appendChild(S);}}return i}function Sr(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function bp(e,t){return !e&&!t||!e||!t?false:Sr(e.top,t.top)&&Sr(e.bottom,t.bottom)&&Sr(e.left,t.left)&&Sr(e.right,t.right)&&Sr(e.between,t.between)}function In(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Qt.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),Wo(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");for(let E of t.runs)ll(E)&&(E.displayMode==="float"||E.wrapType&&["square","tight","through"].includes(E.wrapType));let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId);let u=t.attrs?.bidi;u&&(a.dir="rtl"),l?l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":l==="left"?a.style.textAlign="left":a.style.textAlign=u?"right":"left":u&&(a.style.textAlign="right");let d=t.attrs?.indent,c=0,p=0;d&&(u?(d.left&&d.left>0&&(p=d.left),d.right&&d.right>0&&(c=d.right)):(d.left&&d.left>0&&(c=d.left),d.right&&d.right>0&&(p=d.right)));let m=t.attrs?.borders;if(m){let E=H=>{switch(H){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 F=H=>`${H.width}px ${E(H.style)} ${H.color}`,G=bp(r.prevBorders,m),Y=bp(m,r.nextBorders);if(G&&m.between?a.style.borderTop=F(m.between):m.top&&!G&&(a.style.borderTop=F(m.top)),m.bottom&&!Y&&(a.style.borderBottom=F(m.bottom)),m.left&&(a.style.borderLeft=F(m.left)),m.right&&(a.style.borderRight=F(m.right)),m.bar){let H=i.createElement("div");H.style.position="absolute",H.style.left="-8px",H.style.top="0",H.style.bottom="0",H.style.borderLeft=F(m.bar),a.style.position="relative",a.appendChild(H);}if(m.top||m.bottom||m.left||m.right||m.between){let H=m.top||m.between;a.style.paddingLeft=m.left?`${m.left.space??4}px`:"0",a.style.paddingRight=m.right?`${m.right.space??4}px`:"0",a.style.paddingTop=H?`${H.space??2}px`:"0",a.style.paddingBottom=m.bottom?`${m.bottom.space??6}px`:"0";}}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let f=e.width-c-p,g=t.runs[t.runs.length-1]?.kind==="lineBreak",S=n.lines.length,T=0;d?.hanging&&d.hanging>0?T=-d.hanging:d?.firstLine&&d.firstLine>0&&(T=d.firstLine);let x=0,z=r.renderedInlineImageKeys??new Set;for(let E=0;E<s.length;E++){let F=s[E],G=e.fromLine+E,Y=G===S-1,N=G===0&&!e.continuesFromPrev,H=F.leftOffset??0,J=F.rightOffset??0,de=f;if(N){let me=d?.hanging&&d.hanging>0,pe=d?.firstLine&&d.firstLine>0;me&&d?.hanging?de=f+d.hanging:pe&&d?.firstLine&&(de=f-d.firstLine);}let D=Cp(t,F,l,i,{availableWidth:de-H-J,isLastLine:Y,isFirstLine:N,paragraphEndsWithLineBreak:g,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:N?T:0,context:o,renderedInlineImageKeys:z});H>0&&(D.style.marginLeft=`${H}px`),J>0&&(D.style.marginRight=`${J}px`),x+=F.lineHeight;let P=d?.hanging&&d.hanging>0,R=d?.firstLine&&d.firstLine>0;if(N?c>0&&P?(D.style.paddingLeft=`${c}px`,D.style.textIndent=`-${d.hanging}px`):c>0&&R?(D.style.paddingLeft=`${c}px`,D.style.textIndent=`${d.firstLine}px`):c>0?D.style.paddingLeft=`${c}px`:R&&(D.style.textIndent=`${d.firstLine}px`):c>0?D.style.paddingLeft=`${c}px`:P&&(D.style.paddingLeft=`${d.hanging}px`),p>0&&(D.style.paddingRight=`${p}px`),N&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let me=Math.max(0,c-(d?.hanging??0));D.style.paddingLeft=`${me}px`,D.style.textIndent="0";let pe;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let w=F.fromRun;w<=F.toRun;w++){let A=t.runs[w];if(A&&A.kind==="text"){pe=A;break}}let Be=t.attrs.listMarkerFontFamily??pe?.fontFamily??t.attrs.defaultFontFamily,Me=t.attrs.listMarkerFontSize??pe?.fontSize??t.attrs.defaultFontSize,We=Fy(t.attrs.listMarker,d,i,Be,Me);D.insertBefore(We,D.firstChild);}a.appendChild(D);}return a}function Fy(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=chunkOJ7NJK46_cjs.a(o).cssFallback),r){let s=r*96/72;i.style.fontSize=`${s}px`;}i.textContent=e;let a=t?.hanging??24;return i.style.minWidth=`${a}px`,i.style.textAlign="left",i.style.boxSizing="border-box",i}var kn={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 Ly(e,t,n,o){let r=o.createElement("div");r.className=kn.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`;for(let l=0;l<e.blocks.length;l++){let u=e.blocks[l],d=t.blocks[l];if(u?.kind==="paragraph"&&d?.kind==="paragraph"){let c=u,p=d,m={blockId:c.id,width:s,height:p.totalHeight,fromLine:0,toLine:p.lines.length,pmStart:c.pmStart,pmEnd:c.pmEnd},f=In(m,c,p,n,{document:o});f.style.position="relative",r.appendChild(f);}else if(u?.kind==="table"&&d?.kind==="table"){let m=By(u,d,n,o);m.style.position="relative",r.appendChild(m);}}return r}function By(e,t,n,o){let r=o.createElement("div");r.className=`${kn.table} layout-nested-table`,r.style.position="relative",r.style.width=`${t.totalWidth}px`,r.style.display="block",e.justification==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):e.justification==="right"?r.style.marginLeft="auto":e.indent&&(r.style.marginLeft=`${e.indent}px`),r.dataset.blockId=String(e.id),e.pmStart!==void 0&&(r.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(r.dataset.pmEnd=String(e.pmEnd));let i=[],a=0;for(let u=0;u<t.rows.length;u++)i.push(a),a+=t.rows[u]?.height??0;i.push(a);let s=new Map,l=0;for(let u=0;u<e.rows.length;u++){let d=e.rows[u],c=t.rows[u];if(!d||!c)continue;let p=pl(d,c,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=c.height;}return r.style.height=`${l}px`,r}function Ca(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 Ay(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=kn.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,d=e.padding?.bottom??1,c=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${d}px ${c}px`,e.borders&&(r.isFirstRow&&Ca(s,"top",e.borders.top),Ca(s,"right",e.borders.right),Ca(s,"bottom",e.borders.bottom),r.isFirstCol&&Ca(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=Ly(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let m=e.blocks[0],f=e.blocks[e.blocks.length-1];m&&"pmStart"in m&&m.pmStart!==void 0&&(s.dataset.pmStart=String(m.pmStart)),f&&"pmEnd"in f&&f.pmEnd!==void 0&&(s.dataset.pmEnd=String(f.pmEnd));}return s}function pl(e,t,n,o,r,i,a,s,l,u,d){let c=s.createElement("div");c.className=kn.row,c.style.position="absolute",c.style.left="0",c.style.top=`${o}px`,c.style.width="100%",c.style.height=`${t.height}px`,c.dataset.rowIndex=String(n);let p=new Set;if(l){for(let[,b]of l)if(b.startRow<n&&b.startRow+b.rowSpan>n)for(let g=0;g<b.colSpan;g++)p.add(b.columnIndex+g);}let m=0,f=0;for(;p.has(f);)m+=r[f]??0,f++;for(let b=0;b<e.cells.length;b++){let g=e.cells[b],S=t.cells[b];if(!g||!S)continue;let T=g.colSpan??1,x=g.rowSpan??1,z=t.height;if(x>1&&u){z=0;for(let H=n;H<n+x&&H<u.length-1;H++)z+=(u[H+1]??0)-(u[H]??0);z===0&&(z=t.height*x);}let E=n===0||d===true,G=f===0;f+T>=r.length;let N=Ay(g,S,m,z,{isFirstRow:E,isFirstCol:G},a,s);if(N.dataset.cellIndex=String(b),N.dataset.columnIndex=String(f),x>1&&(N.dataset.rowSpan=String(x)),c.appendChild(N),x>1&&l){let H=`${n}-${f}`;l.set(H,{cell:g,cellMeasure:S,columnIndex:f,startRow:n,rowSpan:x,colSpan:T,x:m,totalHeight:z});}for(let H=0;H<T&&f+H<r.length;H++)m+=r[f+H]??0;for(f+=T;p.has(f);)m+=r[f]??0,f++;}return c}function wa(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=kn.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 f=0;f<n.columnWidths.length-1;f++){s+=n.columnWidths[f]??0;let b=i.createElement("div");b.className=kn.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(f),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 f=0;f<n.rows.length;f++)l.push(u),u+=n.rows[f]?.height??0;l.push(u);let d=new Map,c=e.headerRowCount??0,p=0;if(c>0&&e.continuesFromPrev)for(let f=0;f<c;f++){let b=t.rows[f],g=n.rows[f];if(!b||!g)continue;let S=pl(b,g,f,p,n.columnWidths,t.rows.length,o,i,d,l,f===0);S.dataset.repeatedHeader="true",a.appendChild(S),p+=g.height;}for(let f=e.fromRow;f<e.toRow;f++){let b=t.rows[f],g=n.rows[f];if(!b||!g)continue;let S=c>0&&e.continuesFromPrev?false:e.continuesFromPrev&&f===e.fromRow,T=pl(b,g,f,p,n.columnWidths,t.rows.length,o,i,d,l,S);a.appendChild(T),p+=g.height;}let m=0;for(let f=e.fromRow;f<e.toRow;f++)if(m+=n.rows[f]?.height??0,f<e.toRow-1){let b=i.createElement("div");b.className=kn.rowResizeHandle,b.style.position="absolute",b.style.left="0",b.style.top=`${m-3}px`,b.style.width="100%",b.style.height="6px",b.style.cursor="row-resize",b.style.zIndex="10",b.dataset.rowIndex=String(f),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 f=i.createElement("div");f.className=kn.tableEdgeHandleBottom,f.style.position="absolute",f.style.left="0",f.style.top=`${m-3}px`,f.style.width="100%",f.style.height="6px",f.style.cursor="row-resize",f.style.zIndex="10",f.dataset.rowIndex=String(t.rows.length-1),f.dataset.tableBlockId=String(e.blockId),f.dataset.isEdge="bottom",e.pmStart!==void 0&&(f.dataset.tablePmStart=String(e.pmStart)),a.appendChild(f);}if(e.toRow===t.rows.length){let f=n.columnWidths.reduce((g,S)=>g+S,0),b=i.createElement("div");b.className=kn.tableEdgeHandleRight,b.style.position="absolute",b.style.left=`${f-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 fl={image:"layout-image",imageAnchored:"layout-image-anchored"};function va(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=fl.image,e.isAnchored&&a.classList.add(fl.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 wp={textBox:"layout-textbox"};function Ra(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=wp.textBox,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.style.boxSizing="border-box",t.fillColor&&(a.style.backgroundColor=t.fillColor),t.outlineWidth&&t.outlineWidth>0){let d=t.outlineStyle||"solid",c=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${d} ${c}`;}let s=t.margins??chunkOJ7NJK46_cjs.c;a.style.padding=`${s.top}px ${s.right}px ${s.bottom}px ${s.left}px`,a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let l=e.width-s.left-s.right,u=0;for(let d=0;d<t.content.length;d++){let c=t.content[d],p=n.innerMeasures[d];if(!p)continue;let m={blockId:c.id,width:l,height:p.totalHeight,pmStart:c.pmStart,pmEnd:c.pmEnd,fromLine:0,toLine:p.lines.length},f=In(m,c,p,o,{document:i});f.style.position="relative",f.style.left="0",f.style.top="0",a.appendChild(f),u+=p.totalHeight;}return a}var Kn={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function Pa(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=Po(l,a[s],o.theme);for(let[d,c]of Object.entries(u))e.style[d]=String(c);}}}}function Dy(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 Hy(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 Ia(e){return e===void 0?0:Math.round(e*96/914400)}function Ny(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function zy(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!Ny(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,d=i.distRight??12,c="left",p=0;if(a?.horizontal){let f=a.horizontal;f.align==="right"?(c="right",p=n-i.width):f.align==="left"?(c="left",p=0):f.align==="center"?(c="left",p=(n-i.width)/2):f.posOffset!==void 0&&(p=Ia(f.posOffset),c=p>n/2?"right":"left");}else i.cssFloat==="right"&&(c="right",p=n-i.width);let m=0;if(a?.vertical){let f=a.vertical;f.align==="top"?m=0:f.align==="bottom"?m=t:f.posOffset!==void 0?m=Ia(f.posOffset):m=t,f.relativeTo==="margin"&&(f.align==="top"||f.posOffset!==void 0)||f.relativeTo==="paragraph"&&(m=t+m);}else m=t;o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:c,x:p,y:m,distTop:s,distBottom:l,distLeft:u,distRight:d,pmStart:i.pmStart,pmEnd:i.pmEnd});}return o}function Oy(e,t){let n=[],o=0,r=0,i=1/0,a=0;for(let s of e){let l=s.x-s.distLeft,u=s.x+s.width+s.distRight,d=s.y-s.distTop,c=s.y+s.height+s.distBottom;s.side==="left"?o=Math.max(o,u):r=Math.max(r,t-l),i=Math.min(i,d),a=Math.max(a,c);}return (o>0||r>0)&&n.push({leftMargin:o,rightMargin:r,topY:i===1/0?0:i,bottomY:a}),n}function $y(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.width=o.width,i.height=o.height,o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function vp(e,t,n){let o=n.document??document,r=o.createElement("div");r.style.position="relative";let i=t.contentWidth??600,a=[],s=0;for(let l=0;l<e.blocks.length;l++){let u=e.blocks[l],d=e.measures[l];if(u?.kind==="paragraph"&&d?.kind==="paragraph"){let c=u,p=d,m=s,f=[];for(let T of c.runs)if(T.kind==="image"&&"position"in T&&T.position){let x=T;a.push({src:x.src,width:x.width,height:x.height,alt:x.alt,paragraphY:m,position:x.position});}else f.push(T);let b={...c,runs:f},g={blockId:c.id,width:i,height:p.totalHeight,fromLine:0,toLine:p.lines.length},S=In(g,b,p,t,{document:o});S.style.position="relative",S.style.marginBottom="0",r.appendChild(S),s+=p.totalHeight;}}for(let l of a){let u=o.createElement("img");u.src=l.src,u.width=l.width,u.height=l.height,l.alt&&(u.alt=l.alt),u.style.position="absolute";let d=l.position.horizontal;d&&(d.align==="right"?u.style.right="0":d.align==="center"?(u.style.left="50%",u.style.transform="translateX(-50%)"):d.posOffset!==void 0?u.style.left=`${Ia(d.posOffset)}px`:u.style.left="0");let c=l.position.vertical;if(c){let p=l.paragraphY;c.align==="bottom"?u.style.bottom="0":c.align==="center"?(u.style.top="50%",u.style.transform=(u.style.transform||"")+" translateY(-50%)"):c.posOffset!==void 0?u.style.top=`${p+Ia(c.posOffset)}px`:u.style.top=`${p}px`;}else u.style.top=`${l.paragraphY}px`;r.appendChild(u);}return r}function _y(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 Fa(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??Kn.page,r.dataset.pageNumber=String(e.number),Pa(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=Kn.content,Dy(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let m of e.fragments)if(m.kind==="paragraph"&&n.blockLookup){let f=n.blockLookup.get(String(m.blockId));if(f?.block.kind==="paragraph"){let b=f.block,g=m.y-e.margins.top,S=zy(b,g,a);s.push(...S);}}for(let m of s)l.push({side:m.side,x:m.x,y:m.y,width:m.width,height:m.height,distTop:m.distTop,distBottom:m.distBottom,distLeft:m.distLeft,distRight:m.distRight});if(n.blockLookup)for(let m of e.fragments){if(m.kind!=="table")continue;let f=n.blockLookup.get(String(m.blockId));if(f?.block.kind!=="table")continue;let g=f.block.floating;if(!g)continue;let S=m.x-e.margins.left,T=m.y-e.margins.top,x=g.topFromText??0,z=g.bottomFromText??0,E=g.leftFromText??12,F=g.rightFromText??12,G=S<a/2?"left":"right";l.push({side:G,x:S,y:T,width:m.width,height:m.height,distTop:x,distBottom:z,distLeft:E,distRight:F});}Oy(l,a);if(s.length>0){let m=$y(s,o);i.appendChild(m);}let d=m=>{if(m.kind!=="paragraph"||!n.blockLookup||!m.blockId)return;let f=n.blockLookup.get(String(m.blockId));if(f?.block.kind==="paragraph")return f.block.attrs?.borders},c,p=new Map;for(let m=0;m<e.fragments.length;m++){let f=e.fragments[m],b,g={...t,section:"body",contentWidth:a};f.y-e.margins.top;if(n.blockLookup&&f.blockId){let T=n.blockLookup.get(String(f.blockId));if(f.kind==="paragraph"&&T?.block.kind==="paragraph"&&T?.measure.kind==="paragraph"){let x=T.block,z=m+1<e.fragments.length?d(e.fragments[m+1]):void 0,E=String(f.blockId),F=p.get(E);F||(F=new Set,p.set(E,F)),b=In(f,x,T.measure,g,{document:o,prevBorders:c,nextBorders:z,renderedInlineImageKeys:F}),c=x.attrs?.borders;}else f.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=wa(f,T.block,T.measure,g,{document:o}),c=void 0):f.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=va(f,T.block,T.measure,g,{document:o}),c=void 0):f.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=Ra(f,T.block,T.measure,g,{document:o}),c=void 0):(b=xr(f,g,{document:o}),c=void 0);}else b=xr(f,g,{document:o}),c=void 0;Hy(b,f,{left:e.margins.left,top:e.margins.top}),i.appendChild(b);}if(e.columns&&e.columns.separator&&e.columns.count>1){let m=e.columns.count,f=e.columns.gap,b=(a-(m-1)*f)/m,g=e.size.h-e.margins.top-e.margins.bottom;for(let S=0;S<m-1;S++){let T=(S+1)*b+S*f+f/2,x=o.createElement("div");x.style.position="absolute",x.style.left=`${T}px`,x.style.top="0",x.style.height=`${g}px`,x.style.width="0.5px",x.style.backgroundColor="#000",x.style.pointerEvents="none",i.appendChild(x);}}if(n.footnoteArea&&n.footnoteArea.length>0){let m=_y(n.footnoteArea,a,o);m.style.position="absolute";let f=e.footnoteReservedHeight??0,b=e.size.h-e.margins.bottom-e.margins.top;m.style.top=`${b-f}px`,m.style.left="0",m.style.right="0",i.appendChild(m);}r.appendChild(i);{let f=n.headerDistance??e.margins.header??48,b=e.size.w-e.margins.left-e.margins.right,g=Math.max(e.margins.top-f,48),T=(n.headerContent?.height??0)>g,x=o.createElement("div");x.className=Kn.header,x.style.position="absolute",x.style.top=`${f}px`,x.style.left=`${e.margins.left}px`,x.style.right=`${e.margins.right}px`,x.style.width=`${b}px`,x.style.minHeight="24px";let z=!T;if(n.headerContent&&n.headerContent.blocks.length>0){let E=vp(n.headerContent,{...t,section:"header",contentWidth:b},n);E.querySelector("img")&&(z=false),x.appendChild(E);}z&&(x.style.maxHeight=`${g}px`,x.style.overflow="hidden"),r.appendChild(x);}{let f=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,g=Math.max(e.margins.bottom-f,48),T=(n.footerContent?.height??0)>g,x=o.createElement("div");x.className=Kn.footer,x.style.position="absolute",x.style.bottom=`${f}px`,x.style.left=`${e.margins.left}px`,x.style.right=`${e.margins.right}px`,x.style.width=`${b}px`,x.style.minHeight="24px";let z=!T;if(n.footerContent&&n.footerContent.blocks.length>0){let E=vp(n.footerContent,{...t,section:"footer",contentWidth:b},n);E.querySelector("img")&&(z=false),x.appendChild(E);}z&&(x.style.maxHeight=`${g}px`,x.style.overflow="hidden"),r.appendChild(x);}return r}function ml(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body"},r={...n};if(n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Rp(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 Wy(e){let t=[];return e.headerContent&&t.push(`hdr:${e.headerContent.blocks.length},${e.headerContent.height}`),e.footerContent&&t.push(`ftr:${e.footerContent.blocks.length},${e.footerContent.height}`),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 Vy(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 Ea=2,jy=8;function gl(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=Wy(n),l=o>=jy;if(a&&a.optionsHash===s&&l){let g=a.pageStates,S=a.pageDataMap,T=i.__pageObserver,x=[];for(let F of e)x.push(Rp(F));let z=a.totalPages!==o,E=Math.min(g.length,e.length);for(let F=0;F<E;F++){let G=g[F],Y=x[F];if(G.fingerprint===Y&&!z){let J=S.get(G.element);J&&(J.page=e[F]);continue}let N=G.element,H=S.get(N);H&&(H.page=e[F],H.rendered&&Uy(N,S,o,n)),G.fingerprint=Y,Pa(N,e[F].size.w,e[F].size.h,n),N.dataset.pageNumber=String(e[F].number);}if(e.length>g.length){let F=n.document??document;for(let G=g.length;G<e.length;G++){let Y=e[G],N=F.createElement("div");N.className=n.pageClassName??Kn.page,N.dataset.pageNumber=String(Y.number),N.dataset.pageIndex=String(G),Pa(N,Y.size.w,Y.size.h,n),t.appendChild(N),g.push({element:N,fingerprint:x[G]}),S.set(N,{page:Y,index:G,rendered:false}),T&&T.observe(N);}}if(e.length<g.length){for(let F=g.length-1;F>=e.length;F--){let G=g[F].element;T&&T.unobserve(G),S.delete(G),t.removeChild(G);}g.length=e.length;}for(let F=0;F<g.length;F++){let G=S.get(g[F].element);G&&(G.index=F);}a.totalPages=o,a.currentOptions=n;return}let d=i.__pageObserver;d&&(d.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,Vy(t,r);let c=[],p=[];for(let g=0;g<e.length;g++){let S=e[g];if(p.push(Rp(S)),l){let x=(n.document??document).createElement("div");x.className=n.pageClassName??Kn.page,x.dataset.pageNumber=String(S.number),x.dataset.pageIndex=String(g),Pa(x,S.size.w,S.size.h,n),t.appendChild(x),c.push(x);}else {let{context:T,pageOptions:x}=ml(S,o,n),z=Fa(S,T,x);t.appendChild(z),c.push(z);}}if(!l)return;let m=new Map;for(let g=0;g<e.length;g++)m.set(c[g],{page:e[g],index:g,rendered:false});let f=new IntersectionObserver(g=>{let S=i.__pageRenderState;if(!S)return;let{currentOptions:T,totalPages:x,pageDataMap:z}=S;for(let Y of g){let N=Y.target,H=z.get(N);if(H&&Y.isIntersecting){Ma(N,z,x,T);for(let J=-Ea;J<=Ea;J++){let de=H.index+J;de>=0&&de<S.pageStates.length&&de!==H.index&&Ma(S.pageStates[de].element,z,x,T);}}}let E=window.innerHeight,F=E*3,G=new Set;for(let[Y,N]of z){if(!N.rendered)continue;let H=Y.getBoundingClientRect();H.bottom>-F&&H.top<E+F&&G.add(N.index);}for(let[Y,N]of z){if(!N.rendered)continue;let H=false;for(let J of G)if(Math.abs(N.index-J)<=Ea+1){H=true;break}!H&&G.size>0&&Ky(Y,z);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let g of c)f.observe(g);i.__pageObserver=f,i.__pageRenderState={pageStates:c.map((g,S)=>({element:g,fingerprint:p[S]})),totalPages:o,optionsHash:s,pageDataMap:m,currentOptions:n};let b=Math.min(e.length,Ea+3);for(let g=0;g<b;g++)Ma(c[g],m,o,n);}function Ma(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=ml(r.page,n,o),s=Fa(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function Uy(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=ml(r.page,n,o),l=Fa(r.page,i,a).querySelector(`.${Kn.content}`),u=e.querySelector(`.${Kn.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,Ma(e,t,n,o));}function Ky(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var La=class{constructor(t={}){chunkPCJ5ACUV_cjs.d(this,"container",null);chunkPCJ5ACUV_cjs.d(this,"blockLookup",new Map);chunkPCJ5ACUV_cjs.d(this,"pageStates",[]);chunkPCJ5ACUV_cjs.d(this,"totalPages",0);chunkPCJ5ACUV_cjs.d(this,"options");chunkPCJ5ACUV_cjs.d(this,"doc");this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body"},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return In(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return wa(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return va(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return Ra(t,r,i,n,{document:this.doc})}return xr(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 Fn,Gn,qn,Ln,Vo,ho,Ep,hl,Ba=class{constructor(){chunkPCJ5ACUV_cjs.f(this,ho);chunkPCJ5ACUV_cjs.f(this,Fn,0);chunkPCJ5ACUV_cjs.f(this,Gn,0);chunkPCJ5ACUV_cjs.f(this,qn,false);chunkPCJ5ACUV_cjs.f(this,Ln,null);chunkPCJ5ACUV_cjs.f(this,Vo,new Set);}setStateSeq(t){chunkPCJ5ACUV_cjs.g(this,Fn,t);}incrementStateSeq(){return ++chunkPCJ5ACUV_cjs.i(this,Fn)._}getStateSeq(){return chunkPCJ5ACUV_cjs.e(this,Fn)}getRenderSeq(){return chunkPCJ5ACUV_cjs.e(this,Gn)}onLayoutStart(){chunkPCJ5ACUV_cjs.g(this,qn,true);}onLayoutComplete(t){chunkPCJ5ACUV_cjs.g(this,Gn,t),chunkPCJ5ACUV_cjs.g(this,qn,false),chunkPCJ5ACUV_cjs.h(this,ho,Ep).call(this);}isSafeToRender(){return !chunkPCJ5ACUV_cjs.e(this,qn)&&chunkPCJ5ACUV_cjs.e(this,Gn)>=chunkPCJ5ACUV_cjs.e(this,Fn)}requestRender(){this.isSafeToRender()?chunkPCJ5ACUV_cjs.h(this,ho,hl).call(this):chunkPCJ5ACUV_cjs.g(this,Ln,()=>chunkPCJ5ACUV_cjs.h(this,ho,hl).call(this));}onRender(t){return chunkPCJ5ACUV_cjs.e(this,Vo).add(t),()=>{chunkPCJ5ACUV_cjs.e(this,Vo).delete(t);}}reset(){chunkPCJ5ACUV_cjs.g(this,Fn,0),chunkPCJ5ACUV_cjs.g(this,Gn,0),chunkPCJ5ACUV_cjs.g(this,qn,false),chunkPCJ5ACUV_cjs.g(this,Ln,null);}getDebugInfo(){return {stateSeq:chunkPCJ5ACUV_cjs.e(this,Fn),renderSeq:chunkPCJ5ACUV_cjs.e(this,Gn),layoutUpdating:chunkPCJ5ACUV_cjs.e(this,qn),hasPendingRender:chunkPCJ5ACUV_cjs.e(this,Ln)!==null,isSafe:this.isSafeToRender()}}};Fn=new WeakMap,Gn=new WeakMap,qn=new WeakMap,Ln=new WeakMap,Vo=new WeakMap,ho=new WeakSet,Ep=function(){if(chunkPCJ5ACUV_cjs.e(this,Ln)&&this.isSafeToRender()){let t=chunkPCJ5ACUV_cjs.e(this,Ln);chunkPCJ5ACUV_cjs.g(this,Ln,null),t();}},hl=function(){for(let t of chunkPCJ5ACUV_cjs.e(this,Vo))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var Mp=".layout-page-content .layout-line";function Gy(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 qy(e){let t=Gy(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 Ip({pagesContainerRef:e}){let t=Gp.useRef(null),n=Gp.useRef(-1),o=Gp.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let d of Array.from(l)){let c=d,p=Number(c.dataset.pmStart),m=Number(c.dataset.pmEnd);if(c.classList.contains("layout-run-tab")){if(s>=p&&s<m)return c.getBoundingClientRect().left;continue}if(s>=p&&s<=m&&d.firstChild?.nodeType===Node.TEXT_NODE){let f=d.firstChild,b=Math.min(s-p,f.length),g=c.ownerDocument;if(!g)continue;let S=g.createRange();return S.setStart(f,b),S.setEnd(f,b),S.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let d of Array.from(u)){let c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),m=Number(c.dataset.pmEnd);if(s>=p&&s<=m)return d.getBoundingClientRect().left}return null},[e]),r=Gp.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(Mp);for(let u of Array.from(l)){let d=u,c=d.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(c)){let m=p,f=Number(m.dataset.pmStart),b=Number(m.dataset.pmEnd);if(s>=f&&s<=b)return d}}for(let u of Array.from(l)){let d=u,c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),m=Number(c.dataset.pmEnd);if(s>=p&&s<=m&&c.querySelector(".layout-line")===d)return d}return null},[e]),i=Gp.useCallback((s,l)=>{let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let m=s.closest(".layout-paragraph");return m?.dataset.pmStart?Number(m.dataset.pmStart)+1:null}for(let m of Array.from(u)){let f=m,b=f.getBoundingClientRect(),g=Number(f.dataset.pmStart),S=Number(f.dataset.pmEnd);if(f.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let T=(b.left+b.right)/2;return l<T?g:S}continue}if(l>=b.left&&l<=b.right){let T=f.firstChild;if(!T||T.nodeType!==Node.TEXT_NODE)return g;let x=T,z=f.ownerDocument;if(!z)return g;let E=0,F=x.length;for(;E<F;){let G=Math.floor((E+F)/2),Y=z.createRange();Y.setStart(x,G),Y.setEnd(x,G),l<Y.getBoundingClientRect().left?F=G:E=G+1;}if(E>0&&E<=x.length){let G=z.createRange();G.setStart(x,E-1),G.setEnd(x,E-1);let Y=G.getBoundingClientRect().left;G.setStart(x,Math.min(E,x.length)),G.setEnd(x,Math.min(E,x.length));let N=G.getBoundingClientRect().left;if(Math.abs(l-Y)<Math.abs(l-N))return g+(E-1)}return g+Math.min(E,S-g)}}let d=null,c=1/0;for(let m of Array.from(u)){let f=m,b=f.getBoundingClientRect(),g=l<b.left?b.left-l:l-b.right;g<c&&(c=g,d=f);}if(!d)return null;let p=d.getBoundingClientRect();return l<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)},[]),a=Gp.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(Mp));if(u.length===0)return false;let{from:d,anchor:c}=s.state.selection;if(t.current===null){let x=o(d);if(x===null)return false;t.current=x;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let x=r(d);if(!x||(p=u.indexOf(x),p===-1))return false}let m=l.key==="ArrowUp"?p-1:p+1;if(m<0||m>=u.length)return n.current=-1,false;let f=u[m],b=i(f,t.current);if(b===null)return false;n.current=m;let{state:g,dispatch:S}=s,T=Math.max(0,Math.min(b,g.doc.content.size));try{let x=l.shiftKey?prosemirrorState.TextSelection.create(g.doc,c,T):prosemirrorState.TextSelection.create(g.doc,T);S(g.tr.setSelection(x));}catch{let x=g.doc.resolve(T),z=l.shiftKey?prosemirrorState.TextSelection.between(g.doc.resolve(c),x):prosemirrorState.TextSelection.near(x);S(g.tr.setSelection(z));}return qy(f),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var Yn=40,Na=12;function Yy(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 Fp({pagesContainerRef:e,onScrollExtendSelection:t}){let n=Gp.useRef(null),o=Gp.useRef({x:0,y:0}),r=Gp.useRef(false),i=Gp.useRef(null),a=Gp.useCallback(()=>{if(i.current)return i.current;let c=e.current;return c?(i.current=Yy(c),i.current):null},[e]),s=Gp.useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=Gp.useCallback(()=>{if(!r.current)return;let c=a();if(!c)return;let p=c.getBoundingClientRect(),{x:m,y:f}=o.current,b=0;if(f<p.top+Yn){let g=Math.max(0,p.top+Yn-f);b=-Math.min(Na,g/Yn*Na);}else if(f>p.bottom-Yn){let g=Math.max(0,f-(p.bottom-Yn));b=Math.min(Na,g/Yn*Na);}b!==0&&(c.scrollTop+=b,t(m,f)),n.current=requestAnimationFrame(l);},[a,t]),u=Gp.useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:Gp.useCallback((c,p)=>{if(o.current={x:c,y:p},!r.current){let m=a();if(!m)return;let f=m.getBoundingClientRect();(p<f.top+Yn||p>f.bottom-Yn)&&u();}},[a,u]),stopAutoScroll:s}}var Xy=12,za=8;function Lp(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 bl(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 Zy(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let d={kind:"text",text:`${t} `,fontSize:za,superscript:true};l.push(d);}for(let d of s.content){let c=d;if(c.type==="run"&&Array.isArray(c.content)){let p=c.formatting,m={};if(p){if(p.bold&&(m.bold=true),p.italic&&(m.italic=true),p.underline&&(m.underline=true),p.strike&&(m.strike=true),p.color){let f=p.color;f.val?m.color=`#${f.val}`:f.rgb&&(m.color=`#${f.rgb}`);}if(p.fontSize&&(m.fontSize=p.fontSize/2),p.fontFamily){let f=p.fontFamily;m.fontFamily=f.ascii||f.hAnsi;}}m.fontSize||(m.fontSize=za);for(let f of c.content){let b=f;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...m}):b.type==="tab"?l.push({kind:"tab",...m}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:za});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:za}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=_o(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 Bp(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=Zy(l,i,n);o.set(s.footnoteId,u),i++;}return o}function Ap(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+=Xy,n.set(o,i));}return n}var yl=class{constructor(t,n=1){chunkPCJ5ACUV_cjs.d(this,"pagesContainer");chunkPCJ5ACUV_cjs.d(this,"zoom");this.pagesContainer=t,this.zoom=n;}getCoordinatesForPosition(t){let n=this.pagesContainer.getBoundingClientRect(),o=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(o)){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(a.classList.contains("layout-run-tab")){if(t>=s&&t<l){let u=a.getBoundingClientRect(),d=a.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,d=Math.min(t-s,u.length),c=a.ownerDocument;if(!c)continue;let p=c.createRange();p.setStart(u,d),p.setEnd(u,d);let m=p.getBoundingClientRect(),f=a.closest(".layout-line"),b=f?f.offsetHeight:16;return {x:(m.left-n.left)/this.zoom,y:(m.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),d=i.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let f=s.getBoundingClientRect();r.push({x:(f.left-o.left)/this.zoom,y:(f.top-o.top)/this.zoom,width:f.width/this.zoom,height:f.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let d=a.firstChild,c=s.ownerDocument;if(!c)continue;let p=Math.max(0,t-l),m=Math.min(d.length,n-l);if(p<m){let f=c.createRange();f.setStart(d,p),f.setEnd(d,m);let b=f.getClientRects();for(let g of Array.from(b))r.push({x:(g.left-o.left)/this.zoom,y:(g.top-o.top)/this.zoom,width:g.width/this.zoom,height:g.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function Dp(e,t=1){return new yl(e,t)}var nx=816,$p=1056,Oa={top:96,right:96,bottom:96,left:96},ox=24,Jn=30,rx=200,ix=[],ax={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},sx={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24},lx={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},cx={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function cn(e){return Math.round(e/1440*96)}function dx(e){return {w:e?.pageWidth?cn(e.pageWidth):nx,h:e?.pageHeight?cn(e.pageHeight):$p}}function ux(e){let t=e?.marginTop?cn(e.marginTop):Oa.top,n=e?.marginBottom?cn(e.marginBottom):Oa.bottom;return {top:t,right:e?.marginRight?cn(e.marginRight):Oa.right,bottom:n,left:e?.marginLeft?cn(e.marginLeft):Oa.left,header:e?.headerDistance?cn(e.headerDistance):48,footer:e?.footerDistance?cn(e.footerDistance):48}}function px(e){let t=e?.columnCount??1;if(t<=1)return;let n=cn(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function fx(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 mx(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function Np(e){return e===void 0?0:Math.round(e*96/914400)}function gx(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 _p(e,t){let i=e.columnWidths??[],a=gx(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((f,b)=>f+(b.colSpan??1),0),m=(a??t)/Math.max(1,c);i=Array(c).fill(m);}else if(i.length>0&&a){let c=i.reduce((p,m)=>p+m,0);if(c>0&&Math.abs(c-a)>1){let p=a/c;i=i.map(m=>m*p);}}let s=new Map;for(let c=0;c<e.rows.length;c++){let p=e.rows[c];if(!p)continue;let m=0,f=s.get(c)??new Set;for(;f.has(m);)m++;for(let b of p.cells){let g=b.colSpan??1,S=b.rowSpan??1;if(S>1)for(let T=c+1;T<c+S;T++){s.has(T)||s.set(T,new Set);let x=s.get(T);for(let z=0;z<g;z++)x.add(m+z);}for(m+=g;f.has(m);)m++;}}let l=e.rows.map((c,p)=>{let m=0,f=s.get(p)??new Set;for(;f.has(m);)m++;return {cells:c.cells.map(b=>{let g=b.colSpan??1,S=0;for(let E=0;E<g&&m+E<i.length;E++)S+=i[m+E]??0;for(S===0&&(S=b.width??100),m+=g;f.has(m);)m++;let T=b.padding?.left??7,x=b.padding?.right??7,z=Math.max(1,S-T-x);return {blocks:b.blocks.map(E=>Wp(E,z)),width:S,height:0,colSpan:b.colSpan,rowSpan:b.rowSpan}}),height:0}});for(let c=0;c<l.length;c++){let p=l[c],m=e.rows[c]?.cells,f=0;for(let T=0;T<p.cells.length;T++){let x=p.cells[T],z=m?.[T];x.height=x.blocks.reduce((G,Y)=>"totalHeight"in Y?G+Y.totalHeight:G,0);let E=z?.padding?.top??1,F=z?.padding?.bottom??1;x.height+=E+F,f=Math.max(f,x.height);}let b=e.rows[c],g=b?.height,S=b?.heightRule;g&&S==="exact"?p.height=g:g&&S==="atLeast"?p.height=Math.max(f,g):p.height=Math.max(f,24);}let u=l.reduce((c,p)=>c+p.height,0),d=i.reduce((c,p)=>c+p,0)||a||t;return {kind:"table",rows:l,columnWidths:i,totalWidth:d,totalHeight:u}}function hx(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(!mx(s))continue;let l=0,u=s.position,d=s.distTop??0,c=s.distBottom??0,p=s.distLeft??12,m=s.distRight??12;if(u?.vertical){let S=u.vertical;S.align==="top"&&S.relativeTo==="margin"?l=0:S.posOffset!==void 0&&(l=Np(S.posOffset));}let f=l+s.height,b=0,g=0;if(u?.horizontal){let S=u.horizontal;if(S.align==="left")b=s.width+m;else if(S.align==="right")g=s.width+p;else if(S.posOffset!==void 0){let T=Np(S.posOffset);T<t/2?b=T+s.width+m:g=t-T+p;}}else s.cssFloat==="left"?b=s.width+m:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let S=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-d,bottomY:f+c,anchorBlockIndex:o,isMarginRelative:S});}}}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=_p(i,t),l=s.totalWidth,u=s.totalHeight,d=a.leftFromText??12,c=a.rightFromText??12,p=a.topFromText??0,m=a.bottomFromText??0,f=0,b=0,g=0;a.tblpX!==void 0?g=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?g=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?g=t-l:a.tblpXSpec==="center"&&(g=(t-l)/2):i.justification==="center"?g=(t-l)/2:i.justification==="right"&&(g=t-l),g<t/2?f=g+l+c:b=t-g+d;let S=a.tblpY??0,T=S+u;n.push({leftMargin:f,rightMargin:b,topY:S-p,bottomY:T+m,anchorBlockIndex:o});}return n}function Wp(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=nl(r,t);if(a)return a}let i=_o(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&ol(r,t,i),i}case "table":return _p(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??chunkOJ7NJK46_cjs.c,a=(r.width??chunkOJ7NJK46_cjs.d)-i.left-i.right,s=r.content.map(d=>_o(d,a)),l=s.reduce((d,c)=>d+c.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??chunkOJ7NJK46_cjs.d,height:u,innerMeasures:s}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function Vp(e,t){let n=Array.isArray(t)?t[0]??0:t,o=hx(e,n),r=o.filter(p=>p.isMarginRelative),i=o.filter(p=>!p.isMarginRelative),a=new Map;for(let p of r){let m=a.get(p.topY)??[];m.push(p),a.set(p.topY,m);}let s=[...i];for(let p of a.values()){let m=Math.min(...p.map(f=>f.anchorBlockIndex));for(let f of p)s.push({...f,anchorBlockIndex:m});}let l=new Map;for(let p of s){let m=l.get(p.anchorBlockIndex)??[];m.push({leftMargin:p.leftMargin,rightMargin:p.rightMargin,topY:p.topY,bottomY:p.bottomY}),l.set(p.anchorBlockIndex,m);}let u=new Set(s.map(p=>p.anchorBlockIndex)),d=0,c=[];return e.map((p,m)=>{u.has(m)&&(d=0,c=l.get(m)??[]);let f=c.length>0?c:void 0;try{let b=performance.now(),g=Array.isArray(t)?t[m]??n:t,S=Wp(p,g,f,d),T=performance.now()-b;return T>500&&console.warn(`[measureBlocks] Block ${m} (${p.kind}) took ${Math.round(T)}ms`),"totalHeight"in S&&(p.kind==="table"&&p.floating||(d+=S.totalHeight)),S}catch(b){return console.error(`[measureBlocks] Error measuring block ${m} (${p.kind}):`,b),{totalHeight:20}}})}function $a(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,d=f=>Math.round(f/914400*96),c=u?.width?d(u.width):100,p=u?.height?d(u.height):100,m=l.position;t.push({kind:"image",src:l.src||"",width:c,height:p,alt:l.alt||void 0,position:m?{horizontal:m.horizontal,vertical:m.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=$a(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=$a(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=$a(o.children);t.push(...r);}}return t}function zp(e,t){if(!e||!e.content||e.content.length===0)return;let n=[];for(let a of e.content){let s=a;if(s.type==="paragraph"&&Array.isArray(s.content)){let l=s.formatting,u={};if(l){if(l.alignment){let c=l.alignment;c==="both"?u.alignment="justify":["left","center","right","justify"].includes(c)&&(u.alignment=c);}if(l.borders){let c=l.borders,p={};for(let m of ["top","bottom","left","right","between"]){let f=c[m];if(f){let b=xa(f);b&&(p[m]=b);}}Object.keys(p).length>0&&(u.borders=p);}(l.spaceAfter!=null||l.spaceBefore!=null)&&(u.spacing={before:l.spaceBefore,after:l.spaceAfter}),Array.isArray(l.tabs)&&l.tabs.length>0&&(u.tabs=l.tabs.map(c=>({val:c.alignment==="left"?"start":c.alignment==="right"?"end":c.alignment,pos:c.position,leader:c.leader})));}let d=$a(s.content);if(d.length>0){let c={kind:"paragraph",id:String(n.length),runs:d,attrs:Object.keys(u).length>0?u:void 0};n.push(c);}}}if(n.length===0)return;let o=n.map(a=>{if(a.kind!=="paragraph")return a;let s=a;if(!s.runs.some(d=>d.kind==="image"&&"position"in d&&d.position))return a;let u=s.runs.filter(d=>!(d.kind==="image"&&"position"in d&&d.position));return u.length===0&&u.push({kind:"text",text:""}),{...s,runs:u}}),r=Vp(o,t),i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {blocks:n,measures:r,height:i}}function bx(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let c=t.get(l)?.displayNumber??0,p=chunkCL62W2HQ_cjs.b(u);s.push({displayNumber:String(c),text:p});}s.length>0&&o.set(i,s);}return o}var yx=Gp.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,readOnly:u=false,pageGap:d=ox,zoom:c=1,onDocumentChange:p,onSelectionChange:m,externalPlugins:f=ix,extensionManager:b,onReady:g,onRenderedDomContextReady:S,pluginOverlays:T,onHeaderFooterDoubleClick:x,hfEditMode:z,onBodyClick:E,className:F,style:G,commentsSidebarOpen:Y=false,sidebarOverlay:N,scrollContainerRef:H,onHyperlinkClick:J}=t,de=Gp.useCallback(()=>H&&typeof H=="object"?H.current:D.current,[H]),D=Gp.useRef(null),P=Gp.useRef(null),R=Gp.useRef(null),me=Gp.useRef(null),{handlePMKeyDown:pe}=Ip({pagesContainerRef:P}),Be=Gp.useRef(()=>{}),Me=Gp.useRef(m),We=Gp.useRef(p),w=Gp.useRef(g),A=Gp.useRef(S);Me.current=m,We.current=p,w.current=g,A.current=S;let[k,M]=Gp.useState(null),[B,v]=Gp.useState([]),[q,ae]=Gp.useState([]),[$,_]=Gp.useState(false),[ne,ge]=Gp.useState([]),[I,W]=Gp.useState(null),[O,X]=Gp.useState(null),ue=Gp.useRef(false),fe=Gp.useCallback((C,V)=>{let j=C.tagName==="IMG"?C:C.querySelector("img"),U=(j??C).getBoundingClientRect();return {element:j??C,pmPos:V,width:Math.round(U.width/c),height:Math.round(U.height/c)}},[c]),Fe=Gp.useRef(false),he=Gp.useRef(null),Pe=Gp.useRef(false),be=Gp.useRef(0),ot=Gp.useRef(0),rt=Gp.useRef(0),je=Gp.useRef({left:0,right:0}),Qe=Gp.useRef(null),Ue=Gp.useRef(false),mt=Gp.useRef(0),vt=Gp.useRef(0),Ne=Gp.useRef(0),ct=Gp.useRef(0),He=Gp.useRef(null),$t=Gp.useRef(false),Tn=Gp.useRef(false),Ko=Gp.useRef(0),Er=Gp.useRef(0),Bn=Gp.useRef(0),ko=Gp.useRef(0),bt=Gp.useRef(null),Ut=Gp.useRef(false),_t=Gp.useRef(null),en=Gp.useRef(null),Mt=Gp.useRef(null),ce=5,[tn,nn]=Gp.useState(null),on=Gp.useRef(null),An=Gp.useCallback(()=>{on.current&&(clearTimeout(on.current),on.current=null);},[]);Gp.useEffect(()=>()=>{on.current&&clearTimeout(on.current);},[]);let ze=Gp.useMemo(()=>new Ba,[]),Rt=Gp.useMemo(()=>dx(a),[a]),yt=Gp.useMemo(()=>ux(a),[a]),Wt=Gp.useMemo(()=>px(a),[a]),Cn=Rt.w-yt.left-yt.right,Pr=Gp.useMemo(()=>new La({pageGap:d,showShadow:true,pageBackground:"#fff"}),[d]);me.current=Pr;let It=Gp.useCallback(C=>{let V=performance.now(),j=ze.getStateSeq();ze.onLayoutStart();try{let U=performance.now(),re=Rt.h-yt.top-yt.bottom,K=op(C.doc,{theme:i,pageContentHeight:re}),Q=performance.now()-U;Q>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(Q)}ms (${K.length} blocks)`),v(K),U=performance.now();let oe=fx(K,Cn,Wt),le=Vp(K,oe);Q=performance.now()-U,Q>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(Q)}ms (${K.length} blocks)`),ae(le);let xe=Lp(K),ye=xe.length>0&&o?.package?.footnotes,Ce=zp(s,Cn),Ie=zp(l,Cn),we=yt.header??48,Le=yt.footer??48,Ve=yt.top-we,dt=yt.bottom-Le,ut=Ce?.height??0,Yt=Ie?.height??0,Hn=yt;if(ut>Ve||Yt>dt){Hn={...yt};let rn=8;ut>Ve&&(Hn.top=Math.max(yt.top,we+ut+rn)),Yt>dt&&(Hn.bottom=Math.max(yt.bottom,Le+Yt+rn));}U=performance.now();let pn,io=new Map,Xt=new Map,qa=a?.sectionStart,Zo={pageSize:Rt,margins:Hn,columns:Wt,bodyBreakType:qa};if(ye){let rn=chunkOJ7NJK46_cjs.e(K,le,Zo);io=bl(rn.pages,xe),Xt=Bp(o.package.footnotes,xe,Cn);let ao=Ap(io,Xt);if(ao.size>0){pn=chunkOJ7NJK46_cjs.e(K,le,{...Zo,footnoteReservedHeights:ao}),io=bl(pn.pages,xe);for(let[fn,so]of io){let lo=pn.pages.find(Ya=>Ya.number===fn);lo&&(lo.footnoteIds=so);}}else pn=rn;}else pn=chunkOJ7NJK46_cjs.e(K,le,Zo);if(Q=performance.now()-U,Q>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(Q)}ms (${pn.pages.length} pages)`),M(pn),P.current&&me.current){U=performance.now();let rn=new Map;for(let fn=0;fn<K.length;fn++){let so=K[fn],lo=le[fn];so&&lo&&rn.set(String(so.id),{block:so,measure:lo});}me.current.setBlockLookup(rn);let ao=ye?bx(io,Xt,o):void 0;if(gl(pn.pages,P.current,{pageGap:d,showShadow:!0,pageBackground:"#fff",blockLookup:rn,headerContent:Ce,footerContent:Ie,headerDistance:a?.headerDistance?cn(a.headerDistance):void 0,footerDistance:a?.footerDistance?cn(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:ao?.size?ao:void 0}),Q=performance.now()-U,Q>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(Q)}ms`),S){let fn=Dp(P.current,c);S(fn);}}let Hr=performance.now()-V;Hr>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(Hr)}ms total (${K.length} blocks, ${le.length} measures)`);}catch(U){console.error("[PagedEditor] Layout pipeline error:",U);}ze.onLayoutComplete(j);},[Cn,Wt,Rt,yt,d,c,ze,s,l,a,S,o]),Dt=Gp.useRef(null),Mr=Gp.useCallback(C=>{if(Dt.current){Dt.current.state=C;return}let V=requestAnimationFrame(()=>{let j=Dt.current;Dt.current=null,j&&It(j.state);});Dt.current={rafId:V,state:C};},[It]);Gp.useEffect(()=>()=>{Dt.current&&(cancelAnimationFrame(Dt.current.rafId),Dt.current=null);},[]);let Dn=Gp.useCallback((C,V=1)=>{if(!P.current)return null;let j=P.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!j)return null;let U=j.getBoundingClientRect(),re=P.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let Q of Array.from(re)){let oe=Q,le=Number(oe.dataset.pmStart),xe=Number(oe.dataset.pmEnd);if(oe.classList.contains("layout-run-tab")){if(C>=le&&C<xe){let ye=oe.getBoundingClientRect(),Ce=oe.closest(".layout-page"),Ie=Ce?Number(Ce.dataset.pageNumber)-1:0,we=oe.closest(".layout-line"),Le=we?we.offsetHeight:16;return {x:(ye.left-U.left)/V,y:(ye.top-U.top)/V,height:Le,pageIndex:Ie}}continue}if(C>=le&&C<=xe&&Q.firstChild?.nodeType===Node.TEXT_NODE){let ye=Q.firstChild,Ce=Math.min(C-le,ye.length),Ie=oe.ownerDocument;if(!Ie)continue;let we=Ie.createRange();we.setStart(ye,Ce),we.setEnd(ye,Ce);let Le=we.getBoundingClientRect(),Ve=oe.closest(".layout-page"),dt=Ve?Number(Ve.dataset.pageNumber)-1:0,ut=oe.closest(".layout-line"),Yt=ut?ut.offsetHeight:16;return {x:(Le.left-U.left)/V,y:(Le.top-U.top)/V,height:Yt,pageIndex:dt}}}let K=P.current.querySelectorAll(".layout-empty-run");for(let Q of Array.from(K)){let oe=Q.closest(".layout-paragraph");if(!oe)continue;let le=Number(oe.dataset.pmStart),xe=Number(oe.dataset.pmEnd);if(C>=le&&C<=xe){let ye=Q.getBoundingClientRect(),Ce=oe.closest(".layout-page"),Ie=Ce?Number(Ce.dataset.pageNumber)-1:0,we=Q.closest(".layout-line"),Le=we?we.offsetHeight:16;return {x:(ye.left-U.left)/V,y:(ye.top-U.top)/V,height:Le,pageIndex:Ie}}}return null},[]),Ht=Gp.useCallback(C=>{let{from:V,to:j}=C.selection;if(Me.current?.(V,j),P.current){let U=P.current.querySelectorAll(".layout-table-cell-selected");for(let Q of Array.from(U))Q.classList.remove("layout-table-cell-selected");let re=C.selection;if("$anchorCell"in re&&typeof re.forEachCell=="function"){let Q=[];re.forEachCell((le,xe)=>{Q.push([xe,xe+le.nodeSize]);});let oe=P.current.querySelectorAll(".layout-table-cell");for(let le of Array.from(oe)){let xe=le,ye=xe.dataset.pmStart;if(ye!==void 0){let Ce=Number(ye);for(let[Ie,we]of Q)if(Ce>=Ie&&Ce<we){xe.classList.add("layout-table-cell-selected");break}}}}}if(!(!k||B.length===0))if(V===j){let U=Dn(V,c);if(U)W(U);else {let re=P.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),K=P.current?.querySelector(".layout-page");if(re&&K){let Q=re.getBoundingClientRect(),oe=K.getBoundingClientRect(),le=chunkOJ7NJK46_cjs.o(k,B,q,V);W(le?{...le,x:le.x+(oe.left-Q.left)/c,y:le.y+(oe.top-Q.top)/c}:null);}else W(null);}ge([]);}else {let U=P.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(U&&P.current){let re=U.getBoundingClientRect(),K=[],Q=P.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let oe of Array.from(Q)){let le=oe,xe=Number(le.dataset.pmStart);if(Number(le.dataset.pmEnd)>V&&xe<j){if(le.classList.contains("layout-run-tab")){let Ve=le.getBoundingClientRect(),dt=le.closest(".layout-page"),ut=dt?Number(dt.dataset.pageNumber)-1:0;K.push({x:(Ve.left-re.left)/c,y:(Ve.top-re.top)/c,width:Ve.width/c,height:Ve.height/c,pageIndex:ut});continue}let Ce=null;if(oe.firstChild?.nodeType===Node.TEXT_NODE?Ce=oe.firstChild:oe.firstChild?.nodeType===Node.ELEMENT_NODE&&oe.firstChild.tagName==="A"&&oe.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(Ce=oe.firstChild.firstChild),!Ce)continue;let Ie=le.ownerDocument;if(!Ie)continue;let we=Math.max(0,V-xe),Le=Math.min(Ce.length,j-xe);if(we<Le){let Ve=Ie.createRange();Ve.setStart(Ce,we),Ve.setEnd(Ce,Le);let dt=Ve.getClientRects();for(let ut of Array.from(dt)){let Yt=le.closest(".layout-page"),Hn=Yt?Number(Yt.dataset.pageNumber)-1:0;K.push({x:(ut.left-re.left)/c,y:(ut.top-re.top)/c,width:ut.width/c,height:ut.height/c,pageIndex:Hn});}}}}if(K.length>0)ge(K);else {let oe=P.current.querySelector(".layout-page");if(oe){let le=oe.getBoundingClientRect(),xe=(le.left-re.left)/c,ye=(le.top-re.top)/c,Ie=chunkOJ7NJK46_cjs.n(k,B,q,V,j).map(we=>({...we,x:we.x+xe,y:we.y+ye}));ge(Ie);}else ge([]);}}else ge([]);W(null);}},[k,B,q,Dn,c]),Go=Gp.useCallback((C,V)=>{if(C.docChanged){ze.incrementStateSeq(),Mr(V);let j=R.current?.getDocument();j&&We.current?.(j);}ze.requestRender(),C.docChanged||Ht(V);},[Mr,Ht,ze]),To=Gp.useCallback(C=>{let{selection:V}=C;V instanceof prosemirrorState.NodeSelection&&V.node.type.name==="image"?(ge([]),W(null)):ze.isSafeToRender()&&Ht(C),requestAnimationFrame(()=>{let j=R.current?.getView();if(!j){X(null);return}let{selection:U}=j.state;if(U instanceof prosemirrorState.NodeSelection&&U.node.type.name==="image"){let re=U.from,K=P.current?.querySelector(`[data-pm-start="${re}"]`);if(K){X(fe(K,re));return}}ue.current||X(null);});},[Ht,c,fe,ze]),st=Gp.useCallback((C,V)=>{if(!P.current||!k)return null;let j=mp(P.current,C,V,c);if(j!==null)return j;let U=P.current.querySelectorAll(".layout-page"),re=-1,K=null;for(let Ce=0;Ce<U.length;Ce++){let we=U[Ce].getBoundingClientRect();if(C>=we.left&&C<=we.right&&V>=we.top&&V<=we.bottom){re=Ce,K=we;break}}if(re<0||!K)return null;let Q=(C-K.left)/c,oe=(V-K.top)/c,le=k.pages[re];if(!le)return null;let xe={pageIndex:re,page:le,pageY:oe},ye=chunkOJ7NJK46_cjs.l(xe,B,q,{x:Q,y:oe});if(!ye)return null;if(ye.fragment.kind==="table"){let Ce=chunkOJ7NJK46_cjs.m(xe,B,q,{x:Q,y:oe});return il(ye,Ce)}return il(ye)},[k,B,q,c]),wn=Gp.useCallback(C=>{let V=R.current?.getView();if(!V)return null;try{let j=V.state.doc.resolve(C);for(let U=j.depth;U>0;U--){let re=j.node(U);if(re.type.name==="tableCell"||re.type.name==="tableHeader")return j.before(U)}}catch{}return null},[]),qo=Gp.useCallback(C=>{let V=["layout-block-image","layout-image","layout-page-floating-image"],j=U=>!!U.dataset.pmStart&&V.some(re=>U.classList.contains(re));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&j(C.parentElement)?C.parentElement:j(C)?C:null},[]),Kt=Gp.useCallback(C=>{let V=P.current;if(!V)return;let j=V.querySelector(`[data-pm-start="${C}"]`);j&&j.scrollIntoView({behavior:"smooth",block:"center"});},[]),Ir=Gp.useCallback(C=>{if(!R.current||C.button!==0||(nn(null),An(),C.target.closest("a[href]")&&C.preventDefault(),u))return;if(z&&E){let K=C.target;if(!(K.closest(".layout-page-header")||K.closest(".layout-page-footer")||K.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),E();return}}if(!z){let K=C.target;if(K.closest(".layout-page-header")||K.closest(".layout-page-footer")){C.preventDefault(),R.current&&(R.current.setSelection(0),R.current.focus(),_(true));return}}let j=C.target;if(j.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),Pe.current=true,be.current=C.clientX,Qe.current=j,j.classList.add("dragging");let K=parseInt(j.dataset.columnIndex??"0",10);ot.current=K,rt.current=parseInt(j.dataset.tablePmStart??"0",10);let Q=R.current.getView();if(Q){let oe=Q.state.doc.resolve(rt.current+1);for(let le=oe.depth;le>=0;le--){let xe=oe.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[K]!==void 0&&ye[K+1]!==void 0&&(je.current={left:ye[K],right:ye[K+1]});break}}}return}if(j.classList.contains("layout-table-row-resize-handle")||j.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),Ue.current=true,mt.current=C.clientY,He.current=j,$t.current=j.dataset.isEdge==="bottom",j.classList.add("dragging");let K=parseInt(j.dataset.rowIndex??"0",10);vt.current=K,Ne.current=parseInt(j.dataset.tablePmStart??"0",10);let Q=R.current.getView();if(Q){let oe=Q.state.doc.resolve(Ne.current+1);for(let le=oe.depth;le>=0;le--){let xe=oe.node(le);if(xe.type.name==="table"){let ye=null,Ce=0;if(xe.forEach(Ie=>{Ce===K&&(ye=Ie),Ce++;}),ye){let Ie=ye.attrs.height;if(Ie)ct.current=Ie;else {let Le=j.closest(".layout-table")?.querySelector(`[data-row-index="${K}"]`),Ve=Le?Le.getBoundingClientRect().height:30;ct.current=Math.round(Ve*15);}}break}}}return}if(j.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),Tn.current=true,Ko.current=C.clientX,bt.current=j,j.classList.add("dragging");let K=parseInt(j.dataset.columnIndex??"0",10);Er.current=K,Bn.current=parseInt(j.dataset.tablePmStart??"0",10);let Q=R.current.getView();if(Q){let oe=Q.state.doc.resolve(Bn.current+1);for(let le=oe.depth;le>=0;le--){let xe=oe.node(le);if(xe.type.name==="table"){let ye=xe.attrs.columnWidths;ye&&ye[K]!==void 0&&(ko.current=ye[K]);break}}}return}let U=qo(j);if(U){C.preventDefault(),C.stopPropagation();let K=U.dataset.pmStart;if(K!==void 0){let Q=parseInt(K,10);R.current.setNodeSelection(Q),X(fe(U,Q)),ge([]),W(null);}R.current.focus(),_(true);return}X(null),C.preventDefault();let re=st(C.clientX,C.clientY);if(re!==null){let K=wn(re);_t.current=K,Ut.current=false,en.current=null,Mt.current=null,Fe.current=true,he.current=re,R.current.setSelection(re);}else {_t.current=null,Ut.current=false;let K=R.current.getView();if(K){let Q=Math.max(0,K.state.doc.content.size-1);R.current.setSelection(Q),he.current=Q,Fe.current=true;}}R.current.focus(),_(true);},[st,wn,u,z,E,c,J,An]),oo=Gp.useCallback((C,V)=>{Be.current(C,V);},[]),{updateMousePosition:Fr,stopAutoScroll:Ae}=Fp({pagesContainerRef:P,onScrollExtendSelection:oo});Be.current=(C,V)=>{if(!Fe.current||he.current===null||!R.current)return;let j=st(C,V);j!==null&&R.current.setSelection(he.current,j);};let qe=Gp.useCallback(C=>{if(Pe.current){C.preventDefault();let U=C.clientX-be.current;if(Qe.current){let re=parseFloat(Qe.current.style.left);Qe.current.style.left=`${re+U}px`,be.current=C.clientX;let K=Math.round(U*15),Q=300,oe=je.current.left+K,le=je.current.right-K;oe>=Q&&le>=Q&&(je.current={left:oe,right:le});}return}if(Ue.current){C.preventDefault();let U=C.clientY-mt.current;if(He.current){let re=parseFloat(He.current.style.top);He.current.style.top=`${re+U}px`,mt.current=C.clientY;let K=Math.round(U*15),Q=200,oe=ct.current+K;oe>=Q&&(ct.current=oe);}return}if(Tn.current){C.preventDefault();let U=C.clientX-Ko.current;if(bt.current){let re=parseFloat(bt.current.style.left);bt.current.style.left=`${re+U}px`,Ko.current=C.clientX;let K=Math.round(U*15),Q=300,oe=ko.current+K;oe>=Q&&(ko.current=oe);}return}if(!Fe.current||he.current===null||!R.current||!P.current)return;Fr(C.clientX,C.clientY);let V=st(C.clientX,C.clientY);if(V===null)return;if(_t.current!==null){if(Ut.current){let re=wn(V);if(re!==null){R.current.setCellSelection(_t.current,re);return}}let U=wn(V);if(U!==null&&U!==_t.current){Ut.current=true,R.current.setCellSelection(_t.current,U),Mt.current=null;return}if(en.current!==null&&V===en.current){if(Mt.current===null)Mt.current=C.clientX;else if(Math.abs(C.clientX-Mt.current)>=ce){Ut.current=true,R.current.setCellSelection(_t.current,_t.current),Mt.current=null;return}}else Mt.current=null,en.current=V;}let j=he.current;R.current.setSelection(j,V);},[st,wn,Fr]),Yo=Gp.useCallback(()=>{if(Pe.current){Pe.current=false,Qe.current&&(Qe.current.classList.remove("dragging"),Qe.current=null);let C=R.current?.getView();if(C){let V=rt.current,j=ot.current,{left:U,right:re}=je.current,K=C.state.doc.resolve(V+1);for(let Q=K.depth;Q>=0;Q--){let oe=K.node(Q);if(oe.type.name==="table"){let le=K.before(Q),xe=C.state.tr,ye=[...oe.attrs.columnWidths];ye[j]=U,ye[j+1]=re,xe.setNodeMarkup(le,void 0,{...oe.attrs,columnWidths:ye});let Ce=le+1;oe.forEach(Ie=>{let we=Ce+1,Le=0;Ie.forEach(Ve=>{let dt=Ve.attrs.colspan||1;if(Le===j||Le===j+1){let ut=Le===j?U:re;xe.setNodeMarkup(xe.mapping.map(we),void 0,{...Ve.attrs,width:ut,widthType:"dxa",colwidth:null});}we+=Ve.nodeSize,Le+=dt;}),Ce+=Ie.nodeSize;}),C.dispatch(xe);break}}}return}if(Ue.current){Ue.current=false,He.current&&(He.current.classList.remove("dragging"),He.current=null);let C=R.current?.getView();if(C){let V=Ne.current,j=vt.current,U=ct.current,re=C.state.doc.resolve(V+1);for(let K=re.depth;K>=0;K--){let Q=re.node(K);if(Q.type.name==="table"){let oe=re.before(K),le=C.state.tr,xe=oe+1,ye=0;Q.forEach(Ce=>{ye===j&&le.setNodeMarkup(le.mapping.map(xe),void 0,{...Ce.attrs,height:U,heightRule:"atLeast"}),xe+=Ce.nodeSize,ye++;}),C.dispatch(le);break}}}return}if(Tn.current){Tn.current=false,bt.current&&(bt.current.classList.remove("dragging"),bt.current=null);let C=R.current?.getView();if(C){let V=Bn.current,j=Er.current,U=ko.current,re=C.state.doc.resolve(V+1);for(let K=re.depth;K>=0;K--){let Q=re.node(K);if(Q.type.name==="table"){let oe=re.before(K),le=C.state.tr,xe=[...Q.attrs.columnWidths];xe[j]=U,le.setNodeMarkup(oe,void 0,{...Q.attrs,columnWidths:xe});let ye=oe+1;Q.forEach(Ce=>{let Ie=ye+1,we=0;Ce.forEach(Le=>{let Ve=Le.attrs.colspan||1;we===j&&le.setNodeMarkup(le.mapping.map(Ie),void 0,{...Le.attrs,width:U,widthType:"dxa",colwidth:null}),Ie+=Le.nodeSize,we+=Ve;}),ye+=Ce.nodeSize;}),C.dispatch(le);break}}}return}Fe.current=false,Ut.current=false,en.current=null,Mt.current=null,Ae();},[Ae]);Gp.useEffect(()=>(window.addEventListener("mousemove",qe),window.addEventListener("mouseup",Yo),()=>{window.removeEventListener("mousemove",qe),window.removeEventListener("mouseup",Yo);}),[qe,Yo]);let ja=Gp.useCallback(C=>{if(u||Fe.current||Pe.current||Ue.current||Tn.current||Ut.current)return;let V=P.current;if(!V)return;let j=C.clientX,U=C.clientY,re=C.target.closest(".layout-table");if(!re){let Ie=V.querySelectorAll(".layout-table");for(let we of Array.from(Ie)){let Le=we.getBoundingClientRect(),Ve=j>=Le.left-Jn&&j<Le.left,dt=U>=Le.top-Jn&&U<Le.top,ut=j>=Le.left-Jn&&j<=Le.right,Yt=U>=Le.top-Jn&&U<=Le.bottom;if(Ve&&Yt||dt&&ut){re=we;break}}}if(!re){nn(null);return}let K=re.getBoundingClientRect(),Q=j<K.left+Jn&&j>=K.left-Jn,oe=U<K.top+Jn&&U>=K.top-Jn;if(!Q&&!oe){nn(null);return}let le=re.querySelectorAll(":scope > .layout-table-row");if(le.length===0){nn(null);return}let xe=V.parentElement;if(!xe)return;let ye=xe.getBoundingClientRect(),Ce=Ie=>Ie&&Number(Ie.dataset.pmStart)||0;if(Q)for(let Ie=0;Ie<le.length;Ie++){let we=le[Ie].getBoundingClientRect();if(U>=we.top&&U<=we.bottom){let Le=le[Ie].querySelector(".layout-table-cell"),Ve=Ce(Le);if(!Ve)break;let dt=we.top+we.height/2;nn({type:"row",x:K.left-ye.left-24,y:dt-ye.top-10,cellPmPos:Ve}),An();return}}if(oe){let Ie=le[0].querySelectorAll(":scope > .layout-table-cell");for(let we=0;we<Ie.length;we++){let Le=Ie[we].getBoundingClientRect();if(j>=Le.left&&j<=Le.right){let Ve=Ce(Ie[we]);if(!Ve)break;let dt=Le.left+Le.width/2;nn({type:"column",x:dt-ye.left-10,y:K.top-ye.top-24,cellPmPos:Ve}),An();return}}}on.current||(on.current=setTimeout(()=>{nn(null),on.current=null;},rx));},[u,An]),kt=Gp.useCallback(C=>{if(C.preventDefault(),C.stopPropagation(),!tn||!R.current)return;let V=R.current.getView();if(!V)return;let{type:j,cellPmPos:U}=tn,re=V.state.tr.setSelection(prosemirrorState.TextSelection.create(V.state.doc,U+1));V.dispatch(re),j==="row"?No(V.state,V.dispatch):zo(V.state,V.dispatch),nn(null),R.current.focus();},[tn]),Tt=Gp.useCallback(C=>{let V=C.target.closest("a[href]");if(V){C.preventDefault();let j=V.getAttribute("href")||"";if(j.startsWith("#")){let U=j.substring(1);if(U&&R.current){let re=R.current.getView();if(re){let K=null;re.state.doc.descendants((Q,oe)=>{if(K!==null)return false;if(Q.type.name==="paragraph"&&Q.attrs.bookmarks?.some(xe=>xe.name===U))return K=oe,false}),K!==null&&(Kt(K),R.current.setSelection(K+1));}}}else if(J){let U=R.current?.getView();if(!(U&&U.state.selection.from!==U.state.selection.to)){let K=V.textContent||"",Q=V.getAttribute("title")||void 0,oe=V.getBoundingClientRect();J({href:j,displayText:K,tooltip:Q,anchorRect:oe});}}return}if(C.detail===2&&x){let j=C.target,U=j.closest(".layout-page-header"),re=j.closest(".layout-page-footer");if(U){C.preventDefault(),C.stopPropagation(),x("header");return}if(re){C.preventDefault(),C.stopPropagation(),x("footer");return}}if(C.detail===2&&R.current){let j=st(C.clientX,C.clientY);if(j!==null){let U=wn(j);if(U!==null){C.preventDefault(),C.stopPropagation(),R.current.setCellSelection(U,U);return}let re=R.current.getView();if(re){let{doc:K}=re.state,Q=K.resolve(j),oe=Q.parent;if(oe.isTextblock){let le=oe.textContent,xe=Q.parentOffset,ye=xe;for(;ye>0&&/\w/.test(le[ye-1]);)ye--;let Ce=xe;for(;Ce<le.length&&/\w/.test(le[Ce]);)Ce++;let Ie=Q.start()+ye,we=Q.start()+Ce;Ie<we&&R.current.setSelection(Ie,we);}}}}if(C.detail===3&&R.current){let j=st(C.clientX,C.clientY);if(j!==null){let U=R.current.getView();if(U){let{doc:re}=U.state,K=re.resolve(j),Q=K.start(K.depth),oe=K.end(K.depth);R.current.setSelection(Q,oe);}}}},[st,x,J]),Lr=Gp.useCallback(C=>{u||C.target.closest(".docx-comments-sidebar")||(R.current?.focus(),_(true));},[u]),Br=Gp.useCallback(C=>{let V=C.relatedTarget;V&&D.current?.contains(V)||_(false);},[]),Ua=Gp.useCallback((C,V,j)=>{let U=R.current?.getView();if(U)try{let re=U.state.doc.nodeAt(C);if(!re||re.type.name!=="image")return;let K=U.state.tr.setNodeMarkup(C,void 0,{...re.attrs,width:V,height:j});U.dispatch(K),R.current?.setNodeSelection(C);}catch{}},[]),Co=Gp.useCallback(()=>{ue.current=true;},[]),wo=Gp.useCallback(()=>{ue.current=false;},[]),Ar=Gp.useCallback((C,V,j)=>{let U=R.current?.getView();if(U)try{let re=U.state.doc.nodeAt(C);if(!re||re.type.name!=="image")return;if(re.attrs.displayMode==="float"||re.attrs.wrapType&&["square","tight","through"].includes(re.attrs.wrapType)){let Q=P.current?.querySelectorAll(".layout-page");if(!Q||Q.length===0)return;let oe=null;for(let dt of Q){let ut=dt.getBoundingClientRect();if(j>=ut.top&&j<=ut.bottom){oe=dt.querySelector(".layout-page-content");break}}if(oe||(oe=Q[Q.length-1].querySelector(".layout-page-content")),!oe)return;let le=oe.getBoundingClientRect(),xe=(V-le.left)/c,ye=(j-le.top)/c,Ce=914400/96,Ie=Math.round(xe*Ce),we=Math.round(ye*Ce),Le={horizontal:{posOffset:Ie,relativeTo:"margin"},vertical:{posOffset:we,relativeTo:"margin"}},Ve=U.state.tr.setNodeMarkup(C,void 0,{...re.attrs,position:Le});U.dispatch(Ve),R.current?.setNodeSelection(C);}else {let Q=st(V,j);if(Q===null||Q===C||Q===C+1)return;let oe=U.state.tr;if(Q<=C)oe=oe.delete(C,C+re.nodeSize),oe=oe.insert(Q,re),R.current?.setNodeSelection(Q);else {oe=oe.delete(C,C+re.nodeSize);let le=Q-re.nodeSize;oe=oe.insert(Math.min(le,oe.doc.content.size),re),R.current?.setNodeSelection(Math.min(le,oe.doc.content.size-1));}U.dispatch(oe);}}catch{}},[st,c]),Gt=Gp.useCallback(()=>{ue.current=true;},[]),qt=Gp.useCallback(()=>{ue.current=false;},[]),Xo=Gp.useCallback(C=>{if(!u){if(R.current?.isFocused()||(R.current?.focus(),_(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey&&!C.nativeEvent.isComposing){C.preventDefault();let V=R.current?.getView();if(V){let{from:j,to:U}=V.state.selection;V.someProp("handleTextInput",K=>K(V,j,U," "))||V.dispatch(V.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)){let V=de();V&&(V.scrollTop=0);}if(C.key==="End"&&(C.metaKey||C.ctrlKey)){let V=de();V&&(V.scrollTop=V.scrollHeight);}}},[u,de]),ro=Gp.useCallback(C=>{u||C.target.closest(".docx-comments-sidebar")||R.current?.isFocused()||(R.current?.focus(),_(true));},[u]),Ka=Gp.useCallback(C=>{It(C.state),Ht(C.state),u||requestAnimationFrame(()=>{C.focus(),_(true);});},[It,Ht,u]);Gp.useEffect(()=>{let C=()=>{let V=R.current?.getView();V&&(chunkOJ7NJK46_cjs.f(),rl(),It(V.state),Ht(V.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let Dr=Gp.useRef(0);Gp.useEffect(()=>{if(Dr.current===0){Dr.current=1;return}let C=R.current?.getView();C&&It(C.state);},[s,l,It]),Gp.useEffect(()=>{let C=D.current;if(!C)return;let V=new ResizeObserver(()=>{let j=R.current?.getState();j&&Ht(j);});return V.observe(C),()=>V.disconnect()},[Ht]),Gp.useImperativeHandle(n,()=>({getDocument(){return R.current?.getDocument()??null},getState(){return R.current?.getState()??null},getView(){return R.current?.getView()??null},focus(){R.current?.focus(),_(true);},blur(){R.current?.blur(),_(false);},isFocused(){return R.current?.isFocused()??false},dispatch(C){R.current?.dispatch(C);},undo(){return R.current?.undo()??false},redo(){return R.current?.redo()??false},setSelection(C,V){R.current?.setSelection(C,V);},getLayout(){return k},relayout(){let C=R.current?.getState();C&&It(C);},scrollToPosition:Kt}),[k,It,Kt]),Gp.useEffect(()=>{let C=R.current?.getState();k&&C&&Ht(C);},[k,Ht]),Gp.useEffect(()=>{w.current&&R.current&&w.current({getDocument:()=>R.current?.getDocument()??null,getState:()=>R.current?.getState()??null,getView:()=>R.current?.getView()??null,focus:()=>{R.current?.focus(),_(true);},blur:()=>{R.current?.blur(),_(false);},isFocused:()=>R.current?.isFocused()??false,dispatch:C=>R.current?.dispatch(C),undo:()=>R.current?.undo()??false,redo:()=>R.current?.redo()??false,setSelection:(C,V)=>R.current?.setSelection(C,V),getLayout:()=>k,relayout:()=>{let C=R.current?.getState();C&&It(C);},scrollToPosition:Kt});},[k,It]);let Ga=Gp.useMemo(()=>{if(!k)return $p+48;let C=k.pages.length;return C*Rt.h+(C-1)*d+48},[k,Rt.h,d]);return jsxRuntime.jsxs("div",{ref:D,className:`ep-root paged-editor ${F??""}`,style:{...ax,...G},tabIndex:0,onFocus:Lr,onBlur:Br,onKeyDown:Xo,onMouseDown:ro,children:[jsxRuntime.jsx(qu,{ref:R,document:o,styles:r,widthPx:Cn,readOnly:u,onTransaction:Go,onSelectionChange:To,externalPlugins:f,extensionManager:b,onEditorViewReady:Ka,onKeyDown:pe}),jsxRuntime.jsxs("div",{style:{...sx,minHeight:Ga,transform:(()=>{let C=[];return Y&&C.push("translateX(-120px)"),c!==1&&C.push(`scale(${c})`),C.length>0?C.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:P,className:`paged-editor__pages${u?" paged-editor--readonly":""}${z?` paged-editor--hf-editing paged-editor--editing-${z}`:""}`,style:lx,onMouseDown:Ir,onMouseMove:ja,onClick:Tt,"aria-hidden":"true"}),jsxRuntime.jsx(Xu,{selectionRects:ne,caretPosition:I,isFocused:$,pageGap:d,readOnly:u}),jsxRuntime.jsx(tp,{imageInfo:O,zoom:c,isFocused:$,onResize:Ua,onResizeStart:Co,onResizeEnd:wo,onDragMove:Ar,onDragStart:Gt,onDragEnd:qt}),tn&&jsxRuntime.jsx("button",{type:"button",onMouseDown:kt,onMouseEnter:An,onMouseLeave:()=>nn(null),style:{position:"absolute",left:tn.x,top:tn.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:tn.type==="row"?"Insert row below":"Insert column to the right","aria-label":tn.type==="row"?"Insert row below":"Insert column to the right",children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),T&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:cx,children:T})]}),N]})}),jp=Gp.memo(yx);var Tx=Gp.lazy(()=>import('./FindReplaceDialog-J3DI3U5I.cjs')),Cx=Gp.lazy(()=>import('./HyperlinkDialog-PEPS3C2G.cjs')),wx=Gp.lazy(()=>import('./TablePropertiesDialog-A36OXG3A.cjs').then(e=>({default:e.TablePropertiesDialog}))),vx=Gp.lazy(()=>import('./ImagePositionDialog-UYXYHSP4.cjs').then(e=>({default:e.ImagePositionDialog}))),Rx=Gp.lazy(()=>import('./ImagePropertiesDialog-V6SVKINO.cjs').then(e=>({default:e.ImagePropertiesDialog}))),Ex=Gp.lazy(()=>import('./FootnotePropertiesDialog-DO5DCAW6.cjs').then(e=>({default:e.FootnotePropertiesDialog}))),Px=Gp.lazy(()=>import('./PageSetupDialog-RLMYJ3BA.cjs').then(e=>({default:e.PageSetupDialog}))),Up=[{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 Fx({mode:e,onModeChange:t}){let[n,o]=Gp.useState(false),[r,i]=Gp.useState(false),a=Gp.useRef(null),s=Gp.useRef(null),[l,u]=Gp.useState({top:0,left:0}),d=Up.find(c=>c.value===e);return Gp.useEffect(()=>{let c=window.matchMedia("(max-width: 1400px)");i(c.matches);let p=m=>i(m.matches);return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[]),Gp.useEffect(()=>{if(!n||!a.current)return;let c=a.current.getBoundingClientRect();u({top:c.bottom+2,left:c.right-220});},[n]),Gp.useEffect(()=>{if(!n)return;let c=m=>{!a.current?.contains(m.target)&&!s.current?.contains(m.target)&&o(false);},p=m=>{m.key==="Escape"&&o(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",p);}},[n]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:a,type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>o(!n),title:`${d.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:d.icon,size:18}),!r&&jsxRuntime.jsx("span",{children:d.label}),jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"arrow_drop_down",size:16})]}),n&&jsxRuntime.jsx("div",{ref:s,onMouseDown:c=>c.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:Up.map(c=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(c.value),o(false);},onMouseOver:p=>{p.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)";},onMouseOut:p=>{p.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text, #374151)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:c.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:c.label}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:c.desc})]}),c.value===e&&jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},c.value))})]})}var Lx=Date.now(),xl=-1;function Sl(e,t,n){return {id:Lx++,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 Kp=Gp.forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i,onSelectionChange:a,onError:s,onFontsLoaded:l,theme:u,showToolbar:d=true,showZoomControl:c=true,showMarginGuides:p=false,marginGuideColor:m,showRuler:f=false,rulerUnit:b="inch",initialZoom:g=1,readOnly:S=false,toolbarExtra:T,className:x="",style:z,placeholder:E,loadingIndicator:F,showOutline:G=false,showPrintButton:Y=true,printOptions:N,onPrint:H,onCopy:J,onCut:de,onPaste:D,mode:P,onModeChange:R,externalPlugins:me,onEditorViewReady:pe,onRenderedDomContextReady:Be,pluginOverlays:Me,renderLogo:We,documentName:w,onDocumentNameChange:A,documentNameEditable:k=true,renderTitleBarRight:M},B){let[v,q]=Gp.useState({isLoading:!!t,parseError:null,zoom:g,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[ae,$]=Gp.useState(false),[_,ne]=Gp.useState(false),[ge,I]=Gp.useState(false),[W,O]=Gp.useState(false),[X,ue]=Gp.useState(null),[fe,Fe]=Gp.useState(G),he=Gp.useRef(false);he.current=fe;let[Pe,be]=Gp.useState([]),[ot,rt]=Gp.useState(false),[je,Qe]=Gp.useState([]),[Ue,mt]=Gp.useState([]),[vt,Ne]=Gp.useState(false),[ct,He]=Gp.useState(null),[$t,Tn]=Gp.useState(null),[Ko,Er]=Gp.useState(P??"editing"),Bn=P??Ko,ko=y=>{P||Er(y),R?.(y);},bt=S||Bn==="viewing",[Ut,_t]=Gp.useState(null),en=Gp.useRef(null),Mt=Gp.useCallback(()=>{let y=ze.current?.getView();if(!y)return;let{doc:h,schema:L}=y.state,Z=L.marks.insertion,ee=L.marks.deletion;if(!Z&&!ee)return;let ie=[];h.descendants((se,ke)=>{if(se.isText)for(let ve of se.marks)(ve.type===Z||ve.type===ee)&&ie.push({type:ve.type===Z?"insertion":"deletion",text:se.text||"",author:ve.attrs.author||"",date:ve.attrs.date,from:ke,to:ke+se.nodeSize,revisionId:ve.attrs.revisionId});});let te=[];for(let se of ie){let ke=te[te.length-1];ke&&ke.revisionId===se.revisionId&&ke.type===se.type&&ke.to===se.from?(ke.text+=se.text,ke.to=se.to):te.push({...se});}mt(te);},[]);Gp.useEffect(()=>()=>{en.current&&clearTimeout(en.current);},[]),Gp.useEffect(()=>{if(Fe(G),G){let y=ze.current?.getView();y&&be(Mo(y.state.doc));}},[G]);let ce=zu(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),tn=Gp.useRef(false);Gp.useEffect(()=>{if(tn.current)return;let y=ce.state;if(!y)return;let h=y.package?.document?.comments;h&&h.length>0&&(Qe(h),rt(true),tn.current=true);},[ce.state]);let nn=Gp.useMemo(()=>{let y=new zn(Do());return y.buildSchema(),y.initializeRuntime(),y},[]),on=Gp.useMemo(()=>Wu(false,r),[]),An=Gp.useMemo(()=>[on,...me??[]],[on,me]),ze=Gp.useRef(null),Rt=Gp.useRef(null),yt=Gp.useRef(null),Wt=Gp.useRef(null),Cn=Gp.useRef(null),Pr=Gp.useRef(null),It=Gp.useRef(null),Dt=Gp.useRef(null),Mr=Gp.useRef(null),Dn=Gp.useRef(null),[Ht,Go]=Gp.useState(0),To=Gp.useRef(ce.state);To.current=ce.state;let st=Gp.useRef({style:"single",size:4,color:{rgb:"000000"}}),wn=Gp.useRef(null),qo=Gp.useCallback(y=>{let h=wn.current;if(h&&h.styles===y)return h.resolver;let L=mo(y);return wn.current={styles:y,resolver:L},L},[]),[Kt,Ir]=Gp.useState({currentPage:1,totalPages:1,visible:false}),oo=Gp.useRef(null),Fr=Gp.useCallback(y=>{if(Mr.current=y,Dn.current&&(Dn.current.disconnect(),Dn.current=null),!y){Go(0);return}Go(y.offsetHeight);let h=new ResizeObserver(()=>{Go(y.offsetHeight);});h.observe(y),Dn.current=h;},[]);Gp.useEffect(()=>()=>{Dn.current?.disconnect();},[]);let Ae=Gp.useCallback(()=>X&&Rt.current?Rt.current.getView():ze.current?.getView(),[X]),qe=Gp.useCallback(()=>{X&&Rt.current?Rt.current.focus():ze.current?.focus();},[X]),Yo=Gp.useCallback(()=>{X&&Rt.current?Rt.current.undo():ze.current?.undo();},[X]),ja=Gp.useCallback(()=>{X&&Rt.current?Rt.current.redo():ze.current?.redo();},[X]),kt=chunkVTAS7VZ6_cjs.m(),Tt=chunkXS2AQFMF_cjs.m(),[Lr,Br]=Gp.useState(false),Ua=Gp.useCallback(()=>Br(true),[]),[Co,wo]=Gp.useState(null);Gp.useEffect(()=>{if(!t){n&&(ce.reset(n),q(h=>({...h,isLoading:false})),chunkCL62W2HQ_cjs.l(n).catch(h=>{console.warn("Failed to load document fonts:",h);}));return}q(h=>({...h,isLoading:true,parseError:null})),(async()=>{try{let h=await chunkCL62W2HQ_cjs.n(t);ce.reset(h),q(L=>({...L,isLoading:!1,parseError:null})),chunkCL62W2HQ_cjs.l(h).catch(L=>{console.warn("Failed to load document fonts:",L);});}catch(h){let L=h instanceof Error?h.message:"Failed to parse document";q(Z=>({...Z,isLoading:false,parseError:L})),s?.(h instanceof Error?h:new Error(L));}})();},[t,n,s]),Gp.useEffect(()=>{n&&!t&&ce.reset(n);},[n,t]),Gp.useEffect(()=>{ce.state?yt.current=new chunkNKW2UER2_cjs.f(ce.state):yt.current=null;},[ce.state]);let Ar=Gp.useRef(false);Gp.useEffect(()=>{if(!v.isLoading&&ce.state){let y=setTimeout(()=>{Mt(),Ar.current||(Ar.current=true,mt(h=>(h.length>0&&rt(true),h)));},200);return ()=>clearTimeout(y)}},[v.isLoading,ce.state,Mt]),Gp.useEffect(()=>chunkCL62W2HQ_cjs.h(()=>{l?.();}),[l]),Gp.useEffect(()=>{let y=ze.current?.getView();y&&Vu(Bn==="suggesting",y.state,y.dispatch,r);},[Bn,r]);let Gt=Gp.useCallback(y=>(ce.push(y),y),[ce]),qt=Gp.useCallback(y=>{if(Gt(y),i?.(y),he.current){let h=ze.current?.getView();h&&be(Mo(h.state.doc));}en.current&&clearTimeout(en.current),en.current=setTimeout(Mt,300);},[i,Gt,Mt]),Xo=Gp.useCallback(y=>{let h=Ae();if(h){let{from:tt,to:Ke}=h.state.selection;Cn.current={from:tt,to:Ke};}let L=null;if(h&&(L=Ge(h.state),L.isInTable||(L=null)),L?.cellBorderColor){let tt=L.cellBorderColor,Ke=tt.rgb;(!Ke||Ke==="auto")&&(Ke=chunkIA4LPH2A_cjs.a(tt,u).replace(/^#/,"")),st.current={...st.current,color:{rgb:Ke}};}let Z=null;if(h){let tt=h.state.selection,Ke=tt.node;Ke?.type.name==="image"&&(Z={pos:tt.from,wrapType:Ke.attrs.wrapType??"inline",displayMode:Ke.attrs.displayMode??"inline",cssFloat:Ke.attrs.cssFloat??null,transform:Ke.attrs.transform??null,alt:Ke.attrs.alt??null,borderWidth:Ke.attrs.borderWidth??null,borderColor:Ke.attrs.borderColor??null,borderStyle:Ke.attrs.borderStyle??null});}if(!y){_t(null),q(tt=>({...tt,selectionFormatting:{},pmTableContext:L,pmImageContext:Z}));return}let{textFormatting:ee,paragraphFormatting:ie}=y,te=ee.fontFamily?.ascii||ee.fontFamily?.hAnsi,se=ee.fontSize;if(!te||!se){let tt=To.current,Ke=ie.styleId;if(tt?.package.styles&&Ke){let St=qo(tt.package.styles).resolveParagraphStyle(Ke);!te&&St.runFormatting?.fontFamily&&(te=St.runFormatting.fontFamily.ascii||St.runFormatting.fontFamily.hAnsi),!se&&St.runFormatting?.fontSize&&(se=St.runFormatting.fontSize);}}let ke=ee.color?.rgb?`#${ee.color.rgb}`:void 0,ve=ie.numPr,it=ve?{type:ve.numId===1?"bullet":"numbered",level:ve.ilvl??0,isInList:true,numId:ve.numId}:void 0,et={bold:ee.bold,italic:ee.italic,underline:!!ee.underline,strike:ee.strike,superscript:ee.vertAlign==="superscript",subscript:ee.vertAlign==="subscript",fontFamily:te,fontSize:se,color:ke,highlight:ee.highlight,alignment:ie.alignment,lineSpacing:ie.lineSpacing,listState:it,styleId:y.styleId??void 0,indentLeft:ie.indentLeft,bidi:!!ie.bidi};if(q(tt=>({...tt,selectionFormatting:et,paragraphIndentLeft:ie.indentLeft??0,paragraphIndentRight:ie.indentRight??0,paragraphFirstLineIndent:ie.indentFirstLine??0,paragraphHangingIndent:ie.hangingIndent??false,paragraphTabs:ie.tabs??null,pmTableContext:L,pmImageContext:Z})),h&&y.hasSelection&&!vt&&!bt){let tt=Dt.current,Ke=It.current;if(tt&&Ke){let{from:Zt}=h.state.selection,St=tt.querySelector(".paged-editor__pages");if(St){let co=St.querySelector(".layout-page"),Or=St.querySelectorAll("span[data-pm-start]");for(let $r of Or){let _r=$r,Wr=Number(_r.dataset.pmStart),wf=Number(_r.dataset.pmEnd);if(Zt>=Wr&&Zt<=wf){let vf=_r.getBoundingClientRect(),Za=Ke.getBoundingClientRect(),Rf=vf.top-Za.top+tt.scrollTop,Ef=co?co.getBoundingClientRect().right-Za.left:Za.width/2+408;_t({top:Rf,left:Ef});break}}}}}else _t(null);a?.(y);},[a,vt,bt]),ro=yc({document:ce.state,onChange:qt,onSelectionChange:y=>{}});Gp.useEffect(()=>{let y=h=>{let Z=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!Z&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let ee=ze.current?.getView();if(ee){let ie=ee.state.selection;if("$anchorCell"in ie&&typeof ie.forEachCell=="function"){let se=Ge(ee.state);if(se.isInTable&&se.table){let ke=0;se.table.descendants(it=>{(it.type.name==="tableCell"||it.type.name==="tableHeader")&&(ke+=1);});let ve=0;if(ie.forEachCell(()=>{ve+=1;}),ke>0&&ve>=ke){h.preventDefault(),fr(ee.state,ee.dispatch);return}}}}if(ro.state.tableIndex!==null){h.preventDefault(),ro.handleAction("deleteTable");return}}if(Z&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let ee=window.getSelection(),ie=ee&&!ee.isCollapsed?ee.toString():"";kt.openFind(ie);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let ee=window.getSelection(),ie=ee&&!ee.isCollapsed?ee.toString():"";kt.openReplace(ie);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let ee=ze.current?.getView();if(ee){let ie=Lo(ee.state),te=Fo(ee.state);te?Tt.openEdit({url:te.href,displayText:ie,tooltip:te.tooltip}):Tt.openInsert(ie);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[kt,Tt,ro]);let Ka=Gp.useCallback((y,h)=>{let L=Ae();L&&(zi(y,h)(L.state,L.dispatch),qe());},[Ae,qe]),Dr=Gp.useCallback(()=>{let y=Ae();y&&(da(y.state,y.dispatch),qe());},[Ae,qe]),Ga=Gp.useCallback(()=>{let y=Ae();y&&(Ni(y.state,y.dispatch),qe());},[Ae,qe]),C=Gp.useCallback(()=>{Fe(y=>{if(!y){let h=ze.current?.getView();h&&be(Mo(h.state.doc));}return !y});},[]),V=Gp.useCallback(y=>{ze.current?.scrollToPosition(y),ze.current?.setSelection(y+1),ze.current?.focus();},[]),j=Gp.useCallback(()=>{Pr.current?.click();},[]),U=Gp.useCallback(y=>{let h=y.target.files?.[0];if(!h)return;let L=Ae();if(!L)return;let Z=new FileReader;Z.onload=()=>{let ee=Z.result,ie=new Image;ie.onload=()=>{let te=ie.naturalWidth,se=ie.naturalHeight,ke=612;if(te>ke){let Ke=ke/te;te=ke,se=Math.round(se*Ke);}let ve=`rId_img_${Date.now()}`,it=L.state.schema.nodes.image.create({src:ee,alt:h.name,width:te,height:se,rId:ve,wrapType:"inline",displayMode:"inline"}),{from:et}=L.state.selection,tt=L.state.tr.insert(et,it);L.dispatch(tt.scrollIntoView()),qe();},ie.src=ee;},Z.readAsDataURL(h),y.target.value="";},[Ae,qe]),re=Gp.useCallback(y=>{let h=Ae();if(!h||!v.pmImageContext)return;let L=v.pmImageContext.pos,Z=h.state.doc.nodeAt(L);if(!Z||Z.type.name!=="image")return;let ee="inline",ie=null;switch(y){case "inline":ee="inline",ie=null;break;case "square":case "tight":case "through":ee="float",ie="left";break;case "topAndBottom":ee="block",ie=null;break;case "behind":case "inFront":ee="float",ie="none";break;case "wrapLeft":ee="float",ie="right",y="square";break;case "wrapRight":ee="float",ie="left",y="square";break}let te=h.state.tr.setNodeMarkup(L,void 0,{...Z.attrs,wrapType:y,displayMode:ee,cssFloat:ie});h.dispatch(te.scrollIntoView()),qe();},[Ae,qe,v.pmImageContext]),K=Gp.useCallback(y=>{let h=Ae();if(!h||!v.pmImageContext)return;let L=v.pmImageContext.pos,Z=h.state.doc.nodeAt(L);if(!Z||Z.type.name!=="image")return;let ee=Z.attrs.transform||"",ie=ee.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),te=ie?parseFloat(ie[1]):0,se=/scaleX\(-1\)/.test(ee),ke=/scaleY\(-1\)/.test(ee);switch(y){case "rotateCW":te=(te+90)%360;break;case "rotateCCW":te=(te-90+360)%360;break;case "flipH":se=!se;break;case "flipV":ke=!ke;break}let ve=[];te!==0&&ve.push(`rotate(${te}deg)`),se&&ve.push("scaleX(-1)"),ke&&ve.push("scaleY(-1)");let it=ve.length>0?ve.join(" "):null,et=h.state.tr.setNodeMarkup(L,void 0,{...Z.attrs,transform:it});h.dispatch(et.scrollIntoView()),qe();},[Ae,qe,v.pmImageContext]),Q=Gp.useCallback(y=>{let h=Ae();if(!h||!v.pmImageContext)return;let L=v.pmImageContext.pos,Z=h.state.doc.nodeAt(L);if(!Z||Z.type.name!=="image")return;let ee=h.state.tr.setNodeMarkup(L,void 0,{...Z.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??Z.attrs.distTop,distBottom:y.distBottom??Z.attrs.distBottom,distLeft:y.distLeft??Z.attrs.distLeft,distRight:y.distRight??Z.attrs.distRight});h.dispatch(ee.scrollIntoView()),qe();},[Ae,qe,v.pmImageContext]),oe=Gp.useCallback(()=>{I(true);},[]),le=Gp.useCallback(y=>{let h=Ae();if(!h||!v.pmImageContext)return;let L=v.pmImageContext.pos,Z=h.state.doc.nodeAt(L);if(!Z||Z.type.name!=="image")return;let ee=h.state.tr.setNodeMarkup(L,void 0,{...Z.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});h.dispatch(ee.scrollIntoView()),qe();},[Ae,qe,v.pmImageContext]),xe=Gp.useCallback((y,h)=>{if(!ce.state?.package)return;let L={...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:h}};Gt({...ce.state,package:{...ce.state.package,document:L}});},[ce,Gt]),ye=Gp.useCallback(y=>{let h=Ae();if(h){switch(y){case "addRowAbove":Oi(h.state,h.dispatch);break;case "addRowBelow":No(h.state,h.dispatch);break;case "addColumnLeft":_i(h.state,h.dispatch);break;case "addColumnRight":zo(h.state,h.dispatch);break;case "deleteRow":$i(h.state,h.dispatch);break;case "deleteColumn":Wi(h.state,h.dispatch);break;case "deleteTable":fr(h.state,h.dispatch);break;case "selectTable":Vi(h.state,h.dispatch);break;case "selectRow":ji(h.state,h.dispatch);break;case "selectColumn":Ui(h.state,h.dispatch);break;case "mergeCells":Ki(h.state,h.dispatch);break;case "splitCell":Gi(h.state,h.dispatch);break;case "borderAll":Yi(h.state,h.dispatch,st.current);break;case "borderOutside":Xi(h.state,h.dispatch,st.current);break;case "borderInside":Zi(h.state,h.dispatch,st.current);break;case "borderNone":qi(h.state,h.dispatch);break;case "borderTop":On("top",st.current,true)(h.state,h.dispatch);break;case "borderBottom":On("bottom",st.current,true)(h.state,h.dispatch);break;case "borderLeft":On("left",st.current,true)(h.state,h.dispatch);break;case "borderRight":On("right",st.current,true)(h.state,h.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")sa(y.color)(h.state,h.dispatch);else if(y.type==="borderColor"){let L=y.color.replace(/^#/,"");st.current={...st.current,color:{rgb:L}},la(y.color)(h.state,h.dispatch);}else if(y.type==="borderWidth")st.current={...st.current,size:y.size},ca(y.size)(h.state,h.dispatch);else if(y.type==="cellBorder")On(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(y.type==="cellVerticalAlign")Ji(y.align)(h.state,h.dispatch);else if(y.type==="cellMargins")Qi(y.margins)(h.state,h.dispatch);else if(y.type==="cellTextDirection")ea(y.direction)(h.state,h.dispatch);else if(y.type==="toggleNoWrap")ta()(h.state,h.dispatch);else if(y.type==="rowHeight")na(y.height,y.rule)(h.state,h.dispatch);else if(y.type==="toggleHeaderRow")oa()(h.state,h.dispatch);else if(y.type==="distributeColumns")ra()(h.state,h.dispatch);else if(y.type==="autoFitContents")ia()(h.state,h.dispatch);else if(y.type==="openTableProperties")$(true);else if(y.type==="tableProperties")mr(y.props)(h.state,h.dispatch);else if(y.type==="applyTableStyle"){let L=Bu(y.styleId),Z=To.current;if(!L&&Z?.package.styles){let ie=qo(Z.package.styles).getStyle(y.styleId);if(ie){if(L={id:ie.styleId,name:ie.name??ie.styleId},ie.tblPr?.borders){let te=ie.tblPr.borders;L.tableBorders={};for(let se of ["top","bottom","left","right","insideH","insideV"]){let ke=te[se];ke&&(L.tableBorders[se]={style:ke.style,size:ke.size,color:ke.color?.rgb?{rgb:ke.color.rgb}:void 0});}}if(ie.tblStylePr){L.conditionals={};for(let te of ie.tblStylePr){let se={};if(te.tcPr?.shading?.fill&&(se.backgroundColor=`#${te.tcPr.shading.fill}`),te.tcPr?.borders){let ke={};for(let ve of ["top","bottom","left","right"]){let it=te.tcPr.borders[ve];it&&(ke[ve]={style:it.style,size:it.size,color:it.color?.rgb?{rgb:it.color.rgb}:void 0});}se.borders=ke;}te.rPr?.bold&&(se.bold=true),te.rPr?.color?.rgb&&(se.color=`#${te.rPr.color.rgb}`),L.conditionals[te.type]=se;}}L.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}L&&aa({styleId:L.id,tableBorders:L.tableBorders,conditionals:L.conditionals,look:L.look})(h.state,h.dispatch);}}else ro.handleAction(y);}qe();}},[ro,Ae,qe]),Ce=Gp.useCallback(y=>{let h=Ae();if(!h)return;h.focus();let L=h===ze.current?.getView(),{from:Z,to:ee}=h.state.selection,ie=Cn.current;if(L&&ie&&(Z!==ie.from||ee!==ie.to))try{let te=h.state.tr.setSelection(prosemirrorState.TextSelection.create(h.state.doc,ie.from,ie.to));h.dispatch(te);}catch(te){console.warn("Could not restore selection:",te);}if(y==="bold"){pi(h.state,h.dispatch);return}if(y==="italic"){fi(h.state,h.dispatch);return}if(y==="underline"){mi(h.state,h.dispatch);return}if(y==="strikethrough"){gi(h.state,h.dispatch);return}if(y==="superscript"){hi(h.state,h.dispatch);return}if(y==="subscript"){bi(h.state,h.dispatch);return}if(y==="bulletList"){Ii(h.state,h.dispatch);return}if(y==="numberedList"){Fi(h.state,h.dispatch);return}if(y==="indent"){Li(h.state,h.dispatch)||Ri()(h.state,h.dispatch);return}if(y==="outdent"){Bi(h.state,h.dispatch)||Ei()(h.state,h.dispatch);return}if(y==="clearFormatting"){ir(h.state,h.dispatch);return}if(y==="setRtl"){Di(h.state,h.dispatch);return}if(y==="setLtr"){Hi(h.state,h.dispatch);return}if(y==="insertLink"){let te=Lo(h.state),se=Fo(h.state);se?Tt.openEdit({url:se.href,displayText:te,tooltip:se.tooltip}):Tt.openInsert(te);return}if(typeof y=="object")switch(y.type){case "alignment":wi(y.value)(h.state,h.dispatch);break;case "textColor":{let te=y.value;typeof te=="string"?cr({rgb:te.replace("#","")})(h.state,h.dispatch):te.auto?yi(h.state,h.dispatch):cr(te)(h.state,h.dispatch);break}case "highlightColor":{let te=y.value?chunk7YCCCWUZ_cjs.z(y.value):"";xi(te||y.value)(h.state,h.dispatch);break}case "fontSize":Si(chunk7YCCCWUZ_cjs.i(y.value))(h.state,h.dispatch);break;case "fontFamily":ki(y.value)(h.state,h.dispatch);break;case "lineSpacing":vi(y.value)(h.state,h.dispatch);break;case "applyStyle":{let te=To.current,se=te?.package.styles?qo(te.package.styles):null;if(se){let ke=se.resolveParagraphStyle(y.value);pr(y.value,{paragraphFormatting:ke.paragraphFormatting,runFormatting:ke.runFormatting})(h.state,h.dispatch);}else pr(y.value)(h.state,h.dispatch);break}}},[Ae]),Ie=Gp.useCallback(y=>{q(h=>({...h,zoom:y}));},[]),we=Gp.useCallback(y=>{let h=Ae();if(!h)return;let L=y.url||"",Z=y.tooltip,{empty:ee}=h.state.selection;ee&&y.displayText?dr(y.displayText,L,Z)(h.state,h.dispatch):ee?y.displayText&&dr(y.displayText,L,Z)(h.state,h.dispatch):Ti(L,Z)(h.state,h.dispatch),Tt.close(),qe();},[Tt,Ae,qe]),Le=Gp.useCallback(()=>{let y=Ae();y&&(Ci(y.state,y.dispatch),qe());},[Ae,qe]),Ve=Gp.useCallback(()=>{Le(),Tt.close();},[Tt,Le]),dt=Gp.useCallback(y=>wo(y),[]),ut=Gp.useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),Yt=Gp.useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let h=document.createElement("textarea");h.value=y,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h);});},[]),Hn=Gp.useCallback((y,h)=>{let L=Ae();if(!L)return;let Z=L.state.schema.marks.hyperlink;if(!Z)return;let{$from:ee}=L.state.selection,ie=ee.marks().find(te=>te.type===Z);if(ie){let te=ee.parent,se=ee.start(),ke=[],ve=null;te.forEach((St,co)=>{let Or=se+co,$r=Or+St.nodeSize;(St.isText?St.marks.find(Wr=>Wr.type===Z&&Wr.attrs.href===ie.attrs.href):null)?ve?ve.end=$r:ve={start:Or,end:$r}:ve&&(ke.push(ve),ve=null);}),ve&&ke.push(ve);let it=ee.pos,et=ke.find(St=>St.start<=it&&it<=St.end);if(!et)return;let tt=L.state.tr,Ke=Z.create({href:h,tooltip:ie.attrs.tooltip}),Zt=L.state.schema.text(y,[...ee.marks().filter(St=>St.type!==Z),Ke]);tt.replaceWith(et.start,et.end,Zt),L.dispatch(tt.scrollIntoView());}wo(null),qe();},[Ae,qe]),pn=Gp.useCallback(()=>{let y=Ae();if(!y)return;let h=y.state.schema.marks.hyperlink;if(!h)return;let{$from:L}=y.state.selection,Z=L.marks().find(et=>et.type===h);if(!Z&&L.nodeAfter&&(Z=L.nodeAfter.marks.find(et=>et.type===h)),!Z&&L.nodeBefore&&(Z=L.nodeBefore.marks.find(et=>et.type===h)),!Z&&Co&&L.parent.forEach(tt=>{if(!Z&&tt.isText){let Ke=tt.marks.find(Zt=>Zt.type===h&&Zt.attrs.href===Co.href);Ke&&(Z=Ke);}}),!Z)return;let ee=L.parent,ie=L.start(),te=[],se=null;ee.forEach((et,tt)=>{let Ke=ie+tt,Zt=Ke+et.nodeSize;(et.isText?et.marks.find(co=>co.type===h&&co.attrs.href===Z.attrs.href):null)?se?se.end=Zt:se={start:Ke,end:Zt}:se&&(te.push(se),se=null);}),se&&te.push(se);let ke=L.pos,ve=te.find(et=>et.start<=ke&&ke<=et.end);if(!ve)return;let it=y.state.tr;it.removeMark(ve.start,ve.end,h),y.dispatch(it.scrollIntoView()),wo(null),qe(),sonner.toast("Link removed");},[Ae,qe,Co]),io=Gp.useCallback(()=>{wo(null);},[]),Xt=Gp.useCallback(y=>h=>{if(!ce.state||bt)return;let L={...ce.state,package:{...ce.state.package,document:{...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,[y]:h}}}};qt(L);},[ce.state,bt,qt]),qa=Gp.useMemo(()=>Xt("marginLeft"),[Xt]),Zo=Gp.useMemo(()=>Xt("marginRight"),[Xt]),Hr=Gp.useMemo(()=>Xt("marginTop"),[Xt]),rn=Gp.useMemo(()=>Xt("marginBottom"),[Xt]),ao=Gp.useCallback(y=>{if(!ce.state||bt)return;let h={...ce.state,package:{...ce.state.package,document:{...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,...y}}}};qt(h);},[ce.state,bt,qt]),fn=Gp.useCallback(y=>{let h=Ae();h&&Pi(y)(h.state,h.dispatch);},[Ae]),so=Gp.useCallback(y=>{let h=Ae();h&&Mi(y)(h.state,h.dispatch);},[Ae]),lo=Gp.useCallback(y=>{let h=Ae();h&&(y<0?ur(-y,true)(h.state,h.dispatch):ur(y,false)(h.state,h.dispatch));},[Ae]),Ya=Gp.useCallback(y=>{let h=Ae();h&&Ai(y)(h.state,h.dispatch);},[Ae]),vo=Dt.current;Gp.useEffect(()=>{if(!vo)return;let y=()=>{let h=ze.current?.getLayout();if(!h||h.pages.length===0)return;let L=vo.scrollTop,Z=h.pages.length,ee=24,ie=24,te=L+vo.clientHeight/2,se=ie,ke=1;for(let ve=0;ve<h.pages.length;ve++){let it=h.pages[ve].size.h,et=se+it;if(te<et){ke=ve+1;break}se=et+ee,ke=ve+2;}ke=Math.min(ke,Z),Ir({currentPage:ke,totalPages:Z,visible:true}),oo.current&&clearTimeout(oo.current),oo.current=setTimeout(()=>{Ir(ve=>({...ve,visible:false}));},600);};return vo.addEventListener("scroll",y,{passive:true}),()=>{vo.removeEventListener("scroll",y),oo.current&&clearTimeout(oo.current);}},[vo]);let wl=Gp.useCallback(async y=>{if(!yt.current)return null;try{let h=yt.current.getDocument(),L=ze.current?.getDocument();L?.package?.document&&(h.package.document.content=L.package.document.content),h.package.document.comments=je;let Z=y?.selective!==!1,ee=ze.current?.getView(),ie;if(Z&&ee){let se=ee.state;ie={selective:{changedParaIds:Ud(se),structuralChange:Kd(se),hasUntrackedChanges:Gd(se)}};}let te=await yt.current.toBuffer(ie);return ee&&ee.dispatch(qd(ee.state)),o?.(te),te}catch(h){return s?.(h instanceof Error?h:new Error("Failed to save document")),null}},[o,s,je]),uf=Gp.useCallback(y=>{s?.(y);},[s]),Nr=Gp.useCallback(()=>{let y=Wt.current?.querySelector(".paged-editor__pages");if(!y){window.print(),H?.();return}let h=window.open("","_blank");if(!h){window.print(),H?.();return}let L=[];for(let ee of Array.from(document.styleSheets))try{for(let ie of Array.from(ee.cssRules))ie instanceof CSSFontFaceRule&&L.push(ie.cssText);}catch{}let Z=y.cloneNode(true);Z.style.cssText="display: block; margin: 0; padding: 0;";for(let ee of Array.from(Z.querySelectorAll(".layout-page"))){let ie=ee;ie.style.boxShadow="none",ie.style.margin="0";}h.document.write(`<!DOCTYPE html>
|
|
19
|
+
<html><head><title>Print</title>
|
|
20
|
+
<style>
|
|
21
|
+
${L.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>${Z.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),H?.();},[H]),Nt=Gp.useRef(null),pf=Gp.useCallback((y,h)=>{if(!ce.state||!y.trim())return Nt.current=null,null;let L=chunkVTAS7VZ6_cjs.j(ce.state,y,h),Z={matches:L,totalCount:L.length,currentIndex:0};return Nt.current=Z,kt.setMatches(L,0),L.length>0&&Wt.current&&chunkVTAS7VZ6_cjs.l(Wt.current,L[0]),Z},[ce.state,kt]),ff=Gp.useCallback(()=>{if(!Nt.current||Nt.current.matches.length===0)return null;let y=kt.goToNextMatch(),h=Nt.current.matches[y];return h&&Wt.current&&chunkVTAS7VZ6_cjs.l(Wt.current,h),h||null},[kt]),mf=Gp.useCallback(()=>{if(!Nt.current||Nt.current.matches.length===0)return null;let y=kt.goToPreviousMatch(),h=Nt.current.matches[y];return h&&Wt.current&&chunkVTAS7VZ6_cjs.l(Wt.current,h),h||null},[kt]),gf=Gp.useCallback(y=>{if(!ce.state||!Nt.current||Nt.current.matches.length===0)return false;let h=Nt.current.matches[Nt.current.currentIndex];if(!h)return false;try{let L=chunkP7ZF45KZ_cjs.a(ce.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:y});return qt(L),!0}catch(L){return console.error("Replace failed:",L),false}},[ce.state,qt]),hf=Gp.useCallback((y,h,L)=>{if(!ce.state||!y.trim())return 0;let Z=chunkVTAS7VZ6_cjs.j(ce.state,y,L);if(Z.length===0)return 0;let ee=ce.state,ie=[...Z].sort((te,se)=>te.paragraphIndex!==se.paragraphIndex?se.paragraphIndex-te.paragraphIndex:se.startOffset-te.startOffset);for(let te of ie)try{ee=chunkP7ZF45KZ_cjs.a(ee,{type:"replaceText",range:{start:{paragraphIndex:te.paragraphIndex,offset:te.startOffset},end:{paragraphIndex:te.paragraphIndex,offset:te.endOffset}},text:h});}catch(se){console.error("Replace failed for match:",te,se);}return qt(ee),Nt.current=null,kt.setMatches([],0),Z.length},[ce.state,qt,kt]);Gp.useImperativeHandle(B,()=>({getAgent:()=>yt.current,getDocument:()=>ce.state,getEditorRef:()=>ze.current,save:wl,setZoom:y=>q(h=>({...h,zoom:y})),getZoom:()=>v.zoom,focus:()=>{ze.current?.focus();},getCurrentPage:()=>Kt.currentPage,getTotalPages:()=>Kt.totalPages,scrollToPage:y=>{},openPrintPreview:Nr,print:Nr}),[ce.state,v.zoom,Kt,wl,Nr]);let{headerContent:Jo,footerContent:Qo}=Gp.useMemo(()=>{if(!ce.state?.package)return {headerContent:null,footerContent:null};let y=ce.state.package,h=y.document?.finalSectionProperties,L=y.headers,Z=y.footers,ee=null,ie=null;if(L&&h?.headerReferences){let te=h.headerReferences.find(se=>se.type==="default");te?.rId&&(ee=L.get(te.rId)??null);}if(Z&&h?.footerReferences){let te=h.footerReferences.find(se=>se.type==="default");te?.rId&&(ie=Z.get(te.rId)??null);}return {headerContent:ee,footerContent:ie}},[ce.state]),bf=Gp.useCallback(y=>{if(y==="header"?Jo:Qo){ue(y);return}if(!ce.state?.package)return;let L=ce.state.package,Z=L.document?.finalSectionProperties;if(!Z)return;let ee=`rId_new_${y}`,ie={type:y==="header"?"header":"footer",hdrFtrType:"default",content:[{type:"paragraph",content:[]}]},te=y==="header"?"headers":"footers",se=new Map(L[te]??[]);se.set(ee,ie);let ke=y==="header"?"headerReferences":"footerReferences",ve=Z[ke]??[],it={type:"default",rId:ee},et={...ce.state,package:{...L,[te]:se,document:L.document?{...L.document,finalSectionProperties:{...Z,[ke]:[...ve,it]}}:L.document}};Gt(et),ue(y);},[Jo,Qo,ce,Gt]),Xa=Gp.useCallback(y=>{if(!X||!ce.state?.package){ue(null);return}let h=ce.state.package,L=h.document?.finalSectionProperties,ee=(X==="header"?L?.headerReferences:L?.footerReferences)?.find(se=>se.type==="default"),ie=X==="header"?"headers":"footers",te=h[ie];if(ee?.rId&&te){let se=te.get(ee.rId),ke={type:X,hdrFtrType:"default",...se,content:y},ve=new Map(te);ve.set(ee.rId,ke);let it={...ce.state,package:{...h,[ie]:ve}};Gt(it);}ue(null);},[X,ce,Gt]),yf=Gp.useCallback(()=>{if(!X)return;let y=Rt.current?.getView();if(y){let h=lr(y.state.doc);Xa(h);}else ue(null);},[X,Xa]),xf=Gp.useCallback(()=>{if(!X||!ce.state?.package){ue(null);return}let y=ce.state.package,h=y.document?.finalSectionProperties,L=X==="header"?"headerReferences":"footerReferences",Z=X==="header"?"headers":"footers",ee=h?.[L],ie=ee?.find(te=>te.type==="default");if(ie?.rId){let te=new Map(y[Z]??[]);te.delete(ie.rId);let se=(ee??[]).filter(ve=>ve.rId!==ie.rId),ke={...ce.state,package:{...y,[Z]:te,document:y.document?{...y.document,finalSectionProperties:{...h,[L]:se}}:y.document}};Gt(ke);}ue(null);},[X,ce,Gt]),Sf=Gp.useCallback(y=>{let h=Wt.current?.querySelector(".paged-editor__pages");if(!h)return null;let L=y==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(L)},[]),zr={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...z},kf={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Tf={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};if(v.isLoading)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-loading ${x}`,style:zr,"data-testid":"docx-editor",children:F||jsxRuntime.jsx(Au,{})});if(v.parseError)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-error ${x}`,style:zr,"data-testid":"docx-editor",children:jsxRuntime.jsx(Hu,{message:v.parseError})});if(!ce.state)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-empty ${x}`,style:zr,"data-testid":"docx-editor",children:E||jsxRuntime.jsx(Du,{})});let Cf=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunk7YCCCWUZ_cjs.C,{}),jsxRuntime.jsx(chunk7YCCCWUZ_cjs.A,{onClick:()=>rt(!ot),active:ot,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"comment",size:20})}),jsxRuntime.jsx(chunk7YCCCWUZ_cjs.C,{}),jsxRuntime.jsx(Fx,{mode:Bn,onModeChange:y=>{ko(y),y==="suggesting"&&rt(true);}}),T]});return jsxRuntime.jsx(hc,{children:jsxRuntime.jsx(Zr,{onError:uf,children:jsxRuntime.jsxs("div",{ref:Wt,className:`ep-root docx-editor ${x}`,style:zr,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:kf,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[d&&!S&&jsxRuntime.jsxs("div",{ref:Fr,className:"z-50 flex flex-col gap-0 bg-white shadow-sm flex-shrink-0",children:[jsxRuntime.jsxs(zt,{currentFormatting:v.selectionFormatting,onFormat:Ce,onUndo:Yo,onRedo:ja,canUndo:true,canRedo:true,disabled:bt,documentStyles:ce.state?.package.styles?.styles,theme:ce.state?.package.theme||u,showPrintButton:Y,onPrint:Nr,showZoomControl:c,zoom:v.zoom,onZoomChange:Ie,onRefocusEditor:qe,onInsertTable:Ka,showTableInsert:true,onInsertImage:j,onInsertPageBreak:Dr,onInsertTOC:Ga,imageContext:v.pmImageContext,onImageWrapType:re,onImageTransform:K,onOpenImageProperties:oe,onPageSetup:Ua,tableContext:v.pmTableContext,onTableAction:ye,children:[jsxRuntime.jsxs(zt.TitleBar,{children:[We&&jsxRuntime.jsx(zt.Logo,{children:We()}),w!==void 0&&jsxRuntime.jsx(zt.DocumentName,{value:w,onChange:A,editable:k}),M&&jsxRuntime.jsx(zt.TitleBarRight,{children:M()}),jsxRuntime.jsx(zt.MenuBar,{})]}),jsxRuntime.jsx(zt.FormattingBar,{children:Cf})]}),f&&jsxRuntime.jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:ot?"calc(20px + 240px)":void 0,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.E,{sectionProps:ce.state?.package.document?.finalSectionProperties,zoom:v.zoom,unit:b,editable:!bt,onLeftMarginChange:qa,onRightMarginChange:Zo,indentLeft:v.paragraphIndentLeft,indentRight:v.paragraphIndentRight,onIndentLeftChange:fn,onIndentRightChange:so,showFirstLineIndent:true,firstLineIndent:v.paragraphFirstLineIndent,hangingIndent:v.paragraphHangingIndent,onFirstLineIndentChange:lo,tabStops:v.paragraphTabs,onTabStopRemove:Ya})})]}),jsxRuntime.jsx("div",{ref:Dt,style:Tf,children:jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxRuntime.jsxs("div",{ref:It,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y=>{y.target===y.currentTarget&&(y.preventDefault(),ze.current?.focus());},children:[f&&!S&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsxRuntime.jsx(Ic,{sectionProps:ce.state?.package.document?.finalSectionProperties,zoom:v.zoom,unit:b,editable:!bt,onTopMarginChange:Hr,onBottomMarginChange:rn})}),jsxRuntime.jsx(jp,{ref:ze,document:ce.state,styles:ce.state?.package.styles,theme:ce.state?.package.theme||u,sectionProperties:ce.state?.package.document?.finalSectionProperties,headerContent:Jo,footerContent:Qo,onHeaderFooterDoubleClick:bf,hfEditMode:X,onBodyClick:yf,zoom:v.zoom,readOnly:bt,extensionManager:nn,onDocumentChange:qt,onSelectionChange:(y,h)=>{let L=ze.current?.getView();if(L){let Z=Ho(L.state);Xo(Z);}else Xo(null);},externalPlugins:An,onReady:y=>{pe?.(y.getView());},onRenderedDomContextReady:Be,pluginOverlays:Me,onHyperlinkClick:dt,commentsSidebarOpen:ot,scrollContainerRef:Dt,sidebarOverlay:ot?jsxRuntime.jsx(vc,{comments:je,trackedChanges:Ue,pageWidth:(()=>{let y=ce.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),editorContainerRef:Dt,onCommentResolve:y=>{Qe(h=>h.map(L=>L.id===y?{...L,done:true}:L));},onCommentDelete:y=>{Qe(h=>h.filter(L=>L.id!==y&&L.parentId!==y));},onCommentReply:(y,h)=>{Qe(L=>[...L,Sl(h,r,y)]);},onAddComment:y=>{let h=Sl(y,r),L=ze.current?.getView();if(L&&ct){let{from:Z,to:ee}=ct,ie=L.state.schema.marks.comment.create({commentId:xl}),te=L.state.schema.marks.comment.create({commentId:h.id}),se=L.state.tr.removeMark(Z,ee,ie).addMark(Z,ee,te);L.dispatch(se);}Qe(Z=>[...Z,h]),Ne(false),He(null),Tn(null);},onTrackedChangeReply:(y,h)=>{Qe(L=>[...L,Sl(h,r,y)]);},onCancelAddComment:()=>{let y=ze.current?.getView();if(y&&ct){let{from:h,to:L}=ct,Z=y.state.schema.marks.comment.create({commentId:xl});y.dispatch(y.state.tr.removeMark(h,L,Z));}Ne(false),He(null),Tn(null);},onAcceptChange:(y,h)=>{let L=ze.current?.getView();L&&(zs(y,h)(L.state,L.dispatch),Mt());},onRejectChange:(y,h)=>{let L=ze.current?.getView();L&&(Os(y,h)(L.state,L.dispatch),Mt());},isAddingComment:vt,addCommentYPosition:$t,topOffset:0}):void 0}),Ut!=null&&!vt&&!bt&&jsxRuntime.jsx(chunk7YCCCWUZ_cjs.c,{content:"Add comment",side:"bottom",delayMs:300,children:jsxRuntime.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),y.stopPropagation();let h=ze.current?.getView();if(h){let{from:L,to:Z}=h.state.selection;if(L!==Z){He({from:L,to:Z});let ee=h.state.schema.marks.comment.create({commentId:xl}),ie=h.state.tr.addMark(L,Z,ee);ie.setSelection(prosemirrorState.TextSelection.create(ie.doc,Z)),h.dispatch(ie);}}Tn(Ut.top),ot||rt(true),Ne(true),_t(null);},style:{position:"absolute",top:Ut.top,left:Ut.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:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"add_comment",size:16})})}),X&&(X==="header"?Jo:Qo)&&(()=>{let y=Sf(X),h=It.current;return !y||!h?null:jsxRuntime.jsx(Eu,{ref:Rt,headerFooter:X==="header"?Jo:Qo,position:X,styles:ce.state?.package.styles,targetElement:y,parentElement:h,onSave:Xa,onClose:()=>ue(null),onSelectionChange:Xo,onRemove:xf})})()]})})}),Kt.totalPages>1&&jsxRuntime.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:Kt.visible?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:[Kt.currentPage," of ",Kt.totalPages]}),fe&&jsxRuntime.jsx(Sc,{headings:Pe,onHeadingClick:V,onClose:()=>Fe(false),topOffset:Ht}),!fe&&jsxRuntime.jsx("button",{className:"docx-outline-nav",onClick:C,onMouseDown:y=>y.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:Ht+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(chunk7YCCCWUZ_cjs.d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]})}),jsxRuntime.jsx(Lu,{data:Co,onNavigate:ut,onCopy:Yt,onEdit:Hn,onRemove:pn,onClose:io,readOnly:bt}),jsxRuntime.jsx(sonner.Toaster,{position:"bottom-right"}),jsxRuntime.jsxs(Gp.Suspense,{fallback:null,children:[kt.state.isOpen&&jsxRuntime.jsx(Tx,{isOpen:kt.state.isOpen,onClose:kt.close,onFind:pf,onFindNext:ff,onFindPrevious:mf,onReplace:gf,onReplaceAll:hf,initialSearchText:kt.state.searchText,replaceMode:kt.state.replaceMode,currentResult:Nt.current}),Tt.state.isOpen&&jsxRuntime.jsx(Cx,{isOpen:Tt.state.isOpen,onClose:Tt.close,onSubmit:we,onRemove:Tt.state.isEditing?Ve:void 0,initialData:Tt.state.initialData,selectedText:Tt.state.selectedText,isEditing:Tt.state.isEditing}),ae&&jsxRuntime.jsx(wx,{isOpen:ae,onClose:()=>$(false),onApply:y=>{let h=Ae();h&&mr(y)(h.state,h.dispatch);},currentProps:v.pmTableContext?.table?.attrs}),_&&jsxRuntime.jsx(vx,{isOpen:_,onClose:()=>ne(false),onApply:Q}),ge&&jsxRuntime.jsx(Rx,{isOpen:ge,onClose:()=>I(false),onApply:le,currentData:v.pmImageContext?{alt:v.pmImageContext.alt??void 0,borderWidth:v.pmImageContext.borderWidth??void 0,borderColor:v.pmImageContext.borderColor??void 0,borderStyle:v.pmImageContext.borderStyle??void 0}:void 0}),Lr&&jsxRuntime.jsx(Px,{isOpen:Lr,onClose:()=>Br(false),onApply:ao,currentProps:ce.state?.package.document?.finalSectionProperties}),W&&jsxRuntime.jsx(Ex,{isOpen:W,onClose:()=>O(false),onApply:xe,footnotePr:ce.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:ce.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsxRuntime.jsx("input",{ref:Pr,type:"file",accept:"image/*",style:{display:"none"},onChange:U})]})})})});function tP(e,t,n={}){return new Promise((o,r)=>{let i=Gp__default.default.createRef(),a=null;try{a=client.createRoot(t);}catch(d){r(d);return}let s={save:async()=>{let d=await(i.current?.save()??Promise.resolve(null));return d?new Blob([d],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:d=>i.current?.setZoom(d),destroy:()=>{a?.unmount(),a=null;}},l=false,u=Gp__default.default.createElement(Kp,{...n,documentBuffer:e,onError:d=>{n.onError?.(d),l||(l=true,r(d));},onChange:d=>{n.onChange?.(d),l||(l=true,o(s));},ref:i});a.render(u);})}function dP(e,t={}){let{storageKey:n,interval:o,enabled:r=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:d}=t,c=Gp.useMemo(()=>new chunk2VHQ7YOQ_cjs.r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:d,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);Gp.useEffect(()=>{r?(c.enable(),c.startInterval()):c.disable();},[c,r]),Gp.useEffect(()=>{c.onDocumentChanged(e??null);},[c,e]),Gp.useEffect(()=>()=>{c.destroy();},[c]);let p=Gp.useSyncExternalStore(c.subscribe,c.getSnapshot),m=Gp.useCallback(()=>c.save(),[c]),f=Gp.useCallback(()=>c.clear(),[c]),b=Gp.useCallback(()=>c.getRecoveryData(),[c]),g=Gp.useCallback(()=>c.acceptRecovery(),[c]),S=Gp.useCallback(()=>c.dismissRecovery(),[c]),T=Gp.useCallback(()=>c.enable(),[c]),x=Gp.useCallback(()=>c.disable(),[c]);return {status:p.status,lastSaveTime:p.lastSaveTime,save:m,clearAutoSave:f,hasRecoveryData:p.hasRecoveryData,getRecoveryData:b,acceptRecovery:g,dismissRecovery:S,isEnabled:p.isEnabled,enable:T,disable:x}}var Ox=1,qp=.25,Yp=4,$x=.1,dn=[.25,.5,.75,1,1.25,1.5,2,3,4];function Xp(e,t,n){return Math.max(t,Math.min(n,e))}function Zp(e){return Math.round(e*100)/100}function _x(e){let t=dn[0],n=Math.abs(e-t);for(let o of dn){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function Wx(e){for(let t of dn)if(t>e+.01)return t;return dn[dn.length-1]}function Vx(e){for(let t=dn.length-1;t>=0;t--)if(dn[t]<e-.01)return dn[t];return dn[0]}function fP(e={}){let{initialZoom:t=Ox,minZoom:n=qp,maxZoom:o=Yp,zoomStep:r=$x,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[d,c]=Gp.useState(t),p=Gp.useRef(d);Gp.useEffect(()=>{p.current=d;},[d]);let m=Gp.useCallback(E=>{let F=Zp(Xp(E,n,o));F!==p.current&&(c(F),s?.(F));},[n,o,s]),f=Gp.useCallback(()=>{m(p.current+r);},[r,m]),b=Gp.useCallback(()=>{m(p.current-r);},[r,m]),g=Gp.useCallback(()=>{m(t);},[t,m]),S=Gp.useCallback(()=>{m(1);},[m]),T=Gp.useCallback((E,F)=>{if(F>0){let G=E/F;m(G);}},[m]),x=Gp.useCallback(E=>{if(!i||!(E.ctrlKey||E.metaKey))return;u&&E.preventDefault();let G=E.deltaY;G<0?m(p.current+r):G>0&&m(p.current-r);},[i,u,r,m]),z=Gp.useCallback(E=>{if(!(!i||!l||!(E.ctrlKey||E.metaKey))){if(E.key==="0"){E.preventDefault(),S();return}if(E.key==="+"||E.key==="="){E.preventDefault(),f();return}if(E.key==="-"){E.preventDefault(),b();return}}},[i,l,f,b,S]);return Gp.useEffect(()=>{if(!i)return;let E=a?.current;if(E)return E.addEventListener("wheel",x,{passive:false}),()=>{E.removeEventListener("wheel",x);}},[i,a,x]),Gp.useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",z),()=>{document.removeEventListener("keydown",z);}},[i,l,z]),{zoom:d,setZoom:m,zoomIn:f,zoomOut:b,resetZoom:g,zoomTo100:S,zoomToFit:T,isMinZoom:d<=n,isMaxZoom:d>=o,zoomPercent:Math.round(d*100),handleWheel:x,handleKeyDown:z}}function mP(){return [...dn]}function gP(e){return _x(e)}function hP(e){return Wx(e)}function bP(e){return Vx(e)}function yP(e){return `${Math.round(e*100)}%`}function xP(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function SP(e){return dn.some(t=>Math.abs(t-e)<.01)}function kP(e,t=qp,n=Yp){return Zp(Xp(e,t,n))}var Uo={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},CP={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},wP={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function Jp(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 jx(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 Cl(e){let t=Jp(e);return jx(t)}function vP(e,t=Uo){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 RP(e,t=Uo){let n=t.backgroundColor;return `
|
|
30
|
+
${e}::selection,
|
|
31
|
+
${e} *::selection {
|
|
32
|
+
background-color: ${n} !important;
|
|
33
|
+
color: inherit !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${e}::-moz-selection,
|
|
37
|
+
${e} *::-moz-selection {
|
|
38
|
+
background-color: ${n} !important;
|
|
39
|
+
color: inherit !important;
|
|
40
|
+
}
|
|
41
|
+
`}function Qp(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function ef(){let e=window.getSelection();return e?e.toString():""}function tf(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function EP(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function PP(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function MP(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function IP(){let e=window.getSelection();e&&e.removeAllRanges();}function Ux(){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 FP(){let e=window.getSelection();if(!e||e.rangeCount===0||!Ux())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 no=null;function nf(e=Uo){Kx();let t=`
|
|
42
|
+
/* DOCX Editor Selection Highlighting */
|
|
43
|
+
|
|
44
|
+
/* Base selection style for all editable content */
|
|
45
|
+
.docx-editor [contenteditable="true"]::selection,
|
|
46
|
+
.docx-editor [contenteditable="true"] *::selection,
|
|
47
|
+
.docx-run-editable::selection,
|
|
48
|
+
.docx-run-editable *::selection {
|
|
49
|
+
background-color: ${e.backgroundColor} !important;
|
|
50
|
+
color: inherit !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Firefox selection */
|
|
54
|
+
.docx-editor [contenteditable="true"]::-moz-selection,
|
|
55
|
+
.docx-editor [contenteditable="true"] *::-moz-selection,
|
|
56
|
+
.docx-run-editable::-moz-selection,
|
|
57
|
+
.docx-run-editable *::-moz-selection {
|
|
58
|
+
background-color: ${e.backgroundColor} !important;
|
|
59
|
+
color: inherit !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Ensure selection is visible against all backgrounds */
|
|
63
|
+
.docx-run-highlighted::selection,
|
|
64
|
+
.docx-run-highlighted *::selection {
|
|
65
|
+
/* For highlighted (yellow background) text, use darker selection */
|
|
66
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.docx-run-highlighted::-moz-selection,
|
|
70
|
+
.docx-run-highlighted *::-moz-selection {
|
|
71
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Selection in dark text */
|
|
75
|
+
.docx-run-dark-bg::selection,
|
|
76
|
+
.docx-run-dark-bg *::selection {
|
|
77
|
+
/* Use lighter selection for dark backgrounds */
|
|
78
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.docx-run-dark-bg::-moz-selection,
|
|
82
|
+
.docx-run-dark-bg *::-moz-selection {
|
|
83
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Programmatic highlight class */
|
|
87
|
+
.docx-selection-highlight {
|
|
88
|
+
background-color: ${e.backgroundColor};
|
|
89
|
+
${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
|
|
90
|
+
${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Find/replace highlight */
|
|
94
|
+
.docx-find-highlight {
|
|
95
|
+
background-color: rgba(255, 235, 59, 0.5);
|
|
96
|
+
border-radius: 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.docx-find-highlight-current {
|
|
100
|
+
background-color: rgba(255, 152, 0, 0.6);
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
outline: 2px solid rgba(255, 152, 0, 0.8);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* AI action selection preview */
|
|
106
|
+
.docx-ai-selection-preview {
|
|
107
|
+
background-color: rgba(156, 39, 176, 0.2);
|
|
108
|
+
border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
|
|
109
|
+
}
|
|
110
|
+
`;no=document.createElement("style"),no.id="docx-selection-styles",no.textContent=t,document.head.appendChild(no);}function Kx(){no&&(no.remove(),no=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function of(){return no!==null||document.getElementById("docx-selection-styles")!==null}function LP(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?Cl(e):Jp(e);t(o);}}function zP(e){let{containerRef:t,enabled:n=true,config:o=Uo,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=Gp.useState(false),[u,d]=Gp.useState(""),[c,p]=Gp.useState([]),[m,f]=Gp.useState(false),b=Gp.useRef(null),g=Gp.useRef(0),S=Gp.useCallback(()=>{let E=t.current,F=Qp(),G=ef(),Y=E?tf(E):false;if(l(F),d(G),f(Y),r&&Y){let N=Cl(E);p(N);}else p([]);a&&a(F&&Y,G);},[t,r,a]),T=Gp.useCallback(()=>{let E=performance.now();if(E-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),S(),b.current=null;},i);return}g.current=E,S();},[i,S]),x=Gp.useCallback(()=>{S();},[S]),z=Gp.useCallback(E=>({position:"absolute",left:`${E.left}px`,top:`${E.top}px`,width:`${E.width}px`,height:`${E.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 Gp.useEffect(()=>(n&&!of()&&nf(o),()=>{}),[n,o]),Gp.useEffect(()=>{if(!n)return;let E=()=>{T();};return document.addEventListener("selectionchange",E),document.addEventListener("mouseup",E),S(),()=>{document.removeEventListener("selectionchange",E),document.removeEventListener("mouseup",E),b.current!==null&&clearTimeout(b.current);}},[n,T,S]),{hasSelection:s,selectedText:u,highlightRects:c,isSelectionInContainer:m,refresh:x,getOverlayStyle:z}}function OP(e,t=Uo){return e.map((n,o)=>Gp__default.default.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 UP(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=Gp.useRef(false),l=Gp.useRef(null),u=Gp.useCallback(async g=>{if(s.current)return false;s.current=true;try{let S=await chunk7YCCCWUZ_cjs.M(g.runs,{onError:a});return S&&t?.(g),S}finally{s.current=false;}},[t,a]),d=Gp.useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let S=await chunk7YCCCWUZ_cjs.M(g.runs,{onError:a});return S&&n?.(g),S}finally{s.current=false;}},[n,i,a]),c=Gp.useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let S=await navigator.clipboard.read(),T="",x="";for(let E of S)E.types.includes("text/html")&&(T=await(await E.getType("text/html")).text()),E.types.includes("text/plain")&&(x=await(await E.getType("text/plain")).text());g&&(T="");let z=chunk7YCCCWUZ_cjs.T(T,x,r);return l.current=z,o?.(z,g),z}return null}catch(S){return a?.(S),null}finally{s.current=false;}},[i,r,o,a]),p=Gp.useCallback(g=>{let S=chunk2VHQ7YOQ_cjs.F();if(!S)return;g.preventDefault();let T=chunk7YCCCWUZ_cjs.O(S.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",T.plainText),g.clipboardData.setData("text/html",T.html),T.internal&&g.clipboardData.setData("application/x-docx-editor",T.internal)),t?.(S);},[t]),m=Gp.useCallback(g=>{if(!i)return;let S=chunk2VHQ7YOQ_cjs.F();if(!S)return;g.preventDefault();let T=chunk7YCCCWUZ_cjs.O(S.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",T.plainText),g.clipboardData.setData("text/html",T.html),T.internal&&g.clipboardData.setData("application/x-docx-editor",T.internal)),n?.(S);},[i,n]),f=Gp.useCallback(g=>{if(!i)return;g.preventDefault();let S=chunk7YCCCWUZ_cjs.S(g,{cleanWordFormatting:r});if(S){l.current=S;let T=g.shiftKey??false;o?.(S,T);}},[i,r,o]),b=Gp.useCallback(g=>{},[]);return {copy:u,cut:d,paste:c,handleCopy:p,handleCut:m,handlePaste:f,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var Va={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},cf=chunk2VHQ7YOQ_cjs.I,df=`
|
|
111
|
+
.plugin-host {
|
|
112
|
+
display: flex;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
overflow: visible;
|
|
116
|
+
position: relative;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.plugin-host-editor {
|
|
120
|
+
flex: 1;
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
min-width: 0;
|
|
124
|
+
overflow: visible;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
.plugin-panels-left,
|
|
129
|
+
.plugin-panels-right {
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
background: #f8f9fa;
|
|
134
|
+
border-color: #e9ecef;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.plugin-panels-left {
|
|
138
|
+
border-right: 1px solid #e9ecef;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.plugin-panels-right {
|
|
142
|
+
border-left: 1px solid #e9ecef;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.plugin-panels-bottom {
|
|
146
|
+
border-top: 1px solid #e9ecef;
|
|
147
|
+
background: #f8f9fa;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.plugin-panel {
|
|
151
|
+
position: relative;
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
transition: width 0.2s ease, height 0.2s ease;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.plugin-panel.collapsed {
|
|
159
|
+
overflow: visible;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.plugin-panel-toggle {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 4px;
|
|
166
|
+
padding: 6px 8px;
|
|
167
|
+
background: transparent;
|
|
168
|
+
border: none;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
font-size: 12px;
|
|
171
|
+
color: #6c757d;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.plugin-panel.collapsed .plugin-panel-toggle {
|
|
176
|
+
writing-mode: vertical-rl;
|
|
177
|
+
text-orientation: mixed;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
height: 100%;
|
|
180
|
+
padding: 8px 6px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.plugin-panel-toggle:hover {
|
|
184
|
+
background: #e9ecef;
|
|
185
|
+
color: #495057;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.plugin-panel-toggle-icon {
|
|
189
|
+
font-weight: bold;
|
|
190
|
+
font-size: 14px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.plugin-panel.collapsed .plugin-panel-toggle-icon {
|
|
194
|
+
transform: rotate(90deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.plugin-panel-toggle-label {
|
|
198
|
+
font-weight: 500;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.plugin-panel-content {
|
|
202
|
+
flex: 1;
|
|
203
|
+
overflow: auto;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Right panel rendered inside viewport - scrolls with content */
|
|
207
|
+
.plugin-panel-in-viewport {
|
|
208
|
+
position: absolute;
|
|
209
|
+
top: 0;
|
|
210
|
+
/* Position is set dynamically via inline styles based on page edge */
|
|
211
|
+
width: 220px;
|
|
212
|
+
pointer-events: auto;
|
|
213
|
+
z-index: 10;
|
|
214
|
+
overflow: visible;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.plugin-panel-in-viewport.collapsed {
|
|
218
|
+
width: 32px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.plugin-panel-in-viewport .plugin-panel-toggle {
|
|
222
|
+
position: sticky;
|
|
223
|
+
top: 0;
|
|
224
|
+
background: rgba(255, 255, 255, 0.95);
|
|
225
|
+
border-radius: 4px;
|
|
226
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.plugin-panel-in-viewport-content {
|
|
230
|
+
overflow: visible;
|
|
231
|
+
position: relative;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Plugin overlay container for rendering highlights/decorations */
|
|
235
|
+
.plugin-overlays-container {
|
|
236
|
+
position: absolute;
|
|
237
|
+
top: 0;
|
|
238
|
+
left: 0;
|
|
239
|
+
right: 0;
|
|
240
|
+
bottom: 0;
|
|
241
|
+
pointer-events: none;
|
|
242
|
+
overflow: visible;
|
|
243
|
+
z-index: 5;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.plugin-overlay {
|
|
247
|
+
position: absolute;
|
|
248
|
+
top: 0;
|
|
249
|
+
left: 0;
|
|
250
|
+
right: 0;
|
|
251
|
+
bottom: 0;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Individual overlay children manage their own pointer-events.
|
|
256
|
+
Do NOT set pointer-events: auto here \u2014 it overrides overlay containers
|
|
257
|
+
that need pointer-events: none to let clicks pass through to the editor. */
|
|
258
|
+
`,Qx=Gp.forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=Gp.useState(null),s=Gp.useRef(n.props);s.current=n.props;let[l,u]=Gp.useState(null),d=Gp.useMemo(()=>new chunk2VHQ7YOQ_cjs.J,[]),c=Gp.useSyncExternalStore(d.subscribe,d.getSnapshot),[p,m]=Gp.useState(()=>{let D=new Set;for(let P of t)({...Va,...P.panelConfig}).defaultCollapsed&&D.add(P.id);return D}),[f]=Gp.useState(()=>{let D=new Map;for(let P of t){let R={...Va,...P.panelConfig};D.set(P.id,R.defaultSize);}return D});Gp.useEffect(()=>{if(!i)return;let D=t.map(P=>({id:P.id,styles:P.styles,initialize:P.initialize,onStateChange:P.onStateChange,destroy:P.destroy}));return d.initialize(D,i),()=>{d.destroy();}},[d,i,t]),Gp.useEffect(()=>{let D=t.filter(P=>P.styles).map(P=>cf(P.id,P.styles));return ()=>D.forEach(P=>P())},[t]),Gp.useEffect(()=>{if(!i?.dom)return;let D=()=>{d.updateStates(i);},P=null,R=()=>{P&&cancelAnimationFrame(P),P=requestAnimationFrame(D);};D();let me=i.dom;me.addEventListener("input",R),me.addEventListener("focus",D),me.addEventListener("click",D);let pe=i.dispatch.bind(i);return i.dispatch=Be=>{pe(Be),R();},()=>{me.removeEventListener("input",R),me.removeEventListener("focus",D),me.removeEventListener("click",D),P&&cancelAnimationFrame(P),i.dispatch=pe;}},[i,d]),Gp.useEffect(()=>cf("plugin-host-base",df),[]);let b=Gp.useCallback(D=>{if(!i)return;if(i.coordsAtPos(D)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:R}=i,me=R.doc.resolve(Math.min(D,R.doc.content.size)),pe=R.tr.setSelection(prosemirrorState.TextSelection.near(me));i.dispatch(pe),i.focus();}},[i]),g=Gp.useCallback((D,P)=>{if(!i)return;let{state:R}=i,me=R.doc.content.size,pe=Math.max(0,Math.min(D,me)),Be=Math.max(0,Math.min(P,me)),Me=R.tr.setSelection(prosemirrorState.TextSelection.create(R.doc,pe,Be));i.dispatch(Me),i.focus();},[i]),S=Gp.useCallback(D=>d.getPluginState(D),[d]),T=Gp.useCallback((D,P)=>{d.setPluginState(D,P);},[d]),x=Gp.useCallback(()=>{i&&d.updateStates(i);},[i,d]);Gp.useImperativeHandle(r,()=>({getPluginState:S,setPluginState:T,getEditorView:()=>i,refreshPluginStates:x}),[S,T,i,x]);let z=Gp.useMemo(()=>{let D=[];for(let P of t)P.proseMirrorPlugins&&D.push(...P.proseMirrorPlugins);return D},[t]),E=Gp.useCallback(D=>{m(P=>{let R=new Set(P);return R.has(D)?R.delete(D):R.add(D),R});},[]),[F,G]=Gp.useState(null);Gp.useEffect(()=>{if(!l){G(null);return}let D=()=>{let me=l.pagesContainer,pe=me.querySelector(".layout-page");if(!pe){G(null);return}let Be=l.getContainerOffset(),Me=pe.getBoundingClientRect(),We=me.getBoundingClientRect(),w=(Me.right-We.left)/l.zoom,A=Be.x+w+5;G(A);};D();let P=()=>{requestAnimationFrame(D);};window.addEventListener("resize",P);let R=new ResizeObserver(()=>{requestAnimationFrame(D);});return R.observe(l.pagesContainer),()=>{window.removeEventListener("resize",P),R.disconnect();}},[l]);let Y=Gp.useMemo(()=>{let D=[];if(l){for(let P of t)if(P.renderOverlay){let R=c.states.get(P.id);D.push(jsxRuntime.jsx("div",{className:"plugin-overlay","data-plugin-id":P.id,children:P.renderOverlay(l,R,i)},`overlay-${P.id}`));}}for(let P of t){if(!P.Panel||(P.panelConfig?.position??"right")!=="right")continue;let me={...Va,...P.panelConfig},pe=p.has(P.id),Be=f.get(P.id)??me.defaultSize,Me=P.Panel,We=c.states.get(P.id),w=F!==null?`${F}px`:"calc(50% + 428px)";D.push(jsxRuntime.jsxs("div",{className:`plugin-panel-in-viewport ${pe?"collapsed":""}`,style:{width:pe?"32px":`${Be}px`,left:w},"data-plugin-id":P.id,children:[me.collapsible&&jsxRuntime.jsx("button",{className:"plugin-panel-toggle",onClick:()=>E(P.id),title:pe?`Show ${P.name}`:`Hide ${P.name}`,"aria-label":pe?`Show ${P.name}`:`Hide ${P.name}`,children:jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:pe?"\u2039":"\u203A"})}),!pe&&l&&jsxRuntime.jsx("div",{className:"plugin-panel-in-viewport-content",children:jsxRuntime.jsx(Me,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:We,panelWidth:Be,renderedDomContext:l})})]},`panel-overlay-${P.id}`));}return D.length>0?D:null},[l,t,c.version,i,p,f,b,g,E,F]),N=Gp.useCallback(D=>{u(D);let P=s.current?.onRenderedDomContextReady;typeof P=="function"&&P(D);},[]),H=Gp.useMemo(()=>Gp.cloneElement(n,{externalPlugins:z,pluginOverlays:Y,onRenderedDomContextReady:N,onEditorViewReady:D=>{a(D);let P=s.current?.onEditorViewReady;typeof P=="function"&&P(D);}}),[n,z,Y,N]),J=Gp.useMemo(()=>{let D=[],P=[],R=[];for(let me of t){if(!me.Panel)continue;let pe=me.panelConfig?.position??"right";pe==="left"?D.push(me):pe==="bottom"?R.push(me):P.push(me);}return {left:D,right:P,bottom:R}},[t]),de=D=>{if(!D.Panel)return null;let P={...Va,...D.panelConfig},R=p.has(D.id),me=f.get(D.id)??P.defaultSize,pe=D.Panel,Be=c.states.get(D.id);return jsxRuntime.jsxs("div",{className:`plugin-panel plugin-panel-${P.position} ${R?"collapsed":""}`,style:{[P.position==="bottom"?"height":"width"]:R?"32px":`${me}px`,minWidth:P.position!=="bottom"?R?"32px":`${P.minSize}px`:void 0,maxWidth:P.position!=="bottom"?`${P.maxSize}px`:void 0,minHeight:P.position==="bottom"?R?"32px":`${P.minSize}px`:void 0,maxHeight:P.position==="bottom"?`${P.maxSize}px`:void 0},"data-plugin-id":D.id,children:[P.collapsible&&jsxRuntime.jsxs("button",{className:"plugin-panel-toggle",onClick:()=>E(D.id),title:R?`Show ${D.name}`:`Hide ${D.name}`,"aria-label":R?`Show ${D.name}`:`Hide ${D.name}`,children:[jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:R?"\u203A":"\u2039"}),R&&jsxRuntime.jsx("span",{className:"plugin-panel-toggle-label",children:D.name})]}),!R&&jsxRuntime.jsx("div",{className:"plugin-panel-content",children:jsxRuntime.jsx(pe,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:Be,panelWidth:me,renderedDomContext:l??null})})]},D.id)};return jsxRuntime.jsxs("div",{className:`plugin-host ${o}`,children:[J.left.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-left",children:J.left.map(de)}),jsxRuntime.jsxs("div",{className:"plugin-host-editor",children:[H,J.bottom.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-bottom",children:J.bottom.map(de)})]})]})});exports.A=jx;exports.B=Cl;exports.C=vP;exports.D=RP;exports.E=Qp;exports.F=ef;exports.G=tf;exports.H=EP;exports.I=PP;exports.J=MP;exports.K=IP;exports.L=Ux;exports.M=FP;exports.N=nf;exports.O=Kx;exports.P=of;exports.Q=LP;exports.R=zP;exports.S=OP;exports.T=UP;exports.U=df;exports.V=Qx;exports.a=zt;exports.b=hS;exports.c=hc;exports.d=Zr;exports.e=bS;exports.f=yS;exports.g=xS;exports.h=SS;exports.i=yc;exports.j=Kp;exports.k=tP;exports.l=dP;exports.m=dn;exports.n=fP;exports.o=mP;exports.p=gP;exports.q=hP;exports.r=bP;exports.s=yP;exports.t=xP;exports.u=SP;exports.v=kP;exports.w=Uo;exports.x=CP;exports.y=wP;exports.z=Jp;
|