@eigenpal/docx-js-editor 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocumentAgent-Ci6_T-XM.d.ts +412 -0
- package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
- package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
- package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
- package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
- package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
- package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
- package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
- package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
- package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
- package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
- package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
- package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
- package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
- package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
- package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
- package/dist/chunk-2ASOEN3V.js +1 -0
- package/dist/chunk-6MBDPZVD.js +111 -0
- package/dist/chunk-6YLNNCRZ.cjs +10 -0
- package/dist/chunk-BVQ2QRHA.cjs +4 -0
- package/dist/chunk-COP5BIBZ.js +10 -0
- package/dist/chunk-CZ7W7MCM.cjs +2 -0
- package/dist/chunk-E6XDMUAM.js +4 -0
- package/dist/chunk-EMKABJPH.js +1 -0
- package/dist/{chunk-GIZ5CTBD.cjs → chunk-EPCZ24TY.cjs} +5 -5
- package/dist/chunk-ESI4BSBF.js +1 -0
- package/dist/chunk-FLECKDK4.cjs +58 -0
- package/dist/chunk-ITWEFKGQ.cjs +1 -0
- package/dist/chunk-KESNGXGO.js +1 -0
- package/dist/chunk-KVAT5SVD.js +2 -0
- package/dist/chunk-L34XFLQZ.cjs +1 -0
- package/dist/chunk-M7F2CUUD.js +2 -0
- package/dist/chunk-MDPDH7KS.js +58 -0
- package/dist/chunk-MTX3EEBJ.js +258 -0
- package/dist/chunk-NT2REEAA.cjs +1 -0
- package/dist/{chunk-P332HWDE.js → chunk-OTG4NABM.js} +5 -5
- package/dist/chunk-OW5H5DNE.cjs +1 -0
- package/dist/chunk-PJVI53AH.js +2 -0
- package/dist/chunk-PNMZPPPI.cjs +2 -0
- package/dist/chunk-SF53KLDZ.cjs +1 -0
- package/dist/chunk-TOI5W3HK.js +8 -0
- package/dist/chunk-UAVOWAIF.cjs +8 -0
- package/dist/chunk-VN7XH644.cjs +258 -0
- package/dist/chunk-W4DUKACP.cjs +111 -0
- package/dist/chunk-XS2AQFMF.cjs +2 -0
- package/dist/chunk-ZDYHAYN6.js +1 -0
- package/dist/clipboard-BOocwmAM.d.ts +539 -0
- package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
- package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
- package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.d.cts +4 -3
- package/dist/core-plugins.d.ts +4 -3
- package/dist/core-plugins.js +1 -1
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +23 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +1 -0
- package/dist/headless.cjs +2 -2
- package/dist/headless.d.cts +8 -175
- package/dist/headless.d.ts +8 -175
- package/dist/headless.js +1 -1
- package/dist/index.cjs +9 -378
- package/dist/index.d.cts +17 -4161
- package/dist/index.d.ts +17 -4161
- package/dist/index.js +9 -378
- package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
- package/dist/insertOperations-DKVmCV32.d.cts +176 -0
- package/dist/mcp-cli.js +21 -21
- package/dist/mcp.cjs +10 -10
- package/dist/mcp.d.cts +2 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +9 -9
- package/dist/processTemplate-BHBTDAIC.js +1 -0
- package/dist/processTemplate-QOEAXCKA.cjs +1 -0
- package/dist/react-Be1YOl4z.d.ts +1356 -0
- package/dist/react-DPuSVbgY.d.cts +1356 -0
- package/dist/react.cjs +1 -0
- package/dist/react.css +1 -0
- package/dist/react.d.cts +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +1 -0
- package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
- package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
- package/dist/types-D96elyJF.d.cts +310 -0
- package/dist/types-xMzSPT4i.d.ts +310 -0
- package/dist/ui.cjs +1 -0
- package/dist/ui.d.cts +2103 -0
- package/dist/ui.d.ts +2103 -0
- package/dist/ui.js +1 -0
- package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
- package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
- package/package.json +85 -10
- package/dist/chunk-56AGRHVO.cjs +0 -58
- package/dist/chunk-E23CAQXT.js +0 -9
- package/dist/chunk-HIBC7HTU.cjs +0 -9
- package/dist/chunk-ICEPOA7G.js +0 -58
- package/dist/chunk-IZGUXSCC.js +0 -10
- package/dist/chunk-XF3IPO7C.cjs +0 -10
package/dist/index.js
CHANGED
|
@@ -1,373 +1,4 @@
|
|
|
1
|
-
import {y,n,o as o$1,x,b as b$1,a as a$3,w,P,N,v,u,O,c as c$3}from'./chunk-E23CAQXT.js';export{y as DocumentAgent,l as blendColors,F as buildExtendedSelectionContext,E as buildSelectionContext,m as colorsEqual,I as createDocumentWithText,H as createEmptyDocument,i as createRgbColor,h as createThemeColor,j as darkenColor,p as emuToPixels,r as emuToTwips,x as formatPx,B as getAgentContext,f as getContrastingColor,D as getDocumentSummary,u as halfPointsToPixels,d as isBlack,e as isWhite,k as lightenColor,g as parseColorString,q as pixelsToEmu,o as pixelsToTwips,t as pointsToPixels,a as resolveColor,b as resolveHighlightColor,c as resolveShadingColor,s as twipsToEmu,n as twipsToPixels}from'./chunk-E23CAQXT.js';export{x as docxtemplaterPlugin,q as getTemplateTags,n as processTemplate,p as processTemplateAsBlob,o as processTemplateDetailed,r as validateTemplate}from'./chunk-IZGUXSCC.js';export{b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties}from'./chunk-ICEPOA7G.js';import {m,o,i as i$1,c as c$1,a as a$2}from'./chunk-P332HWDE.js';export{j as canRenderFont,h as getLoadedFonts,f as isFontLoaded,g as isFontsLoading,d as loadFont,k as loadFontFromBuffer,e as loadFonts,i as onFontsLoaded,o as parseDocx,l as preloadCommonFonts,n as toArrayBuffer}from'./chunk-P332HWDE.js';import {a}from'./chunk-MMJD2DLL.js';export{a as executeCommand,b as executeCommands}from'./chunk-MMJD2DLL.js';export{a as PluginRegistry,b as pluginRegistry,c as registerPlugins}from'./chunk-QHWHCIUW.js';import {j,i,g,h,a as a$1,f as f$1,c as c$2,d,b as b$2,e as e$1}from'./chunk-S6FZ7HL6.js';import {c,b,e,g as g$1,h as h$1,j as j$1,f,i as i$2,d as d$1}from'./chunk-3IYNTJO5.js';import*as cn from'react';import cn__default,{createContext,forwardRef,useRef,useState,useLayoutEffect,useEffect,useCallback,useImperativeHandle,memo,useMemo,cloneElement,Component,useContext}from'react';import*as st from'@radix-ui/react-select';import {clsx}from'clsx';import {jsx,jsxs,Fragment as Fragment$1}from'react/jsx-runtime';import {PluginKey,EditorState,NodeSelection,TextSelection,Plugin,Selection}from'prosemirror-state';import {EditorView,DecorationSet,Decoration}from'prosemirror-view';import {redo,undo,history}from'prosemirror-history';import {Schema,Fragment}from'prosemirror-model';import {toggleMark,selectParentNode,selectAll,baseKeymap,splitBlock,joinForward,deleteSelection,joinBackward}from'prosemirror-commands';import {CellSelection,splitCell,mergeCells,columnResizing,tableEditing}from'prosemirror-tables';import {dropCursor}from'prosemirror-dropcursor';import {keymap}from'prosemirror-keymap';import'prosemirror-view/style/prosemirror.css';import {createRoot}from'react-dom/client';var Zb={};c(Zb,{CLIPBOARD_TYPES:()=>Kt,INTERNAL_CLIPBOARD_TYPE:()=>Wb,cleanWordHtml:()=>_l,copyParagraphs:()=>qu,copyRuns:()=>Xo,createClipboardHandlers:()=>ju,default:()=>Y2,handlePasteEvent:()=>bi,htmlToRuns:()=>$l,isEditorHtml:()=>zl,isWordHtml:()=>Ol,paragraphsToClipboardContent:()=>Ku,parseClipboardHtml:()=>Hl,readFromClipboard:()=>hi,runsToClipboardContent:()=>Jo,writeToClipboard:()=>gi});async function Xo(e,t={}){let{includeFormatting:n=true,onError:o}=t;try{let r=Jo(e,n);return await gi(r)}catch(r){return o?.(r),false}}async function qu(e,t={}){let{includeFormatting:n=true,onError:o}=t;try{let r=Ku(e,n);return await gi(r)}catch(r){return o?.(r),false}}function Jo(e,t=true){let n=e.map(Gu).join(""),o=t?Vb(e):Yu(n),r=JSON.stringify(e);return {plainText:n,html:o,internal:r}}function Ku(e,t=true){let n=e.map(q2).join(`
|
|
2
|
-
`),o=t?K2(e):Yu(n),r=JSON.stringify(e);return {plainText:n,html:o,internal:r}}async function gi(e){try{if(navigator.clipboard&&navigator.clipboard.write){let t=[new ClipboardItem({[Kt.PLAIN]:new Blob([e.plainText],{type:Kt.PLAIN}),[Kt.HTML]:new Blob([e.html],{type:Kt.HTML})})];return await navigator.clipboard.write(t),!0}return zb(e)}catch{return zb(e)}}function zb(e){let t=document.createElement("div");t.innerHTML=e.html,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t);try{let n=window.getSelection();if(!n)return !1;let o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o);let r=document.execCommand("copy");return n.removeAllRanges(),r}finally{document.body.removeChild(t);}}async function hi(e={}){let{cleanWordFormatting:t=true,onError:n}=e;try{if(navigator.clipboard&&navigator.clipboard.read){let o=await navigator.clipboard.read();return await Z2(o,t)}return null}catch(o){return n?.(o),null}}async function Z2(e,t){let n="",o="";for(let r of e)r.types.includes(Kt.HTML)&&(n=await(await r.getType(Kt.HTML)).text()),r.types.includes(Kt.PLAIN)&&(o=await(await r.getType(Kt.PLAIN)).text());return Hl(n,o,t)}function bi(e,t={}){let{cleanWordFormatting:n=true}=t,o=e.clipboardData;if(!o)return null;let r=o.getData(Kt.HTML),i=o.getData(Kt.PLAIN);return Hl(r,i,n)}function Hl(e,t,n=true){let o=Ol(e),r=zl(e);if(r){let s=e.match(/data-docx-editor-content="([^"]+)"/);if(s)try{return {runs:JSON.parse(decodeURIComponent(s[1])),fromWord:!1,fromEditor:!0,plainText:t}}catch{}}let i=e;return o&&n&&(i=_l(e)),{runs:$l(i,t),fromWord:o,fromEditor:r,plainText:t}}function Ol(e){return e.includes("urn:schemas-microsoft-com:office")||e.includes("mso-")||e.includes("MsoNormal")||e.includes('class="Mso')||e.includes("<!--[if gte mso")}function zl(e){return e.includes("data-docx-editor")||e.includes("docx-run")||e.includes("docx-paragraph")}function _l(e){let t=e;return t=t.replace(/<!--\[if[\s\S]*?<!\[endif\]-->/gi,""),t=t.replace(/<!--[\s\S]*?-->/g,""),t=t.replace(/<\?xml[^>]*>/gi,""),t=t.replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,""),t=t.replace(/<o:[^>]*\/>/gi,""),t=t.replace(/<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi,""),t=t.replace(/<w:[^>]*\/>/gi,""),t=t.replace(/\s*mso-[^:;]+:[^;]+;?/gi,""),t=t.replace(/\s*style="\s*"/gi,""),t=t.replace(/\s*class="[^"]*Mso[^"]*"/gi,""),t=t.replace(/<span[^>]*>\s*<\/span>/gi,""),t=t.replace(/<\/?font[^>]*>/gi,""),t=t.replace(/\s+/g," ").trim(),t}function $l(e,t){if(!e||e.trim()==="")return t?[Uu(t)]:[];let n=document.createElement("div");n.innerHTML=e;let o=[];return Zu(n,o,{}),o.length===0&&t?[Uu(t)]:o}function Zu(e,t,n){if(e.nodeType===Node.TEXT_NODE){let a=e.textContent||"";(a.trim()||a.includes(" "))&&t.push(Uu(a,n));return}if(e.nodeType!==Node.ELEMENT_NODE)return;let o=e,r=o.tagName.toLowerCase(),i={...n,...U2(o)};switch(r){case "br":t.push($b(i));return;case "p":case "div":for(let a of o.childNodes)Zu(a,t,i);o.nextSibling&&t.push($b(i));return;case "b":case "strong":i.bold=true;break;case "i":case "em":i.italic=true;break;case "u":i.underline={style:"single"};break;case "s":case "strike":case "del":i.strike=true;break;case "sup":i.vertAlign="superscript";break;case "sub":i.vertAlign="subscript";break;case "code":case "pre":i.fontFamily={ascii:"Courier New"};break}for(let a of o.childNodes)Zu(a,t,i);}function U2(e){let t={},n=e.style;(n.fontWeight==="bold"||parseInt(n.fontWeight)>=700)&&(t.bold=true),n.fontStyle==="italic"&&(t.italic=true);let o=n.textDecoration||n.textDecorationLine;if(o&&(o.includes("underline")&&(t.underline={style:"single"}),o.includes("line-through")&&(t.strike=true)),n.fontSize){let r=parseFloat(n.fontSize);isNaN(r)||(t.fontSize=Math.round(r/1.333*2));}if(n.fontFamily){let r=n.fontFamily.replace(/["']/g,"").split(",")[0].trim();r&&(t.fontFamily={ascii:r});}if(n.color){let r=_b(n.color);r&&(t.color={rgb:r});}if(n.backgroundColor&&n.backgroundColor!=="transparent"){let r=_b(n.backgroundColor);r&&(t.shading={fill:{rgb:r}});}return t}function _b(e){if(!e||e==="transparent"||e==="inherit")return null;if(e.startsWith("#"))return e.slice(1).toUpperCase();let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(t){let n=parseInt(t[1]).toString(16).padStart(2,"0"),o=parseInt(t[2]).toString(16).padStart(2,"0"),r=parseInt(t[3]).toString(16).padStart(2,"0");return (n+o+r).toUpperCase()}return null}function Gu(e){return e.content.map(t=>t.type==="text"?t.text:t.type==="tab"?" ":t.type==="break"&&t.breakType==="textWrapping"?`
|
|
3
|
-
`:"").join("")}function q2(e){return (e.content||[]).map(t=>t.type==="run"?Gu(t):"").join("")}function Vb(e){return e.map(G2).join("")}function K2(e){return e.map(t=>`<p>${Vb(t.content?.filter(n=>n.type==="run")||[])}</p>`).join("")}function G2(e){let t=Gu(e);if(!t)return "";let n=Yu(t),o=e.formatting;if(!o)return n;o.bold&&(n=`<strong>${n}</strong>`),o.italic&&(n=`<em>${n}</em>`),o.underline&&(n=`<u>${n}</u>`),o.strike&&(n=`<s>${n}</s>`),o.vertAlign==="superscript"&&(n=`<sup>${n}</sup>`),o.vertAlign==="subscript"&&(n=`<sub>${n}</sub>`);let r=[];if(o.fontSize){let i=o.fontSize/2;r.push(`font-size: ${i}pt`);}return o.fontFamily?.ascii&&r.push(`font-family: "${o.fontFamily.ascii}"`),o.color?.rgb&&r.push(`color: #${o.color.rgb}`),o.shading?.fill?.rgb&&r.push(`background-color: #${o.shading.fill.rgb}`),r.length>0&&(n=`<span style="${r.join("; ")}">${n}</span>`),n}function Yu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Uu(e,t){return {type:"run",formatting:t,content:[{type:"text",text:e}]}}function $b(e){return {type:"run",formatting:e,content:[{type:"break",breakType:"textWrapping"}]}}function ju(e){let{onCopy:t,onCut:n,onPaste:o,clipboardOptions:r={}}=e;return {handleCopy:async d=>{if(!t)return;let c=t();if(!c)return;d.preventDefault();let u=Jo(c.runs);d.clipboardData?(d.clipboardData.setData(Kt.PLAIN,u.plainText),d.clipboardData.setData(Kt.HTML,u.html)):await gi(u);},handleCut:async d=>{if(!n)return;let c=n();if(!c)return;d.preventDefault();let u=Jo(c.runs);d.clipboardData?(d.clipboardData.setData(Kt.PLAIN,u.plainText),d.clipboardData.setData(Kt.HTML,u.html)):await gi(u);},handlePaste:d=>{if(!o)return;d.preventDefault();let c=bi(d,r);c&&o(c);},handleKeyDown:async d=>{let c=d.ctrlKey||d.metaKey;if(c&&d.key==="c"&&!d.shiftKey&&t){let u=t();u&&await Xo(u.runs,r);}if(c&&d.key==="x"&&!d.shiftKey&&n){let u=n();u&&await Xo(u.runs,r);}}}}var Wb,Kt,Y2,ia=b(()=>{Wb="application/x-docx-editor",Kt={HTML:"text/html",PLAIN:"text/plain"};Y2={copyRuns:Xo,copyParagraphs:qu,readFromClipboard:hi,handlePasteEvent:bi,htmlToRuns:$l,cleanWordHtml:_l,isWordHtml:Ol,isEditorHtml:zl,createClipboardHandlers:ju};});function Ce(...e){return clsx(e)}var Po=st.Root,Br=st.Group,ba=st.Value;function Ro({className:e,children:t,onMouseDown:n,...o}){return jsxs(st.Trigger,{className:Ce("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-slate-700 bg-transparent","hover:bg-slate-100/80 focus:outline-none focus:bg-slate-100/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[t,jsx(st.Icon,{asChild:true,children:jsx(Bx,{className:"h-4 w-4 text-slate-400 shrink-0"})})]})}function Eo({className:e,children:t,position:n="popper",onCloseAutoFocus:o,...r}){return jsx(st.Portal,{children:jsx("div",{className:"ep-root",children:jsx(st.Content,{className:Ce("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-slate-200 bg-white shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:n,onCloseAutoFocus:i=>{i.preventDefault(),o?.(i);},...r,children:jsx(st.Viewport,{className:Ce("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:i=>i.preventDefault(),children:t})})})})}function Nr({className:e,...t}){return jsx(st.Label,{className:Ce("px-2 py-1.5 text-xs font-medium text-slate-500",e),...t})}function Kn({className:e,children:t,onMouseDown:n,...o}){return jsxs(st.Item,{className:Ce("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-slate-700 outline-none","hover:bg-slate-100 focus:bg-slate-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),n?.(r);},...o,children:[jsx(st.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(st.ItemIndicator,{children:jsx(Nx,{className:"h-4 w-4"})})})]})}function Li({className:e,...t}){return jsx(st.Separator,{className:Ce("-mx-1 my-1 h-px bg-slate-100",e),...t})}function Bx({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})}function Nx({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})}var Hx=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function Fc({value:e,onChange:t,fonts:n=Hx,disabled:o=false,className:r,placeholder:i="Arial",width:a=120,showPreview:s=true}){let l=cn.useMemo(()=>e?n.find(p=>p.fontFamily===e||p.name.toLowerCase()===e.toLowerCase())?.name||e:i,[e,n,i]),d=cn.useCallback(u=>{let p=n.find(f=>f.name===u);p&&t?.(p.fontFamily);},[t,n]),c=cn.useMemo(()=>{let u={"sans-serif":[],serif:[],monospace:[],other:[]};return n.forEach(p=>{let f=p.category||"other";u[f].push(p);}),u},[n]);return jsxs(Po,{value:l,onValueChange:d,disabled:o,children:[jsx(Ro,{className:Ce("h-8 text-sm",r),style:{minWidth:typeof a=="number"?`${a}px`:a},"aria-label":"Select font family",children:jsx(ba,{placeholder:i,children:l})}),jsxs(Eo,{className:"max-h-[300px]",children:[c["sans-serif"].length>0&&jsxs(Br,{children:[jsx(Nr,{children:"Sans Serif"}),c["sans-serif"].map(u=>jsx(Kn,{value:u.name,style:s?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]}),c.serif.length>0&&jsxs(Fragment$1,{children:[jsx(Li,{}),jsxs(Br,{children:[jsx(Nr,{children:"Serif"}),c.serif.map(u=>jsx(Kn,{value:u.name,style:s?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]})]}),c.monospace.length>0&&jsxs(Fragment$1,{children:[jsx(Li,{}),jsxs(Br,{children:[jsx(Nr,{children:"Monospace"}),c.monospace.map(u=>jsx(Kn,{value:u.name,style:s?{fontFamily:u.fontFamily}:void 0,children:u.name},u.name))]})]})]})]})}var Pp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Rp=clsx,Ep=(e,t)=>n=>{var o;if(t?.variants==null)return Rp(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(d=>{let c=n?.[d],u=i?.[d];if(c===null)return null;let p=Pp(c)||Pp(u);return r[d][p]}),s=n&&Object.entries(n).reduce((d,c)=>{let[u,p]=c;return p===void 0||(d[u]=p),d},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,c)=>{let{class:u,className:p,...f}=c;return Object.entries(f).every(m=>{let[b,g]=m;return Array.isArray(g)?g.includes({...i,...s}[b]):{...i,...s}[b]===g})?[...d,u,p]:d},[]);return Rp(e,a,l,n?.class,n?.className)};var zx=Ep("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-8 w-8"}},defaultVariants:{variant:"default",size:"default"}}),dt=cn.forwardRef(({className:e,variant:t,size:n,...o},r)=>jsx("button",{className:Ce(zx({variant:t,size:n,className:e})),ref:r,...o}));dt.displayName="Button";function ae({size:e=20,className:t="",style:n,children:o}){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...n},"aria-hidden":"true",children:o})}function $x(e){return jsx(ae,{...e,children:jsx("path",{d:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"})})}function Wx(e){return jsx(ae,{...e,children:jsx("path",{d:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"})})}function Vx(e){return jsx(ae,{...e,children:jsx("path",{d:"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"})})}function Zx(e){return jsx(ae,{...e,children:jsx("path",{d:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"})})}function Ux(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function qx(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"})})}function Kx(e){return jsx(ae,{...e,children:jsx("path",{d:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"})})}function Gx(e){return jsx(ae,{...e,children:jsx("path",{d:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"})})}function Yx(e){return jsx(ae,{...e,children:jsx("path",{d:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"})})}function jx(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"})})}function Xx(e){return jsx(ae,{...e,children:jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function Jx(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function Qx(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function ey(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function ty(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function Dc(e){return jsx(ae,{...e,children:jsx("path",{d:"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"})})}function ny(e){return jsx(ae,{...e,children:jsx("path",{d:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"})})}function oy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"})})}function ry(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function iy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function ay(e){return jsx(ae,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function sy(e){return jsx(ae,{...e,children:jsx("path",{d:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"})})}function ly(e){return jsx(ae,{...e,children:jsx("path",{d:"M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"})})}function cy(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function dy(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"})})}function uy(e){return jsx(ae,{...e,children:jsx("path",{d:"M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"})})}function py(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"})})}function fy(e){return jsx(ae,{...e,children:jsx("path",{d:"M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"})})}function my(e){return jsx(ae,{...e,children:jsx("path",{d:"M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"})})}function gy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function hy(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"})})}function by(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"})})}function xy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function yy(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function vy(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function Sy(e){return jsx(ae,{...e,children:jsx("path",{d:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"})})}function Cy(e){return jsx(ae,{...e,children:jsx("path",{d:"M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"})})}function Ty(e){return jsx(ae,{...e,children:jsx("path",{d:"m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"})})}function wy(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function ky(e){return jsx(ae,{...e,children:jsx("path",{d:"M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"})})}function Py(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"})})}function Ry(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function Ey(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function Iy(e){return jsx(ae,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function My(e){return jsx(ae,{...e,children:jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Ly(e){return jsx(ae,{...e,children:jsx("path",{d:"M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function Fy(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"})})}function Dy(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function Ay(e){return jsx(ae,{...e,children:jsx("path",{d:"M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"})})}function By(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})})}function Ny(e){return jsx(ae,{...e,children:jsx("path",{d:"M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"})})}function Hy(e){return jsx(ae,{...e,children:jsx("path",{d:"M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"})})}function Oy(e){return jsx(ae,{...e,children:jsx("path",{d:"M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"})})}function zy(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"})})}function _y(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function $y(e){return jsx(ae,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function Wy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Vy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Zy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Uy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"})})}function qy(e){return jsx(ae,{...e,children:jsx("path",{d:"M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})})}function Ky(e){return jsx(ae,{...e,children:jsx("path",{d:"M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"})})}function Gy(e){return jsx(ae,{...e,children:jsx("path",{d:"M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"})})}function Yy(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"})})}function jy(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function Xy(e){return jsx(ae,{...e,children:jsx("path",{d:"m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"})})}function Jy(e){return jsx(ae,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"})})}function Qy(e){return jsx(ae,{...e,children:jsx("path",{d:"m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"})})}function ev(e){return jsx(ae,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function tv(e){return jsx(ae,{...e,children:jsx("path",{d:"M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"})})}function nv(e){return jsx(ae,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function ov(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function rv(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function iv(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function av(e){return jsx(ae,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function sv(e){return jsx(ae,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function lv(e){return jsx(ae,{...e,children:jsx("path",{d:"M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"})})}function cv(e){return jsx(ae,{...e,children:jsx("path",{d:"M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"})})}function dv(e){return jsx(ae,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}var uv={undo:$x,redo:Wx,print:Vx,format_bold:Zx,format_italic:Ux,format_underlined:qx,strikethrough_s:Kx,superscript:Gx,subscript:Yx,link:jx,format_clear:Xx,format_align_left:Jx,format_align_center:Qx,format_align_right:ey,format_align_justify:ty,format_line_spacing:Dc,format_list_bulleted:ny,format_list_numbered:oy,format_indent_increase:ry,format_indent_decrease:iy,format_color_text:ay,ink_highlighter:sy,format_color_reset:ly,arrow_drop_down:cy,table:dy,table_chart:uy,grid_on:py,table_rows:fy,view_column:my,border_all:gy,border_outer:hy,border_inner:by,border_clear:xy,add:yy,remove:vy,delete:Sy,delete_sweep:Cy,call_merge:Ty,call_split:wy,drag_indicator:ky,image:Py,format_image_left:Ry,format_image_right:Ey,horizontal_rule:Iy,flip_to_back:My,flip_to_front:Ly,open_with:Fy,tune:Dy,rotate_right:Ay,rotate_left:By,swap_horiz:Ny,swap_vert:Hy,shapes:Oy,format_paint:zy,expand_more:_y,expand_less:$y,border_top:Wy,border_bottom:Vy,border_left:Zy,border_right:Uy,padding:qy,text_rotation_none:Ky,wrap_text:Gy,height:Yy,fit_width:jy,settings:Xy,border_color:Jy,format_color_fill:Qy,vertical_align_top:ev,vertical_align_center:tv,vertical_align_bottom:nv,line_weight:ov,keyboard_arrow_up:rv,keyboard_arrow_down:iv,keyboard_arrow_left:av,keyboard_arrow_right:sv,more_vert:lv,page_break:cv,arrow_back:dv};function se({name:e,size:t=20,className:n="",style:o}){let r=uv[e];return r?jsx(r,{size:t,className:n,style:o}):(console.warn(`Icon not found: ${e}`),jsx("span",{className:n,style:{fontSize:t,width:t,height:t,...o},children:e}))}var fv=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],mv=1,gv=400;function Dp(e){return e/2}function Nc(e){return e*2}function Mp(e,t,n){for(let o of t)if(o>e)return o;return Math.min(e+1,n)}function Lp(e,t,n){for(let o=t.length-1;o>=0;o--)if(t[o]<e)return t[o];return Math.max(e-1,n)}function Hc({value:e,onChange:t,sizes:n=fv,disabled:o=false,className:r,placeholder:i="11",minSize:a=mv,maxSize:s=gv}){let[l,d]=useState(false),[c,u]=useState(""),[p,f]=useState(false),m=useRef(null),b=useRef(null),g=useRef(null),h=e??(parseInt(i,10)||11),x=e!==void 0?e.toString():i;useEffect(()=>{if(!p)return;let N=U=>{b.current&&!b.current.contains(U.target)&&g.current&&!g.current.contains(U.target)&&f(false);},_=U=>{U.key==="Escape"&&(f(false),d(false));};return document.addEventListener("mousedown",N),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",_);}},[p]);let y=useCallback(N=>{if(N.preventDefault(),o)return;let _=Lp(h,n,a);t?.(_);},[h,n,a,o,t]),k=useCallback(N=>{if(N.preventDefault(),o)return;let _=Mp(h,n,s);t?.(_);},[h,n,s,o,t]),T=useCallback(N=>{N.preventDefault(),!o&&(d(true),u(x),f(true),requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();}));},[o,x]),A=useCallback(N=>{u(N.target.value);},[]),B=useCallback(()=>{d(false);let N=parseInt(c,10);!isNaN(N)&&N>=a&&N<=s&&t?.(N);},[c,a,s,t]),R=useCallback(N=>{if(N.key==="Enter")N.preventDefault(),B(),f(false);else if(N.key==="Escape")d(false),f(false);else if(N.key==="ArrowUp"){N.preventDefault();let _=Mp(h,n,s);u(_.toString()),t?.(_);}else if(N.key==="ArrowDown"){N.preventDefault();let _=Lp(h,n,a);u(_.toString()),t?.(_);}},[B,h,n,s,a,t]),E=useCallback(N=>{t?.(N),f(false),d(false);},[t]),S=useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxs("div",{ref:b,className:Ce("flex items-center",r),onMouseDown:S,children:[jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("h-7 w-7 text-slate-500 hover:text-slate-900 hover:bg-slate-100/80 rounded-r-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:y,disabled:o||h<=a,"aria-label":"Decrease font size","data-testid":"font-size-decrease",children:jsx(se,{name:"remove",size:18})}),jsxs("div",{className:"relative",children:[l?jsx("input",{ref:m,type:"text",value:c,onChange:A,onBlur:B,onKeyDown:R,className:Ce("h-7 w-10 text-center text-sm border border-slate-300 bg-white","focus:outline-none focus:ring-1 focus:ring-slate-400","rounded-none"),"aria-label":"Font size","data-testid":"font-size-input"}):jsx("button",{type:"button",onClick:T,className:Ce("h-7 w-10 text-center text-sm border border-slate-200 bg-white","hover:border-slate-300 hover:bg-slate-50","focus:outline-none focus:ring-1 focus:ring-slate-400","rounded-none",o&&"opacity-50 cursor-not-allowed"),disabled:o,"aria-label":"Font size","aria-haspopup":"listbox","aria-expanded":p,"data-testid":"font-size-display",children:x}),p&&jsx("div",{ref:g,className:Ce("absolute top-full left-1/2 -translate-x-1/2 mt-1 z-50","bg-white border border-slate-200 rounded-md shadow-lg","max-h-60 overflow-y-auto min-w-[60px]"),role:"listbox","aria-label":"Font sizes",children:n.map(N=>jsx("button",{type:"button",onClick:()=>E(N),className:Ce("w-full px-3 py-1.5 text-sm text-left","hover:bg-slate-100",N===h&&"bg-slate-100 font-medium"),role:"option","aria-selected":N===h,children:N},N))})]}),jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("h-7 w-7 text-slate-500 hover:text-slate-900 hover:bg-slate-100/80 rounded-l-none",o&&"opacity-30 cursor-not-allowed"),onMouseDown:k,disabled:o||h>=s,"aria-label":"Increase font size","data-testid":"font-size-increase",children:jsx(se,{name:"add",size:18})})]})}var xv=[{name:"Black",hex:"000000"},{name:"Dark Red",hex:"7F0000"},{name:"Dark Orange",hex:"FF6600"},{name:"Dark Yellow",hex:"808000"},{name:"Dark Green",hex:"006400"},{name:"Dark Teal",hex:"008080"},{name:"Dark Blue",hex:"000080"},{name:"Dark Purple",hex:"4B0082"},{name:"Dark Gray",hex:"404040"},{name:"Gray",hex:"808080"},{name:"Red",hex:"FF0000"},{name:"Orange",hex:"FF9900"},{name:"Yellow",hex:"FFFF00"},{name:"Light Green",hex:"00FF00"},{name:"Cyan",hex:"00FFFF"},{name:"Light Blue",hex:"0066FF"},{name:"Blue",hex:"0000FF"},{name:"Purple",hex:"9900FF"},{name:"Magenta",hex:"FF00FF"},{name:"Pink",hex:"FF66FF"},{name:"Light Red",hex:"FFCCCC"},{name:"Light Orange",hex:"FFE5CC"},{name:"Light Yellow",hex:"FFFFCC"},{name:"Pale Green",hex:"CCFFCC"},{name:"Light Cyan",hex:"CCFFFF"},{name:"Sky Blue",hex:"CCE5FF"},{name:"Light Blue 2",hex:"CCCCFF"},{name:"Lavender",hex:"E5CCFF"},{name:"Light Magenta",hex:"FFCCFF"},{name:"White",hex:"FFFFFF"}],yv=[{name:"No Color",hex:""},{name:"Yellow",hex:"FFFF00"},{name:"Bright Green",hex:"00FF00"},{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Blue",hex:"0000FF"},{name:"Red",hex:"FF0000"},{name:"Dark Blue",hex:"00008B"},{name:"Teal",hex:"008080"},{name:"Green",hex:"008000"},{name:"Violet",hex:"800080"},{name:"Dark Red",hex:"8B0000"},{name:"Dark Yellow",hex:"808000"},{name:"Gray 50%",hex:"808080"},{name:"Gray 25%",hex:"C0C0C0"},{name:"Black",hex:"000000"}],vv={position:"relative",display:"inline-block"},ya={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},Sv={...ya,backgroundColor:"var(--doc-bg-hover)"},Cv={...ya,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},Tv={...ya,cursor:"default",opacity:.38},wv={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"0"},kv={width:"14px",height:"3px",borderRadius:"0",marginTop:"-2px"},Pv={position:"absolute",top:"100%",left:0,zIndex:1e3,marginTop:"2px",padding:"8px",backgroundColor:"#fff",border:"1px solid #ccc",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"},Rv={display:"grid",gap:"2px"},va={width:"20px",height:"20px",border:"1px solid #ccc",borderRadius:"2px",cursor:"pointer",transition:"transform 0.1s, border-color 0.1s",padding:0},Ev={...va,transform:"scale(1.1)",borderColor:"#333",zIndex:1},Iv={...va,borderWidth:"2px",borderColor:"#0066cc",boxShadow:"0 0 0 1px #0066cc"},Mv={...va,position:"relative",backgroundColor:"#fff"},Lv={position:"absolute",top:"50%",left:"-2px",right:"-2px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"},Bp={fontSize:"11px",color:"#666",marginBottom:"4px",marginTop:"8px"},Fv={marginTop:"8px",paddingTop:"8px",borderTop:"1px solid #eee"},Dv={display:"flex",alignItems:"center",gap:"8px"},Av={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid #ccc",borderRadius:"3px",fontSize:"12px"},Bv={height:"24px",padding:"0 8px",border:"1px solid #ccc",borderRadius:"3px",backgroundColor:"#f5f5f5",fontSize:"12px",cursor:"pointer"},Nv=()=>jsx(se,{name:"format_color_text",size:18}),Hv=()=>jsx(se,{name:"ink_highlighter",size:18}),Ov=()=>jsx(se,{name:"arrow_drop_down",size:14});function zv({colors:e,selectedColor:t,onSelect:n,columns:o=10,cellSize:r=20}){let[i,a]=useState(null),s={...Rv,gridTemplateColumns:`repeat(${o}, ${r}px)`};return jsx("div",{style:s,className:"docx-color-grid",role:"grid",children:e.map((l,d)=>{let c=t?.toUpperCase()===l.hex.toUpperCase(),u=i===d,p=l.hex==="",f={...c?Iv:u?Ev:va,width:`${r}px`,height:`${r}px`};return p||(f.backgroundColor=`#${l.hex}`),jsx("button",{type:"button",style:p?{...Mv,...f}:f,onClick:()=>n(l),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>a(d),onMouseLeave:()=>a(null),title:l.name,role:"gridcell","aria-label":l.name,"aria-selected":c,children:p&&jsx("span",{style:Lv})},`${l.hex}-${d}`)})})}function zc({value:e,onChange:t,type:n="text",theme:o,colors:r,disabled:i=false,className:a,style:s,title:l,children:d,dropdownWidth:c=230,showNoColor:u=true,showMoreColors:p=true}){let[f,m]=useState(false),[b,g]=useState(false),[h,x]=useState(""),y=useRef(null),k=useMemo(()=>{if(n==="highlight")return yv;let _=[...xv];return u&&_.unshift({name:"Automatic",hex:"000000"}),_},[n,u]),T=r||k,A=useMemo(()=>e?e.startsWith("#")?e:n==="highlight"?b$1(e)||"transparent":`#${e}`:n==="text"?"#000000":"transparent",[e,n]);useEffect(()=>{let _=U=>{let Z=U;y.current&&!y.current.contains(Z.target)&&m(false);};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]);let B=useCallback(_=>{t?.(_.hex),m(false);},[t]),R=useCallback(()=>{let _=h.replace(/^#/,"").toUpperCase();/^[0-9A-F]{6}$/i.test(_)&&(t?.(_),m(false),x(""));},[h,t]),E=useCallback(()=>{i||m(_=>!_);},[i]),S=i?Tv:f?Cv:b?Sv:ya,N=n==="text"?"Font Color":"Text Highlight Color";return jsxs("div",{ref:y,className:`docx-color-picker docx-color-picker-${n} ${a||""}`,style:{...vv,...s},children:[jsxs("button",{type:"button",className:"docx-color-picker-button",style:S,onClick:E,onMouseDown:_=>_.preventDefault(),onMouseEnter:()=>g(true),onMouseLeave:()=>g(false),disabled:i,title:l||N,"aria-label":l||N,"aria-haspopup":"true","aria-expanded":f,children:[d||jsxs("div",{style:wv,children:[n==="text"?jsx(Nv,{}):jsx(Hv,{}),jsx("div",{style:{...kv,backgroundColor:A==="transparent"?"#fff":A,border:A==="transparent"?"1px solid #ccc":"none"}})]}),jsx(Ov,{})]}),f&&jsxs("div",{className:"docx-color-picker-dropdown",style:{...Pv,width:c},role:"dialog","aria-label":`${n==="text"?"Font":"Highlight"} color picker`,onMouseDown:_=>_.preventDefault(),children:[n==="highlight"&&jsx("div",{style:Bp,children:"Highlight Colors"}),jsx(zv,{colors:T,selectedColor:e,onSelect:B,columns:n==="highlight"?8:10}),p&&n==="text"&&jsxs("div",{style:Fv,children:[jsx("div",{style:Bp,children:"Custom Color"}),jsxs("div",{style:Dv,children:[jsx("span",{style:{fontSize:"12px",color:"#666"},children:"#"}),jsx("input",{type:"text",style:Av,value:h,onChange:_=>x(_.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:_=>{_.key==="Enter"&&R();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:Bv,onClick:R,disabled:!/^[0-9A-Fa-f]{6}$/.test(h),children:"Apply"})]})]})]})]})}function Np(e){return jsx(zc,{...e,type:"text"})}function Hp(e){return jsx(zc,{...e,type:"highlight",showMoreColors:false})}function wt({content:e,children:t,side:n="bottom",delayMs:o=400}){let[r,i]=cn.useState(false),[a,s]=cn.useState({x:0,y:0}),l=cn.useRef(null),d=cn.useRef(null),c=cn.useCallback(()=>{d.current=setTimeout(()=>{if(l.current){let m=l.current.getBoundingClientRect(),b=m.left+m.width/2,g=n==="top"?m.top-8:m.bottom+8;s({x:b,y:g});}i(true);},o);},[o,n]),u=cn.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null),i(false);},[]);cn.useEffect(()=>()=>{d.current&&clearTimeout(d.current);},[]);let p=t.props,f=cn.cloneElement(t,{ref:l,onMouseEnter:m=>{c(),p.onMouseEnter?.(m);},onMouseLeave:m=>{u(),p.onMouseLeave?.(m);}});return jsxs(Fragment$1,{children:[f,r&&jsx("div",{className:Ce("fixed z-50 px-2 py-1 text-xs font-medium text-white bg-slate-900 rounded-md shadow-lg","animate-in fade-in-0 zoom-in-95 duration-150",n==="top"&&"-translate-x-1/2 -translate-y-full",n==="bottom"&&"-translate-x-1/2"),style:{left:a.x,top:a.y,transform:n==="top"?"translate(-50%, -100%)":n==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var Di=20,_c=[{value:"left",label:"Align Left",icon:jsx(se,{name:"format_align_left",size:Di}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",icon:jsx(se,{name:"format_align_center",size:Di}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",icon:jsx(se,{name:"format_align_right",size:Di}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",icon:jsx(se,{name:"format_align_justify",size:Di}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function $c({value:e="left",onChange:t,disabled:n=false}){let[o,r]=useState(false),i=useRef(null);useEffect(()=>{if(!o)return;let c=p=>{i.current&&!i.current.contains(p.target)&&r(false);},u=p=>{p.key==="Escape"&&r(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u);}},[o]);let a=useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s=useCallback(c=>{n||t?.(c),r(false);},[n,t]),l=_c.find(c=>c.value===e)||_c[0],d=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",o&&"bg-slate-100",n&&"opacity-30 cursor-not-allowed"),onMouseDown:a,onClick:()=>!n&&r(c=>!c),disabled:n,"aria-label":`${l.label}${l.shortcut?` (${l.shortcut})`:""}`,"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(se,{name:l.iconName,size:Di}),jsx(se,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[o?d:jsx(wt,{content:`${l.label}${l.shortcut?` (${l.shortcut})`:""}`,children:d}),o&&!n&&jsx("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:6,zIndex:1e3},onMouseDown:c=>c.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:_c.map(c=>{let u=e===c.value;return jsx("button",{type:"button",title:`${c.label}${c.shortcut?` (${c.shortcut})`:""}`,"data-testid":`alignment-${c.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:u?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:u?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:p=>p.preventDefault(),onMouseEnter:p=>{u||(p.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=u?"var(--doc-primary-light)":"transparent";},onClick:()=>s(c.value),children:jsx(se,{name:c.iconName,size:18})},c.value)})})})]})}var Gv={display:"inline-flex",alignItems:"center",gap:"4px"},_p={display:"inline-flex",alignItems:"center",gap:"4px"},wa={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},Yv={...wa,backgroundColor:"var(--doc-bg-hover)"},jv={...wa,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},Xv={...wa,cursor:"default",opacity:.38},Jv={width:"28px",height:"28px",padding:"2px"},Qv={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Sa=20;function Ca({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,style:a}){let[s,l]=useState(false),d={...t?Xv:e?jv:s?Yv:wa,...a},c=u=>{u.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:d,onMouseDown:c,onClick:t?void 0:o,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),disabled:t,title:n,"aria-label":n,"aria-pressed":e,role:"button",children:r})}function Wc({listState:e,onBulletList:t,onNumberedList:n,onIndent:o,onOutdent:r,disabled:i=false,className:a,style:s,showIndentButtons:l=true,compact:d=false,hasIndent:c=false}){let u=useCallback(()=>d?{...Jv}:{},[d]),p=e?.type==="bullet",f=e?.type==="numbered",b=(e?.isInList||p||f)&&(e?.level??0)>0||c;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...Gv,...s},role:"group","aria-label":"List formatting",children:[jsxs("div",{style:_p,role:"group","aria-label":"List type",children:[jsx(Ca,{active:p,disabled:i,title:"Bullet List",onClick:t,style:u(),children:jsx(se,{name:"format_list_bulleted",size:Sa})}),jsx(Ca,{active:f,disabled:i,title:"Numbered List",onClick:n,style:u(),children:jsx(se,{name:"format_list_numbered",size:Sa})})]}),l&&jsxs(Fragment$1,{children:[jsx("div",{style:Qv,role:"separator"}),jsxs("div",{style:_p,role:"group","aria-label":"List indentation",children:[jsx(Ca,{active:false,disabled:i||!b,title:"Decrease Indent",onClick:r,style:u(),children:jsx(se,{name:"format_indent_decrease",size:Sa})}),jsx(Ca,{active:false,disabled:i,title:"Increase Indent",onClick:o,style:u(),children:jsx(se,{name:"format_indent_increase",size:Sa})})]})]})]})}function ka(){return {type:"none",level:0,isInList:false}}var tS=[{label:"Single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",value:2,twipsValue:480}];function Vc({value:e,onChange:t,options:n=tS,disabled:o=false,className:r}){let i=cn.useMemo(()=>e===void 0?n[0]:n.find(s=>s.twipsValue===e)||n[0],[e,n]),a=cn.useCallback(s=>{let l=parseInt(s,10);isNaN(l)||t?.(l);},[t]);return jsxs(Po,{value:i.twipsValue.toString(),onValueChange:a,disabled:o,children:[jsx(Ro,{className:Ce("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},title:`Line spacing: ${i.label}`,children:jsx(Dc,{className:"h-5 w-5 shrink-0"})}),jsxs(Eo,{children:[n.map(s=>jsx(Kn,{value:s.twipsValue.toString(),children:s.label},s.twipsValue)),jsx(Li,{}),jsx(Br,{children:jsx(Nr,{children:"Paragraph spacing"})})]})]})}var Wp=[{styleId:"Normal",name:"Normal text",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}],nS="#4a6c8c",oS={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14};function rS(e){let t={};return t.fontSize=`${oS[e.styleId]??14}px`,t.lineHeight="1.3",e.bold&&(t.fontWeight="bold"),e.italic&&(t.fontStyle="italic"),e.color?t.color=`#${e.color}`:e.styleId.startsWith("Heading")&&(t.color=nS),t}function Zc({value:e,onChange:t,styles:n,disabled:o=false,className:r,width:i=120}){let a=cn.useMemo(()=>{if(!n||n.length===0)return Wp;let c=new Set(["Normal","Title","Subtitle","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6"]);return n.filter(f=>f.type==="paragraph").filter(f=>c.has(f.styleId)).map(f=>({styleId:f.styleId,name:f.name||f.styleId,type:f.type,isDefault:f.default,qFormat:f.qFormat,priority:f.uiPriority??99,fontSize:f.rPr?.fontSize,bold:f.rPr?.bold,italic:f.rPr?.italic,color:f.rPr?.color?.rgb})).map(f=>{let m=Wp.find(b=>b.styleId===f.styleId);return {...m,...f,fontSize:f.fontSize??m?.fontSize,bold:f.bold??m?.bold,italic:f.italic??m?.italic,color:f.color??m?.color}}).sort((f,m)=>(f.priority??99)-(m.priority??99))},[n]),s=cn.useCallback(c=>{t?.(c);},[t]),l=e||"Normal",d=a.find(c=>c.styleId===l)?.name||l;return jsxs(Po,{value:l,onValueChange:s,disabled:o,children:[jsx(Ro,{className:Ce("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":"Select paragraph style",children:jsx("span",{className:"truncate",children:d})}),jsx(Eo,{className:"min-w-[260px] max-h-[400px]",children:a.map(c=>jsx(Kn,{value:c.styleId,className:"py-2.5 px-3",children:jsx("span",{style:rS(c),children:c.name})},c.styleId))})]})}var aS=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function Uc({value:e=1,onChange:t,levels:n=aS,disabled:o=false,className:r,compact:i=false}){let a=cn.useMemo(()=>{let l=n.find(d=>Math.abs(d.value-e)<.001);return l?l.label:`${Math.round(e*100)}%`},[n,e]),s=cn.useCallback(l=>{let d=parseFloat(l);isNaN(d)||t?.(d);},[t]);return jsxs(Po,{value:e.toString(),onValueChange:s,disabled:o,children:[jsx(Ro,{className:Ce(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[70px] text-sm",r),"aria-label":`Zoom: ${a}`,children:jsx(ba,{placeholder:"100%",children:a})}),jsx(Eo,{children:n.map(l=>jsx(Kn,{value:l.value.toString(),children:l.label},l.value))})]})}var Kc=18,cS=2,Zp={width:Kc,height:Kc,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},dS={...Zp,backgroundColor:"var(--doc-primary, #3b82f6)",border:"1px solid var(--doc-primary, #3b82f6)"},uS={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text, #374151)",textAlign:"center"};function Up({onInsert:e,gridRows:t=6,gridColumns:n=6}){let[o,r]=useState(0),[i,a]=useState(0),s=useCallback(()=>{o>0&&i>0&&e(o,i);},[o,i,e]),l=[];for(let c=1;c<=t;c++)for(let u=1;u<=n;u++){let p=c<=o&&u<=i;l.push(jsx("div",{style:p?dS:Zp,onMouseEnter:()=>{r(c),a(u);},onClick:s,role:"gridcell","aria-selected":p},`${c}-${u}`));}let d=o>0&&i>0?`${i} \xD7 ${o}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:cS,gridTemplateColumns:`repeat(${n}, ${Kc}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:l}),jsx("div",{style:uS,children:d})]})}function jn({isOpen:e,onClose:t,align:n="left"}){let o=useRef(null),r=useRef(null),[i,a]=useState({top:0,left:0});useEffect(()=>{if(!e||!o.current)return;let d=o.current.getBoundingClientRect();n==="right"?requestAnimationFrame(()=>{if(r.current){let c=r.current.getBoundingClientRect();a({top:d.bottom+4,left:d.right-c.width});}else a({top:d.bottom+4,left:d.left});}):a({top:d.bottom+4,left:d.left});},[e,n]),useEffect(()=>{if(!e)return;let d=p=>{let f=p.target;o.current&&!o.current.contains(f)&&r.current&&!r.current.contains(f)&&t();},c=p=>{p.key==="Escape"&&t();},u=()=>t();return document.addEventListener("mousedown",d),document.addEventListener("keydown",c),window.addEventListener("scroll",u,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",c),window.removeEventListener("scroll",u,true);}},[e,t]);let s=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),l={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:o,dropdownRef:r,dropdownStyle:l,handleMouseDown:s}}var hS=[{action:"borderAll",icon:"border_all",label:"All borders"},{action:"borderOutside",icon:"border_outer",label:"Outside borders"},{action:"borderInside",icon:"border_inner",label:"Inside borders"},{action:"borderTop",icon:"border_top",label:"Top border"},{action:"borderBottom",icon:"border_bottom",label:"Bottom border"},{action:"borderLeft",icon:"border_left",label:"Left border"},{action:"borderRight",icon:"border_right",label:"Right border"},{action:"borderNone",icon:"border_clear",label:"No borders"}];function Gc({onAction:e,disabled:t=false}){let[n,o]=useState(false),r=useCallback(()=>o(false),[]),{containerRef:i,dropdownRef:a,dropdownStyle:s,handleMouseDown:l}=jn({isOpen:n,onClose:r}),d=useCallback(u=>{e(u),o(false);},[e]),c=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",n&&"bg-slate-100",t&&"opacity-30 cursor-not-allowed"),onMouseDown:l,onClick:()=>!t&&o(u=>!u),disabled:t,"aria-label":"Border style","aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(se,{name:"border_all",size:20}),jsx(se,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[n?c:jsx(wt,{content:"Borders",children:c}),n&&!t&&jsx("div",{ref:a,style:{...s,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:6},onMouseDown:u=>u.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:hS.map(({action:u,icon:p,label:f})=>jsx("button",{type:"button",title:f,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsx(se,{name:p,size:18})},typeof u=="string"?u:u.type))})})]})}var bS=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff"],xS={width:18,height:18,borderRadius:2,border:"1px solid var(--doc-border)",cursor:"pointer",padding:0,backgroundColor:"transparent"};function Yc({onAction:e,disabled:t=false}){let[n,o]=useState(false),[r,i]=useState("#000000"),a=useCallback(()=>o(false),[]),{containerRef:s,dropdownRef:l,dropdownStyle:d,handleMouseDown:c}=jn({isOpen:n,onClose:a}),u=useCallback(f=>{i(f),e({type:"borderColor",color:f.replace(/^#/,"")}),o(false);},[e]),p=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80 flex-col gap-0 !p-0.5",n&&"bg-slate-100",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&o(f=>!f),disabled:t,"aria-label":"Border color","aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-color",children:[jsx(se,{name:"border_color",size:18}),jsx("div",{style:{width:16,height:3,backgroundColor:r,borderRadius:0,marginTop:-2}})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[n?p:jsx(wt,{content:"Border color",children:p}),n&&!t&&jsx("div",{ref:l,style:{...d,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:8},onMouseDown:f=>f.stopPropagation(),children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:2},children:bS.map(f=>jsx("button",{type:"button",style:{...xS,backgroundColor:f,outline:r===f?"2px solid var(--doc-primary)":"none",outlineOffset:1},title:f,onMouseDown:m=>m.preventDefault(),onClick:()=>u(f)},f))})})]})}var vS=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function Xc({onAction:e,disabled:t=false}){let[n,o]=useState(false),r=useCallback(()=>o(false),[]),{containerRef:i,dropdownRef:a,dropdownStyle:s,handleMouseDown:l}=jn({isOpen:n,onClose:r}),d=useCallback(u=>{e({type:"borderWidth",size:u}),o(false);},[e]),c=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",n&&"bg-slate-100",t&&"opacity-30 cursor-not-allowed"),onMouseDown:l,onClick:()=>!t&&o(u=>!u),disabled:t,"aria-label":"Border width","aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(se,{name:"line_weight",size:20}),jsx(se,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[n?c:jsx(wt,{content:"Border width",children:c}),n&&!t&&jsx("div",{ref:a,style:{...s,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:"4px 0",minWidth:120},onMouseDown:u=>u.stopPropagation(),children:vS.map(({size:u,label:p,thickness:f})=>jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:[jsx("div",{style:{width:50,height:Math.max(f,1),backgroundColor:"#000",borderRadius:f>2?1:0}}),jsx("span",{children:p})]},u))})]})}var SS=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff"],CS={width:18,height:18,borderRadius:2,border:"1px solid var(--doc-border)",cursor:"pointer",padding:0,backgroundColor:"transparent"};function Qc({onAction:e,disabled:t=false}){let[n,o]=useState(false),[r,i]=useState(null),a=useCallback(()=>o(false),[]),{containerRef:s,dropdownRef:l,dropdownStyle:d,handleMouseDown:c}=jn({isOpen:n,onClose:a}),u=useCallback(m=>{i(m),e({type:"cellFillColor",color:m}),o(false);},[e]),p=useCallback(()=>{i(null),e({type:"cellFillColor",color:null}),o(false);},[e]),f=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80 flex-col gap-0 !p-0.5",n&&"bg-slate-100",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&o(m=>!m),disabled:t,"aria-label":"Cell fill color","aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-cell-fill",children:[jsx(se,{name:"format_color_fill",size:18}),jsx("div",{style:{width:16,height:3,backgroundColor:r||"transparent",borderRadius:0,marginTop:-2,border:r?"none":"1px solid var(--doc-border)"}})]});return jsxs("div",{ref:s,style:{position:"relative",display:"inline-block"},children:[n?f:jsx(wt,{content:"Cell fill color",children:f}),n&&!t&&jsxs("div",{ref:l,style:{...d,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:8},onMouseDown:m=>m.stopPropagation(),children:[jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:2},children:SS.map(m=>jsx("button",{type:"button",style:{...CS,backgroundColor:m,outline:r===m?"2px solid var(--doc-primary)":"none",outlineOffset:1},title:m,onMouseDown:b=>b.preventDefault(),onClick:()=>u(m)},m))}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,marginTop:6,padding:"4px 8px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text-muted)",borderRadius:4},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:p,children:[jsx(se,{name:"format_color_reset",size:14}),jsx("span",{children:"No fill"})]})]})]})}var TS={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},$r={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},of={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function td({onAction:e,disabled:t=false,tableContext:n}){let[o,r]=useState(false),[i,a]=useState(null),s=useCallback(()=>r(false),[]),{containerRef:l,dropdownRef:d,dropdownStyle:c,handleMouseDown:u}=jn({isOpen:o,onClose:s,align:"right"}),p=n?.table?.attrs?.justification??"left",f=useCallback(g=>{e(g),r(false);},[e]),m=(g,h,x,y,k)=>{let T=t||k?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...TS,backgroundColor:i===g&&!T?"var(--doc-bg-hover)":"transparent",color:T?"var(--doc-text-muted)":k?.danger?"var(--doc-error)":"var(--doc-text)",cursor:T?"not-allowed":"pointer"},onClick:()=>!T&&f(y),onMouseEnter:()=>a(g),onMouseLeave:()=>a(null),disabled:T,children:[jsx(se,{name:h,size:16,className:k?.danger&&!T?"text-red-600":""}),jsx("span",{style:{flex:1},children:x})]},g)},b=jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",o&&"bg-slate-100",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&r(g=>!g),disabled:t,"aria-label":"More table options","aria-expanded":o,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(se,{name:"more_vert",size:20})});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[o?b:jsx(wt,{content:"More table options",children:b}),o&&!t&&jsxs("div",{ref:d,style:{...c,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:"4px 0",minWidth:200,maxHeight:"70vh",overflowY:"auto"},role:"menu",onMouseDown:g=>g.stopPropagation(),children:[m("addRowAbove","add","Insert row above","addRowAbove"),m("addRowBelow","add","Insert row below","addRowBelow"),m("addColumnLeft","add","Insert column left","addColumnLeft"),m("addColumnRight","add","Insert column right","addColumnRight"),jsx("div",{style:$r,role:"separator"}),m("mergeCells","call_merge","Merge cells","mergeCells",{itemDisabled:!n?.hasMultiCellSelection}),m("splitCell","call_split","Split cell","splitCell",{itemDisabled:!n?.canSplitCell}),jsx("div",{style:$r,role:"separator"}),m("deleteRow","delete","Delete row","deleteRow",{danger:true,itemDisabled:(n?.rowCount??0)<=1}),m("deleteColumn","delete","Delete column","deleteColumn",{danger:true,itemDisabled:(n?.columnCount??0)<=1}),m("deleteTable","delete","Delete table","deleteTable",{danger:true}),jsx("div",{style:$r,role:"separator"}),jsx("div",{style:of,children:"Vertical alignment"}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(g=>{let h={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsx("button",{type:"button",title:{top:"Top",center:"Middle",bottom:"Bottom"}[g],style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent";},onClick:()=>f({type:"cellVerticalAlign",align:g}),children:jsx(se,{name:h[g],size:16})},g)})}),jsx("div",{style:$r,role:"separator"}),jsx("div",{style:of,children:"Table alignment"}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(g=>{let h={left:"format_align_left",center:"format_align_center",right:"format_align_right"},x=p===g;return jsx("button",{type:"button",title:`Align table ${g}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",borderColor:x?"var(--doc-primary)":"var(--doc-border)",color:x?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onClick:()=>f({type:"tableProperties",props:{justification:g}}),children:jsx(se,{name:h[g],size:16})},g)})}),jsx("div",{style:$r,role:"separator"}),m("headerRow","table_rows","Toggle header row",{type:"toggleHeaderRow"}),m("distribute","view_column","Distribute columns evenly",{type:"distributeColumns"}),m("autoFit","fit_width","Auto-fit to contents",{type:"autoFitContents"}),m("noWrap","wrap_text","Toggle no-wrap",{type:"toggleNoWrap"}),jsx("div",{style:$r,role:"separator"}),m("properties","settings","Table properties...",{type:"openTableProperties"})]})]})}function kS(e){return "type"in e&&e.type==="separator"}var sf={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},PS={...sf,background:"var(--doc-hover, #f3f4f6)"},lf={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text, #374151)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},RS={...lf,opacity:.4,cursor:"default"},ES={height:1,backgroundColor:"var(--doc-border, #e5e7eb)",margin:"4px 0"},IS={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted, #9ca3af)"},MS={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:8,zIndex:1001};function od({label:e,items:t,disabled:n}){let[o,r]=useState(false),[i,a]=useState(null),s=useRef(null),l=useRef(null),[d,c]=useState({top:0,left:0}),u=useCallback(()=>{r(false),a(null);},[]);useEffect(()=>{if(!o||!s.current)return;let f=s.current.getBoundingClientRect();c({top:f.bottom+2,left:f.left});},[o]),useEffect(()=>{if(!o)return;function f(g){let h=g.target;s.current&&!s.current.contains(h)&&l.current&&!l.current.contains(h)&&u();}function m(g){g.key==="Escape"&&u();}function b(){u();}return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),window.addEventListener("scroll",b,true),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m),window.removeEventListener("scroll",b,true);}},[o,u]);let p=f=>{f.disabled||f.submenuContent||f.onClick&&(f.onClick(),u());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:s,type:"button",onClick:()=>!n&&r(!o),onMouseDown:f=>f.preventDefault(),disabled:n,style:o?PS:sf,children:[e,jsx(se,{name:"arrow_drop_down",size:16})]}),o&&jsx("div",{ref:l,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:f=>f.preventDefault(),children:t.map((f,m)=>{if(kS(f))return jsx("div",{style:ES},`sep-${m}`);let b=f;if(b.customContent)return jsx("div",{onMouseDown:x=>x.preventDefault(),children:b.customContent},b.label);let g=!!b.submenuContent,h=i===b.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>g&&a(b.label),onMouseLeave:()=>g&&a(null),children:[jsxs("button",{type:"button",style:b.disabled?RS:lf,onClick:()=>p(b),onMouseDown:x=>x.preventDefault(),onMouseOver:x=>{b.disabled||(x.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)");},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsx(se,{name:b.icon,size:18}),jsx("span",{children:b.label}),b.shortcut&&jsx("span",{style:IS,children:b.shortcut}),g&&jsx("span",{style:{marginLeft:"auto"},children:jsx(se,{name:"keyboard_arrow_right",size:16})})]}),g&&h&&jsx("div",{style:MS,onMouseDown:x=>x.preventDefault(),children:b.submenuContent(u)})]},b.label)})})]})}var AS=20;function Fa({options:e,activeValue:t,triggerIcon:n,tooltipContent:o,onSelect:r,disabled:i=false,ariaLabel:a,testId:s}){let[l,d]=useState(false),c=useRef(null);useEffect(()=>{if(!l)return;let m=g=>{c.current&&!c.current.contains(g.target)&&d(false);},b=g=>{g.key==="Escape"&&d(false);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b);}},[l]);let u=useCallback(m=>{m.preventDefault(),m.stopPropagation();},[]),p=useCallback(m=>{i||r(m),d(false);},[i,r]),f=jsxs(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",l&&"bg-slate-100",i&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!i&&d(m=>!m),disabled:i,"aria-label":a??o,"aria-expanded":l,"aria-haspopup":"true","data-testid":s,children:[jsx(se,{name:n,size:AS}),jsx(se,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[l?f:jsx(wt,{content:o,children:f}),l&&!i&&jsx("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.12)",padding:6,zIndex:1e3},onMouseDown:m=>m.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:e.map(m=>{let b=t===m.value;return jsx("button",{type:"button",title:m.label,"data-testid":s?`${s}-${m.value}`:void 0,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:b?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:b?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:g=>g.preventDefault(),onMouseEnter:g=>{b||(g.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=b?"var(--doc-primary-light)":"transparent";},onClick:()=>p(m.value),children:jsx(se,{name:m.iconName,size:18})},m.value)})})})]})}var rd=[{value:"inline",label:"Inline with text",iconName:"format_image_left"},{value:"wrapRight",label:"Float left (wrap right)",iconName:"format_image_right"},{value:"wrapLeft",label:"Float right (wrap left)",iconName:"format_image_left"},{value:"topAndBottom",label:"Top and bottom",iconName:"horizontal_rule"},{value:"behind",label:"Behind text",iconName:"flip_to_back"},{value:"inFront",label:"In front of text",iconName:"flip_to_front"}];function BS(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function uf({imageContext:e,onChange:t,disabled:n=false}){let o=BS(e),r=rd.find(i=>i.value===o)||rd[0];return jsx(Fa,{options:rd,activeValue:o,triggerIcon:r.iconName,tooltipContent:`Wrap: ${r.label}`,onSelect:t,disabled:n,testId:"toolbar-image-wrap"})}var HS=[{value:"rotateCW",label:"Rotate clockwise",iconName:"rotate_right"},{value:"rotateCCW",label:"Rotate counter-clockwise",iconName:"rotate_left"},{value:"flipH",label:"Flip horizontal",iconName:"swap_horiz"},{value:"flipV",label:"Flip vertical",iconName:"swap_vert"}];function pf({onTransform:e,disabled:t=false}){return jsx(Fa,{options:HS,triggerIcon:"rotate_right",tooltipContent:"Transform",onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var zS={FFFF00:"yellow","00FF00":"green","00FFFF":"cyan",FF00FF:"magenta","0000FF":"blue",FF0000:"red","00008B":"darkBlue","008080":"darkCyan","008000":"darkGreen",800080:"darkMagenta","8B0000":"darkRed",808e3:"darkYellow",808080:"darkGray",C0C0C0:"lightGray","000000":"black",FFFFFF:"white"};function id(e){let t=e.replace(/^#/,"").toUpperCase();return zS[t]||null}function yn({active:e=false,disabled:t=false,title:n,onClick:o,children:r,className:i,ariaLabel:a}){let s=a?.toLowerCase().replace(/\s+/g,"-")||n?.toLowerCase().replace(/\s+/g,"-").replace(/\([^)]*\)/g,"").trim(),l=c=>{c.preventDefault();},d=jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",e&&"bg-slate-900 text-white hover:bg-slate-800 hover:text-white",t&&"opacity-30 cursor-not-allowed",i),onMouseDown:l,onClick:t?void 0:o,disabled:t,"aria-pressed":e,"aria-label":a||n,"data-testid":s?`toolbar-${s}`:void 0,children:r});return n?jsx(wt,{content:n,children:d}):d}function Jn({label:e,children:t,className:n}){return jsx("div",{className:Ce("flex items-center gap-0.5 px-1 border-r border-slate-200/50 last:border-r-0",n),role:"group","aria-label":e,children:t})}function WS(){return jsx("div",{className:"w-px h-6 bg-slate-200 mx-1.5",role:"separator"})}var Mn=20;function ad({currentFormatting:e={},onFormat:t,onUndo:n,onRedo:o,canUndo:r=false,canRedo:i=false,disabled:a=false,className:s,style:l,enableShortcuts:d=true,editorRef:c,children:u,showFontPicker:p=true,showFontSizePicker:f=true,showTextColorPicker:m=true,showHighlightColorPicker:b=true,showAlignmentButtons:g=true,showListButtons:h=true,showLineSpacingPicker:x=true,showStylePicker:y=true,documentStyles:k,theme:T,onPrint:A,showPrintButton:B=true,showZoomControl:R=true,zoom:E,onZoomChange:S,onRefocusEditor:N,onInsertTable:_,showTableInsert:U=true,onInsertImage:Z,onInsertPageBreak:L,onInsertTOC:H,imageContext:q,onImageWrapType:xe,onImageTransform:ie,onOpenImageProperties:we,tableContext:M,onTableAction:O}){let C=useRef(null),P=useCallback(W=>{!a&&t&&t(W);},[a,t]),I=useCallback(()=>{!a&&r&&n&&n();},[a,r,n]),z=useCallback(()=>{!a&&i&&o&&o();},[a,i,o]),Y=useCallback(W=>{!a&&t&&(t({type:"fontFamily",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),j=useCallback(W=>{!a&&t&&(t({type:"fontSize",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),F=useCallback(W=>{!a&&t&&(t({type:"textColor",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),V=useCallback(W=>{!a&&t&&(t({type:"highlightColor",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),G=useCallback(W=>{!a&&t&&t({type:"alignment",value:W});},[a,t]),be=useCallback(()=>{!a&&t&&t("bulletList");},[a,t]),me=useCallback(()=>{!a&&t&&t("numberedList");},[a,t]),oe=useCallback(()=>{!a&&t&&t("indent");},[a,t]),K=useCallback(()=>{!a&&t&&t("outdent");},[a,t]),de=useCallback(W=>{!a&&t&&(t({type:"lineSpacing",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),Fe=useCallback(W=>{!a&&t&&(t({type:"applyStyle",value:W}),requestAnimationFrame(()=>N?.()));},[a,t,N]),Ke=useCallback((W,Te)=>{!a&&_&&(_(W,Te),requestAnimationFrame(()=>N?.()));},[a,_,N]),Ge=useCallback(W=>{!a&&O&&(O(W),requestAnimationFrame(()=>N?.()));},[a,O,N]);useEffect(()=>{if(!d)return;let W=Te=>{let Ie=Te.target,Me=c?.current,Qe=C.current,Be=Me?.contains(Ie),xt=Qe?.contains(Ie);if(!Be&&!xt)return;if((Te.ctrlKey||Te.metaKey)&&!Te.altKey)switch(Te.key.toLowerCase()){case "b":Te.preventDefault(),P("bold");break;case "i":Te.preventDefault(),P("italic");break;case "u":Te.preventDefault(),P("underline");break;case "=":Te.shiftKey?(Te.preventDefault(),P("superscript")):(Te.preventDefault(),P("subscript"));break;case "l":Te.preventDefault(),G("left");break;case "e":Te.preventDefault(),G("center");break;case "r":Te.preventDefault(),G("right");break;case "j":Te.preventDefault(),G("both");break;case "k":Te.preventDefault(),P("insertLink");break}};return document.addEventListener("keydown",W),()=>{document.removeEventListener("keydown",W);}},[d,P,c]);let Ye=useCallback(W=>{let Te=W.target;Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.tagName==="SELECT"||Te.tagName==="OPTION"||W.preventDefault();},[]),ze=useCallback(W=>{let Te=W.target,Ie=document.activeElement;Te.tagName==="SELECT"||Te.tagName==="OPTION"||Ie?.tagName==="SELECT"||requestAnimationFrame(()=>{N?.();});},[N]);return jsxs("div",{ref:C,className:Ce("flex items-center gap-0 px-2 py-2 bg-white border-b border-slate-100 min-h-[44px] overflow-x-auto",s),style:l,role:"toolbar","aria-label":"Formatting toolbar","data-testid":"toolbar",onMouseDown:Ye,onMouseUp:ze,children:[B&&A&&jsx(od,{label:"File",disabled:a,items:[{icon:"print",label:"Print",shortcut:"Ctrl+P",onClick:A}]}),jsx(od,{label:"Insert",disabled:a,items:[...Z?[{icon:"image",label:"Image",onClick:Z}]:[],...U&&_?[{icon:"grid_on",label:"Table",submenuContent:W=>jsx(Up,{onInsert:(Te,Ie)=>{Ke(Te,Ie),W();}})}]:[],...Z||U&&_?[{type:"separator"}]:[],{icon:"page_break",label:"Page break",onClick:L,disabled:!L},{icon:"format_list_numbered",label:"Table of contents",onClick:H,disabled:!H}]}),jsxs(Jn,{label:"History",children:[jsx(yn,{onClick:I,disabled:a||!r,title:"Undo (Ctrl+Z)",ariaLabel:"Undo",children:jsx(se,{name:"undo",size:Mn})}),jsx(yn,{onClick:z,disabled:a||!i,title:"Redo (Ctrl+Y)",ariaLabel:"Redo",children:jsx(se,{name:"redo",size:Mn})})]}),R&&jsx(Jn,{label:"Zoom",children:jsx(Uc,{value:E,onChange:S,minZoom:.5,maxZoom:2,disabled:a,compact:true,showButtons:false})}),y&&jsx(Jn,{label:"Styles",children:jsx(Zc,{value:e.styleId||"Normal",onChange:Fe,styles:k,theme:T,disabled:a,width:150})}),(p||f)&&jsxs(Jn,{label:"Font",children:[p&&jsx(Fc,{value:e.fontFamily||"Arial",onChange:Y,disabled:a,width:70,placeholder:"Arial"}),f&&jsx(Hc,{value:e.fontSize!==void 0?Dp(e.fontSize):11,onChange:j,disabled:a,width:50,placeholder:"11"})]}),jsxs(Jn,{label:"Text formatting",children:[jsx(yn,{onClick:()=>P("bold"),active:e.bold,disabled:a,title:"Bold (Ctrl+B)",ariaLabel:"Bold",children:jsx(se,{name:"format_bold",size:Mn})}),jsx(yn,{onClick:()=>P("italic"),active:e.italic,disabled:a,title:"Italic (Ctrl+I)",ariaLabel:"Italic",children:jsx(se,{name:"format_italic",size:Mn})}),jsx(yn,{onClick:()=>P("underline"),active:e.underline,disabled:a,title:"Underline (Ctrl+U)",ariaLabel:"Underline",children:jsx(se,{name:"format_underlined",size:Mn})}),jsx(yn,{onClick:()=>P("strikethrough"),active:e.strike,disabled:a,title:"Strikethrough",ariaLabel:"Strikethrough",children:jsx(se,{name:"strikethrough_s",size:Mn})}),m&&jsx(Np,{value:e.color?.replace(/^#/,""),onChange:F,disabled:a,title:"Font Color"}),b&&jsx(Hp,{value:e.highlight,onChange:V,disabled:a,title:"Text Highlight Color"}),jsx(yn,{onClick:()=>P("insertLink"),disabled:a,title:"Insert link (Ctrl+K)",ariaLabel:"Insert link",children:jsx(se,{name:"link",size:Mn})})]}),jsxs(Jn,{label:"Script",children:[jsx(yn,{onClick:()=>P("superscript"),active:e.superscript,disabled:a,title:"Superscript (Ctrl+Shift+=)",ariaLabel:"Superscript",children:jsx(se,{name:"superscript",size:Mn})}),jsx(yn,{onClick:()=>P("subscript"),active:e.subscript,disabled:a,title:"Subscript (Ctrl+=)",ariaLabel:"Subscript",children:jsx(se,{name:"subscript",size:Mn})})]}),g&&jsx($c,{value:e.alignment||"left",onChange:G,disabled:a}),(h||x)&&jsxs(Jn,{label:"List formatting",children:[h&&jsx(Wc,{listState:e.listState||ka(),onBulletList:be,onNumberedList:me,onIndent:oe,onOutdent:K,disabled:a,showIndentButtons:true,compact:true,hasIndent:(e.indentLeft??0)>0}),x&&jsx(Vc,{value:e.lineSpacing,onChange:de,disabled:a})]}),q&&xe&&jsxs(Jn,{label:"Image",children:[jsx(uf,{imageContext:q,onChange:xe,disabled:a}),ie&&jsx(pf,{onTransform:ie,disabled:a}),we&&jsx(yn,{onClick:we,disabled:a,title:"Image properties (alt text, border)...",ariaLabel:"Image properties",children:jsx(se,{name:"tune",size:Mn})})]}),M?.isInTable&&O&&jsxs(Jn,{label:"Table",children:[jsx(Gc,{onAction:Ge,disabled:a}),jsx(Yc,{onAction:Ge,disabled:a}),jsx(Xc,{onAction:Ge,disabled:a}),jsx(Qc,{onAction:Ge,disabled:a}),jsx(td,{onAction:Ge,disabled:a,tableContext:M})]}),jsx(yn,{onClick:()=>P("clearFormatting"),disabled:a,title:"Clear formatting",ariaLabel:"Clear formatting",children:jsx(se,{name:"format_clear",size:Mn})}),u]})}var Je={panel:{backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:"8px",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"13px"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:"var(--doc-bg-subtle)",borderBottom:"1px solid var(--doc-border)"},headerTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:600,color:"var(--doc-text)"},headerCount:{fontSize:"11px",color:"var(--doc-text-muted)",backgroundColor:"var(--doc-border)",padding:"2px 6px",borderRadius:"10px"},collapseButton:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,border:"none",backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text-muted)",borderRadius:"4px",transition:"background-color 0.15s"},body:{padding:"16px"},bodyCollapsed:{display:"none"},searchBox:{marginBottom:"12px"},searchInput:{width:"100%",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"13px",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s"},variableList:{display:"flex",flexDirection:"column",gap:"12px",maxHeight:"400px",overflowY:"auto"},variableItem:{display:"flex",flexDirection:"column",gap:"4px"},variableLabel:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},variableName:{fontFamily:"monospace",fontSize:"12px",color:"var(--doc-warning)",backgroundColor:"var(--doc-warning-bg)",padding:"2px 6px",borderRadius:"3px",border:"1px solid var(--doc-warning)"},variableDescription:{fontSize:"11px",color:"var(--doc-text-subtle)",fontStyle:"italic"},variableInput:{padding:"8px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"13px",outline:"none",transition:"border-color 0.15s, box-shadow 0.15s"},variableInputFocused:{borderColor:"var(--doc-primary)",boxShadow:"0 0 0 2px rgba(26, 115, 232, 0.2)"},variableInputFilled:{borderColor:"var(--doc-success)",backgroundColor:"var(--doc-success-bg)"},footer:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",padding:"12px 16px",borderTop:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg-input)"},footerStats:{fontSize:"11px",color:"var(--doc-text-subtle)"},footerButtons:{display:"flex",gap:"8px"},button:{padding:"8px 16px",border:"none",borderRadius:"4px",fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"background-color 0.15s, opacity 0.15s"},buttonPrimary:{backgroundColor:"var(--doc-primary)",color:"white"},buttonSecondary:{backgroundColor:"var(--doc-border)",color:"var(--doc-text)"},buttonDisabled:{opacity:.6,cursor:"not-allowed"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 16px",textAlign:"center",color:"var(--doc-text-subtle)"},emptyIcon:{marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"14px",fontWeight:500,color:"var(--doc-text-muted)",marginBottom:"4px"},emptyMessage:{fontSize:"12px",color:"var(--doc-text-placeholder)"}};function ld({variables:e,values:t={},onValuesChange:n,onApply:o,onReset:r,isApplying:i=false,disabled:a=false,className:s,style:l,title:d="Template Variables",emptyMessage:c="No template variables found in the document.",showCount:u=true,collapsible:p=true,defaultCollapsed:f=false,showSearch:m=false,descriptions:b={}}){let[g,h]=useState({}),[x,y]=useState(f),[k,T]=useState(""),[A,B]=useState(null),R=useMemo(()=>({...g,...t}),[g,t]),E=useMemo(()=>{if(!k)return e;let q=k.toLowerCase();return e.filter(xe=>xe.toLowerCase().includes(q)||(b[xe]||"").toLowerCase().includes(q))},[e,k,b]),S=useMemo(()=>e.filter(q=>R[q]?.trim()).length,[e,R]),N=useCallback((q,xe)=>{let ie={...R,[q]:xe};h(ie),n&&n(ie);},[R,n]),_=useCallback(q=>{q.preventDefault(),o&&!a&&!i&&o(R);},[R,o,a,i]),U=useCallback(()=>{h({}),r&&r(),n&&n({});},[r,n]),Z=useCallback(()=>{y(q=>!q);},[]),L=["docx-variable-panel"];s&&L.push(s),a&&L.push("docx-variable-panel-disabled"),x&&L.push("docx-variable-panel-collapsed");let H={...Je.panel,...l};return e.length===0?jsxs("div",{className:L.join(" "),style:H,children:[jsx("div",{style:Je.header,children:jsxs("span",{style:Je.headerTitle,children:[jsx(ff,{}),d]})}),jsxs("div",{style:Je.emptyState,children:[jsx("div",{style:Je.emptyIcon,children:jsx(ZS,{})}),jsx("div",{style:Je.emptyTitle,children:"No Variables"}),jsx("div",{style:Je.emptyMessage,children:c})]})]}):jsxs("form",{className:L.join(" "),style:H,onSubmit:_,children:[jsxs("div",{style:Je.header,children:[jsxs("span",{style:Je.headerTitle,children:[jsx(ff,{}),d,u&&jsx("span",{style:Je.headerCount,children:e.length})]}),p&&jsx("button",{type:"button",onClick:Z,style:Je.collapseButton,"aria-label":x?"Expand":"Collapse","aria-expanded":!x,children:jsx(US,{collapsed:x})})]}),jsxs("div",{style:{...Je.body,...x?Je.bodyCollapsed:{}},children:[m&&jsx("div",{style:Je.searchBox,children:jsx("input",{type:"text",value:k,onChange:q=>T(q.target.value),placeholder:"Search variables...",style:Je.searchInput,disabled:a})}),jsx("div",{style:Je.variableList,children:E.map(q=>jsx(VS,{name:q,value:R[q]||"",description:b[q],onChange:xe=>N(q,xe),disabled:a||i,isFocused:A===q,onFocus:()=>B(q),onBlur:()=>B(null)},q))})]}),!x&&jsxs("div",{style:Je.footer,children:[jsxs("span",{style:Je.footerStats,children:[S," of ",e.length," filled"]}),jsxs("div",{style:Je.footerButtons,children:[jsx("button",{type:"button",onClick:U,disabled:a||i,style:{...Je.button,...Je.buttonSecondary,...a||i?Je.buttonDisabled:{}},children:"Reset"}),jsx("button",{type:"submit",disabled:a||i,style:{...Je.button,...Je.buttonPrimary,...a||i?Je.buttonDisabled:{}},children:i?"Applying...":"Apply"})]})]})]})}function VS({name:e,value:t,description:n,onChange:o,disabled:r,isFocused:i,onFocus:a,onBlur:s}){let l={...Je.variableInput,...i?Je.variableInputFocused:{},...t.trim()?Je.variableInputFilled:{}};return jsxs("div",{style:Je.variableItem,className:"docx-variable-item",children:[jsx("label",{style:Je.variableLabel,children:jsx("span",{style:Je.variableName,children:`{{${e}}}`})}),n&&jsx("span",{style:Je.variableDescription,children:n}),jsx("input",{type:"text",value:t,onChange:d=>o(d.target.value),disabled:r,placeholder:`Enter value for ${e}`,style:l,onFocus:a,onBlur:s,className:"docx-variable-input","aria-label":`Value for ${e}`})]})}function ff(){return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M4 3C2.5 3 2 4 2 5.5V6.5C2 7 1.5 7.5 1 7.5V8.5C1.5 8.5 2 9 2 9.5V10.5C2 12 2.5 13 4 13",stroke:"#e4b416",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"}),jsx("path",{d:"M12 3C13.5 3 14 4 14 5.5V6.5C14 7 14.5 7.5 15 7.5V8.5C14.5 8.5 14 9 14 9.5V10.5C14 12 13.5 13 12 13",stroke:"#e4b416",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})]})}function ZS(){return jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"8",y:"12",width:"32",height:"24",rx:"2",stroke:"var(--doc-border)",strokeWidth:"2",fill:"none"}),jsx("path",{d:"M14 20H34M14 26H28",stroke:"var(--doc-border)",strokeWidth:"2",strokeLinecap:"round"})]})}function US({collapsed:e}){return jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s"},children:jsx("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var gf=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=useState(false);return useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":"Document outline",style:{position:"absolute",top:o,left:30,bottom:0,width:240,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:r?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:a=>a.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsx("button",{onClick:n,"aria-label":"Close outline",style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:"Close outline",children:jsx(se,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?jsx("div",{style:{padding:"8px 16px",color:"#80868b",fontSize:13,lineHeight:"20px"},children:"No headings found. Add headings to your document to see them here."}):e.map((a,s)=>jsx("div",{style:{marginLeft:a.level*12},children:jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(a.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"#1f1f1f",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:a.text,children:a.text})},`${a.pmPos}-${s}`))})]})};var bf=createContext(null);function JS(){let e=useContext(bf);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function cd({children:e}){let[t,n]=useState([]),o=useRef(0),r=useCallback((u,p,f)=>{let m=`error-${++o.current}-${Date.now()}`,b={id:m,message:u,severity:p,details:f,timestamp:Date.now()};return n(g=>[...g,b]),p!=="error"&&setTimeout(()=>{l(m);},5e3),m},[]),i=useCallback((u,p)=>{r(u,"error",p);},[r]),a=useCallback((u,p)=>{r(u,"warning",p);},[r]),s=useCallback((u,p)=>{r(u,"info",p);},[r]),l=useCallback(u=>{n(p=>p.map(f=>f.id===u?{...f,dismissed:true}:f)),setTimeout(()=>{n(p=>p.filter(f=>f.id!==u));},300);},[]),d=useCallback(()=>{n([]);},[]),c={notifications:t,showError:i,showWarning:a,showInfo:s,dismissNotification:l,clearNotifications:d};return jsxs(bf.Provider,{value:c,children:[e,jsx(QS,{notifications:t,onDismiss:l})]})}function QS({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:n.map(r=>jsx(eC,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function eC({notification:e,onDismiss:t}){let[n,o]=useState(false),i=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"#f5c6cb",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"#ffeeba",text:"#856404",icon:"var(--doc-warning)"};case "info":return {bg:"#e8f4fd",border:"#b8daff",text:"#0c5460",icon:"var(--doc-primary)"}}})(e.severity),a={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},d={flex:1,minWidth:0},c={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},u={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},f=m=>{switch(m){case "error":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[jsx("style",{children:`
|
|
4
|
-
@keyframes slideIn {
|
|
5
|
-
from {
|
|
6
|
-
opacity: 0;
|
|
7
|
-
transform: translateX(100%);
|
|
8
|
-
}
|
|
9
|
-
to {
|
|
10
|
-
opacity: 1;
|
|
11
|
-
transform: translateX(0);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`}),jsxs("div",{style:s,children:[jsx("span",{style:l,children:f(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:c,children:e.message}),e.details&&jsxs(Fragment$1,{children:[jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsx("div",{style:u,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Bi=class extends Component{constructor(n){super(n);e(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:i}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsx(tC,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function tC({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"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxs("div",{className:"docx-error-fallback",style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:a,children:"Something went wrong"}),jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxs("div",{style:l,children:[jsx("strong",{children:"Error:"})," ",e.message,t&&jsxs(Fragment$1,{children:[`
|
|
15
|
-
|
|
16
|
-
`,jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:d,children:"Try Again"})]})}function nC({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"},d={padding:"8px 16px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"13px",cursor:"pointer"};return jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h3",{style:a,children:"Unable to Parse Document"}),jsx("p",{style:s,children:e}),t&&jsx("div",{style:l,children:t}),n&&jsx("button",{type:"button",onClick:n,style:d,children:"Try Again"})]})}function oC({feature:e,description:t,className:n=""}){let o={display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--doc-warning-bg)",border:"1px solid #ffeeba",borderRadius:"4px",fontSize:"12px",color:"#856404"},r={flexShrink:0,color:"var(--doc-warning)"};return jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsx("span",{style:r,children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxs("span",{children:[jsx("strong",{children:e}),t&&`: ${t}`]})]})}function rC(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function iC(e){let t=e.message.toLowerCase();return t.includes("network")||t.includes("fetch")?"Network error. Please check your internet connection and try again.":t.includes("parse")||t.includes("xml")||t.includes("invalid")?"The document could not be parsed. It may be corrupted or in an unsupported format.":t.includes("permission")||t.includes("access")?"Access denied. You may not have permission to access this file.":t.includes("not found")||t.includes("404")?"The requested file was not found.":t.includes("timeout")?"The operation timed out. Please try again.":"An unexpected error occurred. Please try again."}var sC={display:"inline-flex",alignItems:"center",justifyContent:"center",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"13px",userSelect:"none",transition:"opacity 0.2s, transform 0.2s"},lC={position:"absolute",zIndex:100,pointerEvents:"auto"},cC={default:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"var(--doc-text)",padding:"6px 12px",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.1)"},minimal:{backgroundColor:"transparent",color:"var(--doc-text-muted)",padding:"4px 8px"},badge:{backgroundColor:"var(--doc-primary)",color:"white",padding:"4px 10px",borderRadius:"4px",fontWeight:500,fontSize:"12px"},pill:{backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",padding:"6px 14px",borderRadius:"16px",fontSize:"12px",fontWeight:500}},dC={"bottom-left":{bottom:"16px",left:"16px"},"bottom-center":{bottom:"16px",left:"50%",transform:"translateX(-50%)"},"bottom-right":{bottom:"16px",right:"16px"},"top-left":{top:"16px",left:"16px"},"top-center":{top:"16px",left:"50%",transform:"translateX(-50%)"},"top-right":{top:"16px",right:"16px"}};function dd({currentPage:e,totalPages:t,position:n="bottom-center",variant:o="default",floating:r=true,showPrefix:i=true,formatText:a,onClick:s,disabled:l=false,className:d="",style:c,children:u}){let p=useMemo(()=>a?a(e,t):i?`Page ${e} of ${t}`:`${e} / ${t}`,[e,t,a,i]),f={...sC,...cC[o],...r?lC:{},...r?dC[n]:{},...s&&!l?{cursor:"pointer"}:{},...l?{opacity:.5,pointerEvents:"none"}:{},...c},m=()=>{!l&&s&&s();};return jsx("div",{className:`docx-page-indicator docx-page-indicator-${o} ${d}`,style:f,onClick:m,role:s?"button":"status","aria-label":`Page ${e} of ${t}`,"aria-live":"polite",tabIndex:s&&!l?0:void 0,onKeyDown:b=>{s&&!l&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s());},children:u||p})}function yf(e){let t=["th","st","nd","rd"],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function uC(e){return (t,n)=>e.replace("{current}",String(t)).replace("{total}",String(n)).replace("{ordinal}",yf(t))}function pC(e,t){return t<=1?100:Math.round((e-1)/(t-1)*100)}function fC(e){return e===1}function mC(e,t){return e===t}function gC(e,t,n=20){let o=0;for(let r=0;r<t.length;r++){let i=o,a=o+t[r],s=(i+a)/2;if(e<s)return r+1;o=a+n;}return t.length}function hC(e,t,n,o=20){if(e<1||e>t.length)return 0;let r=0;for(let s=0;s<e-1;s++)r+=t[s]+o;let i=t[e-1],a=Math.max(0,(n-i)/2);return Math.max(0,r-a)}function xC(){return jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"15 18 9 12 15 6"})})}function yC(){return jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"9 18 15 12 9 6"})})}function vC(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"18 15 12 9 6 15"})})}function SC(){return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"6 9 12 15 18 9"})})}var CC={display:"inline-flex",alignItems:"center",gap:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"13px",userSelect:"none",transition:"opacity 0.2s"},TC={position:"absolute",zIndex:100,pointerEvents:"auto"},wC={default:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"var(--doc-text)",padding:"4px 8px",borderRadius:"6px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.1)"},compact:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"var(--doc-text)",padding:"2px 4px",borderRadius:"4px",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.1)",border:"1px solid rgba(0, 0, 0, 0.08)",fontSize:"12px"},minimal:{backgroundColor:"transparent",color:"var(--doc-text-muted)",padding:"4px"}},kC={"bottom-left":{bottom:"16px",left:"16px"},"bottom-center":{bottom:"16px",left:"50%",transform:"translateX(-50%)"},"bottom-right":{bottom:"16px",right:"16px"},"top-left":{top:"16px",left:"16px"},"top-center":{top:"16px",left:"50%",transform:"translateX(-50%)"},"top-right":{top:"16px",right:"16px"}},vf={display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",color:"var(--doc-text-muted)",cursor:"pointer",transition:"background-color 0.15s, color 0.15s"},Sf={backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)"},Cf={opacity:.4,cursor:"not-allowed"},PC={display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.15s",minWidth:"80px",justifyContent:"center"},RC={backgroundColor:"rgba(0, 0, 0, 0.04)"};function EC({currentPage:e,totalPages:t,onNavigate:n,onClose:o,anchorRef:r}){let[i,a]=useState(String(e)),[s,l]=useState(null),d=useRef(null),c=useRef(null);useEffect(()=>{d.current?.focus(),d.current?.select();},[]),useEffect(()=>{let B=R=>{c.current&&!c.current.contains(R.target)&&r.current&&!r.current.contains(R.target)&&o();};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[o,r]),useEffect(()=>{let B=R=>{R.key==="Escape"&&o();};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[o]);let u=useCallback(()=>{let B=parseInt(i,10);if(isNaN(B)){l("Please enter a number");return}if(B<1||B>t){l(`Page must be 1-${t}`);return}n(B),o();},[i,t,n,o]),p=B=>{a(B.target.value),l(null);},f=B=>{if(B.key==="Enter")B.preventDefault(),u();else if(B.key==="ArrowUp"){B.preventDefault();let R=Math.min(parseInt(i,10)+1||1,t);a(String(R)),l(null);}else if(B.key==="ArrowDown"){B.preventDefault();let R=Math.max(parseInt(i,10)-1||1,1);a(String(R)),l(null);}},m=()=>{n(1),o();},b=()=>{n(t),o();},g={position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",border:"1px solid rgba(0, 0, 0, 0.1)",padding:"12px",minWidth:"200px",zIndex:1e3},h={display:"flex",alignItems:"center",gap:"8px",marginBottom:s?"4px":"12px"},x={flex:1,padding:"8px 12px",fontSize:"14px",border:s?"1px solid var(--doc-error)":"1px solid var(--doc-border)",borderRadius:"4px",outline:"none",textAlign:"center",fontFamily:"inherit"},y={padding:"8px 16px",fontSize:"14px",fontWeight:500,backgroundColor:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},k={color:"var(--doc-error)",fontSize:"12px",marginBottom:"8px"},T={display:"flex",justifyContent:"space-between",gap:"8px"},A={flex:1,padding:"6px 12px",fontSize:"12px",backgroundColor:"var(--doc-bg-muted)",color:"var(--doc-text)",border:"1px solid var(--doc-border-light)",borderRadius:"4px",cursor:"pointer"};return jsxs("div",{ref:c,style:g,role:"dialog","aria-label":"Go to page",children:[jsxs("div",{style:{fontSize:"12px",color:"var(--doc-text-muted)",marginBottom:"8px",textAlign:"center"},children:["Go to page (1-",t,")"]}),jsxs("div",{style:h,children:[jsx("input",{ref:d,type:"text",value:i,onChange:p,onKeyDown:f,style:x,"aria-label":"Page number","aria-invalid":!!s}),jsx("button",{onClick:u,style:y,type:"button",children:"Go"})]}),s&&jsx("div",{style:k,children:s}),jsxs("div",{style:T,children:[jsx("button",{onClick:m,style:A,disabled:e===1,type:"button",children:"First"}),jsx("button",{onClick:b,style:A,disabled:e===t,type:"button",children:"Last"})]})]})}function fd({currentPage:e,totalPages:t,onNavigate:n,position:o="bottom-center",variant:r="default",floating:i=true,showButtons:a=true,disabled:s=false,className:l="",style:d}){let[c,u]=useState(false),[p,f]=useState(false),[m,b]=useState(false),[g,h]=useState(false),x=useRef(null),y=e>1,k=e<t,T=useCallback(()=>{y&&!s&&n(e-1);},[y,s,e,n]),A=useCallback(()=>{k&&!s&&n(e+1);},[k,s,e,n]),B=useCallback(L=>{s||(L.key==="ArrowLeft"||L.key==="PageUp"?(L.preventDefault(),T()):L.key==="ArrowRight"||L.key==="PageDown"?(L.preventDefault(),A()):L.key==="Home"?(L.preventDefault(),n(1)):L.key==="End"&&(L.preventDefault(),n(t)));},[s,T,A,n,t]),R=useCallback(()=>{s||u(L=>!L);},[s]),E=useCallback(()=>{u(false);},[]),S=useCallback(L=>{n(L),E();},[n,E]),N={...CC,...wC[r],...i?TC:{},...i?kC[o]:{},...s?{opacity:.5,pointerEvents:"none"}:{},...d},_={...vf,...r==="compact"?{width:"24px",height:"24px"}:{},...p&&y?Sf:{},...y?{}:Cf},U={...vf,...r==="compact"?{width:"24px",height:"24px"}:{},...m&&k?Sf:{},...k?{}:Cf},Z={...PC,...r==="compact"?{padding:"2px 6px",minWidth:"60px"}:{},...g&&!s?RC:{},...s?{cursor:"not-allowed"}:{}};return jsxs("div",{className:`docx-page-navigator docx-page-navigator-${r} ${l}`,style:N,role:"navigation","aria-label":"Page navigation",onKeyDown:B,tabIndex:0,children:[a&&jsx("button",{onClick:T,disabled:!y||s,style:_,onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),"aria-label":"Previous page",title:"Previous page (\u2190)",type:"button",children:jsx(xC,{})}),jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:x,onClick:R,style:Z,onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),"aria-haspopup":"dialog","aria-expanded":c,"aria-label":`Page ${e} of ${t}. Click to go to a specific page.`,title:"Click to go to a specific page",disabled:s,type:"button",children:[jsxs("span",{children:["Page ",jsx("strong",{children:e})," of ",t]}),c?jsx(vC,{}):jsx(SC,{})]}),c&&jsx(EC,{currentPage:e,totalPages:t,onNavigate:S,onClose:E,anchorRef:x})]}),a&&jsx("button",{onClick:A,disabled:!k||s,style:U,onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),"aria-label":"Next page",title:"Next page (\u2192)",type:"button",children:jsx(yC,{})})]})}function IC(e){let t=e.trim(),n=parseInt(t,10);return isNaN(n)?null:n}function MC(e,t){return Number.isInteger(e)&&e>=1&&e<=t}function LC(e,t){return Math.min(Math.max(1,Math.round(e)),t)}function FC(){return [{key:"\u2190 or PageUp",description:"Previous page"},{key:"\u2192 or PageDown",description:"Next page"},{key:"Home",description:"First page"},{key:"End",description:"Last page"},{key:"Enter (in input)",description:"Go to page"}]}function DC(e,t,n){return e===t?`Page ${e} of ${n}`:`Pages ${e}-${t} of ${n}`}function AC(e,t){return t<=1?100:Math.round((e-1)/(t-1)*100)}var wf=12240,Na=1440,Ha=1440,Oa=567,gd=22,HC="var(--doc-text-muted)",OC="var(--doc-text-subtle)",Tf="rgba(0, 0, 0, 0.06)",zC="#4285f4",_C="#3367d6",$C="#2a56c6",gr=5;function WC(e,t){return t==="inch"?(e/Ha).toFixed(2)+'"':(e/Oa).toFixed(1)+" cm"}function bd({sectionProps:e,zoom:t=1,editable:n$1=false,onLeftMarginChange:o,onRightMarginChange:r,onFirstLineIndentChange:i,showFirstLineIndent:a=false,firstLineIndent:s=0,hangingIndent:l=false,indentLeft:d=0,indentRight:c=0,onIndentLeftChange:u,onIndentRightChange:p,unit:f="inch",className:m="",style:b,tabStops:g,onTabStopRemove:h}){let[x$1,y]=useState(null),[k,T]=useState(null),[A,B]=useState(null),[R,E]=useState(null),S=useRef(null),N=e?.pageWidth??wf,_=e?.marginLeft??Na,U=e?.marginRight??Na,Z=N-_-U,L=n(N)*t,H=n(_)*t,q=n(U)*t,xe=n(d)*t,ie=n(c)*t,we=l?-s:s,M=n(we)*t,O=H+xe,C=L-q-ie,P=H+xe+M,I=useCallback((F,V)=>{n$1&&(F.preventDefault(),F.stopPropagation(),y(V));},[n$1]),z=useCallback(F=>{if(!x$1||!S.current)return;let V=S.current.getBoundingClientRect(),G=F.clientX-V.left;E(G);let be=o$1(G/t);if(x$1==="leftMargin"){let me=N-U-720,oe=Math.round(Math.max(0,Math.min(be,me)));B(oe),o?.(oe);}else if(x$1==="rightMargin"){let me=N-be,oe=N-_-720,K=Math.round(Math.max(0,Math.min(me,oe)));B(K),r?.(K);}else if(x$1==="firstLineIndent"){let me=_+d,oe=be-me,K=Z-d-c-720,de=Math.round(Math.max(-d,Math.min(oe,K)));B(de),i?.(de);}else if(x$1==="leftIndent"){let me=be-_,oe=Z-c-720,K=Math.round(Math.max(0,Math.min(me,oe)));B(K),u?.(K);}else if(x$1==="rightIndent"){let oe=N-U-be,K=Z-d-720,de=Math.round(Math.max(0,Math.min(oe,K)));B(de),p?.(de);}},[x$1,t,N,_,U,Z,d,c,o,r,i,u,p]),Y=useCallback(()=>{y(null),B(null),E(null);},[]);useEffect(()=>{if(x$1)return document.addEventListener("mousemove",z),document.addEventListener("mouseup",Y),()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",Y);}},[x$1,z,Y]);let j=KC(N,t,f);return jsxs("div",{ref:S,className:`docx-horizontal-ruler ${m}`,style:{position:"relative",width:x(L),height:gd,backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:x$1?"ew-resize":"default",...b},role:"slider","aria-label":"Horizontal ruler","aria-valuemin":0,"aria-valuemax":N,children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:x(H),height:gd,backgroundColor:Tf,borderRight:"1px solid rgba(0,0,0,0.12)",cursor:n$1?"ew-resize":"default",zIndex:1},onMouseDown:n$1&&o?F=>I(F,"leftMargin"):void 0}),jsx("div",{style:{position:"absolute",top:0,right:0,width:x(q),height:gd,backgroundColor:Tf,borderLeft:"1px solid rgba(0,0,0,0.12)",cursor:n$1?"ew-resize":"default",zIndex:1},onMouseDown:n$1&&r?F=>I(F,"rightMargin"):void 0}),jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:j.map((F,V)=>jsx(VC,{tick:F},V))}),a&&jsx(hd,{direction:"down",positionPx:P,editable:n$1,isDragging:x$1==="firstLineIndent",isHovered:k==="firstLineIndent",onMouseEnter:()=>T("firstLineIndent"),onMouseLeave:()=>T(null),onMouseDown:F=>I(F,"firstLineIndent"),label:"First line indent"}),n$1&&u&&jsx(hd,{direction:"up",positionPx:O,editable:n$1,isDragging:x$1==="leftIndent",isHovered:k==="leftIndent",onMouseEnter:()=>T("leftIndent"),onMouseLeave:()=>T(null),onMouseDown:F=>I(F,"leftIndent"),label:"Left indent"}),n$1&&p&&jsx(hd,{direction:"down",positionPx:C,editable:n$1,isDragging:x$1==="rightIndent",isHovered:k==="rightIndent",onMouseEnter:()=>T("rightIndent"),onMouseLeave:()=>T(null),onMouseDown:F=>I(F,"rightIndent"),label:"Right indent"}),g?.map(F=>jsx(qC,{tabStop:F,positionPx:n(F.position)*t,onDoubleClick:()=>h?.(F.position)},F.position)),x$1&&A!==null&&R!==null&&jsx(ZC,{value:WC(A,f),positionPx:R})]})}function VC({tick:e}){return jsxs(Fragment$1,{children:[jsx("div",{style:{position:"absolute",left:x(e.position),bottom:0,width:1,height:e.height,backgroundColor:OC}}),e.label&&jsx("div",{style:{position:"absolute",left:x(e.position),top:3,transform:"translateX(-50%)",fontSize:"9px",color:HC,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function hd({direction:e,positionPx:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,label:l}){let d=o?$C:r?_C:zC,c=Math.round(gr*1.6),u={position:"absolute",left:x(t-gr),width:gr*2,height:c+2,cursor:n?"ew-resize":"default",zIndex:o?10:4,...e==="down"?{top:0}:{bottom:0}},p=e==="down"?{position:"absolute",top:1,left:0,width:0,height:0,borderLeft:`${gr}px solid transparent`,borderRight:`${gr}px solid transparent`,borderTop:`${c}px solid ${d}`,transition:"border-top-color 0.1s"}:{position:"absolute",bottom:1,left:0,width:0,height:0,borderLeft:`${gr}px solid transparent`,borderRight:`${gr}px solid transparent`,borderBottom:`${c}px solid ${d}`,transition:"border-bottom-color 0.1s"};return jsx("div",{className:"docx-ruler-indent",style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":l,"aria-orientation":"horizontal",tabIndex:n?0:-1,children:jsx("div",{style:p})})}function ZC({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:x(t),top:-22,transform:"translateX(-50%)",backgroundColor:"#333",color:"#fff",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var UC={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function qC({tabStop:e,positionPx:t,onDoubleClick:n}){return jsx("div",{style:{position:"absolute",left:x(t-5),bottom:0,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"#555",cursor:"pointer",userSelect:"none"},onDoubleClick:o=>{o.stopPropagation(),n();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:UC[e.alignment]||"L"})}function KC(e,t,n$1){let o=[];if(n$1==="inch"){let r=Ha/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=n(s)*t;a%8===0?o.push({position:l,height:10,label:a/8>0?String(a/8):void 0}):a%4===0?o.push({position:l,height:6}):a%2===0?o.push({position:l,height:4}):o.push({position:l,height:2});}}else {let r=Oa/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=n(s)*t;a%10===0?o.push({position:l,height:10,label:a/10>0?String(a/10):void 0}):a%5===0?o.push({position:l,height:6}):o.push({position:l,height:3});}}return o}function GC(e,t,n,o){let r=o$1(e/o);return t==="left"?Math.max(0,r):Math.max(0,o$1(n/o)-r)}function YC(e,t=1){let n$1=e?.pageWidth??wf,o=e?.marginLeft??Na,r=e?.marginRight??Na,i=n(n$1)*t,a=n(o)*t,s=n(r)*t;return {width:i,leftMargin:a,rightMargin:s,contentWidth:i-a-s}}function jC(e,t){return t==="inch"?(e/Ha).toFixed(2)+'"':(e/Oa).toFixed(1)+" cm"}function XC(e,t){let n=parseFloat(e.replace(/[^\d.]/g,""));return isNaN(n)?null:Math.round(n*(t==="inch"?Ha:Oa))}var tT=15840,Rf=1440,nT=1440,oT=567,If=20,rT="var(--doc-text-muted)",iT="var(--doc-text-subtle)",aT="var(--doc-primary)",sT="var(--doc-primary)",lT="var(--doc-primary-hover)";function Mf({sectionProps:e,zoom:t=1,editable:n$1=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,d]=useState(null),[c,u]=useState(null),p=useRef(null),f=e?.pageHeight??tT,m=e?.marginTop??Rf,b=e?.marginBottom??Rf,g=n(f)*t,h=n(m)*t,x$1=n(b)*t,y=useCallback((R,E)=>{n$1&&(R.preventDefault(),d(E));},[n$1]),k=useCallback(R=>{if(!l||!p.current)return;let E=p.current.getBoundingClientRect(),S=R.clientY-E.top,N=o$1(S/t);if(l==="topMargin"){let _=f-b-720,U=Math.max(0,Math.min(N,_));o?.(Math.round(U));}else if(l==="bottomMargin"){let _=f-N,U=f-m-720,Z=Math.max(0,Math.min(_,U));r?.(Math.round(Z));}},[l,t,f,m,b,o,r]),T=useCallback(()=>{d(null);},[]);useEffect(()=>{if(l)return document.addEventListener("mousemove",k),document.addEventListener("mouseup",T),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",T);}},[l,k,T]);let A=dT(f,t,i),B={position:"relative",width:If,height:x(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:B,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:A.map((R,E)=>jsx(cT,{tick:R},E))}),jsx(Ef,{type:"topMargin",position:h,editable:n$1,isDragging:l==="topMargin",isHovered:c==="topMargin",onMouseEnter:()=>u("topMargin"),onMouseLeave:()=>u(null),onMouseDown:R=>y(R,"topMargin")}),jsx(Ef,{type:"bottomMargin",position:g-x$1,editable:n$1,isDragging:l==="bottomMargin",isHovered:c==="bottomMargin",onMouseEnter:()=>u("bottomMargin"),onMouseLeave:()=>u(null),onMouseDown:R=>y(R,"bottomMargin")})]})}function cT({tick:e}){let t={position:"absolute",top:x(e.position),right:0,height:1,width:e.width,backgroundColor:iT},n={position:"absolute",top:x(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:rT,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment$1,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function Ef({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?lT:r?sT:aT,d={position:"absolute",top:x(t-5),right:0,width:If,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},c={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:d,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsx("div",{style:c})})}function dT(e,t,n$1){let o=[];if(n$1==="inch"){let r=nT/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=n(s)*t;if(a%8===0){let d=a/8;o.push({position:l,width:10,label:d>0?String(d):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=oT/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=n(s)*t;if(a%10===0){let d=a/10;o.push({position:l,width:10,label:d>0?String(d):void 0});}else a%5===0?o.push({position:l,width:6}):o.push({position:l,width:3});}}return o}function _a(){return {matchCase:false,matchWholeWord:false,useRegex:false}}function yd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vd(e,t){if(!e)return null;try{let n;t.useRegex?n=e:n=yd(e),t.matchWholeWord&&(n=`\\b${n}\\b`);let o=t.matchCase?"g":"gi";return new RegExp(n,o)}catch{return null}}function $a(e,t,n){if(!e||!t)return [];let o=[],r=t;n.matchCase||(r=t.toLowerCase());let i=c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a;n.matchWholeWord?a=`\\b${i(r)}\\b`:a=i(r);let s=n.matchCase?"g":"gi",l=new RegExp(a,s),d;for(;(d=l.exec(e))!==null;)o.push({start:d.index,end:d.index+d[0].length}),d[0].length===0&&l.lastIndex++;return o}function Ff(e,t,n,o){let r=vd(t,o);return r?e.replace(r,n):e}function Df(e,t,n,o,r=0){let i=$a(e,t,o),a=i.find(l=>l.start>=r)||i[0];return a?{content:e.substring(0,a.start)+n+e.substring(a.end),replaced:true,matchStart:a.start,matchEnd:a.start+n.length}:{content:e,replaced:false,matchStart:-1,matchEnd:-1}}function Af(e){return e?e.totalCount===0?"No results":e.totalCount===1?"1 match":`${e.currentIndex+1} of ${e.totalCount} matches`:""}function Bf(e){return !e||e.trim()===""}function Nf(){return {currentMatchColor:"#FFFF00",otherMatchColor:"#FFFFAA"}}function za(e){if(!e||!e.content)return "";let t="";for(let n of e.content)n.type==="text"?t+=n.text||"":n.type==="tab"?t+=" ":n.type==="break"&&n.breakType==="textWrapping"&&(t+=`
|
|
17
|
-
`);return t}function pT(e){if(!e||!e.content)return "";let t="";for(let n of e.content)if(n.type==="run")t+=za(n);else if(n.type==="hyperlink")for(let o of n.children||[])o.type==="run"&&(t+=za(o));return t}function Ni(e,t,n){if(!e||!t)return [];let o=[],r=e.package?.document||e.package?.document;if(!r||!r.content)return o;let i=0;for(let a of r.content)if(a.type==="paragraph"){let s=Sd(a,t,n,i);o.push(...s),i++;}else if(a.type==="table")for(let s of a.rows||[])for(let l of s.cells||[])for(let d of l.content||[])d.type;return o}function Sd(e,t,n,o){let r=[],i=pT(e);if(!i)return r;let a=$a(i,t,n);for(let s of a){let l=fT(e,s.start);r.push({paragraphIndex:o,contentIndex:l.contentIndex,startOffset:l.offsetInContent,endOffset:l.offsetInContent+(s.end-s.start),text:i.substring(s.start,s.end)});}return r}function fT(e,t){if(!e||!e.content)return {contentIndex:0,runIndex:0,offsetInContent:t};let n=0,o=0;for(let r of e.content){let i="";if(r.type==="run")i=za(r);else if(r.type==="hyperlink")for(let s of r.children||[])s.type==="run"&&(i+=za(s));let a=i.length;if(n+a>t)return {contentIndex:o,runIndex:o,offsetInContent:t-n};n+=a,o++;}return {contentIndex:Math.max(0,e.content.length-1),runIndex:Math.max(0,e.content.length-1),offsetInContent:0}}function Zr(e,t){if(!e||!t)return;let n=e.querySelector(`[data-paragraph-index="${t.paragraphIndex}"]`);n&&n.scrollIntoView({behavior:"smooth",block:"center"});}function Wa(e){let[t,n]=useState({isOpen:false,searchText:"",replaceText:"",options:_a(),matches:[],currentIndex:0,replaceMode:e?.initialReplaceMode??false}),o=useCallback(g=>{n(h=>({...h,isOpen:true,replaceMode:false,searchText:g||h.searchText,matches:[],currentIndex:0}));},[]),r=useCallback(g=>{n(h=>({...h,isOpen:true,replaceMode:true,searchText:g||h.searchText,matches:[],currentIndex:0}));},[]),i=useCallback(()=>{n(g=>({...g,isOpen:false}));},[]),a=useCallback(()=>{n(g=>({...g,isOpen:!g.isOpen}));},[]),s=useCallback(g=>{n(h=>({...h,searchText:g}));},[]),l=useCallback(g=>{n(h=>({...h,replaceText:g}));},[]),d=useCallback(g=>{n(h=>({...h,options:{...h.options,...g}}));},[]),c=useCallback((g,h=0)=>{let x=Math.max(0,Math.min(h,g.length-1));n(y=>({...y,matches:g,currentIndex:g.length>0?x:0})),e?.onMatchesChange?.(g),g.length>0?e?.onCurrentMatchChange?.(g[x],x):e?.onCurrentMatchChange?.(null,-1);},[e]),u=useCallback(()=>{let g=0;return n(h=>h.matches.length===0?h:(g=(h.currentIndex+1)%h.matches.length,{...h,currentIndex:g})),g},[]),p=useCallback(()=>{let g=0;return n(h=>h.matches.length===0?h:(g=h.currentIndex===0?h.matches.length-1:h.currentIndex-1,{...h,currentIndex:g})),g},[]),f=useCallback(g=>{n(h=>h.matches.length===0||g<0||g>=h.matches.length?h:{...h,currentIndex:g});},[]),m=useCallback(()=>t.matches.length===0?null:t.matches[t.currentIndex]||null,[t.matches,t.currentIndex]),b=useCallback(()=>t.matches.length>0,[t.matches.length]);return {state:t,openFind:o,openReplace:r,close:i,toggle:a,setSearchText:s,setReplaceText:l,setOptions:d,setMatches:c,goToNextMatch:u,goToPreviousMatch:p,goToMatch:f,getCurrentMatch:m,hasMatches:b}}var gT={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent",display:"flex",alignItems:"flex-start",justifyContent:"flex-end",zIndex:1e4,pointerEvents:"none"},hT={backgroundColor:"white",borderRadius:"4px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.2)",minWidth:"360px",maxWidth:"440px",width:"100%",margin:"60px 20px 20px 20px",pointerEvents:"auto"},bT={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg-subtle)",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"},xT={margin:0,fontSize:"14px",fontWeight:600,color:"var(--doc-text)"},yT={background:"none",border:"none",fontSize:"18px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"2px 6px",lineHeight:1},vT={padding:"16px"},Of={display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px"},zf={width:"60px",fontSize:"13px",color:"var(--doc-text)",flexShrink:0},wd={flex:1,padding:"8px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"13px",boxSizing:"border-box",outline:"none"},_f={...wd,borderColor:"var(--doc-link)",boxShadow:"0 0 0 2px rgba(5, 99, 193, 0.1)"},ST={display:"flex",flexDirection:"column",gap:"6px",marginLeft:"8px"},kd={padding:"6px 12px",borderRadius:"3px",fontSize:"12px",fontWeight:500,cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)",minWidth:"80px",textAlign:"center"},$f={...kd,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text-placeholder)",cursor:"not-allowed"},Pd={padding:"6px 10px",borderRadius:"3px",fontSize:"14px",cursor:"pointer",border:"1px solid var(--doc-border-input)",backgroundColor:"var(--doc-bg-input)",color:"var(--doc-text)"},Wf={...Pd,color:"var(--doc-border-input)",cursor:"not-allowed"},CT={display:"flex",gap:"16px",marginTop:"4px",marginLeft:"68px"},Td={display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--doc-text-muted)",cursor:"pointer"},Vf={width:"14px",height:"14px",cursor:"pointer"},Zf={marginLeft:"68px",fontSize:"12px",color:"var(--doc-text-muted)",marginBottom:"8px"},TT={...Zf,color:"var(--doc-error)"},wT=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"18 15 12 9 6 15"})}),kT=({style:e})=>jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:e,children:jsx("polyline",{points:"6 9 12 15 18 9"})});function Rd({isOpen:e,onClose:t,onFind:n,onFindNext:o,onFindPrevious:r,onReplace:i,onReplaceAll:a,onHighlightMatches:s,onClearHighlights:l,initialSearchText:d="",replaceMode:c=false,currentResult:u,className:p,style:f}){let[m,b]=useState(""),[g,h]=useState(""),[x,y]=useState(c),[k,T]=useState(false),[A,B]=useState(false),[R,E]=useState(null),[S,N]=useState(false),[_,U]=useState(false),Z=useRef(null),L=useRef(null);useEffect(()=>{u!==void 0&&E(u);},[u]),useEffect(()=>{if(e){if(b(d),h(""),y(c),E(null),setTimeout(()=>{Z.current?.focus(),Z.current?.select();},100),d){let F=n(d,{matchCase:k,matchWholeWord:A});E(F),F?.matches&&s&&s(F.matches);}}else l&&l();},[e,d,c]);let H=useCallback(()=>{if(!m.trim()){E(null),l&&l();return}let F=n(m,{matchCase:k,matchWholeWord:A});E(F),F?.matches&&s?s(F.matches):l&&l();},[m,k,A,n,s,l]);useEffect(()=>{e&&m.trim()&&H();},[k,A]);let q=useCallback(F=>{b(F.target.value);},[]),xe=useCallback(F=>{F.key==="Enter"?(F.preventDefault(),F.shiftKey?M():R?we():H()):F.key==="Escape"&&t();},[R,H,t]),ie=useCallback(F=>{F.key==="Enter"?(F.preventDefault(),O()):F.key==="Escape"&&t();},[t]),we=useCallback(()=>{if(!m.trim()){H();return}if(!R){H();return}if(o()&&R){let V=(R.currentIndex+1)%R.totalCount;E({...R,currentIndex:V});}},[m,R,H,o]),M=useCallback(()=>{if(!m.trim()){H();return}if(!R){H();return}if(r()&&R){let V=R.currentIndex===0?R.totalCount-1:R.currentIndex-1;E({...R,currentIndex:V});}},[m,R,H,r]),O=useCallback(()=>{if(!R||R.totalCount===0)return;if(i(g)){let V=n(m,{matchCase:k,matchWholeWord:A});E(V),V?.matches&&s&&s(V.matches);}},[R,g,m,k,A,i,n,s]),C=useCallback(()=>{if(!m.trim())return;a(m,g,{matchCase:k,matchWholeWord:A})>0&&(E({matches:[],totalCount:0,currentIndex:-1}),l&&l());},[m,g,k,A,a,l]),P=useCallback(()=>{y(F=>{let V=!F;return V&&setTimeout(()=>L.current?.focus(),100),V});},[]),I=useCallback(F=>{F.target,F.currentTarget;},[]),z=useCallback(F=>{F.key==="Escape"&&t();},[t]);if(!e)return null;let Y=R&&R.totalCount>0,j=R&&R.totalCount===0&&m.trim();return jsx("div",{className:`docx-find-replace-dialog-overlay ${p||""}`,style:{...gT,...f},onClick:I,onKeyDown:z,children:jsxs("div",{className:"docx-find-replace-dialog",style:hT,role:"dialog","aria-modal":"false","aria-labelledby":"find-replace-dialog-title",children:[jsxs("div",{className:"docx-find-replace-dialog-header",style:bT,children:[jsx("h2",{id:"find-replace-dialog-title",style:xT,children:x?"Find and Replace":"Find"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-close",style:yT,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-find-replace-dialog-body",style:vT,children:[jsxs("div",{className:"docx-find-replace-dialog-row",style:Of,children:[jsx("label",{htmlFor:"find-text",style:zf,children:"Find:"}),jsx("input",{ref:Z,id:"find-text",type:"text",className:"docx-find-replace-dialog-input",style:S?_f:wd,value:m,onChange:q,onKeyDown:xe,onFocus:()=>N(true),onBlur:()=>{N(false),m.trim()&&!R&&H();},placeholder:"Enter text to find...","aria-label":"Find text"}),jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:Y?Pd:Wf,onClick:M,disabled:!Y,"aria-label":"Find previous",title:"Find Previous (Shift+Enter)",children:jsx(wT,{})}),jsx("button",{type:"button",className:"docx-find-replace-dialog-nav",style:Y?Pd:Wf,onClick:we,disabled:!Y,"aria-label":"Find next",title:"Find Next (Enter)",children:jsx(kT,{})})]})]}),Y&&jsxs("div",{className:"docx-find-replace-dialog-status",style:Zf,children:[R.currentIndex+1," of ",R.totalCount," matches"]}),j&&jsx("div",{className:"docx-find-replace-dialog-status",style:TT,children:"No results found"}),x&&jsx(Fragment$1,{children:jsxs("div",{className:"docx-find-replace-dialog-row",style:Of,children:[jsx("label",{htmlFor:"replace-text",style:zf,children:"Replace:"}),jsx("input",{ref:L,id:"replace-text",type:"text",className:"docx-find-replace-dialog-input",style:_?_f:wd,value:g,onChange:F=>h(F.target.value),onKeyDown:ie,onFocus:()=>U(true),onBlur:()=>U(false),placeholder:"Enter replacement text...","aria-label":"Replace text"}),jsxs("div",{style:ST,children:[jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:Y?kd:$f,onClick:O,disabled:!Y,title:"Replace current match",children:"Replace"}),jsx("button",{type:"button",className:"docx-find-replace-dialog-button",style:Y?kd:$f,onClick:C,disabled:!Y,title:"Replace all matches",children:"Replace All"})]})]})}),jsxs("div",{className:"docx-find-replace-dialog-options",style:CT,children:[jsxs("label",{className:"docx-find-replace-dialog-option",style:Td,children:[jsx("input",{type:"checkbox",style:Vf,checked:k,onChange:F=>T(F.target.checked)}),"Match case"]}),jsxs("label",{className:"docx-find-replace-dialog-option",style:Td,children:[jsx("input",{type:"checkbox",style:Vf,checked:A,onChange:F=>B(F.target.checked)}),"Whole words"]}),!x&&jsx("button",{type:"button",style:{...Td,background:"none",border:"none",cursor:"pointer",color:"var(--doc-link)",padding:0},onClick:P,children:"+ Replace"})]})]})]})})}var RT={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},ET={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"400px",maxWidth:"500px",width:"100%",margin:"20px"},IT={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},MT={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},LT={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},FT={padding:"20px"},Va={marginBottom:"16px"},Za={display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},Hi={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box",outline:"none"},DT={...Hi,borderColor:"var(--doc-error)"},AT={...Hi,cursor:"pointer"},BT={color:"var(--doc-error)",fontSize:"12px",marginTop:"4px"},Kf={color:"var(--doc-text-muted)",fontSize:"12px",marginTop:"4px"},NT={display:"flex",borderBottom:"1px solid var(--doc-border)",marginBottom:"16px"},Ed={padding:"10px 16px",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"var(--doc-text-muted)",borderBottom:"2px solid transparent",marginBottom:"-1px"},Gf={...Ed,color:"var(--doc-link)",borderBottomColor:"var(--doc-link)",fontWeight:500},HT={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Ua={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},OT={...Ua,backgroundColor:"var(--doc-link)",color:"white"},zT={...Ua,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},_T={...Ua,backgroundColor:"var(--doc-error)",color:"white"},$T={...Ua,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function Yf(e){if(!e||e.trim()==="")return false;let t=e.trim();if(t.startsWith("mailto:")||t.startsWith("tel:"))return t.length>7;if(t.startsWith("ftp://"))return t.length>6;try{let n=t.match(/^https?:\/\//)?t:`https://${t}`,o=new URL(n);return o.protocol==="http:"||o.protocol==="https:"}catch{return false}}function WT(e){if(!e)return "";let t=e.trim();return t.startsWith("mailto:")||t.startsWith("tel:")||t.startsWith("ftp://")||t.match(/^https?:\/\//)?t:`https://${t}`}function Id({isOpen:e,onClose:t,onSubmit:n,onRemove:o,initialData:r,selectedText:i="",isEditing:a=false,bookmarks:s=[],className:l,style:d}){let[c,u]=useState("url"),[p,f]=useState(""),[m,b]=useState(""),[g,h]=useState(""),[x,y]=useState(""),[k,T]=useState(""),[A,B]=useState(false),R=useRef(null),E=useRef(null);useEffect(()=>{e&&(r?(r.bookmark?(u("bookmark"),h(r.bookmark)):(u("url"),f(r.url||"")),b(r.displayText||""),y(r.tooltip||"")):(u("url"),f(""),b(i),h(""),y("")),T(""),B(false));},[e,r,i]),useEffect(()=>{e&&setTimeout(()=>{c==="url"?R.current?.focus():E.current?.focus();},100);},[e,c]);let S=useCallback(()=>{c==="url"&&p.trim()?Yf(p)?T(""):T("Please enter a valid URL"):T("");},[c,p]),N=useCallback(H=>{if(H?.preventDefault(),c==="url"){if(!p.trim()){T("URL is required"),B(true);return}if(!Yf(p)){T("Please enter a valid URL"),B(true);return}}else if(c==="bookmark"&&!g)return;let q={displayText:m.trim()||void 0,tooltip:x.trim()||void 0};c==="url"?q.url=WT(p):q.bookmark=g,n(q);},[c,p,g,m,x,n]),_=useCallback(H=>{H.key==="Escape"?t():H.key==="Enter"&&!H.shiftKey&&H.target.tagName!=="TEXTAREA"&&(H.preventDefault(),N());},[t,N]),U=useCallback(H=>{H.target===H.currentTarget&&t();},[t]);if(!e)return null;let Z=s.length>0,L=c==="url"&&p.trim()&&!k||c==="bookmark"&&g;return jsx("div",{className:`docx-hyperlink-dialog-overlay ${l||""}`,style:{...RT,...d},onClick:U,onKeyDown:_,role:"dialog","aria-modal":"true","aria-labelledby":"hyperlink-dialog-title",children:jsxs("div",{className:"docx-hyperlink-dialog",style:ET,children:[jsxs("div",{className:"docx-hyperlink-dialog-header",style:IT,children:[jsx("h2",{id:"hyperlink-dialog-title",style:MT,children:a?"Edit Hyperlink":"Insert Hyperlink"}),jsx("button",{type:"button",className:"docx-hyperlink-dialog-close",style:LT,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("form",{className:"docx-hyperlink-dialog-body",style:FT,onSubmit:N,children:[Z&&jsxs("div",{className:"docx-hyperlink-dialog-tabs",style:NT,children:[jsx("button",{type:"button",className:`docx-hyperlink-dialog-tab ${c==="url"?"active":""}`,style:c==="url"?Gf:Ed,onClick:()=>u("url"),"aria-selected":c==="url",children:"Web Address"}),jsx("button",{type:"button",className:`docx-hyperlink-dialog-tab ${c==="bookmark"?"active":""}`,style:c==="bookmark"?Gf:Ed,onClick:()=>u("bookmark"),"aria-selected":c==="bookmark",children:"Bookmark"})]}),c==="url"&&jsxs("div",{className:"docx-hyperlink-dialog-field",style:Va,children:[jsx("label",{htmlFor:"hyperlink-url",style:Za,children:"URL"}),jsx("input",{ref:R,id:"hyperlink-url",type:"text",className:"docx-hyperlink-dialog-input",style:k&&A?DT:Hi,value:p,onChange:H=>{f(H.target.value),A&&T("");},onBlur:()=>{B(true),S();},placeholder:"https://example.com","aria-invalid":!!k,"aria-describedby":k?"url-error":"url-hint"}),k&&A&&jsx("div",{id:"url-error",style:BT,children:k}),!k&&jsx("div",{id:"url-hint",style:Kf,children:"Enter a web address, email (mailto:), or phone (tel:)"})]}),c==="bookmark"&&jsxs("div",{className:"docx-hyperlink-dialog-field",style:Va,children:[jsx("label",{htmlFor:"hyperlink-bookmark",style:Za,children:"Bookmark"}),jsxs("select",{ref:E,id:"hyperlink-bookmark",className:"docx-hyperlink-dialog-select",style:AT,value:g,onChange:H=>h(H.target.value),children:[jsx("option",{value:"",children:"Select a bookmark..."}),s.map(H=>jsx("option",{value:H.name,children:H.label||H.name},H.name))]})]}),jsxs("div",{className:"docx-hyperlink-dialog-field",style:Va,children:[jsx("label",{htmlFor:"hyperlink-display-text",style:Za,children:"Display Text"}),jsx("input",{id:"hyperlink-display-text",type:"text",className:"docx-hyperlink-dialog-input",style:Hi,value:m,onChange:H=>b(H.target.value),placeholder:"Text to display (optional)"}),jsx("div",{style:Kf,children:"Leave empty to use the selected text"})]}),jsxs("div",{className:"docx-hyperlink-dialog-field",style:Va,children:[jsx("label",{htmlFor:"hyperlink-tooltip",style:Za,children:"Tooltip (optional)"}),jsx("input",{id:"hyperlink-tooltip",type:"text",className:"docx-hyperlink-dialog-input",style:Hi,value:x,onChange:H=>y(H.target.value),placeholder:"Text shown on hover"})]})]}),jsxs("div",{className:"docx-hyperlink-dialog-footer",style:HT,children:[a&&o&&jsx("button",{type:"button",className:"docx-hyperlink-dialog-remove",style:_T,onClick:o,children:"Remove Link"}),jsx("div",{style:{flex:1}}),jsx("button",{type:"button",className:"docx-hyperlink-dialog-cancel",style:zT,onClick:t,children:"Cancel"}),jsx("button",{type:"submit",className:"docx-hyperlink-dialog-submit",style:L?OT:$T,onClick:N,disabled:!L,children:a?"Update":"Insert"})]})]})})}function Md(){let[e,t]=useState({isOpen:false,isEditing:false}),n=useCallback(a=>{t({isOpen:true,selectedText:a,initialData:void 0,isEditing:false});},[]),o=useCallback(a=>{t({isOpen:true,initialData:a,selectedText:a.displayText,isEditing:true});},[]),r=useCallback(()=>{t(a=>({...a,isOpen:false}));},[]),i=useCallback(()=>{t(a=>({...a,isOpen:!a.isOpen}));},[]);return {state:e,openInsert:n,openEdit:o,close:r,toggle:i}}var ZT={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},UT={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:360,maxWidth:440,width:"100%",margin:20},qT={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},KT={padding:"16px 20px",display:"flex",flexDirection:"column",gap:12},Fd={display:"flex",alignItems:"center",gap:12},Dd={width:80,fontSize:13,color:"var(--doc-text-muted)"},Qf={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13},Xf={...Qf},GT={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},Jf={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function em({isOpen:e,onClose:t,onApply:n,currentProps:o}){let[r,i]=useState(o?.width||0),[a,s]=useState(o?.widthType||"auto"),[l,d]=useState(o?.justification||"left");useEffect(()=>{e&&(i(o?.width||0),s(o?.widthType||"auto"),d(o?.justification||"left"));},[e,o]);let c=useCallback(()=>{let p={};a==="auto"?(p.width=null,p.widthType="auto"):(p.width=r,p.widthType=a),p.justification=l,n(p),t();},[r,a,l,n,t]),u=useCallback(p=>{p.key==="Escape"&&t(),p.key==="Enter"&&c();},[t,c]);return e?jsx("div",{style:ZT,onClick:t,onKeyDown:u,children:jsxs("div",{style:UT,onClick:p=>p.stopPropagation(),role:"dialog","aria-label":"Table properties",children:[jsx("div",{style:qT,children:"Table Properties"}),jsxs("div",{style:KT,children:[jsxs("div",{style:Fd,children:[jsx("label",{style:Dd,children:"Width type"}),jsxs("select",{style:Xf,value:a,onChange:p=>s(p.target.value),children:[jsx("option",{value:"auto",children:"Auto"}),jsx("option",{value:"dxa",children:"Fixed (twips)"}),jsx("option",{value:"pct",children:"Percentage"})]})]}),a!=="auto"&&jsxs("div",{style:Fd,children:[jsx("label",{style:Dd,children:"Width"}),jsx("input",{type:"number",style:Qf,min:0,step:a==="pct"?5:100,value:r,onChange:p=>i(Number(p.target.value)||0)}),jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:a==="pct"?"(50ths of %)":"tw"})]}),jsxs("div",{style:Fd,children:[jsx("label",{style:Dd,children:"Alignment"}),jsxs("select",{style:Xf,value:l,onChange:p=>d(p.target.value),children:[jsx("option",{value:"left",children:"Left"}),jsx("option",{value:"center",children:"Center"}),jsx("option",{value:"right",children:"Right"})]})]})]}),jsxs("div",{style:GT,children:[jsx("button",{type:"button",style:Jf,onClick:t,children:"Cancel"}),jsx("button",{type:"button",style:{...Jf,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:c,children:"Apply"})]})]})}):null}var jT={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},XT={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:400,maxWidth:480,width:"100%",margin:20},JT={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},QT={padding:"16px 20px",display:"flex",flexDirection:"column",gap:16},Ad={display:"flex",flexDirection:"column",gap:8},Bd={fontSize:13,fontWeight:600,color:"var(--doc-text)"},Sn={display:"flex",alignItems:"center",gap:8},Cn={width:75,fontSize:12,color:"var(--doc-text-muted)"},hr={flex:1,padding:"4px 6px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:12},Ur={...hr},ew={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},nm={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function om({isOpen:e,onClose:t,onApply:n,currentData:o}){let[r,i]=useState("align"),[a,s]=useState("center"),[l,d]=useState("column"),[c,u]=useState(0),[p,f]=useState("align"),[m,b]=useState("top"),[g,h]=useState("paragraph"),[x,y]=useState(0),[k,T]=useState(0),[A,B]=useState(0),[R,E]=useState(0),[S,N]=useState(0);useEffect(()=>{if(!e)return;let Z=o?.horizontal,L=o?.vertical;Z?.align?(i("align"),s(Z.align)):Z?.posOffset!=null&&(i("offset"),u(Z.posOffset)),Z?.relativeTo&&d(Z.relativeTo),L?.align?(f("align"),b(L.align)):L?.posOffset!=null&&(f("offset"),y(L.posOffset)),L?.relativeTo&&h(L.relativeTo),T(o?.distTop??0),B(o?.distBottom??0),E(o?.distLeft??0),N(o?.distRight??0);},[e,o]);let _=useCallback(()=>{let Z={};Z.horizontal={relativeTo:l,...r==="align"?{align:a}:{posOffset:c}},Z.vertical={relativeTo:g,...p==="align"?{align:m}:{posOffset:x}},Z.distTop=k,Z.distBottom=A,Z.distLeft=R,Z.distRight=S,n(Z),t();},[r,a,l,c,p,m,g,x,k,A,R,S,n,t]),U=useCallback(Z=>{Z.key==="Escape"&&t(),Z.key==="Enter"&&_();},[t,_]);return e?jsx("div",{style:jT,onClick:t,onKeyDown:U,children:jsxs("div",{style:XT,onClick:Z=>Z.stopPropagation(),role:"dialog","aria-label":"Image position",children:[jsx("div",{style:JT,children:"Image Position"}),jsxs("div",{style:QT,children:[jsxs("div",{style:Ad,children:[jsx("div",{style:Bd,children:"Horizontal"}),jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Position"}),jsxs("select",{style:Ur,value:r,onChange:Z=>i(Z.target.value),children:[jsx("option",{value:"align",children:"Alignment"}),jsx("option",{value:"offset",children:"Offset"})]})]}),r==="align"?jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Align"}),jsxs("select",{style:Ur,value:a,onChange:Z=>s(Z.target.value),children:[jsx("option",{value:"left",children:"Left"}),jsx("option",{value:"center",children:"Center"}),jsx("option",{value:"right",children:"Right"})]})]}):jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Offset (px)"}),jsx("input",{type:"number",style:hr,value:c,onChange:Z=>u(Number(Z.target.value)||0)})]}),jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Relative to"}),jsxs("select",{style:Ur,value:l,onChange:Z=>d(Z.target.value),children:[jsx("option",{value:"page",children:"Page"}),jsx("option",{value:"column",children:"Column"}),jsx("option",{value:"margin",children:"Margin"}),jsx("option",{value:"character",children:"Character"})]})]})]}),jsxs("div",{style:Ad,children:[jsx("div",{style:Bd,children:"Vertical"}),jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Position"}),jsxs("select",{style:Ur,value:p,onChange:Z=>f(Z.target.value),children:[jsx("option",{value:"align",children:"Alignment"}),jsx("option",{value:"offset",children:"Offset"})]})]}),p==="align"?jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Align"}),jsxs("select",{style:Ur,value:m,onChange:Z=>b(Z.target.value),children:[jsx("option",{value:"top",children:"Top"}),jsx("option",{value:"center",children:"Center"}),jsx("option",{value:"bottom",children:"Bottom"})]})]}):jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Offset (px)"}),jsx("input",{type:"number",style:hr,value:x,onChange:Z=>y(Number(Z.target.value)||0)})]}),jsxs("div",{style:Sn,children:[jsx("label",{style:Cn,children:"Relative to"}),jsxs("select",{style:Ur,value:g,onChange:Z=>h(Z.target.value),children:[jsx("option",{value:"page",children:"Page"}),jsx("option",{value:"margin",children:"Margin"}),jsx("option",{value:"paragraph",children:"Paragraph"}),jsx("option",{value:"line",children:"Line"})]})]})]}),jsxs("div",{style:Ad,children:[jsx("div",{style:Bd,children:"Distance from text (px)"}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[jsxs("div",{style:Sn,children:[jsx("label",{style:{...Cn,width:45},children:"Top"}),jsx("input",{type:"number",style:hr,min:0,value:k,onChange:Z=>T(Number(Z.target.value)||0)})]}),jsxs("div",{style:Sn,children:[jsx("label",{style:{...Cn,width:45},children:"Bottom"}),jsx("input",{type:"number",style:hr,min:0,value:A,onChange:Z=>B(Number(Z.target.value)||0)})]}),jsxs("div",{style:Sn,children:[jsx("label",{style:{...Cn,width:45},children:"Left"}),jsx("input",{type:"number",style:hr,min:0,value:R,onChange:Z=>E(Number(Z.target.value)||0)})]}),jsxs("div",{style:Sn,children:[jsx("label",{style:{...Cn,width:45},children:"Right"}),jsx("input",{type:"number",style:hr,min:0,value:S,onChange:Z=>N(Number(Z.target.value)||0)})]})]})]})]}),jsxs("div",{style:ew,children:[jsx("button",{type:"button",style:nm,onClick:t,children:"Cancel"}),jsx("button",{type:"button",style:{...nm,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:_,children:"Apply"})]})]})}):null}var nw={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},ow={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:380,maxWidth:440,width:"100%",margin:20},rw={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},iw={padding:"16px 20px",display:"flex",flexDirection:"column",gap:16},im={display:"flex",flexDirection:"column",gap:8},am={fontSize:13,fontWeight:600,color:"var(--doc-text)"},Nd={display:"flex",alignItems:"center",gap:8},Hd={width:60,fontSize:12,color:"var(--doc-text-muted)"},Ka={flex:1,padding:"4px 6px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:12},aw={...Ka},sw={...Ka,minHeight:60,resize:"vertical",fontFamily:"inherit"},lw={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},sm={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function lm({isOpen:e,onClose:t,onApply:n,currentData:o}){let[r,i]=useState(""),[a,s]=useState(0),[l,d]=useState("#000000"),[c,u]=useState("solid");useEffect(()=>{e&&(i(o?.alt??""),s(o?.borderWidth??0),d(o?.borderColor??"#000000"),u(o?.borderStyle??"solid"));},[e,o]);let p=useCallback(()=>{n({alt:r||void 0,borderWidth:a>0?a:void 0,borderColor:a>0?l:void 0,borderStyle:a>0?c:void 0}),t();},[r,a,l,c,n,t]),f=useCallback(m=>{m.key==="Escape"&&t(),m.key==="Enter"&&!m.shiftKey&&p();},[t,p]);return e?jsx("div",{style:nw,onClick:t,onKeyDown:f,children:jsxs("div",{style:ow,onClick:m=>m.stopPropagation(),role:"dialog","aria-label":"Image properties",children:[jsx("div",{style:rw,children:"Image Properties"}),jsxs("div",{style:iw,children:[jsxs("div",{style:im,children:[jsx("div",{style:am,children:"Alt Text"}),jsx("textarea",{style:sw,value:r,onChange:m=>i(m.target.value),placeholder:"Describe this image for accessibility..."})]}),jsxs("div",{style:im,children:[jsx("div",{style:am,children:"Border"}),jsxs("div",{style:Nd,children:[jsx("label",{style:Hd,children:"Width"}),jsx("input",{type:"number",style:{...Ka,maxWidth:80},min:0,max:20,step:.5,value:a,onChange:m=>s(Number(m.target.value)||0)}),jsx("span",{style:{fontSize:12,color:"var(--doc-text-muted)"},children:"px"})]}),jsxs("div",{style:Nd,children:[jsx("label",{style:Hd,children:"Style"}),jsxs("select",{style:aw,value:c,onChange:m=>u(m.target.value),children:[jsx("option",{value:"solid",children:"Solid"}),jsx("option",{value:"dashed",children:"Dashed"}),jsx("option",{value:"dotted",children:"Dotted"}),jsx("option",{value:"double",children:"Double"}),jsx("option",{value:"groove",children:"Groove"}),jsx("option",{value:"ridge",children:"Ridge"}),jsx("option",{value:"inset",children:"Inset"}),jsx("option",{value:"outset",children:"Outset"})]})]}),jsxs("div",{style:Nd,children:[jsx("label",{style:Hd,children:"Color"}),jsx("input",{type:"color",value:l,onChange:m=>d(m.target.value),style:{width:32,height:24,padding:0,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"}}),jsx("input",{type:"text",style:{...Ka,maxWidth:90},value:l,onChange:m=>d(m.target.value)})]}),a>0&&jsx("div",{style:{marginTop:4,padding:8,border:`${a}px ${c} ${l}`,borderRadius:4,fontSize:11,color:"var(--doc-text-muted)",textAlign:"center"},children:"Preview"})]})]}),jsxs("div",{style:lw,children:[jsx("button",{type:"button",style:sm,onClick:t,children:"Cancel"}),jsx("button",{type:"button",style:{...sm,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:p,children:"Apply"})]})]})}):null}var Oo={High:50,Default:100,Low:150};function on(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??Oo.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function nt(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??Oo.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function Ae(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??Oo.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var cm=nt({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table)+"}});var dm=nt({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});var cw={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Carlito","Calibri","Arial","Helvetica","sans-serif"]},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Caladea","Cambria","Georgia","serif"]},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arimo","Arial","Helvetica","sans-serif"]},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Tinos","Times New Roman","Times","serif"]},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Cousine","Courier New","Courier","monospace"]},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"]},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"]},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"]},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"]},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"]},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"]},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"]},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"]},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"]},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"]},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"]},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"]},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"]},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"]},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"]},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"]},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"]},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"]}},dw={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function uw(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function pm(e){let t=e.trim().toLowerCase(),n=cw[t];if(n)return {googleFont:n.googleFont,cssFallback:n.fallbackStack.map(um).join(", "),originalFont:e,hasGoogleEquivalent:true};let o=uw(e),r=dw[o];return {googleFont:null,cssFallback:`${um(e)}, ${r}`,originalFont:e,hasGoogleEquivalent:false}}function um(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function mm(e,t){if(!e)return {};let n$1={};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=pm(a);n$1.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n$1.fontSize=`${v(e.fontSize)}pt`),e.bold&&(n$1.fontWeight="bold"),e.italic&&(n$1.fontStyle="italic"),e.color&&(n$1.color=a$3(e.color,t)),e.highlight&&e.highlight!=="none"){let a=b$1(e.highlight);a&&(n$1.backgroundColor=a);}if(e.shading){let a=hm(e.shading,t);a&&!n$1.backgroundColor&&(n$1.backgroundColor=a);}let o=[],r=[],i=[];if(e.underline&&e.underline.style!=="none"){o.push("underline");let a=pw(e.underline.style);a!=="solid"&&r.push(a),e.underline.color&&i.push(a$3(e.underline.color,t));}if(e.strike&&o.push("line-through"),e.doubleStrike&&o.push("line-through"),o.length>0&&(n$1.textDecoration=o.join(" "),r.length>0&&(n$1.textDecorationStyle=r[0]),i.length>0&&(n$1.textDecorationColor=i[0])),e.vertAlign)switch(e.vertAlign){case "superscript":n$1.verticalAlign="super",n$1.fontSize||(n$1.fontSize="0.83em");break;case "subscript":n$1.verticalAlign="sub",n$1.fontSize||(n$1.fontSize="0.83em");break}if(e.position&&e.position!==0){let a=u(e.position);n$1.position="relative",n$1.top=x(-a);}return e.allCaps?n$1.textTransform="uppercase":e.smallCaps&&(n$1.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n$1.letterSpacing=x(n(e.spacing))),e.scale!==void 0&&e.scale!==100&&(n$1.transform=`scaleX(${e.scale/100})`,n$1.display="inline-block"),e.hidden&&(n$1.display="none"),e.emboss&&(n$1.textShadow="1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.3)"),e.imprint&&(n$1.textShadow="-1px -1px 1px rgba(255,255,255,0.5), 1px 1px 1px rgba(0,0,0,0.3)"),e.outline&&(n$1.WebkitTextStroke="1px currentColor",n$1.WebkitTextFillColor="transparent"),e.shadow&&!e.emboss&&!e.imprint&&(n$1.textShadow="1px 1px 2px rgba(0,0,0,0.3)"),e.rtl&&(n$1.direction="rtl"),n$1}function gm(e,t){if(!e)return {};let n$1={};if(e.alignment&&(n$1.textAlign=fw(e.alignment)),e.spaceBefore!==void 0&&(n$1.marginTop=x(n(e.spaceBefore))),e.spaceAfter!==void 0&&(n$1.marginBottom=x(n(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=n(e.lineSpacing);o>0&&(n$1.lineHeight=x(o));break}case "atLeast":{let o=n(e.lineSpacing);o>0&&(n$1.minHeight=x(o),n$1.lineHeight=x(o));break}default:{let o=e.lineSpacing/240;o>0&&(n$1.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n$1.marginLeft=x(n(e.indentLeft))),e.indentRight!==void 0&&(n$1.marginRight=x(n(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n$1.textIndent=x(n(e.indentFirstLine)):n$1.textIndent=x(n(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n$1,qr(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n$1,qr(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n$1,qr(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n$1,qr(e.borders.right,"Right",t))),e.shading){let o=hm(e.shading,t);o&&(n$1.backgroundColor=o);}return e.bidi&&(n$1.direction="rtl"),e.pageBreakBefore&&(n$1.pageBreakBefore="always"),e.keepNext&&(n$1.pageBreakAfter="avoid"),e.keepLines&&(n$1.pageBreakInside="avoid"),n$1}function qr(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?w(e.size):1,i=e.color?a$3(e.color,n):"#000000",a=mw(e.style),s=`border${t}Width`,l=`border${t}Style`,d=`border${t}Color`;return o[s]=x(Math.max(1,r)),o[l]=a,o[d]=i,o}function hm(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":c$3(e.fill,t):e.pattern==="solid"&&e.color?c$3(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?c$3(e.color,t):""}function pw(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 fw(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function mw(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 Kr(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 hw(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=gm(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function bw(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 xw(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${bw(n)} docx-list-level-${o}`}var yw={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},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},outlineLevel:{default:null},bookmarks:{default:null},_originalFormatting:{default:null}},parseDOM:[{tag:"p",getAttrs(e){let t=e;return {paraId:t.dataset.paraId||void 0,alignment:t.dataset.alignment,styleId:t.dataset.styleId||void 0,sectionBreakType:t.dataset.sectionBreak||void 0}}}],toDOM(e){let t=e.attrs,n=hw(t),o=xw(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.sectionBreakType&&(r["data-section-break"]=t.sectionBreakType,r.class=(r.class?r.class+" ":"")+"docx-section-break"),["p",r,0]}};function Dn(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,d)=>{l.type.name==="paragraph"&&!s.has(d)&&(s.add(d),a=a.setNodeMarkup(d,void 0,{...l.attrs,[e]:t}));}),o(a.scrollIntoView()),true}}function bm(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 Oi(e){return (t,n)=>Dn("alignment",e)(t,n)}function Ga(e,t="auto"){return (n,o)=>bm({lineSpacing:e,lineSpacingRule:t})(n,o)}function vw(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 d=s.attrs.indentLeft||0;i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:d+e});}}),n(i.scrollIntoView()),true}}function Sw(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 d=s.attrs.indentLeft||0,c=Math.max(0,d-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:c>0?c:null});}}),n(i.scrollIntoView()),true}}function Cw(e){return (t,n)=>(o,r)=>{let{$from:i,$to:a}=o.selection;if(!r)return true;let s=o.tr,l=new Set,d=[];if(n?.runFormatting){let u=n.runFormatting;u.bold&&d.push(e.marks.bold.create()),u.italic&&d.push(e.marks.italic.create()),u.fontSize&&d.push(e.marks.fontSize.create({size:u.fontSize})),u.fontFamily&&d.push(e.marks.fontFamily.create({ascii:u.fontFamily.ascii,hAnsi:u.fontFamily.hAnsi,asciiTheme:u.fontFamily.asciiTheme})),u.color&&!u.color.auto&&d.push(e.marks.textColor.create({rgb:u.color.rgb,themeColor:u.color.themeColor,themeTint:u.color.themeTint,themeShade:u.color.themeShade})),u.underline&&u.underline.style!=="none"&&d.push(e.marks.underline.create({style:u.underline.style,color:u.underline.color})),(u.strike||u.doubleStrike)&&d.push(e.marks.strike.create({double:u.doubleStrike||false}));}let c=[e.marks.bold,e.marks.italic,e.marks.fontSize,e.marks.fontFamily,e.marks.textColor,e.marks.underline,e.marks.strike].filter(Boolean);return o.doc.nodesBetween(i.pos,a.pos,(u,p)=>{if(u.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...u.attrs,styleId:t};if(n?.paragraphFormatting){let m=n.paragraphFormatting;m.alignment!==void 0&&(f.alignment=m.alignment),m.spaceBefore!==void 0&&(f.spaceBefore=m.spaceBefore),m.spaceAfter!==void 0&&(f.spaceAfter=m.spaceAfter),m.lineSpacing!==void 0&&(f.lineSpacing=m.lineSpacing),m.lineSpacingRule!==void 0&&(f.lineSpacingRule=m.lineSpacingRule),m.indentLeft!==void 0&&(f.indentLeft=m.indentLeft),m.indentRight!==void 0&&(f.indentRight=m.indentRight),m.indentFirstLine!==void 0&&(f.indentFirstLine=m.indentFirstLine);}if(s=s.setNodeMarkup(p,void 0,f),n){let m=p+1,b=p+u.nodeSize-1;if(b>m){for(let g of c)s=s.removeMark(m,b,g);for(let g of d)s=s.addMark(m,b,g);}}}}),d.length>0&&(s=s.setStoredMarks(d)),r(s.scrollIntoView()),true}}var xm=nt({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:yw,onSchemaReady(e){let t=Cw(e.schema);return {commands:{setAlignment:n=>Oi(n),alignLeft:()=>Oi("left"),alignCenter:()=>Oi("center"),alignRight:()=>Oi("right"),alignJustify:()=>Oi("both"),setLineSpacing:(n,o)=>Ga(n,o),singleSpacing:()=>Ga(240),oneAndHalfSpacing:()=>Ga(360),doubleSpacing:()=>Ga(480),setSpaceBefore:n=>Dn("spaceBefore",n),setSpaceAfter:n=>Dn("spaceAfter",n),increaseIndent:n=>vw(n),decreaseIndent:n=>Sw(n),setIndentLeft:n=>Dn("indentLeft",n>0?n:null),setIndentRight:n=>Dn("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>bm({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Dn("styleId",null),insertSectionBreak:n=>Dn("sectionBreakType",n),removeSectionBreak:()=>Dn("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=Kr(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let c of r){let u=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:u,level:c.level,text:c.text});let p=a.mapping.map(c.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let h=[...(m.attrs.bookmarks||[]).filter(x=>!x.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:u}];a.setNodeMarkup(p,void 0,{...m.attrs,bookmarks:h});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let c of s){let u=c.level*720,p=`TOC${c.level+1}`,f=i.marks.hyperlink.create({href:`#${c.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:u>0?u:null},[i.text(c.text,[f])]));}let d=a.mapping.map(n.selection.from);return a.insert(d,Fragment.from(l)),o(a.scrollIntoView()),true},setTabs:n=>Dn("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 u=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return Dn("tabs",u)(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(d=>d.position!==n);return Dn("tabs",l.length>0?l:null)(o,r)}}}}});var vm=on({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>undo,redo:()=>redo},keyboardShortcuts:{"Mod-z":undo,"Mod-y":redo,"Mod-Shift-z":redo}}}});var Cm=Ae({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:()=>toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":toggleMark(e.schema.marks.bold)}}}});var wm=Ae({name:"italic",schemaMarkName:"italic",markSpec:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"?null:false}],toDOM(){return ["em",0]}},onSchemaReady(e){return {commands:{toggleItalic:()=>toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":toggleMark(e.schema.marks.italic)}}}});function ww(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 km(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=ww(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function eo(e,t){return (n,o)=>{let{from:r,to:i,empty:a}=n.selection,s=e.create(t);if(a){if(o){let l=e.isInSet(n.storedMarks||n.selection.$from.marks())?(n.storedMarks||n.selection.$from.marks()).filter(c=>c.type!==e):n.storedMarks||n.selection.$from.marks(),d=n.tr.setStoredMarks([...l,s]);d=km(n,d),o(d);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function to(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=km(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}var zi=(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),d=Math.min(o,s+a.nodeSize);for(let c of a.marks)i=i.removeMark(l,d,c.type);}}),t(i.scrollIntoView());}return true};var Rm=Ae({name:"underline",schemaMarkName:"underline",markSpec:{attrs:{style:{default:"single"},color:{default:null}},parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:e=>e.includes("underline")?{}:false}],toDOM(e){let t=e.attrs,n=["text-decoration: underline"];if(t.style&&t.style!=="single"){let r={double:"double",dotted:"dotted",dash:"dashed",wave:"wavy"}[t.style];r&&n.push(`text-decoration-style: ${r}`);}return t.color?.rgb&&n.push(`text-decoration-color: #${t.color.rgb}`),["span",{style:n.join("; ")},0]}},onSchemaReady(e){return {commands:{toggleUnderline:()=>toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>eo(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":toggleMark(e.schema.marks.underline)}}}});var Em=Ae({name:"strike",schemaMarkName:"strike",markSpec:{attrs:{double:{default:false}},parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:e=>e.includes("line-through")?{}:false}],toDOM(){return ["s",0]}},onSchemaReady(e){return {commands:{toggleStrike:()=>toggleMark(e.schema.marks.strike)}}}});var Im=Ae({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=mm({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?to(e.schema.marks.textColor):eo(e.schema.marks.textColor,t),clearTextColor:()=>to(e.schema.marks.textColor)}}}});var Mm=Ae({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: ${b$1(t)||(t.startsWith("#")?t:`#${t}`)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?to(e.schema.marks.highlight):eo(e.schema.marks.highlight,{color:t}),clearHighlight:()=>to(e.schema.marks.highlight)}}}});var Lm=Ae({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=>eo(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>to(e.schema.marks.fontSize)}}}});var Fm=Ae({name:"fontFamily",schemaMarkName:"fontFamily",markSpec:{attrs:{ascii:{default:null},hAnsi:{default:null},asciiTheme:{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=>eo(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>to(e.schema.marks.fontFamily)}}}});var Dm=Ae({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>toggleMark(e.schema.marks.superscript)}}}});var Am=Ae({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>toggleMark(e.schema.marks.subscript)}}}});function Gr(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 Yr(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var Bm=Ae({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:d,to:c,empty:u}=s.selection;if(u)return false;if(l){let p=t.create({href:i,tooltip:a||null});l(s.tr.addMark(d,c,p).scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:d}=i.selection;if(d){let c=i.selection.$from;if(!c.marks().find(g=>g.type===t))return false;let f=c.pos,m=c.pos;return c.parent.forEach((g,h)=>{if(g.isText){let x=c.start()+h,y=x+g.nodeSize;x<=c.pos&&c.pos<=y&&g.marks.some(T=>T.type===t)&&(f=Math.min(f,x),m=Math.max(m,y));}}),a&&a(i.tr.removeMark(f,m,t).scrollIntoView()),true}return a&&a(i.tr.removeMark(s,l,t).scrollIntoView()),true};return {commands:{setHyperlink:n,removeHyperlink:()=>o,insertHyperlink:(i,a,s)=>(l,d)=>{if(d){let c=t.create({href:a,tooltip:s||null}),u=l.schema.text(i,[c]);d(l.tr.replaceSelectionWith(u,false).scrollIntoView());}return true}}}}});var Nm=Ae({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var Hm=Ae({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 Om=Ae({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}),d=t.text(String(i),[l]),c=a.tr.replaceSelectionWith(d,false);return s(c.scrollIntoView()),true}}let o=(r,i)=>{let{$from:a,$to:s}=r.selection;if(!i)return true;let l=r.tr,d=t.marks.footnoteRef;return l=l.removeMark(a.pos,s.pos,d),i(l.scrollIntoView()),true};return {commands:{insertFootnote:n("footnote"),insertEndnote:n("endnote"),deleteNoteRef:()=>o}}}});function Ew(e){return e/2*(96/72)}var zm=Ae({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$1=[],o={class:"docx-char-spacing"};if(t.spacing!=null&&t.spacing!==0&&(n$1.push(`letter-spacing: ${x(n(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=Ew(t.position);n$1.push(`vertical-align: ${x(r)}`),o["data-position"]=String(t.position);}return t.scale!=null&&t.scale!==100&&(n$1.push(`transform: scaleX(${t.scale/100})`),n$1.push("display: inline-block"),o["data-scale"]=String(t.scale)),t.kerning!=null&&(o["data-kerning"]=String(t.kerning)),n$1.length>0&&(o.style=n$1.join("; ")),["span",o,0]}}});var _m=Ae({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 $m=Ae({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]}}}),Wm=Ae({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 Vm=Ae({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]}}}),Zm=Ae({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]}}}),Um=Ae({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]}}}),qm=Ae({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]}}}),Km=Ae({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 Gm=nt({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 Ym=nt({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 jm=nt({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}},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 Xm=nt({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",d=t.outlineColor||"#000000";o.push(`border: ${t.outlineWidth}px ${l} ${d}`);}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 Iw(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 Mw(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(u=>`<stop offset="${Math.round(u.position/1e3)}%" stop-color="${u.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)),d=Math.round(50+50*Math.sin(i));return `<linearGradient id="${e}" x1="${a}%" y1="${s}%" x2="${l}%" y2="${d}%">${n}</linearGradient>`}var Jm=nt({name:"shape",schemaNodeName:"shape",nodeSpec:{inline:true,group:"inline",draggable:true,atom:true,attrs:{shapeType:{default:"rect"},shapeId:{default:null},width:{default:100},height:{default:80},fillColor:{default:null},fillType:{default:"solid"},gradientType:{default:null},gradientAngle:{default:null},gradientStops:{default:null},outlineWidth:{default:1},outlineColor:{default:"#000000"},outlineStyle:{default:"solid"},transform:{default:null},displayMode:{default:"inline"},cssFloat:{default:null},wrapType:{default:"inline"},shadowColor:{default:null},shadowBlur:{default:null},shadowOffsetX:{default:null},shadowOffsetY:{default:null},glowColor:{default:null},glowRadius:{default:null}},parseDOM:[{tag:"span.docx-shape",getAttrs(e){let t=e;return {shapeType:t.dataset.shapeType||"rect",shapeId:t.dataset.shapeId||void 0,width:t.dataset.width?Number(t.dataset.width):void 0,height:t.dataset.height?Number(t.dataset.height):void 0,fillColor:t.dataset.fillColor||void 0,fillType:t.dataset.fillType||"solid",gradientType:t.dataset.gradientType||void 0,gradientAngle:t.dataset.gradientAngle?Number(t.dataset.gradientAngle):void 0,gradientStops:t.dataset.gradientStops||void 0,outlineWidth:t.dataset.outlineWidth?Number(t.dataset.outlineWidth):void 0,outlineColor:t.dataset.outlineColor||void 0,outlineStyle:t.dataset.outlineStyle||void 0,transform:t.dataset.transform||void 0,displayMode:t.dataset.displayMode||void 0,cssFloat:t.dataset.cssFloat||void 0,wrapType:t.dataset.wrapType||void 0,shadowColor:t.dataset.shadowColor||void 0,shadowBlur:t.dataset.shadowBlur?Number(t.dataset.shadowBlur):void 0,shadowOffsetX:t.dataset.shadowOffsetX?Number(t.dataset.shadowOffsetX):void 0,shadowOffsetY:t.dataset.shadowOffsetY?Number(t.dataset.shadowOffsetY):void 0,glowColor:t.dataset.glowColor||void 0,glowRadius:t.dataset.glowRadius?Number(t.dataset.glowRadius):void 0}}}],toDOM(e){let t=e.attrs,n=t.width||100,o=t.height||80,r={class:"docx-shape","data-shape-type":t.shapeType||"rect"};t.shapeId&&(r["data-shape-id"]=t.shapeId),r["data-width"]=String(n),r["data-height"]=String(o),t.fillColor&&(r["data-fill-color"]=t.fillColor),t.fillType&&(r["data-fill-type"]=t.fillType),t.gradientType&&(r["data-gradient-type"]=t.gradientType),t.gradientAngle!=null&&(r["data-gradient-angle"]=String(t.gradientAngle)),t.gradientStops&&(r["data-gradient-stops"]=t.gradientStops),t.outlineWidth&&(r["data-outline-width"]=String(t.outlineWidth)),t.outlineColor&&(r["data-outline-color"]=t.outlineColor),t.outlineStyle&&(r["data-outline-style"]=t.outlineStyle),t.transform&&(r["data-transform"]=t.transform),t.displayMode&&(r["data-display-mode"]=t.displayMode),t.cssFloat&&(r["data-css-float"]=t.cssFloat),t.wrapType&&(r["data-wrap-type"]=t.wrapType),t.shadowColor&&(r["data-shadow-color"]=t.shadowColor),t.shadowBlur!=null&&(r["data-shadow-blur"]=String(t.shadowBlur)),t.shadowOffsetX!=null&&(r["data-shadow-offset-x"]=String(t.shadowOffsetX)),t.shadowOffsetY!=null&&(r["data-shadow-offset-y"]=String(t.shadowOffsetY)),t.glowColor&&(r["data-glow-color"]=t.glowColor),t.glowRadius!=null&&(r["data-glow-radius"]=String(t.glowRadius));let i=["display: inline-block",`width: ${n}px`,`height: ${o}px`,"vertical-align: middle","line-height: 0"];if(t.transform&&i.push(`transform: ${t.transform}`),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"?(i.push(`float: ${t.cssFloat}`),i.push("margin: 4px 8px")):t.displayMode==="block"&&(i.push("display: block"),i.push("margin: 4px auto")),t.shadowColor){let m=t.shadowOffsetX||2,b=t.shadowOffsetY||2,g=t.shadowBlur||4;i.push(`filter: drop-shadow(${m}px ${b}px ${g}px ${t.shadowColor})`);}if(t.glowColor&&t.glowRadius){let m=i.find(g=>g.startsWith("filter:")),b=`drop-shadow(0 0 ${t.glowRadius}px ${t.glowColor})`;if(m){let g=i.indexOf(m);i[g]=m+" "+b;}else i.push(`filter: ${b}`);}r.style=i.join("; ");let a="",s;if(t.fillType==="gradient"&&t.gradientStops){let m=`grad-${t.shapeId||Math.random().toString(36).slice(2,8)}`;s=`url(#${m})`,a=Mw(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,d=t.outlineColor||"#000000",c=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",u=Iw(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:${d};stroke-width:${l}${c}">`+(a?`<defs>${a}</defs>`:"")+u+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var Qm=nt({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var eg=nt({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 tg=nt({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 ng=nt({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 og=nt({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 zw={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}},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]]}},_w={content:"(tableCell | tableHeader)+",tableRole:"row",attrs:{height:{default:null},heightRule:{default:null},isHeader:{default:false}},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]}},$w={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 rg(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=$w[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 ig(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 ag(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 sg(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 Ww={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}},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(...ig(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...sg(t)),o.push(...rg(t)),o.push(...ag(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]}},Vw={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}},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(...ig(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...sg(t)),o.push(...rg(t)),o.push(...ag(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 Ue(e){let{selection:t}=e,{$from:n}=t,o=t instanceof CellSelection,r,i,a,s,l;for(let p=n.depth;p>0;p--){let f=n.node(p);if(f.type.name==="tableCell"||f.type.name==="tableHeader"){l=f;let m=n.node(p-1);if(m&&m.type.name==="tableRow"){let b=0,g=false;m.forEach((h,x,y)=>{g||(y===n.index(p-1)?(s=b,g=true):b+=h.attrs.colspan||1);});}}else if(f.type.name==="tableRow"){let m=n.node(p-1);m&&m.type.name==="table"&&(a=n.index(p-1));}else if(f.type.name==="table"){r=f,i=n.before(p);break}}if(!r)return {isInTable:false};let d=0,c=0;r.forEach(p=>{if(p.type.name==="tableRow"){d++;let f=0;p.forEach(m=>{f+=m.attrs.colspan||1;}),c=Math.max(c,f);}});let u=l&&((l.attrs.colspan||1)>1||(l.attrs.rowspan||1)>1);return {isInTable:true,table:r,tablePos:i,rowIndex:a,columnIndex:s,rowCount:d,columnCount:c,hasMultiCellSelection:o,canSplitCell:!!u}}function _i(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 lg(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 cg(){return (e,t)=>{if(!_i(e))return false;let n=lg(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 d=l+1+1,c=e.tr.setSelection(Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}if(s<r.childCount-1){let d=o.before(n.rowDepth)+i.nodeSize;if(t){let c=d+1+1+1,u=e.tr.setSelection(Selection.near(e.doc.resolve(c)));t(u.scrollIntoView());}return true}return false}}function dg(){return (e,t)=>{if(!_i(e))return false;let n=lg(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),d=n.cellPos-l.nodeSize;if(t){let c=d+l.nodeSize-2,u=e.tr.setSelection(Selection.near(e.doc.resolve(c),-1));t(u.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),d=o.before(n.rowDepth)-s.nodeSize;if(t){let u=d+s.nodeSize-1-1,p=e.tr.setSelection(Selection.near(e.doc.resolve(u),-1));t(p.scrollIntoView());}return true}return false}}var Zw=nt({name:"table",schemaNodeName:"table",nodeSpec:zw}),Uw=nt({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:_w}),qw=nt({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:Ww}),Kw=nt({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:Vw}),Gw=on({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...M){return (O,C,P)=>{for(let I of M)if(I(O,C,P))return true;return false}}function o(M,O={}){let C=M?.attrs??{};return {colspan:C.colspan||1,rowspan:1,colwidth:C.colwidth,width:C.width,widthType:C.widthType,verticalAlign:C.verticalAlign,backgroundColor:C.backgroundColor,borders:C.borders,margins:C.margins,textDirection:C.textDirection,noWrap:C.noWrap,...O}}function r(M,O,C="000000"){let P=[],z=Math.floor(9360/O),Y=360,j="atLeast",F={style:"single",size:4,color:{rgb:C}},V={top:F,bottom:F,left:F,right:F};for(let be=0;be<M;be++){let me=[];for(let oe=0;oe<O;oe++){let K=t.nodes.paragraph.create(),de={colspan:1,rowspan:1,borders:V,width:z,widthType:"dxa"};me.push(t.nodes.tableCell.create(de,K));}P.push(t.nodes.tableRow.create({height:Y,heightRule:j},me));}let G=Array(O).fill(z);return t.nodes.table.create({columnWidths:G,width:9360,widthType:"dxa"},P)}function i(M,O){return (C,P)=>{let{$from:I}=C.selection,z="000000",Y=C.storedMarks||I.marks();for(let V of Y)if(V.type.name==="textColor"&&V.attrs.rgb){z=V.attrs.rgb;break}let j=I.pos,F=Ue(C);if(F.isInTable&&F.tablePos!==void 0&&F.table)j=F.tablePos+F.table.nodeSize;else for(let V=I.depth;V>0;V--)if(I.node(V).type.spec.group==="block"||V===1){j=I.after(V);break}if(P){let V=r(M,O,z),G=t.nodes.paragraph.create(),me=C.doc.resolve(j).nodeBefore?.type.name==="table",oe=me?[G,V,G]:[V,G],K=C.tr.insert(j,oe),de=j+1;me&&(de+=G.nodeSize);let Ke=de+1+1;K.setSelection(TextSelection.create(K.doc,Ke)),P(K.scrollIntoView());}return true}}function a(M,O){let C=Ue(M);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0)return false;if(O){let P=M.tr,I=C.table.child(C.rowIndex),z=[];I.forEach(F=>{let V=t.nodes.paragraph.create(),G=o(F);z.push(t.nodes.tableCell.create(G,V));});let Y=t.nodes.tableRow.create({height:I.attrs.height??360,heightRule:I.attrs.heightRule??"atLeast"},z),j=C.tablePos+1;for(let F=0;F<C.rowIndex;F++)j+=C.table.child(F).nodeSize;P.insert(j,Y),O(P.scrollIntoView());}return true}function s(M,O){let C=Ue(M);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0)return false;if(O){let P=M.tr,I=C.table.child(C.rowIndex),z=[];I.forEach(F=>{let V=t.nodes.paragraph.create(),G=o(F);z.push(t.nodes.tableCell.create(G,V));});let Y=t.nodes.tableRow.create({height:I.attrs.height??360,heightRule:I.attrs.heightRule??"atLeast"},z),j=C.tablePos+1;for(let F=0;F<=C.rowIndex;F++)j+=C.table.child(F).nodeSize;P.insert(j,Y),O(P.scrollIntoView());}return true}function l(M,O){let C=Ue(M);if(!C.isInTable||C.rowIndex===void 0||!C.table||C.tablePos===void 0||(C.rowCount||0)<=1)return false;if(O){let P=M.tr,I=C.tablePos+1;for(let Y=0;Y<C.rowIndex;Y++)I+=C.table.child(Y).nodeSize;let z=I+C.table.child(C.rowIndex).nodeSize;P.delete(I,z),O(P.scrollIntoView());}return true}function d(M,O){let C=Ue(M);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0)return false;if(O){let P=M.tr,I=(C.columnCount||1)+1,z=Math.floor(100/I),Y=C.tablePos+1,j=0;C.table.forEach(V=>{if(V.type.name==="tableRow"){let G=Y+1,be=0;if(V.forEach(me=>{if(be===C.columnIndex){let oe=t.nodes.paragraph.create(),K=o(me,{colspan:1,rowspan:1});j===0&&(K.width=z,K.widthType="pct");let de=t.nodes.tableCell.create(K,oe);P=P.insert(G,de);}G+=me.nodeSize,be+=me.attrs.colspan||1;}),be<=C.columnIndex){let me=t.nodes.paragraph.create(),oe=o(V.child(V.childCount-1)??null,{colspan:1,rowspan:1});j===0&&(oe.width=z,oe.widthType="pct");let K=t.nodes.tableCell.create(oe,me);P=P.insert(G,K);}j++;}Y+=V.nodeSize;});let F=P.doc.nodeAt(C.tablePos);if(F&&F.type.name==="table"){let V=F.child(0);if(V&&V.type.name==="tableRow"){let oe=C.tablePos+2;V.forEach(K=>{(K.type.name==="tableCell"||K.type.name==="tableHeader")&&(P=P.setNodeMarkup(oe,void 0,{...K.attrs,width:z,widthType:"pct"})),oe+=K.nodeSize;});}let G=V?.childCount??I,be=F.attrs.width||9360,me=Math.floor(be/Math.max(1,G));P=P.setNodeMarkup(C.tablePos,void 0,{...F.attrs,columnWidths:Array(G).fill(me)});}O(P.scrollIntoView());}return true}function c(M,O){let C=Ue(M);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0)return false;if(O){let P=M.tr,I=(C.columnCount||1)+1,z=Math.floor(100/I),Y=C.tablePos+1,j=0;C.table.forEach(V=>{if(V.type.name==="tableRow"){let G=Y+1,be=0,me=false;if(V.forEach(oe=>{if(G+=oe.nodeSize,be+=oe.attrs.colspan||1,!me&&be>C.columnIndex){let K=t.nodes.paragraph.create(),de=o(oe,{colspan:1,rowspan:1});j===0&&(de.width=z,de.widthType="pct");let Fe=t.nodes.tableCell.create(de,K);P=P.insert(G,Fe),me=true;}}),!me){let oe=t.nodes.paragraph.create(),K=o(V.child(V.childCount-1)??null,{colspan:1,rowspan:1});j===0&&(K.width=z,K.widthType="pct");let de=t.nodes.tableCell.create(K,oe);P=P.insert(G,de);}j++;}Y+=V.nodeSize;});let F=P.doc.nodeAt(C.tablePos);if(F&&F.type.name==="table"){let V=F.child(0);if(V&&V.type.name==="tableRow"){let oe=C.tablePos+2;V.forEach(K=>{(K.type.name==="tableCell"||K.type.name==="tableHeader")&&(P=P.setNodeMarkup(oe,void 0,{...K.attrs,width:z,widthType:"pct"})),oe+=K.nodeSize;});}let G=V?.childCount??I,be=F.attrs.width||9360,me=Math.floor(be/Math.max(1,G));P=P.setNodeMarkup(C.tablePos,void 0,{...F.attrs,columnWidths:Array(G).fill(me)});}O(P.scrollIntoView());}return true}function u(M,O){let C=Ue(M);if(!C.isInTable||C.columnIndex===void 0||!C.table||C.tablePos===void 0||(C.columnCount||0)<=1)return false;if(O){let P=M.tr,I=(C.columnCount||2)-1,z=Math.floor(100/I),Y=[],j=C.tablePos+1;C.table.forEach(V=>{if(V.type.name==="tableRow"){let G=j+1,be=0;V.forEach(me=>{let oe=G,K=G+me.nodeSize,de=me.attrs.colspan||1;be<=C.columnIndex&&C.columnIndex<be+de&&Y.push({start:oe,end:K}),G=K,be+=de;});}j+=V.nodeSize;}),Y.reverse().forEach(({start:V,end:G})=>{P=P.delete(V,G);});let F=P.doc.nodeAt(C.tablePos);if(F&&F.type.name==="table"){let V=F.child(0);if(V&&V.type.name==="tableRow"){let oe=C.tablePos+2;V.forEach(K=>{(K.type.name==="tableCell"||K.type.name==="tableHeader")&&(P=P.setNodeMarkup(oe,void 0,{...K.attrs,width:z,widthType:"pct"})),oe+=K.nodeSize;});}let G=V?.childCount??I,be=F.attrs.width||9360,me=Math.floor(be/Math.max(1,G));P=P.setNodeMarkup(C.tablePos,void 0,{...F.attrs,columnWidths:Array(G).fill(me)});}O(P.scrollIntoView());}return true}function p(M,O){let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(O){let P=M.tr;P.delete(C.tablePos,C.tablePos+C.table.nodeSize),O(P.scrollIntoView());}return true}function f(M,O){let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(O){let P=C.tablePos+1,I=M.doc.resolve(P),z=M.doc.resolve(C.tablePos+C.table.nodeSize-2),Y=CellSelection.create(M.doc,I.pos,z.pos);O(M.tr.setSelection(Y));}return true}function m(M,O){let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table||C.rowIndex===void 0)return false;if(O){let I=C.tablePos+1;for(let V=0;V<C.rowIndex;V++){let G=C.table.child(V);I+=G.nodeSize;}let z=C.table.child(C.rowIndex),Y=I+1,j=I+z.nodeSize-2,F=CellSelection.create(M.doc,Y,j);O(M.tr.setSelection(F));}return true}function b(M,O){let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table||C.columnIndex===void 0)return false;if(O){let P=C.tablePos+1,I=C.table.child(0),z=C.table.child(C.table.childCount-1),Y=P+1;for(let G=0;G<C.columnIndex&&G<I.childCount;G++)Y+=I.child(G).nodeSize;let j=P;for(let G=0;G<C.table.childCount-1;G++)j+=C.table.child(G).nodeSize;let F=j+1;for(let G=0;G<C.columnIndex&&G<z.childCount;G++)F+=z.child(G).nodeSize;let V=CellSelection.create(M.doc,Y,F);O(M.tr.setSelection(V));}return true}function g(M){let O=M.selection,C=[];if(O instanceof CellSelection)return O.forEachCell((I,z)=>{C.push({pos:z,node:I});}),C;let{$from:P}=O;for(let I=P.depth;I>0;I--){let z=P.node(I);if(z.type.name==="tableCell"||z.type.name==="tableHeader"){C.push({pos:P.before(I),node:z});break}}return C}function h(M,O){let C=new Map,P=new Map,I=M.childCount,z=0;return M.forEach((Y,j,F)=>{if(Y.type.name!=="tableRow")return;let V=0;Y.forEach((G,be)=>{let me=O+j+be+2,oe=G.attrs.colspan||1;C.set(me,{rowIdx:F,colIdx:V,colspan:oe,pos:me,node:G}),P.set(`${F},${V}`,me),V+=oe;}),z=Math.max(z,V);}),{cellByPos:C,cellByRC:P,totalRows:I,totalCols:z}}function x(M,O){return (C,P)=>{let I=Ue(C);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;if(P){let z=C.tr,Y=I.table,j=I.tablePos,F=O??{style:"single",size:4,color:{rgb:"000000"}},V={style:"none"},{cellByPos:G,cellByRC:be}=h(Y,j),me=g(C),oe=1/0,K=-1,de=1/0,Fe=-1;for(let{pos:ze}of me){let W=G.get(ze);W&&(oe=Math.min(oe,W.rowIdx),K=Math.max(K,W.rowIdx),de=Math.min(de,W.colIdx),Fe=Math.max(Fe,W.colIdx+W.colspan-1));}let Ke=new Map,Ge=(ze,W)=>Ke.get(ze)??{...W.attrs},Ye=(ze,W)=>{Ke.set(ze,W);};for(let{pos:ze}of me){let W=G.get(ze);if(!W)continue;let Te=W.rowIdx===oe,Ie=W.rowIdx===K,Me=W.colIdx===de,Qe=W.colIdx+W.colspan-1===Fe,Be;switch(M){case "all":Be={top:F,bottom:F,left:F,right:F};break;case "outside":Be={top:Te?F:V,bottom:Ie?F:V,left:Me?F:V,right:Qe?F:V};break;case "inside":Be={top:Te?V:F,bottom:Ie?V:F,left:Me?V:F,right:Qe?V:F};break;case "none":Be={top:V,bottom:V,left:V,right:V};break}let xt=Ge(ze,W.node),Gt=xt.borders||{};if(Ye(ze,{...xt,borders:{...Gt,...Be}}),Be.top){let je=be.get(`${W.rowIdx-1},${W.colIdx}`);if(je!==void 0){let Yt=G.get(je),_e=Ge(je,Yt.node),Dt=_e.borders||{};Ye(je,{..._e,borders:{...Dt,bottom:Be.top}});}}if(Be.bottom){let je=be.get(`${W.rowIdx+1},${W.colIdx}`);if(je!==void 0){let Yt=G.get(je),_e=Ge(je,Yt.node),Dt=_e.borders||{};Ye(je,{..._e,borders:{...Dt,top:Be.bottom}});}}if(Be.left){let je=be.get(`${W.rowIdx},${W.colIdx-1}`);if(je!==void 0){let Yt=G.get(je),_e=Ge(je,Yt.node),Dt=_e.borders||{};Ye(je,{..._e,borders:{...Dt,right:Be.left}});}}if(Be.right){let je=be.get(`${W.rowIdx},${W.colIdx+W.colspan}`);if(je!==void 0){let Yt=G.get(je),_e=Ge(je,Yt.node),Dt=_e.borders||{};Ye(je,{..._e,borders:{...Dt,left:Be.right}});}}}for(let[ze,W]of Ke)z.setNodeMarkup(z.mapping.map(ze),void 0,W);P(z.scrollIntoView());}return true}}function y(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O),Y=M?M.replace(/^#/,""):null;for(let{pos:j,node:F}of z)I.setNodeMarkup(I.mapping.map(j),void 0,{...F.attrs,backgroundColor:Y});C(I.scrollIntoView());}return true}}function k(M,O){return (C,P)=>{let I=Ue(C);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;if(P){let z=C.tr,Y=g(C),j=O||{style:"none"},{cellByPos:F,cellByRC:V}=h(I.table,I.tablePos),G=new Map,be=(K,de)=>G.get(K)??{...de.attrs},me=(K,de)=>G.set(K,de),oe={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:K,node:de}of Y){let Fe=F.get(K),Ke=be(K,de),Ge=Ke.borders||{},Ye=M==="all"?["top","bottom","left","right"]:[M],ze={...Ge};for(let W of Ye)if(ze[W]=j,Fe){let Te=oe[W],Ie=W==="right"?Fe.colIdx+Fe.colspan:Fe.colIdx+Te.dCol,Me=V.get(`${Fe.rowIdx+Te.dRow},${Ie}`);if(Me!==void 0){let Qe=F.get(Me),Be=be(Me,Qe.node),xt=Be.borders||{};me(Me,{...Be,borders:{...xt,[Te.adjSide]:j}});}}me(K,{...Ke,borders:ze});}for(let[K,de]of G)z.setNodeMarkup(z.mapping.map(K),void 0,de);P(z.scrollIntoView());}return true}}function T(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O);for(let{pos:Y,node:j}of z)I.setNodeMarkup(I.mapping.map(Y),void 0,{...j.attrs,verticalAlign:M});C(I.scrollIntoView());}return true}}function A(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O);for(let{pos:Y,node:j}of z){let V={...j.attrs.margins||{},...M};I.setNodeMarkup(I.mapping.map(Y),void 0,{...j.attrs,margins:V});}C(I.scrollIntoView());}return true}}function B(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O);for(let{pos:Y,node:j}of z)I.setNodeMarkup(I.mapping.map(Y),void 0,{...j.attrs,textDirection:M});C(I.scrollIntoView());}return true}}function R(){return (M,O)=>{let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(O){let P=M.tr,I=g(M);for(let{pos:z,node:Y}of I)P.setNodeMarkup(P.mapping.map(z),void 0,{...Y.attrs,noWrap:!Y.attrs.noWrap});O(P.scrollIntoView());}return true}}function E(M,O){return (C,P)=>{let I=Ue(C);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;if(P){let z=C.tr,{$from:Y}=C.selection;for(let j=Y.depth;j>0;j--){let F=Y.node(j);if(F.type.name==="tableRow"){let V=Y.before(j),G={...F.attrs,height:M,heightRule:M?O||"atLeast":null};return z.setNodeMarkup(V,void 0,G),P(z.scrollIntoView()),true}}}return true}}function S(){return (M,O)=>{let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table||!C.columnCount)return false;if(O){let P=M.tr,I=C.table,z=C.columnCount,Y=I.attrs.columnWidths,j=Y?Y.reduce((be,me)=>be+me,0):9360,F=Math.floor(j/z),V=C.tablePos+1;I.forEach(be=>{if(be.type.name==="tableRow"){let me=V+1;be.forEach(oe=>{(oe.type.name==="tableCell"||oe.type.name==="tableHeader")&&(P=P.setNodeMarkup(me,void 0,{...oe.attrs,width:F,widthType:"dxa",colwidth:null})),me+=oe.nodeSize;});}V+=be.nodeSize;});let G=Array(z).fill(F);P=P.setNodeMarkup(C.tablePos,void 0,{...I.attrs,columnWidths:G}),O(P.scrollIntoView());}return true}}function N(){return (M,O)=>{let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(O){let P=M.tr,I=C.table,z=C.tablePos+1;I.forEach(Y=>{if(Y.type.name==="tableRow"){let j=z+1;Y.forEach(F=>{(F.type.name==="tableCell"||F.type.name==="tableHeader")&&(P=P.setNodeMarkup(j,void 0,{...F.attrs,width:null,widthType:null,colwidth:null})),j+=F.nodeSize;});}z+=Y.nodeSize;}),P=P.setNodeMarkup(C.tablePos,void 0,{...I.attrs,columnWidths:null,width:null,widthType:"auto"}),O(P.scrollIntoView());}return true}}function _(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=P.table,Y=P.tablePos,j=z.childCount,F=M.look??{firstRow:true,lastRow:false,noHBand:false},V=M.conditionals??{},G=M.tableBorders;I=I.setNodeMarkup(Y,void 0,{...z.attrs,styleId:M.styleId});let be=0,me=Y+1;for(let oe=0;oe<j;oe++){let K=z.child(oe),de=oe===0&&!!F.firstRow,Fe=oe===j-1&&!!F.lastRow,Ke=F.noHBand!==true,Ge=K.childCount,Ye;de?Ye="firstRow":Fe?Ye="lastRow":(Ke&&(Ye=be%2===0?"band1Horz":"band2Horz"),be++);let ze=me+1;for(let W=0;W<Ge;W++){let Te=K.child(W),Ie=I.mapping.map(ze),Me=Ye,Qe=W===0&&!!F.firstCol,Be=W===Ge-1&&!!F.lastCol;de&&Qe&&V.nwCell?Me="nwCell":de&&Be&&V.neCell?Me="neCell":Fe&&Qe&&V.swCell?Me="swCell":Fe&&Be&&V.seCell?Me="seCell":Qe?Me="firstCol":Be&&(Me="lastCol");let xt=Me?V[Me]:void 0,Gt={...Te.attrs};xt?.backgroundColor?Gt.backgroundColor=xt.backgroundColor:Gt.backgroundColor=null;let je={},Yt=["top","bottom","left","right"];for(let _e of Yt)xt?.borders&&xt.borders[_e]!==void 0?je[_e]=xt.borders[_e]:G&&(_e==="top"&&oe>0||_e==="bottom"&&oe<j-1?je[_e]=G.insideH??G[_e]:_e==="left"&&W>0||_e==="right"&&W<Ge-1?je[_e]=G.insideV??G[_e]:je[_e]=G[_e]);Object.keys(je).length>0?Gt.borders=je:Gt.borders=null,I=I.setNodeMarkup(Ie,void 0,Gt),ze+=Te.nodeSize;}me+=K.nodeSize;}C(I.scrollIntoView());}return true}}function U(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z={...P.table.attrs};"width"in M&&(z.width=M.width),"widthType"in M&&(z.widthType=M.widthType),"justification"in M&&(z.justification=M.justification),I.setNodeMarkup(P.tablePos,void 0,z),C(I.scrollIntoView());}return true}}function Z(){return (M,O)=>{let C=Ue(M);if(!C.isInTable||C.tablePos===void 0||!C.table)return false;if(O){let P=M.tr,{$from:I}=M.selection;for(let z=I.depth;z>0;z--){let Y=I.node(z);if(Y.type.name==="tableRow"){let j=I.before(z),F={...Y.attrs,isHeader:!Y.attrs.isHeader};return P.setNodeMarkup(j,void 0,F),O(P.scrollIntoView()),true}}}return true}}function L(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O),Y=M.replace(/^#/,""),j={style:"single",size:4},{cellByPos:F,cellByRC:V}=h(P.table,P.tablePos),G=new Map,be=(K,de)=>G.get(K)??{...de.attrs},me=(K,de)=>G.set(K,de),oe={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:K,node:de}of z){let Fe=F.get(K),Ke=be(K,de),Ge=Ke.borders||{},Ye={};for(let ze of ["top","bottom","left","right"]){let W={...j,...Ge[ze],color:{rgb:Y}};if(Ye[ze]=W,Fe){let Te=oe[ze],Ie=ze==="right"?Fe.colIdx+Fe.colspan:Fe.colIdx+Te.dCol,Me=V.get(`${Fe.rowIdx+Te.dRow},${Ie}`);if(Me!==void 0){let Qe=F.get(Me),Be=be(Me,Qe.node),xt=Be.borders||{};me(Me,{...Be,borders:{...xt,[Te.adjSide]:W}});}}}me(K,{...Ke,borders:{...Ge,...Ye}});}for(let[K,de]of G)I.setNodeMarkup(I.mapping.map(K),void 0,de);C(I.scrollIntoView());}return true}}function H(M){return (O,C)=>{let P=Ue(O);if(!P.isInTable||P.tablePos===void 0||!P.table)return false;if(C){let I=O.tr,z=g(O),Y={style:"single",color:{rgb:"000000"}},{cellByPos:j,cellByRC:F}=h(P.table,P.tablePos),V=new Map,G=(oe,K)=>V.get(oe)??{...K.attrs},be=(oe,K)=>V.set(oe,K),me={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:oe,node:K}of z){let de=j.get(oe),Fe=G(oe,K),Ke=Fe.borders||{},Ge={};for(let Ye of ["top","bottom","left","right"]){let ze={...Y,...Ke[Ye],size:M};if(Ge[Ye]=ze,de){let W=me[Ye],Te=Ye==="right"?de.colIdx+de.colspan:de.colIdx+W.dCol,Ie=F.get(`${de.rowIdx+W.dRow},${Te}`);if(Ie!==void 0){let Me=j.get(Ie),Qe=G(Ie,Me.node),Be=Qe.borders||{};be(Ie,{...Qe,borders:{...Be,[W.adjSide]:ze}});}}}be(oe,{...Fe,borders:{...Ke,...Ge}});}for(let[oe,K]of V)I.setNodeMarkup(I.mapping.map(oe),void 0,K);C(I.scrollIntoView());}return true}}function q(){return (M,O)=>{let C=M.selection;if(!("$anchorCell"in C&&typeof C.forEachCell=="function"))return false;let I=Ue(M);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;let z=0;I.table.descendants(F=>{(F.type.name==="tableCell"||F.type.name==="tableHeader")&&(z+=1);});let Y=0;if(C.forEachCell(()=>{Y+=1;}),!(z>0&&Y>=z))return false;if(O){let F=M.tr.delete(I.tablePos,I.tablePos+I.table.nodeSize);O(F.scrollIntoView());}return true}}function xe(){return M=>{let{$from:O,empty:C}=M.selection;if(!C)return false;let P=O.parent;if(P.type.name!=="paragraph"||P.textContent.length>0)return false;let I=O.depth;if(I<1)return false;let z=O.node(I-1),Y=O.index(I-1),j=Y>0?z.child(Y-1):null,F=Y+1<z.childCount?z.child(Y+1):null,V=j?.type.name==="table",G=F?.type.name==="table";return !!(V||G)}}let ie=new PluginKey("activeCell"),we=new Plugin({key:ie,props:{decorations(M){let{selection:O}=M;if(O instanceof CellSelection)return DecorationSet.empty;let{$from:C}=O;for(let P=C.depth;P>0;P--){let I=C.node(P);if(I.type.name==="tableCell"||I.type.name==="tableHeader"){let z=C.before(P);return DecorationSet.create(M.doc,[Decoration.node(z,z+I.nodeSize,{class:"activeCell"})])}}return DecorationSet.empty}}});return {plugins:[columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),tableEditing(),we],keyboardShortcuts:{Backspace:n(q(),xe()),Delete:n(q(),xe())},commands:{insertTable:(M,O)=>i(M,O),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>d,addColumnRight:()=>c,deleteColumn:()=>u,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>mergeCells,splitCell:()=>splitCell,setCellBorder:(M,O)=>k(M,O),setTableBorders:(M,O)=>x(M,O),setCellVerticalAlign:M=>T(M),setCellMargins:M=>A(M),setCellTextDirection:M=>B(M),toggleNoWrap:()=>R(),setRowHeight:(M,O)=>E(M,O),toggleHeaderRow:()=>Z(),distributeColumns:()=>S(),autoFitContents:()=>N(),setTableProperties:M=>U(M),applyTableStyle:M=>_(M),setCellFillColor:M=>y(M),setTableBorderColor:M=>L(M),setTableBorderWidth:M=>H(M),removeTableBorders:()=>x("none"),setAllTableBorders:M=>x("all",M),setOutsideTableBorders:M=>x("outside",M),setInsideTableBorders:M=>x("inside",M)}}}});function ug(){return [Zw(),Uw(),qw(),Kw(),Gw()]}function $d(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function pg(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,d=new Set;return t.doc.nodesBetween(o.pos,r.pos,(c,u)=>{if(c.type.name==="paragraph"&&!d.has(u))if(d.add(u),s)l=l.setNodeMarkup(u,void 0,{...c.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(u,void 0,{...c.attrs,numPr:{numId:e,ilvl:c.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var Yw=(e,t)=>pg(1)(e,t),jw=(e,t)=>pg(2)(e,t),Xw=(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},Jw=(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},Qw=(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 ek(){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 tk(){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 nk(){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 ok(){return (e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph")return false;let r=o.attrs.numPr;if(!r)return false;let i=r.ilvl??0;if(i>=8)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:{...r,ilvl:i+1},indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}}function rk(){return (e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph")return false;let r=o.attrs.numPr;if(!r)return false;let i=r.ilvl??0;if(i<=0){if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:{...r,ilvl:i-1},indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}}function ik(){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 fg=on({name:"list",priority:Oo.High,onSchemaReady(){return {commands:{toggleBulletList:()=>Yw,toggleNumberedList:()=>jw,increaseListLevel:()=>Xw,decreaseListLevel:()=>Jw,removeList:()=>Qw},keyboardShortcuts:{Tab:$d(cg(),ok(),ik()),"Shift-Tab":$d(dg(),rk()),"Shift-Enter":()=>false,Enter:$d(ek(),tk()),Backspace:nk()}}}});function gg(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var pk=(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},fk=(e,t,n)=>{if(!splitBlock(e,t,n))return false;if(t&&n){let o=n.state,{$from:r}=o.selection,i=r.parent;if(i.type.name==="paragraph"&&i.attrs.borders){let a=r.before(),s=o.tr.setNodeMarkup(a,void 0,{...i.attrs,borders:null});t(s.scrollIntoView());}}return true},hg=on({name:"baseKeymap",priority:Oo.Low,onSchemaReady(e){return {keyboardShortcuts:{...baseKeymap,Enter:fk,Backspace:gg(deleteSelection,pk,joinBackward),Delete:gg(deleteSelection,joinForward),"Mod-a":selectAll,Escape:selectParentNode}}}});var Wd=new PluginKey("selectionTracker");function br(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,h,x)=>{h<=o&&(s=x),h<=r&&(l=x);});let d=hk(e),c=a.parent,u={};c.type.name==="paragraph"&&(c.attrs.alignment&&(u.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(u.lineSpacing=c.attrs.lineSpacing,u.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.indentLeft&&(u.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(u.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(u.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(u.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(u.tabs=c.attrs.tabs),c.attrs.numPr&&(u.numPr=c.attrs.numPr));let p=c.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl;return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:d,paragraphFormatting:u,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b}}function hk(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 ja(e){return new Plugin({key:Wd,state:{init(t,n){return br(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=br(r);return e&&!bk(n,i)&&setTimeout(()=>e(i),0),i}},view(){return {update(t,n){if(t.state.selection.eq(n.selection)&&t.state.doc.eq(n.doc))return;let o=br(t.state);e&&e(o);}}}})}function bk(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&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var bg=on({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[ja(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(br(n),true)}}}});var vk=new PluginKey("imageDrag"),yg=on({name:"imageDrag",onSchemaReady(e){return {plugins:[new Plugin({key:vk,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof NodeSelection&&r.node.type.name==="image"){n.dom.classList.add("pm-image-dragging");let i=o;if(i.dataTransfer){i.dataTransfer.effectAllowed="move";let a=document.createElement("div");a.style.cssText="position: fixed; left: -9999px; top: -9999px; opacity: 0.6; pointer-events: none; border: 2px dashed var(--doc-primary, #2563eb); border-radius: 4px; background: rgba(37, 99, 235, 0.08);",a.style.width=`${r.node.attrs.width||100}px`,a.style.height=`${r.node.attrs.height||100}px`,document.body.appendChild(a),i.dataTransfer.setDragImage(a,0,0),requestAnimationFrame(()=>{document.body.removeChild(a);});}}return false},dragend(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false},dragover(n,o){let{selection:r}=n.state;if(r instanceof NodeSelection&&r.node.type.name==="image"){let i=o;i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move");}return false},drop(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false}}}})]}}});var vg=on({name:"dropCursor",onSchemaReady(){return {plugins:[dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});function Xr(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",cm()),o("text",dm()),o("paragraph",xm()),o("history",vm({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Cm()),o("italic",wm()),o("underline",Rm()),o("strike",Em()),o("textColor",Im()),o("highlight",Mm()),o("fontSize",Lm()),o("fontFamily",Fm()),o("superscript",Dm()),o("subscript",Am()),o("hyperlink",Bm()),o("allCaps",Nm()),o("smallCaps",Hm()),o("footnoteRef",Om()),o("characterSpacing",zm()),o("emboss",Vm()),o("imprint",Zm()),o("textShadow",Um()),o("emphasisMark",qm()),o("textOutline",Km()),o("comment",_m()),o("insertion",$m()),o("deletion",Wm()),o("hardBreak",Gm()),o("tab",Ym()),o("image",jm()),o("textBox",Xm()),o("shape",Jm()),o("imageDrag",yg()),o("dropCursor",vg()),o("horizontalRule",Qm()),o("pageBreak",eg()),o("field",tg()),o("sdt",ng()),o("math",og()),t.has("table")||n.push(...ug()),o("list",fg()),o("baseKeymap",hg()),o("selectionTracker",bg({onSelectionChange:e.onSelectionChange})),n}var zo=class{constructor(t){e(this,"extensions");e(this,"schema",null);e(this,"plugins",[]);e(this,"commands",{});this.extensions=[...t].sort((n,o)=>n.config.priority-o.config.priority);}buildSchema(){let t={},n={};for(let o of this.extensions)o.type==="node"?t[o.config.schemaNodeName]=o.config.nodeSpec:o.type==="mark"&&(n[o.config.schemaMarkName]=o.config.markSpec);this.schema=new Schema({nodes:t,marks:n});}initializeRuntime(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called before initializeRuntime()");let t={schema:this.schema},n=[],o=[],r={};for(let i of this.extensions){let a=i.onSchemaReady(t);a.commands&&Object.assign(r,a.commands),a.keyboardShortcuts&&n.push(a.keyboardShortcuts),a.plugins&&o.push(...a.plugins);}this.plugins=[...o,...n.map(i=>keymap(i))],this.commands=r;}getSchema(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called first");return this.schema}getPlugins(){return this.plugins}getCommands(){return this.commands}getCommand(t){return this.commands[t]}destroy(){this.plugins=[],this.commands={};}};var Xa=new zo(Xr());Xa.buildSchema();Xa.initializeRuntime();var xr=Xa,ve=Xa.getSchema();var $i=class{constructor(t){e(this,"stylesById");e(this,"docDefaults");e(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")}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 _o(e){return new $i(e)}function Qa(e,t){let n=e.package.document.content,o=[],r=t?.styles?_o(t.styles):null;for(let i of n)if(i.type==="paragraph"){let a=Cg(i),s=es(i,r);o.push(s);for(let l of a)o.push(Tg(l,r));Bk(i)&&o.push(ve.node("pageBreak"));}else if(i.type==="table"){let a=Vd(i,r);o.push(a);}return o.length===0&&o.push(ve.node("paragraph",{},[])),ve.node("doc",null,o)}function es(e,t,n,o){let r=kk(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let d=oo(l,o);for(let c of e.content){if(c.type==="commentRangeStart")s.add(c.id);else if(c.type==="commentRangeEnd")s.delete(c.id);else if(c.type==="run"){let u=Zd(c,d,t);s.size>0&&(u=wk(u,s)),i.push(...u);}else if(c.type==="hyperlink"){let u=Ud(c,d,t);i.push(...u);}else if(c.type==="simpleField"||c.type==="complexField"){let u=Ik(c,d);u&&i.push(u);}else if(c.type==="inlineSdt"){let u=Lk(c,d,t);u&&i.push(u);}else if(c.type==="insertion"){let u=Sg(c,"insertion",d,t);i.push(...u);}else if(c.type==="deletion"){let u=Sg(c,"deletion",d,t);i.push(...u);}else if(c.type==="mathEquation"){let u=Mk(c);u&&i.push(u);}c.type==="bookmarkStart"&&(a||(a=[]),a.push({id:c.id,name:c.name}));}return a&&(r.bookmarks=a),ve.node("paragraph",r,i)}function wk(e,t){if(t.size===0)return e;let n=[...t][0],o=ve.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function Sg(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...Zd(a,n,o)):a.type==="hyperlink"&&r.push(...Ud(a,n,o));let i=ve.marks[t].create({revisionId:e.info.id,author:e.info.author,date:e.info.date??null});return r.map(a=>a.isText?a.mark(i.addToSet(a.marks)):a)}function kk(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,_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;let l=Ja(n?.runProperties,t);if(r.defaultTextFormatting=oo(s,l),e.sectionProperties?.sectionStart){let d=e.sectionProperties.sectionStart;(d==="nextPage"||d==="continuous"||d==="oddPage"||d==="evenPage")&&(r.sectionBreakType=d);}!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.defaultTextFormatting=Ja(n?.runProperties,t);if(e.sectionProperties?.sectionStart){let i=e.sectionProperties.sectionStart;(i==="nextPage"||i==="continuous"||i==="oddPage"||i==="evenPage")&&(r.sectionBreakType=i);}return r}function pn(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=Ja(r.pPr?.runProperties,e),a=Ja(r.rPr,e),s=oo(i,a);return {tcPr:r.tcPr,rPr:s}}function no(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=oo(e.rPr,t.rPr),n}function Ja(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return oo(n,e)}function Pk(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],d=l.formatting?.gridSpan??1,c=l.formatting?.vMerge,u=`${r}-${a}`;if(c==="restart")o.set(a,r),t.set(u,{rowSpan:1,skip:false});else if(c==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(u,{rowSpan:1,skip:true});}else o.delete(a),t.set(u,{rowSpan:1,skip:false});a+=d;}}return t}function Vd(e,t){let n=Pk(e),o=e.columnWidths,r=o?.reduce((y,k)=>y+k,0)??0,i=e.formatting?.styleId,a=e.formatting?.look,s=i?t?.getStyle(i):void 0,l=e.formatting?.borders??s?.tblPr?.borders,d=e.formatting?.cellMargins??s?.tblPr?.cellMargins??void 0,c=d?{top:d.top?.value,bottom:d.bottom?.value,left:d.left?.value,right:d.right?.value}:void 0,u={styleId:e.formatting?.styleId,width:e.formatting?.width?.value,widthType:e.formatting?.width?.type,justification:e.formatting?.justification,columnWidths:o,floating:e.formatting?.floating,cellMargins:c},p={wholeTable:pn(t,i,"wholeTable"),firstRow:pn(t,i,"firstRow"),lastRow:pn(t,i,"lastRow"),firstCol:pn(t,i,"firstCol"),lastCol:pn(t,i,"lastCol"),band1Horz:pn(t,i,"band1Horz"),band2Horz:pn(t,i,"band2Horz"),band1Vert:pn(t,i,"band1Vert"),band2Vert:pn(t,i,"band2Vert"),nwCell:pn(t,i,"nwCell"),neCell:pn(t,i,"neCell"),swCell:pn(t,i,"swCell"),seCell:pn(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,g=e.rows.length,h=o?.length??e.rows[0]?.cells.reduce((y,k)=>y+(k.formatting?.gridSpan??1),0)??0,x=e.rows.map((y,k)=>{let T=k===0&&!!a?.firstRow,A=k===g-1&&!!a?.lastRow,B=f&&!T&&!A?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!T&&!A&&b++,Rk(y,t,T,o,r,p,B,m,a,l,k,g,h,n,c)});return ve.node("table",u,x)}function Rk(e,t,n,o,r,i,a,s,l,d,c,u,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header},g=e.cells.length,h=c===0,x=c===(u??1)-1,y=e.formatting?.conditionalFormat,k=y?.firstRow??h,T=y?.lastRow??x,A=p??g,B=0,R=[];for(let E=0;E<e.cells.length;E++){let S=e.cells[E],N=S.formatting?.gridSpan??1,_=`${c??0}-${B}`,U=f?.get(_),Z=U?.skip??false,L=U?.rowSpan??1,H;if(o&&r&&r>0){let Y=0;for(let j=0;j<N&&B+j<o.length;j++)Y+=o[B+j];H=Math.round(Y/r*100);}if(B+=N,Z)continue;let q=B-N===0,xe=B===A,ie=S.formatting?.conditionalFormat,we=ie?.firstRow??k,M=ie?.lastRow??T,O=ie?.firstColumn??q,C=ie?.lastColumn??xe,P;if(s){let Y=l?.firstColumn?1:0,j=B-N-Y;j>=0&&!(l?.lastColumn&&C)&&!(l?.firstColumn&&O)&&(P=j%2===0?i?.band1Vert:i?.band2Vert);}ie?.oddVBand?P=i?.band1Vert:ie?.evenVBand&&(P=i?.band2Vert);let I=a;y?.oddHBand?I=i?.band1Horz:y?.evenHBand&&(I=i?.band2Horz),ie?.oddHBand?I=i?.band1Horz:ie?.evenHBand&&(I=i?.band2Horz);let z=i?.wholeTable;z=no(z,I),z=no(z,P),we&&(l?.firstRow||y?.firstRow||ie?.firstRow)&&(z=no(z,i?.firstRow)),M&&(l?.lastRow||y?.lastRow||ie?.lastRow)&&(z=no(z,i?.lastRow)),O&&(l?.firstColumn||y?.firstColumn||ie?.firstColumn)&&(z=no(z,i?.firstCol)),C&&(l?.lastColumn||y?.lastColumn||ie?.lastColumn)&&(z=no(z,i?.lastCol)),we&&O&&(l?.firstRow||y?.firstRow||ie?.firstRow)&&(l?.firstColumn||y?.firstColumn||ie?.firstColumn)&&(z=no(z,i?.nwCell)),we&&C&&(l?.firstRow||y?.firstRow||ie?.firstRow)&&(l?.lastColumn||y?.lastColumn||ie?.lastColumn)&&(z=no(z,i?.neCell)),M&&O&&(l?.lastRow||y?.lastRow||ie?.lastRow)&&(l?.firstColumn||y?.firstColumn||ie?.firstColumn)&&(z=no(z,i?.swCell)),M&&C&&(l?.lastRow||y?.lastRow||ie?.lastRow)&&(l?.lastColumn||y?.lastColumn||ie?.lastColumn)&&(z=no(z,i?.seCell)),R.push(Ek(S,t,n,H,z,d,h,x,q,xe,L,m));}return ve.node("tableRow",b,R)}function Ek(e,t,n,o,r,i,a,s,l,d,c,u){let p=e.formatting,f=c??1,m=p?.width?.value,b=p?.width?.type;m===void 0&&o!==void 0&&(m=o,b="pct");let g=p?.shading?.fill?.rgb??r?.tcPr?.shading?.fill?.rgb,h=i?{top:a?i.top:i.insideH,bottom:s?i.bottom:i.insideH,left:l?i.left:i.insideV,right:d?i.right:i.insideV}:void 0,x=r?.tcPr?.borders,y=p?.borders,k=h||x||y?{...h??{},...x??{},...y??{}}:void 0,T={colspan:p?.gridSpan??1,rowspan:f,width:m,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:g,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:k,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}:u},A=[];for(let R of e.content)R.type==="paragraph"?A.push(es(R,t,void 0,r?.rPr)):R.type==="table"&&A.push(Vd(R,t));A.length===0&&A.push(ve.node("paragraph",{},[]));let B=n?"tableHeader":"tableCell";return ve.node(B,T,A)}function Ik(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=oo(t,o),a=qd(i);return ve.node("field",{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false},void 0,a)}function Mk(e){return ve.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Lk(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=Zd(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Ud(i,t,n);r.push(...a);}return ve.node("sdt",{sdtType:o.sdtType,alias:o.alias??null,tag:o.tag??null,lock:o.lock??null,placeholder:o.placeholder??null,showingPlaceholder:o.showingPlaceholder??false,dateFormat:o.dateFormat??null,listItems:o.listItems?JSON.stringify(o.listItems):null,checked:o.checked??null},r.length>0?r:void 0)}function Zd(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=oo(oo(t,r),e.formatting),a=qd(i);for(let s of e.content){let l=Fk(s,a);o.push(...l);}return o}function oo(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 Fk(e,t){switch(e.type){case "text":return e.text?[ve.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[ve.node("hardBreak")]:[];case "tab":return [ve.node("tab")];case "drawing":return e.image?[Dk(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[Ak(r)]}case "footnoteRef":let n=ve.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [ve.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=ve.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [ve.text(e.id.toString(),[...t,o])];default:return []}}function Dk(e){let t=e.size?.width?a$2(e.size.width):void 0,n=e.size?.height?a$2(e.size.height):void 0,o=e.wrap.type,r=e.wrap.wrapText,i=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?r==="left"?a="right":r==="right"||i==="left"?a="left":i==="right"?a="right":a="none":a="none";let s="inline";o==="inline"?s="inline":a&&a!=="none"?s="float":s="block";let l;if(e.transform){let h=[];e.transform.rotation&&h.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&h.push("scaleX(-1)"),e.transform.flipV&&h.push("scaleY(-1)"),h.length>0&&(l=h.join(" "));}let d=e.wrap.distT?a$2(e.wrap.distT):void 0,c=e.wrap.distB?a$2(e.wrap.distB):void 0,u=e.wrap.distL?a$2(e.wrap.distL):void 0,p=e.wrap.distR?a$2(e.wrap.distR):void 0,f;e.position&&(f={horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0});let m,b,g;if(e.outline&&e.outline.width){m=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(b=`#${e.outline.color.rgb}`);let h={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&&h[e.outline.style]||"solid";}return ve.node("image",{src:e.src||"",alt:e.alt,title:e.title,width:t,height:n,rId:e.rId,wrapType:o,displayMode:s,cssFloat:a,transform:l,distTop:d,distBottom:c,distLeft:u,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:g})}function Ud(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=ve.mark("hyperlink",{href:r,tooltip:e.tooltip,rId:e.rId});for(let a of e.children)if(a.type==="run"){let s=a.formatting?.styleId?n?.resolveRunStyle(a.formatting.styleId):void 0,l=oo(oo(t,s),a.formatting),c=[...qd(l),i];for(let u of a.content)u.type==="text"&&u.text&&o.push(ve.text(u.text,c));}return o}function qd(e){if(!e)return [];let t=[];return e.bold&&t.push(ve.mark("bold")),e.italic&&t.push(ve.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(ve.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(ve.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(ve.mark("textColor",{rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&e.highlight!=="none"&&t.push(ve.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(ve.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(ve.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"?t.push(ve.mark("superscript")):e.vertAlign==="subscript"&&t.push(ve.mark("subscript")),e.allCaps&&t.push(ve.mark("allCaps")),e.smallCaps&&t.push(ve.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(ve.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(ve.mark("emboss")),e.imprint&&t.push(ve.mark("imprint")),e.shadow&&t.push(ve.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(ve.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(ve.mark("textOutline")),t}function Ak(e){let t=e.size?.width?a$2(e.size.width):100,n=e.size?.height?a$2(e.size.height):80,o,r="solid",i,a,s;if(e.fill&&(r=e.fill.type,e.fill.color?.rgb&&(o=`#${e.fill.color.rgb}`),e.fill.type==="gradient"&&e.fill.gradient)){let p=e.fill.gradient;i=p.type,a=p.angle,s=JSON.stringify(p.stops.map(f=>({position:f.position,color:f.color.rgb?`#${f.color.rgb}`:"#000000"})));}let l,d,c;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(d=`#${e.outline.color.rgb}`),c=e.outline.style||"solid");let u;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&&(u=p.join(" "));}return ve.node("shape",{shapeType:e.shapeType||"rect",shapeId:e.id,width:t,height:n,fillColor:o,fillType:r,gradientType:i,gradientAngle:a,gradientStops:s,outlineWidth:l,outlineColor:d,outlineStyle:c,transform:u})}function Cg(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 Tg(e,t){let n=e.size?.width?a$2(e.size.width):200,o=e.size?.height?a$2(e.size.height):void 0,r;e.fill?.color?.rgb&&(r=`#${e.fill.color.rgb}`);let i,a,s;e.outline&&e.outline.width&&(i=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(a=`#${e.outline.color.rgb}`),s=e.outline.style||"solid");let l=e.margins?.top!=null?a$2(e.margins.top):4,d=e.margins?.bottom!=null?a$2(e.margins.bottom):4,c=e.margins?.left!=null?a$2(e.margins.left):7,u=e.margins?.right!=null?a$2(e.margins.right):7,p=[];for(let f of e.content)p.push(es(f,t));return p.length===0&&p.push(ve.node("paragraph",{},[])),ve.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:d,marginLeft:c,marginRight:u},p)}function Kd(e,t){let n=[],o=t?.styles?_o(t.styles):null;for(let r of e)if(r.type==="paragraph"){let i=Cg(r);n.push(es(r,o));for(let a of i)n.push(Tg(a,o));}else r.type==="table"&&n.push(Vd(r,o));return n.length===0&&n.push(ve.node("paragraph",{},[])),ve.node("doc",null,n)}function Bk(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 ts(){return ve.node("doc",null,[ve.node("paragraph",{},[])])}function ns(e,t){let o={content:kg(e),finalSectionProperties:t?.package.document.finalSectionProperties,sections:t?.package.document.sections};return t?{...t,package:{...t.package,document:o}}:{package:{document:o}}}function kg(e){let t=[];return e.forEach(n=>{n.type.name==="paragraph"?t.push(Gd(n)):n.type.name==="table"?t.push(Eg(n)):n.type.name==="textBox"?t.push(n1(n)):n.type.name==="pageBreak"&&t.push(Nk());}),t}function Nk(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Gd(e){let t=e.attrs,n=Hk(Pg(e),e),o=t.bookmarks;if(o&&o.length>0){let i=o.map(s=>({type:"bookmarkStart",id:s.id,name:s.name})),a=o.map(s=>({type:"bookmarkEnd",id:s.id}));n=[...i,...n,...a];}let r={type:"paragraph",paraId:t.paraId||void 0,textId:t.textId||void 0,formatting:Ok(t),content:n};return t.sectionBreakType&&(r.sectionProperties={sectionStart:t.sectionBreakType}),r}function Hk(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 s)r.has(l)||(o.push({type:"commentRangeStart",id:l}),r.add(l));i<e.length&&o.push(e[i]);for(let l of r)s.has(l)||(o.push({type:"commentRangeEnd",id:l}),r.delete(l));i++;});for(let a of r)o.push({type:"commentRangeEnd",id:a});return o}function Ok(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),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)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}}function Pg(e){let t=[],n=null,o=null,r=null;return e.forEach(i=>{let a=i.marks.find(c=>c.type.name==="footnoteRef");if(a){n&&(t.push(n),n=null,o=null),r&&(t.push(r),r=null);let u={type:a.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(a.attrs.id,10)||0};t.push({type:"run",content:[u]});return}let s=i.marks.find(c=>c.type.name==="insertion"),l=i.marks.find(c=>c.type.name==="deletion");if(s||l){n&&(t.push(n),n=null,o=null),r&&(t.push(r),r=null);let c=s||l,u=i.marks.filter(b=>b.type.name!=="insertion"&&b.type.name!=="deletion"),p=Yd(u),f={type:"run",content:i.isText&&i.text?[{type:"text",text:i.text}]:[],...Object.keys(p).length>0?{formatting:p}:{}},m={id:c.attrs.revisionId,author:c.attrs.author||"Unknown",date:c.attrs.date||void 0};s?t.push({type:"insertion",info:m,content:[f]}):t.push({type:"deletion",info:m,content:[f]});return}let d=i.marks.find(c=>c.type.name==="hyperlink");if(d){let c=zk(d),u=r?.href||(r?.anchor?`#${r.anchor}`:"");r&&u===c||(n&&(t.push(n),n=null,o=null),r&&t.push(r),r=$k(d)),wg(r,i);return}if(r&&(t.push(r),r=null),i.isText){let c=_k(i.marks);n&&o===c?Wk(n,i.text||""):(n&&t.push(n),n=Rg(i.text||"",i.marks),o=c);}else i.type.name==="hardBreak"?(n&&(t.push(n),n=null,o=null),t.push(Vk())):i.type.name==="image"?(n&&(t.push(n),n=null,o=null),t.push(Gk(i))):i.type.name==="shape"?(n&&(t.push(n),n=null,o=null),t.push(Yk(i))):i.type.name==="tab"?(n&&(t.push(n),n=null,o=null),t.push(Zk())):i.type.name==="field"?(n&&(t.push(n),n=null,o=null),t.push(Uk(i,i.marks))):i.type.name==="sdt"?(n&&(t.push(n),n=null,o=null),t.push(Kk(i))):i.type.name==="math"&&(n&&(t.push(n),n=null,o=null),t.push(qk(i)));}),n&&t.push(n),r&&t.push(r),t}function zk(e){return e.attrs.href||""}function _k(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 $k(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 wg(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=Rg(t.text,n);e.children.push(o);}}function Rg(e,t){let n=Yd(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function Wk(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 Vk(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function Zk(){return {type:"run",content:[{type:"tab"}]}}function Uk(e,t){let n=e.attrs,o=t&&t.length>0?Yd(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 qk(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function Kk(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=Pg(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function Gk(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));let i={type:"image",rId:t.rId||"",src:t.src,alt:t.alt||void 0,title:t.title||void 0,size:{width:t.width||0,height:t.height||0},wrap:r};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 {type:"run",content:[{type:"drawing",image:i}]}}function Yk(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 Yd(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,cs:o.ascii||void 0,asciiTheme:o.asciiTheme};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 jk(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 Eg(e){let t=e.attrs,n=[];e.forEach(r=>{r.type.name==="tableRow"&&n.push(Jk(r));});let o=Xk(t)||void 0;if(!o?.borders){let r=jk(n);if(r)if(o)o.borders=r;else return {type:"table",formatting:{borders:r},rows:n}}return {type:"table",formatting:o,rows:n}}function Xk(e){if(!(e.styleId||e.width||e.justification||e.floating||e.cellMargins))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;return {styleId:e.styleId||void 0,width:e.width?{value:e.width,type:e.widthType||"dxa"}:void 0,justification:e.justification||void 0,floating:e.floating||void 0,cellMargins:n}}function Jk(e){let t=e.attrs,n=[];return e.forEach(o=>{(o.type.name==="tableCell"||o.type.name==="tableHeader")&&n.push(e1(o));}),{type:"tableRow",formatting:Qk(t),cells:n}}function Qk(e){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 e1(e){let t=e.attrs,n=[];return e.forEach(o=>{o.type.name==="paragraph"?n.push(Gd(o)):o.type.name==="table"&&n.push(Eg(o));}),{type:"tableCell",formatting:t1(t),content:n}}function t1(e){if(!(e.colspan>1||e.rowspan>1||e.width||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?{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 n1(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(Gd(a));});let o={type:"shape",shapeType:"rect",id:t.textBoxId||void 0,size:{width:t.width?Math.round(t.width*(914400/96)):0,height:t.height?Math.round(t.height*(914400/96)):0},textBody:{content:n.length>0?n:[{type:"paragraph",content:[]}],margins:{top:t.marginTop!=null?Math.round(t.marginTop*(914400/96)):void 0,bottom:t.marginBottom!=null?Math.round(t.marginBottom*(914400/96)):void 0,left:t.marginLeft!=null?Math.round(t.marginLeft*(914400/96)):void 0,right:t.marginRight!=null?Math.round(t.marginRight*(914400/96)):void 0}}};if(t.fillColor&&(o.fill={type:"solid",color:{rgb:t.fillColor.replace("#","")}}),t.outlineWidth&&t.outlineWidth>0){let a={solid:"solid",dotted:"dot",dashed:"dash"};o.outline={width:Math.round(t.outlineWidth*(914400/96)),color:t.outlineColor?{rgb:t.outlineColor.replace("#","")}:void 0,style:t.outlineStyle&&a[t.outlineStyle]||"solid"};}return {type:"paragraph",content:[{type:"run",content:[{type:"shape",shape:o}]}]}}function Wi(e){return kg(e)}function Jr(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,h,x)=>{h<=o&&(s=x),h<=r&&(l=x);});let d={},c=a.parent,u=c.type.name==="paragraph"&&c.textContent.length===0,p=c.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();u&&f.length===0&&p&&(d={...p});for(let g of f)switch(g.type.name){case "bold":d.bold=true;break;case "italic":d.italic=true;break;case "underline":d.underline={style:g.attrs.style||"single",color:g.attrs.color};break;case "strike":g.attrs.double?d.doubleStrike=true:d.strike=true;break;case "textColor":d.color={rgb:g.attrs.rgb,themeColor:g.attrs.themeColor};break;case "highlight":d.highlight=g.attrs.color;break;case "fontSize":d.fontSize=g.attrs.size;break;case "fontFamily":d.fontFamily={ascii:g.attrs.ascii,hAnsi:g.attrs.hAnsi};break;case "superscript":d.vertAlign="superscript";break;case "subscript":d.vertAlign="subscript";break}let m={},b=null;return c.type.name==="paragraph"&&(c.attrs.alignment&&(m.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(m.lineSpacing=c.attrs.lineSpacing,m.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.numPr&&(m.numPr=c.attrs.numPr),c.attrs.indentLeft&&(m.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(m.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(m.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(m.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(m.tabs=c.attrs.tabs),c.attrs.styleId&&(b=c.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:d,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var Wt=xr.getCommands(),os=Wt.toggleBold(),rs=Wt.toggleItalic(),is=Wt.toggleUnderline(),as=Wt.toggleStrike(),ss=Wt.toggleSuperscript(),ls=Wt.toggleSubscript();function cs(e){return Wt.setTextColor(e)}Wt.clearTextColor();function ds(e){return Wt.setHighlight(e)}Wt.clearHighlight();function us(e){return Wt.setFontSize(e)}Wt.clearFontSize();function ps(e){return Wt.setFontFamily(e)}Wt.clearFontFamily();function fs(e,t){return Wt.setHyperlink(e,t)}var ms=Wt.removeHyperlink();function Vi(e,t,n){return Wt.insertHyperlink(e,t,n)}var mt=xr.getCommands();function gs(e){return mt.setAlignment(e)}mt.alignLeft();mt.alignCenter();mt.alignRight();mt.alignJustify();function hs(e,t="auto"){return mt.setLineSpacing(e,t)}mt.singleSpacing();mt.oneAndHalfSpacing();mt.doubleSpacing();function bs(e=720){return mt.increaseIndent(e)}function xs(e=720){return mt.decreaseIndent(e)}function ys(e){return mt.setIndentLeft(e)}function vs(e){return mt.setIndentRight(e)}function Zi(e,t){return mt.setIndentFirstLine(e,t)}var Ss=mt.toggleBulletList(),Cs=mt.toggleNumberedList(),Ts=mt.increaseListLevel(),ws=mt.decreaseListLevel();mt.removeList();function Ui(e,t){return mt.applyStyle(e,t)}mt.clearStyle();mt.removeSectionBreak();function ks(e){return mt.removeTabStop(e)}var Ps=mt.generateTOC();var ot=xr.getCommands();function Rs(e,t){return ot.insertTable(e,t)}function Es(e,t){return ot.addRowAbove()(e,t)}function Is(e,t){return ot.addRowBelow()(e,t)}function Ms(e,t){return ot.deleteRow()(e,t)}function Ls(e,t){return ot.addColumnLeft()(e,t)}function Fs(e,t){return ot.addColumnRight()(e,t)}function Ds(e,t){return ot.deleteColumn()(e,t)}function qi(e,t){return ot.deleteTable()(e,t)}function As(e,t){return ot.selectTable()(e,t)}function Bs(e,t){return ot.selectRow()(e,t)}function Ns(e,t){return ot.selectColumn()(e,t)}function Hs(e,t){return ot.mergeCells()(e,t)}function Os(e,t){return ot.splitCell()(e,t)}function $o(e,t){return ot.setCellBorder(e,t)}function zs(e,t){return ot.removeTableBorders()(e,t)}function _s(e,t,n){return ot.setAllTableBorders(n)(e,t)}function $s(e,t,n){return ot.setOutsideTableBorders(n)(e,t)}function Ws(e,t,n){return ot.setInsideTableBorders(n)(e,t)}function Vs(e){return ot.setCellVerticalAlign(e)}function Zs(e){return ot.setCellMargins(e)}function Us(e){return ot.setCellTextDirection(e)}function qs(){return ot.toggleNoWrap()}function Ks(e,t){return ot.setRowHeight(e,t)}function Gs(){return ot.toggleHeaderRow()}function Ys(){return ot.distributeColumns()}function js(){return ot.autoFitContents()}function Ki(e){return ot.setTableProperties(e)}function Xs(e){return ot.applyTableStyle(e)}function Js(e){return ot.setCellFillColor(e)}function Qs(e){return ot.setTableBorderColor(e)}function el(e){return ot.setTableBorderWidth(e)}var tl=(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,d;if(i.parent.isTextblock)if(i.parentOffset>0&&i.parentOffset<i.parent.content.size){a.split(i.pos);let c=a.mapping.map(i.pos);a.insert(c,Fragment.from([s,r.create()])),d=c+l+1;}else if(i.parentOffset===i.parent.content.size){let c=i.after();a.insert(c,Fragment.from([s,r.create()])),d=c+l+1;}else {let c=i.before();a.insert(c,s),d=c+l+1;}else {let c=i.pos;a.insert(c,Fragment.from([s,r.create()])),d=c+l+1;}a.setSelection(TextSelection.create(a.doc,d)),t(a.scrollIntoView());}return true};var Kg={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},Gg={fontWeight:500,letterSpacing:.3},v1={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},S1={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"},nl={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},jg=forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:d},c){let u=useRef(null),p=useRef(null),[f,m]=useState(false),[b,g]=useState(false),h=useRef(null),[x,y]=useState(null);useLayoutEffect(()=>{let R=()=>{let S=i.getBoundingClientRect(),N=r.getBoundingClientRect();y({top:N.top-S.top+i.scrollTop,left:N.left-S.left+i.scrollLeft,width:N.width});};R();let E=i.closest('[style*="overflow"]')||i;return E.addEventListener("scroll",R),window.addEventListener("resize",R),()=>{E.removeEventListener("scroll",R),window.removeEventListener("resize",R);}},[r,i]),useEffect(()=>{if(!u.current||p.current)return;let R=Kd(t.content,{styles:o||void 0}),E=new zo(Xr());E.buildSchema(),E.initializeRuntime();let S=E.getPlugins(),N=EditorState.create({doc:R,schema:ve,plugins:S}),_=new EditorView(u.current,{state:N,dispatchTransaction(U){let Z=_.state.apply(U);if(_.updateState(Z),U.docChanged&&m(true),U.selectionSet||U.docChanged){let L=Jr(Z);l?.(L);}}});return p.current=_,requestAnimationFrame(()=>{_.focus();let U=Jr(_.state);l?.(U);}),()=>{_.destroy(),p.current=null;}},[x]);let k=useCallback(()=>{if(!p.current)return;let R=Wi(p.current.state.doc);a(R);},[a]),T=useCallback(()=>{f?k():s();},[f,k,s]);useEffect(()=>{function R(E){E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),T());}return document.addEventListener("keydown",R,true),()=>document.removeEventListener("keydown",R,true)},[T]),useEffect(()=>{if(!b)return;function R(E){h.current&&!h.current.contains(E.target)&&g(false);}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[b]),useImperativeHandle(c,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let R=p.current;return R?undo(R.state,R.dispatch):false},redo:()=>{let R=p.current;return R?redo(R.state,R.dispatch):false}}));let A=n==="header"?"Header":"Footer";if(!x)return null;let B={position:"absolute",top:x.top,left:x.left,width:x.width,zIndex:10};return jsxs("div",{className:"hf-inline-editor",style:B,onMouseDown:R=>{R.stopPropagation();},children:[n==="footer"&&jsxs("div",{className:"hf-separator-bar",style:Kg,children:[jsx("span",{style:Gg,children:A}),jsx(Yg,{label:A,showOptions:b,setShowOptions:g,optionsRef:h,onRemove:d,onClose:T,viewRef:p})]}),jsx("div",{ref:u,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxs("div",{className:"hf-separator-bar",style:Kg,children:[jsx("span",{style:Gg,children:A}),jsx(Yg,{label:A,showOptions:b,setShowOptions:g,optionsRef:h,onRemove:d,onClose:T,viewRef:p})]})]})});function Yg({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let s=l=>{let d=a.current;if(!d)return;let{$from:c,from:u}=d.state.selection,p=d.state.storedMarks||c.marks(),f=ve.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),m=d.state.tr.insert(u,f.mark(p));d.dispatch(m),d.focus();};return jsxs("div",{style:{position:"relative"},ref:o,children:[jsx("button",{type:"button",style:v1,onClick:l=>{l.stopPropagation(),n(d=>!d);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxs("div",{style:S1,children:[jsx("button",{type:"button",style:nl,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsx("button",{type:"button",style:nl,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxs("button",{type:"button",style:nl,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxs("button",{type:"button",style:nl,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var T1={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},w1={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",padding:24,minWidth:400,maxWidth:500},Xg={marginBottom:16,padding:12,border:"1px solid #e0e0e0",borderRadius:4},Vo={display:"block",fontSize:12,color:"#666",marginBottom:4},Qr={width:"100%",padding:"4px 8px",border:"1px solid #ccc",borderRadius:4,fontSize:13,marginBottom:8},Jg={width:60,padding:"4px 8px",border:"1px solid #ccc",borderRadius:4,fontSize:13,marginBottom:8},k1={display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},eh={padding:"6px 16px",border:"1px solid #ccc",borderRadius:4,cursor:"pointer",fontSize:13,backgroundColor:"white"},P1={...eh,backgroundColor:"#2563eb",color:"white",border:"1px solid #2563eb"},Qg=[{value:"decimal",label:"1, 2, 3, ..."},{value:"lowerRoman",label:"i, ii, iii, ..."},{value:"upperRoman",label:"I, II, III, ..."},{value:"lowerLetter",label:"a, b, c, ..."},{value:"upperLetter",label:"A, B, C, ..."},{value:"chicago",label:"*, \u2020, \u2021, ..."}];function th({isOpen:e,onClose:t,onApply:n,footnotePr:o,endnotePr:r}){let[i,a]=useState(o?.position??"pageBottom"),[s,l]=useState(o?.numFmt??"decimal"),[d,c]=useState(o?.numStart??1),[u,p]=useState(o?.numRestart??"continuous"),[f,m]=useState(r?.position??"docEnd"),[b,g]=useState(r?.numFmt??"lowerRoman"),[h,x]=useState(r?.numStart??1),[y,k]=useState(r?.numRestart??"continuous"),T=useCallback(()=>{n({position:i,numFmt:s,numStart:d,numRestart:u},{position:f,numFmt:b,numStart:h,numRestart:y}),t();},[i,s,d,u,f,b,h,y,n,t]);return e?jsx("div",{style:T1,onClick:t,children:jsxs("div",{style:w1,onClick:A=>A.stopPropagation(),children:[jsx("h3",{style:{margin:"0 0 16px",fontSize:16},children:"Footnote & Endnote Properties"}),jsxs("div",{style:Xg,children:[jsx("h4",{style:{margin:"0 0 8px",fontSize:14},children:"Footnotes"}),jsx("label",{style:Vo,children:"Position"}),jsxs("select",{style:Qr,value:i,onChange:A=>a(A.target.value),children:[jsx("option",{value:"pageBottom",children:"Bottom of page"}),jsx("option",{value:"beneathText",children:"Below text"})]}),jsx("label",{style:Vo,children:"Number format"}),jsx("select",{style:Qr,value:s,onChange:A=>l(A.target.value),children:Qg.map(A=>jsx("option",{value:A.value,children:A.label},A.value))}),jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[jsxs("div",{children:[jsx("label",{style:Vo,children:"Start at"}),jsx("input",{type:"number",min:1,style:Jg,value:d,onChange:A=>c(parseInt(A.target.value,10)||1)})]}),jsxs("div",{style:{flex:1},children:[jsx("label",{style:Vo,children:"Numbering"}),jsxs("select",{style:Qr,value:u,onChange:A=>p(A.target.value),children:[jsx("option",{value:"continuous",children:"Continuous"}),jsx("option",{value:"eachSect",children:"Restart each section"}),jsx("option",{value:"eachPage",children:"Restart each page"})]})]})]})]}),jsxs("div",{style:Xg,children:[jsx("h4",{style:{margin:"0 0 8px",fontSize:14},children:"Endnotes"}),jsx("label",{style:Vo,children:"Position"}),jsxs("select",{style:Qr,value:f,onChange:A=>m(A.target.value),children:[jsx("option",{value:"docEnd",children:"End of document"}),jsx("option",{value:"sectEnd",children:"End of section"})]}),jsx("label",{style:Vo,children:"Number format"}),jsx("select",{style:Qr,value:b,onChange:A=>g(A.target.value),children:Qg.map(A=>jsx("option",{value:A.value,children:A.label},A.value))}),jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[jsxs("div",{children:[jsx("label",{style:Vo,children:"Start at"}),jsx("input",{type:"number",min:1,style:Jg,value:h,onChange:A=>x(parseInt(A.target.value,10)||1)})]}),jsxs("div",{style:{flex:1},children:[jsx("label",{style:Vo,children:"Numbering"}),jsxs("select",{style:Qr,value:y,onChange:A=>k(A.target.value),children:[jsx("option",{value:"continuous",children:"Continuous"}),jsx("option",{value:"eachSect",children:"Restart each section"})]})]})]})]}),jsxs("div",{style:k1,children:[jsx("button",{style:eh,onClick:t,children:"Cancel"}),jsx("button",{style:P1,onClick:T,children:"Apply"})]})]})}):null}var Se=e=>({style:"single",size:4,color:{rgb:e}}),R1=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:Se("000000"),bottom:Se("000000"),left:Se("000000"),right:Se("000000"),insideH:Se("000000"),insideV:Se("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:Se("BFBFBF"),bottom:Se("BFBFBF"),left:Se("BFBFBF"),right:Se("BFBFBF"),insideH:Se("BFBFBF"),insideV:Se("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Se("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:Se("BFBFBF"),bottom:Se("BFBFBF"),insideH:Se("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:Se("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:Se("B4C6E7"),bottom:Se("B4C6E7"),left:Se("B4C6E7"),right:Se("B4C6E7"),insideH:Se("B4C6E7"),insideV:Se("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Se("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:Se("4472C4"),bottom:Se("4472C4"),left:Se("4472C4"),right:Se("4472C4"),insideH:Se("4472C4"),insideV:Se("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:Se("FFFFFF"),bottom:Se("FFFFFF"),left:Se("FFFFFF"),right:Se("FFFFFF"),insideH:Se("FFFFFF"),insideV:Se("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:Se("ED7D31"),bottom:Se("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:Se("A5A5A5"),bottom:Se("A5A5A5"),insideH:Se("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:Se("5B9BD5"),bottom:Se("5B9BD5"),left:Se("5B9BD5"),right:Se("5B9BD5"),insideH:Se("5B9BD5"),insideV:Se("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:Se("70AD47"),bottom:Se("70AD47"),left:Se("70AD47"),right:Se("70AD47"),insideH:Se("70AD47"),insideV:Se("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function nh(e){return R1.find(t=>t.id===e)}function oh(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsx("div",{style:{width:"36px",height:"36px",border:"3px solid var(--doc-border)",borderTopColor:"var(--doc-primary)",borderRadius:"50%",animation:"docx-spin 0.8s linear infinite"}}),jsx("style",{children:`
|
|
18
|
-
@keyframes docx-spin {
|
|
19
|
-
to { transform: rotate(360deg); }
|
|
20
|
-
}
|
|
21
|
-
`}),jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function rh(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsx("div",{style:{marginTop:"16px"},children:"No document loaded"})]})}function ih({message:e}){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:"Failed to Load Document"}),jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function eu(e){let t=new Set,n=/\{\{([^}]+)\}\}/g,o=i=>{for(let a of i.content||[])if(a.type==="run"){for(let s of a.content||[])if(s.type==="text"){let l;for(;(l=n.exec(s.text))!==null;)t.add(l[1].trim());}}},r=e.package.document;for(let i of r.content||[])i.type==="paragraph"&&o(i);return Array.from(t)}function ah(e){let t={},n=eu(e);for(let o of n)t[o]="";return t}var fo=16;function I1(){return jsx(se,{name:"table_rows",size:fo,style:{transform:"scaleY(-1)"}})}function M1(){return jsx(se,{name:"table_rows",size:fo})}function L1(){return jsx(se,{name:"view_column",size:fo,style:{transform:"scaleX(-1)"}})}function F1(){return jsx(se,{name:"view_column",size:fo})}function D1(){return jsx(se,{name:"delete_sweep",size:fo})}function A1(){return jsx(se,{name:"delete_sweep",size:fo,style:{transform:"rotate(90deg)"}})}function B1(){return jsx(se,{name:"call_merge",size:fo})}function N1(){return jsx(se,{name:"call_split",size:fo})}function H1(){return jsx(se,{name:"delete",size:fo,className:"text-red-600"})}var Bn={container:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"var(--doc-bg-subtle)",borderRadius:"4px",border:"1px solid var(--doc-border)",fontSize:"12px"},containerCompact:{padding:"2px 4px",gap:"2px"},containerFloating:{position:"absolute",zIndex:1e3,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"},group:{display:"flex",alignItems:"center",gap:"2px"},separator:{width:"1px",height:"20px",backgroundColor:"var(--doc-border-dark)",margin:"0 4px"},button:{display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"4px 8px",border:"none",borderRadius:"3px",backgroundColor:"transparent",color:"var(--doc-text)",cursor:"pointer",fontSize:"12px",lineHeight:"1",transition:"background-color 0.15s, color 0.15s"},buttonCompact:{padding:"3px 5px"},buttonHover:{backgroundColor:"var(--doc-border)"},buttonDisabled:{color:"var(--doc-text-subtle)",cursor:"not-allowed"},buttonDelete:{color:"var(--doc-error)"},label:{fontSize:"11px",fontWeight:500,color:"var(--doc-text-muted)",marginRight:"8px",whiteSpace:"nowrap"}};function po({action:e,label:t,icon:n,disabled:o=false,onClick:r,showLabel:i=false,compact:a=false,shortcut:s}){let[l,d]=cn__default.useState(false),c=typeof e=="string"&&e.startsWith("delete"),u={...Bn.button,...a?Bn.buttonCompact:{},...l&&!o?Bn.buttonHover:{},...o?Bn.buttonDisabled:{},...c&&!o?Bn.buttonDelete:{}},p=s?`${t} (${s})`:t;return jsxs("button",{type:"button",className:`docx-table-toolbar-button docx-table-toolbar-${typeof e=="string"?e:e.type}`,style:u,disabled:o,onClick:r,onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),title:p,"aria-label":t,children:[n,i&&jsx("span",{children:t})]})}function tu({children:e,showSeparator:t=true}){return jsxs(Fragment$1,{children:[jsx("div",{style:Bn.group,children:e}),t&&jsx("div",{style:Bn.separator})]})}function O1({context:e,onAction:t,disabled:n=false,className:o,style:r,showLabels:i=false,compact:a=false,position:s="top",children:l}){if(!e)return null;let d=g=>{!n&&t&&e&&t(g,e);},c=e.rowCount>1,u=e.columnCount>1,p=e.hasMultiCellSelection,f=e.canSplitCell,m={...Bn.container,...a?Bn.containerCompact:{},...s==="floating"?Bn.containerFloating:{},...r},b=["docx-table-toolbar"];return o&&b.push(o),a&&b.push("docx-table-toolbar-compact"),s==="floating"&&b.push("docx-table-toolbar-floating"),jsxs("div",{className:b.join(" "),style:m,role:"toolbar","aria-label":"Table editing tools",children:[jsx("span",{style:Bn.label,children:"Table:"}),jsxs(tu,{children:[jsx(po,{action:"addRowAbove",label:"Insert Row Above",icon:jsx(I1,{}),disabled:n,onClick:()=>d("addRowAbove"),showLabel:i,compact:a}),jsx(po,{action:"addRowBelow",label:"Insert Row Below",icon:jsx(M1,{}),disabled:n,onClick:()=>d("addRowBelow"),showLabel:i,compact:a}),jsx(po,{action:"deleteRow",label:"Delete Row",icon:jsx(D1,{}),disabled:n||!c,onClick:()=>d("deleteRow"),showLabel:i,compact:a})]}),jsxs(tu,{children:[jsx(po,{action:"addColumnLeft",label:"Insert Column Left",icon:jsx(L1,{}),disabled:n,onClick:()=>d("addColumnLeft"),showLabel:i,compact:a}),jsx(po,{action:"addColumnRight",label:"Insert Column Right",icon:jsx(F1,{}),disabled:n,onClick:()=>d("addColumnRight"),showLabel:i,compact:a}),jsx(po,{action:"deleteColumn",label:"Delete Column",icon:jsx(A1,{}),disabled:n||!u,onClick:()=>d("deleteColumn"),showLabel:i,compact:a})]}),jsxs(tu,{showSeparator:false,children:[jsx(po,{action:"mergeCells",label:"Merge Cells",icon:jsx(B1,{}),disabled:n||!p,onClick:()=>d("mergeCells"),showLabel:i,compact:a}),jsx(po,{action:"splitCell",label:"Split Cell",icon:jsx(N1,{}),disabled:n||!f,onClick:()=>d("splitCell"),showLabel:i,compact:a}),jsx(po,{action:"deleteTable",label:"Delete Table",icon:jsx(H1,{}),disabled:n,onClick:()=>d("deleteTable"),showLabel:i,compact:a})]}),l]})}function nu(e,t){let n=e.rows.length,o=vr(e),r=!!(t.selectedCells&&(t.selectedCells.startRow!==t.selectedCells.endRow||t.selectedCells.startCol!==t.selectedCells.endCol)),i=ou(e,t.rowIndex,t.columnIndex),a=!!(i&&((i.formatting?.gridSpan??1)>1||i.formatting?.vMerge==="restart"));return {table:e,selection:t,hasMultiCellSelection:r,canSplitCell:a,rowCount:n,columnCount:o}}function vr(e){if(!e.rows.length)return 0;let t=0;for(let n of e.rows){let o=0;for(let r of n.cells)o+=r.formatting?.gridSpan??1;t=Math.max(t,o);}return t}function ou(e,t,n){let o=e.rows[t];if(!o)return null;let r=0;for(let i of o.cells){let a=i.formatting?.gridSpan??1;if(n>=r&&n<r+a)return i;r+=a;}return null}function z1(e,t){let n=[],o=0;for(let r of e.cells){let i=r.formatting?.gridSpan??1;n.push({type:"tableCell",content:[{type:"paragraph",content:[],formatting:{}}],formatting:{...r.formatting,vMerge:void 0}}),o+=i;}for(;o<t;)n.push({type:"tableCell",content:[{type:"paragraph",content:[],formatting:{}}],formatting:{}}),o++;return {type:"tableRow",cells:n,formatting:{...e.formatting,header:false}}}function _1(){return {type:"tableCell",content:[{type:"paragraph",content:[],formatting:{}}],formatting:{}}}function ol(e,t,n="after"){let o=[...e.rows],r=n==="before"?t:t+1,i=e.rows[t]||e.rows[0],a=vr(e),s=z1(i,a);return o.splice(r,0,s),{...e,rows:o}}function ru(e,t){if(e.rows.length<=1)return e;let n=e.rows.filter((o,r)=>r!==t);return {...e,rows:n}}function rl(e,t,n="after"){let o=n==="before"?t:t+1,r=e.rows.map(a=>{let s=[...a.cells],l=0,d=0;for(let c=0;c<a.cells.length;c++){let p=a.cells[c].formatting?.gridSpan??1;if(o<=l+p){d=n==="before"?c:c+1;break}l+=p,d=c+1;}return s.splice(d,0,_1()),{...a,cells:s}}),i=e.columnWidths;if(e.columnWidths&&e.columnWidths.length>0){i=[...e.columnWidths];let a=e.columnWidths[t]||e.columnWidths[0]||1440;i.splice(o,0,a);}return {...e,rows:r,columnWidths:i}}function iu(e,t){if(vr(e)<=1)return e;let o=e.rows.map(i=>{let a=0,s=[];for(let l of i.cells){let d=l.formatting?.gridSpan??1;t>=a&&t<a+d?d>1&&s.push({...l,formatting:{...l.formatting,gridSpan:d-1}}):s.push(l),a+=d;}return {...i,cells:s}}),r=e.columnWidths;return e.columnWidths&&e.columnWidths.length>t&&(r=e.columnWidths.filter((i,a)=>a!==t)),{...e,rows:o,columnWidths:r}}function au(e,t){if(!t.selectedCells)return e;let{startRow:n,startCol:o,endRow:r,endCol:i}=t.selectedCells,a=r-n+1,s=i-o+1,l=e.rows.map((d,c)=>{if(c<n||c>r)return d;let u=[],p=0;for(let f of d.cells){let m=f.formatting?.gridSpan??1,b=p+m-1;p<=i&&b>=o?c===n&&p===o?u.push({...f,formatting:{...f.formatting,gridSpan:s,vMerge:a>1?"restart":void 0}}):c>n&&p===o&&u.push({...f,formatting:{...f.formatting,gridSpan:s,vMerge:"continue"}}):u.push(f),p+=m;}return {...d,cells:u}});return {...e,rows:l}}function su(e,t,n){let o=ou(e,t,n);if(!o)return e;let r=o.formatting?.gridSpan??1,i=o.formatting?.vMerge==="restart";if(r<=1&&!i)return e;let a=e.rows.map((s,l)=>{if(l!==t&&!i)return s;let d=[],c=0;for(let u of s.cells){let p=u.formatting?.gridSpan??1;if(c===n||c<=n&&n<c+p)if(r>1)for(let f=0;f<r;f++)d.push({type:"tableCell",content:f===0?u.content:[{type:"paragraph",content:[],formatting:{}}],formatting:{...u.formatting,gridSpan:void 0,vMerge:void 0}});else i&&l===t?d.push({...u,formatting:{...u.formatting,vMerge:void 0}}):u.formatting?.vMerge==="continue"?d.push({type:"tableCell",content:[{type:"paragraph",content:[],formatting:{}}],formatting:{...u.formatting,vMerge:void 0}}):d.push(u);else d.push(u);c+=p;}return {...s,cells:d}});return {...e,rows:a}}var V1={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function Z1(e,t){if(!e.package?.document?.content)return null;let n=0;for(let o of e.package.document.content)if(o.type==="table"){if(n===t)return o;n++;}return null}function U1(e,t,n){if(!e.package?.document?.content)return e;let o=0,r=e.package.document.content.map(i=>{if(i.type==="table"){if(o===t)return o++,n;o++;}return i});return {...e,package:{...e.package,document:{...e.package.document,content:r}}}}function q1(e,t){if(!e.package?.document?.content)return e;let n=0,o=e.package.document.content.filter(r=>{if(r.type==="table"){let i=n===t;return n++,!i}return true});return {...e,package:{...e.package,document:{...e.package.document,content:o}}}}function lu({document:e,onChange:t,onSelectionChange:n}){let[o,r]=useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),i=useCallback((d,c,u)=>{if(!e)return;let p=Z1(e,d);if(!p){r({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}let m=nu(p,{tableIndex:d,rowIndex:c,columnIndex:u});r({context:m,table:p,tableIndex:d,rowIndex:c,columnIndex:u}),n?.(m);},[e,n]),a=useCallback(()=>{r({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[n]),s=useCallback(d=>{if(!e||!o.context||o.tableIndex===null||o.rowIndex===null||o.columnIndex===null)return;let c=o.table;if(!c)return;let u=null,p=null,f=o.rowIndex,m=o.columnIndex;switch(d){case "addRowAbove":u=ol(c,o.rowIndex,"before"),f=o.rowIndex+1;break;case "addRowBelow":u=ol(c,o.rowIndex,"after");break;case "addColumnLeft":u=rl(c,o.columnIndex,"before"),m=o.columnIndex+1;break;case "addColumnRight":u=rl(c,o.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(u=ru(c,o.rowIndex),f>=u.rows.length&&(f=u.rows.length-1));break;case "deleteColumn":{if(vr(c)>1){u=iu(c,o.columnIndex);let g=vr(u);m>=g&&(m=g-1);}break}case "mergeCells":o.context.selection.selectedCells&&(u=au(c,o.context.selection));break;case "splitCell":o.context.canSplitCell&&(u=su(c,o.rowIndex,o.columnIndex));break;case "deleteTable":p=q1(e,o.tableIndex),a(),t?.(p);return}u&&(p=U1(e,o.tableIndex,u),t?.(p),p&&i(o.tableIndex,f,m));},[e,o,t,a,i]),l=useCallback((d,c,u)=>o.tableIndex===d&&o.rowIndex===c&&o.columnIndex===u,[o]);return {state:o,handleCellClick:i,handleAction:s,clearSelection:a,isCellSelected:l,tableContext:o.context}}function G1(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Y1(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=G1,onUndo:a,onRedo:s,containerRef:l}=t,[d,c]=useState(e),[u,p]=useState([]),[f,m]=useState([]),b=useRef(0),g=useRef(false),h=useCallback((R,E)=>{if(i(d,R))return;if(g.current){c(R);return}let S=Date.now();S-b.current<o&&u.length>0?p(_=>{let U=[..._];return U[U.length-1]={state:d,timestamp:S,description:E||U[U.length-1].description},U}):p(_=>{let U={state:d,timestamp:S,description:E},Z=[..._,U];return Z.length>n?Z.slice(Z.length-n):Z}),m([]),c(R),b.current=S;},[d,i,o,n,u.length]),x=useCallback(()=>{if(u.length===0)return;g.current=true;let R=u[u.length-1];return p(E=>E.slice(0,-1)),m(E=>[...E,{state:d,timestamp:Date.now()}]),c(R.state),setTimeout(()=>{g.current=false;},0),a?.(R.state),R.state},[u,d,a]),y=useCallback(()=>{if(f.length===0)return;g.current=true;let R=f[f.length-1];return m(E=>E.slice(0,-1)),p(E=>[...E,{state:d,timestamp:Date.now()}]),c(R.state),setTimeout(()=>{g.current=false;},0),s?.(R.state),R.state},[f,d,s]),k=useCallback(()=>{p([]),m([]);},[]),T=useCallback(R=>{c(R??e),p([]),m([]),b.current=0;},[e]),A=useCallback(()=>[...u],[u]),B=useCallback(()=>[...f],[f]);return useEffect(()=>{if(!r)return;let R=S=>{if((S.ctrlKey||S.metaKey)&&S.key==="z"&&!S.shiftKey){S.preventDefault(),x();return}if((S.ctrlKey||S.metaKey)&&S.key==="y"||(S.ctrlKey||S.metaKey)&&S.key==="z"&&S.shiftKey){S.preventDefault(),y();return}},E=l?.current||document;return E.addEventListener("keydown",R),()=>{E.removeEventListener("keydown",R);}},[r,x,y,l]),{state:d,canUndo:u.length>0,canRedo:f.length>0,undoCount:u.length,redoCount:f.length,push:h,undo:x,redo:y,clear:k,reset:T,getUndoStack:A,getRedoStack:B}}function lh(e,t={}){let n=useCallback((o,r)=>!(o?.package?.document!==r?.package?.document&&JSON.stringify(o?.package?.document)!==JSON.stringify(r?.package?.document)||o?.package?.headers!==r?.package?.headers||o?.package?.footers!==r?.package?.footers),[]);return Y1(e,{...t,isEqual:n})}var rP={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function ph(e,t,n,o=[]){let r=n?.getSchema()??ve,i=e?Qa(e,{styles:t??void 0}):ts(),a=[...n?.getPlugins()??[],...o];return EditorState.create({doc:i,schema:r,plugins:a})}function iP(e,t){return t?ns(e.doc,t):null}var aP=forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:d,externalPlugins:c=[],extensionManager:u,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=useRef(null),g=useRef(null),h=useRef(o),x=useRef(false),y=useRef(null),k=useRef(false),T=useRef(l),A=useRef(d),B=useRef(p),R=useRef(f),E=useRef(m);T.current=l,A.current=d,B.current=p,R.current=f,E.current=m,h.current=o;let S=useCallback(()=>{if(!b.current||x.current)return;let U={state:ph(o,r,u,c),editable:()=>!s,dispatchTransaction:Z=>{if(!g.current||x.current)return;let L=g.current.state.apply(Z);g.current.updateState(L),T.current?.(Z,L),(Z.selectionSet||Z.docChanged)&&A.current?.(L);},handleKeyDown:(Z,L)=>E.current?.(Z,L)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new EditorView(b.current,U),B.current?.(g.current);},[o,r,c,u,s]),N=useCallback(()=>{g.current&&!x.current&&(x.current=true,R.current?.(),g.current.destroy(),g.current=null,x.current=false);},[]);return useEffect(()=>(S(),()=>N()),[]),useEffect(()=>{if(!g.current||x.current)return;let U=(L=>{if(!L)return "empty";let H=L.package?.properties;return `${H?.created||""}-${H?.modified||""}-${H?.title||""}`})(o);if(k.current&&U===y.current)return;k.current=true,y.current=U;let Z=ph(o,r,u,c);g.current.updateState(Z),A.current?.(Z);},[o,r,u,c]),useEffect(()=>{g.current;},[s]),useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?iP(g.current.state,h.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(_){g.current&&!x.current&&g.current.dispatch(_);},executeCommand(_){return g.current?_(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?undo(g.current.state,g.current.dispatch):false},redo(){return g.current?redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?undo(g.current.state):false},canRedo(){return g.current?redo(g.current.state):false},setSelection(_,U){if(!g.current)return;let{state:Z,dispatch:L}=g.current,H=Z.doc.resolve(_),q=U!==void 0?Z.doc.resolve(U):H,xe=TextSelection.between(H,q);L(Z.tr.setSelection(xe));},setNodeSelection(_){if(!g.current)return;let{state:U,dispatch:Z}=g.current;try{let L=NodeSelection.create(U.doc,_);Z(U.tr.setSelection(L));}catch{this.setSelection(_);}},setCellSelection(_,U){if(!g.current)return;let{state:Z,dispatch:L}=g.current;try{let H=CellSelection.create(Z.doc,_,U);L(Z.tr.setSelection(H));}catch{this.setSelection(_,U);}},scrollToSelection(){}}),[]),jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...rP,width:a>0?`${a}px`:void 0}})}),fh=memo(aP);var dP="#000",uP="rgba(66, 133, 244, 0.3)",pP=2,fP=530,mP={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},gP=(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"}),hP=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),bP=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=useState(r),s=useRef(null);return useEffect(()=>(s.current&&(window.clearInterval(s.current),s.current=null),r&&o>0?(a(true),s.current=window.setInterval(()=>{a(l=>!l);},o)):a(false),()=>{s.current&&window.clearInterval(s.current);}),[r,o]),useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsx("div",{style:gP(e,t,n,i),"data-testid":"caret"})},xP=({rect:e,color:t,index:n})=>jsx("div",{style:hP(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),gh=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=dP,selectionColor:i=uP,caretWidth:a=pP,blinkInterval:s=fP})=>{if(o)return null;let l=e.length>0,d=t!==null&&!l;return jsxs("div",{style:mP,"data-testid":"selection-overlay",children:[l&&e.map((c,u)=>jsx(xP,{rect:c,color:i,index:u},`sel-${c.pageIndex}-${c.x}-${c.y}-${u}`)),d&&t&&jsx(bP,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var pu=10,Uo=pu/2,ji=2,yh="#2563eb",bh={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},vP={position:"absolute",border:`${ji}px solid ${yh}`,pointerEvents:"none",boxSizing:"border-box"},SP={position:"absolute",width:`${pu}px`,height:`${pu}px`,backgroundColor:yh,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},CP={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%)"},TP={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function wP(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,d=r+n*s;if(i){let c=Math.max(l/o,d/r);l=o*c,d=r*c;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,d))}}function vh({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[d,c]=useState(false),[u,p]=useState(false),[f,m]=useState(0),[b,g]=useState(0),[h,x]=useState(null),y=useRef(null),k=useRef(null),T=useRef(o),A=useRef(r),B=useRef(i),R=useRef(a),E=useRef(s),S=useRef(l);T.current=o,A.current=r,B.current=i,R.current=a,E.current=s,S.current=l;let N=useRef(e),_=useRef(t);N.current=e,_.current=t;let U=useCallback(()=>{if(!e||!k.current){x(null);return}let M=k.current.offsetParent;if(!M){x(null);return}let O=M.getBoundingClientRect(),C=e.element.getBoundingClientRect();x({left:(C.left-O.left)/t,top:(C.top-O.top)/t,width:C.width/t,height:C.height/t});},[e,t]);useEffect(()=>{U();},[U]),useEffect(()=>{if(!e)return;let M=k.current?.closest('[style*="overflow"]')??k.current?.closest(".paged-editor__container");if(!M)return;let O=()=>{y.current&&cancelAnimationFrame(y.current),y.current=requestAnimationFrame(U);};return M.addEventListener("scroll",O,{passive:true}),window.addEventListener("resize",O,{passive:true}),()=>{M.removeEventListener("scroll",O),window.removeEventListener("resize",O),y.current&&cancelAnimationFrame(y.current);}},[e,U]);let Z=useCallback((M,O)=>{if(!e||!h)return;O.preventDefault(),O.stopPropagation();let C=h.width,P=h.height,I=O.clientX,z=O.clientY,Y=Math.round(C),j=Math.round(P);c(true),m(Y),g(j),A.current?.();let F=G=>{let be=_.current,me=(G.clientX-I)/be,oe=(G.clientY-z)/be,K=!G.shiftKey,de=wP(M,me,oe,C,P,K);Y=Math.round(de.width),j=Math.round(de.height),m(Y),g(j),x(Fe=>{if(!Fe)return Fe;let Ke={...Fe};return M.includes("w")&&(Ke.left=Fe.left+(Fe.width-de.width)),M.includes("n")&&(Ke.top=Fe.top+(Fe.height-de.height)),Ke.width=de.width,Ke.height=de.height,Ke});},V=()=>{window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",V),c(false);let G=N.current;G&&T.current?.(G.pmPos,Y,j),B.current?.();};window.addEventListener("mousemove",F),window.addEventListener("mouseup",V);},[e,h]),L=useCallback(M=>{if(!e||!h)return;M.preventDefault(),M.stopPropagation();let O=4,C=M.clientX,P=M.clientY,I=false,z=null,Y=F=>{let V=F.clientX-C,G=F.clientY-P;!I&&Math.sqrt(V*V+G*G)<O||(I||(I=true,p(true),E.current?.(),z=document.createElement("div"),z.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);",z.style.width=`${h.width}px`,z.style.height=`${h.height}px`,document.body.appendChild(z)),z&&(z.style.left=`${F.clientX-h.width/2}px`,z.style.top=`${F.clientY-h.height/2}px`));},j=F=>{if(window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",j),z&&(z.remove(),z=null),p(false),I){let V=N.current;V&&R.current?.(V.pmPos,F.clientX,F.clientY),S.current?.();}};window.addEventListener("mousemove",Y),window.addEventListener("mouseup",j);},[e,h]);if(!!!(e&&h&&n))return jsx("div",{ref:k,style:{...bh,visibility:"hidden"},className:"image-selection-overlay"});let{left:q,top:xe,width:ie,height:we}=h;return jsxs("div",{ref:k,style:bh,className:"image-selection-overlay",children:[jsx("div",{style:{...vP,left:q-ji,top:xe-ji,width:ie+ji*2,height:we+ji*2}}),jsx("div",{style:{position:"absolute",left:q,top:xe,width:ie,height:we,cursor:u?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:L}),jsx(sl,{handle:"nw",style:{left:q-Uo,top:xe-Uo},onMouseDown:Z}),jsx(sl,{handle:"ne",style:{left:q+ie-Uo,top:xe-Uo},onMouseDown:Z}),jsx(sl,{handle:"se",style:{left:q+ie-Uo,top:xe+we-Uo},onMouseDown:Z}),jsx(sl,{handle:"sw",style:{left:q-Uo,top:xe+we-Uo},onMouseDown:Z}),d&&jsxs("div",{style:{...CP,left:q+ie/2,top:xe+we+12},children:[f," \xD7 ",b]})]})}function sl({handle:e,style:t,onMouseDown:n}){return jsx("div",{style:{...SP,...t,cursor:TP[e]},onMouseDown:o=>n(e,o),"data-handle":e})}function kP(e,t,n,o){let r=e-t-n,i=(o.count-1)*o.gap;return (r-i)/o.count}function fu(e){let{pageSize:t,margins:n,columns:o={count:1,gap:0}}=e,r=[],i=[],a=n.top,s=t.h-n.bottom;if(s-a<=0)throw new Error("Paginator: page size and margins yield no content area");let d=kP(t.w,n.left,n.right,o);function c(k){return n.left+k*(d+o.gap)}function u(){let k=r.length+1,T=e.footnoteReservedHeights?.get(k)??0,A=s-T,B={number:k,fragments:[],margins:{...n},size:{...t},footnoteReservedHeight:T>0?T:void 0},R={page:B,cursorY:a,columnIndex:0,topMargin:a,contentBottom:A,trailingSpacing:0};return r.push(B),i.push(R),e.onNewPage&&e.onNewPage(R),R}function p(){return i.length===0?u():i[i.length-1]}function f(k){return k.contentBottom-k.cursorY}function m(k,T){let A=T||p();return f(A)>=k}function b(k){return k.columnIndex<o.count-1?(k.columnIndex+=1,k.cursorY=k.topMargin,k.trailingSpacing=0,k):u()}function g(k){let T=p();for(;!m(k,T);)T=b(T);return T}function h(k,T,A=0,B=0){let R=Math.max(A,p().trailingSpacing),E=R+T,S=g(E),_=S.cursorY===S.topMargin?0:R,U=c(S.columnIndex),Z=S.cursorY+_;return k.x=U,k.y=Z,S.page.fragments.push(k),S.cursorY=Z+T,S.trailingSpacing=B,{state:S,x:U,y:Z}}function x(){return u()}function y(){let k=p();return b(k)}return {pages:r,states:i,columnWidth:d,getCurrentState:p,getAvailableHeight:()=>f(p()),fits:k=>m(k),ensureFits:g,addFragment:h,forcePageBreak:x,forceColumnBreak:y,getColumnX:c}}function mu(e){let t=new Map,n=new Set;for(let o=0;o<e.length;o++){if(n.has(o))continue;let r=e[o];if(r.kind!=="paragraph"||!r.attrs?.keepNext)continue;let a=[o],s=o;for(let c=o+1;c<e.length;c++){let u=e[c];if(u.kind==="sectionBreak"||u.kind==="pageBreak"||u.kind==="columnBreak"||u.kind!=="paragraph")break;if(u.attrs?.keepNext)a.push(c),s=c,n.add(c);else break}let l=s+1,d=-1;if(l<e.length){let c=e[l];c.kind!=="sectionBreak"&&c.kind!=="pageBreak"&&c.kind!=="columnBreak"&&(d=l);}t.set(o,{startIndex:o,endIndex:s,memberIndices:a,anchorIndex:d});}return t}function gu(e,t,n){let o=0;for(let r of e.memberIndices){let i=t[r],a=n[r];if(i.kind!=="paragraph"||a.kind!=="paragraph")continue;let s=i,l=a,d=s.attrs?.spacing?.before??0;o+=d,o+=l.totalHeight;let c=s.attrs?.spacing?.after??0;o+=c;}if(e.anchorIndex!==-1){let r=n[e.anchorIndex];if(r?.kind==="paragraph"){let i=r;i.lines.length>0&&(o+=i.lines[0].lineHeight);}}return o}function hu(e){let t=new Set;for(let n of e.values())for(let o=1;o<n.memberIndices.length;o++)t.add(n.memberIndices[o]);return t}function bu(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var PP={w:816,h:1056},ti={top:96,right:96,bottom:96,left:96};function Sh(e){return e.attrs?.spacing?.before??0}function Ch(e){return e.attrs?.spacing?.after??0}function RP(e){for(let t=0;t<e.length-1;t++){let n=e[t],o=e[t+1];if(n.kind!=="paragraph"||o.kind!=="paragraph")continue;let r=n.attrs,i=o.attrs;r?.contextualSpacing&&i?.contextualSpacing&&r.styleId&&r.styleId===i.styleId&&(r.spacing&&(r.spacing={...r.spacing,after:0}),i.spacing&&(i.spacing={...i.spacing,before:0}));}}function ll(e,t,n={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let o=n.pageSize??PP,r={top:n.margins?.top??ti.top,right:n.margins?.right??ti.right,bottom:n.margins?.bottom??ti.bottom,left:n.margins?.left??ti.left,header:n.margins?.header??n.margins?.top??ti.top,footer:n.margins?.footer??n.margins?.bottom??ti.bottom};n.headerContentHeights,n.footerContentHeights,n.titlePage,n.evenAndOddHeaders;let i={...r},a=o.w-i.left-i.right;if(a<=0)throw new Error("layoutDocument: page size and margins yield no content area");let s=fu({pageSize:o,margins:i,columns:n.columns,footnoteReservedHeights:n.footnoteReservedHeights});RP(e);let l=mu(e),d=hu(l);for(let c=0;c<e.length;c++){let u=e[c],p=t[c];bu(u)&&s.forcePageBreak();let f=l.get(c);if(f&&!d.has(c)){let m=gu(f,e,t),b=s.getCurrentState(),g=s.getAvailableHeight(),h=b.contentBottom-b.topMargin;m<=h&&m>g&&b.page.fragments.length>0&&s.forcePageBreak();}switch(u.kind){case "paragraph":EP(u,p,s,a);break;case "table":u.floating?MP(u,p,s,a):IP(u,p,s);break;case "image":LP(u,p,s);break;case "pageBreak":s.forcePageBreak();break;case "columnBreak":s.forceColumnBreak();break;case "sectionBreak":DP(u,s);break}}return s.pages.length===0&&s.getCurrentState(),{pageSize:o,pages:s.pages,columns:n.columns,pageGap:n.pageGap}}function EP(e,t,n,o){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let r=t.lines;if(r.length===0){let l=Sh(e),d=Ch(e),c=n.getCurrentState(),u={kind:"paragraph",blockId:e.id,x:n.getColumnX(c.columnIndex),y:c.cursorY+l,width:o,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};n.addFragment(u,0,l,d);return}let i=Sh(e),a=Ch(e),s=0;for(;s<r.length;){let l=n.getCurrentState(),d=n.getAvailableHeight(),c=0,u=0;for(let x=s;x<r.length;x++){let y=r[x].lineHeight,k=c+y;if((s===0&&x===s?k+i:k)<=d||u===0)c=k,u++;else break}let p=s===0,f=s+u>=r.length,m=p?i:0,b=f?a:0,g={kind:"paragraph",blockId:e.id,x:n.getColumnX(l.columnIndex),y:0,width:o,height:c,fromLine:s,toLine:s+u,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!p,continuesOnNext:!f},h=n.addFragment(g,c,m,b);g.y=h.y,s+=u,s<r.length&&n.ensureFits(r[s].lineHeight);}}function IP(e,t,n){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let o=t.rows;if(o.length===0)return;let r=0;for(;r<o.length;){let i=n.getCurrentState(),a=n.getAvailableHeight(),s=0,l=0;for(let m=r;m<o.length;m++){let b=o[m].height,g=s+b;if(g<=a||l===0)s=g,l++;else break}let d=r===0,c=r+l>=o.length,u=n.getColumnX(i.columnIndex);e.justification==="center"?u=u+(n.columnWidth-t.totalWidth)/2:e.justification==="right"&&(u=u+n.columnWidth-t.totalWidth);let p={kind:"table",blockId:e.id,x:u,y:0,width:t.totalWidth,height:s,fromRow:r,toRow:r+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!d,continuesOnNext:!c},f=n.addFragment(p,s,0,0);p.y=f.y,p.x=u,r+=l,r<o.length&&n.ensureFits(o[r].height);}}function MP(e,t,n,o){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let r=n.getCurrentState(),i=e.floating,a=r.page,s=a.margins,l=t.totalWidth,d=t.totalHeight,c=a.size.h-s.top-s.bottom,u=s.left,p=s.top;i?.horzAnchor==="page"&&(u=0),i?.vertAnchor==="page"&&(p=0);let f=n.getColumnX(r.columnIndex);if(i?.tblpX!==void 0)f=u+i.tblpX;else if(i?.tblpXSpec){let y=i.tblpXSpec;y==="left"||y==="inside"?f=u:y==="right"||y==="outside"?f=u+o-l:y==="center"&&(f=u+(o-l)/2);}else e.justification==="center"?f=u+(o-l)/2:e.justification==="right"&&(f=u+o-l);let m=r.cursorY,b=false;if(i?.tblpY!==void 0)m=p+i.tblpY,b=true;else if(i?.tblpYSpec){b=true;let y=i.tblpYSpec;y==="top"?m=p:y==="bottom"?m=p+c-d:y==="center"&&(m=p+(c-d)/2);}b||(m=n.ensureFits(d).cursorY);let g=s.left,h=s.left+o-l;Number.isFinite(h)&&(f=Math.max(g,Math.min(f,h)));let x={kind:"table",blockId:e.id,x:f,y:m,width:l,height:d,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};r.page.fragments.push(x);}function LP(e,t,n){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){FP(e,t,n);return}let o=n.ensureFits(t.height),r={kind:"image",blockId:e.id,x:n.getColumnX(o.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},i=n.addFragment(r,t.height,0,0);r.y=i.y;}function FP(e,t,n){let o=n.getCurrentState(),r=e.anchor,i=r.offsetH??n.getColumnX(o.columnIndex),a=r.offsetV??o.cursorY,s={kind:"image",blockId:e.id,x:i,y:a,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:r.behindDoc?-1:1};o.page.fragments.push(s);}function DP(e,t){switch(e.type??"continuous"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}}var AP="Calibri";function xu(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 BP=11;function Et(e){return e/1440*96}var NP=0;function ni(){return `block-${++NP}`}function HP(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 cl(e,t){let n={};for(let o of e)switch(o.type.name){case "bold":n.bold=true;break;case "italic":n.italic=true;break;case "underline":{let r=o.attrs;if(r.style||r.color){let i=r.color?a$3(r.color,t):void 0;n.underline={style:r.style,color:i};}else n.underline=true;break}case "strike":n.strike=true;break;case "textColor":{let r=o.attrs;(r.themeColor||r.rgb)&&(n.color=a$3({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=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}}return n}function OP(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 d=cl(a.marks,i),c={kind:"text",text:a.text,...d,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="hardBreak"){let d={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="tab"){let c={kind:"tab",...cl(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="image"){let d=a.attrs,c=xu(d.width||100,d.height||100,n.pageContentHeight),u={kind:"image",src:d.src,width:c.width,height:c.height,alt:d.alt,transform:d.transform,wrapType:d.wrapType,displayMode:d.displayMode,cssFloat:d.cssFloat,distTop:d.distTop,distBottom:d.distBottom,distLeft:d.distLeft,distRight:d.distRight,position:d.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="field"){let d=a.attrs.fieldType,u={kind:"field",fieldType:d==="PAGE"?"PAGE":d==="NUMPAGES"?"NUMPAGES":d==="DATE"?"DATE":d==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="math"){let c={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="sdt"){let d=l+1;a.forEach((c,u)=>{let p=d+u;if(c.isText&&c.text){let f=cl(c.marks,i),m={kind:"text",text:c.text,...f,pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+c.nodeSize};o.push(f);}else if(c.type.name==="tab"){let m={kind:"tab",...cl(c.marks,i),pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="image"){let f=c.attrs,m=xu(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+c.nodeSize};o.push(b);}});}}),o}function zP(e){let t={};if(e.alignment){let a=e.alignment;a==="both"||a==="distribute"?t.alignment="justify":a==="left"?t.alignment="left":a==="center"?t.alignment="center":a==="right"&&(t.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(t.spacing={},e.spaceBefore!=null&&(t.spacing.before=Et(e.spaceBefore)),e.spaceAfter!=null&&(t.spacing.after=Et(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(t.spacing.line=Et(e.lineSpacing),t.spacing.lineUnit="px",t.spacing.lineRule=e.lineSpacingRule):(t.spacing.line=e.lineSpacing/240,t.spacing.lineUnit="multiplier",t.spacing.lineRule="auto")));let n=e.indentLeft,o=e.indentFirstLine,r=e.hangingIndent;if(e.numPr?.numId&&n==null&&(n=((e.numPr.ilvl??0)+1)*720,o==null&&(o=-360,r=true)),(n!=null||e.indentRight!=null||o!=null)&&(t.indent={},n!=null&&(t.indent.left=Et(n)),e.indentRight!=null&&(t.indent.right=Et(e.indentRight)),o!=null&&(r?t.indent.hanging=Math.abs(Et(o)):t.indent.firstLine=Et(o))),e.styleId&&(t.styleId=e.styleId),e.borders){let a=e.borders;t.borders={};let s=l=>{if(!l||l.style==="none"||l.style==="nil")return;let d=l.size?Math.max(1,Math.round(l.size/8*1.333)):1,c="#000000";return l.color?.rgb&&(c=`#${l.color.rgb}`),{style:l.style||"single",width:d,color:c}};a.top&&(t.borders.top=s(a.top)),a.bottom&&(t.borders.bottom=s(a.bottom)),a.left&&(t.borders.left=s(a.left)),a.right&&(t.borders.right=s(a.right)),!t.borders.top&&!t.borders.bottom&&!t.borders.left&&!t.borders.right&&delete t.borders;}e.shading?.fill?.rgb&&(t.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(t.tabs=e.tabs.map(a=>({val:_P(a.alignment),pos:a.position,leader:a.leader}))),e.pageBreakBefore&&(t.pageBreakBefore=true),e.keepNext&&(t.keepNext=true),e.keepLines&&(t.keepLines=true),e.contextualSpacing&&(t.contextualSpacing=true),e.styleId&&(t.styleId=e.styleId),e.numPr&&(t.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(t.listMarker=e.listMarker),e.listIsBullet!=null&&(t.listIsBullet=e.listIsBullet);let i=e.defaultTextFormatting;return i&&(i.fontSize!=null&&(t.defaultFontSize=i.fontSize/2),i.fontFamily&&(t.defaultFontFamily=i.fontFamily.ascii||i.fontFamily.hAnsi)),t}function _P(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 Th(e,t,n){let o=e.attrs,r=OP(e,t,n),i=zP(o);return {kind:"paragraph",id:ni(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function $P(e){return Math.max(1,Math.round(e/8*1.333))}var WP={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 VP(e){let t=e.borders;if(!t)return;let n={},o=["top","bottom","left","right"];for(let r of o){let i=t[r];if(!i||!i.style||i.style==="none"||i.style==="nil"){n[r]={width:0,style:"none"};continue}let a={style:WP[i.style]||"solid"};i.color?.rgb&&(a.color=`#${i.color.rgb}`),i.size&&(a.width=$P(i.size)),n[r]=a;}return Object.keys(n).length>0?n:void 0}function ZP(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Th(l,r,n)):l.type.name==="table"&&o.push(wh(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?Et(a.top):0,right:a?.right!=null?Et(a.right):7,bottom:a?.bottom!=null?Et(a.bottom):0,left:a?.left!=null?Et(a.left):7};return {id:ni(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?Et(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:VP(i),padding:s}}function UP(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(ZP(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:ni(),cells:o,height:i.height?Et(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function wh(e,t,n){let o=[],r=t+1;e.forEach(p=>{p.type.name==="tableRow"&&o.push(UP(p,r,n)),r+=p.nodeSize;});let a=e.attrs.columnWidths?.map(Et),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let f=o[0].cells.map(m=>m.width);f.every(m=>m!==void 0&&m>0)&&(a=f);}let d=e.attrs.justification,c=e.attrs.floating,u=c?{horzAnchor:c.horzAnchor,vertAnchor:c.vertAnchor,tblpX:c.tblpX!==void 0?Et(c.tblpX):void 0,tblpXSpec:c.tblpXSpec,tblpY:c.tblpY!==void 0?Et(c.tblpY):void 0,tblpYSpec:c.tblpYSpec,topFromText:c.topFromText!==void 0?Et(c.topFromText):void 0,bottomFromText:c.bottomFromText!==void 0?Et(c.bottomFromText):void 0,leftFromText:c.leftFromText!==void 0?Et(c.leftFromText):void 0,rightFromText:c.rightFromText!==void 0?Et(c.rightFromText):void 0}:void 0;return {kind:"table",id:ni(),rows:o,columnWidths:a,width:s,widthType:l,justification:d,floating:u,pmStart:t,pmEnd:t+e.nodeSize}}function qP(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=xu(o.width||100,o.height||100,n);return {kind:"image",id:ni(),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,pmStart:t,pmEnd:t+e.nodeSize}}function kh(e,t={}){let n={...t,defaultFont:t.defaultFont??AP,defaultSize:t.defaultSize??BP},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let d=Th(a,l,n),c=a.attrs;if(c.numPr&&!c.listMarker){let u=c.numPr.numId;if(u==null||u===0)break;let p=c.numPr.ilvl??0,f=i.get(u)??new Array(9).fill(0);f[p]=(f[p]??0)+1;for(let b=p+1;b<f.length;b+=1)f[b]=0;i.set(u,f);let m=c.listIsBullet?"\u2022":HP(f,p);d.attrs={...d.attrs,listMarker:m};}o.push(d);}break;case "table":o.push(wh(a,l,n));break;case "image":o.push(qP(a,l,n.pageContentHeight));break;case "horizontalRule":case "pageBreak":{let d={kind:"pageBreak",id:ni(),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);break}}}),o}var mo=11,Xi="Calibri",yu=1.15,oi=.5;function Ph(e){return {fontFamily:e.fontFamily??Xi,fontSize:e.fontSize??mo,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Mh(e,t,n){let o=f$1(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.lineHeight??o*yu,s;return t?.lineRule==="exact"&&t.line!==void 0?s=t.line:t?.lineRule==="atLeast"&&t.line!==void 0?s=Math.max(t.line,a):t?.line!==void 0&&t?.lineUnit==="multiplier"?s=a*t.line:t?.line!==void 0&&t?.lineUnit==="px"?s=t.line:s=a,{ascent:r,descent:i,lineHeight:s}}function Rh(e,t,n){let o=b$2({fontSize:e,fontFamily:n??Xi});return Mh(e,t,o)}function Eh(e){return e.kind==="text"}function KP(e){return e.kind==="tab"}function GP(e){return e.kind==="image"}function YP(e){return e.kind==="lineBreak"}function jP(e){return e.kind==="field"}function XP(e){return !e.text||e.text.length===0}function JP(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 QP=48;function Ih(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 Ji(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,d$1=l?.left??0,c=l?.right??0,u=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-d$1-c),f=Math.max(1,p-u),m=0,b=f$1(mo)*yu,g=Ih(0,b,a,s),h=Math.max(1,f-g.leftMargin-g.rightMargin),x=[];if(o.length===0){let E=r?.defaultFontSize??mo,S=r?.defaultFontFamily??Xi,N=Rh(E,i,S);return x.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...N}),{kind:"paragraph",lines:x,totalHeight:N.lineHeight}}if(o.length===1&&Eh(o[0])&&XP(o[0])){let E=o[0],S=E.fontSize??r?.defaultFontSize??mo,N=E.fontFamily??r?.defaultFontFamily??Xi,_=Rh(S,i,N);return x.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,..._}),{kind:"paragraph",lines:x,totalHeight:_.lineHeight}}let y={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:mo,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:h,leftOffset:g.leftMargin,rightOffset:g.rightMargin},k=()=>{let E=Mh(y.maxFontSize,i,y.maxFontMetrics),S={...E};y.maxImageHeightPx>S.lineHeight&&(S.lineHeight=y.maxImageHeightPx,S.ascent=y.maxImageHeightPx*.8,S.descent=y.maxImageHeightPx*.2);let N={fromRun:y.fromRun,fromChar:y.fromChar,toRun:y.toRun,toChar:y.toChar,width:y.width,...S};y.leftOffset>0&&(N.leftOffset=y.leftOffset),y.rightOffset>0&&(N.rightOffset=y.rightOffset),x.push(N),m+=E.lineHeight;},T=(E,S)=>{k();let N=f$1(mo)*yu,_=Ih(m,N,a,s),U=Math.max(1,p-_.leftMargin-_.rightMargin);y={fromRun:E,fromChar:S,toRun:E,toChar:S,width:0,maxFontSize:mo,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:U,leftOffset:_.leftMargin,rightOffset:_.rightMargin};},A=E=>{let S=E.fontSize??mo;S>y.maxFontSize&&(y.maxFontSize=S,y.maxFontMetrics=b$2(E));};for(let E=0;E<o.length;E++){let S=o[E];if(YP(S)){y.toRun=E,y.toChar=0,T(E+1,0);continue}if(KP(S)){let N=Ph(S);A(N);let _=S.width??QP;y.width+_>y.availableWidth+oi&&(T(E,0),A(N)),y.width+=_,y.toRun=E,y.toChar=1;continue}if(GP(S)){let N=S.wrapType,_=S.displayMode==="float"||N&&["square","tight","through"].includes(N);if(S.position&&_){y.toRun=E,y.toChar=1;continue}if(N==="topAndBottom"||S.displayMode==="block"){y.width>0&&T(E,0);let L=S.height,H=S.distTop??6,q=S.distBottom??6;y.toRun=E,y.toChar=1,y.maxImageHeightPx=L+H+q,T(E+1,0);continue}let U=S.width,Z=S.height;Z>y.maxImageHeightPx&&(y.maxImageHeightPx=Z),y.width+U>y.availableWidth+oi&&T(E,0),y.width+=U,y.toRun=E,y.toChar=1;continue}if(jP(S)){let N=S.fallback||"1",_={fontFamily:S.fontFamily??Xi,fontSize:S.fontSize??mo,bold:S.bold,italic:S.italic};A(_);let U=c$2(N,_);y.width>0&&y.width+U>y.availableWidth+oi&&(T(E,0),A(_)),y.width+=U,y.toRun=E,y.toChar=1;continue}if(Eh(S)){let N=S,_=N.text,U=Ph(N);if(A(U),!_||_.length===0){y.toRun=E,y.toChar=0;continue}let Z=JP(_),L=0;for(;L<_.length;){let H=_.length;for(let ie of Z)if(ie>L){H=ie;break}let q=_.slice(L,H),xe=c$2(q,U);if(xe>y.availableWidth+oi){y.width>0&&(T(E,L),A(U));let{charWidths:ie}=d(q,U),we=0;for(;we<q.length;){let M=0,O=we;for(;O<q.length;){let C=ie[O]??0;if(M+C>y.availableWidth+oi)break;M+=C,O+=1;}O===we&&(O=Math.min(q.length,we+1),M=ie[we]??0),y.width+=M,y.toRun=E,y.toChar=L+O,we=O,we<q.length&&(T(E,L+we),A(U));}L=H;continue}y.width>0&&y.width+xe>y.availableWidth+oi&&(T(E,L),A(U)),y.width+=xe,y.toRun=E,y.toChar=H,L=H;}}}k();let R=x.reduce((E,S)=>E+S.lineHeight,0);return i?.before&&(R+=i.before),i?.after&&(R+=i.after),{kind:"paragraph",lines:x,totalHeight:R}}var eR=new Map;function Lh(){eR.clear();}var tR=new Map;function Fh(){tR.clear();}var nR=new Map;function Dh(){nR.clear();}function vu(){Lh(),Fh(),Dh();}function oR(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function rR(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,d=s?t.toChar:i.length,c=i.slice(l,d);c.length>0&&n.push({...r,text:c});}else n.push(r);}}}return n}function iR(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 d=l.text??"",c=s===t.fromRun?t.fromChar:0,u=s===t.toRun?t.toChar:d.length;a+=u-c;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function aR(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 sR(e,t,n,o){let{pmStart:r,pmEnd:i}=iR(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 d$1=rR(e,t);if(d$1.length===0)return {charOffset:0,pmPosition:r};let c=0,u=0;for(let f of d$1){if(f.kind==="tab"){let m=f.width??48,b=c+m;if(l<=b){let g=c+m/2;return l<g?{charOffset:u,pmPosition:r+u}:{charOffset:u+1,pmPosition:r+u+1}}c=b,u+=1;continue}if(f.kind==="image"){let m=f.width,b=c+m;if(l<=b){let g=c+m/2;return l<g?{charOffset:u,pmPosition:r+u}:{charOffset:u+1,pmPosition:r+u+1}}c=b,u+=1;continue}if(f.kind==="lineBreak"){if(l>=c)return {charOffset:u,pmPosition:r+u};u+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=oR(f),g=d(m,b),h=c+g.width;if(l<=h){let x=l-c,y=e$1(x,g.charWidths),k=u+y;return {charOffset:k,pmPosition:r+k}}c=h,u+=m.length;}}return {charOffset:i-r,pmPosition:i}}function Ah(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,d=aR(l,i,a.fromLine,a.toLine);if(d===null)return null;let c=l.lines[d];if(!c)return null;let u=0;for(let y=a.fromLine;y<d;y++)u+=l.lines[y]?.lineHeight??0;let p=s.attrs?.indent,f=p?.left??0,m=p?.right??0,b=Math.max(0,t.width-f-m),g=r-f,{charOffset:h,pmPosition:x}=sR(s,c,g,b);return {pmPosition:x,charOffset:h,lineIndex:d}}function lR(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 Ah(i)?.pmPosition??null}function Su(e,t){if(t)return lR(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?Ah(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Bh(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 Nh(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);return l&&l.dataset.pmStart?Number(l.dataset.pmStart):cR(e,i,t,n)}function Nh(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let u=e.getBoundingClientRect(),p=(u.left+u.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 d=0,c=s;for(;d<c;){let u=Math.floor((d+c)/2),p=l.createRange();p.setStart(a,u),p.setEnd(a,u);let m=p.getBoundingClientRect().left;t<m?c=u:d=u+1;}if(d>0&&d<=s){let u=l.createRange();u.setStart(a,d-1),u.setEnd(a,d-1);let p=u.getBoundingClientRect();u.setStart(a,Math.min(d,s)),u.setEnd(a,Math.min(d,s));let f=u.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(d-1)}return o+Math.min(d,r-o)}function cR(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let f=t.querySelectorAll(".layout-paragraph");if(f.length>0){let m=f[0];return Number(m.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let f of Array.from(a)){let m=f,b=m.getBoundingClientRect(),g=(b.top+b.bottom)/2,h=Math.abs(o-g);h<l&&(l=h,s=m);}if(!s)return null;let d=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(d.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let c=null,u=1/0;for(let f of Array.from(d)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return Nh(m,n);let g=n<b.left?b.left-n:n-b.right;g<u&&(u=g,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return n<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)}var Ko={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function dR(e){return e.kind==="paragraph"}function uR(e){return e.kind==="table"}function pR(e){return e.kind==="image"}function dl(e){e.style.position="absolute",e.style.overflow="hidden";}function fR(e,t,n){let o=n.createElement("div");return o.className=`${Ko.fragment} ${Ko.paragraph}`,dl(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 mR(e,t,n){let o=n.createElement("div");return o.className=`${Ko.fragment} ${Ko.table}`,dl(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 gR(e,t,n){let o=n.createElement("div");return o.className=`${Ko.fragment} ${Ko.image}`,dl(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 Qi(e,t,n={}){let o=n.document??document;if(dR(e))return fR(e,t,o);if(uR(e))return mR(e,t,o);if(pR(e))return gR(e,t,o);let r=o.createElement("div");r.className=Ko.fragment,dl(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function Cu(e){return e/1440*96}function hR(e){return e/96*1440}function bR(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(u=>u.val!=="clear").filter(u=>u.pos>=o),i=t.filter(u=>u.val==="clear").map(u=>u.pos),a=r.reduce((u,p)=>Math.max(u,p.pos),0),s=[...r];o>0&&!r.some(u=>u.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let d=a>0?Math.max(a,o):o,c=o+14400;for(;d<c;){d+=n;let u=r.some(m=>Math.abs(m.pos-d)<20),p=i.some(m=>Math.abs(m-d)<20),f=o>0&&Math.abs(d-o)<20;!u&&!p&&!f&&s.push({val:"start",pos:d,leader:"none"});}return s.sort((u,p)=>u.pos-p.pos)}function Hh(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=hR(e),l=bR(t).find(u=>u.pos>a);if(!l){let u=Cu(i),p=u-e%u;return p<=0&&(p=u),{width:p,alignment:"default"}}let c=Cu(l.pos)-e;if(l.val==="center"||l.val==="end"){let u=o?o(n):0;l.val==="center"?c-=u/2:c-=u;}else if(l.val==="decimal"){let u=n.indexOf(r);if(u>=0&&o){let p=n.slice(0,u),f=o(p);c-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(c<1){let u=Cu(i),p=u-e%u;return p<=0&&(p=u),{width:p,alignment:"default"}}return {width:c,leader:l.leader,alignment:l.val}}var Tn={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 pl(e){return e.kind==="text"}function ul(e){return e.kind==="tab"}function Tu(e){return e.kind==="image"}function wu(e){return e.kind==="lineBreak"}function ku(e){return e.kind==="field"}var zh='"Segoe UI", Arial, sans-serif';function xR(e,t){if(t.fontFamily){let o=t.fontFamily.includes(" ")?`"${t.fontFamily}"`:t.fontFamily;e.style.fontFamily=`${o}, ${zh}`;}if(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"),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 ri(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Pu(e,t){let n=t.createElement("span");if(n.className=`${Tn.run} ${Tn.text}`,xR(n,e),ri(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,o.style.color=e.color||"#0563c1",o.style.textDecoration="underline",n.appendChild(o);}else n.textContent=e.text;return n}function _h(e,t,n,o){let r=t.createElement("span");if(r.className=`${Tn.run} ${Tn.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,ri(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=yR(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 yR(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";default:return null}}function vR(e,t){let n=t.createElement("img");return n.className=`${Tn.run} ${Tn.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",ri(n,e.pmStart,e.pmEnd),n}function Oh(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),ri(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function $h(e,t){let n=e.displayMode,o=e.wrapType;return n==="float"||o&&["square","tight","through"].includes(o)||n==="block"||o==="topAndBottom"?Oh(e,t):vR(e,t)}function Wh(e,t){let n=t.createElement("br");return n.className=`${Tn.run} ${Tn.lineBreak}`,ri(n,e.pmStart,e.pmEnd),n}function Vh(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 Pu(r,t)}function SR(e,t,n){if(pl(e))return Pu(e,t);if(ul(e))return _h(e,t,48,void 0);if(Tu(e))return $h(e,t);if(wu(e))return Wh(e,t);if(ku(e)&&n)return Vh(e,t,n);let o=t.createElement("span");return o.className=Tn.run,o}function Zh(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(pl(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 CR(e){return {val:e.val,pos:e.pos,leader:e.leader}}function TR(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(pl(i))o+=i.text;else if(ku(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(ul(i)||wu(i))break}return o}function wR(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=i.includes(" ")?`"${i}"`:i,s=r*96/72;return n.font=`${s}px ${a}, ${zh}`,n.measureText(o).width}}function Uh(e,t,n,o,r){let i=o.createElement("div");i.className=Tn.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=Zh(e,t);if(a.length===0){let m=o.createElement("span");return m.className=`${Tn.run} layout-empty-run`,m.innerHTML=" ",i.appendChild(m),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",i.style.overflow="visible";let d=a.some(ul),c,u=wR(o);if(d){let m=r?.tabStops?.map(CR),b=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;c={explicitStops:m,leftIndent:b};}let p=0,f=r?.leftIndentPx??0;if(r?.isFirstLine){let m=r?.firstLineIndentPx??0;p=f+m;}else p=f;for(let m=0;m<a.length;m++){let b=a[m];if(ul(b)&&c){let g=TR(a,m,r?.context),h=Hh(p,c,g,u),x=_h(b,o,h.width,h.leader);i.appendChild(x),p+=h.width;}else if(pl(b)){let g=Pu(b,o);i.appendChild(g);let h=b.fontSize||11,x=b.fontFamily||"Calibri";p+=u(b.text,h,x);}else if(Tu(b)){if(b.displayMode==="float"||b.wrapType&&["square","tight","through"].includes(b.wrapType))continue;let h=$h(b,o);i.appendChild(h),b.displayMode!=="block"&&b.wrapType!=="topAndBottom"&&(p+=b.width);}else if(wu(b)){let g=Wh(b,o);i.appendChild(g);}else if(ku(b)&&r?.context){let g=Vh(b,o,r.context);i.appendChild(g);let h=b.fallback??"";b.fieldType==="PAGE"?h=String(r.context.pageNumber):b.fieldType==="NUMPAGES"&&(h=String(r.context.totalPages));let x=b.fontSize||11,y=b.fontFamily||"Calibri";p+=u(h,x,y);}else {let g=SR(b,o,r?.context);i.appendChild(g);}}return i}function Sr(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Tn.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),ri(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");for(let y of t.runs)Tu(y)&&(y.displayMode==="float"||y.wrapType&&["square","tight","through"].includes(y.wrapType));let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId),l&&(l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":a.style.textAlign="left");let d=t.attrs?.indent,c=0,u=0;d&&(d.left&&d.left>0&&(c=d.left),d.right&&d.right>0&&(u=d.right));let p=t.attrs?.borders;if(p){let y=T=>{switch(T){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",p.top&&(a.style.borderTop=`${p.top.width}px ${y(p.top.style)} ${p.top.color}`),p.bottom&&(a.style.borderBottom=`${p.bottom.width}px ${y(p.bottom.style)} ${p.bottom.color}`),p.left&&(a.style.borderLeft=`${p.left.width}px ${y(p.left.style)} ${p.left.color}`),p.right&&(a.style.borderRight=`${p.right.width}px ${y(p.right.style)} ${p.right.color}`),(p.top||p.bottom||p.left||p.right)&&(a.style.paddingLeft=p.left?"4px":"0",a.style.paddingRight=p.right?"4px":"0",a.style.paddingTop=p.top?"2px":"0",a.style.paddingBottom=p.bottom?"6px":"0");}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let f=e.width-c-u,b=t.runs[t.runs.length-1]?.kind==="lineBreak",g=n.lines.length,h=0;d?.hanging&&d.hanging>0?h=-d.hanging:d?.firstLine&&d.firstLine>0&&(h=d.firstLine);let x=0;for(let y=0;y<s.length;y++){let k=s[y],T=e.fromLine+y,A=T===g-1,B=T===0&&!e.continuesFromPrev,R=k.leftOffset??0,E=k.rightOffset??0,S=f;if(B){let Z=d?.hanging&&d.hanging>0,L=d?.firstLine&&d.firstLine>0;Z&&d?.hanging?S=f+d.hanging:L&&d?.firstLine&&(S=f-d.firstLine);}let N=Uh(t,k,l,i,{availableWidth:S-R-E,isLastLine:A,isFirstLine:B,paragraphEndsWithLineBreak:b,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:B?h:0,context:o});R>0&&(N.style.marginLeft=`${R}px`),E>0&&(N.style.marginRight=`${E}px`),x+=k.lineHeight;let _=d?.hanging&&d.hanging>0,U=d?.firstLine&&d.firstLine>0;if(B?c>0&&_?(N.style.paddingLeft=`${c}px`,N.style.textIndent=`-${d.hanging}px`):c>0&&U?(N.style.paddingLeft=`${c}px`,N.style.textIndent=`${d.firstLine}px`):c>0?N.style.paddingLeft=`${c}px`:U&&(N.style.textIndent=`${d.firstLine}px`):c>0?N.style.paddingLeft=`${c}px`:_&&(N.style.paddingLeft=`${d.hanging}px`),u>0&&(N.style.paddingRight=`${u}px`),B&&t.attrs?.listMarker){let Z=Math.max(0,c-(d?.hanging??0));N.style.paddingLeft=`${Z}px`,N.style.textIndent="0";let L=kR(t.attrs.listMarker,d,i);N.insertBefore(L,N.firstChild);}a.appendChild(N);}return a}function kR(e,t,n){let o=n.createElement("span");o.className="layout-list-marker",o.style.display="inline-block",o.textContent=e;let r=t?.hanging??24;return o.style.minWidth=`${r}px`,o.style.textAlign="left",o.style.boxSizing="border-box",o}var io={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 PR(e,t,n,o){let r=o.createElement("div");r.className=io.cellContent,r.style.position="relative",r.style.width=`${t.width}px`;let i=0;for(let a=0;a<e.blocks.length;a++){let s=e.blocks[a],l=t.blocks[a];if(s?.kind==="paragraph"&&l?.kind==="paragraph"){let d=s,c=l,u={blockId:d.id,width:t.width,height:c.totalHeight,fromLine:0,toLine:c.lines.length,pmStart:d.pmStart,pmEnd:d.pmEnd},p=Sr(u,d,c,n,{document:o});p.style.position="relative",r.appendChild(p),i+=c.totalHeight;}else if(s?.kind==="table"&&l?.kind==="table"){let d=s,c=l,u=RR(d,c,n,o);u.style.position="relative",u.style.marginTop=`${i}px`,r.appendChild(u),i+=c.totalHeight;}}return r}function RR(e,t,n,o){let r=o.createElement("div");r.className=`${io.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"),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 d=0;d<t.rows.length;d++)i.push(a),a+=t.rows[d]?.height??0;i.push(a);let s=new Map,l=0;for(let d=0;d<e.rows.length;d++){let c=e.rows[d],u=t.rows[d];if(!c||!u)continue;let p=qh(c,u,d,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=u.height;}return r.style.height=`${l}px`,r}function fl(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 ER(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=io.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??0,d=e.padding?.right??7,c=e.padding?.bottom??0,u=e.padding?.left??7;if(s.style.padding=`${l}px ${d}px ${c}px ${u}px`,e.borders&&(r.isFirstRow&&fl(s,"top",e.borders.top),fl(s,"right",e.borders.right),fl(s,"bottom",e.borders.bottom),r.isFirstCol&&fl(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=PR(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let f=e.blocks[0],m=e.blocks[e.blocks.length-1];f&&"pmStart"in f&&f.pmStart!==void 0&&(s.dataset.pmStart=String(f.pmStart)),m&&"pmEnd"in m&&m.pmEnd!==void 0&&(s.dataset.pmEnd=String(m.pmEnd));}return s}function qh(e,t,n,o,r,i,a,s,l,d){let c=s.createElement("div");c.className=io.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 u=new Set;if(l){for(let[,m]of l)if(m.startRow<n&&m.startRow+m.rowSpan>n)for(let b=0;b<m.colSpan;b++)u.add(m.columnIndex+b);}let p=0,f=0;for(;u.has(f);)p+=r[f]??0,f++;for(let m=0;m<e.cells.length;m++){let b=e.cells[m],g=t.cells[m];if(!b||!g)continue;let h=b.colSpan??1,x=b.rowSpan??1,y=t.height;if(x>1&&d){y=0;for(let E=n;E<n+x&&E<d.length-1;E++)y+=(d[E+1]??0)-(d[E]??0);y===0&&(y=t.height*x);}let k=n===0,A=f===0;f+h>=r.length;let R=ER(b,g,p,y,{isFirstRow:k,isFirstCol:A},a,s);if(R.dataset.cellIndex=String(m),R.dataset.columnIndex=String(f),x>1&&(R.dataset.rowSpan=String(x)),c.appendChild(R),x>1&&l){let E=`${n}-${f}`;l.set(E,{cell:b,cellMeasure:g,columnIndex:f,startRow:n,rowSpan:x,colSpan:h,x:p,totalHeight:y});}for(let E=0;E<h&&f+E<r.length;E++)p+=r[f+E]??0;for(f+=h;u.has(f);)p+=r[f]??0,f++;}return c}function ml(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=io.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 m=i.createElement("div");m.className=io.resizeHandle,m.style.position="absolute",m.style.left=`${s-3}px`,m.style.top="0",m.style.width="6px",m.style.height="100%",m.style.cursor="col-resize",m.style.zIndex="10",m.dataset.columnIndex=String(f),m.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}let l=[],d=0;for(let f=0;f<n.rows.length;f++)l.push(d),d+=n.rows[f]?.height??0;l.push(d);let c=new Map,u=0;for(let f=e.fromRow;f<e.toRow;f++){let m=t.rows[f],b=n.rows[f];if(!m||!b)continue;let g=qh(m,b,f,u,n.columnWidths,t.rows.length,o,i,c,l);a.appendChild(g),u+=b.height;}let p=0;for(let f=e.fromRow;f<e.toRow;f++)if(p+=n.rows[f]?.height??0,f<e.toRow-1){let m=i.createElement("div");m.className=io.rowResizeHandle,m.style.position="absolute",m.style.left="0",m.style.top=`${p-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(f),m.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let f=i.createElement("div");f.className=io.tableEdgeHandleBottom,f.style.position="absolute",f.style.left="0",f.style.top=`${p-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((b,g)=>b+g,0),m=i.createElement("div");m.className=io.tableEdgeHandleRight,m.style.position="absolute",m.style.left=`${f-3}px`,m.style.top="0",m.style.width="6px",m.style.height="100%",m.style.cursor="col-resize",m.style.zIndex="10",m.dataset.columnIndex=String(n.columnWidths.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="right",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}return a}var Ru={image:"layout-image",imageAnchored:"layout-image-anchored"};function gl(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Ru.image,e.isAnchored&&a.classList.add(Ru.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");return 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,a.appendChild(s),a}var hl={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function IR(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 d=qr(l,a[s],o.theme);for(let[c,u]of Object.entries(d))e.style[c]=String(u);}}}}function MR(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 LR(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 bl(e){return e===void 0?0:Math.round(e*96/914400)}function FR(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function DR(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!FR(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,d=i.distLeft??12,c=i.distRight??12,u="left",p=0;if(a?.horizontal){let m=a.horizontal;m.align==="right"?(u="right",p=n-i.width):m.align==="left"?(u="left",p=0):m.align==="center"?(u="left",p=(n-i.width)/2):m.posOffset!==void 0&&(p=bl(m.posOffset),u=p>n/2?"right":"left");}else i.cssFloat==="right"&&(u="right",p=n-i.width);let f=0;if(a?.vertical){let m=a.vertical;m.align==="top"?f=0:m.align==="bottom"?f=t:m.posOffset!==void 0?f=bl(m.posOffset):f=t,m.relativeTo==="margin"&&(m.align==="top"||m.posOffset!==void 0)||m.relativeTo==="paragraph"&&(f=t+f);}else f=t;o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:u,x:p,y:f,distTop:s,distBottom:l,distLeft:d,distRight:c,pmStart:i.pmStart,pmEnd:i.pmEnd});}return o}function AR(e,t){let n=[],o=0,r=0,i=1/0,a=0;for(let s of e){let l=s.x-s.distLeft,d=s.x+s.width+s.distRight,c=s.y-s.distTop,u=s.y+s.height+s.distBottom;s.side==="left"?o=Math.max(o,d):r=Math.max(r,t-l),i=Math.min(i,c),a=Math.max(a,u);}return (o>0||r>0)&&n.push({leftMargin:o,rightMargin:r,topY:i===1/0?0:i,bottomY:a}),n}function BR(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 Kh(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 d=e.blocks[l],c=e.measures[l];if(d?.kind==="paragraph"&&c?.kind==="paragraph"){let u=d,p=c,f=s,m=[];for(let x of u.runs)if(x.kind==="image"&&"position"in x&&x.position){let y=x;a.push({src:y.src,width:y.width,height:y.height,alt:y.alt,paragraphY:f,position:y.position});}else m.push(x);let b={...u,runs:m},g={blockId:u.id,width:i,height:p.totalHeight,fromLine:0,toLine:p.lines.length},h=Sr(g,b,p,t,{document:o});h.style.position="relative",h.style.marginBottom="0",r.appendChild(h),s+=p.totalHeight;}}for(let l of a){let d=o.createElement("img");d.src=l.src,d.width=l.width,d.height=l.height,l.alt&&(d.alt=l.alt),d.style.position="absolute";let c=l.position.horizontal;c&&(c.align==="right"?d.style.right="0":c.align==="center"?(d.style.left="50%",d.style.transform="translateX(-50%)"):c.posOffset!==void 0?d.style.left=`${bl(c.posOffset)}px`:d.style.left="0");let u=l.position.vertical;if(u){let p=l.paragraphY;u.align==="bottom"?d.style.bottom="0":u.align==="center"?(d.style.top="50%",d.style.transform=(d.style.transform||"")+" translateY(-50%)"):u.posOffset!==void 0?d.style.top=`${p+bl(u.posOffset)}px`:d.style.top=`${p}px`;}else d.style.top=`${l.paragraphY}px`;r.appendChild(d);}return r}function NR(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 Gh(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??hl.page,r.dataset.pageNumber=String(e.number),IR(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=hl.content,MR(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let c of e.fragments)if(c.kind==="paragraph"&&n.blockLookup){let u=n.blockLookup.get(String(c.blockId));if(u?.block.kind==="paragraph"){let p=u.block,f=c.y-e.margins.top,m=DR(p,f,a);s.push(...m);}}for(let c of s)l.push({side:c.side,x:c.x,y:c.y,width:c.width,height:c.height,distTop:c.distTop,distBottom:c.distBottom,distLeft:c.distLeft,distRight:c.distRight});if(n.blockLookup)for(let c of e.fragments){if(c.kind!=="table")continue;let u=n.blockLookup.get(String(c.blockId));if(u?.block.kind!=="table")continue;let f=u.block.floating;if(!f)continue;let m=c.x-e.margins.left,b=c.y-e.margins.top,g=f.topFromText??0,h=f.bottomFromText??0,x=f.leftFromText??12,y=f.rightFromText??12,k=m<a/2?"left":"right";l.push({side:k,x:m,y:b,width:c.width,height:c.height,distTop:g,distBottom:h,distLeft:x,distRight:y});}AR(l,a);if(s.length>0){let c=BR(s,o);i.appendChild(c);}for(let c of e.fragments){let u,p={...t,section:"body",contentWidth:a};c.y-e.margins.top;if(n.blockLookup&&c.blockId){let m=n.blockLookup.get(String(c.blockId));c.kind==="paragraph"&&m?.block.kind==="paragraph"&&m?.measure.kind==="paragraph"?u=Sr(c,m.block,m.measure,p,{document:o}):c.kind==="table"&&m?.block.kind==="table"&&m?.measure.kind==="table"?u=ml(c,m.block,m.measure,p,{document:o}):c.kind==="image"&&m?.block.kind==="image"&&m?.measure.kind==="image"?u=gl(c,m.block,m.measure,p,{document:o}):u=Qi(c,p,{document:o});}else u=Qi(c,p,{document:o});LR(u,c,{left:e.margins.left,top:e.margins.top}),i.appendChild(u);}if(n.footnoteArea&&n.footnoteArea.length>0){let c=NR(n.footnoteArea,a,o);c.style.position="absolute";let u=e.footnoteReservedHeight??0,p=e.size.h-e.margins.bottom-e.margins.top;c.style.top=`${p-u}px`,c.style.left="0",c.style.right="0",i.appendChild(c);}r.appendChild(i);{let u=n.headerDistance??e.margins.header??48,p=e.size.w-e.margins.left-e.margins.right,f=Math.max(e.margins.top-u,48),b=(n.headerContent?.height??0)>f,g=o.createElement("div");if(g.className=hl.header,g.style.position="absolute",g.style.top=`${u}px`,g.style.left=`${e.margins.left}px`,g.style.right=`${e.margins.right}px`,g.style.width=`${p}px`,b||(g.style.maxHeight=`${f}px`,g.style.overflow="hidden"),g.style.minHeight="24px",n.headerContent&&n.headerContent.blocks.length>0){let h=Kh(n.headerContent,{...t,section:"header",contentWidth:p},n);g.appendChild(h);}r.appendChild(g);}{let u=n.footerDistance??e.margins.footer??48,p=e.size.w-e.margins.left-e.margins.right,f=Math.max(e.margins.bottom-u,48),b=(n.footerContent?.height??0)>f,g=o.createElement("div");if(g.className=hl.footer,g.style.position="absolute",g.style.bottom=`${u}px`,g.style.left=`${e.margins.left}px`,g.style.right=`${e.margins.right}px`,g.style.width=`${p}px`,b||(g.style.maxHeight=`${f}px`,g.style.overflow="hidden"),g.style.minHeight="24px",n.footerContent&&n.footerContent.blocks.length>0){let h=Kh(n.footerContent,{...t,section:"footer",contentWidth:p},n);g.appendChild(h);}r.appendChild(g);}return r}function Eu(e,t,n={}){let o=e.length,r=n.pageGap??24;t.innerHTML="",t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.gap=`${r}px`,t.style.padding=`${r}px`,t.style.backgroundColor="var(--doc-bg, #f8f9fa)";for(let i=0;i<e.length;i++){let a=e[i],s={pageNumber:a.number,totalPages:o,section:"body"},l={...n};if(n.footnotesByPage){let c=n.footnotesByPage.get(a.number);c&&c.length>0&&(l.footnoteArea=c);}let d=Gh(a,s,l);t.appendChild(d);}}var xl=class{constructor(t={}){e(this,"container",null);e(this,"blockLookup",new Map);e(this,"pageStates",[]);e(this,"totalPages",0);e(this,"options");e(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 Sr(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return ml(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return gl(t,r,i,n,{document:this.doc})}return Qi(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 go,Go,Yo,ho,ii,Cr,Yh,Iu,yl=class{constructor(){g$1(this,Cr);g$1(this,go,0);g$1(this,Go,0);g$1(this,Yo,false);g$1(this,ho,null);g$1(this,ii,new Set);}setStateSeq(t){h$1(this,go,t);}incrementStateSeq(){return ++j$1(this,go)._}getStateSeq(){return f(this,go)}getRenderSeq(){return f(this,Go)}onLayoutStart(){h$1(this,Yo,true);}onLayoutComplete(t){h$1(this,Go,t),h$1(this,Yo,false),i$2(this,Cr,Yh).call(this);}isSafeToRender(){return !f(this,Yo)&&f(this,Go)>=f(this,go)}requestRender(){this.isSafeToRender()?i$2(this,Cr,Iu).call(this):h$1(this,ho,()=>i$2(this,Cr,Iu).call(this));}onRender(t){return f(this,ii).add(t),()=>{f(this,ii).delete(t);}}reset(){h$1(this,go,0),h$1(this,Go,0),h$1(this,Yo,false),h$1(this,ho,null);}getDebugInfo(){return {stateSeq:f(this,go),renderSeq:f(this,Go),layoutUpdating:f(this,Yo),hasPendingRender:f(this,ho)!==null,isSafe:this.isSafeToRender()}}};go=new WeakMap,Go=new WeakMap,Yo=new WeakMap,ho=new WeakMap,ii=new WeakMap,Cr=new WeakSet,Yh=function(){if(f(this,ho)&&this.isSafeToRender()){let t=f(this,ho);h$1(this,ho,null),t();}},Iu=function(){for(let t of f(this,ii))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};function Xh({pagesContainerRef:e}){let t=useRef(null),n=useRef(-1),o=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let c of Array.from(l)){let u=c,p=Number(u.dataset.pmStart),f=Number(u.dataset.pmEnd);if(u.classList.contains("layout-run-tab")){if(s>=p&&s<f)return u.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&c.firstChild?.nodeType===Node.TEXT_NODE){let m=c.firstChild,b=Math.min(s-p,m.length),g=u.ownerDocument;if(!g)continue;let h=g.createRange();return h.setStart(m,b),h.setEnd(m,b),h.getBoundingClientRect().left}}let d=e.current.querySelectorAll(".layout-empty-run");for(let c of Array.from(d)){let u=c.closest(".layout-paragraph");if(!u)continue;let p=Number(u.dataset.pmStart),f=Number(u.dataset.pmEnd);if(s>=p&&s<=f)return c.getBoundingClientRect().left}return null},[e]),r=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(".layout-line");for(let d of Array.from(l)){let c=d,u=c.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(u)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return c}}for(let d of Array.from(l)){let c=d,u=c.closest(".layout-paragraph");if(!u)continue;let p=Number(u.dataset.pmStart),f=Number(u.dataset.pmEnd);if(s>=p&&s<=f&&u.querySelector(".layout-line")===c)return c}return null},[e]),i=useCallback((s,l)=>{let d=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(d.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart)+1:null}for(let f of Array.from(d)){let m=f,b=m.getBoundingClientRect(),g=Number(m.dataset.pmStart),h=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let x=(b.left+b.right)/2;return l<x?g:h}continue}if(l>=b.left&&l<=b.right){let x=m.firstChild;if(!x||x.nodeType!==Node.TEXT_NODE)return g;let y=x,k=m.ownerDocument;if(!k)return g;let T=0,A=y.length;for(;T<A;){let B=Math.floor((T+A)/2),R=k.createRange();R.setStart(y,B),R.setEnd(y,B),l<R.getBoundingClientRect().left?A=B:T=B+1;}if(T>0&&T<=y.length){let B=k.createRange();B.setStart(y,T-1),B.setEnd(y,T-1);let R=B.getBoundingClientRect().left;B.setStart(y,Math.min(T,y.length)),B.setEnd(y,Math.min(T,y.length));let E=B.getBoundingClientRect().left;if(Math.abs(l-R)<Math.abs(l-E))return g+(T-1)}return g+Math.min(T,h-g)}}let c=null,u=1/0;for(let f of Array.from(d)){let m=f,b=m.getBoundingClientRect(),g=l<b.left?b.left-l:l-b.right;g<u&&(u=g,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return l<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)},[]),a=useCallback((s,l)=>{if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return (["ArrowLeft","ArrowRight","Home","End"].includes(l.key)||l.key.length===1&&!l.ctrlKey&&!l.metaKey)&&(t.current=null,n.current=-1),false;if(l.ctrlKey||l.metaKey)return t.current=null,n.current=-1,false;if(!e.current)return false;let d=Array.from(e.current.querySelectorAll(".layout-line"));if(d.length===0)return false;let{from:c,anchor:u}=s.state.selection;if(t.current===null){let y=o(c);if(y===null)return false;t.current=y;}let p;if(n.current>=0&&n.current<d.length)p=n.current;else {let y=r(c);if(!y||(p=d.indexOf(y),p===-1))return false}let f=l.key==="ArrowUp"?p-1:p+1;if(f<0||f>=d.length)return n.current=-1,false;let m=d[f],b=i(m,t.current);if(b===null)return false;n.current=f;let{state:g,dispatch:h}=s,x=Math.max(0,Math.min(b,g.doc.content.size));try{let y=l.shiftKey?TextSelection.create(g.doc,u,x):TextSelection.create(g.doc,x);h(g.tr.setSelection(y));}catch{let y=g.doc.resolve(x),k=l.shiftKey?TextSelection.between(g.doc.resolve(u),y):TextSelection.near(y);h(g.tr.setSelection(k));}return true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var HR=12,Cl=8;function Jh(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 Mu(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 d=n.get(r.number)??[];d.includes(o.footnoteId)||d.push(o.footnoteId),n.set(r.number,d),i=true;break}}if(i)break}return n}function OR(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let c={kind:"text",text:`${t} `,fontSize:Cl,superscript:true};l.push(c);}for(let c of s.content){let u=c;if(u.type==="run"&&Array.isArray(u.content)){let p=u.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=Cl);for(let m of u.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:Cl});let d={kind:"paragraph",id:`fn-${e.id}-p${a}`,runs:l};o.push(d);}o.length===0&&o.push({kind:"paragraph",id:`fn-${e.id}-empty`,runs:[{kind:"text",text:"",fontSize:Cl}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=Ji(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 Qh(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 d=OR(l,i,n);o.set(s.footnoteId,d),i++;}return o}function eb(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+=HR,n.set(o,i));}return n}var Tl=class{constructor(t,n=1){e(this,"pagesContainer");e(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 d=a.getBoundingClientRect(),c=a.closest(".layout-line"),u=c?c.offsetHeight:16;return {x:(d.left-n.left)/this.zoom,y:(d.top-n.top)/this.zoom,height:u/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let d=i.firstChild,c=Math.min(t-s,d.length),u=a.ownerDocument;if(!u)continue;let p=u.createRange();p.setStart(d,c),p.setEnd(d,c);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let d=i.getBoundingClientRect(),c=i.closest(".layout-line"),u=c?c.offsetHeight:16;return {x:(d.left-n.left)/this.zoom,y:(d.top-n.top)/this.zoom,height:u/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let c=a.firstChild,u=s.ownerDocument;if(!u)continue;let p=Math.max(0,t-l),f=Math.min(c.length,n-l);if(p<f){let m=u.createRange();m.setStart(c,p),m.setEnd(c,f);let b=m.getClientRects();for(let g of Array.from(b))r.push({x:(g.left-o.left)/this.zoom,y:(g.top-o.top)/this.zoom,width:g.width/this.zoom,height:g.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function Lu(e,t=1){return new Tl(e,t)}var WR=816,ib=1056,wl={top:96,right:96,bottom:96,left:96},VR=24,ZR=[],UR={position:"relative",width:"100%",height:"100%",overflow:"auto",backgroundColor:"var(--doc-bg, #f8f9fa)"},qR={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24},KR={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},GR={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function ao(e){return Math.round(e/1440*96)}function YR(e){return {w:e?.pageWidth?ao(e.pageWidth):WR,h:e?.pageHeight?ao(e.pageHeight):ib}}function jR(e){let t=e?.marginTop?ao(e.marginTop):wl.top,n=e?.marginBottom?ao(e.marginBottom):wl.bottom;return {top:t,right:e?.marginRight?ao(e.marginRight):wl.right,bottom:n,left:e?.marginLeft?ao(e.marginLeft):wl.left,header:e?.headerDistance?ao(e.headerDistance):48,footer:e?.footerDistance?ao(e.footerDistance):48}}function XR(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function nb(e){return e===void 0?0:Math.round(e*96/914400)}function JR(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 ab(e,t){let i=e.columnWidths??[],a=JR(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((f,m)=>f+(m.colSpan??1),0),p=(a??t)/Math.max(1,c);i=Array(c).fill(p);}else if(i.length>0&&a){let c=i.reduce((u,p)=>u+p,0);if(c>0&&Math.abs(c-a)>1){let u=a/c;i=i.map(p=>p*u);}}let s=e.rows.map(c=>{let u=0;return {cells:c.cells.map(p=>{let f=p.colSpan??1,m=0;for(let x=0;x<f&&u+x<i.length;x++)m+=i[u+x]??0;m===0&&(m=p.width??100),u+=f;let b=p.padding?.left??7,g=p.padding?.right??7,h=Math.max(1,m-b-g);return {blocks:p.blocks.map(x=>sb(x,h)),width:m,height:0,colSpan:p.colSpan,rowSpan:p.rowSpan}}),height:0}});for(let c=0;c<s.length;c++){let u=s[c],p=e.rows[c]?.cells,f=0;for(let h=0;h<u.cells.length;h++){let x=u.cells[h],y=p?.[h];x.height=x.blocks.reduce((A,B)=>"totalHeight"in B?A+B.totalHeight:A,0);let k=y?.padding?.top??0,T=y?.padding?.bottom??0;x.height+=k+T,f=Math.max(f,x.height);}let m=e.rows[c],b=m?.height,g=m?.heightRule;b&&g==="exact"?u.height=b:b&&g==="atLeast"?u.height=Math.max(f,b):u.height=Math.max(f,24);}let l=s.reduce((c,u)=>c+u.height,0),d=i.reduce((c,u)=>c+u,0)||a||t;return {kind:"table",rows:s,columnWidths:i,totalWidth:d,totalHeight:l}}function QR(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(!XR(s))continue;let l=0,d=s.position,c=s.distTop??0,u=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(d?.vertical){let h=d.vertical;h.align==="top"&&h.relativeTo==="margin"?l=0:h.posOffset!==void 0&&(l=nb(h.posOffset));}let m=l+s.height,b=0,g=0;if(d?.horizontal){let h=d.horizontal;if(h.align==="left")b=s.width+f;else if(h.align==="right")g=s.width+p;else if(h.posOffset!==void 0){let x=nb(h.posOffset);x<t/2?b=x+s.width+f:g=t-x+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let h=d?.vertical?.relativeTo==="margin"||d?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-c,bottomY:m+u,anchorBlockIndex:o,isMarginRelative:h});}}}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=ab(i,t),l=s.totalWidth,d=s.totalHeight,c=a.leftFromText??12,u=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,g=0;a.tblpX!==void 0?g=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?g=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?g=t-l:a.tblpXSpec==="center"&&(g=(t-l)/2):i.justification==="center"?g=(t-l)/2:i.justification==="right"&&(g=t-l),g<t/2?m=g+l+u:b=t-g+c;let h=a.tblpY??0,x=h+d;n.push({leftMargin:m,rightMargin:b,topY:h-p,bottomY:x+f,anchorBlockIndex:o});}return n}function sb(e,t,n,o){switch(e.kind){case "paragraph":return Ji(e,t,{floatingZones:n,paragraphYOffset:o??0});case "table":return ab(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function lb(e,t){let n=QR(e,t),o=n.filter(u=>u.isMarginRelative),r=n.filter(u=>!u.isMarginRelative),i=new Map;for(let u of o){let p=i.get(u.topY)??[];p.push(u),i.set(u.topY,p);}let a=[...r];for(let u of i.values()){let p=Math.min(...u.map(f=>f.anchorBlockIndex));for(let f of u)a.push({...f,anchorBlockIndex:p});}let s=new Map;for(let u of a){let p=s.get(u.anchorBlockIndex)??[];p.push({leftMargin:u.leftMargin,rightMargin:u.rightMargin,topY:u.topY,bottomY:u.bottomY}),s.set(u.anchorBlockIndex,p);}let l=new Set(a.map(u=>u.anchorBlockIndex)),d=0,c=[];return e.map((u,p)=>{l.has(p)&&(d=0,c=s.get(p)??[]);let f=c.length>0?c:void 0;try{let m=performance.now(),b=sb(u,t,f,d),g=performance.now()-m;return g>500&&console.warn(`[measureBlocks] Block ${p} (${u.kind}) took ${Math.round(g)}ms`),"totalHeight"in b&&(u.kind==="table"&&u.floating||(d+=b.totalHeight)),b}catch(m){return console.error(`[measureBlocks] Error measuring block ${p} (${u.kind}):`,m),{totalHeight:20}}})}function kl(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,d=l.size,c=m=>Math.round(m/914400*96),u=d?.width?c(d.width):100,p=d?.height?c(d.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:u,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,d=l.rgb||l.val;d&&(i.color=d.startsWith("#")?d:`#${d}`);}}}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=kl(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,d=l.rgb||l.val;d&&(i.color=d.startsWith("#")?d:`#${d}`);}}}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=kl(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=kl(o.children);t.push(...r);}}return t}function ob(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,d={};if(l&&l.alignment){let u=l.alignment;u==="both"?d.alignment="justify":["left","center","right","justify"].includes(u)&&(d.alignment=u);}let c=kl(s.content);if(c.length>0){let u={kind:"paragraph",id:String(n.length),runs:c,attrs:Object.keys(d).length>0?d:void 0};n.push(u);}}}if(n.length===0)return;let o=n.map(a=>{if(a.kind!=="paragraph")return a;let s=a;if(!s.runs.some(c=>c.kind==="image"&&"position"in c&&c.position))return a;let d=s.runs.filter(c=>!(c.kind==="image"&&"position"in c&&c.position));return d.length===0&&d.push({kind:"text",text:""}),{...s,runs:d}}),r=lb(o,t),i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {blocks:n,measures:r,height:i}}function eE(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 d=r.get(l);if(!d)continue;let u=t.get(l)?.displayNumber??0,p=c$1(d);s.push({displayNumber:String(u),text:p});}s.length>0&&o.set(i,s);}return o}var tE=forwardRef(function(t,n){let{document:o,styles:r,theme:i$1,sectionProperties:a,headerContent:s,footerContent:l,readOnly:d=false,pageGap:c=VR,zoom:u=1,onDocumentChange:p,onSelectionChange:f,externalPlugins:m=ZR,extensionManager:b,onReady:g$1,onRenderedDomContextReady:h$1,pluginOverlays:x,onHeaderFooterDoubleClick:y,hfEditMode:k,onBodyClick:T,className:A,style:B}=t,R=useRef(null),E=useRef(null),S=useRef(null),N=useRef(null),{handlePMKeyDown:_}=Xh({pagesContainerRef:E}),U=useRef(f),Z=useRef(p),L=useRef(g$1),H=useRef(h$1);U.current=f,Z.current=p,L.current=g$1,H.current=h$1;let[q,xe]=useState(null),[ie,we]=useState([]),[M,O]=useState([]),[C,P]=useState(false),[I,z]=useState([]),[Y,j$1]=useState(null),[F,V]=useState(null),G=useRef(false),be=useCallback((D,ce)=>{let ee=D.tagName==="IMG"?D:D.querySelector("img"),te=(ee??D).getBoundingClientRect();return {element:ee??D,pmPos:ce,width:Math.round(te.width/u),height:Math.round(te.height/u)}},[u]),me=useRef(false),oe=useRef(null),K=useRef(false),de=useRef(0),Fe=useRef(0),Ke=useRef(0),Ge=useRef({left:0,right:0}),Ye=useRef(null),ze=useRef(false),W=useRef(0),Te=useRef(0),Ie=useRef(0),Me=useRef(0),Qe=useRef(null),Be=useRef(false),xt=useRef(false),Gt=useRef(0),je=useRef(0),Yt=useRef(0),_e=useRef(0),Dt=useRef(null),$n=useRef(false),bn=useRef(null),Ot=useRef(null),Wn=useRef(null),$e=5,et=useMemo(()=>new yl,[]),Vn=useMemo(()=>YR(a),[a]),sn=useMemo(()=>jR(a),[a]),yt=Vn.w-sn.left-sn.right,zt=useMemo(()=>new xl({pageGap:c,showShadow:true,pageBackground:"#fff"}),[c]);N.current=zt;let vt=useCallback(D=>{let ce=performance.now(),ee=et.getStateSeq();et.onLayoutStart();try{let te=performance.now(),ne=Vn.h-sn.top-sn.bottom,X=kh(D.doc,{theme:i$1,pageContentHeight:ne}),J=performance.now()-te;J>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(J)}ms (${X.length} blocks)`),we(X),te=performance.now();let re=lb(X,yt);J=performance.now()-te,J>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(J)}ms (${X.length} blocks)`),O(re);let ue=Jh(X),ye=ue.length>0&&o?.package?.footnotes,ge=ob(s,yt),Re=ob(l,yt),Ne=sn.header??48,He=sn.footer??48,ft=sn.top-Ne,ct=sn.bottom-He,Lt=ge?.height??0,ht=Re?.height??0,jt=sn;(Lt>ft||ht>ct)&&(jt={...sn},Lt>ft&&(jt.top=Ne+Lt),ht>ct&&(jt.bottom=He+ht)),te=performance.now();let xn,lo=new Map,Pi=new Map;if(ye){let wo=ll(X,re,{pageSize:Vn,margins:jt});lo=Mu(wo.pages,ue),Pi=Qh(o.package.footnotes,ue,yt);let Un=eb(lo,Pi);if(Un.size>0){xn=ll(X,re,{pageSize:Vn,margins:jt,footnoteReservedHeights:Un}),lo=Mu(xn.pages,ue);for(let[qn,rr]of lo){let ir=xn.pages.find(w=>w.number===qn);ir&&(ir.footnoteIds=rr);}}else xn=wo;}else xn=ll(X,re,{pageSize:Vn,margins:jt});if(J=performance.now()-te,J>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(J)}ms (${xn.pages.length} pages)`),xe(xn),E.current&&N.current){te=performance.now();let wo=new Map;for(let qn=0;qn<X.length;qn++){let rr=X[qn],ir=re[qn];rr&&ir&&wo.set(String(rr.id),{block:rr,measure:ir});}N.current.setBlockLookup(wo);let Un=ye?eE(lo,Pi,o):void 0;if(Eu(xn.pages,E.current,{pageGap:c,showShadow:!0,pageBackground:"#fff",blockLookup:wo,headerContent:ge,footerContent:Re,headerDistance:a?.headerDistance?ao(a.headerDistance):void 0,footerDistance:a?.footerDistance?ao(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i$1,footnotesByPage:Un?.size?Un:void 0}),J=performance.now()-te,J>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(J)}ms`),h$1){let qn=Lu(E.current,u);h$1(qn);}}let pa=performance.now()-ce;pa>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(pa)}ms total (${X.length} blocks, ${re.length} measures)`);}catch(te){console.error("[PagedEditor] Layout pipeline error:",te);}et.onLayoutComplete(ee);},[yt,Vn,sn,c,u,et,s,l,a,h$1,o]),Dr=useCallback(D=>{if(!E.current)return null;let ce=E.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!ce)return null;let ee=ce.getBoundingClientRect(),te=E.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let X of Array.from(te)){let J=X,re=Number(J.dataset.pmStart),ue=Number(J.dataset.pmEnd);if(J.classList.contains("layout-run-tab")){if(D>=re&&D<ue){let ye=J.getBoundingClientRect(),ge=J.closest(".layout-page"),Re=ge?Number(ge.dataset.pageNumber)-1:0,Ne=J.closest(".layout-line"),He=Ne?Ne.offsetHeight:16;return {x:ye.left-ee.left,y:ye.top-ee.top,height:He,pageIndex:Re}}continue}if(D>=re&&D<=ue&&X.firstChild?.nodeType===Node.TEXT_NODE){let ye=X.firstChild,ge=Math.min(D-re,ye.length),Re=J.ownerDocument;if(!Re)continue;let Ne=Re.createRange();Ne.setStart(ye,ge),Ne.setEnd(ye,ge);let He=Ne.getBoundingClientRect(),ft=J.closest(".layout-page"),ct=ft?Number(ft.dataset.pageNumber)-1:0,Lt=J.closest(".layout-line"),ht=Lt?Lt.offsetHeight:16;return {x:He.left-ee.left,y:He.top-ee.top,height:ht,pageIndex:ct}}}let ne=E.current.querySelectorAll(".layout-empty-run");for(let X of Array.from(ne)){let J=X.closest(".layout-paragraph");if(!J)continue;let re=Number(J.dataset.pmStart),ue=Number(J.dataset.pmEnd);if(D>=re&&D<=ue){let ye=X.getBoundingClientRect(),ge=J.closest(".layout-page"),Re=ge?Number(ge.dataset.pageNumber)-1:0,Ne=X.closest(".layout-line"),He=Ne?Ne.offsetHeight:16;return {x:ye.left-ee.left,y:ye.top-ee.top,height:He,pageIndex:Re}}}return null},[]),_t=useCallback(D=>{let{from:ce,to:ee}=D.selection;if(U.current?.(ce,ee),E.current){let te=E.current.querySelectorAll(".layout-table-cell-selected");for(let J of Array.from(te))J.classList.remove("layout-table-cell-selected");let ne=D.selection;if("$anchorCell"in ne&&typeof ne.forEachCell=="function"){let J=[];ne.forEachCell((ue,ye)=>{J.push([ye,ye+ue.nodeSize]);});let re=E.current.querySelectorAll(".layout-table-cell");for(let ue of Array.from(re)){let ye=ue,ge=ye.dataset.pmStart;if(ge!==void 0){let Re=Number(ge);for(let[Ne,He]of J)if(Re>=Ne&&Re<He){ye.classList.add("layout-table-cell-selected");break}}}}}if(!(!q||ie.length===0))if(ce===ee){let te=Dr(ce);if(te)j$1(te);else {let ne=E.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),X=E.current?.querySelector(".layout-page");if(ne&&X){let J=ne.getBoundingClientRect(),re=X.getBoundingClientRect(),ue=j(q,ie,M,ce);j$1(ue?{...ue,x:ue.x+(re.left-J.left),y:ue.y+(re.top-J.top)}:null);}else j$1(null);}z([]);}else {let te=E.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(te&&E.current){let ne=te.getBoundingClientRect(),X=[],J=E.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let re of Array.from(J)){let ue=re,ye=Number(ue.dataset.pmStart);if(Number(ue.dataset.pmEnd)>ce&&ye<ee){if(ue.classList.contains("layout-run-tab")){let ct=ue.getBoundingClientRect(),Lt=ue.closest(".layout-page"),ht=Lt?Number(Lt.dataset.pageNumber)-1:0;X.push({x:ct.left-ne.left,y:ct.top-ne.top,width:ct.width,height:ct.height,pageIndex:ht});continue}if(re.firstChild?.nodeType!==Node.TEXT_NODE)continue;let Re=re.firstChild,Ne=ue.ownerDocument;if(!Ne)continue;let He=Math.max(0,ce-ye),ft=Math.min(Re.length,ee-ye);if(He<ft){let ct=Ne.createRange();ct.setStart(Re,He),ct.setEnd(Re,ft);let Lt=ct.getClientRects();for(let ht of Array.from(Lt)){let jt=ue.closest(".layout-page"),xn=jt?Number(jt.dataset.pageNumber)-1:0;X.push({x:ht.left-ne.left,y:ht.top-ne.top,width:ht.width,height:ht.height,pageIndex:xn});}}}}if(X.length>0)z(X);else {let re=E.current.querySelector(".layout-page");if(re){let ue=re.getBoundingClientRect(),ye=ue.left-ne.left,ge=ue.top-ne.top,Ne=i(q,ie,M,ce,ee).map(He=>({...He,x:He.x+ye,y:He.y+ge}));z(Ne);}else z([]);}}else z([]);j$1(null);}},[q,ie,M,Dr]),lc=useCallback((D,ce)=>{if(D.docChanged){et.incrementStateSeq(),vt(ce);let ee=S.current?.getDocument();ee&&Z.current?.(ee);}et.requestRender(),_t(ce);},[vt,_t,et]),cc=useCallback(D=>{let{selection:ce}=D;ce instanceof NodeSelection&&ce.node.type.name==="image"?(z([]),j$1(null)):_t(D),requestAnimationFrame(()=>{let ee=S.current?.getView();if(!ee){V(null);return}let{selection:te}=ee.state;if(te instanceof NodeSelection&&te.node.type.name==="image"){let ne=te.from,X=E.current?.querySelector(`[data-pm-start="${ne}"]`);if(X){V(be(X,ne));return}}G.current||V(null);});},[_t,u,be]),Rn=useCallback((D,ce)=>{if(!E.current||!q)return null;let ee=Bh(E.current,D,ce,u);if(ee!==null)return ee;let te=E.current.querySelectorAll(".layout-page"),ne=-1,X=null;for(let Re=0;Re<te.length;Re++){let He=te[Re].getBoundingClientRect();if(D>=He.left&&D<=He.right&&ce>=He.top&&ce<=He.bottom){ne=Re,X=He;break}}if(ne<0||!X)return null;let J=(D-X.left)/u,re=(ce-X.top)/u,ue=q.pages[ne];if(!ue)return null;let ye={pageIndex:ne,page:ue,pageY:re},ge=g(ye,ie,M,{x:J,y:re});if(!ge)return null;if(ge.fragment.kind==="table"){let Re=h(ye,ie,M,{x:J,y:re});return Su(ge,Re)}return Su(ge)},[q,ie,M,u]),To=useCallback(D=>{let ce=S.current?.getView();if(!ce)return null;try{let ee=ce.state.doc.resolve(D);for(let te=ee.depth;te>0;te--){let ne=ee.node(te);if(ne.type.name==="tableCell"||ne.type.name==="tableHeader")return ee.before(te)}}catch{}return null},[]),dc=useCallback(D=>{let ce=["layout-block-image","layout-image","layout-page-floating-image"],ee=te=>!!te.dataset.pmStart&&ce.some(ne=>te.classList.contains(ne));return D.tagName==="IMG"&&D.classList.contains("layout-run-image")?D:D.tagName==="IMG"&&D.parentElement&&ee(D.parentElement)?D.parentElement:ee(D)?D:null},[]),Ar=useCallback(D=>{let ce=E.current;if(!ce)return;let ee=ce.querySelector(`[data-pm-start="${D}"]`);ee&&ee.scrollIntoView({behavior:"smooth",block:"center"});},[]),uc=useCallback(D=>{if(!S.current||D.button!==0)return;if(D.target.closest('a[href^="#"]')){D.preventDefault(),D.stopPropagation();return}if(d)return;if(k&&T){let X=D.target;if(!(X.closest(".layout-page-header")||X.closest(".layout-page-footer")||X.closest(".hf-inline-editor"))){D.preventDefault(),D.stopPropagation(),T();return}}if(!k){let X=D.target;if(X.closest(".layout-page-header")||X.closest(".layout-page-footer")){D.preventDefault(),S.current&&(S.current.setSelection(0),S.current.focus(),P(true));return}}let ee=D.target;if(ee.classList.contains("layout-table-resize-handle")){D.preventDefault(),D.stopPropagation(),K.current=true,de.current=D.clientX,Ye.current=ee,ee.classList.add("dragging");let X=parseInt(ee.dataset.columnIndex??"0",10);Fe.current=X,Ke.current=parseInt(ee.dataset.tablePmStart??"0",10);let J=S.current.getView();if(J){let re=J.state.doc.resolve(Ke.current+1);for(let ue=re.depth;ue>=0;ue--){let ye=re.node(ue);if(ye.type.name==="table"){let ge=ye.attrs.columnWidths;ge&&ge[X]!==void 0&&ge[X+1]!==void 0&&(Ge.current={left:ge[X],right:ge[X+1]});break}}}return}if(ee.classList.contains("layout-table-row-resize-handle")||ee.classList.contains("layout-table-edge-handle-bottom")){D.preventDefault(),D.stopPropagation(),ze.current=true,W.current=D.clientY,Qe.current=ee,Be.current=ee.dataset.isEdge==="bottom",ee.classList.add("dragging");let X=parseInt(ee.dataset.rowIndex??"0",10);Te.current=X,Ie.current=parseInt(ee.dataset.tablePmStart??"0",10);let J=S.current.getView();if(J){let re=J.state.doc.resolve(Ie.current+1);for(let ue=re.depth;ue>=0;ue--){let ye=re.node(ue);if(ye.type.name==="table"){let ge=null,Re=0;if(ye.forEach(Ne=>{Re===X&&(ge=Ne),Re++;}),ge){let Ne=ge.attrs.height;if(Ne)Me.current=Ne;else {let ft=ee.closest(".layout-table")?.querySelector(`[data-row-index="${X}"]`),ct=ft?ft.getBoundingClientRect().height:30;Me.current=Math.round(ct*15);}}break}}}return}if(ee.classList.contains("layout-table-edge-handle-right")){D.preventDefault(),D.stopPropagation(),xt.current=true,Gt.current=D.clientX,Dt.current=ee,ee.classList.add("dragging");let X=parseInt(ee.dataset.columnIndex??"0",10);je.current=X,Yt.current=parseInt(ee.dataset.tablePmStart??"0",10);let J=S.current.getView();if(J){let re=J.state.doc.resolve(Yt.current+1);for(let ue=re.depth;ue>=0;ue--){let ye=re.node(ue);if(ye.type.name==="table"){let ge=ye.attrs.columnWidths;ge&&ge[X]!==void 0&&(_e.current=ge[X]);break}}}return}let te=dc(ee);if(te){D.preventDefault(),D.stopPropagation();let X=te.dataset.pmStart;if(X!==void 0){let J=parseInt(X,10);S.current.setNodeSelection(J),V(be(te,J)),z([]),j$1(null);}S.current.focus(),P(true);return}V(null),D.preventDefault();let ne=Rn(D.clientX,D.clientY);if(ne!==null){let X=To(ne);bn.current=X,$n.current=false,Ot.current=null,Wn.current=null,me.current=true,oe.current=ne,S.current.setSelection(ne);}else {bn.current=null,$n.current=false;let X=S.current.getView();if(X){let J=Math.max(0,X.state.doc.content.size-1);S.current.setSelection(J),oe.current=J,me.current=true;}}S.current.focus(),P(true);},[Rn,To,d,k,T,u]),wi=useCallback(D=>{if(K.current){D.preventDefault();let te=D.clientX-de.current;if(Ye.current){let ne=parseFloat(Ye.current.style.left);Ye.current.style.left=`${ne+te}px`,de.current=D.clientX;let X=Math.round(te*15),J=300,re=Ge.current.left+X,ue=Ge.current.right-X;re>=J&&ue>=J&&(Ge.current={left:re,right:ue});}return}if(ze.current){D.preventDefault();let te=D.clientY-W.current;if(Qe.current){let ne=parseFloat(Qe.current.style.top);Qe.current.style.top=`${ne+te}px`,W.current=D.clientY;let X=Math.round(te*15),J=200,re=Me.current+X;re>=J&&(Me.current=re);}return}if(xt.current){D.preventDefault();let te=D.clientX-Gt.current;if(Dt.current){let ne=parseFloat(Dt.current.style.left);Dt.current.style.left=`${ne+te}px`,Gt.current=D.clientX;let X=Math.round(te*15),J=300,re=_e.current+X;re>=J&&(_e.current=re);}return}if(!me.current||oe.current===null||!S.current||!E.current)return;let ce=Rn(D.clientX,D.clientY);if(ce===null)return;if(bn.current!==null){if($n.current){let ne=To(ce);if(ne!==null){S.current.setCellSelection(bn.current,ne);return}}let te=To(ce);if(te!==null&&te!==bn.current){$n.current=true,S.current.setCellSelection(bn.current,te),Wn.current=null;return}if(Ot.current!==null&&ce===Ot.current){if(Wn.current===null)Wn.current=D.clientX;else if(Math.abs(D.clientX-Wn.current)>=$e){$n.current=true,S.current.setCellSelection(bn.current,bn.current),Wn.current=null;return}}else Wn.current=null,Ot.current=ce;}let ee=oe.current;S.current.setSelection(ee,ce);},[Rn,To]),ki=useCallback(()=>{if(K.current){K.current=false,Ye.current&&(Ye.current.classList.remove("dragging"),Ye.current=null);let D=S.current?.getView();if(D){let ce=Ke.current,ee=Fe.current,{left:te,right:ne}=Ge.current,X=D.state.doc.resolve(ce+1);for(let J=X.depth;J>=0;J--){let re=X.node(J);if(re.type.name==="table"){let ue=X.before(J),ye=D.state.tr,ge=[...re.attrs.columnWidths];ge[ee]=te,ge[ee+1]=ne,ye.setNodeMarkup(ue,void 0,{...re.attrs,columnWidths:ge});let Re=ue+1;re.forEach(Ne=>{let He=Re+1,ft=0;Ne.forEach(ct=>{let Lt=ct.attrs.colspan||1;if(ft===ee||ft===ee+1){let ht=ft===ee?te:ne;ye.setNodeMarkup(ye.mapping.map(He),void 0,{...ct.attrs,width:ht,widthType:"dxa",colwidth:null});}He+=ct.nodeSize,ft+=Lt;}),Re+=Ne.nodeSize;}),D.dispatch(ye);break}}}return}if(ze.current){ze.current=false,Qe.current&&(Qe.current.classList.remove("dragging"),Qe.current=null);let D=S.current?.getView();if(D){let ce=Ie.current,ee=Te.current,te=Me.current,ne=D.state.doc.resolve(ce+1);for(let X=ne.depth;X>=0;X--){let J=ne.node(X);if(J.type.name==="table"){let re=ne.before(X),ue=D.state.tr,ye=re+1,ge=0;J.forEach(Re=>{ge===ee&&ue.setNodeMarkup(ue.mapping.map(ye),void 0,{...Re.attrs,height:te,heightRule:"atLeast"}),ye+=Re.nodeSize,ge++;}),D.dispatch(ue);break}}}return}if(xt.current){xt.current=false,Dt.current&&(Dt.current.classList.remove("dragging"),Dt.current=null);let D=S.current?.getView();if(D){let ce=Yt.current,ee=je.current,te=_e.current,ne=D.state.doc.resolve(ce+1);for(let X=ne.depth;X>=0;X--){let J=ne.node(X);if(J.type.name==="table"){let re=ne.before(X),ue=D.state.tr,ye=[...J.attrs.columnWidths];ye[ee]=te,ue.setNodeMarkup(re,void 0,{...J.attrs,columnWidths:ye});let ge=re+1;J.forEach(Re=>{let Ne=ge+1,He=0;Re.forEach(ft=>{let ct=ft.attrs.colspan||1;He===ee&&ue.setNodeMarkup(ue.mapping.map(Ne),void 0,{...ft.attrs,width:te,widthType:"dxa",colwidth:null}),Ne+=ft.nodeSize,He+=ct;}),ge+=Re.nodeSize;}),D.dispatch(ue);break}}}return}me.current=false,$n.current=false,Ot.current=null,Wn.current=null;},[]);useEffect(()=>(window.addEventListener("mousemove",wi),window.addEventListener("mouseup",ki),()=>{window.removeEventListener("mousemove",wi),window.removeEventListener("mouseup",ki);}),[wi,ki]);let pc=useCallback(D=>{let ce=D.target.closest('a[href^="#"]');if(ce){D.preventDefault(),D.stopPropagation();let ee=ce.getAttribute("href")?.substring(1);if(ee&&S.current){let te=S.current.getView();if(te){let ne=null;te.state.doc.descendants((X,J)=>{if(ne!==null)return false;if(X.type.name==="paragraph"&&X.attrs.bookmarks?.some(ue=>ue.name===ee))return ne=J,false}),ne!==null&&(Ar(ne),S.current.setSelection(ne+1));}}return}if(D.detail===2&&y){let ee=D.target,te=ee.closest(".layout-page-header"),ne=ee.closest(".layout-page-footer");if(te){D.preventDefault(),D.stopPropagation(),y("header");return}if(ne){D.preventDefault(),D.stopPropagation(),y("footer");return}}if(D.detail===2&&S.current){let ee=Rn(D.clientX,D.clientY);if(ee!==null){let te=To(ee);if(te!==null){D.preventDefault(),D.stopPropagation(),S.current.setCellSelection(te,te);return}let ne=S.current.getView();if(ne){let{doc:X}=ne.state,J=X.resolve(ee),re=J.parent;if(re.isTextblock){let ue=re.textContent,ye=J.parentOffset,ge=ye;for(;ge>0&&/\w/.test(ue[ge-1]);)ge--;let Re=ye;for(;Re<ue.length&&/\w/.test(ue[Re]);)Re++;let Ne=J.start()+ge,He=J.start()+Re;Ne<He&&S.current.setSelection(Ne,He);}}}}if(D.detail===3&&S.current){let ee=Rn(D.clientX,D.clientY);if(ee!==null){let te=S.current.getView();if(te){let{doc:ne}=te.state,X=ne.resolve(ee),J=X.start(X.depth),re=X.end(X.depth);S.current.setSelection(J,re);}}}},[Rn,y]),fc=useCallback(()=>{d||(S.current?.focus(),P(true));},[d]),mc=useCallback(D=>{let ce=D.relatedTarget;ce&&R.current?.contains(ce)||P(false);},[]),gc=useCallback((D,ce,ee)=>{let te=S.current?.getView();if(te)try{let ne=te.state.doc.nodeAt(D);if(!ne||ne.type.name!=="image")return;let X=te.state.tr.setNodeMarkup(D,void 0,{...ne.attrs,width:ce,height:ee});te.dispatch(X),S.current?.setNodeSelection(D);}catch{}},[]),hc=useCallback(()=>{G.current=true;},[]),bc=useCallback(()=>{G.current=false;},[]),xc=useCallback((D,ce,ee)=>{let te=S.current?.getView();if(te)try{let ne=te.state.doc.nodeAt(D);if(!ne||ne.type.name!=="image")return;if(ne.attrs.displayMode==="float"||ne.attrs.wrapType&&["square","tight","through"].includes(ne.attrs.wrapType)){let J=E.current?.querySelectorAll(".layout-page");if(!J||J.length===0)return;let re=null;for(let Lt of J){let ht=Lt.getBoundingClientRect();if(ee>=ht.top&&ee<=ht.bottom){re=Lt.querySelector(".layout-page-content");break}}if(re||(re=J[J.length-1].querySelector(".layout-page-content")),!re)return;let ue=re.getBoundingClientRect(),ye=(ce-ue.left)/u,ge=(ee-ue.top)/u,Re=914400/96,Ne=Math.round(ye*Re),He=Math.round(ge*Re),ft={horizontal:{posOffset:Ne,relativeTo:"margin"},vertical:{posOffset:He,relativeTo:"margin"}},ct=te.state.tr.setNodeMarkup(D,void 0,{...ne.attrs,position:ft});te.dispatch(ct),S.current?.setNodeSelection(D);}else {let J=Rn(ce,ee);if(J===null||J===D||J===D+1)return;let re=te.state.tr;if(J<=D)re=re.delete(D,D+ne.nodeSize),re=re.insert(J,ne),S.current?.setNodeSelection(J);else {re=re.delete(D,D+ne.nodeSize);let ue=J-ne.nodeSize;re=re.insert(Math.min(ue,re.doc.content.size),ne),S.current?.setNodeSelection(Math.min(ue,re.doc.content.size-1));}te.dispatch(re);}}catch{}},[Rn,u]),yc=useCallback(()=>{G.current=true;},[]),vc=useCallback(()=>{G.current=false;},[]),Sc=useCallback(D=>{if(!d){if(S.current?.isFocused()||(S.current?.focus(),P(true)),D.key===" "&&!D.ctrlKey&&!D.metaKey){D.preventDefault();let ce=S.current?.getView();if(ce){let{state:ee,dispatch:te}=ce;te(ee.tr.insertText(" "));}return}["PageUp","PageDown"].includes(D.key)&&!D.metaKey&&D.ctrlKey,D.key==="Home"&&(D.metaKey||D.ctrlKey)&&R.current&&(R.current.scrollTop=0),D.key==="End"&&(D.metaKey||D.ctrlKey)&&R.current&&(R.current.scrollTop=R.current.scrollHeight);}},[d]),Cc=useCallback(()=>{d||S.current?.isFocused()||(S.current?.focus(),P(true));},[d]),Zn=useCallback(D=>{vt(D.state),_t(D.state),d||requestAnimationFrame(()=>{D.focus(),P(true);});},[vt,_t,d]);useEffect(()=>{let D=()=>{let ce=S.current?.getView();ce&&(a$1(),vu(),vt(ce.state),_t(ce.state));};return window.document.fonts.addEventListener("loadingdone",D),()=>{window.document.fonts.removeEventListener("loadingdone",D);}},[]);let ua=useRef(0);useEffect(()=>{if(ua.current===0){ua.current=1;return}let D=S.current?.getView();D&&vt(D.state);},[s,l,vt]),useEffect(()=>{let D=R.current;if(!D)return;let ce=new ResizeObserver(()=>{let ee=S.current?.getState();ee&&_t(ee);});return ce.observe(D),()=>ce.disconnect()},[_t]),useImperativeHandle(n,()=>({getDocument(){return S.current?.getDocument()??null},getState(){return S.current?.getState()??null},getView(){return S.current?.getView()??null},focus(){S.current?.focus(),P(true);},blur(){S.current?.blur(),P(false);},isFocused(){return S.current?.isFocused()??false},dispatch(D){S.current?.dispatch(D);},undo(){return S.current?.undo()??false},redo(){return S.current?.redo()??false},setSelection(D,ce){S.current?.setSelection(D,ce);},getLayout(){return q},relayout(){let D=S.current?.getState();D&&vt(D);},scrollToPosition:Ar}),[q,vt,Ar]),useEffect(()=>{let D=S.current?.getState();q&&D&&_t(D);},[q,_t]),useEffect(()=>{L.current&&S.current&&L.current({getDocument:()=>S.current?.getDocument()??null,getState:()=>S.current?.getState()??null,getView:()=>S.current?.getView()??null,focus:()=>{S.current?.focus(),P(true);},blur:()=>{S.current?.blur(),P(false);},isFocused:()=>S.current?.isFocused()??false,dispatch:D=>S.current?.dispatch(D),undo:()=>S.current?.undo()??false,redo:()=>S.current?.redo()??false,setSelection:(D,ce)=>S.current?.setSelection(D,ce),getLayout:()=>q,relayout:()=>{let D=S.current?.getState();D&&vt(D);},scrollToPosition:Ar});},[q,vt]);let Tc=useMemo(()=>{if(!q)return ib+48;let D=q.pages.length;return D*Vn.h+(D-1)*c+48},[q,Vn.h,c]);return jsxs("div",{ref:R,className:`ep-root paged-editor ${A??""}`,style:{...UR,...B},tabIndex:0,onFocus:fc,onBlur:mc,onKeyDown:Sc,onMouseDown:Cc,children:[jsx(fh,{ref:S,document:o,styles:r,widthPx:yt,readOnly:d,onTransaction:lc,onSelectionChange:cc,externalPlugins:m,extensionManager:b,onEditorViewReady:Zn,onKeyDown:_}),jsxs("div",{style:{...qR,minHeight:Tc,transform:u!==1?`scale(${u})`:void 0,transformOrigin:"top center"},children:[jsx("div",{ref:E,className:`paged-editor__pages${k?` paged-editor--hf-editing paged-editor--editing-${k}`:""}`,style:KR,onMouseDown:uc,onClick:pc,"aria-hidden":"true"}),jsx(gh,{selectionRects:I,caretPosition:Y,isFocused:C,pageGap:c,readOnly:d}),jsx(vh,{imageInfo:F,zoom:u,isFocused:C,onResize:gc,onResizeStart:hc,onResizeEnd:bc,onDragMove:xc,onDragStart:yc,onDragEnd:vc}),x&&jsx("div",{className:"paged-editor__plugin-overlays",style:GR,children:x})]})]})}),cb=memo(tE);var Fu=forwardRef(function({documentBuffer:t,document:n,onSave:o$1,onChange:r,onSelectionChange:i,onError:a$1,onFontsLoaded:s,theme:l,showToolbar:d=true,showVariablePanel:c=true,showZoomControl:u=true,showPageNumbers:p=true,enablePageNavigation:f=true,pageNumberPosition:m$1="bottom-center",pageNumberVariant:b="default",showMarginGuides:g=false,marginGuideColor:h,showRuler:x=false,rulerUnit:y$1="inch",initialZoom:k=1,readOnly:T=false,toolbarExtra:A,variablePanelPosition:B="right",variableDescriptions:R,className:E="",style:S,placeholder:N,loadingIndicator:_,showOutline:U=false,showPrintButton:Z=true,printOptions:L,onPrint:H,onCopy:q,onCut:xe,onPaste:ie,externalPlugins:we,onEditorViewReady:M,onRenderedDomContextReady:O,pluginOverlays:C},P){let[I,z]=useState({isLoading:!!t,parseError:null,zoom:k,variableValues:{},isApplyingVariables:false,selectionFormatting:{},currentPage:1,totalPages:1,paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Y,j]=useState(false),[F,V]=useState(false),[G,be]=useState(false),[me,oe]=useState(false),[K,de]=useState(null),[Fe,Ke]=useState(U),Ge=useRef(false);Ge.current=Fe;let[Ye,ze]=useState([]);useEffect(()=>{if(Ke(U),U){let w=Ie.current?.getView();w&&ze(Kr(w.state.doc));}},[U]);let W=lh(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),Te=useMemo(()=>{let w=new zo(Xr());return w.buildSchema(),w.initializeRuntime(),w},[]),Ie=useRef(null),Me=useRef(null),Qe=useRef(null),Be=useRef(null),xt=useRef(null),Gt=useRef(null),je=useRef(null),Yt=useRef(null),_e=useRef(null),[Dt,$n]=useState(0),bn=useRef(W.state);bn.current=W.state;let Ot=useRef({style:"single",size:4,color:{rgb:"000000"}}),Wn=useCallback(w=>{if(Yt.current=w,_e.current&&(_e.current.disconnect(),_e.current=null),!w){$n(0);return}$n(w.offsetHeight);let v=new ResizeObserver(()=>{$n(w.offsetHeight);});v.observe(w),_e.current=v;},[]);useEffect(()=>()=>{_e.current?.disconnect();},[]);let $e=useCallback(()=>K&&Me.current?Me.current.getView():Ie.current?.getView(),[K]),et=useCallback(()=>{K&&Me.current?Me.current.focus():Ie.current?.focus();},[K]),Vn=useCallback(()=>{K&&Me.current?Me.current.undo():Ie.current?.undo();},[K]),sn=useCallback(()=>{K&&Me.current?Me.current.redo():Ie.current?.redo();},[K]),yt=Wa(),zt=Md();useEffect(()=>{if(!t){n&&(W.reset(n),z(v=>({...v,isLoading:false})),m(n).catch(v=>{console.warn("Failed to load document fonts:",v);}));return}z(v=>({...v,isLoading:true,parseError:null})),(async()=>{try{let v=await o(t);if(W.reset(v),z(Q=>({...Q,isLoading:!1,parseError:null})),v.package.document){let Q=ah(v);z(he=>({...he,variableValues:Q}));}m(v).catch(Q=>{console.warn("Failed to load document fonts:",Q);});}catch(v){let Q=v instanceof Error?v.message:"Failed to parse document";z(he=>({...he,isLoading:false,parseError:Q})),a$1?.(v instanceof Error?v:new Error(Q));}})();},[t,n,a$1]),useEffect(()=>{n&&!t&&W.reset(n);},[n,t]),useEffect(()=>{W.state?Qe.current=new y(W.state):Qe.current=null;},[W.state]),useEffect(()=>i$1(()=>{s?.();}),[s]);let vt=useCallback(w=>{if(W.push(w),r?.(w),Ge.current){let v=Ie.current?.getView();v&&ze(Kr(v.state.doc));}},[r,W]),Dr=useCallback(w=>{let v=$e();if(v){let{from:nn,to:ln}=v.state.selection;xt.current={from:nn,to:ln};}let Q=null;v&&(Q=Ue(v.state),Q.isInTable||(Q=null));let he=null;if(v){let nn=v.state.selection,ln=nn.node;ln?.type.name==="image"&&(he={pos:nn.from,wrapType:ln.attrs.wrapType??"inline",displayMode:ln.attrs.displayMode??"inline",cssFloat:ln.attrs.cssFloat??null,transform:ln.attrs.transform??null,alt:ln.attrs.alt??null,borderWidth:ln.attrs.borderWidth??null,borderColor:ln.attrs.borderColor??null,borderStyle:ln.attrs.borderStyle??null});}if(!w){z(nn=>({...nn,selectionFormatting:{},pmTableContext:Q,pmImageContext:he}));return}let{textFormatting:le,paragraphFormatting:pe}=w,fe=le.fontFamily?.ascii||le.fontFamily?.hAnsi,ke=le.color?.rgb?`#${le.color.rgb}`:void 0,We=pe.numPr,St=We?{type:We.numId===1?"bullet":"numbered",level:We.ilvl??0,isInList:true,numId:We.numId}:void 0,At={bold:le.bold,italic:le.italic,underline:!!le.underline,strike:le.strike,superscript:le.vertAlign==="superscript",subscript:le.vertAlign==="subscript",fontFamily:fe,fontSize:le.fontSize,color:ke,highlight:le.highlight,alignment:pe.alignment,lineSpacing:pe.lineSpacing,listState:St,styleId:w.styleId??void 0,indentLeft:pe.indentLeft};z(nn=>({...nn,selectionFormatting:At,paragraphIndentLeft:pe.indentLeft??0,paragraphIndentRight:pe.indentRight??0,paragraphFirstLineIndent:pe.indentFirstLine??0,paragraphHangingIndent:pe.hangingIndent??false,paragraphTabs:pe.tabs??null,pmTableContext:Q,pmImageContext:he})),i?.(w);},[i]),_t=lu({document:W.state,onChange:vt,onSelectionChange:w=>{}});useEffect(()=>{let w=v=>{let he=navigator.platform.toUpperCase().indexOf("MAC")>=0?v.metaKey:v.ctrlKey;if(!he&&!v.shiftKey&&!v.altKey&&(v.key==="Delete"||v.key==="Backspace")){let le=Ie.current?.getView();if(le){let pe=le.state.selection;if("$anchorCell"in pe&&typeof pe.forEachCell=="function"){let ke=Ue(le.state);if(ke.isInTable&&ke.table){let We=0;ke.table.descendants(At=>{(At.type.name==="tableCell"||At.type.name==="tableHeader")&&(We+=1);});let St=0;if(pe.forEachCell(()=>{St+=1;}),We>0&&St>=We){v.preventDefault(),qi(le.state,le.dispatch);return}}}}if(_t.state.tableIndex!==null){v.preventDefault(),_t.handleAction("deleteTable");return}}if(he&&!v.shiftKey&&!v.altKey){if(v.key.toLowerCase()==="f"){v.preventDefault();let le=window.getSelection(),pe=le&&!le.isCollapsed?le.toString():"";yt.openFind(pe);}else if(v.key.toLowerCase()==="h"){v.preventDefault();let le=window.getSelection(),pe=le&&!le.isCollapsed?le.toString():"";yt.openReplace(pe);}else if(v.key.toLowerCase()==="k"){v.preventDefault();let le=Ie.current?.getView();if(le){let pe=Yr(le.state),fe=Gr(le.state);fe?zt.openEdit({url:fe.href,displayText:pe,tooltip:fe.tooltip}):zt.openInsert(pe);}}}};return document.addEventListener("keydown",w),()=>{document.removeEventListener("keydown",w);}},[yt,zt,_t]);let lc=useCallback((w,v)=>{let Q=$e();Q&&(Rs(w,v)(Q.state,Q.dispatch),et());},[$e,et]),cc=useCallback(()=>{let w=$e();w&&(tl(w.state,w.dispatch),et());},[$e,et]),Rn=useCallback(()=>{let w=$e();w&&(Ps(w.state,w.dispatch),et());},[$e,et]),To=useCallback(()=>{Ke(w=>{if(!w){let v=Ie.current?.getView();v&&ze(Kr(v.state.doc));}return !w});},[]),dc=useCallback(w=>{Ie.current?.scrollToPosition(w),Ie.current?.setSelection(w+1),Ie.current?.focus();},[]),Ar=useCallback(()=>{Gt.current?.click();},[]),uc=useCallback(w=>{let v=w.target.files?.[0];if(!v)return;let Q=$e();if(!Q)return;let he=new FileReader;he.onload=()=>{let le=he.result,pe=new Image;pe.onload=()=>{let fe=pe.naturalWidth,ke=pe.naturalHeight,We=612;if(fe>We){let $0=We/fe;fe=We,ke=Math.round(ke*$0);}let St=`rId_img_${Date.now()}`,At=Q.state.schema.nodes.image.create({src:le,alt:v.name,width:fe,height:ke,rId:St,wrapType:"inline",displayMode:"inline"}),{from:nn}=Q.state.selection,ln=Q.state.tr.insert(nn,At);Q.dispatch(ln.scrollIntoView()),et();},pe.src=le;},he.readAsDataURL(v),w.target.value="";},[$e,et]),wi=useCallback(w=>{let v=$e();if(!v||!I.pmImageContext)return;let Q=I.pmImageContext.pos,he=v.state.doc.nodeAt(Q);if(!he||he.type.name!=="image")return;let le="inline",pe=null;switch(w){case "inline":le="inline",pe=null;break;case "square":case "tight":case "through":le="float",pe="left";break;case "topAndBottom":le="block",pe=null;break;case "behind":case "inFront":le="float",pe="none";break;case "wrapLeft":le="float",pe="right",w="square";break;case "wrapRight":le="float",pe="left",w="square";break}let fe=v.state.tr.setNodeMarkup(Q,void 0,{...he.attrs,wrapType:w,displayMode:le,cssFloat:pe});v.dispatch(fe.scrollIntoView()),et();},[$e,et,I.pmImageContext]),ki=useCallback(w=>{let v=$e();if(!v||!I.pmImageContext)return;let Q=I.pmImageContext.pos,he=v.state.doc.nodeAt(Q);if(!he||he.type.name!=="image")return;let le=he.attrs.transform||"",pe=le.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),fe=pe?parseFloat(pe[1]):0,ke=/scaleX\(-1\)/.test(le),We=/scaleY\(-1\)/.test(le);switch(w){case "rotateCW":fe=(fe+90)%360;break;case "rotateCCW":fe=(fe-90+360)%360;break;case "flipH":ke=!ke;break;case "flipV":We=!We;break}let St=[];fe!==0&&St.push(`rotate(${fe}deg)`),ke&&St.push("scaleX(-1)"),We&&St.push("scaleY(-1)");let At=St.length>0?St.join(" "):null,nn=v.state.tr.setNodeMarkup(Q,void 0,{...he.attrs,transform:At});v.dispatch(nn.scrollIntoView()),et();},[$e,et,I.pmImageContext]),pc=useCallback(w=>{let v=$e();if(!v||!I.pmImageContext)return;let Q=I.pmImageContext.pos,he=v.state.doc.nodeAt(Q);if(!he||he.type.name!=="image")return;let le=v.state.tr.setNodeMarkup(Q,void 0,{...he.attrs,position:{horizontal:w.horizontal,vertical:w.vertical},distTop:w.distTop??he.attrs.distTop,distBottom:w.distBottom??he.attrs.distBottom,distLeft:w.distLeft??he.attrs.distLeft,distRight:w.distRight??he.attrs.distRight});v.dispatch(le.scrollIntoView()),et();},[$e,et,I.pmImageContext]),fc=useCallback(()=>{be(true);},[]),mc=useCallback(w=>{let v=$e();if(!v||!I.pmImageContext)return;let Q=I.pmImageContext.pos,he=v.state.doc.nodeAt(Q);if(!he||he.type.name!=="image")return;let le=v.state.tr.setNodeMarkup(Q,void 0,{...he.attrs,alt:w.alt??null,borderWidth:w.borderWidth??null,borderColor:w.borderColor??null,borderStyle:w.borderStyle??null});v.dispatch(le.scrollIntoView()),et();},[$e,et,I.pmImageContext]),gc=useCallback((w,v)=>{if(!W.state?.package)return;let Q={...W.state.package.document,finalSectionProperties:{...W.state.package.document.finalSectionProperties,footnotePr:w,endnotePr:v}};W.push({...W.state,package:{...W.state.package,document:Q}});},[W]),hc=useCallback(w=>{let v=$e();if(v){switch(w){case "addRowAbove":Es(v.state,v.dispatch);break;case "addRowBelow":Is(v.state,v.dispatch);break;case "addColumnLeft":Ls(v.state,v.dispatch);break;case "addColumnRight":Fs(v.state,v.dispatch);break;case "deleteRow":Ms(v.state,v.dispatch);break;case "deleteColumn":Ds(v.state,v.dispatch);break;case "deleteTable":qi(v.state,v.dispatch);break;case "selectTable":As(v.state,v.dispatch);break;case "selectRow":Bs(v.state,v.dispatch);break;case "selectColumn":Ns(v.state,v.dispatch);break;case "mergeCells":Hs(v.state,v.dispatch);break;case "splitCell":Os(v.state,v.dispatch);break;case "borderAll":_s(v.state,v.dispatch,Ot.current);break;case "borderOutside":$s(v.state,v.dispatch,Ot.current);break;case "borderInside":Ws(v.state,v.dispatch,Ot.current);break;case "borderNone":zs(v.state,v.dispatch);break;case "borderTop":$o("top",Ot.current)(v.state,v.dispatch);break;case "borderBottom":$o("bottom",Ot.current)(v.state,v.dispatch);break;case "borderLeft":$o("left",Ot.current)(v.state,v.dispatch);break;case "borderRight":$o("right",Ot.current)(v.state,v.dispatch);break;default:if(typeof w=="object"){if(w.type==="cellFillColor")Js(w.color)(v.state,v.dispatch);else if(w.type==="borderColor"){let Q=w.color.replace(/^#/,"");Ot.current={...Ot.current,color:{rgb:Q}},Qs(w.color)(v.state,v.dispatch);}else if(w.type==="borderWidth")Ot.current={...Ot.current,size:w.size},el(w.size)(v.state,v.dispatch);else if(w.type==="cellBorder")$o(w.side,{style:w.style,size:w.size,color:{rgb:w.color.replace(/^#/,"")}})(v.state,v.dispatch);else if(w.type==="cellVerticalAlign")Vs(w.align)(v.state,v.dispatch);else if(w.type==="cellMargins")Zs(w.margins)(v.state,v.dispatch);else if(w.type==="cellTextDirection")Us(w.direction)(v.state,v.dispatch);else if(w.type==="toggleNoWrap")qs()(v.state,v.dispatch);else if(w.type==="rowHeight")Ks(w.height,w.rule)(v.state,v.dispatch);else if(w.type==="toggleHeaderRow")Gs()(v.state,v.dispatch);else if(w.type==="distributeColumns")Ys()(v.state,v.dispatch);else if(w.type==="autoFitContents")js()(v.state,v.dispatch);else if(w.type==="openTableProperties")j(true);else if(w.type==="tableProperties")Ki(w.props)(v.state,v.dispatch);else if(w.type==="applyTableStyle"){let Q=nh(w.styleId),he=bn.current;if(!Q&&he?.package.styles){let pe=_o(he.package.styles).getStyle(w.styleId);if(pe){if(Q={id:pe.styleId,name:pe.name??pe.styleId},pe.tblPr?.borders){let fe=pe.tblPr.borders;Q.tableBorders={};for(let ke of ["top","bottom","left","right","insideH","insideV"]){let We=fe[ke];We&&(Q.tableBorders[ke]={style:We.style,size:We.size,color:We.color?.rgb?{rgb:We.color.rgb}:void 0});}}if(pe.tblStylePr){Q.conditionals={};for(let fe of pe.tblStylePr){let ke={};if(fe.tcPr?.shading?.fill&&(ke.backgroundColor=`#${fe.tcPr.shading.fill}`),fe.tcPr?.borders){let We={};for(let St of ["top","bottom","left","right"]){let At=fe.tcPr.borders[St];At&&(We[St]={style:At.style,size:At.size,color:At.color?.rgb?{rgb:At.color.rgb}:void 0});}ke.borders=We;}fe.rPr?.bold&&(ke.bold=true),fe.rPr?.color?.rgb&&(ke.color=`#${fe.rPr.color.rgb}`),Q.conditionals[fe.type]=ke;}}Q.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}Q&&Xs({styleId:Q.id,tableBorders:Q.tableBorders,conditionals:Q.conditionals,look:Q.look})(v.state,v.dispatch);}}else _t.handleAction(w);}et();}},[_t,$e,et]),bc=useCallback(w=>{let v=$e();if(!v)return;v.focus();let Q=v===Ie.current?.getView(),{from:he,to:le}=v.state.selection,pe=xt.current;if(Q&&pe&&(he!==pe.from||le!==pe.to))try{let fe=v.state.tr.setSelection(TextSelection.create(v.state.doc,pe.from,pe.to));v.dispatch(fe);}catch(fe){console.warn("Could not restore selection:",fe);}if(w==="bold"){os(v.state,v.dispatch);return}if(w==="italic"){rs(v.state,v.dispatch);return}if(w==="underline"){is(v.state,v.dispatch);return}if(w==="strikethrough"){as(v.state,v.dispatch);return}if(w==="superscript"){ss(v.state,v.dispatch);return}if(w==="subscript"){ls(v.state,v.dispatch);return}if(w==="bulletList"){Ss(v.state,v.dispatch);return}if(w==="numberedList"){Cs(v.state,v.dispatch);return}if(w==="indent"){Ts(v.state,v.dispatch)||bs()(v.state,v.dispatch);return}if(w==="outdent"){ws(v.state,v.dispatch)||xs()(v.state,v.dispatch);return}if(w==="clearFormatting"){zi(v.state,v.dispatch);return}if(w==="insertLink"){let fe=Yr(v.state),ke=Gr(v.state);ke?zt.openEdit({url:ke.href,displayText:fe,tooltip:ke.tooltip}):zt.openInsert(fe);return}if(typeof w=="object")switch(w.type){case "alignment":gs(w.value)(v.state,v.dispatch);break;case "textColor":cs({rgb:w.value.replace("#","")})(v.state,v.dispatch);break;case "highlightColor":{let fe=w.value?id(w.value):"";ds(fe||w.value)(v.state,v.dispatch);break}case "fontSize":us(Nc(w.value))(v.state,v.dispatch);break;case "fontFamily":ps(w.value)(v.state,v.dispatch);break;case "lineSpacing":hs(w.value)(v.state,v.dispatch);break;case "applyStyle":{let fe=bn.current,ke=fe?.package.styles?_o(fe.package.styles):null;if(ke){let We=ke.resolveParagraphStyle(w.value);Ui(w.value,{paragraphFormatting:We.paragraphFormatting,runFormatting:We.runFormatting})(v.state,v.dispatch);}else Ui(w.value)(v.state,v.dispatch);break}}},[$e]),xc=useCallback(w=>{z(v=>({...v,variableValues:w}));},[]),yc=useCallback(async w=>{if(Qe.current){z(v=>({...v,isApplyingVariables:true}));try{let v=Qe.current.setVariables(w).getDocument();vt(v);}catch(v){a$1?.(v instanceof Error?v:new Error("Failed to apply variables"));}finally{z(v=>({...v,isApplyingVariables:false}));}}},[vt,a$1]),vc=useCallback(w=>{z(v=>({...v,zoom:w}));},[]),Sc=useCallback(w=>{let v=$e();if(!v)return;let Q=w.url||"",he=w.tooltip,{empty:le}=v.state.selection;le&&w.displayText?Vi(w.displayText,Q,he)(v.state,v.dispatch):le?w.displayText&&Vi(w.displayText,Q,he)(v.state,v.dispatch):fs(Q,he)(v.state,v.dispatch),zt.close(),et();},[zt,$e,et]),Cc=useCallback(()=>{let w=$e();w&&(ms(w.state,w.dispatch),zt.close(),et());},[zt,$e,et]),Zn=useCallback(w=>v=>{if(!W.state||T)return;let Q={...W.state,package:{...W.state.package,document:{...W.state.package.document,finalSectionProperties:{...W.state.package.document.finalSectionProperties,[w]:v}}}};vt(Q);},[W.state,T,vt]),ua=useMemo(()=>Zn("marginLeft"),[Zn]),Tc=useMemo(()=>Zn("marginRight"),[Zn]),D=useMemo(()=>Zn("marginTop"),[Zn]),ce=useMemo(()=>Zn("marginBottom"),[Zn]),ee=useCallback(w=>{let v=$e();v&&ys(w)(v.state,v.dispatch);},[$e]),te=useCallback(w=>{let v=$e();v&&vs(w)(v.state,v.dispatch);},[$e]),ne=useCallback(w=>{let v=$e();v&&(w<0?Zi(-w,true)(v.state,v.dispatch):Zi(w,false)(v.state,v.dispatch));},[$e]),X=useCallback(w=>{let v=$e();v&&ks(w)(v.state,v.dispatch);},[$e]),J=useCallback(w=>{},[]),re=useCallback(async()=>{if(!Qe.current)return null;try{let w=await Qe.current.toBuffer();return o$1?.(w),w}catch(w){return a$1?.(w instanceof Error?w:new Error("Failed to save document")),null}},[o$1,a$1]),ue=useCallback(w=>{a$1?.(w);},[a$1]),ye=useCallback(()=>{let w=Be.current?.querySelector(".paged-editor__pages");if(!w){window.print(),H?.();return}let v=window.open("","_blank");if(!v){window.print(),H?.();return}let Q=[];for(let le of Array.from(document.styleSheets))try{for(let pe of Array.from(le.cssRules))pe instanceof CSSFontFaceRule&&Q.push(pe.cssText);}catch{}let he=w.cloneNode(true);he.style.cssText="display: block; margin: 0; padding: 0;";for(let le of Array.from(he.querySelectorAll(".layout-page"))){let pe=le;pe.style.boxShadow="none",pe.style.margin="0";}v.document.write(`<!DOCTYPE html>
|
|
22
|
-
<html><head><title>Print</title>
|
|
23
|
-
<style>
|
|
24
|
-
${Q.join(`
|
|
25
|
-
`)}
|
|
26
|
-
* { margin: 0; padding: 0; }
|
|
27
|
-
body { background: white; }
|
|
28
|
-
.layout-page { break-after: page; }
|
|
29
|
-
.layout-page:last-child { break-after: auto; }
|
|
30
|
-
@page { margin: 0; size: auto; }
|
|
31
|
-
</style>
|
|
32
|
-
</head><body>${he.outerHTML}</body></html>`),v.document.close(),v.onload=()=>{v.print(),v.close();},setTimeout(()=>{v.closed||(v.print(),v.close());},1e3),H?.();},[H]),ge=useRef(null),Re=useCallback((w,v)=>{if(!W.state||!w.trim())return ge.current=null,null;let Q=Ni(W.state,w,v),he={matches:Q,totalCount:Q.length,currentIndex:0};return ge.current=he,yt.setMatches(Q,0),Q.length>0&&Be.current&&Zr(Be.current,Q[0]),he},[W.state,yt]),Ne=useCallback(()=>{if(!ge.current||ge.current.matches.length===0)return null;let w=yt.goToNextMatch(),v=ge.current.matches[w];return v&&Be.current&&Zr(Be.current,v),v||null},[yt]),He=useCallback(()=>{if(!ge.current||ge.current.matches.length===0)return null;let w=yt.goToPreviousMatch(),v=ge.current.matches[w];return v&&Be.current&&Zr(Be.current,v),v||null},[yt]),ft=useCallback(w=>{if(!W.state||!ge.current||ge.current.matches.length===0)return false;let v=ge.current.matches[ge.current.currentIndex];if(!v)return false;try{let Q=a(W.state,{type:"replaceText",range:{start:{paragraphIndex:v.paragraphIndex,offset:v.startOffset},end:{paragraphIndex:v.paragraphIndex,offset:v.endOffset}},text:w});return vt(Q),!0}catch(Q){return console.error("Replace failed:",Q),false}},[W.state,vt]),ct=useCallback((w,v,Q)=>{if(!W.state||!w.trim())return 0;let he=Ni(W.state,w,Q);if(he.length===0)return 0;let le=W.state,pe=[...he].sort((fe,ke)=>fe.paragraphIndex!==ke.paragraphIndex?ke.paragraphIndex-fe.paragraphIndex:ke.startOffset-fe.startOffset);for(let fe of pe)try{le=a(le,{type:"replaceText",range:{start:{paragraphIndex:fe.paragraphIndex,offset:fe.startOffset},end:{paragraphIndex:fe.paragraphIndex,offset:fe.endOffset}},text:v});}catch(ke){console.error("Replace failed for match:",fe,ke);}return vt(le),ge.current=null,yt.setMatches([],0),he.length},[W.state,vt,yt]);useImperativeHandle(P,()=>({getAgent:()=>Qe.current,getDocument:()=>W.state,getEditorRef:()=>Ie.current,save:re,setZoom:w=>z(v=>({...v,zoom:w})),getZoom:()=>I.zoom,focus:()=>{Ie.current?.focus();},getCurrentPage:()=>I.currentPage,getTotalPages:()=>I.totalPages,scrollToPage:w=>{},openPrintPreview:ye,print:ye}),[W.state,I.zoom,I.currentPage,I.totalPages,re,ye]);let Lt=useMemo(()=>W.state?eu(W.state):[],[W.state]),{headerContent:ht,footerContent:jt}=useMemo(()=>{if(!W.state?.package)return {headerContent:null,footerContent:null};let w=W.state.package,v=w.document?.finalSectionProperties,Q=w.headers,he=w.footers,le=null,pe=null;if(Q&&v?.headerReferences){let fe=v.headerReferences.find(ke=>ke.type==="default");fe?.rId&&(le=Q.get(fe.rId)??null);}if(he&&v?.footerReferences){let fe=v.footerReferences.find(ke=>ke.type==="default");fe?.rId&&(pe=he.get(fe.rId)??null);}return {headerContent:le,footerContent:pe}},[W.state]),xn=useCallback(w=>{if(w==="header"?ht:jt){de(w);return}if(!W.state?.package)return;let Q=W.state.package,he=Q.document?.finalSectionProperties;if(!he)return;let le=`rId_new_${w}`,pe={type:w==="header"?"header":"footer",hdrFtrType:"default",content:[{type:"paragraph",content:[]}]},fe=w==="header"?"headers":"footers",ke=new Map(Q[fe]??[]);ke.set(le,pe);let We=w==="header"?"headerReferences":"footerReferences",St=he[We]??[],At={type:"default",rId:le},nn={...W.state,package:{...Q,[fe]:ke,document:Q.document?{...Q.document,finalSectionProperties:{...he,[We]:[...St,At]}}:Q.document}};W.push(nn),de(w);},[ht,jt,W]),lo=useCallback(w=>{if(!K||!W.state?.package){de(null);return}let v=W.state.package,Q=v.document?.finalSectionProperties,le=(K==="header"?Q?.headerReferences:Q?.footerReferences)?.find(ke=>ke.type==="default"),pe=K==="header"?"headers":"footers",fe=v[pe];if(le?.rId&&fe){let ke=fe.get(le.rId),We={type:K,hdrFtrType:"default",...ke,content:w},St=new Map(fe);St.set(le.rId,We);let At={...W.state,package:{...v,[pe]:St}};W.push(At);}de(null);},[K,W]),Pi=useCallback(()=>{if(!K)return;let w=Me.current?.getView();if(w){let v=Wi(w.state.doc);lo(v);}else de(null);},[K,lo]),pa=useCallback(()=>{if(!K||!W.state?.package){de(null);return}let w=W.state.package,v=w.document?.finalSectionProperties,Q=K==="header"?"headerReferences":"footerReferences",he=K==="header"?"headers":"footers",le=v?.[Q],pe=le?.find(fe=>fe.type==="default");if(pe?.rId){let fe=new Map(w[he]??[]);fe.delete(pe.rId);let ke=(le??[]).filter(St=>St.rId!==pe.rId),We={...W.state,package:{...w,[he]:fe,document:w.document?{...w.document,finalSectionProperties:{...v,[Q]:ke}}:w.document}};W.push(We);}de(null);},[K,W]),wo=useCallback(w=>{let v=Be.current?.querySelector(".paged-editor__pages");if(!v)return null;let Q=w==="header"?".layout-page-header":".layout-page-footer";return v.querySelector(Q)},[]),Un={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...S},qn={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:B==="left"?"row-reverse":"row"},rr={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"},ir={width:"300px",borderLeft:B==="right"?"1px solid var(--doc-border)":void 0,borderRight:B==="left"?"1px solid var(--doc-border)":void 0,overflow:"auto",backgroundColor:"white"};return I.isLoading?jsx("div",{className:`ep-root docx-editor docx-editor-loading ${E}`,style:Un,"data-testid":"docx-editor",children:_||jsx(oh,{})}):I.parseError?jsx("div",{className:`ep-root docx-editor docx-editor-error ${E}`,style:Un,"data-testid":"docx-editor",children:jsx(ih,{message:I.parseError})}):W.state?jsx(cd,{children:jsx(Bi,{onError:ue,children:jsxs("div",{ref:Be,className:`ep-root docx-editor ${E}`,style:Un,"data-testid":"docx-editor",children:[jsxs("div",{style:qn,children:[jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[jsxs("div",{style:rr,children:[d&&!T&&jsxs("div",{ref:Wn,className:"sticky top-0 z-50 flex flex-col gap-0 bg-white shadow-sm",children:[jsx(ad,{currentFormatting:I.selectionFormatting,onFormat:bc,onUndo:Vn,onRedo:sn,canUndo:true,canRedo:true,disabled:T,documentStyles:W.state?.package.styles?.styles,theme:W.state?.package.theme||l,showPrintButton:Z,onPrint:ye,showZoomControl:u,zoom:I.zoom,onZoomChange:vc,onRefocusEditor:et,onInsertTable:lc,showTableInsert:true,onInsertImage:Ar,onInsertPageBreak:cc,onInsertTOC:Rn,imageContext:I.pmImageContext,onImageWrapType:wi,onImageTransform:ki,onOpenImageProperties:fc,tableContext:I.pmTableContext,onTableAction:hc,children:A}),x&&jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",children:jsx(bd,{sectionProps:W.state?.package.document?.finalSectionProperties,zoom:I.zoom,unit:y$1,editable:!T,onLeftMarginChange:ua,onRightMarginChange:Tc,indentLeft:I.paragraphIndentLeft,indentRight:I.paragraphIndentRight,onIndentLeftChange:ee,onIndentRightChange:te,showFirstLineIndent:true,firstLineIndent:I.paragraphFirstLineIndent,hangingIndent:I.paragraphHangingIndent,onFirstLineIndentChange:ne,tabStops:I.paragraphTabs,onTabStopRemove:X})})]}),x&&!T&&jsx("div",{style:{position:"absolute",left:0,top:0,paddingTop:20,zIndex:10},children:jsx(Mf,{sectionProps:W.state?.package.document?.finalSectionProperties,zoom:I.zoom,unit:y$1,editable:!T,onTopMarginChange:D,onBottomMarginChange:ce})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxs("div",{ref:je,style:{position:"relative",flex:1,minWidth:0},onMouseDown:w=>{w.target===w.currentTarget&&(w.preventDefault(),Ie.current?.focus());},children:[jsx(cb,{ref:Ie,document:W.state,styles:W.state?.package.styles,theme:W.state?.package.theme||l,sectionProperties:W.state?.package.document?.finalSectionProperties,headerContent:ht,footerContent:jt,onHeaderFooterDoubleClick:xn,hfEditMode:K,onBodyClick:Pi,zoom:I.zoom,readOnly:T,extensionManager:Te,onDocumentChange:vt,onSelectionChange:(w,v)=>{let Q=Ie.current?.getView();if(Q){let he=Jr(Q.state);Dr(he);}else Dr(null);},externalPlugins:we,onReady:w=>{M?.(w.getView());},onRenderedDomContextReady:O,pluginOverlays:C}),p&&I.totalPages>0&&(f?jsx(fd,{currentPage:I.currentPage,totalPages:I.totalPages,onNavigate:J,position:m$1,variant:b,floating:true}):jsx(dd,{currentPage:I.currentPage,totalPages:I.totalPages,position:m$1,variant:b,floating:true})),K&&(K==="header"?ht:jt)&&(()=>{let w=wo(K),v=je.current;return !w||!v?null:jsx(jg,{ref:Me,headerFooter:K==="header"?ht:jt,position:K,styles:W.state?.package.styles,targetElement:w,parentElement:v,onSave:lo,onClose:()=>de(null),onSelectionChange:Dr,onRemove:pa})})()]})})]}),Fe&&jsx(gf,{headings:Ye,onHeadingClick:dc,onClose:()=>Ke(false),topOffset:Dt}),!Fe&&jsx("button",{className:"docx-outline-nav",onClick:To,onMouseDown:w=>w.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:Dt+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsx(se,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]}),c&&!T&&Lt.length>0&&jsx("div",{style:ir,children:jsx(ld,{variables:Lt,values:I.variableValues,onValuesChange:xc,onApply:yc,isApplying:I.isApplyingVariables,descriptions:R,disabled:T})})]}),jsx(Rd,{isOpen:yt.state.isOpen,onClose:yt.close,onFind:Re,onFindNext:Ne,onFindPrevious:He,onReplace:ft,onReplaceAll:ct,initialSearchText:yt.state.searchText,replaceMode:yt.state.replaceMode,currentResult:ge.current}),jsx(Id,{isOpen:zt.state.isOpen,onClose:zt.close,onSubmit:Sc,onRemove:zt.state.isEditing?Cc:void 0,initialData:zt.state.initialData,selectedText:zt.state.selectedText,isEditing:zt.state.isEditing}),jsx(em,{isOpen:Y,onClose:()=>j(false),onApply:w=>{let v=$e();v&&Ki(w)(v.state,v.dispatch);},currentProps:I.pmTableContext?.table?.attrs}),jsx(om,{isOpen:F,onClose:()=>V(false),onApply:pc}),jsx(lm,{isOpen:G,onClose:()=>be(false),onApply:mc,currentData:I.pmImageContext?{alt:I.pmImageContext.alt??void 0,borderWidth:I.pmImageContext.borderWidth??void 0,borderColor:I.pmImageContext.borderColor??void 0,borderStyle:I.pmImageContext.borderStyle??void 0}:void 0}),jsx(th,{isOpen:me,onClose:()=>oe(false),onApply:gc,footnotePr:W.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:W.state?.package.document?.finalSectionProperties?.endnotePr}),jsx("input",{ref:Gt,type:"file",accept:"image/*",style:{display:"none"},onChange:uc})]})})}):jsx("div",{className:`ep-root docx-editor docx-editor-empty ${E}`,style:Un,"data-testid":"docx-editor",children:N||jsx(rh,{})})});function iE(e,t,n={}){return new Promise((o,r)=>{let i=cn__default.createRef(),a=null;try{a=createRoot(t);}catch(c){r(c);return}let s={save:()=>i.current?.save()??Promise.resolve(null),getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:c=>i.current?.setZoom(c),destroy:()=>{a?.unmount(),a=null;}},l=false,d=cn__default.createElement(Fu,{...n,documentBuffer:e,onError:c=>{n.onError?.(c),l||(l=true,r(c));},onChange:c=>{n.onChange?.(c),l||(l=true,o(s));},ref:i});a.render(d);})}var aE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 4v4M8 10v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),sE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M13 3L3 13M3 3h4v4M13 13h-4v-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),lE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),cE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 4h10M3 8h7M3 12h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),dE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 3h6M5 3v6M3 5c0 2 1 4 2 4s2-2 2-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M9 7l3 6M15 7l-3 6M10 11h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),uE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 6c0-1.1.9-2 2-2s2 .9 2 2c0 1.5-2 1.5-2 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"8",cy:"12",r:"0.5",fill:"currentColor"})]}),pE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M4 12l3-8 3 8M5 10h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M12 6l2 2-2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),fE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 7h4M6 9h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),mE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"5",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 9c.5.5 1 1 2 1s1.5-.5 2-1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"6",cy:"7",r:"0.5",fill:"currentColor"}),jsx("circle",{cx:"10",cy:"7",r:"0.5",fill:"currentColor"})]}),gE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M12 4L4 12M4 4l8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function hE(e){switch(e){case "askAI":return jsx(aE,{});case "rewrite":return jsx(sE,{});case "expand":return jsx(lE,{});case "summarize":return jsx(cE,{});case "translate":return jsx(dE,{});case "explain":return jsx(uE,{});case "fixGrammar":return jsx(pE,{});case "makeFormal":return jsx(fE,{});case "makeCasual":return jsx(mE,{});case "custom":return jsx(gE,{});default:return null}}var bE=({action:e,onClick:t,isHighlighted:n,onMouseEnter:o})=>{let r=N(e),i=O(e),a=hE(e);return jsxs("button",{type:"button",className:`docx-context-menu-item ${n?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:o,title:i,role:"menuitem",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",border:"none",background:n?"var(--doc-primary-light)":"transparent",cursor:"pointer",fontSize:"13px",color:"var(--doc-text)",textAlign:"left"},children:[jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)"},children:a}),jsx("span",{children:r})]})},xE=({isOpen:e,onSubmit:t,onClose:n,selectedText:o})=>{let[r,i]=useState(""),a=useRef(null);useEffect(()=>{e&&a.current&&a.current.focus();},[e]);let s=d=>{d.preventDefault(),r.trim()&&(t(r.trim()),i(""));},l=d=>{d.key==="Escape"&&n();};return e?jsx("div",{className:"docx-custom-prompt-dialog",style:{position:"absolute",top:"100%",left:0,right:0,padding:"8px",background:"white",borderTop:"1px solid var(--doc-border)"},children:jsxs("form",{onSubmit:s,children:[jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:['Selected: "',o.slice(0,50),o.length>50?"...":"",'"']}),jsx("input",{ref:a,type:"text",value:r,onChange:d=>i(d.target.value),onKeyDown:l,placeholder:"Enter custom prompt...",style:{width:"100%",padding:"8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"13px"}}),jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px",justifyContent:"flex-end"},children:[jsx("button",{type:"button",onClick:n,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px"},children:"Cancel"}),jsx("button",{type:"submit",disabled:!r.trim(),style:{padding:"6px 12px",border:"none",borderRadius:"4px",background:r.trim()?"var(--doc-primary)":"var(--doc-border)",color:r.trim()?"white":"var(--doc-text-placeholder)",cursor:r.trim()?"pointer":"not-allowed",fontSize:"12px"},children:"Send"})]})]})}):null},yE=({isOpen:e,position:t,selectedText:n,selectionContext:o,onAction:r,onClose:i,actions:a=P,showCustomPrompt:s=true,className:l=""})=>{let d=useRef(null),[c,u]=useState(0),[p,f]=useState(false),m=s?[...a,"custom"]:a;useEffect(()=>{if(!e)return;let x=y=>{d.current&&!d.current.contains(y.target)&&i();};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[e,i]),useEffect(()=>{if(!e)return;let x=y=>{switch(y.key){case "Escape":p?f(false):i();break;case "ArrowDown":y.preventDefault(),u(T=>(T+1)%m.length);break;case "ArrowUp":y.preventDefault(),u(T=>(T-1+m.length)%m.length);break;case "Enter":y.preventDefault();let k=m[c];k==="custom"?f(true):(r(k),i());break}};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[e,c,m,r,i,p]),useEffect(()=>{e&&(u(0),f(false));},[e]);let b=useCallback(()=>{let y=m.length*36+16,k=t.x,T=t.y;return typeof window<"u"&&(k+200>window.innerWidth&&(k=window.innerWidth-200-10),T+y>window.innerHeight&&(T=window.innerHeight-y-10),k<10&&(k=10),T<10&&(T=10)),{position:"fixed",top:T,left:k,minWidth:200,background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.15)",zIndex:1e4,padding:"4px 0",overflow:"hidden"}},[t,m.length]),g=x=>{x==="custom"?f(true):(r(x),i());},h=x=>{r("custom",x),i();};return !e||!n?null:jsxs("div",{ref:d,className:`docx-context-menu ${l}`,style:b(),role:"menu","aria-label":"AI actions menu",children:[jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:"11px",color:"var(--doc-text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:['"',n.slice(0,30),n.length>30?"...":"",'"']}),jsx("div",{role:"group",children:m.map((x,y)=>jsx(bE,{action:x,onClick:()=>g(x),isHighlighted:y===c,onMouseEnter:()=>u(y)},x))}),s&&jsx(xE,{isOpen:p,onSubmit:h,onClose:()=>f(false),selectedText:n})]})};function vE(){let[e,t]=useState(false),[n,o]=useState({x:0,y:0}),[r,i]=useState(""),[a,s]=useState(),l=useCallback((c,u,p)=>{c.preventDefault(),o({x:c.clientX,y:c.clientY}),i(u),s(p),t(true);},[]),d=useCallback(()=>{t(false);},[]);return {isOpen:e,position:n,selectedText:r,selectionContext:a,openMenu:l,closeMenu:d}}function SE(e){return {rewrite:"Ctrl+Shift+R",summarize:"Ctrl+Shift+S",translate:"Ctrl+Shift+T",fixGrammar:"Ctrl+Shift+G"}[e]}function CE(e,t,n){return !(!t||t.trim().length===0)}function TE(){return [...P]}function wE(){return ["askAI","rewrite","expand","summarize","translate","explain","fixGrammar","makeFormal","makeCasual","custom"]}var kE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M3 8l4 4 6-8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),fb=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),PE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 8a6 6 0 0111.318-2.828M14 8a6 6 0 01-11.318 2.828",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("path",{d:"M13 2v4h-4M3 14v-4h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),RE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M11 2l3 3-9 9H2v-3l9-9z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),EE=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{animation:"spin 1s linear infinite"},children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"var(--doc-border)",strokeWidth:"2",fill:"none"}),jsx("path",{d:"M10 2a8 8 0 018 8",stroke:"var(--doc-primary)",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),jsx("style",{children:`
|
|
33
|
-
@keyframes spin {
|
|
34
|
-
from { transform: rotate(0deg); }
|
|
35
|
-
to { transform: rotate(360deg); }
|
|
36
|
-
}
|
|
37
|
-
`})]});function IE(e,t){let n=[],o=e.split(/(\s+)/),r=t.split(/(\s+)/),i=0,a=0;for(;i<o.length||a<r.length;){if(i>=o.length){n.push({type:"added",text:r.slice(a).join("")});break}if(a>=r.length){n.push({type:"removed",text:o.slice(i).join("")});break}if(o[i]===r[a])n.push({type:"same",text:o[i]}),i++,a++;else {let l=r.indexOf(o[i],a),d=o.indexOf(r[a],i);l===-1&&d===-1?(n.push({type:"removed",text:o[i]}),n.push({type:"added",text:r[a]}),i++,a++):d!==-1&&(l===-1||d-i<=l-a)?(n.push({type:"added",text:r[a]}),a++):(n.push({type:"removed",text:o[i]}),i++);}}let s=[];for(let l of n)s.length>0&&s[s.length-1].type===l.type?s[s.length-1].text+=l.text:s.push(l);return s}var ME=({original:e,modified:t})=>{let n=IE(e,t);return jsx("div",{className:"docx-response-diff",style:{lineHeight:1.6,fontSize:"14px"},children:n.map((o,r)=>{let i={};switch(o.type){case "removed":i={textDecoration:"line-through",color:"#d32f2f",backgroundColor:"#ffebee"};break;case "added":i={color:"#2e7d32",backgroundColor:"#e8f5e9"};break;}return jsx("span",{style:i,children:o.text},r)})})},LE=({originalText:e,response:t,action:n,isLoading:o,error:r,onAccept:i,onReject:a,onRetry:s,allowEdit:l=true,showDiff:d=true,className:c="",position:u})=>{let[p,f]=useState(false),[m,b]=useState(""),g=useRef(null),h=useRef(null),x=t?.newText||"";useEffect(()=>{x&&b(x);},[x]),useEffect(()=>{p&&g.current&&(g.current.focus(),g.current.select());},[p]),useEffect(()=>{let B=R=>{R.key==="Escape"?p?(f(false),b(x)):a():R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),y());};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[p,x,a]);let y=useCallback(()=>{i(p?m:x);},[p,m,x,i]),k=useCallback(()=>{f(true);},[]),T=useCallback(()=>{f(false),b(x);},[x]),A={position:u?"fixed":"relative",...u&&{left:u.x,top:u.y},width:"400px",maxWidth:"90vw",maxHeight:"80vh",background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column"};return o?jsx("div",{ref:h,className:`docx-response-preview docx-response-preview-loading ${c}`,style:A,children:jsxs("div",{style:{padding:"24px",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[jsx(EE,{}),jsxs("div",{style:{color:"var(--doc-text-muted)",fontSize:"14px"},children:[N(n),"..."]})]})}):r?jsx("div",{ref:h,className:`docx-response-preview docx-response-preview-error ${c}`,style:A,children:jsxs("div",{style:{padding:"16px"},children:[jsx("div",{style:{padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",color:"var(--doc-error)",fontSize:"13px",marginBottom:"16px"},children:r}),jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s&&jsxs("button",{type:"button",onClick:s,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"13px"},children:[jsx(PE,{}),"Retry"]}),jsx("button",{type:"button",onClick:a,style:{padding:"8px 16px",border:"none",borderRadius:"4px",background:"var(--doc-border)",cursor:"pointer",fontSize:"13px"},children:"Close"})]})]})}):!t||!x?null:jsxs("div",{ref:h,className:`docx-response-preview ${c}`,style:A,children:[jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--doc-text)"},children:[N(n)," Result"]}),jsx("button",{type:"button",onClick:a,style:{display:"flex",padding:"4px",border:"none",background:"transparent",cursor:"pointer",color:"var(--doc-text-muted)"},title:"Close (Esc)",children:jsx(fb,{})})]}),jsxs("div",{style:{padding:"16px",overflowY:"auto",flex:1},children:[p?jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:"Edit the result before accepting:"}),jsx("textarea",{ref:g,value:m,onChange:B=>b(B.target.value),style:{width:"100%",minHeight:"120px",padding:"12px",border:"1px solid var(--doc-primary)",borderRadius:"4px",fontSize:"14px",lineHeight:1.6,resize:"vertical",fontFamily:"inherit"}})]}):d?jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:"Changes:"}),jsx(ME,{original:e,modified:x})]}):jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:"Original:"}),jsx("div",{style:{padding:"8px 12px",background:"var(--doc-bg-subtle)",borderRadius:"4px",marginBottom:"16px",textDecoration:"line-through",color:"var(--doc-text-placeholder)",fontSize:"13px"},children:e}),jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:"New:"}),jsx("div",{style:{padding:"8px 12px",background:"#e8f5e9",borderRadius:"4px",color:"#2e7d32",fontSize:"13px"},children:x})]}),t.warnings&&t.warnings.length>0&&jsx("div",{style:{marginTop:"16px",padding:"8px 12px",background:"var(--doc-warning-bg)",borderRadius:"4px",fontSize:"12px",color:"var(--doc-warning)"},children:t.warnings.map((B,R)=>jsx("div",{children:B},R))})]}),jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("div",{children:[l&&!p&&jsxs("button",{type:"button",onClick:k,style:{display:"flex",alignItems:"center",gap:"4px",padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px",color:"var(--doc-text-muted)"},children:[jsx(RE,{}),"Edit"]}),p&&jsx("button",{type:"button",onClick:T,style:{padding:"6px 12px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"12px",color:"var(--doc-text-muted)"},children:"Cancel Edit"})]}),jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsxs("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",background:"white",cursor:"pointer",fontSize:"13px",color:"var(--doc-text-muted)"},children:[jsx(fb,{}),"Reject"]}),jsxs("button",{type:"button",onClick:y,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",border:"none",borderRadius:"4px",background:"var(--doc-primary)",cursor:"pointer",fontSize:"13px",color:"white"},children:[jsx(kE,{}),"Accept"]})]})]})]})};function FE(){let[e,t]=useState({isVisible:false,originalText:"",response:null,action:"rewrite",isLoading:false}),n=useCallback((a,s,l)=>{t({isVisible:true,originalText:a,response:null,action:s,isLoading:true,position:l});},[]),o=useCallback(a=>{t(s=>({...s,response:a,isLoading:false}));},[]),r=useCallback(a=>{t(s=>({...s,error:a,isLoading:false}));},[]),i=useCallback(()=>{t(a=>({...a,isVisible:false}));},[]);return {state:e,showPreview:n,setResponse:o,setError:r,hidePreview:i}}function DE(e,t){return {success:true,newText:e,warnings:t}}function AE(e){return {success:false,error:e}}var mb=[{action:"cut",label:"Cut",shortcut:"Ctrl+X"},{action:"copy",label:"Copy",shortcut:"Ctrl+C"},{action:"paste",label:"Paste",shortcut:"Ctrl+V"},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:"Ctrl+Shift+V",dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:true},{action:"selectAll",label:"Select All",shortcut:"Ctrl+A"}],NE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"4",cy:"12",r:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("circle",{cx:"12",cy:"12",r:"2",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M5.5 10.5L10.5 3M10.5 10.5L5.5 3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),HE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"5",y:"5",width:"8",height:"9",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M11 5V3a1 1 0 00-1-1H4a1 1 0 00-1 1v8a1 1 0 001 1h2",stroke:"currentColor",strokeWidth:"1.5"})]}),OE=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"3",y:"3",width:"10",height:"11",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 3V2a1 1 0 011-1h2a1 1 0 011 1v1",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M6 8h4M6 11h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),zE=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),_E=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"2 2"}),jsx("rect",{x:"4",y:"4",width:"8",height:"8",fill:"currentColor",opacity:"0.3"})]});function $E(e){switch(e){case "cut":return jsx(NE,{});case "copy":return jsx(HE,{});case "paste":case "pasteAsPlainText":return jsx(OE,{});case "delete":return jsx(zE,{});case "selectAll":return jsx(_E,{});default:return null}}var WE=({item:e,onClick:t,isHighlighted:n,onMouseEnter:o})=>e.action==="separator"?jsx("div",{className:"docx-text-context-menu-separator",style:{height:"1px",backgroundColor:"var(--doc-border)",margin:"4px 12px"}}):jsxs(Fragment$1,{children:[jsxs("button",{type:"button",className:`docx-text-context-menu-item ${n?"docx-text-context-menu-item-highlighted":""} ${e.disabled?"docx-text-context-menu-item-disabled":""}`,onClick:t,onMouseEnter:o,disabled:e.disabled,role:"menuitem","aria-disabled":e.disabled,style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:n&&!e.disabled?"var(--doc-primary-light)":"transparent",cursor:e.disabled?"not-allowed":"pointer",fontSize:"13px",color:e.disabled?"var(--doc-text-subtle)":"var(--doc-text)",textAlign:"left",opacity:e.disabled?.6:1},children:[jsx("span",{style:{display:"flex",color:e.disabled?"var(--doc-border)":"var(--doc-text-muted)"},children:$E(e.action)}),jsx("span",{style:{flex:1},children:e.label}),e.shortcut&&jsx("span",{style:{fontSize:"11px",color:"var(--doc-text-subtle)",fontFamily:"monospace"},children:e.shortcut})]}),e.dividerAfter&&jsx("div",{className:"docx-text-context-menu-separator",style:{height:"1px",backgroundColor:"var(--doc-border)",margin:"4px 12px"}})]}),VE=({isOpen:e,position:t,hasSelection:n,isEditable:o,hasClipboardContent:r=true,onAction:i,onClose:a,items:s,className:l=""})=>{let d=useRef(null),[c,u]=useState(0),p=(s||mb).map(g=>{let h=(()=>{if(g.disabled!==void 0)return g.disabled;switch(g.action){case "cut":case "copy":case "delete":return !n;case "paste":case "pasteAsPlainText":return !o||!r;default:return false}})();return {...g,disabled:h}}),f=p.filter(g=>g.action!=="separator");useEffect(()=>{if(!e)return;let g=x=>{d.current&&!d.current.contains(x.target)&&a();},h=setTimeout(()=>{document.addEventListener("mousedown",g);},0);return ()=>{clearTimeout(h),document.removeEventListener("mousedown",g);}},[e,a]),useEffect(()=>{if(!e)return;let g=h=>{switch(h.key){case "Escape":h.preventDefault(),a();break;case "ArrowDown":h.preventDefault(),u(y=>{let k=(y+1)%f.length;for(;f[k]?.disabled&&k!==y;)k=(k+1)%f.length;return k});break;case "ArrowUp":h.preventDefault(),u(y=>{let k=(y-1+f.length)%f.length;for(;f[k]?.disabled&&k!==y;)k=(k-1+f.length)%f.length;return k});break;case "Enter":h.preventDefault();let x=f[c];x&&!x.disabled&&(i(x.action),a());break}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,c,f,i,a]),useEffect(()=>{e&&u(0);},[e]);let m=useCallback(()=>{let h=p.length*36+16,x=t.x,y=t.y;return typeof window<"u"&&(x+220>window.innerWidth&&(x=window.innerWidth-220-10),y+h>window.innerHeight&&(y=window.innerHeight-h-10),x<10&&(x=10),y<10&&(y=10)),{position:"fixed",top:y,left:x,minWidth:220,background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.15)",zIndex:1e4,padding:"4px 0",overflow:"hidden"}},[t,p.length]),b=g=>{g.disabled||(i(g.action),a());};return e?jsx("div",{ref:d,className:`docx-text-context-menu ${l}`,style:m(),role:"menu","aria-label":"Text editing menu",children:p.map((g,h)=>{let x=f.findIndex(y=>y===g);return jsx(WE,{item:g,onClick:()=>b(g),isHighlighted:x===c,onMouseEnter:()=>{x>=0&&!g.disabled&&u(x);}},`${g.action}-${h}`)})}):null};function ZE(e={}){let{enabled:t=true,isEditable:n=true,containerRef:o,onAction:r}=e,[i,a]=useState(false),[s,l]=useState({x:0,y:0}),[d,c]=useState(false),u=useCallback(()=>{let g=window.getSelection(),h=g&&!g.isCollapsed&&g.toString().length>0;return c(!!h),!!h},[]),p=useCallback(g=>{t&&(g.preventDefault(),g.stopPropagation(),u(),l({x:g.clientX,y:g.clientY}),a(true));},[t,u]),f=useCallback(()=>{a(false);},[]),m=useCallback(g=>{switch(f(),g){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":document.execCommand("paste");break;case "pasteAsPlainText":navigator.clipboard.readText?.().then(h=>{document.execCommand("insertText",false,h);}).catch(()=>{document.execCommand("paste");});break;case "delete":document.execCommand("delete");break;case "selectAll":document.execCommand("selectAll");break}r?.(g);},[f,r]),b=useCallback(g=>{p(g);},[p]);return useEffect(()=>{if(!i)return;let g=h=>{h.key==="Escape"&&f();};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i,f]),{isOpen:i,position:s,hasSelection:d,openMenu:p,closeMenu:f,handleAction:m,onContextMenu:b}}function UE(e){return {cut:"Cut",copy:"Copy",paste:"Paste",pasteAsPlainText:"Paste as Plain Text",selectAll:"Select All",delete:"Delete",separator:""}[e]}function qE(e){return {cut:"Ctrl+X",copy:"Ctrl+C",paste:"Ctrl+V",pasteAsPlainText:"Ctrl+Shift+V",selectAll:"Ctrl+A",delete:"Del",separator:""}[e]}function KE(){return [...mb]}function GE(e,t,n){switch(e){case "cut":case "copy":case "delete":return t;case "paste":case "pasteAsPlainText":return n;case "selectAll":return true;default:return true}}var jE={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function XE({onPrint:e,disabled:t=false,label:n="Print",className:o="",style:r,showIcon:i=true,compact:a=false}){let s={display:"flex",alignItems:"center",gap:a?"4px":"6px",padding:a?"4px 8px":"6px 12px",fontSize:a?"13px":"14px",backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:"4px",cursor:t?"not-allowed":"pointer",color:t?"var(--doc-text-muted)":"var(--doc-text)",opacity:t?.6:1,transition:"background-color 0.15s, border-color 0.15s",...r};return jsxs("button",{className:`docx-print-button ${o}`.trim(),style:s,onClick:e,disabled:t,"aria-label":n,title:n,children:[i&&jsx(QE,{size:a?14:16}),!a&&jsx("span",{children:n})]})}function JE(){return jsx("style",{children:`
|
|
38
|
-
@media print {
|
|
39
|
-
/* Hide everything except print content */
|
|
40
|
-
body * {
|
|
41
|
-
visibility: hidden;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.docx-print-pages,
|
|
45
|
-
.docx-print-pages * {
|
|
46
|
-
visibility: visible;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.docx-print-pages {
|
|
50
|
-
position: absolute;
|
|
51
|
-
left: 0;
|
|
52
|
-
top: 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* Remove shadows and margins in print */
|
|
56
|
-
.docx-print-page {
|
|
57
|
-
box-shadow: none !important;
|
|
58
|
-
margin: 0 !important;
|
|
59
|
-
page-break-after: always;
|
|
60
|
-
page-break-inside: avoid;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* Ensure images print */
|
|
64
|
-
img {
|
|
65
|
-
max-width: 100%;
|
|
66
|
-
page-break-inside: avoid;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* Ensure tables don't break badly */
|
|
70
|
-
table {
|
|
71
|
-
page-break-inside: avoid;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
tr {
|
|
75
|
-
page-break-inside: avoid;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/* Keep headings with content */
|
|
79
|
-
h1, h2, h3, h4, h5, h6 {
|
|
80
|
-
page-break-after: avoid;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/* Avoid orphan lines */
|
|
84
|
-
p {
|
|
85
|
-
orphans: 3;
|
|
86
|
-
widows: 3;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@page {
|
|
91
|
-
margin: 0;
|
|
92
|
-
size: auto;
|
|
93
|
-
}
|
|
94
|
-
`})}function QE({size:e=18}){return jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function eI(){window.print();}function tI(e="Document",t){let n=window.open("","_blank");return n?(n.document.write(`
|
|
95
|
-
<!DOCTYPE html>
|
|
96
|
-
<html>
|
|
97
|
-
<head>
|
|
98
|
-
<title>${e}</title>
|
|
99
|
-
<style>
|
|
100
|
-
@media print {
|
|
101
|
-
body {
|
|
102
|
-
margin: 0;
|
|
103
|
-
padding: 0;
|
|
104
|
-
}
|
|
105
|
-
@page {
|
|
106
|
-
margin: 0;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
</style>
|
|
110
|
-
</head>
|
|
111
|
-
<body>
|
|
112
|
-
${t}
|
|
113
|
-
</body>
|
|
114
|
-
</html>
|
|
115
|
-
`),n.document.close(),n):null}function nI(){return {...jE}}function oI(e,t){if(!e||!e.trim())return null;let n=e.trim();if(/^\d+$/.test(n)){let r=parseInt(n,10);return r>=1&&r<=t?{start:r,end:r}:null}let o=n.match(/^(\d+)-(\d+)$/);if(o){let r=parseInt(o[1],10),i=parseInt(o[2],10);return r>=1&&i<=t&&r<=i?{start:r,end:i}:null}return null}function rI(e,t){return e?e.start===e.end?`Page ${e.start}`:`Pages ${e.start}-${e.end}`:`All (${t} pages)`}function iI(){return typeof window<"u"&&typeof window.print=="function"}function aI({onAction:e,disabled:t=false,canMerge:n=false,canSplit:o=false}){let r=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),i=useCallback(()=>{n&&e("mergeCells");},[e,n]),a=useCallback(()=>{o&&e("splitCell");},[e,o]),s=jsx(wt,{content:"Merge cells",children:jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!n)&&"opacity-30 cursor-not-allowed"),onMouseDown:r,onClick:i,disabled:t||!n,"aria-label":"Merge cells","data-testid":"toolbar-table-merge",children:jsx(se,{name:"call_merge",size:20})})}),l=jsx(wt,{content:"Split cell",children:jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!o)&&"opacity-30 cursor-not-allowed"),onMouseDown:r,onClick:a,disabled:t||!o,"aria-label":"Split cell","data-testid":"toolbar-table-split",children:jsx(se,{name:"call_split",size:20})})});return jsxs(Fragment$1,{children:[s,l]})}var dI=[{action:"addRowAbove",icon:"keyboard_arrow_up",label:"Insert row above",testId:"toolbar-table-add-row-above"},{action:"addRowBelow",icon:"keyboard_arrow_down",label:"Insert row below",testId:"toolbar-table-add-row-below"},{action:"addColumnLeft",icon:"keyboard_arrow_left",label:"Insert column left",testId:"toolbar-table-add-col-left"},{action:"addColumnRight",icon:"keyboard_arrow_right",label:"Insert column right",testId:"toolbar-table-add-col-right"}];function uI({onAction:e,disabled:t=false}){let n=useCallback(o=>{o.preventDefault(),o.stopPropagation();},[]);return jsx(Fragment$1,{children:dI.map(({action:o,icon:r,label:i,testId:a})=>jsx(wt,{content:i,children:jsx(dt,{variant:"ghost",size:"icon-sm",className:Ce("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",t&&"opacity-30 cursor-not-allowed"),onMouseDown:n,onClick:()=>!t&&e(o),disabled:t,"aria-label":i,"data-testid":a,children:jsx(se,{name:r,size:20})})},typeof o=="string"?o:o.type))})}var Vt={container:{position:"relative",display:"inline-block"},button:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 8px",border:"1px solid #d0d0d0",borderRadius:"3px",backgroundColor:"#fff",cursor:"pointer",fontSize:"12px",gap:"4px",minWidth:"32px",height:"28px",transition:"background-color 0.15s, border-color 0.15s"},buttonHover:{borderColor:"#1a73e8",backgroundColor:"#f0f7ff"},buttonDisabled:{opacity:.5,cursor:"not-allowed"},colorIndicator:{width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px"},dropdown:{position:"absolute",top:"100%",left:"0",marginTop:"4px",padding:"8px",backgroundColor:"#fff",border:"1px solid #e0e0e0",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",zIndex:1e3,minWidth:"180px"},colorGrid:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:"4px",marginBottom:"8px"},colorCell:{width:"24px",height:"24px",border:"1px solid #ccc",borderRadius:"2px",cursor:"pointer",transition:"transform 0.1s, box-shadow 0.1s"},colorCellHover:{transform:"scale(1.1)",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)"},colorCellSelected:{border:"2px solid #1a73e8"},noFillButton:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"6px 8px",border:"none",borderRadius:"3px",backgroundColor:"transparent",cursor:"pointer",fontSize:"12px",color:"#333",transition:"background-color 0.15s"},noFillButtonHover:{backgroundColor:"#f0f0f0"},separator:{height:"1px",backgroundColor:"#e0e0e0",margin:"8px 0"},customColorRow:{display:"flex",alignItems:"center",gap:"8px"},customColorInput:{width:"40px",height:"28px",padding:"0",border:"1px solid #ccc",borderRadius:"3px",cursor:"pointer"},customColorLabel:{fontSize:"11px",color:"#666"}};function gI(){return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M2 12L6.5 2.5L11 7L7 11H13V13H2V12Z",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),jsx("circle",{cx:"13",cy:"10",r:"2",fill:"currentColor"})]})}function hI(){return jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"2",width:"12",height:"12",stroke:"#ccc",strokeWidth:"1",fill:"none"}),jsx("line",{x1:"2",y1:"14",x2:"14",y2:"2",stroke:"#d32f2f",strokeWidth:"1.5"})]})}var na=[{hex:"#FFFFFF",name:"White"},{hex:"#F2F2F2",name:"Light Gray 1"},{hex:"#D9D9D9",name:"Light Gray 2"},{hex:"#BFBFBF",name:"Gray"},{hex:"#808080",name:"Dark Gray"},{hex:"#000000",name:"Black"},{hex:"#E6F3FF",name:"Light Blue 1"},{hex:"#CCE5FF",name:"Light Blue 2"},{hex:"#99CCFF",name:"Light Blue 3"},{hex:"#4DA6FF",name:"Blue"},{hex:"#0066CC",name:"Dark Blue"},{hex:"#003366",name:"Navy"},{hex:"#E6FFE6",name:"Light Green 1"},{hex:"#CCFFCC",name:"Light Green 2"},{hex:"#99FF99",name:"Light Green 3"},{hex:"#33CC33",name:"Green"},{hex:"#009900",name:"Dark Green"},{hex:"#006600",name:"Forest"},{hex:"#FFFFCC",name:"Light Yellow"},{hex:"#FFFF99",name:"Yellow"},{hex:"#FFE066",name:"Gold"},{hex:"#FFCC00",name:"Orange Yellow"},{hex:"#FF9900",name:"Orange"},{hex:"#CC6600",name:"Dark Orange"},{hex:"#FFE6E6",name:"Light Pink"},{hex:"#FFCCCC",name:"Pink"},{hex:"#FF9999",name:"Light Red"},{hex:"#FF6666",name:"Red"},{hex:"#CC0000",name:"Dark Red"},{hex:"#660000",name:"Maroon"},{hex:"#F2E6FF",name:"Light Purple 1"},{hex:"#E6CCFF",name:"Light Purple 2"},{hex:"#CC99FF",name:"Light Purple 3"},{hex:"#9933FF",name:"Purple"},{hex:"#6600CC",name:"Dark Purple"},{hex:"#330066",name:"Indigo"}];function bI({value:e,onChange:t,colors:n=na,disabled:o=false,className:r,style:i,showNoFill:a=true,showCustomColor:s=true,compact:l=false}){let[d,c]=useState(false),[u,p]=useState(false),[f,m]=useState(null),[b,g]=useState(false),h=useRef(null);useEffect(()=>{let E=S=>{h.current&&!h.current.contains(S.target)&&c(false);};return d&&document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E);}},[d]);let x=useCallback(()=>{o||c(E=>!E);},[o]),y=useCallback(E=>{t?.(E),c(false);},[t]),k=useCallback(()=>{t?.(null),c(false);},[t]),T=useCallback(E=>{t?.(E.target.value);},[t]),A={...Vt.button,...u&&!o?Vt.buttonHover:{},...o?Vt.buttonDisabled:{},...l?{padding:"2px 4px",minWidth:"28px",height:"24px"}:{}},B={...Vt.colorIndicator,backgroundColor:e||"transparent",...e===null?{background:"repeating-linear-gradient(45deg, #fff, #fff 2px, #f0f0f0 2px, #f0f0f0 4px)"}:{}},R=["docx-cell-background-picker"];return r&&R.push(r),l&&R.push("docx-cell-background-picker-compact"),jsxs("div",{ref:h,className:R.join(" "),style:{...Vt.container,...i},children:[jsxs("button",{type:"button",style:A,onClick:x,onMouseEnter:()=>p(true),onMouseLeave:()=>p(false),disabled:o,title:"Cell Background Color","aria-label":"Cell Background Color","aria-haspopup":"true","aria-expanded":d,children:[jsx(gI,{}),jsx("div",{style:B})]}),d&&jsxs("div",{style:Vt.dropdown,children:[a&&jsxs(Fragment$1,{children:[jsxs("button",{type:"button",style:{...Vt.noFillButton,...b?Vt.noFillButtonHover:{}},onClick:k,onMouseEnter:()=>g(true),onMouseLeave:()=>g(false),children:[jsx(hI,{}),jsx("span",{children:"No Fill"})]}),jsx("div",{style:Vt.separator})]}),jsx("div",{style:Vt.colorGrid,children:n.map(E=>jsx("button",{type:"button",style:{...Vt.colorCell,backgroundColor:E.hex,...f===E.hex?Vt.colorCellHover:{},...e===E.hex?Vt.colorCellSelected:{}},onClick:()=>y(E.hex),onMouseEnter:()=>m(E.hex),onMouseLeave:()=>m(null),title:E.name,"aria-label":E.name},E.hex))}),s&&jsxs(Fragment$1,{children:[jsx("div",{style:Vt.separator}),jsxs("div",{style:Vt.customColorRow,children:[jsx("input",{type:"color",value:e||"#FFFFFF",onChange:T,style:Vt.customColorInput,title:"Custom Color"}),jsx("span",{style:Vt.customColorLabel,children:"Custom color"})]})]})]})]})}function xI(){return na}function yI(e,t){return {hex:e.toUpperCase(),name:t||e}}function vI(e){return na.some(t=>t.hex.toUpperCase()===e.toUpperCase())}function SI(e){return na.find(n=>n.hex.toUpperCase()===e.toUpperCase())?.name||e}function CI(e){if(e)return {fill:{rgb:e.replace("#","")},pattern:"clear"}}function TI(e){return !e||!e.fill?null:e.fill.rgb?`#${e.fill.rgb}`:null}function wI(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function kI(e){let t=wI(e);return t?(.299*t.r+.587*t.g+.114*t.b)/255>.5?"#000000":"#FFFFFF":"#000000"}var PI="var(--doc-error)",RI="var(--doc-success)",EI="You have unsaved changes. Are you sure you want to leave?",II=({size:e=16})=>jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M3 2h8l2 2v9a1 1 0 01-1 1H3a1 1 0 01-1-1V3a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M5 2v4h5V2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M5 14v-4h6v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),MI=({size:e=16})=>jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),jsx("circle",{cx:"8",cy:"11",r:"0.5",fill:"currentColor"})]}),LI=`
|
|
116
|
-
@keyframes docx-unsaved-pulse {
|
|
117
|
-
0%, 100% { opacity: 1; }
|
|
118
|
-
50% { opacity: 0.6; }
|
|
119
|
-
}
|
|
120
|
-
`,FI=(e,t,n,o,r,i,a)=>{let s={display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",animation:n&&o?"docx-unsaved-pulse 2s ease-in-out infinite":"none"};switch(t==="absolute-top-right"?(s.position="absolute",s.top="4px",s.right="4px"):t==="absolute-top-left"&&(s.position="absolute",s.top="4px",s.left="4px"),e){case "dot":return {...s,width:`${a}px`,height:`${a}px`,borderRadius:"50%",backgroundColor:n?r:i};case "badge":return {...s,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:500,backgroundColor:n?r:i,color:"white"};case "text":return {...s,fontSize:"12px",color:n?r:i,fontWeight:500};case "icon":return {...s,color:n?r:i};default:return s}},DI=({hasUnsavedChanges:e,variant:t="dot",position:n="inline",showPulse:o=true,label:r="Unsaved",savedLabel:i="Saved",showWhenSaved:a=false,unsavedColor:s=PI,savedColor:l=RI,size:d=8,className:c="",style:u,onClick:p,title:f})=>{if(useEffect(()=>{if(!o||!e)return;let x="docx-unsaved-pulse-keyframes";if(!document.getElementById(x)){let y=document.createElement("style");y.id=x,y.textContent=LI,document.head.appendChild(y);}},[o,e]),!e&&!a)return null;let b={...FI(t,n,e,o,s,l,d),...u,cursor:p?"pointer":void 0},g=e?"Document has unsaved changes":"All changes saved",h=()=>{switch(t){case "dot":return null;case "badge":return e?r:i;case "text":return e?r:i;case "icon":return e?jsx(MI,{size:d}):jsx(II,{size:d});default:return null}};return jsx("span",{className:`docx-unsaved-indicator docx-unsaved-indicator-${t} ${e?"docx-unsaved":"docx-saved"} ${c}`,style:b,onClick:p,title:f??g,role:p?"button":"status","aria-label":e?"Unsaved changes":"All changes saved",children:h()})};function AI(e={}){let{document:t,warnBeforeLeave:n=true,warningMessage:o=EI,enabled:r=true,onChangeStatusChange:i}=e,[a,s]=useState(false),[l,d]=useState(0),[c,u]=useState(null),p=useRef(null),f=useRef(false),m=useCallback(x=>{if(!x)return null;try{return JSON.stringify(x.package)}catch{return null}},[]),b=useCallback(()=>{r&&(s(false),d(0),u(t??null),p.current=m(t));},[r,t,m]),g=useCallback(()=>{r&&(a||(s(true),i?.(true)),d(x=>x+1));},[r,a,i]),h=useCallback(x=>{let y=x!==void 0?x:t;s(false),d(0),u(y??null),p.current=m(y),f.current=true;},[t,m]);return useEffect(()=>{!r||!t||f.current||h(t);},[r,t,h]),useEffect(()=>{if(!r||!t||!f.current)return;let x=m(t),y=p.current;if(x!==y){let k=m(c);x!==k?(a||(s(true),i?.(true)),d(T=>T+1)):a&&(s(false),i?.(false)),p.current=x;}},[r,t,c,a,m,i]),useEffect(()=>{if(!r||!n||!a)return;let x=y=>(y.preventDefault(),y.returnValue=o,o);return window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[r,n,a,o]),{hasUnsavedChanges:a,markAsSaved:b,markAsChanged:g,resetTracking:h,lastSavedDocument:c,changeCount:l}}function BI(e){return {dot:"Dot",badge:"Badge",text:"Text",icon:"Icon"}[e]}function NI(){return ["dot","badge","text","icon"]}function HI(){return ["inline","absolute-top-right","absolute-top-left"]}function OI(){let e=0,t=null,n=false;return {markChanged:()=>{e++,n=true;},markSaved:()=>{n=false,t=new Date;},getState:()=>({changeCount:e,lastSaveTime:t,hasUnsavedChanges:n}),reset:()=>{e=0,t=null,n=false;}}}var zI={small:{size:16,strokeWidth:2,fontSize:11},medium:{size:32,strokeWidth:3,fontSize:13},large:{size:48,strokeWidth:4,fontSize:14}},_I="var(--doc-primary)",$I=300,WI=`
|
|
121
|
-
@keyframes docx-loading-spin {
|
|
122
|
-
0% { transform: rotate(0deg); }
|
|
123
|
-
100% { transform: rotate(360deg); }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@keyframes docx-loading-pulse {
|
|
127
|
-
0%, 100% { opacity: 1; transform: scale(1); }
|
|
128
|
-
50% { opacity: 0.5; transform: scale(0.95); }
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@keyframes docx-loading-dots {
|
|
132
|
-
0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
|
|
133
|
-
40% { transform: scale(1); opacity: 1; }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@keyframes docx-loading-bar {
|
|
137
|
-
0% { left: -35%; right: 100%; }
|
|
138
|
-
60% { left: 100%; right: -90%; }
|
|
139
|
-
100% { left: 100%; right: -90%; }
|
|
140
|
-
}
|
|
141
|
-
`,VI=({size:e,strokeWidth:t,color:n})=>{let o=(e-t)/2,r=o*2*Math.PI;return jsxs("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,style:{animation:"docx-loading-spin 1s linear infinite"},children:[jsx("circle",{cx:e/2,cy:e/2,r:o,fill:"none",stroke:n,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${r*.75} ${r}`,opacity:.25}),jsx("circle",{cx:e/2,cy:e/2,r:o,fill:"none",stroke:n,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${r*.25} ${r}`,transform:`rotate(-90 ${e/2} ${e/2})`})]})},ZI=({size:e,color:t})=>{let n=e/4,o=n/2;return jsx("div",{style:{display:"flex",gap:`${o}px`},children:[0,1,2].map(r=>jsx("div",{style:{width:n,height:n,borderRadius:"50%",backgroundColor:t,animation:`docx-loading-dots 1.4s ease-in-out ${r*.16}s infinite both`}},r))})},UI=({size:e,color:t})=>jsx("div",{style:{width:e*3,height:e/4,backgroundColor:`${t}20`,borderRadius:e/8,overflow:"hidden",position:"relative"},children:jsx("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0,backgroundColor:t,borderRadius:e/8,animation:"docx-loading-bar 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite"}})}),qI=({size:e,color:t})=>jsx("div",{style:{width:e,height:e,borderRadius:"50%",backgroundColor:t,animation:"docx-loading-pulse 1.5s ease-in-out infinite"}}),KI=({size:e,color:t,progress:n,showText:o,fontSize:r})=>{let i=Math.max(0,Math.min(100,n));return jsxs("div",{style:{width:e*3,height:e/4,backgroundColor:`${t}20`,borderRadius:e/8,overflow:"hidden",position:"relative"},children:[jsx("div",{style:{position:"absolute",top:0,bottom:0,left:0,width:`${i}%`,backgroundColor:t,borderRadius:e/8,transition:"width 0.3s ease"}}),o&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:r,fontWeight:500,color:i>50?"#fff":t},children:[Math.round(i),"%"]})]})},GI=({isLoading:e,variant:t="spinner",size:n="medium",message:o,overlay:r=false,overlayOpacity:i=.5,progress:a=0,showProgressText:s=true,color:l=_I,className:d="",style:c})=>{let u=zI[n];if(useEffect(()=>{let m="docx-loading-keyframes";if(!document.getElementById(m)){let b=document.createElement("style");b.id=m,b.textContent=WI,document.head.appendChild(b);}},[]),!e)return null;let p=()=>{switch(t){case "spinner":return jsx(VI,{size:u.size,strokeWidth:u.strokeWidth,color:l});case "dots":return jsx(ZI,{size:u.size,color:l});case "bar":return jsx(UI,{size:u.size,color:l});case "pulse":return jsx(qI,{size:u.size,color:l});case "progress":return jsx(KI,{size:u.size,color:l,progress:a,showText:s,fontSize:u.fontSize});default:return null}},f=jsxs("div",{className:`docx-loading-content ${d}`,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",...c},children:[p(),o&&jsx("div",{style:{fontSize:u.fontSize,color:r?"white":"var(--doc-text-muted)",textAlign:"center"},children:o})]});return r?jsx("div",{className:`docx-loading-overlay ${d}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:`rgba(0, 0, 0, ${i})`,zIndex:1e4,...c},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?a:void 0,"aria-busy":"true","aria-label":o||"Loading",children:f}):jsx("div",{className:`docx-loading-inline ${d}`,style:{display:"inline-flex",alignItems:"center",...c},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?a:void 0,"aria-busy":"true","aria-label":o||"Loading",children:f})};function YI(e={}){let{initialLoading:t=false,minDuration:n=$I,onStart:o,onEnd:r}=e,[i,a]=useState(t),[s,l]=useState(null),[d,c]=useState(0),u=useRef(null),p=useRef(null),f=useCallback(g=>{u.current=Date.now(),a(true),l(g||null),c(0),o?.();},[o]),m=useCallback(()=>{let g=u.current,h=Date.now(),x=g?h-g:0,y=Math.max(0,n-x);y>0?p.current=setTimeout(()=>{a(false),l(null),c(0),u.current=null,r?.();},y):(a(false),l(null),c(0),u.current=null,r?.());},[n,r]),b=useCallback(async(g,h)=>{f(h);try{let x=await g();return m(),x}catch(x){throw m(),x}},[f,m]);return useEffect(()=>()=>{p.current&&clearTimeout(p.current);},[]),{isLoading:i,message:s,progress:d,startLoading:f,stopLoading:m,setProgress:c,setMessage:l,withLoading:b}}function jI(){let[e,t]=useState(new Map),n=useCallback((s,l)=>{t(d=>{let c=new Map(d);return c.set(s,{id:s,message:l,startTime:Date.now()}),c});},[]),o=useCallback((s,l)=>{t(d=>{let c=d.get(s);if(!c)return d;let u=new Map(d);return u.set(s,{...c,...l}),u});},[]),r=useCallback(s=>{t(l=>{let d=new Map(l);return d.delete(s),d});},[]),i=e.size>0;return {operations:Array.from(e.values()),isAnyLoading:i,startOperation:n,updateOperation:o,endOperation:r,getOperation:s=>e.get(s)}}function XI(e){return {spinner:"Spinner",dots:"Dots",bar:"Bar",pulse:"Pulse",progress:"Progress"}[e]}function JI(){return ["spinner","dots","bar","pulse","progress"]}function QI(){return ["small","medium","large"]}function eM(e){return new Promise(t=>setTimeout(t,e))}var Cb=4,Tb=36,rM=32,iM=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("circle",{cx:"3",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor"}),jsx("circle",{cx:"13",cy:"8",r:"1.5",fill:"currentColor"})]});function wb(e){let{containerRef:t,items:n,itemGap:o=Cb,overflowButtonWidth:r=Tb}=e,[i,a]=useState(n.length),s=useRef(new Map),l=useCallback(()=>{let u=t.current;if(!u){a(n.length);return}let p=u.offsetWidth;if(p===0)return;let f=[...n].sort((g,h)=>g.alwaysVisible&&!h.alwaysVisible?-1:!g.alwaysVisible&&h.alwaysVisible?1:(g.priority||3)-(h.priority||3)),m=0,b=0;for(let g of f){let x=(g.minWidth||s.current.get(g.id)||rM)+(b>0?o:0),y=b<n.length-1?r+o:0;if(m+x+y<=p)m+=x,b++;else if(g.alwaysVisible)m+=x,b++;else break}a(Math.max(0,b));},[t,n,o,r]);useLayoutEffect(()=>{let u=t.current;if(!u)return;l();let p=new ResizeObserver(()=>{l();});return p.observe(u),()=>{p.disconnect();}},[t,l]),useEffect(()=>{l();},[n,l]);let{visibleItems:d,overflowItems:c}=useMemo(()=>{let u=[...n].sort((p,f)=>p.alwaysVisible&&!f.alwaysVisible?-1:!p.alwaysVisible&&f.alwaysVisible?1:(p.priority||3)-(f.priority||3));return {visibleItems:u.slice(0,i),overflowItems:u.slice(i)}},[n,i]);return {visibleItems:d,overflowItems:c,hasOverflow:c.length>0,recalculate:l}}var aM=({items:e,isOpen:t,onClose:n,anchorRef:o})=>{let r=useRef(null);return useEffect(()=>{if(!t)return;let i=a=>{r.current&&!r.current.contains(a.target)&&o.current&&!o.current.contains(a.target)&&n();};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[t,n,o]),useEffect(()=>{if(!t)return;let i=a=>{a.key==="Escape"&&n();};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t,n]),!t||e.length===0?null:jsx("div",{ref:r,className:"docx-responsive-toolbar-overflow-menu",style:{position:"absolute",top:"100%",right:0,marginTop:"4px",backgroundColor:"white",border:"1px solid var(--doc-border)",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",padding:"8px",zIndex:1e3,display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"300px"},role:"menu",children:e.map(i=>jsx("div",{className:"docx-responsive-toolbar-overflow-item",role:"menuitem",children:i.content},i.id))})},sM=({items:e,overflowItems:t=[],alwaysShowOverflow:n=false,renderOverflowButton:o,renderOverflowMenu:r,itemGap:i=Cb,padding:a="8px 12px",overflowButtonWidth:s=Tb,className:l="",style:d,height:c=44,backgroundColor:u="var(--doc-toolbar-bg)",borderBottom:p="1px solid var(--doc-border)"})=>{let f=useRef(null),m=useRef(null),[b,g]=useState(false),{visibleItems:h,overflowItems:x,hasOverflow:y}=wb({containerRef:f,items:e,itemGap:i,overflowButtonWidth:s}),k=[...x,...t],T=y||n||t.length>0,A=useCallback(()=>{g(E=>!E);},[]),B=useCallback(()=>{g(false);},[]),R=jsx("button",{ref:m,type:"button",className:"docx-responsive-toolbar-overflow-button",onClick:A,"aria-label":`Show ${k.length} more options`,"aria-expanded":b,"aria-haspopup":"menu",style:{display:"flex",alignItems:"center",justifyContent:"center",width:`${s}px`,height:"32px",border:"none",borderRadius:"4px",backgroundColor:b?"var(--doc-primary-light)":"transparent",color:"var(--doc-text-muted)",cursor:"pointer",transition:"background-color 0.15s ease"},children:jsx(iM,{})});return jsxs("div",{ref:f,className:`docx-responsive-toolbar ${l}`,style:{display:"flex",alignItems:"center",gap:`${i}px`,height:typeof c=="number"?`${c}px`:c,padding:a,backgroundColor:u,borderBottom:p,position:"relative",...d},children:[h.map(E=>jsxs(cn__default.Fragment,{children:[jsx("div",{className:"docx-responsive-toolbar-item","data-item-id":E.id,style:{flexShrink:0},children:E.content}),E.separatorAfter&&jsx("div",{className:"docx-responsive-toolbar-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]},E.id)),T&&jsx("div",{style:{flex:1,minWidth:0}}),T&&jsxs("div",{style:{position:"relative",flexShrink:0},children:[o?o(k.length,b,A):R,r?b&&r(k,B):jsx(aM,{items:k,isOpen:b,onClose:B,anchorRef:m})]})]})},lM=({children:e,gap:t=2,separatorAfter:n=false,className:o="",style:r})=>jsxs(Fragment$1,{children:[jsx("div",{className:`docx-toolbar-group ${o}`,style:{display:"flex",alignItems:"center",gap:`${t}px`,...r},children:e}),n&&jsx("div",{className:"docx-toolbar-group-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]});function cM(e,t,n){return {id:e,content:t,priority:3,...n}}function dM(e){return e.map(t=>({...t,priority:t.priority||3}))}function uM(e){return {undo:1,redo:1,bold:1,italic:1,underline:2,fontFamily:2,fontSize:2,textColor:3,highlightColor:3,alignment:3,lists:4,indent:4,lineSpacing:5,styles:5}[e]||3}var mM={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},gM={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"320px",maxWidth:"400px",width:"100%",margin:"20px"},hM={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},bM={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},xM={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},yM={padding:"20px"},vM={display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"16px"},SM={display:"grid",gap:"2px",padding:"4px",backgroundColor:"var(--doc-bg-hover)",borderRadius:"4px",cursor:"pointer"},Mb={width:"24px",height:"24px",backgroundColor:"white",border:"1px solid var(--doc-border-dark)",borderRadius:"2px",transition:"background-color 0.1s, border-color 0.1s"},CM={...Mb,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)"},TM={marginTop:"8px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},wM={display:"flex",alignItems:"center",gap:"12px",margin:"16px 0",color:"var(--doc-text-muted)",fontSize:"12px"},Pb={flex:1,height:"1px",backgroundColor:"var(--doc-border)"},Rb={display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},Eb={fontSize:"14px",fontWeight:500,color:"var(--doc-text)",minWidth:"80px"},Ib={width:"80px",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",textAlign:"center"},kM={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},_u={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},PM={..._u,backgroundColor:"var(--doc-primary)",color:"white"},RM={..._u,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},EM={..._u,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function IM(){return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"2",y:"2",width:"16",height:"16",stroke:"currentColor",strokeWidth:"1.5",fill:"none",rx:"1"}),jsx("line",{x1:"2",y1:"7",x2:"18",y2:"7",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"2",y1:"12",x2:"18",y2:"12",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"18",stroke:"currentColor",strokeWidth:"1.5"}),jsx("line",{x1:"13",y1:"2",x2:"13",y2:"18",stroke:"currentColor",strokeWidth:"1.5"})]})}function MM({isOpen:e,onClose:t,onInsert:n,maxGridRows:o=8,maxGridColumns:r=10,maxRows:i=100,maxColumns:a=20,className:s,style:l}){let[d,c]=useState(0),[u,p]=useState(0),[f,m]=useState(3),[b,g]=useState(3),h=useRef(null);useEffect(()=>{e&&(c(0),p(0),m(3),g(3));},[e]),useEffect(()=>{e&&h.current?.focus();},[e]);let x=useCallback((_,U)=>{c(_),p(U);},[]),y=useCallback(()=>{d>0&&u>0&&n({rows:d,columns:u});},[d,u,n]),k=useCallback(()=>{let _=Math.min(Math.max(1,f),i),U=Math.min(Math.max(1,b),a);n({rows:_,columns:U});},[f,b,i,a,n]),T=useCallback(_=>{_.key==="Escape"?t():_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),k());},[t,k]),A=useCallback(_=>{_.target===_.currentTarget&&t();},[t]),B=useCallback(_=>{let U=parseInt(_.target.value,10);isNaN(U)?_.target.value===""&&m(1):m(Math.min(Math.max(1,U),i));},[i]),R=useCallback(_=>{let U=parseInt(_.target.value,10);isNaN(U)?_.target.value===""&&g(1):g(Math.min(Math.max(1,U),a));},[a]);if(!e)return null;let E=[];for(let _=1;_<=o;_++)for(let U=1;U<=r;U++){let Z=_<=d&&U<=u;E.push(jsx("div",{style:Z?CM:Mb,onMouseEnter:()=>x(_,U),onClick:y,role:"gridcell","aria-selected":Z},`${_}-${U}`));}let S=f>=1&&b>=1,N=d>0&&u>0?`${u} x ${d} Table`:"Hover to select size";return jsx("div",{className:`docx-insert-table-dialog-overlay ${s||""}`,style:{...mM,...l},onClick:A,onKeyDown:T,role:"dialog","aria-modal":"true","aria-labelledby":"insert-table-dialog-title",children:jsxs("div",{ref:h,className:"docx-insert-table-dialog",style:gM,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-table-dialog-header",style:hM,children:[jsx("h2",{id:"insert-table-dialog-title",style:bM,children:jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsx(IM,{}),"Insert Table"]})}),jsx("button",{type:"button",className:"docx-insert-table-dialog-close",style:xM,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-table-dialog-body",style:yM,children:[jsxs("div",{className:"docx-insert-table-grid-container",style:vM,children:[jsx("div",{className:"docx-insert-table-grid",style:{...SM,gridTemplateColumns:`repeat(${r}, 1fr)`},onMouseLeave:()=>{c(0),p(0);},role:"grid","aria-label":"Table size selector",children:E}),jsx("div",{className:"docx-insert-table-grid-label",style:TM,children:N})]}),jsxs("div",{className:"docx-insert-table-separator",style:wM,children:[jsx("div",{style:Pb}),jsx("span",{children:"or specify size"}),jsx("div",{style:Pb})]}),jsxs("div",{className:"docx-insert-table-inputs",children:[jsxs("div",{style:Rb,children:[jsx("label",{htmlFor:"insert-table-rows",style:Eb,children:"Rows:"}),jsx("input",{id:"insert-table-rows",type:"number",min:1,max:i,value:f,onChange:B,style:Ib})]}),jsxs("div",{style:Rb,children:[jsx("label",{htmlFor:"insert-table-cols",style:Eb,children:"Columns:"}),jsx("input",{id:"insert-table-cols",type:"number",min:1,max:a,value:b,onChange:R,style:Ib})]})]})]}),jsxs("div",{className:"docx-insert-table-dialog-footer",style:kM,children:[jsx("button",{type:"button",className:"docx-insert-table-dialog-cancel",style:RM,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-table-dialog-insert",style:S?PM:EM,onClick:k,disabled:!S,children:"Insert Table"})]})]})})}function LM(){let[e,t]=useState(false),n=useCallback(()=>t(true),[]),o=useCallback(()=>t(false),[]),r=useCallback(()=>t(i=>!i),[]);return {isOpen:e,open:n,close:o,toggle:r}}function FM(e=3,t=3){return {rows:e,columns:t}}function DM(e,t=100,n=20){return e.rows>=1&&e.rows<=t&&e.columns>=1&&e.columns<=n}function AM(e,t=100,n=20){return {rows:Math.min(Math.max(1,e.rows),t),columns:Math.min(Math.max(1,e.columns),n)}}function BM(e){return `${e.columns} x ${e.rows}`}function NM(){return [{label:"2 x 2",config:{rows:2,columns:2}},{label:"3 x 3",config:{rows:3,columns:3}},{label:"4 x 4",config:{rows:4,columns:4}},{label:"2 x 4",config:{rows:2,columns:4}},{label:"4 x 2",config:{rows:4,columns:2}},{label:"5 x 5",config:{rows:5,columns:5}}]}var OM={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},zM={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"450px",maxWidth:"600px",width:"100%",margin:"20px",maxHeight:"90vh",overflow:"auto"},_M={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},$M={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},WM={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},VM={padding:"20px"},$u={border:"2px dashed var(--doc-border-input)",borderRadius:"8px",padding:"40px 20px",textAlign:"center",cursor:"pointer",transition:"border-color 0.2s, background-color 0.2s",marginBottom:"16px"},ZM={...$u,borderColor:"var(--doc-primary)",backgroundColor:"var(--doc-primary-light)"},UM={...$u,padding:"20px",borderStyle:"solid",borderColor:"var(--doc-primary)"},qM={display:"flex",justifyContent:"center",alignItems:"center",maxHeight:"250px",overflow:"hidden"},KM={maxWidth:"100%",maxHeight:"250px",objectFit:"contain",borderRadius:"4px"},GM={fontSize:"48px",color:"var(--doc-text-placeholder)",marginBottom:"12px"},YM={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"8px"},jM={fontSize:"12px",color:"var(--doc-text-placeholder)"},Fb={marginBottom:"16px"},Db={display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},XM={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},JM={display:"flex",alignItems:"center",gap:"12px"},Ab={width:"100px",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",textAlign:"center"},Nb={padding:"6px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"16px"},QM={...Nb,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)",color:"white"},e2={fontSize:"12px",color:"var(--doc-text-muted)",marginTop:"8px",textAlign:"center"},t2={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Wu={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},n2={...Wu,backgroundColor:"var(--doc-primary)",color:"white"},o2={...Wu,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},r2={...Wu,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function i2(){return jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{x:"6",y:"10",width:"36",height:"28",rx:"2",stroke:"var(--doc-text-placeholder)",strokeWidth:"2",fill:"none"}),jsx("circle",{cx:"16",cy:"20",r:"4",stroke:"var(--doc-text-placeholder)",strokeWidth:"2",fill:"none"}),jsx("path",{d:"M6 32L16 24L26 34L36 22L42 28",stroke:"var(--doc-text-placeholder)",strokeWidth:"2",fill:"none"})]})}function a2({locked:e}){return e?jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M12 6V4a4 4 0 0 0-8 0v2H3v8h10V6h-1zm-6-2a2 2 0 0 1 4 0v2H6V4zm6 8H4V8h8v4z"})}):jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M10 6V4a2 2 0 0 0-4 0v2H4v8h8V6h-2zM6 4a2 2 0 0 1 4 0v2h-2V4H6v2H4v2H6V4zm4 8H6V8h4v4z"})})}function s2({isOpen:e,onClose:t,onInsert:n,maxWidth:o=800,maxHeight:r=600,accept:i="image/*",className:a,style:s}){let[l,d]=useState(null),[c,u]=useState(false),[p,f]=useState(0),[m,b]=useState(0),[g,h]=useState(""),[x,y]=useState(true),[k,T]=useState(1),[A,B]=useState(null),R=useRef(null),E=useRef(null);useEffect(()=>{e&&(d(null),u(false),f(0),b(0),h(""),y(true),T(1),B(null));},[e]);let S=useCallback(P=>{if(!P.type.startsWith("image/")){B("Please select a valid image file");return}if(P.size>10*1024*1024){B("Image file is too large (max 10MB)");return}B(null);let I=new FileReader;I.onload=z=>{let Y=z.target?.result,j=new Image;j.onload=()=>{let F=j.width,V=j.height;if(F>o||V>r){let G=o/F,be=r/V,me=Math.min(G,be);F=Math.round(F*me),V=Math.round(V*me);}f(F),b(V),T(j.width/j.height),d({src:Y,width:F,height:V,fileName:P.name,mimeType:P.type});},j.src=Y;},I.onerror=()=>{B("Failed to read image file");},I.readAsDataURL(P);},[o,r]),N=useCallback(P=>{let I=P.target.files?.[0];I&&S(I);},[S]),_=useCallback(()=>{R.current?.click();},[]),U=useCallback(P=>{P.preventDefault(),u(true);},[]),Z=useCallback(P=>{P.preventDefault(),u(false);},[]),L=useCallback(P=>{P.preventDefault(),u(false);let I=P.dataTransfer.files?.[0];I&&S(I);},[S]),H=useCallback(P=>{let I=parseInt(P.target.value,10)||0;f(I),x&&k&&b(Math.round(I/k));},[x,k]),q=useCallback(P=>{let I=parseInt(P.target.value,10)||0;b(I),x&&k&&f(Math.round(I*k));},[x,k]),xe=useCallback(()=>{l&&n({...l,width:p,height:m,alt:g||void 0});},[l,p,m,g,n]),ie=useCallback(P=>{P.key==="Escape"?t():P.key==="Enter"&&l&&!P.shiftKey&&(P.preventDefault(),xe());},[t,l,xe]),we=useCallback(P=>{P.target===P.currentTarget&&t();},[t]),M=useCallback(()=>{d(null),f(0),b(0),h(""),B(null),R.current&&(R.current.value="");},[]);if(!e)return null;let O=l!==null&&p>0&&m>0,C=()=>l?UM:c?ZM:$u;return jsx("div",{className:`docx-insert-image-dialog-overlay ${a||""}`,style:{...OM,...s},onClick:we,onKeyDown:ie,role:"dialog","aria-modal":"true","aria-labelledby":"insert-image-dialog-title",children:jsxs("div",{ref:E,className:"docx-insert-image-dialog",style:zM,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-image-dialog-header",style:_M,children:[jsx("h2",{id:"insert-image-dialog-title",style:$M,children:"Insert Image"}),jsx("button",{type:"button",className:"docx-insert-image-dialog-close",style:WM,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-image-dialog-body",style:VM,children:[jsx("input",{ref:R,type:"file",accept:i,onChange:N,style:{display:"none"}}),jsx("div",{className:"docx-insert-image-dropzone",style:C(),onClick:_,onDragOver:U,onDragLeave:Z,onDrop:L,role:"button",tabIndex:0,"aria-label":"Click or drag to upload image",children:l?jsx("div",{style:qM,children:jsx("img",{src:l.src,alt:g||"Preview",style:KM})}):jsxs(Fragment$1,{children:[jsx("div",{style:GM,children:jsx(i2,{})}),jsx("div",{style:YM,children:"Click to select or drag and drop an image"}),jsx("div",{style:jM,children:"PNG, JPG, GIF up to 10MB"})]})}),l?.fileName&&jsxs("div",{style:e2,children:[l.fileName,jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),M();},style:{marginLeft:"8px",background:"none",border:"none",color:"var(--doc-primary)",cursor:"pointer",fontSize:"12px"},children:"Change"})]}),A&&jsx("div",{style:{color:"var(--doc-error)",fontSize:"14px",marginBottom:"16px",textAlign:"center"},children:A}),l&&jsxs(Fragment$1,{children:[jsxs("div",{style:Fb,children:[jsx("label",{style:Db,children:"Dimensions"}),jsxs("div",{style:JM,children:[jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"Width:"}),jsx("input",{type:"number",value:p,onChange:H,min:1,max:o,style:Ab}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"px"}),jsx("button",{type:"button",onClick:()=>y(!x),style:x?QM:Nb,title:x?"Aspect ratio locked":"Aspect ratio unlocked",children:jsx(a2,{locked:x})}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"Height:"}),jsx("input",{type:"number",value:m,onChange:q,min:1,max:r,style:Ab}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"px"})]})]}),jsxs("div",{style:Fb,children:[jsx("label",{htmlFor:"insert-image-alt",style:Db,children:"Alt Text (optional)"}),jsx("input",{id:"insert-image-alt",type:"text",value:g,onChange:P=>h(P.target.value),placeholder:"Describe the image for accessibility",style:XM})]})]})]}),jsxs("div",{className:"docx-insert-image-dialog-footer",style:t2,children:[jsx("button",{type:"button",className:"docx-insert-image-dialog-cancel",style:o2,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-image-dialog-insert",style:O?n2:r2,onClick:xe,disabled:!O,children:"Insert Image"})]})]})})}function l2(){let[e,t]=useState(false),n=useCallback(()=>t(true),[]),o=useCallback(()=>t(false),[]),r=useCallback(()=>t(i=>!i),[]);return {isOpen:e,open:n,close:o,toggle:r}}function c2(e){return e.type.startsWith("image/")}function d2(){return [".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]}function u2(){return "image/png,image/jpeg,image/gif,image/webp,image/bmp,image/svg+xml"}function p2(e,t,n,o){if(e<=n&&t<=o)return {width:e,height:t};let r=n/e,i=o/t,a=Math.min(r,i);return {width:Math.round(e*a),height:Math.round(t*a)}}function f2(e){let t=e.split(","),n=t[0].match(/:(.*?);/)?.[1]||"image/png",o=atob(t[1]),r=new Uint8Array(o.length);for(let i=0;i<o.length;i++)r[i]=o.charCodeAt(i);return new Blob([r],{type:n})}function m2(e){return new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.width,height:o.height}),o.onerror=()=>n(new Error("Failed to load image")),o.src=e;})}function g2(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var y2={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},v2={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"450px",maxWidth:"550px",width:"100%",margin:"20px",maxHeight:"80vh",display:"flex",flexDirection:"column"},S2={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},C2={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},T2={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},w2={padding:"20px",flex:1,overflow:"auto"},k2={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",marginBottom:"16px",boxSizing:"border-box"},P2={display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"16px"},Hb={padding:"6px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"12px",transition:"all 0.15s"},R2={...Hb,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)",color:"white"},E2={display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:"4px",maxHeight:"250px",overflow:"auto"},I2={width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--doc-border)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"18px",transition:"all 0.15s"},M2={marginTop:"16px",padding:"12px",backgroundColor:"var(--doc-bg-subtle)",borderRadius:"4px",display:"flex",alignItems:"center",gap:"16px"},L2={fontSize:"36px",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"white",borderRadius:"4px",border:"1px solid var(--doc-border)"},F2={flex:1},D2={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Vu={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},A2={...Vu,backgroundColor:"var(--doc-primary)",color:"white"},B2={...Vu,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},N2={...Vu,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"},mi=[{name:"common",label:"Common",symbols:["\xA9","\xAE","\u2122","\u2022","\u2026","\u2014","\u2013","\xB0","\xB1","\xD7","\xF7","\u2260","\u2264","\u2265","\u221E","\u221A","\u2211","\u220F","\u222B","\u03C0","\u20AC","\xA3","\xA5","\xA2","\xA7","\xB6","\u2020","\u2021","\u2030","\u2116"]},{name:"arrows",label:"Arrows",symbols:["\u2190","\u2191","\u2192","\u2193","\u2194","\u2195","\u2196","\u2197","\u2198","\u2199","\u21D0","\u21D1","\u21D2","\u21D3","\u21D4","\u21D5","\u27F5","\u27F6","\u27F7","\u2794","\u279C","\u279E","\u27A1","\u27A2","\u27A3","\u27A4","\u27A5","\u27A6","\u27A7","\u27A8"]},{name:"math",label:"Math",symbols:["+","\u2212","\xD7","\xF7","=","\u2260","<",">","\u2264","\u2265","\xB1","\u2213","\u221E","\u221A","\u221B","\u221C","\u2211","\u220F","\u222B","\u2202","\u2206","\u2207","\u2208","\u2209","\u220B","\u2205","\u2200","\u2203","\u2204","\u2282","\u2283","\u2286","\u2287","\u222A","\u2229","\u2295","\u2297","\u22A5","\u2220","\u221F"]},{name:"greek",label:"Greek",symbols:["\u03B1","\u03B2","\u03B3","\u03B4","\u03B5","\u03B6","\u03B7","\u03B8","\u03B9","\u03BA","\u03BB","\u03BC","\u03BD","\u03BE","\u03BF","\u03C0","\u03C1","\u03C3","\u03C4","\u03C5","\u03C6","\u03C7","\u03C8","\u03C9","\u0391","\u0392","\u0393","\u0394","\u0395","\u0396","\u0397","\u0398","\u0399","\u039A","\u039B","\u039C","\u039D","\u039E","\u039F","\u03A0"]},{name:"shapes",label:"Shapes",symbols:["\u25A0","\u25A1","\u25AA","\u25AB","\u25AC","\u25AD","\u25AE","\u25AF","\u25B0","\u25B1","\u25B2","\u25B3","\u25B4","\u25B5","\u25B6","\u25B7","\u25B8","\u25B9","\u25BA","\u25BB","\u25BC","\u25BD","\u25BE","\u25BF","\u25C0","\u25C1","\u25C2","\u25C3","\u25C4","\u25C5","\u25CF","\u25CB","\u25CE","\u25C9","\u25CC","\u25CD","\u25D0","\u25D1","\u25D2","\u25D3"]},{name:"punctuation",label:"Punctuation",symbols:["\u2013","\u2014","\u2018","\u2019","\u201C","\u201D","\xAB","\xBB","\u2039","\u203A","\u2026","\xB7","\u2022","\u2023","\u2043","\u2010","\u2011","\u2012","\u2015","\u2016","\u2032","\u2033","\u2034","\u2057","\u2035","\u2036","\u2037","\u203B","\u203D","\u2042"]},{name:"currency",label:"Currency",symbols:["$","\xA2","\xA3","\xA4","\xA5","\u20A0","\u20A1","\u20A2","\u20A3","\u20A4","\u20A5","\u20A6","\u20A7","\u20A8","\u20A9","\u20AA","\u20AB","\u20AC","\u20AD","\u20AE","\u20AF","\u20B0","\u20B1","\u20B2","\u20B3","\u20B4","\u20B5","\u20B6","\u20B7","\u20B8"]},{name:"music",label:"Music",symbols:["\u2669","\u266A","\u266B","\u266C","\u266D","\u266E","\u266F","\u{1D11E}","\u{1D122}","\u{1D12A}","\u{1D12B}","\u{1D157}\u{1D165}","\u{1D158}\u{1D165}","\u{1D158}\u{1D165}\u{1D16E}","\u{1D158}\u{1D165}\u{1D16F}","\u{1D158}\u{1D165}\u{1D170}","\u{1D192}","\u{1D193}","\u{1D110}","\u{1D111}"]},{name:"emoji",label:"Emoji",symbols:["\u{1F600}","\u{1F603}","\u{1F604}","\u{1F601}","\u{1F606}","\u{1F605}","\u{1F923}","\u{1F602}","\u{1F642}","\u{1F643}","\u{1F609}","\u{1F60A}","\u{1F607}","\u{1F970}","\u{1F60D}","\u{1F929}","\u{1F618}","\u{1F617}","\u263A","\u{1F61A}","\u2764","\u{1F9E1}","\u{1F49B}","\u{1F49A}","\u{1F499}","\u{1F49C}","\u{1F5A4}","\u{1F90D}","\u{1F494}","\u2763","\u{1F44D}","\u{1F44E}","\u{1F44C}","\u270C","\u{1F91E}","\u{1F91F}","\u{1F918}","\u{1F44B}","\u{1F64F}","\u2705"]}];function Ob(){return mi.flatMap(e=>e.symbols)}function H2({isOpen:e,onClose:t,onInsert:n,recentSymbols:o=[],className:r,style:i}){let[a,s]=useState("common"),[l,d]=useState(null),[c,u]=useState(""),[p,f]=useState(null),m=useRef(null);useEffect(()=>{e&&(d(null),u(""),f(null),setTimeout(()=>m.current?.focus(),100));},[e]);let b=useMemo(()=>{if(!c.trim())return a==="recent"?o:mi.find(U=>U.name===a)?.symbols||[];let S=c.toLowerCase();return Ob().filter(_=>{let U=_.codePointAt(0)?.toString(16).toUpperCase()||"";return _.includes(S)||U.includes(S.toUpperCase())||`U+${U}`.toLowerCase().includes(S)})},[c,a,o]),g=useCallback(S=>{d(S);},[]),h=useCallback(S=>{n(S);},[n]),x=useCallback(()=>{l&&n(l);},[l,n]),y=useCallback(S=>{S.key==="Escape"?t():S.key==="Enter"&&l&&(S.preventDefault(),x());},[t,l,x]),k=useCallback(S=>{S.target===S.currentTarget&&t();},[t]),T=S=>{if(!S)return null;let N=S.codePointAt(0);return {character:S,codePoint:N?`U+${N.toString(16).toUpperCase().padStart(4,"0")}`:"",decimal:N||0}};if(!e)return null;let B=T(p||l),R=l!==null,E=[...o.length>0?[{name:"recent",label:"Recent"}]:[],...mi.map(S=>({name:S.name,label:S.label}))];return jsx("div",{className:`docx-insert-symbol-dialog-overlay ${r||""}`,style:{...y2,...i},onClick:k,onKeyDown:y,role:"dialog","aria-modal":"true","aria-labelledby":"insert-symbol-dialog-title",children:jsxs("div",{className:"docx-insert-symbol-dialog",style:v2,children:[jsxs("div",{className:"docx-insert-symbol-dialog-header",style:S2,children:[jsx("h2",{id:"insert-symbol-dialog-title",style:C2,children:"Insert Symbol"}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-close",style:T2,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-symbol-dialog-body",style:w2,children:[jsx("input",{ref:m,type:"text",placeholder:"Search symbols (character or Unicode)...",value:c,onChange:S=>u(S.target.value),style:k2}),!c&&jsx("div",{className:"docx-insert-symbol-categories",style:P2,children:E.map(S=>jsx("button",{type:"button",onClick:()=>s(S.name),style:a===S.name?R2:Hb,children:S.label},S.name))}),jsx("div",{className:"docx-insert-symbol-grid",style:E2,children:b.map((S,N)=>jsx("button",{type:"button",onClick:()=>g(S),onDoubleClick:()=>h(S),onMouseEnter:()=>f(S),onMouseLeave:()=>f(null),style:{...I2,...l===S?{backgroundColor:"var(--doc-primary-light)",borderColor:"var(--doc-primary)"}:{}},title:`${S} - U+${S.codePointAt(0)?.toString(16).toUpperCase()}`,children:S},`${S}-${N}`))}),b.length===0&&jsxs("div",{style:{textAlign:"center",padding:"20px",color:"var(--doc-text-muted)"},children:['No symbols found for "',c,'"']}),B&&jsxs("div",{className:"docx-insert-symbol-preview",style:M2,children:[jsx("div",{style:L2,children:B.character}),jsxs("div",{style:F2,children:[jsx("div",{style:{fontSize:"14px",fontWeight:500,marginBottom:"4px"},children:B.codePoint}),jsxs("div",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:["Decimal: ",B.decimal]})]})]})]}),jsxs("div",{className:"docx-insert-symbol-dialog-footer",style:D2,children:[jsx("button",{type:"button",className:"docx-insert-symbol-dialog-cancel",style:B2,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-insert",style:R?A2:N2,onClick:x,disabled:!R,children:"Insert"})]})]})})}function O2(e=20){let[t,n]=useState(false),[o,r]=useState([]),i=useCallback(()=>n(true),[]),a=useCallback(()=>n(false),[]),s=useCallback(()=>n(d=>!d),[]),l=useCallback(d=>{r(c=>{let u=c.filter(p=>p!==d);return [d,...u].slice(0,e)});},[e]);return {isOpen:t,recentSymbols:o,open:i,close:a,toggle:s,addRecent:l}}function z2(){return mi}function _2(e){return mi.find(n=>n.name===e)?.symbols||[]}function $2(e){let t=e.codePointAt(0)||0;return {character:e,codePoint:`U+${t.toString(16).toUpperCase().padStart(4,"0")}`,decimal:t,hex:t.toString(16).toUpperCase()}}function W2(e){if(!e.trim())return [];let t=e.toLowerCase();return Ob().filter(n=>{let o=n.codePointAt(0)?.toString(16).toUpperCase()||"";return n.includes(e)||o.includes(t.toUpperCase())||`U+${o}`.toLowerCase().includes(t)})}function V2(e){let t=e.replace(/^U\+/i,"").replace(/^0x/i,""),n=parseInt(t,16);return isNaN(n)||n<0||n>1114111?null:String.fromCodePoint(n)}ia();var Er=[{id:"formatted",label:"Keep Source Formatting",description:"Paste with original formatting",shortcut:"Ctrl+V"},{id:"plainText",label:"Paste as Plain Text",description:"Paste without any formatting",shortcut:"Ctrl+Shift+V"}],X2=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M4 4h12v2H4V4zM4 8h8v2H4V8zM4 12h10v2H4v-2zM4 16h6v2H4v-2z",fill:"currentColor"}),jsx("path",{d:"M14 10l3 3-3 3v-2h-2v-2h2v-2z",fill:"currentColor",opacity:"0.6"})]}),J2=()=>jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4 4h12v1H4V4zM4 7h12v1H4V7zM4 10h12v1H4v-1zM4 13h12v1H4v-1zM4 16h8v1H4v-1z",fill:"currentColor"})});function Q2(e){switch(e){case "formatted":return jsx(X2,{});case "plainText":return jsx(J2,{});default:return null}}var eL=({option:e,isSelected:t,onClick:n,onMouseEnter:o})=>jsxs("button",{type:"button",className:`docx-paste-special-option ${t?"docx-paste-special-option-selected":""}`,onClick:n,onMouseEnter:o,role:"menuitem","aria-selected":t,style:{display:"flex",alignItems:"center",gap:"12px",width:"100%",padding:"12px 16px",border:"none",background:t?"var(--doc-primary-light)":"transparent",cursor:"pointer",textAlign:"left",borderRadius:"4px",transition:"background-color 0.15s ease"},children:[jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",borderRadius:"4px",background:t?"var(--doc-primary)":"var(--doc-bg-hover)",color:t?"white":"var(--doc-text-muted)"},children:Q2(e.id)}),jsxs("div",{style:{flex:1},children:[jsx("div",{style:{fontSize:"14px",fontWeight:500,color:"var(--doc-text)",marginBottom:"2px"},children:e.label}),jsx("div",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:e.description})]}),jsx("span",{style:{fontSize:"11px",color:"var(--doc-text-subtle)",fontFamily:"monospace"},children:e.shortcut})]}),tL=({isOpen:e,onClose:t,onPaste:n,position:o,className:r=""})=>{let i=useRef(null),[a,s]=useState(0),[l,d]=useState(null),[c,u]=useState(false),[p,f]=useState(null);useEffect(()=>{if(!e){d(null),f(null),s(0);return}(async()=>{u(true),f(null);try{let h=await hi({cleanWordFormatting:!0});d(h),h||f("No content available to paste");}catch{f("Unable to read clipboard. Please use Ctrl+V to paste.");}finally{u(false);}})();},[e]),useEffect(()=>{if(!e)return;let g=h=>{i.current&&!i.current.contains(h.target)&&t();};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[e,t]),useEffect(()=>{if(!e)return;let g=h=>{switch(h.key){case "Escape":h.preventDefault(),t();break;case "ArrowDown":h.preventDefault(),s(x=>(x+1)%Er.length);break;case "ArrowUp":h.preventDefault(),s(x=>(x-1+Er.length)%Er.length);break;case "Enter":h.preventDefault(),m(Er[a].id);break}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e,a,t]);let m=useCallback(g=>{if(!l){f("No content available to paste");return}n(l,g==="plainText"),t();},[l,n,t]),b=useCallback(()=>{let x=o?.x??(typeof window<"u"?window.innerWidth/2-160:100),y=o?.y??(typeof window<"u"?window.innerHeight/2-200/2:100);return typeof window<"u"&&(x+320>window.innerWidth&&(x=window.innerWidth-320-10),y+200>window.innerHeight&&(y=window.innerHeight-200-10),x<10&&(x=10),y<10&&(y=10)),{position:"fixed",top:y,left:x,width:320,background:"white",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",zIndex:10001,overflow:"hidden"}},[o]);return e?jsxs("div",{ref:i,className:`docx-paste-special-dialog ${r}`,style:b(),role:"dialog","aria-label":"Paste Special",children:[jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--doc-border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"var(--doc-text)"},children:"Paste Special"}),jsx("button",{type:"button",onClick:t,"aria-label":"Close",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"4px",color:"var(--doc-text-muted)"},children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),jsx("div",{style:{padding:"8px"},children:c?jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--doc-text-muted)",fontSize:"13px"},children:"Reading clipboard..."}):p?jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--doc-error)",fontSize:"13px"},children:p}):jsx("div",{role:"menu",children:Er.map((g,h)=>jsx(eL,{option:g,isSelected:h===a,onClick:()=>m(g.id),onMouseEnter:()=>s(h)},g.id))})}),l&&!c&&!p&&jsxs("div",{style:{padding:"8px 16px 12px",borderTop:"1px solid var(--doc-border)"},children:[jsx("div",{style:{fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px"},children:"Preview:"}),jsxs("div",{style:{fontSize:"12px",color:"var(--doc-text)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",padding:"6px 8px",background:"var(--doc-bg)",borderRadius:"4px"},children:['"',l.plainText.slice(0,50),l.plainText.length>50?"...":"",'"']})]})]}):null};function nL(e={}){let{onPaste:t,enabled:n=true}=e,[o,r]=useState(false),i=useCallback(()=>{n&&r(true);},[n]),a=useCallback(()=>{r(false);},[]),s=useCallback(async()=>{if(!(!n||!t))try{let d=await hi({cleanWordFormatting:!0});d&&t(d,!0);}catch(d){console.error("Failed to paste as plain text:",d);}},[n,t]),l=useCallback(d=>n&&(d.ctrlKey||d.metaKey)&&d.shiftKey&&d.key.toLowerCase()==="v"?(d.preventDefault(),i(),true):false,[n,i]);return {isOpen:o,openDialog:i,closeDialog:a,handleKeyDown:l,pasteAsPlainText:s}}function oL(e){return Er.find(t=>t.id===e)}function rL(){return [...Er]}function iL(){return "formatted"}function aL(e){return (e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()==="v"}var Kb={editing:"Editing",formatting:"Formatting",navigation:"Navigation",clipboard:"Clipboard",selection:"Selection",view:"View",file:"File",other:"Other"},Gb=["file","editing","clipboard","formatting","selection","navigation","view","other"],Vl=[{id:"save",name:"Save",description:"Save document",keys:"Ctrl+S",category:"file",common:true},{id:"print",name:"Print",description:"Print document",keys:"Ctrl+P",category:"file"},{id:"undo",name:"Undo",description:"Undo last action",keys:"Ctrl+Z",category:"editing",common:true},{id:"redo",name:"Redo",description:"Redo last action",keys:"Ctrl+Y",altKeys:"Ctrl+Shift+Z",category:"editing",common:true},{id:"delete",name:"Delete",description:"Delete selected text",keys:"Del",altKeys:"Backspace",category:"editing"},{id:"find",name:"Find",description:"Find text in document",keys:"Ctrl+F",category:"editing",common:true},{id:"replace",name:"Find & Replace",description:"Find and replace text",keys:"Ctrl+H",category:"editing"},{id:"cut",name:"Cut",description:"Cut selected text",keys:"Ctrl+X",category:"clipboard",common:true},{id:"copy",name:"Copy",description:"Copy selected text",keys:"Ctrl+C",category:"clipboard",common:true},{id:"paste",name:"Paste",description:"Paste from clipboard",keys:"Ctrl+V",category:"clipboard",common:true},{id:"paste-plain",name:"Paste as Plain Text",description:"Paste without formatting",keys:"Ctrl+Shift+V",category:"clipboard"},{id:"bold",name:"Bold",description:"Toggle bold formatting",keys:"Ctrl+B",category:"formatting",common:true},{id:"italic",name:"Italic",description:"Toggle italic formatting",keys:"Ctrl+I",category:"formatting",common:true},{id:"underline",name:"Underline",description:"Toggle underline formatting",keys:"Ctrl+U",category:"formatting",common:true},{id:"strikethrough",name:"Strikethrough",description:"Toggle strikethrough",keys:"Ctrl+Shift+X",category:"formatting"},{id:"subscript",name:"Subscript",description:"Toggle subscript",keys:"Ctrl+=",category:"formatting"},{id:"superscript",name:"Superscript",description:"Toggle superscript",keys:"Ctrl+Shift+=",category:"formatting"},{id:"align-left",name:"Align Left",description:"Left align paragraph",keys:"Ctrl+L",category:"formatting"},{id:"align-center",name:"Align Center",description:"Center align paragraph",keys:"Ctrl+E",category:"formatting"},{id:"align-right",name:"Align Right",description:"Right align paragraph",keys:"Ctrl+R",category:"formatting"},{id:"align-justify",name:"Justify",description:"Justify paragraph",keys:"Ctrl+J",category:"formatting"},{id:"indent",name:"Increase Indent",description:"Increase paragraph indent",keys:"Tab",category:"formatting"},{id:"outdent",name:"Decrease Indent",description:"Decrease paragraph indent",keys:"Shift+Tab",category:"formatting"},{id:"select-all",name:"Select All",description:"Select all content",keys:"Ctrl+A",category:"selection",common:true},{id:"select-word",name:"Select Word",description:"Select current word",keys:"Double-click",category:"selection"},{id:"select-paragraph",name:"Select Paragraph",description:"Select current paragraph",keys:"Triple-click",category:"selection"},{id:"extend-selection-word",name:"Extend Selection by Word",description:"Extend selection to next/previous word",keys:"Ctrl+Shift+Arrow",category:"selection"},{id:"extend-selection-line",name:"Extend Selection to Line Edge",description:"Extend selection to line start/end",keys:"Shift+Home/End",category:"selection"},{id:"move-word",name:"Move by Word",description:"Move cursor to next/previous word",keys:"Ctrl+Arrow",category:"navigation"},{id:"move-line-start",name:"Move to Line Start",description:"Move cursor to start of line",keys:"Home",category:"navigation"},{id:"move-line-end",name:"Move to Line End",description:"Move cursor to end of line",keys:"End",category:"navigation"},{id:"move-doc-start",name:"Move to Document Start",description:"Move cursor to start of document",keys:"Ctrl+Home",category:"navigation"},{id:"move-doc-end",name:"Move to Document End",description:"Move cursor to end of document",keys:"Ctrl+End",category:"navigation"},{id:"page-up",name:"Page Up",description:"Scroll up one page",keys:"Page Up",category:"navigation"},{id:"page-down",name:"Page Down",description:"Scroll down one page",keys:"Page Down",category:"navigation"},{id:"zoom-in",name:"Zoom In",description:"Increase zoom level",keys:"Ctrl++",altKeys:"Ctrl+Scroll Up",category:"view"},{id:"zoom-out",name:"Zoom Out",description:"Decrease zoom level",keys:"Ctrl+-",altKeys:"Ctrl+Scroll Down",category:"view"},{id:"zoom-reset",name:"Reset Zoom",description:"Reset zoom to 100%",keys:"Ctrl+0",category:"view"},{id:"shortcuts",name:"Keyboard Shortcuts",description:"Show this help dialog",keys:"Ctrl+/",altKeys:"F1",category:"view"}];function sL(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function Qu(e){return sL()?e.replace(/Ctrl\+/g,"\u2318").replace(/Alt\+/g,"\u2325").replace(/Shift\+/g,"\u21E7"):e}var lL=({shortcut:e})=>{let t=Qu(e.keys),n=e.altKeys?Qu(e.altKeys):null;return jsxs("div",{className:"docx-shortcut-item",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 0",borderBottom:"1px solid var(--doc-border-light)"},children:[jsxs("div",{style:{flex:1},children:[jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--doc-text)"},children:e.name}),jsx("div",{style:{fontSize:"11px",color:"var(--doc-text-muted)",marginTop:"2px"},children:e.description})]}),jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[jsx("kbd",{style:{display:"inline-flex",alignItems:"center",padding:"4px 8px",fontSize:"12px",fontFamily:"monospace",color:"var(--doc-text)",backgroundColor:"var(--doc-bg-hover)",borderRadius:"4px",border:"1px solid var(--doc-border-light)",boxShadow:"0 1px 1px rgba(0,0,0,0.1)"},children:t}),n&&jsxs(Fragment$1,{children:[jsx("span",{style:{color:"var(--doc-text-subtle)",fontSize:"11px"},children:"or"}),jsx("kbd",{style:{display:"inline-flex",alignItems:"center",padding:"4px 8px",fontSize:"12px",fontFamily:"monospace",color:"var(--doc-text)",backgroundColor:"var(--doc-bg-hover)",borderRadius:"4px",border:"1px solid var(--doc-border-light)",boxShadow:"0 1px 1px rgba(0,0,0,0.1)"},children:n})]})]})]})},cL=({isOpen:e,onClose:t,customShortcuts:n=[],showSearch:o=true,className:r=""})=>{let i=useRef(null),a=useRef(null),[s,l]=useState(""),d=useMemo(()=>{let p=[...Vl];for(let f of n){let m=p.findIndex(b=>b.id===f.id);m>=0?p[m]=f:p.push(f);}return p},[n]),c=useMemo(()=>{if(!s.trim())return d;let p=s.toLowerCase();return d.filter(f=>f.name.toLowerCase().includes(p)||f.description.toLowerCase().includes(p)||f.keys.toLowerCase().includes(p)||f.altKeys&&f.altKeys.toLowerCase().includes(p))},[d,s]),u=useMemo(()=>{let p=new Map;for(let m of c){let b=p.get(m.category)||[];b.push(m),p.set(m.category,b);}let f=[];for(let m of Gb){let b=p.get(m);b&&b.length>0&&f.push({category:m,shortcuts:b});}return f},[c]);return useEffect(()=>{e&&o&&a.current&&setTimeout(()=>a.current?.focus(),0);},[e,o]),useEffect(()=>{e||l("");},[e]),useEffect(()=>{if(!e)return;let p=f=>{i.current&&!i.current.contains(f.target)&&t();};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,t]),useEffect(()=>{if(!e)return;let p=f=>{f.key==="Escape"&&t();};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[e,t]),e?jsx("div",{className:"docx-shortcuts-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10001},children:jsxs("div",{ref:i,className:`docx-shortcuts-dialog ${r}`,style:{width:"600px",maxWidth:"90vw",maxHeight:"80vh",backgroundColor:"white",borderRadius:"12px",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},role:"dialog","aria-label":"Keyboard Shortcuts",children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},children:[jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},children:"Keyboard Shortcuts"}),jsx("button",{type:"button",onClick:t,"aria-label":"Close",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"50%",color:"var(--doc-text-muted)"},children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),o&&jsx("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--doc-border)"},children:jsx("input",{ref:a,type:"text",value:s,onChange:p=>l(p.target.value),placeholder:"Search shortcuts...",style:{width:"100%",padding:"10px 12px",fontSize:"14px",border:"1px solid var(--doc-border-light)",borderRadius:"6px",outline:"none"}})}),jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:u.length===0?jsxs("div",{style:{textAlign:"center",padding:"32px",color:"var(--doc-text-muted)"},children:['No shortcuts found matching "',s,'"']}):u.map(({category:p,shortcuts:f})=>jsxs("div",{style:{marginBottom:"24px"},children:[jsx("h3",{style:{margin:"0 0 12px 0",fontSize:"13px",fontWeight:600,color:"var(--doc-primary)",textTransform:"uppercase",letterSpacing:"0.5px"},children:Kb[p]}),jsx("div",{children:f.map(m=>jsx(lL,{shortcut:m},m.id))})]},p))}),jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",fontSize:"12px",color:"var(--doc-text-muted)",textAlign:"center"},children:["Press"," ",jsx("kbd",{style:{padding:"2px 6px",backgroundColor:"white",borderRadius:"4px",border:"1px solid var(--doc-border-light)"},children:"Esc"})," ","to close"]})]})}):null};function dL(e={}){let{enabled:t=true,openShortcut:n="Ctrl+/"}=e,[o,r]=useState(false),i=useCallback(()=>{t&&r(true);},[t]),a=useCallback(()=>{r(false);},[]),s=useCallback(()=>{r(d=>!d);},[]),l=useCallback(d=>{if(!t)return;if((d.ctrlKey||d.metaKey)&&(d.key==="/"||d.key==="?")){d.preventDefault(),s();return}if(d.key==="F1"){d.preventDefault(),i();return}},[t,s,i]);return useEffect(()=>{if(t)return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,l]),{isOpen:o,open:i,close:a,toggle:s,handleKeyDown:l}}function uL(){return [...Vl]}function pL(e){return Vl.filter(t=>t.category===e)}function fL(){return Vl.filter(e=>e.common)}function mL(e){return Kb[e]}function gL(){return [...Gb]}function hL(e){return Qu(e)}var Yb="docx-editor-autosave",xL=3e4,yL=1440*60*1e3,vL=2e3,Ul=1;function jb(){try{let e="__docx_editor_test__";return localStorage.setItem(e,"test"),localStorage.removeItem(e),!0}catch{return false}}function SL(e){let t={...e,originalBuffer:null};return JSON.stringify(t)}function CL(e){try{let t=JSON.parse(e);return !t||typeof t!="object"||!t.document||!t.savedAt?null:(t.version!==Ul&&console.warn("Auto-save data version mismatch, may need migration"),t)}catch{return null}}function TL(e,t){let n=new Date(e).getTime();return Date.now()-n>t}function wL(e,t={}){let{storageKey:n=Yb,interval:o=xL,enabled:r=true,maxAge:i=yL,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:d=true,debounceDelay:c=vL}=t,[u,p]=useState("idle"),[f,m]=useState(null),[b,g]=useState(false),[h,x]=useState(r),y=useRef(e),k=useRef(null),T=useRef(null),A=useRef(null),B=useRef(jb());useEffect(()=>{y.current=e;},[e]);let R=useCallback(async()=>{if(!B.current)return s?.(new Error("localStorage is not available")),false;let L=y.current;if(!L)return false;p("saving");try{let H=SL(L);if(H===A.current)return p("saved"),!0;let q={document:L,savedAt:new Date().toISOString(),version:Ul},xe={document:{...L,originalBuffer:null},savedAt:q.savedAt,version:Ul};localStorage.setItem(n,JSON.stringify(xe)),A.current=H;let ie=new Date;return m(ie),p("saved"),a?.(ie),!0}catch(H){return console.error("Auto-save failed:",H),p("error"),s?.(H),false}},[n,a,s]),E=useCallback(()=>{if(B.current)try{localStorage.removeItem(n),g(!1),A.current=null;}catch(L){console.error("Failed to clear auto-save:",L);}},[n]),S=useCallback(()=>{if(!B.current)return null;try{let L=localStorage.getItem(n);if(!L)return null;let H=CL(L);return H?TL(H.savedAt,i)?(E(),null):H:null}catch{return null}},[n,i,E]),N=useCallback(()=>{let L=S();return L?(g(false),L.document):null},[S]),_=useCallback(()=>{E(),g(false);},[E]),U=useCallback(()=>{x(true);},[]),Z=useCallback(()=>{x(false),k.current&&(clearInterval(k.current),k.current=null),T.current&&(clearTimeout(T.current),T.current=null);},[]);return useEffect(()=>{if(!B.current)return;let L=S();L&&(g(true),l?.(L));},[S,l]),useEffect(()=>{if(!h||!B.current){k.current&&(clearInterval(k.current),k.current=null);return}return k.current=setInterval(()=>{R();},o),()=>{k.current&&(clearInterval(k.current),k.current=null);}},[h,o,R]),useEffect(()=>{if(!(!h||!d||!e||!B.current))return T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{R();},c),()=>{T.current&&clearTimeout(T.current);}},[h,d,e,c,R]),useEffect(()=>()=>{if(h&&y.current&&B.current)try{let H={document:{...y.current,originalBuffer:null},savedAt:new Date().toISOString(),version:Ul};localStorage.setItem(n,JSON.stringify(H));}catch(L){console.error("Failed to save on unmount:",L);}},[h,n]),{status:u,lastSaveTime:f,save:R,clearAutoSave:E,hasRecoveryData:b,getRecoveryData:S,acceptRecovery:N,dismissRecovery:_,isEnabled:h,enable:U,disable:Z}}function kL(e){if(!e)return "Never";let n=new Date().getTime()-e.getTime(),o=Math.floor(n/1e3),r=Math.floor(o/60),i=Math.floor(r/60);return o<10?"Just now":o<60?`${o} seconds ago`:r<60?`${r} minute${r===1?"":"s"} ago`:i<24?`${i} hour${i===1?"":"s"} ago`:e.toLocaleDateString()}function PL(e){return {idle:"Ready",saving:"Saving...",saved:"Saved",error:"Save failed"}[e]}function RL(e=Yb){try{let t=localStorage.getItem(e);return t?new Blob([t]).size:0}catch{return 0}}function EL(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function IL(){return jb()}var FL=1,Xb=.25,Jb=4,DL=.1,Pn=[.25,.5,.75,1,1.25,1.5,2,3,4];function Qb(e,t,n){return Math.max(t,Math.min(n,e))}function e0(e){return Math.round(e*100)/100}function AL(e){let t=Pn[0],n=Math.abs(e-t);for(let o of Pn){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function BL(e){for(let t of Pn)if(t>e+.01)return t;return Pn[Pn.length-1]}function NL(e){for(let t=Pn.length-1;t>=0;t--)if(Pn[t]<e-.01)return Pn[t];return Pn[0]}function HL(e={}){let{initialZoom:t=FL,minZoom:n=Xb,maxZoom:o=Jb,zoomStep:r=DL,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:d=true}=e,[c,u]=useState(t),p=useRef(c);useEffect(()=>{p.current=c;},[c]);let f=useCallback(T=>{let A=e0(Qb(T,n,o));A!==p.current&&(u(A),s?.(A));},[n,o,s]),m=useCallback(()=>{f(p.current+r);},[r,f]),b=useCallback(()=>{f(p.current-r);},[r,f]),g=useCallback(()=>{f(t);},[t,f]),h=useCallback(()=>{f(1);},[f]),x=useCallback((T,A)=>{if(A>0){let B=T/A;f(B);}},[f]),y=useCallback(T=>{if(!i||!(T.ctrlKey||T.metaKey))return;d&&T.preventDefault();let B=T.deltaY;B<0?f(p.current+r):B>0&&f(p.current-r);},[i,d,r,f]),k=useCallback(T=>{if(!(!i||!l||!(T.ctrlKey||T.metaKey))){if(T.key==="0"){T.preventDefault(),h();return}if(T.key==="+"||T.key==="="){T.preventDefault(),m();return}if(T.key==="-"){T.preventDefault(),b();return}}},[i,l,m,b,h]);return useEffect(()=>{if(!i)return;let T=a?.current;if(T)return T.addEventListener("wheel",y,{passive:false}),()=>{T.removeEventListener("wheel",y);}},[i,a,y]),useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k);}},[i,l,k]),{zoom:c,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:g,zoomTo100:h,zoomToFit:x,isMinZoom:c<=n,isMaxZoom:c>=o,zoomPercent:Math.round(c*100),handleWheel:y,handleKeyDown:k}}function OL(){return [...Pn]}function zL(e){return AL(e)}function _L(e){return BL(e)}function $L(e){return NL(e)}function WL(e){return `${Math.round(e*100)}%`}function VL(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function ZL(e){return Pn.some(t=>Math.abs(t-e)<.01)}function UL(e,t=Xb,n=Jb){return e0(Qb(e,t,n))}function t0(){return {type:"break",breakType:"page"}}function qL(){return {type:"break",breakType:"column"}}function KL(e){return {type:"break",breakType:"textWrapping",clear:e}}function GL(){return {type:"run",content:[t0()]}}function n0(){return {type:"paragraph",content:[],formatting:{pageBreakBefore:true}}}function o0(e){return e.content.filter(t=>t.type==="run")}function YL(e,t){let{paragraphIndex:n}=t,o=[...e.package.document.content||[]],r=n0();return o.splice(n+1,0,r),{...e,package:{...e.package,document:{...e.package.document,content:o}}}}function r0(){return {type:"paragraph",content:[],formatting:{borders:{bottom:{style:"single",color:{rgb:"000000"},size:12,space:1}},spaceBefore:120,spaceAfter:120}}}function jL(e,t){let{paragraphIndex:n}=t,o=[...e.package.document.content||[]],r=r0();return o.splice(n+1,0,r),{...e,package:{...e.package,document:{...e.package.document,content:o}}}}function ql(e){return e.type==="break"&&e.breakType==="page"}function XL(e){return e.type==="break"&&e.breakType==="column"}function JL(e){return e.type==="break"&&e.breakType==="textWrapping"}function QL(e){return e.type==="break"}function Kl(e){return e.formatting?.pageBreakBefore===true}function eF(e){let t=0;for(let n of e.package.document.content||[])if(n.type==="paragraph"){let o=n;Kl(o)&&t++;let r=o0(o);for(let i of r)for(let a of i.content)ql(a)&&t++;}return t}function tF(e){let t=[],n=e.package.document.content||[];for(let o=0;o<n.length;o++){let r=n[o];if(r.type==="paragraph"){let i=r;Kl(i)&&t.push({paragraphIndex:o});let a=o0(i);for(let s=0;s<a.length;s++){let l=a[s];for(let d of l.content)ql(d)&&t.push({paragraphIndex:o,runIndex:s});}}}return t}function nF(e,t){let{paragraphIndex:n,runIndex:o}=t,r=[...e.package.document.content||[]],i=r[n];if(i.type!=="paragraph")return e;let a=i;if(Kl(a)&&o===void 0)return r[n]={...a,formatting:{...a.formatting,pageBreakBefore:false}},{...e,package:{...e.package,document:{...e.package.document,content:r}}};if(o!==void 0){let s=[],l=0;for(let d of a.content)if(d.type==="run"){if(l===o){let c=d.content.filter(u=>!ql(u));c.length>0&&s.push({...d,content:c});}else s.push(d);l++;}else s.push(d);return r[n]={...a,content:s},{...e,package:{...e.package,document:{...e.package.document,content:r}}}}return e}var Lr={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},oF={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},rF={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function tp(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 i0(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 d=Math.max(r.left+r.width,a.left+a.width);r.width=d-r.left,r.height=Math.max(r.height,a.height);}else o.push(r),r={...a};}return o.push(r),o}function Gl(e){let t=tp(e);return i0(t)}function iF(e,t=Lr){return {position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}function aF(e,t=Lr){let n=t.backgroundColor;return `
|
|
142
|
-
${e}::selection,
|
|
143
|
-
${e} *::selection {
|
|
144
|
-
background-color: ${n} !important;
|
|
145
|
-
color: inherit !important;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
${e}::-moz-selection,
|
|
149
|
-
${e} *::-moz-selection {
|
|
150
|
-
background-color: ${n} !important;
|
|
151
|
-
color: inherit !important;
|
|
152
|
-
}
|
|
153
|
-
`}function np(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function op(){let e=window.getSelection();return e?e.toString():""}function rp(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function sF(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function lF(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function cF(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function dF(){let e=window.getSelection();e&&e.removeAllRanges();}function a0(){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 uF(){let e=window.getSelection();if(!e||e.rangeCount===0||!a0())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 er=null;function ip(e=Lr){s0();let t=`
|
|
154
|
-
/* DOCX Editor Selection Highlighting */
|
|
155
|
-
|
|
156
|
-
/* Base selection style for all editable content */
|
|
157
|
-
.docx-editor [contenteditable="true"]::selection,
|
|
158
|
-
.docx-editor [contenteditable="true"] *::selection,
|
|
159
|
-
.docx-run-editable::selection,
|
|
160
|
-
.docx-run-editable *::selection {
|
|
161
|
-
background-color: ${e.backgroundColor} !important;
|
|
162
|
-
color: inherit !important;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* Firefox selection */
|
|
166
|
-
.docx-editor [contenteditable="true"]::-moz-selection,
|
|
167
|
-
.docx-editor [contenteditable="true"] *::-moz-selection,
|
|
168
|
-
.docx-run-editable::-moz-selection,
|
|
169
|
-
.docx-run-editable *::-moz-selection {
|
|
170
|
-
background-color: ${e.backgroundColor} !important;
|
|
171
|
-
color: inherit !important;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/* Ensure selection is visible against all backgrounds */
|
|
175
|
-
.docx-run-highlighted::selection,
|
|
176
|
-
.docx-run-highlighted *::selection {
|
|
177
|
-
/* For highlighted (yellow background) text, use darker selection */
|
|
178
|
-
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.docx-run-highlighted::-moz-selection,
|
|
182
|
-
.docx-run-highlighted *::-moz-selection {
|
|
183
|
-
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/* Selection in dark text */
|
|
187
|
-
.docx-run-dark-bg::selection,
|
|
188
|
-
.docx-run-dark-bg *::selection {
|
|
189
|
-
/* Use lighter selection for dark backgrounds */
|
|
190
|
-
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.docx-run-dark-bg::-moz-selection,
|
|
194
|
-
.docx-run-dark-bg *::-moz-selection {
|
|
195
|
-
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/* Programmatic highlight class */
|
|
199
|
-
.docx-selection-highlight {
|
|
200
|
-
background-color: ${e.backgroundColor};
|
|
201
|
-
${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
|
|
202
|
-
${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/* Find/replace highlight */
|
|
206
|
-
.docx-find-highlight {
|
|
207
|
-
background-color: rgba(255, 235, 59, 0.5);
|
|
208
|
-
border-radius: 2px;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.docx-find-highlight-current {
|
|
212
|
-
background-color: rgba(255, 152, 0, 0.6);
|
|
213
|
-
border-radius: 2px;
|
|
214
|
-
outline: 2px solid rgba(255, 152, 0, 0.8);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/* AI action selection preview */
|
|
218
|
-
.docx-ai-selection-preview {
|
|
219
|
-
background-color: rgba(156, 39, 176, 0.2);
|
|
220
|
-
border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
|
|
221
|
-
}
|
|
222
|
-
`;er=document.createElement("style"),er.id="docx-selection-styles",er.textContent=t,document.head.appendChild(er);}function s0(){er&&(er.remove(),er=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function ap(){return er!==null||document.getElementById("docx-selection-styles")!==null}function pF(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?Gl(e):tp(e);t(o);}}function mF(e){let{containerRef:t,enabled:n=true,config:o=Lr,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=useState(false),[d,c]=useState(""),[u,p]=useState([]),[f,m]=useState(false),b=useRef(null),g=useRef(0),h=useCallback(()=>{let T=t.current,A=np(),B=op(),R=T?rp(T):false;if(l(A),c(B),m(R),r&&R){let E=Gl(T);p(E);}else p([]);a&&a(A&&R,B);},[t,r,a]),x=useCallback(()=>{let T=performance.now();if(T-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),h(),b.current=null;},i);return}g.current=T,h();},[i,h]),y=useCallback(()=>{h();},[h]),k=useCallback(T=>({position:"absolute",left:`${T.left}px`,top:`${T.top}px`,width:`${T.width}px`,height:`${T.height}px`,backgroundColor:o.backgroundColor,borderRadius:o.borderRadius?`${o.borderRadius}px`:void 0,border:o.borderColor?`1px solid ${o.borderColor}`:void 0,zIndex:o.zIndex??0,opacity:o.opacity??1,mixBlendMode:o.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[o]);return useEffect(()=>(n&&!ap()&&ip(o),()=>{}),[n,o]),useEffect(()=>{if(!n)return;let T=()=>{x();};return document.addEventListener("selectionchange",T),document.addEventListener("mouseup",T),h(),()=>{document.removeEventListener("selectionchange",T),document.removeEventListener("mouseup",T),b.current!==null&&clearTimeout(b.current);}},[n,x,h]),{hasSelection:s,selectedText:d,highlightRects:u,isSelectionInContainer:f,refresh:y,getOverlayStyle:k}}function gF(e,t=Lr){return e.map((n,o)=>cn__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"}}))}var hF=/[\p{L}\p{N}''\-]/u,bF=/\s/;function Xl(e){return !e||e.length===0?false:hF.test(e)}function Jl(e){return !e||e.length===0?false:bF.test(e)}function tr(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let n=e[t];if(Jl(n)){let o=t,r=t;for(;o>0&&Jl(e[o-1]);)o--;for(;r<e.length&&Jl(e[r]);)r++;return [o,r]}if(Xl(n)){let o=t,r=t;for(;o>0&&Xl(e[o-1]);)o--;for(;r<e.length&&Xl(e[r]);)r++;return [o,r]}return [t,t+1]}function xF(e,t){let[n,o]=tr(e,t);return e.slice(n,o)}function yF(e,t){let[n,o]=tr(e,t);return {word:e.slice(n,o),startIndex:n,endIndex:o}}function cp(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),n=t.startContainer;if(n.nodeType===Node.TEXT_NODE){let o=n.textContent||"",r=t.startOffset,[i,a]=tr(o,r);if(a>i)return t.setStart(n,i),t.setEnd(n,a),e.removeAllRanges(),e.addRange(t),true}if(n.nodeType===Node.ELEMENT_NODE){let o=n,r=d0(o);if(r.length>0){let i=t.startOffset,a=null,s=i;if(i<o.childNodes.length){let l=o.childNodes[i];if(l.nodeType===Node.TEXT_NODE)a=l,s=0;else if(l instanceof Element){let d=d0(l);d.length>0&&(a=d[0],s=0);}}if(!a&&r.length>0&&(a=r[0],s=0),a){let l=a.textContent||"",[d,c]=tr(l,s);if(c>d){let u=document.createRange();return u.setStart(a,d),u.setEnd(a,c),e.removeAllRanges(),e.addRange(u),true}}}}return false}function vF(e,t){let n=window.getSelection();if(!n)return false;let o=e.textContent||"",[r,i]=tr(o,t);if(i>r){let a=document.createRange();return a.setStart(e,r),a.setEnd(e,i),n.removeAllRanges(),n.addRange(a),true}return false}function SF(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return cp();let n=t.startContainer,o=t.endContainer,r=t.startOffset,i=t.endOffset;if(n.nodeType===Node.TEXT_NODE){let a=n.textContent||"",[s]=tr(a,t.startOffset);r=s;}if(o.nodeType===Node.TEXT_NODE){let a=o.textContent||"",s=Math.max(0,t.endOffset-1),[,l]=tr(a,s);i=l;}try{return t.setStart(n,r),t.setEnd(o,i),e.removeAllRanges(),e.addRange(t),!0}catch(a){return console.warn("Could not expand selection to word boundaries:",a),false}}function p0(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let n=e.getRangeAt(0).commonAncestorContainer,o=CF(n);if(o){let r=document.createRange();return r.selectNodeContents(o),e.removeAllRanges(),e.addRange(r),true}return false}function CF(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function d0(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),o;for(;o=n.nextNode();)o.nodeType===Node.TEXT_NODE&&t.push(o);return t}var sp=0,yi=null,lp=null,TF=500;function u0(){sp=0,lp=null,yi&&(clearTimeout(yi),yi=null);}function f0(e){return e.target!==lp&&u0(),sp++,lp=e.target,yi&&clearTimeout(yi),yi=setTimeout(u0,TF),Math.min(sp,3)}function wF(){return e=>{e.ctrlKey||e.metaKey||e.altKey||cp();}}function kF(){return e=>{if(f0(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;p0();}}}function zn(e){return e?/[\p{L}\p{N}_]/u.test(e):false}function dp(e){return e?/\s/.test(e):false}function PF(e){return e?/[\p{P}]/u.test(e):false}function RF(e,t){if(t<=0)return 0;t>e.length&&(t=e.length);let n=t;for(;n>0&&dp(e[n-1]);)n--;if(n===0)return 0;for(;n>0&&zn(e[n-1]);)n--;return n}function EF(e,t){if(t>=e.length)return e.length;t<0&&(t=0);let n=t;for(;n<e.length&&zn(e[n]);)n++;for(;n<e.length&&dp(e[n]);)n++;return n}function m0(e,t){if(t>=e.length)return e.length;let n=t;for(;n<e.length&&zn(e[n]);)n++;for(;n<e.length&&!zn(e[n]);)n++;return n}function g0(e,t){if(t<=0)return 0;let n=t;for(;n>0&&!zn(e[n-1]);)n--;for(;n>0&&zn(e[n-1]);)n--;return n}function h0(e,t){if(!window.getSelection())return null;let o=document.createRange();if(e.nodeType===Node.TEXT_NODE){o.setStart(e,Math.min(t,e.textContent?.length||0)),o.collapse(true);let i=o.getBoundingClientRect().top,a=0,s=t;for(;a<s;){let l=Math.floor((a+s)/2);o.setStart(e,l),o.collapse(true);let d=o.getBoundingClientRect();Math.abs(d.top-i)<2?s=l:a=l+1;}return {node:e,offset:a}}return null}function b0(e,t){if(!window.getSelection())return null;let o=e.textContent?.length||0,r=document.createRange();if(e.nodeType===Node.TEXT_NODE){r.setStart(e,Math.min(t,o)),r.collapse(true);let a=r.getBoundingClientRect().top,s=t,l=o;for(;s<l;){let d=Math.ceil((s+l)/2);r.setStart(e,d),r.collapse(true);let c=r.getBoundingClientRect();Math.abs(c.top-a)<2?s=d:l=d-1;}return {node:e,offset:s}}return null}function IF(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return {node:t.startContainer,offset:t.startOffset,anchorNode:e.anchorNode,anchorOffset:e.anchorOffset,focusNode:e.focusNode,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,text:e.toString()}}function Ql(e,t){let n=window.getSelection();if(!n)return;let o=document.createRange(),r=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;o.setStart(e,Math.min(t,r)),o.collapse(true),n.removeAllRanges(),n.addRange(o);}function ec(e,t){let n=window.getSelection();if(!(!n||!n.anchorNode))try{n.extend(e,Math.min(t,e.textContent?.length||0));}catch{let o=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;n.setBaseAndExtent(n.anchorNode,n.anchorOffset,e,Math.min(t,o));}}function x0(e,t=false){let n=window.getSelection();if(!n||n.rangeCount===0)return false;let o=n.focusNode;if(!o||o.nodeType!==Node.TEXT_NODE)return false;let r=o.textContent||"",i=n.focusOffset,a;return e==="left"?a=g0(r,i):a=m0(r,i),t?ec(o,a):Ql(o,a),true}function y0(e,t=false){let n=window.getSelection();if(!n||n.rangeCount===0)return false;let o=n.focusNode;if(!o)return false;if(o.nodeType===Node.TEXT_NODE){let a=e==="start"?h0(o,n.focusOffset):b0(o,n.focusOffset);if(a)return t?ec(a.node,a.offset):Ql(a.node,a.offset),true}let r=o.textContent||"",i=e==="start"?0:r.length;return t?ec(o,i):Ql(o,i),true}function v0(e){let{key:t,ctrlKey:n,metaKey:o,shiftKey:r,altKey:i}=e,a=n||o;switch(t){case "ArrowLeft":if(a)return {direction:"left",unit:"word",extend:r};break;case "ArrowRight":if(a)return {direction:"right",unit:"word",extend:r};break;case "Home":return a?{direction:"left",unit:"document",extend:r}:{direction:"left",unit:"line",extend:r};case "End":return a?{direction:"right",unit:"document",extend:r}:{direction:"right",unit:"line",extend:r}}return null}function MF(e,t){let n=v0(e);if(!n)return false;switch(n.unit){case "word":if((n.direction==="left"||n.direction==="right")&&x0(n.direction,n.extend))return e.preventDefault(),true;break;case "line":let o=n.direction==="left"?"start":"end";if(y0(o,n.extend))return e.preventDefault(),true;break;case "document":if(n.direction==="left"&&t?.onDocumentStart)return e.preventDefault(),t.onDocumentStart(),true;if(n.direction==="right"&&t?.onDocumentEnd)return e.preventDefault(),t.onDocumentEnd(),true;break}return false}function LF(e){let{key:t,ctrlKey:n,metaKey:o}=e;return !!((n||o)&&(t==="ArrowLeft"||t==="ArrowRight")||t==="Home"||t==="End")}function FF(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return false;let n=t.textContent||"",o=e.focusOffset,r=o,i=o;for(;r>0&&zn(n[r-1]);)r--;for(;i<n.length&&zn(n[i]);)i++;if(r===i)return false;let a=document.createRange();return a.setStart(t,r),a.setEnd(t,i),e.removeAllRanges(),e.addRange(a),true}function DF(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return null;let n=t.textContent||"",o=e.focusOffset,r=o,i=o;for(;r>0&&zn(n[r-1]);)r--;for(;i<n.length&&zn(n[i]);)i++;return r===i?null:n.slice(r,i)}function AF(e,t){let n=e.ctrlKey||e.metaKey,o=t.ctrlKey||t.metaKey;return e.key.toLowerCase()===t.key.toLowerCase()&&n===!!o&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}var gn={wordLeft:{key:"ArrowLeft",ctrlKey:true},wordRight:{key:"ArrowRight",ctrlKey:true},selectWordLeft:{key:"ArrowLeft",ctrlKey:true,shiftKey:true},selectWordRight:{key:"ArrowRight",ctrlKey:true,shiftKey:true},lineStart:{key:"Home"},lineEnd:{key:"End"},selectToLineStart:{key:"Home",shiftKey:true},selectToLineEnd:{key:"End",shiftKey:true},documentStart:{key:"Home",ctrlKey:true},documentEnd:{key:"End",ctrlKey:true},selectToDocumentStart:{key:"Home",ctrlKey:true,shiftKey:true},selectToDocumentEnd:{key:"End",ctrlKey:true,shiftKey:true}};function hn(e){let t=[];if(e.ctrlKey||e.metaKey){let o=typeof navigator<"u"&&/Mac/i.test(navigator.platform);t.push(o?"\u2318":"Ctrl");}e.shiftKey&&t.push("Shift"),e.altKey&&t.push("Alt");let n=e.key;return n==="ArrowLeft"?n="\u2190":n==="ArrowRight"?n="\u2192":n==="ArrowUp"?n="\u2191":n==="ArrowDown"&&(n="\u2193"),t.push(n),t.join("+")}function BF(){return [{action:"Move by word (left)",shortcut:hn(gn.wordLeft)},{action:"Move by word (right)",shortcut:hn(gn.wordRight)},{action:"Select word (left)",shortcut:hn(gn.selectWordLeft)},{action:"Select word (right)",shortcut:hn(gn.selectWordRight)},{action:"Go to line start",shortcut:hn(gn.lineStart)},{action:"Go to line end",shortcut:hn(gn.lineEnd)},{action:"Select to line start",shortcut:hn(gn.selectToLineStart)},{action:"Select to line end",shortcut:hn(gn.selectToLineEnd)},{action:"Go to document start",shortcut:hn(gn.documentStart)},{action:"Go to document end",shortcut:hn(gn.documentEnd)},{action:"Select to document start",shortcut:hn(gn.selectToDocumentStart)},{action:"Select to document end",shortcut:hn(gn.selectToDocumentEnd)}]}ia();function w0(){let e=window.getSelection();if(!e||e.isCollapsed)return [];let t=[],n=e.getRangeAt(0),o=n.commonAncestorContainer,r=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement;if(!r)return t;if(r.querySelectorAll(".docx-run").forEach(a=>{if(n.intersectsNode(a)){let s=NF(a,n);if(s){let l=HF(a);t.push({type:"run",formatting:l,content:[{type:"text",text:s}]});}}}),t.length===0){let a=e.toString();a&&t.push({type:"run",content:[{type:"text",text:a}]});}return t}function NF(e,t){let n=document.createRange();n.selectNodeContents(e);let o=t.compareBoundaryPoints(Range.START_TO_START,n)>=0&&t.compareBoundaryPoints(Range.START_TO_END,n)<=0,r=t.compareBoundaryPoints(Range.END_TO_START,n)>=0&&t.compareBoundaryPoints(Range.END_TO_END,n)<=0;if(o&&r)return t.toString();if(o){let i=document.createRange();return i.setStart(t.startContainer,t.startOffset),i.selectNodeContents(e),i.setEnd(n.endContainer,n.endOffset),i.toString()}else if(r){let i=document.createRange();return i.selectNodeContents(e),i.setEnd(t.endContainer,t.endOffset),i.setStart(n.startContainer,n.startOffset),i.toString()}else if(t.intersectsNode(e))return e.textContent||"";return ""}function HF(e){let t=window.getComputedStyle(e),n={};(t.fontWeight==="bold"||parseInt(t.fontWeight)>=700)&&(n.bold=true),t.fontStyle==="italic"&&(n.italic=true);let o=t.textDecoration||t.textDecorationLine;o&&o.includes("underline")&&(n.underline={style:"single"}),o&&o.includes("line-through")&&(n.strike=true);let r=parseFloat(t.fontSize);!isNaN(r)&&r>0&&(n.fontSize=Math.round(r/1.333*2));let i=t.fontFamily.replace(/["']/g,"").split(",")[0].trim();i&&(n.fontFamily={ascii:i});let a=t.color;if(a&&a!=="rgb(0, 0, 0)"){let l=C0(a);l&&(n.color={rgb:l});}let s=t.backgroundColor;if(s&&s!=="transparent"&&s!=="rgba(0, 0, 0, 0)"){let l=C0(s);l&&(n.shading={fill:{rgb:l}});}return Object.keys(n).length>0?n:void 0}function C0(e){if(!e||e==="transparent"||e==="inherit")return null;if(e.startsWith("#"))return e.slice(1).toUpperCase();let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(t){let n=parseInt(t[1]).toString(16).padStart(2,"0"),o=parseInt(t[2]).toString(16).padStart(2,"0"),r=parseInt(t[3]).toString(16).padStart(2,"0");return (n+o+r).toUpperCase()}return null}function up(){let e=window.getSelection();if(!e||e.isCollapsed)return null;let t=w0();if(t.length===0)return null;let n=e.toString(),o=e.getRangeAt(0),r=T0(o.startContainer),i=T0(o.endContainer),a=r?parseInt(r.getAttribute("data-paragraph-index")||"0",10):0,s=i?parseInt(i.getAttribute("data-paragraph-index")||"0",10):0;return {text:n,runs:t,startParagraphIndex:a,startRunIndex:0,startOffset:o.startOffset,endParagraphIndex:s,endRunIndex:0,endOffset:o.endOffset,isMultiParagraph:a!==s}}function T0(e){let t=e;for(;t;){if(t.nodeType===Node.ELEMENT_NODE){let n=t;if(n.hasAttribute("data-paragraph-index"))return n}t=t.parentNode;}return null}function OF(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=useRef(false),l=useRef(null),d=useCallback(async g=>{if(s.current)return false;s.current=true;try{let h=await Xo(g.runs,{onError:a});return h&&t?.(g),h}finally{s.current=false;}},[t,a]),c=useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let h=await Xo(g.runs,{onError:a});return h&&n?.(g),h}finally{s.current=false;}},[n,i,a]),u=useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let h=await navigator.clipboard.read(),x="",y="";for(let T of h)T.types.includes("text/html")&&(x=await(await T.getType("text/html")).text()),T.types.includes("text/plain")&&(y=await(await T.getType("text/plain")).text());g&&(x="");let k=zF(x,y,r);return l.current=k,o?.(k,g),k}return null}catch(h){return a?.(h),null}finally{s.current=false;}},[i,r,o,a]),p=useCallback(g=>{let h=up();if(!h)return;g.preventDefault();let x=Jo(h.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",x.plainText),g.clipboardData.setData("text/html",x.html),x.internal&&g.clipboardData.setData("application/x-docx-editor",x.internal)),t?.(h);},[t]),f=useCallback(g=>{if(!i)return;let h=up();if(!h)return;g.preventDefault();let x=Jo(h.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",x.plainText),g.clipboardData.setData("text/html",x.html),x.internal&&g.clipboardData.setData("application/x-docx-editor",x.internal)),n?.(h);},[i,n]),m=useCallback(g=>{if(!i)return;g.preventDefault();let h=bi(g,{cleanWordFormatting:r});if(h){l.current=h;let x=g.shiftKey??false;o?.(h,x);}},[i,r,o]),b=useCallback(g=>{g.ctrlKey||g.metaKey;},[]);return {copy:d,cut:c,paste:u,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}function zF(e,t,n){let{parseClipboardHtml:o}=(ia(),d$1(Zb));return o(e,t,n)}ia();var nc={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false};function R0(e,t){let n=`plugin-styles-${e}`,o=document.getElementById(n);o&&o.remove();let r=document.createElement("style");return r.id=n,r.textContent=t,document.head.appendChild(r),()=>{let i=document.getElementById(n);i&&i.remove();}}var pp=`
|
|
223
|
-
.plugin-host {
|
|
224
|
-
display: flex;
|
|
225
|
-
width: 100%;
|
|
226
|
-
height: 100%;
|
|
227
|
-
overflow: visible;
|
|
228
|
-
position: relative;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.plugin-host-editor {
|
|
232
|
-
flex: 1;
|
|
233
|
-
display: flex;
|
|
234
|
-
flex-direction: column;
|
|
235
|
-
min-width: 0;
|
|
236
|
-
overflow: visible;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
.plugin-panels-left,
|
|
241
|
-
.plugin-panels-right {
|
|
242
|
-
display: flex;
|
|
243
|
-
flex-direction: column;
|
|
244
|
-
flex-shrink: 0;
|
|
245
|
-
background: #f8f9fa;
|
|
246
|
-
border-color: #e9ecef;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.plugin-panels-left {
|
|
250
|
-
border-right: 1px solid #e9ecef;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.plugin-panels-right {
|
|
254
|
-
border-left: 1px solid #e9ecef;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.plugin-panels-bottom {
|
|
258
|
-
border-top: 1px solid #e9ecef;
|
|
259
|
-
background: #f8f9fa;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.plugin-panel {
|
|
263
|
-
position: relative;
|
|
264
|
-
display: flex;
|
|
265
|
-
flex-direction: column;
|
|
266
|
-
overflow: hidden;
|
|
267
|
-
transition: width 0.2s ease, height 0.2s ease;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.plugin-panel.collapsed {
|
|
271
|
-
overflow: visible;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.plugin-panel-toggle {
|
|
275
|
-
display: flex;
|
|
276
|
-
align-items: center;
|
|
277
|
-
gap: 4px;
|
|
278
|
-
padding: 6px 8px;
|
|
279
|
-
background: transparent;
|
|
280
|
-
border: none;
|
|
281
|
-
cursor: pointer;
|
|
282
|
-
font-size: 12px;
|
|
283
|
-
color: #6c757d;
|
|
284
|
-
white-space: nowrap;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.plugin-panel.collapsed .plugin-panel-toggle {
|
|
288
|
-
writing-mode: vertical-rl;
|
|
289
|
-
text-orientation: mixed;
|
|
290
|
-
flex-direction: column;
|
|
291
|
-
height: 100%;
|
|
292
|
-
padding: 8px 6px;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.plugin-panel-toggle:hover {
|
|
296
|
-
background: #e9ecef;
|
|
297
|
-
color: #495057;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.plugin-panel-toggle-icon {
|
|
301
|
-
font-weight: bold;
|
|
302
|
-
font-size: 14px;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.plugin-panel.collapsed .plugin-panel-toggle-icon {
|
|
306
|
-
transform: rotate(90deg);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.plugin-panel-toggle-label {
|
|
310
|
-
font-weight: 500;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.plugin-panel-content {
|
|
314
|
-
flex: 1;
|
|
315
|
-
overflow: auto;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/* Right panel rendered inside viewport - scrolls with content */
|
|
319
|
-
.plugin-panel-in-viewport {
|
|
320
|
-
position: absolute;
|
|
321
|
-
top: 0;
|
|
322
|
-
/* Position is set dynamically via inline styles based on page edge */
|
|
323
|
-
width: 220px;
|
|
324
|
-
pointer-events: auto;
|
|
325
|
-
z-index: 10;
|
|
326
|
-
overflow: visible;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.plugin-panel-in-viewport.collapsed {
|
|
330
|
-
width: 32px;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.plugin-panel-in-viewport .plugin-panel-toggle {
|
|
334
|
-
position: sticky;
|
|
335
|
-
top: 0;
|
|
336
|
-
background: rgba(255, 255, 255, 0.95);
|
|
337
|
-
border-radius: 4px;
|
|
338
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.plugin-panel-in-viewport-content {
|
|
342
|
-
overflow: visible;
|
|
343
|
-
position: relative;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/* Plugin overlay container for rendering highlights/decorations */
|
|
347
|
-
.plugin-overlays-container {
|
|
348
|
-
position: absolute;
|
|
349
|
-
top: 0;
|
|
350
|
-
left: 0;
|
|
351
|
-
right: 0;
|
|
352
|
-
bottom: 0;
|
|
353
|
-
pointer-events: none;
|
|
354
|
-
overflow: visible;
|
|
355
|
-
z-index: 5;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
.plugin-overlay {
|
|
359
|
-
position: absolute;
|
|
360
|
-
top: 0;
|
|
361
|
-
left: 0;
|
|
362
|
-
right: 0;
|
|
363
|
-
bottom: 0;
|
|
364
|
-
pointer-events: none;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
.plugin-overlay > * {
|
|
368
|
-
pointer-events: auto;
|
|
369
|
-
}
|
|
370
|
-
`,E0=forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=useState(null),s=useRef(n.props);s.current=n.props;let[l,d]=useState(null),c=useRef(new Map),[u,p]=useState(0),f=useCallback(()=>p(L=>L+1),[]),[m,b]=useState(()=>{let L=new Set;for(let H of t)({...nc,...H.panelConfig}).defaultCollapsed&&L.add(H.id);return L}),[g]=useState(()=>{let L=new Map;for(let H of t){let q={...nc,...H.panelConfig};L.set(H.id,q.defaultSize);}return L});useEffect(()=>{for(let L of t)L.initialize&&!c.current.has(L.id)&&c.current.set(L.id,L.initialize(i));f();},[t,i]),useEffect(()=>R0("plugin-host-base",pp),[]),useEffect(()=>{let L=[];for(let H of t)H.styles&&L.push(R0(H.id,H.styles));return ()=>{for(let H of L)H();}},[t]),useEffect(()=>()=>{for(let L of t)L.destroy&&L.destroy();},[t]),useEffect(()=>{if(!i)return;let L=()=>{let we=false;for(let M of t)if(M.onStateChange){let O=M.onStateChange(i);O!==void 0&&(c.current.set(M.id,O),we=true);}we&&f();};L();let H=i.dom;H.addEventListener("input",L),H.addEventListener("focus",L),H.addEventListener("click",L);let q=null,xe=()=>{q&&cancelAnimationFrame(q),q=requestAnimationFrame(L);},ie=i.dispatch.bind(i);return i.dispatch=we=>{ie(we),xe();},()=>{H.removeEventListener("input",L),H.removeEventListener("focus",L),H.removeEventListener("click",L),q&&cancelAnimationFrame(q),i.dispatch=ie;}},[i,t]);let h=useCallback(L=>{if(!i)return;if(i.coordsAtPos(L)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:q}=i,xe=q.doc.resolve(Math.min(L,q.doc.content.size)),ie=q.tr.setSelection(TextSelection.near(xe));i.dispatch(ie),i.focus();}},[i]),x=useCallback((L,H)=>{if(!i)return;let{state:q}=i,xe=q.doc.content.size,ie=Math.max(0,Math.min(L,xe)),we=Math.max(0,Math.min(H,xe)),M=q.tr.setSelection(TextSelection.create(q.doc,ie,we));i.dispatch(M),i.focus();},[i]),y=useCallback(L=>c.current.get(L),[]),k=useCallback((L,H)=>{c.current.set(L,H),f();},[]),T=useCallback(()=>{if(i){for(let L of t)if(L.onStateChange){let H=L.onStateChange(i);H!==void 0&&c.current.set(L.id,H);}f();}},[i,t]);useImperativeHandle(r,()=>({getPluginState:y,setPluginState:k,getEditorView:()=>i,refreshPluginStates:T}),[y,k,i,T]);let A=useMemo(()=>{let L=[];for(let H of t)H.proseMirrorPlugins&&L.push(...H.proseMirrorPlugins);return L},[t]),B=useCallback(L=>{b(H=>{let q=new Set(H);return q.has(L)?q.delete(L):q.add(L),q});},[]),[R,E]=useState(null);useEffect(()=>{if(!l){E(null);return}let L=()=>{let xe=l.pagesContainer,ie=xe.querySelector(".layout-page");if(!ie){E(null);return}let we=l.getContainerOffset(),M=ie.getBoundingClientRect(),O=xe.getBoundingClientRect(),C=(M.right-O.left)/l.zoom,P=we.x+C+5;E(P);};L();let H=()=>{requestAnimationFrame(L);};window.addEventListener("resize",H);let q=new ResizeObserver(()=>{requestAnimationFrame(L);});return q.observe(l.pagesContainer),()=>{window.removeEventListener("resize",H),q.disconnect();}},[l]);let S=useMemo(()=>{let L=[];if(l){for(let H of t)if(H.renderOverlay){let q=c.current.get(H.id);L.push(jsx("div",{className:"plugin-overlay","data-plugin-id":H.id,children:H.renderOverlay(l,q,i)},`overlay-${H.id}`));}}for(let H of t){if(!H.Panel||(H.panelConfig?.position??"right")!=="right")continue;let xe={...nc,...H.panelConfig},ie=m.has(H.id),we=g.get(H.id)??xe.defaultSize,M=H.Panel,O=c.current.get(H.id),C=R!==null?`${R}px`:"calc(50% + 428px)";L.push(jsxs("div",{className:`plugin-panel-in-viewport ${ie?"collapsed":""}`,style:{width:ie?"32px":`${we}px`,left:C},"data-plugin-id":H.id,children:[xe.collapsible&&jsx("button",{className:"plugin-panel-toggle",onClick:()=>B(H.id),title:ie?`Show ${H.name}`:`Hide ${H.name}`,"aria-label":ie?`Show ${H.name}`:`Hide ${H.name}`,children:jsx("span",{className:"plugin-panel-toggle-icon",children:ie?"\u2039":"\u203A"})}),!ie&&l&&jsx("div",{className:"plugin-panel-in-viewport-content",children:jsx(M,{editorView:i,doc:i?.state.doc??null,scrollToPosition:h,selectRange:x,pluginState:O,panelWidth:we,renderedDomContext:l})})]},`panel-overlay-${H.id}`));}return L.length>0?L:null},[l,t,u,i,m,g,h,x,B,R]),N=useCallback(L=>{d(L);let H=s.current?.onRenderedDomContextReady;typeof H=="function"&&H(L);},[]),_=useMemo(()=>cloneElement(n,{externalPlugins:A,pluginOverlays:S,onRenderedDomContextReady:N,onEditorViewReady:L=>{a(L);let H=s.current?.onEditorViewReady;typeof H=="function"&&H(L);}}),[n,A,S,N]),U=useMemo(()=>{let L=[],H=[],q=[];for(let xe of t){if(!xe.Panel)continue;let ie=xe.panelConfig?.position??"right";ie==="left"?L.push(xe):ie==="bottom"?q.push(xe):H.push(xe);}return {left:L,right:H,bottom:q}},[t]),Z=L=>{if(!L.Panel)return null;let H={...nc,...L.panelConfig},q=m.has(L.id),xe=g.get(L.id)??H.defaultSize,ie=L.Panel,we=c.current.get(L.id);return jsxs("div",{className:`plugin-panel plugin-panel-${H.position} ${q?"collapsed":""}`,style:{[H.position==="bottom"?"height":"width"]:q?"32px":`${xe}px`,minWidth:H.position!=="bottom"?q?"32px":`${H.minSize}px`:void 0,maxWidth:H.position!=="bottom"?`${H.maxSize}px`:void 0,minHeight:H.position==="bottom"?q?"32px":`${H.minSize}px`:void 0,maxHeight:H.position==="bottom"?`${H.maxSize}px`:void 0},"data-plugin-id":L.id,children:[H.collapsible&&jsxs("button",{className:"plugin-panel-toggle",onClick:()=>B(L.id),title:q?`Show ${L.name}`:`Hide ${L.name}`,"aria-label":q?`Show ${L.name}`:`Hide ${L.name}`,children:[jsx("span",{className:"plugin-panel-toggle-icon",children:q?"\u203A":"\u2039"}),q&&jsx("span",{className:"plugin-panel-toggle-label",children:L.name})]}),!q&&jsx("div",{className:"plugin-panel-content",children:jsx(ie,{editorView:i,doc:i?.state.doc??null,scrollToPosition:h,selectRange:x,pluginState:we,panelWidth:xe,renderedDomContext:l??null})})]},L.id)};return jsxs("div",{className:`plugin-host ${o}`,children:[U.left.length>0&&jsx("div",{className:"plugin-panels-left",children:U.left.map(Z)}),jsxs("div",{className:"plugin-host-editor",children:[_,U.bottom.length>0&&jsx("div",{className:"plugin-panels-bottom",children:U.bottom.map(Z)})]})]})});var I0=/\{([#/^@]?)([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}/g,Ht=new PluginKey("template");function qF(e,t,n){return `${e}:${t}:${n}`}function M0(e){let t=[];e.descendants((l,d)=>(l.isText&&l.text&&t.push({text:l.text,pos:d}),true));let n="",o=[];for(let l of t){for(let d=0;d<l.text.length;d++)o.push(l.pos+d);n+=l.text;}let r=[],i=[],a=new Map,s;for(I0.lastIndex=0;(s=I0.exec(n))!==null;){let[l,d,c]=s,u=o[s.index],p=o[s.index+l.length-1]+1,f;d==="#"?f="sectionStart":d==="/"?f="sectionEnd":d==="^"?f="invertedStart":d==="@"?f="raw":f="variable";let m=`${f}:${c}`,b=a.get(m)??0;a.set(m,b+1);let g={id:qF(f,c,b),type:f,name:c,rawTag:l,from:u,to:p};if(f==="sectionStart"||f==="invertedStart")g.nestedVars=[],i.push(g);else if(f==="sectionEnd"){for(let h=i.length-1;h>=0;h--)if(i[h].name===c){i.splice(h,1);break}}else f==="variable"&&i.length>0&&(i[i.length-1].nestedVars?.push(c),g.insideSection=true);r.push(g);}return r}function KF(e){switch(e){case "sectionStart":case "sectionEnd":return "#3b82f6";case "invertedStart":return "#8b5cf6";case "raw":return "#ef4444";default:return "#f59e0b"}}function fp(e,t,n,o){let r=[];for(let i of t){let a=i.id===n,s=i.id===o,l=KF(i.type),d=["docx-template-tag"];a&&d.push("hovered"),s&&d.push("selected"),r.push(Decoration.inline(i.from,i.to,{class:d.join(" "),"data-tag-id":i.id,style:`background-color: ${l}22; border-radius: 2px;`}));}return DecorationSet.create(e,r)}function GF(e,t){if(e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n].id!==t[n].id)return false;return true}function oc(){return new Plugin({key:Ht,state:{init(e,t){let n=M0(t.doc);return {tags:n,decorations:fp(t.doc,n)}},apply(e,t,n,o){if(e.docChanged){let i=M0(o.doc),a=GF(t.tags,i);return {tags:i,decorations:a?t.decorations.map(e.mapping,e.doc):fp(o.doc,i,t.hoveredId,t.selectedId),hoveredId:t.hoveredId,selectedId:t.selectedId}}let r=e.getMeta(Ht);if(r){let i=r.hoveredId??t.hoveredId,a=r.selectedId??t.selectedId;return {...t,hoveredId:i,selectedId:a,decorations:fp(o.doc,t.tags,i,a)}}return {...t,decorations:t.decorations.map(e.mapping,e.doc)}}},props:{decorations(e){return Ht.getState(e)?.decorations??DecorationSet.empty},handleClick(e,t){let o=(Ht.getState(e.state)?.tags??[]).find(i=>t>=i.from&&t<=i.to);return o?(e.dispatch(e.state.tr.setMeta(Ht,{selectedId:o.id})),true):(Ht.getState(e.state)?.selectedId&&e.dispatch(e.state.tr.setMeta(Ht,{selectedId:void 0})),false)},handleDOMEvents:{mouseover(e,t){let o=t.target.closest?.("[data-tag-id]")?.getAttribute("data-tag-id")||void 0,r=Ht.getState(e.state)?.hoveredId;return o!==r&&e.dispatch(e.state.tr.setMeta(Ht,{hoveredId:o})),false},mouseout(e,t){return t.relatedTarget?.closest?.("[data-tag-id]")||Ht.getState(e.state)?.hoveredId&&e.dispatch(e.state.tr.setMeta(Ht,{hoveredId:void 0})),false}}}})}function F0(e){return Ht.getState(e)?.tags??[]}function Ci(e,t){e.dispatch(e.state.tr.setMeta(Ht,{hoveredId:t}));}function Ti(e,t){e.dispatch(e.state.tr.setMeta(Ht,{selectedId:t}));}var rc=`
|
|
1
|
+
export{n as countPageBreaks,b as createColumnBreak,g as createHorizontalRule,c as createLineBreak,a as createPageBreak,e as createPageBreakParagraph,d as createPageBreakRun,o as findPageBreaks,m as hasPageBreakBefore,h as insertHorizontalRule,f as insertPageBreak,l as isBreakContent,j as isColumnBreak,k as isLineBreak,i as isPageBreak,p as removePageBreak}from'./chunk-KESNGXGO.js';export{e as buildExtendedSelectionContext,d as buildSelectionContext,h as createDocumentWithText,g as createEmptyDocument,a as getAgentContext,c as getDocumentSummary}from'./chunk-TOI5W3HK.js';export{B as DEFAULT_SELECTION_STYLE,j as DocxEditor,c as ErrorBoundary,b as ErrorProvider,C as HIGH_CONTRAST_SELECTION_STYLE,$ as PLUGIN_HOST_STYLES,d as ParseErrorDisplay,aa as PluginHost,D as SELECTION_CSS_VARS,h as TABLE_DATA_ATTRIBUTES,e as UnsupportedFeatureWarning,r as ZOOM_PRESETS,U as areSelectionStylesInjected,A as clampZoom,P as clearSelection,V as createSelectionChangeHandler,Z as createSelectionFromDOM,u as findNearestZoomPreset,m as formatLastSaveTime,p as formatStorageSize,x as formatZoom,X as generateOverlayElements,I as generateSelectionCSS,n as getAutoSaveStatusLabel,o as getAutoSaveStorageSize,H as getHighlightRectStyle,G as getMergedSelectionRects,v as getNextZoomPreset,w as getPreviousZoomPreset,K as getSelectedText,M as getSelectionBoundingRect,E as getSelectionRects,Y as getSelectionRuns,g as getUserFriendlyMessage,t as getZoomPresets,J as hasActiveSelection,N as highlightTextRange,S as injectSelectionStyles,q as isAutoSaveSupported,f as isParseError,Q as isSelectionBackwards,L as isSelectionWithin,z as isZoomPreset,F as mergeAdjacentRects,R as normalizeSelectionDirection,y as parseZoom,T as removeSelectionStyles,k as renderAsync,O as selectRange,l as useAutoSave,_ as useClipboard,a as useErrorNotifications,W as useSelectionHighlight,i as useTableSelection,s as useWheelZoom}from'./chunk-MTX3EEBJ.js';import'./chunk-S6FZ7HL6.js';export{a as DocumentAgent}from'./chunk-M7F2CUUD.js';export{B as CellBackgroundPicker,a as ContextMenu,A as DEFAULT_CELL_COLORS,ha as InsertImageDialog,ra as InsertSymbolDialog,aa as InsertTableDialog,Ea as KeyboardShortcutsDialog,P as LoadingIndicator,ya as PasteSpecialDialog,q as PrintButton,r as PrintStyles,g as ResponsePreview,X as ResponsiveToolbar,Y as ResponsiveToolbarGroup,qa as SYMBOL_CATEGORIES,z as TableInsertButtons,y as TableMergeButton,k as TextContextMenu,J as UnsavedIndicator,ma as calculateFitDimensions,ea as clampTableConfig,D as createCellColorOption,O as createChangeTracker,ca as createDefaultTableConfig,j as createErrorResponse,i as createMockResponse,G as createShadingFromColor,Z as createToolbarItem,_ as createToolbarItems,na as dataUrlToBlob,V as delay,pa as formatFileSize,w as formatPrintPageRange,La as formatShortcutKeys,fa as formatTableDimensions,c as getActionShortcut,f as getAllActions,Ka as getAllCategories,N as getAllIndicatorPositions,M as getAllIndicatorVariants,U as getAllLoadingSizes,T as getAllLoadingVariants,Ba as getAllPasteOptions,Ja as getCategoryLabel,F as getCellColorName,H as getColorFromShading,Ia as getCommonShortcuts,I as getContrastingTextColor,e as getDefaultActions,C as getDefaultCellColors,Ca as getDefaultPasteOption,u as getDefaultPrintOptions,Ga as getDefaultShortcuts,o as getDefaultTextContextMenuItems,la as getImageAcceptString,oa as getImageDimensions,S as getLoadingVariantLabel,Aa as getPasteOption,$ as getRecommendedPriority,Ha as getShortcutsByCategory,ka as getSupportedImageExtensions,ta as getSymbolCategories,va as getSymbolUnicodeInfo,ua as getSymbolsByCategory,ga as getTablePresets,m as getTextActionLabel,n as getTextActionShortcut,L as getVariantLabel,d as isActionAvailable,E as isDefaultCellColor,Da as isPasteSpecialShortcut,x as isPrintSupported,p as isTextActionAvailable,ja as isValidImageFile,da as isValidTableConfig,t as openPrintWindow,v as parsePageRange,wa as searchSymbols,xa as symbolFromCodePoint,s as triggerPrint,b as useContextMenu,ia as useInsertImageDialog,sa as useInsertSymbolDialog,ba as useInsertTableDialog,Fa as useKeyboardShortcutsDialog,Q as useLoading,R as useLoadingOperations,za as usePasteSpecial,h as useResponsePreview,W as useResponsiveToolbar,l as useTextContextMenu,K as useUnsavedChanges}from'./chunk-6MBDPZVD.js';import'./chunk-EMKABJPH.js';import {ra}from'./chunk-E6XDMUAM.js';export{i as AlignmentButtons,ca as CLIPBOARD_TYPES,g as ColorPicker,b as FontPicker,f as FontSizePicker,O as HorizontalRuler,ba as INTERNAL_CLIPBOARD_TYPE,l as LineSpacingPicker,j as ListButtons,H as PageNavigator,z as PageNumberIndicator,m as StylePicker,p as TableBorderColorPicker,o as TableBorderPicker,q as TableBorderWidthPicker,r as TableCellFillPicker,s as TableMoreDropdown,T as TableToolbar,x as Toolbar,u as ToolbarButton,v as ToolbarGroup,w as ToolbarSeparator,y as VariablePanel,n as ZoomControl,Z as addColumn,X as addRow,N as calculateProgress,G as calculateScrollToPage,F as calculateVisiblePage,K as clampPageNumber,na as cleanWordHtml,ea as copyParagraphs,da as copyRuns,pa as createClipboardHandlers,k as createDefaultListState,B as createPageFormat,U as createTableContext,_ as deleteColumn,Y as deleteRow,A as formatPageOrdinal,M as formatPageRange,W as getCellAt,V as getColumnCount,R as getMarginInUnits,L as getNavigationShortcuts,C as getPageProgress,Q as getRulerDimensions,ja as handlePasteEvent,oa as htmlToRuns,ma as isEditorHtml,D as isFirstPage,E as isLastPage,J as isValidPageNumber,la as isWordHtml,$ as mergeCells,ga as paragraphsToClipboardContent,ka as parseClipboardHtml,S as parseMarginFromUnits,I as parsePageInput,P as positionToMargin,ia as readFromClipboard,fa as runsToClipboardContent,aa as splitCell,ha as writeToClipboard}from'./chunk-E6XDMUAM.js';export{d as HyperlinkDialog,m as useHyperlinkDialog}from'./chunk-PJVI53AH.js';export{l as blendColors,m as colorsEqual,i as createRgbColor,h as createThemeColor,j as darkenColor,p as emuToPixels,r as emuToTwips,x as formatPx,f as getContrastingColor,u as halfPointsToPixels,d as isBlack,e as isWhite,k as lightenColor,g as parseColorString,q as pixelsToEmu,o as pixelsToTwips,t as pointsToPixels,a as resolveColor,b as resolveHighlightColor,c as resolveShadingColor,s as twipsToEmu,n as twipsToPixels}from'./chunk-ZDYHAYN6.js';export{b as docxtemplaterPlugin}from'./chunk-COP5BIBZ.js';export{e as getTemplateTags,a as processTemplate,c as processTemplateAsBlob,b as processTemplateDetailed,f as validateTemplate}from'./chunk-ESI4BSBF.js';import'./chunk-2ASOEN3V.js';export{b as serializeDocumentBody,c as serializeDocx,a as serializeSectionProperties}from'./chunk-MDPDH7KS.js';export{a as executeCommand,b as executeCommands}from'./chunk-MMJD2DLL.js';export{k as canRenderFont,i as getLoadedFonts,g as isFontLoaded,h as isFontsLoading,e as loadFont,l as loadFontFromBuffer,f as loadFonts,j as onFontsLoaded,p as parseDocx,m as preloadCommonFonts,o as toArrayBuffer}from'./chunk-OTG4NABM.js';export{a as PluginRegistry,b as pluginRegistry,c as registerPlugins}from'./chunk-QHWHCIUW.js';export{n as FindReplaceDialog,a as createDefaultFindOptions,c as createSearchPattern,b as escapeRegexString,d as findAllMatches,j as findInDocument,k as findInParagraph,i as getDefaultHighlightOptions,g as getMatchCountText,h as isEmptySearch,e as replaceAllInContent,f as replaceFirstInContent,l as scrollToMatch,m as useFindReplace}from'./chunk-KVAT5SVD.js';import'./chunk-3IYNTJO5.js';import ye,{useState,useRef,useMemo,useCallback,useEffect}from'react';import {PluginKey,TextSelection,Plugin}from'prosemirror-state';import {DecorationSet,Decoration}from'prosemirror-view';import {jsx,jsxs}from'react/jsx-runtime';var Xa=/[\p{L}\p{N}''\-]/u,qa=/\s/;function M(e){return !e||e.length===0?false:Xa.test(e)}function K(e){return !e||e.length===0?false:qa.test(e)}function R(e,t){if(!e||e.length===0)return [0,0];t=Math.max(0,Math.min(t,e.length-1));let o=e[t];if(K(o)){let n=t,r=t;for(;n>0&&K(e[n-1]);)n--;for(;r<e.length&&K(e[r]);)r++;return [n,r]}if(M(o)){let n=t,r=t;for(;n>0&&M(e[n-1]);)n--;for(;r<e.length&&M(e[r]);)r++;return [n,r]}return [t,t+1]}function ja(e,t){let[o,n]=R(e,t);return e.slice(o,n)}function Ja(e,t){let[o,n]=R(e,t);return {word:e.slice(o,n),startIndex:o,endIndex:n}}function $(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0),o=t.startContainer;if(o.nodeType===Node.TEXT_NODE){let n=o.textContent||"",r=t.startOffset,[a,i]=R(n,r);if(i>a)return t.setStart(o,a),t.setEnd(o,i),e.removeAllRanges(),e.addRange(t),true}if(o.nodeType===Node.ELEMENT_NODE){let n=o,r=q(n);if(r.length>0){let a=t.startOffset,i=null,l=a;if(a<n.childNodes.length){let p=n.childNodes[a];if(p.nodeType===Node.TEXT_NODE)i=p,l=0;else if(p instanceof Element){let d=q(p);d.length>0&&(i=d[0],l=0);}}if(!i&&r.length>0&&(i=r[0],l=0),i){let p=i.textContent||"",[d,c]=R(p,l);if(c>d){let u=document.createRange();return u.setStart(i,d),u.setEnd(i,c),e.removeAllRanges(),e.addRange(u),true}}}}return false}function Qa(e,t){let o=window.getSelection();if(!o)return false;let n=e.textContent||"",[r,a]=R(n,t);if(a>r){let i=document.createRange();return i.setStart(e,r),i.setEnd(e,a),o.removeAllRanges(),o.addRange(i),true}return false}function ei(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.getRangeAt(0);if(t.collapsed)return $();let o=t.startContainer,n=t.endContainer,r=t.startOffset,a=t.endOffset;if(o.nodeType===Node.TEXT_NODE){let i=o.textContent||"",[l]=R(i,t.startOffset);r=l;}if(n.nodeType===Node.TEXT_NODE){let i=n.textContent||"",l=Math.max(0,t.endOffset-1),[,p]=R(i,l);a=p;}try{return t.setStart(o,r),t.setEnd(n,a),e.removeAllRanges(),e.addRange(t),!0}catch(i){return console.warn("Could not expand selection to word boundaries:",i),false}}function J(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let o=e.getRangeAt(0).commonAncestorContainer,n=ti(o);if(n){let r=document.createRange();return r.selectNodeContents(n),e.removeAllRanges(),e.addRange(r),true}return false}function ti(e){if(!e)return null;let t=e;for(;t;){if(t instanceof Element&&t.hasAttribute("data-paragraph-index"))return t;t=t.parentNode;}return null}function q(e){let t=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),n;for(;n=o.nextNode();)n.nodeType===Node.TEXT_NODE&&t.push(n);return t}var V=0,O=null,G=null,oi=500;function j(){V=0,G=null,O&&(clearTimeout(O),O=null);}function Q(e){return e.target!==G&&j(),V++,G=e.target,O&&clearTimeout(O),O=setTimeout(j,oi),Math.min(V,3)}function ni(){return e=>{e.ctrlKey||e.metaKey||e.altKey||$();}}function ri(){return e=>{if(Q(e)===3){if(e.ctrlKey||e.metaKey||e.altKey)return;J();}}}function P(e){return e?/[\p{L}\p{N}_]/u.test(e):false}function Y(e){return e?/\s/.test(e):false}function ai(e){return e?/[\p{P}]/u.test(e):false}function ii(e,t){if(t<=0)return 0;t>e.length&&(t=e.length);let o=t;for(;o>0&&Y(e[o-1]);)o--;if(o===0)return 0;for(;o>0&&P(e[o-1]);)o--;return o}function si(e,t){if(t>=e.length)return e.length;t<0&&(t=0);let o=t;for(;o<e.length&&P(e[o]);)o++;for(;o<e.length&&Y(e[o]);)o++;return o}function ee(e,t){if(t>=e.length)return e.length;let o=t;for(;o<e.length&&P(e[o]);)o++;for(;o<e.length&&!P(e[o]);)o++;return o}function te(e,t){if(t<=0)return 0;let o=t;for(;o>0&&!P(e[o-1]);)o--;for(;o>0&&P(e[o-1]);)o--;return o}function oe(e,t){if(!window.getSelection())return null;let n=document.createRange();if(e.nodeType===Node.TEXT_NODE){n.setStart(e,Math.min(t,e.textContent?.length||0)),n.collapse(true);let a=n.getBoundingClientRect().top,i=0,l=t;for(;i<l;){let p=Math.floor((i+l)/2);n.setStart(e,p),n.collapse(true);let d=n.getBoundingClientRect();Math.abs(d.top-a)<2?l=p:i=p+1;}return {node:e,offset:i}}return null}function ne(e,t){if(!window.getSelection())return null;let n=e.textContent?.length||0,r=document.createRange();if(e.nodeType===Node.TEXT_NODE){r.setStart(e,Math.min(t,n)),r.collapse(true);let i=r.getBoundingClientRect().top,l=t,p=n;for(;l<p;){let d=Math.ceil((l+p)/2);r.setStart(e,d),r.collapse(true);let c=r.getBoundingClientRect();Math.abs(c.top-i)<2?l=d:p=d-1;}return {node:e,offset:l}}return null}function li(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.getRangeAt(0);return {node:t.startContainer,offset:t.startOffset,anchorNode:e.anchorNode,anchorOffset:e.anchorOffset,focusNode:e.focusNode,focusOffset:e.focusOffset,isCollapsed:e.isCollapsed,text:e.toString()}}function H(e,t){let o=window.getSelection();if(!o)return;let n=document.createRange(),r=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;n.setStart(e,Math.min(t,r)),n.collapse(true),o.removeAllRanges(),o.addRange(n);}function _(e,t){let o=window.getSelection();if(!(!o||!o.anchorNode))try{o.extend(e,Math.min(t,e.textContent?.length||0));}catch{let n=e.nodeType===Node.TEXT_NODE?e.textContent?.length||0:e.childNodes.length;o.setBaseAndExtent(o.anchorNode,o.anchorOffset,e,Math.min(t,n));}}function re(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let n=o.focusNode;if(!n||n.nodeType!==Node.TEXT_NODE)return false;let r=n.textContent||"",a=o.focusOffset,i;return e==="left"?i=te(r,a):i=ee(r,a),t?_(n,i):H(n,i),true}function ae(e,t=false){let o=window.getSelection();if(!o||o.rangeCount===0)return false;let n=o.focusNode;if(!n)return false;if(n.nodeType===Node.TEXT_NODE){let i=e==="start"?oe(n,o.focusOffset):ne(n,o.focusOffset);if(i)return t?_(i.node,i.offset):H(i.node,i.offset),true}let r=n.textContent||"",a=e==="start"?0:r.length;return t?_(n,a):H(n,a),true}function ie(e){let{key:t,ctrlKey:o,metaKey:n,shiftKey:r,altKey:a}=e,i=o||n;switch(t){case "ArrowLeft":if(i)return {direction:"left",unit:"word",extend:r};break;case "ArrowRight":if(i)return {direction:"right",unit:"word",extend:r};break;case "Home":return i?{direction:"left",unit:"document",extend:r}:{direction:"left",unit:"line",extend:r};case "End":return i?{direction:"right",unit:"document",extend:r}:{direction:"right",unit:"line",extend:r}}return null}function ci(e,t){let o=ie(e);if(!o)return false;switch(o.unit){case "word":if((o.direction==="left"||o.direction==="right")&&re(o.direction,o.extend))return e.preventDefault(),true;break;case "line":let n=o.direction==="left"?"start":"end";if(ae(n,o.extend))return e.preventDefault(),true;break;case "document":if(o.direction==="left"&&t?.onDocumentStart)return e.preventDefault(),t.onDocumentStart(),true;if(o.direction==="right"&&t?.onDocumentEnd)return e.preventDefault(),t.onDocumentEnd(),true;break}return false}function pi(e){let{key:t,ctrlKey:o,metaKey:n}=e;return !!((o||n)&&(t==="ArrowLeft"||t==="ArrowRight")||t==="Home"||t==="End")}function di(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return false;let o=t.textContent||"",n=e.focusOffset,r=n,a=n;for(;r>0&&P(o[r-1]);)r--;for(;a<o.length&&P(o[a]);)a++;if(r===a)return false;let i=document.createRange();return i.setStart(t,r),i.setEnd(t,a),e.removeAllRanges(),e.addRange(i),true}function ui(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;let t=e.focusNode;if(!t||t.nodeType!==Node.TEXT_NODE)return null;let o=t.textContent||"",n=e.focusOffset,r=n,a=n;for(;r>0&&P(o[r-1]);)r--;for(;a<o.length&&P(o[a]);)a++;return r===a?null:o.slice(r,a)}function gi(e,t){let o=e.ctrlKey||e.metaKey,n=t.ctrlKey||t.metaKey;return e.key.toLowerCase()===t.key.toLowerCase()&&o===!!n&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}var T={wordLeft:{key:"ArrowLeft",ctrlKey:true},wordRight:{key:"ArrowRight",ctrlKey:true},selectWordLeft:{key:"ArrowLeft",ctrlKey:true,shiftKey:true},selectWordRight:{key:"ArrowRight",ctrlKey:true,shiftKey:true},lineStart:{key:"Home"},lineEnd:{key:"End"},selectToLineStart:{key:"Home",shiftKey:true},selectToLineEnd:{key:"End",shiftKey:true},documentStart:{key:"Home",ctrlKey:true},documentEnd:{key:"End",ctrlKey:true},selectToDocumentStart:{key:"Home",ctrlKey:true,shiftKey:true},selectToDocumentEnd:{key:"End",ctrlKey:true,shiftKey:true}};function S(e){let t=[];if(e.ctrlKey||e.metaKey){let n=typeof navigator<"u"&&/Mac/i.test(navigator.platform);t.push(n?"\u2318":"Ctrl");}e.shiftKey&&t.push("Shift"),e.altKey&&t.push("Alt");let o=e.key;return o==="ArrowLeft"?o="\u2190":o==="ArrowRight"?o="\u2192":o==="ArrowUp"?o="\u2191":o==="ArrowDown"&&(o="\u2193"),t.push(o),t.join("+")}function fi(){return [{action:"Move by word (left)",shortcut:S(T.wordLeft)},{action:"Move by word (right)",shortcut:S(T.wordRight)},{action:"Select word (left)",shortcut:S(T.selectWordLeft)},{action:"Select word (right)",shortcut:S(T.selectWordRight)},{action:"Go to line start",shortcut:S(T.lineStart)},{action:"Go to line end",shortcut:S(T.lineEnd)},{action:"Select to line start",shortcut:S(T.selectToLineStart)},{action:"Select to line end",shortcut:S(T.selectToLineEnd)},{action:"Go to document start",shortcut:S(T.documentStart)},{action:"Go to document end",shortcut:S(T.documentEnd)},{action:"Select to document start",shortcut:S(T.selectToDocumentStart)},{action:"Select to document end",shortcut:S(T.selectToDocumentEnd)}]}ra();var se=/\{([#/^@]?)([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}/g,m=new PluginKey("template");function Ti(e,t,o){return `${e}:${t}:${o}`}function le(e){let t=[];e.descendants((p,d)=>(p.isText&&p.text&&t.push({text:p.text,pos:d}),true));let o="",n=[];for(let p of t){for(let d=0;d<p.text.length;d++)n.push(p.pos+d);o+=p.text;}let r=[],a=[],i=new Map,l;for(se.lastIndex=0;(l=se.exec(o))!==null;){let[p,d,c]=l,u=n[l.index],x=n[l.index+p.length-1]+1,g;d==="#"?g="sectionStart":d==="/"?g="sectionEnd":d==="^"?g="invertedStart":d==="@"?g="raw":g="variable";let b=`${g}:${c}`,k=i.get(b)??0;i.set(b,k+1);let N={id:Ti(g,c,k),type:g,name:c,rawTag:p,from:u,to:x};if(g==="sectionStart"||g==="invertedStart")N.nestedVars=[],a.push(N);else if(g==="sectionEnd"){for(let s=a.length-1;s>=0;s--)if(a[s].name===c){a.splice(s,1);break}}else g==="variable"&&a.length>0&&(a[a.length-1].nestedVars?.push(c),N.insideSection=true);r.push(N);}return r}function Si(e){switch(e){case "sectionStart":case "sectionEnd":return "#3b82f6";case "invertedStart":return "#8b5cf6";case "raw":return "#ef4444";default:return "#f59e0b"}}function Z(e,t,o,n){let r=[];for(let a of t){let i=a.id===o,l=a.id===n,p=Si(a.type),d=["docx-template-tag"];i&&d.push("hovered"),l&&d.push("selected"),r.push(Decoration.inline(a.from,a.to,{class:d.join(" "),"data-tag-id":a.id,style:`background-color: ${p}22; border-radius: 2px;`}));}return DecorationSet.create(e,r)}function xi(e,t){if(e.length!==t.length)return false;for(let o=0;o<e.length;o++)if(e[o].id!==t[o].id)return false;return true}function B(){return new Plugin({key:m,state:{init(e,t){let o=le(t.doc);return {tags:o,decorations:Z(t.doc,o)}},apply(e,t,o,n){if(e.docChanged){let a=le(n.doc),i=xi(t.tags,a);return {tags:a,decorations:i?t.decorations.map(e.mapping,e.doc):Z(n.doc,a,t.hoveredId,t.selectedId),hoveredId:t.hoveredId,selectedId:t.selectedId}}let r=e.getMeta(m);if(r){let a=r.hoveredId??t.hoveredId,i=r.selectedId??t.selectedId;return {...t,hoveredId:a,selectedId:i,decorations:Z(n.doc,t.tags,a,i)}}return {...t,decorations:t.decorations.map(e.mapping,e.doc)}}},props:{decorations(e){return m.getState(e)?.decorations??DecorationSet.empty},handleClick(e,t){let n=(m.getState(e.state)?.tags??[]).find(a=>t>=a.from&&t<=a.to);return n?(e.dispatch(e.state.tr.setMeta(m,{selectedId:n.id})),true):(m.getState(e.state)?.selectedId&&e.dispatch(e.state.tr.setMeta(m,{selectedId:void 0})),false)},handleDOMEvents:{mouseover(e,t){let n=t.target.closest?.("[data-tag-id]")?.getAttribute("data-tag-id")||void 0,r=m.getState(e.state)?.hoveredId;return n!==r&&e.dispatch(e.state.tr.setMeta(m,{hoveredId:n})),false},mouseout(e,t){return t.relatedTarget?.closest?.("[data-tag-id]")||m.getState(e.state)?.hoveredId&&e.dispatch(e.state.tr.setMeta(m,{hoveredId:void 0})),false}}}})}function pe(e){return m.getState(e)?.tags??[]}function D(e,t){e.dispatch(e.state.tr.setMeta(m,{hoveredId:t}));}function L(e,t){e.dispatch(e.state.tr.setMeta(m,{selectedId:t}));}var F=`
|
|
371
2
|
.docx-template-tag {
|
|
372
3
|
cursor: pointer;
|
|
373
4
|
transition: background-color 0.1s;
|
|
@@ -381,8 +12,8 @@ body { background: white; }
|
|
|
381
12
|
.docx-template-tag.selected {
|
|
382
13
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
|
|
383
14
|
}
|
|
384
|
-
`;var
|
|
385
|
-
Iterates over ${
|
|
15
|
+
`;var Ei={variable:"#f59e0b",sectionStart:"#3b82f6",sectionEnd:"#3b82f6",invertedStart:"#8b5cf6",raw:"#ef4444"};function vi(e){switch(e){case "sectionStart":return "LOOP / IF";case "invertedStart":return "IF NOT";case "raw":return "HTML";default:return ""}}function U({editorView:e,pluginState:t,renderedDomContext:o}){let n=t?.tags??[],r=t?.hoveredId,a=t?.selectedId,[i,l]=useState(0),p=useRef(null),d=useRef(new Map),c=useRef([]),u=useMemo(()=>n.filter(s=>s.type!=="sectionEnd"&&!s.insideSection),[n]),x=useCallback(()=>{if(u.length===0||!o)return c.current;let s=[],h=o.getContainerOffset(),C=new Map;for(let f of c.current)C.set(f.tag.id,f.top);for(let f of u){let y=o.getRectsForRange(f.from,f.from+1);if(y.length>0){let v=y[0].y+h.y-40;s.push({tag:f,top:v});}else {let v=C.get(f.id);v!==void 0&&s.push({tag:f,top:v});}}s.sort((f,y)=>f.top-y.top);let I=6;for(let f=1;f<s.length;f++){let y=s[f-1],v=s[f],E=d.current.get(y.tag.id),w=32;E?w=E.offsetHeight:y.tag.nestedVars&&y.tag.nestedVars.length>0&&(w=42+y.tag.nestedVars.length*26),v.top<y.top+w+I&&(v.top=y.top+w+I);}return c.current=s,s},[u,o]),g=useMemo(()=>x(),[x,i]);useEffect(()=>{if(!o)return;let s=new ResizeObserver(()=>{requestAnimationFrame(()=>l(h=>h+1));});return s.observe(o.pagesContainer),()=>s.disconnect()},[o]),useEffect(()=>{let s=()=>{requestAnimationFrame(()=>l(h=>h+1));};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);let b=useRef("");useEffect(()=>{let s=u.map(h=>h.id).join(",");if(s&&b.current!==s){let h=setTimeout(()=>{b.current=s,l(C=>C+1);},50);return ()=>clearTimeout(h)}},[u]);let k=s=>{e&&D(e,s);},N=s=>{if(!e)return;L(e,s.id);let{state:h}=e,C=h.tr.setSelection(TextSelection.near(h.doc.resolve(s.from)));e.dispatch(C),e.focus();};return u.length===0?null:jsx("div",{className:"template-panel",ref:p,children:jsx("div",{className:"template-panel-annotations",children:g.map(({tag:s,top:h})=>{let C=vi(s.type),I=Ei[s.type],f=s.type==="sectionStart"||s.type==="invertedStart",y=s.id===r,v=s.id===a;return jsxs("div",{className:"template-annotation-anchor",style:{top:`${h}px`},children:[jsx("div",{className:"template-annotation-connector"}),jsxs("div",{ref:E=>{E?d.current.set(s.id,E):d.current.delete(s.id);},className:`template-annotation-chip ${y?"hovered":""} ${v?"selected":""}`,style:{borderLeftColor:I},onMouseEnter:()=>k(s.id),onMouseLeave:()=>k(void 0),onClick:()=>N(s),title:f?`${s.rawTag}
|
|
16
|
+
Iterates over ${s.name}[]. Access nested properties via ${s.name}.property`:s.rawTag,children:[C&&jsx("span",{className:"template-chip-badge",style:{background:I},children:C}),!C&&jsx("span",{className:"template-chip-dot",style:{color:I},children:"\u25CF"}),jsx("span",{className:"template-chip-name",children:s.name}),f&&s.nestedVars&&s.nestedVars.length>0&&jsx("div",{className:"template-chip-nested",children:s.nestedVars.map((E,w)=>jsx("span",{className:"template-nested-var",title:`Access: ${s.name}.${E}`,children:E.includes(".")?E.split(".").pop():E},w))})]})]},s.id)})})})}var z=`
|
|
386
17
|
.template-panel {
|
|
387
18
|
display: flex;
|
|
388
19
|
min-height: 100%;
|
|
@@ -493,7 +124,7 @@ Iterates over ${h.name}[]. Access nested properties via ${h.name}.property`:h.ra
|
|
|
493
124
|
background: rgba(59, 130, 246, 0.15);
|
|
494
125
|
color: #1e40af;
|
|
495
126
|
}
|
|
496
|
-
`;var
|
|
127
|
+
`;var Ii={variable:"rgba(245, 158, 11, 0.3)",sectionStart:"rgba(59, 130, 246, 0.3)",sectionEnd:"rgba(59, 130, 246, 0.3)",invertedStart:"rgba(139, 92, 246, 0.3)",raw:"rgba(239, 68, 68, 0.3)"},wi={variable:"rgba(245, 158, 11, 0.5)",sectionStart:"rgba(59, 130, 246, 0.5)",sectionEnd:"rgba(59, 130, 246, 0.5)",invertedStart:"rgba(139, 92, 246, 0.5)",raw:"rgba(239, 68, 68, 0.5)"};function me({context:e,tags:t,hoveredId:o,selectedId:n,onHover:r,onSelect:a}){let[i,l]=useState(0),p=useCallback(()=>{let c=e.getContainerOffset(),u=[];for(let x of t){let g=e.getRectsForRange(x.from,x.to);for(let b of g)u.push({tagId:x.id,tagType:x.type,x:b.x+c.x,y:b.y+c.y,width:b.width,height:b.height});}return u},[e,t]),d=useMemo(()=>p(),[p,i]);return useEffect(()=>{let c=()=>{requestAnimationFrame(()=>l(u=>u+1));};return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),useEffect(()=>{let c=new ResizeObserver(()=>{requestAnimationFrame(()=>l(u=>u+1));});return c.observe(e.pagesContainer),()=>c.disconnect()},[e.pagesContainer]),d.length===0?null:jsx("div",{className:"template-highlight-overlay",children:d.map((c,u)=>{let x=c.tagId===o,g=c.tagId===n,b=x||g?wi[c.tagType]:Ii[c.tagType];return jsx("div",{className:`template-highlight ${x?"hovered":""} ${g?"selected":""}`,style:{position:"absolute",left:c.x,top:c.y,width:c.width,height:c.height,backgroundColor:b,borderRadius:2,cursor:"pointer"},onMouseEnter:()=>r?.(c.tagId),onMouseLeave:()=>r?.(void 0),onClick:()=>a?.(c.tagId)},`${c.tagId}-${u}`)})})}var he=`
|
|
497
128
|
.template-highlight-overlay {
|
|
498
129
|
position: absolute;
|
|
499
130
|
top: 0;
|
|
@@ -517,8 +148,8 @@ Iterates over ${h.name}[]. Access nested properties via ${h.name}.property`:h.ra
|
|
|
517
148
|
.template-highlight.selected {
|
|
518
149
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.6);
|
|
519
150
|
}
|
|
520
|
-
`;var
|
|
521
|
-
${
|
|
522
|
-
${
|
|
523
|
-
${
|
|
524
|
-
`}}var
|
|
151
|
+
`;var Di=ye.memo(U,(e,t)=>{let o=e.pluginState,n=t.pluginState;if(o?.hoveredId!==n?.hoveredId||o?.selectedId!==n?.selectedId)return false;let r=o?.tags??[],a=n?.tags??[];if(r.length!==a.length)return false;for(let i=0;i<r.length;i++)if(r[i].id!==a[i].id)return false;return e.renderedDomContext===t.renderedDomContext});function Te(e={}){return {id:"template",name:"Template",proseMirrorPlugins:[B()],Panel:Di,panelConfig:{position:e.panelPosition??"right",defaultSize:e.panelWidth??280,minSize:200,maxSize:400,resizable:true,collapsible:true,defaultCollapsed:e.defaultCollapsed??false},onStateChange:o=>{let n=m.getState(o.state);if(n)return {tags:n.tags,hoveredId:n.hoveredId,selectedId:n.selectedId}},initialize:o=>({tags:[]}),renderOverlay:(o,n,r)=>!n||n.tags.length===0?null:ye.createElement(me,{context:o,tags:n.tags,hoveredId:n.hoveredId,selectedId:n.selectedId,onHover:a=>{r&&D(r,a);},onSelect:a=>{if(r){L(r,a);let i=n.tags.find(l=>l.id===a);if(i){let l=r.state.tr.setSelection(TextSelection.near(r.state.doc.resolve(i.from)));r.dispatch(l),r.focus();}}}}),styles:`
|
|
152
|
+
${F}
|
|
153
|
+
${z}
|
|
154
|
+
${he}
|
|
155
|
+
`}}var Li=Te();var ts="0.0.2";export{z as ANNOTATION_PANEL_STYLES,U as AnnotationPanel,T as NAVIGATION_SHORTCUTS,F as TEMPLATE_DECORATION_STYLES,ts as VERSION,ni as createDoubleClickWordSelector,Te as createTemplatePlugin,B as createTemplateProseMirrorPlugin,ri as createTripleClickParagraphSelector,S as describeShortcut,di as expandSelectionToWord,ei as expandSelectionToWordBoundaries,_ as extendSelectionTo,ee as findNextWordStart,te as findPreviousWordStart,ne as findVisualLineEnd,oe as findVisualLineStart,Ja as findWordAt,R as findWordBoundaries,si as findWordEnd,ii as findWordStart,fi as getNavigationShortcutDescriptions,li as getSelectionInfo,pe as getTemplatePluginTags,ja as getWordAt,ui as getWordAtCursor,Q as handleClickForMultiClick,ci as handleNavigationKey,pi as isNavigationKey,ai as isPunctuation,K as isWhitespace,Y as isWhitespaceChar,P as isWordChar,M as isWordCharacter,gi as matchesShortcut,re as moveByWord,ae as moveToLineEdge,ie as parseNavigationAction,J as selectParagraphAtCursor,$ as selectWordAtCursor,Qa as selectWordInTextNode,D as setHoveredElement,L as setSelectedElement,H as setSelectionPosition,Li as templatePlugin,m as templatePluginKey};
|