@dotit/editor 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +19 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28,5 +28,5 @@ ${zt(t)}
|
|
|
28
28
|
.docs-page .tiptap{padding:0;}
|
|
29
29
|
[data-it-spacer]{display:none!important;}
|
|
30
30
|
${e==="minimal-ink"?ce:""}
|
|
31
|
-
`;return`<!doctype html><html><head><meta charset="utf-8">${c}<style>${m}${d}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${o}</div></div></body></html>`}function le(t,e,s){const n=new Blob([t],{type:s}),o=URL.createObjectURL(n),c=document.createElement("a");c.href=o,c.download=e,c.click(),URL.revokeObjectURL(o)}function de(t,e,s){let n=Pn(t,s);if(!n){const o=z.parseIntentText(t);n=z.renderPrint(o,{theme:e}),s==="minimal-ink"&&(n=Hn(n,ce))}return n}function Bt(t,e,s="normal"){try{ae(de(t,e,s))}catch{}}function ue(t,e){try{let s=e;if(!s)try{const n=z.parseIntentText(t),c=n.blocks.find(a=>a.type==="meta")?.properties?.id,i=n.blocks.find(a=>a.type==="title")?.content||"";s=`${String(c||i||"document").trim().replace(/[^\w\-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"document"}.it`}catch{s="document.it"}le(t,s,"text/plain;charset=utf-8")}catch{}}function Dn(t,e,s="normal"){try{le(de(t,e,s),"document.html","text/html")}catch{}}function pe(){return z.listBuiltinThemes()}function Qt(t){try{const e=Pt(vt(t));return e.trim()?e:t}catch{return t}}const Xt="dotit.editor.lastSigner",Zt="dotit.editor.lastRole";function In({content:t,onChange:e,trust:s,intact:n}){const[o,c]=u.useState(!1),[i,p]=u.useState(!1),[a,m]=u.useState(!1),[d,h]=u.useState(()=>localStorage.getItem(Xt)||""),[g,y]=u.useState(()=>localStorage.getItem(Zt)||""),[S,j]=u.useState(!1),b=u.useRef(null),k=u.useRef(0),H=u.useCallback(v=>{const I=Date.now();I-k.current<400||(k.current=I,v())},[]);u.useEffect(()=>{if(!o)return;const v=I=>{b.current&&!b.current.contains(I.target)&&(c(!1),m(!1))};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);const E=s.isSealed||z.isSealed(t),D=u.useCallback(()=>{const v=d.trim();if(v){j(!0);try{const I=Qt(t),R=z.signDocument(I,{signer:v,role:g.trim()||void 0});R.source&&R.source!==t&&e(R.source),localStorage.setItem(Xt,v),g.trim()&&localStorage.setItem(Zt,g.trim())}finally{j(!1),m(!1),c(!1)}}},[t,e,d,g]),F=u.useCallback(()=>{const v=d.trim()||s.signatures[0]?.by||"Document owner";j(!0);try{const I=z.sealDocument(Qt(t),{signer:v,role:g.trim()||s.signatures[0]?.role||void 0,skipSign:!0});I.source&&I.source!==t&&!I.error&&e(I.source)}finally{j(!1),c(!1)}},[t,e,d,g,s.signatures]),O=u.useCallback(()=>{j(!0);try{const v=z.unsealDocument(t);typeof v=="string"&&v!==t&&e(v)}finally{j(!1),c(!1)}},[t,e]),[W,_]=u.useState(null),P=u.useCallback(()=>{try{_(z.verifyDocument(t))}catch{_(null)}},[t]);let V=r.jsx(N.PenTool,{size:15}),J="Draft",q="trust-face--draft";return E?(V=r.jsx(N.FileLock2,{size:15}),J=n===!1?"Sealed · changed!":"Sealed",q=n===!1?"trust-face--broken":"trust-face--sealed"):s.signatures.length>0&&(V=r.jsx(N.ShieldCheck,{size:15}),J=`Signed · ${s.signatures.length}`,q="trust-face--signed"),r.jsxs("div",{className:"trust-control",ref:b,children:[r.jsxs("button",{className:`docs-tb-btn trust-face ${q}`,onClick:()=>{c(v=>!v),m(!1),E&&P()},title:"Document trust — sign, seal, verify",children:[r.jsx("span",{className:"trust-face__icon",children:V}),r.jsx("span",{className:"ribbon-btn-text",children:J}),E&&n===!0&&r.jsx("span",{className:"trust-face__ok",title:"Hash verified",children:"✓"}),r.jsx(N.ChevronDown,{size:12})]}),o&&r.jsxs("div",{className:"trust-popover",children:[r.jsx("div",{className:"trust-popover__state",children:E?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"🔒 Sealed — read-only"}),r.jsxs("div",{className:"trust-popover__meta",children:[s.sealedBy&&r.jsxs(r.Fragment,{children:["by ",s.sealedBy]}),s.sealedAt&&r.jsxs(r.Fragment,{children:[" on ",s.sealedAt]})]})]}):s.signatures.length>0?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:["Signed · ",s.signatures.length]}),r.jsx("div",{className:"trust-popover__meta",children:s.signatures.map(v=>v.role?`${v.by} (${v.role})`:v.by).join(" · ")}),r.jsxs("div",{className:"trust-popover__warn",children:["⚠ Still editable — editing will break"," ",s.signatures.length," signature",s.signatures.length===1?"":"s",". Seal to lock it."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"Draft"}),r.jsx("div",{className:"trust-popover__meta",children:"Not signed or sealed yet."})]})}),r.jsx("button",{className:"trust-popover__help-toggle",onClick:()=>p(v=>!v),children:"(?) what does this mean"}),i&&r.jsxs("div",{className:"trust-popover__help",children:[r.jsxs("p",{children:[r.jsx("b",{children:"Sign"})," adds your name to the document. It stays editable — but changing it afterwards invalidates the signatures."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Seal"})," freezes the document with a tamper-evident hash and makes it ",r.jsx("b",{children:"read-only"}),". ",r.jsx("b",{children:"Unseal"})," makes it editable again."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Verify"})," recomputes the hash and confirms the content still matches the seal."]})]}),r.jsx("div",{className:"trust-popover__divider"}),E?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"trust-popover__verify",children:[W?W.intact?r.jsx("span",{className:"trust-verify--ok",children:"✓ Verified — content matches the seal"}):r.jsx("span",{className:"trust-verify--bad",children:"⚠ Hash mismatch — content changed after sealing"}):null,W?.hash&&r.jsxs("details",{className:"trust-popover__hash",children:[r.jsx("summary",{children:"Show hash"}),r.jsx("code",{children:W.hash})]})]}),r.jsxs("button",{className:"trust-popover__action",onClick:()=>H(P),disabled:S,children:[r.jsx(N.ShieldCheck,{size:14})," Re-verify"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--warn",onClick:()=>H(O),disabled:S,title:"Remove the freeze lock (keeps signatures) and make the document editable again",children:[r.jsx(N.LockOpen,{size:14})," Unseal (make editable)"]})]}):a?r.jsxs("div",{className:"trust-sign-form",children:[r.jsx("input",{className:"trust-sign-input",placeholder:"Your name",value:d,autoFocus:!0,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&D(),v.key==="Escape"&&m(!1)}}),r.jsx("input",{className:"trust-sign-input",placeholder:"Role (optional, e.g. CEO)",value:g,onChange:v=>y(v.target.value),onKeyDown:v=>{v.key==="Enter"&&D(),v.key==="Escape"&&m(!1)}}),r.jsxs("div",{className:"trust-sign-actions",children:[r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:D,disabled:S||!d.trim(),children:[r.jsx(N.PenTool,{size:14})," Add signature"]}),r.jsx("button",{className:"trust-popover__action",onClick:()=>m(!1),children:"Cancel"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"trust-popover__action",onClick:()=>m(!0),disabled:S,title:"Add a signature line (does not freeze the document)",children:[r.jsx(N.PenTool,{size:14})," Sign"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:()=>H(F),disabled:S,title:"Freeze the document with a tamper-evident hash. It becomes read-only until unsealed.",children:[r.jsx(N.FileLock2,{size:14})," Seal (freeze)"]})]})]})]})}const At=[{label:"Normal text",node:"paragraph"},{label:"Title",node:"itTitle"},{label:"Section",node:"itSection"},{label:"Subsection",node:"itSub"},{label:"Summary",node:"itSummary"},{label:"Quote",node:"itQuote"}],Bn=new Set(["history","revision","track","freeze"]),On=new Set(["agent","model","meta","context","history"]),Fn=["identity","structure","content","data","trust","layout"],te=[{label:"Default",value:""},{label:"Inter",value:"Inter"},{label:"Arial",value:"Arial"},{label:"Times New Roman",value:"Times New Roman"},{label:"Georgia",value:"Georgia"},{label:"Courier New",value:"Courier New"},{label:"Verdana",value:"Verdana"},{label:"Trebuchet MS",value:"Trebuchet MS"}],qn=["1","1.15","1.5","2","2.5","3"],Un="12px",Gn=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],Wn=["#ffffff","#cfe2f3","#d9ead3","#fff2cc","#fce5cd","#f4cccc","#d9d2e9","#ead1dc","#d0e0e3","#e6b8af"];function M({onClick:t,active:e,disabled:s,title:n,children:o}){return r.jsx("button",{className:`docs-tb-btn${e?" active":""}`,onClick:t,disabled:s,title:n,children:o})}function X({label:t,children:e,className:s=""}){return r.jsx("div",{className:`ribbon-group ${s}`.trim(),role:"group","aria-label":t,children:e})}function ot(){return r.jsx("div",{className:"ribbon-sep"})}function Kn({editor:t,isRtl:e=!1,onToggleRtl:s,content:n,onChange:o,theme:c,onThemeChange:i,onTrustAction:p,trust:a,sealIntact:m=null,locked:d=!1}){const[h,g]=u.useState(!1),[y,S]=u.useState(!1),[j,b]=u.useState(!1),[k,H]=u.useState(!1),[E,D]=u.useState(!1),[F,O]=u.useState(!1),[W,_]=u.useState(!1),P=u.useRef(null),V=u.useRef(null),J=u.useRef(null),q=u.useRef(null),v=u.useRef(null),I=u.useRef(null);u.useEffect(()=>{const f=L=>{const C=L.target;P.current&&!P.current.contains(C)&&g(!1),V.current&&!V.current.contains(C)&&S(!1),J.current&&!J.current.contains(C)&&b(!1),q.current&&!q.current.contains(C)&&H(!1),v.current&&!v.current.contains(C)&&D(!1),I.current&&!I.current.contains(C)&&O(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const R=()=>{g(!1),S(!1),b(!1),H(!1),D(!1),O(!1)},ct=u.useCallback(()=>{if(!t)return"Normal text";for(const f of At)if(f.node==="paragraph"&&t.isActive("paragraph")){if(!At.some(C=>C.node!=="paragraph"&&t.isActive(C.node)))return f.label}else if(t.isActive(f.node))return f.label;return"Normal text"},[t]),ht=u.useCallback(()=>{if(!t)return"Default";const f=t.getAttributes("textStyle")?.fontFamily;if(!f)return"Default";const L=te.find(C=>C.value===f);return L?L.label:"Default"},[t]),[nt,x]=u.useState(11),[,w]=u.useState(0),A=u.useMemo(()=>{const f=new Map;for(const C of z.LANGUAGE_REGISTRY){if(C.status!=="stable"||On.has(C.canonical)||C.category==="agent")continue;const st=C.category,xt=f.get(st)||[];xt.push({label:C.canonical,keyword:C.canonical,category:st,description:C.description,isReadOnly:Bn.has(C.canonical)}),f.set(st,xt)}const L=[];for(const C of Fn){const st=f.get(C);!st||st.length===0||(st.sort((xt,Se)=>xt.keyword.localeCompare(Se.keyword)),L.push({category:Vt[C]?.label||C,items:st}))}return L},[]);u.useEffect(()=>{if(!t)return;const f=()=>{const L=t.getAttributes("textStyle");if(L?.fontSize){const C=parseInt(L.fontSize,10);isNaN(C)||x(C)}w(C=>C+1)};return t.on("selectionUpdate",f),t.on("transaction",f),()=>{t.off("selectionUpdate",f),t.off("transaction",f)}},[t]);const U=u.useCallback(f=>{t&&(f==="paragraph"?t.chain().focus().setParagraph().run():f==="itQuote"?t.chain().focus().setNode("itQuote").run():t.chain().focus().setNode(f).run(),R())},[t]),K=u.useCallback(f=>{if(!t)return;const L=t.chain().focus();f==="divider"?L.setNode("itDivider").run():f==="break"?L.setNode("itBreak").run():f==="code"?L.setNode("itCode",{lang:""}).run():["tip","info","warning","danger","success"].includes(f)?L.setNode("itCallout",{variant:f}).run():L.setNode("itGenericBlock",{keyword:f,properties:""}).run(),R()},[t]),G=u.useCallback(f=>{const L=Math.min(96,Math.max(8,nt+f));x(L),t?.chain().focus().setFontSize(`${L}pt`).run()},[t,nt]),Q=u.useCallback(f=>{t?.chain().focus().setBlockProp("leading",f).run(),R()},[t]),ut=u.useCallback(f=>{if(!t)return;const L=rt(t,f);t.chain().focus().setBlockProp(f,L?null:Un).run(),R()},[t]),mt=u.useCallback(()=>{if(!t)return;const f=window.prompt("Space before block (e.g. 12px, 1em — empty for none):",rt(t,"space-before")||"");if(f===null)return;const L=window.prompt("Space after block (e.g. 12px, 1em — empty for none):",rt(t,"space-after")||"");L!==null&&(t.chain().focus().setBlockProp("space-before",f.trim()||null).setBlockProp("space-after",L.trim()||null).run(),R())},[t]),ge=u.useCallback(()=>{if(!t)return;const f=rt(t,"end"),L=window.prompt("Line-end text (shown at the end of the line — empty to remove):",f||"");L!==null&&t.chain().focus().setBlockProp("end",L.trim()||null).run()},[t]),he=u.useCallback(()=>{t&&(t.chain().focus().insertContent({type:"paragraph",attrs:{end:"End text"},content:[{type:"text",text:"Start text"}]}).run(),R())},[t]),me=u.useMemo(()=>pe(),[]),Ot=W?"minimal-ink":"normal",be=u.useCallback(()=>Bt(n,c,Ot),[n,c,Ot]),ye=u.useCallback(()=>ue(n),[n]);if(!t)return null;const jt=rt(t,"leading"),xe=!!rt(t,"end");return r.jsxs("div",{className:"docs-toolbar docs-ribbon",children:[r.jsxs(X,{label:"Edit",children:[r.jsx(M,{onClick:()=>t.chain().focus().undo().run(),disabled:d||!t.can().undo(),title:"Undo (⌘Z)",children:r.jsx(N.Undo2,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().redo().run(),disabled:d||!t.can().redo(),title:"Redo (⌘⇧Z)",children:r.jsx(N.Redo2,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"File",children:[r.jsxs(M,{onClick:ye,title:"Save / Download the .it file",children:[r.jsx(N.Download,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"Save"})]}),r.jsxs(M,{onClick:be,title:"Export PDF (⌘P) — WYSIWYG",children:[r.jsx(N.Printer,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"PDF"})]}),r.jsx(M,{onClick:()=>_(f=>!f),active:W,title:"Minimal ink mode (plain callouts when printing)",children:r.jsx(N.Droplets,{size:16})}),r.jsx("select",{className:"ribbon-theme-select",value:c,onChange:f=>i(f.target.value),title:"Document theme (used everywhere — canvas, print, export)",children:me.map(f=>r.jsx("option",{value:f,children:f.charAt(0).toUpperCase()+f.slice(1)},f))})]}),r.jsx(ot,{}),r.jsxs("div",{className:d?"ribbon-locked":"ribbon-editing",children:[r.jsx(X,{label:"Style",children:r.jsxs("div",{className:"docs-tb-dropdown",ref:P,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-paragraph-select",onClick:()=>{R(),g(!h)},children:[r.jsx("span",{className:"docs-tb-select-label",children:ct()}),r.jsx(N.ChevronDown,{size:14})]}),h&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-style-menu",children:At.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${ct()===f.label?" active":""}`,onClick:()=>U(f.node),children:r.jsx("span",{className:`docs-style-preview docs-style-${f.node}`,children:f.label})},f.node))})]})}),r.jsx(ot,{}),r.jsxs(X,{label:"Font",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:J,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-font-select",onClick:()=>{R(),b(!j)},children:[r.jsx("span",{className:"docs-tb-select-label",children:ht()}),r.jsx(N.ChevronDown,{size:14})]}),j&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-font-menu",children:te.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${ht()===f.label?" active":""}`,style:{fontFamily:f.value||"inherit"},onClick:()=>{f.value?t.chain().focus().setFontFamily(f.value).run():t.chain().focus().unsetFontFamily().run(),R()},children:f.label},f.value||"default"))})]}),r.jsx(M,{onClick:()=>G(-1),title:"Decrease font size",children:r.jsx(N.Minus,{size:14})}),r.jsx("span",{className:"docs-tb-fontsize",children:nt}),r.jsx(M,{onClick:()=>G(1),title:"Increase font size",children:r.jsx(N.Plus,{size:14})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Text",children:[r.jsx(M,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (⌘B)",children:r.jsx(N.Bold,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (⌘I)",children:r.jsx(N.Italic,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (⌘U)",children:r.jsx(N.Underline,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough (⌘⇧X)",children:r.jsx(N.Strikethrough,{size:16})}),r.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:q,children:[r.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{R(),H(!k)},title:"Text color",children:[r.jsx(N.Palette,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("textStyle")?.color||"#000000"}})]}),k&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[r.jsx("div",{className:"docs-color-grid-label",children:"Text color"}),r.jsx("div",{className:"docs-color-grid",children:Gn.map(f=>r.jsx("button",{className:"docs-color-swatch",style:{background:f},title:f,onClick:()=>{t.chain().focus().setColor(f).run(),R()}},f))}),r.jsxs("button",{className:"docs-tb-dropdown-item",onClick:()=>{t.chain().focus().unsetColor().run(),R()},children:[r.jsx(N.RemoveFormatting,{size:14})," Reset"]})]})]}),r.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:v,children:[r.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{R(),D(!E)},title:"Highlight color",children:[r.jsx(N.Highlighter,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("highlight")?.color||"transparent"}})]}),E&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[r.jsx("div",{className:"docs-color-grid-label",children:"Highlight color"}),r.jsx("div",{className:"docs-color-grid docs-highlight-grid",children:Wn.map(f=>r.jsx("button",{className:"docs-color-swatch",style:{background:f},title:f,onClick:()=>{f==="#ffffff"?t.chain().focus().unsetHighlight().run():t.chain().focus().toggleHighlight({color:f}).run(),R()}},f))})]})]}),r.jsx(M,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline code",children:r.jsx(N.Code,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().unsetAllMarks().clearNodes().run(),title:"Clear formatting",children:r.jsx(N.RemoveFormatting,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Paragraph",children:[r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("left").run(),active:t.isActive({textAlign:"left"}),title:"Align left",children:r.jsx(N.AlignLeft,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("center").run(),active:t.isActive({textAlign:"center"}),title:"Align center",children:r.jsx(N.AlignCenter,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("right").run(),active:t.isActive({textAlign:"right"}),title:"Align right",children:r.jsx(N.AlignRight,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),active:t.isActive({textAlign:"justify"}),title:"Justify",children:r.jsx(N.AlignJustify,{size:16})}),r.jsx(M,{onClick:()=>s?.(),active:e,title:e?"Switch to LTR (left-to-right)":"Switch to RTL (right-to-left)",children:r.jsx("span",{style:{fontSize:11,fontWeight:700,letterSpacing:-.5,lineHeight:1},children:e?"LTR":"RTL"})}),r.jsxs("div",{className:"docs-tb-dropdown",ref:I,children:[r.jsxs("button",{className:`docs-tb-btn${jt?" active":""}`,onClick:()=>{R(),O(!F)},title:"Line & paragraph spacing",children:[r.jsx(N.Rows3,{size:16}),r.jsx(N.ChevronDown,{size:12})]}),F&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-spacing-menu",children:[r.jsx("div",{className:"docs-insert-category",children:"Line spacing"}),r.jsx("button",{className:`docs-tb-dropdown-item${jt?"":" active"}`,onClick:()=>Q(null),children:"Default"}),qn.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${jt===f?" active":""}`,onClick:()=>Q(f),children:f==="1"?"Single":f==="2"?"Double":f},f)),r.jsx("div",{className:"docs-insert-divider"}),r.jsx("div",{className:"docs-insert-category",children:"Paragraph spacing"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>ut("space-before"),children:rt(t,"space-before")?"Remove space before block":"Add space before block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>ut("space-after"),children:rt(t,"space-after")?"Remove space after block":"Add space after block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:mt,children:"Custom spacing…"})]})]}),r.jsx(M,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet list",children:r.jsx(N.List,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Numbered list",children:r.jsx(N.ListOrdered,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Insert",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:V,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-insert-select",onClick:()=>{R(),S(!y)},children:[r.jsx(N.Plus,{size:15}),r.jsx("span",{children:"Insert"}),r.jsx(N.ChevronDown,{size:14})]}),y&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-insert-menu",children:[r.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:he,title:"Two-sided row — content at the line start, value at the line end (text: … | end: …)",children:[r.jsx("span",{className:"docs-insert-icon",children:r.jsx(N.AlignHorizontalSpaceBetween,{size:13})}),r.jsx("span",{className:"docs-insert-label",children:"two-sided row"}),r.jsx("span",{className:"docs-insert-kw",children:"end:"})]}),r.jsx("div",{className:"docs-insert-divider"}),A.map((f,L)=>r.jsxs("div",{children:[L>0&&r.jsx("div",{className:"docs-insert-divider"}),r.jsx("div",{className:"docs-insert-category",children:f.category}),f.items.map(C=>r.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:()=>K(C.keyword),disabled:C.isReadOnly,title:C.description,children:[r.jsx("span",{className:"docs-insert-icon",children:Vt[C.category]?.icon||"•"}),r.jsx("span",{className:"docs-insert-label",children:C.label}),r.jsx("span",{className:"docs-insert-kw",children:C.isReadOnly?"locked":`.${C.keyword}`})]},C.keyword))]},f.category))]})]}),r.jsx(M,{onClick:ge,active:xe,title:"Two-sided row — set the text shown at the END of this line (end: property)",children:r.jsx(N.AlignHorizontalSpaceBetween,{size:16})})]})]}),a&&o?r.jsxs(r.Fragment,{children:[r.jsx(ot,{}),r.jsx(X,{label:"Trust",children:r.jsx(In,{content:n,onChange:o,trust:a,intact:m})})]}):p&&r.jsxs(r.Fragment,{children:[r.jsx(ot,{}),r.jsxs(X,{label:"Trust",children:[r.jsx(M,{onClick:()=>p("seal"),disabled:d,title:"Seal — freeze the document with a tamper-evident hash",children:r.jsx("span",{className:"ribbon-btn-text",children:"Seal"})}),r.jsx(M,{onClick:()=>p("sign"),title:"Sign",children:r.jsx("span",{className:"ribbon-btn-text",children:"Sign"})}),r.jsx(M,{onClick:()=>p("verify"),title:"Verify",children:r.jsx("span",{className:"ribbon-btn-text",children:"Verify"})})]})]})]})}const Yn={in:96,cm:96/2.54},Vn={in:.25,cm:.5};function fe(t,e){const s=Yn[e],n=Vn[e],o=[],c=t/s;for(let i=0;i<=c+1e-6;i+=n){const p=Math.abs(i-Math.round(i))<1e-6;o.push({x:i*s,kind:p?"major":"minor",label:p&&i>0?String(Math.round(i)):void 0})}return o}function Jn({geometry:t,zoom:e,scrollEl:s,onMargins:n,locked:o=!1}){const[c,i]=u.useState(0),[p,a]=u.useState(null),m=u.useRef(null);u.useEffect(()=>{const S=s.current;if(!S)return;const j=()=>i(S.scrollLeft);return j(),S.addEventListener("scroll",j,{passive:!0}),()=>S.removeEventListener("scroll",j)},[s]);const d=u.useMemo(()=>fe(t.width,t.unit),[t.width,t.unit]),h=u.useCallback(S=>j=>{!n||o||(j.preventDefault(),a(S))},[n,o]);u.useEffect(()=>{if(!p||!n)return;const S=b=>{const k=m.current;if(!k)return;const H=k.getBoundingClientRect(),E=(b.clientX-H.left)/e;if(p==="left"){const D=Math.max(0,Math.min(E,t.width/2));n({left:D})}else{const D=Math.max(0,Math.min(t.width-E,t.width/2));n({right:D})}},j=()=>a(null);return window.addEventListener("pointermove",S),window.addEventListener("pointerup",j),()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",j)}},[p,n,e,t.width]);const g=t.width*e,y=!!n&&!o;return r.jsx("div",{className:`docs-ruler${y?" docs-ruler--draggable":""}`,children:r.jsxs("div",{ref:m,className:"docs-ruler-track",style:{width:g,transform:`translateX(${-c}px)`},children:[r.jsx("div",{className:"docs-ruler-margin",style:{left:0,width:t.marginLeft*e}}),r.jsx("div",{className:"docs-ruler-margin",style:{right:0,width:t.marginRight*e}}),d.map((S,j)=>S.label?r.jsx("span",{className:"docs-ruler-num",style:{left:S.x*e},children:S.label},j):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--${S.kind}`,style:{left:S.x*e}},j)),y&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--h${p==="left"?" dragging":""}`,style:{left:t.marginLeft*e},onPointerDown:h("left"),title:"Drag to set the left margin"}),r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--h${p==="right"?" dragging":""}`,style:{left:(t.width-t.marginRight)*e},onPointerDown:h("right"),title:"Drag to set the right margin"})]})]})})}function Qn({geometry:t,zoom:e,scrollEl:s,onMargins:n,locked:o=!1,topOffset:c=0}){const[i,p]=u.useState(0),[a,m]=u.useState(null),d=u.useRef(null);u.useEffect(()=>{const b=s.current;if(!b)return;const k=()=>p(b.scrollTop);return k(),b.addEventListener("scroll",k,{passive:!0}),()=>b.removeEventListener("scroll",k)},[s]);const h=t.autoHeight?t.width*1.414:t.height,g=u.useMemo(()=>fe(h,t.unit),[h,t.unit]),y=u.useCallback(b=>k=>{!n||o||t.autoHeight||(k.preventDefault(),m(b))},[n,o,t.autoHeight]);u.useEffect(()=>{if(!a||!n)return;const b=H=>{const E=d.current;if(!E)return;const D=E.getBoundingClientRect(),F=(H.clientY-D.top)/e;if(a==="top"){const O=Math.max(0,Math.min(F,h/2));n({top:O})}else{const O=Math.max(0,Math.min(h-F,h/2));n({bottom:O})}},k=()=>m(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",k),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",k)}},[a,n,e,h]);const S=h*e,j=!!n&&!o&&!t.autoHeight;return r.jsx("div",{className:"docs-ruler-v",children:r.jsxs("div",{ref:d,className:"docs-ruler-v-track",style:{height:S,transform:`translateY(${c-i}px)`},children:[r.jsx("div",{className:"docs-ruler-margin docs-ruler-margin--v",style:{top:0,height:t.marginTop*e}}),r.jsx("div",{className:"docs-ruler-margin docs-ruler-margin--v",style:{bottom:0,height:t.marginBottom*e}}),g.map((b,k)=>b.label?r.jsx("span",{className:"docs-ruler-num docs-ruler-num--v",style:{top:b.x*e},children:b.label},k):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--v docs-ruler-tick--${b.kind}`,style:{top:b.x*e}},k)),j&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${a==="top"?" dragging":""}`,style:{top:t.marginTop*e},onPointerDown:y("top"),title:"Drag to set the top margin"}),r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${a==="bottom"?" dragging":""}`,style:{top:(h-t.marginBottom)*e},onPointerDown:y("bottom"),title:"Drag to set the bottom margin"})]})]})})}function Lt(t,e){return e?`${t} (${e})`:t}function Xn({trust:t,intact:e}){if(t.isSealed){const s=t.sealedBy||"unknown",n=t.signatures[t.signatures.length-1]?.role;return r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--sealed",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"🔒"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Sealed"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["signed by ",Lt(s,n),t.sealedAt?` on ${t.sealedAt}`:""," · read-only"]}),e===!0&&r.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--ok",children:"hash verified ✓"}),e===!1&&r.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--bad",children:"⚠ hash mismatch — content changed after sealing"})]})}if(t.signatures.length>0){const s=t.signatures.length;return r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--signed",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"✍"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Signed"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.signatures.map(n=>`${Lt(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]}),r.jsxs("span",{className:"docs-trust-banner__warn",children:["⚠ Editing will break ",s," signature",s===1?"":"s"]})]})}return t.approvals.length>0?r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--approved",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"✓"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Approved"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.approvals.map(s=>`${Lt(s.by,s.role)}${s.at?` on ${s.at}`:""}`).join(" · ")]})]}):null}function Zn(t){let e;try{e=z.parseIntentText(t)}catch{return[]}const s=[],n=(o,c)=>{const i=c==null?"":String(c).trim();i&&s.push({key:o,value:i})};for(const o of e.blocks)switch(o.type){case"meta":for(const[c,i]of Object.entries(o.properties||{}))n(c,i);break;case"track":n("tracked",o.properties?.id??o.content);break;case"page":{const c=o.properties?.orientation;n("page",[o.content,c].filter(Boolean).join(" · "));break}case"font":n("font",[o.content||o.properties?.family,o.properties?.size].filter(Boolean).join(" · "));break;case"header":n("header",o.content);break;case"footer":n("footer",o.content);break;case"watermark":n("watermark",o.content);break}return s}function ts({source:t}){const[e,s]=u.useState(!1),n=u.useMemo(()=>Zn(t),[t]);if(n.length===0)return null;const o=n.slice(0,4).map(c=>`${c.key}: ${c.value}`).join(" · ");return r.jsxs("div",{className:`docs-props-bar${e?" open":""}`,children:[r.jsxs("button",{className:"docs-props-toggle",onClick:()=>s(c=>!c),title:e?"Hide document properties":"Show document properties",children:[r.jsx("span",{className:"docs-props-caret",children:e?"▾":"▸"}),"Document properties",!e&&r.jsx("span",{className:"docs-props-summary",children:o})]}),e&&r.jsx("div",{className:"docs-props-chips",children:n.map((c,i)=>r.jsxs("span",{className:"docs-props-chip",children:[r.jsx("b",{children:c.key})," ",c.value]},`${c.key}-${i}`))})]})}function B(t,e,s=""){const n=t?.properties?.[e];return n!=null?String(n):s}function Et(t){const e={lifecycle:"draft",isTracked:!1,trackBlock:null,approvals:[],signatures:[],isSealed:!1,sealedBy:null,sealedAt:null,sealHash:null,amendments:[]};if(!t)return e;const s=t.blocks,n=s.find(a=>a.type==="track");n&&(e.isTracked=!0,e.lifecycle="tracked",e.trackBlock={id:B(n,"id",n.content??""),by:B(n,"by"),at:B(n,"at")});const o=s.filter(a=>a.type==="approve");for(const a of o)e.approvals.push({by:B(a,"by",a.content??""),role:B(a,"role"),at:B(a,"at"),note:B(a,"note")||void 0});e.approvals.length>0&&(e.lifecycle="approved");const c=s.filter(a=>a.type==="sign");for(const a of c)e.signatures.push({by:B(a,"by",a.content??""),role:B(a,"role"),at:B(a,"at")});e.signatures.length>0&&(e.lifecycle="signed");const i=s.find(a=>a.type==="freeze");if(i){e.isSealed=!0,e.lifecycle="sealed";const a=e.signatures[e.signatures.length-1];e.sealedBy=a?.by||B(i,"by",i.content??""),e.sealedAt=B(i,"at")||a?.at||"",e.sealHash=B(i,"hash")}const p=s.filter(a=>a.type==="amendment");for(const a of p)e.amendments.push({section:B(a,"section",a.content??""),was:B(a,"was"),now:B(a,"now"),by:B(a,"by"),ref:B(a,"ref"),at:B(a,"at")});return e}const ee=new gt.PluginKey("template-highlight"),wt=/\{\{[^}]+\}\}/g;function ne(t){const e=[];return t.descendants((s,n)=>{if(!s.isText||!s.text)return;wt.lastIndex=0;let o;for(;o=wt.exec(s.text);)e.push(dt.Decoration.inline(n+o.index,n+o.index+o[0].length,{class:"it-doc-var"}))}),dt.DecorationSet.create(t,e)}const es=T.Extension.create({name:"templateHighlight",addProseMirrorPlugins(){return[new gt.Plugin({key:ee,state:{init:(t,e)=>ne(e.doc),apply:(t,e)=>t.docChanged?ne(t.doc):e},props:{decorations(t){return ee.getState(t)}}})]}});function ns(t){const e=new Set,s=[];wt.lastIndex=0;let n;for(;n=wt.exec(t);){const o=n[0].slice(2,-2).trim();/^(page|pages|date|time|year)$/i.test(o)||e.has(o)||(e.add(o),s.push(o))}return s}function ss(t){const e={};for(const s of t){const n=s.split(".");let o=e;for(let c=0;c<n.length;c++){const i=n[c];c===n.length-1?i in o||(o[i]=""):((!(i in o)||typeof o[i]!="object"||o[i]===null)&&(o[i]={}),o=o[i])}}return e}function rs(t,e,s){const n=t.coordsAtPos(e),o=n.top+1,c=n.bottom-1,i=s==="start"?-1:1;let p=e,a=e;for(let m=0;m<1e5;m++){const d=p+i;if(d<0||d>t.state.doc.content.size)break;let h;try{h=t.coordsAtPos(d)}catch{break}if(h.bottom<=o||h.top>=c)break;p=d,a=d}return a}const os=T.Extension.create({name:"lineKeymap",addKeyboardShortcuts(){const t=(e,s)=>{const{view:n}=this.editor,{state:o}=n,{selection:c}=o,i=c.head,p=rs(n,i,e);if(p==null||p===i)return!1;const a=o.doc.resolve(p),m=s?c.anchor:p,d=o.tr.setSelection(s?gt.TextSelection.between(o.doc.resolve(m),a):gt.TextSelection.near(a));return n.dispatch(d.scrollIntoView()),!0};return{Home:()=>t("start",!1),End:()=>t("end",!1),"Shift-Home":()=>t("start",!0),"Shift-End":()=>t("end",!0)}}}),is=28,as={title:[".it-doc-title"],summary:[".it-doc-summary"],section:[".it-doc-section"],sub:[".it-doc-sub"],text:["p"],quote:[".it-doc-quote"],callout:[".it-doc-callout"],info:[".it-doc-callout"],table:[".it-doc-table th",".it-doc-table td"],"table-header":[".it-doc-table th"],metric:[".it-doc-metric"],contact:['.it-doc-generic[data-keyword="contact"]'],divider:[".it-doc-divider"]};function cs({value:t,onChange:e,theme:s,onThemeChange:n,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:i=!0,onTrustAction:p}){const a=u.useRef(""),m=u.useRef(!1),d=u.useRef(!0),[h,g]=u.useState([]),y=u.useRef(kt("")),[S,j]=u.useState(1),b=Ft.useEditor({extensions:[Ye.configure({geometry:()=>y.current,gap:is,onPages:j}),$e.default.configure({heading:!1,codeBlock:!1,blockquote:!1,horizontalRule:!1,paragraph:!1}),Rn,zn,os,Me.default,we.TextStyle,Ee.default,Re.default.configure({multicolor:!0}),ze.default.configure({types:["paragraph","itTitle","itSummary","itSection","itSub"]}),He.default,Be,Pe.default,De.default,hn,mn,bn,yn,xn,Sn,kn,vn,jn,wn,Tn,Nn,Cn,An,Ln,_n,es],content:vt(t),onUpdate:({editor:x})=>{if(d.current)return;const w=x.getJSON(),A=Pt(w);a.current=A,m.current=!0,g(an(w)),e(A)},editorProps:{attributes:{class:"docs-page-content",spellcheck:"true"}}});u.useEffect(()=>{const x=window.setTimeout(()=>{d.current=!1,a.current=t},0);return()=>window.clearTimeout(x)},[]),u.useEffect(()=>{if(b){if(m.current){m.current=!1;return}if(t!==a.current){const x=vt(t);b.commands.setContent(x),a.current=t}}},[t,b]),u.useEffect(()=>{if(!b)return;const x=w=>{const A=w.detail;A&&b.chain().focus().insertContent(A).run()};return window.addEventListener("it-insert-text",x),()=>window.removeEventListener("it-insert-text",x)},[b]);const k=u.useMemo(()=>kt(t),[t]);u.useEffect(()=>{y.current=k,b?.view.dispatch(b.state.tr)},[k,b]);const H=u.useRef(null),E=u.useCallback(()=>b?b.storage.characterCount?.words?.()??b.getText().split(/\s+/).filter(Boolean).length:0,[b]),D=u.useMemo(()=>{if(!s)return"";try{const x=z.getBuiltinTheme(s);return x?z.generateThemeCSS(x).replace(/:root\{/,".docs-page{"):""}catch{return""}},[s]),F=u.useMemo(()=>{try{const x=z.parseIntentText(t),w=x.blocks.find(G=>G.type==="header")?.content||"",A=x.blocks.find(G=>G.type==="footer")?.content||"",U=x.blocks.find(G=>G.type==="meta"),K=String(U?.properties?.dir||"ltr").toLowerCase();return{header:w,footer:A,dir:K}}catch{return{header:"",footer:"",dir:"ltr"}}},[t]),O=u.useMemo(()=>{try{return Et(z.parseIntentText(t))}catch{return Et(null)}},[t]),W=u.useMemo(()=>{if(!O.isSealed)return null;try{return z.verifyDocument(t).intact}catch{return null}},[t,O.isSealed]),_=O.isSealed||o;u.useEffect(()=>{b&&b.isEditable!==!_&&b.setEditable(!_)},[b,_]),u.useEffect(()=>{if(!b)return;b.view.dom.setAttribute("dir",F.dir==="rtl"?"rtl":"ltr")},[b,F.dir]);const P=u.useMemo(()=>{try{return z.documentStyleCSS(z.parseIntentText(t),as,".docs-page .tiptap ")}catch{return""}},[t]);u.useEffect(()=>{let x=document.getElementById("it-doc-style-rules");x||(x=document.createElement("style"),x.id="it-doc-style-rules",document.head.appendChild(x)),x.textContent=P},[P]);const V=u.useCallback(()=>{if(b){const{from:w,to:A}=b.state.selection;let U=0,K=!1;if(b.state.doc.nodesBetween(w,A,Q=>{if(Q.isTextblock){U++;const ut=Q.attrs?.dir,mt=(()=>{try{return Q.attrs?.props?JSON.parse(Q.attrs.props).dir:void 0}catch{return}})();return(ut==="rtl"||mt==="rtl")&&(K=!0),!1}return!0}),w!==A&&U>=1){b.chain().focus().setBlockProp("dir",K?null:"rtl").run();return}}const x=F.dir==="rtl";e(z.upsertMetaProperty(t,"dir",x?null:"rtl"))},[b,t,e,F.dir]),J=u.useCallback(x=>{const w=y.current,A=mt=>Math.max(0,Math.round(mt/Z*10)/10),U=A(x.top??w.marginTop),K=A(x.right??w.marginRight),G=A(x.bottom??w.marginBottom),Q=A(x.left??w.marginLeft),ut=`${U}mm ${K}mm ${G}mm ${Q}mm`;e(We(t,ut))},[t,e]);u.useEffect(()=>{const x="it-editor-theme-css";let w=document.getElementById(x);w||(w=document.createElement("style"),w.id=x,document.head.appendChild(w)),w.textContent=D},[D]);const q=u.useRef(null),[v,I]=u.useState(1),R=u.useRef(v),ct=u.useRef(null),ht=u.useCallback(x=>{const w=q.current;if(!w)return;const A=w.getBoundingClientRect();ct.current={cx:w.scrollLeft+(x.clientX-A.left),cy:w.scrollTop+(x.clientY-A.top)}},[]),nt=u.useCallback(()=>{const x=q.current;x&&(ct.current={cx:x.scrollLeft+x.clientWidth/2,cy:x.scrollTop+x.clientHeight/2})},[]);return u.useLayoutEffect(()=>{const x=q.current,w=ct.current,A=R.current;if(!x||!w||A===v)return;const U=v/A;x.getBoundingClientRect();const K=w.cx-x.scrollLeft,G=w.cy-x.scrollTop;x.scrollLeft=w.cx*U-K,x.scrollTop=w.cy*U-G,ct.current=null,R.current=v},[v]),u.useEffect(()=>{const x=w=>{if(w.metaKey||w.ctrlKey){if(w.key==="p"||w.key==="P"){w.preventDefault(),Bt(t,s);return}w.key==="="||w.key==="+"?(w.preventDefault(),nt(),I(A=>Math.min(2,+(A+.1).toFixed(2)))):w.key==="-"?(w.preventDefault(),nt(),I(A=>Math.max(.25,+(A-.1).toFixed(2)))):w.key==="0"&&(w.preventDefault(),nt(),I(1))}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[nt,t,s]),u.useEffect(()=>{const x=q.current;if(!x)return;const w=A=>{if(A.ctrlKey||A.metaKey){A.preventDefault();const U=A.deltaY>0?-.1:.1;ht(A),I(K=>Math.min(2,Math.max(.25,+(K+U).toFixed(2))))}};return x.addEventListener("wheel",w,{passive:!1}),()=>x.removeEventListener("wheel",w)},[ht]),r.jsxs("div",{className:"docs-container",children:[c&&r.jsx(Kn,{editor:b,isRtl:F.dir==="rtl",onToggleRtl:V,content:t,onChange:e,theme:s,onThemeChange:n,onTrustAction:p,trust:O,sealIntact:W,locked:_}),i&&r.jsx(Xn,{trust:O,intact:W}),i&&r.jsx(ts,{source:t}),h.length>0&&r.jsxs("div",{className:"docs-fidelity-warning",role:"status",children:["⚠ Some formatting (",h.join(", "),") can’t be saved to"," ",r.jsx("code",{children:".it"})," and won’t appear when printed through the template — remove it or use the toolbar’s color/size/style controls instead."]}),r.jsx(Jn,{geometry:k,zoom:v,scrollEl:q,onMargins:J,locked:_}),r.jsxs("div",{className:"docs-canvas-row",children:[r.jsx(Qn,{geometry:k,zoom:v,scrollEl:q,onMargins:J,locked:_}),r.jsxs("div",{className:"docs-canvas",ref:q,children:[r.jsx("div",{className:"docs-page-scaler",style:{width:k.width*v},children:r.jsx("div",{className:"docs-page-flow",dir:F.dir,style:{transform:v!==1?`scale(${v})`:void 0,transformOrigin:"top left"},children:r.jsxs("div",{className:"docs-page docs-sheet",ref:H,style:{width:k.width,minHeight:k.autoHeight?k.width:void 0,"--page-mx-l":`${k.marginLeft}px`,"--page-mx-r":`${k.marginRight}px`},children:[r.jsx("div",{className:"docs-sheet-header","data-it-spacer":"",style:{height:k.autoHeight?void 0:k.marginTop},children:r.jsx("div",{className:"docs-pb-header",children:r.jsx("span",{className:"docs-pb-text",children:k.autoHeight?"":Rt(k.header,1,S)})})}),r.jsx(Ft.EditorContent,{editor:b})]})})}),r.jsxs("div",{className:"docs-page-footer",children:[S," ",S===1?"page":"pages"," ·"," ",E()," words",v!==1&&r.jsxs("span",{className:"zoom-indicator",children:[" ","· ",Math.round(v*100),"%"]})]})]})]})]})}const ls="corporate";function ds({value:t,onChange:e,theme:s,onThemeChange:n,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:i=!0,onTrustAction:p}){const[a,m]=u.useState(s??ls),d=s??a,h=u.useCallback(g=>{m(g),n?.(g)},[n]);return r.jsx(cs,{value:t,onChange:e,theme:d,onThemeChange:h,readOnly:o,showRibbon:c,showTrustBanner:i,onTrustAction:p})}exports.IntentTextEditor=ds;exports.buildSampleSkeleton=ss;exports.builtinThemes=pe;exports.docToSource=Pt;exports.downloadItFile=ue;exports.exportDocumentHTML=Dn;exports.exportDocumentPDF=Bt;exports.extractTemplateVariables=ns;exports.extractTrustState=Et;exports.getPageGeometry=kt;exports.printHtmlViaIframe=ae;exports.resolvePageTokens=Rt;exports.sourceToDoc=vt;
|
|
31
|
+
`;return`<!doctype html><html><head><meta charset="utf-8">${c}<style>${m}${d}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${o}</div></div></body></html>`}function le(t,e,s){const n=new Blob([t],{type:s}),o=URL.createObjectURL(n),c=document.createElement("a");c.href=o,c.download=e,c.click(),URL.revokeObjectURL(o)}function de(t,e,s){let n=Pn(t,s);if(!n){const o=z.parseIntentText(t);n=z.renderPrint(o,{theme:e}),s==="minimal-ink"&&(n=Hn(n,ce))}return n}function Bt(t,e,s="normal"){try{ae(de(t,e,s))}catch{}}function ue(t,e){try{let s=e;if(!s)try{const n=z.parseIntentText(t),c=n.blocks.find(a=>a.type==="meta")?.properties?.id,i=n.blocks.find(a=>a.type==="title")?.content||"";s=`${String(c||i||"document").trim().replace(/[^\w\-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"document"}.it`}catch{s="document.it"}le(t,s,"text/plain;charset=utf-8")}catch{}}function Dn(t,e,s="normal"){try{le(de(t,e,s),"document.html","text/html")}catch{}}function pe(){return z.listBuiltinThemes()}function Qt(t){try{const e=Pt(vt(t));return e.trim()?e:t}catch{return t}}const Xt="dotit.editor.lastSigner",Zt="dotit.editor.lastRole";function In({content:t,onChange:e,trust:s,intact:n}){const[o,c]=u.useState(!1),[i,p]=u.useState(!1),[a,m]=u.useState(!1),[d,h]=u.useState(()=>localStorage.getItem(Xt)||""),[g,y]=u.useState(()=>localStorage.getItem(Zt)||""),[S,j]=u.useState(!1),b=u.useRef(null),k=u.useRef(0),H=u.useCallback(v=>{const I=Date.now();I-k.current<400||(k.current=I,v())},[]);u.useEffect(()=>{if(!o)return;const v=I=>{b.current&&!b.current.contains(I.target)&&(c(!1),m(!1))};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);const E=s.isSealed||z.isSealed(t),D=u.useCallback(()=>{const v=d.trim();if(v){j(!0);try{const I=Qt(t),R=z.signDocument(I,{signer:v,role:g.trim()||void 0});R.source&&R.source!==t&&e(R.source),localStorage.setItem(Xt,v),g.trim()&&localStorage.setItem(Zt,g.trim())}finally{j(!1),m(!1),c(!1)}}},[t,e,d,g]),F=u.useCallback(()=>{const v=d.trim()||s.signatures[0]?.by||"Document owner";j(!0);try{const I=z.sealDocument(Qt(t),{signer:v,role:g.trim()||s.signatures[0]?.role||void 0,skipSign:!0});I.source&&I.source!==t&&!I.error&&e(I.source)}finally{j(!1),c(!1)}},[t,e,d,g,s.signatures]),O=u.useCallback(()=>{j(!0);try{const v=z.unsealDocument(t);typeof v=="string"&&v!==t&&e(v)}finally{j(!1),c(!1)}},[t,e]),[W,_]=u.useState(null),P=u.useCallback(()=>{try{_(z.verifyDocument(t))}catch{_(null)}},[t]);let V=r.jsx(N.PenTool,{size:15}),J="Draft",q="trust-face--draft";return E?(V=r.jsx(N.FileLock2,{size:15}),J=n===!1?"Sealed · changed!":"Sealed",q=n===!1?"trust-face--broken":"trust-face--sealed"):s.signatures.length>0&&(V=r.jsx(N.ShieldCheck,{size:15}),J=`Signed · ${s.signatures.length}`,q="trust-face--signed"),r.jsxs("div",{className:"trust-control",ref:b,children:[r.jsxs("button",{className:`docs-tb-btn trust-face ${q}`,onClick:()=>{c(v=>!v),m(!1),E&&P()},title:"Document trust — sign, seal, verify",children:[r.jsx("span",{className:"trust-face__icon",children:V}),r.jsx("span",{className:"ribbon-btn-text",children:J}),E&&n===!0&&r.jsx("span",{className:"trust-face__ok",title:"Hash verified",children:"✓"}),r.jsx(N.ChevronDown,{size:12})]}),o&&r.jsxs("div",{className:"trust-popover",children:[r.jsx("div",{className:"trust-popover__state",children:E?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"🔒 Sealed — read-only"}),r.jsxs("div",{className:"trust-popover__meta",children:[s.sealedBy&&r.jsxs(r.Fragment,{children:["by ",s.sealedBy]}),s.sealedAt&&r.jsxs(r.Fragment,{children:[" on ",s.sealedAt]})]})]}):s.signatures.length>0?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:["Signed · ",s.signatures.length]}),r.jsx("div",{className:"trust-popover__meta",children:s.signatures.map(v=>v.role?`${v.by} (${v.role})`:v.by).join(" · ")}),r.jsxs("div",{className:"trust-popover__warn",children:["⚠ Still editable — editing will break"," ",s.signatures.length," signature",s.signatures.length===1?"":"s",". Seal to lock it."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"Draft"}),r.jsx("div",{className:"trust-popover__meta",children:"Not signed or sealed yet."})]})}),r.jsx("button",{className:"trust-popover__help-toggle",onClick:()=>p(v=>!v),children:"(?) what does this mean"}),i&&r.jsxs("div",{className:"trust-popover__help",children:[r.jsxs("p",{children:[r.jsx("b",{children:"Sign"})," adds your name to the document. It stays editable — but changing it afterwards invalidates the signatures."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Seal"})," freezes the document with a tamper-evident hash and makes it ",r.jsx("b",{children:"read-only"}),". ",r.jsx("b",{children:"Unseal"})," makes it editable again."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Verify"})," recomputes the hash and confirms the content still matches the seal."]})]}),r.jsx("div",{className:"trust-popover__divider"}),E?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"trust-popover__verify",children:[W?W.intact?r.jsx("span",{className:"trust-verify--ok",children:"✓ Verified — content matches the seal"}):r.jsx("span",{className:"trust-verify--bad",children:"⚠ Hash mismatch — content changed after sealing"}):null,W?.hash&&r.jsxs("details",{className:"trust-popover__hash",children:[r.jsx("summary",{children:"Show hash"}),r.jsx("code",{children:W.hash})]})]}),r.jsxs("button",{className:"trust-popover__action",onClick:()=>H(P),disabled:S,children:[r.jsx(N.ShieldCheck,{size:14})," Re-verify"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--warn",onClick:()=>H(O),disabled:S,title:"Remove the freeze lock (keeps signatures) and make the document editable again",children:[r.jsx(N.LockOpen,{size:14})," Unseal (make editable)"]})]}):a?r.jsxs("div",{className:"trust-sign-form",children:[r.jsx("input",{className:"trust-sign-input",placeholder:"Your name",value:d,autoFocus:!0,onChange:v=>h(v.target.value),onKeyDown:v=>{v.key==="Enter"&&D(),v.key==="Escape"&&m(!1)}}),r.jsx("input",{className:"trust-sign-input",placeholder:"Role (optional, e.g. CEO)",value:g,onChange:v=>y(v.target.value),onKeyDown:v=>{v.key==="Enter"&&D(),v.key==="Escape"&&m(!1)}}),r.jsxs("div",{className:"trust-sign-actions",children:[r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:D,disabled:S||!d.trim(),children:[r.jsx(N.PenTool,{size:14})," Add signature"]}),r.jsx("button",{className:"trust-popover__action",onClick:()=>m(!1),children:"Cancel"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"trust-popover__action",onClick:()=>m(!0),disabled:S,title:"Add a signature line (does not freeze the document)",children:[r.jsx(N.PenTool,{size:14})," Sign"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:()=>H(F),disabled:S,title:"Freeze the document with a tamper-evident hash. It becomes read-only until unsealed.",children:[r.jsx(N.FileLock2,{size:14})," Seal (freeze)"]})]})]})]})}const At=[{label:"Normal text",node:"paragraph"},{label:"Title",node:"itTitle"},{label:"Section",node:"itSection"},{label:"Subsection",node:"itSub"},{label:"Summary",node:"itSummary"},{label:"Quote",node:"itQuote"}],Bn=new Set(["history","revision","track","freeze"]),On=new Set(["agent","model","meta","context","history"]),Fn=["identity","structure","content","data","trust","layout"],te=[{label:"Default",value:""},{label:"Inter",value:"Inter"},{label:"Arial",value:"Arial"},{label:"Times New Roman",value:"Times New Roman"},{label:"Georgia",value:"Georgia"},{label:"Courier New",value:"Courier New"},{label:"Verdana",value:"Verdana"},{label:"Trebuchet MS",value:"Trebuchet MS"}],qn=["1","1.15","1.5","2","2.5","3"],Un="12px",Gn=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"],Wn=["#ffffff","#cfe2f3","#d9ead3","#fff2cc","#fce5cd","#f4cccc","#d9d2e9","#ead1dc","#d0e0e3","#e6b8af"];function M({onClick:t,active:e,disabled:s,title:n,children:o}){return r.jsx("button",{className:`docs-tb-btn${e?" active":""}`,onClick:t,disabled:s,title:n,children:o})}function X({label:t,children:e,className:s=""}){return r.jsx("div",{className:`ribbon-group ${s}`.trim(),role:"group","aria-label":t,children:e})}function ot(){return r.jsx("div",{className:"ribbon-sep"})}function Kn({editor:t,isRtl:e=!1,onToggleRtl:s,content:n,onChange:o,theme:c,onThemeChange:i,onTrustAction:p,trust:a,sealIntact:m=null,locked:d=!1}){const[h,g]=u.useState(!1),[y,S]=u.useState(!1),[j,b]=u.useState(!1),[k,H]=u.useState(!1),[E,D]=u.useState(!1),[F,O]=u.useState(!1),[W,_]=u.useState(!1),P=u.useRef(null),V=u.useRef(null),J=u.useRef(null),q=u.useRef(null),v=u.useRef(null),I=u.useRef(null);u.useEffect(()=>{const f=L=>{const C=L.target;P.current&&!P.current.contains(C)&&g(!1),V.current&&!V.current.contains(C)&&S(!1),J.current&&!J.current.contains(C)&&b(!1),q.current&&!q.current.contains(C)&&H(!1),v.current&&!v.current.contains(C)&&D(!1),I.current&&!I.current.contains(C)&&O(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const R=()=>{g(!1),S(!1),b(!1),H(!1),D(!1),O(!1)},ct=u.useCallback(()=>{if(!t)return"Normal text";for(const f of At)if(f.node==="paragraph"&&t.isActive("paragraph")){if(!At.some(C=>C.node!=="paragraph"&&t.isActive(C.node)))return f.label}else if(t.isActive(f.node))return f.label;return"Normal text"},[t]),ht=u.useCallback(()=>{if(!t)return"Default";const f=t.getAttributes("textStyle")?.fontFamily;if(!f)return"Default";const L=te.find(C=>C.value===f);return L?L.label:"Default"},[t]),[nt,x]=u.useState(11),[,w]=u.useState(0),A=u.useMemo(()=>{const f=new Map;for(const C of z.LANGUAGE_REGISTRY){if(C.status!=="stable"||On.has(C.canonical)||C.category==="agent")continue;const st=C.category,xt=f.get(st)||[];xt.push({label:C.canonical,keyword:C.canonical,category:st,description:C.description,isReadOnly:Bn.has(C.canonical)}),f.set(st,xt)}const L=[];for(const C of Fn){const st=f.get(C);!st||st.length===0||(st.sort((xt,Se)=>xt.keyword.localeCompare(Se.keyword)),L.push({category:Vt[C]?.label||C,items:st}))}return L},[]);u.useEffect(()=>{if(!t)return;const f=()=>{const L=t.getAttributes("textStyle");if(L?.fontSize){const C=parseInt(L.fontSize,10);isNaN(C)||x(C)}w(C=>C+1)};return t.on("selectionUpdate",f),t.on("transaction",f),()=>{t.off("selectionUpdate",f),t.off("transaction",f)}},[t]);const U=u.useCallback(f=>{t&&(f==="paragraph"?t.chain().focus().setParagraph().run():f==="itQuote"?t.chain().focus().setNode("itQuote").run():t.chain().focus().setNode(f).run(),R())},[t]),K=u.useCallback(f=>{if(!t)return;const L=t.chain().focus();f==="divider"?L.setNode("itDivider").run():f==="break"?L.setNode("itBreak").run():f==="code"?L.setNode("itCode",{lang:""}).run():["tip","info","warning","danger","success"].includes(f)?L.setNode("itCallout",{variant:f}).run():L.setNode("itGenericBlock",{keyword:f,properties:""}).run(),R()},[t]),Q=u.useCallback(f=>{const L=Math.min(96,Math.max(8,nt+f));x(L),t?.chain().focus().setFontSize(`${L}pt`).run()},[t,nt]),G=u.useCallback(f=>{t?.chain().focus().setBlockProp("leading",f).run(),R()},[t]),ut=u.useCallback(f=>{if(!t)return;const L=rt(t,f);t.chain().focus().setBlockProp(f,L?null:Un).run(),R()},[t]),mt=u.useCallback(()=>{if(!t)return;const f=window.prompt("Space before block (e.g. 12px, 1em — empty for none):",rt(t,"space-before")||"");if(f===null)return;const L=window.prompt("Space after block (e.g. 12px, 1em — empty for none):",rt(t,"space-after")||"");L!==null&&(t.chain().focus().setBlockProp("space-before",f.trim()||null).setBlockProp("space-after",L.trim()||null).run(),R())},[t]),ge=u.useCallback(()=>{if(!t)return;const f=rt(t,"end"),L=window.prompt("Line-end text (shown at the end of the line — empty to remove):",f||"");L!==null&&t.chain().focus().setBlockProp("end",L.trim()||null).run()},[t]),he=u.useCallback(()=>{t&&(t.chain().focus().insertContent({type:"paragraph",attrs:{end:"End text"},content:[{type:"text",text:"Start text"}]}).run(),R())},[t]),me=u.useMemo(()=>pe(),[]),Ot=W?"minimal-ink":"normal",be=u.useCallback(()=>Bt(n,c,Ot),[n,c,Ot]),ye=u.useCallback(()=>ue(n),[n]);if(!t)return null;const jt=rt(t,"leading"),xe=!!rt(t,"end");return r.jsxs("div",{className:"docs-toolbar docs-ribbon",children:[r.jsxs(X,{label:"Edit",children:[r.jsx(M,{onClick:()=>t.chain().focus().undo().run(),disabled:d||!t.can().undo(),title:"Undo (⌘Z)",children:r.jsx(N.Undo2,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().redo().run(),disabled:d||!t.can().redo(),title:"Redo (⌘⇧Z)",children:r.jsx(N.Redo2,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"File",children:[r.jsxs(M,{onClick:ye,title:"Save / Download the .it file",children:[r.jsx(N.Download,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"Save"})]}),r.jsxs(M,{onClick:be,title:"Export PDF (⌘P) — WYSIWYG",children:[r.jsx(N.Printer,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"PDF"})]}),r.jsx(M,{onClick:()=>_(f=>!f),active:W,title:"Minimal ink mode (plain callouts when printing)",children:r.jsx(N.Droplets,{size:16})}),r.jsx("select",{className:"ribbon-theme-select",value:c,onChange:f=>i(f.target.value),title:"Document theme (used everywhere — canvas, print, export)",children:me.map(f=>r.jsx("option",{value:f,children:f.charAt(0).toUpperCase()+f.slice(1)},f))})]}),r.jsx(ot,{}),r.jsxs("div",{className:d?"ribbon-locked":"ribbon-editing",children:[r.jsx(X,{label:"Style",children:r.jsxs("div",{className:"docs-tb-dropdown",ref:P,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-paragraph-select",onClick:()=>{R(),g(!h)},children:[r.jsx("span",{className:"docs-tb-select-label",children:ct()}),r.jsx(N.ChevronDown,{size:14})]}),h&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-style-menu",children:At.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${ct()===f.label?" active":""}`,onClick:()=>U(f.node),children:r.jsx("span",{className:`docs-style-preview docs-style-${f.node}`,children:f.label})},f.node))})]})}),r.jsx(ot,{}),r.jsxs(X,{label:"Font",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:J,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-font-select",onClick:()=>{R(),b(!j)},children:[r.jsx("span",{className:"docs-tb-select-label",children:ht()}),r.jsx(N.ChevronDown,{size:14})]}),j&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-font-menu",children:te.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${ht()===f.label?" active":""}`,style:{fontFamily:f.value||"inherit"},onClick:()=>{f.value?t.chain().focus().setFontFamily(f.value).run():t.chain().focus().unsetFontFamily().run(),R()},children:f.label},f.value||"default"))})]}),r.jsx(M,{onClick:()=>Q(-1),title:"Decrease font size",children:r.jsx(N.Minus,{size:14})}),r.jsx("span",{className:"docs-tb-fontsize",children:nt}),r.jsx(M,{onClick:()=>Q(1),title:"Increase font size",children:r.jsx(N.Plus,{size:14})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Text",children:[r.jsx(M,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (⌘B)",children:r.jsx(N.Bold,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (⌘I)",children:r.jsx(N.Italic,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (⌘U)",children:r.jsx(N.Underline,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough (⌘⇧X)",children:r.jsx(N.Strikethrough,{size:16})}),r.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:q,children:[r.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{R(),H(!k)},title:"Text color",children:[r.jsx(N.Palette,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("textStyle")?.color||"#000000"}})]}),k&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[r.jsx("div",{className:"docs-color-grid-label",children:"Text color"}),r.jsx("div",{className:"docs-color-grid",children:Gn.map(f=>r.jsx("button",{className:"docs-color-swatch",style:{background:f},title:f,onClick:()=>{t.chain().focus().setColor(f).run(),R()}},f))}),r.jsxs("button",{className:"docs-tb-dropdown-item",onClick:()=>{t.chain().focus().unsetColor().run(),R()},children:[r.jsx(N.RemoveFormatting,{size:14})," Reset"]})]})]}),r.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:v,children:[r.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{R(),D(!E)},title:"Highlight color",children:[r.jsx(N.Highlighter,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("highlight")?.color||"transparent"}})]}),E&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-color-grid-menu",children:[r.jsx("div",{className:"docs-color-grid-label",children:"Highlight color"}),r.jsx("div",{className:"docs-color-grid docs-highlight-grid",children:Wn.map(f=>r.jsx("button",{className:"docs-color-swatch",style:{background:f},title:f,onClick:()=>{f==="#ffffff"?t.chain().focus().unsetHighlight().run():t.chain().focus().toggleHighlight({color:f}).run(),R()}},f))})]})]}),r.jsx(M,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline code",children:r.jsx(N.Code,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().unsetAllMarks().clearNodes().run(),title:"Clear formatting",children:r.jsx(N.RemoveFormatting,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Paragraph",children:[r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("left").run(),active:t.isActive({textAlign:"left"}),title:"Align left",children:r.jsx(N.AlignLeft,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("center").run(),active:t.isActive({textAlign:"center"}),title:"Align center",children:r.jsx(N.AlignCenter,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("right").run(),active:t.isActive({textAlign:"right"}),title:"Align right",children:r.jsx(N.AlignRight,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),active:t.isActive({textAlign:"justify"}),title:"Justify",children:r.jsx(N.AlignJustify,{size:16})}),r.jsx(M,{onClick:()=>s?.(),active:e,title:e?"Switch to LTR (left-to-right)":"Switch to RTL (right-to-left)",children:r.jsx("span",{style:{fontSize:11,fontWeight:700,letterSpacing:-.5,lineHeight:1},children:e?"LTR":"RTL"})}),r.jsxs("div",{className:"docs-tb-dropdown",ref:I,children:[r.jsxs("button",{className:`docs-tb-btn${jt?" active":""}`,onClick:()=>{R(),O(!F)},title:"Line & paragraph spacing",children:[r.jsx(N.Rows3,{size:16}),r.jsx(N.ChevronDown,{size:12})]}),F&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-spacing-menu",children:[r.jsx("div",{className:"docs-insert-category",children:"Line spacing"}),r.jsx("button",{className:`docs-tb-dropdown-item${jt?"":" active"}`,onClick:()=>G(null),children:"Default"}),qn.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${jt===f?" active":""}`,onClick:()=>G(f),children:f==="1"?"Single":f==="2"?"Double":f},f)),r.jsx("div",{className:"docs-insert-divider"}),r.jsx("div",{className:"docs-insert-category",children:"Paragraph spacing"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>ut("space-before"),children:rt(t,"space-before")?"Remove space before block":"Add space before block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>ut("space-after"),children:rt(t,"space-after")?"Remove space after block":"Add space after block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:mt,children:"Custom spacing…"})]})]}),r.jsx(M,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet list",children:r.jsx(N.List,{size:16})}),r.jsx(M,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Numbered list",children:r.jsx(N.ListOrdered,{size:16})})]}),r.jsx(ot,{}),r.jsxs(X,{label:"Insert",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:V,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-insert-select",onClick:()=>{R(),S(!y)},children:[r.jsx(N.Plus,{size:15}),r.jsx("span",{children:"Insert"}),r.jsx(N.ChevronDown,{size:14})]}),y&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-insert-menu",children:[r.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:he,title:"Two-sided row — content at the line start, value at the line end (text: … | end: …)",children:[r.jsx("span",{className:"docs-insert-icon",children:r.jsx(N.AlignHorizontalSpaceBetween,{size:13})}),r.jsx("span",{className:"docs-insert-label",children:"two-sided row"}),r.jsx("span",{className:"docs-insert-kw",children:"end:"})]}),r.jsx("div",{className:"docs-insert-divider"}),A.map((f,L)=>r.jsxs("div",{children:[L>0&&r.jsx("div",{className:"docs-insert-divider"}),r.jsx("div",{className:"docs-insert-category",children:f.category}),f.items.map(C=>r.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:()=>K(C.keyword),disabled:C.isReadOnly,title:C.description,children:[r.jsx("span",{className:"docs-insert-icon",children:Vt[C.category]?.icon||"•"}),r.jsx("span",{className:"docs-insert-label",children:C.label}),r.jsx("span",{className:"docs-insert-kw",children:C.isReadOnly?"locked":`.${C.keyword}`})]},C.keyword))]},f.category))]})]}),r.jsx(M,{onClick:ge,active:xe,title:"Two-sided row — set the text shown at the END of this line (end: property)",children:r.jsx(N.AlignHorizontalSpaceBetween,{size:16})})]})]}),a&&o?r.jsxs(r.Fragment,{children:[r.jsx(ot,{}),r.jsx(X,{label:"Trust",children:r.jsx(In,{content:n,onChange:o,trust:a,intact:m})})]}):p&&r.jsxs(r.Fragment,{children:[r.jsx(ot,{}),r.jsxs(X,{label:"Trust",children:[r.jsx(M,{onClick:()=>p("seal"),disabled:d,title:"Seal — freeze the document with a tamper-evident hash",children:r.jsx("span",{className:"ribbon-btn-text",children:"Seal"})}),r.jsx(M,{onClick:()=>p("sign"),title:"Sign",children:r.jsx("span",{className:"ribbon-btn-text",children:"Sign"})}),r.jsx(M,{onClick:()=>p("verify"),title:"Verify",children:r.jsx("span",{className:"ribbon-btn-text",children:"Verify"})})]})]})]})}const Yn={in:96,cm:96/2.54},Vn={in:.25,cm:.5};function fe(t,e){const s=Yn[e],n=Vn[e],o=[],c=t/s;for(let i=0;i<=c+1e-6;i+=n){const p=Math.abs(i-Math.round(i))<1e-6;o.push({x:i*s,kind:p?"major":"minor",label:p&&i>0?String(Math.round(i)):void 0})}return o}function Jn({geometry:t,zoom:e,scrollEl:s,onMargins:n,locked:o=!1}){const[c,i]=u.useState(0),[p,a]=u.useState(null),m=u.useRef(null);u.useEffect(()=>{const S=s.current;if(!S)return;const j=()=>i(S.scrollLeft);return j(),S.addEventListener("scroll",j,{passive:!0}),()=>S.removeEventListener("scroll",j)},[s]);const d=u.useMemo(()=>fe(t.width,t.unit),[t.width,t.unit]),h=u.useCallback(S=>j=>{!n||o||(j.preventDefault(),a(S))},[n,o]);u.useEffect(()=>{if(!p||!n)return;const S=b=>{const k=m.current;if(!k)return;const H=k.getBoundingClientRect(),E=(b.clientX-H.left)/e;if(p==="left"){const D=Math.max(0,Math.min(E,t.width/2));n({left:D})}else{const D=Math.max(0,Math.min(t.width-E,t.width/2));n({right:D})}},j=()=>a(null);return window.addEventListener("pointermove",S),window.addEventListener("pointerup",j),()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",j)}},[p,n,e,t.width]);const g=t.width*e,y=!!n&&!o;return r.jsx("div",{className:`docs-ruler${y?" docs-ruler--draggable":""}`,children:r.jsxs("div",{ref:m,className:"docs-ruler-track",style:{width:g,transform:`translateX(${-c}px)`},children:[r.jsx("div",{className:"docs-ruler-margin",style:{left:0,width:t.marginLeft*e}}),r.jsx("div",{className:"docs-ruler-margin",style:{right:0,width:t.marginRight*e}}),d.map((S,j)=>S.label?r.jsx("span",{className:"docs-ruler-num",style:{left:S.x*e},children:S.label},j):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--${S.kind}`,style:{left:S.x*e}},j)),y&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--h${p==="left"?" dragging":""}`,style:{left:t.marginLeft*e},onPointerDown:h("left"),title:"Drag to set the left margin"}),r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--h${p==="right"?" dragging":""}`,style:{left:(t.width-t.marginRight)*e},onPointerDown:h("right"),title:"Drag to set the right margin"})]})]})})}function Qn({geometry:t,zoom:e,scrollEl:s,onMargins:n,locked:o=!1,topOffset:c=0}){const[i,p]=u.useState(0),[a,m]=u.useState(null),d=u.useRef(null);u.useEffect(()=>{const b=s.current;if(!b)return;const k=()=>p(b.scrollTop);return k(),b.addEventListener("scroll",k,{passive:!0}),()=>b.removeEventListener("scroll",k)},[s]);const h=t.autoHeight?t.width*1.414:t.height,g=u.useMemo(()=>fe(h,t.unit),[h,t.unit]),y=u.useCallback(b=>k=>{!n||o||t.autoHeight||(k.preventDefault(),m(b))},[n,o,t.autoHeight]);u.useEffect(()=>{if(!a||!n)return;const b=H=>{const E=d.current;if(!E)return;const D=E.getBoundingClientRect(),F=(H.clientY-D.top)/e;if(a==="top"){const O=Math.max(0,Math.min(F,h/2));n({top:O})}else{const O=Math.max(0,Math.min(h-F,h/2));n({bottom:O})}},k=()=>m(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",k),()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",k)}},[a,n,e,h]);const S=h*e,j=!!n&&!o&&!t.autoHeight;return r.jsx("div",{className:"docs-ruler-v",children:r.jsxs("div",{ref:d,className:"docs-ruler-v-track",style:{height:S,transform:`translateY(${c-i}px)`},children:[r.jsx("div",{className:"docs-ruler-margin docs-ruler-margin--v",style:{top:0,height:t.marginTop*e}}),r.jsx("div",{className:"docs-ruler-margin docs-ruler-margin--v",style:{bottom:0,height:t.marginBottom*e}}),g.map((b,k)=>b.label?r.jsx("span",{className:"docs-ruler-num docs-ruler-num--v",style:{top:b.x*e},children:b.label},k):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--v docs-ruler-tick--${b.kind}`,style:{top:b.x*e}},k)),j&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${a==="top"?" dragging":""}`,style:{top:t.marginTop*e},onPointerDown:y("top"),title:"Drag to set the top margin"}),r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${a==="bottom"?" dragging":""}`,style:{top:(h-t.marginBottom)*e},onPointerDown:y("bottom"),title:"Drag to set the bottom margin"})]})]})})}function Lt(t,e){return e?`${t} (${e})`:t}function Xn({trust:t,intact:e}){if(t.isSealed){const s=t.sealedBy||"unknown",n=t.signatures[t.signatures.length-1]?.role;return r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--sealed",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"🔒"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Sealed"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["signed by ",Lt(s,n),t.sealedAt?` on ${t.sealedAt}`:""," · read-only"]}),e===!0&&r.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--ok",children:"hash verified ✓"}),e===!1&&r.jsx("span",{className:"docs-trust-banner__verify docs-trust-banner__verify--bad",children:"⚠ hash mismatch — content changed after sealing"})]})}if(t.signatures.length>0){const s=t.signatures.length;return r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--signed",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"✍"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Signed"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.signatures.map(n=>`${Lt(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]}),r.jsxs("span",{className:"docs-trust-banner__warn",children:["⚠ Editing will break ",s," signature",s===1?"":"s"]})]})}return t.approvals.length>0?r.jsxs("div",{className:"docs-trust-banner docs-trust-banner--approved",role:"status",children:[r.jsx("span",{className:"docs-trust-banner__icon",children:"✓"}),r.jsx("span",{className:"docs-trust-banner__title",children:"Approved"}),r.jsxs("span",{className:"docs-trust-banner__text",children:["by"," ",t.approvals.map(s=>`${Lt(s.by,s.role)}${s.at?` on ${s.at}`:""}`).join(" · ")]})]}):null}function Zn(t){let e;try{e=z.parseIntentText(t)}catch{return[]}const s=[],n=(o,c)=>{const i=c==null?"":String(c).trim();i&&s.push({key:o,value:i})};for(const o of e.blocks)switch(o.type){case"meta":for(const[c,i]of Object.entries(o.properties||{}))n(c,i);break;case"track":n("tracked",o.properties?.id??o.content);break;case"page":{const c=o.properties?.orientation;n("page",[o.content,c].filter(Boolean).join(" · "));break}case"font":n("font",[o.content||o.properties?.family,o.properties?.size].filter(Boolean).join(" · "));break;case"header":n("header",o.content);break;case"footer":n("footer",o.content);break;case"watermark":n("watermark",o.content);break}return s}function ts({source:t}){const[e,s]=u.useState(!1),n=u.useMemo(()=>Zn(t),[t]);if(n.length===0)return null;const o=n.slice(0,4).map(c=>`${c.key}: ${c.value}`).join(" · ");return r.jsxs("div",{className:`docs-props-bar${e?" open":""}`,children:[r.jsxs("button",{className:"docs-props-toggle",onClick:()=>s(c=>!c),title:e?"Hide document properties":"Show document properties",children:[r.jsx("span",{className:"docs-props-caret",children:e?"▾":"▸"}),"Document properties",!e&&r.jsx("span",{className:"docs-props-summary",children:o})]}),e&&r.jsx("div",{className:"docs-props-chips",children:n.map((c,i)=>r.jsxs("span",{className:"docs-props-chip",children:[r.jsx("b",{children:c.key})," ",c.value]},`${c.key}-${i}`))})]})}function B(t,e,s=""){const n=t?.properties?.[e];return n!=null?String(n):s}function Et(t){const e={lifecycle:"draft",isTracked:!1,trackBlock:null,approvals:[],signatures:[],isSealed:!1,sealedBy:null,sealedAt:null,sealHash:null,amendments:[]};if(!t)return e;const s=t.blocks,n=s.find(a=>a.type==="track");n&&(e.isTracked=!0,e.lifecycle="tracked",e.trackBlock={id:B(n,"id",n.content??""),by:B(n,"by"),at:B(n,"at")});const o=s.filter(a=>a.type==="approve");for(const a of o)e.approvals.push({by:B(a,"by",a.content??""),role:B(a,"role"),at:B(a,"at"),note:B(a,"note")||void 0});e.approvals.length>0&&(e.lifecycle="approved");const c=s.filter(a=>a.type==="sign");for(const a of c)e.signatures.push({by:B(a,"by",a.content??""),role:B(a,"role"),at:B(a,"at")});e.signatures.length>0&&(e.lifecycle="signed");const i=s.find(a=>a.type==="freeze");if(i){e.isSealed=!0,e.lifecycle="sealed";const a=e.signatures[e.signatures.length-1];e.sealedBy=a?.by||B(i,"by",i.content??""),e.sealedAt=B(i,"at")||a?.at||"",e.sealHash=B(i,"hash")}const p=s.filter(a=>a.type==="amendment");for(const a of p)e.amendments.push({section:B(a,"section",a.content??""),was:B(a,"was"),now:B(a,"now"),by:B(a,"by"),ref:B(a,"ref"),at:B(a,"at")});return e}const ee=new gt.PluginKey("template-highlight"),wt=/\{\{[^}]+\}\}/g;function ne(t){const e=[];return t.descendants((s,n)=>{if(!s.isText||!s.text)return;wt.lastIndex=0;let o;for(;o=wt.exec(s.text);)e.push(dt.Decoration.inline(n+o.index,n+o.index+o[0].length,{class:"it-doc-var"}))}),dt.DecorationSet.create(t,e)}const es=T.Extension.create({name:"templateHighlight",addProseMirrorPlugins(){return[new gt.Plugin({key:ee,state:{init:(t,e)=>ne(e.doc),apply:(t,e)=>t.docChanged?ne(t.doc):e},props:{decorations(t){return ee.getState(t)}}})]}});function ns(t){const e=new Set,s=[];wt.lastIndex=0;let n;for(;n=wt.exec(t);){const o=n[0].slice(2,-2).trim();/^(page|pages|date|time|year)$/i.test(o)||e.has(o)||(e.add(o),s.push(o))}return s}function ss(t){const e={};for(const s of t){const n=s.split(".");let o=e;for(let c=0;c<n.length;c++){const i=n[c];c===n.length-1?i in o||(o[i]=""):((!(i in o)||typeof o[i]!="object"||o[i]===null)&&(o[i]={}),o=o[i])}}return e}function rs(t,e,s){const n=t.coordsAtPos(e),o=n.top+1,c=n.bottom-1,i=s==="start"?-1:1;let p=e,a=e;for(let m=0;m<1e5;m++){const d=p+i;if(d<0||d>t.state.doc.content.size)break;let h;try{h=t.coordsAtPos(d)}catch{break}if(h.bottom<=o||h.top>=c)break;p=d,a=d}return a}const os=T.Extension.create({name:"lineKeymap",addKeyboardShortcuts(){const t=(e,s)=>{const{view:n}=this.editor,{state:o}=n,{selection:c}=o,i=c.head,p=rs(n,i,e);if(p==null||p===i)return!1;const a=o.doc.resolve(p),m=s?c.anchor:p,d=o.tr.setSelection(s?gt.TextSelection.between(o.doc.resolve(m),a):gt.TextSelection.near(a));return n.dispatch(d.scrollIntoView()),!0};return{Home:()=>t("start",!1),End:()=>t("end",!1),"Shift-Home":()=>t("start",!0),"Shift-End":()=>t("end",!0)}}}),is=28,as={title:[".it-doc-title"],summary:[".it-doc-summary"],section:[".it-doc-section"],sub:[".it-doc-sub"],text:["p"],quote:[".it-doc-quote"],callout:[".it-doc-callout"],info:[".it-doc-callout"],table:[".it-doc-table th",".it-doc-table td"],"table-header":[".it-doc-table th"],metric:[".it-doc-metric"],contact:['.it-doc-generic[data-keyword="contact"]'],divider:[".it-doc-divider"]};function cs({value:t,onChange:e,theme:s,onThemeChange:n,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:i=!0,onTrustAction:p}){const a=u.useRef(""),m=u.useRef(!1),d=u.useRef(!0),[h,g]=u.useState([]),y=u.useRef(kt("")),[S,j]=u.useState(1),b=Ft.useEditor({extensions:[Ye.configure({geometry:()=>y.current,gap:is,onPages:j}),$e.default.configure({heading:!1,codeBlock:!1,blockquote:!1,horizontalRule:!1,paragraph:!1}),Rn,zn,os,Me.default,we.TextStyle,Ee.default,Re.default.configure({multicolor:!0}),ze.default.configure({types:["paragraph","itTitle","itSummary","itSection","itSub"]}),He.default,Be,Pe.default,De.default,hn,mn,bn,yn,xn,Sn,kn,vn,jn,wn,Tn,Nn,Cn,An,Ln,_n,es],content:vt(t),onUpdate:({editor:x})=>{if(d.current)return;const w=x.getJSON(),A=Pt(w);a.current=A,m.current=!0,g(an(w)),e(A)},editorProps:{attributes:{class:"docs-page-content",spellcheck:"true"}}});u.useEffect(()=>{const x=window.setTimeout(()=>{d.current=!1,a.current=t},0);return()=>window.clearTimeout(x)},[]),u.useEffect(()=>{if(b){if(m.current){m.current=!1;return}if(t!==a.current){const x=vt(t);b.commands.setContent(x),a.current=t}}},[t,b]),u.useEffect(()=>{if(!b)return;const x=w=>{const A=w.detail;A&&b.chain().focus().insertContent(A).run()};return window.addEventListener("it-insert-text",x),()=>window.removeEventListener("it-insert-text",x)},[b]);const k=u.useMemo(()=>kt(t),[t]);u.useEffect(()=>{y.current=k,b?.view.dispatch(b.state.tr)},[k,b]);const H=u.useRef(null),E=u.useCallback(()=>b?b.storage.characterCount?.words?.()??b.getText().split(/\s+/).filter(Boolean).length:0,[b]),D=u.useMemo(()=>{if(!s)return"";try{const x=z.getBuiltinTheme(s);return x?z.generateThemeCSS(x).replace(/:root\{/,".docs-page{"):""}catch{return""}},[s]),F=u.useMemo(()=>{try{const x=z.parseIntentText(t),w=x.blocks.find(G=>G.type==="header")?.content||"",A=x.blocks.find(G=>G.type==="footer")?.content||"",U=x.metadata?.meta,K=String(x.metadata?.language||"").toLowerCase(),Q=String(U?.dir||(K==="rtl"?"rtl":"")||"ltr").toLowerCase();return{header:w,footer:A,dir:Q}}catch{return{header:"",footer:"",dir:"ltr"}}},[t]),O=u.useMemo(()=>{try{return Et(z.parseIntentText(t))}catch{return Et(null)}},[t]),W=u.useMemo(()=>{if(!O.isSealed)return null;try{return z.verifyDocument(t).intact}catch{return null}},[t,O.isSealed]),_=O.isSealed||o;u.useEffect(()=>{b&&b.isEditable!==!_&&b.setEditable(!_)},[b,_]),u.useEffect(()=>{if(!b)return;b.view.dom.setAttribute("dir",F.dir==="rtl"?"rtl":"ltr")},[b,F.dir]);const P=u.useMemo(()=>{try{return z.documentStyleCSS(z.parseIntentText(t),as,".docs-page .tiptap ")}catch{return""}},[t]);u.useEffect(()=>{let x=document.getElementById("it-doc-style-rules");x||(x=document.createElement("style"),x.id="it-doc-style-rules",document.head.appendChild(x)),x.textContent=P},[P]);const V=u.useCallback(()=>{if(b){const{from:w,to:A}=b.state.selection;let U=0,K=!1;if(b.state.doc.nodesBetween(w,A,G=>{if(G.isTextblock){U++;const ut=G.attrs?.dir,mt=(()=>{try{return G.attrs?.props?JSON.parse(G.attrs.props).dir:void 0}catch{return}})();return(ut==="rtl"||mt==="rtl")&&(K=!0),!1}return!0}),w!==A&&U>=1){b.chain().focus().setBlockProp("dir",K?null:"rtl").run();return}}const x=F.dir==="rtl";e(z.upsertMetaProperty(t,"dir",x?null:"rtl"))},[b,t,e,F.dir]),J=u.useCallback(x=>{const w=y.current,A=mt=>Math.max(0,Math.round(mt/Z*10)/10),U=A(x.top??w.marginTop),K=A(x.right??w.marginRight),Q=A(x.bottom??w.marginBottom),G=A(x.left??w.marginLeft),ut=`${U}mm ${K}mm ${Q}mm ${G}mm`;e(We(t,ut))},[t,e]);u.useEffect(()=>{const x="it-editor-theme-css";let w=document.getElementById(x);w||(w=document.createElement("style"),w.id=x,document.head.appendChild(w)),w.textContent=D},[D]);const q=u.useRef(null),[v,I]=u.useState(1),R=u.useRef(v),ct=u.useRef(null),ht=u.useCallback(x=>{const w=q.current;if(!w)return;const A=w.getBoundingClientRect();ct.current={cx:w.scrollLeft+(x.clientX-A.left),cy:w.scrollTop+(x.clientY-A.top)}},[]),nt=u.useCallback(()=>{const x=q.current;x&&(ct.current={cx:x.scrollLeft+x.clientWidth/2,cy:x.scrollTop+x.clientHeight/2})},[]);return u.useLayoutEffect(()=>{const x=q.current,w=ct.current,A=R.current;if(!x||!w||A===v)return;const U=v/A;x.getBoundingClientRect();const K=w.cx-x.scrollLeft,Q=w.cy-x.scrollTop;x.scrollLeft=w.cx*U-K,x.scrollTop=w.cy*U-Q,ct.current=null,R.current=v},[v]),u.useEffect(()=>{const x=w=>{if(w.metaKey||w.ctrlKey){if(w.key==="p"||w.key==="P"){w.preventDefault(),Bt(t,s);return}w.key==="="||w.key==="+"?(w.preventDefault(),nt(),I(A=>Math.min(2,+(A+.1).toFixed(2)))):w.key==="-"?(w.preventDefault(),nt(),I(A=>Math.max(.25,+(A-.1).toFixed(2)))):w.key==="0"&&(w.preventDefault(),nt(),I(1))}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[nt,t,s]),u.useEffect(()=>{const x=q.current;if(!x)return;const w=A=>{if(A.ctrlKey||A.metaKey){A.preventDefault();const U=A.deltaY>0?-.1:.1;ht(A),I(K=>Math.min(2,Math.max(.25,+(K+U).toFixed(2))))}};return x.addEventListener("wheel",w,{passive:!1}),()=>x.removeEventListener("wheel",w)},[ht]),r.jsxs("div",{className:"docs-container",children:[c&&r.jsx(Kn,{editor:b,isRtl:F.dir==="rtl",onToggleRtl:V,content:t,onChange:e,theme:s,onThemeChange:n,onTrustAction:p,trust:O,sealIntact:W,locked:_}),i&&r.jsx(Xn,{trust:O,intact:W}),i&&r.jsx(ts,{source:t}),h.length>0&&r.jsxs("div",{className:"docs-fidelity-warning",role:"status",children:["⚠ Some formatting (",h.join(", "),") can’t be saved to"," ",r.jsx("code",{children:".it"})," and won’t appear when printed through the template — remove it or use the toolbar’s color/size/style controls instead."]}),r.jsx(Jn,{geometry:k,zoom:v,scrollEl:q,onMargins:J,locked:_}),r.jsxs("div",{className:"docs-canvas-row",children:[r.jsx(Qn,{geometry:k,zoom:v,scrollEl:q,onMargins:J,locked:_}),r.jsxs("div",{className:"docs-canvas",ref:q,children:[r.jsx("div",{className:"docs-page-scaler",style:{width:k.width*v},children:r.jsx("div",{className:"docs-page-flow",dir:F.dir,style:{transform:v!==1?`scale(${v})`:void 0,transformOrigin:"top left"},children:r.jsxs("div",{className:"docs-page docs-sheet",ref:H,style:{width:k.width,minHeight:k.autoHeight?k.width:void 0,"--page-mx-l":`${k.marginLeft}px`,"--page-mx-r":`${k.marginRight}px`},children:[r.jsx("div",{className:"docs-sheet-header","data-it-spacer":"",style:{height:k.autoHeight?void 0:k.marginTop},children:r.jsx("div",{className:"docs-pb-header",children:r.jsx("span",{className:"docs-pb-text",children:k.autoHeight?"":Rt(k.header,1,S)})})}),r.jsx(Ft.EditorContent,{editor:b})]})})}),r.jsxs("div",{className:"docs-page-footer",children:[S," ",S===1?"page":"pages"," ·"," ",E()," words",v!==1&&r.jsxs("span",{className:"zoom-indicator",children:[" ","· ",Math.round(v*100),"%"]})]})]})]})]})}const ls="corporate";function ds({value:t,onChange:e,theme:s,onThemeChange:n,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:i=!0,onTrustAction:p}){const[a,m]=u.useState(s??ls),d=s??a,h=u.useCallback(g=>{m(g),n?.(g)},[n]);return r.jsx(cs,{value:t,onChange:e,theme:d,onThemeChange:h,readOnly:o,showRibbon:c,showTrustBanner:i,onTrustAction:p})}exports.IntentTextEditor=ds;exports.buildSampleSkeleton=ss;exports.builtinThemes=pe;exports.docToSource=Pt;exports.downloadItFile=ue;exports.exportDocumentHTML=Dn;exports.exportDocumentPDF=Bt;exports.extractTemplateVariables=ns;exports.extractTrustState=Et;exports.getPageGeometry=kt;exports.printHtmlViaIframe=ae;exports.resolvePageTokens=Rt;exports.sourceToDoc=vt;
|
|
32
32
|
//# sourceMappingURL=index.cjs.map
|