@dotit/editor 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,23 +1,22 @@
1
- import { jsxs as b, jsx as a, Fragment as me } from "react/jsx-runtime";
2
- import { useState as P, useRef as B, useEffect as j, useCallback as R, useMemo as Y, useLayoutEffect as be } from "react";
3
- import { useEditor as ye, EditorContent as ke } from "@tiptap/react";
4
- import Se from "@tiptap/starter-kit";
5
- import we from "@tiptap/extension-placeholder";
6
- import ve from "@tiptap/extension-underline";
7
- import { TextStyle as Te } from "@tiptap/extension-text-style";
8
- import xe from "@tiptap/extension-color";
9
- import Le from "@tiptap/extension-highlight";
10
- import Ae from "@tiptap/extension-text-align";
11
- import Ce from "@tiptap/extension-font-family";
12
- import Ne from "@tiptap/extension-subscript";
13
- import $e from "@tiptap/extension-superscript";
14
- import { Extension as vt, Node as E, mergeAttributes as _ } from "@tiptap/core";
15
- import { Plugin as Xt, PluginKey as te } from "@tiptap/pm/state";
16
- import { DecorationSet as St, Decoration as Nt } from "@tiptap/pm/view";
17
- import { parseIntentText as et, listBuiltinThemes as Me, renderPrint as ze, cssContentValue as _e, LANGUAGE_REGISTRY as He, getBuiltinTheme as Re, generateThemeCSS as Ee, verifyDocument as Pe, documentStyleCSS as Be } from "@dotit/core";
18
- import Ie from "@tiptap/extension-paragraph";
19
- import { Undo2 as Oe, Redo2 as De, Printer as Fe, FileCode2 as je, Droplets as We, ChevronDown as yt, Minus as Ge, Plus as Bt, Bold as Ue, Italic as Ye, Underline as Ke, Strikethrough as qe, Palette as Je, RemoveFormatting as It, Highlighter as Ve, Code as Qe, AlignLeft as Ze, AlignCenter as Xe, AlignRight as tn, AlignJustify as en, Rows3 as nn, List as rn, ListOrdered as on, AlignHorizontalSpaceBetween as Ot, FileLock2 as sn, PenTool as an, ShieldCheck as cn } from "lucide-react";
20
- const ln = vt.create({
1
+ import { jsxs as g, jsx as s, Fragment as J } from "react/jsx-runtime";
2
+ import { useState as z, useRef as U, useCallback as M, useEffect as W, useMemo as Q, useLayoutEffect as Me } from "react";
3
+ import { useEditor as Ee, EditorContent as ze } from "@tiptap/react";
4
+ import He from "@tiptap/starter-kit";
5
+ import Re from "@tiptap/extension-underline";
6
+ import { TextStyle as Pe } from "@tiptap/extension-text-style";
7
+ import Be from "@tiptap/extension-color";
8
+ import Ie from "@tiptap/extension-highlight";
9
+ import De from "@tiptap/extension-text-align";
10
+ import Oe from "@tiptap/extension-font-family";
11
+ import Fe from "@tiptap/extension-subscript";
12
+ import je from "@tiptap/extension-superscript";
13
+ import { Extension as vt, Node as Y, mergeAttributes as F } from "@tiptap/core";
14
+ import { Plugin as ue, PluginKey as pe, TextSelection as Wt } from "@tiptap/pm/state";
15
+ import { DecorationSet as xt, Decoration as Ht } from "@tiptap/pm/view";
16
+ import { parseIntentText as rt, listBuiltinThemes as Ue, renderPrint as We, cssContentValue as Ge, isSealed as Ye, signDocument as Ke, sealDocument as qe, unsealDocument as Ve, verifyDocument as fe, LANGUAGE_REGISTRY as Je, getBuiltinTheme as Qe, generateThemeCSS as Xe, documentStyleCSS as Ze, upsertMetaProperty as tn } from "@dotit/core";
17
+ import en from "@tiptap/extension-paragraph";
18
+ import { ChevronDown as yt, ShieldCheck as Gt, LockOpen as nn, PenTool as Ct, FileLock2 as Yt, Undo2 as rn, Redo2 as on, Download as sn, Printer as an, Droplets as cn, Minus as ln, Plus as Kt, Bold as dn, Italic as un, Underline as pn, Strikethrough as fn, Palette as gn, RemoveFormatting as qt, Highlighter as hn, Code as mn, AlignLeft as bn, AlignCenter as yn, AlignRight as vn, AlignJustify as kn, Rows3 as Sn, List as wn, ListOrdered as Tn, AlignHorizontalSpaceBetween as Vt } from "lucide-react";
19
+ const xn = vt.create({
21
20
  name: "fontSize",
22
21
  addOptions() {
23
22
  return { types: ["textStyle"] };
@@ -42,30 +41,30 @@ const ln = vt.create({
42
41
  unsetFontSize: () => ({ chain: t }) => t().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
43
42
  };
44
43
  }
45
- }), tt = 96 / 25.4, kt = {
44
+ }), nt = 96 / 25.4, Tt = {
46
45
  A4: [210, 297],
47
46
  A5: [148, 210],
48
47
  A3: [297, 420],
49
48
  Letter: [215.9, 279.4],
50
49
  Legal: [215.9, 355.6],
51
50
  Tabloid: [279.4, 431.8]
52
- }, dn = {
51
+ }, Nn = {
53
52
  A4: "cm",
54
53
  A5: "cm",
55
54
  A3: "cm",
56
55
  LETTER: "in",
57
56
  LEGAL: "in",
58
57
  TABLOID: "in"
59
- }, un = 20, pn = 4, fn = 120;
60
- function $t(t) {
58
+ }, Ln = 20, An = 4, Cn = 120;
59
+ function Rt(t) {
61
60
  const e = /^(-?\d+(?:\.\d+)?)\s*(mm|cm|in|px|pt)?$/.exec(t.trim());
62
61
  if (!e) return null;
63
62
  const n = parseFloat(e[1]);
64
63
  switch (e[2] || "mm") {
65
64
  case "mm":
66
- return n * tt;
65
+ return n * nt;
67
66
  case "cm":
68
- return n * 10 * tt;
67
+ return n * 10 * nt;
69
68
  case "in":
70
69
  return n * 96;
71
70
  case "pt":
@@ -76,62 +75,77 @@ function $t(t) {
76
75
  return null;
77
76
  }
78
77
  }
79
- function gn(t, e) {
80
- const n = t.trim().split(/\s+/).map($t);
78
+ function $n(t, e) {
79
+ const n = t.trim().split(/\s+/).map(Rt);
81
80
  if (n.some((o) => o === null) || n.length === 0)
82
81
  return [e, e, e, e];
83
82
  const r = n;
84
83
  return r.length === 1 ? [r[0], r[0], r[0], r[0]] : r.length === 2 ? [r[0], r[1], r[0], r[1]] : r.length === 3 ? [r[0], r[1], r[2], r[1]] : [r[0], r[1], r[2], r[3]];
85
84
  }
86
- function Mt(t) {
85
+ function Pt(t) {
87
86
  let e = "A4", n, r = "", o = "";
88
87
  try {
89
- const C = et(t), w = C.blocks.find((I) => I.type === "page")?.properties || {};
90
- w.size && (e = String(w.size)), n = w.margin ?? w.margins, r = C.blocks.find((I) => I.type === "header")?.content || String(w.header || ""), o = C.blocks.find((I) => I.type === "footer")?.content || String(w.footer || "");
88
+ const T = rt(t), v = T.blocks.find((H) => H.type === "page")?.properties || {};
89
+ v.size && (e = String(v.size)), n = v.margin ?? v.margins, r = T.blocks.find((H) => H.type === "header")?.content || String(v.header || ""), o = T.blocks.find((H) => H.type === "footer")?.content || String(v.footer || "");
91
90
  } catch {
92
91
  }
93
- let l = kt.A4[0] * tt, c = kt.A4[1] * tt, d = !1, s = "cm";
94
- const f = kt[e] || kt[e.toUpperCase?.()];
95
- if (f)
96
- l = f[0] * tt, c = f[1] * tt, s = dn[e.toUpperCase()] || "cm";
92
+ let c = Tt.A4[0] * nt, a = Tt.A4[1] * nt, d = !1, i = "cm";
93
+ const m = Tt[e] || Tt[e.toUpperCase?.()];
94
+ if (m)
95
+ c = m[0] * nt, a = m[1] * nt, i = Nn[e.toUpperCase()] || "cm";
97
96
  else {
98
- const C = e.trim().split(/\s+/), v = C[0] ? $t(C[0]) : null;
99
- if (v && (l = v), /(\d)\s*in\b/.test(e) && (s = "in"), C[1] === "auto")
100
- d = !0, c = 1 / 0;
97
+ const T = e.trim().split(/\s+/), y = T[0] ? Rt(T[0]) : null;
98
+ if (y && (c = y), /(\d)\s*in\b/.test(e) && (i = "in"), T[1] === "auto")
99
+ d = !0, a = 1 / 0;
101
100
  else {
102
- const w = C[1] ? $t(C[1]) : null;
103
- w && (c = w);
101
+ const v = T[1] ? Rt(T[1]) : null;
102
+ v && (a = v);
104
103
  }
105
104
  }
106
- const p = (l <= fn * tt ? pn : un) * tt, [h, g, k, M] = n ? gn(n, p) : [p, p, p, p];
105
+ const u = (c <= Cn * nt ? An : Ln) * nt, [h, f, b, S] = n ? $n(n, u) : [u, u, u, u];
107
106
  return {
108
- width: l,
109
- height: c,
107
+ width: c,
108
+ height: a,
110
109
  autoHeight: d,
111
110
  marginTop: h,
112
- marginRight: g,
113
- marginBottom: k,
114
- marginLeft: M,
115
- contentHeight: d ? 1 / 0 : c - h - k,
111
+ marginRight: f,
112
+ marginBottom: b,
113
+ marginLeft: S,
114
+ contentHeight: d ? 1 / 0 : a - h - b,
116
115
  header: r,
117
116
  footer: o,
118
- unit: s
117
+ unit: i
119
118
  };
120
119
  }
121
- function ee(t, e, n) {
120
+ function _n(t, e) {
121
+ const n = t.split(`
122
+ `), r = n.findIndex((a) => /^\s*page\s*:/i.test(a));
123
+ if (r >= 0) {
124
+ let a = n[r].replace(/\s*\|\s*margins?\s*:[^|]*/gi, "").replace(/\s+$/, "");
125
+ return a = `${a} | margin: ${e}`, n[r] = a, n.join(`
126
+ `);
127
+ }
128
+ const o = n.findIndex(
129
+ (a) => a.trim() && !/^\s*(meta|title|summary)\s*:/i.test(a)
130
+ ), c = `page: A4 | margin: ${e}`;
131
+ return o <= 0 ? `${c}
132
+ ${t}` : (n.splice(o, 0, c), n.join(`
133
+ `));
134
+ }
135
+ function ge(t, e, n) {
122
136
  return t.replace(/\{\{\s*page\s*\}\}/g, String(e)).replace(/\{\{\s*pages\s*\}\}/g, String(n));
123
137
  }
124
- const ft = new te("pagination");
125
- function xt(t, e, n, r) {
126
- const o = ee(e, n, r);
138
+ const mt = new pe("pagination");
139
+ function $t(t, e, n, r) {
140
+ const o = ge(e, n, r);
127
141
  return `<div class="docs-pb-${t}">
128
- <span class="docs-pb-text">${hn(o)}</span>
142
+ <span class="docs-pb-text">${Mn(o)}</span>
129
143
  </div>`;
130
144
  }
131
- function hn(t) {
145
+ function Mn(t) {
132
146
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
133
147
  }
134
- const mn = vt.create({
148
+ const En = vt.create({
135
149
  name: "pagination",
136
150
  addOptions() {
137
151
  return {
@@ -154,95 +168,95 @@ const mn = vt.create({
154
168
  addProseMirrorPlugins() {
155
169
  const t = this.options;
156
170
  return [
157
- new Xt({
158
- key: ft,
171
+ new ue({
172
+ key: mt,
159
173
  state: {
160
- init: () => St.empty,
174
+ init: () => xt.empty,
161
175
  apply(e, n) {
162
- const r = e.getMeta(ft);
176
+ const r = e.getMeta(mt);
163
177
  return r || n.map(e.mapping, e.doc);
164
178
  }
165
179
  },
166
180
  props: {
167
181
  decorations(e) {
168
- return ft.getState(e);
182
+ return mt.getState(e);
169
183
  }
170
184
  },
171
185
  view(e) {
172
186
  let n = 0, r = "";
173
- const o = (s, f, p, h) => {
174
- const g = document.createElement("div");
175
- return g.className = "docs-page-spacer", g.contentEditable = "false", g.setAttribute("data-it-spacer", ""), g.style.setProperty("--pb-mx-l", `${s.marginLeft}px`), g.style.setProperty("--pb-mx-r", `${s.marginRight}px`), g.innerHTML = `
176
- <div class="docs-pb-fill" style="height:${f}px"></div>
177
- <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${s.marginBottom}px">
178
- ${xt("footer", s.footer, p, h)}
187
+ const o = (i, m, u, h) => {
188
+ const f = document.createElement("div");
189
+ return f.className = "docs-page-spacer", f.contentEditable = "false", f.setAttribute("data-it-spacer", ""), f.style.setProperty("--pb-mx-l", `${i.marginLeft}px`), f.style.setProperty("--pb-mx-r", `${i.marginRight}px`), f.innerHTML = `
190
+ <div class="docs-pb-fill" style="height:${m}px"></div>
191
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${i.marginBottom}px">
192
+ ${$t("footer", i.footer, u, h)}
179
193
  </div>
180
194
  <div class="docs-pb-gap" style="height:${t.gap}px"></div>
181
- <div class="docs-pb-margin docs-pb-margin-top" style="height:${s.marginTop}px">
182
- ${xt("header", s.header, p + 1, h)}
183
- </div>`, g;
184
- }, l = (s, f, p, h) => {
185
- const g = document.createElement("div");
186
- return g.className = "docs-page-spacer docs-page-tail", g.contentEditable = "false", g.setAttribute("data-it-spacer", ""), g.style.setProperty("--pb-mx-l", `${s.marginLeft}px`), g.style.setProperty("--pb-mx-r", `${s.marginRight}px`), g.innerHTML = `
187
- <div class="docs-pb-fill" style="height:${f}px"></div>
188
- <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${s.marginBottom}px">
189
- ${xt("footer", s.footer, p, h)}
190
- </div>`, g;
191
- }, c = () => {
192
- const s = t.geometry(), f = e.dom, p = e.state.doc;
193
- if (s.autoHeight) {
195
+ <div class="docs-pb-margin docs-pb-margin-top" style="height:${i.marginTop}px">
196
+ ${$t("header", i.header, u + 1, h)}
197
+ </div>`, f;
198
+ }, c = (i, m, u, h) => {
199
+ const f = document.createElement("div");
200
+ return f.className = "docs-page-spacer docs-page-tail", f.contentEditable = "false", f.setAttribute("data-it-spacer", ""), f.style.setProperty("--pb-mx-l", `${i.marginLeft}px`), f.style.setProperty("--pb-mx-r", `${i.marginRight}px`), f.innerHTML = `
201
+ <div class="docs-pb-fill" style="height:${m}px"></div>
202
+ <div class="docs-pb-margin docs-pb-margin-bottom" style="height:${i.marginBottom}px">
203
+ ${$t("footer", i.footer, u, h)}
204
+ </div>`, f;
205
+ }, a = () => {
206
+ const i = t.geometry(), m = e.dom, u = e.state.doc;
207
+ if (i.autoHeight) {
194
208
  r !== "auto" && (r = "auto", e.dispatch(
195
- e.state.tr.setMeta(ft, St.empty)
209
+ e.state.tr.setMeta(mt, xt.empty)
196
210
  ), t.onPages?.(1));
197
211
  return;
198
212
  }
199
- const h = f.getBoundingClientRect().top, g = Array.from(f.children), k = [];
200
- let M = 0;
201
- for (const N of g) {
202
- if (N.hasAttribute?.("data-it-spacer")) {
203
- M += N.offsetHeight;
213
+ const h = m.getBoundingClientRect().top, f = Array.from(m.children), b = [];
214
+ let S = 0;
215
+ for (const C of f) {
216
+ if (C.hasAttribute?.("data-it-spacer")) {
217
+ S += C.offsetHeight;
204
218
  continue;
205
219
  }
206
- const H = N.getBoundingClientRect();
207
- k.push({
208
- natTop: H.top - h - M,
209
- natBottom: H.bottom - h - M
220
+ const R = C.getBoundingClientRect();
221
+ b.push({
222
+ natTop: R.top - h - S,
223
+ natBottom: R.bottom - h - S
210
224
  });
211
225
  }
212
- const C = [];
213
- let v = 0, w = k.length ? k[0].natTop : 0, I = w;
214
- for (let N = 0; N < k.length && N < p.childCount; N++) {
215
- const H = k[N], ot = p.child(N).nodeSize;
216
- H.natTop > w && // never break before the page's first block
217
- H.natBottom - w > s.contentHeight && (C.push({
218
- pos: v,
219
- rest: Math.max(0, s.contentHeight - (H.natTop - w))
220
- }), w = H.natTop), I = H.natBottom, v += ot;
226
+ const T = [];
227
+ let y = 0, v = b.length ? b[0].natTop : 0, H = v;
228
+ for (let C = 0; C < b.length && C < u.childCount; C++) {
229
+ const R = b[C], V = u.child(C).nodeSize;
230
+ R.natTop > v && // never break before the page's first block
231
+ R.natBottom - v > i.contentHeight && (T.push({
232
+ pos: y,
233
+ rest: Math.max(0, i.contentHeight - (R.natTop - v))
234
+ }), v = R.natTop), H = R.natBottom, y += V;
221
235
  }
222
- const O = C.length + 1, K = Math.max(
236
+ const B = T.length + 1, j = Math.max(
223
237
  0,
224
- s.contentHeight - (I - w)
225
- ), q = C.map((N) => `${N.pos}:${Math.round(N.rest)}`).join(",") + `|${Math.round(K)}|${O}|${s.header}|${s.footer}|${Math.round(s.contentHeight)}`;
226
- if (q === r) return;
227
- r = q;
228
- const W = C.map(
229
- (N, H) => Nt.widget(
230
- N.pos,
231
- () => o(s, N.rest, H + 1, O),
232
- { side: -1, key: `pb-${H + 1}-${Math.round(N.rest)}` }
238
+ i.contentHeight - (H - v)
239
+ ), P = T.map((C) => `${C.pos}:${Math.round(C.rest)}`).join(",") + `|${Math.round(j)}|${B}|${i.header}|${i.footer}|${Math.round(i.contentHeight)}`;
240
+ if (P === r) return;
241
+ r = P;
242
+ const I = T.map(
243
+ (C, R) => Ht.widget(
244
+ C.pos,
245
+ () => o(i, C.rest, R + 1, B),
246
+ { side: -1, key: `pb-${R + 1}-${Math.round(C.rest)}` }
233
247
  )
234
248
  );
235
- W.push(
236
- Nt.widget(
237
- p.content.size,
238
- () => l(s, K, O, O),
239
- { side: 1, key: `pb-tail-${O}-${Math.round(K)}` }
249
+ I.push(
250
+ Ht.widget(
251
+ u.content.size,
252
+ () => c(i, j, B, B),
253
+ { side: 1, key: `pb-tail-${B}-${Math.round(j)}` }
240
254
  )
241
255
  );
242
- const rt = St.create(e.state.doc, W);
243
- e.dispatch(e.state.tr.setMeta(ft, rt)), t.onPages?.(O);
256
+ const X = xt.create(e.state.doc, I);
257
+ e.dispatch(e.state.tr.setMeta(mt, X)), t.onPages?.(B);
244
258
  }, d = () => {
245
- cancelAnimationFrame(n), n = requestAnimationFrame(c);
259
+ cancelAnimationFrame(n), n = requestAnimationFrame(a);
246
260
  };
247
261
  return d(), {
248
262
  update: d,
@@ -252,28 +266,28 @@ const mn = vt.create({
252
266
  })
253
267
  ];
254
268
  }
255
- }), Dt = /* @__PURE__ */ new Set(["tip", "info", "warning", "danger", "success"]), bn = /* @__PURE__ */ new Set([
269
+ }), Jt = /* @__PURE__ */ new Set(["tip", "info", "warning", "danger", "success"]), zn = /* @__PURE__ */ new Set([
256
270
  "page",
257
271
  "meta",
258
272
  "font",
259
273
  "header",
260
274
  "footer",
261
275
  "watermark"
262
- ]), yn = /* @__PURE__ */ new Set([
276
+ ]), Hn = /* @__PURE__ */ new Set([
263
277
  "sign",
264
278
  "seal",
265
279
  "approve",
266
280
  "freeze",
267
281
  "amend",
268
282
  "amendment"
269
- ]), Ft = {
283
+ ]), Qt = {
270
284
  title: "itTitle",
271
285
  section: "itSection",
272
286
  sub: "itSub"
273
- }, kn = {
287
+ }, Rn = {
274
288
  note: "text",
275
289
  "body-text": "text"
276
- }, Sn = /* @__PURE__ */ new Set([
290
+ }, Pn = /* @__PURE__ */ new Set([
277
291
  "weight",
278
292
  "italic",
279
293
  "underline",
@@ -289,7 +303,7 @@ const mn = vt.create({
289
303
  "font",
290
304
  "bgcolor"
291
305
  ]);
292
- function wn(t) {
306
+ function Bn(t) {
293
307
  if (!t || t === "{}") return {};
294
308
  try {
295
309
  return typeof t == "string" ? JSON.parse(t) : t || {};
@@ -297,20 +311,20 @@ function wn(t) {
297
311
  return {};
298
312
  }
299
313
  }
300
- function F(t, e) {
314
+ function q(t, e) {
301
315
  const n = Object.entries(t).filter(
302
316
  ([r, o]) => o !== void 0 && o !== "" && (!e || !e.has(r))
303
317
  );
304
318
  return n.length === 0 ? "" : " | " + n.map(([r, o]) => `${r}: ${o}`).join(" | ");
305
319
  }
306
- function zt(t) {
320
+ function Bt(t) {
307
321
  if (!t) return [];
308
322
  const e = t.split("\\n"), n = [];
309
323
  return e.forEach((r, o) => {
310
324
  r && n.push({ type: "text", text: r }), o < e.length - 1 && n.push({ type: "hardBreak" });
311
325
  }), n;
312
326
  }
313
- function vn(t) {
327
+ function In(t) {
314
328
  switch (t.type) {
315
329
  case "bold":
316
330
  return [{ type: "bold" }];
@@ -330,7 +344,7 @@ function vn(t) {
330
344
  return null;
331
345
  }
332
346
  }
333
- const Tn = /* @__PURE__ */ new Set([
347
+ const Dn = /* @__PURE__ */ new Set([
334
348
  "text",
335
349
  "bold",
336
350
  "italic",
@@ -338,26 +352,26 @@ const Tn = /* @__PURE__ */ new Set([
338
352
  "highlight",
339
353
  "styled"
340
354
  ]);
341
- function xn(t, e) {
342
- if (!t || t.length === 0 || t.every((r) => r.type === "text") || !t.every((r) => Tn.has(r.type)))
343
- return zt(e);
355
+ function On(t, e) {
356
+ if (!t || t.length === 0 || t.every((r) => r.type === "text") || !t.every((r) => Dn.has(r.type)))
357
+ return Bt(e);
344
358
  const n = [];
345
359
  for (const r of t) {
346
- const o = vn(r), c = (r.value ?? "").split("\\n");
347
- c.forEach((d, s) => {
348
- d && n.push(o ? { type: "text", text: d, marks: o } : { type: "text", text: d }), s < c.length - 1 && n.push({ type: "hardBreak" });
360
+ const o = In(r), a = (r.value ?? "").split("\\n");
361
+ a.forEach((d, i) => {
362
+ d && n.push(o ? { type: "text", text: d, marks: o } : { type: "text", text: d }), i < a.length - 1 && n.push({ type: "hardBreak" });
349
363
  });
350
364
  }
351
- return n.length ? n : zt(e);
365
+ return n.length ? n : Bt(e);
352
366
  }
353
- function Ln(t, e) {
367
+ function Fn(t, e) {
354
368
  if (!e || t.length === 0) return t;
355
- const n = [], r = {}, o = e, l = o.family ?? o.font, c = o.bg ?? o.bgcolor;
356
- 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 && (r.color = String(o.color)), l && (r.fontFamily = String(l)), o.size && (r.fontSize = String(o.size)), c && n.push({ type: "highlight", attrs: { color: String(c) } }), Object.keys(r).length > 0 && n.push({ type: "textStyle", attrs: r }), n.length === 0 ? t : t.map(
369
+ const n = [], r = {}, o = e, c = o.family ?? o.font, a = o.bg ?? o.bgcolor;
370
+ 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 && (r.color = String(o.color)), c && (r.fontFamily = String(c)), o.size && (r.fontSize = String(o.size)), a && n.push({ type: "highlight", attrs: { color: String(a) } }), Object.keys(r).length > 0 && n.push({ type: "textStyle", attrs: r }), n.length === 0 ? t : t.map(
357
371
  (d) => d.type === "text" ? { ...d, marks: [...d.marks || [], ...n] } : d
358
372
  );
359
373
  }
360
- function ne(t) {
374
+ function he(t) {
361
375
  const e = {};
362
376
  for (const n of t || [])
363
377
  switch (n.type) {
@@ -388,30 +402,30 @@ function ne(t) {
388
402
  }
389
403
  return e;
390
404
  }
391
- function An(t) {
405
+ function jn(t) {
392
406
  if (t.type === "hardBreak") return "\\n";
393
- if (t.type !== "text") return Ht(t);
407
+ if (t.type !== "text") return Dt(t);
394
408
  const e = t.text || "";
395
409
  if (!e) return "";
396
410
  const n = t.marks || [];
397
411
  if (!n.length) return e;
398
412
  const r = new Set(n.map((h) => h.type)), o = n.find((h) => h.type === "link");
399
413
  if (o?.attrs?.href) return `[${e}](${o.attrs.href})`;
400
- const l = n.find((h) => h.type === "textStyle")?.attrs || {}, c = n.find((h) => h.type === "highlight")?.attrs || {}, d = !!(l.color || l.fontFamily || l.fontSize || c.color), s = ["bold", "italic", "strike", "underline", "code"].filter(
414
+ 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(
401
415
  (h) => r.has(h)
402
416
  ).length;
403
- if (!d && s === 1 && !r.has("underline")) {
417
+ if (!d && i === 1 && !r.has("underline")) {
404
418
  if (r.has("bold")) return `*${e}*`;
405
419
  if (r.has("italic")) return `_${e}_`;
406
420
  if (r.has("strike")) return `~${e}~`;
407
421
  if (r.has("code")) return `\`${e}\``;
408
422
  }
409
- if (!d && s === 0 && r.has("highlight") && !c.color)
423
+ if (!d && i === 0 && r.has("highlight") && !a.color)
410
424
  return `^${e}^`;
411
- const f = ne(n), p = [];
412
- return f.color && p.push(`color: ${f.color}`), f.family && p.push(`family: ${f.family}`), f.size && p.push(`size: ${f.size}`), f.weight && p.push(`weight: ${f.weight}`), f.italic === "true" && p.push("italic: true"), f.underline && p.push("underline: true"), f.strike && p.push("strike: true"), f.bg && p.push(`bg: ${f.bg}`), f.valign && p.push(`valign: ${f.valign}`), p.length ? `[${e}]{ ${p.join("; ")} }` : e;
425
+ const m = he(n), u = [];
426
+ 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;
413
427
  }
414
- const Cn = /* @__PURE__ */ new Set([
428
+ const Un = /* @__PURE__ */ new Set([
415
429
  "bold",
416
430
  "italic",
417
431
  "underline",
@@ -423,237 +437,237 @@ const Cn = /* @__PURE__ */ new Set([
423
437
  "subscript",
424
438
  "superscript"
425
439
  ]);
426
- function Nn(t) {
440
+ function Wn(t) {
427
441
  const e = /* @__PURE__ */ new Set(), n = (r) => {
428
442
  for (const o of r.marks || [])
429
- Cn.has(o.type) || e.add(o.type);
443
+ Un.has(o.type) || e.add(o.type);
430
444
  for (const o of r.content || []) n(o);
431
445
  };
432
446
  return n(t), [...e].sort();
433
447
  }
434
- function _t(t) {
448
+ function It(t) {
435
449
  const e = t.content || [], n = t.attrs?.textAlign && t.attrs.textAlign !== "left" ? { align: String(t.attrs.textAlign) } : {};
436
450
  return e.length === 1 && e[0].type === "text" ? {
437
451
  text: e[0].text || "",
438
- props: { ...ne(e[0].marks), ...n }
439
- } : { text: e.map(An).join(""), props: { ...n } };
452
+ props: { ...he(e[0].marks), ...n }
453
+ } : { text: e.map(jn).join(""), props: { ...n } };
440
454
  }
441
- function Ht(t) {
442
- return t.content ? t.content.map((e) => e.type === "text" ? e.text || "" : e.type === "hardBreak" ? "\\n" : Ht(e)).join("") : "";
455
+ function Dt(t) {
456
+ return t.content ? t.content.map((e) => e.type === "text" ? e.text || "" : e.type === "hardBreak" ? "\\n" : Dt(e)).join("") : "";
443
457
  }
444
- function it(t, e, n) {
445
- const r = wn(t);
446
- for (const o of Sn) delete r[o];
458
+ function pt(t, e, n) {
459
+ const r = Bn(t);
460
+ for (const o of Pn) delete r[o];
447
461
  if (n) for (const o of n) delete r[o];
448
462
  return { ...r, ...e };
449
463
  }
450
- function Rt(t) {
464
+ function Ot(t) {
451
465
  const e = t.toLowerCase();
452
- return kn[e] || e;
466
+ return Rn[e] || e;
453
467
  }
454
- function jt(t) {
468
+ function Xt(t) {
455
469
  if (t === "---") return "divider";
456
470
  const e = t.match(/^([a-zA-Z][\w-]*):/);
457
- return e ? Rt(e[1]) : null;
471
+ return e ? Ot(e[1]) : null;
458
472
  }
459
- function ct(t) {
460
- return Rt(t);
473
+ function ft(t) {
474
+ return Ot(t);
461
475
  }
462
- function lt(t, e) {
476
+ function gt(t, e) {
463
477
  return !!(t === e || t === "info" && ["tip", "warning", "danger", "success"].includes(e) || e === "info" && ["tip", "warning", "danger", "success"].includes(t));
464
478
  }
465
- function $n(t) {
479
+ function Gn(t) {
466
480
  if (!t) return { content: "", properties: {} };
467
481
  const e = t.split(" | ");
468
482
  let n = e[0] || "";
469
483
  const r = {};
470
484
  for (let o = 1; o < e.length; o++) {
471
- const l = e[o], c = l.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);
472
- if (!c) {
473
- n += ` | ${l}`;
485
+ const c = e[o], a = c.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);
486
+ if (!a) {
487
+ n += ` | ${c}`;
474
488
  continue;
475
489
  }
476
- r[c[1]] = c[2];
490
+ r[a[1]] = a[2];
477
491
  }
478
492
  return { content: n, properties: r };
479
493
  }
480
- function Wt(t) {
494
+ function Zt(t) {
481
495
  if (t === "---") return { type: "divider" };
482
496
  const e = t.match(/^([a-zA-Z][\w-]*):\s*(.*)$/);
483
497
  if (!e) return null;
484
- const n = Rt(e[1]), r = e[2] || "", { content: o, properties: l } = $n(r);
485
- let c;
498
+ const n = Ot(e[1]), r = e[2] || "", { content: o, properties: c } = Gn(r);
499
+ let a;
486
500
  try {
487
- c = et(`text: ${o}`).blocks[0]?.inline;
501
+ a = rt(`text: ${o}`).blocks[0]?.inline;
488
502
  } catch {
489
- c = void 0;
503
+ a = void 0;
490
504
  }
491
- return { type: n, content: o, properties: l, inline: c };
505
+ return { type: n, content: o, properties: c, inline: a };
492
506
  }
493
- function Gt(t) {
507
+ function te(t) {
494
508
  const e = t.match(/^[-*]\s+(.*)$/);
495
509
  if (e) return { ordered: !1, text: e[1] };
496
510
  const n = t.match(/^\d+\.\s+(.*)$/);
497
511
  return n ? { ordered: !0, text: n[1] } : null;
498
512
  }
499
- function Mn(t) {
513
+ function Yn(t) {
500
514
  return {
501
515
  type: "listItem",
502
- content: [{ type: "paragraph", content: zt(t) }]
516
+ content: [{ type: "paragraph", content: Bt(t) }]
503
517
  };
504
518
  }
505
- function Ut(t) {
519
+ function ee(t) {
506
520
  if (!t.trim())
507
521
  return {
508
522
  type: "doc",
509
523
  content: [{ type: "paragraph" }]
510
524
  };
511
- const e = et(t), n = [];
512
- for (const c of e.blocks) {
513
- const d = Lt(c);
525
+ const e = rt(t), n = [];
526
+ for (const a of e.blocks) {
527
+ const d = _t(a);
514
528
  d && n.push(d);
515
529
  }
516
530
  const r = t.split(`
517
531
  `);
518
532
  let o = 0;
519
- const l = [];
520
- for (let c = 0; c < r.length; c++) {
521
- const s = r[c].trim();
522
- if (!s) continue;
533
+ const c = [];
534
+ for (let a = 0; a < r.length; a++) {
535
+ const i = r[a].trim();
536
+ if (!i) continue;
523
537
  {
524
- const g = jt(s);
525
- if (g && bn.has(g)) {
526
- l.push({ type: "itMeta", attrs: { raw: s } });
527
- const k = e.blocks[o]?.type;
528
- k && lt(g, ct(k)) && o++;
538
+ const f = Xt(i);
539
+ if (f && zn.has(f)) {
540
+ c.push({ type: "itMeta", attrs: { raw: i } });
541
+ const b = e.blocks[o]?.type;
542
+ b && gt(f, ft(b)) && o++;
529
543
  continue;
530
544
  }
531
- if (g && yn.has(g)) {
532
- l.push({ type: "itTrust", attrs: { raw: s, keyword: g } });
533
- const k = e.blocks[o]?.type;
534
- k && lt(g, ct(k)) && o++;
545
+ if (f && Hn.has(f)) {
546
+ c.push({ type: "itTrust", attrs: { raw: i, keyword: f } });
547
+ const b = e.blocks[o]?.type;
548
+ b && gt(f, ft(b)) && o++;
535
549
  continue;
536
550
  }
537
- if (g === "metric") {
538
- l.push({ type: "itMetric", attrs: { raw: s } });
539
- const k = e.blocks[o]?.type;
540
- k && lt(g, ct(k)) && o++;
551
+ if (f === "metric") {
552
+ c.push({ type: "itMetric", attrs: { raw: i } });
553
+ const b = e.blocks[o]?.type;
554
+ b && gt(f, ft(b)) && o++;
541
555
  continue;
542
556
  }
543
- if (g === "style") {
544
- l.push({ type: "itStyleRule", attrs: { raw: s } });
545
- const k = e.blocks[o]?.type;
546
- k && lt(g, ct(k)) && o++;
557
+ if (f === "style") {
558
+ c.push({ type: "itStyleRule", attrs: { raw: i } });
559
+ const b = e.blocks[o]?.type;
560
+ b && gt(f, ft(b)) && o++;
547
561
  continue;
548
562
  }
549
563
  }
550
- const f = Gt(s);
551
- if (f) {
552
- const g = f.ordered, k = [];
553
- let M = c;
554
- for (; M < r.length; ) {
555
- const C = r[M].trim(), v = C ? Gt(C) : null;
556
- if (!v || v.ordered !== g) break;
557
- k.push(Mn(v.text));
558
- const w = e.blocks[o]?.type;
559
- (w === "list-item" || w === "step-item") && o++, M++;
564
+ const m = te(i);
565
+ if (m) {
566
+ const f = m.ordered, b = [];
567
+ let S = a;
568
+ for (; S < r.length; ) {
569
+ const T = r[S].trim(), y = T ? te(T) : null;
570
+ if (!y || y.ordered !== f) break;
571
+ b.push(Yn(y.text));
572
+ const v = e.blocks[o]?.type;
573
+ (v === "list-item" || v === "step-item") && o++, S++;
560
574
  }
561
- l.push({
562
- type: g ? "orderedList" : "bulletList",
563
- content: k
564
- }), c = M - 1;
575
+ c.push({
576
+ type: f ? "orderedList" : "bulletList",
577
+ content: b
578
+ }), a = S - 1;
565
579
  continue;
566
580
  }
567
- if (s.startsWith("|") && s.endsWith("|") && (s.match(/\|/g) || []).length >= 3) {
568
- const g = [];
569
- let k = c;
570
- for (; k < r.length; ) {
571
- const M = r[k].trim();
572
- if (!(M.startsWith("|") && M.endsWith("|"))) break;
573
- g.push(
574
- M.slice(1, -1).split("|").map((C) => C.trim())
575
- ), k++;
581
+ if (i.startsWith("|") && i.endsWith("|") && (i.match(/\|/g) || []).length >= 3) {
582
+ const f = [];
583
+ let b = a;
584
+ for (; b < r.length; ) {
585
+ const S = r[b].trim();
586
+ if (!(S.startsWith("|") && S.endsWith("|"))) break;
587
+ f.push(
588
+ S.slice(1, -1).split("|").map((T) => T.trim())
589
+ ), b++;
576
590
  }
577
- l.push({ type: "itTable", attrs: { rows: JSON.stringify(g) } }), c = k - 1;
591
+ c.push({ type: "itTable", attrs: { rows: JSON.stringify(f) } }), a = b - 1;
578
592
  continue;
579
593
  }
580
- if (s.startsWith("//")) {
581
- l.push({
594
+ if (i.startsWith("//")) {
595
+ c.push({
582
596
  type: "itComment",
583
- content: s.slice(2).trim() ? [{ type: "text", text: s.slice(2).trim() }] : []
597
+ content: i.slice(2).trim() ? [{ type: "text", text: i.slice(2).trim() }] : []
584
598
  });
585
599
  continue;
586
600
  }
587
- if (s.startsWith("```")) continue;
588
- const p = jt(s);
589
- if (p && (p === "text" || s.includes("{{"))) {
590
- const g = Wt(s);
591
- if (g) {
592
- const k = Lt(g);
593
- if (k && l.push(k), o < e.blocks.length) {
594
- const M = ct(e.blocks[o].type);
595
- lt(p, M) && o++;
601
+ if (i.startsWith("```")) continue;
602
+ const u = Xt(i);
603
+ if (u && (u === "text" || i.includes("{{"))) {
604
+ const f = Zt(i);
605
+ if (f) {
606
+ const b = _t(f);
607
+ if (b && c.push(b), o < e.blocks.length) {
608
+ const S = ft(e.blocks[o].type);
609
+ gt(u, S) && o++;
596
610
  }
597
611
  continue;
598
612
  }
599
613
  }
600
- if (o < n.length && p) {
601
- const g = e.blocks[o], k = ct(g.type);
602
- if (lt(p, k)) {
603
- l.push(n[o]), o++;
614
+ if (o < n.length && u) {
615
+ const f = e.blocks[o], b = ft(f.type);
616
+ if (gt(u, b)) {
617
+ c.push(n[o]), o++;
604
618
  continue;
605
619
  }
606
620
  }
607
- const h = Wt(s);
621
+ const h = Zt(i);
608
622
  if (h) {
609
- const g = Lt(h);
610
- g && l.push(g);
623
+ const f = _t(h);
624
+ f && c.push(f);
611
625
  continue;
612
626
  }
613
- o < n.length && (l.push(n[o]), o++);
627
+ o < n.length && (c.push(n[o]), o++);
614
628
  }
615
629
  for (; o < n.length; )
616
- l.push(n[o]), o++;
630
+ c.push(n[o]), o++;
617
631
  return {
618
632
  type: "doc",
619
- content: l.length > 0 ? l : [{ type: "paragraph" }]
633
+ content: c.length > 0 ? c : [{ type: "paragraph" }]
620
634
  };
621
635
  }
622
- function Lt(t) {
623
- const { type: e, content: n, properties: r, inline: o } = t, l = n || "";
624
- let c = xn(o, l);
625
- c = Ln(c, r);
636
+ function _t(t) {
637
+ const { type: e, content: n, properties: r, inline: o } = t, c = n || "";
638
+ let a = On(o, c);
639
+ a = Fn(a, r);
626
640
  const d = r ? JSON.stringify(
627
641
  Object.fromEntries(
628
- Object.entries(r).map(([p, h]) => [p, String(h)])
642
+ Object.entries(r).map(([u, h]) => [u, String(h)])
629
643
  )
630
- ) : "{}", s = r?.align ? String(r.align) : void 0;
631
- if (e in Ft)
644
+ ) : "{}", i = r?.align ? String(r.align) : void 0;
645
+ if (e in Qt)
632
646
  return {
633
- type: Ft[e],
634
- attrs: { props: d, ...s && { textAlign: s } },
635
- content: c.length ? c : void 0
647
+ type: Qt[e],
648
+ attrs: { props: d, ...i && { textAlign: i } },
649
+ content: a.length ? a : void 0
636
650
  };
637
651
  if (e === "summary")
638
652
  return {
639
653
  type: "itSummary",
640
- attrs: { props: d, ...s && { textAlign: s } },
641
- content: c.length ? c : void 0
654
+ attrs: { props: d, ...i && { textAlign: i } },
655
+ content: a.length ? a : void 0
642
656
  };
643
657
  if (e === "text" || e === "body-text") {
644
- const p = {};
645
- return s && (p.textAlign = s), r?.end && (p.end = String(r.end)), r?.leading && (p.leading = String(r.leading)), r?.["space-before"] && (p.spaceBefore = String(r["space-before"])), r?.["space-after"] && (p.spaceAfter = String(r["space-after"])), {
658
+ const u = {};
659
+ return i && (u.textAlign = i), r?.end && (u.end = String(r.end)), r?.leading && (u.leading = String(r.leading)), r?.["space-before"] && (u.spaceBefore = String(r["space-before"])), r?.["space-after"] && (u.spaceAfter = String(r["space-after"])), {
646
660
  type: "paragraph",
647
- ...Object.keys(p).length && { attrs: p },
648
- content: c.length ? c : void 0
661
+ ...Object.keys(u).length && { attrs: u },
662
+ content: a.length ? a : void 0
649
663
  };
650
664
  }
651
- if (Dt.has(e)) {
652
- const p = e === "info" ? String(r?.type || "info").toLowerCase() : e;
665
+ if (Jt.has(e)) {
666
+ const u = e === "info" ? String(r?.type || "info").toLowerCase() : e;
653
667
  return {
654
668
  type: "itCallout",
655
- attrs: { variant: Dt.has(p) ? p : "info", props: d },
656
- content: c.length ? c : void 0
669
+ attrs: { variant: Jt.has(u) ? u : "info", props: d },
670
+ content: a.length ? a : void 0
657
671
  };
658
672
  }
659
673
  if (e === "quote")
@@ -662,9 +676,9 @@ function Lt(t) {
662
676
  attrs: {
663
677
  by: r?.by ? String(r.by) : "",
664
678
  props: d,
665
- ...s && { textAlign: s }
679
+ ...i && { textAlign: i }
666
680
  },
667
- content: c.length ? c : void 0
681
+ content: a.length ? a : void 0
668
682
  };
669
683
  if (e === "code")
670
684
  return {
@@ -673,81 +687,81 @@ function Lt(t) {
673
687
  lang: r?.lang ? String(r.lang) : "",
674
688
  props: d
675
689
  },
676
- content: l ? [{ type: "text", text: l }] : void 0
690
+ content: c ? [{ type: "text", text: c }] : void 0
677
691
  };
678
692
  if (e === "divider")
679
693
  return { type: "itDivider" };
680
694
  if (e === "break")
681
695
  return { type: "itBreak" };
682
- const f = r ? Object.entries(r).filter(([, p]) => p !== void 0 && p !== "").map(([p, h]) => `${p}: ${h}`).join(" | ") : "";
696
+ const m = r ? Object.entries(r).filter(([, u]) => u !== void 0 && u !== "").map(([u, h]) => `${u}: ${h}`).join(" | ") : "";
683
697
  return {
684
698
  type: "itGenericBlock",
685
- attrs: { keyword: e, properties: f, props: d },
686
- content: c.length ? c : void 0
699
+ attrs: { keyword: e, properties: m, props: d },
700
+ content: a.length ? a : void 0
687
701
  };
688
702
  }
689
- function zn(t) {
703
+ function Kn(t) {
690
704
  if (!t.content) return "";
691
705
  const e = [];
692
706
  for (const n of t.content)
693
- e.push(..._n(n));
707
+ e.push(...qn(n));
694
708
  return e.join(`
695
709
  `);
696
710
  }
697
- function _n(t) {
711
+ function qn(t) {
698
712
  if (t.type === "bulletList" && t.content)
699
713
  return t.content.flatMap((n) => n.content ? n.content.map((r) => {
700
- const { text: o, props: l } = _t(r);
701
- return `- ${o}${F(l)}`;
714
+ const { text: o, props: c } = It(r);
715
+ return `- ${o}${q(c)}`;
702
716
  }) : []);
703
717
  if (t.type === "orderedList" && t.content) {
704
718
  let n = 1;
705
719
  return t.content.flatMap((r) => r.content ? r.content.map((o) => {
706
- const { text: l, props: c } = _t(o);
707
- return `${n++}. ${l}${F(c)}`;
720
+ const { text: c, props: a } = It(o);
721
+ return `${n++}. ${c}${q(a)}`;
708
722
  }) : []);
709
723
  }
710
- const e = Hn(t);
724
+ const e = Vn(t);
711
725
  return e !== null ? [e] : [];
712
726
  }
713
- function Hn(t) {
714
- const { text: e, props: n } = _t(t);
727
+ function Vn(t) {
728
+ const { text: e, props: n } = It(t);
715
729
  switch (t.type) {
716
730
  case "itTitle": {
717
- const r = it(t.attrs?.props, n);
718
- return `title: ${e}${F(r)}`;
731
+ const r = pt(t.attrs?.props, n);
732
+ return `title: ${e}${q(r)}`;
719
733
  }
720
734
  case "itSummary": {
721
- const r = it(t.attrs?.props, n);
722
- return `summary: ${e}${F(r)}`;
735
+ const r = pt(t.attrs?.props, n);
736
+ return `summary: ${e}${q(r)}`;
723
737
  }
724
738
  case "itSection": {
725
- const r = it(t.attrs?.props, n);
726
- return `section: ${e}${F(r)}`;
739
+ const r = pt(t.attrs?.props, n);
740
+ return `section: ${e}${q(r)}`;
727
741
  }
728
742
  case "itSub": {
729
- const r = it(t.attrs?.props, n);
730
- return `sub: ${e}${F(r)}`;
743
+ const r = pt(t.attrs?.props, n);
744
+ return `sub: ${e}${q(r)}`;
731
745
  }
732
746
  case "paragraph": {
733
747
  const r = t.attrs || {}, o = {};
734
- return r.end && (o.end = String(r.end)), r.leading && (o.leading = String(r.leading)), r.spaceBefore && (o["space-before"] = String(r.spaceBefore)), r.spaceAfter && (o["space-after"] = String(r.spaceAfter)), `text: ${e}${F({ ...o, ...n })}`;
748
+ return r.end && (o.end = String(r.end)), r.leading && (o.leading = String(r.leading)), r.spaceBefore && (o["space-before"] = String(r.spaceBefore)), r.spaceAfter && (o["space-after"] = String(r.spaceAfter)), `text: ${e}${q({ ...o, ...n })}`;
735
749
  }
736
750
  case "itCallout": {
737
- const r = t.attrs?.variant || "tip", o = it(
751
+ const r = t.attrs?.variant || "tip", o = pt(
738
752
  t.attrs?.props,
739
753
  n,
740
754
  /* @__PURE__ */ new Set(["variant"])
741
755
  );
742
- return r === "info" ? `info: ${e}${F(o)}` : `info: ${e} | type: ${r}${F(o, /* @__PURE__ */ new Set(["type"]))}`;
756
+ return r === "info" ? `info: ${e}${q(o)}` : `info: ${e} | type: ${r}${q(o, /* @__PURE__ */ new Set(["type"]))}`;
743
757
  }
744
758
  case "itQuote": {
745
- const r = t.attrs?.by, o = r ? ` | by: ${r}` : "", l = it(t.attrs?.props, n, /* @__PURE__ */ new Set(["by"]));
746
- return `quote: ${e}${o}${F(l)}`;
759
+ const r = t.attrs?.by, o = r ? ` | by: ${r}` : "", c = pt(t.attrs?.props, n, /* @__PURE__ */ new Set(["by"]));
760
+ return `quote: ${e}${o}${q(c)}`;
747
761
  }
748
762
  case "itCode":
749
763
  return `\`\`\`${t.attrs?.lang || ""}
750
- ${Ht(t)}
764
+ ${Dt(t)}
751
765
  \`\`\``;
752
766
  case "itDivider":
753
767
  return "divider:";
@@ -774,132 +788,132 @@ ${Ht(t)}
774
788
  case "itComment":
775
789
  return e ? `// ${e}` : "//";
776
790
  case "itGenericBlock": {
777
- const r = t.attrs?.keyword || "text", o = it(t.attrs?.props, n);
778
- return `${r}: ${e}${F(o)}`;
791
+ const r = t.attrs?.keyword || "text", o = pt(t.attrs?.props, n);
792
+ return `${r}: ${e}${q(o)}`;
779
793
  }
780
794
  default:
781
- return e ? `text: ${e}${F(n)}` : null;
795
+ return e ? `text: ${e}${q(n)}` : null;
782
796
  }
783
797
  }
784
- function i(t, e) {
798
+ function l(t, e) {
785
799
  return { property: t, css: e };
786
800
  }
787
- const Rn = [
788
- i("align", "textAlign"),
789
- i("color", "color"),
790
- i("size", "fontSize"),
791
- i("weight", "fontWeight"),
801
+ const Jn = [
802
+ l("align", "textAlign"),
803
+ l("color", "color"),
804
+ l("size", "fontSize"),
805
+ l("weight", "fontWeight"),
792
806
  { property: "style", css: "fontStyle" },
793
- i("bgcolor", "backgroundColor"),
794
- i("padding", "padding"),
795
- i("indent", "paddingLeft"),
796
- i("opacity", "opacity")
797
- ], gt = [
798
- i("bgcolor", "backgroundColor"),
799
- i("color", "color"),
800
- i("border", "borderLeft")
801
- ], A = [
802
- i("color", "borderColor"),
803
- i("bgcolor", "backgroundColor")
804
- ], En = {
807
+ l("bgcolor", "backgroundColor"),
808
+ l("padding", "padding"),
809
+ l("indent", "paddingLeft"),
810
+ l("opacity", "opacity")
811
+ ], bt = [
812
+ l("bgcolor", "backgroundColor"),
813
+ l("color", "color"),
814
+ l("border", "borderLeft")
815
+ ], $ = [
816
+ l("color", "borderColor"),
817
+ l("bgcolor", "backgroundColor")
818
+ ], Qn = {
805
819
  // ── Identity ──
806
820
  title: [
807
- i("align", "textAlign"),
808
- i("color", "color"),
809
- i("size", "fontSize"),
810
- i("weight", "fontWeight"),
811
- i("font", "fontFamily")
821
+ l("align", "textAlign"),
822
+ l("color", "color"),
823
+ l("size", "fontSize"),
824
+ l("weight", "fontWeight"),
825
+ l("font", "fontFamily")
812
826
  ],
813
827
  summary: [
814
- i("align", "textAlign"),
815
- i("color", "color"),
816
- i("size", "fontSize"),
828
+ l("align", "textAlign"),
829
+ l("color", "color"),
830
+ l("size", "fontSize"),
817
831
  { property: "style", css: "fontStyle" }
818
832
  ],
819
833
  // ── Structure ──
820
834
  section: [
821
- i("align", "textAlign"),
822
- i("color", "color"),
823
- i("size", "fontSize"),
824
- i("weight", "fontWeight"),
825
- i("border", "borderBottom"),
826
- i("spacing", "marginTop")
835
+ l("align", "textAlign"),
836
+ l("color", "color"),
837
+ l("size", "fontSize"),
838
+ l("weight", "fontWeight"),
839
+ l("border", "borderBottom"),
840
+ l("spacing", "marginTop")
827
841
  ],
828
842
  sub: [
829
- i("align", "textAlign"),
830
- i("color", "color"),
831
- i("size", "fontSize"),
832
- i("weight", "fontWeight")
843
+ l("align", "textAlign"),
844
+ l("color", "color"),
845
+ l("size", "fontSize"),
846
+ l("weight", "fontWeight")
833
847
  ],
834
848
  divider: [
835
849
  { property: "style", css: "borderStyle" },
836
- i("color", "borderColor"),
837
- i("width", "borderTopWidth"),
838
- i("spacing", "margin")
850
+ l("color", "borderColor"),
851
+ l("width", "borderTopWidth"),
852
+ l("spacing", "margin")
839
853
  ],
840
854
  // ── Content ──
841
- text: [...Rn],
842
- tip: [...gt],
843
- info: [...gt],
844
- warning: [...gt],
845
- danger: [...gt],
846
- success: [...gt],
855
+ text: [...Jn],
856
+ tip: [...bt],
857
+ info: [...bt],
858
+ warning: [...bt],
859
+ danger: [...bt],
860
+ success: [...bt],
847
861
  quote: [
848
- i("align", "textAlign"),
849
- i("color", "color"),
850
- i("size", "fontSize"),
862
+ l("align", "textAlign"),
863
+ l("color", "color"),
864
+ l("size", "fontSize"),
851
865
  { property: "style", css: "fontStyle" },
852
- i("border", "borderLeft"),
853
- i("padding", "paddingLeft"),
854
- i("bgcolor", "backgroundColor")
866
+ l("border", "borderLeft"),
867
+ l("padding", "paddingLeft"),
868
+ l("bgcolor", "backgroundColor")
855
869
  ],
856
870
  cite: [
857
- i("align", "textAlign"),
858
- i("color", "color"),
859
- i("size", "fontSize"),
871
+ l("align", "textAlign"),
872
+ l("color", "color"),
873
+ l("size", "fontSize"),
860
874
  { property: "style", css: "fontStyle" }
861
875
  ],
862
876
  def: [
863
- i("color", "color"),
864
- i("bgcolor", "backgroundColor"),
865
- i("border", "borderLeft"),
866
- i("padding", "paddingLeft")
877
+ l("color", "color"),
878
+ l("bgcolor", "backgroundColor"),
879
+ l("border", "borderLeft"),
880
+ l("padding", "paddingLeft")
867
881
  ],
868
882
  caption: [
869
- i("align", "textAlign"),
870
- i("color", "color"),
871
- i("size", "fontSize"),
883
+ l("align", "textAlign"),
884
+ l("color", "color"),
885
+ l("size", "fontSize"),
872
886
  { property: "style", css: "fontStyle" }
873
887
  ],
874
- footnote: [i("color", "color"), i("size", "fontSize")],
888
+ footnote: [l("color", "color"), l("size", "fontSize")],
875
889
  byline: [
876
- i("align", "textAlign"),
877
- i("color", "color"),
878
- i("size", "fontSize"),
890
+ l("align", "textAlign"),
891
+ l("color", "color"),
892
+ l("size", "fontSize"),
879
893
  { property: "style", css: "fontStyle" },
880
- i("weight", "fontWeight")
894
+ l("weight", "fontWeight")
881
895
  ],
882
896
  epigraph: [
883
- i("align", "textAlign"),
884
- i("color", "color"),
885
- i("size", "fontSize"),
897
+ l("align", "textAlign"),
898
+ l("color", "color"),
899
+ l("size", "fontSize"),
886
900
  { property: "style", css: "fontStyle" },
887
- i("padding", "padding")
901
+ l("padding", "padding")
888
902
  ],
889
903
  dedication: [
890
- i("align", "textAlign"),
891
- i("color", "color"),
904
+ l("align", "textAlign"),
905
+ l("color", "color"),
892
906
  { property: "style", css: "fontStyle" },
893
- i("padding", "padding")
907
+ l("padding", "padding")
894
908
  ],
895
909
  // ── Media ──
896
910
  image: [
897
- i("width", "width"),
898
- i("height", "height"),
899
- i("radius", "borderRadius"),
900
- i("border", "border"),
901
- i("opacity", "opacity"),
902
- i("bgcolor", "backgroundColor"),
911
+ l("width", "width"),
912
+ l("height", "height"),
913
+ l("radius", "borderRadius"),
914
+ l("border", "border"),
915
+ l("opacity", "opacity"),
916
+ l("bgcolor", "backgroundColor"),
903
917
  {
904
918
  property: "shadow",
905
919
  css: "boxShadow",
@@ -907,150 +921,150 @@ const Rn = [
907
921
  }
908
922
  ],
909
923
  figure: [
910
- i("width", "width"),
911
- i("align", "textAlign"),
912
- i("border", "border"),
913
- i("padding", "padding"),
914
- i("bgcolor", "backgroundColor"),
924
+ l("width", "width"),
925
+ l("align", "textAlign"),
926
+ l("border", "border"),
927
+ l("padding", "padding"),
928
+ l("bgcolor", "backgroundColor"),
915
929
  {
916
930
  property: "shadow",
917
931
  css: "boxShadow",
918
932
  transform: () => "0 4px 12px rgba(0,0,0,0.15)"
919
933
  }
920
934
  ],
921
- link: [i("color", "color"), i("weight", "fontWeight")],
922
- ref: [i("color", "color"), { property: "style", css: "fontStyle" }],
935
+ link: [l("color", "color"), l("weight", "fontWeight")],
936
+ ref: [l("color", "color"), { property: "style", css: "fontStyle" }],
923
937
  embed: [
924
- i("width", "width"),
925
- i("height", "height"),
926
- i("border", "border"),
927
- i("radius", "borderRadius")
938
+ l("width", "width"),
939
+ l("height", "height"),
940
+ l("border", "border"),
941
+ l("radius", "borderRadius")
928
942
  ],
929
943
  // ── Data ──
930
944
  metric: [
931
- i("color", "color"),
932
- i("size", "fontSize"),
933
- i("align", "textAlign"),
934
- i("bgcolor", "backgroundColor"),
935
- i("border", "border"),
936
- i("padding", "padding")
945
+ l("color", "color"),
946
+ l("size", "fontSize"),
947
+ l("align", "textAlign"),
948
+ l("bgcolor", "backgroundColor"),
949
+ l("border", "border"),
950
+ l("padding", "padding")
937
951
  ],
938
952
  columns: [
939
- i("border", "border"),
940
- i("bgcolor", "backgroundColor"),
941
- i("padding", "padding"),
942
- i("size", "fontSize"),
943
- i("align", "textAlign")
953
+ l("border", "border"),
954
+ l("bgcolor", "backgroundColor"),
955
+ l("padding", "padding"),
956
+ l("size", "fontSize"),
957
+ l("align", "textAlign")
944
958
  ],
945
959
  row: [
946
- i("border", "border"),
947
- i("bgcolor", "backgroundColor"),
948
- i("padding", "padding"),
949
- i("size", "fontSize"),
950
- i("align", "textAlign")
960
+ l("border", "border"),
961
+ l("bgcolor", "backgroundColor"),
962
+ l("padding", "padding"),
963
+ l("size", "fontSize"),
964
+ l("align", "textAlign")
951
965
  ],
952
966
  input: [
953
- i("color", "color"),
954
- i("bgcolor", "backgroundColor"),
955
- i("border", "borderLeft"),
956
- i("size", "fontSize")
967
+ l("color", "color"),
968
+ l("bgcolor", "backgroundColor"),
969
+ l("border", "borderLeft"),
970
+ l("size", "fontSize")
957
971
  ],
958
972
  output: [
959
- i("color", "color"),
960
- i("bgcolor", "backgroundColor"),
961
- i("border", "borderLeft"),
962
- i("size", "fontSize")
973
+ l("color", "color"),
974
+ l("bgcolor", "backgroundColor"),
975
+ l("border", "borderLeft"),
976
+ l("size", "fontSize")
963
977
  ],
964
978
  // ── Code ──
965
979
  code: [
966
- i("size", "fontSize"),
967
- i("bgcolor", "backgroundColor"),
968
- i("color", "color"),
969
- i("padding", "padding"),
970
- i("radius", "borderRadius"),
971
- i("border", "border")
980
+ l("size", "fontSize"),
981
+ l("bgcolor", "backgroundColor"),
982
+ l("color", "color"),
983
+ l("padding", "padding"),
984
+ l("radius", "borderRadius"),
985
+ l("border", "border")
972
986
  ],
973
987
  // ── Contact ──
974
988
  contact: [
975
- i("color", "color"),
976
- i("bgcolor", "backgroundColor"),
977
- i("border", "border"),
978
- i("padding", "padding"),
979
- i("size", "fontSize")
989
+ l("color", "color"),
990
+ l("bgcolor", "backgroundColor"),
991
+ l("border", "border"),
992
+ l("padding", "padding"),
993
+ l("size", "fontSize")
980
994
  ],
981
995
  deadline: [
982
- i("color", "color"),
983
- i("bgcolor", "backgroundColor"),
984
- i("weight", "fontWeight"),
985
- i("size", "fontSize")
996
+ l("color", "color"),
997
+ l("bgcolor", "backgroundColor"),
998
+ l("weight", "fontWeight"),
999
+ l("size", "fontSize")
986
1000
  ],
987
1001
  // ── Agent workflow chips ──
988
- step: [...A],
989
- decision: [...A],
990
- gate: [...A],
991
- trigger: [...A],
992
- loop: [...A],
993
- parallel: [...A],
994
- call: [...A],
995
- wait: [...A],
996
- checkpoint: [...A],
997
- error: [...A],
998
- result: [...A],
999
- audit: [...A],
1000
- signal: [...A],
1001
- handoff: [...A],
1002
- retry: [...A],
1003
- progress: [...A],
1004
- tool: [...A],
1005
- prompt: [...A],
1006
- memory: [...A],
1007
- policy: [...A],
1008
- context: [...A],
1002
+ step: [...$],
1003
+ decision: [...$],
1004
+ gate: [...$],
1005
+ trigger: [...$],
1006
+ loop: [...$],
1007
+ parallel: [...$],
1008
+ call: [...$],
1009
+ wait: [...$],
1010
+ checkpoint: [...$],
1011
+ error: [...$],
1012
+ result: [...$],
1013
+ audit: [...$],
1014
+ signal: [...$],
1015
+ handoff: [...$],
1016
+ retry: [...$],
1017
+ progress: [...$],
1018
+ tool: [...$],
1019
+ prompt: [...$],
1020
+ memory: [...$],
1021
+ policy: [...$],
1022
+ context: [...$],
1009
1023
  // ── Trust badges ──
1010
- track: [...A],
1011
- approve: [...A],
1012
- sign: [...A],
1013
- freeze: [...A],
1014
- revision: [...A],
1015
- amendment: [...A],
1016
- history: [i("color", "borderColor")],
1024
+ track: [...$],
1025
+ approve: [...$],
1026
+ sign: [...$],
1027
+ freeze: [...$],
1028
+ revision: [...$],
1029
+ amendment: [...$],
1030
+ history: [l("color", "borderColor")],
1017
1031
  // ── v2.13 ──
1018
1032
  assert: [
1019
- i("color", "borderColor"),
1020
- i("bgcolor", "backgroundColor"),
1021
- i("border", "borderLeft")
1033
+ l("color", "borderColor"),
1034
+ l("bgcolor", "backgroundColor"),
1035
+ l("border", "borderLeft")
1022
1036
  ],
1023
1037
  secret: [
1024
- i("color", "color"),
1025
- i("bgcolor", "backgroundColor"),
1026
- i("blur", "filter")
1038
+ l("color", "color"),
1039
+ l("bgcolor", "backgroundColor"),
1040
+ l("blur", "filter")
1027
1041
  ],
1028
1042
  // ── Layout ──
1029
1043
  watermark: [
1030
- i("color", "color"),
1031
- i("size", "fontSize"),
1032
- i("opacity", "opacity")
1044
+ l("color", "color"),
1045
+ l("size", "fontSize"),
1046
+ l("opacity", "opacity")
1033
1047
  ],
1034
- signline: [i("color", "color"), i("width", "width")]
1048
+ signline: [l("color", "color"), l("width", "width")]
1035
1049
  };
1036
- function Pn(t, e) {
1037
- const n = En[t];
1050
+ function Xn(t, e) {
1051
+ const n = Qn[t];
1038
1052
  if (!n) return {};
1039
1053
  const r = {};
1040
1054
  for (const o of n) {
1041
- const l = e[o.property];
1042
- l && (o.transform ? r[o.css] = o.transform(l) : r[o.css] = l);
1055
+ const c = e[o.property];
1056
+ c && (o.transform ? r[o.css] = o.transform(c) : r[o.css] = c);
1043
1057
  }
1044
1058
  return r;
1045
1059
  }
1046
- function J(t, e) {
1047
- const n = Pn(t, e);
1060
+ function ot(t, e) {
1061
+ const n = Xn(t, e);
1048
1062
  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(([r, o]) => `${r.replace(/([A-Z])/g, "-$1").toLowerCase()}:${o}`).join(";");
1049
1063
  }
1050
- function Et(t) {
1064
+ function Ft(t) {
1051
1065
  return t.end ? { "data-it-end": t.end } : {};
1052
1066
  }
1053
- const Bn = E.create({
1067
+ const Zn = Y.create({
1054
1068
  name: "itTitle",
1055
1069
  group: "block",
1056
1070
  content: "inline*",
@@ -1067,15 +1081,15 @@ const Bn = E.create({
1067
1081
  return [{ tag: 'h1[data-it-type="title"]' }];
1068
1082
  },
1069
1083
  renderHTML({ HTMLAttributes: t, node: e }) {
1070
- const n = nt(e.attrs.props), r = _(t, {
1084
+ const n = dt(e.attrs.props), r = F(t, {
1071
1085
  "data-it-type": "title",
1072
1086
  class: "it-doc-title",
1073
- style: J("title", n),
1074
- ...Et(n)
1087
+ style: ot("title", n),
1088
+ ...Ft(n)
1075
1089
  });
1076
1090
  return n.end ? ["h1", r, ["span", { class: "it-split-main" }, 0]] : ["h1", r, 0];
1077
1091
  }
1078
- }), In = E.create({
1092
+ }), tr = Y.create({
1079
1093
  name: "itSummary",
1080
1094
  group: "block",
1081
1095
  content: "inline*",
@@ -1089,18 +1103,18 @@ const Bn = E.create({
1089
1103
  return [{ tag: 'p[data-it-type="summary"]' }];
1090
1104
  },
1091
1105
  renderHTML({ HTMLAttributes: t, node: e }) {
1092
- const n = nt(e.attrs.props);
1106
+ const n = dt(e.attrs.props);
1093
1107
  return [
1094
1108
  "p",
1095
- _(t, {
1109
+ F(t, {
1096
1110
  "data-it-type": "summary",
1097
1111
  class: "it-doc-summary",
1098
- style: J("summary", n)
1112
+ style: ot("summary", n)
1099
1113
  }),
1100
1114
  0
1101
1115
  ];
1102
1116
  }
1103
- }), On = E.create({
1117
+ }), er = Y.create({
1104
1118
  name: "itSection",
1105
1119
  group: "block",
1106
1120
  content: "inline*",
@@ -1114,15 +1128,15 @@ const Bn = E.create({
1114
1128
  return [{ tag: 'h2[data-it-type="section"]' }];
1115
1129
  },
1116
1130
  renderHTML({ HTMLAttributes: t, node: e }) {
1117
- const n = nt(e.attrs.props), r = _(t, {
1131
+ const n = dt(e.attrs.props), r = F(t, {
1118
1132
  "data-it-type": "section",
1119
1133
  class: "it-doc-section",
1120
- style: J("section", n),
1121
- ...Et(n)
1134
+ style: ot("section", n),
1135
+ ...Ft(n)
1122
1136
  });
1123
1137
  return n.end ? ["h2", r, ["span", { class: "it-split-main" }, 0]] : ["h2", r, 0];
1124
1138
  }
1125
- }), Dn = E.create({
1139
+ }), nr = Y.create({
1126
1140
  name: "itSub",
1127
1141
  group: "block",
1128
1142
  content: "inline*",
@@ -1136,15 +1150,15 @@ const Bn = E.create({
1136
1150
  return [{ tag: 'h3[data-it-type="sub"]' }];
1137
1151
  },
1138
1152
  renderHTML({ HTMLAttributes: t, node: e }) {
1139
- const n = nt(e.attrs.props), r = _(t, {
1153
+ const n = dt(e.attrs.props), r = F(t, {
1140
1154
  "data-it-type": "sub",
1141
1155
  class: "it-doc-sub",
1142
- style: J("sub", n),
1143
- ...Et(n)
1156
+ style: ot("sub", n),
1157
+ ...Ft(n)
1144
1158
  });
1145
1159
  return n.end ? ["h3", r, ["span", { class: "it-split-main" }, 0]] : ["h3", r, 0];
1146
1160
  }
1147
- }), Fn = E.create({
1161
+ }), rr = Y.create({
1148
1162
  name: "itCallout",
1149
1163
  group: "block",
1150
1164
  content: "inline*",
@@ -1163,7 +1177,7 @@ const Bn = E.create({
1163
1177
  return [{ tag: 'div[data-it-type="callout"]' }];
1164
1178
  },
1165
1179
  renderHTML({ HTMLAttributes: t, node: e }) {
1166
- const n = e.attrs.variant || "tip", r = nt(e.attrs.props), o = {
1180
+ const n = e.attrs.variant || "tip", r = dt(e.attrs.props), o = {
1167
1181
  tip: "tip",
1168
1182
  info: "info",
1169
1183
  warning: "warning",
@@ -1172,11 +1186,11 @@ const Bn = E.create({
1172
1186
  };
1173
1187
  return [
1174
1188
  "div",
1175
- _(t, {
1189
+ F(t, {
1176
1190
  "data-it-type": "callout",
1177
1191
  "data-variant": n,
1178
1192
  class: `it-doc-callout it-doc-callout-${n}`,
1179
- style: J(n, r)
1193
+ style: ot(n, r)
1180
1194
  }),
1181
1195
  [
1182
1196
  "span",
@@ -1189,7 +1203,7 @@ const Bn = E.create({
1189
1203
  ["span", { class: "it-doc-callout-text" }, 0]
1190
1204
  ];
1191
1205
  }
1192
- }), jn = E.create({
1206
+ }), or = Y.create({
1193
1207
  name: "itQuote",
1194
1208
  group: "block",
1195
1209
  content: "inline*",
@@ -1204,18 +1218,18 @@ const Bn = E.create({
1204
1218
  return [{ tag: 'blockquote[data-it-type="quote"]' }];
1205
1219
  },
1206
1220
  renderHTML({ HTMLAttributes: t, node: e }) {
1207
- const n = nt(e.attrs.props);
1221
+ const n = dt(e.attrs.props);
1208
1222
  return [
1209
1223
  "blockquote",
1210
- _(t, {
1224
+ F(t, {
1211
1225
  "data-it-type": "quote",
1212
1226
  class: "it-doc-quote",
1213
- style: J("quote", n)
1227
+ style: ot("quote", n)
1214
1228
  }),
1215
1229
  0
1216
1230
  ];
1217
1231
  }
1218
- }), Wn = E.create({
1232
+ }), sr = Y.create({
1219
1233
  name: "itCode",
1220
1234
  group: "block",
1221
1235
  content: "text*",
@@ -1232,19 +1246,19 @@ const Bn = E.create({
1232
1246
  return [{ tag: "pre" }];
1233
1247
  },
1234
1248
  renderHTML({ HTMLAttributes: t, node: e }) {
1235
- const n = nt(e.attrs.props);
1249
+ const n = dt(e.attrs.props);
1236
1250
  return [
1237
1251
  "pre",
1238
- _(t, {
1252
+ F(t, {
1239
1253
  "data-it-type": "code",
1240
1254
  class: "it-doc-code",
1241
1255
  "data-lang": e.attrs.lang || "",
1242
- style: J("code", n)
1256
+ style: ot("code", n)
1243
1257
  }),
1244
1258
  ["code", 0]
1245
1259
  ];
1246
1260
  }
1247
- }), Gn = E.create({
1261
+ }), ir = Y.create({
1248
1262
  name: "itDivider",
1249
1263
  group: "block",
1250
1264
  atom: !0,
@@ -1252,9 +1266,9 @@ const Bn = E.create({
1252
1266
  return [{ tag: "hr" }];
1253
1267
  },
1254
1268
  renderHTML({ HTMLAttributes: t }) {
1255
- return ["hr", _(t, { class: "it-doc-divider" })];
1269
+ return ["hr", F(t, { class: "it-doc-divider" })];
1256
1270
  }
1257
- }), Un = E.create({
1271
+ }), ar = Y.create({
1258
1272
  name: "itMeta",
1259
1273
  group: "block",
1260
1274
  atom: !0,
@@ -1274,14 +1288,24 @@ const Bn = E.create({
1274
1288
  const n = String(e.attrs.raw || "").replace(/\s*\|\s*/g, " · ");
1275
1289
  return [
1276
1290
  "div",
1277
- _(t, { "data-it-meta": "", class: "it-doc-meta" }),
1291
+ F(t, { "data-it-meta": "", class: "it-doc-meta" }),
1278
1292
  `⚙ ${n}`
1279
1293
  ];
1280
1294
  }
1281
- }), Yn = E.create({
1295
+ });
1296
+ function Mt(t) {
1297
+ try {
1298
+ const e = JSON.parse(t || "[]");
1299
+ return Array.isArray(e) ? e : [];
1300
+ } catch {
1301
+ return [];
1302
+ }
1303
+ }
1304
+ const cr = Y.create({
1282
1305
  name: "itTable",
1283
1306
  group: "block",
1284
1307
  atom: !0,
1308
+ selectable: !0,
1285
1309
  addAttributes() {
1286
1310
  return {
1287
1311
  rows: {
@@ -1295,45 +1319,89 @@ const Bn = E.create({
1295
1319
  return [{ tag: "table[data-it-table]" }];
1296
1320
  },
1297
1321
  renderHTML({ HTMLAttributes: t, node: e }) {
1298
- let n = [];
1299
- try {
1300
- n = JSON.parse(e.attrs.rows || "[]");
1301
- } catch {
1302
- n = [];
1303
- }
1304
- const r = n[0] || [], o = n.slice(1);
1322
+ const n = Mt(e.attrs.rows), r = n[0] || [], o = n.slice(1);
1305
1323
  return [
1306
1324
  "table",
1307
- _(t, {
1325
+ F(t, {
1308
1326
  "data-it-table": "",
1309
1327
  class: "it-doc-table"
1310
1328
  }),
1311
1329
  [
1312
1330
  "thead",
1313
- ["tr", ...r.map((l) => ["th", Yt(l), String(l)])]
1331
+ ["tr", ...r.map((c) => ["th", ne(c), String(c)])]
1314
1332
  ],
1315
1333
  [
1316
1334
  "tbody",
1317
- ...o.map((l) => [
1335
+ ...o.map((c) => [
1318
1336
  "tr",
1319
- ...l.map((c) => ["td", Yt(c), String(c)])
1337
+ ...c.map((a) => ["td", ne(a), String(a)])
1320
1338
  ])
1321
1339
  ]
1322
1340
  ];
1341
+ },
1342
+ addNodeView() {
1343
+ return ({ node: t, editor: e, getPos: n }) => {
1344
+ const r = document.createElement("table");
1345
+ r.className = "it-doc-table", r.setAttribute("data-it-table", "");
1346
+ const o = document.createElement("thead"), c = document.createElement("tbody");
1347
+ r.append(o, c);
1348
+ let a = Mt(t.attrs.rows);
1349
+ const d = () => {
1350
+ const u = [];
1351
+ r.querySelectorAll("tr").forEach((f) => {
1352
+ const b = [];
1353
+ f.querySelectorAll("th,td").forEach(
1354
+ (S) => b.push((S.textContent || "").trim())
1355
+ ), u.push(b);
1356
+ });
1357
+ const h = JSON.stringify(u);
1358
+ if (h !== t.attrs.rows && (a = u, typeof n == "function")) {
1359
+ const f = n();
1360
+ if (f == null) return;
1361
+ const b = e.view.state.tr.setNodeAttribute(f, "rows", h);
1362
+ e.view.dispatch(b);
1363
+ }
1364
+ }, i = (u, h) => {
1365
+ const f = document.createElement(u);
1366
+ f.textContent = h;
1367
+ const b = e.isEditable;
1368
+ return f.contentEditable = b ? "true" : "false", /\{\{[^}]+\}\}|^each:/.test(String(h).trim()) && (f.className = "it-doc-var-cell"), f.addEventListener("blur", d), f.addEventListener("keydown", (S) => {
1369
+ S.key === "Enter" && (S.preventDefault(), S.target.blur());
1370
+ }), f;
1371
+ }, m = (u) => {
1372
+ o.innerHTML = "", c.innerHTML = "";
1373
+ const h = u[0] || [], f = document.createElement("tr");
1374
+ h.forEach((b) => f.appendChild(i("th", String(b)))), o.appendChild(f), u.slice(1).forEach((b) => {
1375
+ const S = document.createElement("tr");
1376
+ b.forEach((T) => S.appendChild(i("td", String(T)))), c.appendChild(S);
1377
+ });
1378
+ };
1379
+ return m(a), {
1380
+ dom: r,
1381
+ // Re-render only when the attr changed from OUTSIDE this view (e.g.
1382
+ // source-mode edit), not from our own commit, to keep the caret stable.
1383
+ update(u) {
1384
+ return u.type.name !== "itTable" ? !1 : (u.attrs.rows !== JSON.stringify(a) && (a = Mt(u.attrs.rows), m(a)), !0);
1385
+ },
1386
+ // The cells own the selection while editing; let ProseMirror ignore
1387
+ // mutations inside the contenteditable cells.
1388
+ ignoreMutation: () => !0
1389
+ };
1390
+ };
1323
1391
  }
1324
1392
  });
1325
- function Yt(t) {
1393
+ function ne(t) {
1326
1394
  return /\{\{[^}]+\}\}|^each:/.test(String(t).trim()) ? { class: "it-doc-var-cell" } : {};
1327
1395
  }
1328
- function Pt(t) {
1329
- 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()), l = o.shift() || "", c = {};
1396
+ function jt(t) {
1397
+ 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 = {};
1330
1398
  for (const d of o) {
1331
- const s = d.indexOf(":");
1332
- s > 0 && (c[d.slice(0, s).trim().toLowerCase()] = d.slice(s + 1).trim());
1399
+ const i = d.indexOf(":");
1400
+ i > 0 && (a[d.slice(0, i).trim().toLowerCase()] = d.slice(i + 1).trim());
1333
1401
  }
1334
- return { keyword: n, content: l, props: c };
1402
+ return { keyword: n, content: c, props: a };
1335
1403
  }
1336
- const Kn = E.create({
1404
+ const lr = Y.create({
1337
1405
  name: "itTrust",
1338
1406
  group: "block",
1339
1407
  atom: !0,
@@ -1355,36 +1423,36 @@ const Kn = E.create({
1355
1423
  return [{ tag: "div[data-it-trust]" }];
1356
1424
  },
1357
1425
  renderHTML({ HTMLAttributes: t, node: e }) {
1358
- const { keyword: n, content: r, props: o } = Pt(
1426
+ const { keyword: n, content: r, props: o } = jt(
1359
1427
  String(e.attrs.raw || "")
1360
- ), l = o.role || o.title || "", c = (o.at || o.date || o.time || "").slice(0, 10), d = [];
1428
+ ), c = o.role || o.title || "", a = (o.at || o.date || o.time || "").slice(0, 10), d = [];
1361
1429
  if (n === "seal" || n === "freeze") {
1362
- const s = n === "seal" && r || o.hash || "";
1363
- d.push(["span", { class: "it-doc-trust__label" }, "Sealed document"]), c && d.push(["span", { class: "it-doc-trust__date" }, c]), s && d.push([
1430
+ const i = n === "seal" && r || o.hash || "";
1431
+ d.push(["span", { class: "it-doc-trust__label" }, "Sealed document"]), a && d.push(["span", { class: "it-doc-trust__date" }, a]), i && d.push([
1364
1432
  "code",
1365
1433
  { class: "it-doc-trust__hash" },
1366
- s.length > 20 ? s.slice(0, 20) + "..." : s
1434
+ i.length > 20 ? i.slice(0, 20) + "..." : i
1367
1435
  ]);
1368
1436
  } else if (n === "approve") {
1369
- const s = o.by || r, f = o.by ? r : "";
1370
- d.push(["span", { class: "it-doc-trust__label" }, "Approved"]), f && d.push(["span", { class: "it-doc-trust__what" }, f]), s && d.push([
1437
+ const i = o.by || r, m = o.by ? r : "";
1438
+ d.push(["span", { class: "it-doc-trust__label" }, "Approved"]), m && d.push(["span", { class: "it-doc-trust__what" }, m]), i && d.push([
1371
1439
  "span",
1372
1440
  { class: "it-doc-trust__who" },
1373
- l ? `${s}, ${l}` : s
1374
- ]), c && d.push(["span", { class: "it-doc-trust__date" }, c]);
1441
+ c ? `${i}, ${c}` : i
1442
+ ]), a && d.push(["span", { class: "it-doc-trust__date" }, a]);
1375
1443
  } else if (n === "amend" || n === "amendment")
1376
- d.push(["span", { class: "it-doc-trust__label" }, "Amendment"]), r && d.push(["span", { class: "it-doc-trust__what" }, r]), c && d.push(["span", { class: "it-doc-trust__date" }, c]);
1444
+ d.push(["span", { class: "it-doc-trust__label" }, "Amendment"]), r && d.push(["span", { class: "it-doc-trust__what" }, r]), a && d.push(["span", { class: "it-doc-trust__date" }, a]);
1377
1445
  else {
1378
- const s = r || o.by || "", f = !!o.hash;
1379
- d.push(["span", { class: "it-doc-trust__name" }, s]), l && d.push(["span", { class: "it-doc-trust__role" }, l]), c && d.push(["span", { class: "it-doc-trust__date" }, c]), d.push([
1446
+ const i = r || o.by || "", m = !!o.hash;
1447
+ 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([
1380
1448
  "span",
1381
1449
  { class: "it-doc-trust__status" },
1382
- f ? "Signed · verified" : "Signed"
1450
+ m ? "Signed · verified" : "Signed"
1383
1451
  ]);
1384
1452
  }
1385
1453
  return [
1386
1454
  "div",
1387
- _(t, {
1455
+ F(t, {
1388
1456
  "data-it-trust": "",
1389
1457
  "data-trust": n,
1390
1458
  class: `it-doc-trust it-doc-trust--${n}`
@@ -1392,7 +1460,7 @@ const Kn = E.create({
1392
1460
  ...d
1393
1461
  ];
1394
1462
  }
1395
- }), qn = E.create({
1463
+ }), dr = Y.create({
1396
1464
  name: "itMetric",
1397
1465
  group: "block",
1398
1466
  atom: !0,
@@ -1409,22 +1477,22 @@ const Kn = E.create({
1409
1477
  return [{ tag: "div[data-it-metric]" }];
1410
1478
  },
1411
1479
  renderHTML({ HTMLAttributes: t, node: e }) {
1412
- const { content: n, props: r } = Pt(String(e.attrs.raw || "")), o = [r.value, r.unit].filter(Boolean).join(" "), l = /\b(total|balance due|amount due|grand)\b/i.test(n), c = /\{\{[^}]+\}\}/.test(o);
1480
+ const { content: n, props: r } = jt(String(e.attrs.raw || "")), o = [r.value, r.unit].filter(Boolean).join(" "), c = /\b(total|balance due|amount due|grand)\b/i.test(n), a = /\{\{[^}]+\}\}/.test(o);
1413
1481
  return [
1414
1482
  "div",
1415
- _(t, {
1483
+ F(t, {
1416
1484
  "data-it-metric": "",
1417
- class: `it-doc-metric${l ? " it-doc-metric--total" : ""}`
1485
+ class: `it-doc-metric${c ? " it-doc-metric--total" : ""}`
1418
1486
  }),
1419
1487
  ["span", { class: "it-doc-metric__label" }, n],
1420
1488
  [
1421
1489
  "span",
1422
- { class: `it-doc-metric__value${c ? " it-doc-var" : ""}` },
1490
+ { class: `it-doc-metric__value${a ? " it-doc-var" : ""}` },
1423
1491
  o
1424
1492
  ]
1425
1493
  ];
1426
1494
  }
1427
- }), Jn = E.create({
1495
+ }), ur = Y.create({
1428
1496
  name: "itStyleRule",
1429
1497
  group: "block",
1430
1498
  atom: !0,
@@ -1441,10 +1509,10 @@ const Kn = E.create({
1441
1509
  return [{ tag: "div[data-it-style-rule]" }];
1442
1510
  },
1443
1511
  renderHTML({ HTMLAttributes: t, node: e }) {
1444
- const { content: n, props: r } = Pt(String(e.attrs.raw || "")), o = Object.entries(r).map(([l, c]) => `${l}: ${c}`).join(" · ");
1512
+ const { content: n, props: r } = jt(String(e.attrs.raw || "")), o = Object.entries(r).map(([c, a]) => `${c}: ${a}`).join(" · ");
1445
1513
  return [
1446
1514
  "div",
1447
- _(t, {
1515
+ F(t, {
1448
1516
  "data-it-style-rule": "",
1449
1517
  class: "it-doc-stylerule"
1450
1518
  }),
@@ -1453,7 +1521,7 @@ const Kn = E.create({
1453
1521
  ["span", { class: "it-doc-stylerule__decl" }, o]
1454
1522
  ];
1455
1523
  }
1456
- }), Vn = E.create({
1524
+ }), pr = Y.create({
1457
1525
  name: "itBreak",
1458
1526
  group: "block",
1459
1527
  atom: !0,
@@ -1463,13 +1531,13 @@ const Kn = E.create({
1463
1531
  renderHTML({ HTMLAttributes: t }) {
1464
1532
  return [
1465
1533
  "div",
1466
- _(t, {
1534
+ F(t, {
1467
1535
  "data-it-type": "break",
1468
1536
  class: "it-doc-break"
1469
1537
  })
1470
1538
  ];
1471
1539
  }
1472
- }), Qn = E.create({
1540
+ }), fr = Y.create({
1473
1541
  name: "itGenericBlock",
1474
1542
  group: "block",
1475
1543
  content: "inline*",
@@ -1485,16 +1553,16 @@ const Kn = E.create({
1485
1553
  return [{ tag: '[data-it-type="generic"]' }];
1486
1554
  },
1487
1555
  renderHTML({ HTMLAttributes: t, node: e }) {
1488
- const n = e.attrs.keyword, r = nt(e.attrs.props), o = String(
1556
+ const n = e.attrs.keyword, r = dt(e.attrs.props), o = String(
1489
1557
  r.to || r.url || r.href || r.file || ""
1490
1558
  ).trim();
1491
1559
  return (n === "link" || n === "ref") && o ? [
1492
1560
  "p",
1493
- _(t, {
1561
+ F(t, {
1494
1562
  "data-it-type": "generic",
1495
1563
  "data-keyword": n,
1496
1564
  class: `it-doc-generic it-doc-kw-${n}`,
1497
- style: J(n, r)
1565
+ style: ot(n, r)
1498
1566
  }),
1499
1567
  [
1500
1568
  "a",
@@ -1508,16 +1576,16 @@ const Kn = E.create({
1508
1576
  ]
1509
1577
  ] : [
1510
1578
  "p",
1511
- _(t, {
1579
+ F(t, {
1512
1580
  "data-it-type": "generic",
1513
1581
  "data-keyword": n,
1514
1582
  class: `it-doc-generic it-doc-kw-${n}`,
1515
- style: J(n, r)
1583
+ style: ot(n, r)
1516
1584
  }),
1517
1585
  ["span", { class: "it-doc-generic-content" }, 0]
1518
1586
  ];
1519
1587
  }
1520
- }), Zn = E.create({
1588
+ }), gr = Y.create({
1521
1589
  name: "itComment",
1522
1590
  group: "block",
1523
1591
  content: "inline*",
@@ -1528,7 +1596,7 @@ const Kn = E.create({
1528
1596
  renderHTML({ HTMLAttributes: t }) {
1529
1597
  return [
1530
1598
  "p",
1531
- _(t, {
1599
+ F(t, {
1532
1600
  "data-it-type": "comment",
1533
1601
  class: "it-doc-comment"
1534
1602
  }),
@@ -1536,19 +1604,19 @@ const Kn = E.create({
1536
1604
  ];
1537
1605
  }
1538
1606
  });
1539
- function nt(t) {
1607
+ function dt(t) {
1540
1608
  try {
1541
1609
  return typeof t == "string" ? JSON.parse(t) : t || {};
1542
1610
  } catch {
1543
1611
  return {};
1544
1612
  }
1545
1613
  }
1546
- const re = {
1614
+ const me = {
1547
1615
  leading: "leading",
1548
1616
  "space-before": "spaceBefore",
1549
1617
  "space-after": "spaceAfter",
1550
1618
  end: "end"
1551
- }, Xn = /* @__PURE__ */ new Set([
1619
+ }, hr = /* @__PURE__ */ new Set([
1552
1620
  "itTitle",
1553
1621
  "itSummary",
1554
1622
  "itSection",
@@ -1556,18 +1624,18 @@ const re = {
1556
1624
  "itQuote",
1557
1625
  "itCallout",
1558
1626
  "itGenericBlock"
1559
- ]), tr = /* @__PURE__ */ new Set(["itTitle", "itSection", "itSub"]);
1560
- function oe(t) {
1627
+ ]), mr = /* @__PURE__ */ new Set(["itTitle", "itSection", "itSub"]);
1628
+ function be(t) {
1561
1629
  try {
1562
1630
  return typeof t == "string" ? JSON.parse(t) : t || {};
1563
1631
  } catch {
1564
1632
  return {};
1565
1633
  }
1566
1634
  }
1567
- function se(t, e) {
1568
- return t === "paragraph" ? !0 : e === "end" ? tr.has(t) : Xn.has(t);
1635
+ function ye(t, e) {
1636
+ return t === "paragraph" ? !0 : e === "end" ? mr.has(t) : hr.has(t);
1569
1637
  }
1570
- const er = Ie.extend({
1638
+ const br = en.extend({
1571
1639
  addAttributes() {
1572
1640
  return {
1573
1641
  ...this.parent?.(),
@@ -1596,30 +1664,30 @@ const er = Ie.extend({
1596
1664
  renderHTML({ node: t, HTMLAttributes: e }) {
1597
1665
  return t.attrs.end ? [
1598
1666
  "p",
1599
- _(e),
1667
+ F(e),
1600
1668
  ["span", { class: "it-split-main" }, 0]
1601
- ] : ["p", _(e), 0];
1669
+ ] : ["p", F(e), 0];
1602
1670
  }
1603
- }), nr = vt.create({
1671
+ }), yr = vt.create({
1604
1672
  name: "blockProps",
1605
1673
  addCommands() {
1606
1674
  return {
1607
1675
  setBlockProp: (t, e) => ({ state: n, tr: r, dispatch: o }) => {
1608
- const { from: l, to: c } = n.selection;
1676
+ const { from: c, to: a } = n.selection;
1609
1677
  let d = !1;
1610
- return n.doc.nodesBetween(l, c, (s, f) => {
1611
- const p = s.type.name;
1612
- if (p === "bulletList" || p === "orderedList" || !s.isBlock || s.isAtom) return !1;
1613
- if (!se(p, t)) return !0;
1614
- if (p === "paragraph")
1615
- r.setNodeMarkup(f, void 0, {
1616
- ...s.attrs,
1617
- [re[t]]: e
1678
+ return n.doc.nodesBetween(c, a, (i, m) => {
1679
+ const u = i.type.name;
1680
+ if (u === "bulletList" || u === "orderedList" || !i.isBlock || i.isAtom) return !1;
1681
+ if (!ye(u, t)) return !0;
1682
+ if (u === "paragraph")
1683
+ r.setNodeMarkup(m, void 0, {
1684
+ ...i.attrs,
1685
+ [me[t]]: e
1618
1686
  });
1619
1687
  else {
1620
- const h = oe(s.attrs.props);
1621
- e == null || e === "" ? delete h[t] : h[t] = e, r.setNodeMarkup(f, void 0, {
1622
- ...s.attrs,
1688
+ const h = be(i.attrs.props);
1689
+ e == null || e === "" ? delete h[t] : h[t] = e, r.setNodeMarkup(m, void 0, {
1690
+ ...i.attrs,
1623
1691
  props: JSON.stringify(h)
1624
1692
  });
1625
1693
  }
@@ -1629,23 +1697,23 @@ const er = Ie.extend({
1629
1697
  };
1630
1698
  }
1631
1699
  });
1632
- function X(t, e) {
1700
+ function ct(t, e) {
1633
1701
  if (!t) return null;
1634
1702
  const { state: n } = t, { from: r, to: o } = n.selection;
1635
- let l = null;
1636
- return n.doc.nodesBetween(r, o, (c) => {
1637
- if (l !== null) return !1;
1638
- const d = c.type.name;
1639
- if (!se(d, e)) return !0;
1703
+ let c = null;
1704
+ return n.doc.nodesBetween(r, o, (a) => {
1705
+ if (c !== null) return !1;
1706
+ const d = a.type.name;
1707
+ if (!ye(d, e)) return !0;
1640
1708
  if (d === "paragraph") {
1641
- const s = c.attrs[re[e]];
1642
- l = s != null ? String(s) : "";
1709
+ const i = a.attrs[me[e]];
1710
+ c = i != null ? String(i) : "";
1643
1711
  } else
1644
- l = oe(c.attrs.props)[e] ?? "";
1712
+ c = be(a.attrs.props)[e] ?? "";
1645
1713
  return !1;
1646
- }), l;
1714
+ }), c;
1647
1715
  }
1648
- const Kt = {
1716
+ const re = {
1649
1717
  identity: { label: "Identity", icon: "ID", color: "#3b82f6" },
1650
1718
  content: { label: "Content", icon: "Tx", color: "#6b7280" },
1651
1719
  structure: { label: "Structure", icon: "##", color: "#22c55e" },
@@ -1654,7 +1722,7 @@ const Kt = {
1654
1722
  trust: { label: "Trust", icon: "Tr", color: "#eab308" },
1655
1723
  layout: { label: "Layout", icon: "Pg", color: "#64748b" }
1656
1724
  };
1657
- function rr(t) {
1725
+ function vr(t) {
1658
1726
  const e = document.createElement("iframe");
1659
1727
  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);
1660
1728
  let n = !1;
@@ -1672,87 +1740,308 @@ function rr(t) {
1672
1740
  const o = e.contentWindow.document;
1673
1741
  o.open(), o.write(t), o.close(), o.readyState === "complete" && window.setTimeout(r, 250);
1674
1742
  }
1675
- function or(t, e) {
1743
+ function kr(t, e) {
1676
1744
  return t.includes("</head>") ? t.replace("</head>", `<style>${e}</style></head>`) : t;
1677
1745
  }
1678
- const ie = ".it-doc-callout{background:none!important;border:1px solid #ccc!important}", qt = _e;
1679
- function sr(t, e) {
1746
+ const ve = ".it-doc-callout{background:none!important;border:1px solid #ccc!important}", oe = Ge;
1747
+ function Sr(t, e) {
1680
1748
  const n = document.querySelector(".docs-page .tiptap");
1681
1749
  if (!n) return null;
1682
1750
  const r = n.cloneNode(!0);
1683
- r.querySelectorAll("[data-it-spacer]").forEach((h) => h.remove());
1684
- const o = r.innerHTML, l = Array.from(
1751
+ r.querySelectorAll("[data-it-spacer]").forEach((h) => h.remove()), r.querySelectorAll('.it-doc-comment, [data-it-type="comment"]').forEach((h) => h.remove());
1752
+ const o = r.innerHTML, c = Array.from(
1685
1753
  document.querySelectorAll('style, link[rel="stylesheet"]')
1686
1754
  ).map((h) => h.outerHTML).join(`
1687
- `), c = Mt(t), d = c.autoHeight ? `${c.width}px auto` : `${c.width}px ${c.height}px`, s = `${c.marginTop}px ${c.marginRight}px ${c.marginBottom}px ${c.marginLeft}px`;
1688
- let f = `@page{size:${d};margin:${s};}`;
1689
- c.header && (f += `@page{@top-center{content:${qt(c.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`), c.footer && (f += `@page{@bottom-center{content:${qt(c.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);
1690
- const p = `
1755
+ `), a = Pt(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`;
1756
+ let m = `@page{size:${d};margin:${i};}`;
1757
+ a.header && (m += `@page{@top-center{content:${oe(a.header)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`), a.footer && (m += `@page{@bottom-center{content:${oe(a.footer)};font:10px -apple-system,sans-serif;color:#9aa0a6;}}`);
1758
+ const u = `
1691
1759
  html,body{margin:0;background:#fff;}
1692
1760
  .docs-page,.docs-page.docs-sheet{box-shadow:none;border-radius:0;margin:0;width:auto;min-height:0;padding:0;background:#fff;}
1693
1761
  .docs-page .tiptap{padding:0;}
1694
1762
  [data-it-spacer]{display:none!important;}
1695
- ${e === "minimal-ink" ? ie : ""}
1763
+ ${e === "minimal-ink" ? ve : ""}
1696
1764
  `;
1697
- return `<!doctype html><html><head><meta charset="utf-8">${l}<style>${f}${p}</style></head><body><div class="docs-page docs-sheet"><div class="tiptap">${o}</div></div></body></html>`;
1765
+ 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>`;
1698
1766
  }
1699
- function ir(t, e, n) {
1700
- const r = new Blob([t], { type: n }), o = URL.createObjectURL(r), l = document.createElement("a");
1701
- l.href = o, l.download = e, l.click(), URL.revokeObjectURL(o);
1767
+ function ke(t, e, n) {
1768
+ const r = new Blob([t], { type: n }), o = URL.createObjectURL(r), c = document.createElement("a");
1769
+ c.href = o, c.download = e, c.click(), URL.revokeObjectURL(o);
1702
1770
  }
1703
- function ae(t, e, n) {
1704
- let r = sr(t, n);
1771
+ function Se(t, e, n) {
1772
+ let r = Sr(t, n);
1705
1773
  if (!r) {
1706
- const o = et(t);
1707
- r = ze(o, { theme: e }), n === "minimal-ink" && (r = or(r, ie));
1774
+ const o = rt(t);
1775
+ r = We(o, { theme: e }), n === "minimal-ink" && (r = kr(r, ve));
1708
1776
  }
1709
1777
  return r;
1710
1778
  }
1711
- function ar(t, e, n = "normal") {
1779
+ function we(t, e, n = "normal") {
1712
1780
  try {
1713
- rr(ae(t, e, n));
1781
+ vr(Se(t, e, n));
1782
+ } catch {
1783
+ }
1784
+ }
1785
+ function wr(t, e) {
1786
+ try {
1787
+ let n = e;
1788
+ if (!n)
1789
+ try {
1790
+ const r = rt(t), c = r.blocks.find((i) => i.type === "meta")?.properties?.id, a = r.blocks.find((i) => i.type === "title")?.content || "";
1791
+ n = `${String(c || a || "document").trim().replace(/[^\w\-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "document"}.it`;
1792
+ } catch {
1793
+ n = "document.it";
1794
+ }
1795
+ ke(t, n, "text/plain;charset=utf-8");
1714
1796
  } catch {
1715
1797
  }
1716
1798
  }
1717
- function cr(t, e, n = "normal") {
1799
+ function po(t, e, n = "normal") {
1718
1800
  try {
1719
- ir(
1720
- ae(t, e, n),
1801
+ ke(
1802
+ Se(t, e, n),
1721
1803
  "document.html",
1722
1804
  "text/html"
1723
1805
  );
1724
1806
  } catch {
1725
1807
  }
1726
1808
  }
1727
- function lr() {
1728
- return Me();
1809
+ function Tr() {
1810
+ return Ue();
1811
+ }
1812
+ const se = "dotit.editor.lastSigner", ie = "dotit.editor.lastRole";
1813
+ function xr({ content: t, onChange: e, trust: n, intact: r }) {
1814
+ const [o, c] = z(!1), [a, d] = z(!1), [i, m] = z(
1815
+ () => localStorage.getItem(se) || ""
1816
+ ), [u, h] = z(() => localStorage.getItem(ie) || ""), [f, b] = z(!1), S = U(null), T = U(0), y = M((x) => {
1817
+ const _ = Date.now();
1818
+ _ - T.current < 400 || (T.current = _, x());
1819
+ }, []);
1820
+ W(() => {
1821
+ if (!o) return;
1822
+ const x = (_) => {
1823
+ S.current && !S.current.contains(_.target) && (c(!1), d(!1));
1824
+ };
1825
+ return document.addEventListener("mousedown", x), () => document.removeEventListener("mousedown", x);
1826
+ }, [o]);
1827
+ const v = n.isSealed || Ye(t), H = M(() => {
1828
+ const x = i.trim();
1829
+ if (x) {
1830
+ b(!0);
1831
+ try {
1832
+ const _ = Ke(t, {
1833
+ signer: x,
1834
+ role: u.trim() || void 0
1835
+ });
1836
+ _.source && _.source !== t && e(_.source), localStorage.setItem(se, x), u.trim() && localStorage.setItem(ie, u.trim());
1837
+ } finally {
1838
+ b(!1), d(!1), c(!1);
1839
+ }
1840
+ }
1841
+ }, [t, e, i, u]), B = M(() => {
1842
+ const x = i.trim() || n.signatures[0]?.by || "Document owner";
1843
+ b(!0);
1844
+ try {
1845
+ const _ = qe(t, {
1846
+ signer: x,
1847
+ role: u.trim() || n.signatures[0]?.role || void 0
1848
+ });
1849
+ _.source && _.source !== t && !_.error && e(_.source);
1850
+ } finally {
1851
+ b(!1), c(!1);
1852
+ }
1853
+ }, [t, e, i, u, n.signatures]), j = M(() => {
1854
+ b(!0);
1855
+ try {
1856
+ const x = Ve(t);
1857
+ typeof x == "string" && x !== t && e(x);
1858
+ } finally {
1859
+ b(!1), c(!1);
1860
+ }
1861
+ }, [t, e]), [P, I] = z(null), X = M(() => {
1862
+ try {
1863
+ I(fe(t));
1864
+ } catch {
1865
+ I(null);
1866
+ }
1867
+ }, [t]);
1868
+ let C = /* @__PURE__ */ s(Ct, { size: 15 }), R = "Draft", V = "trust-face--draft";
1869
+ return v ? (C = /* @__PURE__ */ s(Yt, { size: 15 }), R = r === !1 ? "Sealed · changed!" : "Sealed", V = r === !1 ? "trust-face--broken" : "trust-face--sealed") : n.signatures.length > 0 && (C = /* @__PURE__ */ s(Gt, { size: 15 }), R = `Signed · ${n.signatures.length}`, V = "trust-face--signed"), /* @__PURE__ */ g("div", { className: "trust-control", ref: S, children: [
1870
+ /* @__PURE__ */ g(
1871
+ "button",
1872
+ {
1873
+ className: `docs-tb-btn trust-face ${V}`,
1874
+ onClick: () => {
1875
+ c((x) => !x), d(!1), v && X();
1876
+ },
1877
+ title: "Document trust — sign, seal, verify",
1878
+ children: [
1879
+ /* @__PURE__ */ s("span", { className: "trust-face__icon", children: C }),
1880
+ /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: R }),
1881
+ v && r === !0 && /* @__PURE__ */ s("span", { className: "trust-face__ok", title: "Hash verified", children: "✓" }),
1882
+ /* @__PURE__ */ s(yt, { size: 12 })
1883
+ ]
1884
+ }
1885
+ ),
1886
+ o && /* @__PURE__ */ g("div", { className: "trust-popover", children: [
1887
+ /* @__PURE__ */ s("div", { className: "trust-popover__state", children: v ? /* @__PURE__ */ g(J, { children: [
1888
+ /* @__PURE__ */ s("strong", { children: "🔒 Sealed — read-only" }),
1889
+ /* @__PURE__ */ g("div", { className: "trust-popover__meta", children: [
1890
+ n.sealedBy && /* @__PURE__ */ g(J, { children: [
1891
+ "by ",
1892
+ n.sealedBy
1893
+ ] }),
1894
+ n.sealedAt && /* @__PURE__ */ g(J, { children: [
1895
+ " on ",
1896
+ n.sealedAt
1897
+ ] })
1898
+ ] })
1899
+ ] }) : n.signatures.length > 0 ? /* @__PURE__ */ g(J, { children: [
1900
+ /* @__PURE__ */ s("strong", { children: "Signed" }),
1901
+ /* @__PURE__ */ s("div", { className: "trust-popover__meta", children: n.signatures.map((x) => x.role ? `${x.by} (${x.role})` : x.by).join(" · ") })
1902
+ ] }) : /* @__PURE__ */ g(J, { children: [
1903
+ /* @__PURE__ */ s("strong", { children: "Draft" }),
1904
+ /* @__PURE__ */ s("div", { className: "trust-popover__meta", children: "Not signed or sealed yet." })
1905
+ ] }) }),
1906
+ /* @__PURE__ */ s("div", { className: "trust-popover__divider" }),
1907
+ v ? /* @__PURE__ */ g(J, { children: [
1908
+ /* @__PURE__ */ g("div", { className: "trust-popover__verify", children: [
1909
+ P ? P.intact ? /* @__PURE__ */ s("span", { className: "trust-verify--ok", children: "✓ Verified — content matches the seal" }) : /* @__PURE__ */ s("span", { className: "trust-verify--bad", children: "⚠ Hash mismatch — content changed after sealing" }) : null,
1910
+ P?.hash && /* @__PURE__ */ g("details", { className: "trust-popover__hash", children: [
1911
+ /* @__PURE__ */ s("summary", { children: "Show hash" }),
1912
+ /* @__PURE__ */ s("code", { children: P.hash })
1913
+ ] })
1914
+ ] }),
1915
+ /* @__PURE__ */ g(
1916
+ "button",
1917
+ {
1918
+ className: "trust-popover__action",
1919
+ onClick: () => y(X),
1920
+ disabled: f,
1921
+ children: [
1922
+ /* @__PURE__ */ s(Gt, { size: 14 }),
1923
+ " Re-verify"
1924
+ ]
1925
+ }
1926
+ ),
1927
+ /* @__PURE__ */ g(
1928
+ "button",
1929
+ {
1930
+ className: "trust-popover__action trust-popover__action--warn",
1931
+ onClick: () => y(j),
1932
+ disabled: f,
1933
+ title: "Remove the freeze lock (keeps signatures) and make the document editable again",
1934
+ children: [
1935
+ /* @__PURE__ */ s(nn, { size: 14 }),
1936
+ " Unseal (make editable)"
1937
+ ]
1938
+ }
1939
+ )
1940
+ ] }) : a ? /* @__PURE__ */ g("div", { className: "trust-sign-form", children: [
1941
+ /* @__PURE__ */ s(
1942
+ "input",
1943
+ {
1944
+ className: "trust-sign-input",
1945
+ placeholder: "Your name",
1946
+ value: i,
1947
+ autoFocus: !0,
1948
+ onChange: (x) => m(x.target.value),
1949
+ onKeyDown: (x) => {
1950
+ x.key === "Enter" && H(), x.key === "Escape" && d(!1);
1951
+ }
1952
+ }
1953
+ ),
1954
+ /* @__PURE__ */ s(
1955
+ "input",
1956
+ {
1957
+ className: "trust-sign-input",
1958
+ placeholder: "Role (optional, e.g. CEO)",
1959
+ value: u,
1960
+ onChange: (x) => h(x.target.value),
1961
+ onKeyDown: (x) => {
1962
+ x.key === "Enter" && H(), x.key === "Escape" && d(!1);
1963
+ }
1964
+ }
1965
+ ),
1966
+ /* @__PURE__ */ g("div", { className: "trust-sign-actions", children: [
1967
+ /* @__PURE__ */ g(
1968
+ "button",
1969
+ {
1970
+ className: "trust-popover__action trust-popover__action--primary",
1971
+ onClick: H,
1972
+ disabled: f || !i.trim(),
1973
+ children: [
1974
+ /* @__PURE__ */ s(Ct, { size: 14 }),
1975
+ " Add signature"
1976
+ ]
1977
+ }
1978
+ ),
1979
+ /* @__PURE__ */ s(
1980
+ "button",
1981
+ {
1982
+ className: "trust-popover__action",
1983
+ onClick: () => d(!1),
1984
+ children: "Cancel"
1985
+ }
1986
+ )
1987
+ ] })
1988
+ ] }) : /* @__PURE__ */ g(J, { children: [
1989
+ /* @__PURE__ */ g(
1990
+ "button",
1991
+ {
1992
+ className: "trust-popover__action",
1993
+ onClick: () => d(!0),
1994
+ disabled: f,
1995
+ title: "Add a signature line (does not freeze the document)",
1996
+ children: [
1997
+ /* @__PURE__ */ s(Ct, { size: 14 }),
1998
+ " Sign"
1999
+ ]
2000
+ }
2001
+ ),
2002
+ /* @__PURE__ */ g(
2003
+ "button",
2004
+ {
2005
+ className: "trust-popover__action trust-popover__action--primary",
2006
+ onClick: () => y(B),
2007
+ disabled: f,
2008
+ title: "Freeze the document with a tamper-evident hash. It becomes read-only until unsealed.",
2009
+ children: [
2010
+ /* @__PURE__ */ s(Yt, { size: 14 }),
2011
+ " Seal (freeze)"
2012
+ ]
2013
+ }
2014
+ )
2015
+ ] })
2016
+ ] })
2017
+ ] });
1729
2018
  }
1730
- const At = [
2019
+ const Et = [
1731
2020
  { label: "Normal text", node: "paragraph" },
1732
2021
  { label: "Title", node: "itTitle" },
1733
2022
  { label: "Section", node: "itSection" },
1734
2023
  { label: "Subsection", node: "itSub" },
1735
2024
  { label: "Summary", node: "itSummary" },
1736
2025
  { label: "Quote", node: "itQuote" }
1737
- ], dr = /* @__PURE__ */ new Set([
2026
+ ], Nr = /* @__PURE__ */ new Set([
1738
2027
  "history",
1739
2028
  "revision",
1740
2029
  "track",
1741
2030
  "freeze"
1742
- ]), ur = /* @__PURE__ */ new Set([
2031
+ ]), Lr = /* @__PURE__ */ new Set([
1743
2032
  "agent",
1744
2033
  "model",
1745
2034
  "meta",
1746
2035
  "context",
1747
2036
  "history"
1748
- ]), pr = [
2037
+ ]), Ar = [
1749
2038
  "identity",
1750
2039
  "structure",
1751
2040
  "content",
1752
2041
  "data",
1753
2042
  "trust",
1754
2043
  "layout"
1755
- ], Jt = [
2044
+ ], ae = [
1756
2045
  { label: "Default", value: "" },
1757
2046
  { label: "Inter", value: "Inter" },
1758
2047
  { label: "Arial", value: "Arial" },
@@ -1761,7 +2050,7 @@ const At = [
1761
2050
  { label: "Courier New", value: "Courier New" },
1762
2051
  { label: "Verdana", value: "Verdana" },
1763
2052
  { label: "Trebuchet MS", value: "Trebuchet MS" }
1764
- ], fr = ["1", "1.15", "1.5", "2", "2.5", "3"], gr = "12px", hr = [
2053
+ ], Cr = ["1", "1.15", "1.5", "2", "2.5", "3"], $r = "12px", _r = [
1765
2054
  "#000000",
1766
2055
  "#434343",
1767
2056
  "#666666",
@@ -1812,7 +2101,7 @@ const At = [
1812
2101
  "#6fa8dc",
1813
2102
  "#8e7cc3",
1814
2103
  "#c27ba0"
1815
- ], mr = [
2104
+ ], Mr = [
1816
2105
  "#ffffff",
1817
2106
  "#cfe2f3",
1818
2107
  "#d9ead3",
@@ -1824,14 +2113,14 @@ const At = [
1824
2113
  "#d0e0e3",
1825
2114
  "#e6b8af"
1826
2115
  ];
1827
- function $({
2116
+ function E({
1828
2117
  onClick: t,
1829
2118
  active: e,
1830
2119
  disabled: n,
1831
2120
  title: r,
1832
2121
  children: o
1833
2122
  }) {
1834
- return /* @__PURE__ */ a(
2123
+ return /* @__PURE__ */ s(
1835
2124
  "button",
1836
2125
  {
1837
2126
  className: `docs-tb-btn${e ? " active" : ""}`,
@@ -1842,12 +2131,12 @@ function $({
1842
2131
  }
1843
2132
  );
1844
2133
  }
1845
- function dt({
2134
+ function et({
1846
2135
  label: t,
1847
2136
  children: e,
1848
2137
  className: n = ""
1849
2138
  }) {
1850
- return /* @__PURE__ */ a(
2139
+ return /* @__PURE__ */ s(
1851
2140
  "div",
1852
2141
  {
1853
2142
  className: `ribbon-group ${n}`.trim(),
@@ -1857,283 +2146,317 @@ function dt({
1857
2146
  }
1858
2147
  );
1859
2148
  }
1860
- function ht() {
1861
- return /* @__PURE__ */ a("div", { className: "ribbon-sep" });
2149
+ function lt() {
2150
+ return /* @__PURE__ */ s("div", { className: "ribbon-sep" });
1862
2151
  }
1863
- function br({
2152
+ function Er({
1864
2153
  editor: t,
1865
2154
  isRtl: e = !1,
1866
2155
  onToggleRtl: n,
1867
2156
  content: r,
1868
- theme: o,
1869
- onThemeChange: l,
1870
- onTrustAction: c,
1871
- locked: d = !1
2157
+ onChange: o,
2158
+ theme: c,
2159
+ onThemeChange: a,
2160
+ onTrustAction: d,
2161
+ trust: i,
2162
+ sealIntact: m = null,
2163
+ locked: u = !1
1872
2164
  }) {
1873
- const [s, f] = P(!1), [p, h] = P(!1), [g, k] = P(!1), [M, C] = P(!1), [v, w] = P(!1), [I, O] = P(!1), [K, q] = P(!1), W = B(null), rt = B(null), N = B(null), H = B(null), ot = B(null), G = B(null);
1874
- j(() => {
1875
- const u = (x) => {
1876
- const S = x.target;
1877
- W.current && !W.current.contains(S) && f(!1), rt.current && !rt.current.contains(S) && h(!1), N.current && !N.current.contains(S) && k(!1), H.current && !H.current.contains(S) && C(!1), ot.current && !ot.current.contains(S) && w(!1), G.current && !G.current.contains(S) && O(!1);
2165
+ const [h, f] = z(!1), [b, S] = z(!1), [T, y] = z(!1), [v, H] = z(!1), [B, j] = z(!1), [P, I] = z(!1), [X, C] = z(!1), R = U(null), V = U(null), x = U(null), _ = U(null), G = U(null), st = U(null);
2166
+ W(() => {
2167
+ const p = (A) => {
2168
+ const N = A.target;
2169
+ R.current && !R.current.contains(N) && f(!1), V.current && !V.current.contains(N) && S(!1), x.current && !x.current.contains(N) && y(!1), _.current && !_.current.contains(N) && H(!1), G.current && !G.current.contains(N) && j(!1), st.current && !st.current.contains(N) && I(!1);
1878
2170
  };
1879
- return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
2171
+ return document.addEventListener("mousedown", p), () => document.removeEventListener("mousedown", p);
1880
2172
  }, []);
1881
- const L = () => {
1882
- f(!1), h(!1), k(!1), C(!1), w(!1), O(!1);
1883
- }, st = R(() => {
2173
+ const D = () => {
2174
+ f(!1), S(!1), y(!1), H(!1), j(!1), I(!1);
2175
+ }, ut = M(() => {
1884
2176
  if (!t) return "Normal text";
1885
- for (const u of At)
1886
- if (u.node === "paragraph" && t.isActive("paragraph")) {
1887
- if (!At.some(
1888
- (S) => S.node !== "paragraph" && t.isActive(S.node)
1889
- )) return u.label;
1890
- } else if (t.isActive(u.node))
1891
- return u.label;
2177
+ for (const p of Et)
2178
+ if (p.node === "paragraph" && t.isActive("paragraph")) {
2179
+ if (!Et.some(
2180
+ (N) => N.node !== "paragraph" && t.isActive(N.node)
2181
+ )) return p.label;
2182
+ } else if (t.isActive(p.node))
2183
+ return p.label;
1892
2184
  return "Normal text";
1893
- }, [t]), ut = R(() => {
2185
+ }, [t]), ht = M(() => {
1894
2186
  if (!t) return "Default";
1895
- const u = t.getAttributes("textStyle")?.fontFamily;
1896
- if (!u) return "Default";
1897
- const x = Jt.find((S) => S.value === u);
1898
- return x ? x.label : "Default";
1899
- }, [t]), [V, pt] = P(11), [, at] = P(0), m = Y(() => {
1900
- const u = /* @__PURE__ */ new Map();
1901
- for (const S of He) {
1902
- if (S.status !== "stable" || ur.has(S.canonical) || S.category === "agent") continue;
1903
- const Z = S.category, bt = u.get(Z) || [];
1904
- bt.push({
1905
- label: S.canonical,
1906
- keyword: S.canonical,
1907
- category: Z,
1908
- description: S.description,
1909
- isReadOnly: dr.has(S.canonical)
1910
- }), u.set(Z, bt);
2187
+ const p = t.getAttributes("textStyle")?.fontFamily;
2188
+ if (!p) return "Default";
2189
+ const A = ae.find((N) => N.value === p);
2190
+ return A ? A.label : "Default";
2191
+ }, [t]), [it, k] = z(11), [, w] = z(0), L = Q(() => {
2192
+ const p = /* @__PURE__ */ new Map();
2193
+ for (const N of Je) {
2194
+ if (N.status !== "stable" || Lr.has(N.canonical) || N.category === "agent") continue;
2195
+ const at = N.category, wt = p.get(at) || [];
2196
+ wt.push({
2197
+ label: N.canonical,
2198
+ keyword: N.canonical,
2199
+ category: at,
2200
+ description: N.description,
2201
+ isReadOnly: Nr.has(N.canonical)
2202
+ }), p.set(at, wt);
1911
2203
  }
1912
- const x = [];
1913
- for (const S of pr) {
1914
- const Z = u.get(S);
1915
- !Z || Z.length === 0 || (Z.sort((bt, he) => bt.keyword.localeCompare(he.keyword)), x.push({
1916
- category: Kt[S]?.label || S,
1917
- items: Z
2204
+ const A = [];
2205
+ for (const N of Ar) {
2206
+ const at = p.get(N);
2207
+ !at || at.length === 0 || (at.sort((wt, _e) => wt.keyword.localeCompare(_e.keyword)), A.push({
2208
+ category: re[N]?.label || N,
2209
+ items: at
1918
2210
  }));
1919
2211
  }
1920
- return x;
2212
+ return A;
1921
2213
  }, []);
1922
- j(() => {
2214
+ W(() => {
1923
2215
  if (!t) return;
1924
- const u = () => {
1925
- const x = t.getAttributes("textStyle");
1926
- if (x?.fontSize) {
1927
- const S = parseInt(x.fontSize, 10);
1928
- isNaN(S) || pt(S);
2216
+ const p = () => {
2217
+ const A = t.getAttributes("textStyle");
2218
+ if (A?.fontSize) {
2219
+ const N = parseInt(A.fontSize, 10);
2220
+ isNaN(N) || k(N);
1929
2221
  }
1930
- at((S) => S + 1);
2222
+ w((N) => N + 1);
1931
2223
  };
1932
- return t.on("selectionUpdate", u), t.on("transaction", u), () => {
1933
- t.off("selectionUpdate", u), t.off("transaction", u);
2224
+ return t.on("selectionUpdate", p), t.on("transaction", p), () => {
2225
+ t.off("selectionUpdate", p), t.off("transaction", p);
1934
2226
  };
1935
2227
  }, [t]);
1936
- const y = R(
1937
- (u) => {
1938
- t && (u === "paragraph" ? t.chain().focus().setParagraph().run() : u === "itQuote" ? t.chain().focus().setNode("itQuote").run() : t.chain().focus().setNode(u).run(), L());
2228
+ const Z = M(
2229
+ (p) => {
2230
+ t && (p === "paragraph" ? t.chain().focus().setParagraph().run() : p === "itQuote" ? t.chain().focus().setNode("itQuote").run() : t.chain().focus().setNode(p).run(), D());
1939
2231
  },
1940
2232
  [t]
1941
- ), T = R(
1942
- (u) => {
2233
+ ), tt = M(
2234
+ (p) => {
1943
2235
  if (!t) return;
1944
- const x = t.chain().focus();
1945
- u === "divider" ? x.setNode("itDivider").run() : u === "break" ? x.setNode("itBreak").run() : u === "code" ? x.setNode("itCode", { lang: "" }).run() : ["tip", "info", "warning", "danger", "success"].includes(u) ? x.setNode("itCallout", { variant: u }).run() : x.setNode("itGenericBlock", { keyword: u, properties: "" }).run(), L();
2236
+ const A = t.chain().focus();
2237
+ p === "divider" ? A.setNode("itDivider").run() : p === "break" ? A.setNode("itBreak").run() : p === "code" ? A.setNode("itCode", { lang: "" }).run() : ["tip", "info", "warning", "danger", "success"].includes(p) ? A.setNode("itCallout", { variant: p }).run() : A.setNode("itGenericBlock", { keyword: p, properties: "" }).run(), D();
1946
2238
  },
1947
2239
  [t]
1948
- ), D = R(
1949
- (u) => {
1950
- const x = Math.min(96, Math.max(8, V + u));
1951
- pt(x), t?.chain().focus().setFontSize(`${x}pt`).run();
2240
+ ), K = M(
2241
+ (p) => {
2242
+ const A = Math.min(96, Math.max(8, it + p));
2243
+ k(A), t?.chain().focus().setFontSize(`${A}pt`).run();
1952
2244
  },
1953
- [t, V]
1954
- ), Q = R(
1955
- (u) => {
1956
- t?.chain().focus().setBlockProp("leading", u).run(), L();
2245
+ [t, it]
2246
+ ), kt = M(
2247
+ (p) => {
2248
+ t?.chain().focus().setBlockProp("leading", p).run(), D();
1957
2249
  },
1958
2250
  [t]
1959
- ), U = R(
1960
- (u) => {
2251
+ ), St = M(
2252
+ (p) => {
1961
2253
  if (!t) return;
1962
- const x = X(t, u);
1963
- t.chain().focus().setBlockProp(u, x ? null : gr).run(), L();
2254
+ const A = ct(t, p);
2255
+ t.chain().focus().setBlockProp(p, A ? null : $r).run(), D();
1964
2256
  },
1965
2257
  [t]
1966
- ), ce = R(() => {
2258
+ ), Lt = M(() => {
1967
2259
  if (!t) return;
1968
- const u = window.prompt(
2260
+ const p = window.prompt(
1969
2261
  "Space before block (e.g. 12px, 1em — empty for none):",
1970
- X(t, "space-before") || ""
2262
+ ct(t, "space-before") || ""
1971
2263
  );
1972
- if (u === null) return;
1973
- const x = window.prompt(
2264
+ if (p === null) return;
2265
+ const A = window.prompt(
1974
2266
  "Space after block (e.g. 12px, 1em — empty for none):",
1975
- X(t, "space-after") || ""
2267
+ ct(t, "space-after") || ""
1976
2268
  );
1977
- x !== null && (t.chain().focus().setBlockProp("space-before", u.trim() || null).setBlockProp("space-after", x.trim() || null).run(), L());
1978
- }, [t]), le = R(() => {
2269
+ A !== null && (t.chain().focus().setBlockProp("space-before", p.trim() || null).setBlockProp("space-after", A.trim() || null).run(), D());
2270
+ }, [t]), xe = M(() => {
1979
2271
  if (!t) return;
1980
- const u = X(t, "end"), x = window.prompt(
2272
+ const p = ct(t, "end"), A = window.prompt(
1981
2273
  "Line-end text (shown at the end of the line — empty to remove):",
1982
- u || ""
2274
+ p || ""
1983
2275
  );
1984
- x !== null && t.chain().focus().setBlockProp("end", x.trim() || null).run();
1985
- }, [t]), de = R(() => {
2276
+ A !== null && t.chain().focus().setBlockProp("end", A.trim() || null).run();
2277
+ }, [t]), Ne = M(() => {
1986
2278
  t && (t.chain().focus().insertContent({
1987
2279
  type: "paragraph",
1988
2280
  attrs: { end: "End text" },
1989
2281
  content: [{ type: "text", text: "Start text" }]
1990
- }).run(), L());
1991
- }, [t]), ue = Y(() => lr(), []), mt = K ? "minimal-ink" : "normal", pe = R(
1992
- () => ar(r, o, mt),
1993
- [r, o, mt]
1994
- ), fe = R(
1995
- () => cr(r, o, mt),
1996
- [r, o, mt]
1997
- );
2282
+ }).run(), D());
2283
+ }, [t]), Le = Q(() => Tr(), []), Ut = X ? "minimal-ink" : "normal", Ae = M(
2284
+ () => we(r, c, Ut),
2285
+ [r, c, Ut]
2286
+ ), Ce = M(() => wr(r), [r]);
1998
2287
  if (!t) return null;
1999
- const Tt = X(t, "leading"), ge = !!X(t, "end");
2000
- return /* @__PURE__ */ b("div", { className: "docs-toolbar docs-ribbon", children: [
2001
- /* @__PURE__ */ b(dt, { label: "Edit", children: [
2002
- /* @__PURE__ */ a(
2003
- $,
2288
+ const At = ct(t, "leading"), $e = !!ct(t, "end");
2289
+ return /* @__PURE__ */ g("div", { className: "docs-toolbar docs-ribbon", children: [
2290
+ /* @__PURE__ */ g(et, { label: "Edit", children: [
2291
+ /* @__PURE__ */ s(
2292
+ E,
2004
2293
  {
2005
2294
  onClick: () => t.chain().focus().undo().run(),
2006
- disabled: d || !t.can().undo(),
2295
+ disabled: u || !t.can().undo(),
2007
2296
  title: "Undo (⌘Z)",
2008
- children: /* @__PURE__ */ a(Oe, { size: 16 })
2297
+ children: /* @__PURE__ */ s(rn, { size: 16 })
2009
2298
  }
2010
2299
  ),
2011
- /* @__PURE__ */ a(
2012
- $,
2300
+ /* @__PURE__ */ s(
2301
+ E,
2013
2302
  {
2014
2303
  onClick: () => t.chain().focus().redo().run(),
2015
- disabled: d || !t.can().redo(),
2304
+ disabled: u || !t.can().redo(),
2016
2305
  title: "Redo (⌘⇧Z)",
2017
- children: /* @__PURE__ */ a(De, { size: 16 })
2306
+ children: /* @__PURE__ */ s(on, { size: 16 })
2018
2307
  }
2019
2308
  )
2020
2309
  ] }),
2021
- /* @__PURE__ */ a(ht, {}),
2022
- /* @__PURE__ */ b(dt, { label: "File", children: [
2023
- /* @__PURE__ */ b($, { onClick: pe, title: "Print / Export PDF (WYSIWYG)", children: [
2024
- /* @__PURE__ */ a(Fe, { size: 16 }),
2025
- /* @__PURE__ */ a("span", { className: "ribbon-btn-text", children: "PDF" })
2310
+ /* @__PURE__ */ s(lt, {}),
2311
+ /* @__PURE__ */ g(et, { label: "File", children: [
2312
+ /* @__PURE__ */ g(E, { onClick: Ce, title: "Save / Download the .it file", children: [
2313
+ /* @__PURE__ */ s(sn, { size: 16 }),
2314
+ /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: "Save" })
2026
2315
  ] }),
2027
- /* @__PURE__ */ b($, { onClick: fe, title: "Export HTML", children: [
2028
- /* @__PURE__ */ a(je, { size: 16 }),
2029
- /* @__PURE__ */ a("span", { className: "ribbon-btn-text", children: "HTML" })
2316
+ /* @__PURE__ */ g(E, { onClick: Ae, title: "Export PDF (⌘P) — WYSIWYG", children: [
2317
+ /* @__PURE__ */ s(an, { size: 16 }),
2318
+ /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: "PDF" })
2030
2319
  ] }),
2031
- /* @__PURE__ */ a(
2032
- $,
2320
+ /* @__PURE__ */ s(
2321
+ E,
2033
2322
  {
2034
- onClick: () => q((u) => !u),
2035
- active: K,
2323
+ onClick: () => C((p) => !p),
2324
+ active: X,
2036
2325
  title: "Minimal ink mode (plain callouts when printing)",
2037
- children: /* @__PURE__ */ a(We, { size: 16 })
2326
+ children: /* @__PURE__ */ s(cn, { size: 16 })
2038
2327
  }
2039
2328
  ),
2040
- /* @__PURE__ */ a(
2329
+ /* @__PURE__ */ s(
2041
2330
  "select",
2042
2331
  {
2043
2332
  className: "ribbon-theme-select",
2044
- value: o,
2045
- onChange: (u) => l(u.target.value),
2046
- title: "Document theme (used by print/export)",
2047
- children: ue.map((u) => /* @__PURE__ */ a("option", { value: u, children: u.charAt(0).toUpperCase() + u.slice(1) }, u))
2333
+ value: c,
2334
+ onChange: (p) => a(p.target.value),
2335
+ title: "Document theme (used everywhere — canvas, print, export)",
2336
+ children: Le.map((p) => /* @__PURE__ */ s("option", { value: p, children: p.charAt(0).toUpperCase() + p.slice(1) }, p))
2048
2337
  }
2049
2338
  )
2050
2339
  ] }),
2051
- /* @__PURE__ */ a(ht, {}),
2052
- /* @__PURE__ */ b("div", { className: d ? "ribbon-locked" : "ribbon-editing", children: [
2053
- /* @__PURE__ */ b(dt, { label: "Text", children: [
2054
- /* @__PURE__ */ b("div", { className: "docs-tb-dropdown", ref: N, children: [
2055
- /* @__PURE__ */ b(
2340
+ /* @__PURE__ */ s(lt, {}),
2341
+ /* @__PURE__ */ g("div", { className: u ? "ribbon-locked" : "ribbon-editing", children: [
2342
+ /* @__PURE__ */ s(et, { label: "Style", children: /* @__PURE__ */ g("div", { className: "docs-tb-dropdown", ref: R, children: [
2343
+ /* @__PURE__ */ g(
2344
+ "button",
2345
+ {
2346
+ className: "docs-tb-select docs-tb-paragraph-select",
2347
+ onClick: () => {
2348
+ D(), f(!h);
2349
+ },
2350
+ children: [
2351
+ /* @__PURE__ */ s("span", { className: "docs-tb-select-label", children: ut() }),
2352
+ /* @__PURE__ */ s(yt, { size: 14 })
2353
+ ]
2354
+ }
2355
+ ),
2356
+ h && /* @__PURE__ */ s("div", { className: "docs-tb-dropdown-menu docs-style-menu", children: Et.map((p) => /* @__PURE__ */ s(
2357
+ "button",
2358
+ {
2359
+ className: `docs-tb-dropdown-item${ut() === p.label ? " active" : ""}`,
2360
+ onClick: () => Z(p.node),
2361
+ children: /* @__PURE__ */ s(
2362
+ "span",
2363
+ {
2364
+ className: `docs-style-preview docs-style-${p.node}`,
2365
+ children: p.label
2366
+ }
2367
+ )
2368
+ },
2369
+ p.node
2370
+ )) })
2371
+ ] }) }),
2372
+ /* @__PURE__ */ s(lt, {}),
2373
+ /* @__PURE__ */ g(et, { label: "Font", children: [
2374
+ /* @__PURE__ */ g("div", { className: "docs-tb-dropdown", ref: x, children: [
2375
+ /* @__PURE__ */ g(
2056
2376
  "button",
2057
2377
  {
2058
2378
  className: "docs-tb-select docs-tb-font-select",
2059
2379
  onClick: () => {
2060
- L(), k(!g);
2380
+ D(), y(!T);
2061
2381
  },
2062
2382
  children: [
2063
- /* @__PURE__ */ a("span", { className: "docs-tb-select-label", children: ut() }),
2064
- /* @__PURE__ */ a(yt, { size: 14 })
2383
+ /* @__PURE__ */ s("span", { className: "docs-tb-select-label", children: ht() }),
2384
+ /* @__PURE__ */ s(yt, { size: 14 })
2065
2385
  ]
2066
2386
  }
2067
2387
  ),
2068
- g && /* @__PURE__ */ a("div", { className: "docs-tb-dropdown-menu docs-font-menu", children: Jt.map((u) => /* @__PURE__ */ a(
2388
+ T && /* @__PURE__ */ s("div", { className: "docs-tb-dropdown-menu docs-font-menu", children: ae.map((p) => /* @__PURE__ */ s(
2069
2389
  "button",
2070
2390
  {
2071
- className: `docs-tb-dropdown-item${ut() === u.label ? " active" : ""}`,
2072
- style: { fontFamily: u.value || "inherit" },
2391
+ className: `docs-tb-dropdown-item${ht() === p.label ? " active" : ""}`,
2392
+ style: { fontFamily: p.value || "inherit" },
2073
2393
  onClick: () => {
2074
- u.value ? t.chain().focus().setFontFamily(u.value).run() : t.chain().focus().unsetFontFamily().run(), L();
2394
+ p.value ? t.chain().focus().setFontFamily(p.value).run() : t.chain().focus().unsetFontFamily().run(), D();
2075
2395
  },
2076
- children: u.label
2396
+ children: p.label
2077
2397
  },
2078
- u.value || "default"
2398
+ p.value || "default"
2079
2399
  )) })
2080
2400
  ] }),
2081
- /* @__PURE__ */ a($, { onClick: () => D(-1), title: "Decrease font size", children: /* @__PURE__ */ a(Ge, { size: 14 }) }),
2082
- /* @__PURE__ */ a("span", { className: "docs-tb-fontsize", children: V }),
2083
- /* @__PURE__ */ a($, { onClick: () => D(1), title: "Increase font size", children: /* @__PURE__ */ a(Bt, { size: 14 }) }),
2084
- /* @__PURE__ */ a(
2085
- $,
2401
+ /* @__PURE__ */ s(E, { onClick: () => K(-1), title: "Decrease font size", children: /* @__PURE__ */ s(ln, { size: 14 }) }),
2402
+ /* @__PURE__ */ s("span", { className: "docs-tb-fontsize", children: it }),
2403
+ /* @__PURE__ */ s(E, { onClick: () => K(1), title: "Increase font size", children: /* @__PURE__ */ s(Kt, { size: 14 }) })
2404
+ ] }),
2405
+ /* @__PURE__ */ s(lt, {}),
2406
+ /* @__PURE__ */ g(et, { label: "Text", children: [
2407
+ /* @__PURE__ */ s(
2408
+ E,
2086
2409
  {
2087
2410
  onClick: () => t.chain().focus().toggleBold().run(),
2088
2411
  active: t.isActive("bold"),
2089
2412
  title: "Bold (⌘B)",
2090
- children: /* @__PURE__ */ a(Ue, { size: 16 })
2413
+ children: /* @__PURE__ */ s(dn, { size: 16 })
2091
2414
  }
2092
2415
  ),
2093
- /* @__PURE__ */ a(
2094
- $,
2416
+ /* @__PURE__ */ s(
2417
+ E,
2095
2418
  {
2096
2419
  onClick: () => t.chain().focus().toggleItalic().run(),
2097
2420
  active: t.isActive("italic"),
2098
2421
  title: "Italic (⌘I)",
2099
- children: /* @__PURE__ */ a(Ye, { size: 16 })
2422
+ children: /* @__PURE__ */ s(un, { size: 16 })
2100
2423
  }
2101
2424
  ),
2102
- /* @__PURE__ */ a(
2103
- $,
2425
+ /* @__PURE__ */ s(
2426
+ E,
2104
2427
  {
2105
2428
  onClick: () => t.chain().focus().toggleUnderline().run(),
2106
2429
  active: t.isActive("underline"),
2107
2430
  title: "Underline (⌘U)",
2108
- children: /* @__PURE__ */ a(Ke, { size: 16 })
2431
+ children: /* @__PURE__ */ s(pn, { size: 16 })
2109
2432
  }
2110
2433
  ),
2111
- /* @__PURE__ */ a(
2112
- $,
2434
+ /* @__PURE__ */ s(
2435
+ E,
2113
2436
  {
2114
2437
  onClick: () => t.chain().focus().toggleStrike().run(),
2115
2438
  active: t.isActive("strike"),
2116
2439
  title: "Strikethrough (⌘⇧X)",
2117
- children: /* @__PURE__ */ a(qe, { size: 16 })
2440
+ children: /* @__PURE__ */ s(fn, { size: 16 })
2118
2441
  }
2119
2442
  ),
2120
- /* @__PURE__ */ b(
2443
+ /* @__PURE__ */ g(
2121
2444
  "div",
2122
2445
  {
2123
2446
  className: "docs-tb-dropdown docs-tb-color-dropdown",
2124
- ref: H,
2447
+ ref: _,
2125
2448
  children: [
2126
- /* @__PURE__ */ b(
2449
+ /* @__PURE__ */ g(
2127
2450
  "button",
2128
2451
  {
2129
2452
  className: "docs-tb-btn docs-tb-color-btn",
2130
2453
  onClick: () => {
2131
- L(), C(!M);
2454
+ D(), H(!v);
2132
2455
  },
2133
2456
  title: "Text color",
2134
2457
  children: [
2135
- /* @__PURE__ */ a(Je, { size: 16 }),
2136
- /* @__PURE__ */ a(
2458
+ /* @__PURE__ */ s(gn, { size: 16 }),
2459
+ /* @__PURE__ */ s(
2137
2460
  "span",
2138
2461
  {
2139
2462
  className: "docs-tb-color-indicator",
@@ -2145,29 +2468,29 @@ function br({
2145
2468
  ]
2146
2469
  }
2147
2470
  ),
2148
- M && /* @__PURE__ */ b("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2149
- /* @__PURE__ */ a("div", { className: "docs-color-grid-label", children: "Text color" }),
2150
- /* @__PURE__ */ a("div", { className: "docs-color-grid", children: hr.map((u) => /* @__PURE__ */ a(
2471
+ v && /* @__PURE__ */ g("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2472
+ /* @__PURE__ */ s("div", { className: "docs-color-grid-label", children: "Text color" }),
2473
+ /* @__PURE__ */ s("div", { className: "docs-color-grid", children: _r.map((p) => /* @__PURE__ */ s(
2151
2474
  "button",
2152
2475
  {
2153
2476
  className: "docs-color-swatch",
2154
- style: { background: u },
2155
- title: u,
2477
+ style: { background: p },
2478
+ title: p,
2156
2479
  onClick: () => {
2157
- t.chain().focus().setColor(u).run(), L();
2480
+ t.chain().focus().setColor(p).run(), D();
2158
2481
  }
2159
2482
  },
2160
- u
2483
+ p
2161
2484
  )) }),
2162
- /* @__PURE__ */ b(
2485
+ /* @__PURE__ */ g(
2163
2486
  "button",
2164
2487
  {
2165
2488
  className: "docs-tb-dropdown-item",
2166
2489
  onClick: () => {
2167
- t.chain().focus().unsetColor().run(), L();
2490
+ t.chain().focus().unsetColor().run(), D();
2168
2491
  },
2169
2492
  children: [
2170
- /* @__PURE__ */ a(It, { size: 14 }),
2493
+ /* @__PURE__ */ s(qt, { size: 14 }),
2171
2494
  " Reset"
2172
2495
  ]
2173
2496
  }
@@ -2176,23 +2499,23 @@ function br({
2176
2499
  ]
2177
2500
  }
2178
2501
  ),
2179
- /* @__PURE__ */ b(
2502
+ /* @__PURE__ */ g(
2180
2503
  "div",
2181
2504
  {
2182
2505
  className: "docs-tb-dropdown docs-tb-color-dropdown",
2183
- ref: ot,
2506
+ ref: G,
2184
2507
  children: [
2185
- /* @__PURE__ */ b(
2508
+ /* @__PURE__ */ g(
2186
2509
  "button",
2187
2510
  {
2188
2511
  className: "docs-tb-btn docs-tb-color-btn",
2189
2512
  onClick: () => {
2190
- L(), w(!v);
2513
+ D(), j(!B);
2191
2514
  },
2192
2515
  title: "Highlight color",
2193
2516
  children: [
2194
- /* @__PURE__ */ a(Ve, { size: 16 }),
2195
- /* @__PURE__ */ a(
2517
+ /* @__PURE__ */ s(hn, { size: 16 }),
2518
+ /* @__PURE__ */ s(
2196
2519
  "span",
2197
2520
  {
2198
2521
  className: "docs-tb-color-indicator",
@@ -2204,117 +2527,87 @@ function br({
2204
2527
  ]
2205
2528
  }
2206
2529
  ),
2207
- v && /* @__PURE__ */ b("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2208
- /* @__PURE__ */ a("div", { className: "docs-color-grid-label", children: "Highlight color" }),
2209
- /* @__PURE__ */ a("div", { className: "docs-color-grid docs-highlight-grid", children: mr.map((u) => /* @__PURE__ */ a(
2530
+ B && /* @__PURE__ */ g("div", { className: "docs-tb-dropdown-menu docs-color-grid-menu", children: [
2531
+ /* @__PURE__ */ s("div", { className: "docs-color-grid-label", children: "Highlight color" }),
2532
+ /* @__PURE__ */ s("div", { className: "docs-color-grid docs-highlight-grid", children: Mr.map((p) => /* @__PURE__ */ s(
2210
2533
  "button",
2211
2534
  {
2212
2535
  className: "docs-color-swatch",
2213
- style: { background: u },
2214
- title: u,
2536
+ style: { background: p },
2537
+ title: p,
2215
2538
  onClick: () => {
2216
- u === "#ffffff" ? t.chain().focus().unsetHighlight().run() : t.chain().focus().toggleHighlight({ color: u }).run(), L();
2539
+ p === "#ffffff" ? t.chain().focus().unsetHighlight().run() : t.chain().focus().toggleHighlight({ color: p }).run(), D();
2217
2540
  }
2218
2541
  },
2219
- u
2542
+ p
2220
2543
  )) })
2221
2544
  ] })
2222
2545
  ]
2223
2546
  }
2224
2547
  ),
2225
- /* @__PURE__ */ a(
2226
- $,
2548
+ /* @__PURE__ */ s(
2549
+ E,
2227
2550
  {
2228
2551
  onClick: () => t.chain().focus().toggleCode().run(),
2229
2552
  active: t.isActive("code"),
2230
2553
  title: "Inline code",
2231
- children: /* @__PURE__ */ a(Qe, { size: 16 })
2554
+ children: /* @__PURE__ */ s(mn, { size: 16 })
2232
2555
  }
2233
2556
  ),
2234
- /* @__PURE__ */ a(
2235
- $,
2557
+ /* @__PURE__ */ s(
2558
+ E,
2236
2559
  {
2237
2560
  onClick: () => t.chain().focus().unsetAllMarks().clearNodes().run(),
2238
2561
  title: "Clear formatting",
2239
- children: /* @__PURE__ */ a(It, { size: 16 })
2562
+ children: /* @__PURE__ */ s(qt, { size: 16 })
2240
2563
  }
2241
2564
  )
2242
2565
  ] }),
2243
- /* @__PURE__ */ a(ht, {}),
2244
- /* @__PURE__ */ b(dt, { label: "Paragraph", children: [
2245
- /* @__PURE__ */ b("div", { className: "docs-tb-dropdown", ref: W, children: [
2246
- /* @__PURE__ */ b(
2247
- "button",
2248
- {
2249
- className: "docs-tb-select docs-tb-paragraph-select",
2250
- onClick: () => {
2251
- L(), f(!s);
2252
- },
2253
- children: [
2254
- /* @__PURE__ */ a("span", { className: "docs-tb-select-label", children: st() }),
2255
- /* @__PURE__ */ a(yt, { size: 14 })
2256
- ]
2257
- }
2258
- ),
2259
- s && /* @__PURE__ */ a("div", { className: "docs-tb-dropdown-menu docs-style-menu", children: At.map((u) => /* @__PURE__ */ a(
2260
- "button",
2261
- {
2262
- className: `docs-tb-dropdown-item${st() === u.label ? " active" : ""}`,
2263
- onClick: () => y(u.node),
2264
- children: /* @__PURE__ */ a(
2265
- "span",
2266
- {
2267
- className: `docs-style-preview docs-style-${u.node}`,
2268
- children: u.label
2269
- }
2270
- )
2271
- },
2272
- u.node
2273
- )) })
2274
- ] }),
2275
- /* @__PURE__ */ a(
2276
- $,
2566
+ /* @__PURE__ */ s(lt, {}),
2567
+ /* @__PURE__ */ g(et, { label: "Paragraph", children: [
2568
+ /* @__PURE__ */ s(
2569
+ E,
2277
2570
  {
2278
2571
  onClick: () => t.chain().focus().setTextAlign("left").run(),
2279
2572
  active: t.isActive({ textAlign: "left" }),
2280
2573
  title: "Align left",
2281
- children: /* @__PURE__ */ a(Ze, { size: 16 })
2574
+ children: /* @__PURE__ */ s(bn, { size: 16 })
2282
2575
  }
2283
2576
  ),
2284
- /* @__PURE__ */ a(
2285
- $,
2577
+ /* @__PURE__ */ s(
2578
+ E,
2286
2579
  {
2287
2580
  onClick: () => t.chain().focus().setTextAlign("center").run(),
2288
2581
  active: t.isActive({ textAlign: "center" }),
2289
2582
  title: "Align center",
2290
- children: /* @__PURE__ */ a(Xe, { size: 16 })
2583
+ children: /* @__PURE__ */ s(yn, { size: 16 })
2291
2584
  }
2292
2585
  ),
2293
- /* @__PURE__ */ a(
2294
- $,
2586
+ /* @__PURE__ */ s(
2587
+ E,
2295
2588
  {
2296
2589
  onClick: () => t.chain().focus().setTextAlign("right").run(),
2297
2590
  active: t.isActive({ textAlign: "right" }),
2298
2591
  title: "Align right",
2299
- children: /* @__PURE__ */ a(tn, { size: 16 })
2592
+ children: /* @__PURE__ */ s(vn, { size: 16 })
2300
2593
  }
2301
2594
  ),
2302
- /* @__PURE__ */ a(
2303
- $,
2595
+ /* @__PURE__ */ s(
2596
+ E,
2304
2597
  {
2305
2598
  onClick: () => t.chain().focus().setTextAlign("justify").run(),
2306
2599
  active: t.isActive({ textAlign: "justify" }),
2307
2600
  title: "Justify",
2308
- children: /* @__PURE__ */ a(en, { size: 16 })
2601
+ children: /* @__PURE__ */ s(kn, { size: 16 })
2309
2602
  }
2310
2603
  ),
2311
- /* @__PURE__ */ a(
2312
- $,
2604
+ /* @__PURE__ */ s(
2605
+ E,
2313
2606
  {
2314
2607
  onClick: () => n?.(),
2315
2608
  active: e,
2316
2609
  title: e ? "Switch to LTR (left-to-right)" : "Switch to RTL (right-to-left)",
2317
- children: /* @__PURE__ */ a(
2610
+ children: /* @__PURE__ */ s(
2318
2611
  "span",
2319
2612
  {
2320
2613
  style: {
@@ -2328,323 +2621,457 @@ function br({
2328
2621
  )
2329
2622
  }
2330
2623
  ),
2331
- /* @__PURE__ */ b("div", { className: "docs-tb-dropdown", ref: G, children: [
2332
- /* @__PURE__ */ b(
2624
+ /* @__PURE__ */ g("div", { className: "docs-tb-dropdown", ref: st, children: [
2625
+ /* @__PURE__ */ g(
2333
2626
  "button",
2334
2627
  {
2335
- className: `docs-tb-btn${Tt ? " active" : ""}`,
2628
+ className: `docs-tb-btn${At ? " active" : ""}`,
2336
2629
  onClick: () => {
2337
- L(), O(!I);
2630
+ D(), I(!P);
2338
2631
  },
2339
2632
  title: "Line & paragraph spacing",
2340
2633
  children: [
2341
- /* @__PURE__ */ a(nn, { size: 16 }),
2342
- /* @__PURE__ */ a(yt, { size: 12 })
2634
+ /* @__PURE__ */ s(Sn, { size: 16 }),
2635
+ /* @__PURE__ */ s(yt, { size: 12 })
2343
2636
  ]
2344
2637
  }
2345
2638
  ),
2346
- I && /* @__PURE__ */ b("div", { className: "docs-tb-dropdown-menu docs-spacing-menu", children: [
2347
- /* @__PURE__ */ a("div", { className: "docs-insert-category", children: "Line spacing" }),
2348
- /* @__PURE__ */ a(
2639
+ P && /* @__PURE__ */ g("div", { className: "docs-tb-dropdown-menu docs-spacing-menu", children: [
2640
+ /* @__PURE__ */ s("div", { className: "docs-insert-category", children: "Line spacing" }),
2641
+ /* @__PURE__ */ s(
2349
2642
  "button",
2350
2643
  {
2351
- className: `docs-tb-dropdown-item${Tt ? "" : " active"}`,
2352
- onClick: () => Q(null),
2644
+ className: `docs-tb-dropdown-item${At ? "" : " active"}`,
2645
+ onClick: () => kt(null),
2353
2646
  children: "Default"
2354
2647
  }
2355
2648
  ),
2356
- fr.map((u) => /* @__PURE__ */ a(
2649
+ Cr.map((p) => /* @__PURE__ */ s(
2357
2650
  "button",
2358
2651
  {
2359
- className: `docs-tb-dropdown-item${Tt === u ? " active" : ""}`,
2360
- onClick: () => Q(u),
2361
- children: u === "1" ? "Single" : u === "2" ? "Double" : u
2652
+ className: `docs-tb-dropdown-item${At === p ? " active" : ""}`,
2653
+ onClick: () => kt(p),
2654
+ children: p === "1" ? "Single" : p === "2" ? "Double" : p
2362
2655
  },
2363
- u
2656
+ p
2364
2657
  )),
2365
- /* @__PURE__ */ a("div", { className: "docs-insert-divider" }),
2366
- /* @__PURE__ */ a("div", { className: "docs-insert-category", children: "Paragraph spacing" }),
2367
- /* @__PURE__ */ a(
2658
+ /* @__PURE__ */ s("div", { className: "docs-insert-divider" }),
2659
+ /* @__PURE__ */ s("div", { className: "docs-insert-category", children: "Paragraph spacing" }),
2660
+ /* @__PURE__ */ s(
2368
2661
  "button",
2369
2662
  {
2370
2663
  className: "docs-tb-dropdown-item",
2371
- onClick: () => U("space-before"),
2372
- children: X(t, "space-before") ? "Remove space before block" : "Add space before block"
2664
+ onClick: () => St("space-before"),
2665
+ children: ct(t, "space-before") ? "Remove space before block" : "Add space before block"
2373
2666
  }
2374
2667
  ),
2375
- /* @__PURE__ */ a(
2668
+ /* @__PURE__ */ s(
2376
2669
  "button",
2377
2670
  {
2378
2671
  className: "docs-tb-dropdown-item",
2379
- onClick: () => U("space-after"),
2380
- children: X(t, "space-after") ? "Remove space after block" : "Add space after block"
2672
+ onClick: () => St("space-after"),
2673
+ children: ct(t, "space-after") ? "Remove space after block" : "Add space after block"
2381
2674
  }
2382
2675
  ),
2383
- /* @__PURE__ */ a(
2676
+ /* @__PURE__ */ s(
2384
2677
  "button",
2385
2678
  {
2386
2679
  className: "docs-tb-dropdown-item",
2387
- onClick: ce,
2680
+ onClick: Lt,
2388
2681
  children: "Custom spacing…"
2389
2682
  }
2390
2683
  )
2391
2684
  ] })
2392
2685
  ] }),
2393
- /* @__PURE__ */ a(
2394
- $,
2686
+ /* @__PURE__ */ s(
2687
+ E,
2395
2688
  {
2396
2689
  onClick: () => t.chain().focus().toggleBulletList().run(),
2397
2690
  active: t.isActive("bulletList"),
2398
2691
  title: "Bullet list",
2399
- children: /* @__PURE__ */ a(rn, { size: 16 })
2692
+ children: /* @__PURE__ */ s(wn, { size: 16 })
2400
2693
  }
2401
2694
  ),
2402
- /* @__PURE__ */ a(
2403
- $,
2695
+ /* @__PURE__ */ s(
2696
+ E,
2404
2697
  {
2405
2698
  onClick: () => t.chain().focus().toggleOrderedList().run(),
2406
2699
  active: t.isActive("orderedList"),
2407
2700
  title: "Numbered list",
2408
- children: /* @__PURE__ */ a(on, { size: 16 })
2701
+ children: /* @__PURE__ */ s(Tn, { size: 16 })
2409
2702
  }
2410
2703
  )
2411
2704
  ] }),
2412
- /* @__PURE__ */ a(ht, {}),
2413
- /* @__PURE__ */ b(dt, { label: "Insert", children: [
2414
- /* @__PURE__ */ b("div", { className: "docs-tb-dropdown", ref: rt, children: [
2415
- /* @__PURE__ */ b(
2705
+ /* @__PURE__ */ s(lt, {}),
2706
+ /* @__PURE__ */ g(et, { label: "Insert", children: [
2707
+ /* @__PURE__ */ g("div", { className: "docs-tb-dropdown", ref: V, children: [
2708
+ /* @__PURE__ */ g(
2416
2709
  "button",
2417
2710
  {
2418
2711
  className: "docs-tb-select docs-tb-insert-select",
2419
2712
  onClick: () => {
2420
- L(), h(!p);
2713
+ D(), S(!b);
2421
2714
  },
2422
2715
  children: [
2423
- /* @__PURE__ */ a(Bt, { size: 15 }),
2424
- /* @__PURE__ */ a("span", { children: "Insert" }),
2425
- /* @__PURE__ */ a(yt, { size: 14 })
2716
+ /* @__PURE__ */ s(Kt, { size: 15 }),
2717
+ /* @__PURE__ */ s("span", { children: "Insert" }),
2718
+ /* @__PURE__ */ s(yt, { size: 14 })
2426
2719
  ]
2427
2720
  }
2428
2721
  ),
2429
- p && /* @__PURE__ */ b("div", { className: "docs-tb-dropdown-menu docs-insert-menu", children: [
2430
- /* @__PURE__ */ b(
2722
+ b && /* @__PURE__ */ g("div", { className: "docs-tb-dropdown-menu docs-insert-menu", children: [
2723
+ /* @__PURE__ */ g(
2431
2724
  "button",
2432
2725
  {
2433
2726
  className: "docs-tb-dropdown-item docs-insert-item",
2434
- onClick: de,
2727
+ onClick: Ne,
2435
2728
  title: "Two-sided row — content at the line start, value at the line end (text: … | end: …)",
2436
2729
  children: [
2437
- /* @__PURE__ */ a("span", { className: "docs-insert-icon", children: /* @__PURE__ */ a(Ot, { size: 13 }) }),
2438
- /* @__PURE__ */ a("span", { className: "docs-insert-label", children: "two-sided row" }),
2439
- /* @__PURE__ */ a("span", { className: "docs-insert-kw", children: "end:" })
2730
+ /* @__PURE__ */ s("span", { className: "docs-insert-icon", children: /* @__PURE__ */ s(Vt, { size: 13 }) }),
2731
+ /* @__PURE__ */ s("span", { className: "docs-insert-label", children: "two-sided row" }),
2732
+ /* @__PURE__ */ s("span", { className: "docs-insert-kw", children: "end:" })
2440
2733
  ]
2441
2734
  }
2442
2735
  ),
2443
- /* @__PURE__ */ a("div", { className: "docs-insert-divider" }),
2444
- m.map((u, x) => /* @__PURE__ */ b("div", { children: [
2445
- x > 0 && /* @__PURE__ */ a("div", { className: "docs-insert-divider" }),
2446
- /* @__PURE__ */ a("div", { className: "docs-insert-category", children: u.category }),
2447
- u.items.map((S) => /* @__PURE__ */ b(
2736
+ /* @__PURE__ */ s("div", { className: "docs-insert-divider" }),
2737
+ L.map((p, A) => /* @__PURE__ */ g("div", { children: [
2738
+ A > 0 && /* @__PURE__ */ s("div", { className: "docs-insert-divider" }),
2739
+ /* @__PURE__ */ s("div", { className: "docs-insert-category", children: p.category }),
2740
+ p.items.map((N) => /* @__PURE__ */ g(
2448
2741
  "button",
2449
2742
  {
2450
2743
  className: "docs-tb-dropdown-item docs-insert-item",
2451
- onClick: () => T(S.keyword),
2452
- disabled: S.isReadOnly,
2453
- title: S.description,
2744
+ onClick: () => tt(N.keyword),
2745
+ disabled: N.isReadOnly,
2746
+ title: N.description,
2454
2747
  children: [
2455
- /* @__PURE__ */ a("span", { className: "docs-insert-icon", children: Kt[S.category]?.icon || "•" }),
2456
- /* @__PURE__ */ a("span", { className: "docs-insert-label", children: S.label }),
2457
- /* @__PURE__ */ a("span", { className: "docs-insert-kw", children: S.isReadOnly ? "locked" : `.${S.keyword}` })
2748
+ /* @__PURE__ */ s("span", { className: "docs-insert-icon", children: re[N.category]?.icon || "•" }),
2749
+ /* @__PURE__ */ s("span", { className: "docs-insert-label", children: N.label }),
2750
+ /* @__PURE__ */ s("span", { className: "docs-insert-kw", children: N.isReadOnly ? "locked" : `.${N.keyword}` })
2458
2751
  ]
2459
2752
  },
2460
- S.keyword
2753
+ N.keyword
2461
2754
  ))
2462
- ] }, u.category))
2755
+ ] }, p.category))
2463
2756
  ] })
2464
2757
  ] }),
2465
- /* @__PURE__ */ a(
2466
- $,
2758
+ /* @__PURE__ */ s(
2759
+ E,
2467
2760
  {
2468
- onClick: le,
2469
- active: ge,
2761
+ onClick: xe,
2762
+ active: $e,
2470
2763
  title: "Two-sided row — set the text shown at the END of this line (end: property)",
2471
- children: /* @__PURE__ */ a(Ot, { size: 16 })
2764
+ children: /* @__PURE__ */ s(Vt, { size: 16 })
2472
2765
  }
2473
2766
  )
2474
2767
  ] })
2475
2768
  ] }),
2476
- c && /* @__PURE__ */ b(me, { children: [
2477
- /* @__PURE__ */ a(ht, {}),
2478
- /* @__PURE__ */ b(dt, { label: "Trust", children: [
2479
- /* @__PURE__ */ b(
2480
- $,
2481
- {
2482
- onClick: () => c("seal"),
2483
- disabled: d,
2484
- title: d ? "Document is already sealed" : "Seal — freeze the document with a tamper-evident hash",
2485
- children: [
2486
- /* @__PURE__ */ a(sn, { size: 16 }),
2487
- /* @__PURE__ */ a("span", { className: "ribbon-btn-text", children: "Seal" })
2488
- ]
2489
- }
2490
- ),
2491
- /* @__PURE__ */ b(
2492
- $,
2769
+ i && o ? /* @__PURE__ */ g(J, { children: [
2770
+ /* @__PURE__ */ s(lt, {}),
2771
+ /* @__PURE__ */ s(et, { label: "Trust", children: /* @__PURE__ */ s(
2772
+ xr,
2773
+ {
2774
+ content: r,
2775
+ onChange: o,
2776
+ trust: i,
2777
+ intact: m
2778
+ }
2779
+ ) })
2780
+ ] }) : d && /* @__PURE__ */ g(J, { children: [
2781
+ /* @__PURE__ */ s(lt, {}),
2782
+ /* @__PURE__ */ g(et, { label: "Trust", children: [
2783
+ /* @__PURE__ */ s(
2784
+ E,
2493
2785
  {
2494
- onClick: () => c("sign"),
2495
- title: "Sign — add a signature",
2496
- children: [
2497
- /* @__PURE__ */ a(an, { size: 16 }),
2498
- /* @__PURE__ */ a("span", { className: "ribbon-btn-text", children: "Sign" })
2499
- ]
2786
+ onClick: () => d("seal"),
2787
+ disabled: u,
2788
+ title: "Seal — freeze the document with a tamper-evident hash",
2789
+ children: /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: "Seal" })
2500
2790
  }
2501
2791
  ),
2502
- /* @__PURE__ */ b(
2503
- $,
2504
- {
2505
- onClick: () => c("verify"),
2506
- title: "Verify — check the document hash and signatures",
2507
- children: [
2508
- /* @__PURE__ */ a(cn, { size: 16 }),
2509
- /* @__PURE__ */ a("span", { className: "ribbon-btn-text", children: "Verify" })
2510
- ]
2511
- }
2512
- )
2792
+ /* @__PURE__ */ s(E, { onClick: () => d("sign"), title: "Sign", children: /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: "Sign" }) }),
2793
+ /* @__PURE__ */ s(E, { onClick: () => d("verify"), title: "Verify", children: /* @__PURE__ */ s("span", { className: "ribbon-btn-text", children: "Verify" }) })
2513
2794
  ] })
2514
2795
  ] })
2515
2796
  ] });
2516
2797
  }
2517
- const yr = { in: 96, cm: 96 / 2.54 }, kr = { in: 0.25, cm: 0.5 };
2518
- function Sr({ geometry: t, zoom: e, scrollEl: n }) {
2519
- const [r, o] = P(0);
2520
- j(() => {
2521
- const d = n.current;
2522
- if (!d) return;
2523
- const s = () => o(d.scrollLeft);
2524
- return s(), d.addEventListener("scroll", s, { passive: !0 }), () => d.removeEventListener("scroll", s);
2798
+ const zr = { in: 96, cm: 96 / 2.54 }, Hr = { in: 0.25, cm: 0.5 };
2799
+ function Te(t, e) {
2800
+ const n = zr[e], r = Hr[e], o = [], c = t / n;
2801
+ for (let a = 0; a <= c + 1e-6; a += r) {
2802
+ const d = Math.abs(a - Math.round(a)) < 1e-6;
2803
+ o.push({
2804
+ x: a * n,
2805
+ kind: d ? "major" : "minor",
2806
+ label: d && a > 0 ? String(Math.round(a)) : void 0
2807
+ });
2808
+ }
2809
+ return o;
2810
+ }
2811
+ function Rr({
2812
+ geometry: t,
2813
+ zoom: e,
2814
+ scrollEl: n,
2815
+ onMargins: r,
2816
+ locked: o = !1
2817
+ }) {
2818
+ const [c, a] = z(0), [d, i] = z(null), m = U(null);
2819
+ W(() => {
2820
+ const S = n.current;
2821
+ if (!S) return;
2822
+ const T = () => a(S.scrollLeft);
2823
+ return T(), S.addEventListener("scroll", T, { passive: !0 }), () => S.removeEventListener("scroll", T);
2525
2824
  }, [n]);
2526
- const l = Y(() => {
2527
- const d = yr[t.unit], s = kr[t.unit], f = [], p = t.width / d;
2528
- for (let h = 0; h <= p + 1e-6; h += s) {
2529
- const g = Math.abs(h - Math.round(h)) < 1e-6;
2530
- f.push({
2531
- x: h * d,
2532
- kind: g ? "major" : "minor",
2533
- label: g && h > 0 ? String(Math.round(h)) : void 0
2534
- });
2535
- }
2536
- return f;
2537
- }, [t.width, t.unit]), c = t.width * e;
2538
- return /* @__PURE__ */ a("div", { className: "docs-ruler", "aria-hidden": "true", children: /* @__PURE__ */ b(
2825
+ const u = Q(
2826
+ () => Te(t.width, t.unit),
2827
+ [t.width, t.unit]
2828
+ ), h = M(
2829
+ (S) => (T) => {
2830
+ !r || o || (T.preventDefault(), i(S));
2831
+ },
2832
+ [r, o]
2833
+ );
2834
+ W(() => {
2835
+ if (!d || !r) return;
2836
+ const S = (y) => {
2837
+ const v = m.current;
2838
+ if (!v) return;
2839
+ const H = v.getBoundingClientRect(), B = (y.clientX - H.left) / e;
2840
+ if (d === "left") {
2841
+ const j = Math.max(0, Math.min(B, t.width / 2));
2842
+ r({ left: j });
2843
+ } else {
2844
+ const j = Math.max(0, Math.min(t.width - B, t.width / 2));
2845
+ r({ right: j });
2846
+ }
2847
+ }, T = () => i(null);
2848
+ return window.addEventListener("pointermove", S), window.addEventListener("pointerup", T), () => {
2849
+ window.removeEventListener("pointermove", S), window.removeEventListener("pointerup", T);
2850
+ };
2851
+ }, [d, r, e, t.width]);
2852
+ const f = t.width * e, b = !!r && !o;
2853
+ return /* @__PURE__ */ s("div", { className: `docs-ruler${b ? " docs-ruler--draggable" : ""}`, children: /* @__PURE__ */ g(
2539
2854
  "div",
2540
2855
  {
2856
+ ref: m,
2541
2857
  className: "docs-ruler-track",
2542
- style: { width: c, transform: `translateX(${-r}px)` },
2858
+ style: { width: f, transform: `translateX(${-c}px)` },
2543
2859
  children: [
2544
- /* @__PURE__ */ a(
2860
+ /* @__PURE__ */ s(
2545
2861
  "div",
2546
2862
  {
2547
2863
  className: "docs-ruler-margin",
2548
2864
  style: { left: 0, width: t.marginLeft * e }
2549
2865
  }
2550
2866
  ),
2551
- /* @__PURE__ */ a(
2867
+ /* @__PURE__ */ s(
2552
2868
  "div",
2553
2869
  {
2554
2870
  className: "docs-ruler-margin",
2555
2871
  style: { right: 0, width: t.marginRight * e }
2556
2872
  }
2557
2873
  ),
2558
- l.map(
2559
- (d, s) => d.label ? /* @__PURE__ */ a(
2874
+ u.map(
2875
+ (S, T) => S.label ? /* @__PURE__ */ s("span", { className: "docs-ruler-num", style: { left: S.x * e }, children: S.label }, T) : /* @__PURE__ */ s(
2560
2876
  "span",
2561
2877
  {
2562
- className: "docs-ruler-num",
2563
- style: { left: d.x * e },
2564
- children: d.label
2878
+ className: `docs-ruler-tick docs-ruler-tick--${S.kind}`,
2879
+ style: { left: S.x * e }
2565
2880
  },
2566
- s
2567
- ) : /* @__PURE__ */ a(
2881
+ T
2882
+ )
2883
+ ),
2884
+ b && /* @__PURE__ */ g(J, { children: [
2885
+ /* @__PURE__ */ s(
2568
2886
  "span",
2569
2887
  {
2570
- className: `docs-ruler-tick docs-ruler-tick--${d.kind}`,
2571
- style: { left: d.x * e }
2888
+ className: `docs-ruler-stop docs-ruler-stop--h${d === "left" ? " dragging" : ""}`,
2889
+ style: { left: t.marginLeft * e },
2890
+ onPointerDown: h("left"),
2891
+ title: "Drag to set the left margin"
2892
+ }
2893
+ ),
2894
+ /* @__PURE__ */ s(
2895
+ "span",
2896
+ {
2897
+ className: `docs-ruler-stop docs-ruler-stop--h${d === "right" ? " dragging" : ""}`,
2898
+ style: { left: (t.width - t.marginRight) * e },
2899
+ onPointerDown: h("right"),
2900
+ title: "Drag to set the right margin"
2901
+ }
2902
+ )
2903
+ ] })
2904
+ ]
2905
+ }
2906
+ ) });
2907
+ }
2908
+ function Pr({
2909
+ geometry: t,
2910
+ zoom: e,
2911
+ scrollEl: n,
2912
+ onMargins: r,
2913
+ locked: o = !1,
2914
+ /** Extra px between the top of the scroll area and the page sheet top. */
2915
+ topOffset: c = 0
2916
+ }) {
2917
+ const [a, d] = z(0), [i, m] = z(null), u = U(null);
2918
+ W(() => {
2919
+ const y = n.current;
2920
+ if (!y) return;
2921
+ const v = () => d(y.scrollTop);
2922
+ return v(), y.addEventListener("scroll", v, { passive: !0 }), () => y.removeEventListener("scroll", v);
2923
+ }, [n]);
2924
+ const h = t.autoHeight ? t.width * 1.414 : t.height, f = Q(
2925
+ () => Te(h, t.unit),
2926
+ [h, t.unit]
2927
+ ), b = M(
2928
+ (y) => (v) => {
2929
+ !r || o || t.autoHeight || (v.preventDefault(), m(y));
2930
+ },
2931
+ [r, o, t.autoHeight]
2932
+ );
2933
+ W(() => {
2934
+ if (!i || !r) return;
2935
+ const y = (H) => {
2936
+ const B = u.current;
2937
+ if (!B) return;
2938
+ const j = B.getBoundingClientRect(), P = (H.clientY - j.left) / e;
2939
+ if (i === "top") {
2940
+ const I = Math.max(0, Math.min(P, h / 2));
2941
+ r({ top: I });
2942
+ } else {
2943
+ const I = Math.max(0, Math.min(h - P, h / 2));
2944
+ r({ bottom: I });
2945
+ }
2946
+ }, v = () => m(null);
2947
+ return window.addEventListener("pointermove", y), window.addEventListener("pointerup", v), () => {
2948
+ window.removeEventListener("pointermove", y), window.removeEventListener("pointerup", v);
2949
+ };
2950
+ }, [i, r, e, h]);
2951
+ const S = h * e, T = !!r && !o && !t.autoHeight;
2952
+ return /* @__PURE__ */ s("div", { className: "docs-ruler-v", children: /* @__PURE__ */ g(
2953
+ "div",
2954
+ {
2955
+ ref: u,
2956
+ className: "docs-ruler-v-track",
2957
+ style: { height: S, transform: `translateY(${c - a}px)` },
2958
+ children: [
2959
+ /* @__PURE__ */ s(
2960
+ "div",
2961
+ {
2962
+ className: "docs-ruler-margin docs-ruler-margin--v",
2963
+ style: { top: 0, height: t.marginTop * e }
2964
+ }
2965
+ ),
2966
+ /* @__PURE__ */ s(
2967
+ "div",
2968
+ {
2969
+ className: "docs-ruler-margin docs-ruler-margin--v",
2970
+ style: { bottom: 0, height: t.marginBottom * e }
2971
+ }
2972
+ ),
2973
+ f.map(
2974
+ (y, v) => y.label ? /* @__PURE__ */ s("span", { className: "docs-ruler-num docs-ruler-num--v", style: { top: y.x * e }, children: y.label }, v) : /* @__PURE__ */ s(
2975
+ "span",
2976
+ {
2977
+ className: `docs-ruler-tick docs-ruler-tick--v docs-ruler-tick--${y.kind}`,
2978
+ style: { top: y.x * e }
2572
2979
  },
2573
- s
2980
+ v
2574
2981
  )
2575
- )
2982
+ ),
2983
+ T && /* @__PURE__ */ g(J, { children: [
2984
+ /* @__PURE__ */ s(
2985
+ "span",
2986
+ {
2987
+ className: `docs-ruler-stop docs-ruler-stop--v${i === "top" ? " dragging" : ""}`,
2988
+ style: { top: t.marginTop * e },
2989
+ onPointerDown: b("top"),
2990
+ title: "Drag to set the top margin"
2991
+ }
2992
+ ),
2993
+ /* @__PURE__ */ s(
2994
+ "span",
2995
+ {
2996
+ className: `docs-ruler-stop docs-ruler-stop--v${i === "bottom" ? " dragging" : ""}`,
2997
+ style: { top: (h - t.marginBottom) * e },
2998
+ onPointerDown: b("bottom"),
2999
+ title: "Drag to set the bottom margin"
3000
+ }
3001
+ )
3002
+ ] })
2576
3003
  ]
2577
3004
  }
2578
3005
  ) });
2579
3006
  }
2580
- function Ct(t, e) {
3007
+ function zt(t, e) {
2581
3008
  return e ? `${t} (${e})` : t;
2582
3009
  }
2583
- function wr({ trust: t, intact: e }) {
3010
+ function Br({ trust: t, intact: e }) {
2584
3011
  if (t.isSealed) {
2585
3012
  const n = t.sealedBy || "unknown", r = t.signatures[t.signatures.length - 1]?.role;
2586
- return /* @__PURE__ */ b("div", { className: "docs-trust-banner docs-trust-banner--sealed", role: "status", children: [
2587
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__icon", children: "🔒" }),
2588
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__title", children: "Sealed" }),
2589
- /* @__PURE__ */ b("span", { className: "docs-trust-banner__text", children: [
3013
+ return /* @__PURE__ */ g("div", { className: "docs-trust-banner docs-trust-banner--sealed", role: "status", children: [
3014
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__icon", children: "🔒" }),
3015
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__title", children: "Sealed" }),
3016
+ /* @__PURE__ */ g("span", { className: "docs-trust-banner__text", children: [
2590
3017
  "signed by ",
2591
- Ct(n, r),
3018
+ zt(n, r),
2592
3019
  t.sealedAt ? ` on ${t.sealedAt}` : "",
2593
3020
  " · read-only"
2594
3021
  ] }),
2595
- e === !0 && /* @__PURE__ */ a("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--ok", children: "hash verified ✓" }),
2596
- e === !1 && /* @__PURE__ */ a("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--bad", children: "⚠ hash mismatch — content changed after sealing" })
3022
+ e === !0 && /* @__PURE__ */ s("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--ok", children: "hash verified ✓" }),
3023
+ e === !1 && /* @__PURE__ */ s("span", { className: "docs-trust-banner__verify docs-trust-banner__verify--bad", children: "⚠ hash mismatch — content changed after sealing" })
2597
3024
  ] });
2598
3025
  }
2599
- return t.signatures.length > 0 ? /* @__PURE__ */ b("div", { className: "docs-trust-banner docs-trust-banner--signed", role: "status", children: [
2600
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__icon", children: "✍" }),
2601
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__title", children: "Signed" }),
2602
- /* @__PURE__ */ b("span", { className: "docs-trust-banner__text", children: [
3026
+ return t.signatures.length > 0 ? /* @__PURE__ */ g("div", { className: "docs-trust-banner docs-trust-banner--signed", role: "status", children: [
3027
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__icon", children: "✍" }),
3028
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__title", children: "Signed" }),
3029
+ /* @__PURE__ */ g("span", { className: "docs-trust-banner__text", children: [
2603
3030
  "by",
2604
3031
  " ",
2605
- t.signatures.map((n) => `${Ct(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
3032
+ t.signatures.map((n) => `${zt(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
2606
3033
  ] })
2607
- ] }) : t.approvals.length > 0 ? /* @__PURE__ */ b(
3034
+ ] }) : t.approvals.length > 0 ? /* @__PURE__ */ g(
2608
3035
  "div",
2609
3036
  {
2610
3037
  className: "docs-trust-banner docs-trust-banner--approved",
2611
3038
  role: "status",
2612
3039
  children: [
2613
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__icon", children: "✓" }),
2614
- /* @__PURE__ */ a("span", { className: "docs-trust-banner__title", children: "Approved" }),
2615
- /* @__PURE__ */ b("span", { className: "docs-trust-banner__text", children: [
3040
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__icon", children: "✓" }),
3041
+ /* @__PURE__ */ s("span", { className: "docs-trust-banner__title", children: "Approved" }),
3042
+ /* @__PURE__ */ g("span", { className: "docs-trust-banner__text", children: [
2616
3043
  "by",
2617
3044
  " ",
2618
- t.approvals.map((n) => `${Ct(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
3045
+ t.approvals.map((n) => `${zt(n.by, n.role)}${n.at ? ` on ${n.at}` : ""}`).join(" · ")
2619
3046
  ] })
2620
3047
  ]
2621
3048
  }
2622
3049
  ) : null;
2623
3050
  }
2624
- function vr(t) {
3051
+ function Ir(t) {
2625
3052
  let e;
2626
3053
  try {
2627
- e = et(t);
3054
+ e = rt(t);
2628
3055
  } catch {
2629
3056
  return [];
2630
3057
  }
2631
- const n = [], r = (o, l) => {
2632
- const c = l == null ? "" : String(l).trim();
2633
- c && n.push({ key: o, value: c });
3058
+ const n = [], r = (o, c) => {
3059
+ const a = c == null ? "" : String(c).trim();
3060
+ a && n.push({ key: o, value: a });
2634
3061
  };
2635
3062
  for (const o of e.blocks)
2636
3063
  switch (o.type) {
2637
3064
  case "meta":
2638
- for (const [l, c] of Object.entries(o.properties || {})) r(l, c);
3065
+ for (const [c, a] of Object.entries(o.properties || {})) r(c, a);
2639
3066
  break;
2640
3067
  case "track":
2641
3068
  r("tracked", o.properties?.id ?? o.content);
2642
3069
  break;
2643
3070
  case "page": {
2644
- const l = o.properties?.orientation;
3071
+ const c = o.properties?.orientation;
2645
3072
  r(
2646
3073
  "page",
2647
- [o.content, l].filter(Boolean).join(" · ")
3074
+ [o.content, c].filter(Boolean).join(" · ")
2648
3075
  );
2649
3076
  break;
2650
3077
  }
@@ -2669,36 +3096,36 @@ function vr(t) {
2669
3096
  }
2670
3097
  return n;
2671
3098
  }
2672
- function Tr({ source: t }) {
2673
- const [e, n] = P(!1), r = Y(() => vr(t), [t]);
3099
+ function Dr({ source: t }) {
3100
+ const [e, n] = z(!1), r = Q(() => Ir(t), [t]);
2674
3101
  if (r.length === 0) return null;
2675
- const o = r.slice(0, 4).map((l) => `${l.key}: ${l.value}`).join(" · ");
2676
- return /* @__PURE__ */ b("div", { className: `docs-props-bar${e ? " open" : ""}`, children: [
2677
- /* @__PURE__ */ b(
3102
+ const o = r.slice(0, 4).map((c) => `${c.key}: ${c.value}`).join(" · ");
3103
+ return /* @__PURE__ */ g("div", { className: `docs-props-bar${e ? " open" : ""}`, children: [
3104
+ /* @__PURE__ */ g(
2678
3105
  "button",
2679
3106
  {
2680
3107
  className: "docs-props-toggle",
2681
- onClick: () => n((l) => !l),
3108
+ onClick: () => n((c) => !c),
2682
3109
  title: e ? "Hide document properties" : "Show document properties",
2683
3110
  children: [
2684
- /* @__PURE__ */ a("span", { className: "docs-props-caret", children: e ? "▾" : "▸" }),
3111
+ /* @__PURE__ */ s("span", { className: "docs-props-caret", children: e ? "▾" : "▸" }),
2685
3112
  "Document properties",
2686
- !e && /* @__PURE__ */ a("span", { className: "docs-props-summary", children: o })
3113
+ !e && /* @__PURE__ */ s("span", { className: "docs-props-summary", children: o })
2687
3114
  ]
2688
3115
  }
2689
3116
  ),
2690
- e && /* @__PURE__ */ a("div", { className: "docs-props-chips", children: r.map((l, c) => /* @__PURE__ */ b("span", { className: "docs-props-chip", children: [
2691
- /* @__PURE__ */ a("b", { children: l.key }),
3117
+ e && /* @__PURE__ */ s("div", { className: "docs-props-chips", children: r.map((c, a) => /* @__PURE__ */ g("span", { className: "docs-props-chip", children: [
3118
+ /* @__PURE__ */ s("b", { children: c.key }),
2692
3119
  " ",
2693
- l.value
2694
- ] }, `${l.key}-${c}`)) })
3120
+ c.value
3121
+ ] }, `${c.key}-${a}`)) })
2695
3122
  ] });
2696
3123
  }
2697
- function z(t, e, n = "") {
3124
+ function O(t, e, n = "") {
2698
3125
  const r = t?.properties?.[e];
2699
3126
  return r != null ? String(r) : n;
2700
3127
  }
2701
- function Vt(t) {
3128
+ function ce(t) {
2702
3129
  const e = {
2703
3130
  lifecycle: "draft",
2704
3131
  isTracked: !1,
@@ -2712,104 +3139,140 @@ function Vt(t) {
2712
3139
  amendments: []
2713
3140
  };
2714
3141
  if (!t) return e;
2715
- const n = t.blocks, r = n.find((s) => s.type === "track");
3142
+ const n = t.blocks, r = n.find((i) => i.type === "track");
2716
3143
  r && (e.isTracked = !0, e.lifecycle = "tracked", e.trackBlock = {
2717
- id: z(r, "id", r.content ?? ""),
2718
- by: z(r, "by"),
2719
- at: z(r, "at")
3144
+ id: O(r, "id", r.content ?? ""),
3145
+ by: O(r, "by"),
3146
+ at: O(r, "at")
2720
3147
  });
2721
- const o = n.filter((s) => s.type === "approve");
2722
- for (const s of o)
3148
+ const o = n.filter((i) => i.type === "approve");
3149
+ for (const i of o)
2723
3150
  e.approvals.push({
2724
- by: z(s, "by", s.content ?? ""),
2725
- role: z(s, "role"),
2726
- at: z(s, "at"),
2727
- note: z(s, "note") || void 0
3151
+ by: O(i, "by", i.content ?? ""),
3152
+ role: O(i, "role"),
3153
+ at: O(i, "at"),
3154
+ note: O(i, "note") || void 0
2728
3155
  });
2729
3156
  e.approvals.length > 0 && (e.lifecycle = "approved");
2730
- const l = n.filter((s) => s.type === "sign");
2731
- for (const s of l)
3157
+ const c = n.filter((i) => i.type === "sign");
3158
+ for (const i of c)
2732
3159
  e.signatures.push({
2733
- by: z(s, "by", s.content ?? ""),
2734
- role: z(s, "role"),
2735
- at: z(s, "at")
3160
+ by: O(i, "by", i.content ?? ""),
3161
+ role: O(i, "role"),
3162
+ at: O(i, "at")
2736
3163
  });
2737
3164
  e.signatures.length > 0 && (e.lifecycle = "signed");
2738
- const c = n.find((s) => s.type === "freeze");
2739
- if (c) {
3165
+ const a = n.find((i) => i.type === "freeze");
3166
+ if (a) {
2740
3167
  e.isSealed = !0, e.lifecycle = "sealed";
2741
- const s = e.signatures[e.signatures.length - 1];
2742
- e.sealedBy = s?.by || z(c, "by", c.content ?? ""), e.sealedAt = z(c, "at") || s?.at || "", e.sealHash = z(c, "hash");
3168
+ const i = e.signatures[e.signatures.length - 1];
3169
+ e.sealedBy = i?.by || O(a, "by", a.content ?? ""), e.sealedAt = O(a, "at") || i?.at || "", e.sealHash = O(a, "hash");
2743
3170
  }
2744
- const d = n.filter((s) => s.type === "amendment");
2745
- for (const s of d)
3171
+ const d = n.filter((i) => i.type === "amendment");
3172
+ for (const i of d)
2746
3173
  e.amendments.push({
2747
- section: z(s, "section", s.content ?? ""),
2748
- was: z(s, "was"),
2749
- now: z(s, "now"),
2750
- by: z(s, "by"),
2751
- ref: z(s, "ref"),
2752
- at: z(s, "at")
3174
+ section: O(i, "section", i.content ?? ""),
3175
+ was: O(i, "was"),
3176
+ now: O(i, "now"),
3177
+ by: O(i, "by"),
3178
+ ref: O(i, "ref"),
3179
+ at: O(i, "at")
2753
3180
  });
2754
3181
  return e;
2755
3182
  }
2756
- const Qt = new te("template-highlight"), wt = /\{\{[^}]+\}\}/g;
2757
- function Zt(t) {
3183
+ const le = new pe("template-highlight"), Nt = /\{\{[^}]+\}\}/g;
3184
+ function de(t) {
2758
3185
  const e = [];
2759
3186
  return t.descendants((n, r) => {
2760
3187
  if (!n.isText || !n.text) return;
2761
- wt.lastIndex = 0;
3188
+ Nt.lastIndex = 0;
2762
3189
  let o;
2763
- for (; o = wt.exec(n.text); )
3190
+ for (; o = Nt.exec(n.text); )
2764
3191
  e.push(
2765
- Nt.inline(r + o.index, r + o.index + o[0].length, {
3192
+ Ht.inline(r + o.index, r + o.index + o[0].length, {
2766
3193
  class: "it-doc-var"
2767
3194
  })
2768
3195
  );
2769
- }), St.create(t, e);
3196
+ }), xt.create(t, e);
2770
3197
  }
2771
- const xr = vt.create({
3198
+ const Or = vt.create({
2772
3199
  name: "templateHighlight",
2773
3200
  addProseMirrorPlugins() {
2774
3201
  return [
2775
- new Xt({
2776
- key: Qt,
3202
+ new ue({
3203
+ key: le,
2777
3204
  state: {
2778
- init: (t, e) => Zt(e.doc),
2779
- apply: (t, e) => t.docChanged ? Zt(t.doc) : e
3205
+ init: (t, e) => de(e.doc),
3206
+ apply: (t, e) => t.docChanged ? de(t.doc) : e
2780
3207
  },
2781
3208
  props: {
2782
3209
  decorations(t) {
2783
- return Qt.getState(t);
3210
+ return le.getState(t);
2784
3211
  }
2785
3212
  }
2786
3213
  })
2787
3214
  ];
2788
3215
  }
2789
3216
  });
2790
- function qr(t) {
3217
+ function fo(t) {
2791
3218
  const e = /* @__PURE__ */ new Set(), n = [];
2792
- wt.lastIndex = 0;
3219
+ Nt.lastIndex = 0;
2793
3220
  let r;
2794
- for (; r = wt.exec(t); ) {
3221
+ for (; r = Nt.exec(t); ) {
2795
3222
  const o = r[0].slice(2, -2).trim();
2796
3223
  /^(page|pages|date|time|year)$/i.test(o) || e.has(o) || (e.add(o), n.push(o));
2797
3224
  }
2798
3225
  return n;
2799
3226
  }
2800
- function Jr(t) {
3227
+ function go(t) {
2801
3228
  const e = {};
2802
3229
  for (const n of t) {
2803
3230
  const r = n.split(".");
2804
3231
  let o = e;
2805
- for (let l = 0; l < r.length; l++) {
2806
- const c = r[l];
2807
- l === r.length - 1 ? c in o || (o[c] = "") : ((!(c in o) || typeof o[c] != "object" || o[c] === null) && (o[c] = {}), o = o[c]);
3232
+ for (let c = 0; c < r.length; c++) {
3233
+ const a = r[c];
3234
+ c === r.length - 1 ? a in o || (o[a] = "") : ((!(a in o) || typeof o[a] != "object" || o[a] === null) && (o[a] = {}), o = o[a]);
2808
3235
  }
2809
3236
  }
2810
3237
  return e;
2811
3238
  }
2812
- const Lr = 28, Ar = {
3239
+ function Fr(t, e, n) {
3240
+ const r = t.coordsAtPos(e), o = r.top + 1, c = r.bottom - 1, a = n === "start" ? -1 : 1;
3241
+ let d = e, i = e;
3242
+ for (let m = 0; m < 1e5; m++) {
3243
+ const u = d + a;
3244
+ if (u < 0 || u > t.state.doc.content.size) break;
3245
+ let h;
3246
+ try {
3247
+ h = t.coordsAtPos(u);
3248
+ } catch {
3249
+ break;
3250
+ }
3251
+ if (h.bottom <= o || h.top >= c) break;
3252
+ d = u, i = u;
3253
+ }
3254
+ return i;
3255
+ }
3256
+ const jr = vt.create({
3257
+ name: "lineKeymap",
3258
+ addKeyboardShortcuts() {
3259
+ const t = (e, n) => {
3260
+ const { view: r } = this.editor, { state: o } = r, { selection: c } = o, a = c.head, d = Fr(r, a, e);
3261
+ if (d == null || d === a)
3262
+ return !1;
3263
+ const i = o.doc.resolve(d), m = n ? c.anchor : d, u = o.tr.setSelection(
3264
+ n ? Wt.between(o.doc.resolve(m), i) : Wt.near(i)
3265
+ );
3266
+ return r.dispatch(u.scrollIntoView()), !0;
3267
+ };
3268
+ return {
3269
+ Home: () => t("start", !1),
3270
+ End: () => t("end", !1),
3271
+ "Shift-Home": () => t("start", !0),
3272
+ "Shift-End": () => t("end", !0)
3273
+ };
3274
+ }
3275
+ }), Ur = 28, Wr = {
2813
3276
  title: [".it-doc-title"],
2814
3277
  summary: [".it-doc-summary"],
2815
3278
  section: [".it-doc-section"],
@@ -2824,24 +3287,24 @@ const Lr = 28, Ar = {
2824
3287
  contact: ['.it-doc-generic[data-keyword="contact"]'],
2825
3288
  divider: [".it-doc-divider"]
2826
3289
  };
2827
- function Cr({
3290
+ function Gr({
2828
3291
  value: t,
2829
3292
  onChange: e,
2830
3293
  theme: n,
2831
3294
  onThemeChange: r,
2832
3295
  readOnly: o = !1,
2833
- showRibbon: l = !0,
2834
- showTrustBanner: c = !0,
3296
+ showRibbon: c = !0,
3297
+ showTrustBanner: a = !0,
2835
3298
  onTrustAction: d
2836
3299
  }) {
2837
- const s = B(""), f = B(!1), p = B(!0), [h, g] = P([]), k = B(Mt("")), [M, C] = P(1), v = ye({
3300
+ const i = U(""), m = U(!1), u = U(!0), [h, f] = z([]), b = U(Pt("")), [S, T] = z(1), y = Ee({
2838
3301
  extensions: [
2839
- mn.configure({
2840
- geometry: () => k.current,
2841
- gap: Lr,
2842
- onPages: C
3302
+ En.configure({
3303
+ geometry: () => b.current,
3304
+ gap: Ur,
3305
+ onPages: T
2843
3306
  }),
2844
- Se.configure({
3307
+ He.configure({
2845
3308
  heading: !1,
2846
3309
  codeBlock: !1,
2847
3310
  blockquote: !1,
@@ -2849,47 +3312,43 @@ function Cr({
2849
3312
  // Replaced by ITParagraph (core block props: end/leading/space-…).
2850
3313
  paragraph: !1
2851
3314
  }),
2852
- er,
2853
- nr,
2854
- we.configure({
2855
- // Professional behavior: a new empty line shows just the cursor.
2856
- // The hint appears only on a completely empty document.
2857
- placeholder: ({ editor: m }) => m.isEmpty ? "Start typing..." : ""
2858
- }),
2859
- ve,
2860
- Te,
2861
- xe,
2862
- Le.configure({ multicolor: !0 }),
2863
- Ae.configure({
3315
+ br,
3316
+ yr,
3317
+ jr,
3318
+ Re,
3319
+ Pe,
3320
+ Be,
3321
+ Ie.configure({ multicolor: !0 }),
3322
+ De.configure({
2864
3323
  types: ["paragraph", "itTitle", "itSummary", "itSection", "itSub"]
2865
3324
  }),
2866
- Ce,
2867
- ln,
2868
- Ne,
2869
- $e,
2870
- Bn,
2871
- In,
2872
- On,
2873
- Dn,
2874
- Fn,
2875
- jn,
2876
- Wn,
2877
- Gn,
2878
- Yn,
2879
- Un,
2880
- Kn,
2881
- qn,
2882
- Jn,
2883
- Vn,
2884
- Qn,
3325
+ Oe,
3326
+ xn,
3327
+ Fe,
3328
+ je,
2885
3329
  Zn,
2886
- xr
3330
+ tr,
3331
+ er,
3332
+ nr,
3333
+ rr,
3334
+ or,
3335
+ sr,
3336
+ ir,
3337
+ cr,
3338
+ ar,
3339
+ lr,
3340
+ dr,
3341
+ ur,
3342
+ pr,
3343
+ fr,
3344
+ gr,
3345
+ Or
2887
3346
  ],
2888
- content: Ut(t),
2889
- onUpdate: ({ editor: m }) => {
2890
- if (p.current) return;
2891
- const y = m.getJSON(), T = zn(y);
2892
- s.current = T, f.current = !0, g(Nn(y)), e(T);
3347
+ content: ee(t),
3348
+ onUpdate: ({ editor: k }) => {
3349
+ if (u.current) return;
3350
+ const w = k.getJSON(), L = Kn(w);
3351
+ i.current = L, m.current = !0, f(Wn(w)), e(L);
2893
3352
  },
2894
3353
  editorProps: {
2895
3354
  attributes: {
@@ -2898,280 +3357,303 @@ function Cr({
2898
3357
  }
2899
3358
  }
2900
3359
  });
2901
- j(() => {
2902
- const m = window.setTimeout(() => {
2903
- p.current = !1, s.current = t;
3360
+ W(() => {
3361
+ const k = window.setTimeout(() => {
3362
+ u.current = !1, i.current = t;
2904
3363
  }, 0);
2905
- return () => window.clearTimeout(m);
2906
- }, []), j(() => {
2907
- if (v) {
2908
- if (f.current) {
2909
- f.current = !1;
3364
+ return () => window.clearTimeout(k);
3365
+ }, []), W(() => {
3366
+ if (y) {
3367
+ if (m.current) {
3368
+ m.current = !1;
2910
3369
  return;
2911
3370
  }
2912
- if (t !== s.current) {
2913
- const m = Ut(t);
2914
- v.commands.setContent(m), s.current = t;
3371
+ if (t !== i.current) {
3372
+ const k = ee(t);
3373
+ y.commands.setContent(k), i.current = t;
2915
3374
  }
2916
3375
  }
2917
- }, [t, v]), j(() => {
2918
- if (!v) return;
2919
- const m = (y) => {
2920
- const T = y.detail;
2921
- T && v.chain().focus().insertContent(T).run();
3376
+ }, [t, y]), W(() => {
3377
+ if (!y) return;
3378
+ const k = (w) => {
3379
+ const L = w.detail;
3380
+ L && y.chain().focus().insertContent(L).run();
2922
3381
  };
2923
- return window.addEventListener("it-insert-text", m), () => window.removeEventListener("it-insert-text", m);
2924
- }, [v]);
2925
- const w = Y(() => Mt(t), [t]);
2926
- j(() => {
2927
- k.current = w, v?.view.dispatch(v.state.tr);
2928
- }, [w, v]);
2929
- const I = B(null), O = R(() => v ? v.storage.characterCount?.words?.() ?? v.getText().split(/\s+/).filter(Boolean).length : 0, [v]), K = Y(() => {
3382
+ return window.addEventListener("it-insert-text", k), () => window.removeEventListener("it-insert-text", k);
3383
+ }, [y]);
3384
+ const v = Q(() => Pt(t), [t]);
3385
+ W(() => {
3386
+ b.current = v, y?.view.dispatch(y.state.tr);
3387
+ }, [v, y]);
3388
+ const H = U(null), B = M(() => y ? y.storage.characterCount?.words?.() ?? y.getText().split(/\s+/).filter(Boolean).length : 0, [y]), j = Q(() => {
2930
3389
  if (!n) return "";
2931
3390
  try {
2932
- const m = Re(n);
2933
- return m ? Ee(m).replace(/:root\{/, ".docs-page{") : "";
3391
+ const k = Qe(n);
3392
+ return k ? Xe(k).replace(/:root\{/, ".docs-page{") : "";
2934
3393
  } catch {
2935
3394
  return "";
2936
3395
  }
2937
- }, [n]), q = Y(() => {
3396
+ }, [n]), P = Q(() => {
2938
3397
  try {
2939
- const m = et(t), y = m.blocks.find((U) => U.type === "header")?.content || "", T = m.blocks.find((U) => U.type === "footer")?.content || "", D = m.blocks.find((U) => U.type === "meta"), Q = String(D?.properties?.dir || "ltr").toLowerCase();
2940
- return { header: y, footer: T, dir: Q };
3398
+ const k = rt(t), w = k.blocks.find((K) => K.type === "header")?.content || "", L = k.blocks.find((K) => K.type === "footer")?.content || "", Z = k.blocks.find((K) => K.type === "meta"), tt = String(Z?.properties?.dir || "ltr").toLowerCase();
3399
+ return { header: w, footer: L, dir: tt };
2941
3400
  } catch {
2942
3401
  return { header: "", footer: "", dir: "ltr" };
2943
3402
  }
2944
- }, [t]), W = Y(() => {
3403
+ }, [t]), I = Q(() => {
2945
3404
  try {
2946
- return Vt(et(t));
3405
+ return ce(rt(t));
2947
3406
  } catch {
2948
- return Vt(null);
3407
+ return ce(null);
2949
3408
  }
2950
- }, [t]), rt = Y(() => {
2951
- if (!W.isSealed) return null;
3409
+ }, [t]), X = Q(() => {
3410
+ if (!I.isSealed) return null;
2952
3411
  try {
2953
- return Pe(t).intact;
3412
+ return fe(t).intact;
2954
3413
  } catch {
2955
3414
  return null;
2956
3415
  }
2957
- }, [t, W.isSealed]), N = W.isSealed || o;
2958
- j(() => {
2959
- v && v.isEditable !== !N && v.setEditable(!N);
2960
- }, [v, N]);
2961
- const H = Y(() => {
3416
+ }, [t, I.isSealed]), C = I.isSealed || o;
3417
+ W(() => {
3418
+ y && y.isEditable !== !C && y.setEditable(!C);
3419
+ }, [y, C]), W(() => {
3420
+ if (!y) return;
3421
+ y.view.dom.setAttribute("dir", P.dir === "rtl" ? "rtl" : "ltr");
3422
+ }, [y, P.dir]);
3423
+ const R = Q(() => {
2962
3424
  try {
2963
- return Be(
2964
- et(t),
2965
- Ar,
3425
+ return Ze(
3426
+ rt(t),
3427
+ Wr,
2966
3428
  ".docs-page .tiptap "
2967
3429
  );
2968
3430
  } catch {
2969
3431
  return "";
2970
3432
  }
2971
3433
  }, [t]);
2972
- j(() => {
2973
- let m = document.getElementById(
3434
+ W(() => {
3435
+ let k = document.getElementById(
2974
3436
  "it-doc-style-rules"
2975
3437
  );
2976
- m || (m = document.createElement("style"), m.id = "it-doc-style-rules", document.head.appendChild(m)), m.textContent = H;
2977
- }, [H]);
2978
- const ot = R(() => {
2979
- if (q.dir === "rtl") {
2980
- const y = t.split(`
2981
- `).map((T) => {
2982
- if (/^meta:/i.test(T.trim())) {
2983
- const D = T.replace(/\s*\|\s*dir:\s*rtl/gi, "").trim();
2984
- return D === "meta:" ? null : D;
2985
- }
2986
- return T;
2987
- }).filter((T) => T !== null).join(`
2988
- `);
2989
- e(y);
2990
- } else {
2991
- const y = /^meta:.*$/m.exec(t);
2992
- y ? e(t.replace(/^meta:.*$/m, `${y[0]} | dir: rtl`)) : /^(title:|summary:)/m.test(t) ? e(
2993
- t.replace(/^((?:title:|summary:).*)$/m, `$1
2994
- meta: | dir: rtl`)
2995
- ) : e(`meta: | dir: rtl
2996
- ${t}`);
2997
- }
2998
- }, [t, e, q.dir]);
2999
- j(() => {
3000
- const m = "it-editor-theme-css";
3001
- let y = document.getElementById(m);
3002
- y || (y = document.createElement("style"), y.id = m, document.head.appendChild(y)), y.textContent = K;
3003
- }, [K]);
3004
- const G = B(null), [L, st] = P(1), ut = B(L), V = B(null), pt = R(
3005
- (m) => {
3006
- const y = G.current;
3007
- if (!y) return;
3008
- const T = y.getBoundingClientRect();
3009
- V.current = {
3010
- cx: y.scrollLeft + (m.clientX - T.left),
3011
- cy: y.scrollTop + (m.clientY - T.top)
3438
+ k || (k = document.createElement("style"), k.id = "it-doc-style-rules", document.head.appendChild(k)), k.textContent = R;
3439
+ }, [R]);
3440
+ const V = M(() => {
3441
+ const k = P.dir === "rtl";
3442
+ e(tn(t, "dir", k ? null : "rtl"));
3443
+ }, [t, e, P.dir]), x = M(
3444
+ (k) => {
3445
+ const w = b.current, L = (Lt) => Math.max(0, Math.round(Lt / nt * 10) / 10), Z = L(k.top ?? w.marginTop), tt = L(k.right ?? w.marginRight), K = L(k.bottom ?? w.marginBottom), kt = L(k.left ?? w.marginLeft), St = `${Z}mm ${tt}mm ${K}mm ${kt}mm`;
3446
+ e(_n(t, St));
3447
+ },
3448
+ [t, e]
3449
+ );
3450
+ W(() => {
3451
+ const k = "it-editor-theme-css";
3452
+ let w = document.getElementById(k);
3453
+ w || (w = document.createElement("style"), w.id = k, document.head.appendChild(w)), w.textContent = j;
3454
+ }, [j]);
3455
+ const _ = U(null), [G, st] = z(1), D = U(G), ut = U(null), ht = M(
3456
+ (k) => {
3457
+ const w = _.current;
3458
+ if (!w) return;
3459
+ const L = w.getBoundingClientRect();
3460
+ ut.current = {
3461
+ cx: w.scrollLeft + (k.clientX - L.left),
3462
+ cy: w.scrollTop + (k.clientY - L.top)
3012
3463
  };
3013
3464
  },
3014
3465
  []
3015
- ), at = R(() => {
3016
- const m = G.current;
3017
- m && (V.current = {
3018
- cx: m.scrollLeft + m.clientWidth / 2,
3019
- cy: m.scrollTop + m.clientHeight / 2
3466
+ ), it = M(() => {
3467
+ const k = _.current;
3468
+ k && (ut.current = {
3469
+ cx: k.scrollLeft + k.clientWidth / 2,
3470
+ cy: k.scrollTop + k.clientHeight / 2
3020
3471
  });
3021
3472
  }, []);
3022
- return be(() => {
3023
- const m = G.current, y = V.current, T = ut.current;
3024
- if (!m || !y || T === L) return;
3025
- const D = L / T;
3026
- m.getBoundingClientRect();
3027
- const Q = y.cx - m.scrollLeft, U = y.cy - m.scrollTop;
3028
- m.scrollLeft = y.cx * D - Q, m.scrollTop = y.cy * D - U, V.current = null, ut.current = L;
3029
- }, [L]), j(() => {
3030
- const m = (y) => {
3031
- (y.metaKey || y.ctrlKey) && (y.key === "=" || y.key === "+" ? (y.preventDefault(), at(), st((T) => Math.min(2, +(T + 0.1).toFixed(2)))) : y.key === "-" ? (y.preventDefault(), at(), st((T) => Math.max(0.25, +(T - 0.1).toFixed(2)))) : y.key === "0" && (y.preventDefault(), at(), st(1)));
3473
+ return Me(() => {
3474
+ const k = _.current, w = ut.current, L = D.current;
3475
+ if (!k || !w || L === G) return;
3476
+ const Z = G / L;
3477
+ k.getBoundingClientRect();
3478
+ const tt = w.cx - k.scrollLeft, K = w.cy - k.scrollTop;
3479
+ k.scrollLeft = w.cx * Z - tt, k.scrollTop = w.cy * Z - K, ut.current = null, D.current = G;
3480
+ }, [G]), W(() => {
3481
+ const k = (w) => {
3482
+ if (w.metaKey || w.ctrlKey) {
3483
+ if (w.key === "p" || w.key === "P") {
3484
+ w.preventDefault(), we(t, n);
3485
+ return;
3486
+ }
3487
+ w.key === "=" || w.key === "+" ? (w.preventDefault(), it(), st((L) => Math.min(2, +(L + 0.1).toFixed(2)))) : w.key === "-" ? (w.preventDefault(), it(), st((L) => Math.max(0.25, +(L - 0.1).toFixed(2)))) : w.key === "0" && (w.preventDefault(), it(), st(1));
3488
+ }
3032
3489
  };
3033
- return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
3034
- }, [at]), j(() => {
3035
- const m = G.current;
3036
- if (!m) return;
3037
- const y = (T) => {
3038
- if (T.ctrlKey || T.metaKey) {
3039
- T.preventDefault();
3040
- const D = T.deltaY > 0 ? -0.1 : 0.1;
3041
- pt(T), st((Q) => Math.min(2, Math.max(0.25, +(Q + D).toFixed(2))));
3490
+ return window.addEventListener("keydown", k), () => window.removeEventListener("keydown", k);
3491
+ }, [it, t, n]), W(() => {
3492
+ const k = _.current;
3493
+ if (!k) return;
3494
+ const w = (L) => {
3495
+ if (L.ctrlKey || L.metaKey) {
3496
+ L.preventDefault();
3497
+ const Z = L.deltaY > 0 ? -0.1 : 0.1;
3498
+ ht(L), st((tt) => Math.min(2, Math.max(0.25, +(tt + Z).toFixed(2))));
3042
3499
  }
3043
3500
  };
3044
- return m.addEventListener("wheel", y, { passive: !1 }), () => m.removeEventListener("wheel", y);
3045
- }, [pt]), /* @__PURE__ */ b("div", { className: "docs-container", children: [
3046
- l && /* @__PURE__ */ a(
3047
- br,
3501
+ return k.addEventListener("wheel", w, { passive: !1 }), () => k.removeEventListener("wheel", w);
3502
+ }, [ht]), /* @__PURE__ */ g("div", { className: "docs-container", children: [
3503
+ c && /* @__PURE__ */ s(
3504
+ Er,
3048
3505
  {
3049
- editor: v,
3050
- isRtl: q.dir === "rtl",
3051
- onToggleRtl: ot,
3506
+ editor: y,
3507
+ isRtl: P.dir === "rtl",
3508
+ onToggleRtl: V,
3052
3509
  content: t,
3510
+ onChange: e,
3053
3511
  theme: n,
3054
3512
  onThemeChange: r,
3055
3513
  onTrustAction: d,
3056
- locked: N
3514
+ trust: I,
3515
+ sealIntact: X,
3516
+ locked: C
3057
3517
  }
3058
3518
  ),
3059
- c && /* @__PURE__ */ a(wr, { trust: W, intact: rt }),
3060
- c && /* @__PURE__ */ a(Tr, { source: t }),
3061
- h.length > 0 && /* @__PURE__ */ b("div", { className: "docs-fidelity-warning", role: "status", children: [
3519
+ a && /* @__PURE__ */ s(Br, { trust: I, intact: X }),
3520
+ a && /* @__PURE__ */ s(Dr, { source: t }),
3521
+ h.length > 0 && /* @__PURE__ */ g("div", { className: "docs-fidelity-warning", role: "status", children: [
3062
3522
  "⚠ Some formatting (",
3063
3523
  h.join(", "),
3064
3524
  ") can’t be saved to",
3065
3525
  " ",
3066
- /* @__PURE__ */ a("code", { children: ".it" }),
3526
+ /* @__PURE__ */ s("code", { children: ".it" }),
3067
3527
  " and won’t appear when printed through the template — remove it or use the toolbar’s color/size/style controls instead."
3068
3528
  ] }),
3069
- /* @__PURE__ */ a(Sr, { geometry: w, zoom: L, scrollEl: G }),
3070
- /* @__PURE__ */ b("div", { className: "docs-canvas", ref: G, children: [
3071
- /* @__PURE__ */ a(
3072
- "div",
3529
+ /* @__PURE__ */ s(
3530
+ Rr,
3531
+ {
3532
+ geometry: v,
3533
+ zoom: G,
3534
+ scrollEl: _,
3535
+ onMargins: x,
3536
+ locked: C
3537
+ }
3538
+ ),
3539
+ /* @__PURE__ */ g("div", { className: "docs-canvas-row", children: [
3540
+ /* @__PURE__ */ s(
3541
+ Pr,
3073
3542
  {
3074
- className: "docs-page-scaler",
3075
- style: { width: w.width * L },
3076
- children: /* @__PURE__ */ a(
3077
- "div",
3078
- {
3079
- className: "docs-page-flow",
3080
- dir: q.dir,
3081
- style: {
3082
- transform: L !== 1 ? `scale(${L})` : void 0,
3083
- transformOrigin: "top left"
3084
- },
3085
- children: /* @__PURE__ */ b(
3086
- "div",
3087
- {
3088
- className: "docs-page docs-sheet",
3089
- ref: I,
3090
- style: {
3091
- width: w.width,
3092
- minHeight: w.autoHeight ? w.width : void 0,
3093
- "--page-mx-l": `${w.marginLeft}px`,
3094
- "--page-mx-r": `${w.marginRight}px`
3095
- },
3096
- children: [
3097
- /* @__PURE__ */ a(
3098
- "div",
3099
- {
3100
- className: "docs-sheet-header",
3101
- "data-it-spacer": "",
3102
- style: { height: w.autoHeight ? void 0 : w.marginTop },
3103
- children: /* @__PURE__ */ a("div", { className: "docs-pb-header", children: /* @__PURE__ */ a("span", { className: "docs-pb-text", children: w.autoHeight ? "" : ee(w.header, 1, M) }) })
3104
- }
3105
- ),
3106
- /* @__PURE__ */ a(ke, { editor: v })
3107
- ]
3108
- }
3109
- )
3110
- }
3111
- )
3543
+ geometry: v,
3544
+ zoom: G,
3545
+ scrollEl: _,
3546
+ onMargins: x,
3547
+ locked: C
3112
3548
  }
3113
3549
  ),
3114
- /* @__PURE__ */ b("div", { className: "docs-page-footer", children: [
3115
- M,
3116
- " ",
3117
- M === 1 ? "page" : "pages",
3118
- " ·",
3119
- " ",
3120
- O(),
3121
- " words",
3122
- L !== 1 && /* @__PURE__ */ b("span", { className: "zoom-indicator", children: [
3550
+ /* @__PURE__ */ g("div", { className: "docs-canvas", ref: _, children: [
3551
+ /* @__PURE__ */ s(
3552
+ "div",
3553
+ {
3554
+ className: "docs-page-scaler",
3555
+ style: { width: v.width * G },
3556
+ children: /* @__PURE__ */ s(
3557
+ "div",
3558
+ {
3559
+ className: "docs-page-flow",
3560
+ dir: P.dir,
3561
+ style: {
3562
+ transform: G !== 1 ? `scale(${G})` : void 0,
3563
+ transformOrigin: "top left"
3564
+ },
3565
+ children: /* @__PURE__ */ g(
3566
+ "div",
3567
+ {
3568
+ className: "docs-page docs-sheet",
3569
+ ref: H,
3570
+ style: {
3571
+ width: v.width,
3572
+ minHeight: v.autoHeight ? v.width : void 0,
3573
+ "--page-mx-l": `${v.marginLeft}px`,
3574
+ "--page-mx-r": `${v.marginRight}px`
3575
+ },
3576
+ children: [
3577
+ /* @__PURE__ */ s(
3578
+ "div",
3579
+ {
3580
+ className: "docs-sheet-header",
3581
+ "data-it-spacer": "",
3582
+ style: { height: v.autoHeight ? void 0 : v.marginTop },
3583
+ children: /* @__PURE__ */ s("div", { className: "docs-pb-header", children: /* @__PURE__ */ s("span", { className: "docs-pb-text", children: v.autoHeight ? "" : ge(v.header, 1, S) }) })
3584
+ }
3585
+ ),
3586
+ /* @__PURE__ */ s(ze, { editor: y })
3587
+ ]
3588
+ }
3589
+ )
3590
+ }
3591
+ )
3592
+ }
3593
+ ),
3594
+ /* @__PURE__ */ g("div", { className: "docs-page-footer", children: [
3595
+ S,
3123
3596
  " ",
3124
- "· ",
3125
- Math.round(L * 100),
3126
- "%"
3597
+ S === 1 ? "page" : "pages",
3598
+ " ·",
3599
+ " ",
3600
+ B(),
3601
+ " words",
3602
+ G !== 1 && /* @__PURE__ */ g("span", { className: "zoom-indicator", children: [
3603
+ " ",
3604
+ "· ",
3605
+ Math.round(G * 100),
3606
+ "%"
3607
+ ] })
3127
3608
  ] })
3128
3609
  ] })
3129
3610
  ] })
3130
3611
  ] });
3131
3612
  }
3132
- const Nr = "corporate";
3133
- function Vr({
3613
+ const Yr = "corporate";
3614
+ function ho({
3134
3615
  value: t,
3135
3616
  onChange: e,
3136
3617
  theme: n,
3137
3618
  onThemeChange: r,
3138
3619
  readOnly: o = !1,
3139
- showRibbon: l = !0,
3140
- showTrustBanner: c = !0,
3620
+ showRibbon: c = !0,
3621
+ showTrustBanner: a = !0,
3141
3622
  onTrustAction: d
3142
3623
  }) {
3143
- const [s, f] = P(n ?? Nr), p = n ?? s, h = R(
3144
- (g) => {
3145
- f(g), r?.(g);
3624
+ const [i, m] = z(n ?? Yr), u = n ?? i, h = M(
3625
+ (f) => {
3626
+ m(f), r?.(f);
3146
3627
  },
3147
3628
  [r]
3148
3629
  );
3149
- return /* @__PURE__ */ a(
3150
- Cr,
3630
+ return /* @__PURE__ */ s(
3631
+ Gr,
3151
3632
  {
3152
3633
  value: t,
3153
3634
  onChange: e,
3154
- theme: p,
3635
+ theme: u,
3155
3636
  onThemeChange: h,
3156
3637
  readOnly: o,
3157
- showRibbon: l,
3158
- showTrustBanner: c,
3638
+ showRibbon: c,
3639
+ showTrustBanner: a,
3159
3640
  onTrustAction: d
3160
3641
  }
3161
3642
  );
3162
3643
  }
3163
3644
  export {
3164
- Vr as IntentTextEditor,
3165
- Jr as buildSampleSkeleton,
3166
- lr as builtinThemes,
3167
- zn as docToSource,
3168
- cr as exportDocumentHTML,
3169
- ar as exportDocumentPDF,
3170
- qr as extractTemplateVariables,
3171
- Vt as extractTrustState,
3172
- Mt as getPageGeometry,
3173
- rr as printHtmlViaIframe,
3174
- ee as resolvePageTokens,
3175
- Ut as sourceToDoc
3645
+ ho as IntentTextEditor,
3646
+ go as buildSampleSkeleton,
3647
+ Tr as builtinThemes,
3648
+ Kn as docToSource,
3649
+ wr as downloadItFile,
3650
+ po as exportDocumentHTML,
3651
+ we as exportDocumentPDF,
3652
+ fo as extractTemplateVariables,
3653
+ ce as extractTrustState,
3654
+ Pt as getPageGeometry,
3655
+ vr as printHtmlViaIframe,
3656
+ ge as resolvePageTokens,
3657
+ ee as sourceToDoc
3176
3658
  };
3177
3659
  //# sourceMappingURL=index.mjs.map