@eigenpal/docx-js-editor 0.0.11 → 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.
Files changed (99) hide show
  1. package/dist/DocumentAgent-Ci6_T-XM.d.ts +412 -0
  2. package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
  3. package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
  4. package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
  5. package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
  6. package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
  7. package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
  8. package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
  9. package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
  10. package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
  11. package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
  12. package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
  13. package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
  14. package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
  15. package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
  16. package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
  17. package/dist/chunk-2ASOEN3V.js +1 -0
  18. package/dist/chunk-6MBDPZVD.js +111 -0
  19. package/dist/chunk-6YLNNCRZ.cjs +10 -0
  20. package/dist/chunk-BVQ2QRHA.cjs +4 -0
  21. package/dist/chunk-COP5BIBZ.js +10 -0
  22. package/dist/chunk-CZ7W7MCM.cjs +2 -0
  23. package/dist/chunk-E6XDMUAM.js +4 -0
  24. package/dist/chunk-EMKABJPH.js +1 -0
  25. package/dist/{chunk-TRAQI6RX.cjs → chunk-EPCZ24TY.cjs} +5 -5
  26. package/dist/chunk-ESI4BSBF.js +1 -0
  27. package/dist/chunk-FLECKDK4.cjs +58 -0
  28. package/dist/chunk-ITWEFKGQ.cjs +1 -0
  29. package/dist/chunk-KESNGXGO.js +1 -0
  30. package/dist/chunk-KVAT5SVD.js +2 -0
  31. package/dist/chunk-L34XFLQZ.cjs +1 -0
  32. package/dist/chunk-M7F2CUUD.js +2 -0
  33. package/dist/chunk-MDPDH7KS.js +58 -0
  34. package/dist/chunk-MTX3EEBJ.js +258 -0
  35. package/dist/chunk-NT2REEAA.cjs +1 -0
  36. package/dist/{chunk-PM4Y7OFN.js → chunk-OTG4NABM.js} +5 -5
  37. package/dist/chunk-OW5H5DNE.cjs +1 -0
  38. package/dist/chunk-PJVI53AH.js +2 -0
  39. package/dist/chunk-PNMZPPPI.cjs +2 -0
  40. package/dist/chunk-SF53KLDZ.cjs +1 -0
  41. package/dist/chunk-TOI5W3HK.js +8 -0
  42. package/dist/chunk-UAVOWAIF.cjs +8 -0
  43. package/dist/chunk-VN7XH644.cjs +258 -0
  44. package/dist/chunk-W4DUKACP.cjs +111 -0
  45. package/dist/chunk-XS2AQFMF.cjs +2 -0
  46. package/dist/chunk-ZDYHAYN6.js +1 -0
  47. package/dist/clipboard-BOocwmAM.d.ts +539 -0
  48. package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
  49. package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
  50. package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
  51. package/dist/core-plugins.cjs +1 -1
  52. package/dist/core-plugins.d.cts +4 -3
  53. package/dist/core-plugins.d.ts +4 -3
  54. package/dist/core-plugins.js +1 -1
  55. package/dist/core.cjs +1 -0
  56. package/dist/core.d.cts +23 -0
  57. package/dist/core.d.ts +23 -0
  58. package/dist/core.js +1 -0
  59. package/dist/headless.cjs +2 -2
  60. package/dist/headless.d.cts +8 -175
  61. package/dist/headless.d.ts +8 -175
  62. package/dist/headless.js +1 -1
  63. package/dist/index.cjs +9 -378
  64. package/dist/index.d.cts +17 -4161
  65. package/dist/index.d.ts +17 -4161
  66. package/dist/index.js +9 -378
  67. package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
  68. package/dist/insertOperations-DKVmCV32.d.cts +176 -0
  69. package/dist/mcp-cli.js +21 -21
  70. package/dist/mcp.cjs +10 -10
  71. package/dist/mcp.d.cts +2 -1
  72. package/dist/mcp.d.ts +2 -1
  73. package/dist/mcp.js +9 -9
  74. package/dist/processTemplate-BHBTDAIC.js +1 -0
  75. package/dist/processTemplate-QOEAXCKA.cjs +1 -0
  76. package/dist/react-Be1YOl4z.d.ts +1356 -0
  77. package/dist/react-DPuSVbgY.d.cts +1356 -0
  78. package/dist/react.cjs +1 -0
  79. package/dist/react.css +1 -0
  80. package/dist/react.d.cts +9 -0
  81. package/dist/react.d.ts +9 -0
  82. package/dist/react.js +1 -0
  83. package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
  84. package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
  85. package/dist/types-D96elyJF.d.cts +310 -0
  86. package/dist/types-xMzSPT4i.d.ts +310 -0
  87. package/dist/ui.cjs +1 -0
  88. package/dist/ui.d.cts +2103 -0
  89. package/dist/ui.d.ts +2103 -0
  90. package/dist/ui.js +1 -0
  91. package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
  92. package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
  93. package/package.json +85 -10
  94. package/dist/chunk-GQ4JYQWC.js +0 -58
  95. package/dist/chunk-H3JNHCD7.cjs +0 -10
  96. package/dist/chunk-L2UUZRZI.js +0 -10
  97. package/dist/chunk-QOIY4Y6N.cjs +0 -9
  98. package/dist/chunk-QYKJKSKZ.cjs +0 -58
  99. package/dist/chunk-TPUJJJWA.js +0 -9
@@ -0,0 +1,111 @@
1
+ import {g,e,f}from'./chunk-EMKABJPH.js';import {ra as ra$1,h,c,d,a,ia}from'./chunk-E6XDMUAM.js';import qo,{useRef,useState,useEffect,useCallback,useLayoutEffect,useMemo}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var Xt=()=>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"})]}),Jt=()=>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"})}),Qt=()=>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"})}),qt=()=>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"})}),eo=()=>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"})]}),to=()=>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"})]}),oo=()=>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"})]}),ro=()=>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"})]}),no=()=>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"})]}),io=()=>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 ao(e){switch(e){case "askAI":return jsx(Xt,{});case "rewrite":return jsx(Jt,{});case "expand":return jsx(Qt,{});case "summarize":return jsx(qt,{});case "translate":return jsx(eo,{});case "explain":return jsx(to,{});case "fixGrammar":return jsx(oo,{});case "makeFormal":return jsx(ro,{});case "makeCasual":return jsx(no,{});case "custom":return jsx(io,{});default:return null}}var so=({action:e$1,onClick:t,isHighlighted:o,onMouseEnter:r})=>{let n=e(e$1),i=f(e$1),a=ao(e$1);return jsxs("button",{type:"button",className:`docx-context-menu-item ${o?"docx-context-menu-item-highlighted":""}`,onClick:t,onMouseEnter:r,title:i,role:"menuitem",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",border:"none",background:o?"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:n})]})},lo=({isOpen:e,onSubmit:t,onClose:o,selectedText:r})=>{let[n,i]=useState(""),a=useRef(null);useEffect(()=>{e&&a.current&&a.current.focus();},[e]);let c=s=>{s.preventDefault(),n.trim()&&(t(n.trim()),i(""));},d=s=>{s.key==="Escape"&&o();};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:c,children:[jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:['Selected: "',r.slice(0,50),r.length>50?"...":"",'"']}),jsx("input",{ref:a,type:"text",value:n,onChange:s=>i(s.target.value),onKeyDown:d,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:o,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:!n.trim(),style:{padding:"6px 12px",border:"none",borderRadius:"4px",background:n.trim()?"var(--doc-primary)":"var(--doc-border)",color:n.trim()?"white":"var(--doc-text-placeholder)",cursor:n.trim()?"pointer":"not-allowed",fontSize:"12px"},children:"Send"})]})]})}):null},In=({isOpen:e,position:t,selectedText:o,selectionContext:r,onAction:n,onClose:i,actions:a=g,showCustomPrompt:c=true,className:d=""})=>{let s=useRef(null),[x,m]=useState(0),[p,g]=useState(false),b=c?[...a,"custom"]:a;useEffect(()=>{if(!e)return;let l=h=>{s.current&&!s.current.contains(h.target)&&i();};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[e,i]),useEffect(()=>{if(!e)return;let l=h=>{switch(h.key){case "Escape":p?g(false):i();break;case "ArrowDown":h.preventDefault(),m(P=>(P+1)%b.length);break;case "ArrowUp":h.preventDefault(),m(P=>(P-1+b.length)%b.length);break;case "Enter":h.preventDefault();let C=b[x];C==="custom"?g(true):(n(C),i());break}};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,x,b,n,i,p]),useEffect(()=>{e&&(m(0),g(false));},[e]);let v=useCallback(()=>{let h=b.length*36+16,C=t.x,P=t.y;return typeof window<"u"&&(C+200>window.innerWidth&&(C=window.innerWidth-200-10),P+h>window.innerHeight&&(P=window.innerHeight-h-10),C<10&&(C=10),P<10&&(P=10)),{position:"fixed",top:P,left:C,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,b.length]),u=l=>{l==="custom"?g(true):(n(l),i());},f=l=>{n("custom",l),i();};return !e||!o?null:jsxs("div",{ref:s,className:`docx-context-menu ${d}`,style:v(),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:['"',o.slice(0,30),o.length>30?"...":"",'"']}),jsx("div",{role:"group",children:b.map((l,h)=>jsx(so,{action:l,onClick:()=>u(l),isHighlighted:h===x,onMouseEnter:()=>m(h)},l))}),c&&jsx(lo,{isOpen:p,onSubmit:f,onClose:()=>g(false),selectedText:o})]})};function Rn(){let[e,t]=useState(false),[o,r]=useState({x:0,y:0}),[n,i]=useState(""),[a,c]=useState(),d=useCallback((x,m,p)=>{x.preventDefault(),r({x:x.clientX,y:x.clientY}),i(m),c(p),t(true);},[]),s=useCallback(()=>{t(false);},[]);return {isOpen:e,position:o,selectedText:n,selectionContext:a,openMenu:d,closeMenu:s}}function Pn(e){return {rewrite:"Ctrl+Shift+R",summarize:"Ctrl+Shift+S",translate:"Ctrl+Shift+T",fixGrammar:"Ctrl+Shift+G"}[e]}function Ln(e,t,o){return !(!t||t.trim().length===0)}function Dn(){return [...g]}function Mn(){return ["askAI","rewrite","expand","summarize","translate","explain","fixGrammar","makeFormal","makeCasual","custom"]}var co=()=>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"})}),ct=()=>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"})}),po=()=>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"})]}),uo=()=>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"})}),go=()=>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:`
2
+ @keyframes spin {
3
+ from { transform: rotate(0deg); }
4
+ to { transform: rotate(360deg); }
5
+ }
6
+ `})]});function mo(e,t){let o=[],r=e.split(/(\s+)/),n=t.split(/(\s+)/),i=0,a=0;for(;i<r.length||a<n.length;){if(i>=r.length){o.push({type:"added",text:n.slice(a).join("")});break}if(a>=n.length){o.push({type:"removed",text:r.slice(i).join("")});break}if(r[i]===n[a])o.push({type:"same",text:r[i]}),i++,a++;else {let d=n.indexOf(r[i],a),s=r.indexOf(n[a],i);d===-1&&s===-1?(o.push({type:"removed",text:r[i]}),o.push({type:"added",text:n[a]}),i++,a++):s!==-1&&(d===-1||s-i<=d-a)?(o.push({type:"added",text:n[a]}),a++):(o.push({type:"removed",text:r[i]}),i++);}}let c=[];for(let d of o)c.length>0&&c[c.length-1].type===d.type?c[c.length-1].text+=d.text:c.push(d);return c}var xo=({original:e,modified:t})=>{let o=mo(e,t);return jsx("div",{className:"docx-response-diff",style:{lineHeight:1.6,fontSize:"14px"},children:o.map((r,n)=>{let i={};switch(r.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:r.text},n)})})},Fn=({originalText:e$1,response:t,action:o,isLoading:r,error:n,onAccept:i,onReject:a,onRetry:c,allowEdit:d=true,showDiff:s=true,className:x="",position:m})=>{let[p,g]=useState(false),[b,v]=useState(""),u=useRef(null),f=useRef(null),l=t?.newText||"";useEffect(()=>{l&&v(l);},[l]),useEffect(()=>{p&&u.current&&(u.current.focus(),u.current.select());},[p]),useEffect(()=>{let R=D=>{D.key==="Escape"?p?(g(false),v(l)):a():D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&(D.preventDefault(),h());};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[p,l,a]);let h=useCallback(()=>{i(p?b:l);},[p,b,l,i]),C=useCallback(()=>{g(true);},[]),P=useCallback(()=>{g(false),v(l);},[l]),H={position:m?"fixed":"relative",...m&&{left:m.x,top:m.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 r?jsx("div",{ref:f,className:`docx-response-preview docx-response-preview-loading ${x}`,style:H,children:jsxs("div",{style:{padding:"24px",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[jsx(go,{}),jsxs("div",{style:{color:"var(--doc-text-muted)",fontSize:"14px"},children:[e(o),"..."]})]})}):n?jsx("div",{ref:f,className:`docx-response-preview docx-response-preview-error ${x}`,style:H,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:n}),jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[c&&jsxs("button",{type:"button",onClick:c,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(po,{}),"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||!l?null:jsxs("div",{ref:f,className:`docx-response-preview ${x}`,style:H,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:[e(o)," 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(ct,{})})]}),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:u,value:b,onChange:R=>v(R.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"}})]}):s?jsxs("div",{children:[jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"var(--doc-text-muted)"},children:"Changes:"}),jsx(xo,{original:e$1,modified:l})]}):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$1}),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:l})]}),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((R,D)=>jsx("div",{children:R},D))})]}),jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("div",{children:[d&&!p&&jsxs("button",{type:"button",onClick:C,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(uo,{}),"Edit"]}),p&&jsx("button",{type:"button",onClick:P,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(ct,{}),"Reject"]}),jsxs("button",{type:"button",onClick:h,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(co,{}),"Accept"]})]})]})]})};function zn(){let[e,t]=useState({isVisible:false,originalText:"",response:null,action:"rewrite",isLoading:false}),o=useCallback((a,c,d)=>{t({isVisible:true,originalText:a,response:null,action:c,isLoading:true,position:d});},[]),r=useCallback(a=>{t(c=>({...c,response:a,isLoading:false}));},[]),n=useCallback(a=>{t(c=>({...c,error:a,isLoading:false}));},[]),i=useCallback(()=>{t(a=>({...a,isVisible:false}));},[]);return {state:e,showPreview:o,setResponse:r,setError:n,hidePreview:i}}function Wn(e,t){return {success:true,newText:e,warnings:t}}function Hn(e){return {success:false,error:e}}var pt=[{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"}],bo=()=>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"})]}),ho=()=>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"})]}),vo=()=>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"})]}),yo=()=>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"})}),Co=()=>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 wo(e){switch(e){case "cut":return jsx(bo,{});case "copy":return jsx(ho,{});case "paste":case "pasteAsPlainText":return jsx(vo,{});case "delete":return jsx(yo,{});case "selectAll":return jsx(Co,{});default:return null}}var So=({item:e,onClick:t,isHighlighted:o,onMouseEnter:r})=>e.action==="separator"?jsx("div",{className:"docx-text-context-menu-separator",style:{height:"1px",backgroundColor:"var(--doc-border)",margin:"4px 12px"}}):jsxs(Fragment,{children:[jsxs("button",{type:"button",className:`docx-text-context-menu-item ${o?"docx-text-context-menu-item-highlighted":""} ${e.disabled?"docx-text-context-menu-item-disabled":""}`,onClick:t,onMouseEnter:r,disabled:e.disabled,role:"menuitem","aria-disabled":e.disabled,style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:o&&!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:wo(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"}})]}),$n=({isOpen:e,position:t,hasSelection:o,isEditable:r,hasClipboardContent:n=true,onAction:i,onClose:a,items:c,className:d=""})=>{let s=useRef(null),[x,m]=useState(0),p=(c||pt).map(u=>{let f=(()=>{if(u.disabled!==void 0)return u.disabled;switch(u.action){case "cut":case "copy":case "delete":return !o;case "paste":case "pasteAsPlainText":return !r||!n;default:return false}})();return {...u,disabled:f}}),g=p.filter(u=>u.action!=="separator");useEffect(()=>{if(!e)return;let u=l=>{s.current&&!s.current.contains(l.target)&&a();},f=setTimeout(()=>{document.addEventListener("mousedown",u);},0);return ()=>{clearTimeout(f),document.removeEventListener("mousedown",u);}},[e,a]),useEffect(()=>{if(!e)return;let u=f=>{switch(f.key){case "Escape":f.preventDefault(),a();break;case "ArrowDown":f.preventDefault(),m(h=>{let C=(h+1)%g.length;for(;g[C]?.disabled&&C!==h;)C=(C+1)%g.length;return C});break;case "ArrowUp":f.preventDefault(),m(h=>{let C=(h-1+g.length)%g.length;for(;g[C]?.disabled&&C!==h;)C=(C-1+g.length)%g.length;return C});break;case "Enter":f.preventDefault();let l=g[x];l&&!l.disabled&&(i(l.action),a());break}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,x,g,i,a]),useEffect(()=>{e&&m(0);},[e]);let b=useCallback(()=>{let f=p.length*36+16,l=t.x,h=t.y;return typeof window<"u"&&(l+220>window.innerWidth&&(l=window.innerWidth-220-10),h+f>window.innerHeight&&(h=window.innerHeight-f-10),l<10&&(l=10),h<10&&(h=10)),{position:"fixed",top:h,left:l,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]),v=u=>{u.disabled||(i(u.action),a());};return e?jsx("div",{ref:s,className:`docx-text-context-menu ${d}`,style:b(),role:"menu","aria-label":"Text editing menu",children:p.map((u,f)=>{let l=g.findIndex(h=>h===u);return jsx(So,{item:u,onClick:()=>v(u),isHighlighted:l===x,onMouseEnter:()=>{l>=0&&!u.disabled&&m(l);}},`${u.action}-${f}`)})}):null};function Gn(e={}){let{enabled:t=true,isEditable:o=true,containerRef:r,onAction:n}=e,[i,a]=useState(false),[c,d]=useState({x:0,y:0}),[s,x]=useState(false),m=useCallback(()=>{let u=window.getSelection(),f=u&&!u.isCollapsed&&u.toString().length>0;return x(!!f),!!f},[]),p=useCallback(u=>{t&&(u.preventDefault(),u.stopPropagation(),m(),d({x:u.clientX,y:u.clientY}),a(true));},[t,m]),g=useCallback(()=>{a(false);},[]),b=useCallback(u=>{switch(g(),u){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":document.execCommand("paste");break;case "pasteAsPlainText":navigator.clipboard.readText?.().then(f=>{document.execCommand("insertText",false,f);}).catch(()=>{document.execCommand("paste");});break;case "delete":document.execCommand("delete");break;case "selectAll":document.execCommand("selectAll");break}n?.(u);},[g,n]),v=useCallback(u=>{p(u);},[p]);return useEffect(()=>{if(!i)return;let u=f=>{f.key==="Escape"&&g();};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[i,g]),{isOpen:i,position:c,hasSelection:s,openMenu:p,closeMenu:g,handleAction:b,onContextMenu:v}}function jn(e){return {cut:"Cut",copy:"Copy",paste:"Paste",pasteAsPlainText:"Paste as Plain Text",selectAll:"Select All",delete:"Delete",separator:""}[e]}function Zn(e){return {cut:"Ctrl+X",copy:"Ctrl+C",paste:"Ctrl+V",pasteAsPlainText:"Ctrl+Shift+V",selectAll:"Ctrl+A",delete:"Del",separator:""}[e]}function Xn(){return [...pt]}function Jn(e,t,o){switch(e){case "cut":case "copy":case "delete":return t;case "paste":case "pasteAsPlainText":return o;case "selectAll":return true;default:return true}}var To={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function ei({onPrint:e,disabled:t=false,label:o="Print",className:r="",style:n,showIcon:i=true,compact:a=false}){let c={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",...n};return jsxs("button",{className:`docx-print-button ${r}`.trim(),style:c,onClick:e,disabled:t,"aria-label":o,title:o,children:[i&&jsx(Eo,{size:a?14:16}),!a&&jsx("span",{children:o})]})}function ti(){return jsx("style",{children:`
7
+ @media print {
8
+ /* Hide everything except print content */
9
+ body * {
10
+ visibility: hidden;
11
+ }
12
+
13
+ .docx-print-pages,
14
+ .docx-print-pages * {
15
+ visibility: visible;
16
+ }
17
+
18
+ .docx-print-pages {
19
+ position: absolute;
20
+ left: 0;
21
+ top: 0;
22
+ }
23
+
24
+ /* Remove shadows and margins in print */
25
+ .docx-print-page {
26
+ box-shadow: none !important;
27
+ margin: 0 !important;
28
+ page-break-after: always;
29
+ page-break-inside: avoid;
30
+ }
31
+
32
+ /* Ensure images print */
33
+ img {
34
+ max-width: 100%;
35
+ page-break-inside: avoid;
36
+ }
37
+
38
+ /* Ensure tables don't break badly */
39
+ table {
40
+ page-break-inside: avoid;
41
+ }
42
+
43
+ tr {
44
+ page-break-inside: avoid;
45
+ }
46
+
47
+ /* Keep headings with content */
48
+ h1, h2, h3, h4, h5, h6 {
49
+ page-break-after: avoid;
50
+ }
51
+
52
+ /* Avoid orphan lines */
53
+ p {
54
+ orphans: 3;
55
+ widows: 3;
56
+ }
57
+ }
58
+
59
+ @page {
60
+ margin: 0;
61
+ size: auto;
62
+ }
63
+ `})}function Eo({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 oi(){window.print();}function ri(e="Document",t){let o=window.open("","_blank");return o?(o.document.write(`
64
+ <!DOCTYPE html>
65
+ <html>
66
+ <head>
67
+ <title>${e}</title>
68
+ <style>
69
+ @media print {
70
+ body {
71
+ margin: 0;
72
+ padding: 0;
73
+ }
74
+ @page {
75
+ margin: 0;
76
+ }
77
+ }
78
+ </style>
79
+ </head>
80
+ <body>
81
+ ${t}
82
+ </body>
83
+ </html>
84
+ `),o.document.close(),o):null}function ni(){return {...To}}function ii(e,t){if(!e||!e.trim())return null;let o=e.trim();if(/^\d+$/.test(o)){let n=parseInt(o,10);return n>=1&&n<=t?{start:n,end:n}:null}let r=o.match(/^(\d+)-(\d+)$/);if(r){let n=parseInt(r[1],10),i=parseInt(r[2],10);return n>=1&&i<=t&&n<=i?{start:n,end:i}:null}return null}function ai(e,t){return e?e.start===e.end?`Page ${e.start}`:`Pages ${e.start}-${e.end}`:`All (${t} pages)`}function si(){return typeof window<"u"&&typeof window.print=="function"}function fi({onAction:e,disabled:t=false,canMerge:o=false,canSplit:r=false}){let n=useCallback(s=>{s.preventDefault(),s.stopPropagation();},[]),i=useCallback(()=>{o&&e("mergeCells");},[e,o]),a$1=useCallback(()=>{r&&e("splitCell");},[e,r]),c$1=jsx(h,{content:"Merge cells",children:jsx(c,{variant:"ghost",size:"icon-sm",className:a("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!o)&&"opacity-30 cursor-not-allowed"),onMouseDown:n,onClick:i,disabled:t||!o,"aria-label":"Merge cells","data-testid":"toolbar-table-merge",children:jsx(d,{name:"call_merge",size:20})})}),d$1=jsx(h,{content:"Split cell",children:jsx(c,{variant:"ghost",size:"icon-sm",className:a("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",(t||!r)&&"opacity-30 cursor-not-allowed"),onMouseDown:n,onClick:a$1,disabled:t||!r,"aria-label":"Split cell","data-testid":"toolbar-table-split",children:jsx(d,{name:"call_split",size:20})})});return jsxs(Fragment,{children:[c$1,d$1]})}var Lo=[{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 Ti({onAction:e,disabled:t=false}){let o=useCallback(r=>{r.preventDefault(),r.stopPropagation();},[]);return jsx(Fragment,{children:Lo.map(({action:r,icon:n,label:i,testId:a$1})=>jsx(h,{content:i,children:jsx(c,{variant:"ghost",size:"icon-sm",className:a("text-slate-500 hover:text-slate-900 hover:bg-slate-100/80",t&&"opacity-30 cursor-not-allowed"),onMouseDown:o,onClick:()=>!t&&e(r),disabled:t,"aria-label":i,"data-testid":a$1,children:jsx(d,{name:n,size:20})})},typeof r=="string"?r:r.type))})}var N={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 Oo(){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 _o(){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 Ae=[{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 Li({value:e,onChange:t,colors:o=Ae,disabled:r=false,className:n,style:i,showNoFill:a=true,showCustomColor:c=true,compact:d=false}){let[s,x]=useState(false),[m,p]=useState(false),[g,b]=useState(null),[v,u]=useState(false),f=useRef(null);useEffect(()=>{let T=y=>{f.current&&!f.current.contains(y.target)&&x(false);};return s&&document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T);}},[s]);let l=useCallback(()=>{r||x(T=>!T);},[r]),h=useCallback(T=>{t?.(T),x(false);},[t]),C=useCallback(()=>{t?.(null),x(false);},[t]),P=useCallback(T=>{t?.(T.target.value);},[t]),H={...N.button,...m&&!r?N.buttonHover:{},...r?N.buttonDisabled:{},...d?{padding:"2px 4px",minWidth:"28px",height:"24px"}:{}},R={...N.colorIndicator,backgroundColor:e||"transparent",...e===null?{background:"repeating-linear-gradient(45deg, #fff, #fff 2px, #f0f0f0 2px, #f0f0f0 4px)"}:{}},D=["docx-cell-background-picker"];return n&&D.push(n),d&&D.push("docx-cell-background-picker-compact"),jsxs("div",{ref:f,className:D.join(" "),style:{...N.container,...i},children:[jsxs("button",{type:"button",style:H,onClick:l,onMouseEnter:()=>p(true),onMouseLeave:()=>p(false),disabled:r,title:"Cell Background Color","aria-label":"Cell Background Color","aria-haspopup":"true","aria-expanded":s,children:[jsx(Oo,{}),jsx("div",{style:R})]}),s&&jsxs("div",{style:N.dropdown,children:[a&&jsxs(Fragment,{children:[jsxs("button",{type:"button",style:{...N.noFillButton,...v?N.noFillButtonHover:{}},onClick:C,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),children:[jsx(_o,{}),jsx("span",{children:"No Fill"})]}),jsx("div",{style:N.separator})]}),jsx("div",{style:N.colorGrid,children:o.map(T=>jsx("button",{type:"button",style:{...N.colorCell,backgroundColor:T.hex,...g===T.hex?N.colorCellHover:{},...e===T.hex?N.colorCellSelected:{}},onClick:()=>h(T.hex),onMouseEnter:()=>b(T.hex),onMouseLeave:()=>b(null),title:T.name,"aria-label":T.name},T.hex))}),c&&jsxs(Fragment,{children:[jsx("div",{style:N.separator}),jsxs("div",{style:N.customColorRow,children:[jsx("input",{type:"color",value:e||"#FFFFFF",onChange:P,style:N.customColorInput,title:"Custom Color"}),jsx("span",{style:N.customColorLabel,children:"Custom color"})]})]})]})]})}function Di(){return Ae}function Mi(e,t){return {hex:e.toUpperCase(),name:t||e}}function Ai(e){return Ae.some(t=>t.hex.toUpperCase()===e.toUpperCase())}function Oi(e){return Ae.find(o=>o.hex.toUpperCase()===e.toUpperCase())?.name||e}function _i(e){if(e)return {fill:{rgb:e.replace("#","")},pattern:"clear"}}function Ni(e){return !e||!e.fill?null:e.fill.rgb?`#${e.fill.rgb}`:null}function No(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 Bi(e){let t=No(e);return t?(.299*t.r+.587*t.g+.114*t.b)/255>.5?"#000000":"#FFFFFF":"#000000"}var Bo="var(--doc-error)",Fo="var(--doc-success)",zo="You have unsaved changes. Are you sure you want to leave?",Wo=({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"})]}),Ho=({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"})]}),Uo=`
85
+ @keyframes docx-unsaved-pulse {
86
+ 0%, 100% { opacity: 1; }
87
+ 50% { opacity: 0.6; }
88
+ }
89
+ `,Yo=(e,t,o,r,n,i,a)=>{let c={display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",animation:o&&r?"docx-unsaved-pulse 2s ease-in-out infinite":"none"};switch(t==="absolute-top-right"?(c.position="absolute",c.top="4px",c.right="4px"):t==="absolute-top-left"&&(c.position="absolute",c.top="4px",c.left="4px"),e){case "dot":return {...c,width:`${a}px`,height:`${a}px`,borderRadius:"50%",backgroundColor:o?n:i};case "badge":return {...c,padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:500,backgroundColor:o?n:i,color:"white"};case "text":return {...c,fontSize:"12px",color:o?n:i,fontWeight:500};case "icon":return {...c,color:o?n:i};default:return c}},Ui=({hasUnsavedChanges:e,variant:t="dot",position:o="inline",showPulse:r=true,label:n="Unsaved",savedLabel:i="Saved",showWhenSaved:a=false,unsavedColor:c=Bo,savedColor:d=Fo,size:s=8,className:x="",style:m,onClick:p,title:g})=>{if(useEffect(()=>{if(!r||!e)return;let l="docx-unsaved-pulse-keyframes";if(!document.getElementById(l)){let h=document.createElement("style");h.id=l,h.textContent=Uo,document.head.appendChild(h);}},[r,e]),!e&&!a)return null;let v={...Yo(t,o,e,r,c,d,s),...m,cursor:p?"pointer":void 0},u=e?"Document has unsaved changes":"All changes saved",f=()=>{switch(t){case "dot":return null;case "badge":return e?n:i;case "text":return e?n:i;case "icon":return e?jsx(Ho,{size:s}):jsx(Wo,{size:s});default:return null}};return jsx("span",{className:`docx-unsaved-indicator docx-unsaved-indicator-${t} ${e?"docx-unsaved":"docx-saved"} ${x}`,style:v,onClick:p,title:g??u,role:p?"button":"status","aria-label":e?"Unsaved changes":"All changes saved",children:f()})};function Yi(e={}){let{document:t,warnBeforeLeave:o=true,warningMessage:r=zo,enabled:n=true,onChangeStatusChange:i}=e,[a,c]=useState(false),[d,s]=useState(0),[x,m]=useState(null),p=useRef(null),g=useRef(false),b=useCallback(l=>{if(!l)return null;try{return JSON.stringify(l.package)}catch{return null}},[]),v=useCallback(()=>{n&&(c(false),s(0),m(t??null),p.current=b(t));},[n,t,b]),u=useCallback(()=>{n&&(a||(c(true),i?.(true)),s(l=>l+1));},[n,a,i]),f=useCallback(l=>{let h=l!==void 0?l:t;c(false),s(0),m(h??null),p.current=b(h),g.current=true;},[t,b]);return useEffect(()=>{!n||!t||g.current||f(t);},[n,t,f]),useEffect(()=>{if(!n||!t||!g.current)return;let l=b(t),h=p.current;if(l!==h){let C=b(x);l!==C?(a||(c(true),i?.(true)),s(P=>P+1)):a&&(c(false),i?.(false)),p.current=l;}},[n,t,x,a,b,i]),useEffect(()=>{if(!n||!o||!a)return;let l=h=>(h.preventDefault(),h.returnValue=r,r);return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[n,o,a,r]),{hasUnsavedChanges:a,markAsSaved:v,markAsChanged:u,resetTracking:f,lastSavedDocument:x,changeCount:d}}function Ki(e){return {dot:"Dot",badge:"Badge",text:"Text",icon:"Icon"}[e]}function Vi(){return ["dot","badge","text","icon"]}function $i(){return ["inline","absolute-top-right","absolute-top-left"]}function Gi(){let e=0,t=null,o=false;return {markChanged:()=>{e++,o=true;},markSaved:()=>{o=false,t=new Date;},getState:()=>({changeCount:e,lastSaveTime:t,hasUnsavedChanges:o}),reset:()=>{e=0,t=null,o=false;}}}var Ko={small:{size:16,strokeWidth:2,fontSize:11},medium:{size:32,strokeWidth:3,fontSize:13},large:{size:48,strokeWidth:4,fontSize:14}},Vo="var(--doc-primary)",$o=300,Go=`
90
+ @keyframes docx-loading-spin {
91
+ 0% { transform: rotate(0deg); }
92
+ 100% { transform: rotate(360deg); }
93
+ }
94
+
95
+ @keyframes docx-loading-pulse {
96
+ 0%, 100% { opacity: 1; transform: scale(1); }
97
+ 50% { opacity: 0.5; transform: scale(0.95); }
98
+ }
99
+
100
+ @keyframes docx-loading-dots {
101
+ 0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
102
+ 40% { transform: scale(1); opacity: 1; }
103
+ }
104
+
105
+ @keyframes docx-loading-bar {
106
+ 0% { left: -35%; right: 100%; }
107
+ 60% { left: 100%; right: -90%; }
108
+ 100% { left: 100%; right: -90%; }
109
+ }
110
+ `,jo=({size:e,strokeWidth:t,color:o})=>{let r=(e-t)/2,n=r*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,fill:"none",stroke:o,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${n*.75} ${n}`,opacity:.25}),jsx("circle",{cx:e/2,cy:e/2,r,fill:"none",stroke:o,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${n*.25} ${n}`,transform:`rotate(-90 ${e/2} ${e/2})`})]})},Zo=({size:e,color:t})=>{let o=e/4,r=o/2;return jsx("div",{style:{display:"flex",gap:`${r}px`},children:[0,1,2].map(n=>jsx("div",{style:{width:o,height:o,borderRadius:"50%",backgroundColor:t,animation:`docx-loading-dots 1.4s ease-in-out ${n*.16}s infinite both`}},n))})},Xo=({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"}})}),Jo=({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"}}),Qo=({size:e,color:t,progress:o,showText:r,fontSize:n})=>{let i=Math.max(0,Math.min(100,o));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"}}),r&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:n,fontWeight:500,color:i>50?"#fff":t},children:[Math.round(i),"%"]})]})},Qi=({isLoading:e,variant:t="spinner",size:o="medium",message:r,overlay:n=false,overlayOpacity:i=.5,progress:a=0,showProgressText:c=true,color:d=Vo,className:s="",style:x})=>{let m=Ko[o];if(useEffect(()=>{let b="docx-loading-keyframes";if(!document.getElementById(b)){let v=document.createElement("style");v.id=b,v.textContent=Go,document.head.appendChild(v);}},[]),!e)return null;let p=()=>{switch(t){case "spinner":return jsx(jo,{size:m.size,strokeWidth:m.strokeWidth,color:d});case "dots":return jsx(Zo,{size:m.size,color:d});case "bar":return jsx(Xo,{size:m.size,color:d});case "pulse":return jsx(Jo,{size:m.size,color:d});case "progress":return jsx(Qo,{size:m.size,color:d,progress:a,showText:c,fontSize:m.fontSize});default:return null}},g=jsxs("div",{className:`docx-loading-content ${s}`,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",...x},children:[p(),r&&jsx("div",{style:{fontSize:m.fontSize,color:n?"white":"var(--doc-text-muted)",textAlign:"center"},children:r})]});return n?jsx("div",{className:`docx-loading-overlay ${s}`,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,...x},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?a:void 0,"aria-busy":"true","aria-label":r||"Loading",children:g}):jsx("div",{className:`docx-loading-inline ${s}`,style:{display:"inline-flex",alignItems:"center",...x},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t==="progress"?a:void 0,"aria-busy":"true","aria-label":r||"Loading",children:g})};function qi(e={}){let{initialLoading:t=false,minDuration:o=$o,onStart:r,onEnd:n}=e,[i,a]=useState(t),[c,d]=useState(null),[s,x]=useState(0),m=useRef(null),p=useRef(null),g=useCallback(u=>{m.current=Date.now(),a(true),d(u||null),x(0),r?.();},[r]),b=useCallback(()=>{let u=m.current,f=Date.now(),l=u?f-u:0,h=Math.max(0,o-l);h>0?p.current=setTimeout(()=>{a(false),d(null),x(0),m.current=null,n?.();},h):(a(false),d(null),x(0),m.current=null,n?.());},[o,n]),v=useCallback(async(u,f)=>{g(f);try{let l=await u();return b(),l}catch(l){throw b(),l}},[g,b]);return useEffect(()=>()=>{p.current&&clearTimeout(p.current);},[]),{isLoading:i,message:c,progress:s,startLoading:g,stopLoading:b,setProgress:x,setMessage:d,withLoading:v}}function ea(){let[e,t]=useState(new Map),o=useCallback((c,d)=>{t(s=>{let x=new Map(s);return x.set(c,{id:c,message:d,startTime:Date.now()}),x});},[]),r=useCallback((c,d)=>{t(s=>{let x=s.get(c);if(!x)return s;let m=new Map(s);return m.set(c,{...x,...d}),m});},[]),n=useCallback(c=>{t(d=>{let s=new Map(d);return s.delete(c),s});},[]),i=e.size>0;return {operations:Array.from(e.values()),isAnyLoading:i,startOperation:o,updateOperation:r,endOperation:n,getOperation:c=>e.get(c)}}function ta(e){return {spinner:"Spinner",dots:"Dots",bar:"Bar",pulse:"Pulse",progress:"Progress"}[e]}function oa(){return ["spinner","dots","bar","pulse","progress"]}function ra(){return ["small","medium","large"]}function na(e){return new Promise(t=>setTimeout(t,e))}var vt=4,yt=36,or=32,rr=()=>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 nr(e){let{containerRef:t,items:o,itemGap:r=vt,overflowButtonWidth:n=yt}=e,[i,a]=useState(o.length),c=useRef(new Map),d=useCallback(()=>{let m=t.current;if(!m){a(o.length);return}let p=m.offsetWidth;if(p===0)return;let g=[...o].sort((u,f)=>u.alwaysVisible&&!f.alwaysVisible?-1:!u.alwaysVisible&&f.alwaysVisible?1:(u.priority||3)-(f.priority||3)),b=0,v=0;for(let u of g){let l=(u.minWidth||c.current.get(u.id)||or)+(v>0?r:0),h=v<o.length-1?n+r:0;if(b+l+h<=p)b+=l,v++;else if(u.alwaysVisible)b+=l,v++;else break}a(Math.max(0,v));},[t,o,r,n]);useLayoutEffect(()=>{let m=t.current;if(!m)return;d();let p=new ResizeObserver(()=>{d();});return p.observe(m),()=>{p.disconnect();}},[t,d]),useEffect(()=>{d();},[o,d]);let{visibleItems:s,overflowItems:x}=useMemo(()=>{let m=[...o].sort((p,g)=>p.alwaysVisible&&!g.alwaysVisible?-1:!p.alwaysVisible&&g.alwaysVisible?1:(p.priority||3)-(g.priority||3));return {visibleItems:m.slice(0,i),overflowItems:m.slice(i)}},[o,i]);return {visibleItems:s,overflowItems:x,hasOverflow:x.length>0,recalculate:d}}var ir=({items:e,isOpen:t,onClose:o,anchorRef:r})=>{let n=useRef(null);return useEffect(()=>{if(!t)return;let i=a=>{n.current&&!n.current.contains(a.target)&&r.current&&!r.current.contains(a.target)&&o();};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[t,o,r]),useEffect(()=>{if(!t)return;let i=a=>{a.key==="Escape"&&o();};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t,o]),!t||e.length===0?null:jsx("div",{ref:n,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))})},la=({items:e,overflowItems:t=[],alwaysShowOverflow:o=false,renderOverflowButton:r,renderOverflowMenu:n,itemGap:i=vt,padding:a="8px 12px",overflowButtonWidth:c=yt,className:d="",style:s,height:x=44,backgroundColor:m="var(--doc-toolbar-bg)",borderBottom:p="1px solid var(--doc-border)"})=>{let g=useRef(null),b=useRef(null),[v,u]=useState(false),{visibleItems:f,overflowItems:l,hasOverflow:h}=nr({containerRef:g,items:e,itemGap:i,overflowButtonWidth:c}),C=[...l,...t],P=h||o||t.length>0,H=useCallback(()=>{u(T=>!T);},[]),R=useCallback(()=>{u(false);},[]),D=jsx("button",{ref:b,type:"button",className:"docx-responsive-toolbar-overflow-button",onClick:H,"aria-label":`Show ${C.length} more options`,"aria-expanded":v,"aria-haspopup":"menu",style:{display:"flex",alignItems:"center",justifyContent:"center",width:`${c}px`,height:"32px",border:"none",borderRadius:"4px",backgroundColor:v?"var(--doc-primary-light)":"transparent",color:"var(--doc-text-muted)",cursor:"pointer",transition:"background-color 0.15s ease"},children:jsx(rr,{})});return jsxs("div",{ref:g,className:`docx-responsive-toolbar ${d}`,style:{display:"flex",alignItems:"center",gap:`${i}px`,height:typeof x=="number"?`${x}px`:x,padding:a,backgroundColor:m,borderBottom:p,position:"relative",...s},children:[f.map(T=>jsxs(qo.Fragment,{children:[jsx("div",{className:"docx-responsive-toolbar-item","data-item-id":T.id,style:{flexShrink:0},children:T.content}),T.separatorAfter&&jsx("div",{className:"docx-responsive-toolbar-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]},T.id)),P&&jsx("div",{style:{flex:1,minWidth:0}}),P&&jsxs("div",{style:{position:"relative",flexShrink:0},children:[r?r(C.length,v,H):D,n?v&&n(C,R):jsx(ir,{items:C,isOpen:v,onClose:R,anchorRef:b})]})]})},da=({children:e,gap:t=2,separatorAfter:o=false,className:r="",style:n})=>jsxs(Fragment,{children:[jsx("div",{className:`docx-toolbar-group ${r}`,style:{display:"flex",alignItems:"center",gap:`${t}px`,...n},children:e}),o&&jsx("div",{className:"docx-toolbar-group-separator",style:{width:"1px",height:"24px",backgroundColor:"var(--doc-border)",margin:"0 4px"}})]});function ca(e,t,o){return {id:e,content:t,priority:3,...o}}function pa(e){return e.map(t=>({...t,priority:t.priority||3}))}function ua(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 lr={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},dr={backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"320px",maxWidth:"400px",width:"100%",margin:"20px"},cr={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},pr={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},ur={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},gr={padding:"20px"},mr={display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"16px"},xr={display:"grid",gap:"2px",padding:"4px",backgroundColor:"var(--doc-bg-hover)",borderRadius:"4px",cursor:"pointer"},Et={width:"24px",height:"24px",backgroundColor:"white",border:"1px solid var(--doc-border-dark)",borderRadius:"2px",transition:"background-color 0.1s, border-color 0.1s"},fr={...Et,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)"},br={marginTop:"8px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},hr={display:"flex",alignItems:"center",gap:"12px",margin:"16px 0",color:"var(--doc-text-muted)",fontSize:"12px"},wt={flex:1,height:"1px",backgroundColor:"var(--doc-border)"},St={display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},kt={fontSize:"14px",fontWeight:500,color:"var(--doc-text)",minWidth:"80px"},Tt={width:"80px",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",textAlign:"center"},vr={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},Je={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},yr={...Je,backgroundColor:"var(--doc-primary)",color:"white"},Cr={...Je,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},wr={...Je,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function Sr(){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 ba({isOpen:e,onClose:t,onInsert:o,maxGridRows:r=8,maxGridColumns:n=10,maxRows:i=100,maxColumns:a=20,className:c,style:d}){let[s,x]=useState(0),[m,p]=useState(0),[g,b]=useState(3),[v,u]=useState(3),f=useRef(null);useEffect(()=>{e&&(x(0),p(0),b(3),u(3));},[e]),useEffect(()=>{e&&f.current?.focus();},[e]);let l=useCallback((I,M)=>{x(I),p(M);},[]),h=useCallback(()=>{s>0&&m>0&&o({rows:s,columns:m});},[s,m,o]),C=useCallback(()=>{let I=Math.min(Math.max(1,g),i),M=Math.min(Math.max(1,v),a);o({rows:I,columns:M});},[g,v,i,a,o]),P=useCallback(I=>{I.key==="Escape"?t():I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),C());},[t,C]),H=useCallback(I=>{I.target===I.currentTarget&&t();},[t]),R=useCallback(I=>{let M=parseInt(I.target.value,10);isNaN(M)?I.target.value===""&&b(1):b(Math.min(Math.max(1,M),i));},[i]),D=useCallback(I=>{let M=parseInt(I.target.value,10);isNaN(M)?I.target.value===""&&u(1):u(Math.min(Math.max(1,M),a));},[a]);if(!e)return null;let T=[];for(let I=1;I<=r;I++)for(let M=1;M<=n;M++){let Ee=I<=s&&M<=m;T.push(jsx("div",{style:Ee?fr:Et,onMouseEnter:()=>l(I,M),onClick:h,role:"gridcell","aria-selected":Ee},`${I}-${M}`));}let y=g>=1&&v>=1,j=s>0&&m>0?`${m} x ${s} Table`:"Hover to select size";return jsx("div",{className:`docx-insert-table-dialog-overlay ${c||""}`,style:{...lr,...d},onClick:H,onKeyDown:P,role:"dialog","aria-modal":"true","aria-labelledby":"insert-table-dialog-title",children:jsxs("div",{ref:f,className:"docx-insert-table-dialog",style:dr,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-table-dialog-header",style:cr,children:[jsx("h2",{id:"insert-table-dialog-title",style:pr,children:jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsx(Sr,{}),"Insert Table"]})}),jsx("button",{type:"button",className:"docx-insert-table-dialog-close",style:ur,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-table-dialog-body",style:gr,children:[jsxs("div",{className:"docx-insert-table-grid-container",style:mr,children:[jsx("div",{className:"docx-insert-table-grid",style:{...xr,gridTemplateColumns:`repeat(${n}, 1fr)`},onMouseLeave:()=>{x(0),p(0);},role:"grid","aria-label":"Table size selector",children:T}),jsx("div",{className:"docx-insert-table-grid-label",style:br,children:j})]}),jsxs("div",{className:"docx-insert-table-separator",style:hr,children:[jsx("div",{style:wt}),jsx("span",{children:"or specify size"}),jsx("div",{style:wt})]}),jsxs("div",{className:"docx-insert-table-inputs",children:[jsxs("div",{style:St,children:[jsx("label",{htmlFor:"insert-table-rows",style:kt,children:"Rows:"}),jsx("input",{id:"insert-table-rows",type:"number",min:1,max:i,value:g,onChange:R,style:Tt})]}),jsxs("div",{style:St,children:[jsx("label",{htmlFor:"insert-table-cols",style:kt,children:"Columns:"}),jsx("input",{id:"insert-table-cols",type:"number",min:1,max:a,value:v,onChange:D,style:Tt})]})]})]}),jsxs("div",{className:"docx-insert-table-dialog-footer",style:vr,children:[jsx("button",{type:"button",className:"docx-insert-table-dialog-cancel",style:Cr,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-table-dialog-insert",style:y?yr:wr,onClick:C,disabled:!y,children:"Insert Table"})]})]})})}function ha(){let[e,t]=useState(false),o=useCallback(()=>t(true),[]),r=useCallback(()=>t(false),[]),n=useCallback(()=>t(i=>!i),[]);return {isOpen:e,open:o,close:r,toggle:n}}function va(e=3,t=3){return {rows:e,columns:t}}function ya(e,t=100,o=20){return e.rows>=1&&e.rows<=t&&e.columns>=1&&e.columns<=o}function Ca(e,t=100,o=20){return {rows:Math.min(Math.max(1,e.rows),t),columns:Math.min(Math.max(1,e.columns),o)}}function wa(e){return `${e.columns} x ${e.rows}`}function Sa(){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 Tr={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},Er={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"},Ir={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},Rr={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},Pr={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},Lr={padding:"20px"},Qe={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"},Dr={...Qe,borderColor:"var(--doc-primary)",backgroundColor:"var(--doc-primary-light)"},Mr={...Qe,padding:"20px",borderStyle:"solid",borderColor:"var(--doc-primary)"},Ar={display:"flex",justifyContent:"center",alignItems:"center",maxHeight:"250px",overflow:"hidden"},Or={maxWidth:"100%",maxHeight:"250px",objectFit:"contain",borderRadius:"4px"},_r={fontSize:"48px",color:"var(--doc-text-placeholder)",marginBottom:"12px"},Nr={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"8px"},Br={fontSize:"12px",color:"var(--doc-text-placeholder)"},Rt={marginBottom:"16px"},Pt={display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},Fr={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box"},zr={display:"flex",alignItems:"center",gap:"12px"},Lt={width:"100px",padding:"8px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",textAlign:"center"},Mt={padding:"6px 10px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"16px"},Wr={...Mt,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)",color:"white"},Hr={fontSize:"12px",color:"var(--doc-text-muted)",marginTop:"8px",textAlign:"center"},Ur={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},qe={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},Yr={...qe,backgroundColor:"var(--doc-primary)",color:"white"},Kr={...qe,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},Vr={...qe,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function $r(){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 Gr({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 Ra({isOpen:e,onClose:t,onInsert:o,maxWidth:r=800,maxHeight:n=600,accept:i="image/*",className:a,style:c}){let[d,s]=useState(null),[x,m]=useState(false),[p,g]=useState(0),[b,v]=useState(0),[u,f]=useState(""),[l,h]=useState(true),[C,P]=useState(1),[H,R]=useState(null),D=useRef(null),T=useRef(null);useEffect(()=>{e&&(s(null),m(false),g(0),v(0),f(""),h(true),P(1),R(null));},[e]);let y=useCallback(E=>{if(!E.type.startsWith("image/")){R("Please select a valid image file");return}if(E.size>10*1024*1024){R("Image file is too large (max 10MB)");return}R(null);let z=new FileReader;z.onload=$t=>{let it=$t.target?.result,ae=new Image;ae.onload=()=>{let se=ae.width,le=ae.height;if(se>r||le>n){let Gt=r/se,jt=n/le,at=Math.min(Gt,jt);se=Math.round(se*at),le=Math.round(le*at);}g(se),v(le),P(ae.width/ae.height),s({src:it,width:se,height:le,fileName:E.name,mimeType:E.type});},ae.src=it;},z.onerror=()=>{R("Failed to read image file");},z.readAsDataURL(E);},[r,n]),j=useCallback(E=>{let z=E.target.files?.[0];z&&y(z);},[y]),I=useCallback(()=>{D.current?.click();},[]),M=useCallback(E=>{E.preventDefault(),m(true);},[]),Ee=useCallback(E=>{E.preventDefault(),m(false);},[]),zt=useCallback(E=>{E.preventDefault(),m(false);let z=E.dataTransfer.files?.[0];z&&y(z);},[y]),Wt=useCallback(E=>{let z=parseInt(E.target.value,10)||0;g(z),l&&C&&v(Math.round(z/C));},[l,C]),Ht=useCallback(E=>{let z=parseInt(E.target.value,10)||0;v(z),l&&C&&g(Math.round(z*C));},[l,C]),He=useCallback(()=>{d&&o({...d,width:p,height:b,alt:u||void 0});},[d,p,b,u,o]),Ut=useCallback(E=>{E.key==="Escape"?t():E.key==="Enter"&&d&&!E.shiftKey&&(E.preventDefault(),He());},[t,d,He]),Yt=useCallback(E=>{E.target===E.currentTarget&&t();},[t]),Kt=useCallback(()=>{s(null),g(0),v(0),f(""),R(null),D.current&&(D.current.value="");},[]);if(!e)return null;let nt=d!==null&&p>0&&b>0,Vt=()=>d?Mr:x?Dr:Qe;return jsx("div",{className:`docx-insert-image-dialog-overlay ${a||""}`,style:{...Tr,...c},onClick:Yt,onKeyDown:Ut,role:"dialog","aria-modal":"true","aria-labelledby":"insert-image-dialog-title",children:jsxs("div",{ref:T,className:"docx-insert-image-dialog",style:Er,tabIndex:-1,children:[jsxs("div",{className:"docx-insert-image-dialog-header",style:Ir,children:[jsx("h2",{id:"insert-image-dialog-title",style:Rr,children:"Insert Image"}),jsx("button",{type:"button",className:"docx-insert-image-dialog-close",style:Pr,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-image-dialog-body",style:Lr,children:[jsx("input",{ref:D,type:"file",accept:i,onChange:j,style:{display:"none"}}),jsx("div",{className:"docx-insert-image-dropzone",style:Vt(),onClick:I,onDragOver:M,onDragLeave:Ee,onDrop:zt,role:"button",tabIndex:0,"aria-label":"Click or drag to upload image",children:d?jsx("div",{style:Ar,children:jsx("img",{src:d.src,alt:u||"Preview",style:Or})}):jsxs(Fragment,{children:[jsx("div",{style:_r,children:jsx($r,{})}),jsx("div",{style:Nr,children:"Click to select or drag and drop an image"}),jsx("div",{style:Br,children:"PNG, JPG, GIF up to 10MB"})]})}),d?.fileName&&jsxs("div",{style:Hr,children:[d.fileName,jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),Kt();},style:{marginLeft:"8px",background:"none",border:"none",color:"var(--doc-primary)",cursor:"pointer",fontSize:"12px"},children:"Change"})]}),H&&jsx("div",{style:{color:"var(--doc-error)",fontSize:"14px",marginBottom:"16px",textAlign:"center"},children:H}),d&&jsxs(Fragment,{children:[jsxs("div",{style:Rt,children:[jsx("label",{style:Pt,children:"Dimensions"}),jsxs("div",{style:zr,children:[jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"Width:"}),jsx("input",{type:"number",value:p,onChange:Wt,min:1,max:r,style:Lt}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"px"}),jsx("button",{type:"button",onClick:()=>h(!l),style:l?Wr:Mt,title:l?"Aspect ratio locked":"Aspect ratio unlocked",children:jsx(Gr,{locked:l})}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"Height:"}),jsx("input",{type:"number",value:b,onChange:Ht,min:1,max:n,style:Lt}),jsx("span",{style:{fontSize:"14px",color:"var(--doc-text-muted)"},children:"px"})]})]}),jsxs("div",{style:Rt,children:[jsx("label",{htmlFor:"insert-image-alt",style:Pt,children:"Alt Text (optional)"}),jsx("input",{id:"insert-image-alt",type:"text",value:u,onChange:E=>f(E.target.value),placeholder:"Describe the image for accessibility",style:Fr})]})]})]}),jsxs("div",{className:"docx-insert-image-dialog-footer",style:Ur,children:[jsx("button",{type:"button",className:"docx-insert-image-dialog-cancel",style:Kr,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-image-dialog-insert",style:nt?Yr:Vr,onClick:He,disabled:!nt,children:"Insert Image"})]})]})})}function Pa(){let[e,t]=useState(false),o=useCallback(()=>t(true),[]),r=useCallback(()=>t(false),[]),n=useCallback(()=>t(i=>!i),[]);return {isOpen:e,open:o,close:r,toggle:n}}function La(e){return e.type.startsWith("image/")}function Da(){return [".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]}function Ma(){return "image/png,image/jpeg,image/gif,image/webp,image/bmp,image/svg+xml"}function Aa(e,t,o,r){if(e<=o&&t<=r)return {width:e,height:t};let n=o/e,i=r/t,a=Math.min(n,i);return {width:Math.round(e*a),height:Math.round(t*a)}}function Oa(e){let t=e.split(","),o=t[0].match(/:(.*?);/)?.[1]||"image/png",r=atob(t[1]),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new Blob([n],{type:o})}function _a(e){return new Promise((t,o)=>{let r=new Image;r.onload=()=>t({width:r.width,height:r.height}),r.onerror=()=>o(new Error("Failed to load image")),r.src=e;})}function Na(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Jr={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},Qr={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"},qr={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},en={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},tn={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},on={padding:"20px",flex:1,overflow:"auto"},rn={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",marginBottom:"16px",boxSizing:"border-box"},nn={display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"16px"},At={padding:"6px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",backgroundColor:"white",cursor:"pointer",fontSize:"12px",transition:"all 0.15s"},an={...At,backgroundColor:"var(--doc-primary)",borderColor:"var(--doc-primary)",color:"white"},sn={display:"grid",gridTemplateColumns:"repeat(10, 1fr)",gap:"4px",maxHeight:"250px",overflow:"auto"},ln={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"},dn={marginTop:"16px",padding:"12px",backgroundColor:"var(--doc-bg-subtle)",borderRadius:"4px",display:"flex",alignItems:"center",gap:"16px"},cn={fontSize:"36px",width:"60px",height:"60px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"white",borderRadius:"4px",border:"1px solid var(--doc-border)"},pn={flex:1},un={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},et={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},gn={...et,backgroundColor:"var(--doc-primary)",color:"white"},mn={...et,backgroundColor:"var(--doc-bg-subtle)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},xn={...et,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"},Se=[{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 Ot(){return Se.flatMap(e=>e.symbols)}function Ha({isOpen:e,onClose:t,onInsert:o,recentSymbols:r=[],className:n,style:i}){let[a,c]=useState("common"),[d,s]=useState(null),[x,m]=useState(""),[p,g]=useState(null),b=useRef(null);useEffect(()=>{e&&(s(null),m(""),g(null),setTimeout(()=>b.current?.focus(),100));},[e]);let v=useMemo(()=>{if(!x.trim())return a==="recent"?r:Se.find(M=>M.name===a)?.symbols||[];let y=x.toLowerCase();return Ot().filter(I=>{let M=I.codePointAt(0)?.toString(16).toUpperCase()||"";return I.includes(y)||M.includes(y.toUpperCase())||`U+${M}`.toLowerCase().includes(y)})},[x,a,r]),u=useCallback(y=>{s(y);},[]),f=useCallback(y=>{o(y);},[o]),l=useCallback(()=>{d&&o(d);},[d,o]),h=useCallback(y=>{y.key==="Escape"?t():y.key==="Enter"&&d&&(y.preventDefault(),l());},[t,d,l]),C=useCallback(y=>{y.target===y.currentTarget&&t();},[t]),P=y=>{if(!y)return null;let j=y.codePointAt(0);return {character:y,codePoint:j?`U+${j.toString(16).toUpperCase().padStart(4,"0")}`:"",decimal:j||0}};if(!e)return null;let R=P(p||d),D=d!==null,T=[...r.length>0?[{name:"recent",label:"Recent"}]:[],...Se.map(y=>({name:y.name,label:y.label}))];return jsx("div",{className:`docx-insert-symbol-dialog-overlay ${n||""}`,style:{...Jr,...i},onClick:C,onKeyDown:h,role:"dialog","aria-modal":"true","aria-labelledby":"insert-symbol-dialog-title",children:jsxs("div",{className:"docx-insert-symbol-dialog",style:Qr,children:[jsxs("div",{className:"docx-insert-symbol-dialog-header",style:qr,children:[jsx("h2",{id:"insert-symbol-dialog-title",style:en,children:"Insert Symbol"}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-close",style:tn,onClick:t,"aria-label":"Close dialog",children:"\xD7"})]}),jsxs("div",{className:"docx-insert-symbol-dialog-body",style:on,children:[jsx("input",{ref:b,type:"text",placeholder:"Search symbols (character or Unicode)...",value:x,onChange:y=>m(y.target.value),style:rn}),!x&&jsx("div",{className:"docx-insert-symbol-categories",style:nn,children:T.map(y=>jsx("button",{type:"button",onClick:()=>c(y.name),style:a===y.name?an:At,children:y.label},y.name))}),jsx("div",{className:"docx-insert-symbol-grid",style:sn,children:v.map((y,j)=>jsx("button",{type:"button",onClick:()=>u(y),onDoubleClick:()=>f(y),onMouseEnter:()=>g(y),onMouseLeave:()=>g(null),style:{...ln,...d===y?{backgroundColor:"var(--doc-primary-light)",borderColor:"var(--doc-primary)"}:{}},title:`${y} - U+${y.codePointAt(0)?.toString(16).toUpperCase()}`,children:y},`${y}-${j}`))}),v.length===0&&jsxs("div",{style:{textAlign:"center",padding:"20px",color:"var(--doc-text-muted)"},children:['No symbols found for "',x,'"']}),R&&jsxs("div",{className:"docx-insert-symbol-preview",style:dn,children:[jsx("div",{style:cn,children:R.character}),jsxs("div",{style:pn,children:[jsx("div",{style:{fontSize:"14px",fontWeight:500,marginBottom:"4px"},children:R.codePoint}),jsxs("div",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:["Decimal: ",R.decimal]})]})]})]}),jsxs("div",{className:"docx-insert-symbol-dialog-footer",style:un,children:[jsx("button",{type:"button",className:"docx-insert-symbol-dialog-cancel",style:mn,onClick:t,children:"Cancel"}),jsx("button",{type:"button",className:"docx-insert-symbol-dialog-insert",style:D?gn:xn,onClick:l,disabled:!D,children:"Insert"})]})]})})}function Ua(e=20){let[t,o]=useState(false),[r,n]=useState([]),i=useCallback(()=>o(true),[]),a=useCallback(()=>o(false),[]),c=useCallback(()=>o(s=>!s),[]),d=useCallback(s=>{n(x=>{let m=x.filter(p=>p!==s);return [s,...m].slice(0,e)});},[e]);return {isOpen:t,recentSymbols:r,open:i,close:a,toggle:c,addRecent:d}}function Ya(){return Se}function Ka(e){return Se.find(o=>o.name===e)?.symbols||[]}function Va(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 $a(e){if(!e.trim())return [];let t=e.toLowerCase();return Ot().filter(o=>{let r=o.codePointAt(0)?.toString(16).toUpperCase()||"";return o.includes(e)||r.includes(t.toUpperCase())||`U+${r}`.toLowerCase().includes(t)})}function Ga(e){let t=e.replace(/^U\+/i,"").replace(/^0x/i,""),o=parseInt(t,16);return isNaN(o)||o<0||o>1114111?null:String.fromCodePoint(o)}ra$1();var ne=[{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"}],bn=()=>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"})]}),hn=()=>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 vn(e){switch(e){case "formatted":return jsx(bn,{});case "plainText":return jsx(hn,{});default:return null}}var yn=({option:e,isSelected:t,onClick:o,onMouseEnter:r})=>jsxs("button",{type:"button",className:`docx-paste-special-option ${t?"docx-paste-special-option-selected":""}`,onClick:o,onMouseEnter:r,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:vn(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})]}),qa=({isOpen:e,onClose:t,onPaste:o,position:r,className:n=""})=>{let i=useRef(null),[a,c]=useState(0),[d,s]=useState(null),[x,m]=useState(false),[p,g]=useState(null);useEffect(()=>{if(!e){s(null),g(null),c(0);return}(async()=>{m(true),g(null);try{let f=await ia({cleanWordFormatting:!0});s(f),f||g("No content available to paste");}catch{g("Unable to read clipboard. Please use Ctrl+V to paste.");}finally{m(false);}})();},[e]),useEffect(()=>{if(!e)return;let u=f=>{i.current&&!i.current.contains(f.target)&&t();};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,t]),useEffect(()=>{if(!e)return;let u=f=>{switch(f.key){case "Escape":f.preventDefault(),t();break;case "ArrowDown":f.preventDefault(),c(l=>(l+1)%ne.length);break;case "ArrowUp":f.preventDefault(),c(l=>(l-1+ne.length)%ne.length);break;case "Enter":f.preventDefault(),b(ne[a].id);break}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,a,t]);let b=useCallback(u=>{if(!d){g("No content available to paste");return}o(d,u==="plainText"),t();},[d,o,t]),v=useCallback(()=>{let l=r?.x??(typeof window<"u"?window.innerWidth/2-160:100),h=r?.y??(typeof window<"u"?window.innerHeight/2-200/2:100);return typeof window<"u"&&(l+320>window.innerWidth&&(l=window.innerWidth-320-10),h+200>window.innerHeight&&(h=window.innerHeight-200-10),l<10&&(l=10),h<10&&(h=10)),{position:"fixed",top:h,left:l,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"}},[r]);return e?jsxs("div",{ref:i,className:`docx-paste-special-dialog ${n}`,style:v(),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:x?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:ne.map((u,f)=>jsx(yn,{option:u,isSelected:f===a,onClick:()=>b(u.id),onMouseEnter:()=>c(f)},u.id))})}),d&&!x&&!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:['"',d.plainText.slice(0,50),d.plainText.length>50?"...":"",'"']})]})]}):null};function es(e={}){let{onPaste:t,enabled:o=true}=e,[r,n]=useState(false),i=useCallback(()=>{o&&n(true);},[o]),a=useCallback(()=>{n(false);},[]),c=useCallback(async()=>{if(!(!o||!t))try{let s=await ia({cleanWordFormatting:!0});s&&t(s,!0);}catch(s){console.error("Failed to paste as plain text:",s);}},[o,t]),d=useCallback(s=>o&&(s.ctrlKey||s.metaKey)&&s.shiftKey&&s.key.toLowerCase()==="v"?(s.preventDefault(),i(),true):false,[o,i]);return {isOpen:r,openDialog:i,closeDialog:a,handleKeyDown:d,pasteAsPlainText:c}}function ts(e){return ne.find(t=>t.id===e)}function os(){return [...ne]}function rs(){return "formatted"}function ns(e){return (e.ctrlKey||e.metaKey)&&e.shiftKey&&e.key.toLowerCase()==="v"}var Bt={editing:"Editing",formatting:"Formatting",navigation:"Navigation",clipboard:"Clipboard",selection:"Selection",view:"View",file:"File",other:"Other"},Ft=["file","editing","clipboard","formatting","selection","navigation","view","other"],We=[{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 Cn(){return typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform)}function rt(e){return Cn()?e.replace(/Ctrl\+/g,"\u2318").replace(/Alt\+/g,"\u2325").replace(/Shift\+/g,"\u21E7"):e}var wn=({shortcut:e})=>{let t=rt(e.keys),o=e.altKeys?rt(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}),o&&jsxs(Fragment,{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:o})]})]})]})},ds=({isOpen:e,onClose:t,customShortcuts:o=[],showSearch:r=true,className:n=""})=>{let i=useRef(null),a=useRef(null),[c,d]=useState(""),s=useMemo(()=>{let p=[...We];for(let g of o){let b=p.findIndex(v=>v.id===g.id);b>=0?p[b]=g:p.push(g);}return p},[o]),x=useMemo(()=>{if(!c.trim())return s;let p=c.toLowerCase();return s.filter(g=>g.name.toLowerCase().includes(p)||g.description.toLowerCase().includes(p)||g.keys.toLowerCase().includes(p)||g.altKeys&&g.altKeys.toLowerCase().includes(p))},[s,c]),m=useMemo(()=>{let p=new Map;for(let b of x){let v=p.get(b.category)||[];v.push(b),p.set(b.category,v);}let g=[];for(let b of Ft){let v=p.get(b);v&&v.length>0&&g.push({category:b,shortcuts:v});}return g},[x]);return useEffect(()=>{e&&r&&a.current&&setTimeout(()=>a.current?.focus(),0);},[e,r]),useEffect(()=>{e||d("");},[e]),useEffect(()=>{if(!e)return;let p=g=>{i.current&&!i.current.contains(g.target)&&t();};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,t]),useEffect(()=>{if(!e)return;let p=g=>{g.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 ${n}`,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"})})})]}),r&&jsx("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--doc-border)"},children:jsx("input",{ref:a,type:"text",value:c,onChange:p=>d(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:m.length===0?jsxs("div",{style:{textAlign:"center",padding:"32px",color:"var(--doc-text-muted)"},children:['No shortcuts found matching "',c,'"']}):m.map(({category:p,shortcuts:g})=>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:Bt[p]}),jsx("div",{children:g.map(b=>jsx(wn,{shortcut:b},b.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 cs(e={}){let{enabled:t=true,openShortcut:o="Ctrl+/"}=e,[r,n]=useState(false),i=useCallback(()=>{t&&n(true);},[t]),a=useCallback(()=>{n(false);},[]),c=useCallback(()=>{n(s=>!s);},[]),d=useCallback(s=>{if(!t)return;if((s.ctrlKey||s.metaKey)&&(s.key==="/"||s.key==="?")){s.preventDefault(),c();return}if(s.key==="F1"){s.preventDefault(),i();return}},[t,c,i]);return useEffect(()=>{if(t)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,d]),{isOpen:r,open:i,close:a,toggle:c,handleKeyDown:d}}function ps(){return [...We]}function us(e){return We.filter(t=>t.category===e)}function gs(){return We.filter(e=>e.common)}function ms(e){return Bt[e]}function xs(){return [...Ft]}function fs(e){return rt(e)}
111
+ export{ua as $,Ae as A,ts as Aa,Li as B,os as Ba,Di as C,rs as Ca,Mi as D,ns as Da,Ai as E,ds as Ea,Oi as F,cs as Fa,_i as G,ps as Ga,Ni as H,us as Ha,Bi as I,gs as Ia,Ui as J,ms as Ja,Yi as K,xs as Ka,Ki as L,fs as La,Vi as M,$i as N,Gi as O,Qi as P,qi as Q,ea as R,ta as S,oa as T,ra as U,na as V,nr as W,la as X,da as Y,ca as Z,pa as _,In as a,ba as aa,Rn as b,ha as ba,Pn as c,va as ca,Ln as d,ya as da,Dn as e,Ca as ea,Mn as f,wa as fa,Fn as g,Sa as ga,zn as h,Ra as ha,Wn as i,Pa as ia,Hn as j,La as ja,$n as k,Da as ka,Gn as l,Ma as la,jn as m,Aa as ma,Zn as n,Oa as na,Xn as o,_a as oa,Jn as p,Na as pa,ei as q,Se as qa,ti as r,Ha as ra,oi as s,Ua as sa,ri as t,Ya as ta,ni as u,Ka as ua,ii as v,Va as va,ai as w,$a as wa,si as x,Ga as xa,fi as y,qa as ya,Ti as z,es as za};
@@ -0,0 +1,10 @@
1
+ 'use strict';var chunkITWEFKGQ_cjs=require('./chunk-ITWEFKGQ.cjs'),chunkNT2REEAA_cjs=require('./chunk-NT2REEAA.cjs'),chunkEPCZ24TY_cjs=require('./chunk-EPCZ24TY.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs');function I(o){return typeof o=="object"&&o!==null&&("_def"in o||"parse"in o||"safeParse"in o)}function w(o,i){let s=i,{position:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.paragraphIndex} out of bounds`);let l=a[n.paragraphIndex],p=`{{${t}}}`;return P(l,n.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function C(o,i){let s=i,{range:n,variableName:t}=s,e=JSON.parse(JSON.stringify(o)),a=e.package.document.content.filter(m=>m.type==="paragraph");if(n.start.paragraphIndex!==n.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(n.start.paragraphIndex>=a.length)throw new Error(`Paragraph index ${n.start.paragraphIndex} out of bounds`);let l=a[n.start.paragraphIndex];D(l,n.start.offset,n.end.offset);let p=`{{${t}}}`;return P(l,n.start.offset,p),e.templateVariables||(e.templateVariables=[]),e.templateVariables.includes(t)||e.templateVariables.push(t),e}function P(o,i,s){let n=0,t=false;for(let e=0;e<o.content.length;e++){let r=o.content[e];if(r.type==="run"){let a=g(r),l=n,p=n+a.length;if(!t&&i>=l&&i<=p){let m=i-l,f=a.slice(0,m),x=a.slice(m),d=[];for(let c=0;c<e;c++)d.push(o.content[c]);f&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:f}]}),d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:s}]}),x&&d.push({type:"run",formatting:r.formatting,content:[{type:"text",text:x}]});for(let c=e+1;c<o.content.length;c++)d.push(o.content[c]);o.content=d,t=true;break}n=p;}else if(r.type==="hyperlink")for(let a of r.children)a.type==="run"&&(n+=g(a).length);}t||o.content.push({type:"run",content:[{type:"text",text:s}]});}function D(o,i,s){let n=[],t=0;for(let e of o.content)if(e.type==="run"){let r=g(e),a=t,l=t+r.length;if(l<=i||a>=s)n.push(e);else {let p="";a<i&&(p+=r.slice(0,i-a)),l>s&&(p+=r.slice(s-a)),p.length>0&&n.push({type:"run",formatting:e.formatting,content:[{type:"text",text:p}]});}t=l;}else n.push(e);o.content=n;}function g(o){return o.content.filter(i=>i.type==="text").map(i=>i.text).join("")}var u={type:"string",description:"Document ID from a previous docx_load call"},V={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},R={name:"docx_get_variables",description:`List all template variables ({{name}} format) found in the document.
2
+ Returns variable names without braces, along with their locations (body, headers, footers, etc.).
3
+ Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};try{let t=chunkNT2REEAA_cjs.b(n.document);return {content:[{type:"text",text:JSON.stringify({variables:t.variables,count:t.variables.length,totalOccurrences:t.totalOccurrences,byLocation:t.byLocation},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},S={name:"docx_insert_variable",description:`Insert a template variable placeholder ({{name}}) at a specific position in the document.
4
+ The variable can later be substituted with actual values using docx_apply_template.
5
+ Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:u,position:V,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {{customer_name}}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(o,i)=>{let{documentId:s,position:n,variableName:t}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(t))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${t}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:r}=await import('./executor-U3BZPPGN.cjs'),a=r(e.document,{type:"insertText",position:n,text:`{{${t}}}`});return e.document=a,e.lastModified=Date.now(),a.templateVariables||(a.templateVariables=[]),a.templateVariables.includes(t)||a.templateVariables.push(t),{content:[{type:"text",text:JSON.stringify({success:!0,variable:t,insertedAs:`{{${t}}}`,position:n})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},k={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
6
+ Replaces all {variable} placeholders with the corresponding values provided.
7
+ Preserves all formatting (fonts, styles, colors, tables).
8
+ Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:u,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(o,i)=>{let{documentId:s,variables:n,keepUnmatchedVariables:t=true}=o,e=i.session.documents.get(s);if(!e)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!e.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let r=chunkITWEFKGQ_cjs.b(e.buffer,n,{nullGetter:t?"keep":"empty"}),a=await chunkEPCZ24TY_cjs.p(r.buffer);return e.document=a,e.buffer=r.buffer,e.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:r.replacedVariables,unreplacedVariables:r.unreplacedVariables,warnings:r.warnings})}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${r.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},E={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
9
+ Checks for syntax errors like unclosed braces, invalid tag names, etc.
10
+ Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:u},required:["documentId"]},handler:async(o,i)=>{let{documentId:s}=o,n=i.session.documents.get(s);if(!n)return {isError:true,content:[{type:"text",text:`Document not found: ${s}`}]};if(!n.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let t=chunkITWEFKGQ_cjs.f(n.buffer);return {content:[{type:"text",text:JSON.stringify({valid:t.valid,tags:t.tags,errors:t.errors.map(e=>({message:e.message,variable:e.variable,type:e.type}))},null,2)}]}}catch(t){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${t.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},M=[R,S,k,E];var _={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:w,replaceWithTemplateVariable:C},mcpTools:M,initialize:()=>{try{chunkRTESADL3_cjs.a("docxtemplater"),chunkRTESADL3_cjs.a("pizzip");}catch{console.warn("[docxtemplater-plugin] Warning: docxtemplater or pizzip not installed. Template features may not work. Install with: npm install docxtemplater pizzip");}}};exports.a=I;exports.b=_;