patent-editor 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/lib.js +908 -902
  2. package/dist/lib.js.map +1 -1
  3. package/package.json +126 -126
package/dist/lib.js CHANGED
@@ -2,7 +2,7 @@ var Sn = Object.defineProperty;
2
2
  var En = (e, t, n) => t in e ? Sn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Se = (e, t, n) => En(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as g, jsxs as L, Fragment as je } from "react/jsx-runtime";
5
- import Ee, { forwardRef as It, useState as $, useEffect as M, useCallback as ae, useImperativeHandle as Nt, useRef as W, useMemo as At } from "react";
5
+ import Ee, { forwardRef as It, useState as F, useEffect as M, useCallback as ae, useImperativeHandle as Nt, useRef as W, useMemo as At } from "react";
6
6
  import { Extension as Oe, ReactRenderer as kn, Node as Z, mergeAttributes as ie, NodeViewWrapper as _n, ReactNodeViewRenderer as Lt, EditorContent as In, useEditor as Nn } from "@tiptap/react";
7
7
  import An from "@tiptap/extension-document";
8
8
  import Ln from "@tiptap/extension-paragraph";
@@ -16,8 +16,8 @@ import zn from "@tiptap/extension-code-block";
16
16
  import On from "@tiptap/extension-horizontal-rule";
17
17
  import Bn from "@tiptap/extension-task-list";
18
18
  import Hn from "@tiptap/extension-task-item";
19
- import qn from "@tiptap/extension-image";
20
- import { Table as Un } from "@tiptap/extension-table";
19
+ import Un from "@tiptap/extension-image";
20
+ import { Table as qn } from "@tiptap/extension-table";
21
21
  import Wn from "@tiptap/extension-table-row";
22
22
  import jn from "@tiptap/extension-table-cell";
23
23
  import Gn from "@tiptap/extension-table-header";
@@ -49,10 +49,10 @@ import "mathlive";
49
49
  import { findWrapping as fr } from "@tiptap/pm/transform";
50
50
  import { Slice as pr, Fragment as hr } from "@tiptap/pm/model";
51
51
  import { createPortal as yr } from "react-dom";
52
- import { Undo2 as br, Redo2 as vr, Bold as Dt, Italic as Rt, Underline as Mt, Strikethrough as Ft, Code as $t, Superscript as zt, Subscript as Ot, Pilcrow as wr, Heading1 as xr, Heading2 as Cr, Heading3 as Tr, AlignLeft as Sr, AlignCenter as Er, AlignRight as kr, AlignJustify as _r, List as Ir, ListOrdered as Nr, Quote as Ar, FileCode2 as Lr, Table as Pr, Minus as Dr, CheckSquare as Rr, Image as Bt, Link2 as Ht, FileText as qt, Box as Mr, Workflow as Fr, FunctionSquare as $r, Sigma as zr, GitGraph as Or, Square as mt, ChevronDown as Ut, Highlighter as Br, Sparkles as Hr, CaseSensitive as qr, ChevronUp as Ur, Replace as gt, X as Wr, ReplaceAll as jr, PanelLeft as Gr, PanelLeftClose as Vr } from "lucide-react";
52
+ import { Undo2 as br, Redo2 as vr, Bold as Dt, Italic as Rt, Underline as Mt, Strikethrough as Ft, Code as $t, Superscript as zt, Subscript as Ot, Pilcrow as wr, Heading1 as xr, Heading2 as Cr, Heading3 as Tr, AlignLeft as Sr, AlignCenter as Er, AlignRight as kr, AlignJustify as _r, List as Ir, ListOrdered as Nr, Quote as Ar, FileCode2 as Lr, Table as Pr, Minus as Dr, CheckSquare as Rr, Image as Bt, Link2 as Ht, FileText as Ut, Box as Mr, Workflow as Fr, FunctionSquare as $r, Sigma as zr, GitGraph as Or, Square as mt, ChevronDown as qt, Highlighter as Br, Sparkles as Hr, CaseSensitive as Ur, ChevronUp as qr, Replace as gt, X as Wr, ReplaceAll as jr, PanelLeft as Gr, PanelLeftClose as Vr } from "lucide-react";
53
53
  import Y from "clsx";
54
54
  import { BubbleMenu as Jr } from "@tiptap/react/menus";
55
- import { convertMillimetersToTwip as he, Document as Kr, Packer as Xr, Paragraph as He, AlignmentType as it, TextRun as qe } from "docx";
55
+ import { convertMillimetersToTwip as he, Document as Kr, Packer as Xr, Paragraph as He, AlignmentType as it, TextRun as Ue } from "docx";
56
56
  import { saveAs as Yr } from "file-saver";
57
57
  const Zr = new we("slashCommand"), Qr = Oe.create({
58
58
  name: "slashCommand",
@@ -83,7 +83,7 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
83
83
  regenerate: !1,
84
84
  chatReferences: [],
85
85
  pendingChatMessage: null
86
- }, I = tr((e) => ({
86
+ }, N = tr((e) => ({
87
87
  editor: null,
88
88
  document: null,
89
89
  selection: null,
@@ -164,34 +164,34 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
164
164
  }))
165
165
  })), Wt = It(
166
166
  ({ items: e, command: t }, n) => {
167
- const [r, a] = $(0);
167
+ const [r, a] = F(0);
168
168
  M(() => {
169
169
  a(0);
170
170
  }, [e]);
171
171
  const i = ae(
172
- (o) => {
173
- const c = e[o];
174
- c && t(c);
172
+ (s) => {
173
+ const o = e[s];
174
+ o && t(o);
175
175
  },
176
176
  [e, t]
177
177
  );
178
178
  return Nt(n, () => ({
179
- onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : o.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : o.key === "Enter" ? (i(r), !0) : !1
180
- })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((o, c) => /* @__PURE__ */ L(
179
+ onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (a((o) => (o + e.length - 1) % e.length), !0) : s.key === "ArrowDown" ? (a((o) => (o + 1) % e.length), !0) : s.key === "Enter" ? (i(r), !0) : !1
180
+ })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ L(
181
181
  "button",
182
182
  {
183
- className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
184
- onClick: () => i(c),
185
- onMouseEnter: () => a(c),
183
+ className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
184
+ onClick: () => i(o),
185
+ onMouseEnter: () => a(o),
186
186
  children: [
187
- /* @__PURE__ */ g("span", { className: "slash-menu-icon", children: o.icon }),
187
+ /* @__PURE__ */ g("span", { className: "slash-menu-icon", children: s.icon }),
188
188
  /* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
189
- /* @__PURE__ */ g("span", { className: "slash-menu-title", children: o.title }),
190
- /* @__PURE__ */ g("span", { className: "slash-menu-desc", children: o.description })
189
+ /* @__PURE__ */ g("span", { className: "slash-menu-title", children: s.title }),
190
+ /* @__PURE__ */ g("span", { className: "slash-menu-desc", children: s.description })
191
191
  ] })
192
192
  ]
193
193
  },
194
- o.title
194
+ s.title
195
195
  )) }) : /* @__PURE__ */ g("div", { className: "slash-menu", children: /* @__PURE__ */ g("div", { className: "slash-menu-empty", children: "No results" }) });
196
196
  }
197
197
  );
@@ -302,7 +302,7 @@ function na() {
302
302
  return {
303
303
  char: "/",
304
304
  items: ({ query: e }) => {
305
- const t = I.getState().editorLanguage, n = ta(t);
305
+ const t = N.getState().editorLanguage, n = ta(t);
306
306
  if (!e) return n;
307
307
  const r = e.toLowerCase();
308
308
  return n.filter(
@@ -347,25 +347,25 @@ const ra = new we("searchReplace");
347
347
  function ke(e, t, n) {
348
348
  if (!t) return [];
349
349
  const r = [], a = e.textBetween(0, e.content.size, `
350
- `, "\0"), i = n ? t : t.toLowerCase(), o = n ? a : a.toLowerCase();
351
- let c = 0;
352
- for (; c < o.length; ) {
353
- const s = o.indexOf(i, c);
354
- if (s === -1) break;
355
- let l = 0, d = -1, m = -1;
356
- e.descendants((u, f) => {
357
- if (d !== -1 && m !== -1) return !1;
358
- if (u.isText) {
359
- const p = u.text || "";
360
- for (let y = 0; y < p.length; y++) {
361
- if (l === s && (d = f + y), l === s + i.length)
362
- return m = f + y, !1;
350
+ `, "\0"), i = n ? t : t.toLowerCase(), s = n ? a : a.toLowerCase();
351
+ let o = 0;
352
+ for (; o < s.length; ) {
353
+ const c = s.indexOf(i, o);
354
+ if (c === -1) break;
355
+ let l = 0, d = -1, u = -1;
356
+ e.descendants((m, f) => {
357
+ if (d !== -1 && u !== -1) return !1;
358
+ if (m.isText) {
359
+ const p = m.text || "";
360
+ for (let h = 0; h < p.length; h++) {
361
+ if (l === c && (d = f + h), l === c + i.length)
362
+ return u = f + h, !1;
363
363
  l++;
364
364
  }
365
- l === s + i.length && m === -1 && (m = f + p.length);
366
- } else u.isBlock && l > 0 && (l === s && (d = f), l++);
365
+ l === c + i.length && u === -1 && (u = f + p.length);
366
+ } else m.isBlock && l > 0 && (l === c && (d = f), l++);
367
367
  return !0;
368
- }), d !== -1 && m !== -1 && r.push({ from: d, to: m }), c = s + 1;
368
+ }), d !== -1 && u !== -1 && r.push({ from: d, to: u }), o = c + 1;
369
369
  }
370
370
  return r;
371
371
  }
@@ -407,10 +407,10 @@ const aa = Oe.create({
407
407
  const { searchTerm: t, replaceTerm: n, caseSensitive: r } = this.storage;
408
408
  let a = ke(e.state.doc, t, r);
409
409
  const i = e.state.tr;
410
- let o = 0;
411
- for (const c of a) {
412
- const s = c.from + o, l = c.to + o;
413
- i.insertText(n, s, l), o += n.length - (c.to - c.from);
410
+ let s = 0;
411
+ for (const o of a) {
412
+ const c = o.from + s, l = o.to + s;
413
+ i.insertText(n, c, l), s += n.length - (o.to - o.from);
414
414
  }
415
415
  return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
416
416
  },
@@ -471,11 +471,11 @@ function ca(e, t) {
471
471
  function Gt(e, t, n) {
472
472
  const r = [];
473
473
  let a = "", i = !0;
474
- return e.state.doc.nodesBetween(t, n, (o, c) => {
475
- if (o.isText) {
476
- const s = c, l = Math.max(t, s) - s, d = Math.min(n, s + o.nodeSize) - s, m = o.text.slice(l, d);
477
- r.push({ textIdx: a.length, docPos: s + l, len: m.length }), a += m, i = !1;
478
- } else o.isLeaf ? (a += "\0", i = !1) : !i && o.isBlock && (a += "\0", i = !0);
474
+ return e.state.doc.nodesBetween(t, n, (s, o) => {
475
+ if (s.isText) {
476
+ const c = o, l = Math.max(t, c) - c, d = Math.min(n, c + s.nodeSize) - c, u = s.text.slice(l, d);
477
+ r.push({ textIdx: a.length, docPos: c + l, len: u.length }), a += u, i = !1;
478
+ } else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
479
479
  }), { text: a, segments: r };
480
480
  }
481
481
  function ye(e, t) {
@@ -492,45 +492,45 @@ function ye(e, t) {
492
492
  return -1;
493
493
  }
494
494
  function ht(e, t, n, r, a) {
495
- const { text: i, segments: o } = Gt(e, n, r);
496
- let c = 0;
497
- for (; c <= i.length - t.length; ) {
498
- const s = i.indexOf(t, c);
499
- if (s === -1) return null;
500
- const l = ye(o, s), d = ye(o, s + t.length);
495
+ const { text: i, segments: s } = Gt(e, n, r);
496
+ let o = 0;
497
+ for (; o <= i.length - t.length; ) {
498
+ const c = i.indexOf(t, o);
499
+ if (c === -1) return null;
500
+ const l = ye(s, c), d = ye(s, c + t.length);
501
501
  if (l >= 0 && d >= 0 && !(a && a.has(l)))
502
502
  return { from: l, to: d };
503
- c = s + 1;
503
+ o = c + 1;
504
504
  }
505
505
  return null;
506
506
  }
507
507
  function Ds(e, t, n, r, a) {
508
508
  const i = t.target;
509
- let o = null;
510
- const c = /* @__PURE__ */ new Set();
509
+ let s = null;
510
+ const o = /* @__PURE__ */ new Set();
511
511
  if (a)
512
512
  for (const d of a)
513
- c.add(d.from);
513
+ o.add(d.from);
514
514
  if (!i)
515
- t.from != null && t.to != null && (o = { from: t.from, to: t.to });
515
+ t.from != null && t.to != null && (s = { from: t.from, to: t.to });
516
516
  else if (i.type === "section" && i.sectionType)
517
- o = ca(e, i.sectionType);
517
+ s = ca(e, i.sectionType);
518
518
  else if (i.type === "ref" && i.refIndex != null) {
519
519
  const d = n[i.refIndex];
520
- (d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (o = { from: d.from, to: d.to });
521
- } else i.type === "search" && i.searchText && (o = ht(e, i.searchText, 0, e.state.doc.content.size, c));
522
- if (!o) return null;
523
- let s = o;
520
+ (d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (s = { from: d.from, to: d.to });
521
+ } else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
522
+ if (!s) return null;
523
+ let c = s;
524
524
  if (t.search) {
525
- const d = ht(e, t.search, o.from, o.to, c);
526
- d && (s = d);
525
+ const d = ht(e, t.search, s.from, s.to, o);
526
+ d && (c = d);
527
527
  }
528
- const l = s.from < s.to ? e.state.doc.textBetween(s.from, s.to, " ", "\0") : "";
528
+ const l = c.from < c.to ? e.state.doc.textBetween(c.from, c.to, " ", "\0") : "";
529
529
  return {
530
530
  id: `patch_${Date.now()}_${r}`,
531
531
  type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
532
- from: s.from,
533
- to: t.op === "insert" ? s.from : s.to,
532
+ from: c.from,
533
+ to: t.op === "insert" ? c.from : c.to,
534
534
  content: t.content || "",
535
535
  originalText: l,
536
536
  reason: t.reason,
@@ -557,7 +557,7 @@ function $s(e = "default") {
557
557
  j.delete(e), ue();
558
558
  }
559
559
  function zs(e, t, n = "default") {
560
- const r = j.get(n) || [], a = r.find((c) => c.id === t);
560
+ const r = j.get(n) || [], a = r.find((o) => o.id === t);
561
561
  if (!a || a.status !== "pending") return !1;
562
562
  a.status = "accepted";
563
563
  const { tr: i } = e.state;
@@ -566,49 +566,49 @@ function zs(e, t, n = "default") {
566
566
  else if (a.type === "insert")
567
567
  i.insertText(a.content, a.from);
568
568
  else if (Vt(e, a.from, a.to)) {
569
- const s = Jt(e, a.content);
570
- i.replaceWith(a.from, a.to, s);
569
+ const c = Jt(e, a.content);
570
+ i.replaceWith(a.from, a.to, c);
571
571
  } else
572
572
  i.insertText(a.content, a.from, a.to);
573
573
  e.view.dispatch(i);
574
- const o = i.mapping;
575
- for (const c of r) {
576
- if (c.id === t || c.status !== "pending") continue;
577
- const s = o.map(c.from, 1), l = o.map(c.to, -1);
578
- s >= l && c.type !== "insert" ? c.status = "rejected" : (c.from = s, c.to = c.type === "insert" ? s : l);
574
+ const s = i.mapping;
575
+ for (const o of r) {
576
+ if (o.id === t || o.status !== "pending") continue;
577
+ const c = s.map(o.from, 1), l = s.map(o.to, -1);
578
+ c >= l && o.type !== "insert" ? o.status = "rejected" : (o.from = c, o.to = o.type === "insert" ? c : l);
579
579
  }
580
- return j.set(n, r.filter((c) => c.id !== t && c.status === "pending")), Ue(e), ue(), !0;
580
+ return j.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), ue(), !0;
581
581
  }
582
582
  function Os(e, t, n = "default") {
583
583
  const r = j.get(n) || [], a = r.find((i) => i.id === t);
584
- return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), Ue(e), ue(), !0);
584
+ return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), qe(e), ue(), !0);
585
585
  }
586
586
  function Bs(e, t = "default") {
587
- const a = [...(j.get(t) || []).filter((o) => o.status === "pending")].sort((o, c) => c.from - o.from), { tr: i } = e.state;
588
- for (const o of a)
589
- if (o.type === "delete")
590
- i.delete(o.from, o.to);
591
- else if (o.type === "insert")
592
- i.insertText(o.content, o.from);
593
- else if (Vt(e, o.from, o.to)) {
594
- const s = Jt(e, o.content);
595
- i.replaceWith(o.from, o.to, s);
587
+ const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
588
+ for (const s of a)
589
+ if (s.type === "delete")
590
+ i.delete(s.from, s.to);
591
+ else if (s.type === "insert")
592
+ i.insertText(s.content, s.from);
593
+ else if (Vt(e, s.from, s.to)) {
594
+ const c = Jt(e, s.content);
595
+ i.replaceWith(s.from, s.to, c);
596
596
  } else
597
- i.insertText(o.content, o.from, o.to);
598
- e.view.dispatch(i), j.delete(t), Ue(e), ue();
597
+ i.insertText(s.content, s.from, s.to);
598
+ e.view.dispatch(i), j.delete(t), qe(e), ue();
599
599
  }
600
600
  function Hs(e, t = "default") {
601
- j.delete(t), Ue(e), ue();
601
+ j.delete(t), qe(e), ue();
602
602
  }
603
- function Ue(e) {
603
+ function qe(e) {
604
604
  e.view.dispatch(e.state.tr.setMeta(jt, !0));
605
605
  }
606
606
  function la(e, t, n) {
607
607
  const r = [];
608
608
  return e.nodesBetween(t, n, (a, i) => {
609
609
  if (a.isTextblock) {
610
- const o = i + 1, c = i + a.nodeSize - 1, s = Math.max(o, t), l = Math.min(c, n);
611
- return l > s && r.push({ from: s, to: l }), !1;
610
+ const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
611
+ return l > c && r.push({ from: c, to: l }), !1;
612
612
  }
613
613
  return !0;
614
614
  }), r;
@@ -616,32 +616,32 @@ function la(e, t, n) {
616
616
  function da(e, t) {
617
617
  if (!t.originalText || !t.content) return null;
618
618
  try {
619
- const c = e.resolve(t.from), s = e.resolve(t.to);
620
- if (c.parent !== s.parent || !c.parent.isTextblock) return null;
619
+ const o = e.resolve(t.from), c = e.resolve(t.to);
620
+ if (o.parent !== c.parent || !o.parent.isTextblock) return null;
621
621
  } catch {
622
622
  return null;
623
623
  }
624
624
  const n = oa(), r = n.diff_main(t.originalText, t.content);
625
625
  n.diff_cleanupSemantic(r);
626
- const a = r.filter(([c]) => c === pt).reduce((c, [, s]) => c + s.length, 0);
626
+ const a = r.filter(([o]) => o === pt).reduce((o, [, c]) => o + c.length, 0);
627
627
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
628
628
  const i = [];
629
- let o = t.from;
630
- for (const [c, s] of r)
631
- if (c === pt)
632
- o += s.length;
633
- else if (c === ia) {
634
- const l = o + s.length;
629
+ let s = t.from;
630
+ for (const [o, c] of r)
631
+ if (o === pt)
632
+ s += c.length;
633
+ else if (o === ia) {
634
+ const l = s + c.length;
635
635
  i.push(
636
- re.inline(o, l, {
636
+ re.inline(s, l, {
637
637
  class: "patch-diff-delete",
638
638
  "data-patch-id": t.id
639
639
  })
640
- ), o = l;
641
- } else c === sa && i.push(
642
- re.widget(o, () => {
640
+ ), s = l;
641
+ } else o === sa && i.push(
642
+ re.widget(s, () => {
643
643
  const l = document.createElement("span");
644
- return l.className = "patch-diff-insert-inline", l.textContent = s, l.setAttribute("data-patch-id", t.id), l;
644
+ return l.className = "patch-diff-insert-inline", l.textContent = c, l.setAttribute("data-patch-id", t.id), l;
645
645
  }, { side: 1 })
646
646
  );
647
647
  return i;
@@ -664,20 +664,20 @@ function ua(e = "default") {
664
664
  }
665
665
  if (a.type === "delete" || a.type === "replace") {
666
666
  const i = la(t.doc, a.from, a.to);
667
- for (const o of i)
667
+ for (const s of i)
668
668
  r.push(
669
- re.inline(o.from, o.to, {
669
+ re.inline(s.from, s.to, {
670
670
  class: "patch-diff-delete",
671
671
  "data-patch-id": a.id
672
672
  })
673
673
  );
674
674
  if (a.type === "replace") {
675
- const o = i.length > 0 ? i[i.length - 1].to : a.to, c = a.content.length > 120 || a.content.includes(`
675
+ const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
676
676
  `);
677
677
  r.push(
678
- re.widget(o, () => {
679
- const s = document.createElement(c ? "div" : "span");
680
- return s.className = c ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", s.textContent = a.content, s.setAttribute("data-patch-id", a.id), s;
678
+ re.widget(s, () => {
679
+ const c = document.createElement(o ? "div" : "span");
680
+ return c.className = o ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", c.textContent = a.content, c.setAttribute("data-patch-id", a.id), c;
681
681
  }, { side: 1 })
682
682
  );
683
683
  }
@@ -766,7 +766,7 @@ const ma = Z.create({
766
766
  On,
767
767
  Bn,
768
768
  Hn.configure({ nested: !0 }),
769
- qn.extend({
769
+ Un.extend({
770
770
  addAttributes() {
771
771
  var e;
772
772
  return {
@@ -782,7 +782,7 @@ const ma = Z.create({
782
782
  inline: !0,
783
783
  allowBase64: !0
784
784
  }),
785
- Un.configure({
785
+ qn.configure({
786
786
  resizable: !0
787
787
  }),
788
788
  Wn,
@@ -843,8 +843,8 @@ class ba {
843
843
  return !r || !r.isActive ? !1 : r.isActive(n);
844
844
  }
845
845
  async execute(t, n, r, a = {}) {
846
- var d, m, u, f;
847
- const i = Date.now(), o = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, s = o ? n.editor.getJSON() : null, l = this.commands.get(t);
846
+ var d, u, m, f;
847
+ const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, c = s ? n.editor.getJSON() : null, l = this.commands.get(t);
848
848
  if (!l)
849
849
  return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
850
850
  name: t,
@@ -852,29 +852,29 @@ class ba {
852
852
  durationMs: Date.now() - i
853
853
  }), !1;
854
854
  if (!this.canExecute(t, n, r))
855
- return (m = a.onComplete) == null || m.call(a, {
855
+ return (u = a.onComplete) == null || u.call(a, {
856
856
  name: t,
857
857
  success: !1,
858
858
  durationMs: Date.now() - i
859
859
  }), !1;
860
860
  try {
861
- const y = !!await l.execute(n, r);
862
- !y && s && c && n.editor.commands.setContent(s);
863
- const b = {
861
+ const h = !!await l.execute(n, r);
862
+ !h && c && o && n.editor.commands.setContent(c);
863
+ const y = {
864
864
  name: t,
865
- success: y,
865
+ success: h,
866
866
  durationMs: Date.now() - i
867
867
  };
868
- return (u = a.onComplete) == null || u.call(a, b), y;
868
+ return (m = a.onComplete) == null || m.call(a, y), h;
869
869
  } catch (p) {
870
- s && c && n.editor.commands.setContent(s);
871
- const y = {
870
+ c && o && n.editor.commands.setContent(c);
871
+ const h = {
872
872
  name: t,
873
873
  success: !1,
874
874
  durationMs: Date.now() - i,
875
875
  error: p
876
876
  };
877
- return (f = a.onComplete) == null || f.call(a, y), !1;
877
+ return (f = a.onComplete) == null || f.call(a, h), !1;
878
878
  }
879
879
  }
880
880
  getCommand(t) {
@@ -1243,96 +1243,96 @@ const Ie = () => {
1243
1243
  let r = t, a = !1;
1244
1244
  const i = document.createElement("div");
1245
1245
  i.classList.add("mermaid-node");
1246
+ const s = document.createElement("div");
1247
+ s.className = "mermaid-view", s.contentEditable = "false";
1246
1248
  const o = document.createElement("div");
1247
- o.className = "mermaid-view", o.contentEditable = "false";
1249
+ o.className = "mermaid-preview", o.contentEditable = "false";
1248
1250
  const c = document.createElement("div");
1249
- c.className = "mermaid-preview", c.contentEditable = "false";
1250
- const s = document.createElement("div");
1251
- s.className = "mermaid-view-hint", o.append(c, s);
1251
+ c.className = "mermaid-view-hint", s.append(o, c);
1252
1252
  const l = document.createElement("div");
1253
1253
  l.className = "mermaid-edit";
1254
1254
  const d = document.createElement("textarea");
1255
1255
  d.className = "mermaid-editor-textarea", d.spellcheck = !1;
1256
- const m = document.createElement("div");
1257
- m.className = "mermaid-edit-toolbar";
1258
- const u = document.createElement("span");
1259
- u.className = "mermaid-error-msg";
1256
+ const u = document.createElement("div");
1257
+ u.className = "mermaid-edit-toolbar";
1258
+ const m = document.createElement("span");
1259
+ m.className = "mermaid-error-msg";
1260
1260
  const f = document.createElement("button");
1261
1261
  f.className = "mermaid-cancel-btn", f.type = "button";
1262
1262
  const p = document.createElement("button");
1263
- p.className = "mermaid-save-btn", p.type = "button", m.append(u, f, p), l.append(d, m), i.append(o, l);
1264
- const y = (T) => {
1265
- const N = typeof n == "function" ? n() : null;
1266
- typeof N == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(N, void 0, { ...r.attrs, ...T }), D && D(A), !0));
1263
+ p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), l.append(d, u), i.append(s, l);
1264
+ const h = (C) => {
1265
+ const I = typeof n == "function" ? n() : null;
1266
+ typeof I == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(I, void 0, { ...r.attrs, ...C }), D && D(A), !0));
1267
1267
  };
1268
- let b = "";
1269
- const w = async (T) => {
1270
- const N = T.trim();
1271
- if (N !== b) {
1272
- if (!N) {
1273
- c.innerHTML = "", b = "";
1268
+ let y = "";
1269
+ const w = async (C) => {
1270
+ const I = C.trim();
1271
+ if (I !== y) {
1272
+ if (!I) {
1273
+ o.innerHTML = "", y = "";
1274
1274
  return;
1275
1275
  }
1276
1276
  try {
1277
1277
  const A = await import("mermaid");
1278
1278
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1279
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, N);
1280
- c.innerHTML = z, b = N;
1279
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
1280
+ o.innerHTML = z, y = I;
1281
1281
  } catch {
1282
- c.innerHTML = "", b = "";
1282
+ o.innerHTML = "", y = "";
1283
1283
  } finally {
1284
1284
  Ie();
1285
1285
  }
1286
1286
  }
1287
1287
  }, x = () => {
1288
- a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", u.textContent = "", u.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
1289
- }, C = () => {
1288
+ a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
1289
+ }, T = () => {
1290
1290
  a = !1, E();
1291
1291
  }, v = async () => {
1292
- const T = d.value;
1293
- u.textContent = "", u.style.display = "none";
1294
- const N = T.trim();
1295
- if (N)
1292
+ const C = d.value;
1293
+ m.textContent = "", m.style.display = "none";
1294
+ const I = C.trim();
1295
+ if (I)
1296
1296
  try {
1297
1297
  const A = await import("mermaid");
1298
1298
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1299
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, N);
1300
- c.innerHTML = z, b = N, Ie();
1299
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
1300
+ o.innerHTML = z, y = I, Ie();
1301
1301
  } catch {
1302
1302
  Ie();
1303
- const A = I.getState().editorLanguage;
1304
- u.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", u.style.display = "inline";
1303
+ const A = N.getState().editorLanguage;
1304
+ m.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
1305
1305
  return;
1306
1306
  }
1307
- y({ code: T }), a = !1, E();
1307
+ h({ code: C }), a = !1, E();
1308
1308
  };
1309
- o.addEventListener("dblclick", (T) => {
1310
- T.preventDefault(), T.stopPropagation(), x();
1311
- }), p.addEventListener("click", (T) => {
1312
- T.stopPropagation(), v();
1313
- }), f.addEventListener("click", (T) => {
1314
- T.stopPropagation(), C();
1315
- }), d.addEventListener("mousedown", (T) => T.stopPropagation()), d.addEventListener("keydown", (T) => T.stopPropagation()), d.addEventListener("keypress", (T) => T.stopPropagation());
1309
+ s.addEventListener("dblclick", (C) => {
1310
+ C.preventDefault(), C.stopPropagation(), x();
1311
+ }), p.addEventListener("click", (C) => {
1312
+ C.stopPropagation(), v();
1313
+ }), f.addEventListener("click", (C) => {
1314
+ C.stopPropagation(), T();
1315
+ }), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
1316
1316
  const E = () => {
1317
- const T = I.getState().editorLanguage, N = H(T), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
- o.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = N.mermaidSaveAndRender || "保存并渲染", f.textContent = N.mermaidCancel || "取消";
1319
- const D = A.trim().length > 0, z = c.querySelector("svg") !== null;
1320
- a || (D && z ? (s.textContent = N.mermaidDoubleClickToEdit || "双击编辑", s.className = "mermaid-view-hint mermaid-view-hint--subtle") : (s.textContent = N.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", s.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== b && w(A);
1317
+ const C = N.getState().editorLanguage, I = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
+ s.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = I.mermaidSaveAndRender || "保存并渲染", f.textContent = I.mermaidCancel || "取消";
1319
+ const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
1320
+ a || (D && z ? (c.textContent = I.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = I.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && w(A);
1321
1321
  };
1322
- let h = I.getState().editorLanguage;
1323
- const _ = I.subscribe((T) => {
1324
- T.editorLanguage !== h && (h = T.editorLanguage, E());
1322
+ let _ = N.getState().editorLanguage;
1323
+ const b = N.subscribe((C) => {
1324
+ C.editorLanguage !== _ && (_ = C.editorLanguage, E());
1325
1325
  });
1326
1326
  return E(), {
1327
1327
  dom: i,
1328
- stopEvent: (T) => {
1329
- const N = T.target;
1330
- return !!(N === d || l.contains(N));
1328
+ stopEvent: (C) => {
1329
+ const I = C.target;
1330
+ return !!(I === d || l.contains(I));
1331
1331
  },
1332
1332
  ignoreMutation: () => !0,
1333
- update: (T) => T.type.name !== "mermaid" ? !1 : (r = T, E(), !0),
1333
+ update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, E(), !0),
1334
1334
  destroy: () => {
1335
- _(), Ie();
1335
+ b(), Ie();
1336
1336
  }
1337
1337
  };
1338
1338
  };
@@ -1386,49 +1386,49 @@ const Ie = () => {
1386
1386
  let r = t, a = !1;
1387
1387
  const i = document.createElement("div");
1388
1388
  i.classList.add("drawio-node");
1389
- const o = document.createElement("div");
1390
- o.className = "drawio-view", o.contentEditable = "false";
1391
- const c = document.createElement("img");
1392
- c.className = "drawio-preview-img", c.style.display = "none";
1393
1389
  const s = document.createElement("div");
1394
- s.className = "drawio-view-hint", o.append(c, s), i.append(o);
1390
+ s.className = "drawio-view", s.contentEditable = "false";
1391
+ const o = document.createElement("img");
1392
+ o.className = "drawio-preview-img", o.style.display = "none";
1393
+ const c = document.createElement("div");
1394
+ c.className = "drawio-view-hint", s.append(o, c), i.append(s);
1395
1395
  const l = (x) => {
1396
- const C = typeof n == "function" ? n() : null;
1397
- typeof C == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(C, void 0, { ...r.attrs, ...x }), E && E(v), !0));
1396
+ const T = typeof n == "function" ? n() : null;
1397
+ typeof T == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(T, void 0, { ...r.attrs, ...x }), E && E(v), !0));
1398
1398
  };
1399
- let d = null, m = null, u = null;
1399
+ let d = null, u = null, m = null;
1400
1400
  const f = () => {
1401
1401
  if (a) return;
1402
- a = !0, m = document.createElement("div"), m.className = "drawio-modal-overlay";
1402
+ a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1403
1403
  const x = document.createElement("div");
1404
1404
  x.className = "drawio-modal-content";
1405
- const C = document.createElement("div");
1406
- C.className = "drawio-modal-header";
1407
- const v = I.getState().editorLanguage, E = document.createElement("span");
1405
+ const T = document.createElement("div");
1406
+ T.className = "drawio-modal-header";
1407
+ const v = N.getState().editorLanguage, E = document.createElement("span");
1408
1408
  E.textContent = v === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", E.className = "drawio-modal-title";
1409
- const h = document.createElement("button");
1410
- h.className = "drawio-modal-close-btn", h.textContent = "✕", h.type = "button", h.addEventListener("click", () => p()), C.append(E, h), u = document.createElement("iframe"), u.className = "drawio-modal-iframe", u.setAttribute("frameborder", "0"), x.append(C, u), m.appendChild(x), document.body.appendChild(m);
1411
- const _ = v === "en" ? "en" : "zh";
1412
- u.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${_}`;
1413
- const T = u;
1414
- d = (N) => {
1409
+ const _ = document.createElement("button");
1410
+ _.className = "drawio-modal-close-btn", _.textContent = "✕", _.type = "button", _.addEventListener("click", () => p()), T.append(E, _), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), x.append(T, m), u.appendChild(x), document.body.appendChild(u);
1411
+ const b = v === "en" ? "en" : "zh";
1412
+ m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${b}`;
1413
+ const C = m;
1414
+ d = (I) => {
1415
1415
  var D, z;
1416
- if (!T || N.source !== T.contentWindow) return;
1416
+ if (!C || I.source !== C.contentWindow) return;
1417
1417
  let A;
1418
1418
  try {
1419
- A = typeof N.data == "string" ? JSON.parse(N.data) : N.data;
1419
+ A = typeof I.data == "string" ? JSON.parse(I.data) : I.data;
1420
1420
  } catch {
1421
1421
  return;
1422
1422
  }
1423
1423
  if (A.event === "init") {
1424
1424
  const Q = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
1425
- (D = T.contentWindow) == null || D.postMessage(
1425
+ (D = C.contentWindow) == null || D.postMessage(
1426
1426
  JSON.stringify({ action: "load", autosave: 0, xml: Q || "" }),
1427
1427
  Ve
1428
1428
  );
1429
1429
  } else if (A.event === "save") {
1430
1430
  const Q = A.xml || "";
1431
- (z = T.contentWindow) == null || z.postMessage(
1431
+ (z = C.contentWindow) == null || z.postMessage(
1432
1432
  JSON.stringify({ action: "export", format: "svg" }),
1433
1433
  Ve
1434
1434
  ), l({ xml: Q });
@@ -1438,25 +1438,25 @@ const Ie = () => {
1438
1438
  } else A.event === "exit" && p();
1439
1439
  }, window.addEventListener("message", d);
1440
1440
  }, p = () => {
1441
- a = !1, d && (window.removeEventListener("message", d), d = null), u && (u.src = "about:blank", u = null), m && (m.remove(), m = null), y();
1441
+ a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), h();
1442
1442
  };
1443
- o.addEventListener("dblclick", (x) => {
1443
+ s.addEventListener("dblclick", (x) => {
1444
1444
  x.preventDefault(), x.stopPropagation(), f();
1445
1445
  });
1446
- const y = () => {
1447
- const x = I.getState().editorLanguage, C = H(x), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
- v ? (c.src = v, c.style.display = "block") : (c.src = "", c.style.display = "none"), v ? (s.textContent = C.mermaidDoubleClickToEdit || "双击编辑", s.className = "drawio-view-hint drawio-view-hint--subtle") : (s.textContent = C.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", s.className = "drawio-view-hint drawio-view-hint--empty");
1446
+ const h = () => {
1447
+ const x = N.getState().editorLanguage, T = H(x), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
+ v ? (o.src = v, o.style.display = "block") : (o.src = "", o.style.display = "none"), v ? (c.textContent = T.mermaidDoubleClickToEdit || "双击编辑", c.className = "drawio-view-hint drawio-view-hint--subtle") : (c.textContent = T.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", c.className = "drawio-view-hint drawio-view-hint--empty");
1449
1449
  };
1450
- let b = I.getState().editorLanguage;
1451
- const w = I.subscribe((x) => {
1452
- x.editorLanguage !== b && (b = x.editorLanguage, y());
1450
+ let y = N.getState().editorLanguage;
1451
+ const w = N.subscribe((x) => {
1452
+ x.editorLanguage !== y && (y = x.editorLanguage, h());
1453
1453
  });
1454
- return y(), {
1454
+ return h(), {
1455
1455
  dom: i,
1456
1456
  ignoreMutation: () => !0,
1457
- update: (x) => x.type.name !== "drawio" ? !1 : (r = x, y(), !0),
1457
+ update: (x) => x.type.name !== "drawio" ? !1 : (r = x, h(), !0),
1458
1458
  destroy: () => {
1459
- w(), d && (window.removeEventListener("message", d), d = null), u && (u.src = "about:blank", u = null), m && (m.remove(), m = null);
1459
+ w(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1460
1460
  }
1461
1461
  };
1462
1462
  };
@@ -1495,56 +1495,56 @@ const Ie = () => {
1495
1495
  selected: n,
1496
1496
  editor: r
1497
1497
  }) => {
1498
- const a = W(null), [i, o] = $(!1), c = e.type.name === "math_block", s = W(!1), l = W(t), d = W(e.attrs.latex ?? "");
1498
+ const a = W(null), [i, s] = F(!1), o = e.type.name === "math_block", c = W(!1), l = W(t), d = W(e.attrs.latex ?? "");
1499
1499
  M(() => {
1500
1500
  l.current = t;
1501
1501
  }, [t]), M(() => {
1502
1502
  d.current = e.attrs.latex ?? "";
1503
1503
  }, [e.attrs.latex]);
1504
- const m = ae(() => {
1505
- s.current || (s.current = !0, o(!0));
1506
- }, []), u = ae(() => {
1507
- var y, b;
1508
- if (!s.current) return;
1509
- s.current = !1;
1510
- const p = ((y = a.current) == null ? void 0 : y.value) ?? d.current;
1511
- l.current({ latex: p }), o(!1), (b = globalThis.mathVirtualKeyboard) == null || b.hide({ animate: !0 });
1504
+ const u = ae(() => {
1505
+ c.current || (c.current = !0, s(!0));
1506
+ }, []), m = ae(() => {
1507
+ var h, y;
1508
+ if (!c.current) return;
1509
+ c.current = !1;
1510
+ const p = ((h = a.current) == null ? void 0 : h.value) ?? d.current;
1511
+ l.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1512
1512
  }, []);
1513
1513
  M(() => {
1514
- var y, b, w;
1515
- const p = !!((w = (b = (y = r == null ? void 0 : r.view) == null ? void 0 : y.state) == null ? void 0 : b.selection) != null && w.empty);
1516
- n && p && m();
1517
- }, [n, m]), M(() => {
1514
+ var h, y, w;
1515
+ const p = !!((w = (y = (h = r == null ? void 0 : r.view) == null ? void 0 : h.state) == null ? void 0 : y.selection) != null && w.empty);
1516
+ n && p && u();
1517
+ }, [n, u]), M(() => {
1518
1518
  i && requestAnimationFrame(() => {
1519
- var y;
1519
+ var h;
1520
1520
  const p = a.current;
1521
- p && (p.virtualKeyboardMode = "onfocus", (y = p.focus) == null || y.call(p));
1521
+ p && (p.virtualKeyboardMode = "onfocus", (h = p.focus) == null || h.call(p));
1522
1522
  });
1523
1523
  }, [i]), M(() => {
1524
1524
  if (!i) return;
1525
1525
  const p = a.current;
1526
1526
  if (!p) return;
1527
- const y = () => {
1527
+ const h = () => {
1528
1528
  setTimeout(() => {
1529
- var x, C, v;
1530
- if (!s.current) return;
1529
+ var x, T, v;
1530
+ if (!c.current) return;
1531
1531
  const w = document.activeElement;
1532
- (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (x = w == null ? void 0 : w.closest) != null && x.call(w, "math-field") || (C = w == null ? void 0 : w.closest) != null && C.call(w, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(w) || u();
1532
+ (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (x = w == null ? void 0 : w.closest) != null && x.call(w, "math-field") || (T = w == null ? void 0 : w.closest) != null && T.call(w, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(w) || m();
1533
1533
  }, 300);
1534
- }, b = (w) => {
1535
- w.key === "Escape" && u();
1534
+ }, y = (w) => {
1535
+ w.key === "Escape" && m();
1536
1536
  };
1537
- return p.addEventListener("focusout", y), p.addEventListener("keydown", b), () => {
1538
- p.removeEventListener("focusout", y), p.removeEventListener("keydown", b);
1537
+ return p.addEventListener("focusout", h), p.addEventListener("keydown", y), () => {
1538
+ p.removeEventListener("focusout", h), p.removeEventListener("keydown", y);
1539
1539
  };
1540
- }, [i, u]), M(() => {
1540
+ }, [i, m]), M(() => {
1541
1541
  !i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
1542
1542
  }, [e.attrs.latex, i]);
1543
1543
  let f = "";
1544
1544
  try {
1545
1545
  f = gr.renderToString(e.attrs.latex || "", {
1546
1546
  throwOnError: !1,
1547
- displayMode: c
1547
+ displayMode: o
1548
1548
  });
1549
1549
  } catch {
1550
1550
  f = e.attrs.latex || "";
@@ -1552,16 +1552,16 @@ const Ie = () => {
1552
1552
  return /* @__PURE__ */ g(
1553
1553
  _n,
1554
1554
  {
1555
- as: c ? "div" : "span",
1556
- className: c ? "math-block" : "math-inline",
1555
+ as: o ? "div" : "span",
1556
+ className: o ? "math-block" : "math-inline",
1557
1557
  children: i ? /* @__PURE__ */ g(
1558
1558
  "math-field",
1559
1559
  {
1560
1560
  ref: a,
1561
- className: c ? "math-live-field math-live-field--block" : "math-live-field",
1561
+ className: o ? "math-live-field math-live-field--block" : "math-live-field",
1562
1562
  children: e.attrs.latex
1563
1563
  }
1564
- ) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: m, children: [
1564
+ ) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
1565
1565
  /* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: f } }),
1566
1566
  /* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
1567
1567
  ] })
@@ -1674,10 +1674,10 @@ const Ie = () => {
1674
1674
  }, st = (e, t, n = {}) => {
1675
1675
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
1676
1676
  let i = null;
1677
- return e.state.doc.nodesBetween(r, a, (o, c) => i ? !1 : o.type.name === t ? (i = { node: o, pos: c }, !1) : !0), i;
1677
+ return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
1678
1678
  }, Xt = (e, t, n = {}) => {
1679
1679
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, i = [];
1680
- return e.state.doc.nodesBetween(r, a, (o, c) => (t(o, c) && i.push({ node: o, pos: c }), !0)), i;
1680
+ return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
1681
1681
  }, Re = (e, t) => {
1682
1682
  const { $from: n } = e.state.selection;
1683
1683
  for (let r = n.depth; r >= 0; r -= 1) {
@@ -1711,30 +1711,30 @@ const Ie = () => {
1711
1711
  const n = Na(t);
1712
1712
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1713
1713
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1714
- var s;
1715
- const i = typeof t.position == "number" ? t.position : (s = st(e, t.type || "")) == null ? void 0 : s.pos;
1714
+ var c;
1715
+ const i = typeof t.position == "number" ? t.position : (c = st(e, t.type || "")) == null ? void 0 : c.pos;
1716
1716
  if (typeof i != "number")
1717
1717
  return !1;
1718
- const o = r.doc.nodeAt(i);
1719
- if (!o || t.type && o.type.name !== t.type)
1718
+ const s = r.doc.nodeAt(i);
1719
+ if (!s || t.type && s.type.name !== t.type)
1720
1720
  return !1;
1721
- const c = { ...o.attrs, ...t.attrs };
1722
- return n.setNodeMarkup(i, void 0, c), a && a(n), !0;
1721
+ const o = { ...s.attrs, ...t.attrs };
1722
+ return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
1723
1723
  }), Zt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1724
- var c;
1725
- const i = typeof t.position == "number" ? t.position : (c = st(e, t.type || "")) == null ? void 0 : c.pos;
1724
+ var o;
1725
+ const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
1726
1726
  if (typeof i != "number")
1727
1727
  return !1;
1728
- const o = r.doc.nodeAt(i);
1729
- return !o || t.type && o.type.name !== t.type ? !1 : (n.delete(i, i + o.nodeSize), a && a(n), !0);
1728
+ const s = r.doc.nodeAt(i);
1729
+ return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
1730
1730
  }), Qt = (e, t) => {
1731
1731
  const n = Ia(e, t.type);
1732
1732
  return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
1733
- const { from: o, to: c } = a.selection, s = a.selection.$from.blockRange(a.selection.$to);
1734
- if (!s)
1733
+ const { from: s, to: o } = a.selection, c = a.selection.$from.blockRange(a.selection.$to);
1734
+ if (!c)
1735
1735
  return !1;
1736
- const l = fr(s, n, t.attrs);
1737
- return l ? (r.wrap(s, l), i && i(r.scrollIntoView()), o <= c) : !1;
1736
+ const l = fr(c, n, t.attrs);
1737
+ return l ? (r.wrap(c, l), i && i(r.scrollIntoView()), s <= o) : !1;
1738
1738
  }) : !1;
1739
1739
  }, Aa = (e, t) => {
1740
1740
  if (t.length === 0)
@@ -1749,10 +1749,10 @@ let Ne = 0;
1749
1749
  const Qe = [];
1750
1750
  let Ae = !1;
1751
1751
  const La = 2e4, bt = 6e4;
1752
- let F = null, Me = !1, ne = null, pe = null;
1752
+ let $ = null, Me = !1, ne = null, pe = null;
1753
1753
  const et = /* @__PURE__ */ new Map();
1754
1754
  function vt() {
1755
- ne && (window.removeEventListener("message", ne), ne = null), F && (F.src = "about:blank", F.remove(), F = null), Me = !1;
1755
+ ne && (window.removeEventListener("message", ne), ne = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1756
1756
  }
1757
1757
  function Pa(e, t) {
1758
1758
  const n = et.get(e);
@@ -1772,31 +1772,31 @@ function tt() {
1772
1772
  }
1773
1773
  ne && (window.removeEventListener("message", ne), ne = null);
1774
1774
  let r = null;
1775
- const a = (o) => {
1776
- r && (clearTimeout(r), r = null), o && et.set(e, o), t(o), Ae = !1, pe = setTimeout(vt, bt), tt();
1775
+ const a = (s) => {
1776
+ r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, pe = setTimeout(vt, bt), tt();
1777
1777
  }, i = () => {
1778
- var o;
1779
- (o = F.contentWindow) == null || o.postMessage(
1778
+ var s;
1779
+ (s = $.contentWindow) == null || s.postMessage(
1780
1780
  JSON.stringify({ action: "load", autosave: 0, xml: e || "" }),
1781
1781
  de
1782
1782
  );
1783
1783
  };
1784
- ne = (o) => {
1785
- if (!F || o.source !== F.contentWindow) return;
1786
- let c;
1784
+ ne = (s) => {
1785
+ if (!$ || s.source !== $.contentWindow) return;
1786
+ let o;
1787
1787
  try {
1788
- c = typeof o.data == "string" ? JSON.parse(o.data) : o.data;
1788
+ o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1789
1789
  } catch {
1790
1790
  return;
1791
1791
  }
1792
- c.event === "init" ? (Me = !0, i()) : c.event === "load" ? setTimeout(() => {
1793
- var s;
1794
- (s = F == null ? void 0 : F.contentWindow) == null || s.postMessage(
1792
+ o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
1793
+ var c;
1794
+ (c = $ == null ? void 0 : $.contentWindow) == null || c.postMessage(
1795
1795
  JSON.stringify({ action: "export", format: "svg" }),
1796
1796
  de
1797
1797
  );
1798
- }, 1500) : c.event === "export" && a(c.data || "");
1799
- }, window.addEventListener("message", ne), r = setTimeout(() => a(""), La), F ? Me && i() : (F = document.createElement("iframe"), F.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild(F), Me = !1, F.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
1798
+ }, 1500) : o.event === "export" && a(o.data || "");
1799
+ }, window.addEventListener("message", ne), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
1800
1800
  }
1801
1801
  const Le = () => {
1802
1802
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
@@ -1831,50 +1831,50 @@ const Le = () => {
1831
1831
  addNodeView() {
1832
1832
  return ({ editor: e, node: t, getPos: n }) => {
1833
1833
  let r = t, a = !1, i = !1;
1834
- const o = document.createElement("figure");
1835
- o.setAttribute("data-type", "figure"), o.className = "figure-block";
1836
- const c = document.createElement("div");
1837
- c.className = "figure-visual", c.contentEditable = "false", c.setAttribute("spellcheck", "false");
1838
- const s = document.createElement("img");
1839
- s.className = "figure-img-preview";
1834
+ const s = document.createElement("figure");
1835
+ s.setAttribute("data-type", "figure"), s.className = "figure-block";
1836
+ const o = document.createElement("div");
1837
+ o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
1838
+ const c = document.createElement("img");
1839
+ c.className = "figure-img-preview";
1840
1840
  const l = document.createElement("div");
1841
1841
  l.className = "figure-upload-area";
1842
1842
  const d = document.createElement("span");
1843
1843
  d.className = "figure-upload-hint";
1844
- const m = document.createElement("input");
1845
- m.type = "file", m.accept = "image/*", m.style.display = "none";
1846
- const u = document.createElement("button");
1847
- u.className = "figure-replace-btn", l.append(d, m);
1844
+ const u = document.createElement("input");
1845
+ u.type = "file", u.accept = "image/*", u.style.display = "none";
1846
+ const m = document.createElement("button");
1847
+ m.className = "figure-replace-btn", l.append(d, u);
1848
1848
  const f = document.createElement("div");
1849
1849
  f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
1850
1850
  const p = document.createElement("div");
1851
1851
  p.className = "figure-mermaid-preview", p.contentEditable = "false";
1852
+ const h = document.createElement("div");
1853
+ h.className = "figure-mermaid-view-hint", f.append(p, h);
1852
1854
  const y = document.createElement("div");
1853
- y.className = "figure-mermaid-view-hint", f.append(p, y);
1854
- const b = document.createElement("div");
1855
- b.className = "figure-mermaid-edit";
1855
+ y.className = "figure-mermaid-edit";
1856
1856
  const w = document.createElement("textarea");
1857
1857
  w.className = "figure-mermaid-editor", w.spellcheck = !1;
1858
1858
  const x = document.createElement("div");
1859
1859
  x.className = "figure-mermaid-toolbar";
1860
- const C = document.createElement("button");
1861
- C.className = "figure-mermaid-save-btn", C.type = "button";
1860
+ const T = document.createElement("button");
1861
+ T.className = "figure-mermaid-save-btn", T.type = "button";
1862
1862
  const v = document.createElement("button");
1863
1863
  v.className = "figure-mermaid-cancel-btn", v.type = "button";
1864
1864
  const E = document.createElement("span");
1865
- E.className = "figure-mermaid-error-inline", x.append(E, v, C), b.append(w, x);
1866
- const h = document.createElement("div");
1867
- h.className = "figure-drawio-view", h.contentEditable = "false";
1868
- const _ = document.createElement("img");
1869
- _.className = "figure-drawio-preview-img", _.style.display = "none";
1870
- const T = document.createElement("div");
1871
- T.className = "figure-drawio-view-hint", h.append(_, T), c.append(s, l, u), c.append(f, b), c.append(h);
1872
- const N = document.createElement("figcaption");
1873
- N.className = "figure-caption";
1865
+ E.className = "figure-mermaid-error-inline", x.append(E, v, T), y.append(w, x);
1866
+ const _ = document.createElement("div");
1867
+ _.className = "figure-drawio-view", _.contentEditable = "false";
1868
+ const b = document.createElement("img");
1869
+ b.className = "figure-drawio-preview-img", b.style.display = "none";
1870
+ const C = document.createElement("div");
1871
+ C.className = "figure-drawio-view-hint", _.append(b, C), o.append(c, l, m), o.append(f, y), o.append(_);
1872
+ const I = document.createElement("figcaption");
1873
+ I.className = "figure-caption";
1874
1874
  const A = document.createElement("span");
1875
1875
  A.className = "figure-id-label", A.contentEditable = "false";
1876
1876
  const D = document.createElement("span");
1877
- D.className = "figure-caption-content", N.append(A, D), o.append(c, N);
1877
+ D.className = "figure-caption-content", I.append(A, D), s.append(o, I);
1878
1878
  const z = (S) => {
1879
1879
  const k = typeof n == "function" ? n() : null;
1880
1880
  typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...S }), O && O(P), !0));
@@ -1887,13 +1887,13 @@ const Le = () => {
1887
1887
  typeof P.result == "string" && z({ imageSrc: P.result });
1888
1888
  }, P.readAsDataURL(k);
1889
1889
  };
1890
- m.addEventListener("change", () => Q(m.files)), l.addEventListener("click", () => m.click()), u.addEventListener("click", (S) => {
1891
- S.stopPropagation(), m.click();
1892
- }), c.addEventListener("dragover", (S) => {
1890
+ u.addEventListener("change", () => Q(u.files)), l.addEventListener("click", () => u.click()), m.addEventListener("click", (S) => {
1891
+ S.stopPropagation(), u.click();
1892
+ }), o.addEventListener("dragover", (S) => {
1893
1893
  r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), l.classList.add("figure-upload-area--dragover"));
1894
- }), c.addEventListener("dragleave", () => {
1894
+ }), o.addEventListener("dragleave", () => {
1895
1895
  l.classList.remove("figure-upload-area--dragover");
1896
- }), c.addEventListener("drop", (S) => {
1896
+ }), o.addEventListener("drop", (S) => {
1897
1897
  var k;
1898
1898
  l.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), Q(((k = S.dataTransfer) == null ? void 0 : k.files) ?? null));
1899
1899
  });
@@ -1913,7 +1913,7 @@ const Le = () => {
1913
1913
  p.innerHTML = R, Le();
1914
1914
  } catch {
1915
1915
  Le();
1916
- const P = I.getState().editorLanguage;
1916
+ const P = N.getState().editorLanguage;
1917
1917
  E.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", E.style.display = "inline";
1918
1918
  return;
1919
1919
  }
@@ -1921,12 +1921,12 @@ const Le = () => {
1921
1921
  };
1922
1922
  f.addEventListener("dblclick", (S) => {
1923
1923
  S.preventDefault(), S.stopPropagation(), gn();
1924
- }), C.addEventListener("click", (S) => {
1924
+ }), T.addEventListener("click", (S) => {
1925
1925
  S.stopPropagation(), pn();
1926
1926
  }), v.addEventListener("click", (S) => {
1927
1927
  S.stopPropagation(), fn();
1928
1928
  }), w.addEventListener("mousedown", (S) => S.stopPropagation()), w.addEventListener("keydown", (S) => S.stopPropagation()), w.addEventListener("keypress", (S) => S.stopPropagation());
1929
- let ee = null, G = null, q = null;
1929
+ let ee = null, G = null, U = null;
1930
1930
  const hn = () => {
1931
1931
  if (i) return;
1932
1932
  i = !0, J(), G = document.createElement("div"), G.className = "drawio-modal-overlay";
@@ -1934,47 +1934,47 @@ const Le = () => {
1934
1934
  S.className = "drawio-modal-content";
1935
1935
  const k = document.createElement("div");
1936
1936
  k.className = "drawio-modal-header";
1937
- const P = document.createElement("span"), O = I.getState().editorLanguage;
1937
+ const P = document.createElement("span"), O = N.getState().editorLanguage;
1938
1938
  P.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", P.className = "drawio-modal-title";
1939
1939
  const R = document.createElement("button");
1940
- R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R), q = document.createElement("iframe"), q.className = "drawio-modal-iframe", q.setAttribute("frameborder", "0"), S.append(k, q), G.appendChild(S), document.body.appendChild(G);
1940
+ R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), S.append(k, U), G.appendChild(S), document.body.appendChild(G);
1941
1941
  const fe = O === "en" ? "en" : "zh";
1942
- q.src = `${de}/?embed=1&proto=json&spin=1&lang=${fe}`;
1943
- const K = q;
1942
+ U.src = `${de}/?embed=1&proto=json&spin=1&lang=${fe}`;
1943
+ const K = U;
1944
1944
  ee = (X) => {
1945
1945
  var oe, Te;
1946
1946
  if (!K || X.source !== K.contentWindow) return;
1947
- let U;
1947
+ let q;
1948
1948
  try {
1949
- U = typeof X.data == "string" ? JSON.parse(X.data) : X.data;
1949
+ q = typeof X.data == "string" ? JSON.parse(X.data) : X.data;
1950
1950
  } catch {
1951
1951
  return;
1952
1952
  }
1953
- if (U.event === "init") {
1953
+ if (q.event === "init") {
1954
1954
  const ce = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
1955
1955
  (oe = K.contentWindow) == null || oe.postMessage(
1956
1956
  JSON.stringify({ action: "load", autosave: 0, xml: ce || "" }),
1957
1957
  de
1958
1958
  );
1959
- } else if (U.event === "save") {
1960
- const ce = U.xml || "";
1959
+ } else if (q.event === "save") {
1960
+ const ce = q.xml || "";
1961
1961
  (Te = K.contentWindow) == null || Te.postMessage(
1962
1962
  JSON.stringify({ action: "export", format: "svg" }),
1963
1963
  de
1964
1964
  ), z({ drawioXml: ce });
1965
- } else if (U.event === "export") {
1966
- const ce = U.data || "";
1965
+ } else if (q.event === "export") {
1966
+ const ce = q.data || "";
1967
1967
  z({ drawioSvg: ce }), We();
1968
- } else U.event === "exit" && We();
1968
+ } else q.event === "exit" && We();
1969
1969
  }, window.addEventListener("message", ee);
1970
1970
  }, We = () => {
1971
- i = !1, ee && (window.removeEventListener("message", ee), ee = null), q && (q.src = "about:blank", q = null), G && (G.remove(), G = null), J();
1971
+ i = !1, ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null), J();
1972
1972
  };
1973
- h.addEventListener("dblclick", (S) => {
1973
+ _.addEventListener("dblclick", (S) => {
1974
1974
  S.preventDefault(), S.stopPropagation(), hn();
1975
- }), o.addEventListener("mousedown", (S) => {
1975
+ }), s.addEventListener("mousedown", (S) => {
1976
1976
  const k = S.target;
1977
- if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || b.contains(k) || k === l || l.contains(k) || k === u || k === m || f.contains(k) || h.contains(k)) return;
1977
+ if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === l || l.contains(k) || k === m || k === u || f.contains(k) || _.contains(k)) return;
1978
1978
  const P = typeof n == "function" ? n() : null;
1979
1979
  if (typeof P != "number") return;
1980
1980
  const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
@@ -2002,16 +2002,16 @@ const Le = () => {
2002
2002
  }
2003
2003
  }
2004
2004
  }, J = () => {
2005
- const S = I.getState().editorLanguage, k = H(S), P = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", O = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", R = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", fe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2005
+ const S = N.getState().editorLanguage, k = H(S), P = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", O = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", R = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", fe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2006
2006
  O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
2007
- const K = P === "image", X = P === "mermaid", U = P === "drawio";
2008
- s.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", u.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", b.style.display = X && a ? "block" : "none", h.style.display = U ? "flex" : "none", K && R && (s.src = R);
2007
+ const K = P === "image", X = P === "mermaid", q = P === "drawio";
2008
+ c.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", y.style.display = X && a ? "block" : "none", _.style.display = q ? "flex" : "none", K && R && (c.src = R);
2009
2009
  const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2010
- U && (oe ? (_.src = oe, _.style.display = "block") : (_.src = "", _.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", u.textContent = k.figureReplaceImage || "更换图片", C.textContent = k.mermaidSaveAndRender || "保存并渲染", v.textContent = k.mermaidCancel || "取消";
2010
+ q && (oe ? (b.src = oe, b.style.display = "block") : (b.src = "", b.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", T.textContent = k.mermaidSaveAndRender || "保存并渲染", v.textContent = k.mermaidCancel || "取消";
2011
2011
  const Te = fe.trim().length > 0, ce = p.querySelector("svg") !== null;
2012
- X && !a && (Te && ce ? (y.textContent = k.mermaidDoubleClickToEdit || "双击编辑", y.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (y.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", y.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), U && !i && (oe ? (T.textContent = k.mermaidDoubleClickToEdit || "双击编辑", T.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (T.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", T.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
2012
+ X && !a && (Te && ce ? (h.textContent = k.mermaidDoubleClickToEdit || "双击编辑", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (h.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), q && !i && (oe ? (C.textContent = k.mermaidDoubleClickToEdit || "双击编辑", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (C.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
2013
2013
  const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
2014
- U && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2014
+ q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2015
2015
  se = null;
2016
2016
  const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2017
2017
  !dt || Tn || xe || (xe = !0, Pa(dt, (ut) => {
@@ -2021,24 +2021,24 @@ const Le = () => {
2021
2021
  }));
2022
2022
  }, bn));
2023
2023
  };
2024
- let lt = I.getState().editorLanguage;
2025
- const xn = I.subscribe((S) => {
2024
+ let lt = N.getState().editorLanguage;
2025
+ const xn = N.subscribe((S) => {
2026
2026
  S.editorLanguage !== lt && (lt = S.editorLanguage, J());
2027
2027
  });
2028
2028
  return J(), {
2029
- dom: o,
2029
+ dom: s,
2030
2030
  contentDOM: D,
2031
2031
  stopEvent: (S) => {
2032
2032
  const k = S.target;
2033
- return !!(k === w || b.contains(k) || k === m);
2033
+ return !!(k === w || y.contains(k) || k === u);
2034
2034
  },
2035
2035
  ignoreMutation: (S) => {
2036
2036
  const k = S.target;
2037
- return !!(c.contains(k) || A.contains(k));
2037
+ return !!(o.contains(k) || A.contains(k));
2038
2038
  },
2039
2039
  update: (S) => S.type.name !== "figure" ? !1 : (r = S, J(), !0),
2040
2040
  destroy: () => {
2041
- se && (clearTimeout(se), se = null), me && (clearTimeout(me), me = null), xn(), Le(), ee && (window.removeEventListener("message", ee), ee = null), q && (q.src = "about:blank", q = null), G && (G.remove(), G = null);
2041
+ se && (clearTimeout(se), se = null), me && (clearTimeout(me), me = null), xn(), Le(), ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null);
2042
2042
  }
2043
2043
  };
2044
2044
  };
@@ -2104,24 +2104,24 @@ const Le = () => {
2104
2104
  return ({ node: e, editor: t }) => {
2105
2105
  let n = e;
2106
2106
  const r = document.createElement("span"), a = () => {
2107
- const i = n.attrs.lang === "en" ? "en" : "zh", o = H(i), c = n.attrs.targetType === "figure" ? "figure" : "claim", s = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = c === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(s) ? o.claimLabel(s) : i === "en" ? "Claim ?" : "权利要求?", m = n.attrs.displayText || d;
2108
- r.textContent = m, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? o.referenceNavigateDisabledTitle : c === "figure" ? o.figureReferenceNavigateTitle : o.referenceNavigateTitle;
2107
+ const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), o = n.attrs.targetType === "figure" ? "figure" : "claim", c = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = o === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(c) ? s.claimLabel(c) : i === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || d;
2108
+ r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? s.referenceNavigateDisabledTitle : o === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2109
2109
  };
2110
2110
  return a(), r.addEventListener("click", () => {
2111
2111
  const i = n.attrs.targetType === "figure" ? "figure" : "claim";
2112
2112
  n.attrs.invalid || setTimeout(() => {
2113
- let o = null;
2113
+ let s = null;
2114
2114
  if (i === "figure") {
2115
- const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
- if (!c)
2115
+ const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
+ if (!o)
2117
2117
  return;
2118
- t.state.doc.descendants((s, l) => o !== null ? !1 : s.type.name === "figure" && s.attrs.id === c ? (o = l, !1) : !0);
2118
+ t.state.doc.descendants((c, l) => s !== null ? !1 : c.type.name === "figure" && c.attrs.id === o ? (s = l, !1) : !0);
2119
2119
  } else {
2120
2120
  if (!n.attrs.targetClaimId)
2121
2121
  return;
2122
- t.state.doc.descendants((c, s) => o !== null ? !1 : c.type.name === "claim" && c.attrs.claimId === n.attrs.targetClaimId ? (o = s, !1) : !0);
2122
+ t.state.doc.descendants((o, c) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = c, !1) : !0);
2123
2123
  }
2124
- typeof o == "number" && t.chain().focus().setTextSelection(o + 1).scrollIntoView().run();
2124
+ typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
2125
2125
  }, 0);
2126
2126
  }), {
2127
2127
  dom: r,
@@ -2197,38 +2197,38 @@ const Le = () => {
2197
2197
  a.className = "pt-title", a.setAttribute("data-type", "patent-title");
2198
2198
  const i = document.createElement("div");
2199
2199
  i.className = "pb-heading", i.contentEditable = "false";
2200
- const o = document.createElement("div");
2201
- o.className = "ps-placeholder", o.contentEditable = "false";
2202
- const c = document.createElement("h1");
2203
- c.className = "pt-title-content", a.append(i, o, c);
2204
- const s = () => {
2205
- const y = typeof n == "function" ? n() : null;
2206
- return typeof y == "number" ? y : null;
2200
+ const s = document.createElement("div");
2201
+ s.className = "ps-placeholder", s.contentEditable = "false";
2202
+ const o = document.createElement("h1");
2203
+ o.className = "pt-title-content", a.append(i, s, o);
2204
+ const c = () => {
2205
+ const h = typeof n == "function" ? n() : null;
2206
+ return typeof h == "number" ? h : null;
2207
2207
  }, l = () => {
2208
- const y = s();
2209
- y !== null && I.getState().setActiveSection("patent_title", y);
2208
+ const h = c();
2209
+ h !== null && N.getState().setActiveSection("patent_title", h);
2210
2210
  }, d = () => {
2211
- const y = s();
2212
- y !== null && (I.getState().openDraftingPanel("patent_title", y), e.commands.focus(y + 1));
2211
+ const h = c();
2212
+ h !== null && (N.getState().openDraftingPanel("patent_title", h), e.commands.focus(h + 1));
2213
2213
  };
2214
- o.addEventListener("click", d), c.addEventListener("focusin", l), c.addEventListener("click", l);
2215
- const m = () => {
2216
- const y = I.getState(), b = H(y.editorLanguage), w = typeof b.bookTitle_description == "string" ? b.bookTitle_description : "说明书", x = typeof b.patentTitlePlaceholder == "string" ? b.patentTitlePlaceholder : "专利名称";
2214
+ s.addEventListener("click", d), o.addEventListener("focusin", l), o.addEventListener("click", l);
2215
+ const u = () => {
2216
+ const h = N.getState(), y = H(h.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", x = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
2217
  i.textContent = w;
2218
- const C = ot(r), v = y.rightPanel.activeSectionPos === s();
2219
- o.textContent = `[${x}]`, o.style.display = C ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !C), c.classList.toggle("pt-title-content--has-content", C);
2218
+ const T = ot(r), v = h.rightPanel.activeSectionPos === c();
2219
+ s.textContent = `[${x}]`, s.style.display = T ? "none" : "", s.classList.toggle("ps-placeholder--active", v && !T), o.classList.toggle("pt-title-content--has-content", T);
2220
2220
  };
2221
- let u = I.getState().editorLanguage, f = I.getState().rightPanel.activeSectionPos;
2222
- const p = I.subscribe((y) => {
2223
- const b = y.editorLanguage !== u, w = y.rightPanel.activeSectionPos !== f;
2224
- u = y.editorLanguage, f = y.rightPanel.activeSectionPos, (b || w) && m();
2221
+ let m = N.getState().editorLanguage, f = N.getState().rightPanel.activeSectionPos;
2222
+ const p = N.subscribe((h) => {
2223
+ const y = h.editorLanguage !== m, w = h.rightPanel.activeSectionPos !== f;
2224
+ m = h.editorLanguage, f = h.rightPanel.activeSectionPos, (y || w) && u();
2225
2225
  });
2226
- return m(), {
2226
+ return u(), {
2227
2227
  dom: a,
2228
- contentDOM: c,
2229
- update: (y) => y.type.name !== "patent_title" ? !1 : (r = y, m(), !0),
2228
+ contentDOM: o,
2229
+ update: (h) => h.type.name !== "patent_title" ? !1 : (r = h, u(), !0),
2230
2230
  destroy: () => {
2231
- p(), o.removeEventListener("click", d), c.removeEventListener("focusin", l), c.removeEventListener("click", l);
2231
+ p(), s.removeEventListener("click", d), o.removeEventListener("focusin", l), o.removeEventListener("click", l);
2232
2232
  }
2233
2233
  };
2234
2234
  };
@@ -2298,40 +2298,40 @@ const Le = () => {
2298
2298
  a.setAttribute("data-type", "patent-section");
2299
2299
  const i = document.createElement("div");
2300
2300
  i.contentEditable = "false";
2301
+ const s = document.createElement("div");
2302
+ s.className = "ps-body";
2301
2303
  const o = document.createElement("div");
2302
- o.className = "ps-body";
2304
+ o.className = "ps-placeholder", o.contentEditable = "false";
2303
2305
  const c = document.createElement("div");
2304
- c.className = "ps-placeholder", c.contentEditable = "false";
2305
- const s = document.createElement("div");
2306
- s.className = "ps-content", o.append(c, s), a.append(i, o);
2306
+ c.className = "ps-content", s.append(o, c), a.append(i, s);
2307
2307
  const l = () => {
2308
- const b = typeof n == "function" ? n() : null;
2309
- return typeof b == "number" ? b : null;
2308
+ const y = typeof n == "function" ? n() : null;
2309
+ return typeof y == "number" ? y : null;
2310
2310
  }, d = () => {
2311
- const b = l();
2312
- if (b === null) return;
2313
- I.getState().setActiveSection(r.attrs.sectionType, b);
2314
- }, m = () => {
2315
- const b = l();
2316
- if (b === null) return;
2317
- I.getState().openDraftingPanel(r.attrs.sectionType, b), e.commands.focus(b + 1);
2311
+ const y = l();
2312
+ if (y === null) return;
2313
+ N.getState().setActiveSection(r.attrs.sectionType, y);
2314
+ }, u = () => {
2315
+ const y = l();
2316
+ if (y === null) return;
2317
+ N.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2318
2318
  };
2319
- c.addEventListener("click", m), s.addEventListener("focusin", d), s.addEventListener("click", d);
2320
- const u = () => {
2321
- const b = I.getState(), w = H(b.editorLanguage), x = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Ma.has(x), v = Fa.has(x), E = wt[x], h = typeof w[E] == "string" ? w[E] : x, _ = ot(r), T = b.rightPanel.activeSectionPos === l();
2322
- a.className = `ps${_ ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = h, c.textContent = `[${h}]`, c.style.display = _ ? "none" : "", c.classList.toggle("ps-placeholder--active", T && !_), s.classList.toggle("ps-content--has-content", _);
2319
+ o.addEventListener("click", u), c.addEventListener("focusin", d), c.addEventListener("click", d);
2320
+ const m = () => {
2321
+ const y = N.getState(), w = H(y.editorLanguage), x = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", T = Ma.has(x), v = Fa.has(x), E = wt[x], _ = typeof w[E] == "string" ? w[E] : x, b = ot(r), C = y.rightPanel.activeSectionPos === l();
2322
+ a.className = `ps${b ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), i.className = T ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = _, o.textContent = `[${_}]`, o.style.display = b ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !b), c.classList.toggle("ps-content--has-content", b);
2323
2323
  };
2324
- let f = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2325
- const y = I.subscribe((b) => {
2326
- const w = b.editorLanguage !== f, x = b.rightPanel.activeSectionPos !== p;
2327
- f = b.editorLanguage, p = b.rightPanel.activeSectionPos, (w || x) && u();
2324
+ let f = N.getState().editorLanguage, p = N.getState().rightPanel.activeSectionPos;
2325
+ const h = N.subscribe((y) => {
2326
+ const w = y.editorLanguage !== f, x = y.rightPanel.activeSectionPos !== p;
2327
+ f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || x) && m();
2328
2328
  });
2329
- return u(), {
2329
+ return m(), {
2330
2330
  dom: a,
2331
- contentDOM: s,
2332
- update: (b) => b.type.name !== "patent_section" ? !1 : (r = b, u(), !0),
2331
+ contentDOM: c,
2332
+ update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
2333
2333
  destroy: () => {
2334
- y(), c.removeEventListener("click", m), s.removeEventListener("focusin", d), s.removeEventListener("click", d);
2334
+ h(), o.removeEventListener("click", u), c.removeEventListener("focusin", d), c.removeEventListener("click", d);
2335
2335
  }
2336
2336
  };
2337
2337
  };
@@ -2350,7 +2350,7 @@ const Le = () => {
2350
2350
  ], Ha = [
2351
2351
  "drawing_figures"
2352
2352
  // 说明书附图
2353
- ], qa = [
2353
+ ], Ua = [
2354
2354
  "design_product_name",
2355
2355
  "design_usage",
2356
2356
  "design_description",
@@ -2370,42 +2370,42 @@ const Le = () => {
2370
2370
  }), en = () => ({
2371
2371
  type: "patent_title",
2372
2372
  content: []
2373
- }), Ua = () => [
2373
+ }), qa = () => [
2374
2374
  ...Oa.map(Fe),
2375
2375
  en(),
2376
2376
  ...Ba.map(Fe),
2377
2377
  ...Ha.map(Fe)
2378
2378
  ], Wa = () => [
2379
2379
  en(),
2380
- ...qa.map(Fe)
2381
- ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Wa() : Ua() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2382
- const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2380
+ ...Ua.map(Fe)
2381
+ ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Wa() : qa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2382
+ const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2383
2383
  ve(e).forEach((i) => {
2384
- const o = V(i.node.attrs.id);
2385
- o && r.add(o);
2384
+ const s = V(i.node.attrs.id);
2385
+ s && r.add(s);
2386
2386
  });
2387
2387
  let a = 1;
2388
2388
  for (; r.has(`${n}${a}`); )
2389
2389
  a += 1;
2390
2390
  return `${n}${a}`;
2391
2391
  }, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
2392
- const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2392
+ const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2393
2393
  if (r.length === 0) return;
2394
2394
  const a = [];
2395
2395
  let i = 1;
2396
- for (const c of r) {
2397
- const s = V(c.node.attrs.id);
2398
- if (!ja.exec(s)) continue;
2396
+ for (const o of r) {
2397
+ const c = V(o.node.attrs.id);
2398
+ if (!ja.exec(c)) continue;
2399
2399
  const d = `${n}${i}`;
2400
- s !== d && a.push({ pos: c.pos, expectedId: d, currentId: s }), i++;
2400
+ c !== d && a.push({ pos: o.pos, expectedId: d, currentId: c }), i++;
2401
2401
  }
2402
2402
  if (a.length === 0) return;
2403
- const { tr: o } = e.state;
2404
- for (const c of a) {
2405
- const s = o.doc.nodeAt(c.pos);
2406
- !s || s.type.name !== "figure" || o.setNodeMarkup(c.pos, void 0, { ...s.attrs, id: c.expectedId });
2403
+ const { tr: s } = e.state;
2404
+ for (const o of a) {
2405
+ const c = s.doc.nodeAt(o.pos);
2406
+ !c || c.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...c.attrs, id: o.expectedId });
2407
2407
  }
2408
- o.steps.length > 0 && (o.setMeta("addToHistory", !1), e.view.dispatch(o));
2408
+ s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
2409
2409
  }, nn = (e) => {
2410
2410
  const t = /* @__PURE__ */ new Map();
2411
2411
  return ve(e).forEach((n) => {
@@ -2415,30 +2415,30 @@ const Le = () => {
2415
2415
  pos: n.pos
2416
2416
  });
2417
2417
  }), t;
2418
- }, rn = () => I.getState().editorLanguage === "en" ? "en" : "zh", an = (e, t, n) => {
2418
+ }, rn = () => N.getState().editorLanguage === "en" ? "en" : "zh", an = (e, t, n) => {
2419
2419
  const r = H(e);
2420
2420
  return n ? r.invalidFigureReference : t || (e === "en" ? "Figure ?" : "附图?");
2421
2421
  }, Je = (e) => {
2422
2422
  const t = nn(e), n = rn();
2423
2423
  e.commands.command(({ tr: r, state: a, dispatch: i }) => {
2424
- let o = !1;
2425
- return a.doc.descendants((c, s) => {
2426
- if (c.type.name !== "reference" || c.attrs.targetType !== "figure")
2424
+ let s = !1;
2425
+ return a.doc.descendants((o, c) => {
2426
+ if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
2427
2427
  return !0;
2428
- const l = typeof c.attrs.targetFigureId == "string" && c.attrs.targetFigureId ? V(c.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0, m = d ? d.id : null, u = !d, f = an(n, m, u), p = {
2429
- ...c.attrs,
2428
+ const l = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? V(o.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0, u = d ? d.id : null, m = !d, f = an(n, u, m), p = {
2429
+ ...o.attrs,
2430
2430
  targetType: "figure",
2431
2431
  targetFigureId: l,
2432
- resolvedFigureId: m,
2433
- invalid: u,
2432
+ resolvedFigureId: u,
2433
+ invalid: m,
2434
2434
  lang: n,
2435
2435
  displayText: f,
2436
- target: m || c.attrs.target || l || null
2436
+ target: u || o.attrs.target || l || null
2437
2437
  };
2438
2438
  return Object.keys(p).some(
2439
- (b) => p[b] !== c.attrs[b]
2440
- ) && (r.setNodeMarkup(s, void 0, p), o = !0), !0;
2441
- }), o && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2439
+ (y) => p[y] !== o.attrs[y]
2440
+ ) && (r.setNodeMarkup(c, void 0, p), s = !0), !0;
2441
+ }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2442
2442
  });
2443
2443
  }, Va = {
2444
2444
  name: "patent",
@@ -2465,14 +2465,14 @@ const Le = () => {
2465
2465
  if (!(n != null && n.lang))
2466
2466
  return !1;
2467
2467
  const r = n.lang === "en" ? "en" : "zh";
2468
- I.getState().setEditorLanguage(r);
2468
+ N.getState().setEditorLanguage(r);
2469
2469
  const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
2470
- return e.commands.command(({ tr: c, state: s, dispatch: l }) => {
2470
+ return e.commands.command(({ tr: o, state: c, dispatch: l }) => {
2471
2471
  let d = !1;
2472
- return s.doc.descendants((m, u) => (m.type.name !== "reference" || i && u !== i.pos || m.attrs.lang !== r && (c.setNodeMarkup(u, void 0, {
2473
- ...m.attrs,
2472
+ return c.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (o.setNodeMarkup(m, void 0, {
2473
+ ...u.attrs,
2474
2474
  lang: r
2475
- }), d = !0), !0)), d && l && (c.setMeta("addToHistory", !1), l(c)), !0;
2475
+ }), d = !0), !0)), d && l && (o.setMeta("addToHistory", !1), l(o)), !0;
2476
2476
  }) ? (Je(e), !0) : !1;
2477
2477
  }
2478
2478
  },
@@ -2500,10 +2500,10 @@ const Le = () => {
2500
2500
  const i = e.state.doc.nodeAt(a);
2501
2501
  if (!i || i.type.name !== "figure")
2502
2502
  return !1;
2503
- const c = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
2504
- if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === c))
2503
+ const o = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
2504
+ if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === o))
2505
2505
  return !1;
2506
- const l = { id: c };
2506
+ const l = { id: o };
2507
2507
  return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (l.contentType = n.contentType), typeof n.imageSrc == "string" && (l.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (l.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (l.drawioXml = n.drawioXml), ze(e, {
2508
2508
  type: "figure",
2509
2509
  position: a,
@@ -2547,7 +2547,7 @@ const Le = () => {
2547
2547
  const i = r.get(a);
2548
2548
  if (!i)
2549
2549
  return !1;
2550
- const o = n.lang || rn(), c = n.displayText || an(o, i.id, !1);
2550
+ const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
2551
2551
  return e.chain().focus().insertContent({
2552
2552
  type: "reference",
2553
2553
  attrs: {
@@ -2556,9 +2556,9 @@ const Le = () => {
2556
2556
  targetFigureId: i.id,
2557
2557
  resolvedNumber: null,
2558
2558
  resolvedFigureId: i.id,
2559
- lang: o,
2559
+ lang: s,
2560
2560
  invalid: !1,
2561
- displayText: c,
2561
+ displayText: o,
2562
2562
  target: n.target || i.id,
2563
2563
  highlight: !1
2564
2564
  }
@@ -2608,7 +2608,7 @@ const Ka = (e = {}) => {
2608
2608
  return {
2609
2609
  editor: e,
2610
2610
  selection: { from: t, to: n },
2611
- store: I.getState()
2611
+ store: N.getState()
2612
2612
  };
2613
2613
  }, ct = (e) => ({
2614
2614
  execCommand: (t, n, r) => B.executeCommand(t, Ke(e), n, r),
@@ -2638,23 +2638,23 @@ const Ka = (e = {}) => {
2638
2638
  }
2639
2639
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
2640
2640
  }, Ct = ({ btn: e, items: t }) => {
2641
- const [n, r] = $(!1), a = W(null), i = W(null), [o, c] = $({ top: 0, left: 0 }), s = ae(() => {
2641
+ const [n, r] = F(!1), a = W(null), i = W(null), [s, o] = F({ top: 0, left: 0 }), c = ae(() => {
2642
2642
  if (!a.current) return;
2643
2643
  const l = a.current.getBoundingClientRect();
2644
- c({ top: l.bottom + 4, left: l.left });
2644
+ o({ top: l.bottom + 4, left: l.left });
2645
2645
  }, []);
2646
2646
  return M(() => {
2647
2647
  if (!n) return;
2648
- s();
2649
- const l = (m) => {
2648
+ c();
2649
+ const l = (u) => {
2650
2650
  var f, p;
2651
- const u = m.target;
2652
- (f = a.current) != null && f.contains(u) || (p = i.current) != null && p.contains(u) || r(!1);
2653
- }, d = () => s();
2651
+ const m = u.target;
2652
+ (f = a.current) != null && f.contains(m) || (p = i.current) != null && p.contains(m) || r(!1);
2653
+ }, d = () => c();
2654
2654
  return document.addEventListener("mousedown", l), window.addEventListener("scroll", d, !0), () => {
2655
2655
  document.removeEventListener("mousedown", l), window.removeEventListener("scroll", d, !0);
2656
2656
  };
2657
- }, [n, s]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2657
+ }, [n, c]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2658
2658
  /* @__PURE__ */ g(
2659
2659
  "button",
2660
2660
  {
@@ -2679,7 +2679,7 @@ const Ka = (e = {}) => {
2679
2679
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
2680
2680
  ),
2681
2681
  disabled: e.disabled,
2682
- children: /* @__PURE__ */ g(Ut, { size: 12 })
2682
+ children: /* @__PURE__ */ g(qt, { size: 12 })
2683
2683
  }
2684
2684
  ),
2685
2685
  n && yr(
@@ -2688,7 +2688,7 @@ const Ka = (e = {}) => {
2688
2688
  {
2689
2689
  ref: i,
2690
2690
  className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
2691
- style: { position: "fixed", top: o.top, left: o.left, zIndex: 9999 },
2691
+ style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
2692
2692
  children: t.map((l, d) => /* @__PURE__ */ g(
2693
2693
  "button",
2694
2694
  {
@@ -2711,16 +2711,22 @@ const Ka = (e = {}) => {
2711
2711
  collapsibleGroups: n = !0,
2712
2712
  defaultCollapsedGroups: r = []
2713
2713
  }) => {
2714
- const [a, i] = $(() => new Set(r)), { editorLanguage: o, setEditorLanguage: c } = I(), s = H(o);
2715
- if (!e)
2714
+ const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: o, setEditorLanguage: c } = N(), l = H(o);
2715
+ if (M(() => {
2716
+ if (!e) return;
2717
+ const b = () => s((C) => C + 1);
2718
+ return e.on("selectionUpdate", b), e.on("update", b), () => {
2719
+ e.off("selectionUpdate", b), e.off("update", b);
2720
+ };
2721
+ }, [e]), !e)
2716
2722
  return null;
2717
- const l = ct(e), d = o === "zh", m = [
2723
+ const d = ct(e), u = o === "zh", m = [
2718
2724
  {
2719
2725
  id: "core-undo",
2720
- label: s.undo,
2726
+ label: l.undo,
2721
2727
  group: "history",
2722
2728
  icon: br,
2723
- tooltip: `${s.undo} (Ctrl+Z)`,
2729
+ tooltip: `${l.undo} (Ctrl+Z)`,
2724
2730
  isActive: !1,
2725
2731
  disabled: !e.can().chain().focus().undo().run(),
2726
2732
  run: () => {
@@ -2729,10 +2735,10 @@ const Ka = (e = {}) => {
2729
2735
  },
2730
2736
  {
2731
2737
  id: "core-redo",
2732
- label: s.redo,
2738
+ label: l.redo,
2733
2739
  group: "history",
2734
2740
  icon: vr,
2735
- tooltip: `${s.redo} (Ctrl+Y)`,
2741
+ tooltip: `${l.redo} (Ctrl+Y)`,
2736
2742
  isActive: !1,
2737
2743
  disabled: !e.can().chain().focus().redo().run(),
2738
2744
  run: () => {
@@ -2741,10 +2747,10 @@ const Ka = (e = {}) => {
2741
2747
  },
2742
2748
  {
2743
2749
  id: "core-bold",
2744
- label: s.bold,
2750
+ label: l.bold,
2745
2751
  group: "text",
2746
2752
  icon: Dt,
2747
- tooltip: s.bold,
2753
+ tooltip: l.bold,
2748
2754
  isActive: e.isActive("bold"),
2749
2755
  disabled: !1,
2750
2756
  run: () => {
@@ -2753,10 +2759,10 @@ const Ka = (e = {}) => {
2753
2759
  },
2754
2760
  {
2755
2761
  id: "core-italic",
2756
- label: s.italic,
2762
+ label: l.italic,
2757
2763
  group: "text",
2758
2764
  icon: Rt,
2759
- tooltip: s.italic,
2765
+ tooltip: l.italic,
2760
2766
  isActive: e.isActive("italic"),
2761
2767
  disabled: !1,
2762
2768
  run: () => {
@@ -2765,10 +2771,10 @@ const Ka = (e = {}) => {
2765
2771
  },
2766
2772
  {
2767
2773
  id: "core-underline",
2768
- label: s.underline,
2774
+ label: l.underline,
2769
2775
  group: "text",
2770
2776
  icon: Mt,
2771
- tooltip: s.underline,
2777
+ tooltip: l.underline,
2772
2778
  isActive: e.isActive("underline"),
2773
2779
  disabled: !1,
2774
2780
  run: () => {
@@ -2777,10 +2783,10 @@ const Ka = (e = {}) => {
2777
2783
  },
2778
2784
  {
2779
2785
  id: "core-strike",
2780
- label: s.strike,
2786
+ label: l.strike,
2781
2787
  group: "text",
2782
2788
  icon: Ft,
2783
- tooltip: s.strike,
2789
+ tooltip: l.strike,
2784
2790
  isActive: e.isActive("strike"),
2785
2791
  disabled: !1,
2786
2792
  run: () => {
@@ -2789,10 +2795,10 @@ const Ka = (e = {}) => {
2789
2795
  },
2790
2796
  {
2791
2797
  id: "core-code",
2792
- label: s.code,
2798
+ label: l.code,
2793
2799
  group: "text",
2794
2800
  icon: $t,
2795
- tooltip: s.code,
2801
+ tooltip: l.code,
2796
2802
  isActive: e.isActive("code"),
2797
2803
  disabled: !1,
2798
2804
  run: () => {
@@ -2801,10 +2807,10 @@ const Ka = (e = {}) => {
2801
2807
  },
2802
2808
  {
2803
2809
  id: "core-superscript",
2804
- label: s.superscript,
2810
+ label: l.superscript,
2805
2811
  group: "text",
2806
2812
  icon: zt,
2807
- tooltip: `${s.superscript} (Ctrl+.)`,
2813
+ tooltip: `${l.superscript} (Ctrl+.)`,
2808
2814
  isActive: e.isActive("superscript"),
2809
2815
  disabled: !1,
2810
2816
  run: () => {
@@ -2813,10 +2819,10 @@ const Ka = (e = {}) => {
2813
2819
  },
2814
2820
  {
2815
2821
  id: "core-subscript",
2816
- label: s.subscript,
2822
+ label: l.subscript,
2817
2823
  group: "text",
2818
2824
  icon: Ot,
2819
- tooltip: `${s.subscript} (Ctrl+,)`,
2825
+ tooltip: `${l.subscript} (Ctrl+,)`,
2820
2826
  isActive: e.isActive("subscript"),
2821
2827
  disabled: !1,
2822
2828
  run: () => {
@@ -2825,10 +2831,10 @@ const Ka = (e = {}) => {
2825
2831
  },
2826
2832
  {
2827
2833
  id: "core-paragraph",
2828
- label: s.paragraph,
2834
+ label: l.paragraph,
2829
2835
  group: "structure",
2830
2836
  icon: wr,
2831
- tooltip: s.paragraph,
2837
+ tooltip: l.paragraph,
2832
2838
  isActive: e.isActive("paragraph"),
2833
2839
  disabled: !1,
2834
2840
  run: () => {
@@ -2840,7 +2846,7 @@ const Ka = (e = {}) => {
2840
2846
  label: "H1",
2841
2847
  group: "structure",
2842
2848
  icon: xr,
2843
- tooltip: s.heading1,
2849
+ tooltip: l.heading1,
2844
2850
  isActive: e.isActive("heading", { level: 1 }),
2845
2851
  disabled: !1,
2846
2852
  run: () => {
@@ -2852,7 +2858,7 @@ const Ka = (e = {}) => {
2852
2858
  label: "H2",
2853
2859
  group: "structure",
2854
2860
  icon: Cr,
2855
- tooltip: s.heading2,
2861
+ tooltip: l.heading2,
2856
2862
  isActive: e.isActive("heading", { level: 2 }),
2857
2863
  disabled: !1,
2858
2864
  run: () => {
@@ -2864,7 +2870,7 @@ const Ka = (e = {}) => {
2864
2870
  label: "H3",
2865
2871
  group: "structure",
2866
2872
  icon: Tr,
2867
- tooltip: s.heading3,
2873
+ tooltip: l.heading3,
2868
2874
  isActive: e.isActive("heading", { level: 3 }),
2869
2875
  disabled: !1,
2870
2876
  run: () => {
@@ -2873,10 +2879,10 @@ const Ka = (e = {}) => {
2873
2879
  },
2874
2880
  {
2875
2881
  id: "core-align-left",
2876
- label: s.alignLeft,
2882
+ label: l.alignLeft,
2877
2883
  group: "format",
2878
2884
  icon: Sr,
2879
- tooltip: s.alignLeft,
2885
+ tooltip: l.alignLeft,
2880
2886
  isActive: e.isActive({ textAlign: "left" }),
2881
2887
  disabled: !1,
2882
2888
  run: () => {
@@ -2885,10 +2891,10 @@ const Ka = (e = {}) => {
2885
2891
  },
2886
2892
  {
2887
2893
  id: "core-align-center",
2888
- label: s.alignCenter,
2894
+ label: l.alignCenter,
2889
2895
  group: "format",
2890
2896
  icon: Er,
2891
- tooltip: s.alignCenter,
2897
+ tooltip: l.alignCenter,
2892
2898
  isActive: e.isActive({ textAlign: "center" }),
2893
2899
  disabled: !1,
2894
2900
  run: () => {
@@ -2897,10 +2903,10 @@ const Ka = (e = {}) => {
2897
2903
  },
2898
2904
  {
2899
2905
  id: "core-align-right",
2900
- label: s.alignRight,
2906
+ label: l.alignRight,
2901
2907
  group: "format",
2902
2908
  icon: kr,
2903
- tooltip: s.alignRight,
2909
+ tooltip: l.alignRight,
2904
2910
  isActive: e.isActive({ textAlign: "right" }),
2905
2911
  disabled: !1,
2906
2912
  run: () => {
@@ -2909,10 +2915,10 @@ const Ka = (e = {}) => {
2909
2915
  },
2910
2916
  {
2911
2917
  id: "core-align-justify",
2912
- label: s.alignJustify,
2918
+ label: l.alignJustify,
2913
2919
  group: "format",
2914
2920
  icon: _r,
2915
- tooltip: s.alignJustify,
2921
+ tooltip: l.alignJustify,
2916
2922
  isActive: e.isActive({ textAlign: "justify" }),
2917
2923
  disabled: !1,
2918
2924
  run: () => {
@@ -2921,10 +2927,10 @@ const Ka = (e = {}) => {
2921
2927
  },
2922
2928
  {
2923
2929
  id: "core-bullet-list",
2924
- label: s.bulletList,
2930
+ label: l.bulletList,
2925
2931
  group: "structure",
2926
2932
  icon: Ir,
2927
- tooltip: s.bulletList,
2933
+ tooltip: l.bulletList,
2928
2934
  isActive: e.isActive("bulletList"),
2929
2935
  disabled: !1,
2930
2936
  run: () => {
@@ -2933,10 +2939,10 @@ const Ka = (e = {}) => {
2933
2939
  },
2934
2940
  {
2935
2941
  id: "core-ordered-list",
2936
- label: s.orderedList,
2942
+ label: l.orderedList,
2937
2943
  group: "structure",
2938
2944
  icon: Nr,
2939
- tooltip: s.orderedList,
2945
+ tooltip: l.orderedList,
2940
2946
  isActive: e.isActive("orderedList"),
2941
2947
  disabled: !1,
2942
2948
  run: () => {
@@ -2945,10 +2951,10 @@ const Ka = (e = {}) => {
2945
2951
  },
2946
2952
  {
2947
2953
  id: "core-blockquote",
2948
- label: s.blockquote,
2954
+ label: l.blockquote,
2949
2955
  group: "structure",
2950
2956
  icon: Ar,
2951
- tooltip: s.blockquote,
2957
+ tooltip: l.blockquote,
2952
2958
  isActive: e.isActive("blockquote"),
2953
2959
  disabled: !1,
2954
2960
  run: () => {
@@ -2957,10 +2963,10 @@ const Ka = (e = {}) => {
2957
2963
  },
2958
2964
  {
2959
2965
  id: "core-code-block",
2960
- label: s.codeBlock,
2966
+ label: l.codeBlock,
2961
2967
  group: "structure",
2962
2968
  icon: Lr,
2963
- tooltip: s.codeBlock,
2969
+ tooltip: l.codeBlock,
2964
2970
  isActive: e.isActive("codeBlock"),
2965
2971
  disabled: !1,
2966
2972
  run: () => {
@@ -2969,10 +2975,10 @@ const Ka = (e = {}) => {
2969
2975
  },
2970
2976
  {
2971
2977
  id: "core-table",
2972
- label: s.insertTable,
2978
+ label: l.insertTable,
2973
2979
  group: "structure",
2974
2980
  icon: Pr,
2975
- tooltip: s.insertTable,
2981
+ tooltip: l.insertTable,
2976
2982
  isActive: !1,
2977
2983
  disabled: !1,
2978
2984
  run: () => {
@@ -2981,10 +2987,10 @@ const Ka = (e = {}) => {
2981
2987
  },
2982
2988
  {
2983
2989
  id: "core-horizontal-rule",
2984
- label: s.horizontalRule,
2990
+ label: l.horizontalRule,
2985
2991
  group: "structure",
2986
2992
  icon: Dr,
2987
- tooltip: s.horizontalRule,
2993
+ tooltip: l.horizontalRule,
2988
2994
  isActive: !1,
2989
2995
  disabled: !1,
2990
2996
  run: () => {
@@ -2993,87 +2999,87 @@ const Ka = (e = {}) => {
2993
2999
  },
2994
3000
  {
2995
3001
  id: "core-task-list",
2996
- label: s.taskList,
3002
+ label: l.taskList,
2997
3003
  group: "structure",
2998
3004
  icon: Rr,
2999
- tooltip: s.taskList,
3005
+ tooltip: l.taskList,
3000
3006
  isActive: e.isActive("taskList"),
3001
3007
  disabled: !1,
3002
3008
  run: () => {
3003
3009
  e.chain().focus().toggleTaskList().run();
3004
3010
  }
3005
3011
  }
3006
- ], u = {
3012
+ ], f = {
3007
3013
  GitGraph: Or,
3008
3014
  Sigma: zr,
3009
3015
  FunctionSquare: $r,
3010
3016
  Workflow: Fr,
3011
3017
  Box: Mr,
3012
- FileText: qt,
3018
+ FileText: Ut,
3013
3019
  Link2: Ht,
3014
3020
  Image: Bt
3015
- }, f = B.getToolbarItems().map((h) => {
3016
- const _ = B.getCommandMeta(h.command), T = d && h.tooltipZh ? h.tooltipZh : h.tooltip || (_ == null ? void 0 : _.description) || h.label, N = h.shortcut || (_ == null ? void 0 : _.shortcut), A = N ? `${T} (${N})` : T;
3021
+ }, p = B.getToolbarItems().map((b) => {
3022
+ const C = B.getCommandMeta(b.command), I = u && b.tooltipZh ? b.tooltipZh : b.tooltip || (C == null ? void 0 : C.description) || b.label, A = b.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${I} (${A})` : I;
3017
3023
  return {
3018
- id: h.id,
3019
- label: h.label,
3020
- group: h.group || "technical",
3021
- icon: h.icon ? u[h.icon] || mt : mt,
3022
- isActive: l.isCommandActive(h.command),
3023
- disabled: !l.canExecCommand(h.command),
3024
- tooltip: A,
3024
+ id: b.id,
3025
+ label: b.label,
3026
+ group: b.group || "technical",
3027
+ icon: b.icon ? f[b.icon] || mt : mt,
3028
+ isActive: d.isCommandActive(b.command),
3029
+ disabled: !d.canExecCommand(b.command),
3030
+ tooltip: D,
3025
3031
  run: () => {
3026
- l.execCommand(h.command);
3032
+ d.execCommand(b.command);
3027
3033
  }
3028
3034
  };
3029
- }), p = [...m, ...f], y = p.map((h) => h.group).filter((h, _, T) => T.indexOf(h) === _ && !t.includes(h)), w = [...t, ...y].map((h) => ({
3030
- group: h,
3031
- items: p.filter((_) => _.group === h)
3032
- })).filter((h) => h.items.length > 0), x = (h) => {
3033
- i((_) => {
3034
- const T = new Set(_);
3035
- return T.has(h) ? T.delete(h) : T.add(h), T;
3035
+ }), h = [...m, ...p], y = h.map((b) => b.group).filter((b, C, I) => I.indexOf(b) === C && !t.includes(b)), x = [...t, ...y].map((b) => ({
3036
+ group: b,
3037
+ items: h.filter((C) => C.group === b)
3038
+ })).filter((b) => b.items.length > 0), T = (b) => {
3039
+ i((C) => {
3040
+ const I = new Set(C);
3041
+ return I.has(b) ? I.delete(b) : I.add(b), I;
3036
3042
  });
3037
- }, C = [
3038
- { label: d ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
3039
- { label: d ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
3040
- { label: d ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
3041
- { label: d ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
3042
- { label: d ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
3043
- { label: d ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
3044
- { label: d ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
3045
- { label: d ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
3046
- { label: d ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
3047
- { label: d ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3048
- { label: d ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3049
- ], v = [
3050
- { label: s.insertImageFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "image" }) },
3051
- { label: s.insertMermaidFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3052
- { label: s.insertDrawioFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3053
- ], E = (h) => h.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: h, items: C }, h.id) : h.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: h, items: v }, h.id) : /* @__PURE__ */ g(
3043
+ }, v = [
3044
+ { label: u ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
3045
+ { label: u ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
3046
+ { label: u ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
3047
+ { label: u ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
3048
+ { label: u ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
3049
+ { label: u ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
3050
+ { label: u ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
3051
+ { label: u ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
3052
+ { label: u ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
3053
+ { label: u ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3054
+ { label: u ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3055
+ ], E = [
3056
+ { label: l.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3057
+ { label: l.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3058
+ { label: l.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3059
+ ], _ = (b) => b.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: b, items: v }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: b, items: E }, b.id) : /* @__PURE__ */ g(
3054
3060
  "button",
3055
3061
  {
3056
- onClick: h.run,
3057
- disabled: h.disabled,
3062
+ onClick: b.run,
3063
+ disabled: b.disabled,
3058
3064
  className: Y(
3059
3065
  "p-2 rounded transition-colors",
3060
- h.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3061
- h.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3066
+ b.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3067
+ b.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3062
3068
  ),
3063
- title: h.tooltip,
3064
- children: /* @__PURE__ */ g(h.icon, { size: 18 })
3069
+ title: b.tooltip,
3070
+ children: /* @__PURE__ */ g(b.icon, { size: 18 })
3065
3071
  },
3066
- h.id
3072
+ b.id
3067
3073
  );
3068
3074
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ L("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
3069
3075
  /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
3070
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.language }),
3076
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.language }),
3071
3077
  /* @__PURE__ */ L(
3072
3078
  "select",
3073
3079
  {
3074
3080
  value: o,
3075
- onChange: (h) => {
3076
- c(h.target.value === "en" ? "en" : "zh");
3081
+ onChange: (b) => {
3082
+ c(b.target.value === "en" ? "en" : "zh");
3077
3083
  },
3078
3084
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
3079
3085
  children: [
@@ -3083,26 +3089,26 @@ const Ka = (e = {}) => {
3083
3089
  }
3084
3090
  )
3085
3091
  ] }),
3086
- w.map((h) => {
3087
- const _ = a.has(h.group);
3092
+ x.map((b) => {
3093
+ const C = a.has(b.group);
3088
3094
  return /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200 last:border-r-0 last:mr-0 last:pr-0", children: [
3089
3095
  n && /* @__PURE__ */ g(
3090
3096
  "button",
3091
3097
  {
3092
3098
  onClick: () => {
3093
- x(h.group);
3099
+ T(b.group);
3094
3100
  },
3095
3101
  className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
3096
- title: _ ? `${s.expand} ${Xe(h.group, s)}` : `${s.collapse} ${Xe(h.group, s)}`,
3097
- children: Xe(h.group, s)
3102
+ title: C ? `${l.expand} ${Xe(b.group, l)}` : `${l.collapse} ${Xe(b.group, l)}`,
3103
+ children: Xe(b.group, l)
3098
3104
  }
3099
3105
  ),
3100
- (!n || !_) && h.items.map(E)
3101
- ] }, h.group);
3106
+ (!n || !C) && b.items.map(_)
3107
+ ] }, b.group);
3102
3108
  })
3103
3109
  ] }) });
3104
3110
  }, Qa = ({ editor: e }) => {
3105
- const [t, n] = $(0), [r, a] = $(""), i = I((v) => v.editorLanguage), o = H(i);
3111
+ const [t, n] = F(0), [r, a] = F(""), i = N((v) => v.editorLanguage), s = H(i);
3106
3112
  if (M(() => {
3107
3113
  if (!e) return;
3108
3114
  const v = () => n((E) => E + 1);
@@ -3110,30 +3116,30 @@ const Ka = (e = {}) => {
3110
3116
  e.off("selectionUpdate", v), e.off("update", v);
3111
3117
  };
3112
3118
  }, [e]), !e) return null;
3113
- const c = ct(e), s = [];
3119
+ const o = ct(e), c = [];
3114
3120
  e.state.doc.descendants((v) => {
3115
3121
  if (v.type.name !== "figure") return !0;
3116
3122
  const E = typeof v.attrs.id == "string" ? v.attrs.id.trim() : "";
3117
- return E && s.push({ id: E, label: E }), !0;
3123
+ return E && c.push({ id: E, label: E }), !0;
3118
3124
  });
3119
- const l = c.findAncestorNode("figure"), d = !!l, m = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", u = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = $(""), y = W(null), b = W(null), w = (l == null ? void 0 : l.pos) ?? null;
3120
- w !== b.current && (b.current = w, d && m !== f && p(m));
3125
+ const l = o.findAncestorNode("figure"), d = !!l, u = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", m = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = F(""), h = W(null), y = W(null), w = (l == null ? void 0 : l.pos) ?? null;
3126
+ w !== y.current && (y.current = w, d && u !== f && p(u));
3121
3127
  const x = (v) => {
3122
- l && c.execCommand("patent.updateFigure", {
3128
+ l && o.execCommand("patent.updateFigure", {
3123
3129
  position: l.pos,
3124
3130
  contentType: v
3125
3131
  });
3126
- }, C = () => {
3132
+ }, T = () => {
3127
3133
  if (!l) return;
3128
3134
  const v = f.trim();
3129
- v !== m && c.execCommand("patent.updateFigure", {
3135
+ v !== u && o.execCommand("patent.updateFigure", {
3130
3136
  position: l.pos,
3131
3137
  id: v
3132
3138
  });
3133
3139
  };
3134
3140
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ L("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
3135
- s.length > 0 && /* @__PURE__ */ L(je, { children: [
3136
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.figureReferenceTarget }),
3141
+ c.length > 0 && /* @__PURE__ */ L(je, { children: [
3142
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
3137
3143
  /* @__PURE__ */ L(
3138
3144
  "select",
3139
3145
  {
@@ -3141,8 +3147,8 @@ const Ka = (e = {}) => {
3141
3147
  onChange: (v) => a(v.target.value === "__none__" ? "" : v.target.value),
3142
3148
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3143
3149
  children: [
3144
- /* @__PURE__ */ g("option", { value: "__none__", children: o.figureReferenceTargetPlaceholder }),
3145
- s.map((v) => /* @__PURE__ */ g("option", { value: v.id, children: v.label }, v.id))
3150
+ /* @__PURE__ */ g("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
3151
+ c.map((v) => /* @__PURE__ */ g("option", { value: v.id, children: v.label }, v.id))
3146
3152
  ]
3147
3153
  }
3148
3154
  ),
@@ -3150,47 +3156,47 @@ const Ka = (e = {}) => {
3150
3156
  "button",
3151
3157
  {
3152
3158
  onClick: () => {
3153
- r && c.execCommand("patent.insertFigureReference", {
3159
+ r && o.execCommand("patent.insertFigureReference", {
3154
3160
  targetType: "figure",
3155
3161
  targetFigureId: r
3156
3162
  });
3157
3163
  },
3158
3164
  className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
3159
- title: o.insertFigureReference,
3165
+ title: s.insertFigureReference,
3160
3166
  children: /* @__PURE__ */ g(Bt, { size: 16 })
3161
3167
  }
3162
3168
  )
3163
3169
  ] }),
3164
3170
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
3165
3171
  d && /* @__PURE__ */ L(je, { children: [
3166
- /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: o.currentFigure }),
3167
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.figureId }),
3172
+ /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: s.currentFigure }),
3173
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureId }),
3168
3174
  /* @__PURE__ */ g(
3169
3175
  "input",
3170
3176
  {
3171
- ref: y,
3177
+ ref: h,
3172
3178
  type: "text",
3173
3179
  value: f,
3174
3180
  onChange: (v) => p(v.target.value),
3175
- onBlur: C,
3181
+ onBlur: T,
3176
3182
  onKeyDown: (v) => {
3177
- v.key === "Enter" && (C(), v.target.blur());
3183
+ v.key === "Enter" && (T(), v.target.blur());
3178
3184
  },
3179
3185
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
3180
3186
  placeholder: i === "en" ? "Fig.1" : "图1"
3181
3187
  }
3182
3188
  ),
3183
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.switchFigureType }),
3189
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
3184
3190
  /* @__PURE__ */ L(
3185
3191
  "select",
3186
3192
  {
3187
- value: u,
3193
+ value: m,
3188
3194
  onChange: (v) => x(v.target.value),
3189
3195
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3190
3196
  children: [
3191
- /* @__PURE__ */ g("option", { value: "image", children: o.figureContentTypeImage }),
3192
- /* @__PURE__ */ g("option", { value: "mermaid", children: o.figureContentTypeMermaid }),
3193
- /* @__PURE__ */ g("option", { value: "drawio", children: o.figureContentTypeDrawio })
3197
+ /* @__PURE__ */ g("option", { value: "image", children: s.figureContentTypeImage }),
3198
+ /* @__PURE__ */ g("option", { value: "mermaid", children: s.figureContentTypeMermaid }),
3199
+ /* @__PURE__ */ g("option", { value: "drawio", children: s.figureContentTypeDrawio })
3194
3200
  ]
3195
3201
  }
3196
3202
  ),
@@ -3200,14 +3206,14 @@ const Ka = (e = {}) => {
3200
3206
  const E = e.getAttributes("image").width || "";
3201
3207
  return /* @__PURE__ */ L(je, { children: [
3202
3208
  /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
3203
- ["25%", "50%", "75%", "100%"].map((_) => /* @__PURE__ */ g(
3209
+ ["25%", "50%", "75%", "100%"].map((b) => /* @__PURE__ */ g(
3204
3210
  "button",
3205
3211
  {
3206
- onClick: () => e.chain().focus().updateAttributes("image", { width: _ }).run(),
3207
- className: `text-xs px-2 py-0.5 rounded border ${E === _ ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3208
- children: _
3212
+ onClick: () => e.chain().focus().updateAttributes("image", { width: b }).run(),
3213
+ className: `text-xs px-2 py-0.5 rounded border ${E === b ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3214
+ children: b
3209
3215
  },
3210
- _
3216
+ b
3211
3217
  )),
3212
3218
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3213
3219
  ] });
@@ -3231,7 +3237,7 @@ const Ka = (e = {}) => {
3231
3237
  design_views: ["design_description"],
3232
3238
  design_brief: ["design_description", "design_views"]
3233
3239
  };
3234
- function qs(e, t) {
3240
+ function Us(e, t) {
3235
3241
  return (sn[e] || []).filter((r) => !t.has(r));
3236
3242
  }
3237
3243
  function ei(e) {
@@ -3270,30 +3276,30 @@ function ti(e, t) {
3270
3276
  if (!n || n.length === 0) return [];
3271
3277
  const r = ei(e), a = new Map(r.map((i) => [i.sectionType, i]));
3272
3278
  return n.map((i) => {
3273
- const o = a.get(i);
3274
- return !o || o.content.trim().length === 0 ? null : {
3279
+ const s = a.get(i);
3280
+ return !s || s.content.trim().length === 0 ? null : {
3275
3281
  sectionType: i,
3276
- content: o.content.trim()
3282
+ content: s.content.trim()
3277
3283
  };
3278
3284
  }).filter((i) => i !== null && i.content.length > 0);
3279
3285
  }
3280
- function Us(e, t = {}) {
3281
- const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3282
- let o = t.sectionType, c = t.targetSectionPos;
3283
- if (!o) {
3284
- const m = on(e);
3285
- m && (o = m.sectionType, c = m.pos);
3286
+ function qs(e, t = {}) {
3287
+ const n = N.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3288
+ let s = t.sectionType, o = t.targetSectionPos;
3289
+ if (!s) {
3290
+ const u = on(e);
3291
+ u && (s = u.sectionType, o = u.pos);
3286
3292
  }
3287
- const s = t.scope || (o ? "section" : i ? "selection" : "document"), l = o ? ti(e, o) : void 0;
3293
+ const c = t.scope || (s ? "section" : i ? "selection" : "document"), l = s ? ti(e, s) : void 0;
3288
3294
  let d;
3289
- if (s === "selection" && r !== a) {
3290
- const u = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(u, r, " ", "\0"), y = e.state.doc.textBetween(a, f, " ", "\0");
3291
- d = `...${p}[SELECTED]${y}...`;
3295
+ if (c === "selection" && r !== a) {
3296
+ const m = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), h = e.state.doc.textBetween(a, f, " ", "\0");
3297
+ d = `...${p}[SELECTED]${h}...`;
3292
3298
  }
3293
3299
  return {
3294
- scope: s,
3295
- sectionType: o,
3296
- targetSectionPos: c,
3300
+ scope: c,
3301
+ sectionType: s,
3302
+ targetSectionPos: o,
3297
3303
  userInput: t.userInput,
3298
3304
  selectedText: i,
3299
3305
  dependencyContext: l,
@@ -3302,19 +3308,19 @@ function Us(e, t = {}) {
3302
3308
  };
3303
3309
  }
3304
3310
  const ni = ({ editor: e, onSelectionOptimize: t }) => {
3305
- const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", o = (l) => Y(
3311
+ const { addChatReference: n, openChatPanel: r, editorLanguage: a } = N(), i = a === "zh", s = (l) => Y(
3306
3312
  "p-1.5 rounded transition-colors",
3307
3313
  l ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3308
- ), c = () => {
3314
+ ), o = () => {
3309
3315
  const { from: l, to: d } = e.state.selection;
3310
3316
  if (l === d) return;
3311
- const m = e.state.doc.textBetween(l, d, " "), u = on(e);
3317
+ const u = e.state.doc.textBetween(l, d, " "), m = on(e);
3312
3318
  if (t) {
3313
- t({ text: m, from: l, to: d, sectionType: u == null ? void 0 : u.sectionType });
3319
+ t({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType });
3314
3320
  return;
3315
3321
  }
3316
- n({ text: m, from: l, to: d, sectionType: u == null ? void 0 : u.sectionType }), r();
3317
- }, s = () => {
3322
+ n({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3323
+ }, c = () => {
3318
3324
  const l = e.getAttributes("link").href, d = window.prompt("URL", l || "https://");
3319
3325
  d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
3320
3326
  };
@@ -3323,15 +3329,15 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3323
3329
  {
3324
3330
  editor: e,
3325
3331
  shouldShow: ({ editor: l, state: d }) => {
3326
- const { from: m, to: u } = d.selection;
3327
- return !(m === u || l.isActive("codeBlock"));
3332
+ const { from: u, to: m } = d.selection;
3333
+ return !(u === m || l.isActive("codeBlock"));
3328
3334
  },
3329
3335
  children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
3330
3336
  /* @__PURE__ */ g(
3331
3337
  "button",
3332
3338
  {
3333
3339
  onClick: () => e.chain().focus().toggleBold().run(),
3334
- className: o(e.isActive("bold")),
3340
+ className: s(e.isActive("bold")),
3335
3341
  title: "Bold",
3336
3342
  children: /* @__PURE__ */ g(Dt, { size: 15 })
3337
3343
  }
@@ -3340,7 +3346,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3340
3346
  "button",
3341
3347
  {
3342
3348
  onClick: () => e.chain().focus().toggleItalic().run(),
3343
- className: o(e.isActive("italic")),
3349
+ className: s(e.isActive("italic")),
3344
3350
  title: "Italic",
3345
3351
  children: /* @__PURE__ */ g(Rt, { size: 15 })
3346
3352
  }
@@ -3349,7 +3355,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3349
3355
  "button",
3350
3356
  {
3351
3357
  onClick: () => e.chain().focus().toggleUnderline().run(),
3352
- className: o(e.isActive("underline")),
3358
+ className: s(e.isActive("underline")),
3353
3359
  title: "Underline",
3354
3360
  children: /* @__PURE__ */ g(Mt, { size: 15 })
3355
3361
  }
@@ -3358,7 +3364,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3358
3364
  "button",
3359
3365
  {
3360
3366
  onClick: () => e.chain().focus().toggleStrike().run(),
3361
- className: o(e.isActive("strike")),
3367
+ className: s(e.isActive("strike")),
3362
3368
  title: "Strikethrough",
3363
3369
  children: /* @__PURE__ */ g(Ft, { size: 15 })
3364
3370
  }
@@ -3367,7 +3373,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3367
3373
  "button",
3368
3374
  {
3369
3375
  onClick: () => e.chain().focus().toggleCode().run(),
3370
- className: o(e.isActive("code")),
3376
+ className: s(e.isActive("code")),
3371
3377
  title: "Code",
3372
3378
  children: /* @__PURE__ */ g($t, { size: 15 })
3373
3379
  }
@@ -3376,7 +3382,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3376
3382
  "button",
3377
3383
  {
3378
3384
  onClick: () => e.chain().focus().toggleSuperscript().run(),
3379
- className: o(e.isActive("superscript")),
3385
+ className: s(e.isActive("superscript")),
3380
3386
  title: "Superscript",
3381
3387
  children: /* @__PURE__ */ g(zt, { size: 15 })
3382
3388
  }
@@ -3385,7 +3391,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3385
3391
  "button",
3386
3392
  {
3387
3393
  onClick: () => e.chain().focus().toggleSubscript().run(),
3388
- className: o(e.isActive("subscript")),
3394
+ className: s(e.isActive("subscript")),
3389
3395
  title: "Subscript",
3390
3396
  children: /* @__PURE__ */ g(Ot, { size: 15 })
3391
3397
  }
@@ -3395,7 +3401,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3395
3401
  "button",
3396
3402
  {
3397
3403
  onClick: () => e.chain().focus().toggleHighlight().run(),
3398
- className: o(e.isActive("highlight")),
3404
+ className: s(e.isActive("highlight")),
3399
3405
  title: "Highlight",
3400
3406
  children: /* @__PURE__ */ g(Br, { size: 15 })
3401
3407
  }
@@ -3403,8 +3409,8 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3403
3409
  /* @__PURE__ */ g(
3404
3410
  "button",
3405
3411
  {
3406
- onClick: s,
3407
- className: o(e.isActive("link")),
3412
+ onClick: c,
3413
+ className: s(e.isActive("link")),
3408
3414
  title: "Link",
3409
3415
  children: /* @__PURE__ */ g(Ht, { size: 15 })
3410
3416
  }
@@ -3413,7 +3419,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3413
3419
  /* @__PURE__ */ g(
3414
3420
  "button",
3415
3421
  {
3416
- onClick: c,
3422
+ onClick: o,
3417
3423
  className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
3418
3424
  title: i ? "AI 优化" : "AI Optimize",
3419
3425
  children: /* @__PURE__ */ g(Hr, { size: 15 })
@@ -3424,35 +3430,35 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3424
3430
  );
3425
3431
  }, ri = ({ editor: e }) => {
3426
3432
  var x;
3427
- const [t, n] = $(!1), [r, a] = $(!1), [i, o] = $(""), [c, s] = $(""), [l, d] = $(!1), m = W(null), u = e.extensionStorage.searchReplace, f = ((x = u == null ? void 0 : u.results) == null ? void 0 : x.length) ?? 0, p = (u == null ? void 0 : u.currentIndex) ?? -1;
3433
+ const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, c] = F(""), [l, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((x = m == null ? void 0 : m.results) == null ? void 0 : x.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3428
3434
  M(() => {
3429
- const C = (v) => {
3435
+ const T = (v) => {
3430
3436
  n(!0);
3431
3437
  const E = v.detail;
3432
3438
  E != null && E.replace && a(!0), requestAnimationFrame(() => {
3433
- var h;
3434
- return (h = m.current) == null ? void 0 : h.focus();
3439
+ var _;
3440
+ return (_ = u.current) == null ? void 0 : _.focus();
3435
3441
  });
3436
3442
  };
3437
- return window.addEventListener("editor:toggleSearch", C), () => window.removeEventListener("editor:toggleSearch", C);
3443
+ return window.addEventListener("editor:toggleSearch", T), () => window.removeEventListener("editor:toggleSearch", T);
3438
3444
  }, []);
3439
- const y = ae(
3440
- (C) => {
3441
- o(C), e.commands.setSearchTerm(C);
3445
+ const h = ae(
3446
+ (T) => {
3447
+ s(T), e.commands.setSearchTerm(T);
3442
3448
  },
3443
3449
  [e]
3444
- ), b = ae(() => {
3450
+ ), y = ae(() => {
3445
3451
  n(!1), e.commands.clearSearch(), e.commands.focus();
3446
3452
  }, [e]);
3447
3453
  M(() => {
3448
- const C = (v) => {
3449
- v.key === "Escape" && t && b();
3454
+ const T = (v) => {
3455
+ v.key === "Escape" && t && y();
3450
3456
  };
3451
- return window.addEventListener("keydown", C), () => window.removeEventListener("keydown", C);
3452
- }, [t, b]);
3457
+ return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
3458
+ }, [t, y]);
3453
3459
  const w = () => {
3454
- const C = !l;
3455
- d(C), e.commands.setCaseSensitive(C);
3460
+ const T = !l;
3461
+ d(T), e.commands.setCaseSensitive(T);
3456
3462
  };
3457
3463
  return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
3458
3464
  /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
@@ -3460,12 +3466,12 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3460
3466
  /* @__PURE__ */ g(
3461
3467
  "input",
3462
3468
  {
3463
- ref: m,
3469
+ ref: u,
3464
3470
  type: "text",
3465
3471
  value: i,
3466
- onChange: (C) => y(C.target.value),
3467
- onKeyDown: (C) => {
3468
- C.key === "Enter" && (C.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
3472
+ onChange: (T) => h(T.target.value),
3473
+ onKeyDown: (T) => {
3474
+ T.key === "Enter" && (T.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
3469
3475
  },
3470
3476
  placeholder: "Find...",
3471
3477
  className: "find-replace-input"
@@ -3479,33 +3485,33 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3479
3485
  onClick: w,
3480
3486
  className: Y("find-replace-btn", l && "find-replace-btn--active"),
3481
3487
  title: "Case Sensitive",
3482
- children: /* @__PURE__ */ g(qr, { size: 15 })
3488
+ children: /* @__PURE__ */ g(Ur, { size: 15 })
3483
3489
  }
3484
3490
  ),
3485
- /* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(Ur, { size: 15 }) }),
3486
- /* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(Ut, { size: 15 }) }),
3491
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(qr, { size: 15 }) }),
3492
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(qt, { size: 15 }) }),
3487
3493
  /* @__PURE__ */ g(
3488
3494
  "button",
3489
3495
  {
3490
- onClick: () => a((C) => !C),
3496
+ onClick: () => a((T) => !T),
3491
3497
  className: Y("find-replace-btn", r && "find-replace-btn--active"),
3492
3498
  title: "Toggle Replace",
3493
3499
  children: /* @__PURE__ */ g(gt, { size: 15 })
3494
3500
  }
3495
3501
  ),
3496
- /* @__PURE__ */ g("button", { onClick: b, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Wr, { size: 15 }) })
3502
+ /* @__PURE__ */ g("button", { onClick: y, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Wr, { size: 15 }) })
3497
3503
  ] }),
3498
3504
  r && /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
3499
3505
  /* @__PURE__ */ g(
3500
3506
  "input",
3501
3507
  {
3502
3508
  type: "text",
3503
- value: c,
3504
- onChange: (C) => {
3505
- s(C.target.value), e.commands.setReplaceTerm(C.target.value);
3509
+ value: o,
3510
+ onChange: (T) => {
3511
+ c(T.target.value), e.commands.setReplaceTerm(T.target.value);
3506
3512
  },
3507
- onKeyDown: (C) => {
3508
- C.key === "Enter" && e.commands.replaceCurrent();
3513
+ onKeyDown: (T) => {
3514
+ T.key === "Enter" && e.commands.replaceCurrent();
3509
3515
  },
3510
3516
  placeholder: "Replace...",
3511
3517
  className: "find-replace-input"
@@ -3516,10 +3522,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3516
3522
  ] })
3517
3523
  ] }) : null;
3518
3524
  }, ai = ({ editor: e }) => {
3519
- const { editorLanguage: t } = I(), n = t === "zh", r = At(() => {
3520
- const a = e.state, o = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: c, to: s } = a.selection;
3525
+ const { editorLanguage: t } = N(), n = t === "zh", r = At(() => {
3526
+ const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: c } = a.selection;
3521
3527
  let l = 0;
3522
- return c !== s && (l = a.doc.textBetween(c, s, " ", "\0").replace(/\s/g, "").length), { charCount: o, selectionCount: l };
3528
+ return o !== c && (l = a.doc.textBetween(o, c, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: l };
3523
3529
  }, [e.state.doc, e.state.selection]);
3524
3530
  return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
3525
3531
  /* @__PURE__ */ L("span", { children: [
@@ -3546,60 +3552,60 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3546
3552
  "drawing_description",
3547
3553
  "detailed_description"
3548
3554
  ]), ci = ({ editor: e }) => {
3549
- const { editorLanguage: t } = I(), n = H(t), [r, a] = $(!1), [i, o] = $(0);
3555
+ const { editorLanguage: t } = N(), n = H(t), [r, a] = F(!1), [i, s] = F(0);
3550
3556
  M(() => {
3551
- const s = () => o((l) => l + 1);
3552
- return e.on("update", s), () => {
3553
- e.off("update", s);
3557
+ const c = () => s((l) => l + 1);
3558
+ return e.on("update", c), () => {
3559
+ e.off("update", c);
3554
3560
  };
3555
3561
  }, [e]);
3556
- const c = At(() => {
3557
- const s = [];
3562
+ const o = At(() => {
3563
+ const c = [];
3558
3564
  let l = !1;
3559
- return e.state.doc.descendants((d, m) => {
3565
+ return e.state.doc.descendants((d, u) => {
3560
3566
  if (d.type.name === "patent_title") {
3561
3567
  if (!l) {
3562
- const y = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
3563
- s.push({
3568
+ const h = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
3569
+ c.push({
3564
3570
  type: "book-group",
3565
- pos: m,
3566
- title: y,
3571
+ pos: u,
3572
+ title: h,
3567
3573
  charCount: 0
3568
3574
  }), l = !0;
3569
3575
  }
3570
- const u = d.textContent || "", f = u.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
3571
- return s.push({
3576
+ const m = d.textContent || "", f = m.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
3577
+ return c.push({
3572
3578
  type: "section",
3573
- pos: m,
3574
- title: f ? u.trim() : p,
3579
+ pos: u,
3580
+ title: f ? m.trim() : p,
3575
3581
  state: f ? "filled" : "empty",
3576
- charCount: u.replace(/\s/g, "").length,
3582
+ charCount: m.replace(/\s/g, "").length,
3577
3583
  indent: !0
3578
3584
  }), !1;
3579
3585
  }
3580
3586
  if (d.type.name === "patent_section") {
3581
- const u = d.attrs.sectionType, f = oi.has(u), p = `sectionTitle_${u}`, y = typeof n[p] == "string" ? n[p] : u, b = d.textContent || "", w = b.trim().length > 0;
3582
- return s.push({
3587
+ const m = d.attrs.sectionType, f = oi.has(m), p = `sectionTitle_${m}`, h = typeof n[p] == "string" ? n[p] : m, y = d.textContent || "", w = y.trim().length > 0;
3588
+ return c.push({
3583
3589
  type: "section",
3584
- pos: m,
3585
- title: y,
3590
+ pos: u,
3591
+ title: h,
3586
3592
  state: w ? "filled" : "empty",
3587
- charCount: b.replace(/\s/g, "").length,
3593
+ charCount: y.replace(/\s/g, "").length,
3588
3594
  indent: f
3589
3595
  }), !1;
3590
3596
  }
3591
3597
  if (d.type.name === "heading") {
3592
- const u = d.attrs.level, f = d.textContent || "";
3593
- return f.trim() && s.push({
3598
+ const m = d.attrs.level, f = d.textContent || "";
3599
+ return f.trim() && c.push({
3594
3600
  type: "heading",
3595
- pos: m,
3601
+ pos: u,
3596
3602
  title: f,
3597
- level: u,
3603
+ level: m,
3598
3604
  charCount: f.replace(/\s/g, "").length
3599
3605
  }), !1;
3600
3606
  }
3601
3607
  return !0;
3602
- }), s;
3608
+ }), c;
3603
3609
  }, [e, i, n]);
3604
3610
  return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
3605
3611
  "button",
@@ -3611,7 +3617,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3611
3617
  }
3612
3618
  ) }) : /* @__PURE__ */ L("div", { className: "outline-panel", children: [
3613
3619
  /* @__PURE__ */ L("div", { className: "outline-panel-header", children: [
3614
- /* @__PURE__ */ g(qt, { size: 14 }),
3620
+ /* @__PURE__ */ g(Ut, { size: 14 }),
3615
3621
  /* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
3616
3622
  /* @__PURE__ */ g(
3617
3623
  "button",
@@ -3624,29 +3630,29 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3624
3630
  )
3625
3631
  ] }),
3626
3632
  /* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
3627
- c.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
3628
- c.map((s, l) => /* @__PURE__ */ L(
3633
+ o.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
3634
+ o.map((c, l) => /* @__PURE__ */ L(
3629
3635
  "button",
3630
3636
  {
3631
3637
  className: Y(
3632
3638
  "outline-panel-item",
3633
- s.type === "heading" && `outline-panel-item--h${s.level}`,
3634
- s.type === "book-group" && "outline-panel-item--book",
3635
- s.indent && "outline-panel-item--indent"
3639
+ c.type === "heading" && `outline-panel-item--h${c.level}`,
3640
+ c.type === "book-group" && "outline-panel-item--book",
3641
+ c.indent && "outline-panel-item--indent"
3636
3642
  ),
3637
3643
  onClick: () => {
3638
- s.type !== "book-group" && (e.chain().setTextSelection(s.pos + 1).focus().run(), requestAnimationFrame(() => {
3639
- const d = e.view.nodeDOM(s.pos);
3644
+ c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
3645
+ const d = e.view.nodeDOM(c.pos);
3640
3646
  d == null || d.scrollIntoView({ behavior: "smooth", block: "start" });
3641
3647
  }));
3642
3648
  },
3643
3649
  children: [
3644
- s.type === "section" && s.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[s.state]), children: ii[s.state] || "○" }),
3645
- /* @__PURE__ */ g("span", { className: "outline-item-title", children: s.title }),
3646
- s.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: s.charCount })
3650
+ c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[c.state]), children: ii[c.state] || "○" }),
3651
+ /* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
3652
+ c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
3647
3653
  ]
3648
3654
  },
3649
- `${s.pos}-${l}`
3655
+ `${c.pos}-${l}`
3650
3656
  ))
3651
3657
  ] })
3652
3658
  ] });
@@ -3680,10 +3686,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3680
3686
  readOnly: r = !1,
3681
3687
  editable: a = !0,
3682
3688
  onEditorReady: i,
3683
- onSelectionOptimize: o,
3684
- patchEditorId: c = "default"
3689
+ onSelectionOptimize: s,
3690
+ patchEditorId: o = "default"
3685
3691
  }) => {
3686
- const { setEditor: s, setDocument: l, editorLanguage: d, autoSaveStatus: m, ai: u } = I(), { setAutoSaveStatus: f, setLastSavedAt: p } = I(), y = W(null), b = e || (t ? null : ui()) || {
3692
+ const { setEditor: c, setDocument: l, editorLanguage: d, autoSaveStatus: u, ai: m } = N(), { setAutoSaveStatus: f, setLastSavedAt: p } = N(), h = W(null), y = e || (t ? null : ui()) || {
3687
3693
  type: "doc",
3688
3694
  content: [
3689
3695
  {
@@ -3691,27 +3697,27 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3691
3697
  content: [{ type: "text", text: "" }]
3692
3698
  }
3693
3699
  ]
3694
- }, w = ae((h) => {
3700
+ }, w = ae((_) => {
3695
3701
  try {
3696
- f("saving"), localStorage.setItem(cn, JSON.stringify(h)), f("saved"), p(/* @__PURE__ */ new Date());
3702
+ f("saving"), localStorage.setItem(cn, JSON.stringify(_)), f("saved"), p(/* @__PURE__ */ new Date());
3697
3703
  } catch {
3698
3704
  f("error");
3699
3705
  }
3700
3706
  }, [f, p]), x = Nn(
3701
3707
  Ka({
3702
- extensions: [fa.configure({ editorId: c })],
3703
- content: b,
3704
- onUpdate: ({ editor: h }) => {
3705
- const _ = h.getJSON();
3706
- l(_), B.notifyStateChange(h), t && t(_), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3707
- w(_);
3708
+ extensions: [fa.configure({ editorId: o })],
3709
+ content: y,
3710
+ onUpdate: ({ editor: _ }) => {
3711
+ const b = _.getJSON();
3712
+ l(b), B.notifyStateChange(_), t && t(b), t || (h.current && clearTimeout(h.current), h.current = setTimeout(() => {
3713
+ w(b);
3708
3714
  }, di));
3709
3715
  },
3710
- onCreate: ({ editor: h }) => {
3711
- s(h), i == null || i(h), B.initializePlugins(h), B.notifyStateChange(h);
3716
+ onCreate: ({ editor: _ }) => {
3717
+ c(_), i == null || i(_), B.initializePlugins(_), B.notifyStateChange(_);
3712
3718
  },
3713
- onSelectionUpdate: ({ editor: h }) => {
3714
- B.notifySelectionChange(h);
3719
+ onSelectionUpdate: ({ editor: _ }) => {
3720
+ B.notifySelectionChange(_);
3715
3721
  },
3716
3722
  editorProps: {
3717
3723
  attributes: {
@@ -3719,29 +3725,29 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3719
3725
  }
3720
3726
  }
3721
3727
  })
3722
- ), C = W(!1);
3728
+ ), T = W(!1);
3723
3729
  if (M(() => {
3724
3730
  if (!(!x || !e)) {
3725
- if (!C.current) {
3726
- C.current = !0;
3731
+ if (!T.current) {
3732
+ T.current = !0;
3727
3733
  return;
3728
3734
  }
3729
3735
  x.commands.setContent(e);
3730
3736
  }
3731
3737
  }, [x, e]), M(() => () => {
3732
- y.current && clearTimeout(y.current), x && (B.destroyPlugins(x), x.destroy());
3738
+ h.current && clearTimeout(h.current), x && (B.destroyPlugins(x), x.destroy());
3733
3739
  }, [x]), M(() => {
3734
3740
  x && B.notifyStateChange(x);
3735
3741
  }, [x, d]), !x)
3736
3742
  return null;
3737
- const v = H(d), E = m === "saving" ? v.autoSaveSaving : m === "saved" ? v.autoSaveSaved : m === "error" ? v.autoSaveError : "";
3743
+ const v = H(d), E = u === "saving" ? v.autoSaveSaving : u === "saved" ? v.autoSaveSaved : u === "error" ? v.autoSaveError : "";
3738
3744
  return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3739
3745
  !r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
3740
3746
  /* @__PURE__ */ g(Za, { editor: x }),
3741
- E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: E })
3747
+ E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${u} ml-2`, children: E })
3742
3748
  ] }),
3743
3749
  !r && x && /* @__PURE__ */ g(Qa, { editor: x }),
3744
- !r && x && /* @__PURE__ */ g(ni, { editor: x, onSelectionOptimize: o }),
3750
+ !r && x && /* @__PURE__ */ g(ni, { editor: x, onSelectionOptimize: s }),
3745
3751
  !r && x && /* @__PURE__ */ g(ri, { editor: x }),
3746
3752
  /* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
3747
3753
  !r && x && /* @__PURE__ */ g(ci, { editor: x }),
@@ -3749,7 +3755,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3749
3755
  li,
3750
3756
  {
3751
3757
  editor: x,
3752
- mode: r || !a || u.status === "streaming" && u.activeSectionType === "claims" ? "readonly" : "edit"
3758
+ mode: r || !a || m.status === "streaming" && m.activeSectionType === "claims" ? "readonly" : "edit"
3753
3759
  }
3754
3760
  ) })
3755
3761
  ] }),
@@ -3763,40 +3769,40 @@ function ln(e) {
3763
3769
  async pull(a) {
3764
3770
  var i;
3765
3771
  for (; ; ) {
3766
- const { done: o, value: c } = await t.read();
3767
- if (o) {
3772
+ const { done: s, value: o } = await t.read();
3773
+ if (s) {
3768
3774
  a.close();
3769
3775
  return;
3770
3776
  }
3771
- r += n.decode(c, { stream: !0 });
3772
- const s = r.split(`
3777
+ r += n.decode(o, { stream: !0 });
3778
+ const c = r.split(`
3773
3779
  `);
3774
- r = s.pop() || "";
3780
+ r = c.pop() || "";
3775
3781
  let l = "";
3776
- for (const d of s) {
3782
+ for (const d of c) {
3777
3783
  if (d.startsWith("event: ")) {
3778
3784
  l = d.slice(7).trim();
3779
3785
  continue;
3780
3786
  }
3781
3787
  if (!d.startsWith("data: ")) continue;
3782
- const m = d.slice(6).trim();
3783
- if (m === "[DONE]") {
3788
+ const u = d.slice(6).trim();
3789
+ if (u === "[DONE]") {
3784
3790
  a.enqueue({ type: "done" }), a.close();
3785
3791
  return;
3786
3792
  }
3787
3793
  try {
3788
- const u = JSON.parse(m), f = l || u.type;
3789
- if (f === "delta" || !f && u.content != null)
3794
+ const m = JSON.parse(u), f = l || m.type;
3795
+ if (f === "delta" || !f && m.content != null)
3790
3796
  a.enqueue({
3791
3797
  type: "delta",
3792
- content: u.content ?? u.text ?? ((i = u.delta) == null ? void 0 : i.content) ?? ""
3798
+ content: m.content ?? m.text ?? ((i = m.delta) == null ? void 0 : i.content) ?? ""
3793
3799
  });
3794
3800
  else if (f === "patch")
3795
- a.enqueue({ type: "patch", patch: u });
3801
+ a.enqueue({ type: "patch", patch: m });
3796
3802
  else if (f === "done") {
3797
- a.enqueue({ type: "done", usage: u.usage }), a.close();
3803
+ a.enqueue({ type: "done", usage: m.usage }), a.close();
3798
3804
  return;
3799
- } else f === "error" && a.enqueue({ type: "error", message: u.message || "Unknown error" });
3805
+ } else f === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
3800
3806
  } catch {
3801
3807
  }
3802
3808
  l = "";
@@ -3833,29 +3839,29 @@ function gi(e, t) {
3833
3839
  function fi(e, t) {
3834
3840
  let n = null;
3835
3841
  const r = e.replace(/\/+$/, "");
3836
- async function a(i, o) {
3837
- const c = await fetch(i, {
3838
- ...o,
3839
- headers: { "Content-Type": "application/json", ...t, ...o == null ? void 0 : o.headers }
3842
+ async function a(i, s) {
3843
+ const o = await fetch(i, {
3844
+ ...s,
3845
+ headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
3840
3846
  });
3841
- if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
3842
- const s = await c.json();
3843
- return s.data ?? s;
3847
+ if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
3848
+ const c = await o.json();
3849
+ return c.data ?? c;
3844
3850
  }
3845
3851
  return {
3846
- async createSession(i, o, c) {
3852
+ async createSession(i, s, o) {
3847
3853
  return a(`${r}/api/v1/chat/sessions`, {
3848
3854
  method: "POST",
3849
- body: JSON.stringify({ patentId: i, title: o, language: c })
3855
+ body: JSON.stringify({ patentId: i, title: s, language: o })
3850
3856
  });
3851
3857
  },
3852
- async listSessions(i, o = 1, c = 20) {
3853
- const s = new URLSearchParams({ page: String(o), pageSize: String(c) });
3854
- return i && s.set("patentId", i), a(`${r}/api/v1/chat/sessions?${s}`);
3858
+ async listSessions(i, s = 1, o = 20) {
3859
+ const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
3860
+ return i && c.set("patentId", i), a(`${r}/api/v1/chat/sessions?${c}`);
3855
3861
  },
3856
- async getMessages(i, o = 1, c = 50) {
3857
- const s = new URLSearchParams({ page: String(o), pageSize: String(c) });
3858
- return a(`${r}/api/v1/chat/sessions/${i}/messages?${s}`);
3862
+ async getMessages(i, s = 1, o = 50) {
3863
+ const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
3864
+ return a(`${r}/api/v1/chat/sessions/${i}/messages?${c}`);
3859
3865
  },
3860
3866
  async deleteSession(i) {
3861
3867
  await fetch(`${r}/api/v1/chat/sessions/${i}`, {
@@ -3863,21 +3869,21 @@ function fi(e, t) {
3863
3869
  headers: { ...t }
3864
3870
  });
3865
3871
  },
3866
- async sendMessage(i, o) {
3872
+ async sendMessage(i, s) {
3867
3873
  return a(`${r}/api/v1/chat/sessions/${i}/messages`, {
3868
3874
  method: "POST",
3869
- body: JSON.stringify(o)
3875
+ body: JSON.stringify(s)
3870
3876
  });
3871
3877
  },
3872
- async subscribeStream(i, o) {
3878
+ async subscribeStream(i, s) {
3873
3879
  n = new AbortController();
3874
- const c = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${o}`, s = await fetch(c, {
3880
+ const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, c = await fetch(o, {
3875
3881
  headers: { Accept: "text/event-stream", ...t },
3876
3882
  signal: n.signal
3877
3883
  });
3878
- if (!s.ok) throw new Error(`Chat stream error: ${s.status} ${s.statusText}`);
3879
- if (!s.body) throw new Error("Chat stream returned no body");
3880
- return ln(s.body);
3884
+ if (!c.ok) throw new Error(`Chat stream error: ${c.status} ${c.statusText}`);
3885
+ if (!c.body) throw new Error("Chat stream returned no body");
3886
+ return ln(c.body);
3881
3887
  },
3882
3888
  abort() {
3883
3889
  n == null || n.abort(), n = null;
@@ -3885,20 +3891,20 @@ function fi(e, t) {
3885
3891
  };
3886
3892
  }
3887
3893
  const pi = It(
3888
- ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: o, aiService: c, chatSessionAPI: s, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: m, patchEditorId: u }, f) => {
3889
- const { setEditorLanguage: p, setAIService: y, setChatSessionAPI: b } = I(), w = W(null), x = ae((v) => {
3894
+ ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m }, f) => {
3895
+ const { setEditorLanguage: p, setAIService: h, setChatSessionAPI: y } = N(), w = W(null), x = ae((v) => {
3890
3896
  w.current = v;
3891
- }, []), C = Ee.useMemo(() => {
3897
+ }, []), T = Ee.useMemo(() => {
3892
3898
  if (e) return e;
3893
3899
  if (t) return tn(t);
3894
3900
  }, [e, t]);
3895
3901
  return Ee.useEffect(() => {
3896
- o && p(o);
3897
- }, [o, p]), Ee.useEffect(() => {
3898
- c ? y(c) : l && y(gi(l, d));
3899
- }, [c, l, d, y]), Ee.useEffect(() => {
3900
- s ? b(s) : l && b(fi(l, d));
3901
- }, [s, l, d, b]), Nt(f, () => ({
3902
+ s && p(s);
3903
+ }, [s, p]), Ee.useEffect(() => {
3904
+ o ? h(o) : l && h(gi(l, d));
3905
+ }, [o, l, d, h]), Ee.useEffect(() => {
3906
+ c ? y(c) : l && y(fi(l, d));
3907
+ }, [c, l, d, y]), Nt(f, () => ({
3902
3908
  getContent: () => {
3903
3909
  var v;
3904
3910
  return ((v = w.current) == null ? void 0 : v.getJSON()) ?? null;
@@ -3916,40 +3922,40 @@ const pi = It(
3916
3922
  })), /* @__PURE__ */ g(
3917
3923
  mi,
3918
3924
  {
3919
- initialContent: C,
3925
+ initialContent: T,
3920
3926
  onChange: n,
3921
3927
  onEditorReady: x,
3922
3928
  className: r,
3923
3929
  readOnly: a,
3924
3930
  editable: i,
3925
- onSelectionOptimize: m,
3926
- patchEditorId: u
3931
+ onSelectionOptimize: u,
3932
+ patchEditorId: m
3927
3933
  }
3928
3934
  );
3929
3935
  }
3930
3936
  );
3931
3937
  pi.displayName = "PatentEditor";
3932
3938
  async function Ws(e, t, n) {
3933
- var a, i, o, c;
3939
+ var a, i, s, o;
3934
3940
  let r = !1;
3935
3941
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
3936
3942
  try {
3937
- let s = dn(e, n);
3943
+ let c = dn(e, n);
3938
3944
  for (; ; ) {
3939
3945
  const { done: l, value: d } = await t.read();
3940
3946
  if (l) break;
3941
3947
  if (!d) continue;
3942
3948
  (i = n.onChunk) == null || i.call(n, d);
3943
- const m = e.state.tr.insertText(d, s);
3944
- e.view.dispatch(m), s = m.mapping.map(s, 1);
3949
+ const u = e.state.tr.insertText(d, c);
3950
+ e.view.dispatch(u), c = u.mapping.map(c, 1);
3945
3951
  }
3946
- n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (o = n.onComplete) == null || o.call(n);
3947
- } catch (s) {
3948
- (c = n.onError) == null || c.call(n, s instanceof Error ? s : new Error(String(s)));
3952
+ n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
3953
+ } catch (c) {
3954
+ (o = n.onError) == null || o.call(n, c instanceof Error ? c : new Error(String(c)));
3949
3955
  }
3950
3956
  }
3951
3957
  async function js(e, t, n, r) {
3952
- var i, o, c, s, l, d, m, u;
3958
+ var i, s, o, c, l, d, u, m;
3953
3959
  const a = new AbortController();
3954
3960
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
3955
3961
  try {
@@ -3961,35 +3967,35 @@ async function js(e, t, n, r) {
3961
3967
  });
3962
3968
  if (!f.ok)
3963
3969
  throw new Error(`HTTP ${f.status}: ${f.statusText}`);
3964
- const p = (o = f.body) == null ? void 0 : o.getReader();
3970
+ const p = (s = f.body) == null ? void 0 : s.getReader();
3965
3971
  if (!p) throw new Error("No response body");
3966
- const y = new TextDecoder();
3967
- let b = dn(e, r), w = "";
3972
+ const h = new TextDecoder();
3973
+ let y = dn(e, r), w = "";
3968
3974
  for (; ; ) {
3969
- const { done: x, value: C } = await p.read();
3975
+ const { done: x, value: T } = await p.read();
3970
3976
  if (x) break;
3971
- w += y.decode(C, { stream: !0 });
3977
+ w += h.decode(T, { stream: !0 });
3972
3978
  const v = w.split(`
3973
3979
  `);
3974
3980
  w = v.pop() || "";
3975
3981
  for (const E of v) {
3976
3982
  if (!E.startsWith("data: ")) continue;
3977
- const h = E.slice(6).trim();
3978
- if (h === "[DONE]")
3979
- return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
3983
+ const _ = E.slice(6).trim();
3984
+ if (_ === "[DONE]")
3985
+ return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
3980
3986
  try {
3981
- const _ = JSON.parse(h), T = _.content || _.text || ((s = _.delta) == null ? void 0 : s.content) || "";
3982
- if (!T) continue;
3983
- (l = r.onChunk) == null || l.call(r, T);
3984
- const N = e.state.tr.insertText(T, b);
3985
- e.view.dispatch(N), b = N.mapping.map(b, 1);
3987
+ const b = JSON.parse(_), C = b.content || b.text || ((c = b.delta) == null ? void 0 : c.content) || "";
3988
+ if (!C) continue;
3989
+ (l = r.onChunk) == null || l.call(r, C);
3990
+ const I = e.state.tr.insertText(C, y);
3991
+ e.view.dispatch(I), y = I.mapping.map(y, 1);
3986
3992
  } catch {
3987
3993
  }
3988
3994
  }
3989
3995
  }
3990
3996
  r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
3991
3997
  } catch (f) {
3992
- f.name === "AbortError" ? (m = r.onAbort) == null || m.call(r) : (u = r.onError) == null || u.call(r, f instanceof Error ? f : new Error(String(f)));
3998
+ f.name === "AbortError" ? (u = r.onAbort) == null || u.call(r) : (m = r.onError) == null || m.call(r, f instanceof Error ? f : new Error(String(f)));
3993
3999
  }
3994
4000
  return { abort: () => a.abort() };
3995
4001
  }
@@ -4006,27 +4012,27 @@ function un(e, t) {
4006
4012
  if (!n || n.type.name !== "patent_section") return;
4007
4013
  const r = t + 1, a = t + n.nodeSize - 1;
4008
4014
  if (a > r + 2) {
4009
- const i = e.state.tr, o = e.state.schema.nodes.paragraph.create();
4010
- i.replaceWith(r, a, o), i.setMeta("addToHistory", !1), e.view.dispatch(i);
4015
+ const i = e.state.tr, s = e.state.schema.nodes.paragraph.create();
4016
+ i.replaceWith(r, a, s), i.setMeta("addToHistory", !1), e.view.dispatch(i);
4011
4017
  }
4012
4018
  }
4013
4019
  function nt(e, t) {
4014
4020
  const n = e.state.doc.nodeAt(t);
4015
4021
  if (!n || n.type.name !== "patent_section") return;
4016
4022
  const r = e.state.tr, a = [];
4017
- let i = t + 1, o = 0;
4018
- n.forEach((s) => {
4019
- o++;
4023
+ let i = t + 1, s = 0;
4024
+ n.forEach((c) => {
4025
+ s++;
4020
4026
  });
4021
- let c = 0;
4022
- if (n.forEach((s) => {
4023
- s.type.name === "paragraph" && s.textContent.trim().length > 0 && c++;
4024
- }), i = t + 1, n.forEach((s) => {
4025
- const l = i, d = i + s.nodeSize;
4026
- s.type.name === "paragraph" && s.textContent.trim().length === 0 && (c > 0 || a.length < o - 1) && a.push({ from: l, to: d }), i = d;
4027
+ let o = 0;
4028
+ if (n.forEach((c) => {
4029
+ c.type.name === "paragraph" && c.textContent.trim().length > 0 && o++;
4030
+ }), i = t + 1, n.forEach((c) => {
4031
+ const l = i, d = i + c.nodeSize;
4032
+ c.type.name === "paragraph" && c.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: l, to: d }), i = d;
4027
4033
  }), a.length !== 0) {
4028
- for (let s = a.length - 1; s >= 0; s--)
4029
- r.delete(a[s].from, a[s].to);
4034
+ for (let c = a.length - 1; c >= 0; c--)
4035
+ r.delete(a[c].from, a[c].to);
4030
4036
  r.setMeta("addToHistory", !1), e.view.dispatch(r);
4031
4037
  }
4032
4038
  }
@@ -4194,31 +4200,31 @@ function yi(e, t, n) {
4194
4200
  const r = n === "zh", a = [];
4195
4201
  let i;
4196
4202
  if (e.includes("技术方案") || e.includes("draft") ? i = Pe["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Pe.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Pe.claims[r ? "zh" : "en"] : i = Pe.default[r ? "zh" : "en"], t.length > 0) {
4197
- const o = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
4203
+ const s = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
4198
4204
 
4199
4205
  ` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
4200
4206
 
4201
4207
  `;
4202
- for (const c of $e(o, 4))
4203
- a.push({ type: "delta", content: c });
4204
- for (const c of $e(i, 4))
4205
- a.push({ type: "delta", content: c });
4206
- for (let c = 0; c < t.length; c++) {
4207
- const s = t[c], l = s.text;
4208
+ for (const o of $e(s, 4))
4209
+ a.push({ type: "delta", content: o });
4210
+ for (const o of $e(i, 4))
4211
+ a.push({ type: "delta", content: o });
4212
+ for (let o = 0; o < t.length; o++) {
4213
+ const c = t[o], l = c.text;
4208
4214
  let d;
4209
- r ? (d = l.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === l && (d = `根据本发明优选实施例,${l}`)) : d = `According to a preferred embodiment, ${l.charAt(0).toLowerCase()}${l.slice(1)}`, s.from != null && s.to != null ? a.push({
4215
+ r ? (d = l.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === l && (d = `根据本发明优选实施例,${l}`)) : d = `According to a preferred embodiment, ${l.charAt(0).toLowerCase()}${l.slice(1)}`, c.from != null && c.to != null ? a.push({
4210
4216
  type: "patch",
4211
4217
  patch: {
4212
4218
  op: "replace",
4213
- target: { type: "ref", refIndex: c },
4219
+ target: { type: "ref", refIndex: o },
4214
4220
  content: d,
4215
4221
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4216
4222
  }
4217
- }) : s.source ? a.push({
4223
+ }) : c.source ? a.push({
4218
4224
  type: "patch",
4219
4225
  patch: {
4220
4226
  op: "replace",
4221
- target: { type: "section", sectionType: s.source },
4227
+ target: { type: "section", sectionType: c.source },
4222
4228
  search: l,
4223
4229
  content: d,
4224
4230
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
@@ -4234,26 +4240,26 @@ function yi(e, t, n) {
4234
4240
  });
4235
4241
  }
4236
4242
  } else
4237
- for (const o of $e(i, 4))
4238
- a.push({ type: "delta", content: o });
4243
+ for (const s of $e(i, 4))
4244
+ a.push({ type: "delta", content: s });
4239
4245
  return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
4240
4246
  }
4241
4247
  function Gs() {
4242
4248
  let e = null;
4243
4249
  return {
4244
4250
  async request(t) {
4245
- var c;
4251
+ var o;
4246
4252
  if (e = new AbortController(), await te(300), e.signal.aborted)
4247
4253
  throw new DOMException("Aborted", "AbortError");
4248
- const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((c = Tt[r]) == null ? void 0 : c[n]) || Tt.technical_field[n];
4254
+ const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((o = Tt[r]) == null ? void 0 : o[n]) || Tt.technical_field[n];
4249
4255
  let i = a;
4250
4256
  t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
4251
4257
 
4252
4258
  ` : `[Generated based on instruction "${t.instruction}"]
4253
4259
 
4254
4260
  `) + a);
4255
- const o = hi(i);
4256
- return rt(o, 25);
4261
+ const s = hi(i);
4262
+ return rt(s, 25);
4257
4263
  },
4258
4264
  abort() {
4259
4265
  e == null || e.abort(), e = null;
@@ -4266,15 +4272,15 @@ function Vs() {
4266
4272
  return {
4267
4273
  async createSession(r, a, i) {
4268
4274
  await te(100);
4269
- const o = `sess_${Date.now()}`, c = {
4270
- sessionId: o,
4275
+ const s = `sess_${Date.now()}`, o = {
4276
+ sessionId: s,
4271
4277
  patentId: r || void 0,
4272
4278
  title: a || (i === "zh" ? "新对话" : "New Chat"),
4273
4279
  messageCount: 0,
4274
4280
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4275
4281
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4276
4282
  };
4277
- return e.set(o, { session: c, messages: [] }), c;
4283
+ return e.set(s, { session: o, messages: [] }), o;
4278
4284
  },
4279
4285
  async listSessions() {
4280
4286
  await te(50);
@@ -4294,21 +4300,21 @@ function Vs() {
4294
4300
  await te(150);
4295
4301
  const i = e.get(r);
4296
4302
  if (!i) throw new Error("Session not found");
4297
- const o = `msg_${Date.now()}`;
4303
+ const s = `msg_${Date.now()}`;
4298
4304
  i.messages.push({
4299
- messageId: o,
4305
+ messageId: s,
4300
4306
  role: "user",
4301
4307
  content: a.content,
4302
4308
  references: a.references,
4303
4309
  status: "done",
4304
4310
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4305
4311
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4306
- const c = yi(
4312
+ const o = yi(
4307
4313
  a.content,
4308
4314
  a.references || [],
4309
4315
  a.language
4310
4316
  );
4311
- return n = { messageId: o, events: c }, { messageId: o, sessionId: r, status: "processing" };
4317
+ return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
4312
4318
  },
4313
4319
  async subscribeStream(r, a) {
4314
4320
  t = new AbortController(), await te(100);
@@ -4316,19 +4322,19 @@ function Vs() {
4316
4322
  if (!i) throw new Error("Session not found");
4317
4323
  if (!n || n.messageId !== a)
4318
4324
  return rt([{ type: "done" }]);
4319
- const o = n.events;
4325
+ const s = n.events;
4320
4326
  n = null;
4321
- const c = rt(o, 18), s = `${a}_a`;
4327
+ const o = rt(s, 18), c = `${a}_a`;
4322
4328
  let l = "";
4323
- for (const d of o)
4329
+ for (const d of s)
4324
4330
  d.type === "delta" && (l += d.content);
4325
4331
  return i.messages.push({
4326
- messageId: s,
4332
+ messageId: c,
4327
4333
  role: "assistant",
4328
4334
  content: l,
4329
4335
  status: "done",
4330
4336
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4331
- }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
4337
+ }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
4332
4338
  },
4333
4339
  abort() {
4334
4340
  t == null || t.abort(), t = null;
@@ -4349,9 +4355,9 @@ function bi(e) {
4349
4355
  });
4350
4356
  if (a.length === 0)
4351
4357
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4352
- for (let o = 0; o < a.length; o++) {
4353
- const c = a[o].index + a[o].matchLength, s = o + 1 < a.length ? a[o + 1].index : n.length, l = n.slice(c, s).trim(), d = a[o].number, m = vi(l, d);
4354
- t.push({ number: d, text: l, dependsOn: m });
4358
+ for (let s = 0; s < a.length; s++) {
4359
+ const o = a[s].index + a[s].matchLength, c = s + 1 < a.length ? a[s + 1].index : n.length, l = n.slice(o, c).trim(), d = a[s].number, u = vi(l, d);
4360
+ t.push({ number: d, text: l, dependsOn: u });
4355
4361
  }
4356
4362
  return t;
4357
4363
  }
@@ -4359,17 +4365,17 @@ function vi(e, t) {
4359
4365
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4360
4366
  let a;
4361
4367
  for (; (a = r.exec(e)) !== null; ) {
4362
- const o = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : o;
4363
- for (let s = o; s <= c; s++)
4364
- s !== t && s > 0 && n.push(s);
4368
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4369
+ for (let c = s; c <= o; c++)
4370
+ c !== t && c > 0 && n.push(c);
4365
4371
  }
4366
4372
  const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4367
4373
  for (; (a = i.exec(e)) !== null; ) {
4368
- const o = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : o;
4369
- for (let s = o; s <= c; s++)
4370
- s !== t && s > 0 && n.push(s);
4374
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4375
+ for (let c = s; c <= o; c++)
4376
+ c !== t && c > 0 && n.push(c);
4371
4377
  }
4372
- return [...new Set(n)].sort((o, c) => o - c);
4378
+ return [...new Set(n)].sort((s, o) => s - o);
4373
4379
  }
4374
4380
  function Js(e) {
4375
4381
  return bi(e).map((n) => ({
@@ -4386,64 +4392,64 @@ function Si(e, t, n) {
4386
4392
  const r = [];
4387
4393
  return e.nodesBetween(t, n, (a, i) => {
4388
4394
  if (a.isTextblock) {
4389
- const o = i + 1, c = i + a.nodeSize - 1, s = Math.max(o, t), l = Math.min(c, n);
4390
- return l > s && r.push({ from: s, to: l }), !1;
4395
+ const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
4396
+ return l > c && r.push({ from: c, to: l }), !1;
4391
4397
  }
4392
4398
  return !0;
4393
4399
  }), r;
4394
4400
  }
4395
4401
  function Ks(e, t) {
4396
- const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), o = Ti(), c = o.diff_main(t, a);
4397
- o.diff_cleanupSemantic(c);
4398
- const s = [];
4402
+ const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ti(), o = s.diff_main(t, a);
4403
+ s.diff_cleanupSemantic(o);
4404
+ const c = [];
4399
4405
  let l = 0;
4400
- for (const [u, f] of c)
4401
- if (u === Ci)
4406
+ for (const [m, f] of o)
4407
+ if (m === Ci)
4402
4408
  l += f.length;
4403
- else if (u === xi) {
4409
+ else if (m === xi) {
4404
4410
  let p = 0;
4405
4411
  for (; p < f.length; ) {
4406
4412
  for (; p < f.length && f[p] === "\0"; ) p++;
4407
4413
  if (p >= f.length) break;
4408
- const y = p;
4414
+ const h = p;
4409
4415
  for (; p < f.length && f[p] !== "\0"; ) p++;
4410
- const b = ye(i, l + y), w = ye(i, l + p);
4411
- if (b >= 0 && w >= 0 && w > b)
4412
- for (const x of Si(n, b, w))
4413
- s.push(
4416
+ const y = ye(i, l + h), w = ye(i, l + p);
4417
+ if (y >= 0 && w >= 0 && w > y)
4418
+ for (const x of Si(n, y, w))
4419
+ c.push(
4414
4420
  re.inline(x.from, x.to, { class: "patch-diff-insert-inline" })
4415
4421
  );
4416
4422
  }
4417
4423
  l += f.length;
4418
- } else if (u === wi) {
4424
+ } else if (m === wi) {
4419
4425
  const p = ye(i, l);
4420
4426
  if (p >= 0) {
4421
- const y = f.replace(/\0/g, " ");
4422
- s.push(
4427
+ const h = f.replace(/\0/g, " ");
4428
+ c.push(
4423
4429
  re.widget(
4424
4430
  p,
4425
4431
  () => {
4426
- const b = document.createElement("span");
4427
- return b.className = "patch-diff-delete", b.textContent = y, b;
4432
+ const y = document.createElement("span");
4433
+ return y.className = "patch-diff-delete", y.textContent = h, y;
4428
4434
  },
4429
4435
  { side: -1 }
4430
4436
  )
4431
4437
  );
4432
4438
  }
4433
4439
  }
4434
- const d = be.create(n, s), m = new Be({
4440
+ const d = be.create(n, c), u = new Be({
4435
4441
  key: at,
4436
4442
  state: {
4437
4443
  init: () => d,
4438
- apply: (u, f) => u.docChanged ? f.map(u.mapping, u.doc) : f
4444
+ apply: (m, f) => m.docChanged ? f.map(m.mapping, m.doc) : f
4439
4445
  },
4440
4446
  props: {
4441
- decorations(u) {
4442
- return at.getState(u);
4447
+ decorations(m) {
4448
+ return at.getState(m);
4443
4449
  }
4444
4450
  }
4445
4451
  });
4446
- e.registerPlugin(m);
4452
+ e.registerPlugin(u);
4447
4453
  }
4448
4454
  function Xs(e) {
4449
4455
  e.unregisterPlugin(at);
@@ -4473,39 +4479,39 @@ function _i(e, t) {
4473
4479
  }), !1;
4474
4480
  }
4475
4481
  if (a.type.name === "patent_section") {
4476
- const i = a.attrs.sectionType, o = `sectionTitle_${i}`, c = typeof n[o] == "string" ? n[o] : i, s = [];
4482
+ const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, c = [];
4477
4483
  return a.forEach((l) => {
4478
4484
  const d = l.textContent.trim();
4479
- d && s.push(d);
4480
- }), r.push({ type: "patent_section", sectionType: i, title: c, paragraphs: s }), !1;
4485
+ d && c.push(d);
4486
+ }), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: c }), !1;
4481
4487
  }
4482
4488
  return !0;
4483
4489
  }), r;
4484
4490
  }
4485
4491
  function St(e) {
4486
4492
  return new He({
4487
- children: [new qe({ text: e, bold: !0, size: 32, font: "黑体" })],
4493
+ children: [new Ue({ text: e, bold: !0, size: 32, font: "黑体" })],
4488
4494
  alignment: it.CENTER,
4489
4495
  spacing: { before: 400, after: 200 }
4490
4496
  });
4491
4497
  }
4492
4498
  function Et(e) {
4493
4499
  return new He({
4494
- children: [new qe({ text: e, bold: !0, size: 28, font: "黑体" })],
4500
+ children: [new Ue({ text: e, bold: !0, size: 28, font: "黑体" })],
4495
4501
  alignment: it.CENTER,
4496
4502
  spacing: { before: 240, after: 120 }
4497
4503
  });
4498
4504
  }
4499
4505
  function Ii(e) {
4500
4506
  return new He({
4501
- children: [new qe({ text: e, bold: !0, size: 36, font: "宋体" })],
4507
+ children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
4502
4508
  alignment: it.CENTER,
4503
4509
  spacing: { before: 200, after: 200 }
4504
4510
  });
4505
4511
  }
4506
4512
  function Ze(e) {
4507
4513
  return new He({
4508
- children: [new qe({ text: e, size: 24, font: "宋体" })],
4514
+ children: [new Ue({ text: e, size: 24, font: "宋体" })],
4509
4515
  spacing: { line: 360 },
4510
4516
  indent: { firstLine: he(7) }
4511
4517
  });
@@ -4516,33 +4522,33 @@ function Ni(e, t) {
4516
4522
  for (const i of e) {
4517
4523
  if (Ei.has(i.sectionType)) {
4518
4524
  r.push(St(i.title));
4519
- for (const o of i.paragraphs)
4520
- r.push(Ze(o));
4525
+ for (const s of i.paragraphs)
4526
+ r.push(Ze(s));
4521
4527
  continue;
4522
4528
  }
4523
4529
  if (i.type === "patent_title") {
4524
4530
  if (!a) {
4525
- const o = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
4526
- r.push(St(o)), a = !0;
4531
+ const s = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
4532
+ r.push(St(s)), a = !0;
4527
4533
  }
4528
- for (const o of i.paragraphs)
4529
- r.push(Ii(o));
4534
+ for (const s of i.paragraphs)
4535
+ r.push(Ii(s));
4530
4536
  continue;
4531
4537
  }
4532
4538
  if (ki.has(i.sectionType)) {
4533
4539
  r.push(Et(i.title));
4534
- for (const o of i.paragraphs)
4535
- r.push(Ze(o));
4540
+ for (const s of i.paragraphs)
4541
+ r.push(Ze(s));
4536
4542
  continue;
4537
4543
  }
4538
4544
  r.push(Et(i.title));
4539
- for (const o of i.paragraphs)
4540
- r.push(Ze(o));
4545
+ for (const s of i.paragraphs)
4546
+ r.push(Ze(s));
4541
4547
  }
4542
4548
  return r;
4543
4549
  }
4544
4550
  async function Ys(e, t) {
4545
- const n = _i(e, t), r = Ni(n, t), a = n.find((l) => l.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", o = {
4551
+ const n = _i(e, t), r = Ni(n, t), a = n.find((l) => l.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4546
4552
  properties: {
4547
4553
  page: {
4548
4554
  margin: {
@@ -4554,10 +4560,10 @@ async function Ys(e, t) {
4554
4560
  }
4555
4561
  },
4556
4562
  children: r
4557
- }, c = new Kr({
4558
- sections: [o]
4559
- }), s = await Xr.toBlob(c);
4560
- Yr(s, i);
4563
+ }, o = new Kr({
4564
+ sections: [s]
4565
+ }), c = await Xr.toBlob(o);
4566
+ Yr(c, i);
4561
4567
  }
4562
4568
  async function Zs(e) {
4563
4569
  window.print();
@@ -4566,65 +4572,65 @@ function Qs(e, t) {
4566
4572
  const n = [], r = t === "zh";
4567
4573
  let a = 0;
4568
4574
  const i = () => `v_${++a}`;
4569
- return e.state.doc.descendants((o, c) => {
4570
- if (o.type.name === "patent_title") {
4571
- const s = o.textContent.trim();
4572
- if (s.length === 0)
4575
+ return e.state.doc.descendants((s, o) => {
4576
+ if (s.type.name === "patent_title") {
4577
+ const c = s.textContent.trim();
4578
+ if (c.length === 0)
4573
4579
  n.push({
4574
4580
  id: i(),
4575
4581
  severity: "warning",
4576
4582
  message: r ? "专利名称为空" : "Patent title is empty",
4577
4583
  sectionType: "patent_title",
4578
- pos: c
4584
+ pos: o
4579
4585
  });
4580
4586
  else {
4581
- const l = s.replace(/\s/g, "").length;
4587
+ const l = c.replace(/\s/g, "").length;
4582
4588
  l > 25 && r && n.push({
4583
4589
  id: i(),
4584
4590
  severity: "error",
4585
4591
  message: `专利名称超过25个汉字(当前${l}字)`,
4586
4592
  sectionType: "patent_title",
4587
- pos: c
4593
+ pos: o
4588
4594
  });
4589
4595
  }
4590
4596
  return !1;
4591
4597
  }
4592
- if (o.type.name === "patent_section") {
4593
- const s = o.attrs.sectionType, l = o.textContent.trim();
4598
+ if (s.type.name === "patent_section") {
4599
+ const c = s.attrs.sectionType, l = s.textContent.trim();
4594
4600
  if (l.length === 0 && n.push({
4595
4601
  id: i(),
4596
4602
  severity: "warning",
4597
- message: r ? `章节"${s}"内容为空` : `Section "${s}" is empty`,
4598
- sectionType: s,
4599
- pos: c
4600
- }), s === "abstract") {
4603
+ message: r ? `章节"${c}"内容为空` : `Section "${c}" is empty`,
4604
+ sectionType: c,
4605
+ pos: o
4606
+ }), c === "abstract") {
4601
4607
  const d = l.replace(/\s/g, "").length;
4602
4608
  d > 0 && d < 50 && n.push({
4603
4609
  id: i(),
4604
4610
  severity: "warning",
4605
4611
  message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
4606
- sectionType: s,
4607
- pos: c
4612
+ sectionType: c,
4613
+ pos: o
4608
4614
  }), d > 300 && n.push({
4609
4615
  id: i(),
4610
4616
  severity: "warning",
4611
4617
  message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
4612
- sectionType: s,
4613
- pos: c
4618
+ sectionType: c,
4619
+ pos: o
4614
4620
  });
4615
4621
  }
4616
- if (s === "claims") {
4622
+ if (c === "claims") {
4617
4623
  const d = /^(\d+)\s*[.、]/;
4618
- o.forEach((m, u) => {
4619
- if (m.type.name !== "paragraph") return;
4620
- const f = m.textContent.trim(), p = d.exec(f);
4624
+ s.forEach((u, m) => {
4625
+ if (u.type.name !== "paragraph") return;
4626
+ const f = u.textContent.trim(), p = d.exec(f);
4621
4627
  if (!p) return;
4622
- const y = p[1];
4628
+ const h = p[1];
4623
4629
  f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
4624
4630
  id: i(),
4625
4631
  severity: "warning",
4626
- message: r ? `权利要求${y}末尾应以句号结束` : `Claim ${y} should end with a period`,
4627
- pos: c + 1 + u
4632
+ message: r ? `权利要求${h}末尾应以句号结束` : `Claim ${h} should end with a period`,
4633
+ pos: o + 1 + m
4628
4634
  });
4629
4635
  });
4630
4636
  }
@@ -4639,13 +4645,13 @@ function Li(e, t) {
4639
4645
  let r;
4640
4646
  for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
4641
4647
  const a = parseInt(r[1], 10), i = r[2] ? parseInt(r[2], 10) : a;
4642
- for (let o = a; o <= i; o++)
4643
- o !== t && o > 0 && n.push(o);
4648
+ for (let s = a; s <= i; s++)
4649
+ s !== t && s > 0 && n.push(s);
4644
4650
  }
4645
4651
  for (_t.lastIndex = 0; (r = _t.exec(e)) !== null; ) {
4646
4652
  const a = parseInt(r[1], 10), i = r[2] ? parseInt(r[2], 10) : a;
4647
- for (let o = a; o <= i; o++)
4648
- o !== t && o > 0 && n.push(o);
4653
+ for (let s = a; s <= i; s++)
4654
+ s !== t && s > 0 && n.push(s);
4649
4655
  }
4650
4656
  return [...new Set(n)].sort((a, i) => a - i);
4651
4657
  }
@@ -4679,15 +4685,15 @@ const mn = (e) => {
4679
4685
  if (n.type.name !== "paragraph") return !0;
4680
4686
  const a = mn(n).trim(), i = Ai.exec(a);
4681
4687
  if (!i) return !0;
4682
- const o = parseInt(i[1], 10);
4683
- if (!Number.isFinite(o) || o <= 0) return !0;
4684
- const c = a.slice(i[0].length).trim(), s = Li(c, o);
4688
+ const s = parseInt(i[1], 10);
4689
+ if (!Number.isFinite(s) || s <= 0) return !0;
4690
+ const o = a.slice(i[0].length).trim(), c = Li(o, s);
4685
4691
  return t.push({
4686
- claimId: `claim_${o}`,
4687
- number: o,
4688
- dependsOn: s,
4689
- dependsOnClaimIds: s.map((l) => `claim_${l}`),
4690
- body: c,
4692
+ claimId: `claim_${s}`,
4693
+ number: s,
4694
+ dependsOn: c,
4695
+ dependsOnClaimIds: c.map((l) => `claim_${l}`),
4696
+ body: o,
4691
4697
  pos: r
4692
4698
  }), !0;
4693
4699
  }), t;
@@ -4699,7 +4705,7 @@ export {
4699
4705
  Bs as acceptAllPatches,
4700
4706
  zs as acceptPatch,
4701
4707
  Ks as applyDocDiffDecorations,
4702
- Us as buildAIContext,
4708
+ qs as buildAIContext,
4703
4709
  Js as buildClaimsJSONContent,
4704
4710
  tn as buildPatentDocument,
4705
4711
  $s as clearPatches,
@@ -4714,7 +4720,7 @@ export {
4714
4720
  eo as extractClaimsFromEditor,
4715
4721
  on as findSectionAtCursor,
4716
4722
  ei as getAllSections,
4717
- qs as getMissingSectionDeps,
4723
+ Us as getMissingSectionDeps,
4718
4724
  Ms as getPatches,
4719
4725
  Rs as onPatchChange,
4720
4726
  B as pluginManager,
@@ -4724,7 +4730,7 @@ export {
4724
4730
  Ds as resolvePatchTarget,
4725
4731
  sn as sectionContextDeps,
4726
4732
  Fs as setPatches,
4727
- I as useEditorStore,
4733
+ N as useEditorStore,
4728
4734
  Qs as validatePatentDocument,
4729
4735
  Ws as writeStream,
4730
4736
  js as writeStreamFromSSE