patent-editor 0.2.13 → 0.2.15

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 +1166 -1125
  2. package/dist/lib.js.map +1 -1
  3. package/package.json +1 -1
package/dist/lib.js CHANGED
@@ -1,12 +1,12 @@
1
1
  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
- import { jsx as g, jsxs as L, Fragment as je } from "react/jsx-runtime";
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
- 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";
4
+ import { jsx as f, jsxs as P, Fragment as je } from "react/jsx-runtime";
5
+ import Ee, { forwardRef as It, useState as M, useEffect as F, useCallback as j, useImperativeHandle as Nt, useRef as W, useMemo as At } from "react";
6
+ import { Extension as Oe, ReactRenderer as kn, Node as Q, mergeAttributes as ie, NodeViewWrapper as _n, ReactNodeViewRenderer as Pt, EditorContent as In, useEditor as Nn } from "@tiptap/react";
7
7
  import An from "@tiptap/extension-document";
8
- import Ln from "@tiptap/extension-paragraph";
9
- import Pn from "@tiptap/extension-text";
8
+ import Pn from "@tiptap/extension-paragraph";
9
+ import Ln from "@tiptap/extension-text";
10
10
  import Dn from "@tiptap/extension-heading";
11
11
  import Rn from "@tiptap/extension-bullet-list";
12
12
  import Mn from "@tiptap/extension-ordered-list";
@@ -30,8 +30,8 @@ import { PluginKey as we, Plugin as Be, TextSelection as Zn } from "@tiptap/pm/s
30
30
  import Qn from "@tiptap/suggestion";
31
31
  import er from "tippy.js";
32
32
  import { create as tr } from "zustand";
33
- import { DecorationSet as be, Decoration as re } from "@tiptap/pm/view";
34
- import { diff_match_patch as Pt } from "diff-match-patch";
33
+ import { DecorationSet as de, Decoration as ae } from "@tiptap/pm/view";
34
+ import { diff_match_patch as Lt } from "diff-match-patch";
35
35
  import nr from "@tiptap/extension-bold";
36
36
  import rr from "@tiptap/extension-italic";
37
37
  import ar from "@tiptap/extension-underline";
@@ -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 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
- import Y from "clsx";
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 Pr, Table as Lr, 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
+ import Z 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 Ue } from "docx";
55
+ import { convertMillimetersToTwip as ye, 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",
@@ -164,35 +164,35 @@ 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] = F(0);
168
- M(() => {
167
+ const [r, a] = M(0);
168
+ F(() => {
169
169
  a(0);
170
170
  }, [e]);
171
- const i = ae(
171
+ const i = j(
172
172
  (s) => {
173
- const c = e[s];
174
- c && t(c);
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: s }) => s.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : s.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : s.key === "Enter" ? (i(r), !0) : !1
180
- })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s, 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__ */ f("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ P(
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: s.icon }),
188
- /* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
189
- /* @__PURE__ */ g("span", { className: "slash-menu-title", children: s.title }),
190
- /* @__PURE__ */ g("span", { className: "slash-menu-desc", children: s.description })
187
+ /* @__PURE__ */ f("span", { className: "slash-menu-icon", children: s.icon }),
188
+ /* @__PURE__ */ P("div", { className: "slash-menu-text", children: [
189
+ /* @__PURE__ */ f("span", { className: "slash-menu-title", children: s.title }),
190
+ /* @__PURE__ */ f("span", { className: "slash-menu-desc", children: s.description })
191
191
  ] })
192
192
  ]
193
193
  },
194
194
  s.title
195
- )) }) : /* @__PURE__ */ g("div", { className: "slash-menu", children: /* @__PURE__ */ g("div", { className: "slash-menu-empty", children: "No results" }) });
195
+ )) }) : /* @__PURE__ */ f("div", { className: "slash-menu", children: /* @__PURE__ */ f("div", { className: "slash-menu-empty", children: "No results" }) });
196
196
  }
197
197
  );
198
198
  Wt.displayName = "SlashMenuList";
@@ -344,32 +344,34 @@ function na() {
344
344
  };
345
345
  }
346
346
  const ra = new we("searchReplace");
347
+ function aa(e) {
348
+ const t = [];
349
+ let n = null, r = -1;
350
+ return e.descendants((a, i) => {
351
+ if (a.isText) {
352
+ const s = a.text || "";
353
+ n && i === r ? n.text += s : (n = { text: s, pos: i }, t.push(n)), r = i + a.nodeSize;
354
+ } else
355
+ n = null, r = -1;
356
+ return !0;
357
+ }), t;
358
+ }
347
359
  function ke(e, t, n) {
348
360
  if (!t) return [];
349
- const r = [], a = e.textBetween(0, e.content.size, `
350
- `, "\0"), i = n ? t : t.toLowerCase(), s = n ? a : a.toLowerCase();
351
- let c = 0;
352
- for (; c < s.length; ) {
353
- const l = s.indexOf(i, c);
354
- if (l === -1) break;
355
- let o = 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 b = 0; b < p.length; b++) {
361
- if (o === l && (d = f + b), o === l + i.length)
362
- return u = f + b, !1;
363
- o++;
364
- }
365
- o === l + i.length && u === -1 && (u = f + p.length);
366
- } else m.isBlock && o > 0 && (o === l && (d = f), o++);
367
- return !0;
368
- }), d !== -1 && u !== -1 && r.push({ from: d, to: u }), c = l + 1;
361
+ const r = [], a = n ? t : t.toLowerCase();
362
+ if (!a) return r;
363
+ for (const i of aa(e)) {
364
+ const s = n ? i.text : i.text.toLowerCase();
365
+ let o = 0;
366
+ for (; o <= s.length; ) {
367
+ const l = s.indexOf(a, o);
368
+ if (l === -1) break;
369
+ r.push({ from: i.pos + l, to: i.pos + l + a.length }), o = l + a.length;
370
+ }
369
371
  }
370
372
  return r;
371
373
  }
372
- const aa = Oe.create({
374
+ const ia = Oe.create({
373
375
  name: "searchReplace",
374
376
  addStorage() {
375
377
  return {
@@ -380,6 +382,20 @@ const aa = Oe.create({
380
382
  currentIndex: 0
381
383
  };
382
384
  },
385
+ // Keep stored match positions in sync with document edits. Without this the
386
+ // positions captured at search time go stale: when the document later shrinks
387
+ // (AI streaming, applying/accepting a diff, replacing content, etc.) a stale
388
+ // `to` can exceed the current doc size, and the decoration plugin would then
389
+ // build an out-of-range Decoration, crashing ProseMirror with
390
+ // "Cannot read properties of undefined (reading 'localsInner')".
391
+ onTransaction({ transaction: e }) {
392
+ if (!e.docChanged || this.storage.results.length === 0) return;
393
+ const t = e.doc.content.size, n = this.storage.results.map((r) => ({
394
+ from: e.mapping.map(r.from, 1),
395
+ to: e.mapping.map(r.to, -1)
396
+ })).filter((r) => r.from < r.to && r.from >= 0 && r.to <= t);
397
+ this.storage.results = n, n.length === 0 ? this.storage.currentIndex = -1 : this.storage.currentIndex >= n.length && (this.storage.currentIndex = n.length - 1);
398
+ },
383
399
  addCommands() {
384
400
  return {
385
401
  setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = ke(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
@@ -408,9 +424,9 @@ const aa = Oe.create({
408
424
  let a = ke(e.state.doc, t, r);
409
425
  const i = e.state.tr;
410
426
  let s = 0;
411
- for (const c of a) {
412
- const l = c.from + s, o = c.to + s;
413
- i.insertText(n, l, o), s += n.length - (c.to - c.from);
427
+ for (const o of a) {
428
+ const l = o.from + s, c = o.to + s;
429
+ i.insertText(n, l, c), s += n.length - (o.to - o.from);
414
430
  }
415
431
  return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
416
432
  },
@@ -437,12 +453,13 @@ const aa = Oe.create({
437
453
  props: {
438
454
  decorations: (t) => {
439
455
  if (!e.searchTerm || e.results.length === 0)
440
- return be.empty;
441
- const n = e.results.map((r, a) => {
442
- const i = a === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
443
- return re.inline(r.from, r.to, { class: i });
444
- });
445
- return be.create(t.doc, n);
456
+ return de.empty;
457
+ const n = t.doc.content.size, r = [];
458
+ return e.results.forEach((a, i) => {
459
+ if (a.from < 0 || a.to > n || a.from >= a.to) return;
460
+ const s = i === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
461
+ r.push(ae.inline(a.from, a.to, { class: s }));
462
+ }), r.length === 0 ? de.empty : de.create(t.doc, r);
446
463
  }
447
464
  }
448
465
  })
@@ -458,27 +475,27 @@ function ft(e) {
458
475
  }
459
476
  });
460
477
  }
461
- const ia = -1, sa = 1, pt = 0;
478
+ const sa = -1, oa = 1, pt = 0;
462
479
  let Ge = null;
463
- function oa() {
464
- return Ge || (Ge = new Pt()), Ge;
480
+ function ca() {
481
+ return Ge || (Ge = new Lt()), Ge;
465
482
  }
466
483
  const jt = new we("patchDiff");
467
- function ca(e, t) {
484
+ function la(e, t) {
468
485
  let n = null;
469
486
  return e.state.doc.descendants((r, a) => n ? !1 : r.type.name === "patent_section" && r.attrs.sectionType === t ? (n = { from: a + 1, to: a + r.nodeSize - 1 }, !1) : !0), n;
470
487
  }
471
488
  function Gt(e, t, n) {
472
489
  const r = [];
473
490
  let a = "", i = !0;
474
- return e.state.doc.nodesBetween(t, n, (s, c) => {
491
+ return e.state.doc.nodesBetween(t, n, (s, o) => {
475
492
  if (s.isText) {
476
- const l = c, o = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, u = s.text.slice(o, d);
477
- r.push({ textIdx: a.length, docPos: l + o, len: u.length }), a += u, i = !1;
493
+ const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, m = s.text.slice(c, d);
494
+ r.push({ textIdx: a.length, docPos: l + c, len: m.length }), a += m, i = !1;
478
495
  } else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
479
496
  }), { text: a, segments: r };
480
497
  }
481
- function ye(e, t) {
498
+ function be(e, t) {
482
499
  for (const n of e)
483
500
  if (t >= n.textIdx && t <= n.textIdx + n.len)
484
501
  return n.docPos + (t - n.textIdx);
@@ -493,71 +510,71 @@ function ye(e, t) {
493
510
  }
494
511
  function ht(e, t, n, r, a) {
495
512
  const { text: i, segments: s } = Gt(e, n, r);
496
- let c = 0;
497
- for (; c <= i.length - t.length; ) {
498
- const l = i.indexOf(t, c);
513
+ let o = 0;
514
+ for (; o <= i.length - t.length; ) {
515
+ const l = i.indexOf(t, o);
499
516
  if (l === -1) return null;
500
- const o = ye(s, l), d = ye(s, l + t.length);
501
- if (o >= 0 && d >= 0 && !(a && a.has(o)))
502
- return { from: o, to: d };
503
- c = l + 1;
517
+ const c = be(s, l), d = be(s, l + t.length);
518
+ if (c >= 0 && d >= 0 && !(a && a.has(c)))
519
+ return { from: c, to: d };
520
+ o = l + 1;
504
521
  }
505
522
  return null;
506
523
  }
507
- function Ds(e, t, n, r, a) {
524
+ function Rs(e, t, n, r, a) {
508
525
  const i = t.target;
509
526
  let s = null;
510
- const c = /* @__PURE__ */ new Set();
527
+ const o = /* @__PURE__ */ new Set();
511
528
  if (a)
512
529
  for (const d of a)
513
- c.add(d.from);
530
+ o.add(d.from);
514
531
  if (!i)
515
532
  t.from != null && t.to != null && (s = { from: t.from, to: t.to });
516
533
  else if (i.type === "section" && i.sectionType)
517
- s = ca(e, i.sectionType);
534
+ s = la(e, i.sectionType);
518
535
  else if (i.type === "ref" && i.refIndex != null) {
519
536
  const d = n[i.refIndex];
520
537
  (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, c));
538
+ } else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
522
539
  if (!s) return null;
523
540
  let l = s;
524
541
  if (t.search) {
525
- const d = ht(e, t.search, s.from, s.to, c);
542
+ const d = ht(e, t.search, s.from, s.to, o);
526
543
  d && (l = d);
527
544
  }
528
- const o = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
545
+ const c = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
529
546
  return {
530
547
  id: `patch_${Date.now()}_${r}`,
531
548
  type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
532
549
  from: l.from,
533
550
  to: t.op === "insert" ? l.from : l.to,
534
551
  content: t.content || "",
535
- originalText: o,
552
+ originalText: c,
536
553
  reason: t.reason,
537
554
  status: "pending"
538
555
  };
539
556
  }
540
- const j = /* @__PURE__ */ new Map();
557
+ const G = /* @__PURE__ */ new Map();
541
558
  let De = [];
542
- function Rs(e) {
559
+ function Ms(e) {
543
560
  return De.push(e), () => {
544
561
  De = De.filter((t) => t !== e);
545
562
  };
546
563
  }
547
- function ue() {
564
+ function me() {
548
565
  De.forEach((e) => e());
549
566
  }
550
- function Ms(e = "default") {
551
- return [...j.get(e) || []];
567
+ function Fs(e = "default") {
568
+ return [...G.get(e) || []];
552
569
  }
553
- function Fs(e, t = "default") {
554
- j.set(t, e), ue();
570
+ function $s(e, t = "default") {
571
+ G.set(t, e), me();
555
572
  }
556
- function $s(e = "default") {
557
- j.delete(e), ue();
573
+ function zs(e = "default") {
574
+ G.delete(e), me();
558
575
  }
559
- function zs(e, t, n = "default") {
560
- const r = j.get(n) || [], a = r.find((c) => c.id === t);
576
+ function Os(e, t, n = "default") {
577
+ const r = G.get(n) || [], a = r.find((o) => o.id === t);
561
578
  if (!a || a.status !== "pending") return !1;
562
579
  a.status = "accepted";
563
580
  const { tr: i } = e.state;
@@ -572,19 +589,19 @@ function zs(e, t, n = "default") {
572
589
  i.insertText(a.content, a.from, a.to);
573
590
  e.view.dispatch(i);
574
591
  const s = i.mapping;
575
- for (const c of r) {
576
- if (c.id === t || c.status !== "pending") continue;
577
- const l = s.map(c.from, 1), o = s.map(c.to, -1);
578
- l >= o && c.type !== "insert" ? c.status = "rejected" : (c.from = l, c.to = c.type === "insert" ? l : o);
592
+ for (const o of r) {
593
+ if (o.id === t || o.status !== "pending") continue;
594
+ const l = s.map(o.from, 1), c = s.map(o.to, -1);
595
+ l >= c && o.type !== "insert" ? o.status = "rejected" : (o.from = l, o.to = o.type === "insert" ? l : c);
579
596
  }
580
- return j.set(n, r.filter((c) => c.id !== t && c.status === "pending")), qe(e), ue(), !0;
597
+ return G.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), me(), !0;
581
598
  }
582
- function Os(e, t, n = "default") {
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)), qe(e), ue(), !0);
599
+ function Bs(e, t, n = "default") {
600
+ const r = G.get(n) || [], a = r.find((i) => i.id === t);
601
+ return !a || a.status !== "pending" ? !1 : (a.status = "rejected", G.set(n, r.filter((i) => i.id !== t)), qe(e), me(), !0);
585
602
  }
586
- function Bs(e, t = "default") {
587
- const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, c) => c.from - s.from), { tr: i } = e.state;
603
+ function Hs(e, t = "default") {
604
+ const a = [...(G.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
588
605
  for (const s of a)
589
606
  if (s.type === "delete")
590
607
  i.delete(s.from, s.to);
@@ -595,101 +612,101 @@ function Bs(e, t = "default") {
595
612
  i.replaceWith(s.from, s.to, l);
596
613
  } else
597
614
  i.insertText(s.content, s.from, s.to);
598
- e.view.dispatch(i), j.delete(t), qe(e), ue();
615
+ e.view.dispatch(i), G.delete(t), qe(e), me();
599
616
  }
600
- function Hs(e, t = "default") {
601
- j.delete(t), qe(e), ue();
617
+ function Us(e, t = "default") {
618
+ G.delete(t), qe(e), me();
602
619
  }
603
620
  function qe(e) {
604
621
  e.view.dispatch(e.state.tr.setMeta(jt, !0));
605
622
  }
606
- function la(e, t, n) {
623
+ function da(e, t, n) {
607
624
  const r = [];
608
625
  return e.nodesBetween(t, n, (a, i) => {
609
626
  if (a.isTextblock) {
610
- const s = i + 1, c = i + a.nodeSize - 1, l = Math.max(s, t), o = Math.min(c, n);
611
- return o > l && r.push({ from: l, to: o }), !1;
627
+ const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
628
+ return c > l && r.push({ from: l, to: c }), !1;
612
629
  }
613
630
  return !0;
614
631
  }), r;
615
632
  }
616
- function da(e, t) {
633
+ function ua(e, t) {
617
634
  if (!t.originalText || !t.content) return null;
618
635
  try {
619
- const c = e.resolve(t.from), l = e.resolve(t.to);
620
- if (c.parent !== l.parent || !c.parent.isTextblock) return null;
636
+ const o = e.resolve(t.from), l = e.resolve(t.to);
637
+ if (o.parent !== l.parent || !o.parent.isTextblock) return null;
621
638
  } catch {
622
639
  return null;
623
640
  }
624
- const n = oa(), r = n.diff_main(t.originalText, t.content);
641
+ const n = ca(), r = n.diff_main(t.originalText, t.content);
625
642
  n.diff_cleanupSemantic(r);
626
- const a = r.filter(([c]) => c === pt).reduce((c, [, l]) => c + l.length, 0);
643
+ const a = r.filter(([o]) => o === pt).reduce((o, [, l]) => o + l.length, 0);
627
644
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
628
645
  const i = [];
629
646
  let s = t.from;
630
- for (const [c, l] of r)
631
- if (c === pt)
647
+ for (const [o, l] of r)
648
+ if (o === pt)
632
649
  s += l.length;
633
- else if (c === ia) {
634
- const o = s + l.length;
650
+ else if (o === sa) {
651
+ const c = s + l.length;
635
652
  i.push(
636
- re.inline(s, o, {
653
+ ae.inline(s, c, {
637
654
  class: "patch-diff-delete",
638
655
  "data-patch-id": t.id
639
656
  })
640
- ), s = o;
641
- } else c === sa && i.push(
642
- re.widget(s, () => {
643
- const o = document.createElement("span");
644
- return o.className = "patch-diff-insert-inline", o.textContent = l, o.setAttribute("data-patch-id", t.id), o;
657
+ ), s = c;
658
+ } else o === oa && i.push(
659
+ ae.widget(s, () => {
660
+ const c = document.createElement("span");
661
+ return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
645
662
  }, { side: 1 })
646
663
  );
647
664
  return i;
648
665
  }
649
- function ua(e = "default") {
666
+ function ma(e = "default") {
650
667
  return new Be({
651
668
  key: jt,
652
669
  props: {
653
670
  decorations(t) {
654
- const n = (j.get(e) || []).filter((a) => a.status === "pending");
655
- if (n.length === 0) return be.empty;
671
+ const n = (G.get(e) || []).filter((a) => a.status === "pending");
672
+ if (n.length === 0) return de.empty;
656
673
  const r = [];
657
674
  for (const a of n) {
658
675
  if (a.type === "replace") {
659
- const i = da(t.doc, a);
676
+ const i = ua(t.doc, a);
660
677
  if (i) {
661
678
  r.push(...i);
662
679
  continue;
663
680
  }
664
681
  }
665
682
  if (a.type === "delete" || a.type === "replace") {
666
- const i = la(t.doc, a.from, a.to);
683
+ const i = da(t.doc, a.from, a.to);
667
684
  for (const s of i)
668
685
  r.push(
669
- re.inline(s.from, s.to, {
686
+ ae.inline(s.from, s.to, {
670
687
  class: "patch-diff-delete",
671
688
  "data-patch-id": a.id
672
689
  })
673
690
  );
674
691
  if (a.type === "replace") {
675
- const s = i.length > 0 ? i[i.length - 1].to : a.to, c = a.content.length > 120 || a.content.includes(`
692
+ const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
676
693
  `);
677
694
  r.push(
678
- re.widget(s, () => {
679
- const l = document.createElement(c ? "div" : "span");
680
- return l.className = c ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", l.textContent = a.content, l.setAttribute("data-patch-id", a.id), l;
695
+ ae.widget(s, () => {
696
+ const l = document.createElement(o ? "div" : "span");
697
+ return l.className = o ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", l.textContent = a.content, l.setAttribute("data-patch-id", a.id), l;
681
698
  }, { side: 1 })
682
699
  );
683
700
  }
684
701
  } else
685
702
  r.push(
686
- re.widget(a.from, () => {
703
+ ae.widget(a.from, () => {
687
704
  const i = document.createElement("span");
688
705
  return i.className = "patch-diff-insert-inline", i.textContent = a.content, i.setAttribute("data-patch-id", a.id), i;
689
706
  })
690
707
  );
691
708
  }
692
- return be.create(t.doc, r);
709
+ return de.create(t.doc, r);
693
710
  }
694
711
  }
695
712
  });
@@ -709,7 +726,7 @@ function Jt(e, t) {
709
726
  );
710
727
  });
711
728
  }
712
- const ma = Z.create({
729
+ const ga = Q.create({
713
730
  name: "hardBreak",
714
731
  inline: !0,
715
732
  group: "inline",
@@ -730,7 +747,7 @@ const ma = Z.create({
730
747
  }
731
748
  };
732
749
  }
733
- }), ga = Oe.create({
750
+ }), fa = Oe.create({
734
751
  name: "dragDropUX",
735
752
  addProseMirrorPlugins() {
736
753
  return [
@@ -741,19 +758,19 @@ const ma = Z.create({
741
758
  Xn()
742
759
  ];
743
760
  }
744
- }), fa = Oe.create({
761
+ }), pa = Oe.create({
745
762
  name: "patchDiff",
746
763
  addOptions() {
747
764
  return { editorId: "default" };
748
765
  },
749
766
  addProseMirrorPlugins() {
750
- return [ua(this.options.editorId)];
767
+ return [ma(this.options.editorId)];
751
768
  }
752
- }), pa = [
769
+ }), ha = [
753
770
  An,
754
- Ln,
755
771
  Pn,
756
- ga,
772
+ Ln,
773
+ fa,
757
774
  Dn.configure({
758
775
  levels: [1, 2, 3, 4, 5, 6]
759
776
  }),
@@ -762,7 +779,7 @@ const ma = Z.create({
762
779
  Fn,
763
780
  $n,
764
781
  zn,
765
- ma,
782
+ ga,
766
783
  On,
767
784
  Bn,
768
785
  Hn.configure({ nested: !0 }),
@@ -795,12 +812,12 @@ const ma = Z.create({
795
812
  Qr.configure({
796
813
  suggestion: na()
797
814
  }),
798
- aa,
815
+ ia,
799
816
  Yn.configure({
800
817
  types: ["heading", "paragraph"],
801
818
  defaultAlignment: "left"
802
819
  })
803
- ], ha = [
820
+ ], ya = [
804
821
  nr,
805
822
  rr,
806
823
  ar,
@@ -814,11 +831,11 @@ const ma = Z.create({
814
831
  dr,
815
832
  ur,
816
833
  mr.configure({ multicolor: !0 })
817
- ], ya = [
818
- ...pa,
819
- ...ha
834
+ ], ba = [
835
+ ...ha,
836
+ ...ya
820
837
  ];
821
- class ba {
838
+ class va {
822
839
  constructor() {
823
840
  Se(this, "commands", /* @__PURE__ */ new Map());
824
841
  }
@@ -843,38 +860,38 @@ class ba {
843
860
  return !r || !r.isActive ? !1 : r.isActive(n);
844
861
  }
845
862
  async execute(t, n, r, a = {}) {
846
- var d, u, m, f;
847
- const i = Date.now(), s = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, o = this.commands.get(t);
848
- if (!o)
863
+ var d, m, g, h;
864
+ const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, c = this.commands.get(t);
865
+ if (!c)
849
866
  return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
850
867
  name: t,
851
868
  success: !1,
852
869
  durationMs: Date.now() - i
853
870
  }), !1;
854
871
  if (!this.canExecute(t, n, r))
855
- return (u = a.onComplete) == null || u.call(a, {
872
+ return (m = a.onComplete) == null || m.call(a, {
856
873
  name: t,
857
874
  success: !1,
858
875
  durationMs: Date.now() - i
859
876
  }), !1;
860
877
  try {
861
- const b = !!await o.execute(n, r);
862
- !b && l && c && n.editor.commands.setContent(l);
878
+ const b = !!await c.execute(n, r);
879
+ !b && l && o && n.editor.commands.setContent(l);
863
880
  const y = {
864
881
  name: t,
865
882
  success: b,
866
883
  durationMs: Date.now() - i
867
884
  };
868
- return (m = a.onComplete) == null || m.call(a, y), b;
885
+ return (g = a.onComplete) == null || g.call(a, y), b;
869
886
  } catch (p) {
870
- l && c && n.editor.commands.setContent(l);
887
+ l && o && n.editor.commands.setContent(l);
871
888
  const b = {
872
889
  name: t,
873
890
  success: !1,
874
891
  durationMs: Date.now() - i,
875
892
  error: p
876
893
  };
877
- return (f = a.onComplete) == null || f.call(a, b), !1;
894
+ return (h = a.onComplete) == null || h.call(a, b), !1;
878
895
  }
879
896
  }
880
897
  getCommand(t) {
@@ -884,8 +901,8 @@ class ba {
884
901
  return Array.from(this.commands.keys()).sort();
885
902
  }
886
903
  }
887
- const le = new ba();
888
- class va {
904
+ const le = new va();
905
+ class wa {
889
906
  constructor() {
890
907
  Se(this, "plugins", /* @__PURE__ */ new Map());
891
908
  Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
@@ -970,7 +987,7 @@ class va {
970
987
  });
971
988
  }
972
989
  }
973
- const B = new va(), yt = {
990
+ const B = new wa(), yt = {
974
991
  zh: {
975
992
  language: "语言",
976
993
  bold: "加粗",
@@ -1223,7 +1240,7 @@ const Ie = () => {
1223
1240
  document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1224
1241
  (e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
1225
1242
  }), document.querySelectorAll('body > div[id^="dstandalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="dmermaid"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="standalone-mermaid-"]').forEach((e) => e.remove());
1226
- }, wa = Z.create({
1243
+ }, xa = Q.create({
1227
1244
  name: "mermaid",
1228
1245
  group: "block",
1229
1246
  atom: !0,
@@ -1245,102 +1262,102 @@ const Ie = () => {
1245
1262
  i.classList.add("mermaid-node");
1246
1263
  const s = document.createElement("div");
1247
1264
  s.className = "mermaid-view", s.contentEditable = "false";
1248
- const c = document.createElement("div");
1249
- c.className = "mermaid-preview", c.contentEditable = "false";
1250
- const l = document.createElement("div");
1251
- l.className = "mermaid-view-hint", s.append(c, l);
1252
1265
  const o = document.createElement("div");
1253
- o.className = "mermaid-edit";
1266
+ o.className = "mermaid-preview", o.contentEditable = "false";
1267
+ const l = document.createElement("div");
1268
+ l.className = "mermaid-view-hint", s.append(o, l);
1269
+ const c = document.createElement("div");
1270
+ c.className = "mermaid-edit";
1254
1271
  const d = document.createElement("textarea");
1255
1272
  d.className = "mermaid-editor-textarea", d.spellcheck = !1;
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
- const f = document.createElement("button");
1261
- f.className = "mermaid-cancel-btn", f.type = "button";
1273
+ const m = document.createElement("div");
1274
+ m.className = "mermaid-edit-toolbar";
1275
+ const g = document.createElement("span");
1276
+ g.className = "mermaid-error-msg";
1277
+ const h = document.createElement("button");
1278
+ h.className = "mermaid-cancel-btn", h.type = "button";
1262
1279
  const p = document.createElement("button");
1263
- p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), o.append(d, u), i.append(s, o);
1264
- const b = (C) => {
1280
+ p.className = "mermaid-save-btn", p.type = "button", m.append(g, h, p), c.append(d, m), i.append(s, c);
1281
+ const b = (v) => {
1265
1282
  const _ = typeof n == "function" ? n() : null;
1266
- typeof _ == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(_, void 0, { ...r.attrs, ...C }), D && D(A), !0));
1283
+ typeof _ == "number" && e.commands.command(({ tr: N, dispatch: D }) => (N.setNodeMarkup(_, void 0, { ...r.attrs, ...v }), D && D(N), !0));
1267
1284
  };
1268
1285
  let y = "";
1269
- const w = async (C) => {
1270
- const _ = C.trim();
1286
+ const w = async (v) => {
1287
+ const _ = v.trim();
1271
1288
  if (_ !== y) {
1272
1289
  if (!_) {
1273
- c.innerHTML = "", y = "";
1290
+ o.innerHTML = "", y = "";
1274
1291
  return;
1275
1292
  }
1276
1293
  try {
1277
- const A = await import("mermaid");
1278
- A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1279
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1280
- c.innerHTML = z, y = _;
1294
+ const N = await import("mermaid");
1295
+ N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1296
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
1297
+ o.innerHTML = z, y = _;
1281
1298
  } catch {
1282
- c.innerHTML = "", y = "";
1299
+ o.innerHTML = "", y = "";
1283
1300
  } finally {
1284
1301
  Ie();
1285
1302
  }
1286
1303
  }
1287
1304
  }, T = () => {
1288
- a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", S(), requestAnimationFrame(() => d.focus()));
1289
- }, v = () => {
1305
+ a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", g.textContent = "", g.style.display = "none", S(), requestAnimationFrame(() => d.focus()));
1306
+ }, C = () => {
1290
1307
  a = !1, S();
1291
1308
  }, x = async () => {
1292
- const C = d.value;
1293
- m.textContent = "", m.style.display = "none";
1294
- const _ = C.trim();
1309
+ const v = d.value;
1310
+ g.textContent = "", g.style.display = "none";
1311
+ const _ = v.trim();
1295
1312
  if (_)
1296
1313
  try {
1297
- const A = await import("mermaid");
1298
- A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1299
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1300
- c.innerHTML = z, y = _, Ie();
1314
+ const N = await import("mermaid");
1315
+ N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1316
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
1317
+ o.innerHTML = z, y = _, Ie();
1301
1318
  } catch {
1302
1319
  Ie();
1303
- const A = I.getState().editorLanguage;
1304
- m.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
1320
+ const N = I.getState().editorLanguage;
1321
+ g.textContent = N === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", g.style.display = "inline";
1305
1322
  return;
1306
1323
  }
1307
- b({ code: C }), a = !1, S();
1324
+ b({ code: v }), a = !1, S();
1308
1325
  };
1309
- s.addEventListener("dblclick", (C) => {
1310
- C.preventDefault(), C.stopPropagation(), T();
1311
- }), p.addEventListener("click", (C) => {
1312
- C.stopPropagation(), x();
1313
- }), f.addEventListener("click", (C) => {
1314
- C.stopPropagation(), v();
1315
- }), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
1326
+ s.addEventListener("dblclick", (v) => {
1327
+ v.preventDefault(), v.stopPropagation(), T();
1328
+ }), p.addEventListener("click", (v) => {
1329
+ v.stopPropagation(), x();
1330
+ }), h.addEventListener("click", (v) => {
1331
+ v.stopPropagation(), C();
1332
+ }), d.addEventListener("mousedown", (v) => v.stopPropagation()), d.addEventListener("keydown", (v) => v.stopPropagation()), d.addEventListener("keypress", (v) => v.stopPropagation());
1316
1333
  const S = () => {
1317
- const C = I.getState().editorLanguage, _ = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
- s.style.display = a ? "none" : "block", o.style.display = a ? "block" : "none", p.textContent = _.mermaidSaveAndRender || "保存并渲染", f.textContent = _.mermaidCancel || "取消";
1319
- const D = A.trim().length > 0, z = c.querySelector("svg") !== null;
1320
- a || (D && z ? (l.textContent = _.mermaidDoubleClickToEdit || "双击编辑", l.className = "mermaid-view-hint mermaid-view-hint--subtle") : (l.textContent = _.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", l.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && w(A);
1334
+ const v = I.getState().editorLanguage, _ = H(v), N = typeof r.attrs.code == "string" ? r.attrs.code : "";
1335
+ s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none", p.textContent = _.mermaidSaveAndRender || "保存并渲染", h.textContent = _.mermaidCancel || "取消";
1336
+ const D = N.trim().length > 0, z = o.querySelector("svg") !== null;
1337
+ a || (D && z ? (l.textContent = _.mermaidDoubleClickToEdit || "双击编辑", l.className = "mermaid-view-hint mermaid-view-hint--subtle") : (l.textContent = _.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", l.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && N.trim() !== y && w(N);
1321
1338
  };
1322
- let N = I.getState().editorLanguage;
1323
- const h = I.subscribe((C) => {
1324
- C.editorLanguage !== N && (N = C.editorLanguage, S());
1339
+ let A = I.getState().editorLanguage;
1340
+ const u = I.subscribe((v) => {
1341
+ v.editorLanguage !== A && (A = v.editorLanguage, S());
1325
1342
  });
1326
1343
  return S(), {
1327
1344
  dom: i,
1328
- stopEvent: (C) => {
1329
- const _ = C.target;
1330
- return !!(_ === d || o.contains(_));
1345
+ stopEvent: (v) => {
1346
+ const _ = v.target;
1347
+ return !!(_ === d || c.contains(_));
1331
1348
  },
1332
1349
  ignoreMutation: () => !0,
1333
- update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, S(), !0),
1350
+ update: (v) => v.type.name !== "mermaid" ? !1 : (r = v, S(), !0),
1334
1351
  destroy: () => {
1335
- h(), Ie();
1352
+ u(), Ie();
1336
1353
  }
1337
1354
  };
1338
1355
  };
1339
1356
  }
1340
- }), xa = {
1357
+ }), Ca = {
1341
1358
  name: "mermaid",
1342
1359
  version: "1.0.0",
1343
- extensions: [wa],
1360
+ extensions: [xa],
1344
1361
  toolbarItems: [
1345
1362
  {
1346
1363
  id: "mermaid-insert",
@@ -1365,7 +1382,7 @@ const Ie = () => {
1365
1382
  }
1366
1383
  }
1367
1384
  }
1368
- }, Ve = "https://draw.goatpatent.com", Ca = Z.create({
1385
+ }, Ve = "https://draw.goatpatent.com", Ta = Q.create({
1369
1386
  name: "drawio",
1370
1387
  group: "block",
1371
1388
  atom: !0,
@@ -1388,64 +1405,64 @@ const Ie = () => {
1388
1405
  i.classList.add("drawio-node");
1389
1406
  const s = document.createElement("div");
1390
1407
  s.className = "drawio-view", s.contentEditable = "false";
1391
- const c = document.createElement("img");
1392
- c.className = "drawio-preview-img", c.style.display = "none";
1408
+ const o = document.createElement("img");
1409
+ o.className = "drawio-preview-img", o.style.display = "none";
1393
1410
  const l = document.createElement("div");
1394
- l.className = "drawio-view-hint", s.append(c, l), i.append(s);
1395
- const o = (T) => {
1396
- const v = typeof n == "function" ? n() : null;
1397
- typeof v == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...T }), S && S(x), !0));
1411
+ l.className = "drawio-view-hint", s.append(o, l), i.append(s);
1412
+ const c = (T) => {
1413
+ const C = typeof n == "function" ? n() : null;
1414
+ typeof C == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(C, void 0, { ...r.attrs, ...T }), S && S(x), !0));
1398
1415
  };
1399
- let d = null, u = null, m = null;
1400
- const f = () => {
1416
+ let d = null, m = null, g = null;
1417
+ const h = () => {
1401
1418
  if (a) return;
1402
- a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1419
+ a = !0, m = document.createElement("div"), m.className = "drawio-modal-overlay";
1403
1420
  const T = document.createElement("div");
1404
1421
  T.className = "drawio-modal-content";
1405
- const v = document.createElement("div");
1406
- v.className = "drawio-modal-header";
1422
+ const C = document.createElement("div");
1423
+ C.className = "drawio-modal-header";
1407
1424
  const x = I.getState().editorLanguage, S = document.createElement("span");
1408
1425
  S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
1409
- const N = document.createElement("button");
1410
- N.className = "drawio-modal-close-btn", N.textContent = "✕", N.type = "button", N.addEventListener("click", () => p()), v.append(S, N), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), T.append(v, m), u.appendChild(T), document.body.appendChild(u);
1411
- const h = x === "en" ? "en" : "zh";
1412
- m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${h}`;
1413
- const C = m;
1426
+ const A = document.createElement("button");
1427
+ A.className = "drawio-modal-close-btn", A.textContent = "✕", A.type = "button", A.addEventListener("click", () => p()), C.append(S, A), g = document.createElement("iframe"), g.className = "drawio-modal-iframe", g.setAttribute("frameborder", "0"), T.append(C, g), m.appendChild(T), document.body.appendChild(m);
1428
+ const u = x === "en" ? "en" : "zh";
1429
+ g.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${u}`;
1430
+ const v = g;
1414
1431
  d = (_) => {
1415
1432
  var D, z;
1416
- if (!C || _.source !== C.contentWindow) return;
1417
- let A;
1433
+ if (!v || _.source !== v.contentWindow) return;
1434
+ let N;
1418
1435
  try {
1419
- A = typeof _.data == "string" ? JSON.parse(_.data) : _.data;
1436
+ N = typeof _.data == "string" ? JSON.parse(_.data) : _.data;
1420
1437
  } catch {
1421
1438
  return;
1422
1439
  }
1423
- if (A.event === "init") {
1424
- const Q = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
1425
- (D = C.contentWindow) == null || D.postMessage(
1426
- JSON.stringify({ action: "load", autosave: 0, xml: Q || "" }),
1440
+ if (N.event === "init") {
1441
+ const ee = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
1442
+ (D = v.contentWindow) == null || D.postMessage(
1443
+ JSON.stringify({ action: "load", autosave: 0, xml: ee || "" }),
1427
1444
  Ve
1428
1445
  );
1429
- } else if (A.event === "save") {
1430
- const Q = A.xml || "";
1431
- (z = C.contentWindow) == null || z.postMessage(
1446
+ } else if (N.event === "save") {
1447
+ const ee = N.xml || "";
1448
+ (z = v.contentWindow) == null || z.postMessage(
1432
1449
  JSON.stringify({ action: "export", format: "svg" }),
1433
1450
  Ve
1434
- ), o({ xml: Q });
1435
- } else if (A.event === "export") {
1436
- const Q = A.data || "";
1437
- o({ svg: Q }), p();
1438
- } else A.event === "exit" && p();
1451
+ ), c({ xml: ee });
1452
+ } else if (N.event === "export") {
1453
+ const ee = N.data || "";
1454
+ c({ svg: ee }), p();
1455
+ } else N.event === "exit" && p();
1439
1456
  }, window.addEventListener("message", d);
1440
1457
  }, p = () => {
1441
- a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), b();
1458
+ a = !1, d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null), b();
1442
1459
  };
1443
1460
  s.addEventListener("dblclick", (T) => {
1444
- T.preventDefault(), T.stopPropagation(), f();
1461
+ T.preventDefault(), T.stopPropagation(), h();
1445
1462
  });
1446
1463
  const b = () => {
1447
- const T = I.getState().editorLanguage, v = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
- x ? (c.src = x, c.style.display = "block") : (c.src = "", c.style.display = "none"), x ? (l.textContent = v.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = v.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
1464
+ const T = I.getState().editorLanguage, C = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1465
+ x ? (o.src = x, o.style.display = "block") : (o.src = "", o.style.display = "none"), x ? (l.textContent = C.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = C.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
1449
1466
  };
1450
1467
  let y = I.getState().editorLanguage;
1451
1468
  const w = I.subscribe((T) => {
@@ -1456,15 +1473,15 @@ const Ie = () => {
1456
1473
  ignoreMutation: () => !0,
1457
1474
  update: (T) => T.type.name !== "drawio" ? !1 : (r = T, b(), !0),
1458
1475
  destroy: () => {
1459
- w(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1476
+ w(), d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null);
1460
1477
  }
1461
1478
  };
1462
1479
  };
1463
1480
  }
1464
- }), Ta = {
1481
+ }), Sa = {
1465
1482
  name: "drawio",
1466
1483
  version: "1.0.0",
1467
- extensions: [Ca],
1484
+ extensions: [Ta],
1468
1485
  toolbarItems: [
1469
1486
  {
1470
1487
  id: "drawio-insert",
@@ -1495,79 +1512,79 @@ const Ie = () => {
1495
1512
  selected: n,
1496
1513
  editor: r
1497
1514
  }) => {
1498
- const a = W(null), [i, s] = F(!1), c = e.type.name === "math_block", l = W(!1), o = W(t), d = W(e.attrs.latex ?? "");
1499
- M(() => {
1500
- o.current = t;
1501
- }, [t]), M(() => {
1515
+ const a = W(null), [i, s] = M(!1), o = e.type.name === "math_block", l = W(!1), c = W(t), d = W(e.attrs.latex ?? "");
1516
+ F(() => {
1517
+ c.current = t;
1518
+ }, [t]), F(() => {
1502
1519
  d.current = e.attrs.latex ?? "";
1503
1520
  }, [e.attrs.latex]);
1504
- const u = ae(() => {
1521
+ const m = j(() => {
1505
1522
  l.current || (l.current = !0, s(!0));
1506
- }, []), m = ae(() => {
1523
+ }, []), g = j(() => {
1507
1524
  var b, y;
1508
1525
  if (!l.current) return;
1509
1526
  l.current = !1;
1510
1527
  const p = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
1511
- o.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1528
+ c.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1512
1529
  }, []);
1513
- M(() => {
1530
+ F(() => {
1514
1531
  var b, y, w;
1515
1532
  const p = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
1516
- n && p && u();
1517
- }, [n, u]), M(() => {
1533
+ n && p && m();
1534
+ }, [n, m]), F(() => {
1518
1535
  i && requestAnimationFrame(() => {
1519
1536
  var b;
1520
1537
  const p = a.current;
1521
1538
  p && (p.virtualKeyboardMode = "onfocus", (b = p.focus) == null || b.call(p));
1522
1539
  });
1523
- }, [i]), M(() => {
1540
+ }, [i]), F(() => {
1524
1541
  if (!i) return;
1525
1542
  const p = a.current;
1526
1543
  if (!p) return;
1527
1544
  const b = () => {
1528
1545
  setTimeout(() => {
1529
- var T, v, x;
1546
+ var T, C, x;
1530
1547
  if (!l.current) return;
1531
1548
  const w = document.activeElement;
1532
- (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (T = w == null ? void 0 : w.closest) != null && T.call(w, "math-field") || (v = w == null ? void 0 : w.closest) != null && v.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || m();
1549
+ (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (T = w == null ? void 0 : w.closest) != null && T.call(w, "math-field") || (C = w == null ? void 0 : w.closest) != null && C.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || g();
1533
1550
  }, 300);
1534
1551
  }, y = (w) => {
1535
- w.key === "Escape" && m();
1552
+ w.key === "Escape" && g();
1536
1553
  };
1537
1554
  return p.addEventListener("focusout", b), p.addEventListener("keydown", y), () => {
1538
1555
  p.removeEventListener("focusout", b), p.removeEventListener("keydown", y);
1539
1556
  };
1540
- }, [i, m]), M(() => {
1557
+ }, [i, g]), F(() => {
1541
1558
  !i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
1542
1559
  }, [e.attrs.latex, i]);
1543
- let f = "";
1560
+ let h = "";
1544
1561
  try {
1545
- f = gr.renderToString(e.attrs.latex || "", {
1562
+ h = gr.renderToString(e.attrs.latex || "", {
1546
1563
  throwOnError: !1,
1547
- displayMode: c
1564
+ displayMode: o
1548
1565
  });
1549
1566
  } catch {
1550
- f = e.attrs.latex || "";
1567
+ h = e.attrs.latex || "";
1551
1568
  }
1552
- return /* @__PURE__ */ g(
1569
+ return /* @__PURE__ */ f(
1553
1570
  _n,
1554
1571
  {
1555
- as: c ? "div" : "span",
1556
- className: c ? "math-block" : "math-inline",
1557
- children: i ? /* @__PURE__ */ g(
1572
+ as: o ? "div" : "span",
1573
+ className: o ? "math-block" : "math-inline",
1574
+ children: i ? /* @__PURE__ */ f(
1558
1575
  "math-field",
1559
1576
  {
1560
1577
  ref: a,
1561
- className: c ? "math-live-field math-live-field--block" : "math-live-field",
1578
+ className: o ? "math-live-field math-live-field--block" : "math-live-field",
1562
1579
  children: e.attrs.latex
1563
1580
  }
1564
- ) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
1565
- /* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: f } }),
1566
- /* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
1581
+ ) : /* @__PURE__ */ P("span", { className: "math-preview", onClick: m, children: [
1582
+ /* @__PURE__ */ f("span", { dangerouslySetInnerHTML: { __html: h } }),
1583
+ /* @__PURE__ */ f("span", { className: "math-tooltip", children: "点击编辑" })
1567
1584
  ] })
1568
1585
  }
1569
1586
  );
1570
- }, Sa = Z.create({
1587
+ }, Ea = Q.create({
1571
1588
  name: "math_inline",
1572
1589
  group: "inline",
1573
1590
  inline: !0,
@@ -1593,14 +1610,14 @@ const Ie = () => {
1593
1610
  return ["span", ie(e, { "data-type": "math_inline" })];
1594
1611
  },
1595
1612
  addNodeView() {
1596
- return Lt(Kt, {
1613
+ return Pt(Kt, {
1597
1614
  stopEvent: ({ event: e }) => {
1598
1615
  const t = e.target;
1599
1616
  return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
1600
1617
  }
1601
1618
  });
1602
1619
  }
1603
- }), Ea = Z.create({
1620
+ }), ka = Q.create({
1604
1621
  name: "math_block",
1605
1622
  group: "block",
1606
1623
  atom: !0,
@@ -1616,17 +1633,17 @@ const Ie = () => {
1616
1633
  return ["div", ie(e, { "data-type": "math_block" })];
1617
1634
  },
1618
1635
  addNodeView() {
1619
- return Lt(Kt, {
1636
+ return Pt(Kt, {
1620
1637
  stopEvent: ({ event: e }) => {
1621
1638
  const t = e.target;
1622
1639
  return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
1623
1640
  }
1624
1641
  });
1625
1642
  }
1626
- }), ka = {
1643
+ }), _a = {
1627
1644
  name: "math",
1628
1645
  version: "1.0.0",
1629
- extensions: [Sa, Ea],
1646
+ extensions: [Ea, ka],
1630
1647
  toolbarItems: [
1631
1648
  {
1632
1649
  id: "math-inline-insert",
@@ -1674,10 +1691,10 @@ const Ie = () => {
1674
1691
  }, st = (e, t, n = {}) => {
1675
1692
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
1676
1693
  let i = null;
1677
- return e.state.doc.nodesBetween(r, a, (s, c) => i ? !1 : s.type.name === t ? (i = { node: s, pos: c }, !1) : !0), i;
1694
+ return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
1678
1695
  }, Xt = (e, t, n = {}) => {
1679
1696
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, i = [];
1680
- return e.state.doc.nodesBetween(r, a, (s, c) => (t(s, c) && i.push({ node: s, pos: c }), !0)), i;
1697
+ return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
1681
1698
  }, Re = (e, t) => {
1682
1699
  const { $from: n } = e.state.selection;
1683
1700
  for (let r = n.depth; r >= 0; r -= 1) {
@@ -1689,7 +1706,7 @@ const Ie = () => {
1689
1706
  };
1690
1707
  }
1691
1708
  return null;
1692
- }, _a = (e) => {
1709
+ }, Ia = (e) => {
1693
1710
  const { $from: t } = e.state.selection;
1694
1711
  for (let n = t.depth; n >= 0; n -= 1) {
1695
1712
  const r = t.node(n);
@@ -1700,7 +1717,7 @@ const Ie = () => {
1700
1717
  };
1701
1718
  }
1702
1719
  return null;
1703
- }, Ia = (e, t) => e.state.schema.nodes[t] || null, Na = (e) => {
1720
+ }, Na = (e, t) => e.state.schema.nodes[t] || null, Aa = (e) => {
1704
1721
  const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
1705
1722
  return {
1706
1723
  type: e.type,
@@ -1708,7 +1725,7 @@ const Ie = () => {
1708
1725
  content: t
1709
1726
  };
1710
1727
  }, Yt = (e, t) => {
1711
- const n = Na(t);
1728
+ const n = Aa(t);
1712
1729
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1713
1730
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1714
1731
  var l;
@@ -1718,25 +1735,25 @@ const Ie = () => {
1718
1735
  const s = r.doc.nodeAt(i);
1719
1736
  if (!s || t.type && s.type.name !== t.type)
1720
1737
  return !1;
1721
- const c = { ...s.attrs, ...t.attrs };
1722
- return n.setNodeMarkup(i, void 0, c), a && a(n), !0;
1738
+ const o = { ...s.attrs, ...t.attrs };
1739
+ return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
1723
1740
  }), 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;
1741
+ var o;
1742
+ const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
1726
1743
  if (typeof i != "number")
1727
1744
  return !1;
1728
1745
  const s = r.doc.nodeAt(i);
1729
1746
  return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
1730
1747
  }), Qt = (e, t) => {
1731
- const n = Ia(e, t.type);
1748
+ const n = Na(e, t.type);
1732
1749
  return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
1733
- const { from: s, to: c } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1750
+ const { from: s, to: o } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1734
1751
  if (!l)
1735
1752
  return !1;
1736
- const o = fr(l, n, t.attrs);
1737
- return o ? (r.wrap(l, o), i && i(r.scrollIntoView()), s <= c) : !1;
1753
+ const c = fr(l, n, t.attrs);
1754
+ return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
1738
1755
  }) : !1;
1739
- }, Aa = (e, t) => {
1756
+ }, Pa = (e, t) => {
1740
1757
  if (t.length === 0)
1741
1758
  return !1;
1742
1759
  const n = e.getJSON();
@@ -1744,17 +1761,17 @@ const Ie = () => {
1744
1761
  if (!(r.type === "insertNode" ? Yt(e, r.payload) : r.type === "updateNodeAttrs" ? ze(e, r.payload) : r.type === "removeNode" ? Zt(e, r.payload) : Qt(e, r.payload)))
1745
1762
  return e.commands.setContent(n), !1;
1746
1763
  return !0;
1747
- }, de = "https://draw.goatpatent.com";
1764
+ }, ue = "https://draw.goatpatent.com";
1748
1765
  let Ne = 0;
1749
1766
  const Qe = [];
1750
1767
  let Ae = !1;
1751
1768
  const La = 2e4, bt = 6e4;
1752
- let $ = null, Me = !1, ne = null, pe = null;
1769
+ let $ = null, Me = !1, re = null, he = null;
1753
1770
  const et = /* @__PURE__ */ new Map();
1754
1771
  function vt() {
1755
- ne && (window.removeEventListener("message", ne), ne = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1772
+ re && (window.removeEventListener("message", re), re = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1756
1773
  }
1757
- function Pa(e, t) {
1774
+ function Da(e, t) {
1758
1775
  const n = et.get(e);
1759
1776
  if (n) {
1760
1777
  t(n);
@@ -1764,45 +1781,45 @@ function Pa(e, t) {
1764
1781
  }
1765
1782
  function tt() {
1766
1783
  if (Ae || Qe.length === 0) return;
1767
- Ae = !0, pe && (clearTimeout(pe), pe = null);
1784
+ Ae = !0, he && (clearTimeout(he), he = null);
1768
1785
  const { xml: e, callback: t } = Qe.shift(), n = et.get(e);
1769
1786
  if (n) {
1770
- t(n), Ae = !1, pe = setTimeout(vt, bt), tt();
1787
+ t(n), Ae = !1, he = setTimeout(vt, bt), tt();
1771
1788
  return;
1772
1789
  }
1773
- ne && (window.removeEventListener("message", ne), ne = null);
1790
+ re && (window.removeEventListener("message", re), re = null);
1774
1791
  let r = null;
1775
1792
  const a = (s) => {
1776
- r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, pe = setTimeout(vt, bt), tt();
1793
+ r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, he = setTimeout(vt, bt), tt();
1777
1794
  }, i = () => {
1778
1795
  var s;
1779
1796
  (s = $.contentWindow) == null || s.postMessage(
1780
1797
  JSON.stringify({ action: "load", autosave: 0, xml: e || "" }),
1781
- de
1798
+ ue
1782
1799
  );
1783
1800
  };
1784
- ne = (s) => {
1801
+ re = (s) => {
1785
1802
  if (!$ || s.source !== $.contentWindow) return;
1786
- let c;
1803
+ let o;
1787
1804
  try {
1788
- c = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1805
+ o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1789
1806
  } catch {
1790
1807
  return;
1791
1808
  }
1792
- c.event === "init" ? (Me = !0, i()) : c.event === "load" ? setTimeout(() => {
1809
+ o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
1793
1810
  var l;
1794
1811
  (l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
1795
1812
  JSON.stringify({ action: "export", format: "svg" }),
1796
- de
1813
+ ue
1797
1814
  );
1798
- }, 1500) : c.event === "export" && a(c.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`);
1815
+ }, 1500) : o.event === "export" && a(o.data || "");
1816
+ }, window.addEventListener("message", re), 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 = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
1800
1817
  }
1801
- const Le = () => {
1818
+ const Pe = () => {
1802
1819
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1803
1820
  (e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
1804
1821
  }), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
1805
- }, Da = Z.create({
1822
+ }, Ra = Q.create({
1806
1823
  name: "figure",
1807
1824
  group: "block",
1808
1825
  content: "inline*",
@@ -1833,217 +1850,217 @@ const Le = () => {
1833
1850
  let r = t, a = !1, i = !1;
1834
1851
  const s = document.createElement("figure");
1835
1852
  s.setAttribute("data-type", "figure"), s.className = "figure-block";
1836
- const c = document.createElement("div");
1837
- c.className = "figure-visual", c.contentEditable = "false", c.setAttribute("spellcheck", "false");
1853
+ const o = document.createElement("div");
1854
+ o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
1838
1855
  const l = document.createElement("img");
1839
1856
  l.className = "figure-img-preview";
1840
- const o = document.createElement("div");
1841
- o.className = "figure-upload-area";
1857
+ const c = document.createElement("div");
1858
+ c.className = "figure-upload-area";
1842
1859
  const d = document.createElement("span");
1843
1860
  d.className = "figure-upload-hint";
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", o.append(d, u);
1848
- const f = document.createElement("div");
1849
- f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
1861
+ const m = document.createElement("input");
1862
+ m.type = "file", m.accept = "image/*", m.style.display = "none";
1863
+ const g = document.createElement("button");
1864
+ g.className = "figure-replace-btn", c.append(d, m);
1865
+ const h = document.createElement("div");
1866
+ h.className = "figure-mermaid-view", h.contentEditable = "false", h.setAttribute("spellcheck", "false");
1850
1867
  const p = document.createElement("div");
1851
1868
  p.className = "figure-mermaid-preview", p.contentEditable = "false";
1852
1869
  const b = document.createElement("div");
1853
- b.className = "figure-mermaid-view-hint", f.append(p, b);
1870
+ b.className = "figure-mermaid-view-hint", h.append(p, b);
1854
1871
  const y = document.createElement("div");
1855
1872
  y.className = "figure-mermaid-edit";
1856
1873
  const w = document.createElement("textarea");
1857
1874
  w.className = "figure-mermaid-editor", w.spellcheck = !1;
1858
1875
  const T = document.createElement("div");
1859
1876
  T.className = "figure-mermaid-toolbar";
1860
- const v = document.createElement("button");
1861
- v.className = "figure-mermaid-save-btn", v.type = "button";
1877
+ const C = document.createElement("button");
1878
+ C.className = "figure-mermaid-save-btn", C.type = "button";
1862
1879
  const x = document.createElement("button");
1863
1880
  x.className = "figure-mermaid-cancel-btn", x.type = "button";
1864
1881
  const S = document.createElement("span");
1865
- S.className = "figure-mermaid-error-inline", T.append(S, x, v), y.append(w, T);
1866
- const N = document.createElement("div");
1867
- N.className = "figure-drawio-view", N.contentEditable = "false";
1868
- const h = document.createElement("img");
1869
- h.className = "figure-drawio-preview-img", h.style.display = "none";
1870
- const C = document.createElement("div");
1871
- C.className = "figure-drawio-view-hint", N.append(h, C), c.append(l, o, m), c.append(f, y), c.append(N);
1882
+ S.className = "figure-mermaid-error-inline", T.append(S, x, C), y.append(w, T);
1883
+ const A = document.createElement("div");
1884
+ A.className = "figure-drawio-view", A.contentEditable = "false";
1885
+ const u = document.createElement("img");
1886
+ u.className = "figure-drawio-preview-img", u.style.display = "none";
1887
+ const v = document.createElement("div");
1888
+ v.className = "figure-drawio-view-hint", A.append(u, v), o.append(l, c, g), o.append(h, y), o.append(A);
1872
1889
  const _ = document.createElement("figcaption");
1873
1890
  _.className = "figure-caption";
1874
- const A = document.createElement("span");
1875
- A.className = "figure-id-label", A.contentEditable = "false";
1891
+ const N = document.createElement("span");
1892
+ N.className = "figure-id-label", N.contentEditable = "false";
1876
1893
  const D = document.createElement("span");
1877
- D.className = "figure-caption-content", _.append(A, D), s.append(c, _);
1894
+ D.className = "figure-caption-content", _.append(N, D), s.append(o, _);
1878
1895
  const z = (E) => {
1879
1896
  const k = typeof n == "function" ? n() : null;
1880
- typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(P), !0));
1881
- }, Q = (E) => {
1897
+ typeof k == "number" && e.commands.command(({ tr: L, dispatch: O }) => (L.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(L), !0));
1898
+ }, ee = (E) => {
1882
1899
  if (!E || E.length === 0) return;
1883
1900
  const k = E[0];
1884
1901
  if (!k.type.startsWith("image/")) return;
1885
- const P = new FileReader();
1886
- P.onload = () => {
1887
- typeof P.result == "string" && z({ imageSrc: P.result });
1888
- }, P.readAsDataURL(k);
1902
+ const L = new FileReader();
1903
+ L.onload = () => {
1904
+ typeof L.result == "string" && z({ imageSrc: L.result });
1905
+ }, L.readAsDataURL(k);
1889
1906
  };
1890
- u.addEventListener("change", () => Q(u.files)), o.addEventListener("click", () => u.click()), m.addEventListener("click", (E) => {
1891
- E.stopPropagation(), u.click();
1892
- }), c.addEventListener("dragover", (E) => {
1893
- r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), o.classList.add("figure-upload-area--dragover"));
1894
- }), c.addEventListener("dragleave", () => {
1895
- o.classList.remove("figure-upload-area--dragover");
1896
- }), c.addEventListener("drop", (E) => {
1907
+ m.addEventListener("change", () => ee(m.files)), c.addEventListener("click", () => m.click()), g.addEventListener("click", (E) => {
1908
+ E.stopPropagation(), m.click();
1909
+ }), o.addEventListener("dragover", (E) => {
1910
+ r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), c.classList.add("figure-upload-area--dragover"));
1911
+ }), o.addEventListener("dragleave", () => {
1912
+ c.classList.remove("figure-upload-area--dragover");
1913
+ }), o.addEventListener("drop", (E) => {
1897
1914
  var k;
1898
- o.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), Q(((k = E.dataTransfer) == null ? void 0 : k.files) ?? null));
1915
+ c.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), ee(((k = E.dataTransfer) == null ? void 0 : k.files) ?? null));
1899
1916
  });
1900
1917
  const gn = () => {
1901
- a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
1918
+ a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", K(), requestAnimationFrame(() => w.focus()));
1902
1919
  }, fn = () => {
1903
- a = !1, J();
1920
+ a = !1, K();
1904
1921
  }, pn = async () => {
1905
1922
  const E = w.value;
1906
1923
  S.textContent = "", S.style.display = "none";
1907
1924
  const k = E.trim();
1908
1925
  if (k)
1909
1926
  try {
1910
- const P = await import("mermaid");
1911
- P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
1912
- const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
1913
- p.innerHTML = R, Le();
1927
+ const L = await import("mermaid");
1928
+ L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
1929
+ const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
1930
+ p.innerHTML = R, Pe();
1914
1931
  } catch {
1915
- Le();
1916
- const P = I.getState().editorLanguage;
1917
- S.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", S.style.display = "inline";
1932
+ Pe();
1933
+ const L = I.getState().editorLanguage;
1934
+ S.textContent = L === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", S.style.display = "inline";
1918
1935
  return;
1919
1936
  }
1920
- z({ mermaidCode: E }), a = !1, J();
1937
+ z({ mermaidCode: E }), a = !1, K();
1921
1938
  };
1922
- f.addEventListener("dblclick", (E) => {
1939
+ h.addEventListener("dblclick", (E) => {
1923
1940
  E.preventDefault(), E.stopPropagation(), gn();
1924
- }), v.addEventListener("click", (E) => {
1941
+ }), C.addEventListener("click", (E) => {
1925
1942
  E.stopPropagation(), pn();
1926
1943
  }), x.addEventListener("click", (E) => {
1927
1944
  E.stopPropagation(), fn();
1928
1945
  }), w.addEventListener("mousedown", (E) => E.stopPropagation()), w.addEventListener("keydown", (E) => E.stopPropagation()), w.addEventListener("keypress", (E) => E.stopPropagation());
1929
- let ee = null, G = null, U = null;
1946
+ let te = null, V = null, U = null;
1930
1947
  const hn = () => {
1931
1948
  if (i) return;
1932
- i = !0, J(), G = document.createElement("div"), G.className = "drawio-modal-overlay";
1949
+ i = !0, K(), V = document.createElement("div"), V.className = "drawio-modal-overlay";
1933
1950
  const E = document.createElement("div");
1934
1951
  E.className = "drawio-modal-content";
1935
1952
  const k = document.createElement("div");
1936
1953
  k.className = "drawio-modal-header";
1937
- const P = document.createElement("span"), O = I.getState().editorLanguage;
1938
- P.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", P.className = "drawio-modal-title";
1954
+ const L = document.createElement("span"), O = I.getState().editorLanguage;
1955
+ L.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", L.className = "drawio-modal-title";
1939
1956
  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), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), E.append(k, U), G.appendChild(E), document.body.appendChild(G);
1941
- const fe = O === "en" ? "en" : "zh";
1942
- U.src = `${de}/?embed=1&proto=json&spin=1&lang=${fe}`;
1943
- const K = U;
1944
- ee = (X) => {
1957
+ R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(L, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), E.append(k, U), V.appendChild(E), document.body.appendChild(V);
1958
+ const pe = O === "en" ? "en" : "zh";
1959
+ U.src = `${ue}/?embed=1&proto=json&spin=1&lang=${pe}`;
1960
+ const X = U;
1961
+ te = (Y) => {
1945
1962
  var oe, Te;
1946
- if (!K || X.source !== K.contentWindow) return;
1963
+ if (!X || Y.source !== X.contentWindow) return;
1947
1964
  let q;
1948
1965
  try {
1949
- q = typeof X.data == "string" ? JSON.parse(X.data) : X.data;
1966
+ q = typeof Y.data == "string" ? JSON.parse(Y.data) : Y.data;
1950
1967
  } catch {
1951
1968
  return;
1952
1969
  }
1953
1970
  if (q.event === "init") {
1954
1971
  const ce = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
1955
- (oe = K.contentWindow) == null || oe.postMessage(
1972
+ (oe = X.contentWindow) == null || oe.postMessage(
1956
1973
  JSON.stringify({ action: "load", autosave: 0, xml: ce || "" }),
1957
- de
1974
+ ue
1958
1975
  );
1959
1976
  } else if (q.event === "save") {
1960
1977
  const ce = q.xml || "";
1961
- (Te = K.contentWindow) == null || Te.postMessage(
1978
+ (Te = X.contentWindow) == null || Te.postMessage(
1962
1979
  JSON.stringify({ action: "export", format: "svg" }),
1963
- de
1980
+ ue
1964
1981
  ), z({ drawioXml: ce });
1965
1982
  } else if (q.event === "export") {
1966
1983
  const ce = q.data || "";
1967
1984
  z({ drawioSvg: ce }), We();
1968
1985
  } else q.event === "exit" && We();
1969
- }, window.addEventListener("message", ee);
1986
+ }, window.addEventListener("message", te);
1970
1987
  }, We = () => {
1971
- i = !1, ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null), J();
1988
+ i = !1, te && (window.removeEventListener("message", te), te = null), U && (U.src = "about:blank", U = null), V && (V.remove(), V = null), K();
1972
1989
  };
1973
- N.addEventListener("dblclick", (E) => {
1990
+ A.addEventListener("dblclick", (E) => {
1974
1991
  E.preventDefault(), E.stopPropagation(), hn();
1975
1992
  }), s.addEventListener("mousedown", (E) => {
1976
1993
  const k = E.target;
1977
- if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === o || o.contains(k) || k === m || k === u || f.contains(k) || N.contains(k)) return;
1978
- const P = typeof n == "function" ? n() : null;
1979
- if (typeof P != "number") return;
1980
- const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
1994
+ if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === c || c.contains(k) || k === g || k === m || h.contains(k) || A.contains(k)) return;
1995
+ const L = typeof n == "function" ? n() : null;
1996
+ if (typeof L != "number") return;
1997
+ const O = L + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
1981
1998
  e.view.dispatch(e.state.tr.setSelection(R));
1982
1999
  });
1983
- let xe = !1, se = null, me = null, Ce = 0;
2000
+ let xe = !1, se = null, ge = null, Ce = 0;
1984
2001
  const yn = 2, bn = 1500, vn = 3e3;
1985
- let ge = "";
2002
+ let fe = "";
1986
2003
  const wn = async (E) => {
1987
2004
  const k = E.trim();
1988
- if (k !== ge) {
2005
+ if (k !== fe) {
1989
2006
  if (!k) {
1990
- p.innerHTML = "", ge = "";
2007
+ p.innerHTML = "", fe = "";
1991
2008
  return;
1992
2009
  }
1993
2010
  try {
1994
- const P = await import("mermaid");
1995
- P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
1996
- const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
1997
- p.innerHTML = R, ge = k;
2011
+ const L = await import("mermaid");
2012
+ L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
2013
+ const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
2014
+ p.innerHTML = R, fe = k;
1998
2015
  } catch {
1999
- p.innerHTML = "", ge = "";
2016
+ p.innerHTML = "", fe = "";
2000
2017
  } finally {
2001
- Le();
2018
+ Pe();
2002
2019
  }
2003
2020
  }
2004
- }, J = () => {
2005
- const E = I.getState().editorLanguage, k = H(E), 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
- O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
2007
- const K = P === "image", X = P === "mermaid", q = P === "drawio";
2008
- l.style.display = K && R ? "block" : "none", o.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", N.style.display = q ? "flex" : "none", K && R && (l.src = R);
2021
+ }, K = () => {
2022
+ const E = I.getState().editorLanguage, k = H(E), L = ["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 : "", pe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2023
+ O ? (N.textContent = `[${O}] `, N.style.display = "inline") : (N.textContent = "", N.style.display = "none");
2024
+ const X = L === "image", Y = L === "mermaid", q = L === "drawio";
2025
+ l.style.display = X && R ? "block" : "none", c.style.display = X && !R ? "flex" : "none", g.style.display = X && R ? "block" : "none", h.style.display = Y && !a ? "block" : "none", y.style.display = Y && a ? "block" : "none", A.style.display = q ? "flex" : "none", X && R && (l.src = R);
2009
2026
  const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2010
- q && (oe ? (h.src = oe, h.style.display = "block") : (h.src = "", h.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", v.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
2011
- const Te = fe.trim().length > 0, ce = p.querySelector("svg") !== null;
2012
- X && !a && (Te && ce ? (b.textContent = k.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", b.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);
2027
+ q && (oe ? (u.src = oe, u.style.display = "block") : (u.src = "", u.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", g.textContent = k.figureReplaceImage || "更换图片", C.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
2028
+ const Te = pe.trim().length > 0, ce = p.querySelector("svg") !== null;
2029
+ Y && !a && (Te && ce ? (b.textContent = k.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", b.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), q && !i && (oe ? (v.textContent = k.mermaidDoubleClickToEdit || "双击编辑", v.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (v.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", v.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), Y && !a && pe.trim() !== fe && wn(pe);
2013
2030
  const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
2014
2031
  q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2015
2032
  se = null;
2016
2033
  const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2017
- !dt || Tn || xe || (xe = !0, Pa(dt, (ut) => {
2018
- xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, me = setTimeout(() => {
2019
- me = null, J();
2034
+ !dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
2035
+ xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, ge = setTimeout(() => {
2036
+ ge = null, K();
2020
2037
  }, vn * Ce));
2021
2038
  }));
2022
2039
  }, bn));
2023
2040
  };
2024
2041
  let lt = I.getState().editorLanguage;
2025
2042
  const xn = I.subscribe((E) => {
2026
- E.editorLanguage !== lt && (lt = E.editorLanguage, J());
2043
+ E.editorLanguage !== lt && (lt = E.editorLanguage, K());
2027
2044
  });
2028
- return J(), {
2045
+ return K(), {
2029
2046
  dom: s,
2030
2047
  contentDOM: D,
2031
2048
  stopEvent: (E) => {
2032
2049
  const k = E.target;
2033
- return !!(k === w || y.contains(k) || k === u);
2050
+ return !!(k === w || y.contains(k) || k === m);
2034
2051
  },
2035
2052
  ignoreMutation: (E) => {
2036
2053
  const k = E.target;
2037
- return !!(c.contains(k) || A.contains(k));
2054
+ return !!(o.contains(k) || N.contains(k));
2038
2055
  },
2039
- update: (E) => E.type.name !== "figure" ? !1 : (r = E, J(), !0),
2056
+ update: (E) => E.type.name !== "figure" ? !1 : (r = E, K(), !0),
2040
2057
  destroy: () => {
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);
2058
+ se && (clearTimeout(se), se = null), ge && (clearTimeout(ge), ge = null), xn(), Pe(), te && (window.removeEventListener("message", te), te = null), U && (U.src = "about:blank", U = null), V && (V.remove(), V = null);
2042
2059
  }
2043
2060
  };
2044
2061
  };
2045
2062
  }
2046
- }), Ra = Z.create({
2063
+ }), Ma = Q.create({
2047
2064
  name: "reference",
2048
2065
  group: "inline",
2049
2066
  inline: !0,
@@ -2104,22 +2121,22 @@ const Le = () => {
2104
2121
  return ({ node: e, editor: t }) => {
2105
2122
  let n = e;
2106
2123
  const r = document.createElement("span"), a = () => {
2107
- const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), c = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), o = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = c === "figure" ? o || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? s.claimLabel(l) : 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 : c === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2124
+ const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), o = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), c = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = o === "figure" ? c || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? s.claimLabel(l) : i === "en" ? "Claim ?" : "权利要求?", m = n.attrs.displayText || d;
2125
+ 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 ? s.referenceNavigateDisabledTitle : o === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2109
2126
  };
2110
2127
  return a(), r.addEventListener("click", () => {
2111
2128
  const i = n.attrs.targetType === "figure" ? "figure" : "claim";
2112
2129
  n.attrs.invalid || setTimeout(() => {
2113
2130
  let s = null;
2114
2131
  if (i === "figure") {
2115
- const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
- if (!c)
2132
+ const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2133
+ if (!o)
2117
2134
  return;
2118
- t.state.doc.descendants((l, o) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === c ? (s = o, !1) : !0);
2135
+ t.state.doc.descendants((l, c) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === o ? (s = c, !1) : !0);
2119
2136
  } else {
2120
2137
  if (!n.attrs.targetClaimId)
2121
2138
  return;
2122
- t.state.doc.descendants((c, l) => s !== null ? !1 : c.type.name === "claim" && c.attrs.claimId === n.attrs.targetClaimId ? (s = l, !1) : !0);
2139
+ t.state.doc.descendants((o, l) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = l, !1) : !0);
2123
2140
  }
2124
2141
  typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
2125
2142
  }, 0);
@@ -2144,7 +2161,7 @@ const Le = () => {
2144
2161
  design_description: "sectionTitle_design_description",
2145
2162
  design_views: "sectionTitle_design_views",
2146
2163
  design_brief: "sectionTitle_design_brief"
2147
- }, Ma = /* @__PURE__ */ new Set([
2164
+ }, Fa = /* @__PURE__ */ new Set([
2148
2165
  "abstract",
2149
2166
  "abstract_drawing",
2150
2167
  "claims",
@@ -2155,7 +2172,7 @@ const Le = () => {
2155
2172
  "design_description",
2156
2173
  "design_views",
2157
2174
  "design_brief"
2158
- ]), Fa = /* @__PURE__ */ new Set([
2175
+ ]), $a = /* @__PURE__ */ new Set([
2159
2176
  "technical_field",
2160
2177
  "background_art",
2161
2178
  "summary",
@@ -2170,7 +2187,7 @@ const Le = () => {
2170
2187
  return e.forEach((n) => {
2171
2188
  !t && ot(n) && (t = !0);
2172
2189
  }), t;
2173
- }, $a = Z.create({
2190
+ }, za = Q.create({
2174
2191
  name: "patent_title",
2175
2192
  group: "block",
2176
2193
  content: "inline*",
@@ -2199,41 +2216,41 @@ const Le = () => {
2199
2216
  i.className = "pb-heading", i.contentEditable = "false";
2200
2217
  const s = document.createElement("div");
2201
2218
  s.className = "ps-placeholder", s.contentEditable = "false";
2202
- const c = document.createElement("h1");
2203
- c.className = "pt-title-content", a.append(i, s, c);
2219
+ const o = document.createElement("h1");
2220
+ o.className = "pt-title-content", a.append(i, s, o);
2204
2221
  const l = () => {
2205
2222
  const b = typeof n == "function" ? n() : null;
2206
2223
  return typeof b == "number" ? b : null;
2207
- }, o = () => {
2224
+ }, c = () => {
2208
2225
  const b = l();
2209
2226
  b !== null && I.getState().setActiveSection("patent_title", b);
2210
2227
  }, d = () => {
2211
2228
  const b = l();
2212
2229
  b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
2213
2230
  };
2214
- s.addEventListener("click", d), c.addEventListener("focusin", o), c.addEventListener("click", o);
2215
- const u = () => {
2231
+ s.addEventListener("click", d), o.addEventListener("focusin", c), o.addEventListener("click", c);
2232
+ const m = () => {
2216
2233
  const b = I.getState(), y = H(b.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", T = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
2234
  i.textContent = w;
2218
- const v = ot(r), x = b.rightPanel.activeSectionPos === l();
2219
- s.textContent = `[${T}]`, s.style.display = v ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !v), c.classList.toggle("pt-title-content--has-content", v);
2235
+ const C = ot(r), x = b.rightPanel.activeSectionPos === l();
2236
+ s.textContent = `[${T}]`, s.style.display = C ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !C), o.classList.toggle("pt-title-content--has-content", C);
2220
2237
  };
2221
- let m = I.getState().editorLanguage, f = I.getState().rightPanel.activeSectionPos;
2238
+ let g = I.getState().editorLanguage, h = I.getState().rightPanel.activeSectionPos;
2222
2239
  const p = I.subscribe((b) => {
2223
- const y = b.editorLanguage !== m, w = b.rightPanel.activeSectionPos !== f;
2224
- m = b.editorLanguage, f = b.rightPanel.activeSectionPos, (y || w) && u();
2240
+ const y = b.editorLanguage !== g, w = b.rightPanel.activeSectionPos !== h;
2241
+ g = b.editorLanguage, h = b.rightPanel.activeSectionPos, (y || w) && m();
2225
2242
  });
2226
- return u(), {
2243
+ return m(), {
2227
2244
  dom: a,
2228
- contentDOM: c,
2229
- update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, u(), !0),
2245
+ contentDOM: o,
2246
+ update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, m(), !0),
2230
2247
  destroy: () => {
2231
- p(), s.removeEventListener("click", d), c.removeEventListener("focusin", o), c.removeEventListener("click", o);
2248
+ p(), s.removeEventListener("click", d), o.removeEventListener("focusin", c), o.removeEventListener("click", c);
2232
2249
  }
2233
2250
  };
2234
2251
  };
2235
2252
  }
2236
- }), za = Z.create({
2253
+ }), Oa = Q.create({
2237
2254
  name: "patent_section",
2238
2255
  group: "block",
2239
2256
  content: "block+",
@@ -2300,57 +2317,57 @@ const Le = () => {
2300
2317
  i.contentEditable = "false";
2301
2318
  const s = document.createElement("div");
2302
2319
  s.className = "ps-body";
2303
- const c = document.createElement("div");
2304
- c.className = "ps-placeholder", c.contentEditable = "false";
2320
+ const o = document.createElement("div");
2321
+ o.className = "ps-placeholder", o.contentEditable = "false";
2305
2322
  const l = document.createElement("div");
2306
- l.className = "ps-content", s.append(c, l), a.append(i, s);
2307
- const o = () => {
2323
+ l.className = "ps-content", s.append(o, l), a.append(i, s);
2324
+ const c = () => {
2308
2325
  const y = typeof n == "function" ? n() : null;
2309
2326
  return typeof y == "number" ? y : null;
2310
2327
  }, d = () => {
2311
- const y = o();
2328
+ const y = c();
2312
2329
  if (y === null) return;
2313
2330
  I.getState().setActiveSection(r.attrs.sectionType, y);
2314
- }, u = () => {
2315
- const y = o();
2331
+ }, m = () => {
2332
+ const y = c();
2316
2333
  if (y === null) return;
2317
2334
  I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2318
2335
  };
2319
- c.addEventListener("click", u), l.addEventListener("focusin", d), l.addEventListener("click", d);
2320
- const m = () => {
2321
- const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v = Ma.has(T), x = Fa.has(T), S = wt[T], N = typeof w[S] == "string" ? w[S] : T, h = ot(r), C = y.rightPanel.activeSectionPos === o();
2322
- a.className = `ps${h ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = v ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = N, c.textContent = `[${N}]`, c.style.display = h ? "none" : "", c.classList.toggle("ps-placeholder--active", C && !h), l.classList.toggle("ps-content--has-content", h);
2336
+ o.addEventListener("click", m), l.addEventListener("focusin", d), l.addEventListener("click", d);
2337
+ const g = () => {
2338
+ const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Fa.has(T), x = $a.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
2339
+ a.className = `ps${u ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = A, o.textContent = `[${A}]`, o.style.display = u ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !u), l.classList.toggle("ps-content--has-content", u);
2323
2340
  };
2324
- let f = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2341
+ let h = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2325
2342
  const b = I.subscribe((y) => {
2326
- const w = y.editorLanguage !== f, T = y.rightPanel.activeSectionPos !== p;
2327
- f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || T) && m();
2343
+ const w = y.editorLanguage !== h, T = y.rightPanel.activeSectionPos !== p;
2344
+ h = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || T) && g();
2328
2345
  });
2329
- return m(), {
2346
+ return g(), {
2330
2347
  dom: a,
2331
2348
  contentDOM: l,
2332
- update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
2349
+ update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, g(), !0),
2333
2350
  destroy: () => {
2334
- b(), c.removeEventListener("click", u), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2351
+ b(), o.removeEventListener("click", m), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2335
2352
  }
2336
2353
  };
2337
2354
  };
2338
2355
  }
2339
- }), Oa = [
2356
+ }), Ba = [
2340
2357
  "abstract",
2341
2358
  // 说明书摘要
2342
2359
  "abstract_drawing"
2343
2360
  // 摘要附图
2344
- ], Ba = [
2361
+ ], Ha = [
2345
2362
  "technical_field",
2346
2363
  "background_art",
2347
2364
  "summary",
2348
2365
  "drawing_description",
2349
2366
  "detailed_description"
2350
- ], Ha = [
2367
+ ], Ua = [
2351
2368
  "drawing_figures"
2352
2369
  // 说明书附图
2353
- ], Ua = [
2370
+ ], qa = [
2354
2371
  "design_product_name",
2355
2372
  "design_usage",
2356
2373
  "design_description",
@@ -2370,46 +2387,46 @@ const Le = () => {
2370
2387
  }), en = () => ({
2371
2388
  type: "patent_title",
2372
2389
  content: []
2373
- }), qa = () => [
2374
- ...Oa.map(Fe),
2375
- en(),
2390
+ }), Wa = () => [
2376
2391
  ...Ba.map(Fe),
2377
- ...Ha.map(Fe)
2378
- ], Wa = () => [
2379
2392
  en(),
2393
+ ...Ha.map(Fe),
2380
2394
  ...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) => {
2395
+ ], ja = () => [
2396
+ en(),
2397
+ ...qa.map(Fe)
2398
+ ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2382
2399
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2383
2400
  ve(e).forEach((i) => {
2384
- const s = V(i.node.attrs.id);
2401
+ const s = J(i.node.attrs.id);
2385
2402
  s && r.add(s);
2386
2403
  });
2387
2404
  let a = 1;
2388
2405
  for (; r.has(`${n}${a}`); )
2389
2406
  a += 1;
2390
2407
  return `${n}${a}`;
2391
- }, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
2408
+ }, Ga = /^(Fig\.|图)(\d+)$/, Va = (e) => {
2392
2409
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2393
2410
  if (r.length === 0) return;
2394
2411
  const a = [];
2395
2412
  let i = 1;
2396
- for (const c of r) {
2397
- const l = V(c.node.attrs.id);
2398
- if (!ja.exec(l)) continue;
2413
+ for (const o of r) {
2414
+ const l = J(o.node.attrs.id);
2415
+ if (!Ga.exec(l)) continue;
2399
2416
  const d = `${n}${i}`;
2400
- l !== d && a.push({ pos: c.pos, expectedId: d, currentId: l }), i++;
2417
+ l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
2401
2418
  }
2402
2419
  if (a.length === 0) return;
2403
2420
  const { tr: s } = e.state;
2404
- for (const c of a) {
2405
- const l = s.doc.nodeAt(c.pos);
2406
- !l || l.type.name !== "figure" || s.setNodeMarkup(c.pos, void 0, { ...l.attrs, id: c.expectedId });
2421
+ for (const o of a) {
2422
+ const l = s.doc.nodeAt(o.pos);
2423
+ !l || l.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...l.attrs, id: o.expectedId });
2407
2424
  }
2408
2425
  s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
2409
2426
  }, nn = (e) => {
2410
2427
  const t = /* @__PURE__ */ new Map();
2411
2428
  return ve(e).forEach((n) => {
2412
- const r = V(n.node.attrs.id);
2429
+ const r = J(n.node.attrs.id);
2413
2430
  r && t.set(r, {
2414
2431
  id: r,
2415
2432
  pos: n.pos
@@ -2422,28 +2439,28 @@ const Le = () => {
2422
2439
  const t = nn(e), n = rn();
2423
2440
  e.commands.command(({ tr: r, state: a, dispatch: i }) => {
2424
2441
  let s = !1;
2425
- return a.doc.descendants((c, l) => {
2426
- if (c.type.name !== "reference" || c.attrs.targetType !== "figure")
2442
+ return a.doc.descendants((o, l) => {
2443
+ if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
2427
2444
  return !0;
2428
- const o = typeof c.attrs.targetFigureId == "string" && c.attrs.targetFigureId ? V(c.attrs.targetFigureId) : null, d = o ? t.get(o) : void 0, u = d ? d.id : null, m = !d, f = an(n, u, m), p = {
2429
- ...c.attrs,
2445
+ const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? J(o.attrs.targetFigureId) : null, d = c ? t.get(c) : void 0, m = d ? d.id : null, g = !d, h = an(n, m, g), p = {
2446
+ ...o.attrs,
2430
2447
  targetType: "figure",
2431
- targetFigureId: o,
2432
- resolvedFigureId: u,
2433
- invalid: m,
2448
+ targetFigureId: c,
2449
+ resolvedFigureId: m,
2450
+ invalid: g,
2434
2451
  lang: n,
2435
- displayText: f,
2436
- target: u || c.attrs.target || o || null
2452
+ displayText: h,
2453
+ target: m || o.attrs.target || c || null
2437
2454
  };
2438
2455
  return Object.keys(p).some(
2439
- (y) => p[y] !== c.attrs[y]
2456
+ (y) => p[y] !== o.attrs[y]
2440
2457
  ) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
2441
2458
  }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2442
2459
  });
2443
- }, Va = {
2460
+ }, Ja = {
2444
2461
  name: "patent",
2445
2462
  version: "1.0.0",
2446
- extensions: [Da, Ra, $a, za],
2463
+ extensions: [Ra, Ma, za, Oa],
2447
2464
  toolbarItems: [
2448
2465
  {
2449
2466
  id: "patent-figure-insert",
@@ -2467,12 +2484,12 @@ const Le = () => {
2467
2484
  const r = n.lang === "en" ? "en" : "zh";
2468
2485
  I.getState().setEditorLanguage(r);
2469
2486
  const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
2470
- return e.commands.command(({ tr: c, state: l, dispatch: o }) => {
2487
+ return e.commands.command(({ tr: o, state: l, dispatch: c }) => {
2471
2488
  let d = !1;
2472
- return l.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (c.setNodeMarkup(m, void 0, {
2473
- ...u.attrs,
2489
+ return l.doc.descendants((m, g) => (m.type.name !== "reference" || i && g !== i.pos || m.attrs.lang !== r && (o.setNodeMarkup(g, void 0, {
2490
+ ...m.attrs,
2474
2491
  lang: r
2475
- }), d = !0), !0)), d && o && (c.setMeta("addToHistory", !1), o(c)), !0;
2492
+ }), d = !0), !0)), d && c && (o.setMeta("addToHistory", !1), c(o)), !0;
2476
2493
  }) ? (Je(e), !0) : !1;
2477
2494
  }
2478
2495
  },
@@ -2482,7 +2499,7 @@ const Le = () => {
2482
2499
  shortcut: "Ctrl+Shift+F",
2483
2500
  isActive: ({ editor: e }) => e.isActive("figure"),
2484
2501
  execute: ({ editor: e }, t) => {
2485
- const n = typeof t == "object" && t ? t : {}, r = V(n.id) || xt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
2502
+ const n = typeof t == "object" && t ? t : {}, r = J(n.id) || xt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
2486
2503
  return e.chain().focus().insertContent({
2487
2504
  type: "figure",
2488
2505
  attrs: { id: r, contentType: a, imageSrc: "", mermaidCode: "", drawioXml: "" },
@@ -2500,14 +2517,14 @@ const Le = () => {
2500
2517
  const i = e.state.doc.nodeAt(a);
2501
2518
  if (!i || i.type.name !== "figure")
2502
2519
  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))
2520
+ const o = (typeof n.id == "string" ? J(n.id) : J(i.attrs.id)) || xt(e);
2521
+ if (ve(e).some((d) => d.pos === a ? !1 : J(d.node.attrs.id) === o))
2505
2522
  return !1;
2506
- const o = { id: c };
2507
- return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (o.contentType = n.contentType), typeof n.imageSrc == "string" && (o.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (o.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (o.drawioXml = n.drawioXml), ze(e, {
2523
+ const c = { id: o };
2524
+ return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (c.contentType = n.contentType), typeof n.imageSrc == "string" && (c.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (c.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (c.drawioXml = n.drawioXml), ze(e, {
2508
2525
  type: "figure",
2509
2526
  position: a,
2510
- attrs: o
2527
+ attrs: c
2511
2528
  });
2512
2529
  }
2513
2530
  },
@@ -2518,7 +2535,7 @@ const Le = () => {
2518
2535
  const t = /* @__PURE__ */ new Set();
2519
2536
  let n = !1;
2520
2537
  return ve(e).forEach((r) => {
2521
- const a = V(r.node.attrs.id);
2538
+ const a = J(r.node.attrs.id);
2522
2539
  if (a) {
2523
2540
  if (t.has(a)) {
2524
2541
  n = !0;
@@ -2541,13 +2558,13 @@ const Le = () => {
2541
2558
  return typeof n.targetFigureId == "string" && n.targetFigureId.trim().length > 0;
2542
2559
  },
2543
2560
  execute: ({ editor: e }, t) => {
2544
- const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ? V(n.targetFigureId) : "";
2561
+ const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ? J(n.targetFigureId) : "";
2545
2562
  if (!a)
2546
2563
  return !1;
2547
2564
  const i = r.get(a);
2548
2565
  if (!i)
2549
2566
  return !1;
2550
- const s = n.lang || rn(), c = n.displayText || an(s, i.id, !1);
2567
+ const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
2551
2568
  return e.chain().focus().insertContent({
2552
2569
  type: "reference",
2553
2570
  attrs: {
@@ -2558,7 +2575,7 @@ const Le = () => {
2558
2575
  resolvedFigureId: i.id,
2559
2576
  lang: s,
2560
2577
  invalid: !1,
2561
- displayText: c,
2578
+ displayText: o,
2562
2579
  target: n.target || i.id,
2563
2580
  highlight: !1
2564
2581
  }
@@ -2589,13 +2606,13 @@ const Le = () => {
2589
2606
  }
2590
2607
  },
2591
2608
  onStateChange: (e) => {
2592
- e.isDestroyed || (Ga(e), Je(e));
2609
+ e.isDestroyed || (Va(e), Je(e));
2593
2610
  }
2594
- }, Ja = [xa, Ta, ka, Va];
2595
- Ja.forEach((e) => B.register(e));
2596
- const Ka = (e = {}) => {
2611
+ }, Ka = [Ca, Sa, _a, Ja];
2612
+ Ka.forEach((e) => B.register(e));
2613
+ const Xa = (e = {}) => {
2597
2614
  const t = [
2598
- ...ya,
2615
+ ...ba,
2599
2616
  ...B.getExtensions(),
2600
2617
  ...e.extensions || []
2601
2618
  ];
@@ -2619,12 +2636,12 @@ const Ka = (e = {}) => {
2619
2636
  updateNodeAttrs: (t) => ze(e, t),
2620
2637
  removeNode: (t) => Zt(e, t),
2621
2638
  wrapSelection: (t) => Qt(e, t),
2622
- applyTransactionBatch: (t) => Aa(e, t),
2639
+ applyTransactionBatch: (t) => Pa(e, t),
2623
2640
  findNodeByType: (t, n) => st(e, t, n),
2624
2641
  findAncestorNode: (t) => Re(e, t),
2625
- findCurrentBlock: () => _a(e),
2642
+ findCurrentBlock: () => Ia(e),
2626
2643
  findNodesByPredicate: (t, n) => Xt(e, t, n)
2627
- }), Xa = ["history", "text", "structure", "format", "technical", "patent"], Ya = {
2644
+ }), Ya = ["history", "text", "structure", "format", "technical", "patent"], Za = {
2628
2645
  history: "groupHistory",
2629
2646
  text: "groupText",
2630
2647
  structure: "groupStructure",
@@ -2633,70 +2650,70 @@ const Ka = (e = {}) => {
2633
2650
  patent: "groupPatent"
2634
2651
  }, Xe = (e, t) => {
2635
2652
  if (t) {
2636
- const n = Ya[e];
2653
+ const n = Za[e];
2637
2654
  if (n && typeof t[n] == "string") return t[n];
2638
2655
  }
2639
2656
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
2640
2657
  }, Ct = ({ btn: e, items: t }) => {
2641
- const [n, r] = F(!1), a = W(null), i = W(null), [s, c] = F({ top: 0, left: 0 }), l = ae(() => {
2658
+ const [n, r] = M(!1), a = W(null), i = W(null), [s, o] = M({ top: 0, left: 0 }), l = j(() => {
2642
2659
  if (!a.current) return;
2643
- const o = a.current.getBoundingClientRect();
2644
- c({ top: o.bottom + 4, left: o.left });
2660
+ const c = a.current.getBoundingClientRect();
2661
+ o({ top: c.bottom + 4, left: c.left });
2645
2662
  }, []);
2646
- return M(() => {
2663
+ return F(() => {
2647
2664
  if (!n) return;
2648
2665
  l();
2649
- const o = (u) => {
2650
- var f, p;
2651
- const m = u.target;
2652
- (f = a.current) != null && f.contains(m) || (p = i.current) != null && p.contains(m) || r(!1);
2666
+ const c = (m) => {
2667
+ var h, p;
2668
+ const g = m.target;
2669
+ (h = a.current) != null && h.contains(g) || (p = i.current) != null && p.contains(g) || r(!1);
2653
2670
  }, d = () => l();
2654
- return document.addEventListener("mousedown", o), window.addEventListener("scroll", d, !0), () => {
2655
- document.removeEventListener("mousedown", o), window.removeEventListener("scroll", d, !0);
2671
+ return document.addEventListener("mousedown", c), window.addEventListener("scroll", d, !0), () => {
2672
+ document.removeEventListener("mousedown", c), window.removeEventListener("scroll", d, !0);
2656
2673
  };
2657
- }, [n, l]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2658
- /* @__PURE__ */ g(
2674
+ }, [n, l]), /* @__PURE__ */ P("div", { className: "flex items-center", children: [
2675
+ /* @__PURE__ */ f(
2659
2676
  "button",
2660
2677
  {
2661
2678
  onClick: e.run,
2662
2679
  disabled: e.disabled,
2663
- className: Y(
2680
+ className: Z(
2664
2681
  "p-2 rounded-l transition-colors",
2665
2682
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
2666
2683
  e.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
2667
2684
  ),
2668
2685
  title: e.tooltip,
2669
- children: /* @__PURE__ */ g(e.icon, { size: 18 })
2686
+ children: /* @__PURE__ */ f(e.icon, { size: 18 })
2670
2687
  }
2671
2688
  ),
2672
- /* @__PURE__ */ g(
2689
+ /* @__PURE__ */ f(
2673
2690
  "button",
2674
2691
  {
2675
2692
  ref: a,
2676
- onClick: () => r((o) => !o),
2677
- className: Y(
2693
+ onClick: () => r((c) => !c),
2694
+ className: Z(
2678
2695
  "px-1 py-2 rounded-r transition-colors border-l border-gray-200",
2679
2696
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
2680
2697
  ),
2681
2698
  disabled: e.disabled,
2682
- children: /* @__PURE__ */ g(qt, { size: 12 })
2699
+ children: /* @__PURE__ */ f(qt, { size: 12 })
2683
2700
  }
2684
2701
  ),
2685
2702
  n && yr(
2686
- /* @__PURE__ */ g(
2703
+ /* @__PURE__ */ f(
2687
2704
  "div",
2688
2705
  {
2689
2706
  ref: i,
2690
2707
  className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
2691
2708
  style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
2692
- children: t.map((o, d) => /* @__PURE__ */ g(
2709
+ children: t.map((c, d) => /* @__PURE__ */ f(
2693
2710
  "button",
2694
2711
  {
2695
2712
  onClick: () => {
2696
- o.onClick(), r(!1);
2713
+ c.onClick(), r(!1);
2697
2714
  },
2698
2715
  className: "block w-full text-left px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100",
2699
- children: o.label
2716
+ children: c.label
2700
2717
  },
2701
2718
  d
2702
2719
  ))
@@ -2705,28 +2722,28 @@ const Ka = (e = {}) => {
2705
2722
  document.body
2706
2723
  )
2707
2724
  ] });
2708
- }, Za = ({
2725
+ }, Qa = ({
2709
2726
  editor: e,
2710
- groupOrder: t = Xa,
2727
+ groupOrder: t = Ya,
2711
2728
  collapsibleGroups: n = !0,
2712
2729
  defaultCollapsedGroups: r = []
2713
2730
  }) => {
2714
- const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: c, setEditorLanguage: l } = I(), o = H(c);
2715
- if (M(() => {
2731
+ const [a, i] = M(() => new Set(r)), [, s] = M(0), { editorLanguage: o, setEditorLanguage: l } = I(), c = H(o);
2732
+ if (F(() => {
2716
2733
  if (!e) return;
2717
- const h = () => s((C) => C + 1);
2718
- return e.on("selectionUpdate", h), e.on("update", h), () => {
2719
- e.off("selectionUpdate", h), e.off("update", h);
2734
+ const u = () => s((v) => v + 1);
2735
+ return e.on("selectionUpdate", u), e.on("update", u), () => {
2736
+ e.off("selectionUpdate", u), e.off("update", u);
2720
2737
  };
2721
2738
  }, [e]), !e)
2722
2739
  return null;
2723
- const d = ct(e), u = c === "zh", m = [
2740
+ const d = ct(e), m = o === "zh", g = [
2724
2741
  {
2725
2742
  id: "core-undo",
2726
- label: o.undo,
2743
+ label: c.undo,
2727
2744
  group: "history",
2728
2745
  icon: br,
2729
- tooltip: `${o.undo} (Ctrl+Z)`,
2746
+ tooltip: `${c.undo} (Ctrl+Z)`,
2730
2747
  isActive: !1,
2731
2748
  disabled: !e.can().chain().focus().undo().run(),
2732
2749
  run: () => {
@@ -2735,10 +2752,10 @@ const Ka = (e = {}) => {
2735
2752
  },
2736
2753
  {
2737
2754
  id: "core-redo",
2738
- label: o.redo,
2755
+ label: c.redo,
2739
2756
  group: "history",
2740
2757
  icon: vr,
2741
- tooltip: `${o.redo} (Ctrl+Y)`,
2758
+ tooltip: `${c.redo} (Ctrl+Y)`,
2742
2759
  isActive: !1,
2743
2760
  disabled: !e.can().chain().focus().redo().run(),
2744
2761
  run: () => {
@@ -2747,10 +2764,10 @@ const Ka = (e = {}) => {
2747
2764
  },
2748
2765
  {
2749
2766
  id: "core-bold",
2750
- label: o.bold,
2767
+ label: c.bold,
2751
2768
  group: "text",
2752
2769
  icon: Dt,
2753
- tooltip: o.bold,
2770
+ tooltip: c.bold,
2754
2771
  isActive: e.isActive("bold"),
2755
2772
  disabled: !1,
2756
2773
  run: () => {
@@ -2759,10 +2776,10 @@ const Ka = (e = {}) => {
2759
2776
  },
2760
2777
  {
2761
2778
  id: "core-italic",
2762
- label: o.italic,
2779
+ label: c.italic,
2763
2780
  group: "text",
2764
2781
  icon: Rt,
2765
- tooltip: o.italic,
2782
+ tooltip: c.italic,
2766
2783
  isActive: e.isActive("italic"),
2767
2784
  disabled: !1,
2768
2785
  run: () => {
@@ -2771,10 +2788,10 @@ const Ka = (e = {}) => {
2771
2788
  },
2772
2789
  {
2773
2790
  id: "core-underline",
2774
- label: o.underline,
2791
+ label: c.underline,
2775
2792
  group: "text",
2776
2793
  icon: Mt,
2777
- tooltip: o.underline,
2794
+ tooltip: c.underline,
2778
2795
  isActive: e.isActive("underline"),
2779
2796
  disabled: !1,
2780
2797
  run: () => {
@@ -2783,10 +2800,10 @@ const Ka = (e = {}) => {
2783
2800
  },
2784
2801
  {
2785
2802
  id: "core-strike",
2786
- label: o.strike,
2803
+ label: c.strike,
2787
2804
  group: "text",
2788
2805
  icon: Ft,
2789
- tooltip: o.strike,
2806
+ tooltip: c.strike,
2790
2807
  isActive: e.isActive("strike"),
2791
2808
  disabled: !1,
2792
2809
  run: () => {
@@ -2795,10 +2812,10 @@ const Ka = (e = {}) => {
2795
2812
  },
2796
2813
  {
2797
2814
  id: "core-code",
2798
- label: o.code,
2815
+ label: c.code,
2799
2816
  group: "text",
2800
2817
  icon: $t,
2801
- tooltip: o.code,
2818
+ tooltip: c.code,
2802
2819
  isActive: e.isActive("code"),
2803
2820
  disabled: !1,
2804
2821
  run: () => {
@@ -2807,10 +2824,10 @@ const Ka = (e = {}) => {
2807
2824
  },
2808
2825
  {
2809
2826
  id: "core-superscript",
2810
- label: o.superscript,
2827
+ label: c.superscript,
2811
2828
  group: "text",
2812
2829
  icon: zt,
2813
- tooltip: `${o.superscript} (Ctrl+.)`,
2830
+ tooltip: `${c.superscript} (Ctrl+.)`,
2814
2831
  isActive: e.isActive("superscript"),
2815
2832
  disabled: !1,
2816
2833
  run: () => {
@@ -2819,10 +2836,10 @@ const Ka = (e = {}) => {
2819
2836
  },
2820
2837
  {
2821
2838
  id: "core-subscript",
2822
- label: o.subscript,
2839
+ label: c.subscript,
2823
2840
  group: "text",
2824
2841
  icon: Ot,
2825
- tooltip: `${o.subscript} (Ctrl+,)`,
2842
+ tooltip: `${c.subscript} (Ctrl+,)`,
2826
2843
  isActive: e.isActive("subscript"),
2827
2844
  disabled: !1,
2828
2845
  run: () => {
@@ -2831,10 +2848,10 @@ const Ka = (e = {}) => {
2831
2848
  },
2832
2849
  {
2833
2850
  id: "core-paragraph",
2834
- label: o.paragraph,
2851
+ label: c.paragraph,
2835
2852
  group: "structure",
2836
2853
  icon: wr,
2837
- tooltip: o.paragraph,
2854
+ tooltip: c.paragraph,
2838
2855
  isActive: e.isActive("paragraph"),
2839
2856
  disabled: !1,
2840
2857
  run: () => {
@@ -2846,7 +2863,7 @@ const Ka = (e = {}) => {
2846
2863
  label: "H1",
2847
2864
  group: "structure",
2848
2865
  icon: xr,
2849
- tooltip: o.heading1,
2866
+ tooltip: c.heading1,
2850
2867
  isActive: e.isActive("heading", { level: 1 }),
2851
2868
  disabled: !1,
2852
2869
  run: () => {
@@ -2858,7 +2875,7 @@ const Ka = (e = {}) => {
2858
2875
  label: "H2",
2859
2876
  group: "structure",
2860
2877
  icon: Cr,
2861
- tooltip: o.heading2,
2878
+ tooltip: c.heading2,
2862
2879
  isActive: e.isActive("heading", { level: 2 }),
2863
2880
  disabled: !1,
2864
2881
  run: () => {
@@ -2870,7 +2887,7 @@ const Ka = (e = {}) => {
2870
2887
  label: "H3",
2871
2888
  group: "structure",
2872
2889
  icon: Tr,
2873
- tooltip: o.heading3,
2890
+ tooltip: c.heading3,
2874
2891
  isActive: e.isActive("heading", { level: 3 }),
2875
2892
  disabled: !1,
2876
2893
  run: () => {
@@ -2879,10 +2896,10 @@ const Ka = (e = {}) => {
2879
2896
  },
2880
2897
  {
2881
2898
  id: "core-align-left",
2882
- label: o.alignLeft,
2899
+ label: c.alignLeft,
2883
2900
  group: "format",
2884
2901
  icon: Sr,
2885
- tooltip: o.alignLeft,
2902
+ tooltip: c.alignLeft,
2886
2903
  isActive: e.isActive({ textAlign: "left" }),
2887
2904
  disabled: !1,
2888
2905
  run: () => {
@@ -2891,10 +2908,10 @@ const Ka = (e = {}) => {
2891
2908
  },
2892
2909
  {
2893
2910
  id: "core-align-center",
2894
- label: o.alignCenter,
2911
+ label: c.alignCenter,
2895
2912
  group: "format",
2896
2913
  icon: Er,
2897
- tooltip: o.alignCenter,
2914
+ tooltip: c.alignCenter,
2898
2915
  isActive: e.isActive({ textAlign: "center" }),
2899
2916
  disabled: !1,
2900
2917
  run: () => {
@@ -2903,10 +2920,10 @@ const Ka = (e = {}) => {
2903
2920
  },
2904
2921
  {
2905
2922
  id: "core-align-right",
2906
- label: o.alignRight,
2923
+ label: c.alignRight,
2907
2924
  group: "format",
2908
2925
  icon: kr,
2909
- tooltip: o.alignRight,
2926
+ tooltip: c.alignRight,
2910
2927
  isActive: e.isActive({ textAlign: "right" }),
2911
2928
  disabled: !1,
2912
2929
  run: () => {
@@ -2915,10 +2932,10 @@ const Ka = (e = {}) => {
2915
2932
  },
2916
2933
  {
2917
2934
  id: "core-align-justify",
2918
- label: o.alignJustify,
2935
+ label: c.alignJustify,
2919
2936
  group: "format",
2920
2937
  icon: _r,
2921
- tooltip: o.alignJustify,
2938
+ tooltip: c.alignJustify,
2922
2939
  isActive: e.isActive({ textAlign: "justify" }),
2923
2940
  disabled: !1,
2924
2941
  run: () => {
@@ -2927,10 +2944,10 @@ const Ka = (e = {}) => {
2927
2944
  },
2928
2945
  {
2929
2946
  id: "core-bullet-list",
2930
- label: o.bulletList,
2947
+ label: c.bulletList,
2931
2948
  group: "structure",
2932
2949
  icon: Ir,
2933
- tooltip: o.bulletList,
2950
+ tooltip: c.bulletList,
2934
2951
  isActive: e.isActive("bulletList"),
2935
2952
  disabled: !1,
2936
2953
  run: () => {
@@ -2939,10 +2956,10 @@ const Ka = (e = {}) => {
2939
2956
  },
2940
2957
  {
2941
2958
  id: "core-ordered-list",
2942
- label: o.orderedList,
2959
+ label: c.orderedList,
2943
2960
  group: "structure",
2944
2961
  icon: Nr,
2945
- tooltip: o.orderedList,
2962
+ tooltip: c.orderedList,
2946
2963
  isActive: e.isActive("orderedList"),
2947
2964
  disabled: !1,
2948
2965
  run: () => {
@@ -2951,10 +2968,10 @@ const Ka = (e = {}) => {
2951
2968
  },
2952
2969
  {
2953
2970
  id: "core-blockquote",
2954
- label: o.blockquote,
2971
+ label: c.blockquote,
2955
2972
  group: "structure",
2956
2973
  icon: Ar,
2957
- tooltip: o.blockquote,
2974
+ tooltip: c.blockquote,
2958
2975
  isActive: e.isActive("blockquote"),
2959
2976
  disabled: !1,
2960
2977
  run: () => {
@@ -2963,10 +2980,10 @@ const Ka = (e = {}) => {
2963
2980
  },
2964
2981
  {
2965
2982
  id: "core-code-block",
2966
- label: o.codeBlock,
2983
+ label: c.codeBlock,
2967
2984
  group: "structure",
2968
- icon: Lr,
2969
- tooltip: o.codeBlock,
2985
+ icon: Pr,
2986
+ tooltip: c.codeBlock,
2970
2987
  isActive: e.isActive("codeBlock"),
2971
2988
  disabled: !1,
2972
2989
  run: () => {
@@ -2975,10 +2992,10 @@ const Ka = (e = {}) => {
2975
2992
  },
2976
2993
  {
2977
2994
  id: "core-table",
2978
- label: o.insertTable,
2995
+ label: c.insertTable,
2979
2996
  group: "structure",
2980
- icon: Pr,
2981
- tooltip: o.insertTable,
2997
+ icon: Lr,
2998
+ tooltip: c.insertTable,
2982
2999
  isActive: !1,
2983
3000
  disabled: !1,
2984
3001
  run: () => {
@@ -2987,10 +3004,10 @@ const Ka = (e = {}) => {
2987
3004
  },
2988
3005
  {
2989
3006
  id: "core-horizontal-rule",
2990
- label: o.horizontalRule,
3007
+ label: c.horizontalRule,
2991
3008
  group: "structure",
2992
3009
  icon: Dr,
2993
- tooltip: o.horizontalRule,
3010
+ tooltip: c.horizontalRule,
2994
3011
  isActive: !1,
2995
3012
  disabled: !1,
2996
3013
  run: () => {
@@ -2999,17 +3016,17 @@ const Ka = (e = {}) => {
2999
3016
  },
3000
3017
  {
3001
3018
  id: "core-task-list",
3002
- label: o.taskList,
3019
+ label: c.taskList,
3003
3020
  group: "structure",
3004
3021
  icon: Rr,
3005
- tooltip: o.taskList,
3022
+ tooltip: c.taskList,
3006
3023
  isActive: e.isActive("taskList"),
3007
3024
  disabled: !1,
3008
3025
  run: () => {
3009
3026
  e.chain().focus().toggleTaskList().run();
3010
3027
  }
3011
3028
  }
3012
- ], f = {
3029
+ ], h = {
3013
3030
  GitGraph: Or,
3014
3031
  Sigma: zr,
3015
3032
  FunctionSquare: $r,
@@ -3018,204 +3035,204 @@ const Ka = (e = {}) => {
3018
3035
  FileText: Ut,
3019
3036
  Link2: Ht,
3020
3037
  Image: Bt
3021
- }, p = B.getToolbarItems().map((h) => {
3022
- const C = B.getCommandMeta(h.command), _ = u && h.tooltipZh ? h.tooltipZh : h.tooltip || (C == null ? void 0 : C.description) || h.label, A = h.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${_} (${A})` : _;
3038
+ }, p = B.getToolbarItems().map((u) => {
3039
+ const v = B.getCommandMeta(u.command), _ = m && u.tooltipZh ? u.tooltipZh : u.tooltip || (v == null ? void 0 : v.description) || u.label, N = u.shortcut || (v == null ? void 0 : v.shortcut), D = N ? `${_} (${N})` : _;
3023
3040
  return {
3024
- id: h.id,
3025
- label: h.label,
3026
- group: h.group || "technical",
3027
- icon: h.icon ? f[h.icon] || mt : mt,
3028
- isActive: d.isCommandActive(h.command),
3029
- disabled: !d.canExecCommand(h.command),
3041
+ id: u.id,
3042
+ label: u.label,
3043
+ group: u.group || "technical",
3044
+ icon: u.icon ? h[u.icon] || mt : mt,
3045
+ isActive: d.isCommandActive(u.command),
3046
+ disabled: !d.canExecCommand(u.command),
3030
3047
  tooltip: D,
3031
3048
  run: () => {
3032
- d.execCommand(h.command);
3049
+ d.execCommand(u.command);
3033
3050
  }
3034
3051
  };
3035
- }), b = [...m, ...p], y = b.map((h) => h.group).filter((h, C, _) => _.indexOf(h) === C && !t.includes(h)), T = [...t, ...y].map((h) => ({
3036
- group: h,
3037
- items: b.filter((C) => C.group === h)
3038
- })).filter((h) => h.items.length > 0), v = (h) => {
3039
- i((C) => {
3040
- const _ = new Set(C);
3041
- return _.has(h) ? _.delete(h) : _.add(h), _;
3052
+ }), b = [...g, ...p], y = b.map((u) => u.group).filter((u, v, _) => _.indexOf(u) === v && !t.includes(u)), T = [...t, ...y].map((u) => ({
3053
+ group: u,
3054
+ items: b.filter((v) => v.group === u)
3055
+ })).filter((u) => u.items.length > 0), C = (u) => {
3056
+ i((v) => {
3057
+ const _ = new Set(v);
3058
+ return _.has(u) ? _.delete(u) : _.add(u), _;
3042
3059
  });
3043
3060
  }, x = [
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() }
3061
+ { label: m ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
3062
+ { label: m ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
3063
+ { label: m ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
3064
+ { label: m ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
3065
+ { label: m ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
3066
+ { label: m ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
3067
+ { label: m ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
3068
+ { label: m ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
3069
+ { label: m ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
3070
+ { label: m ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3071
+ { label: m ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3055
3072
  ], S = [
3056
- { label: o.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3057
- { label: o.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3058
- { label: o.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3059
- ], N = (h) => h.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: h, items: x }, h.id) : h.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: h, items: S }, h.id) : /* @__PURE__ */ g(
3073
+ { label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3074
+ { label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3075
+ { label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3076
+ ], A = (u) => u.id === "core-table" ? /* @__PURE__ */ f(Ct, { btn: u, items: x }, u.id) : u.id === "patent-figure-insert" ? /* @__PURE__ */ f(Ct, { btn: u, items: S }, u.id) : /* @__PURE__ */ f(
3060
3077
  "button",
3061
3078
  {
3062
- onClick: h.run,
3063
- disabled: h.disabled,
3064
- className: Y(
3079
+ onClick: u.run,
3080
+ disabled: u.disabled,
3081
+ className: Z(
3065
3082
  "p-2 rounded transition-colors",
3066
- h.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3067
- h.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3083
+ u.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3084
+ u.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3068
3085
  ),
3069
- title: h.tooltip,
3070
- children: /* @__PURE__ */ g(h.icon, { size: 18 })
3086
+ title: u.tooltip,
3087
+ children: /* @__PURE__ */ f(u.icon, { size: 18 })
3071
3088
  },
3072
- h.id
3089
+ u.id
3073
3090
  );
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: [
3075
- /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
3076
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.language }),
3077
- /* @__PURE__ */ L(
3091
+ return /* @__PURE__ */ f("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ P("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
3092
+ /* @__PURE__ */ P("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
3093
+ /* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: c.language }),
3094
+ /* @__PURE__ */ P(
3078
3095
  "select",
3079
3096
  {
3080
- value: c,
3081
- onChange: (h) => {
3082
- l(h.target.value === "en" ? "en" : "zh");
3097
+ value: o,
3098
+ onChange: (u) => {
3099
+ l(u.target.value === "en" ? "en" : "zh");
3083
3100
  },
3084
3101
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
3085
3102
  children: [
3086
- /* @__PURE__ */ g("option", { value: "zh", children: "中文" }),
3087
- /* @__PURE__ */ g("option", { value: "en", children: "English" })
3103
+ /* @__PURE__ */ f("option", { value: "zh", children: "中文" }),
3104
+ /* @__PURE__ */ f("option", { value: "en", children: "English" })
3088
3105
  ]
3089
3106
  }
3090
3107
  )
3091
3108
  ] }),
3092
- T.map((h) => {
3093
- const C = a.has(h.group);
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: [
3095
- n && /* @__PURE__ */ g(
3109
+ T.map((u) => {
3110
+ const v = a.has(u.group);
3111
+ return /* @__PURE__ */ P("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: [
3112
+ n && /* @__PURE__ */ f(
3096
3113
  "button",
3097
3114
  {
3098
3115
  onClick: () => {
3099
- v(h.group);
3116
+ C(u.group);
3100
3117
  },
3101
3118
  className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
3102
- title: C ? `${o.expand} ${Xe(h.group, o)}` : `${o.collapse} ${Xe(h.group, o)}`,
3103
- children: Xe(h.group, o)
3119
+ title: v ? `${c.expand} ${Xe(u.group, c)}` : `${c.collapse} ${Xe(u.group, c)}`,
3120
+ children: Xe(u.group, c)
3104
3121
  }
3105
3122
  ),
3106
- (!n || !C) && h.items.map(N)
3107
- ] }, h.group);
3123
+ (!n || !v) && u.items.map(A)
3124
+ ] }, u.group);
3108
3125
  })
3109
3126
  ] }) });
3110
- }, Qa = ({ editor: e }) => {
3111
- const [t, n] = F(0), [r, a] = F(""), i = I((x) => x.editorLanguage), s = H(i);
3112
- if (M(() => {
3127
+ }, ei = ({ editor: e }) => {
3128
+ const [t, n] = M(0), [r, a] = M(""), i = I((x) => x.editorLanguage), s = H(i);
3129
+ if (F(() => {
3113
3130
  if (!e) return;
3114
3131
  const x = () => n((S) => S + 1);
3115
3132
  return e.on("selectionUpdate", x), e.on("update", x), () => {
3116
3133
  e.off("selectionUpdate", x), e.off("update", x);
3117
3134
  };
3118
3135
  }, [e]), !e) return null;
3119
- const c = ct(e), l = [];
3136
+ const o = ct(e), l = [];
3120
3137
  e.state.doc.descendants((x) => {
3121
3138
  if (x.type.name !== "figure") return !0;
3122
3139
  const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
3123
3140
  return S && l.push({ id: S, label: S }), !0;
3124
3141
  });
3125
- const o = c.findAncestorNode("figure"), d = !!o, u = o && typeof o.node.attrs.id == "string" ? o.node.attrs.id.trim() : "", m = o && typeof o.node.attrs.contentType == "string" ? o.node.attrs.contentType : "image", [f, p] = F(""), b = W(null), y = W(null), w = (o == null ? void 0 : o.pos) ?? null;
3126
- w !== y.current && (y.current = w, d && u !== f && p(u));
3142
+ const c = o.findAncestorNode("figure"), d = !!c, m = c && typeof c.node.attrs.id == "string" ? c.node.attrs.id.trim() : "", g = c && typeof c.node.attrs.contentType == "string" ? c.node.attrs.contentType : "image", [h, p] = M(""), b = W(null), y = W(null), w = (c == null ? void 0 : c.pos) ?? null;
3143
+ w !== y.current && (y.current = w, d && m !== h && p(m));
3127
3144
  const T = (x) => {
3128
- o && c.execCommand("patent.updateFigure", {
3129
- position: o.pos,
3145
+ c && o.execCommand("patent.updateFigure", {
3146
+ position: c.pos,
3130
3147
  contentType: x
3131
3148
  });
3132
- }, v = () => {
3133
- if (!o) return;
3134
- const x = f.trim();
3135
- x !== u && c.execCommand("patent.updateFigure", {
3136
- position: o.pos,
3149
+ }, C = () => {
3150
+ if (!c) return;
3151
+ const x = h.trim();
3152
+ x !== m && o.execCommand("patent.updateFigure", {
3153
+ position: c.pos,
3137
3154
  id: x
3138
3155
  });
3139
3156
  };
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: [
3141
- l.length > 0 && /* @__PURE__ */ L(je, { children: [
3142
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
3143
- /* @__PURE__ */ L(
3157
+ return /* @__PURE__ */ f("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ P("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
3158
+ l.length > 0 && /* @__PURE__ */ P(je, { children: [
3159
+ /* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
3160
+ /* @__PURE__ */ P(
3144
3161
  "select",
3145
3162
  {
3146
3163
  value: r || "__none__",
3147
3164
  onChange: (x) => a(x.target.value === "__none__" ? "" : x.target.value),
3148
3165
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3149
3166
  children: [
3150
- /* @__PURE__ */ g("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
3151
- l.map((x) => /* @__PURE__ */ g("option", { value: x.id, children: x.label }, x.id))
3167
+ /* @__PURE__ */ f("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
3168
+ l.map((x) => /* @__PURE__ */ f("option", { value: x.id, children: x.label }, x.id))
3152
3169
  ]
3153
3170
  }
3154
3171
  ),
3155
- /* @__PURE__ */ g(
3172
+ /* @__PURE__ */ f(
3156
3173
  "button",
3157
3174
  {
3158
3175
  onClick: () => {
3159
- r && c.execCommand("patent.insertFigureReference", {
3176
+ r && o.execCommand("patent.insertFigureReference", {
3160
3177
  targetType: "figure",
3161
3178
  targetFigureId: r
3162
3179
  });
3163
3180
  },
3164
3181
  className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
3165
3182
  title: s.insertFigureReference,
3166
- children: /* @__PURE__ */ g(Bt, { size: 16 })
3183
+ children: /* @__PURE__ */ f(Bt, { size: 16 })
3167
3184
  }
3168
3185
  )
3169
3186
  ] }),
3170
- /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
3171
- d && /* @__PURE__ */ L(je, { children: [
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 }),
3174
- /* @__PURE__ */ g(
3187
+ /* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
3188
+ d && /* @__PURE__ */ P(je, { children: [
3189
+ /* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: s.currentFigure }),
3190
+ /* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureId }),
3191
+ /* @__PURE__ */ f(
3175
3192
  "input",
3176
3193
  {
3177
3194
  ref: b,
3178
3195
  type: "text",
3179
- value: f,
3196
+ value: h,
3180
3197
  onChange: (x) => p(x.target.value),
3181
- onBlur: v,
3198
+ onBlur: C,
3182
3199
  onKeyDown: (x) => {
3183
- x.key === "Enter" && (v(), x.target.blur());
3200
+ x.key === "Enter" && (C(), x.target.blur());
3184
3201
  },
3185
3202
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
3186
3203
  placeholder: i === "en" ? "Fig.1" : "图1"
3187
3204
  }
3188
3205
  ),
3189
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
3190
- /* @__PURE__ */ L(
3206
+ /* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
3207
+ /* @__PURE__ */ P(
3191
3208
  "select",
3192
3209
  {
3193
- value: m,
3210
+ value: g,
3194
3211
  onChange: (x) => T(x.target.value),
3195
3212
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3196
3213
  children: [
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 })
3214
+ /* @__PURE__ */ f("option", { value: "image", children: s.figureContentTypeImage }),
3215
+ /* @__PURE__ */ f("option", { value: "mermaid", children: s.figureContentTypeMermaid }),
3216
+ /* @__PURE__ */ f("option", { value: "drawio", children: s.figureContentTypeDrawio })
3200
3217
  ]
3201
3218
  }
3202
3219
  ),
3203
- /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3220
+ /* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3204
3221
  ] }),
3205
3222
  e.isActive("image") && (() => {
3206
3223
  const S = e.getAttributes("image").width || "";
3207
- return /* @__PURE__ */ L(je, { children: [
3208
- /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
3209
- ["25%", "50%", "75%", "100%"].map((h) => /* @__PURE__ */ g(
3224
+ return /* @__PURE__ */ P(je, { children: [
3225
+ /* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
3226
+ ["25%", "50%", "75%", "100%"].map((u) => /* @__PURE__ */ f(
3210
3227
  "button",
3211
3228
  {
3212
- onClick: () => e.chain().focus().updateAttributes("image", { width: h }).run(),
3213
- className: `text-xs px-2 py-0.5 rounded border ${S === h ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3214
- children: h
3229
+ onClick: () => e.chain().focus().updateAttributes("image", { width: u }).run(),
3230
+ className: `text-xs px-2 py-0.5 rounded border ${S === u ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3231
+ children: u
3215
3232
  },
3216
- h
3233
+ u
3217
3234
  )),
3218
- /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3235
+ /* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3219
3236
  ] });
3220
3237
  })()
3221
3238
  ] }) });
@@ -3237,10 +3254,10 @@ const Ka = (e = {}) => {
3237
3254
  design_views: ["design_description"],
3238
3255
  design_brief: ["design_description", "design_views"]
3239
3256
  };
3240
- function Us(e, t) {
3257
+ function qs(e, t) {
3241
3258
  return (sn[e] || []).filter((r) => !t.has(r));
3242
3259
  }
3243
- function ei(e) {
3260
+ function ti(e) {
3244
3261
  const t = [];
3245
3262
  return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
3246
3263
  sectionType: "patent_title",
@@ -3271,10 +3288,10 @@ function on(e) {
3271
3288
  }
3272
3289
  return null;
3273
3290
  }
3274
- function ti(e, t) {
3291
+ function ni(e, t) {
3275
3292
  const n = sn[t];
3276
3293
  if (!n || n.length === 0) return [];
3277
- const r = ei(e), a = new Map(r.map((i) => [i.sectionType, i]));
3294
+ const r = ti(e), a = new Map(r.map((i) => [i.sectionType, i]));
3278
3295
  return n.map((i) => {
3279
3296
  const s = a.get(i);
3280
3297
  return !s || s.content.trim().length === 0 ? null : {
@@ -3283,403 +3300,427 @@ function ti(e, t) {
3283
3300
  };
3284
3301
  }).filter((i) => i !== null && i.content.length > 0);
3285
3302
  }
3286
- function qs(e, t = {}) {
3303
+ function Ws(e, t = {}) {
3287
3304
  const n = I.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, c = t.targetSectionPos;
3305
+ let s = t.sectionType, o = t.targetSectionPos;
3289
3306
  if (!s) {
3290
- const u = on(e);
3291
- u && (s = u.sectionType, c = u.pos);
3307
+ const m = on(e);
3308
+ m && (s = m.sectionType, o = m.pos);
3292
3309
  }
3293
- const l = t.scope || (s ? "section" : i ? "selection" : "document"), o = s ? ti(e, s) : void 0;
3310
+ const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
3294
3311
  let d;
3295
3312
  if (l === "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"), b = e.state.doc.textBetween(a, f, " ", "\0");
3313
+ const g = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(g, r, " ", "\0"), b = e.state.doc.textBetween(a, h, " ", "\0");
3297
3314
  d = `...${p}[SELECTED]${b}...`;
3298
3315
  }
3299
3316
  return {
3300
3317
  scope: l,
3301
3318
  sectionType: s,
3302
- targetSectionPos: c,
3319
+ targetSectionPos: o,
3303
3320
  userInput: t.userInput,
3304
3321
  selectedText: i,
3305
- dependencyContext: o,
3322
+ dependencyContext: c,
3306
3323
  surroundingText: d,
3307
3324
  language: n
3308
3325
  };
3309
3326
  }
3310
- const ni = ({ editor: e, onSelectionOptimize: t }) => {
3311
- const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (o) => Y(
3327
+ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3328
+ const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Z(
3312
3329
  "p-1.5 rounded transition-colors",
3313
- o ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3314
- ), c = () => {
3315
- const { from: o, to: d } = e.state.selection;
3316
- if (o === d) return;
3317
- const u = e.state.doc.textBetween(o, d, " "), m = on(e);
3330
+ c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3331
+ ), o = () => {
3332
+ const { from: c, to: d } = e.state.selection;
3333
+ if (c === d) return;
3334
+ const m = e.state.doc.textBetween(c, d, " "), g = on(e);
3318
3335
  if (t) {
3319
- t({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType });
3336
+ t({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType });
3320
3337
  return;
3321
3338
  }
3322
- n({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3339
+ n({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType }), r();
3323
3340
  }, l = () => {
3324
- const o = e.getAttributes("link").href, d = window.prompt("URL", o || "https://");
3341
+ const c = e.getAttributes("link").href, d = window.prompt("URL", c || "https://");
3325
3342
  d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
3326
3343
  };
3327
- return /* @__PURE__ */ g(
3344
+ return /* @__PURE__ */ f(
3328
3345
  Jr,
3329
3346
  {
3330
3347
  editor: e,
3331
- shouldShow: ({ editor: o, state: d }) => {
3332
- const { from: u, to: m } = d.selection;
3333
- return !(u === m || o.isActive("codeBlock"));
3348
+ shouldShow: ({ editor: c, state: d }) => {
3349
+ const { from: m, to: g } = d.selection;
3350
+ return !(m === g || c.isActive("codeBlock"));
3334
3351
  },
3335
- children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
3336
- /* @__PURE__ */ g(
3352
+ children: /* @__PURE__ */ P("div", { className: "bubble-menu", children: [
3353
+ /* @__PURE__ */ f(
3337
3354
  "button",
3338
3355
  {
3339
3356
  onClick: () => e.chain().focus().toggleBold().run(),
3340
3357
  className: s(e.isActive("bold")),
3341
3358
  title: "Bold",
3342
- children: /* @__PURE__ */ g(Dt, { size: 15 })
3359
+ children: /* @__PURE__ */ f(Dt, { size: 15 })
3343
3360
  }
3344
3361
  ),
3345
- /* @__PURE__ */ g(
3362
+ /* @__PURE__ */ f(
3346
3363
  "button",
3347
3364
  {
3348
3365
  onClick: () => e.chain().focus().toggleItalic().run(),
3349
3366
  className: s(e.isActive("italic")),
3350
3367
  title: "Italic",
3351
- children: /* @__PURE__ */ g(Rt, { size: 15 })
3368
+ children: /* @__PURE__ */ f(Rt, { size: 15 })
3352
3369
  }
3353
3370
  ),
3354
- /* @__PURE__ */ g(
3371
+ /* @__PURE__ */ f(
3355
3372
  "button",
3356
3373
  {
3357
3374
  onClick: () => e.chain().focus().toggleUnderline().run(),
3358
3375
  className: s(e.isActive("underline")),
3359
3376
  title: "Underline",
3360
- children: /* @__PURE__ */ g(Mt, { size: 15 })
3377
+ children: /* @__PURE__ */ f(Mt, { size: 15 })
3361
3378
  }
3362
3379
  ),
3363
- /* @__PURE__ */ g(
3380
+ /* @__PURE__ */ f(
3364
3381
  "button",
3365
3382
  {
3366
3383
  onClick: () => e.chain().focus().toggleStrike().run(),
3367
3384
  className: s(e.isActive("strike")),
3368
3385
  title: "Strikethrough",
3369
- children: /* @__PURE__ */ g(Ft, { size: 15 })
3386
+ children: /* @__PURE__ */ f(Ft, { size: 15 })
3370
3387
  }
3371
3388
  ),
3372
- /* @__PURE__ */ g(
3389
+ /* @__PURE__ */ f(
3373
3390
  "button",
3374
3391
  {
3375
3392
  onClick: () => e.chain().focus().toggleCode().run(),
3376
3393
  className: s(e.isActive("code")),
3377
3394
  title: "Code",
3378
- children: /* @__PURE__ */ g($t, { size: 15 })
3395
+ children: /* @__PURE__ */ f($t, { size: 15 })
3379
3396
  }
3380
3397
  ),
3381
- /* @__PURE__ */ g(
3398
+ /* @__PURE__ */ f(
3382
3399
  "button",
3383
3400
  {
3384
3401
  onClick: () => e.chain().focus().toggleSuperscript().run(),
3385
3402
  className: s(e.isActive("superscript")),
3386
3403
  title: "Superscript",
3387
- children: /* @__PURE__ */ g(zt, { size: 15 })
3404
+ children: /* @__PURE__ */ f(zt, { size: 15 })
3388
3405
  }
3389
3406
  ),
3390
- /* @__PURE__ */ g(
3407
+ /* @__PURE__ */ f(
3391
3408
  "button",
3392
3409
  {
3393
3410
  onClick: () => e.chain().focus().toggleSubscript().run(),
3394
3411
  className: s(e.isActive("subscript")),
3395
3412
  title: "Subscript",
3396
- children: /* @__PURE__ */ g(Ot, { size: 15 })
3413
+ children: /* @__PURE__ */ f(Ot, { size: 15 })
3397
3414
  }
3398
3415
  ),
3399
- /* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
3400
- /* @__PURE__ */ g(
3416
+ /* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
3417
+ /* @__PURE__ */ f(
3401
3418
  "button",
3402
3419
  {
3403
3420
  onClick: () => e.chain().focus().toggleHighlight().run(),
3404
3421
  className: s(e.isActive("highlight")),
3405
3422
  title: "Highlight",
3406
- children: /* @__PURE__ */ g(Br, { size: 15 })
3423
+ children: /* @__PURE__ */ f(Br, { size: 15 })
3407
3424
  }
3408
3425
  ),
3409
- /* @__PURE__ */ g(
3426
+ /* @__PURE__ */ f(
3410
3427
  "button",
3411
3428
  {
3412
3429
  onClick: l,
3413
3430
  className: s(e.isActive("link")),
3414
3431
  title: "Link",
3415
- children: /* @__PURE__ */ g(Ht, { size: 15 })
3432
+ children: /* @__PURE__ */ f(Ht, { size: 15 })
3416
3433
  }
3417
3434
  ),
3418
- /* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
3419
- /* @__PURE__ */ g(
3435
+ /* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
3436
+ /* @__PURE__ */ f(
3420
3437
  "button",
3421
3438
  {
3422
- onClick: c,
3439
+ onClick: o,
3423
3440
  className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
3424
3441
  title: i ? "AI 优化" : "AI Optimize",
3425
- children: /* @__PURE__ */ g(Hr, { size: 15 })
3442
+ children: /* @__PURE__ */ f(Hr, { size: 15 })
3426
3443
  }
3427
3444
  )
3428
3445
  ] })
3429
3446
  }
3430
3447
  );
3431
- }, ri = ({ editor: e }) => {
3432
- var T;
3433
- const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [c, l] = F(""), [o, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((T = m == null ? void 0 : m.results) == null ? void 0 : T.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3434
- M(() => {
3435
- const v = (x) => {
3448
+ }, ai = ({ editor: e }) => {
3449
+ var A;
3450
+ const [t, n] = M(!1), [r, a] = M(!1), [i, s] = M(""), [o, l] = M(""), [c, d] = M(!1), [, m] = M(0), g = j(() => m((u) => u + 1), []), h = W(null), p = e.extensionStorage.searchReplace, b = ((A = p == null ? void 0 : p.results) == null ? void 0 : A.length) ?? 0, y = (p == null ? void 0 : p.currentIndex) ?? -1, w = j(() => {
3451
+ e.commands.nextSearchResult(), g();
3452
+ }, [e, g]), T = j(() => {
3453
+ e.commands.previousSearchResult(), g();
3454
+ }, [e, g]);
3455
+ F(() => {
3456
+ const u = (v) => {
3436
3457
  n(!0);
3437
- const S = x.detail;
3438
- S != null && S.replace && a(!0), requestAnimationFrame(() => {
3458
+ const _ = v.detail;
3459
+ _ != null && _.replace && a(!0), requestAnimationFrame(() => {
3439
3460
  var N;
3440
- return (N = u.current) == null ? void 0 : N.focus();
3461
+ return (N = h.current) == null ? void 0 : N.focus();
3441
3462
  });
3442
3463
  };
3443
- return window.addEventListener("editor:toggleSearch", v), () => window.removeEventListener("editor:toggleSearch", v);
3464
+ return window.addEventListener("editor:toggleSearch", u), () => window.removeEventListener("editor:toggleSearch", u);
3444
3465
  }, []);
3445
- const b = ae(
3446
- (v) => {
3447
- s(v), e.commands.setSearchTerm(v);
3466
+ const C = j(
3467
+ (u) => {
3468
+ s(u), e.commands.setSearchTerm(u);
3448
3469
  },
3449
3470
  [e]
3450
- ), y = ae(() => {
3471
+ ), x = j(() => {
3451
3472
  n(!1), e.commands.clearSearch(), e.commands.focus();
3452
3473
  }, [e]);
3453
- M(() => {
3454
- const v = (x) => {
3455
- x.key === "Escape" && t && y();
3474
+ F(() => {
3475
+ const u = (v) => {
3476
+ v.key === "Escape" && t && x();
3456
3477
  };
3457
- return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
3458
- }, [t, y]);
3459
- const w = () => {
3460
- const v = !o;
3461
- d(v), e.commands.setCaseSensitive(v);
3478
+ return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
3479
+ }, [t, x]);
3480
+ const S = () => {
3481
+ const u = !c;
3482
+ d(u), e.commands.setCaseSensitive(u);
3462
3483
  };
3463
- return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
3464
- /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
3465
- /* @__PURE__ */ L("div", { className: "find-replace-input-group", children: [
3466
- /* @__PURE__ */ g(
3484
+ return t ? /* @__PURE__ */ P("div", { className: "find-replace-bar", children: [
3485
+ /* @__PURE__ */ P("div", { className: "find-replace-row", children: [
3486
+ /* @__PURE__ */ P("div", { className: "find-replace-input-group", children: [
3487
+ /* @__PURE__ */ f(
3467
3488
  "input",
3468
3489
  {
3469
- ref: u,
3490
+ ref: h,
3470
3491
  type: "text",
3471
3492
  value: i,
3472
- onChange: (v) => b(v.target.value),
3473
- onKeyDown: (v) => {
3474
- v.key === "Enter" && (v.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
3493
+ onChange: (u) => C(u.target.value),
3494
+ onKeyDown: (u) => {
3495
+ u.key === "Enter" && (u.shiftKey ? T() : w());
3475
3496
  },
3476
3497
  placeholder: "Find...",
3477
3498
  className: "find-replace-input"
3478
3499
  }
3479
3500
  ),
3480
- /* @__PURE__ */ g("span", { className: "find-replace-count", children: f > 0 ? `${p + 1}/${f}` : i ? "0" : "" })
3501
+ /* @__PURE__ */ f("span", { className: "find-replace-count", children: b > 0 ? `${y + 1}/${b}` : i ? "0" : "" })
3481
3502
  ] }),
3482
- /* @__PURE__ */ g(
3503
+ /* @__PURE__ */ f(
3483
3504
  "button",
3484
3505
  {
3485
- onClick: w,
3486
- className: Y("find-replace-btn", o && "find-replace-btn--active"),
3506
+ onClick: S,
3507
+ className: Z("find-replace-btn", c && "find-replace-btn--active"),
3487
3508
  title: "Case Sensitive",
3488
- children: /* @__PURE__ */ g(Ur, { size: 15 })
3509
+ children: /* @__PURE__ */ f(Ur, { size: 15 })
3489
3510
  }
3490
3511
  ),
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 }) }),
3493
- /* @__PURE__ */ g(
3512
+ /* @__PURE__ */ f("button", { onClick: T, className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ f(qr, { size: 15 }) }),
3513
+ /* @__PURE__ */ f("button", { onClick: w, className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ f(qt, { size: 15 }) }),
3514
+ /* @__PURE__ */ f(
3494
3515
  "button",
3495
3516
  {
3496
- onClick: () => a((v) => !v),
3497
- className: Y("find-replace-btn", r && "find-replace-btn--active"),
3517
+ onClick: () => a((u) => !u),
3518
+ className: Z("find-replace-btn", r && "find-replace-btn--active"),
3498
3519
  title: "Toggle Replace",
3499
- children: /* @__PURE__ */ g(gt, { size: 15 })
3520
+ children: /* @__PURE__ */ f(gt, { size: 15 })
3500
3521
  }
3501
3522
  ),
3502
- /* @__PURE__ */ g("button", { onClick: y, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Wr, { size: 15 }) })
3523
+ /* @__PURE__ */ f("button", { onClick: x, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ f(Wr, { size: 15 }) })
3503
3524
  ] }),
3504
- r && /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
3505
- /* @__PURE__ */ g(
3525
+ r && /* @__PURE__ */ P("div", { className: "find-replace-row", children: [
3526
+ /* @__PURE__ */ f(
3506
3527
  "input",
3507
3528
  {
3508
3529
  type: "text",
3509
- value: c,
3510
- onChange: (v) => {
3511
- l(v.target.value), e.commands.setReplaceTerm(v.target.value);
3530
+ value: o,
3531
+ onChange: (u) => {
3532
+ l(u.target.value), e.commands.setReplaceTerm(u.target.value);
3512
3533
  },
3513
- onKeyDown: (v) => {
3514
- v.key === "Enter" && e.commands.replaceCurrent();
3534
+ onKeyDown: (u) => {
3535
+ u.key === "Enter" && (e.commands.replaceCurrent(), g());
3515
3536
  },
3516
3537
  placeholder: "Replace...",
3517
3538
  className: "find-replace-input"
3518
3539
  }
3519
3540
  ),
3520
- /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(gt, { size: 15 }) }),
3521
- /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(jr, { size: 15 }) })
3541
+ /* @__PURE__ */ f(
3542
+ "button",
3543
+ {
3544
+ onClick: () => {
3545
+ e.commands.replaceCurrent(), g();
3546
+ },
3547
+ className: "find-replace-btn",
3548
+ title: "Replace",
3549
+ children: /* @__PURE__ */ f(gt, { size: 15 })
3550
+ }
3551
+ ),
3552
+ /* @__PURE__ */ f(
3553
+ "button",
3554
+ {
3555
+ onClick: () => {
3556
+ e.commands.replaceAll(), g();
3557
+ },
3558
+ className: "find-replace-btn",
3559
+ title: "Replace All",
3560
+ children: /* @__PURE__ */ f(jr, { size: 15 })
3561
+ }
3562
+ )
3522
3563
  ] })
3523
3564
  ] }) : null;
3524
- }, ai = ({ editor: e }) => {
3565
+ }, ii = ({ editor: e }) => {
3525
3566
  const { editorLanguage: t } = I(), 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: c, to: l } = a.selection;
3527
- let o = 0;
3528
- return c !== l && (o = a.doc.textBetween(c, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: o };
3567
+ const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: l } = a.selection;
3568
+ let c = 0;
3569
+ return o !== l && (c = a.doc.textBetween(o, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: c };
3529
3570
  }, [e.state.doc, e.state.selection]);
3530
- return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
3531
- /* @__PURE__ */ L("span", { children: [
3571
+ return /* @__PURE__ */ P("div", { className: "word-count-bar", children: [
3572
+ /* @__PURE__ */ P("span", { children: [
3532
3573
  n ? "字数" : "Characters",
3533
3574
  ": ",
3534
3575
  r.charCount
3535
3576
  ] }),
3536
- r.selectionCount > 0 && /* @__PURE__ */ L("span", { children: [
3577
+ r.selectionCount > 0 && /* @__PURE__ */ P("span", { children: [
3537
3578
  n ? "选区" : "Selected",
3538
3579
  ": ",
3539
3580
  r.selectionCount
3540
3581
  ] })
3541
3582
  ] });
3542
- }, ii = {
3583
+ }, si = {
3543
3584
  empty: "○",
3544
3585
  filled: "●"
3545
- }, si = {
3586
+ }, oi = {
3546
3587
  empty: "text-gray-400",
3547
3588
  filled: "text-green-500"
3548
- }, oi = /* @__PURE__ */ new Set([
3589
+ }, ci = /* @__PURE__ */ new Set([
3549
3590
  "technical_field",
3550
3591
  "background_art",
3551
3592
  "summary",
3552
3593
  "drawing_description",
3553
3594
  "detailed_description"
3554
- ]), ci = ({ editor: e, defaultCollapsed: t = !1 }) => {
3555
- const { editorLanguage: n } = I(), r = H(n), [a, i] = F(t), [s, c] = F(0);
3556
- M(() => {
3557
- const o = () => c((d) => d + 1);
3558
- return e.on("update", o), () => {
3559
- e.off("update", o);
3595
+ ]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
3596
+ const { editorLanguage: n } = I(), r = H(n), [a, i] = M(t), [s, o] = M(0);
3597
+ F(() => {
3598
+ const c = () => o((d) => d + 1);
3599
+ return e.on("update", c), () => {
3600
+ e.off("update", c);
3560
3601
  };
3561
3602
  }, [e]);
3562
3603
  const l = At(() => {
3563
- const o = [];
3604
+ const c = [];
3564
3605
  let d = !1;
3565
- return e.state.doc.descendants((u, m) => {
3566
- if (u.type.name === "patent_title") {
3606
+ return e.state.doc.descendants((m, g) => {
3607
+ if (m.type.name === "patent_title") {
3567
3608
  if (!d) {
3568
3609
  const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
3569
- o.push({
3610
+ c.push({
3570
3611
  type: "book-group",
3571
- pos: m,
3612
+ pos: g,
3572
3613
  title: y,
3573
3614
  charCount: 0
3574
3615
  }), d = !0;
3575
3616
  }
3576
- const f = u.textContent || "", p = f.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
3577
- return o.push({
3617
+ const h = m.textContent || "", p = h.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
3618
+ return c.push({
3578
3619
  type: "section",
3579
- pos: m,
3580
- title: p ? f.trim() : b,
3620
+ pos: g,
3621
+ title: p ? h.trim() : b,
3581
3622
  state: p ? "filled" : "empty",
3582
- charCount: f.replace(/\s/g, "").length,
3623
+ charCount: h.replace(/\s/g, "").length,
3583
3624
  indent: !0
3584
3625
  }), !1;
3585
3626
  }
3586
- if (u.type.name === "patent_section") {
3587
- const f = u.attrs.sectionType, p = oi.has(f), b = `sectionTitle_${f}`, y = typeof r[b] == "string" ? r[b] : f, w = u.textContent || "", T = w.trim().length > 0;
3588
- return o.push({
3627
+ if (m.type.name === "patent_section") {
3628
+ const h = m.attrs.sectionType, p = ci.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
3629
+ return c.push({
3589
3630
  type: "section",
3590
- pos: m,
3631
+ pos: g,
3591
3632
  title: y,
3592
3633
  state: T ? "filled" : "empty",
3593
3634
  charCount: w.replace(/\s/g, "").length,
3594
3635
  indent: p
3595
3636
  }), !1;
3596
3637
  }
3597
- if (u.type.name === "heading") {
3598
- const f = u.attrs.level, p = u.textContent || "";
3599
- return p.trim() && o.push({
3638
+ if (m.type.name === "heading") {
3639
+ const h = m.attrs.level, p = m.textContent || "";
3640
+ return p.trim() && c.push({
3600
3641
  type: "heading",
3601
- pos: m,
3642
+ pos: g,
3602
3643
  title: p,
3603
- level: f,
3644
+ level: h,
3604
3645
  charCount: p.replace(/\s/g, "").length
3605
3646
  }), !1;
3606
3647
  }
3607
3648
  return !0;
3608
- }), o;
3649
+ }), c;
3609
3650
  }, [e, s, r]);
3610
- return a ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
3651
+ return a ? /* @__PURE__ */ f("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ f(
3611
3652
  "button",
3612
3653
  {
3613
3654
  onClick: () => i(!1),
3614
3655
  className: "outline-panel-toggle",
3615
3656
  title: n === "zh" ? "展开大纲" : "Expand Outline",
3616
- children: /* @__PURE__ */ g(Gr, { size: 16 })
3657
+ children: /* @__PURE__ */ f(Gr, { size: 16 })
3617
3658
  }
3618
- ) }) : /* @__PURE__ */ L("div", { className: "outline-panel", children: [
3619
- /* @__PURE__ */ L("div", { className: "outline-panel-header", children: [
3620
- /* @__PURE__ */ g(Ut, { size: 14 }),
3621
- /* @__PURE__ */ g("span", { children: n === "zh" ? "文档大纲" : "Outline" }),
3622
- /* @__PURE__ */ g(
3659
+ ) }) : /* @__PURE__ */ P("div", { className: "outline-panel", children: [
3660
+ /* @__PURE__ */ P("div", { className: "outline-panel-header", children: [
3661
+ /* @__PURE__ */ f(Ut, { size: 14 }),
3662
+ /* @__PURE__ */ f("span", { children: n === "zh" ? "文档大纲" : "Outline" }),
3663
+ /* @__PURE__ */ f(
3623
3664
  "button",
3624
3665
  {
3625
3666
  onClick: () => i(!0),
3626
3667
  className: "outline-panel-toggle ml-auto",
3627
3668
  title: n === "zh" ? "收起大纲" : "Collapse Outline",
3628
- children: /* @__PURE__ */ g(Vr, { size: 14 })
3669
+ children: /* @__PURE__ */ f(Vr, { size: 14 })
3629
3670
  }
3630
3671
  )
3631
3672
  ] }),
3632
- /* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
3633
- l.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
3634
- l.map((o, d) => /* @__PURE__ */ L(
3673
+ /* @__PURE__ */ P("div", { className: "outline-panel-list", children: [
3674
+ l.length === 0 && /* @__PURE__ */ f("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
3675
+ l.map((c, d) => /* @__PURE__ */ P(
3635
3676
  "button",
3636
3677
  {
3637
- className: Y(
3678
+ className: Z(
3638
3679
  "outline-panel-item",
3639
- o.type === "heading" && `outline-panel-item--h${o.level}`,
3640
- o.type === "book-group" && "outline-panel-item--book",
3641
- o.indent && "outline-panel-item--indent"
3680
+ c.type === "heading" && `outline-panel-item--h${c.level}`,
3681
+ c.type === "book-group" && "outline-panel-item--book",
3682
+ c.indent && "outline-panel-item--indent"
3642
3683
  ),
3643
3684
  onClick: () => {
3644
- o.type !== "book-group" && (e.chain().setTextSelection(o.pos + 1).focus().run(), requestAnimationFrame(() => {
3645
- const u = e.view.nodeDOM(o.pos);
3646
- u == null || u.scrollIntoView({ behavior: "smooth", block: "start" });
3685
+ c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
3686
+ const m = e.view.nodeDOM(c.pos);
3687
+ m == null || m.scrollIntoView({ behavior: "smooth", block: "start" });
3647
3688
  }));
3648
3689
  },
3649
3690
  children: [
3650
- o.type === "section" && o.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[o.state]), children: ii[o.state] || "○" }),
3651
- /* @__PURE__ */ g("span", { className: "outline-item-title", children: o.title }),
3652
- o.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: o.charCount })
3691
+ c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
3692
+ /* @__PURE__ */ f("span", { className: "outline-item-title", children: c.title }),
3693
+ c.type !== "book-group" && /* @__PURE__ */ f("span", { className: "outline-item-count", children: c.charCount })
3653
3694
  ]
3654
3695
  },
3655
- `${o.pos}-${d}`
3696
+ `${c.pos}-${d}`
3656
3697
  ))
3657
3698
  ] })
3658
3699
  ] });
3659
- }, li = ({
3700
+ }, di = ({
3660
3701
  editor: e,
3661
3702
  mode: t = "edit",
3662
3703
  className: n
3663
- }) => (M(() => {
3704
+ }) => (F(() => {
3664
3705
  e.setEditable(t === "edit");
3665
- }, [e, t]), /* @__PURE__ */ g(
3706
+ }, [e, t]), /* @__PURE__ */ f(
3666
3707
  "div",
3667
3708
  {
3668
- className: Y(
3709
+ className: Z(
3669
3710
  "h-full",
3670
3711
  t === "readonly" ? "cursor-default" : "cursor-text",
3671
3712
  n
3672
3713
  ),
3673
- children: /* @__PURE__ */ g(In, { editor: e, className: "h-full" })
3714
+ children: /* @__PURE__ */ f(In, { editor: e, className: "h-full" })
3674
3715
  }
3675
- )), cn = "patent-editor-draft", di = 1500, ui = () => {
3716
+ )), cn = "patent-editor-draft", ui = 1500, mi = () => {
3676
3717
  try {
3677
3718
  const e = localStorage.getItem(cn);
3678
3719
  return e ? JSON.parse(e) : null;
3679
3720
  } catch {
3680
3721
  return null;
3681
3722
  }
3682
- }, mi = ({
3723
+ }, gi = ({
3683
3724
  initialContent: e,
3684
3725
  onChange: t,
3685
3726
  className: n,
@@ -3687,10 +3728,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3687
3728
  editable: a = !0,
3688
3729
  onEditorReady: i,
3689
3730
  onSelectionOptimize: s,
3690
- patchEditorId: c = "default",
3731
+ patchEditorId: o = "default",
3691
3732
  defaultOutlineCollapsed: l = !1
3692
3733
  }) => {
3693
- const { setEditor: o, setDocument: d, editorLanguage: u, autoSaveStatus: m, ai: f } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : ui()) || {
3734
+ const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
3694
3735
  type: "doc",
3695
3736
  content: [
3696
3737
  {
@@ -3698,27 +3739,27 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3698
3739
  content: [{ type: "text", text: "" }]
3699
3740
  }
3700
3741
  ]
3701
- }, T = ae((h) => {
3742
+ }, T = j((u) => {
3702
3743
  try {
3703
- p("saving"), localStorage.setItem(cn, JSON.stringify(h)), p("saved"), b(/* @__PURE__ */ new Date());
3744
+ p("saving"), localStorage.setItem(cn, JSON.stringify(u)), p("saved"), b(/* @__PURE__ */ new Date());
3704
3745
  } catch {
3705
3746
  p("error");
3706
3747
  }
3707
- }, [p, b]), v = Nn(
3708
- Ka({
3709
- extensions: [fa.configure({ editorId: c })],
3748
+ }, [p, b]), C = Nn(
3749
+ Xa({
3750
+ extensions: [pa.configure({ editorId: o })],
3710
3751
  content: w,
3711
- onUpdate: ({ editor: h }) => {
3712
- const C = h.getJSON();
3713
- d(C), B.notifyStateChange(h), t && t(C), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3714
- T(C);
3715
- }, di));
3752
+ onUpdate: ({ editor: u }) => {
3753
+ const v = u.getJSON();
3754
+ d(v), B.notifyStateChange(u), t && t(v), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3755
+ T(v);
3756
+ }, ui));
3716
3757
  },
3717
- onCreate: ({ editor: h }) => {
3718
- o(h), i == null || i(h), B.initializePlugins(h), B.notifyStateChange(h);
3758
+ onCreate: ({ editor: u }) => {
3759
+ c(u), i == null || i(u), B.initializePlugins(u), B.notifyStateChange(u);
3719
3760
  },
3720
- onSelectionUpdate: ({ editor: h }) => {
3721
- B.notifySelectionChange(h);
3761
+ onSelectionUpdate: ({ editor: u }) => {
3762
+ B.notifySelectionChange(u);
3722
3763
  },
3723
3764
  editorProps: {
3724
3765
  attributes: {
@@ -3727,40 +3768,40 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3727
3768
  }
3728
3769
  })
3729
3770
  ), x = W(!1);
3730
- if (M(() => {
3731
- if (!(!v || !e)) {
3771
+ if (F(() => {
3772
+ if (!(!C || !e)) {
3732
3773
  if (!x.current) {
3733
3774
  x.current = !0;
3734
3775
  return;
3735
3776
  }
3736
- v.commands.setContent(e);
3777
+ C.commands.setContent(e);
3737
3778
  }
3738
- }, [v, e]), M(() => () => {
3739
- y.current && clearTimeout(y.current), v && (o(null), B.destroyPlugins(v), v.destroy());
3740
- }, [v, o]), M(() => {
3741
- !v || v.isDestroyed || B.notifyStateChange(v);
3742
- }, [v, u]), !v)
3779
+ }, [C, e]), F(() => () => {
3780
+ y.current && clearTimeout(y.current), C && (c(null), B.destroyPlugins(C), C.destroy());
3781
+ }, [C, c]), F(() => {
3782
+ !C || C.isDestroyed || B.notifyStateChange(C);
3783
+ }, [C, m]), !C)
3743
3784
  return null;
3744
- const S = H(u), N = m === "saving" ? S.autoSaveSaving : m === "saved" ? S.autoSaveSaved : m === "error" ? S.autoSaveError : "";
3745
- return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3746
- !r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
3747
- /* @__PURE__ */ g(Za, { editor: v }),
3748
- N && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: N })
3785
+ const S = H(m), A = g === "saving" ? S.autoSaveSaving : g === "saved" ? S.autoSaveSaved : g === "error" ? S.autoSaveError : "";
3786
+ return /* @__PURE__ */ P("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3787
+ !r && /* @__PURE__ */ P("div", { className: "flex items-center", children: [
3788
+ /* @__PURE__ */ f(Qa, { editor: C }),
3789
+ A && /* @__PURE__ */ f("span", { className: `auto-save-indicator auto-save-indicator--${g} ml-2`, children: A })
3749
3790
  ] }),
3750
- !r && v && /* @__PURE__ */ g(Qa, { editor: v }),
3751
- !r && v && /* @__PURE__ */ g(ni, { editor: v, onSelectionOptimize: s }),
3752
- !r && v && /* @__PURE__ */ g(ri, { editor: v }),
3753
- /* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
3754
- !r && v && /* @__PURE__ */ g(ci, { editor: v, defaultCollapsed: l }),
3755
- /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
3756
- li,
3791
+ !r && C && /* @__PURE__ */ f(ei, { editor: C }),
3792
+ !r && C && /* @__PURE__ */ f(ri, { editor: C, onSelectionOptimize: s }),
3793
+ !r && C && /* @__PURE__ */ f(ai, { editor: C }),
3794
+ /* @__PURE__ */ P("div", { className: "flex flex-1 overflow-hidden", children: [
3795
+ !r && C && /* @__PURE__ */ f(li, { editor: C, defaultCollapsed: l }),
3796
+ /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ f(
3797
+ di,
3757
3798
  {
3758
- editor: v,
3759
- mode: r || !a || f.status === "streaming" && f.activeSectionType === "claims" ? "readonly" : "edit"
3799
+ editor: C,
3800
+ mode: r || !a || h.status === "streaming" && h.activeSectionType === "claims" ? "readonly" : "edit"
3760
3801
  }
3761
3802
  ) })
3762
3803
  ] }),
3763
- !r && /* @__PURE__ */ g(ai, { editor: v })
3804
+ !r && /* @__PURE__ */ f(ii, { editor: C })
3764
3805
  ] });
3765
3806
  };
3766
3807
  function ln(e) {
@@ -3770,43 +3811,43 @@ function ln(e) {
3770
3811
  async pull(a) {
3771
3812
  var i;
3772
3813
  for (; ; ) {
3773
- const { done: s, value: c } = await t.read();
3814
+ const { done: s, value: o } = await t.read();
3774
3815
  if (s) {
3775
3816
  a.close();
3776
3817
  return;
3777
3818
  }
3778
- r += n.decode(c, { stream: !0 });
3819
+ r += n.decode(o, { stream: !0 });
3779
3820
  const l = r.split(`
3780
3821
  `);
3781
3822
  r = l.pop() || "";
3782
- let o = "";
3823
+ let c = "";
3783
3824
  for (const d of l) {
3784
3825
  if (d.startsWith("event: ")) {
3785
- o = d.slice(7).trim();
3826
+ c = d.slice(7).trim();
3786
3827
  continue;
3787
3828
  }
3788
3829
  if (!d.startsWith("data: ")) continue;
3789
- const u = d.slice(6).trim();
3790
- if (u === "[DONE]") {
3830
+ const m = d.slice(6).trim();
3831
+ if (m === "[DONE]") {
3791
3832
  a.enqueue({ type: "done" }), a.close();
3792
3833
  return;
3793
3834
  }
3794
3835
  try {
3795
- const m = JSON.parse(u), f = o || m.type;
3796
- if (f === "delta" || !f && m.content != null)
3836
+ const g = JSON.parse(m), h = c || g.type;
3837
+ if (h === "delta" || !h && g.content != null)
3797
3838
  a.enqueue({
3798
3839
  type: "delta",
3799
- content: m.content ?? m.text ?? ((i = m.delta) == null ? void 0 : i.content) ?? ""
3840
+ content: g.content ?? g.text ?? ((i = g.delta) == null ? void 0 : i.content) ?? ""
3800
3841
  });
3801
- else if (f === "patch")
3802
- a.enqueue({ type: "patch", patch: m });
3803
- else if (f === "done") {
3804
- a.enqueue({ type: "done", usage: m.usage }), a.close();
3842
+ else if (h === "patch")
3843
+ a.enqueue({ type: "patch", patch: g });
3844
+ else if (h === "done") {
3845
+ a.enqueue({ type: "done", usage: g.usage }), a.close();
3805
3846
  return;
3806
- } else f === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
3847
+ } else h === "error" && a.enqueue({ type: "error", message: g.message || "Unknown error" });
3807
3848
  } catch {
3808
3849
  }
3809
- o = "";
3850
+ c = "";
3810
3851
  }
3811
3852
  }
3812
3853
  },
@@ -3815,7 +3856,7 @@ function ln(e) {
3815
3856
  }
3816
3857
  });
3817
3858
  }
3818
- function gi(e, t) {
3859
+ function fi(e, t) {
3819
3860
  let n = null;
3820
3861
  return {
3821
3862
  async request(r) {
@@ -3837,31 +3878,31 @@ function gi(e, t) {
3837
3878
  }
3838
3879
  };
3839
3880
  }
3840
- function fi(e, t) {
3881
+ function pi(e, t) {
3841
3882
  let n = null;
3842
3883
  const r = e.replace(/\/+$/, "");
3843
3884
  async function a(i, s) {
3844
- const c = await fetch(i, {
3885
+ const o = await fetch(i, {
3845
3886
  ...s,
3846
3887
  headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
3847
3888
  });
3848
- if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
3849
- const l = await c.json();
3889
+ if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
3890
+ const l = await o.json();
3850
3891
  return l.data ?? l;
3851
3892
  }
3852
3893
  return {
3853
- async createSession(i, s, c) {
3894
+ async createSession(i, s, o) {
3854
3895
  return a(`${r}/api/v1/chat/sessions`, {
3855
3896
  method: "POST",
3856
- body: JSON.stringify({ patentId: i, title: s, language: c })
3897
+ body: JSON.stringify({ patentId: i, title: s, language: o })
3857
3898
  });
3858
3899
  },
3859
- async listSessions(i, s = 1, c = 20) {
3860
- const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3900
+ async listSessions(i, s = 1, o = 20) {
3901
+ const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
3861
3902
  return i && l.set("patentId", i), a(`${r}/api/v1/chat/sessions?${l}`);
3862
3903
  },
3863
- async getMessages(i, s = 1, c = 50) {
3864
- const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3904
+ async getMessages(i, s = 1, o = 50) {
3905
+ const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
3865
3906
  return a(`${r}/api/v1/chat/sessions/${i}/messages?${l}`);
3866
3907
  },
3867
3908
  async deleteSession(i) {
@@ -3878,7 +3919,7 @@ function fi(e, t) {
3878
3919
  },
3879
3920
  async subscribeStream(i, s) {
3880
3921
  n = new AbortController();
3881
- const c = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(c, {
3922
+ const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(o, {
3882
3923
  headers: { Accept: "text/event-stream", ...t },
3883
3924
  signal: n.signal
3884
3925
  });
@@ -3891,9 +3932,9 @@ function fi(e, t) {
3891
3932
  }
3892
3933
  };
3893
3934
  }
3894
- const pi = It(
3895
- ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: c, chatSessionAPI: l, aiBaseUrl: o, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m, defaultOutlineCollapsed: f }, p) => {
3896
- const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), v = ae((S) => {
3935
+ const hi = It(
3936
+ ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: m, patchEditorId: g, defaultOutlineCollapsed: h }, p) => {
3937
+ const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), C = j((S) => {
3897
3938
  T.current = S;
3898
3939
  }, []), x = Ee.useMemo(() => {
3899
3940
  if (e) return e;
@@ -3902,102 +3943,102 @@ const pi = It(
3902
3943
  return Ee.useEffect(() => {
3903
3944
  s && b(s);
3904
3945
  }, [s, b]), Ee.useEffect(() => {
3905
- c ? y(c) : o && y(gi(o, d));
3906
- }, [c, o, d, y]), Ee.useEffect(() => {
3907
- l ? w(l) : o && w(fi(o, d));
3908
- }, [l, o, d, w]), Nt(p, () => ({
3946
+ o ? y(o) : c && y(fi(c, d));
3947
+ }, [o, c, d, y]), Ee.useEffect(() => {
3948
+ l ? w(l) : c && w(pi(c, d));
3949
+ }, [l, c, d, w]), Nt(p, () => ({
3909
3950
  getContent: () => {
3910
3951
  var S;
3911
3952
  return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
3912
3953
  },
3913
3954
  setContent: (S) => {
3914
- var N;
3915
- (N = T.current) == null || N.commands.setContent(S);
3955
+ var A;
3956
+ (A = T.current) == null || A.commands.setContent(S);
3916
3957
  },
3917
3958
  getEditor: () => T.current,
3918
- execCommand: async (S, N) => T.current ? ct(T.current).execCommand(S, N) : null,
3959
+ execCommand: async (S, A) => T.current ? ct(T.current).execCommand(S, A) : null,
3919
3960
  focus: () => {
3920
3961
  var S;
3921
3962
  (S = T.current) == null || S.commands.focus();
3922
3963
  }
3923
- })), /* @__PURE__ */ g(
3924
- mi,
3964
+ })), /* @__PURE__ */ f(
3965
+ gi,
3925
3966
  {
3926
3967
  initialContent: x,
3927
3968
  onChange: n,
3928
- onEditorReady: v,
3969
+ onEditorReady: C,
3929
3970
  className: r,
3930
3971
  readOnly: a,
3931
3972
  editable: i,
3932
- onSelectionOptimize: u,
3933
- patchEditorId: m,
3934
- defaultOutlineCollapsed: f
3973
+ onSelectionOptimize: m,
3974
+ patchEditorId: g,
3975
+ defaultOutlineCollapsed: h
3935
3976
  }
3936
3977
  );
3937
3978
  }
3938
3979
  );
3939
- pi.displayName = "PatentEditor";
3940
- async function Ws(e, t, n) {
3941
- var a, i, s, c;
3980
+ hi.displayName = "PatentEditor";
3981
+ async function js(e, t, n) {
3982
+ var a, i, s, o;
3942
3983
  let r = !1;
3943
3984
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
3944
3985
  try {
3945
3986
  let l = dn(e, n);
3946
3987
  for (; ; ) {
3947
- const { done: o, value: d } = await t.read();
3948
- if (o) break;
3988
+ const { done: c, value: d } = await t.read();
3989
+ if (c) break;
3949
3990
  if (!d) continue;
3950
3991
  (i = n.onChunk) == null || i.call(n, d);
3951
- const u = e.state.tr.insertText(d, l);
3952
- e.view.dispatch(u), l = u.mapping.map(l, 1);
3992
+ const m = e.state.tr.insertText(d, l);
3993
+ e.view.dispatch(m), l = m.mapping.map(l, 1);
3953
3994
  }
3954
3995
  n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
3955
3996
  } catch (l) {
3956
- (c = n.onError) == null || c.call(n, l instanceof Error ? l : new Error(String(l)));
3997
+ (o = n.onError) == null || o.call(n, l instanceof Error ? l : new Error(String(l)));
3957
3998
  }
3958
3999
  }
3959
- async function js(e, t, n, r) {
3960
- var i, s, c, l, o, d, u, m;
4000
+ async function Gs(e, t, n, r) {
4001
+ var i, s, o, l, c, d, m, g;
3961
4002
  const a = new AbortController();
3962
4003
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
3963
4004
  try {
3964
- const f = await fetch(t, {
4005
+ const h = await fetch(t, {
3965
4006
  method: "POST",
3966
4007
  headers: { "Content-Type": "application/json" },
3967
4008
  body: JSON.stringify(n),
3968
4009
  signal: a.signal
3969
4010
  });
3970
- if (!f.ok)
3971
- throw new Error(`HTTP ${f.status}: ${f.statusText}`);
3972
- const p = (s = f.body) == null ? void 0 : s.getReader();
4011
+ if (!h.ok)
4012
+ throw new Error(`HTTP ${h.status}: ${h.statusText}`);
4013
+ const p = (s = h.body) == null ? void 0 : s.getReader();
3973
4014
  if (!p) throw new Error("No response body");
3974
4015
  const b = new TextDecoder();
3975
4016
  let y = dn(e, r), w = "";
3976
4017
  for (; ; ) {
3977
- const { done: T, value: v } = await p.read();
4018
+ const { done: T, value: C } = await p.read();
3978
4019
  if (T) break;
3979
- w += b.decode(v, { stream: !0 });
4020
+ w += b.decode(C, { stream: !0 });
3980
4021
  const x = w.split(`
3981
4022
  `);
3982
4023
  w = x.pop() || "";
3983
4024
  for (const S of x) {
3984
4025
  if (!S.startsWith("data: ")) continue;
3985
- const N = S.slice(6).trim();
3986
- if (N === "[DONE]")
3987
- return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
4026
+ const A = S.slice(6).trim();
4027
+ if (A === "[DONE]")
4028
+ return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
3988
4029
  try {
3989
- const h = JSON.parse(N), C = h.content || h.text || ((l = h.delta) == null ? void 0 : l.content) || "";
3990
- if (!C) continue;
3991
- (o = r.onChunk) == null || o.call(r, C);
3992
- const _ = e.state.tr.insertText(C, y);
4030
+ const u = JSON.parse(A), v = u.content || u.text || ((l = u.delta) == null ? void 0 : l.content) || "";
4031
+ if (!v) continue;
4032
+ (c = r.onChunk) == null || c.call(r, v);
4033
+ const _ = e.state.tr.insertText(v, y);
3993
4034
  e.view.dispatch(_), y = _.mapping.map(y, 1);
3994
4035
  } catch {
3995
4036
  }
3996
4037
  }
3997
4038
  }
3998
4039
  r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
3999
- } catch (f) {
4000
- 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)));
4040
+ } catch (h) {
4041
+ h.name === "AbortError" ? (m = r.onAbort) == null || m.call(r) : (g = r.onError) == null || g.call(r, h instanceof Error ? h : new Error(String(h)));
4001
4042
  }
4002
4043
  return { abort: () => a.abort() };
4003
4044
  }
@@ -4026,12 +4067,12 @@ function nt(e, t) {
4026
4067
  n.forEach((l) => {
4027
4068
  s++;
4028
4069
  });
4029
- let c = 0;
4070
+ let o = 0;
4030
4071
  if (n.forEach((l) => {
4031
- l.type.name === "paragraph" && l.textContent.trim().length > 0 && c++;
4072
+ l.type.name === "paragraph" && l.textContent.trim().length > 0 && o++;
4032
4073
  }), i = t + 1, n.forEach((l) => {
4033
- const o = i, d = i + l.nodeSize;
4034
- l.type.name === "paragraph" && l.textContent.trim().length === 0 && (c > 0 || a.length < s - 1) && a.push({ from: o, to: d }), i = d;
4074
+ const c = i, d = i + l.nodeSize;
4075
+ l.type.name === "paragraph" && l.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: c, to: d }), i = d;
4035
4076
  }), a.length !== 0) {
4036
4077
  for (let l = a.length - 1; l >= 0; l--)
4037
4078
  r.delete(a[l].from, a[l].to);
@@ -4108,7 +4149,7 @@ S103:局部实时避障控制。采用模型预测控制(MPC)策略,以
4108
4149
  S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,验证机动后轨迹在未来72小时内不会与TLE目录中的已知空间目标产生碰撞风险(miss distance > 1km)。`,
4109
4150
  en: "The technical solution of the embodiments of the present invention will be described clearly and completely below with reference to the drawings."
4110
4151
  }
4111
- }, Pe = {
4152
+ }, Le = {
4112
4153
  "help-draft": {
4113
4154
  zh: `当然可以帮你撰写技术方案!请先描述以下信息:
4114
4155
 
@@ -4167,7 +4208,7 @@ S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,
4167
4208
  你可以选中文档中的文字使用浮动菜单的AI操作,或者在左侧面板点击章节的"AI生成"按钮来体验这些功能。`,
4168
4209
  en: "That is a great question. As an AI patent writing assistant, I can help you with..."
4169
4210
  }
4170
- }, te = (e) => new Promise((t) => setTimeout(t, e));
4211
+ }, ne = (e) => new Promise((t) => setTimeout(t, e));
4171
4212
  function rt(e, t = 30) {
4172
4213
  let n = !1;
4173
4214
  return new ReadableStream({
@@ -4177,7 +4218,7 @@ function rt(e, t = 30) {
4177
4218
  r.close();
4178
4219
  return;
4179
4220
  }
4180
- r.enqueue(a), a.type === "delta" && await te(t);
4221
+ r.enqueue(a), a.type === "delta" && await ne(t);
4181
4222
  }
4182
4223
  r.close();
4183
4224
  },
@@ -4186,7 +4227,7 @@ function rt(e, t = 30) {
4186
4227
  }
4187
4228
  });
4188
4229
  }
4189
- function hi(e) {
4230
+ function yi(e) {
4190
4231
  const t = [], n = $e(e, 3);
4191
4232
  for (const r of n)
4192
4233
  t.push({ type: "delta", content: r });
@@ -4198,27 +4239,27 @@ function $e(e, t) {
4198
4239
  n.push(e.slice(r, r + t));
4199
4240
  return n;
4200
4241
  }
4201
- function yi(e, t, n) {
4242
+ function bi(e, t, n) {
4202
4243
  const r = n === "zh", a = [];
4203
4244
  let i;
4204
- 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) {
4245
+ if (e.includes("技术方案") || e.includes("draft") ? i = Le["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Le.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Le.claims[r ? "zh" : "en"] : i = Le.default[r ? "zh" : "en"], t.length > 0) {
4205
4246
  const s = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
4206
4247
 
4207
4248
  ` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
4208
4249
 
4209
4250
  `;
4210
- for (const c of $e(s, 4))
4211
- a.push({ type: "delta", content: c });
4212
- for (const c of $e(i, 4))
4213
- a.push({ type: "delta", content: c });
4214
- for (let c = 0; c < t.length; c++) {
4215
- const l = t[c], o = l.text;
4251
+ for (const o of $e(s, 4))
4252
+ a.push({ type: "delta", content: o });
4253
+ for (const o of $e(i, 4))
4254
+ a.push({ type: "delta", content: o });
4255
+ for (let o = 0; o < t.length; o++) {
4256
+ const l = t[o], c = l.text;
4216
4257
  let d;
4217
- r ? (d = o.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === o && (d = `根据本发明优选实施例,${o}`)) : d = `According to a preferred embodiment, ${o.charAt(0).toLowerCase()}${o.slice(1)}`, l.from != null && l.to != null ? a.push({
4258
+ r ? (d = c.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === c && (d = `根据本发明优选实施例,${c}`)) : d = `According to a preferred embodiment, ${c.charAt(0).toLowerCase()}${c.slice(1)}`, l.from != null && l.to != null ? a.push({
4218
4259
  type: "patch",
4219
4260
  patch: {
4220
4261
  op: "replace",
4221
- target: { type: "ref", refIndex: c },
4262
+ target: { type: "ref", refIndex: o },
4222
4263
  content: d,
4223
4264
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4224
4265
  }
@@ -4227,7 +4268,7 @@ function yi(e, t, n) {
4227
4268
  patch: {
4228
4269
  op: "replace",
4229
4270
  target: { type: "section", sectionType: l.source },
4230
- search: o,
4271
+ search: c,
4231
4272
  content: d,
4232
4273
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4233
4274
  }
@@ -4235,7 +4276,7 @@ function yi(e, t, n) {
4235
4276
  type: "patch",
4236
4277
  patch: {
4237
4278
  op: "replace",
4238
- target: { type: "search", searchText: o },
4279
+ target: { type: "search", searchText: c },
4239
4280
  content: d,
4240
4281
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4241
4282
  }
@@ -4246,21 +4287,21 @@ function yi(e, t, n) {
4246
4287
  a.push({ type: "delta", content: s });
4247
4288
  return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
4248
4289
  }
4249
- function Gs() {
4290
+ function Vs() {
4250
4291
  let e = null;
4251
4292
  return {
4252
4293
  async request(t) {
4253
- var c;
4254
- if (e = new AbortController(), await te(300), e.signal.aborted)
4294
+ var o;
4295
+ if (e = new AbortController(), await ne(300), e.signal.aborted)
4255
4296
  throw new DOMException("Aborted", "AbortError");
4256
- 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];
4297
+ 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];
4257
4298
  let i = a;
4258
4299
  t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
4259
4300
 
4260
4301
  ` : `[Generated based on instruction "${t.instruction}"]
4261
4302
 
4262
4303
  `) + a);
4263
- const s = hi(i);
4304
+ const s = yi(i);
4264
4305
  return rt(s, 25);
4265
4306
  },
4266
4307
  abort() {
@@ -4268,13 +4309,13 @@ function Gs() {
4268
4309
  }
4269
4310
  };
4270
4311
  }
4271
- function Vs() {
4312
+ function Js() {
4272
4313
  const e = /* @__PURE__ */ new Map();
4273
4314
  let t = null, n = null;
4274
4315
  return {
4275
4316
  async createSession(r, a, i) {
4276
- await te(100);
4277
- const s = `sess_${Date.now()}`, c = {
4317
+ await ne(100);
4318
+ const s = `sess_${Date.now()}`, o = {
4278
4319
  sessionId: s,
4279
4320
  patentId: r || void 0,
4280
4321
  title: a || (i === "zh" ? "新对话" : "New Chat"),
@@ -4282,24 +4323,24 @@ function Vs() {
4282
4323
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4283
4324
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4284
4325
  };
4285
- return e.set(s, { session: c, messages: [] }), c;
4326
+ return e.set(s, { session: o, messages: [] }), o;
4286
4327
  },
4287
4328
  async listSessions() {
4288
- await te(50);
4329
+ await ne(50);
4289
4330
  const r = Array.from(e.values()).map((a) => a.session);
4290
4331
  return { total: r.length, items: r };
4291
4332
  },
4292
4333
  async getMessages(r) {
4293
- await te(50);
4334
+ await ne(50);
4294
4335
  const a = e.get(r);
4295
4336
  if (!a) throw new Error("Session not found");
4296
4337
  return { total: a.messages.length, items: a.messages };
4297
4338
  },
4298
4339
  async deleteSession(r) {
4299
- await te(50), e.delete(r);
4340
+ await ne(50), e.delete(r);
4300
4341
  },
4301
4342
  async sendMessage(r, a) {
4302
- await te(150);
4343
+ await ne(150);
4303
4344
  const i = e.get(r);
4304
4345
  if (!i) throw new Error("Session not found");
4305
4346
  const s = `msg_${Date.now()}`;
@@ -4311,39 +4352,39 @@ function Vs() {
4311
4352
  status: "done",
4312
4353
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4313
4354
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4314
- const c = yi(
4355
+ const o = bi(
4315
4356
  a.content,
4316
4357
  a.references || [],
4317
4358
  a.language
4318
4359
  );
4319
- return n = { messageId: s, events: c }, { messageId: s, sessionId: r, status: "processing" };
4360
+ return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
4320
4361
  },
4321
4362
  async subscribeStream(r, a) {
4322
- t = new AbortController(), await te(100);
4363
+ t = new AbortController(), await ne(100);
4323
4364
  const i = e.get(r);
4324
4365
  if (!i) throw new Error("Session not found");
4325
4366
  if (!n || n.messageId !== a)
4326
4367
  return rt([{ type: "done" }]);
4327
4368
  const s = n.events;
4328
4369
  n = null;
4329
- const c = rt(s, 18), l = `${a}_a`;
4330
- let o = "";
4370
+ const o = rt(s, 18), l = `${a}_a`;
4371
+ let c = "";
4331
4372
  for (const d of s)
4332
- d.type === "delta" && (o += d.content);
4373
+ d.type === "delta" && (c += d.content);
4333
4374
  return i.messages.push({
4334
4375
  messageId: l,
4335
4376
  role: "assistant",
4336
- content: o,
4377
+ content: c,
4337
4378
  status: "done",
4338
4379
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4339
- }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
4380
+ }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
4340
4381
  },
4341
4382
  abort() {
4342
4383
  t == null || t.abort(), t = null;
4343
4384
  }
4344
4385
  };
4345
4386
  }
4346
- function bi(e) {
4387
+ function vi(e) {
4347
4388
  const t = [], n = e.replace(/\r\n/g, `
4348
4389
  `).trim();
4349
4390
  if (!n) return t;
@@ -4358,77 +4399,77 @@ function bi(e) {
4358
4399
  if (a.length === 0)
4359
4400
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4360
4401
  for (let s = 0; s < a.length; s++) {
4361
- const c = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, o = n.slice(c, l).trim(), d = a[s].number, u = vi(o, d);
4362
- t.push({ number: d, text: o, dependsOn: u });
4402
+ const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = wi(c, d);
4403
+ t.push({ number: d, text: c, dependsOn: m });
4363
4404
  }
4364
4405
  return t;
4365
4406
  }
4366
- function vi(e, t) {
4407
+ function wi(e, t) {
4367
4408
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4368
4409
  let a;
4369
4410
  for (; (a = r.exec(e)) !== null; ) {
4370
- const s = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : s;
4371
- for (let l = s; l <= c; l++)
4411
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4412
+ for (let l = s; l <= o; l++)
4372
4413
  l !== t && l > 0 && n.push(l);
4373
4414
  }
4374
4415
  const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4375
4416
  for (; (a = i.exec(e)) !== null; ) {
4376
- const s = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : s;
4377
- for (let l = s; l <= c; l++)
4417
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4418
+ for (let l = s; l <= o; l++)
4378
4419
  l !== t && l > 0 && n.push(l);
4379
4420
  }
4380
- return [...new Set(n)].sort((s, c) => s - c);
4421
+ return [...new Set(n)].sort((s, o) => s - o);
4381
4422
  }
4382
- function Js(e) {
4383
- return bi(e).map((n) => ({
4423
+ function Ks(e) {
4424
+ return vi(e).map((n) => ({
4384
4425
  type: "paragraph",
4385
4426
  content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
4386
4427
  }));
4387
4428
  }
4388
- const wi = -1, xi = 1, Ci = 0, at = new we("docDiff");
4429
+ const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
4389
4430
  let Ye = null;
4390
- function Ti() {
4391
- return Ye || (Ye = new Pt()), Ye;
4431
+ function Si() {
4432
+ return Ye || (Ye = new Lt()), Ye;
4392
4433
  }
4393
- function Si(e, t, n) {
4434
+ function Ei(e, t, n) {
4394
4435
  const r = [];
4395
4436
  return e.nodesBetween(t, n, (a, i) => {
4396
4437
  if (a.isTextblock) {
4397
- const s = i + 1, c = i + a.nodeSize - 1, l = Math.max(s, t), o = Math.min(c, n);
4398
- return o > l && r.push({ from: l, to: o }), !1;
4438
+ const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
4439
+ return c > l && r.push({ from: l, to: c }), !1;
4399
4440
  }
4400
4441
  return !0;
4401
4442
  }), r;
4402
4443
  }
4403
- function Ks(e, t) {
4404
- const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ti(), c = s.diff_main(t, a);
4405
- s.diff_cleanupSemantic(c);
4444
+ function Xs(e, t) {
4445
+ const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Si(), o = s.diff_main(t, a);
4446
+ s.diff_cleanupSemantic(o);
4406
4447
  const l = [];
4407
- let o = 0;
4408
- for (const [m, f] of c)
4409
- if (m === Ci)
4410
- o += f.length;
4411
- else if (m === xi) {
4448
+ let c = 0;
4449
+ for (const [g, h] of o)
4450
+ if (g === Ti)
4451
+ c += h.length;
4452
+ else if (g === Ci) {
4412
4453
  let p = 0;
4413
- for (; p < f.length; ) {
4414
- for (; p < f.length && f[p] === "\0"; ) p++;
4415
- if (p >= f.length) break;
4454
+ for (; p < h.length; ) {
4455
+ for (; p < h.length && h[p] === "\0"; ) p++;
4456
+ if (p >= h.length) break;
4416
4457
  const b = p;
4417
- for (; p < f.length && f[p] !== "\0"; ) p++;
4418
- const y = ye(i, o + b), w = ye(i, o + p);
4458
+ for (; p < h.length && h[p] !== "\0"; ) p++;
4459
+ const y = be(i, c + b), w = be(i, c + p);
4419
4460
  if (y >= 0 && w >= 0 && w > y)
4420
- for (const T of Si(n, y, w))
4461
+ for (const T of Ei(n, y, w))
4421
4462
  l.push(
4422
- re.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4463
+ ae.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4423
4464
  );
4424
4465
  }
4425
- o += f.length;
4426
- } else if (m === wi) {
4427
- const p = ye(i, o);
4466
+ c += h.length;
4467
+ } else if (g === xi) {
4468
+ const p = be(i, c);
4428
4469
  if (p >= 0) {
4429
- const b = f.replace(/\0/g, " ");
4470
+ const b = h.replace(/\0/g, " ");
4430
4471
  l.push(
4431
- re.widget(
4472
+ ae.widget(
4432
4473
  p,
4433
4474
  () => {
4434
4475
  const y = document.createElement("span");
@@ -4439,36 +4480,36 @@ function Ks(e, t) {
4439
4480
  );
4440
4481
  }
4441
4482
  }
4442
- const d = be.create(n, l), u = new Be({
4483
+ const d = de.create(n, l), m = new Be({
4443
4484
  key: at,
4444
4485
  state: {
4445
4486
  init: () => d,
4446
- apply: (m, f) => m.docChanged ? f.map(m.mapping, m.doc) : f
4487
+ apply: (g, h) => g.docChanged ? h.map(g.mapping, g.doc) : h
4447
4488
  },
4448
4489
  props: {
4449
- decorations(m) {
4450
- return at.getState(m);
4490
+ decorations(g) {
4491
+ return at.getState(g);
4451
4492
  }
4452
4493
  }
4453
4494
  });
4454
- e.registerPlugin(u);
4495
+ e.registerPlugin(m);
4455
4496
  }
4456
- function Xs(e) {
4497
+ function Ys(e) {
4457
4498
  e.unregisterPlugin(at);
4458
4499
  }
4459
- const Ei = /* @__PURE__ */ new Set([
4500
+ const ki = /* @__PURE__ */ new Set([
4460
4501
  "abstract",
4461
4502
  "abstract_drawing",
4462
4503
  "claims",
4463
4504
  "drawing_figures"
4464
- ]), ki = /* @__PURE__ */ new Set([
4505
+ ]), _i = /* @__PURE__ */ new Set([
4465
4506
  "technical_field",
4466
4507
  "background_art",
4467
4508
  "summary",
4468
4509
  "drawing_description",
4469
4510
  "detailed_description"
4470
4511
  ]);
4471
- function _i(e, t) {
4512
+ function Ii(e, t) {
4472
4513
  const n = H(t), r = [];
4473
4514
  return e.state.doc.descendants((a) => {
4474
4515
  if (a.type.name === "patent_title") {
@@ -4481,11 +4522,11 @@ function _i(e, t) {
4481
4522
  }), !1;
4482
4523
  }
4483
4524
  if (a.type.name === "patent_section") {
4484
- const i = a.attrs.sectionType, s = `sectionTitle_${i}`, c = typeof n[s] == "string" ? n[s] : i, l = [];
4485
- return a.forEach((o) => {
4486
- const d = o.textContent.trim();
4525
+ const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, l = [];
4526
+ return a.forEach((c) => {
4527
+ const d = c.textContent.trim();
4487
4528
  d && l.push(d);
4488
- }), r.push({ type: "patent_section", sectionType: i, title: c, paragraphs: l }), !1;
4529
+ }), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: l }), !1;
4489
4530
  }
4490
4531
  return !0;
4491
4532
  }), r;
@@ -4504,7 +4545,7 @@ function Et(e) {
4504
4545
  spacing: { before: 240, after: 120 }
4505
4546
  });
4506
4547
  }
4507
- function Ii(e) {
4548
+ function Ni(e) {
4508
4549
  return new He({
4509
4550
  children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
4510
4551
  alignment: it.CENTER,
@@ -4515,14 +4556,14 @@ function Ze(e) {
4515
4556
  return new He({
4516
4557
  children: [new Ue({ text: e, size: 24, font: "宋体" })],
4517
4558
  spacing: { line: 360 },
4518
- indent: { firstLine: he(7) }
4559
+ indent: { firstLine: ye(7) }
4519
4560
  });
4520
4561
  }
4521
- function Ni(e, t) {
4562
+ function Ai(e, t) {
4522
4563
  const n = H(t), r = [];
4523
4564
  let a = !1;
4524
4565
  for (const i of e) {
4525
- if (Ei.has(i.sectionType)) {
4566
+ if (ki.has(i.sectionType)) {
4526
4567
  r.push(St(i.title));
4527
4568
  for (const s of i.paragraphs)
4528
4569
  r.push(Ze(s));
@@ -4534,10 +4575,10 @@ function Ni(e, t) {
4534
4575
  r.push(St(s)), a = !0;
4535
4576
  }
4536
4577
  for (const s of i.paragraphs)
4537
- r.push(Ii(s));
4578
+ r.push(Ni(s));
4538
4579
  continue;
4539
4580
  }
4540
- if (ki.has(i.sectionType)) {
4581
+ if (_i.has(i.sectionType)) {
4541
4582
  r.push(Et(i.title));
4542
4583
  for (const s of i.paragraphs)
4543
4584
  r.push(Ze(s));
@@ -4549,32 +4590,32 @@ function Ni(e, t) {
4549
4590
  }
4550
4591
  return r;
4551
4592
  }
4552
- async function Ys(e, t) {
4553
- const n = _i(e, t), r = Ni(n, t), a = n.find((o) => o.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4593
+ async function Zs(e, t) {
4594
+ const n = Ii(e, t), r = Ai(n, t), a = n.find((c) => c.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4554
4595
  properties: {
4555
4596
  page: {
4556
4597
  margin: {
4557
- top: he(25),
4558
- bottom: he(25),
4559
- left: he(25),
4560
- right: he(20)
4598
+ top: ye(25),
4599
+ bottom: ye(25),
4600
+ left: ye(25),
4601
+ right: ye(20)
4561
4602
  }
4562
4603
  }
4563
4604
  },
4564
4605
  children: r
4565
- }, c = new Kr({
4606
+ }, o = new Kr({
4566
4607
  sections: [s]
4567
- }), l = await Xr.toBlob(c);
4608
+ }), l = await Xr.toBlob(o);
4568
4609
  Yr(l, i);
4569
4610
  }
4570
- async function Zs(e) {
4611
+ async function Qs(e) {
4571
4612
  window.print();
4572
4613
  }
4573
- function Qs(e, t) {
4614
+ function eo(e, t) {
4574
4615
  const n = [], r = t === "zh";
4575
4616
  let a = 0;
4576
4617
  const i = () => `v_${++a}`;
4577
- return e.state.doc.descendants((s, c) => {
4618
+ return e.state.doc.descendants((s, o) => {
4578
4619
  if (s.type.name === "patent_title") {
4579
4620
  const l = s.textContent.trim();
4580
4621
  if (l.length === 0)
@@ -4583,56 +4624,56 @@ function Qs(e, t) {
4583
4624
  severity: "warning",
4584
4625
  message: r ? "专利名称为空" : "Patent title is empty",
4585
4626
  sectionType: "patent_title",
4586
- pos: c
4627
+ pos: o
4587
4628
  });
4588
4629
  else {
4589
- const o = l.replace(/\s/g, "").length;
4590
- o > 25 && r && n.push({
4630
+ const c = l.replace(/\s/g, "").length;
4631
+ c > 25 && r && n.push({
4591
4632
  id: i(),
4592
4633
  severity: "error",
4593
- message: `专利名称超过25个汉字(当前${o}字)`,
4634
+ message: `专利名称超过25个汉字(当前${c}字)`,
4594
4635
  sectionType: "patent_title",
4595
- pos: c
4636
+ pos: o
4596
4637
  });
4597
4638
  }
4598
4639
  return !1;
4599
4640
  }
4600
4641
  if (s.type.name === "patent_section") {
4601
- const l = s.attrs.sectionType, o = s.textContent.trim();
4602
- if (o.length === 0 && n.push({
4642
+ const l = s.attrs.sectionType, c = s.textContent.trim();
4643
+ if (c.length === 0 && n.push({
4603
4644
  id: i(),
4604
4645
  severity: "warning",
4605
4646
  message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
4606
4647
  sectionType: l,
4607
- pos: c
4648
+ pos: o
4608
4649
  }), l === "abstract") {
4609
- const d = o.replace(/\s/g, "").length;
4650
+ const d = c.replace(/\s/g, "").length;
4610
4651
  d > 0 && d < 50 && n.push({
4611
4652
  id: i(),
4612
4653
  severity: "warning",
4613
4654
  message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
4614
4655
  sectionType: l,
4615
- pos: c
4656
+ pos: o
4616
4657
  }), d > 300 && n.push({
4617
4658
  id: i(),
4618
4659
  severity: "warning",
4619
4660
  message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
4620
4661
  sectionType: l,
4621
- pos: c
4662
+ pos: o
4622
4663
  });
4623
4664
  }
4624
4665
  if (l === "claims") {
4625
4666
  const d = /^(\d+)\s*[.、]/;
4626
- s.forEach((u, m) => {
4627
- if (u.type.name !== "paragraph") return;
4628
- const f = u.textContent.trim(), p = d.exec(f);
4667
+ s.forEach((m, g) => {
4668
+ if (m.type.name !== "paragraph") return;
4669
+ const h = m.textContent.trim(), p = d.exec(h);
4629
4670
  if (!p) return;
4630
4671
  const b = p[1];
4631
- f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
4672
+ h.length > 0 && !h.endsWith("。") && !h.endsWith(".") && n.push({
4632
4673
  id: i(),
4633
4674
  severity: "warning",
4634
4675
  message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
4635
- pos: c + 1 + m
4676
+ pos: o + 1 + g
4636
4677
  });
4637
4678
  });
4638
4679
  }
@@ -4641,7 +4682,7 @@ function Qs(e, t) {
4641
4682
  return !0;
4642
4683
  }), n;
4643
4684
  }
4644
- const Ai = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4685
+ const Pi = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4645
4686
  function Li(e, t) {
4646
4687
  const n = [];
4647
4688
  let r;
@@ -4659,7 +4700,7 @@ function Li(e, t) {
4659
4700
  }
4660
4701
  const mn = (e) => {
4661
4702
  if (e.type.name === "reference")
4662
- return Pi(e);
4703
+ return Di(e);
4663
4704
  if (e.type.name === "hardBreak")
4664
4705
  return `
4665
4706
  `;
@@ -4669,7 +4710,7 @@ const mn = (e) => {
4669
4710
  return e.forEach((n) => {
4670
4711
  t += mn(n);
4671
4712
  }), t;
4672
- }, Pi = (e) => {
4713
+ }, Di = (e) => {
4673
4714
  const t = e.attrs.lang === "en" ? "en" : "zh", n = e.attrs.targetType === "figure" ? "figure" : "claim", r = typeof e.attrs.displayText == "string" ? e.attrs.displayText.trim() : "";
4674
4715
  if (r)
4675
4716
  return r;
@@ -4679,62 +4720,62 @@ const mn = (e) => {
4679
4720
  }
4680
4721
  const a = Number(e.attrs.resolvedNumber);
4681
4722
  return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
4682
- }, eo = (e) => {
4723
+ }, to = (e) => {
4683
4724
  const t = [];
4684
4725
  return e.state.doc.descendants((n, r) => {
4685
4726
  if (n.type.name === "patent_section")
4686
4727
  return n.attrs.sectionType === "claims";
4687
4728
  if (n.type.name !== "paragraph") return !0;
4688
- const a = mn(n).trim(), i = Ai.exec(a);
4729
+ const a = mn(n).trim(), i = Pi.exec(a);
4689
4730
  if (!i) return !0;
4690
4731
  const s = parseInt(i[1], 10);
4691
4732
  if (!Number.isFinite(s) || s <= 0) return !0;
4692
- const c = a.slice(i[0].length).trim(), l = Li(c, s);
4733
+ const o = a.slice(i[0].length).trim(), l = Li(o, s);
4693
4734
  return t.push({
4694
4735
  claimId: `claim_${s}`,
4695
4736
  number: s,
4696
4737
  dependsOn: l,
4697
- dependsOnClaimIds: l.map((o) => `claim_${o}`),
4698
- body: c,
4738
+ dependsOnClaimIds: l.map((c) => `claim_${c}`),
4739
+ body: o,
4699
4740
  pos: r
4700
4741
  }), !0;
4701
4742
  }), t;
4702
4743
  };
4703
4744
  export {
4704
- mi as EditorView,
4745
+ gi as EditorView,
4705
4746
  jt as PatchDiffPluginKey,
4706
- pi as PatentEditor,
4707
- Bs as acceptAllPatches,
4708
- zs as acceptPatch,
4709
- Ks as applyDocDiffDecorations,
4710
- qs as buildAIContext,
4711
- Js as buildClaimsJSONContent,
4747
+ hi as PatentEditor,
4748
+ Hs as acceptAllPatches,
4749
+ Os as acceptPatch,
4750
+ Xs as applyDocDiffDecorations,
4751
+ Ws as buildAIContext,
4752
+ Ks as buildClaimsJSONContent,
4712
4753
  tn as buildPatentDocument,
4713
- $s as clearPatches,
4714
- fi as createChatSessionAPI,
4754
+ zs as clearPatches,
4755
+ pi as createChatSessionAPI,
4715
4756
  ct as createCommandExecutor,
4716
- Ka as createEditorConfig,
4717
- Gs as createMockAIService,
4718
- Vs as createMockChatSessionAPI,
4719
- gi as createSSEAdapter,
4720
- Zs as exportToPdf,
4721
- Ys as exportToWord,
4722
- eo as extractClaimsFromEditor,
4757
+ Xa as createEditorConfig,
4758
+ Vs as createMockAIService,
4759
+ Js as createMockChatSessionAPI,
4760
+ fi as createSSEAdapter,
4761
+ Qs as exportToPdf,
4762
+ Zs as exportToWord,
4763
+ to as extractClaimsFromEditor,
4723
4764
  on as findSectionAtCursor,
4724
- ei as getAllSections,
4725
- Us as getMissingSectionDeps,
4726
- Ms as getPatches,
4727
- Rs as onPatchChange,
4765
+ ti as getAllSections,
4766
+ qs as getMissingSectionDeps,
4767
+ Fs as getPatches,
4768
+ Ms as onPatchChange,
4728
4769
  B as pluginManager,
4729
- Hs as rejectAllPatches,
4730
- Os as rejectPatch,
4731
- Xs as removeDocDiffDecorations,
4732
- Ds as resolvePatchTarget,
4770
+ Us as rejectAllPatches,
4771
+ Bs as rejectPatch,
4772
+ Ys as removeDocDiffDecorations,
4773
+ Rs as resolvePatchTarget,
4733
4774
  sn as sectionContextDeps,
4734
- Fs as setPatches,
4775
+ $s as setPatches,
4735
4776
  I as useEditorStore,
4736
- Qs as validatePatentDocument,
4737
- Ws as writeStream,
4738
- js as writeStreamFromSSE
4777
+ eo as validatePatentDocument,
4778
+ js as writeStream,
4779
+ Gs as writeStreamFromSSE
4739
4780
  };
4740
4781
  //# sourceMappingURL=lib.js.map