@dotit/editor 1.2.0 → 1.2.1

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.
@@ -1,7 +1,7 @@
1
1
  import { Extension } from "@tiptap/core";
2
2
  import type { Editor } from "@tiptap/core";
3
3
  /** Core property keys managed by the paragraph-level commands. */
4
- export type BlockPropKey = "leading" | "space-before" | "space-after" | "end";
4
+ export type BlockPropKey = "leading" | "space-before" | "space-after" | "end" | "dir";
5
5
  /**
6
6
  * Extended Paragraph: a core `text:`/prose block. Adds the four core block
7
7
  * properties as attributes and renders the `end:` value as the second side of
package/dist/index.cjs CHANGED
@@ -1,32 +1,32 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),Bt=require("@tiptap/react"),xe=require("@tiptap/starter-kit"),Se=require("@tiptap/extension-underline"),ke=require("@tiptap/extension-text-style"),ve=require("@tiptap/extension-color"),we=require("@tiptap/extension-highlight"),je=require("@tiptap/extension-text-align"),Te=require("@tiptap/extension-font-family"),Ne=require("@tiptap/extension-subscript"),Ce=require("@tiptap/extension-superscript"),j=require("@tiptap/core"),ut=require("@tiptap/pm/state"),ct=require("@tiptap/pm/view"),R=require("@dotit/core"),Ae=require("@tiptap/extension-paragraph"),T=require("lucide-react"),Z=t=>t&&t.__esModule?t:{default:t},Le=Z(xe),_e=Z(Se),$e=Z(ve),Me=Z(we),Ee=Z(je),Re=Z(Te),ze=Z(Ne),He=Z(Ce),Pe=Z(Ae),De=j.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]+/g,"")||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Q=96/25.4,yt={A4:[210,297],A5:[148,210],A3:[297,420],Letter:[215.9,279.4],Legal:[215.9,355.6],Tabloid:[279.4,431.8]},Ie={A4:"cm",A5:"cm",A3:"cm",LETTER:"in",LEGAL:"in",TABLOID:"in"},Be=20,Oe=4,Fe=120;function At(t){const e=/^(-?\d+(?:\.\d+)?)\s*(mm|cm|in|px|pt)?$/.exec(t.trim());if(!e)return null;const n=parseFloat(e[1]);switch(e[2]||"mm"){case"mm":return n*Q;case"cm":return n*10*Q;case"in":return n*96;case"pt":return n/72*96;case"px":return n;default:return null}}function qe(t,e){const n=t.trim().split(/\s+/).map(At);if(n.some(o=>o===null)||n.length===0)return[e,e,e,e];const s=n;return s.length===1?[s[0],s[0],s[0],s[0]]:s.length===2?[s[0],s[1],s[0],s[1]]:s.length===3?[s[0],s[1],s[2],s[1]]:[s[0],s[1],s[2],s[3]]}function xt(t){let e="A4",n,s="",o="";try{const w=R.parseIntentText(t),x=w.blocks.find(z=>z.type==="page")?.properties||{};x.size&&(e=String(x.size)),n=x.margin??x.margins,s=w.blocks.find(z=>z.type==="header")?.content||String(x.header||""),o=w.blocks.find(z=>z.type==="footer")?.content||String(x.footer||"")}catch{}let c=yt.A4[0]*Q,a=yt.A4[1]*Q,d=!1,i="cm";const m=yt[e]||yt[e.toUpperCase?.()];if(m)c=m[0]*Q,a=m[1]*Q,i=Ie[e.toUpperCase()]||"cm";else{const w=e.trim().split(/\s+/),y=w[0]?At(w[0]):null;if(y&&(c=y),/(\d)\s*in\b/.test(e)&&(i="in"),w[1]==="auto")d=!0,a=1/0;else{const x=w[1]?At(w[1]):null;x&&(a=x)}}const u=(c<=Fe*Q?Oe:Be)*Q,[h,g,b,k]=n?qe(n,u):[u,u,u,u];return{width:c,height:a,autoHeight:d,marginTop:h,marginRight:g,marginBottom:b,marginLeft:k,contentHeight:d?1/0:a-h-b,header:s,footer:o,unit:i}}function Ue(t,e){const n=t.split(`
2
- `),s=n.findIndex(a=>/^\s*page\s*:/i.test(a));if(s>=0){let a=n[s].replace(/\s*\|\s*margins?\s*:[^|]*/gi,"").replace(/\s+$/,"");return a=`${a} | margin: ${e}`,n[s]=a,n.join(`
3
- `)}const o=n.findIndex(a=>a.trim()&&!/^\s*(meta|title|summary)\s*:/i.test(a)),c=`page: A4 | margin: ${e}`;return o<=0?`${c}
4
- ${t}`:(n.splice(o,0,c),n.join(`
5
- `))}function Et(t,e,n){return t.replace(/\{\{\s*page\s*\}\}/g,String(e)).replace(/\{\{\s*pages\s*\}\}/g,String(n))}const ft=new ut.PluginKey("pagination");function wt(t,e,n,s){const o=Et(e,n,s);return`<div class="docs-pb-${t}">
6
- <span class="docs-pb-text">${We(o)}</span>
7
- </div>`}function We(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Ge=j.Extension.create({name:"pagination",addOptions(){return{geometry:()=>({width:794,height:1122.52,autoHeight:!1,marginTop:75.59,marginRight:75.59,marginBottom:75.59,marginLeft:75.59,contentHeight:971.34,header:"",footer:""}),gap:28,onPages:void 0}},addProseMirrorPlugins(){const t=this.options;return[new ut.Plugin({key:ft,state:{init:()=>ct.DecorationSet.empty,apply(e,n){const s=e.getMeta(ft);return s||n.map(e.mapping,e.doc)}},props:{decorations(e){return ft.getState(e)}},view(e){let n=0,s="";const o=(i,m,u,h)=>{const g=document.createElement("div");return g.className="docs-page-spacer",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${i.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${i.marginRight}px`),g.innerHTML=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("react"),Ft=require("@tiptap/react"),ke=require("@tiptap/starter-kit"),ve=require("@tiptap/extension-underline"),we=require("@tiptap/extension-text-style"),je=require("@tiptap/extension-color"),Te=require("@tiptap/extension-highlight"),Ne=require("@tiptap/extension-text-align"),Ce=require("@tiptap/extension-font-family"),Ae=require("@tiptap/extension-subscript"),Le=require("@tiptap/extension-superscript"),T=require("@tiptap/core"),gt=require("@tiptap/pm/state"),dt=require("@tiptap/pm/view"),z=require("@dotit/core"),_e=require("@tiptap/extension-paragraph"),N=require("lucide-react"),et=t=>t&&t.__esModule?t:{default:t},$e=et(ke),Me=et(ve),Ee=et(je),Re=et(Te),ze=et(Ne),He=et(Ce),Pe=et(Ae),De=et(Le),Ie=et(_e),Be=T.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]+/g,"")||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Z=96/25.4,St={A4:[210,297],A5:[148,210],A3:[297,420],Letter:[215.9,279.4],Legal:[215.9,355.6],Tabloid:[279.4,431.8]},Oe={A4:"cm",A5:"cm",A3:"cm",LETTER:"in",LEGAL:"in",TABLOID:"in"},Fe=20,qe=4,Ue=120;function _t(t){const e=/^(-?\d+(?:\.\d+)?)\s*(mm|cm|in|px|pt)?$/.exec(t.trim());if(!e)return null;const s=parseFloat(e[1]);switch(e[2]||"mm"){case"mm":return s*Z;case"cm":return s*10*Z;case"in":return s*96;case"pt":return s/72*96;case"px":return s;default:return null}}function Ge(t,e){const s=t.trim().split(/\s+/).map(_t);if(s.some(o=>o===null)||s.length===0)return[e,e,e,e];const n=s;return n.length===1?[n[0],n[0],n[0],n[0]]:n.length===2?[n[0],n[1],n[0],n[1]]:n.length===3?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]}function kt(t){let e="A4",s,n="",o="";try{const j=z.parseIntentText(t),k=j.blocks.find(H=>H.type==="page")?.properties||{};k.size&&(e=String(k.size)),s=k.margin??k.margins,n=j.blocks.find(H=>H.type==="header")?.content||String(k.header||""),o=j.blocks.find(H=>H.type==="footer")?.content||String(k.footer||"")}catch{}let c=St.A4[0]*Z,i=St.A4[1]*Z,p=!1,a="cm";const m=St[e]||St[e.toUpperCase?.()];if(m)c=m[0]*Z,i=m[1]*Z,a=Oe[e.toUpperCase()]||"cm";else{const j=e.trim().split(/\s+/),b=j[0]?_t(j[0]):null;if(b&&(c=b),/(\d)\s*in\b/.test(e)&&(a="in"),j[1]==="auto")p=!0,i=1/0;else{const k=j[1]?_t(j[1]):null;k&&(i=k)}}const d=(c<=Ue*Z?qe:Fe)*Z,[h,g,y,S]=s?Ge(s,d):[d,d,d,d];return{width:c,height:i,autoHeight:p,marginTop:h,marginRight:g,marginBottom:y,marginLeft:S,contentHeight:p?1/0:i-h-y,header:n,footer:o,unit:a}}function We(t,e){const s=t.split(`
2
+ `),n=s.findIndex(i=>/^\s*page\s*:/i.test(i));if(n>=0){let i=s[n].replace(/\s*\|\s*margins?\s*:[^|]*/gi,"").replace(/\s+$/,"");return i=`${i} | margin: ${e}`,s[n]=i,s.join(`
3
+ `)}const o=s.findIndex(i=>i.trim()&&!/^\s*(meta|title|summary)\s*:/i.test(i)),c=`page: A4 | margin: ${e}`;return o<=0?`${c}
4
+ ${t}`:(s.splice(o,0,c),s.join(`
5
+ `))}function Rt(t,e,s){return t.replace(/\{\{\s*page\s*\}\}/g,String(e)).replace(/\{\{\s*pages\s*\}\}/g,String(s))}const bt=new gt.PluginKey("pagination");function Tt(t,e,s,n){const o=Rt(e,s,n);return`<div class="docs-pb-${t}">
6
+ <span class="docs-pb-text">${Ke(o)}</span>
7
+ </div>`}function Ke(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Ye=T.Extension.create({name:"pagination",addOptions(){return{geometry:()=>({width:794,height:1122.52,autoHeight:!1,marginTop:75.59,marginRight:75.59,marginBottom:75.59,marginLeft:75.59,contentHeight:971.34,header:"",footer:""}),gap:28,onPages:void 0}},addProseMirrorPlugins(){const t=this.options;return[new gt.Plugin({key:bt,state:{init:()=>dt.DecorationSet.empty,apply(e,s){const n=e.getMeta(bt);return n||s.map(e.mapping,e.doc)}},props:{decorations(e){return bt.getState(e)}},view(e){let s=0,n="";const o=(a,m,d,h)=>{const g=document.createElement("div");return g.className="docs-page-spacer",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${a.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${a.marginRight}px`),g.innerHTML=`
8
8
  <div class="docs-pb-fill" style="height:${m}px"></div>
9
- <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${i.marginBottom}px">
10
- ${wt("footer",i.footer,u,h)}
9
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${a.marginBottom}px">
10
+ ${Tt("footer",a.footer,d,h)}
11
11
  </div>
12
12
  <div class="docs-pb-gap" style="height:${t.gap}px"></div>
13
- <div class="docs-pb-margin docs-pb-margin-top" style="height:${i.marginTop}px">
14
- ${wt("header",i.header,u+1,h)}
15
- </div>`,g},c=(i,m,u,h)=>{const g=document.createElement("div");return g.className="docs-page-spacer docs-page-tail",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${i.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${i.marginRight}px`),g.innerHTML=`
13
+ <div class="docs-pb-margin docs-pb-margin-top" style="height:${a.marginTop}px">
14
+ ${Tt("header",a.header,d+1,h)}
15
+ </div>`,g},c=(a,m,d,h)=>{const g=document.createElement("div");return g.className="docs-page-spacer docs-page-tail",g.contentEditable="false",g.setAttribute("data-it-spacer",""),g.style.setProperty("--pb-mx-l",`${a.marginLeft}px`),g.style.setProperty("--pb-mx-r",`${a.marginRight}px`),g.innerHTML=`
16
16
  <div class="docs-pb-fill" style="height:${m}px"></div>
17
- <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${i.marginBottom}px">
18
- ${wt("footer",i.footer,u,h)}
19
- </div>`,g},a=()=>{const i=t.geometry(),m=e.dom,u=e.state.doc;if(i.autoHeight){s!=="auto"&&(s="auto",e.dispatch(e.state.tr.setMeta(ft,ct.DecorationSet.empty)),t.onPages?.(1));return}const h=m.getBoundingClientRect().top,g=Array.from(m.children),b=[];let k=0;for(const _ of g){if(_.hasAttribute?.("data-it-spacer")){k+=_.offsetHeight;continue}const H=_.getBoundingClientRect();b.push({natTop:H.top-h-k,natBottom:H.bottom-h-k})}const w=[];let y=0,x=b.length?b[0].natTop:0,z=x;for(let _=0;_<b.length&&_<u.childCount;_++){const H=b[_],G=u.child(_).nodeSize;H.natTop>x&&H.natBottom-x>i.contentHeight&&(w.push({pos:y,rest:Math.max(0,i.contentHeight-(H.natTop-x))}),x=H.natTop),z=H.natBottom,y+=G}const D=w.length+1,F=Math.max(0,i.contentHeight-(z-x)),P=w.map(_=>`${_.pos}:${Math.round(_.rest)}`).join(",")+`|${Math.round(F)}|${D}|${i.header}|${i.footer}|${Math.round(i.contentHeight)}`;if(P===s)return;s=P;const I=w.map((_,H)=>ct.Decoration.widget(_.pos,()=>o(i,_.rest,H+1,D),{side:-1,key:`pb-${H+1}-${Math.round(_.rest)}`}));I.push(ct.Decoration.widget(u.content.size,()=>c(i,F,D,D),{side:1,key:`pb-tail-${D}-${Math.round(F)}`}));const K=ct.DecorationSet.create(e.state.doc,I);e.dispatch(e.state.tr.setMeta(ft,K)),t.onPages?.(D)},d=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(a)};return d(),{update:d,destroy:()=>cancelAnimationFrame(n)}}})]}}),Ot=new Set(["tip","info","warning","danger","success"]),Ke=new Set(["page","meta","font","header","footer","watermark"]),Ye=new Set(["sign","seal","approve","freeze","amend","amendment"]),Ft={title:"itTitle",section:"itSection",sub:"itSub"},Ve={note:"text","body-text":"text"},Je=new Set(["weight","italic","underline","strike","color","family","size","bg","valign","align","style","font","bgcolor"]);function Qe(t){if(!t||t==="{}")return{};try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}function W(t,e){const n=Object.entries(t).filter(([s,o])=>o!==void 0&&o!==""&&(!e||!e.has(s)));return n.length===0?"":" | "+n.map(([s,o])=>`${s}: ${o}`).join(" | ")}function Lt(t){if(!t)return[];const e=t.split("\\n"),n=[];return e.forEach((s,o)=>{s&&n.push({type:"text",text:s}),o<e.length-1&&n.push({type:"hardBreak"})}),n}function Xe(t){switch(t.type){case"bold":return[{type:"bold"}];case"italic":return[{type:"italic"}];case"strike":return[{type:"strike"}];case"code":return[{type:"code"}];case"highlight":return[{type:"highlight"}];case"styled":{const e=t.props||{},n=[],s={};return e.weight&&e.weight!=="normal"&&n.push({type:"bold"}),e.italic==="true"&&n.push({type:"italic"}),e.underline==="true"&&n.push({type:"underline"}),e.strike==="true"&&n.push({type:"strike"}),e.color&&(s.color=e.color),e.family&&(s.fontFamily=e.family),e.size&&(s.fontSize=e.size),Object.keys(s).length&&n.push({type:"textStyle",attrs:s}),e.bg&&n.push({type:"highlight",attrs:{color:e.bg}}),e.valign==="sub"&&n.push({type:"subscript"}),e.valign==="super"&&n.push({type:"superscript"}),n.length?n:null}default:return null}}const Ze=new Set(["text","bold","italic","strike","highlight","styled"]);function tn(t,e){if(!t||t.length===0||t.every(s=>s.type==="text")||!t.every(s=>Ze.has(s.type)))return Lt(e);const n=[];for(const s of t){const o=Xe(s),a=(s.value??"").split("\\n");a.forEach((d,i)=>{d&&n.push(o?{type:"text",text:d,marks:o}:{type:"text",text:d}),i<a.length-1&&n.push({type:"hardBreak"})})}return n.length?n:Lt(e)}function en(t,e){if(!e||t.length===0)return t;const n=[],s={},o=e,c=o.family??o.font,a=o.bg??o.bgcolor;return String(o.weight||"").toLowerCase()==="bold"&&n.push({type:"bold"}),(String(o.italic||"")==="true"||String(o.style||"").toLowerCase()==="italic")&&n.push({type:"italic"}),String(o.underline||"")==="true"&&n.push({type:"underline"}),String(o.strike||"")==="true"&&n.push({type:"strike"}),String(o.valign||"")==="sub"&&n.push({type:"subscript"}),String(o.valign||"")==="super"&&n.push({type:"superscript"}),o.color&&(s.color=String(o.color)),c&&(s.fontFamily=String(c)),o.size&&(s.fontSize=String(o.size)),a&&n.push({type:"highlight",attrs:{color:String(a)}}),Object.keys(s).length>0&&n.push({type:"textStyle",attrs:s}),n.length===0?t:t.map(d=>d.type==="text"?{...d,marks:[...d.marks||[],...n]}:d)}function te(t){const e={};for(const n of t||[])switch(n.type){case"bold":e.weight="bold";break;case"italic":e.italic="true";break;case"underline":e.underline="true";break;case"strike":e.strike="true";break;case"textStyle":n.attrs?.color&&(e.color=String(n.attrs.color)),n.attrs?.fontFamily&&(e.family=String(n.attrs.fontFamily)),n.attrs?.fontSize&&(e.size=String(n.attrs.fontSize));break;case"highlight":n.attrs?.color&&(e.bg=String(n.attrs.color));break;case"subscript":e.valign="sub";break;case"superscript":e.valign="super";break}return e}function nn(t){if(t.type==="hardBreak")return"\\n";if(t.type!=="text")return Rt(t);const e=t.text||"";if(!e)return"";const n=t.marks||[];if(!n.length)return e;const s=new Set(n.map(h=>h.type)),o=n.find(h=>h.type==="link");if(o?.attrs?.href)return`[${e}](${o.attrs.href})`;const c=n.find(h=>h.type==="textStyle")?.attrs||{},a=n.find(h=>h.type==="highlight")?.attrs||{},d=!!(c.color||c.fontFamily||c.fontSize||a.color),i=["bold","italic","strike","underline","code"].filter(h=>s.has(h)).length;if(!d&&i===1&&!s.has("underline")){if(s.has("bold"))return`*${e}*`;if(s.has("italic"))return`_${e}_`;if(s.has("strike"))return`~${e}~`;if(s.has("code"))return`\`${e}\``}if(!d&&i===0&&s.has("highlight")&&!a.color)return`^${e}^`;const m=te(n),u=[];return m.color&&u.push(`color: ${m.color}`),m.family&&u.push(`family: ${m.family}`),m.size&&u.push(`size: ${m.size}`),m.weight&&u.push(`weight: ${m.weight}`),m.italic==="true"&&u.push("italic: true"),m.underline&&u.push("underline: true"),m.strike&&u.push("strike: true"),m.bg&&u.push(`bg: ${m.bg}`),m.valign&&u.push(`valign: ${m.valign}`),u.length?`[${e}]{ ${u.join("; ")} }`:e}const sn=new Set(["bold","italic","underline","strike","code","highlight","textStyle","link","subscript","superscript"]);function rn(t){const e=new Set,n=s=>{for(const o of s.marks||[])sn.has(o.type)||e.add(o.type);for(const o of s.content||[])n(o)};return n(t),[...e].sort()}function _t(t){const e=t.content||[],n=t.attrs?.textAlign&&t.attrs.textAlign!=="left"?{align:String(t.attrs.textAlign)}:{};return e.length===1&&e[0].type==="text"?{text:e[0].text||"",props:{...te(e[0].marks),...n}}:{text:e.map(nn).join(""),props:{...n}}}function Rt(t){return t.content?t.content.map(e=>e.type==="text"?e.text||"":e.type==="hardBreak"?"\\n":Rt(e)).join(""):""}function at(t,e,n){const s=Qe(t);for(const o of Je)delete s[o];if(n)for(const o of n)delete s[o];return{...s,...e}}function zt(t){const e=t.toLowerCase();return Ve[e]||e}function qt(t){if(t==="---")return"divider";const e=t.match(/^([a-zA-Z][\w-]*):/);return e?zt(e[1]):null}function lt(t){return zt(t)}function dt(t,e){return!!(t===e||t==="info"&&["tip","warning","danger","success"].includes(e)||e==="info"&&["tip","warning","danger","success"].includes(t))}function on(t){if(!t)return{content:"",properties:{}};const e=t.split(" | ");let n=e[0]||"";const s={};for(let o=1;o<e.length;o++){const c=e[o],a=c.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);if(!a){n+=` | ${c}`;continue}s[a[1]]=a[2]}return{content:n,properties:s}}function Ut(t){if(t==="---")return{type:"divider"};const e=t.match(/^([a-zA-Z][\w-]*):\s*(.*)$/);if(!e)return null;const n=zt(e[1]),s=e[2]||"",{content:o,properties:c}=on(s);let a;try{a=R.parseIntentText(`text: ${o}`).blocks[0]?.inline}catch{a=void 0}return{type:n,content:o,properties:c,inline:a}}function Wt(t){const e=t.match(/^[-*]\s+(.*)$/);if(e)return{ordered:!1,text:e[1]};const n=t.match(/^\d+\.\s+(.*)$/);return n?{ordered:!0,text:n[1]}:null}function an(t){return{type:"listItem",content:[{type:"paragraph",content:Lt(t)}]}}function $t(t){if(!t.trim())return{type:"doc",content:[{type:"paragraph"}]};const e=R.parseIntentText(t),n=[];for(const a of e.blocks){const d=jt(a);d&&n.push(d)}const s=t.split(`
20
- `);let o=0;const c=[];for(let a=0;a<s.length;a++){const i=s[a].trim();if(!i)continue;{const g=qt(i);if(g&&Ke.has(g)){c.push({type:"itMeta",attrs:{raw:i}});const b=e.blocks[o]?.type;b&&dt(g,lt(b))&&o++;continue}if(g&&Ye.has(g)){c.push({type:"itTrust",attrs:{raw:i,keyword:g}});const b=e.blocks[o]?.type;b&&dt(g,lt(b))&&o++;continue}if(g==="metric"){c.push({type:"itMetric",attrs:{raw:i}});const b=e.blocks[o]?.type;b&&dt(g,lt(b))&&o++;continue}if(g==="style"){c.push({type:"itStyleRule",attrs:{raw:i}});const b=e.blocks[o]?.type;b&&dt(g,lt(b))&&o++;continue}}const m=Wt(i);if(m){const g=m.ordered,b=[];let k=a;for(;k<s.length;){const w=s[k].trim(),y=w?Wt(w):null;if(!y||y.ordered!==g)break;b.push(an(y.text));const x=e.blocks[o]?.type;(x==="list-item"||x==="step-item")&&o++,k++}c.push({type:g?"orderedList":"bulletList",content:b}),a=k-1;continue}if(i.startsWith("|")&&i.endsWith("|")&&(i.match(/\|/g)||[]).length>=3){const g=[];let b=a;for(;b<s.length;){const k=s[b].trim();if(!(k.startsWith("|")&&k.endsWith("|")))break;g.push(k.slice(1,-1).split("|").map(w=>w.trim())),b++}c.push({type:"itTable",attrs:{rows:JSON.stringify(g)}}),a=b-1;continue}if(i.startsWith("//")){c.push({type:"itComment",content:i.slice(2).trim()?[{type:"text",text:i.slice(2).trim()}]:[]});continue}if(i.startsWith("```"))continue;const u=qt(i);if(u&&(u==="text"||i.includes("{{"))){const g=Ut(i);if(g){const b=jt(g);if(b&&c.push(b),o<e.blocks.length){const k=lt(e.blocks[o].type);dt(u,k)&&o++}continue}}if(o<n.length&&u){const g=e.blocks[o],b=lt(g.type);if(dt(u,b)){c.push(n[o]),o++;continue}}const h=Ut(i);if(h){const g=jt(h);g&&c.push(g);continue}o<n.length&&(c.push(n[o]),o++)}for(;o<n.length;)c.push(n[o]),o++;return{type:"doc",content:c.length>0?c:[{type:"paragraph"}]}}function jt(t){const{type:e,content:n,properties:s,inline:o}=t,c=n||"";let a=tn(o,c);a=en(a,s);const d=s?JSON.stringify(Object.fromEntries(Object.entries(s).map(([u,h])=>[u,String(h)]))):"{}",i=s?.align?String(s.align):void 0;if(e in Ft)return{type:Ft[e],attrs:{props:d,...i&&{textAlign:i}},content:a.length?a:void 0};if(e==="summary")return{type:"itSummary",attrs:{props:d,...i&&{textAlign:i}},content:a.length?a:void 0};if(e==="text"||e==="body-text"){const u={};return i&&(u.textAlign=i),s?.end&&(u.end=String(s.end)),s?.leading&&(u.leading=String(s.leading)),s?.["space-before"]&&(u.spaceBefore=String(s["space-before"])),s?.["space-after"]&&(u.spaceAfter=String(s["space-after"])),{type:"paragraph",...Object.keys(u).length&&{attrs:u},content:a.length?a:void 0}}if(Ot.has(e)){const u=e==="info"?String(s?.type||"info").toLowerCase():e;return{type:"itCallout",attrs:{variant:Ot.has(u)?u:"info",props:d},content:a.length?a:void 0}}if(e==="quote")return{type:"itQuote",attrs:{by:s?.by?String(s.by):"",props:d,...i&&{textAlign:i}},content:a.length?a:void 0};if(e==="code")return{type:"itCode",attrs:{lang:s?.lang?String(s.lang):"",props:d},content:c?[{type:"text",text:c}]:void 0};if(e==="divider")return{type:"itDivider"};if(e==="break")return{type:"itBreak"};const m=s?Object.entries(s).filter(([,u])=>u!==void 0&&u!=="").map(([u,h])=>`${u}: ${h}`).join(" | "):"";return{type:"itGenericBlock",attrs:{keyword:e,properties:m,props:d},content:a.length?a:void 0}}function ee(t){if(!t.content)return"";const e=[];for(const n of t.content)e.push(...cn(n));return e.join(`
21
- `)}function cn(t){if(t.type==="bulletList"&&t.content)return t.content.flatMap(n=>n.content?n.content.map(s=>{const{text:o,props:c}=_t(s);return`- ${o}${W(c)}`}):[]);if(t.type==="orderedList"&&t.content){let n=1;return t.content.flatMap(s=>s.content?s.content.map(o=>{const{text:c,props:a}=_t(o);return`${n++}. ${c}${W(a)}`}):[])}const e=ln(t);return e!==null?[e]:[]}function ln(t){const{text:e,props:n}=_t(t);switch(t.type){case"itTitle":{const s=at(t.attrs?.props,n);return`title: ${e}${W(s)}`}case"itSummary":{const s=at(t.attrs?.props,n);return`summary: ${e}${W(s)}`}case"itSection":{const s=at(t.attrs?.props,n);return`section: ${e}${W(s)}`}case"itSub":{const s=at(t.attrs?.props,n);return`sub: ${e}${W(s)}`}case"paragraph":{const s=t.attrs||{},o={};return s.end&&(o.end=String(s.end)),s.leading&&(o.leading=String(s.leading)),s.spaceBefore&&(o["space-before"]=String(s.spaceBefore)),s.spaceAfter&&(o["space-after"]=String(s.spaceAfter)),`text: ${e}${W({...o,...n})}`}case"itCallout":{const s=t.attrs?.variant||"tip",o=at(t.attrs?.props,n,new Set(["variant"]));return s==="info"?`info: ${e}${W(o)}`:`info: ${e} | type: ${s}${W(o,new Set(["type"]))}`}case"itQuote":{const s=t.attrs?.by,o=s?` | by: ${s}`:"",c=at(t.attrs?.props,n,new Set(["by"]));return`quote: ${e}${o}${W(c)}`}case"itCode":return`\`\`\`${t.attrs?.lang||""}
22
- ${Rt(t)}
23
- \`\`\``;case"itDivider":return"divider:";case"itTable":{let s=[];try{s=JSON.parse(t.attrs?.rows||"[]")}catch{s=[]}return s.map(o=>`| ${o.join(" | ")} |`).join(`
24
- `)}case"itMeta":return t.attrs?.raw||"";case"itTrust":return t.attrs?.raw||"";case"itMetric":return t.attrs?.raw||"";case"itStyleRule":return t.attrs?.raw||"";case"itBreak":return"break:";case"itComment":return e?`// ${e}`:"//";case"itGenericBlock":{const s=t.attrs?.keyword||"text",o=at(t.attrs?.props,n);return`${s}: ${e}${W(o)}`}default:return e?`text: ${e}${W(n)}`:null}}function l(t,e){return{property:t,css:e}}const dn=[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),{property:"style",css:"fontStyle"},l("bgcolor","backgroundColor"),l("padding","padding"),l("indent","paddingLeft"),l("opacity","opacity")],gt=[l("bgcolor","backgroundColor"),l("color","color"),l("border","borderLeft")],$=[l("color","borderColor"),l("bgcolor","backgroundColor")],un={title:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),l("font","fontFamily")],summary:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],section:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),l("border","borderBottom"),l("spacing","marginTop")],sub:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight")],divider:[{property:"style",css:"borderStyle"},l("color","borderColor"),l("width","borderTopWidth"),l("spacing","margin")],text:[...dn],tip:[...gt],info:[...gt],warning:[...gt],danger:[...gt],success:[...gt],quote:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("border","borderLeft"),l("padding","paddingLeft"),l("bgcolor","backgroundColor")],cite:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],def:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("padding","paddingLeft")],caption:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],footnote:[l("color","color"),l("size","fontSize")],byline:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("weight","fontWeight")],epigraph:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("padding","padding")],dedication:[l("align","textAlign"),l("color","color"),{property:"style",css:"fontStyle"},l("padding","padding")],image:[l("width","width"),l("height","height"),l("radius","borderRadius"),l("border","border"),l("opacity","opacity"),l("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],figure:[l("width","width"),l("align","textAlign"),l("border","border"),l("padding","padding"),l("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],link:[l("color","color"),l("weight","fontWeight")],ref:[l("color","color"),{property:"style",css:"fontStyle"}],embed:[l("width","width"),l("height","height"),l("border","border"),l("radius","borderRadius")],metric:[l("color","color"),l("size","fontSize"),l("align","textAlign"),l("bgcolor","backgroundColor"),l("border","border"),l("padding","padding")],columns:[l("border","border"),l("bgcolor","backgroundColor"),l("padding","padding"),l("size","fontSize"),l("align","textAlign")],row:[l("border","border"),l("bgcolor","backgroundColor"),l("padding","padding"),l("size","fontSize"),l("align","textAlign")],input:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("size","fontSize")],output:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("size","fontSize")],code:[l("size","fontSize"),l("bgcolor","backgroundColor"),l("color","color"),l("padding","padding"),l("radius","borderRadius"),l("border","border")],contact:[l("color","color"),l("bgcolor","backgroundColor"),l("border","border"),l("padding","padding"),l("size","fontSize")],deadline:[l("color","color"),l("bgcolor","backgroundColor"),l("weight","fontWeight"),l("size","fontSize")],step:[...$],decision:[...$],gate:[...$],trigger:[...$],loop:[...$],parallel:[...$],call:[...$],wait:[...$],checkpoint:[...$],error:[...$],result:[...$],audit:[...$],signal:[...$],handoff:[...$],retry:[...$],progress:[...$],tool:[...$],prompt:[...$],memory:[...$],policy:[...$],context:[...$],track:[...$],approve:[...$],sign:[...$],freeze:[...$],revision:[...$],amendment:[...$],history:[l("color","borderColor")],assert:[l("color","borderColor"),l("bgcolor","backgroundColor"),l("border","borderLeft")],secret:[l("color","color"),l("bgcolor","backgroundColor"),l("blur","filter")],watermark:[l("color","color"),l("size","fontSize"),l("opacity","opacity")],signline:[l("color","color"),l("width","width")]};function pn(t,e){const n=un[t];if(!n)return{};const s={};for(const o of n){const c=e[o.property];c&&(o.transform?s[o.css]=o.transform(c):s[o.css]=c)}return s}function X(t,e){const n=pn(t,e);return e.leading&&(n.lineHeight=e.leading),e["space-before"]&&(n.marginTop=e["space-before"]),e["space-after"]&&(n.marginBottom=e["space-after"]),Object.entries(n).map(([s,o])=>`${s.replace(/([A-Z])/g,"-$1").toLowerCase()}:${o}`).join(";")}function Ht(t){return t.end?{"data-it-end":t.end}:{}}const fn=j.Node.create({name:"itTitle",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}",parseHTML:t=>t.getAttribute("data-props")||"{}"}}},parseHTML(){return[{tag:'h1[data-it-type="title"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props),s=j.mergeAttributes(t,{"data-it-type":"title",class:"it-doc-title",style:X("title",n),...Ht(n)});return n.end?["h1",s,["span",{class:"it-split-main"},0]]:["h1",s,0]}}),gn=j.Node.create({name:"itSummary",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'p[data-it-type="summary"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props);return["p",j.mergeAttributes(t,{"data-it-type":"summary",class:"it-doc-summary",style:X("summary",n)}),0]}}),hn=j.Node.create({name:"itSection",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h2[data-it-type="section"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props),s=j.mergeAttributes(t,{"data-it-type":"section",class:"it-doc-section",style:X("section",n),...Ht(n)});return n.end?["h2",s,["span",{class:"it-split-main"},0]]:["h2",s,0]}}),mn=j.Node.create({name:"itSub",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h3[data-it-type="sub"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props),s=j.mergeAttributes(t,{"data-it-type":"sub",class:"it-doc-sub",style:X("sub",n),...Ht(n)});return n.end?["h3",s,["span",{class:"it-split-main"},0]]:["h3",s,0]}}),bn=j.Node.create({name:"itCallout",group:"block",content:"inline*",defining:!0,addAttributes(){return{variant:{default:"tip",parseHTML:t=>t.getAttribute("data-variant")||"tip",renderHTML:t=>({"data-variant":t.variant})},props:{default:"{}"}}},parseHTML(){return[{tag:'div[data-it-type="callout"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.variant||"tip",s=ot(e.attrs.props),o={tip:"tip",info:"info",warning:"warning",danger:"danger",success:"success"};return["div",j.mergeAttributes(t,{"data-it-type":"callout","data-variant":n,class:`it-doc-callout it-doc-callout-${n}`,style:X(n,s)}),["span",{class:`it-doc-callout-icon it-doc-callout-icon-${o[n]||"tip"}`,contenteditable:"false"},""],["span",{class:"it-doc-callout-text"},0]]}}),yn=j.Node.create({name:"itQuote",group:"block",content:"inline*",defining:!0,addAttributes(){return{by:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'blockquote[data-it-type="quote"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props);return["blockquote",j.mergeAttributes(t,{"data-it-type":"quote",class:"it-doc-quote",style:X("quote",n)}),0]}}),xn=j.Node.create({name:"itCode",group:"block",content:"text*",marks:"",code:!0,defining:!0,addAttributes(){return{lang:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:"pre"}]},renderHTML({HTMLAttributes:t,node:e}){const n=ot(e.attrs.props);return["pre",j.mergeAttributes(t,{"data-it-type":"code",class:"it-doc-code","data-lang":e.attrs.lang||"",style:X("code",n)}),["code",0]]}}),Sn=j.Node.create({name:"itDivider",group:"block",atom:!0,parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",j.mergeAttributes(t,{class:"it-doc-divider"})]}}),kn=j.Node.create({name:"itMeta",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-meta]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=String(e.attrs.raw||"").replace(/\s*\|\s*/g," · ");return["div",j.mergeAttributes(t,{"data-it-meta":"",class:"it-doc-meta"}),`⚙ ${n}`]}});function Tt(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)?e:[]}catch{return[]}}const vn=j.Node.create({name:"itTable",group:"block",atom:!0,selectable:!0,addAttributes(){return{rows:{default:"[]",parseHTML:t=>t.getAttribute("data-rows")||"[]",renderHTML:t=>({"data-rows":t.rows})}}},parseHTML(){return[{tag:"table[data-it-table]"}]},renderHTML({HTMLAttributes:t,node:e}){const n=Tt(e.attrs.rows),s=n[0]||[],o=n.slice(1);return["table",j.mergeAttributes(t,{"data-it-table":"",class:"it-doc-table"}),["thead",["tr",...s.map(c=>["th",Gt(c),String(c)])]],["tbody",...o.map(c=>["tr",...c.map(a=>["td",Gt(a),String(a)])])]]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const s=document.createElement("table");s.className="it-doc-table",s.setAttribute("data-it-table","");const o=document.createElement("thead"),c=document.createElement("tbody");s.append(o,c);let a=Tt(t.attrs.rows);const d=()=>{const u=[];s.querySelectorAll("tr").forEach(g=>{const b=[];g.querySelectorAll("th,td").forEach(k=>b.push((k.textContent||"").trim())),u.push(b)});const h=JSON.stringify(u);if(h!==t.attrs.rows&&(a=u,typeof n=="function")){const g=n();if(g==null)return;const b=e.view.state.tr.setNodeAttribute(g,"rows",h);e.view.dispatch(b)}},i=(u,h)=>{const g=document.createElement(u);g.textContent=h;const b=e.isEditable;return g.contentEditable=b?"true":"false",/\{\{[^}]+\}\}|^each:/.test(String(h).trim())&&(g.className="it-doc-var-cell"),g.addEventListener("blur",d),g.addEventListener("keydown",k=>{k.key==="Enter"&&(k.preventDefault(),k.target.blur())}),g},m=u=>{o.innerHTML="",c.innerHTML="";const h=u[0]||[],g=document.createElement("tr");h.forEach(b=>g.appendChild(i("th",String(b)))),o.appendChild(g),u.slice(1).forEach(b=>{const k=document.createElement("tr");b.forEach(w=>k.appendChild(i("td",String(w)))),c.appendChild(k)})};return m(a),{dom:s,update(u){return u.type.name!=="itTable"?!1:(u.attrs.rows!==JSON.stringify(a)&&(a=Tt(u.attrs.rows),m(a)),!0)},ignoreMutation:()=>!0}}}});function Gt(t){return/\{\{[^}]+\}\}|^each:/.test(String(t).trim())?{class:"it-doc-var-cell"}:{}}function Pt(t){const e=t.indexOf(":"),n=(e>=0?t.slice(0,e):t).trim().toLowerCase(),o=(e>=0?t.slice(e+1).trim():"").split("|").map(d=>d.trim()),c=o.shift()||"",a={};for(const d of o){const i=d.indexOf(":");i>0&&(a[d.slice(0,i).trim().toLowerCase()]=d.slice(i+1).trim())}return{keyword:n,content:c,props:a}}const wn=j.Node.create({name:"itTrust",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})},keyword:{default:"",parseHTML:t=>t.getAttribute("data-trust")||"",renderHTML:t=>({"data-trust":t.keyword})}}},parseHTML(){return[{tag:"div[data-it-trust]"}]},renderHTML({HTMLAttributes:t,node:e}){const{keyword:n,content:s,props:o}=Pt(String(e.attrs.raw||"")),c=o.role||o.title||"",a=(o.at||o.date||o.time||"").slice(0,10),d=[];if(n==="seal"||n==="freeze"){const i=n==="seal"&&s||o.hash||"";d.push(["span",{class:"it-doc-trust__label"},"Sealed document"]),a&&d.push(["span",{class:"it-doc-trust__date"},a]),i&&d.push(["code",{class:"it-doc-trust__hash"},i.length>20?i.slice(0,20)+"...":i])}else if(n==="approve"){const i=o.by||s,m=o.by?s:"";d.push(["span",{class:"it-doc-trust__label"},"Approved"]),m&&d.push(["span",{class:"it-doc-trust__what"},m]),i&&d.push(["span",{class:"it-doc-trust__who"},c?`${i}, ${c}`:i]),a&&d.push(["span",{class:"it-doc-trust__date"},a])}else if(n==="amend"||n==="amendment")d.push(["span",{class:"it-doc-trust__label"},"Amendment"]),s&&d.push(["span",{class:"it-doc-trust__what"},s]),a&&d.push(["span",{class:"it-doc-trust__date"},a]);else{const i=s||o.by||"",m=!!o.hash;d.push(["span",{class:"it-doc-trust__name"},i]),c&&d.push(["span",{class:"it-doc-trust__role"},c]),a&&d.push(["span",{class:"it-doc-trust__date"},a]),d.push(["span",{class:"it-doc-trust__status"},m?"Signed · verified":"Signed"])}return["div",j.mergeAttributes(t,{"data-it-trust":"","data-trust":n,class:`it-doc-trust it-doc-trust--${n}`}),...d]}}),jn=j.Node.create({name:"itMetric",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-metric]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:n,props:s}=Pt(String(e.attrs.raw||"")),o=[s.value,s.unit].filter(Boolean).join(" "),c=/\b(total|balance due|amount due|grand)\b/i.test(n),a=/\{\{[^}]+\}\}/.test(o);return["div",j.mergeAttributes(t,{"data-it-metric":"",class:`it-doc-metric${c?" it-doc-metric--total":""}`}),["span",{class:"it-doc-metric__label"},n],["span",{class:`it-doc-metric__value${a?" it-doc-var":""}`},o]]}}),Tn=j.Node.create({name:"itStyleRule",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-style-rule]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:n,props:s}=Pt(String(e.attrs.raw||"")),o=Object.entries(s).map(([c,a])=>`${c}: ${a}`).join(" · ");return["div",j.mergeAttributes(t,{"data-it-style-rule":"",class:"it-doc-stylerule"}),["span",{class:"it-doc-stylerule__icon"},"🎨"],["span",{class:"it-doc-stylerule__target"},n||"?"],["span",{class:"it-doc-stylerule__decl"},o]]}}),Nn=j.Node.create({name:"itBreak",group:"block",atom:!0,parseHTML(){return[{tag:'div[data-it-type="break"]'}]},renderHTML({HTMLAttributes:t}){return["div",j.mergeAttributes(t,{"data-it-type":"break",class:"it-doc-break"})]}}),Cn=j.Node.create({name:"itGenericBlock",group:"block",content:"inline*",defining:!0,addAttributes(){return{keyword:{default:"text"},properties:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'[data-it-type="generic"]'}]},renderHTML({HTMLAttributes:t,node:e}){const n=e.attrs.keyword,s=ot(e.attrs.props),o=String(s.to||s.url||s.href||s.file||"").trim();return(n==="link"||n==="ref")&&o?["p",j.mergeAttributes(t,{"data-it-type":"generic","data-keyword":n,class:`it-doc-generic it-doc-kw-${n}`,style:X(n,s)}),["a",{class:"it-doc-inline-link",href:o,target:"_blank",rel:"noopener noreferrer"},0]]:["p",j.mergeAttributes(t,{"data-it-type":"generic","data-keyword":n,class:`it-doc-generic it-doc-kw-${n}`,style:X(n,s)}),["span",{class:"it-doc-generic-content"},0]]}}),An=j.Node.create({name:"itComment",group:"block",content:"inline*",defining:!0,parseHTML(){return[{tag:'p[data-it-type="comment"]'}]},renderHTML({HTMLAttributes:t}){return["p",j.mergeAttributes(t,{"data-it-type":"comment",class:"it-doc-comment"}),0]}});function ot(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}const ne={leading:"leading","space-before":"spaceBefore","space-after":"spaceAfter",end:"end"},Ln=new Set(["itTitle","itSummary","itSection","itSub","itQuote","itCallout","itGenericBlock"]),_n=new Set(["itTitle","itSection","itSub"]);function se(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}function re(t,e){return t==="paragraph"?!0:e==="end"?_n.has(t):Ln.has(t)}const $n=Pe.default.extend({addAttributes(){return{...this.parent?.(),leading:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.leading?{style:`line-height: ${t.leading}`}:{}},spaceBefore:{default:null,parseHTML:t=>t.style.marginTop||null,renderHTML:t=>t.spaceBefore?{style:`margin-top: ${t.spaceBefore}`}:{}},spaceAfter:{default:null,parseHTML:t=>t.style.marginBottom||null,renderHTML:t=>t.spaceAfter?{style:`margin-bottom: ${t.spaceAfter}`}:{}},end:{default:null,parseHTML:t=>t.getAttribute("data-it-end"),renderHTML:t=>t.end?{"data-it-end":t.end}:{}}}},renderHTML({node:t,HTMLAttributes:e}){return t.attrs.end?["p",j.mergeAttributes(e),["span",{class:"it-split-main"},0]]:["p",j.mergeAttributes(e),0]}}),Mn=j.Extension.create({name:"blockProps",addCommands(){return{setBlockProp:(t,e)=>({state:n,tr:s,dispatch:o})=>{const{from:c,to:a}=n.selection;let d=!1;return n.doc.nodesBetween(c,a,(i,m)=>{const u=i.type.name;if(u==="bulletList"||u==="orderedList"||!i.isBlock||i.isAtom)return!1;if(!re(u,t))return!0;if(u==="paragraph")s.setNodeMarkup(m,void 0,{...i.attrs,[ne[t]]:e});else{const h=se(i.attrs.props);e==null||e===""?delete h[t]:h[t]=e,s.setNodeMarkup(m,void 0,{...i.attrs,props:JSON.stringify(h)})}return d=!0,!1}),d&&o&&o(s),d}}}});function st(t,e){if(!t)return null;const{state:n}=t,{from:s,to:o}=n.selection;let c=null;return n.doc.nodesBetween(s,o,a=>{if(c!==null)return!1;const d=a.type.name;if(!re(d,e))return!0;if(d==="paragraph"){const i=a.attrs[ne[e]];c=i!=null?String(i):""}else c=se(a.attrs.props)[e]??"";return!1}),c}const Kt={identity:{label:"Identity",icon:"ID",color:"#3b82f6"},content:{label:"Content",icon:"Tx",color:"#6b7280"},structure:{label:"Structure",icon:"##",color:"#22c55e"},data:{label:"Data",icon:"Dt",color:"#a855f7"},agent:{label:"Agent",icon:"Ag",color:"#f97316"},trust:{label:"Trust",icon:"Tr",color:"#eab308"},layout:{label:"Layout",icon:"Pg",color:"#64748b"}};function oe(t){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;right:0;bottom:0;width:210mm;height:297mm;border:0;visibility:hidden;",document.body.appendChild(e);let n=!1;const s=()=>{if(!n){n=!0;try{e.contentWindow.focus(),e.contentWindow.print()}finally{setTimeout(()=>e.remove(),1e3)}}};e.onload=()=>window.setTimeout(s,120);const o=e.contentWindow.document;o.open(),o.write(t),o.close(),o.readyState==="complete"&&window.setTimeout(s,250)}function En(t,e){return t.includes("</head>")?t.replace("</head>",`<style>${e}</style></head>`):t}const ie=".it-doc-callout{background:none!important;border:1px solid #ccc!important}",Yt=R.cssContentValue;function Rn(t,e){const n=document.querySelector(".docs-page .tiptap");if(!n)return null;const s=n.cloneNode(!0);s.querySelectorAll("[data-it-spacer]").forEach(h=>h.remove()),s.querySelectorAll('.it-doc-comment, [data-it-type="comment"]').forEach(h=>h.remove());const o=s.innerHTML,c=Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).map(h=>h.outerHTML).join(`
25
- `),a=xt(t),d=a.autoHeight?`${a.width}px auto`:`${a.width}px ${a.height}px`,i=`${a.marginTop}px ${a.marginRight}px ${a.marginBottom}px ${a.marginLeft}px`;let m=`@page{size:${d};margin:${i};}`;a.header&&(m+=`@page{@top-center{content:${Yt(a.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`),a.footer&&(m+=`@page{@bottom-center{content:${Yt(a.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);const u=`
17
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${a.marginBottom}px">
18
+ ${Tt("footer",a.footer,d,h)}
19
+ </div>`,g},i=()=>{const a=t.geometry(),m=e.dom,d=e.state.doc;if(a.autoHeight){n!=="auto"&&(n="auto",e.dispatch(e.state.tr.setMeta(bt,dt.DecorationSet.empty)),t.onPages?.(1));return}const h=m.getBoundingClientRect().top,g=Array.from(m.children),y=[];let S=0;for(const _ of g){if(_.hasAttribute?.("data-it-spacer")){S+=_.offsetHeight;continue}const P=_.getBoundingClientRect();y.push({natTop:P.top-h-S,natBottom:P.bottom-h-S})}const j=[];let b=0,k=y.length?y[0].natTop:0,H=k;for(let _=0;_<y.length&&_<d.childCount;_++){const P=y[_],V=d.child(_).nodeSize;P.natTop>k&&P.natBottom-k>a.contentHeight&&(j.push({pos:b,rest:Math.max(0,a.contentHeight-(P.natTop-k))}),k=P.natTop),H=P.natBottom,b+=V}const E=j.length+1,D=Math.max(0,a.contentHeight-(H-k)),F=j.map(_=>`${_.pos}:${Math.round(_.rest)}`).join(",")+`|${Math.round(D)}|${E}|${a.header}|${a.footer}|${Math.round(a.contentHeight)}`;if(F===n)return;n=F;const O=j.map((_,P)=>dt.Decoration.widget(_.pos,()=>o(a,_.rest,P+1,E),{side:-1,key:`pb-${P+1}-${Math.round(_.rest)}`}));O.push(dt.Decoration.widget(d.content.size,()=>c(a,D,E,E),{side:1,key:`pb-tail-${E}-${Math.round(D)}`}));const W=dt.DecorationSet.create(e.state.doc,O);e.dispatch(e.state.tr.setMeta(bt,W)),t.onPages?.(E)},p=()=>{cancelAnimationFrame(s),s=requestAnimationFrame(i)};return p(),{update:p,destroy:()=>cancelAnimationFrame(s)}}})]}}),qt=new Set(["tip","info","warning","danger","success"]),Ve=new Set(["page","meta","font","header","footer","watermark"]),Je=new Set(["sign","seal","approve","freeze","amend","amendment"]),Ut={title:"itTitle",section:"itSection",sub:"itSub"},Qe={note:"text","body-text":"text"},Xe=new Set(["weight","italic","underline","strike","color","family","size","bg","valign","align","style","font","bgcolor"]);function Ze(t){if(!t||t==="{}")return{};try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}function Y(t,e){const s=Object.entries(t).filter(([n,o])=>o!==void 0&&o!==""&&(!e||!e.has(n)));return s.length===0?"":" | "+s.map(([n,o])=>`${n}: ${o}`).join(" | ")}function $t(t){if(!t)return[];const e=t.split("\\n"),s=[];return e.forEach((n,o)=>{n&&s.push({type:"text",text:n}),o<e.length-1&&s.push({type:"hardBreak"})}),s}function tn(t){switch(t.type){case"bold":return[{type:"bold"}];case"italic":return[{type:"italic"}];case"strike":return[{type:"strike"}];case"code":return[{type:"code"}];case"highlight":return[{type:"highlight"}];case"styled":{const e=t.props||{},s=[],n={};return e.weight&&e.weight!=="normal"&&s.push({type:"bold"}),e.italic==="true"&&s.push({type:"italic"}),e.underline==="true"&&s.push({type:"underline"}),e.strike==="true"&&s.push({type:"strike"}),e.color&&(n.color=e.color),e.family&&(n.fontFamily=e.family),e.size&&(n.fontSize=e.size),Object.keys(n).length&&s.push({type:"textStyle",attrs:n}),e.bg&&s.push({type:"highlight",attrs:{color:e.bg}}),e.valign==="sub"&&s.push({type:"subscript"}),e.valign==="super"&&s.push({type:"superscript"}),s.length?s:null}default:return null}}const en=new Set(["text","bold","italic","strike","highlight","styled"]);function nn(t,e){if(!t||t.length===0||t.every(n=>n.type==="text")||!t.every(n=>en.has(n.type)))return $t(e);const s=[];for(const n of t){const o=tn(n),i=(n.value??"").split("\\n");i.forEach((p,a)=>{p&&s.push(o?{type:"text",text:p,marks:o}:{type:"text",text:p}),a<i.length-1&&s.push({type:"hardBreak"})})}return s.length?s:$t(e)}function sn(t,e){if(!e||t.length===0)return t;const s=[],n={},o=e,c=o.family??o.font,i=o.bg??o.bgcolor;return String(o.weight||"").toLowerCase()==="bold"&&s.push({type:"bold"}),(String(o.italic||"")==="true"||String(o.style||"").toLowerCase()==="italic")&&s.push({type:"italic"}),String(o.underline||"")==="true"&&s.push({type:"underline"}),String(o.strike||"")==="true"&&s.push({type:"strike"}),String(o.valign||"")==="sub"&&s.push({type:"subscript"}),String(o.valign||"")==="super"&&s.push({type:"superscript"}),o.color&&(n.color=String(o.color)),c&&(n.fontFamily=String(c)),o.size&&(n.fontSize=String(o.size)),i&&s.push({type:"highlight",attrs:{color:String(i)}}),Object.keys(n).length>0&&s.push({type:"textStyle",attrs:n}),s.length===0?t:t.map(p=>p.type==="text"?{...p,marks:[...p.marks||[],...s]}:p)}function se(t){const e={};for(const s of t||[])switch(s.type){case"bold":e.weight="bold";break;case"italic":e.italic="true";break;case"underline":e.underline="true";break;case"strike":e.strike="true";break;case"textStyle":s.attrs?.color&&(e.color=String(s.attrs.color)),s.attrs?.fontFamily&&(e.family=String(s.attrs.fontFamily)),s.attrs?.fontSize&&(e.size=String(s.attrs.fontSize));break;case"highlight":s.attrs?.color&&(e.bg=String(s.attrs.color));break;case"subscript":e.valign="sub";break;case"superscript":e.valign="super";break}return e}function rn(t){if(t.type==="hardBreak")return"\\n";if(t.type!=="text")return zt(t);const e=t.text||"";if(!e)return"";const s=t.marks||[];if(!s.length)return e;const n=new Set(s.map(h=>h.type)),o=s.find(h=>h.type==="link");if(o?.attrs?.href)return`[${e}](${o.attrs.href})`;const c=s.find(h=>h.type==="textStyle")?.attrs||{},i=s.find(h=>h.type==="highlight")?.attrs||{},p=!!(c.color||c.fontFamily||c.fontSize||i.color),a=["bold","italic","strike","underline","code"].filter(h=>n.has(h)).length;if(!p&&a===1&&!n.has("underline")){if(n.has("bold"))return`*${e}*`;if(n.has("italic"))return`_${e}_`;if(n.has("strike"))return`~${e}~`;if(n.has("code"))return`\`${e}\``}if(!p&&a===0&&n.has("highlight")&&!i.color)return`^${e}^`;const m=se(s),d=[];return m.color&&d.push(`color: ${m.color}`),m.family&&d.push(`family: ${m.family}`),m.size&&d.push(`size: ${m.size}`),m.weight&&d.push(`weight: ${m.weight}`),m.italic==="true"&&d.push("italic: true"),m.underline&&d.push("underline: true"),m.strike&&d.push("strike: true"),m.bg&&d.push(`bg: ${m.bg}`),m.valign&&d.push(`valign: ${m.valign}`),d.length?`[${e}]{ ${d.join("; ")} }`:e}const on=new Set(["bold","italic","underline","strike","code","highlight","textStyle","link","subscript","superscript"]);function an(t){const e=new Set,s=n=>{for(const o of n.marks||[])on.has(o.type)||e.add(o.type);for(const o of n.content||[])s(o)};return s(t),[...e].sort()}function Mt(t){const e=t.content||[],s=t.attrs?.textAlign&&t.attrs.textAlign!=="left"?{align:String(t.attrs.textAlign)}:{};return e.length===1&&e[0].type==="text"?{text:e[0].text||"",props:{...se(e[0].marks),...s}}:{text:e.map(rn).join(""),props:{...s}}}function zt(t){return t.content?t.content.map(e=>e.type==="text"?e.text||"":e.type==="hardBreak"?"\\n":zt(e)).join(""):""}function lt(t,e,s){const n=Ze(t);for(const o of Xe)delete n[o];if(s)for(const o of s)delete n[o];return{...n,...e}}function Ht(t){const e=t.toLowerCase();return Qe[e]||e}function Gt(t){if(t==="---")return"divider";const e=t.match(/^([a-zA-Z][\w-]*):/);return e?Ht(e[1]):null}function pt(t){return Ht(t)}function ft(t,e){return!!(t===e||t==="info"&&["tip","warning","danger","success"].includes(e)||e==="info"&&["tip","warning","danger","success"].includes(t))}function cn(t){if(!t)return{content:"",properties:{}};const e=t.split(" | ");let s=e[0]||"";const n={};for(let o=1;o<e.length;o++){const c=e[o],i=c.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);if(!i){s+=` | ${c}`;continue}n[i[1]]=i[2]}return{content:s,properties:n}}function Wt(t){if(t==="---")return{type:"divider"};const e=t.match(/^([a-zA-Z][\w-]*):\s*(.*)$/);if(!e)return null;const s=Ht(e[1]),n=e[2]||"",{content:o,properties:c}=cn(n);let i;try{i=z.parseIntentText(`text: ${o}`).blocks[0]?.inline}catch{i=void 0}return{type:s,content:o,properties:c,inline:i}}function Kt(t){const e=t.match(/^[-*]\s+(.*)$/);if(e)return{ordered:!1,text:e[1]};const s=t.match(/^\d+\.\s+(.*)$/);return s?{ordered:!0,text:s[1]}:null}function ln(t){return{type:"listItem",content:[{type:"paragraph",content:$t(t)}]}}function vt(t){if(!t.trim())return{type:"doc",content:[{type:"paragraph"}]};const e=z.parseIntentText(t),s=[];for(const i of e.blocks){const p=Nt(i);p&&s.push(p)}const n=t.split(`
20
+ `);let o=0;const c=[];for(let i=0;i<n.length;i++){const a=n[i].trim();if(!a)continue;{const g=Gt(a);if(g&&Ve.has(g)){c.push({type:"itMeta",attrs:{raw:a}});const y=e.blocks[o]?.type;y&&ft(g,pt(y))&&o++;continue}if(g&&Je.has(g)){c.push({type:"itTrust",attrs:{raw:a,keyword:g}});const y=e.blocks[o]?.type;y&&ft(g,pt(y))&&o++;continue}if(g==="metric"){c.push({type:"itMetric",attrs:{raw:a}});const y=e.blocks[o]?.type;y&&ft(g,pt(y))&&o++;continue}if(g==="style"){c.push({type:"itStyleRule",attrs:{raw:a}});const y=e.blocks[o]?.type;y&&ft(g,pt(y))&&o++;continue}}const m=Kt(a);if(m){const g=m.ordered,y=[];let S=i;for(;S<n.length;){const j=n[S].trim(),b=j?Kt(j):null;if(!b||b.ordered!==g)break;y.push(ln(b.text));const k=e.blocks[o]?.type;(k==="list-item"||k==="step-item")&&o++,S++}c.push({type:g?"orderedList":"bulletList",content:y}),i=S-1;continue}if(a.startsWith("|")&&a.endsWith("|")&&(a.match(/\|/g)||[]).length>=3){const g=[];let y=i;for(;y<n.length;){const S=n[y].trim();if(!(S.startsWith("|")&&S.endsWith("|")))break;g.push(S.slice(1,-1).split("|").map(j=>j.trim())),y++}c.push({type:"itTable",attrs:{rows:JSON.stringify(g)}}),i=y-1;continue}if(a.startsWith("//")){c.push({type:"itComment",content:a.slice(2).trim()?[{type:"text",text:a.slice(2).trim()}]:[]});continue}if(a.startsWith("```"))continue;const d=Gt(a);if(d&&(d==="text"||a.includes("{{"))){const g=Wt(a);if(g){const y=Nt(g);if(y&&c.push(y),o<e.blocks.length){const S=pt(e.blocks[o].type);ft(d,S)&&o++}continue}}if(o<s.length&&d){const g=e.blocks[o],y=pt(g.type);if(ft(d,y)){c.push(s[o]),o++;continue}}const h=Wt(a);if(h){const g=Nt(h);g&&c.push(g);continue}o<s.length&&(c.push(s[o]),o++)}for(;o<s.length;)c.push(s[o]),o++;return{type:"doc",content:c.length>0?c:[{type:"paragraph"}]}}function Nt(t){const{type:e,content:s,properties:n,inline:o}=t,c=s||"";let i=nn(o,c);i=sn(i,n);const p=n?JSON.stringify(Object.fromEntries(Object.entries(n).map(([d,h])=>[d,String(h)]))):"{}",a=n?.align?String(n.align):void 0;if(e in Ut)return{type:Ut[e],attrs:{props:p,...a&&{textAlign:a}},content:i.length?i:void 0};if(e==="summary")return{type:"itSummary",attrs:{props:p,...a&&{textAlign:a}},content:i.length?i:void 0};if(e==="text"||e==="body-text"){const d={};return a&&(d.textAlign=a),n?.end&&(d.end=String(n.end)),n?.leading&&(d.leading=String(n.leading)),n?.["space-before"]&&(d.spaceBefore=String(n["space-before"])),n?.["space-after"]&&(d.spaceAfter=String(n["space-after"])),n?.dir&&(d.dir=String(n.dir)),{type:"paragraph",...Object.keys(d).length&&{attrs:d},content:i.length?i:void 0}}if(qt.has(e)){const d=e==="info"?String(n?.type||"info").toLowerCase():e;return{type:"itCallout",attrs:{variant:qt.has(d)?d:"info",props:p},content:i.length?i:void 0}}if(e==="quote")return{type:"itQuote",attrs:{by:n?.by?String(n.by):"",props:p,...a&&{textAlign:a}},content:i.length?i:void 0};if(e==="code")return{type:"itCode",attrs:{lang:n?.lang?String(n.lang):"",props:p},content:c?[{type:"text",text:c}]:void 0};if(e==="divider")return{type:"itDivider"};if(e==="break")return{type:"itBreak"};const m=n?Object.entries(n).filter(([,d])=>d!==void 0&&d!=="").map(([d,h])=>`${d}: ${h}`).join(" | "):"";return{type:"itGenericBlock",attrs:{keyword:e,properties:m,props:p},content:i.length?i:void 0}}function Pt(t){if(!t.content)return"";const e=[...t.content],s=o=>(o.type==="paragraph"||o.type==="itGenericBlock")&&(!o.content||o.content.length===0||o.content.every(c=>c.type==="text"&&!(c.text||"").trim()))&&!(o.attrs&&Object.values(o.attrs).some(c=>c&&c!=="{}"));for(;e.length>1&&s(e[e.length-1]);)e.pop();const n=[];for(const o of e)n.push(...dn(o));return n.join(`
21
+ `)}function dn(t){if(t.type==="bulletList"&&t.content)return t.content.flatMap(s=>s.content?s.content.map(n=>{const{text:o,props:c}=Mt(n);return`- ${o}${Y(c)}`}):[]);if(t.type==="orderedList"&&t.content){let s=1;return t.content.flatMap(n=>n.content?n.content.map(o=>{const{text:c,props:i}=Mt(o);return`${s++}. ${c}${Y(i)}`}):[])}const e=un(t);return e!==null?[e]:[]}function un(t){const{text:e,props:s}=Mt(t);switch(t.type){case"itTitle":{const n=lt(t.attrs?.props,s);return`title: ${e}${Y(n)}`}case"itSummary":{const n=lt(t.attrs?.props,s);return`summary: ${e}${Y(n)}`}case"itSection":{const n=lt(t.attrs?.props,s);return`section: ${e}${Y(n)}`}case"itSub":{const n=lt(t.attrs?.props,s);return`sub: ${e}${Y(n)}`}case"paragraph":{const n=t.attrs||{},o={};return n.end&&(o.end=String(n.end)),n.leading&&(o.leading=String(n.leading)),n.spaceBefore&&(o["space-before"]=String(n.spaceBefore)),n.spaceAfter&&(o["space-after"]=String(n.spaceAfter)),n.dir&&(o.dir=String(n.dir)),`text: ${e}${Y({...o,...s})}`}case"itCallout":{const n=t.attrs?.variant||"tip",o=lt(t.attrs?.props,s,new Set(["variant"]));return n==="info"?`info: ${e}${Y(o)}`:`info: ${e} | type: ${n}${Y(o,new Set(["type"]))}`}case"itQuote":{const n=t.attrs?.by,o=n?` | by: ${n}`:"",c=lt(t.attrs?.props,s,new Set(["by"]));return`quote: ${e}${o}${Y(c)}`}case"itCode":return`\`\`\`${t.attrs?.lang||""}
22
+ ${zt(t)}
23
+ \`\`\``;case"itDivider":return"divider:";case"itTable":{let n=[];try{n=JSON.parse(t.attrs?.rows||"[]")}catch{n=[]}return n.map(o=>`| ${o.join(" | ")} |`).join(`
24
+ `)}case"itMeta":return t.attrs?.raw||"";case"itTrust":return t.attrs?.raw||"";case"itMetric":return t.attrs?.raw||"";case"itStyleRule":return t.attrs?.raw||"";case"itBreak":return"break:";case"itComment":return e?`// ${e}`:"//";case"itGenericBlock":{const n=t.attrs?.keyword||"text",o=lt(t.attrs?.props,s);return`${n}: ${e}${Y(o)}`}default:return e?`text: ${e}${Y(s)}`:null}}function l(t,e){return{property:t,css:e}}const pn=[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),{property:"style",css:"fontStyle"},l("bgcolor","backgroundColor"),l("padding","padding"),l("indent","paddingLeft"),l("opacity","opacity")],yt=[l("bgcolor","backgroundColor"),l("color","color"),l("border","borderLeft")],$=[l("color","borderColor"),l("bgcolor","backgroundColor")],fn={title:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),l("font","fontFamily")],summary:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],section:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight"),l("border","borderBottom"),l("spacing","marginTop")],sub:[l("align","textAlign"),l("color","color"),l("size","fontSize"),l("weight","fontWeight")],divider:[{property:"style",css:"borderStyle"},l("color","borderColor"),l("width","borderTopWidth"),l("spacing","margin")],text:[...pn],tip:[...yt],info:[...yt],warning:[...yt],danger:[...yt],success:[...yt],quote:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("border","borderLeft"),l("padding","paddingLeft"),l("bgcolor","backgroundColor")],cite:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],def:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("padding","paddingLeft")],caption:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"}],footnote:[l("color","color"),l("size","fontSize")],byline:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("weight","fontWeight")],epigraph:[l("align","textAlign"),l("color","color"),l("size","fontSize"),{property:"style",css:"fontStyle"},l("padding","padding")],dedication:[l("align","textAlign"),l("color","color"),{property:"style",css:"fontStyle"},l("padding","padding")],image:[l("width","width"),l("height","height"),l("radius","borderRadius"),l("border","border"),l("opacity","opacity"),l("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],figure:[l("width","width"),l("align","textAlign"),l("border","border"),l("padding","padding"),l("bgcolor","backgroundColor"),{property:"shadow",css:"boxShadow",transform:()=>"0 4px 12px rgba(0,0,0,0.15)"}],link:[l("color","color"),l("weight","fontWeight")],ref:[l("color","color"),{property:"style",css:"fontStyle"}],embed:[l("width","width"),l("height","height"),l("border","border"),l("radius","borderRadius")],metric:[l("color","color"),l("size","fontSize"),l("align","textAlign"),l("bgcolor","backgroundColor"),l("border","border"),l("padding","padding")],columns:[l("border","border"),l("bgcolor","backgroundColor"),l("padding","padding"),l("size","fontSize"),l("align","textAlign")],row:[l("border","border"),l("bgcolor","backgroundColor"),l("padding","padding"),l("size","fontSize"),l("align","textAlign")],input:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("size","fontSize")],output:[l("color","color"),l("bgcolor","backgroundColor"),l("border","borderLeft"),l("size","fontSize")],code:[l("size","fontSize"),l("bgcolor","backgroundColor"),l("color","color"),l("padding","padding"),l("radius","borderRadius"),l("border","border")],contact:[l("color","color"),l("bgcolor","backgroundColor"),l("border","border"),l("padding","padding"),l("size","fontSize")],deadline:[l("color","color"),l("bgcolor","backgroundColor"),l("weight","fontWeight"),l("size","fontSize")],step:[...$],decision:[...$],gate:[...$],trigger:[...$],loop:[...$],parallel:[...$],call:[...$],wait:[...$],checkpoint:[...$],error:[...$],result:[...$],audit:[...$],signal:[...$],handoff:[...$],retry:[...$],progress:[...$],tool:[...$],prompt:[...$],memory:[...$],policy:[...$],context:[...$],track:[...$],approve:[...$],sign:[...$],freeze:[...$],revision:[...$],amendment:[...$],history:[l("color","borderColor")],assert:[l("color","borderColor"),l("bgcolor","backgroundColor"),l("border","borderLeft")],secret:[l("color","color"),l("bgcolor","backgroundColor"),l("blur","filter")],watermark:[l("color","color"),l("size","fontSize"),l("opacity","opacity")],signline:[l("color","color"),l("width","width")]};function gn(t,e){const s=fn[t];if(!s)return{};const n={};for(const o of s){const c=e[o.property];c&&(o.transform?n[o.css]=o.transform(c):n[o.css]=c)}return n}function tt(t,e){const s=gn(t,e);return e.leading&&(s.lineHeight=e.leading),e["space-before"]&&(s.marginTop=e["space-before"]),e["space-after"]&&(s.marginBottom=e["space-after"]),Object.entries(s).map(([n,o])=>`${n.replace(/([A-Z])/g,"-$1").toLowerCase()}:${o}`).join(";")}function Dt(t){return t.end?{"data-it-end":t.end}:{}}function it(t){const e=t.dir;return e==="rtl"||e==="ltr"||e==="auto"?{dir:e}:{}}const hn=T.Node.create({name:"itTitle",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}",parseHTML:t=>t.getAttribute("data-props")||"{}"}}},parseHTML(){return[{tag:'h1[data-it-type="title"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props),n=T.mergeAttributes(t,{"data-it-type":"title",class:"it-doc-title",style:tt("title",s),...Dt(s),...it(s)});return s.end?["h1",n,["span",{class:"it-split-main"},0]]:["h1",n,0]}}),mn=T.Node.create({name:"itSummary",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'p[data-it-type="summary"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props);return["p",T.mergeAttributes(t,{"data-it-type":"summary",class:"it-doc-summary",style:tt("summary",s),...it(s)}),0]}}),bn=T.Node.create({name:"itSection",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h2[data-it-type="section"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props),n=T.mergeAttributes(t,{"data-it-type":"section",class:"it-doc-section",style:tt("section",s),...Dt(s),...it(s)});return s.end?["h2",n,["span",{class:"it-split-main"},0]]:["h2",n,0]}}),yn=T.Node.create({name:"itSub",group:"block",content:"inline*",defining:!0,addAttributes(){return{props:{default:"{}"}}},parseHTML(){return[{tag:'h3[data-it-type="sub"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props),n=T.mergeAttributes(t,{"data-it-type":"sub",class:"it-doc-sub",style:tt("sub",s),...Dt(s),...it(s)});return s.end?["h3",n,["span",{class:"it-split-main"},0]]:["h3",n,0]}}),xn=T.Node.create({name:"itCallout",group:"block",content:"inline*",defining:!0,addAttributes(){return{variant:{default:"tip",parseHTML:t=>t.getAttribute("data-variant")||"tip",renderHTML:t=>({"data-variant":t.variant})},props:{default:"{}"}}},parseHTML(){return[{tag:'div[data-it-type="callout"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=e.attrs.variant||"tip",n=at(e.attrs.props),o={tip:"tip",info:"info",warning:"warning",danger:"danger",success:"success"};return["div",T.mergeAttributes(t,{"data-it-type":"callout","data-variant":s,class:`it-doc-callout it-doc-callout-${s}`,style:tt(s,n),...it(n)}),["span",{class:`it-doc-callout-icon it-doc-callout-icon-${o[s]||"tip"}`,contenteditable:"false"},""],["span",{class:"it-doc-callout-text"},0]]}}),Sn=T.Node.create({name:"itQuote",group:"block",content:"inline*",defining:!0,addAttributes(){return{by:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'blockquote[data-it-type="quote"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props);return["blockquote",T.mergeAttributes(t,{"data-it-type":"quote",class:"it-doc-quote",style:tt("quote",s),...it(s)}),0]}}),kn=T.Node.create({name:"itCode",group:"block",content:"text*",marks:"",code:!0,defining:!0,addAttributes(){return{lang:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:"pre"}]},renderHTML({HTMLAttributes:t,node:e}){const s=at(e.attrs.props);return["pre",T.mergeAttributes(t,{"data-it-type":"code",class:"it-doc-code","data-lang":e.attrs.lang||"",style:tt("code",s)}),["code",0]]}}),vn=T.Node.create({name:"itDivider",group:"block",atom:!0,parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",T.mergeAttributes(t,{class:"it-doc-divider"})]}}),wn=T.Node.create({name:"itMeta",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-meta]"}]},renderHTML({HTMLAttributes:t,node:e}){const s=String(e.attrs.raw||"").replace(/\s*\|\s*/g," · ");return["div",T.mergeAttributes(t,{"data-it-meta":"",class:"it-doc-meta"}),`⚙ ${s}`]}});function Ct(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)?e:[]}catch{return[]}}const jn=T.Node.create({name:"itTable",group:"block",atom:!0,selectable:!0,addAttributes(){return{rows:{default:"[]",parseHTML:t=>t.getAttribute("data-rows")||"[]",renderHTML:t=>({"data-rows":t.rows})}}},parseHTML(){return[{tag:"table[data-it-table]"}]},renderHTML({HTMLAttributes:t,node:e}){const s=Ct(e.attrs.rows),n=s[0]||[],o=s.slice(1);return["table",T.mergeAttributes(t,{"data-it-table":"",class:"it-doc-table"}),["thead",["tr",...n.map(c=>["th",Yt(c),String(c)])]],["tbody",...o.map(c=>["tr",...c.map(i=>["td",Yt(i),String(i)])])]]},addNodeView(){return({node:t,editor:e,getPos:s})=>{const n=document.createElement("table");n.className="it-doc-table",n.setAttribute("data-it-table","");const o=document.createElement("thead"),c=document.createElement("tbody");n.append(o,c);let i=Ct(t.attrs.rows);const p=()=>{const d=[];n.querySelectorAll("tr").forEach(g=>{const y=[];g.querySelectorAll("th,td").forEach(S=>y.push((S.textContent||"").trim())),d.push(y)});const h=JSON.stringify(d);if(h!==t.attrs.rows&&(i=d,typeof s=="function")){const g=s();if(g==null)return;const y=e.view.state.tr.setNodeAttribute(g,"rows",h);e.view.dispatch(y)}},a=(d,h)=>{const g=document.createElement(d);g.textContent=h;const y=e.isEditable;return g.contentEditable=y?"true":"false",/\{\{[^}]+\}\}|^each:/.test(String(h).trim())&&(g.className="it-doc-var-cell"),g.addEventListener("blur",p),g.addEventListener("keydown",S=>{S.key==="Enter"&&(S.preventDefault(),S.target.blur())}),g},m=d=>{o.innerHTML="",c.innerHTML="";const h=d[0]||[],g=document.createElement("tr");h.forEach(y=>g.appendChild(a("th",String(y)))),o.appendChild(g),d.slice(1).forEach(y=>{const S=document.createElement("tr");y.forEach(j=>S.appendChild(a("td",String(j)))),c.appendChild(S)})};return m(i),{dom:n,update(d){return d.type.name!=="itTable"?!1:(d.attrs.rows!==JSON.stringify(i)&&(i=Ct(d.attrs.rows),m(i)),!0)},ignoreMutation:()=>!0}}}});function Yt(t){return/\{\{[^}]+\}\}|^each:/.test(String(t).trim())?{class:"it-doc-var-cell"}:{}}function It(t){const e=t.indexOf(":"),s=(e>=0?t.slice(0,e):t).trim().toLowerCase(),o=(e>=0?t.slice(e+1).trim():"").split("|").map(p=>p.trim()),c=o.shift()||"",i={};for(const p of o){const a=p.indexOf(":");a>0&&(i[p.slice(0,a).trim().toLowerCase()]=p.slice(a+1).trim())}return{keyword:s,content:c,props:i}}const Tn=T.Node.create({name:"itTrust",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})},keyword:{default:"",parseHTML:t=>t.getAttribute("data-trust")||"",renderHTML:t=>({"data-trust":t.keyword})}}},parseHTML(){return[{tag:"div[data-it-trust]"}]},renderHTML({HTMLAttributes:t,node:e}){const{keyword:s,content:n,props:o}=It(String(e.attrs.raw||"")),c=o.role||o.title||"",i=(o.at||o.date||o.time||"").slice(0,10),p=[];if(s==="seal"||s==="freeze"){const a=s==="seal"&&n||o.hash||"";p.push(["span",{class:"it-doc-trust__label"},"Sealed document"]),i&&p.push(["span",{class:"it-doc-trust__date"},i]),a&&p.push(["code",{class:"it-doc-trust__hash"},a.length>20?a.slice(0,20)+"...":a])}else if(s==="approve"){const a=o.by||n,m=o.by?n:"";p.push(["span",{class:"it-doc-trust__label"},"Approved"]),m&&p.push(["span",{class:"it-doc-trust__what"},m]),a&&p.push(["span",{class:"it-doc-trust__who"},c?`${a}, ${c}`:a]),i&&p.push(["span",{class:"it-doc-trust__date"},i])}else if(s==="amend"||s==="amendment")p.push(["span",{class:"it-doc-trust__label"},"Amendment"]),n&&p.push(["span",{class:"it-doc-trust__what"},n]),i&&p.push(["span",{class:"it-doc-trust__date"},i]);else{const a=n||o.by||"",m=!!o.sig&&!!o.key,d=[c,i].filter(Boolean).join(" · "),h=[["span",{class:"it-doc-trust__rule"}],["span",{class:"it-doc-trust__name"},a]];d&&h.push(["span",{class:"it-doc-trust__meta"},d]),p.push(["span",{class:"it-doc-trust__body"},...h]),p.push(["span",{class:"it-doc-trust__badge"},m?"✓ Signed":"Signed"])}return["div",T.mergeAttributes(t,{"data-it-trust":"","data-trust":s,class:`it-doc-trust it-doc-trust--${s}`}),...p]}}),Nn=T.Node.create({name:"itMetric",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-metric]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:s,props:n}=It(String(e.attrs.raw||"")),o=[n.value,n.unit].filter(Boolean).join(" "),c=/\b(total|balance due|amount due|grand)\b/i.test(s),i=/\{\{[^}]+\}\}/.test(o);return["div",T.mergeAttributes(t,{"data-it-metric":"",class:`it-doc-metric${c?" it-doc-metric--total":""}`}),["span",{class:"it-doc-metric__label"},s],["span",{class:`it-doc-metric__value${i?" it-doc-var":""}`},o]]}}),Cn=T.Node.create({name:"itStyleRule",group:"block",atom:!0,addAttributes(){return{raw:{default:"",parseHTML:t=>t.getAttribute("data-raw")||"",renderHTML:t=>({"data-raw":t.raw})}}},parseHTML(){return[{tag:"div[data-it-style-rule]"}]},renderHTML({HTMLAttributes:t,node:e}){const{content:s,props:n}=It(String(e.attrs.raw||"")),o=Object.entries(n).map(([c,i])=>`${c}: ${i}`).join(" · ");return["div",T.mergeAttributes(t,{"data-it-style-rule":"",class:"it-doc-stylerule"}),["span",{class:"it-doc-stylerule__icon"},"🎨"],["span",{class:"it-doc-stylerule__target"},s||"?"],["span",{class:"it-doc-stylerule__decl"},o]]}}),An=T.Node.create({name:"itBreak",group:"block",atom:!0,parseHTML(){return[{tag:'div[data-it-type="break"]'}]},renderHTML({HTMLAttributes:t}){return["div",T.mergeAttributes(t,{"data-it-type":"break",class:"it-doc-break"})]}}),Ln=T.Node.create({name:"itGenericBlock",group:"block",content:"inline*",defining:!0,addAttributes(){return{keyword:{default:"text"},properties:{default:""},props:{default:"{}"}}},parseHTML(){return[{tag:'[data-it-type="generic"]'}]},renderHTML({HTMLAttributes:t,node:e}){const s=e.attrs.keyword,n=at(e.attrs.props),o=String(n.to||n.url||n.href||n.file||"").trim();return(s==="link"||s==="ref")&&o?["p",T.mergeAttributes(t,{"data-it-type":"generic","data-keyword":s,class:`it-doc-generic it-doc-kw-${s}`,style:tt(s,n),...it(n)}),["a",{class:"it-doc-inline-link",href:o,target:"_blank",rel:"noopener noreferrer"},0]]:["p",T.mergeAttributes(t,{"data-it-type":"generic","data-keyword":s,class:`it-doc-generic it-doc-kw-${s}`,style:tt(s,n),...it(n)}),["span",{class:"it-doc-generic-content"},0]]}}),_n=T.Node.create({name:"itComment",group:"block",content:"inline*",defining:!0,parseHTML(){return[{tag:'p[data-it-type="comment"]'}]},renderHTML({HTMLAttributes:t}){return["p",T.mergeAttributes(t,{"data-it-type":"comment",class:"it-doc-comment"}),0]}});function at(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}const re={leading:"leading","space-before":"spaceBefore","space-after":"spaceAfter",end:"end",dir:"dir"},$n=new Set(["itTitle","itSummary","itSection","itSub","itQuote","itCallout","itGenericBlock"]),Mn=new Set(["itTitle","itSection","itSub"]);function oe(t){try{return typeof t=="string"?JSON.parse(t):t||{}}catch{return{}}}const En=new Set(["itTitle","itSummary","itSection","itSub","itQuote","itCallout","itGenericBlock"]);function ie(t,e){return t==="paragraph"?!0:e==="end"?Mn.has(t):e==="dir"?En.has(t):$n.has(t)}const Rn=Ie.default.extend({addAttributes(){return{...this.parent?.(),leading:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.leading?{style:`line-height: ${t.leading}`}:{}},spaceBefore:{default:null,parseHTML:t=>t.style.marginTop||null,renderHTML:t=>t.spaceBefore?{style:`margin-top: ${t.spaceBefore}`}:{}},spaceAfter:{default:null,parseHTML:t=>t.style.marginBottom||null,renderHTML:t=>t.spaceAfter?{style:`margin-bottom: ${t.spaceAfter}`}:{}},end:{default:null,parseHTML:t=>t.getAttribute("data-it-end"),renderHTML:t=>t.end?{"data-it-end":t.end}:{}},dir:{default:null,parseHTML:t=>t.getAttribute("dir")||null,renderHTML:t=>t.dir==="rtl"||t.dir==="ltr"||t.dir==="auto"?{dir:t.dir}:{}}}},renderHTML({node:t,HTMLAttributes:e}){return t.attrs.end?["p",T.mergeAttributes(e),["span",{class:"it-split-main"},0]]:["p",T.mergeAttributes(e),0]}}),zn=T.Extension.create({name:"blockProps",addCommands(){return{setBlockProp:(t,e)=>({state:s,tr:n,dispatch:o})=>{const{from:c,to:i}=s.selection;let p=!1;return s.doc.nodesBetween(c,i,(a,m)=>{const d=a.type.name;if(d==="bulletList"||d==="orderedList"||!a.isBlock||a.isAtom)return!1;if(!ie(d,t))return!0;if(d==="paragraph")n.setNodeMarkup(m,void 0,{...a.attrs,[re[t]]:e});else{const h=oe(a.attrs.props);e==null||e===""?delete h[t]:h[t]=e,n.setNodeMarkup(m,void 0,{...a.attrs,props:JSON.stringify(h)})}return p=!0,!1}),p&&o&&o(n),p}}}});function rt(t,e){if(!t)return null;const{state:s}=t,{from:n,to:o}=s.selection;let c=null;return s.doc.nodesBetween(n,o,i=>{if(c!==null)return!1;const p=i.type.name;if(!ie(p,e))return!0;if(p==="paragraph"){const a=i.attrs[re[e]];c=a!=null?String(a):""}else c=oe(i.attrs.props)[e]??"";return!1}),c}const Vt={identity:{label:"Identity",icon:"ID",color:"#3b82f6"},content:{label:"Content",icon:"Tx",color:"#6b7280"},structure:{label:"Structure",icon:"##",color:"#22c55e"},data:{label:"Data",icon:"Dt",color:"#a855f7"},agent:{label:"Agent",icon:"Ag",color:"#f97316"},trust:{label:"Trust",icon:"Tr",color:"#eab308"},layout:{label:"Layout",icon:"Pg",color:"#64748b"}};function ae(t){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;right:0;bottom:0;width:210mm;height:297mm;border:0;visibility:hidden;",document.body.appendChild(e);let s=!1;const n=()=>{if(!s){s=!0;try{e.contentWindow.focus(),e.contentWindow.print()}finally{setTimeout(()=>e.remove(),1e3)}}};e.onload=()=>window.setTimeout(n,120);const o=e.contentWindow.document;o.open(),o.write(t),o.close(),o.readyState==="complete"&&window.setTimeout(n,250)}function Hn(t,e){return t.includes("</head>")?t.replace("</head>",`<style>${e}</style></head>`):t}const ce=".it-doc-callout{background:none!important;border:1px solid #ccc!important}",Jt=z.cssContentValue;function Pn(t,e){const s=document.querySelector(".docs-page .tiptap");if(!s)return null;const n=s.cloneNode(!0);n.querySelectorAll("[data-it-spacer]").forEach(h=>h.remove()),n.querySelectorAll('.it-doc-comment, [data-it-type="comment"]').forEach(h=>h.remove());const o=n.innerHTML,c=Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).map(h=>h.outerHTML).join(`
25
+ `),i=kt(t),p=i.autoHeight?`${i.width}px auto`:`${i.width}px ${i.height}px`,a=`${i.marginTop}px ${i.marginRight}px ${i.marginBottom}px ${i.marginLeft}px`;let m=`@page{size:${p};margin:${a};}`;i.header&&(m+=`@page{@top-center{content:${Jt(i.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`),i.footer&&(m+=`@page{@bottom-center{content:${Jt(i.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);const d=`
26
26
  html,body{margin:0;background:#fff;}
27
27
  .docs-page,.docs-page.docs-sheet{box-shadow:none;border-radius:0;margin:0;width:auto;min-height:0;padding:0;background:#fff;}
28
28
  .docs-page .tiptap{padding:0;}
29
29
  [data-it-spacer]{display:none!important;}
30
- ${e==="minimal-ink"?ie:""}
31
- `;return`<!doctype html><html><head><meta charset="utf-8">${c}<style>${m}${u}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${o}</div></div></body></html>`}function ae(t,e,n){const s=new Blob([t],{type:n}),o=URL.createObjectURL(s),c=document.createElement("a");c.href=o,c.download=e,c.click(),URL.revokeObjectURL(o)}function ce(t,e,n){let s=Rn(t,n);if(!s){const o=R.parseIntentText(t);s=R.renderPrint(o,{theme:e}),n==="minimal-ink"&&(s=En(s,ie))}return s}function Dt(t,e,n="normal"){try{oe(ce(t,e,n))}catch{}}function le(t,e){try{let n=e;if(!n)try{const s=R.parseIntentText(t),c=s.blocks.find(i=>i.type==="meta")?.properties?.id,a=s.blocks.find(i=>i.type==="title")?.content||"";n=`${String(c||a||"document").trim().replace(/[^\w\-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"document"}.it`}catch{n="document.it"}ae(t,n,"text/plain;charset=utf-8")}catch{}}function zn(t,e,n="normal"){try{ae(ce(t,e,n),"document.html","text/html")}catch{}}function de(){return R.listBuiltinThemes()}const Vt="dotit.editor.lastSigner",Jt="dotit.editor.lastRole";function Hn({content:t,onChange:e,trust:n,intact:s}){const[o,c]=p.useState(!1),[a,d]=p.useState(!1),[i,m]=p.useState(()=>localStorage.getItem(Vt)||""),[u,h]=p.useState(()=>localStorage.getItem(Jt)||""),[g,b]=p.useState(!1),k=p.useRef(null),w=p.useRef(0),y=p.useCallback(N=>{const M=Date.now();M-w.current<400||(w.current=M,N())},[]);p.useEffect(()=>{if(!o)return;const N=M=>{k.current&&!k.current.contains(M.target)&&(c(!1),d(!1))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[o]);const x=n.isSealed||R.isSealed(t),z=p.useCallback(()=>{const N=i.trim();if(N){b(!0);try{const M=R.signDocument(t,{signer:N,role:u.trim()||void 0});M.source&&M.source!==t&&e(M.source),localStorage.setItem(Vt,N),u.trim()&&localStorage.setItem(Jt,u.trim())}finally{b(!1),d(!1),c(!1)}}},[t,e,i,u]),D=p.useCallback(()=>{const N=i.trim()||n.signatures[0]?.by||"Document owner";b(!0);try{const M=R.sealDocument(t,{signer:N,role:u.trim()||n.signatures[0]?.role||void 0});M.source&&M.source!==t&&!M.error&&e(M.source)}finally{b(!1),c(!1)}},[t,e,i,u,n.signatures]),F=p.useCallback(()=>{b(!0);try{const N=R.unsealDocument(t);typeof N=="string"&&N!==t&&e(N)}finally{b(!1),c(!1)}},[t,e]),[P,I]=p.useState(null),K=p.useCallback(()=>{try{I(R.verifyDocument(t))}catch{I(null)}},[t]);let _=r.jsx(T.PenTool,{size:15}),H="Draft",G="trust-face--draft";return x?(_=r.jsx(T.FileLock2,{size:15}),H=s===!1?"Sealed · changed!":"Sealed",G=s===!1?"trust-face--broken":"trust-face--sealed"):n.signatures.length>0&&(_=r.jsx(T.ShieldCheck,{size:15}),H=`Signed · ${n.signatures.length}`,G="trust-face--signed"),r.jsxs("div",{className:"trust-control",ref:k,children:[r.jsxs("button",{className:`docs-tb-btn trust-face ${G}`,onClick:()=>{c(N=>!N),d(!1),x&&K()},title:"Document trust — sign, seal, verify",children:[r.jsx("span",{className:"trust-face__icon",children:_}),r.jsx("span",{className:"ribbon-btn-text",children:H}),x&&s===!0&&r.jsx("span",{className:"trust-face__ok",title:"Hash verified",children:"✓"}),r.jsx(T.ChevronDown,{size:12})]}),o&&r.jsxs("div",{className:"trust-popover",children:[r.jsx("div",{className:"trust-popover__state",children:x?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"🔒 Sealed — read-only"}),r.jsxs("div",{className:"trust-popover__meta",children:[n.sealedBy&&r.jsxs(r.Fragment,{children:["by ",n.sealedBy]}),n.sealedAt&&r.jsxs(r.Fragment,{children:[" on ",n.sealedAt]})]})]}):n.signatures.length>0?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:"Signed"}),r.jsx("div",{className:"trust-popover__meta",children:n.signatures.map(N=>N.role?`${N.by} (${N.role})`:N.by).join(" · ")})]}):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("div",{className:"trust-popover__divider"}),x?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"trust-popover__verify",children:[P?P.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,P?.hash&&r.jsxs("details",{className:"trust-popover__hash",children:[r.jsx("summary",{children:"Show hash"}),r.jsx("code",{children:P.hash})]})]}),r.jsxs("button",{className:"trust-popover__action",onClick:()=>y(K),disabled:g,children:[r.jsx(T.ShieldCheck,{size:14})," Re-verify"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--warn",onClick:()=>y(F),disabled:g,title:"Remove the freeze lock (keeps signatures) and make the document editable again",children:[r.jsx(T.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:i,autoFocus:!0,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&z(),N.key==="Escape"&&d(!1)}}),r.jsx("input",{className:"trust-sign-input",placeholder:"Role (optional, e.g. CEO)",value:u,onChange:N=>h(N.target.value),onKeyDown:N=>{N.key==="Enter"&&z(),N.key==="Escape"&&d(!1)}}),r.jsxs("div",{className:"trust-sign-actions",children:[r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:z,disabled:g||!i.trim(),children:[r.jsx(T.PenTool,{size:14})," Add signature"]}),r.jsx("button",{className:"trust-popover__action",onClick:()=>d(!1),children:"Cancel"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:"trust-popover__action",onClick:()=>d(!0),disabled:g,title:"Add a signature line (does not freeze the document)",children:[r.jsx(T.PenTool,{size:14})," Sign"]}),r.jsxs("button",{className:"trust-popover__action trust-popover__action--primary",onClick:()=>y(D),disabled:g,title:"Freeze the document with a tamper-evident hash. It becomes read-only until unsealed.",children:[r.jsx(T.FileLock2,{size:14})," Seal (freeze)"]})]})]})]})}const Nt=[{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"}],Pn=new Set(["history","revision","track","freeze"]),Dn=new Set(["agent","model","meta","context","history"]),In=["identity","structure","content","data","trust","layout"],Qt=[{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"}],Bn=["1","1.15","1.5","2","2.5","3"],On="12px",Fn=["#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"],qn=["#ffffff","#cfe2f3","#d9ead3","#fff2cc","#fce5cd","#f4cccc","#d9d2e9","#ead1dc","#d0e0e3","#e6b8af"];function E({onClick:t,active:e,disabled:n,title:s,children:o}){return r.jsx("button",{className:`docs-tb-btn${e?" active":""}`,onClick:t,disabled:n,title:s,children:o})}function J({label:t,children:e,className:n=""}){return r.jsx("div",{className:`ribbon-group ${n}`.trim(),role:"group","aria-label":t,children:e})}function rt(){return r.jsx("div",{className:"ribbon-sep"})}function Un({editor:t,isRtl:e=!1,onToggleRtl:n,content:s,onChange:o,theme:c,onThemeChange:a,onTrustAction:d,trust:i,sealIntact:m=null,locked:u=!1}){const[h,g]=p.useState(!1),[b,k]=p.useState(!1),[w,y]=p.useState(!1),[x,z]=p.useState(!1),[D,F]=p.useState(!1),[P,I]=p.useState(!1),[K,_]=p.useState(!1),H=p.useRef(null),G=p.useRef(null),N=p.useRef(null),M=p.useRef(null),q=p.useRef(null),tt=p.useRef(null);p.useEffect(()=>{const f=L=>{const C=L.target;H.current&&!H.current.contains(C)&&g(!1),G.current&&!G.current.contains(C)&&k(!1),N.current&&!N.current.contains(C)&&y(!1),M.current&&!M.current.contains(C)&&z(!1),q.current&&!q.current.contains(C)&&F(!1),tt.current&&!tt.current.contains(C)&&I(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const B=()=>{g(!1),k(!1),y(!1),z(!1),F(!1),I(!1)},it=p.useCallback(()=>{if(!t)return"Normal text";for(const f of Nt)if(f.node==="paragraph"&&t.isActive("paragraph")){if(!Nt.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]),pt=p.useCallback(()=>{if(!t)return"Default";const f=t.getAttributes("textStyle")?.fontFamily;if(!f)return"Default";const L=Qt.find(C=>C.value===f);return L?L.label:"Default"},[t]),[et,S]=p.useState(11),[,v]=p.useState(0),A=p.useMemo(()=>{const f=new Map;for(const C of R.LANGUAGE_REGISTRY){if(C.status!=="stable"||Dn.has(C.canonical)||C.category==="agent")continue;const nt=C.category,bt=f.get(nt)||[];bt.push({label:C.canonical,keyword:C.canonical,category:nt,description:C.description,isReadOnly:Pn.has(C.canonical)}),f.set(nt,bt)}const L=[];for(const C of In){const nt=f.get(C);!nt||nt.length===0||(nt.sort((bt,ye)=>bt.keyword.localeCompare(ye.keyword)),L.push({category:Kt[C]?.label||C,items:nt}))}return L},[]);p.useEffect(()=>{if(!t)return;const f=()=>{const L=t.getAttributes("textStyle");if(L?.fontSize){const C=parseInt(L.fontSize,10);isNaN(C)||S(C)}v(C=>C+1)};return t.on("selectionUpdate",f),t.on("transaction",f),()=>{t.off("selectionUpdate",f),t.off("transaction",f)}},[t]);const Y=p.useCallback(f=>{t&&(f==="paragraph"?t.chain().focus().setParagraph().run():f==="itQuote"?t.chain().focus().setNode("itQuote").run():t.chain().focus().setNode(f).run(),B())},[t]),V=p.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(),B()},[t]),U=p.useCallback(f=>{const L=Math.min(96,Math.max(8,et+f));S(L),t?.chain().focus().setFontSize(`${L}pt`).run()},[t,et]),ht=p.useCallback(f=>{t?.chain().focus().setBlockProp("leading",f).run(),B()},[t]),mt=p.useCallback(f=>{if(!t)return;const L=st(t,f);t.chain().focus().setBlockProp(f,L?null:On).run(),B()},[t]),kt=p.useCallback(()=>{if(!t)return;const f=window.prompt("Space before block (e.g. 12px, 1em — empty for none):",st(t,"space-before")||"");if(f===null)return;const L=window.prompt("Space after block (e.g. 12px, 1em — empty for none):",st(t,"space-after")||"");L!==null&&(t.chain().focus().setBlockProp("space-before",f.trim()||null).setBlockProp("space-after",L.trim()||null).run(),B())},[t]),pe=p.useCallback(()=>{if(!t)return;const f=st(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]),fe=p.useCallback(()=>{t&&(t.chain().focus().insertContent({type:"paragraph",attrs:{end:"End text"},content:[{type:"text",text:"Start text"}]}).run(),B())},[t]),ge=p.useMemo(()=>de(),[]),It=K?"minimal-ink":"normal",he=p.useCallback(()=>Dt(s,c,It),[s,c,It]),me=p.useCallback(()=>le(s),[s]);if(!t)return null;const vt=st(t,"leading"),be=!!st(t,"end");return r.jsxs("div",{className:"docs-toolbar docs-ribbon",children:[r.jsxs(J,{label:"Edit",children:[r.jsx(E,{onClick:()=>t.chain().focus().undo().run(),disabled:u||!t.can().undo(),title:"Undo (⌘Z)",children:r.jsx(T.Undo2,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().redo().run(),disabled:u||!t.can().redo(),title:"Redo (⌘⇧Z)",children:r.jsx(T.Redo2,{size:16})})]}),r.jsx(rt,{}),r.jsxs(J,{label:"File",children:[r.jsxs(E,{onClick:me,title:"Save / Download the .it file",children:[r.jsx(T.Download,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"Save"})]}),r.jsxs(E,{onClick:he,title:"Export PDF (⌘P) — WYSIWYG",children:[r.jsx(T.Printer,{size:16}),r.jsx("span",{className:"ribbon-btn-text",children:"PDF"})]}),r.jsx(E,{onClick:()=>_(f=>!f),active:K,title:"Minimal ink mode (plain callouts when printing)",children:r.jsx(T.Droplets,{size:16})}),r.jsx("select",{className:"ribbon-theme-select",value:c,onChange:f=>a(f.target.value),title:"Document theme (used everywhere — canvas, print, export)",children:ge.map(f=>r.jsx("option",{value:f,children:f.charAt(0).toUpperCase()+f.slice(1)},f))})]}),r.jsx(rt,{}),r.jsxs("div",{className:u?"ribbon-locked":"ribbon-editing",children:[r.jsx(J,{label:"Style",children:r.jsxs("div",{className:"docs-tb-dropdown",ref:H,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-paragraph-select",onClick:()=>{B(),g(!h)},children:[r.jsx("span",{className:"docs-tb-select-label",children:it()}),r.jsx(T.ChevronDown,{size:14})]}),h&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-style-menu",children:Nt.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${it()===f.label?" active":""}`,onClick:()=>Y(f.node),children:r.jsx("span",{className:`docs-style-preview docs-style-${f.node}`,children:f.label})},f.node))})]})}),r.jsx(rt,{}),r.jsxs(J,{label:"Font",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:N,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-font-select",onClick:()=>{B(),y(!w)},children:[r.jsx("span",{className:"docs-tb-select-label",children:pt()}),r.jsx(T.ChevronDown,{size:14})]}),w&&r.jsx("div",{className:"docs-tb-dropdown-menu docs-font-menu",children:Qt.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${pt()===f.label?" active":""}`,style:{fontFamily:f.value||"inherit"},onClick:()=>{f.value?t.chain().focus().setFontFamily(f.value).run():t.chain().focus().unsetFontFamily().run(),B()},children:f.label},f.value||"default"))})]}),r.jsx(E,{onClick:()=>U(-1),title:"Decrease font size",children:r.jsx(T.Minus,{size:14})}),r.jsx("span",{className:"docs-tb-fontsize",children:et}),r.jsx(E,{onClick:()=>U(1),title:"Increase font size",children:r.jsx(T.Plus,{size:14})})]}),r.jsx(rt,{}),r.jsxs(J,{label:"Text",children:[r.jsx(E,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (⌘B)",children:r.jsx(T.Bold,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (⌘I)",children:r.jsx(T.Italic,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (⌘U)",children:r.jsx(T.Underline,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough (⌘⇧X)",children:r.jsx(T.Strikethrough,{size:16})}),r.jsxs("div",{className:"docs-tb-dropdown docs-tb-color-dropdown",ref:M,children:[r.jsxs("button",{className:"docs-tb-btn docs-tb-color-btn",onClick:()=>{B(),z(!x)},title:"Text color",children:[r.jsx(T.Palette,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("textStyle")?.color||"#000000"}})]}),x&&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:Fn.map(f=>r.jsx("button",{className:"docs-color-swatch",style:{background:f},title:f,onClick:()=>{t.chain().focus().setColor(f).run(),B()}},f))}),r.jsxs("button",{className:"docs-tb-dropdown-item",onClick:()=>{t.chain().focus().unsetColor().run(),B()},children:[r.jsx(T.RemoveFormatting,{size:14})," Reset"]})]})]}),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:()=>{B(),F(!D)},title:"Highlight color",children:[r.jsx(T.Highlighter,{size:16}),r.jsx("span",{className:"docs-tb-color-indicator",style:{background:t.getAttributes("highlight")?.color||"transparent"}})]}),D&&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:qn.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(),B()}},f))})]})]}),r.jsx(E,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline code",children:r.jsx(T.Code,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().unsetAllMarks().clearNodes().run(),title:"Clear formatting",children:r.jsx(T.RemoveFormatting,{size:16})})]}),r.jsx(rt,{}),r.jsxs(J,{label:"Paragraph",children:[r.jsx(E,{onClick:()=>t.chain().focus().setTextAlign("left").run(),active:t.isActive({textAlign:"left"}),title:"Align left",children:r.jsx(T.AlignLeft,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().setTextAlign("center").run(),active:t.isActive({textAlign:"center"}),title:"Align center",children:r.jsx(T.AlignCenter,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().setTextAlign("right").run(),active:t.isActive({textAlign:"right"}),title:"Align right",children:r.jsx(T.AlignRight,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),active:t.isActive({textAlign:"justify"}),title:"Justify",children:r.jsx(T.AlignJustify,{size:16})}),r.jsx(E,{onClick:()=>n?.(),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:tt,children:[r.jsxs("button",{className:`docs-tb-btn${vt?" active":""}`,onClick:()=>{B(),I(!P)},title:"Line & paragraph spacing",children:[r.jsx(T.Rows3,{size:16}),r.jsx(T.ChevronDown,{size:12})]}),P&&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${vt?"":" active"}`,onClick:()=>ht(null),children:"Default"}),Bn.map(f=>r.jsx("button",{className:`docs-tb-dropdown-item${vt===f?" active":""}`,onClick:()=>ht(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:()=>mt("space-before"),children:st(t,"space-before")?"Remove space before block":"Add space before block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:()=>mt("space-after"),children:st(t,"space-after")?"Remove space after block":"Add space after block"}),r.jsx("button",{className:"docs-tb-dropdown-item",onClick:kt,children:"Custom spacing…"})]})]}),r.jsx(E,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet list",children:r.jsx(T.List,{size:16})}),r.jsx(E,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Numbered list",children:r.jsx(T.ListOrdered,{size:16})})]}),r.jsx(rt,{}),r.jsxs(J,{label:"Insert",children:[r.jsxs("div",{className:"docs-tb-dropdown",ref:G,children:[r.jsxs("button",{className:"docs-tb-select docs-tb-insert-select",onClick:()=>{B(),k(!b)},children:[r.jsx(T.Plus,{size:15}),r.jsx("span",{children:"Insert"}),r.jsx(T.ChevronDown,{size:14})]}),b&&r.jsxs("div",{className:"docs-tb-dropdown-menu docs-insert-menu",children:[r.jsxs("button",{className:"docs-tb-dropdown-item docs-insert-item",onClick:fe,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(T.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:()=>V(C.keyword),disabled:C.isReadOnly,title:C.description,children:[r.jsx("span",{className:"docs-insert-icon",children:Kt[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(E,{onClick:pe,active:be,title:"Two-sided row — set the text shown at the END of this line (end: property)",children:r.jsx(T.AlignHorizontalSpaceBetween,{size:16})})]})]}),i&&o?r.jsxs(r.Fragment,{children:[r.jsx(rt,{}),r.jsx(J,{label:"Trust",children:r.jsx(Hn,{content:s,onChange:o,trust:i,intact:m})})]}):d&&r.jsxs(r.Fragment,{children:[r.jsx(rt,{}),r.jsxs(J,{label:"Trust",children:[r.jsx(E,{onClick:()=>d("seal"),disabled:u,title:"Seal — freeze the document with a tamper-evident hash",children:r.jsx("span",{className:"ribbon-btn-text",children:"Seal"})}),r.jsx(E,{onClick:()=>d("sign"),title:"Sign",children:r.jsx("span",{className:"ribbon-btn-text",children:"Sign"})}),r.jsx(E,{onClick:()=>d("verify"),title:"Verify",children:r.jsx("span",{className:"ribbon-btn-text",children:"Verify"})})]})]})]})}const Wn={in:96,cm:96/2.54},Gn={in:.25,cm:.5};function ue(t,e){const n=Wn[e],s=Gn[e],o=[],c=t/n;for(let a=0;a<=c+1e-6;a+=s){const d=Math.abs(a-Math.round(a))<1e-6;o.push({x:a*n,kind:d?"major":"minor",label:d&&a>0?String(Math.round(a)):void 0})}return o}function Kn({geometry:t,zoom:e,scrollEl:n,onMargins:s,locked:o=!1}){const[c,a]=p.useState(0),[d,i]=p.useState(null),m=p.useRef(null);p.useEffect(()=>{const k=n.current;if(!k)return;const w=()=>a(k.scrollLeft);return w(),k.addEventListener("scroll",w,{passive:!0}),()=>k.removeEventListener("scroll",w)},[n]);const u=p.useMemo(()=>ue(t.width,t.unit),[t.width,t.unit]),h=p.useCallback(k=>w=>{!s||o||(w.preventDefault(),i(k))},[s,o]);p.useEffect(()=>{if(!d||!s)return;const k=y=>{const x=m.current;if(!x)return;const z=x.getBoundingClientRect(),D=(y.clientX-z.left)/e;if(d==="left"){const F=Math.max(0,Math.min(D,t.width/2));s({left:F})}else{const F=Math.max(0,Math.min(t.width-D,t.width/2));s({right:F})}},w=()=>i(null);return window.addEventListener("pointermove",k),window.addEventListener("pointerup",w),()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",w)}},[d,s,e,t.width]);const g=t.width*e,b=!!s&&!o;return r.jsx("div",{className:`docs-ruler${b?" 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}}),u.map((k,w)=>k.label?r.jsx("span",{className:"docs-ruler-num",style:{left:k.x*e},children:k.label},w):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--${k.kind}`,style:{left:k.x*e}},w)),b&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--h${d==="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${d==="right"?" dragging":""}`,style:{left:(t.width-t.marginRight)*e},onPointerDown:h("right"),title:"Drag to set the right margin"})]})]})})}function Yn({geometry:t,zoom:e,scrollEl:n,onMargins:s,locked:o=!1,topOffset:c=0}){const[a,d]=p.useState(0),[i,m]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{const y=n.current;if(!y)return;const x=()=>d(y.scrollTop);return x(),y.addEventListener("scroll",x,{passive:!0}),()=>y.removeEventListener("scroll",x)},[n]);const h=t.autoHeight?t.width*1.414:t.height,g=p.useMemo(()=>ue(h,t.unit),[h,t.unit]),b=p.useCallback(y=>x=>{!s||o||t.autoHeight||(x.preventDefault(),m(y))},[s,o,t.autoHeight]);p.useEffect(()=>{if(!i||!s)return;const y=z=>{const D=u.current;if(!D)return;const F=D.getBoundingClientRect(),P=(z.clientY-F.left)/e;if(i==="top"){const I=Math.max(0,Math.min(P,h/2));s({top:I})}else{const I=Math.max(0,Math.min(h-P,h/2));s({bottom:I})}},x=()=>m(null);return window.addEventListener("pointermove",y),window.addEventListener("pointerup",x),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",x)}},[i,s,e,h]);const k=h*e,w=!!s&&!o&&!t.autoHeight;return r.jsx("div",{className:"docs-ruler-v",children:r.jsxs("div",{ref:u,className:"docs-ruler-v-track",style:{height:k,transform:`translateY(${c-a}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((y,x)=>y.label?r.jsx("span",{className:"docs-ruler-num docs-ruler-num--v",style:{top:y.x*e},children:y.label},x):r.jsx("span",{className:`docs-ruler-tick docs-ruler-tick--v docs-ruler-tick--${y.kind}`,style:{top:y.x*e}},x)),w&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${i==="top"?" dragging":""}`,style:{top:t.marginTop*e},onPointerDown:b("top"),title:"Drag to set the top margin"}),r.jsx("span",{className:`docs-ruler-stop docs-ruler-stop--v${i==="bottom"?" dragging":""}`,style:{top:(h-t.marginBottom)*e},onPointerDown:b("bottom"),title:"Drag to set the bottom margin"})]})]})})}function Ct(t,e){return e?`${t} (${e})`:t}function Vn({trust:t,intact:e}){if(t.isSealed){const n=t.sealedBy||"unknown",s=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 ",Ct(n,s),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"})]})}return t.signatures.length>0?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=>`${Ct(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]})]}):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(n=>`${Ct(n.by,n.role)}${n.at?` on ${n.at}`:""}`).join(" · ")]})]}):null}function Jn(t){let e;try{e=R.parseIntentText(t)}catch{return[]}const n=[],s=(o,c)=>{const a=c==null?"":String(c).trim();a&&n.push({key:o,value:a})};for(const o of e.blocks)switch(o.type){case"meta":for(const[c,a]of Object.entries(o.properties||{}))s(c,a);break;case"track":s("tracked",o.properties?.id??o.content);break;case"page":{const c=o.properties?.orientation;s("page",[o.content,c].filter(Boolean).join(" · "));break}case"font":s("font",[o.content||o.properties?.family,o.properties?.size].filter(Boolean).join(" · "));break;case"header":s("header",o.content);break;case"footer":s("footer",o.content);break;case"watermark":s("watermark",o.content);break}return n}function Qn({source:t}){const[e,n]=p.useState(!1),s=p.useMemo(()=>Jn(t),[t]);if(s.length===0)return null;const o=s.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:()=>n(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:s.map((c,a)=>r.jsxs("span",{className:"docs-props-chip",children:[r.jsx("b",{children:c.key})," ",c.value]},`${c.key}-${a}`))})]})}function O(t,e,n=""){const s=t?.properties?.[e];return s!=null?String(s):n}function Mt(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 n=t.blocks,s=n.find(i=>i.type==="track");s&&(e.isTracked=!0,e.lifecycle="tracked",e.trackBlock={id:O(s,"id",s.content??""),by:O(s,"by"),at:O(s,"at")});const o=n.filter(i=>i.type==="approve");for(const i of o)e.approvals.push({by:O(i,"by",i.content??""),role:O(i,"role"),at:O(i,"at"),note:O(i,"note")||void 0});e.approvals.length>0&&(e.lifecycle="approved");const c=n.filter(i=>i.type==="sign");for(const i of c)e.signatures.push({by:O(i,"by",i.content??""),role:O(i,"role"),at:O(i,"at")});e.signatures.length>0&&(e.lifecycle="signed");const a=n.find(i=>i.type==="freeze");if(a){e.isSealed=!0,e.lifecycle="sealed";const i=e.signatures[e.signatures.length-1];e.sealedBy=i?.by||O(a,"by",a.content??""),e.sealedAt=O(a,"at")||i?.at||"",e.sealHash=O(a,"hash")}const d=n.filter(i=>i.type==="amendment");for(const i of d)e.amendments.push({section:O(i,"section",i.content??""),was:O(i,"was"),now:O(i,"now"),by:O(i,"by"),ref:O(i,"ref"),at:O(i,"at")});return e}const Xt=new ut.PluginKey("template-highlight"),St=/\{\{[^}]+\}\}/g;function Zt(t){const e=[];return t.descendants((n,s)=>{if(!n.isText||!n.text)return;St.lastIndex=0;let o;for(;o=St.exec(n.text);)e.push(ct.Decoration.inline(s+o.index,s+o.index+o[0].length,{class:"it-doc-var"}))}),ct.DecorationSet.create(t,e)}const Xn=j.Extension.create({name:"templateHighlight",addProseMirrorPlugins(){return[new ut.Plugin({key:Xt,state:{init:(t,e)=>Zt(e.doc),apply:(t,e)=>t.docChanged?Zt(t.doc):e},props:{decorations(t){return Xt.getState(t)}}})]}});function Zn(t){const e=new Set,n=[];St.lastIndex=0;let s;for(;s=St.exec(t);){const o=s[0].slice(2,-2).trim();/^(page|pages|date|time|year)$/i.test(o)||e.has(o)||(e.add(o),n.push(o))}return n}function ts(t){const e={};for(const n of t){const s=n.split(".");let o=e;for(let c=0;c<s.length;c++){const a=s[c];c===s.length-1?a in o||(o[a]=""):((!(a in o)||typeof o[a]!="object"||o[a]===null)&&(o[a]={}),o=o[a])}}return e}function es(t,e,n){const s=t.coordsAtPos(e),o=s.top+1,c=s.bottom-1,a=n==="start"?-1:1;let d=e,i=e;for(let m=0;m<1e5;m++){const u=d+a;if(u<0||u>t.state.doc.content.size)break;let h;try{h=t.coordsAtPos(u)}catch{break}if(h.bottom<=o||h.top>=c)break;d=u,i=u}return i}const ns=j.Extension.create({name:"lineKeymap",addKeyboardShortcuts(){const t=(e,n)=>{const{view:s}=this.editor,{state:o}=s,{selection:c}=o,a=c.head,d=es(s,a,e);if(d==null||d===a)return!1;const i=o.doc.resolve(d),m=n?c.anchor:d,u=o.tr.setSelection(n?ut.TextSelection.between(o.doc.resolve(m),i):ut.TextSelection.near(i));return s.dispatch(u.scrollIntoView()),!0};return{Home:()=>t("start",!1),End:()=>t("end",!1),"Shift-Home":()=>t("start",!0),"Shift-End":()=>t("end",!0)}}}),ss=28,rs={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 os({value:t,onChange:e,theme:n,onThemeChange:s,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:a=!0,onTrustAction:d}){const i=p.useRef(""),m=p.useRef(!1),u=p.useRef(!0),[h,g]=p.useState([]),b=p.useRef(xt("")),[k,w]=p.useState(1),y=Bt.useEditor({extensions:[Ge.configure({geometry:()=>b.current,gap:ss,onPages:w}),Le.default.configure({heading:!1,codeBlock:!1,blockquote:!1,horizontalRule:!1,paragraph:!1}),$n,Mn,ns,_e.default,ke.TextStyle,$e.default,Me.default.configure({multicolor:!0}),Ee.default.configure({types:["paragraph","itTitle","itSummary","itSection","itSub"]}),Re.default,De,ze.default,He.default,fn,gn,hn,mn,bn,yn,xn,Sn,vn,kn,wn,jn,Tn,Nn,Cn,An,Xn],content:$t(t),onUpdate:({editor:S})=>{if(u.current)return;const v=S.getJSON(),A=ee(v);i.current=A,m.current=!0,g(rn(v)),e(A)},editorProps:{attributes:{class:"docs-page-content",spellcheck:"true"}}});p.useEffect(()=>{const S=window.setTimeout(()=>{u.current=!1,i.current=t},0);return()=>window.clearTimeout(S)},[]),p.useEffect(()=>{if(y){if(m.current){m.current=!1;return}if(t!==i.current){const S=$t(t);y.commands.setContent(S),i.current=t}}},[t,y]),p.useEffect(()=>{if(!y)return;const S=v=>{const A=v.detail;A&&y.chain().focus().insertContent(A).run()};return window.addEventListener("it-insert-text",S),()=>window.removeEventListener("it-insert-text",S)},[y]);const x=p.useMemo(()=>xt(t),[t]);p.useEffect(()=>{b.current=x,y?.view.dispatch(y.state.tr)},[x,y]);const z=p.useRef(null),D=p.useCallback(()=>y?y.storage.characterCount?.words?.()??y.getText().split(/\s+/).filter(Boolean).length:0,[y]),F=p.useMemo(()=>{if(!n)return"";try{const S=R.getBuiltinTheme(n);return S?R.generateThemeCSS(S).replace(/:root\{/,".docs-page{"):""}catch{return""}},[n]),P=p.useMemo(()=>{try{const S=R.parseIntentText(t),v=S.blocks.find(U=>U.type==="header")?.content||"",A=S.blocks.find(U=>U.type==="footer")?.content||"",Y=S.blocks.find(U=>U.type==="meta"),V=String(Y?.properties?.dir||"ltr").toLowerCase();return{header:v,footer:A,dir:V}}catch{return{header:"",footer:"",dir:"ltr"}}},[t]),I=p.useMemo(()=>{try{return Mt(R.parseIntentText(t))}catch{return Mt(null)}},[t]),K=p.useMemo(()=>{if(!I.isSealed)return null;try{return R.verifyDocument(t).intact}catch{return null}},[t,I.isSealed]),_=I.isSealed||o;p.useEffect(()=>{y&&y.isEditable!==!_&&y.setEditable(!_)},[y,_]),p.useEffect(()=>{if(!y)return;y.view.dom.setAttribute("dir",P.dir==="rtl"?"rtl":"ltr")},[y,P.dir]);const H=p.useMemo(()=>{try{return R.documentStyleCSS(R.parseIntentText(t),rs,".docs-page .tiptap ")}catch{return""}},[t]);p.useEffect(()=>{let S=document.getElementById("it-doc-style-rules");S||(S=document.createElement("style"),S.id="it-doc-style-rules",document.head.appendChild(S)),S.textContent=H},[H]);const G=p.useCallback(()=>{const S=P.dir==="rtl";e(R.upsertMetaProperty(t,"dir",S?null:"rtl"))},[t,e,P.dir]),N=p.useCallback(S=>{const v=b.current,A=kt=>Math.max(0,Math.round(kt/Q*10)/10),Y=A(S.top??v.marginTop),V=A(S.right??v.marginRight),U=A(S.bottom??v.marginBottom),ht=A(S.left??v.marginLeft),mt=`${Y}mm ${V}mm ${U}mm ${ht}mm`;e(Ue(t,mt))},[t,e]);p.useEffect(()=>{const S="it-editor-theme-css";let v=document.getElementById(S);v||(v=document.createElement("style"),v.id=S,document.head.appendChild(v)),v.textContent=F},[F]);const M=p.useRef(null),[q,tt]=p.useState(1),B=p.useRef(q),it=p.useRef(null),pt=p.useCallback(S=>{const v=M.current;if(!v)return;const A=v.getBoundingClientRect();it.current={cx:v.scrollLeft+(S.clientX-A.left),cy:v.scrollTop+(S.clientY-A.top)}},[]),et=p.useCallback(()=>{const S=M.current;S&&(it.current={cx:S.scrollLeft+S.clientWidth/2,cy:S.scrollTop+S.clientHeight/2})},[]);return p.useLayoutEffect(()=>{const S=M.current,v=it.current,A=B.current;if(!S||!v||A===q)return;const Y=q/A;S.getBoundingClientRect();const V=v.cx-S.scrollLeft,U=v.cy-S.scrollTop;S.scrollLeft=v.cx*Y-V,S.scrollTop=v.cy*Y-U,it.current=null,B.current=q},[q]),p.useEffect(()=>{const S=v=>{if(v.metaKey||v.ctrlKey){if(v.key==="p"||v.key==="P"){v.preventDefault(),Dt(t,n);return}v.key==="="||v.key==="+"?(v.preventDefault(),et(),tt(A=>Math.min(2,+(A+.1).toFixed(2)))):v.key==="-"?(v.preventDefault(),et(),tt(A=>Math.max(.25,+(A-.1).toFixed(2)))):v.key==="0"&&(v.preventDefault(),et(),tt(1))}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[et,t,n]),p.useEffect(()=>{const S=M.current;if(!S)return;const v=A=>{if(A.ctrlKey||A.metaKey){A.preventDefault();const Y=A.deltaY>0?-.1:.1;pt(A),tt(V=>Math.min(2,Math.max(.25,+(V+Y).toFixed(2))))}};return S.addEventListener("wheel",v,{passive:!1}),()=>S.removeEventListener("wheel",v)},[pt]),r.jsxs("div",{className:"docs-container",children:[c&&r.jsx(Un,{editor:y,isRtl:P.dir==="rtl",onToggleRtl:G,content:t,onChange:e,theme:n,onThemeChange:s,onTrustAction:d,trust:I,sealIntact:K,locked:_}),a&&r.jsx(Vn,{trust:I,intact:K}),a&&r.jsx(Qn,{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(Kn,{geometry:x,zoom:q,scrollEl:M,onMargins:N,locked:_}),r.jsxs("div",{className:"docs-canvas-row",children:[r.jsx(Yn,{geometry:x,zoom:q,scrollEl:M,onMargins:N,locked:_}),r.jsxs("div",{className:"docs-canvas",ref:M,children:[r.jsx("div",{className:"docs-page-scaler",style:{width:x.width*q},children:r.jsx("div",{className:"docs-page-flow",dir:P.dir,style:{transform:q!==1?`scale(${q})`:void 0,transformOrigin:"top left"},children:r.jsxs("div",{className:"docs-page docs-sheet",ref:z,style:{width:x.width,minHeight:x.autoHeight?x.width:void 0,"--page-mx-l":`${x.marginLeft}px`,"--page-mx-r":`${x.marginRight}px`},children:[r.jsx("div",{className:"docs-sheet-header","data-it-spacer":"",style:{height:x.autoHeight?void 0:x.marginTop},children:r.jsx("div",{className:"docs-pb-header",children:r.jsx("span",{className:"docs-pb-text",children:x.autoHeight?"":Et(x.header,1,k)})})}),r.jsx(Bt.EditorContent,{editor:y})]})})}),r.jsxs("div",{className:"docs-page-footer",children:[k," ",k===1?"page":"pages"," ·"," ",D()," words",q!==1&&r.jsxs("span",{className:"zoom-indicator",children:[" ","· ",Math.round(q*100),"%"]})]})]})]})]})}const is="corporate";function as({value:t,onChange:e,theme:n,onThemeChange:s,readOnly:o=!1,showRibbon:c=!0,showTrustBanner:a=!0,onTrustAction:d}){const[i,m]=p.useState(n??is),u=n??i,h=p.useCallback(g=>{m(g),s?.(g)},[s]);return r.jsx(os,{value:t,onChange:e,theme:u,onThemeChange:h,readOnly:o,showRibbon:c,showTrustBanner:a,onTrustAction:d})}exports.IntentTextEditor=as;exports.buildSampleSkeleton=ts;exports.builtinThemes=de;exports.docToSource=ee;exports.downloadItFile=le;exports.exportDocumentHTML=zn;exports.exportDocumentPDF=Dt;exports.extractTemplateVariables=Zn;exports.extractTrustState=Mt;exports.getPageGeometry=xt;exports.printHtmlViaIframe=oe;exports.resolvePageTokens=Et;exports.sourceToDoc=$t;
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;
32
32
  //# sourceMappingURL=index.cjs.map