@dotit/editor 1.2.0 → 1.2.1

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