patent-editor 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -170,19 +170,19 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
170
170
  }, [e]);
171
171
  const i = ae(
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__ */ g("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ L(
181
181
  "button",
182
182
  {
183
- className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
184
- onClick: () => i(c),
185
- onMouseEnter: () => a(c),
183
+ className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
184
+ onClick: () => i(o),
185
+ onMouseEnter: () => a(o),
186
186
  children: [
187
187
  /* @__PURE__ */ g("span", { className: "slash-menu-icon", children: s.icon }),
188
188
  /* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
@@ -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 {
@@ -408,9 +410,9 @@ const aa = Oe.create({
408
410
  let a = ke(e.state.doc, t, r);
409
411
  const i = e.state.tr;
410
412
  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);
413
+ for (const o of a) {
414
+ const l = o.from + s, c = o.to + s;
415
+ i.insertText(n, l, c), s += n.length - (o.to - o.from);
414
416
  }
415
417
  return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
416
418
  },
@@ -458,23 +460,23 @@ function ft(e) {
458
460
  }
459
461
  });
460
462
  }
461
- const ia = -1, sa = 1, pt = 0;
463
+ const sa = -1, oa = 1, pt = 0;
462
464
  let Ge = null;
463
- function oa() {
465
+ function ca() {
464
466
  return Ge || (Ge = new Pt()), Ge;
465
467
  }
466
468
  const jt = new we("patchDiff");
467
- function ca(e, t) {
469
+ function la(e, t) {
468
470
  let n = null;
469
471
  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
472
  }
471
473
  function Gt(e, t, n) {
472
474
  const r = [];
473
475
  let a = "", i = !0;
474
- return e.state.doc.nodesBetween(t, n, (s, c) => {
476
+ return e.state.doc.nodesBetween(t, n, (s, o) => {
475
477
  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;
478
+ const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, u = s.text.slice(c, d);
479
+ r.push({ textIdx: a.length, docPos: l + c, len: u.length }), a += u, i = !1;
478
480
  } else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
479
481
  }), { text: a, segments: r };
480
482
  }
@@ -493,53 +495,53 @@ function ye(e, t) {
493
495
  }
494
496
  function ht(e, t, n, r, a) {
495
497
  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);
498
+ let o = 0;
499
+ for (; o <= i.length - t.length; ) {
500
+ const l = i.indexOf(t, o);
499
501
  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;
502
+ const c = ye(s, l), d = ye(s, l + t.length);
503
+ if (c >= 0 && d >= 0 && !(a && a.has(c)))
504
+ return { from: c, to: d };
505
+ o = l + 1;
504
506
  }
505
507
  return null;
506
508
  }
507
- function Ds(e, t, n, r, a) {
509
+ function Rs(e, t, n, r, a) {
508
510
  const i = t.target;
509
511
  let s = null;
510
- const c = /* @__PURE__ */ new Set();
512
+ const o = /* @__PURE__ */ new Set();
511
513
  if (a)
512
514
  for (const d of a)
513
- c.add(d.from);
515
+ o.add(d.from);
514
516
  if (!i)
515
517
  t.from != null && t.to != null && (s = { from: t.from, to: t.to });
516
518
  else if (i.type === "section" && i.sectionType)
517
- s = ca(e, i.sectionType);
519
+ s = la(e, i.sectionType);
518
520
  else if (i.type === "ref" && i.refIndex != null) {
519
521
  const d = n[i.refIndex];
520
522
  (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));
523
+ } else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
522
524
  if (!s) return null;
523
525
  let l = s;
524
526
  if (t.search) {
525
- const d = ht(e, t.search, s.from, s.to, c);
527
+ const d = ht(e, t.search, s.from, s.to, o);
526
528
  d && (l = d);
527
529
  }
528
- const o = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
530
+ const c = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
529
531
  return {
530
532
  id: `patch_${Date.now()}_${r}`,
531
533
  type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
532
534
  from: l.from,
533
535
  to: t.op === "insert" ? l.from : l.to,
534
536
  content: t.content || "",
535
- originalText: o,
537
+ originalText: c,
536
538
  reason: t.reason,
537
539
  status: "pending"
538
540
  };
539
541
  }
540
542
  const j = /* @__PURE__ */ new Map();
541
543
  let De = [];
542
- function Rs(e) {
544
+ function Ms(e) {
543
545
  return De.push(e), () => {
544
546
  De = De.filter((t) => t !== e);
545
547
  };
@@ -547,17 +549,17 @@ function Rs(e) {
547
549
  function ue() {
548
550
  De.forEach((e) => e());
549
551
  }
550
- function Ms(e = "default") {
552
+ function Fs(e = "default") {
551
553
  return [...j.get(e) || []];
552
554
  }
553
- function Fs(e, t = "default") {
555
+ function $s(e, t = "default") {
554
556
  j.set(t, e), ue();
555
557
  }
556
- function $s(e = "default") {
558
+ function zs(e = "default") {
557
559
  j.delete(e), ue();
558
560
  }
559
- function zs(e, t, n = "default") {
560
- const r = j.get(n) || [], a = r.find((c) => c.id === t);
561
+ function Os(e, t, n = "default") {
562
+ const r = j.get(n) || [], a = r.find((o) => o.id === t);
561
563
  if (!a || a.status !== "pending") return !1;
562
564
  a.status = "accepted";
563
565
  const { tr: i } = e.state;
@@ -572,19 +574,19 @@ function zs(e, t, n = "default") {
572
574
  i.insertText(a.content, a.from, a.to);
573
575
  e.view.dispatch(i);
574
576
  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);
577
+ for (const o of r) {
578
+ if (o.id === t || o.status !== "pending") continue;
579
+ const l = s.map(o.from, 1), c = s.map(o.to, -1);
580
+ l >= c && o.type !== "insert" ? o.status = "rejected" : (o.from = l, o.to = o.type === "insert" ? l : c);
579
581
  }
580
- return j.set(n, r.filter((c) => c.id !== t && c.status === "pending")), qe(e), ue(), !0;
582
+ return j.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), ue(), !0;
581
583
  }
582
- function Os(e, t, n = "default") {
584
+ function Bs(e, t, n = "default") {
583
585
  const r = j.get(n) || [], a = r.find((i) => i.id === t);
584
586
  return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), qe(e), ue(), !0);
585
587
  }
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;
588
+ function Hs(e, t = "default") {
589
+ const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
588
590
  for (const s of a)
589
591
  if (s.type === "delete")
590
592
  i.delete(s.from, s.to);
@@ -597,56 +599,56 @@ function Bs(e, t = "default") {
597
599
  i.insertText(s.content, s.from, s.to);
598
600
  e.view.dispatch(i), j.delete(t), qe(e), ue();
599
601
  }
600
- function Hs(e, t = "default") {
602
+ function Us(e, t = "default") {
601
603
  j.delete(t), qe(e), ue();
602
604
  }
603
605
  function qe(e) {
604
606
  e.view.dispatch(e.state.tr.setMeta(jt, !0));
605
607
  }
606
- function la(e, t, n) {
608
+ function da(e, t, n) {
607
609
  const r = [];
608
610
  return e.nodesBetween(t, n, (a, i) => {
609
611
  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;
612
+ const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
613
+ return c > l && r.push({ from: l, to: c }), !1;
612
614
  }
613
615
  return !0;
614
616
  }), r;
615
617
  }
616
- function da(e, t) {
618
+ function ua(e, t) {
617
619
  if (!t.originalText || !t.content) return null;
618
620
  try {
619
- const c = e.resolve(t.from), l = e.resolve(t.to);
620
- if (c.parent !== l.parent || !c.parent.isTextblock) return null;
621
+ const o = e.resolve(t.from), l = e.resolve(t.to);
622
+ if (o.parent !== l.parent || !o.parent.isTextblock) return null;
621
623
  } catch {
622
624
  return null;
623
625
  }
624
- const n = oa(), r = n.diff_main(t.originalText, t.content);
626
+ const n = ca(), r = n.diff_main(t.originalText, t.content);
625
627
  n.diff_cleanupSemantic(r);
626
- const a = r.filter(([c]) => c === pt).reduce((c, [, l]) => c + l.length, 0);
628
+ const a = r.filter(([o]) => o === pt).reduce((o, [, l]) => o + l.length, 0);
627
629
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
628
630
  const i = [];
629
631
  let s = t.from;
630
- for (const [c, l] of r)
631
- if (c === pt)
632
+ for (const [o, l] of r)
633
+ if (o === pt)
632
634
  s += l.length;
633
- else if (c === ia) {
634
- const o = s + l.length;
635
+ else if (o === sa) {
636
+ const c = s + l.length;
635
637
  i.push(
636
- re.inline(s, o, {
638
+ re.inline(s, c, {
637
639
  class: "patch-diff-delete",
638
640
  "data-patch-id": t.id
639
641
  })
640
- ), s = o;
641
- } else c === sa && i.push(
642
+ ), s = c;
643
+ } else o === oa && i.push(
642
644
  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;
645
+ const c = document.createElement("span");
646
+ return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
645
647
  }, { side: 1 })
646
648
  );
647
649
  return i;
648
650
  }
649
- function ua(e = "default") {
651
+ function ma(e = "default") {
650
652
  return new Be({
651
653
  key: jt,
652
654
  props: {
@@ -656,14 +658,14 @@ function ua(e = "default") {
656
658
  const r = [];
657
659
  for (const a of n) {
658
660
  if (a.type === "replace") {
659
- const i = da(t.doc, a);
661
+ const i = ua(t.doc, a);
660
662
  if (i) {
661
663
  r.push(...i);
662
664
  continue;
663
665
  }
664
666
  }
665
667
  if (a.type === "delete" || a.type === "replace") {
666
- const i = la(t.doc, a.from, a.to);
668
+ const i = da(t.doc, a.from, a.to);
667
669
  for (const s of i)
668
670
  r.push(
669
671
  re.inline(s.from, s.to, {
@@ -672,12 +674,12 @@ function ua(e = "default") {
672
674
  })
673
675
  );
674
676
  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(`
677
+ const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
676
678
  `);
677
679
  r.push(
678
680
  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;
681
+ const l = document.createElement(o ? "div" : "span");
682
+ 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
683
  }, { side: 1 })
682
684
  );
683
685
  }
@@ -709,7 +711,7 @@ function Jt(e, t) {
709
711
  );
710
712
  });
711
713
  }
712
- const ma = Z.create({
714
+ const ga = Z.create({
713
715
  name: "hardBreak",
714
716
  inline: !0,
715
717
  group: "inline",
@@ -730,7 +732,7 @@ const ma = Z.create({
730
732
  }
731
733
  };
732
734
  }
733
- }), ga = Oe.create({
735
+ }), fa = Oe.create({
734
736
  name: "dragDropUX",
735
737
  addProseMirrorPlugins() {
736
738
  return [
@@ -741,19 +743,19 @@ const ma = Z.create({
741
743
  Xn()
742
744
  ];
743
745
  }
744
- }), fa = Oe.create({
746
+ }), pa = Oe.create({
745
747
  name: "patchDiff",
746
748
  addOptions() {
747
749
  return { editorId: "default" };
748
750
  },
749
751
  addProseMirrorPlugins() {
750
- return [ua(this.options.editorId)];
752
+ return [ma(this.options.editorId)];
751
753
  }
752
- }), pa = [
754
+ }), ha = [
753
755
  An,
754
756
  Ln,
755
757
  Pn,
756
- ga,
758
+ fa,
757
759
  Dn.configure({
758
760
  levels: [1, 2, 3, 4, 5, 6]
759
761
  }),
@@ -762,7 +764,7 @@ const ma = Z.create({
762
764
  Fn,
763
765
  $n,
764
766
  zn,
765
- ma,
767
+ ga,
766
768
  On,
767
769
  Bn,
768
770
  Hn.configure({ nested: !0 }),
@@ -795,12 +797,12 @@ const ma = Z.create({
795
797
  Qr.configure({
796
798
  suggestion: na()
797
799
  }),
798
- aa,
800
+ ia,
799
801
  Yn.configure({
800
802
  types: ["heading", "paragraph"],
801
803
  defaultAlignment: "left"
802
804
  })
803
- ], ha = [
805
+ ], ya = [
804
806
  nr,
805
807
  rr,
806
808
  ar,
@@ -814,11 +816,11 @@ const ma = Z.create({
814
816
  dr,
815
817
  ur,
816
818
  mr.configure({ multicolor: !0 })
817
- ], ya = [
818
- ...pa,
819
- ...ha
819
+ ], ba = [
820
+ ...ha,
821
+ ...ya
820
822
  ];
821
- class ba {
823
+ class va {
822
824
  constructor() {
823
825
  Se(this, "commands", /* @__PURE__ */ new Map());
824
826
  }
@@ -843,9 +845,9 @@ class ba {
843
845
  return !r || !r.isActive ? !1 : r.isActive(n);
844
846
  }
845
847
  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)
848
+ var d, u, m, p;
849
+ const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, c = this.commands.get(t);
850
+ if (!c)
849
851
  return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
850
852
  name: t,
851
853
  success: !1,
@@ -858,23 +860,23 @@ class ba {
858
860
  durationMs: Date.now() - i
859
861
  }), !1;
860
862
  try {
861
- const b = !!await o.execute(n, r);
862
- !b && l && c && n.editor.commands.setContent(l);
863
+ const b = !!await c.execute(n, r);
864
+ !b && l && o && n.editor.commands.setContent(l);
863
865
  const y = {
864
866
  name: t,
865
867
  success: b,
866
868
  durationMs: Date.now() - i
867
869
  };
868
870
  return (m = a.onComplete) == null || m.call(a, y), b;
869
- } catch (p) {
870
- l && c && n.editor.commands.setContent(l);
871
+ } catch (h) {
872
+ l && o && n.editor.commands.setContent(l);
871
873
  const b = {
872
874
  name: t,
873
875
  success: !1,
874
876
  durationMs: Date.now() - i,
875
- error: p
877
+ error: h
876
878
  };
877
- return (f = a.onComplete) == null || f.call(a, b), !1;
879
+ return (p = a.onComplete) == null || p.call(a, b), !1;
878
880
  }
879
881
  }
880
882
  getCommand(t) {
@@ -884,8 +886,8 @@ class ba {
884
886
  return Array.from(this.commands.keys()).sort();
885
887
  }
886
888
  }
887
- const le = new ba();
888
- class va {
889
+ const le = new va();
890
+ class wa {
889
891
  constructor() {
890
892
  Se(this, "plugins", /* @__PURE__ */ new Map());
891
893
  Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
@@ -970,7 +972,7 @@ class va {
970
972
  });
971
973
  }
972
974
  }
973
- const B = new va(), yt = {
975
+ const B = new wa(), yt = {
974
976
  zh: {
975
977
  language: "语言",
976
978
  bold: "加粗",
@@ -1223,7 +1225,7 @@ const Ie = () => {
1223
1225
  document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1224
1226
  (e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
1225
1227
  }), 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({
1228
+ }, xa = Z.create({
1227
1229
  name: "mermaid",
1228
1230
  group: "block",
1229
1231
  atom: !0,
@@ -1245,22 +1247,22 @@ const Ie = () => {
1245
1247
  i.classList.add("mermaid-node");
1246
1248
  const s = document.createElement("div");
1247
1249
  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
1250
  const o = document.createElement("div");
1253
- o.className = "mermaid-edit";
1251
+ o.className = "mermaid-preview", o.contentEditable = "false";
1252
+ const l = document.createElement("div");
1253
+ l.className = "mermaid-view-hint", s.append(o, l);
1254
+ const c = document.createElement("div");
1255
+ c.className = "mermaid-edit";
1254
1256
  const d = document.createElement("textarea");
1255
1257
  d.className = "mermaid-editor-textarea", d.spellcheck = !1;
1256
1258
  const u = document.createElement("div");
1257
1259
  u.className = "mermaid-edit-toolbar";
1258
1260
  const m = document.createElement("span");
1259
1261
  m.className = "mermaid-error-msg";
1260
- const f = document.createElement("button");
1261
- f.className = "mermaid-cancel-btn", f.type = "button";
1262
1262
  const p = document.createElement("button");
1263
- p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), o.append(d, u), i.append(s, o);
1263
+ p.className = "mermaid-cancel-btn", p.type = "button";
1264
+ const h = document.createElement("button");
1265
+ h.className = "mermaid-save-btn", h.type = "button", u.append(m, p, h), c.append(d, u), i.append(s, c);
1264
1266
  const b = (C) => {
1265
1267
  const _ = typeof n == "function" ? n() : null;
1266
1268
  typeof _ == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(_, void 0, { ...r.attrs, ...C }), D && D(A), !0));
@@ -1270,16 +1272,16 @@ const Ie = () => {
1270
1272
  const _ = C.trim();
1271
1273
  if (_ !== y) {
1272
1274
  if (!_) {
1273
- c.innerHTML = "", y = "";
1275
+ o.innerHTML = "", y = "";
1274
1276
  return;
1275
1277
  }
1276
1278
  try {
1277
1279
  const A = await import("mermaid");
1278
1280
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1279
1281
  const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1280
- c.innerHTML = z, y = _;
1282
+ o.innerHTML = z, y = _;
1281
1283
  } catch {
1282
- c.innerHTML = "", y = "";
1284
+ o.innerHTML = "", y = "";
1283
1285
  } finally {
1284
1286
  Ie();
1285
1287
  }
@@ -1297,7 +1299,7 @@ const Ie = () => {
1297
1299
  const A = await import("mermaid");
1298
1300
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1299
1301
  const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1300
- c.innerHTML = z, y = _, Ie();
1302
+ o.innerHTML = z, y = _, Ie();
1301
1303
  } catch {
1302
1304
  Ie();
1303
1305
  const A = I.getState().editorLanguage;
@@ -1308,39 +1310,39 @@ const Ie = () => {
1308
1310
  };
1309
1311
  s.addEventListener("dblclick", (C) => {
1310
1312
  C.preventDefault(), C.stopPropagation(), T();
1311
- }), p.addEventListener("click", (C) => {
1313
+ }), h.addEventListener("click", (C) => {
1312
1314
  C.stopPropagation(), x();
1313
- }), f.addEventListener("click", (C) => {
1315
+ }), p.addEventListener("click", (C) => {
1314
1316
  C.stopPropagation(), v();
1315
1317
  }), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
1316
1318
  const S = () => {
1317
1319
  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
+ s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none", h.textContent = _.mermaidSaveAndRender || "保存并渲染", p.textContent = _.mermaidCancel || "取消";
1321
+ const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
1320
1322
  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);
1321
1323
  };
1322
1324
  let N = I.getState().editorLanguage;
1323
- const h = I.subscribe((C) => {
1325
+ const f = I.subscribe((C) => {
1324
1326
  C.editorLanguage !== N && (N = C.editorLanguage, S());
1325
1327
  });
1326
1328
  return S(), {
1327
1329
  dom: i,
1328
1330
  stopEvent: (C) => {
1329
1331
  const _ = C.target;
1330
- return !!(_ === d || o.contains(_));
1332
+ return !!(_ === d || c.contains(_));
1331
1333
  },
1332
1334
  ignoreMutation: () => !0,
1333
1335
  update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, S(), !0),
1334
1336
  destroy: () => {
1335
- h(), Ie();
1337
+ f(), Ie();
1336
1338
  }
1337
1339
  };
1338
1340
  };
1339
1341
  }
1340
- }), xa = {
1342
+ }), Ca = {
1341
1343
  name: "mermaid",
1342
1344
  version: "1.0.0",
1343
- extensions: [wa],
1345
+ extensions: [xa],
1344
1346
  toolbarItems: [
1345
1347
  {
1346
1348
  id: "mermaid-insert",
@@ -1365,7 +1367,7 @@ const Ie = () => {
1365
1367
  }
1366
1368
  }
1367
1369
  }
1368
- }, Ve = "https://draw.goatpatent.com", Ca = Z.create({
1370
+ }, Ve = "https://draw.goatpatent.com", Ta = Z.create({
1369
1371
  name: "drawio",
1370
1372
  group: "block",
1371
1373
  atom: !0,
@@ -1388,16 +1390,16 @@ const Ie = () => {
1388
1390
  i.classList.add("drawio-node");
1389
1391
  const s = document.createElement("div");
1390
1392
  s.className = "drawio-view", s.contentEditable = "false";
1391
- const c = document.createElement("img");
1392
- c.className = "drawio-preview-img", c.style.display = "none";
1393
+ const o = document.createElement("img");
1394
+ o.className = "drawio-preview-img", o.style.display = "none";
1393
1395
  const l = document.createElement("div");
1394
- l.className = "drawio-view-hint", s.append(c, l), i.append(s);
1395
- const o = (T) => {
1396
+ l.className = "drawio-view-hint", s.append(o, l), i.append(s);
1397
+ const c = (T) => {
1396
1398
  const v = typeof n == "function" ? n() : null;
1397
1399
  typeof v == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...T }), S && S(x), !0));
1398
1400
  };
1399
1401
  let d = null, u = null, m = null;
1400
- const f = () => {
1402
+ const p = () => {
1401
1403
  if (a) return;
1402
1404
  a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1403
1405
  const T = document.createElement("div");
@@ -1407,9 +1409,9 @@ const Ie = () => {
1407
1409
  const x = I.getState().editorLanguage, S = document.createElement("span");
1408
1410
  S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
1409
1411
  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}`;
1412
+ N.className = "drawio-modal-close-btn", N.textContent = "✕", N.type = "button", N.addEventListener("click", () => h()), 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);
1413
+ const f = x === "en" ? "en" : "zh";
1414
+ m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${f}`;
1413
1415
  const C = m;
1414
1416
  d = (_) => {
1415
1417
  var D, z;
@@ -1431,21 +1433,21 @@ const Ie = () => {
1431
1433
  (z = C.contentWindow) == null || z.postMessage(
1432
1434
  JSON.stringify({ action: "export", format: "svg" }),
1433
1435
  Ve
1434
- ), o({ xml: Q });
1436
+ ), c({ xml: Q });
1435
1437
  } else if (A.event === "export") {
1436
1438
  const Q = A.data || "";
1437
- o({ svg: Q }), p();
1438
- } else A.event === "exit" && p();
1439
+ c({ svg: Q }), h();
1440
+ } else A.event === "exit" && h();
1439
1441
  }, window.addEventListener("message", d);
1440
- }, p = () => {
1442
+ }, h = () => {
1441
1443
  a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), b();
1442
1444
  };
1443
1445
  s.addEventListener("dblclick", (T) => {
1444
- T.preventDefault(), T.stopPropagation(), f();
1446
+ T.preventDefault(), T.stopPropagation(), p();
1445
1447
  });
1446
1448
  const b = () => {
1447
1449
  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");
1450
+ x ? (o.src = x, o.style.display = "block") : (o.src = "", o.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");
1449
1451
  };
1450
1452
  let y = I.getState().editorLanguage;
1451
1453
  const w = I.subscribe((T) => {
@@ -1461,10 +1463,10 @@ const Ie = () => {
1461
1463
  };
1462
1464
  };
1463
1465
  }
1464
- }), Ta = {
1466
+ }), Sa = {
1465
1467
  name: "drawio",
1466
1468
  version: "1.0.0",
1467
- extensions: [Ca],
1469
+ extensions: [Ta],
1468
1470
  toolbarItems: [
1469
1471
  {
1470
1472
  id: "drawio-insert",
@@ -1495,9 +1497,9 @@ const Ie = () => {
1495
1497
  selected: n,
1496
1498
  editor: r
1497
1499
  }) => {
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 ?? "");
1500
+ const a = W(null), [i, s] = F(!1), o = e.type.name === "math_block", l = W(!1), c = W(t), d = W(e.attrs.latex ?? "");
1499
1501
  M(() => {
1500
- o.current = t;
1502
+ c.current = t;
1501
1503
  }, [t]), M(() => {
1502
1504
  d.current = e.attrs.latex ?? "";
1503
1505
  }, [e.attrs.latex]);
@@ -1507,23 +1509,23 @@ const Ie = () => {
1507
1509
  var b, y;
1508
1510
  if (!l.current) return;
1509
1511
  l.current = !1;
1510
- 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 });
1512
+ const h = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
1513
+ c.current({ latex: h }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1512
1514
  }, []);
1513
1515
  M(() => {
1514
1516
  var b, y, w;
1515
- 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
+ const h = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
1518
+ n && h && u();
1517
1519
  }, [n, u]), M(() => {
1518
1520
  i && requestAnimationFrame(() => {
1519
1521
  var b;
1520
- const p = a.current;
1521
- p && (p.virtualKeyboardMode = "onfocus", (b = p.focus) == null || b.call(p));
1522
+ const h = a.current;
1523
+ h && (h.virtualKeyboardMode = "onfocus", (b = h.focus) == null || b.call(h));
1522
1524
  });
1523
1525
  }, [i]), M(() => {
1524
1526
  if (!i) return;
1525
- const p = a.current;
1526
- if (!p) return;
1527
+ const h = a.current;
1528
+ if (!h) return;
1527
1529
  const b = () => {
1528
1530
  setTimeout(() => {
1529
1531
  var T, v, x;
@@ -1534,40 +1536,40 @@ const Ie = () => {
1534
1536
  }, y = (w) => {
1535
1537
  w.key === "Escape" && m();
1536
1538
  };
1537
- return p.addEventListener("focusout", b), p.addEventListener("keydown", y), () => {
1538
- p.removeEventListener("focusout", b), p.removeEventListener("keydown", y);
1539
+ return h.addEventListener("focusout", b), h.addEventListener("keydown", y), () => {
1540
+ h.removeEventListener("focusout", b), h.removeEventListener("keydown", y);
1539
1541
  };
1540
1542
  }, [i, m]), M(() => {
1541
1543
  !i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
1542
1544
  }, [e.attrs.latex, i]);
1543
- let f = "";
1545
+ let p = "";
1544
1546
  try {
1545
- f = gr.renderToString(e.attrs.latex || "", {
1547
+ p = gr.renderToString(e.attrs.latex || "", {
1546
1548
  throwOnError: !1,
1547
- displayMode: c
1549
+ displayMode: o
1548
1550
  });
1549
1551
  } catch {
1550
- f = e.attrs.latex || "";
1552
+ p = e.attrs.latex || "";
1551
1553
  }
1552
1554
  return /* @__PURE__ */ g(
1553
1555
  _n,
1554
1556
  {
1555
- as: c ? "div" : "span",
1556
- className: c ? "math-block" : "math-inline",
1557
+ as: o ? "div" : "span",
1558
+ className: o ? "math-block" : "math-inline",
1557
1559
  children: i ? /* @__PURE__ */ g(
1558
1560
  "math-field",
1559
1561
  {
1560
1562
  ref: a,
1561
- className: c ? "math-live-field math-live-field--block" : "math-live-field",
1563
+ className: o ? "math-live-field math-live-field--block" : "math-live-field",
1562
1564
  children: e.attrs.latex
1563
1565
  }
1564
1566
  ) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
1565
- /* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: f } }),
1567
+ /* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: p } }),
1566
1568
  /* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
1567
1569
  ] })
1568
1570
  }
1569
1571
  );
1570
- }, Sa = Z.create({
1572
+ }, Ea = Z.create({
1571
1573
  name: "math_inline",
1572
1574
  group: "inline",
1573
1575
  inline: !0,
@@ -1600,7 +1602,7 @@ const Ie = () => {
1600
1602
  }
1601
1603
  });
1602
1604
  }
1603
- }), Ea = Z.create({
1605
+ }), ka = Z.create({
1604
1606
  name: "math_block",
1605
1607
  group: "block",
1606
1608
  atom: !0,
@@ -1623,10 +1625,10 @@ const Ie = () => {
1623
1625
  }
1624
1626
  });
1625
1627
  }
1626
- }), ka = {
1628
+ }), _a = {
1627
1629
  name: "math",
1628
1630
  version: "1.0.0",
1629
- extensions: [Sa, Ea],
1631
+ extensions: [Ea, ka],
1630
1632
  toolbarItems: [
1631
1633
  {
1632
1634
  id: "math-inline-insert",
@@ -1674,10 +1676,10 @@ const Ie = () => {
1674
1676
  }, st = (e, t, n = {}) => {
1675
1677
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
1676
1678
  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;
1679
+ return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
1678
1680
  }, Xt = (e, t, n = {}) => {
1679
1681
  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;
1682
+ return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
1681
1683
  }, Re = (e, t) => {
1682
1684
  const { $from: n } = e.state.selection;
1683
1685
  for (let r = n.depth; r >= 0; r -= 1) {
@@ -1689,7 +1691,7 @@ const Ie = () => {
1689
1691
  };
1690
1692
  }
1691
1693
  return null;
1692
- }, _a = (e) => {
1694
+ }, Ia = (e) => {
1693
1695
  const { $from: t } = e.state.selection;
1694
1696
  for (let n = t.depth; n >= 0; n -= 1) {
1695
1697
  const r = t.node(n);
@@ -1700,7 +1702,7 @@ const Ie = () => {
1700
1702
  };
1701
1703
  }
1702
1704
  return null;
1703
- }, Ia = (e, t) => e.state.schema.nodes[t] || null, Na = (e) => {
1705
+ }, Na = (e, t) => e.state.schema.nodes[t] || null, Aa = (e) => {
1704
1706
  const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
1705
1707
  return {
1706
1708
  type: e.type,
@@ -1708,7 +1710,7 @@ const Ie = () => {
1708
1710
  content: t
1709
1711
  };
1710
1712
  }, Yt = (e, t) => {
1711
- const n = Na(t);
1713
+ const n = Aa(t);
1712
1714
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1713
1715
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1714
1716
  var l;
@@ -1718,25 +1720,25 @@ const Ie = () => {
1718
1720
  const s = r.doc.nodeAt(i);
1719
1721
  if (!s || t.type && s.type.name !== t.type)
1720
1722
  return !1;
1721
- const c = { ...s.attrs, ...t.attrs };
1722
- return n.setNodeMarkup(i, void 0, c), a && a(n), !0;
1723
+ const o = { ...s.attrs, ...t.attrs };
1724
+ return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
1723
1725
  }), 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;
1726
+ var o;
1727
+ const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
1726
1728
  if (typeof i != "number")
1727
1729
  return !1;
1728
1730
  const s = r.doc.nodeAt(i);
1729
1731
  return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
1730
1732
  }), Qt = (e, t) => {
1731
- const n = Ia(e, t.type);
1733
+ const n = Na(e, t.type);
1732
1734
  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);
1735
+ const { from: s, to: o } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1734
1736
  if (!l)
1735
1737
  return !1;
1736
- const o = fr(l, n, t.attrs);
1737
- return o ? (r.wrap(l, o), i && i(r.scrollIntoView()), s <= c) : !1;
1738
+ const c = fr(l, n, t.attrs);
1739
+ return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
1738
1740
  }) : !1;
1739
- }, Aa = (e, t) => {
1741
+ }, La = (e, t) => {
1740
1742
  if (t.length === 0)
1741
1743
  return !1;
1742
1744
  const n = e.getJSON();
@@ -1748,13 +1750,13 @@ const Ie = () => {
1748
1750
  let Ne = 0;
1749
1751
  const Qe = [];
1750
1752
  let Ae = !1;
1751
- const La = 2e4, bt = 6e4;
1753
+ const Pa = 2e4, bt = 6e4;
1752
1754
  let $ = null, Me = !1, ne = null, pe = null;
1753
1755
  const et = /* @__PURE__ */ new Map();
1754
1756
  function vt() {
1755
1757
  ne && (window.removeEventListener("message", ne), ne = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1756
1758
  }
1757
- function Pa(e, t) {
1759
+ function Da(e, t) {
1758
1760
  const n = et.get(e);
1759
1761
  if (n) {
1760
1762
  t(n);
@@ -1783,26 +1785,26 @@ function tt() {
1783
1785
  };
1784
1786
  ne = (s) => {
1785
1787
  if (!$ || s.source !== $.contentWindow) return;
1786
- let c;
1788
+ let o;
1787
1789
  try {
1788
- c = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1790
+ o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1789
1791
  } catch {
1790
1792
  return;
1791
1793
  }
1792
- c.event === "init" ? (Me = !0, i()) : c.event === "load" ? setTimeout(() => {
1794
+ o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
1793
1795
  var l;
1794
1796
  (l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
1795
1797
  JSON.stringify({ action: "export", format: "svg" }),
1796
1798
  de
1797
1799
  );
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`);
1800
+ }, 1500) : o.event === "export" && a(o.data || "");
1801
+ }, window.addEventListener("message", ne), r = setTimeout(() => a(""), Pa), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
1800
1802
  }
1801
1803
  const Le = () => {
1802
1804
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1803
1805
  (e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
1804
1806
  }), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
1805
- }, Da = Z.create({
1807
+ }, Ra = Z.create({
1806
1808
  name: "figure",
1807
1809
  group: "block",
1808
1810
  content: "inline*",
@@ -1833,24 +1835,24 @@ const Le = () => {
1833
1835
  let r = t, a = !1, i = !1;
1834
1836
  const s = document.createElement("figure");
1835
1837
  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");
1838
+ const o = document.createElement("div");
1839
+ o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
1838
1840
  const l = document.createElement("img");
1839
1841
  l.className = "figure-img-preview";
1840
- const o = document.createElement("div");
1841
- o.className = "figure-upload-area";
1842
+ const c = document.createElement("div");
1843
+ c.className = "figure-upload-area";
1842
1844
  const d = document.createElement("span");
1843
1845
  d.className = "figure-upload-hint";
1844
1846
  const u = document.createElement("input");
1845
1847
  u.type = "file", u.accept = "image/*", u.style.display = "none";
1846
1848
  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");
1849
+ m.className = "figure-replace-btn", c.append(d, u);
1850
1850
  const p = document.createElement("div");
1851
- p.className = "figure-mermaid-preview", p.contentEditable = "false";
1851
+ p.className = "figure-mermaid-view", p.contentEditable = "false", p.setAttribute("spellcheck", "false");
1852
+ const h = document.createElement("div");
1853
+ h.className = "figure-mermaid-preview", h.contentEditable = "false";
1852
1854
  const b = document.createElement("div");
1853
- b.className = "figure-mermaid-view-hint", f.append(p, b);
1855
+ b.className = "figure-mermaid-view-hint", p.append(h, b);
1854
1856
  const y = document.createElement("div");
1855
1857
  y.className = "figure-mermaid-edit";
1856
1858
  const w = document.createElement("textarea");
@@ -1865,16 +1867,16 @@ const Le = () => {
1865
1867
  S.className = "figure-mermaid-error-inline", T.append(S, x, v), y.append(w, T);
1866
1868
  const N = document.createElement("div");
1867
1869
  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 f = document.createElement("img");
1871
+ f.className = "figure-drawio-preview-img", f.style.display = "none";
1870
1872
  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);
1873
+ C.className = "figure-drawio-view-hint", N.append(f, C), o.append(l, c, m), o.append(p, y), o.append(N);
1872
1874
  const _ = document.createElement("figcaption");
1873
1875
  _.className = "figure-caption";
1874
1876
  const A = document.createElement("span");
1875
1877
  A.className = "figure-id-label", A.contentEditable = "false";
1876
1878
  const D = document.createElement("span");
1877
- D.className = "figure-caption-content", _.append(A, D), s.append(c, _);
1879
+ D.className = "figure-caption-content", _.append(A, D), s.append(o, _);
1878
1880
  const z = (E) => {
1879
1881
  const k = typeof n == "function" ? n() : null;
1880
1882
  typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(P), !0));
@@ -1887,15 +1889,15 @@ const Le = () => {
1887
1889
  typeof P.result == "string" && z({ imageSrc: P.result });
1888
1890
  }, P.readAsDataURL(k);
1889
1891
  };
1890
- u.addEventListener("change", () => Q(u.files)), o.addEventListener("click", () => u.click()), m.addEventListener("click", (E) => {
1892
+ u.addEventListener("change", () => Q(u.files)), c.addEventListener("click", () => u.click()), m.addEventListener("click", (E) => {
1891
1893
  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) => {
1894
+ }), o.addEventListener("dragover", (E) => {
1895
+ r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), c.classList.add("figure-upload-area--dragover"));
1896
+ }), o.addEventListener("dragleave", () => {
1897
+ c.classList.remove("figure-upload-area--dragover");
1898
+ }), o.addEventListener("drop", (E) => {
1897
1899
  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));
1900
+ c.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), Q(((k = E.dataTransfer) == null ? void 0 : k.files) ?? null));
1899
1901
  });
1900
1902
  const gn = () => {
1901
1903
  a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
@@ -1910,7 +1912,7 @@ const Le = () => {
1910
1912
  const P = await import("mermaid");
1911
1913
  P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
1912
1914
  const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
1913
- p.innerHTML = R, Le();
1915
+ h.innerHTML = R, Le();
1914
1916
  } catch {
1915
1917
  Le();
1916
1918
  const P = I.getState().editorLanguage;
@@ -1919,7 +1921,7 @@ const Le = () => {
1919
1921
  }
1920
1922
  z({ mermaidCode: E }), a = !1, J();
1921
1923
  };
1922
- f.addEventListener("dblclick", (E) => {
1924
+ p.addEventListener("dblclick", (E) => {
1923
1925
  E.preventDefault(), E.stopPropagation(), gn();
1924
1926
  }), v.addEventListener("click", (E) => {
1925
1927
  E.stopPropagation(), pn();
@@ -1974,7 +1976,7 @@ const Le = () => {
1974
1976
  E.preventDefault(), E.stopPropagation(), hn();
1975
1977
  }), s.addEventListener("mousedown", (E) => {
1976
1978
  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;
1979
+ if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === c || c.contains(k) || k === m || k === u || p.contains(k) || N.contains(k)) return;
1978
1980
  const P = typeof n == "function" ? n() : null;
1979
1981
  if (typeof P != "number") return;
1980
1982
  const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
@@ -1987,16 +1989,16 @@ const Le = () => {
1987
1989
  const k = E.trim();
1988
1990
  if (k !== ge) {
1989
1991
  if (!k) {
1990
- p.innerHTML = "", ge = "";
1992
+ h.innerHTML = "", ge = "";
1991
1993
  return;
1992
1994
  }
1993
1995
  try {
1994
1996
  const P = await import("mermaid");
1995
1997
  P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
1996
1998
  const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
1997
- p.innerHTML = R, ge = k;
1999
+ h.innerHTML = R, ge = k;
1998
2000
  } catch {
1999
- p.innerHTML = "", ge = "";
2001
+ h.innerHTML = "", ge = "";
2000
2002
  } finally {
2001
2003
  Le();
2002
2004
  }
@@ -2005,16 +2007,16 @@ const Le = () => {
2005
2007
  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
2008
  O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
2007
2009
  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);
2010
+ l.style.display = K && R ? "block" : "none", c.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", p.style.display = X && !a ? "block" : "none", y.style.display = X && a ? "block" : "none", N.style.display = q ? "flex" : "none", K && R && (l.src = R);
2009
2011
  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
+ q && (oe ? (f.src = oe, f.style.display = "block") : (f.src = "", f.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", v.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
2013
+ const Te = fe.trim().length > 0, ce = h.querySelector("svg") !== null;
2012
2014
  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);
2013
2015
  const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
2014
2016
  q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2015
2017
  se = null;
2016
2018
  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) => {
2019
+ !dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
2018
2020
  xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, me = setTimeout(() => {
2019
2021
  me = null, J();
2020
2022
  }, vn * Ce));
@@ -2034,7 +2036,7 @@ const Le = () => {
2034
2036
  },
2035
2037
  ignoreMutation: (E) => {
2036
2038
  const k = E.target;
2037
- return !!(c.contains(k) || A.contains(k));
2039
+ return !!(o.contains(k) || A.contains(k));
2038
2040
  },
2039
2041
  update: (E) => E.type.name !== "figure" ? !1 : (r = E, J(), !0),
2040
2042
  destroy: () => {
@@ -2043,7 +2045,7 @@ const Le = () => {
2043
2045
  };
2044
2046
  };
2045
2047
  }
2046
- }), Ra = Z.create({
2048
+ }), Ma = Z.create({
2047
2049
  name: "reference",
2048
2050
  group: "inline",
2049
2051
  inline: !0,
@@ -2104,22 +2106,22 @@ const Le = () => {
2104
2106
  return ({ node: e, editor: t }) => {
2105
2107
  let n = e;
2106
2108
  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;
2109
+ 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 ?" : "权利要求?", u = n.attrs.displayText || d;
2110
+ r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? s.referenceNavigateDisabledTitle : o === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2109
2111
  };
2110
2112
  return a(), r.addEventListener("click", () => {
2111
2113
  const i = n.attrs.targetType === "figure" ? "figure" : "claim";
2112
2114
  n.attrs.invalid || setTimeout(() => {
2113
2115
  let s = null;
2114
2116
  if (i === "figure") {
2115
- const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
- if (!c)
2117
+ const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2118
+ if (!o)
2117
2119
  return;
2118
- t.state.doc.descendants((l, o) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === c ? (s = o, !1) : !0);
2120
+ t.state.doc.descendants((l, c) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === o ? (s = c, !1) : !0);
2119
2121
  } else {
2120
2122
  if (!n.attrs.targetClaimId)
2121
2123
  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);
2124
+ t.state.doc.descendants((o, l) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = l, !1) : !0);
2123
2125
  }
2124
2126
  typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
2125
2127
  }, 0);
@@ -2144,7 +2146,7 @@ const Le = () => {
2144
2146
  design_description: "sectionTitle_design_description",
2145
2147
  design_views: "sectionTitle_design_views",
2146
2148
  design_brief: "sectionTitle_design_brief"
2147
- }, Ma = /* @__PURE__ */ new Set([
2149
+ }, Fa = /* @__PURE__ */ new Set([
2148
2150
  "abstract",
2149
2151
  "abstract_drawing",
2150
2152
  "claims",
@@ -2155,7 +2157,7 @@ const Le = () => {
2155
2157
  "design_description",
2156
2158
  "design_views",
2157
2159
  "design_brief"
2158
- ]), Fa = /* @__PURE__ */ new Set([
2160
+ ]), $a = /* @__PURE__ */ new Set([
2159
2161
  "technical_field",
2160
2162
  "background_art",
2161
2163
  "summary",
@@ -2170,7 +2172,7 @@ const Le = () => {
2170
2172
  return e.forEach((n) => {
2171
2173
  !t && ot(n) && (t = !0);
2172
2174
  }), t;
2173
- }, $a = Z.create({
2175
+ }, za = Z.create({
2174
2176
  name: "patent_title",
2175
2177
  group: "block",
2176
2178
  content: "inline*",
@@ -2199,41 +2201,41 @@ const Le = () => {
2199
2201
  i.className = "pb-heading", i.contentEditable = "false";
2200
2202
  const s = document.createElement("div");
2201
2203
  s.className = "ps-placeholder", s.contentEditable = "false";
2202
- const c = document.createElement("h1");
2203
- c.className = "pt-title-content", a.append(i, s, c);
2204
+ const o = document.createElement("h1");
2205
+ o.className = "pt-title-content", a.append(i, s, o);
2204
2206
  const l = () => {
2205
2207
  const b = typeof n == "function" ? n() : null;
2206
2208
  return typeof b == "number" ? b : null;
2207
- }, o = () => {
2209
+ }, c = () => {
2208
2210
  const b = l();
2209
2211
  b !== null && I.getState().setActiveSection("patent_title", b);
2210
2212
  }, d = () => {
2211
2213
  const b = l();
2212
2214
  b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
2213
2215
  };
2214
- s.addEventListener("click", d), c.addEventListener("focusin", o), c.addEventListener("click", o);
2216
+ s.addEventListener("click", d), o.addEventListener("focusin", c), o.addEventListener("click", c);
2215
2217
  const u = () => {
2216
2218
  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
2219
  i.textContent = w;
2218
2220
  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);
2221
+ s.textContent = `[${T}]`, s.style.display = v ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !v), o.classList.toggle("pt-title-content--has-content", v);
2220
2222
  };
2221
- let m = I.getState().editorLanguage, f = I.getState().rightPanel.activeSectionPos;
2222
- 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();
2223
+ let m = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2224
+ const h = I.subscribe((b) => {
2225
+ const y = b.editorLanguage !== m, w = b.rightPanel.activeSectionPos !== p;
2226
+ m = b.editorLanguage, p = b.rightPanel.activeSectionPos, (y || w) && u();
2225
2227
  });
2226
2228
  return u(), {
2227
2229
  dom: a,
2228
- contentDOM: c,
2230
+ contentDOM: o,
2229
2231
  update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, u(), !0),
2230
2232
  destroy: () => {
2231
- p(), s.removeEventListener("click", d), c.removeEventListener("focusin", o), c.removeEventListener("click", o);
2233
+ h(), s.removeEventListener("click", d), o.removeEventListener("focusin", c), o.removeEventListener("click", c);
2232
2234
  }
2233
2235
  };
2234
2236
  };
2235
2237
  }
2236
- }), za = Z.create({
2238
+ }), Oa = Z.create({
2237
2239
  name: "patent_section",
2238
2240
  group: "block",
2239
2241
  content: "block+",
@@ -2300,57 +2302,57 @@ const Le = () => {
2300
2302
  i.contentEditable = "false";
2301
2303
  const s = document.createElement("div");
2302
2304
  s.className = "ps-body";
2303
- const c = document.createElement("div");
2304
- c.className = "ps-placeholder", c.contentEditable = "false";
2305
+ const o = document.createElement("div");
2306
+ o.className = "ps-placeholder", o.contentEditable = "false";
2305
2307
  const l = document.createElement("div");
2306
- l.className = "ps-content", s.append(c, l), a.append(i, s);
2307
- const o = () => {
2308
+ l.className = "ps-content", s.append(o, l), a.append(i, s);
2309
+ const c = () => {
2308
2310
  const y = typeof n == "function" ? n() : null;
2309
2311
  return typeof y == "number" ? y : null;
2310
2312
  }, d = () => {
2311
- const y = o();
2313
+ const y = c();
2312
2314
  if (y === null) return;
2313
2315
  I.getState().setActiveSection(r.attrs.sectionType, y);
2314
2316
  }, u = () => {
2315
- const y = o();
2317
+ const y = c();
2316
2318
  if (y === null) return;
2317
2319
  I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2318
2320
  };
2319
- c.addEventListener("click", u), l.addEventListener("focusin", d), l.addEventListener("click", d);
2321
+ o.addEventListener("click", u), l.addEventListener("focusin", d), l.addEventListener("click", d);
2320
2322
  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);
2323
+ const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v = Fa.has(T), x = $a.has(T), S = wt[T], N = typeof w[S] == "string" ? w[S] : T, f = ot(r), C = y.rightPanel.activeSectionPos === c();
2324
+ a.className = `ps${f ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = v ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = N, o.textContent = `[${N}]`, o.style.display = f ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !f), l.classList.toggle("ps-content--has-content", f);
2323
2325
  };
2324
- let f = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2326
+ let p = I.getState().editorLanguage, h = I.getState().rightPanel.activeSectionPos;
2325
2327
  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();
2328
+ const w = y.editorLanguage !== p, T = y.rightPanel.activeSectionPos !== h;
2329
+ p = y.editorLanguage, h = y.rightPanel.activeSectionPos, (w || T) && m();
2328
2330
  });
2329
2331
  return m(), {
2330
2332
  dom: a,
2331
2333
  contentDOM: l,
2332
2334
  update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
2333
2335
  destroy: () => {
2334
- b(), c.removeEventListener("click", u), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2336
+ b(), o.removeEventListener("click", u), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2335
2337
  }
2336
2338
  };
2337
2339
  };
2338
2340
  }
2339
- }), Oa = [
2341
+ }), Ba = [
2340
2342
  "abstract",
2341
2343
  // 说明书摘要
2342
2344
  "abstract_drawing"
2343
2345
  // 摘要附图
2344
- ], Ba = [
2346
+ ], Ha = [
2345
2347
  "technical_field",
2346
2348
  "background_art",
2347
2349
  "summary",
2348
2350
  "drawing_description",
2349
2351
  "detailed_description"
2350
- ], Ha = [
2352
+ ], Ua = [
2351
2353
  "drawing_figures"
2352
2354
  // 说明书附图
2353
- ], Ua = [
2355
+ ], qa = [
2354
2356
  "design_product_name",
2355
2357
  "design_usage",
2356
2358
  "design_description",
@@ -2370,15 +2372,15 @@ const Le = () => {
2370
2372
  }), en = () => ({
2371
2373
  type: "patent_title",
2372
2374
  content: []
2373
- }), qa = () => [
2374
- ...Oa.map(Fe),
2375
- en(),
2375
+ }), Wa = () => [
2376
2376
  ...Ba.map(Fe),
2377
- ...Ha.map(Fe)
2378
- ], Wa = () => [
2379
2377
  en(),
2378
+ ...Ha.map(Fe),
2380
2379
  ...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) => {
2380
+ ], ja = () => [
2381
+ en(),
2382
+ ...qa.map(Fe)
2383
+ ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2382
2384
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2383
2385
  ve(e).forEach((i) => {
2384
2386
  const s = V(i.node.attrs.id);
@@ -2388,22 +2390,22 @@ const Le = () => {
2388
2390
  for (; r.has(`${n}${a}`); )
2389
2391
  a += 1;
2390
2392
  return `${n}${a}`;
2391
- }, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
2393
+ }, Ga = /^(Fig\.|图)(\d+)$/, Va = (e) => {
2392
2394
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2393
2395
  if (r.length === 0) return;
2394
2396
  const a = [];
2395
2397
  let i = 1;
2396
- for (const c of r) {
2397
- const l = V(c.node.attrs.id);
2398
- if (!ja.exec(l)) continue;
2398
+ for (const o of r) {
2399
+ const l = V(o.node.attrs.id);
2400
+ if (!Ga.exec(l)) continue;
2399
2401
  const d = `${n}${i}`;
2400
- l !== d && a.push({ pos: c.pos, expectedId: d, currentId: l }), i++;
2402
+ l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
2401
2403
  }
2402
2404
  if (a.length === 0) return;
2403
2405
  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 });
2406
+ for (const o of a) {
2407
+ const l = s.doc.nodeAt(o.pos);
2408
+ !l || l.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...l.attrs, id: o.expectedId });
2407
2409
  }
2408
2410
  s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
2409
2411
  }, nn = (e) => {
@@ -2422,28 +2424,28 @@ const Le = () => {
2422
2424
  const t = nn(e), n = rn();
2423
2425
  e.commands.command(({ tr: r, state: a, dispatch: i }) => {
2424
2426
  let s = !1;
2425
- return a.doc.descendants((c, l) => {
2426
- if (c.type.name !== "reference" || c.attrs.targetType !== "figure")
2427
+ return a.doc.descendants((o, l) => {
2428
+ if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
2427
2429
  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,
2430
+ const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? V(o.attrs.targetFigureId) : null, d = c ? t.get(c) : void 0, u = d ? d.id : null, m = !d, p = an(n, u, m), h = {
2431
+ ...o.attrs,
2430
2432
  targetType: "figure",
2431
- targetFigureId: o,
2433
+ targetFigureId: c,
2432
2434
  resolvedFigureId: u,
2433
2435
  invalid: m,
2434
2436
  lang: n,
2435
- displayText: f,
2436
- target: u || c.attrs.target || o || null
2437
+ displayText: p,
2438
+ target: u || o.attrs.target || c || null
2437
2439
  };
2438
- return Object.keys(p).some(
2439
- (y) => p[y] !== c.attrs[y]
2440
- ) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
2440
+ return Object.keys(h).some(
2441
+ (y) => h[y] !== o.attrs[y]
2442
+ ) && (r.setNodeMarkup(l, void 0, h), s = !0), !0;
2441
2443
  }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2442
2444
  });
2443
- }, Va = {
2445
+ }, Ja = {
2444
2446
  name: "patent",
2445
2447
  version: "1.0.0",
2446
- extensions: [Da, Ra, $a, za],
2448
+ extensions: [Ra, Ma, za, Oa],
2447
2449
  toolbarItems: [
2448
2450
  {
2449
2451
  id: "patent-figure-insert",
@@ -2467,12 +2469,12 @@ const Le = () => {
2467
2469
  const r = n.lang === "en" ? "en" : "zh";
2468
2470
  I.getState().setEditorLanguage(r);
2469
2471
  const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
2470
- return e.commands.command(({ tr: c, state: l, dispatch: o }) => {
2472
+ return e.commands.command(({ tr: o, state: l, dispatch: c }) => {
2471
2473
  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, {
2474
+ return l.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (o.setNodeMarkup(m, void 0, {
2473
2475
  ...u.attrs,
2474
2476
  lang: r
2475
- }), d = !0), !0)), d && o && (c.setMeta("addToHistory", !1), o(c)), !0;
2477
+ }), d = !0), !0)), d && c && (o.setMeta("addToHistory", !1), c(o)), !0;
2476
2478
  }) ? (Je(e), !0) : !1;
2477
2479
  }
2478
2480
  },
@@ -2500,14 +2502,14 @@ const Le = () => {
2500
2502
  const i = e.state.doc.nodeAt(a);
2501
2503
  if (!i || i.type.name !== "figure")
2502
2504
  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))
2505
+ const o = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
2506
+ if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === o))
2505
2507
  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, {
2508
+ const c = { id: o };
2509
+ 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
2510
  type: "figure",
2509
2511
  position: a,
2510
- attrs: o
2512
+ attrs: c
2511
2513
  });
2512
2514
  }
2513
2515
  },
@@ -2547,7 +2549,7 @@ const Le = () => {
2547
2549
  const i = r.get(a);
2548
2550
  if (!i)
2549
2551
  return !1;
2550
- const s = n.lang || rn(), c = n.displayText || an(s, i.id, !1);
2552
+ const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
2551
2553
  return e.chain().focus().insertContent({
2552
2554
  type: "reference",
2553
2555
  attrs: {
@@ -2558,7 +2560,7 @@ const Le = () => {
2558
2560
  resolvedFigureId: i.id,
2559
2561
  lang: s,
2560
2562
  invalid: !1,
2561
- displayText: c,
2563
+ displayText: o,
2562
2564
  target: n.target || i.id,
2563
2565
  highlight: !1
2564
2566
  }
@@ -2589,13 +2591,13 @@ const Le = () => {
2589
2591
  }
2590
2592
  },
2591
2593
  onStateChange: (e) => {
2592
- e.isDestroyed || (Ga(e), Je(e));
2594
+ e.isDestroyed || (Va(e), Je(e));
2593
2595
  }
2594
- }, Ja = [xa, Ta, ka, Va];
2595
- Ja.forEach((e) => B.register(e));
2596
- const Ka = (e = {}) => {
2596
+ }, Ka = [Ca, Sa, _a, Ja];
2597
+ Ka.forEach((e) => B.register(e));
2598
+ const Xa = (e = {}) => {
2597
2599
  const t = [
2598
- ...ya,
2600
+ ...ba,
2599
2601
  ...B.getExtensions(),
2600
2602
  ...e.extensions || []
2601
2603
  ];
@@ -2619,12 +2621,12 @@ const Ka = (e = {}) => {
2619
2621
  updateNodeAttrs: (t) => ze(e, t),
2620
2622
  removeNode: (t) => Zt(e, t),
2621
2623
  wrapSelection: (t) => Qt(e, t),
2622
- applyTransactionBatch: (t) => Aa(e, t),
2624
+ applyTransactionBatch: (t) => La(e, t),
2623
2625
  findNodeByType: (t, n) => st(e, t, n),
2624
2626
  findAncestorNode: (t) => Re(e, t),
2625
- findCurrentBlock: () => _a(e),
2627
+ findCurrentBlock: () => Ia(e),
2626
2628
  findNodesByPredicate: (t, n) => Xt(e, t, n)
2627
- }), Xa = ["history", "text", "structure", "format", "technical", "patent"], Ya = {
2629
+ }), Ya = ["history", "text", "structure", "format", "technical", "patent"], Za = {
2628
2630
  history: "groupHistory",
2629
2631
  text: "groupText",
2630
2632
  structure: "groupStructure",
@@ -2633,26 +2635,26 @@ const Ka = (e = {}) => {
2633
2635
  patent: "groupPatent"
2634
2636
  }, Xe = (e, t) => {
2635
2637
  if (t) {
2636
- const n = Ya[e];
2638
+ const n = Za[e];
2637
2639
  if (n && typeof t[n] == "string") return t[n];
2638
2640
  }
2639
2641
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
2640
2642
  }, 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(() => {
2643
+ const [n, r] = F(!1), a = W(null), i = W(null), [s, o] = F({ top: 0, left: 0 }), l = ae(() => {
2642
2644
  if (!a.current) return;
2643
- const o = a.current.getBoundingClientRect();
2644
- c({ top: o.bottom + 4, left: o.left });
2645
+ const c = a.current.getBoundingClientRect();
2646
+ o({ top: c.bottom + 4, left: c.left });
2645
2647
  }, []);
2646
2648
  return M(() => {
2647
2649
  if (!n) return;
2648
2650
  l();
2649
- const o = (u) => {
2650
- var f, p;
2651
+ const c = (u) => {
2652
+ var p, h;
2651
2653
  const m = u.target;
2652
- (f = a.current) != null && f.contains(m) || (p = i.current) != null && p.contains(m) || r(!1);
2654
+ (p = a.current) != null && p.contains(m) || (h = i.current) != null && h.contains(m) || r(!1);
2653
2655
  }, d = () => l();
2654
- return document.addEventListener("mousedown", o), window.addEventListener("scroll", d, !0), () => {
2655
- document.removeEventListener("mousedown", o), window.removeEventListener("scroll", d, !0);
2656
+ return document.addEventListener("mousedown", c), window.addEventListener("scroll", d, !0), () => {
2657
+ document.removeEventListener("mousedown", c), window.removeEventListener("scroll", d, !0);
2656
2658
  };
2657
2659
  }, [n, l]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2658
2660
  /* @__PURE__ */ g(
@@ -2673,7 +2675,7 @@ const Ka = (e = {}) => {
2673
2675
  "button",
2674
2676
  {
2675
2677
  ref: a,
2676
- onClick: () => r((o) => !o),
2678
+ onClick: () => r((c) => !c),
2677
2679
  className: Y(
2678
2680
  "px-1 py-2 rounded-r transition-colors border-l border-gray-200",
2679
2681
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
@@ -2689,14 +2691,14 @@ const Ka = (e = {}) => {
2689
2691
  ref: i,
2690
2692
  className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
2691
2693
  style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
2692
- children: t.map((o, d) => /* @__PURE__ */ g(
2694
+ children: t.map((c, d) => /* @__PURE__ */ g(
2693
2695
  "button",
2694
2696
  {
2695
2697
  onClick: () => {
2696
- o.onClick(), r(!1);
2698
+ c.onClick(), r(!1);
2697
2699
  },
2698
2700
  className: "block w-full text-left px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100",
2699
- children: o.label
2701
+ children: c.label
2700
2702
  },
2701
2703
  d
2702
2704
  ))
@@ -2705,28 +2707,28 @@ const Ka = (e = {}) => {
2705
2707
  document.body
2706
2708
  )
2707
2709
  ] });
2708
- }, Za = ({
2710
+ }, Qa = ({
2709
2711
  editor: e,
2710
- groupOrder: t = Xa,
2712
+ groupOrder: t = Ya,
2711
2713
  collapsibleGroups: n = !0,
2712
2714
  defaultCollapsedGroups: r = []
2713
2715
  }) => {
2714
- const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: c, setEditorLanguage: l } = I(), o = H(c);
2716
+ const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: o, setEditorLanguage: l } = I(), c = H(o);
2715
2717
  if (M(() => {
2716
2718
  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);
2719
+ const f = () => s((C) => C + 1);
2720
+ return e.on("selectionUpdate", f), e.on("update", f), () => {
2721
+ e.off("selectionUpdate", f), e.off("update", f);
2720
2722
  };
2721
2723
  }, [e]), !e)
2722
2724
  return null;
2723
- const d = ct(e), u = c === "zh", m = [
2725
+ const d = ct(e), u = o === "zh", m = [
2724
2726
  {
2725
2727
  id: "core-undo",
2726
- label: o.undo,
2728
+ label: c.undo,
2727
2729
  group: "history",
2728
2730
  icon: br,
2729
- tooltip: `${o.undo} (Ctrl+Z)`,
2731
+ tooltip: `${c.undo} (Ctrl+Z)`,
2730
2732
  isActive: !1,
2731
2733
  disabled: !e.can().chain().focus().undo().run(),
2732
2734
  run: () => {
@@ -2735,10 +2737,10 @@ const Ka = (e = {}) => {
2735
2737
  },
2736
2738
  {
2737
2739
  id: "core-redo",
2738
- label: o.redo,
2740
+ label: c.redo,
2739
2741
  group: "history",
2740
2742
  icon: vr,
2741
- tooltip: `${o.redo} (Ctrl+Y)`,
2743
+ tooltip: `${c.redo} (Ctrl+Y)`,
2742
2744
  isActive: !1,
2743
2745
  disabled: !e.can().chain().focus().redo().run(),
2744
2746
  run: () => {
@@ -2747,10 +2749,10 @@ const Ka = (e = {}) => {
2747
2749
  },
2748
2750
  {
2749
2751
  id: "core-bold",
2750
- label: o.bold,
2752
+ label: c.bold,
2751
2753
  group: "text",
2752
2754
  icon: Dt,
2753
- tooltip: o.bold,
2755
+ tooltip: c.bold,
2754
2756
  isActive: e.isActive("bold"),
2755
2757
  disabled: !1,
2756
2758
  run: () => {
@@ -2759,10 +2761,10 @@ const Ka = (e = {}) => {
2759
2761
  },
2760
2762
  {
2761
2763
  id: "core-italic",
2762
- label: o.italic,
2764
+ label: c.italic,
2763
2765
  group: "text",
2764
2766
  icon: Rt,
2765
- tooltip: o.italic,
2767
+ tooltip: c.italic,
2766
2768
  isActive: e.isActive("italic"),
2767
2769
  disabled: !1,
2768
2770
  run: () => {
@@ -2771,10 +2773,10 @@ const Ka = (e = {}) => {
2771
2773
  },
2772
2774
  {
2773
2775
  id: "core-underline",
2774
- label: o.underline,
2776
+ label: c.underline,
2775
2777
  group: "text",
2776
2778
  icon: Mt,
2777
- tooltip: o.underline,
2779
+ tooltip: c.underline,
2778
2780
  isActive: e.isActive("underline"),
2779
2781
  disabled: !1,
2780
2782
  run: () => {
@@ -2783,10 +2785,10 @@ const Ka = (e = {}) => {
2783
2785
  },
2784
2786
  {
2785
2787
  id: "core-strike",
2786
- label: o.strike,
2788
+ label: c.strike,
2787
2789
  group: "text",
2788
2790
  icon: Ft,
2789
- tooltip: o.strike,
2791
+ tooltip: c.strike,
2790
2792
  isActive: e.isActive("strike"),
2791
2793
  disabled: !1,
2792
2794
  run: () => {
@@ -2795,10 +2797,10 @@ const Ka = (e = {}) => {
2795
2797
  },
2796
2798
  {
2797
2799
  id: "core-code",
2798
- label: o.code,
2800
+ label: c.code,
2799
2801
  group: "text",
2800
2802
  icon: $t,
2801
- tooltip: o.code,
2803
+ tooltip: c.code,
2802
2804
  isActive: e.isActive("code"),
2803
2805
  disabled: !1,
2804
2806
  run: () => {
@@ -2807,10 +2809,10 @@ const Ka = (e = {}) => {
2807
2809
  },
2808
2810
  {
2809
2811
  id: "core-superscript",
2810
- label: o.superscript,
2812
+ label: c.superscript,
2811
2813
  group: "text",
2812
2814
  icon: zt,
2813
- tooltip: `${o.superscript} (Ctrl+.)`,
2815
+ tooltip: `${c.superscript} (Ctrl+.)`,
2814
2816
  isActive: e.isActive("superscript"),
2815
2817
  disabled: !1,
2816
2818
  run: () => {
@@ -2819,10 +2821,10 @@ const Ka = (e = {}) => {
2819
2821
  },
2820
2822
  {
2821
2823
  id: "core-subscript",
2822
- label: o.subscript,
2824
+ label: c.subscript,
2823
2825
  group: "text",
2824
2826
  icon: Ot,
2825
- tooltip: `${o.subscript} (Ctrl+,)`,
2827
+ tooltip: `${c.subscript} (Ctrl+,)`,
2826
2828
  isActive: e.isActive("subscript"),
2827
2829
  disabled: !1,
2828
2830
  run: () => {
@@ -2831,10 +2833,10 @@ const Ka = (e = {}) => {
2831
2833
  },
2832
2834
  {
2833
2835
  id: "core-paragraph",
2834
- label: o.paragraph,
2836
+ label: c.paragraph,
2835
2837
  group: "structure",
2836
2838
  icon: wr,
2837
- tooltip: o.paragraph,
2839
+ tooltip: c.paragraph,
2838
2840
  isActive: e.isActive("paragraph"),
2839
2841
  disabled: !1,
2840
2842
  run: () => {
@@ -2846,7 +2848,7 @@ const Ka = (e = {}) => {
2846
2848
  label: "H1",
2847
2849
  group: "structure",
2848
2850
  icon: xr,
2849
- tooltip: o.heading1,
2851
+ tooltip: c.heading1,
2850
2852
  isActive: e.isActive("heading", { level: 1 }),
2851
2853
  disabled: !1,
2852
2854
  run: () => {
@@ -2858,7 +2860,7 @@ const Ka = (e = {}) => {
2858
2860
  label: "H2",
2859
2861
  group: "structure",
2860
2862
  icon: Cr,
2861
- tooltip: o.heading2,
2863
+ tooltip: c.heading2,
2862
2864
  isActive: e.isActive("heading", { level: 2 }),
2863
2865
  disabled: !1,
2864
2866
  run: () => {
@@ -2870,7 +2872,7 @@ const Ka = (e = {}) => {
2870
2872
  label: "H3",
2871
2873
  group: "structure",
2872
2874
  icon: Tr,
2873
- tooltip: o.heading3,
2875
+ tooltip: c.heading3,
2874
2876
  isActive: e.isActive("heading", { level: 3 }),
2875
2877
  disabled: !1,
2876
2878
  run: () => {
@@ -2879,10 +2881,10 @@ const Ka = (e = {}) => {
2879
2881
  },
2880
2882
  {
2881
2883
  id: "core-align-left",
2882
- label: o.alignLeft,
2884
+ label: c.alignLeft,
2883
2885
  group: "format",
2884
2886
  icon: Sr,
2885
- tooltip: o.alignLeft,
2887
+ tooltip: c.alignLeft,
2886
2888
  isActive: e.isActive({ textAlign: "left" }),
2887
2889
  disabled: !1,
2888
2890
  run: () => {
@@ -2891,10 +2893,10 @@ const Ka = (e = {}) => {
2891
2893
  },
2892
2894
  {
2893
2895
  id: "core-align-center",
2894
- label: o.alignCenter,
2896
+ label: c.alignCenter,
2895
2897
  group: "format",
2896
2898
  icon: Er,
2897
- tooltip: o.alignCenter,
2899
+ tooltip: c.alignCenter,
2898
2900
  isActive: e.isActive({ textAlign: "center" }),
2899
2901
  disabled: !1,
2900
2902
  run: () => {
@@ -2903,10 +2905,10 @@ const Ka = (e = {}) => {
2903
2905
  },
2904
2906
  {
2905
2907
  id: "core-align-right",
2906
- label: o.alignRight,
2908
+ label: c.alignRight,
2907
2909
  group: "format",
2908
2910
  icon: kr,
2909
- tooltip: o.alignRight,
2911
+ tooltip: c.alignRight,
2910
2912
  isActive: e.isActive({ textAlign: "right" }),
2911
2913
  disabled: !1,
2912
2914
  run: () => {
@@ -2915,10 +2917,10 @@ const Ka = (e = {}) => {
2915
2917
  },
2916
2918
  {
2917
2919
  id: "core-align-justify",
2918
- label: o.alignJustify,
2920
+ label: c.alignJustify,
2919
2921
  group: "format",
2920
2922
  icon: _r,
2921
- tooltip: o.alignJustify,
2923
+ tooltip: c.alignJustify,
2922
2924
  isActive: e.isActive({ textAlign: "justify" }),
2923
2925
  disabled: !1,
2924
2926
  run: () => {
@@ -2927,10 +2929,10 @@ const Ka = (e = {}) => {
2927
2929
  },
2928
2930
  {
2929
2931
  id: "core-bullet-list",
2930
- label: o.bulletList,
2932
+ label: c.bulletList,
2931
2933
  group: "structure",
2932
2934
  icon: Ir,
2933
- tooltip: o.bulletList,
2935
+ tooltip: c.bulletList,
2934
2936
  isActive: e.isActive("bulletList"),
2935
2937
  disabled: !1,
2936
2938
  run: () => {
@@ -2939,10 +2941,10 @@ const Ka = (e = {}) => {
2939
2941
  },
2940
2942
  {
2941
2943
  id: "core-ordered-list",
2942
- label: o.orderedList,
2944
+ label: c.orderedList,
2943
2945
  group: "structure",
2944
2946
  icon: Nr,
2945
- tooltip: o.orderedList,
2947
+ tooltip: c.orderedList,
2946
2948
  isActive: e.isActive("orderedList"),
2947
2949
  disabled: !1,
2948
2950
  run: () => {
@@ -2951,10 +2953,10 @@ const Ka = (e = {}) => {
2951
2953
  },
2952
2954
  {
2953
2955
  id: "core-blockquote",
2954
- label: o.blockquote,
2956
+ label: c.blockquote,
2955
2957
  group: "structure",
2956
2958
  icon: Ar,
2957
- tooltip: o.blockquote,
2959
+ tooltip: c.blockquote,
2958
2960
  isActive: e.isActive("blockquote"),
2959
2961
  disabled: !1,
2960
2962
  run: () => {
@@ -2963,10 +2965,10 @@ const Ka = (e = {}) => {
2963
2965
  },
2964
2966
  {
2965
2967
  id: "core-code-block",
2966
- label: o.codeBlock,
2968
+ label: c.codeBlock,
2967
2969
  group: "structure",
2968
2970
  icon: Lr,
2969
- tooltip: o.codeBlock,
2971
+ tooltip: c.codeBlock,
2970
2972
  isActive: e.isActive("codeBlock"),
2971
2973
  disabled: !1,
2972
2974
  run: () => {
@@ -2975,10 +2977,10 @@ const Ka = (e = {}) => {
2975
2977
  },
2976
2978
  {
2977
2979
  id: "core-table",
2978
- label: o.insertTable,
2980
+ label: c.insertTable,
2979
2981
  group: "structure",
2980
2982
  icon: Pr,
2981
- tooltip: o.insertTable,
2983
+ tooltip: c.insertTable,
2982
2984
  isActive: !1,
2983
2985
  disabled: !1,
2984
2986
  run: () => {
@@ -2987,10 +2989,10 @@ const Ka = (e = {}) => {
2987
2989
  },
2988
2990
  {
2989
2991
  id: "core-horizontal-rule",
2990
- label: o.horizontalRule,
2992
+ label: c.horizontalRule,
2991
2993
  group: "structure",
2992
2994
  icon: Dr,
2993
- tooltip: o.horizontalRule,
2995
+ tooltip: c.horizontalRule,
2994
2996
  isActive: !1,
2995
2997
  disabled: !1,
2996
2998
  run: () => {
@@ -2999,17 +3001,17 @@ const Ka = (e = {}) => {
2999
3001
  },
3000
3002
  {
3001
3003
  id: "core-task-list",
3002
- label: o.taskList,
3004
+ label: c.taskList,
3003
3005
  group: "structure",
3004
3006
  icon: Rr,
3005
- tooltip: o.taskList,
3007
+ tooltip: c.taskList,
3006
3008
  isActive: e.isActive("taskList"),
3007
3009
  disabled: !1,
3008
3010
  run: () => {
3009
3011
  e.chain().focus().toggleTaskList().run();
3010
3012
  }
3011
3013
  }
3012
- ], f = {
3014
+ ], p = {
3013
3015
  GitGraph: Or,
3014
3016
  Sigma: zr,
3015
3017
  FunctionSquare: $r,
@@ -3018,27 +3020,27 @@ const Ka = (e = {}) => {
3018
3020
  FileText: Ut,
3019
3021
  Link2: Ht,
3020
3022
  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})` : _;
3023
+ }, h = B.getToolbarItems().map((f) => {
3024
+ const C = B.getCommandMeta(f.command), _ = u && f.tooltipZh ? f.tooltipZh : f.tooltip || (C == null ? void 0 : C.description) || f.label, A = f.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${_} (${A})` : _;
3023
3025
  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),
3026
+ id: f.id,
3027
+ label: f.label,
3028
+ group: f.group || "technical",
3029
+ icon: f.icon ? p[f.icon] || mt : mt,
3030
+ isActive: d.isCommandActive(f.command),
3031
+ disabled: !d.canExecCommand(f.command),
3030
3032
  tooltip: D,
3031
3033
  run: () => {
3032
- d.execCommand(h.command);
3034
+ d.execCommand(f.command);
3033
3035
  }
3034
3036
  };
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) => {
3037
+ }), b = [...m, ...h], y = b.map((f) => f.group).filter((f, C, _) => _.indexOf(f) === C && !t.includes(f)), T = [...t, ...y].map((f) => ({
3038
+ group: f,
3039
+ items: b.filter((C) => C.group === f)
3040
+ })).filter((f) => f.items.length > 0), v = (f) => {
3039
3041
  i((C) => {
3040
3042
  const _ = new Set(C);
3041
- return _.has(h) ? _.delete(h) : _.add(h), _;
3043
+ return _.has(f) ? _.delete(f) : _.add(f), _;
3042
3044
  });
3043
3045
  }, x = [
3044
3046
  { label: u ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
@@ -3053,33 +3055,33 @@ const Ka = (e = {}) => {
3053
3055
  { label: u ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3054
3056
  { label: u ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3055
3057
  ], 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(
3058
+ { label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3059
+ { label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3060
+ { label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3061
+ ], N = (f) => f.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: f, items: x }, f.id) : f.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: f, items: S }, f.id) : /* @__PURE__ */ g(
3060
3062
  "button",
3061
3063
  {
3062
- onClick: h.run,
3063
- disabled: h.disabled,
3064
+ onClick: f.run,
3065
+ disabled: f.disabled,
3064
3066
  className: Y(
3065
3067
  "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"
3068
+ f.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3069
+ f.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3068
3070
  ),
3069
- title: h.tooltip,
3070
- children: /* @__PURE__ */ g(h.icon, { size: 18 })
3071
+ title: f.tooltip,
3072
+ children: /* @__PURE__ */ g(f.icon, { size: 18 })
3071
3073
  },
3072
- h.id
3074
+ f.id
3073
3075
  );
3074
3076
  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
3077
  /* @__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 }),
3078
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.language }),
3077
3079
  /* @__PURE__ */ L(
3078
3080
  "select",
3079
3081
  {
3080
- value: c,
3081
- onChange: (h) => {
3082
- l(h.target.value === "en" ? "en" : "zh");
3082
+ value: o,
3083
+ onChange: (f) => {
3084
+ l(f.target.value === "en" ? "en" : "zh");
3083
3085
  },
3084
3086
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
3085
3087
  children: [
@@ -3089,25 +3091,25 @@ const Ka = (e = {}) => {
3089
3091
  }
3090
3092
  )
3091
3093
  ] }),
3092
- T.map((h) => {
3093
- const C = a.has(h.group);
3094
+ T.map((f) => {
3095
+ const C = a.has(f.group);
3094
3096
  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
3097
  n && /* @__PURE__ */ g(
3096
3098
  "button",
3097
3099
  {
3098
3100
  onClick: () => {
3099
- v(h.group);
3101
+ v(f.group);
3100
3102
  },
3101
3103
  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)
3104
+ title: C ? `${c.expand} ${Xe(f.group, c)}` : `${c.collapse} ${Xe(f.group, c)}`,
3105
+ children: Xe(f.group, c)
3104
3106
  }
3105
3107
  ),
3106
- (!n || !C) && h.items.map(N)
3107
- ] }, h.group);
3108
+ (!n || !C) && f.items.map(N)
3109
+ ] }, f.group);
3108
3110
  })
3109
3111
  ] }) });
3110
- }, Qa = ({ editor: e }) => {
3112
+ }, ei = ({ editor: e }) => {
3111
3113
  const [t, n] = F(0), [r, a] = F(""), i = I((x) => x.editorLanguage), s = H(i);
3112
3114
  if (M(() => {
3113
3115
  if (!e) return;
@@ -3116,24 +3118,24 @@ const Ka = (e = {}) => {
3116
3118
  e.off("selectionUpdate", x), e.off("update", x);
3117
3119
  };
3118
3120
  }, [e]), !e) return null;
3119
- const c = ct(e), l = [];
3121
+ const o = ct(e), l = [];
3120
3122
  e.state.doc.descendants((x) => {
3121
3123
  if (x.type.name !== "figure") return !0;
3122
3124
  const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
3123
3125
  return S && l.push({ id: S, label: S }), !0;
3124
3126
  });
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));
3127
+ const c = o.findAncestorNode("figure"), d = !!c, u = c && typeof c.node.attrs.id == "string" ? c.node.attrs.id.trim() : "", m = c && typeof c.node.attrs.contentType == "string" ? c.node.attrs.contentType : "image", [p, h] = F(""), b = W(null), y = W(null), w = (c == null ? void 0 : c.pos) ?? null;
3128
+ w !== y.current && (y.current = w, d && u !== p && h(u));
3127
3129
  const T = (x) => {
3128
- o && c.execCommand("patent.updateFigure", {
3129
- position: o.pos,
3130
+ c && o.execCommand("patent.updateFigure", {
3131
+ position: c.pos,
3130
3132
  contentType: x
3131
3133
  });
3132
3134
  }, v = () => {
3133
- if (!o) return;
3134
- const x = f.trim();
3135
- x !== u && c.execCommand("patent.updateFigure", {
3136
- position: o.pos,
3135
+ if (!c) return;
3136
+ const x = p.trim();
3137
+ x !== u && o.execCommand("patent.updateFigure", {
3138
+ position: c.pos,
3137
3139
  id: x
3138
3140
  });
3139
3141
  };
@@ -3156,7 +3158,7 @@ const Ka = (e = {}) => {
3156
3158
  "button",
3157
3159
  {
3158
3160
  onClick: () => {
3159
- r && c.execCommand("patent.insertFigureReference", {
3161
+ r && o.execCommand("patent.insertFigureReference", {
3160
3162
  targetType: "figure",
3161
3163
  targetFigureId: r
3162
3164
  });
@@ -3176,8 +3178,8 @@ const Ka = (e = {}) => {
3176
3178
  {
3177
3179
  ref: b,
3178
3180
  type: "text",
3179
- value: f,
3180
- onChange: (x) => p(x.target.value),
3181
+ value: p,
3182
+ onChange: (x) => h(x.target.value),
3181
3183
  onBlur: v,
3182
3184
  onKeyDown: (x) => {
3183
3185
  x.key === "Enter" && (v(), x.target.blur());
@@ -3206,14 +3208,14 @@ const Ka = (e = {}) => {
3206
3208
  const S = e.getAttributes("image").width || "";
3207
3209
  return /* @__PURE__ */ L(je, { children: [
3208
3210
  /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
3209
- ["25%", "50%", "75%", "100%"].map((h) => /* @__PURE__ */ g(
3211
+ ["25%", "50%", "75%", "100%"].map((f) => /* @__PURE__ */ g(
3210
3212
  "button",
3211
3213
  {
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
3214
+ onClick: () => e.chain().focus().updateAttributes("image", { width: f }).run(),
3215
+ className: `text-xs px-2 py-0.5 rounded border ${S === f ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3216
+ children: f
3215
3217
  },
3216
- h
3218
+ f
3217
3219
  )),
3218
3220
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3219
3221
  ] });
@@ -3237,10 +3239,10 @@ const Ka = (e = {}) => {
3237
3239
  design_views: ["design_description"],
3238
3240
  design_brief: ["design_description", "design_views"]
3239
3241
  };
3240
- function Us(e, t) {
3242
+ function qs(e, t) {
3241
3243
  return (sn[e] || []).filter((r) => !t.has(r));
3242
3244
  }
3243
- function ei(e) {
3245
+ function ti(e) {
3244
3246
  const t = [];
3245
3247
  return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
3246
3248
  sectionType: "patent_title",
@@ -3271,10 +3273,10 @@ function on(e) {
3271
3273
  }
3272
3274
  return null;
3273
3275
  }
3274
- function ti(e, t) {
3276
+ function ni(e, t) {
3275
3277
  const n = sn[t];
3276
3278
  if (!n || n.length === 0) return [];
3277
- const r = ei(e), a = new Map(r.map((i) => [i.sectionType, i]));
3279
+ const r = ti(e), a = new Map(r.map((i) => [i.sectionType, i]));
3278
3280
  return n.map((i) => {
3279
3281
  const s = a.get(i);
3280
3282
  return !s || s.content.trim().length === 0 ? null : {
@@ -3283,54 +3285,54 @@ function ti(e, t) {
3283
3285
  };
3284
3286
  }).filter((i) => i !== null && i.content.length > 0);
3285
3287
  }
3286
- function qs(e, t = {}) {
3288
+ function Ws(e, t = {}) {
3287
3289
  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;
3290
+ let s = t.sectionType, o = t.targetSectionPos;
3289
3291
  if (!s) {
3290
3292
  const u = on(e);
3291
- u && (s = u.sectionType, c = u.pos);
3293
+ u && (s = u.sectionType, o = u.pos);
3292
3294
  }
3293
- const l = t.scope || (s ? "section" : i ? "selection" : "document"), o = s ? ti(e, s) : void 0;
3295
+ const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
3294
3296
  let d;
3295
3297
  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");
3297
- d = `...${p}[SELECTED]${b}...`;
3298
+ const m = Math.max(0, r - 200), p = Math.min(e.state.doc.content.size, a + 200), h = e.state.doc.textBetween(m, r, " ", "\0"), b = e.state.doc.textBetween(a, p, " ", "\0");
3299
+ d = `...${h}[SELECTED]${b}...`;
3298
3300
  }
3299
3301
  return {
3300
3302
  scope: l,
3301
3303
  sectionType: s,
3302
- targetSectionPos: c,
3304
+ targetSectionPos: o,
3303
3305
  userInput: t.userInput,
3304
3306
  selectedText: i,
3305
- dependencyContext: o,
3307
+ dependencyContext: c,
3306
3308
  surroundingText: d,
3307
3309
  language: n
3308
3310
  };
3309
3311
  }
3310
- const ni = ({ editor: e, onSelectionOptimize: t }) => {
3311
- const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (o) => Y(
3312
+ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3313
+ const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Y(
3312
3314
  "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);
3315
+ c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3316
+ ), o = () => {
3317
+ const { from: c, to: d } = e.state.selection;
3318
+ if (c === d) return;
3319
+ const u = e.state.doc.textBetween(c, d, " "), m = on(e);
3318
3320
  if (t) {
3319
- t({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType });
3321
+ t({ text: u, from: c, to: d, sectionType: m == null ? void 0 : m.sectionType });
3320
3322
  return;
3321
3323
  }
3322
- n({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3324
+ n({ text: u, from: c, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3323
3325
  }, l = () => {
3324
- const o = e.getAttributes("link").href, d = window.prompt("URL", o || "https://");
3326
+ const c = e.getAttributes("link").href, d = window.prompt("URL", c || "https://");
3325
3327
  d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
3326
3328
  };
3327
3329
  return /* @__PURE__ */ g(
3328
3330
  Jr,
3329
3331
  {
3330
3332
  editor: e,
3331
- shouldShow: ({ editor: o, state: d }) => {
3333
+ shouldShow: ({ editor: c, state: d }) => {
3332
3334
  const { from: u, to: m } = d.selection;
3333
- return !(u === m || o.isActive("codeBlock"));
3335
+ return !(u === m || c.isActive("codeBlock"));
3334
3336
  },
3335
3337
  children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
3336
3338
  /* @__PURE__ */ g(
@@ -3419,7 +3421,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3419
3421
  /* @__PURE__ */ g(
3420
3422
  "button",
3421
3423
  {
3422
- onClick: c,
3424
+ onClick: o,
3423
3425
  className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
3424
3426
  title: i ? "AI 优化" : "AI Optimize",
3425
3427
  children: /* @__PURE__ */ g(Hr, { size: 15 })
@@ -3428,9 +3430,9 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3428
3430
  ] })
3429
3431
  }
3430
3432
  );
3431
- }, ri = ({ editor: e }) => {
3433
+ }, ai = ({ editor: e }) => {
3432
3434
  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;
3435
+ const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, l] = F(""), [c, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, p = ((T = m == null ? void 0 : m.results) == null ? void 0 : T.length) ?? 0, h = (m == null ? void 0 : m.currentIndex) ?? -1;
3434
3436
  M(() => {
3435
3437
  const v = (x) => {
3436
3438
  n(!0);
@@ -3457,7 +3459,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3457
3459
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
3458
3460
  }, [t, y]);
3459
3461
  const w = () => {
3460
- const v = !o;
3462
+ const v = !c;
3461
3463
  d(v), e.commands.setCaseSensitive(v);
3462
3464
  };
3463
3465
  return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
@@ -3477,13 +3479,13 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3477
3479
  className: "find-replace-input"
3478
3480
  }
3479
3481
  ),
3480
- /* @__PURE__ */ g("span", { className: "find-replace-count", children: f > 0 ? `${p + 1}/${f}` : i ? "0" : "" })
3482
+ /* @__PURE__ */ g("span", { className: "find-replace-count", children: p > 0 ? `${h + 1}/${p}` : i ? "0" : "" })
3481
3483
  ] }),
3482
3484
  /* @__PURE__ */ g(
3483
3485
  "button",
3484
3486
  {
3485
3487
  onClick: w,
3486
- className: Y("find-replace-btn", o && "find-replace-btn--active"),
3488
+ className: Y("find-replace-btn", c && "find-replace-btn--active"),
3487
3489
  title: "Case Sensitive",
3488
3490
  children: /* @__PURE__ */ g(Ur, { size: 15 })
3489
3491
  }
@@ -3506,7 +3508,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3506
3508
  "input",
3507
3509
  {
3508
3510
  type: "text",
3509
- value: c,
3511
+ value: o,
3510
3512
  onChange: (v) => {
3511
3513
  l(v.target.value), e.commands.setReplaceTerm(v.target.value);
3512
3514
  },
@@ -3521,11 +3523,11 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3521
3523
  /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(jr, { size: 15 }) })
3522
3524
  ] })
3523
3525
  ] }) : null;
3524
- }, ai = ({ editor: e }) => {
3526
+ }, ii = ({ editor: e }) => {
3525
3527
  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 };
3528
+ const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: l } = a.selection;
3529
+ let c = 0;
3530
+ return o !== l && (c = a.doc.textBetween(o, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: c };
3529
3531
  }, [e.state.doc, e.state.selection]);
3530
3532
  return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
3531
3533
  /* @__PURE__ */ L("span", { children: [
@@ -3539,73 +3541,73 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3539
3541
  r.selectionCount
3540
3542
  ] })
3541
3543
  ] });
3542
- }, ii = {
3544
+ }, si = {
3543
3545
  empty: "○",
3544
3546
  filled: "●"
3545
- }, si = {
3547
+ }, oi = {
3546
3548
  empty: "text-gray-400",
3547
3549
  filled: "text-green-500"
3548
- }, oi = /* @__PURE__ */ new Set([
3550
+ }, ci = /* @__PURE__ */ new Set([
3549
3551
  "technical_field",
3550
3552
  "background_art",
3551
3553
  "summary",
3552
3554
  "drawing_description",
3553
3555
  "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
+ ]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
3557
+ const { editorLanguage: n } = I(), r = H(n), [a, i] = F(t), [s, o] = F(0);
3556
3558
  M(() => {
3557
- const o = () => c((d) => d + 1);
3558
- return e.on("update", o), () => {
3559
- e.off("update", o);
3559
+ const c = () => o((d) => d + 1);
3560
+ return e.on("update", c), () => {
3561
+ e.off("update", c);
3560
3562
  };
3561
3563
  }, [e]);
3562
3564
  const l = At(() => {
3563
- const o = [];
3565
+ const c = [];
3564
3566
  let d = !1;
3565
3567
  return e.state.doc.descendants((u, m) => {
3566
3568
  if (u.type.name === "patent_title") {
3567
3569
  if (!d) {
3568
3570
  const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
3569
- o.push({
3571
+ c.push({
3570
3572
  type: "book-group",
3571
3573
  pos: m,
3572
3574
  title: y,
3573
3575
  charCount: 0
3574
3576
  }), d = !0;
3575
3577
  }
3576
- const f = u.textContent || "", p = f.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
3577
- return o.push({
3578
+ const p = u.textContent || "", h = p.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
3579
+ return c.push({
3578
3580
  type: "section",
3579
3581
  pos: m,
3580
- title: p ? f.trim() : b,
3581
- state: p ? "filled" : "empty",
3582
- charCount: f.replace(/\s/g, "").length,
3582
+ title: h ? p.trim() : b,
3583
+ state: h ? "filled" : "empty",
3584
+ charCount: p.replace(/\s/g, "").length,
3583
3585
  indent: !0
3584
3586
  }), !1;
3585
3587
  }
3586
3588
  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({
3589
+ const p = u.attrs.sectionType, h = ci.has(p), b = `sectionTitle_${p}`, y = typeof r[b] == "string" ? r[b] : p, w = u.textContent || "", T = w.trim().length > 0;
3590
+ return c.push({
3589
3591
  type: "section",
3590
3592
  pos: m,
3591
3593
  title: y,
3592
3594
  state: T ? "filled" : "empty",
3593
3595
  charCount: w.replace(/\s/g, "").length,
3594
- indent: p
3596
+ indent: h
3595
3597
  }), !1;
3596
3598
  }
3597
3599
  if (u.type.name === "heading") {
3598
- const f = u.attrs.level, p = u.textContent || "";
3599
- return p.trim() && o.push({
3600
+ const p = u.attrs.level, h = u.textContent || "";
3601
+ return h.trim() && c.push({
3600
3602
  type: "heading",
3601
3603
  pos: m,
3602
- title: p,
3603
- level: f,
3604
- charCount: p.replace(/\s/g, "").length
3604
+ title: h,
3605
+ level: p,
3606
+ charCount: h.replace(/\s/g, "").length
3605
3607
  }), !1;
3606
3608
  }
3607
3609
  return !0;
3608
- }), o;
3610
+ }), c;
3609
3611
  }, [e, s, r]);
3610
3612
  return a ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
3611
3613
  "button",
@@ -3631,32 +3633,32 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3631
3633
  ] }),
3632
3634
  /* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
3633
3635
  l.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
3634
- l.map((o, d) => /* @__PURE__ */ L(
3636
+ l.map((c, d) => /* @__PURE__ */ L(
3635
3637
  "button",
3636
3638
  {
3637
3639
  className: Y(
3638
3640
  "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"
3641
+ c.type === "heading" && `outline-panel-item--h${c.level}`,
3642
+ c.type === "book-group" && "outline-panel-item--book",
3643
+ c.indent && "outline-panel-item--indent"
3642
3644
  ),
3643
3645
  onClick: () => {
3644
- o.type !== "book-group" && (e.chain().setTextSelection(o.pos + 1).focus().run(), requestAnimationFrame(() => {
3645
- const u = e.view.nodeDOM(o.pos);
3646
+ c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
3647
+ const u = e.view.nodeDOM(c.pos);
3646
3648
  u == null || u.scrollIntoView({ behavior: "smooth", block: "start" });
3647
3649
  }));
3648
3650
  },
3649
3651
  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 })
3652
+ c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
3653
+ /* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
3654
+ c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
3653
3655
  ]
3654
3656
  },
3655
- `${o.pos}-${d}`
3657
+ `${c.pos}-${d}`
3656
3658
  ))
3657
3659
  ] })
3658
3660
  ] });
3659
- }, li = ({
3661
+ }, di = ({
3660
3662
  editor: e,
3661
3663
  mode: t = "edit",
3662
3664
  className: n
@@ -3672,14 +3674,14 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3672
3674
  ),
3673
3675
  children: /* @__PURE__ */ g(In, { editor: e, className: "h-full" })
3674
3676
  }
3675
- )), cn = "patent-editor-draft", di = 1500, ui = () => {
3677
+ )), cn = "patent-editor-draft", ui = 1500, mi = () => {
3676
3678
  try {
3677
3679
  const e = localStorage.getItem(cn);
3678
3680
  return e ? JSON.parse(e) : null;
3679
3681
  } catch {
3680
3682
  return null;
3681
3683
  }
3682
- }, mi = ({
3684
+ }, gi = ({
3683
3685
  initialContent: e,
3684
3686
  onChange: t,
3685
3687
  className: n,
@@ -3687,10 +3689,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3687
3689
  editable: a = !0,
3688
3690
  onEditorReady: i,
3689
3691
  onSelectionOptimize: s,
3690
- patchEditorId: c = "default",
3692
+ patchEditorId: o = "default",
3691
3693
  defaultOutlineCollapsed: l = !1
3692
3694
  }) => {
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()) || {
3695
+ const { setEditor: c, setDocument: d, editorLanguage: u, autoSaveStatus: m, ai: p } = I(), { setAutoSaveStatus: h, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
3694
3696
  type: "doc",
3695
3697
  content: [
3696
3698
  {
@@ -3698,27 +3700,27 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3698
3700
  content: [{ type: "text", text: "" }]
3699
3701
  }
3700
3702
  ]
3701
- }, T = ae((h) => {
3703
+ }, T = ae((f) => {
3702
3704
  try {
3703
- p("saving"), localStorage.setItem(cn, JSON.stringify(h)), p("saved"), b(/* @__PURE__ */ new Date());
3705
+ h("saving"), localStorage.setItem(cn, JSON.stringify(f)), h("saved"), b(/* @__PURE__ */ new Date());
3704
3706
  } catch {
3705
- p("error");
3707
+ h("error");
3706
3708
  }
3707
- }, [p, b]), v = Nn(
3708
- Ka({
3709
- extensions: [fa.configure({ editorId: c })],
3709
+ }, [h, b]), v = Nn(
3710
+ Xa({
3711
+ extensions: [pa.configure({ editorId: o })],
3710
3712
  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(() => {
3713
+ onUpdate: ({ editor: f }) => {
3714
+ const C = f.getJSON();
3715
+ d(C), B.notifyStateChange(f), t && t(C), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3714
3716
  T(C);
3715
- }, di));
3717
+ }, ui));
3716
3718
  },
3717
- onCreate: ({ editor: h }) => {
3718
- o(h), i == null || i(h), B.initializePlugins(h), B.notifyStateChange(h);
3719
+ onCreate: ({ editor: f }) => {
3720
+ c(f), i == null || i(f), B.initializePlugins(f), B.notifyStateChange(f);
3719
3721
  },
3720
- onSelectionUpdate: ({ editor: h }) => {
3721
- B.notifySelectionChange(h);
3722
+ onSelectionUpdate: ({ editor: f }) => {
3723
+ B.notifySelectionChange(f);
3722
3724
  },
3723
3725
  editorProps: {
3724
3726
  attributes: {
@@ -3736,31 +3738,31 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3736
3738
  v.commands.setContent(e);
3737
3739
  }
3738
3740
  }, [v, e]), M(() => () => {
3739
- y.current && clearTimeout(y.current), v && (o(null), B.destroyPlugins(v), v.destroy());
3740
- }, [v, o]), M(() => {
3741
+ y.current && clearTimeout(y.current), v && (c(null), B.destroyPlugins(v), v.destroy());
3742
+ }, [v, c]), M(() => {
3741
3743
  !v || v.isDestroyed || B.notifyStateChange(v);
3742
3744
  }, [v, u]), !v)
3743
3745
  return null;
3744
3746
  const S = H(u), N = m === "saving" ? S.autoSaveSaving : m === "saved" ? S.autoSaveSaved : m === "error" ? S.autoSaveError : "";
3745
3747
  return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3746
3748
  !r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
3747
- /* @__PURE__ */ g(Za, { editor: v }),
3749
+ /* @__PURE__ */ g(Qa, { editor: v }),
3748
3750
  N && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: N })
3749
3751
  ] }),
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 }),
3752
+ !r && v && /* @__PURE__ */ g(ei, { editor: v }),
3753
+ !r && v && /* @__PURE__ */ g(ri, { editor: v, onSelectionOptimize: s }),
3754
+ !r && v && /* @__PURE__ */ g(ai, { editor: v }),
3753
3755
  /* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
3754
- !r && v && /* @__PURE__ */ g(ci, { editor: v, defaultCollapsed: l }),
3756
+ !r && v && /* @__PURE__ */ g(li, { editor: v, defaultCollapsed: l }),
3755
3757
  /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
3756
- li,
3758
+ di,
3757
3759
  {
3758
3760
  editor: v,
3759
- mode: r || !a || f.status === "streaming" && f.activeSectionType === "claims" ? "readonly" : "edit"
3761
+ mode: r || !a || p.status === "streaming" && p.activeSectionType === "claims" ? "readonly" : "edit"
3760
3762
  }
3761
3763
  ) })
3762
3764
  ] }),
3763
- !r && /* @__PURE__ */ g(ai, { editor: v })
3765
+ !r && /* @__PURE__ */ g(ii, { editor: v })
3764
3766
  ] });
3765
3767
  };
3766
3768
  function ln(e) {
@@ -3770,19 +3772,19 @@ function ln(e) {
3770
3772
  async pull(a) {
3771
3773
  var i;
3772
3774
  for (; ; ) {
3773
- const { done: s, value: c } = await t.read();
3775
+ const { done: s, value: o } = await t.read();
3774
3776
  if (s) {
3775
3777
  a.close();
3776
3778
  return;
3777
3779
  }
3778
- r += n.decode(c, { stream: !0 });
3780
+ r += n.decode(o, { stream: !0 });
3779
3781
  const l = r.split(`
3780
3782
  `);
3781
3783
  r = l.pop() || "";
3782
- let o = "";
3784
+ let c = "";
3783
3785
  for (const d of l) {
3784
3786
  if (d.startsWith("event: ")) {
3785
- o = d.slice(7).trim();
3787
+ c = d.slice(7).trim();
3786
3788
  continue;
3787
3789
  }
3788
3790
  if (!d.startsWith("data: ")) continue;
@@ -3792,21 +3794,21 @@ function ln(e) {
3792
3794
  return;
3793
3795
  }
3794
3796
  try {
3795
- const m = JSON.parse(u), f = o || m.type;
3796
- if (f === "delta" || !f && m.content != null)
3797
+ const m = JSON.parse(u), p = c || m.type;
3798
+ if (p === "delta" || !p && m.content != null)
3797
3799
  a.enqueue({
3798
3800
  type: "delta",
3799
3801
  content: m.content ?? m.text ?? ((i = m.delta) == null ? void 0 : i.content) ?? ""
3800
3802
  });
3801
- else if (f === "patch")
3803
+ else if (p === "patch")
3802
3804
  a.enqueue({ type: "patch", patch: m });
3803
- else if (f === "done") {
3805
+ else if (p === "done") {
3804
3806
  a.enqueue({ type: "done", usage: m.usage }), a.close();
3805
3807
  return;
3806
- } else f === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
3808
+ } else p === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
3807
3809
  } catch {
3808
3810
  }
3809
- o = "";
3811
+ c = "";
3810
3812
  }
3811
3813
  }
3812
3814
  },
@@ -3815,7 +3817,7 @@ function ln(e) {
3815
3817
  }
3816
3818
  });
3817
3819
  }
3818
- function gi(e, t) {
3820
+ function fi(e, t) {
3819
3821
  let n = null;
3820
3822
  return {
3821
3823
  async request(r) {
@@ -3837,31 +3839,31 @@ function gi(e, t) {
3837
3839
  }
3838
3840
  };
3839
3841
  }
3840
- function fi(e, t) {
3842
+ function pi(e, t) {
3841
3843
  let n = null;
3842
3844
  const r = e.replace(/\/+$/, "");
3843
3845
  async function a(i, s) {
3844
- const c = await fetch(i, {
3846
+ const o = await fetch(i, {
3845
3847
  ...s,
3846
3848
  headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
3847
3849
  });
3848
- if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
3849
- const l = await c.json();
3850
+ if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
3851
+ const l = await o.json();
3850
3852
  return l.data ?? l;
3851
3853
  }
3852
3854
  return {
3853
- async createSession(i, s, c) {
3855
+ async createSession(i, s, o) {
3854
3856
  return a(`${r}/api/v1/chat/sessions`, {
3855
3857
  method: "POST",
3856
- body: JSON.stringify({ patentId: i, title: s, language: c })
3858
+ body: JSON.stringify({ patentId: i, title: s, language: o })
3857
3859
  });
3858
3860
  },
3859
- async listSessions(i, s = 1, c = 20) {
3860
- const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3861
+ async listSessions(i, s = 1, o = 20) {
3862
+ const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
3861
3863
  return i && l.set("patentId", i), a(`${r}/api/v1/chat/sessions?${l}`);
3862
3864
  },
3863
- async getMessages(i, s = 1, c = 50) {
3864
- const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3865
+ async getMessages(i, s = 1, o = 50) {
3866
+ const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
3865
3867
  return a(`${r}/api/v1/chat/sessions/${i}/messages?${l}`);
3866
3868
  },
3867
3869
  async deleteSession(i) {
@@ -3878,7 +3880,7 @@ function fi(e, t) {
3878
3880
  },
3879
3881
  async subscribeStream(i, s) {
3880
3882
  n = new AbortController();
3881
- const c = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(c, {
3883
+ const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(o, {
3882
3884
  headers: { Accept: "text/event-stream", ...t },
3883
3885
  signal: n.signal
3884
3886
  });
@@ -3891,8 +3893,8 @@ function fi(e, t) {
3891
3893
  }
3892
3894
  };
3893
3895
  }
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 hi = It(
3897
+ ({ 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: u, patchEditorId: m, defaultOutlineCollapsed: p }, h) => {
3896
3898
  const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), v = ae((S) => {
3897
3899
  T.current = S;
3898
3900
  }, []), x = Ee.useMemo(() => {
@@ -3902,10 +3904,10 @@ const pi = It(
3902
3904
  return Ee.useEffect(() => {
3903
3905
  s && b(s);
3904
3906
  }, [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, () => ({
3907
+ o ? y(o) : c && y(fi(c, d));
3908
+ }, [o, c, d, y]), Ee.useEffect(() => {
3909
+ l ? w(l) : c && w(pi(c, d));
3910
+ }, [l, c, d, w]), Nt(h, () => ({
3909
3911
  getContent: () => {
3910
3912
  var S;
3911
3913
  return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
@@ -3921,7 +3923,7 @@ const pi = It(
3921
3923
  (S = T.current) == null || S.commands.focus();
3922
3924
  }
3923
3925
  })), /* @__PURE__ */ g(
3924
- mi,
3926
+ gi,
3925
3927
  {
3926
3928
  initialContent: x,
3927
3929
  onChange: n,
@@ -3931,21 +3933,21 @@ const pi = It(
3931
3933
  editable: i,
3932
3934
  onSelectionOptimize: u,
3933
3935
  patchEditorId: m,
3934
- defaultOutlineCollapsed: f
3936
+ defaultOutlineCollapsed: p
3935
3937
  }
3936
3938
  );
3937
3939
  }
3938
3940
  );
3939
- pi.displayName = "PatentEditor";
3940
- async function Ws(e, t, n) {
3941
- var a, i, s, c;
3941
+ hi.displayName = "PatentEditor";
3942
+ async function js(e, t, n) {
3943
+ var a, i, s, o;
3942
3944
  let r = !1;
3943
3945
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
3944
3946
  try {
3945
3947
  let l = dn(e, n);
3946
3948
  for (; ; ) {
3947
- const { done: o, value: d } = await t.read();
3948
- if (o) break;
3949
+ const { done: c, value: d } = await t.read();
3950
+ if (c) break;
3949
3951
  if (!d) continue;
3950
3952
  (i = n.onChunk) == null || i.call(n, d);
3951
3953
  const u = e.state.tr.insertText(d, l);
@@ -3953,28 +3955,28 @@ async function Ws(e, t, n) {
3953
3955
  }
3954
3956
  n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
3955
3957
  } catch (l) {
3956
- (c = n.onError) == null || c.call(n, l instanceof Error ? l : new Error(String(l)));
3958
+ (o = n.onError) == null || o.call(n, l instanceof Error ? l : new Error(String(l)));
3957
3959
  }
3958
3960
  }
3959
- async function js(e, t, n, r) {
3960
- var i, s, c, l, o, d, u, m;
3961
+ async function Gs(e, t, n, r) {
3962
+ var i, s, o, l, c, d, u, m;
3961
3963
  const a = new AbortController();
3962
3964
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
3963
3965
  try {
3964
- const f = await fetch(t, {
3966
+ const p = await fetch(t, {
3965
3967
  method: "POST",
3966
3968
  headers: { "Content-Type": "application/json" },
3967
3969
  body: JSON.stringify(n),
3968
3970
  signal: a.signal
3969
3971
  });
3970
- if (!f.ok)
3971
- throw new Error(`HTTP ${f.status}: ${f.statusText}`);
3972
- const p = (s = f.body) == null ? void 0 : s.getReader();
3973
- if (!p) throw new Error("No response body");
3972
+ if (!p.ok)
3973
+ throw new Error(`HTTP ${p.status}: ${p.statusText}`);
3974
+ const h = (s = p.body) == null ? void 0 : s.getReader();
3975
+ if (!h) throw new Error("No response body");
3974
3976
  const b = new TextDecoder();
3975
3977
  let y = dn(e, r), w = "";
3976
3978
  for (; ; ) {
3977
- const { done: T, value: v } = await p.read();
3979
+ const { done: T, value: v } = await h.read();
3978
3980
  if (T) break;
3979
3981
  w += b.decode(v, { stream: !0 });
3980
3982
  const x = w.split(`
@@ -3984,11 +3986,11 @@ async function js(e, t, n, r) {
3984
3986
  if (!S.startsWith("data: ")) continue;
3985
3987
  const N = S.slice(6).trim();
3986
3988
  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() };
3989
+ return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
3988
3990
  try {
3989
- const h = JSON.parse(N), C = h.content || h.text || ((l = h.delta) == null ? void 0 : l.content) || "";
3991
+ const f = JSON.parse(N), C = f.content || f.text || ((l = f.delta) == null ? void 0 : l.content) || "";
3990
3992
  if (!C) continue;
3991
- (o = r.onChunk) == null || o.call(r, C);
3993
+ (c = r.onChunk) == null || c.call(r, C);
3992
3994
  const _ = e.state.tr.insertText(C, y);
3993
3995
  e.view.dispatch(_), y = _.mapping.map(y, 1);
3994
3996
  } catch {
@@ -3996,8 +3998,8 @@ async function js(e, t, n, r) {
3996
3998
  }
3997
3999
  }
3998
4000
  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)));
4001
+ } catch (p) {
4002
+ p.name === "AbortError" ? (u = r.onAbort) == null || u.call(r) : (m = r.onError) == null || m.call(r, p instanceof Error ? p : new Error(String(p)));
4001
4003
  }
4002
4004
  return { abort: () => a.abort() };
4003
4005
  }
@@ -4026,12 +4028,12 @@ function nt(e, t) {
4026
4028
  n.forEach((l) => {
4027
4029
  s++;
4028
4030
  });
4029
- let c = 0;
4031
+ let o = 0;
4030
4032
  if (n.forEach((l) => {
4031
- l.type.name === "paragraph" && l.textContent.trim().length > 0 && c++;
4033
+ l.type.name === "paragraph" && l.textContent.trim().length > 0 && o++;
4032
4034
  }), 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;
4035
+ const c = i, d = i + l.nodeSize;
4036
+ l.type.name === "paragraph" && l.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: c, to: d }), i = d;
4035
4037
  }), a.length !== 0) {
4036
4038
  for (let l = a.length - 1; l >= 0; l--)
4037
4039
  r.delete(a[l].from, a[l].to);
@@ -4186,7 +4188,7 @@ function rt(e, t = 30) {
4186
4188
  }
4187
4189
  });
4188
4190
  }
4189
- function hi(e) {
4191
+ function yi(e) {
4190
4192
  const t = [], n = $e(e, 3);
4191
4193
  for (const r of n)
4192
4194
  t.push({ type: "delta", content: r });
@@ -4198,7 +4200,7 @@ function $e(e, t) {
4198
4200
  n.push(e.slice(r, r + t));
4199
4201
  return n;
4200
4202
  }
4201
- function yi(e, t, n) {
4203
+ function bi(e, t, n) {
4202
4204
  const r = n === "zh", a = [];
4203
4205
  let i;
4204
4206
  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) {
@@ -4207,18 +4209,18 @@ function yi(e, t, n) {
4207
4209
  ` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
4208
4210
 
4209
4211
  `;
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;
4212
+ for (const o of $e(s, 4))
4213
+ a.push({ type: "delta", content: o });
4214
+ for (const o of $e(i, 4))
4215
+ a.push({ type: "delta", content: o });
4216
+ for (let o = 0; o < t.length; o++) {
4217
+ const l = t[o], c = l.text;
4216
4218
  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({
4219
+ 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
4220
  type: "patch",
4219
4221
  patch: {
4220
4222
  op: "replace",
4221
- target: { type: "ref", refIndex: c },
4223
+ target: { type: "ref", refIndex: o },
4222
4224
  content: d,
4223
4225
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4224
4226
  }
@@ -4227,7 +4229,7 @@ function yi(e, t, n) {
4227
4229
  patch: {
4228
4230
  op: "replace",
4229
4231
  target: { type: "section", sectionType: l.source },
4230
- search: o,
4232
+ search: c,
4231
4233
  content: d,
4232
4234
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4233
4235
  }
@@ -4235,7 +4237,7 @@ function yi(e, t, n) {
4235
4237
  type: "patch",
4236
4238
  patch: {
4237
4239
  op: "replace",
4238
- target: { type: "search", searchText: o },
4240
+ target: { type: "search", searchText: c },
4239
4241
  content: d,
4240
4242
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4241
4243
  }
@@ -4246,21 +4248,21 @@ function yi(e, t, n) {
4246
4248
  a.push({ type: "delta", content: s });
4247
4249
  return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
4248
4250
  }
4249
- function Gs() {
4251
+ function Vs() {
4250
4252
  let e = null;
4251
4253
  return {
4252
4254
  async request(t) {
4253
- var c;
4255
+ var o;
4254
4256
  if (e = new AbortController(), await te(300), e.signal.aborted)
4255
4257
  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];
4258
+ 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
4259
  let i = a;
4258
4260
  t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
4259
4261
 
4260
4262
  ` : `[Generated based on instruction "${t.instruction}"]
4261
4263
 
4262
4264
  `) + a);
4263
- const s = hi(i);
4265
+ const s = yi(i);
4264
4266
  return rt(s, 25);
4265
4267
  },
4266
4268
  abort() {
@@ -4268,13 +4270,13 @@ function Gs() {
4268
4270
  }
4269
4271
  };
4270
4272
  }
4271
- function Vs() {
4273
+ function Js() {
4272
4274
  const e = /* @__PURE__ */ new Map();
4273
4275
  let t = null, n = null;
4274
4276
  return {
4275
4277
  async createSession(r, a, i) {
4276
4278
  await te(100);
4277
- const s = `sess_${Date.now()}`, c = {
4279
+ const s = `sess_${Date.now()}`, o = {
4278
4280
  sessionId: s,
4279
4281
  patentId: r || void 0,
4280
4282
  title: a || (i === "zh" ? "新对话" : "New Chat"),
@@ -4282,7 +4284,7 @@ function Vs() {
4282
4284
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4283
4285
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4284
4286
  };
4285
- return e.set(s, { session: c, messages: [] }), c;
4287
+ return e.set(s, { session: o, messages: [] }), o;
4286
4288
  },
4287
4289
  async listSessions() {
4288
4290
  await te(50);
@@ -4311,12 +4313,12 @@ function Vs() {
4311
4313
  status: "done",
4312
4314
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4313
4315
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4314
- const c = yi(
4316
+ const o = bi(
4315
4317
  a.content,
4316
4318
  a.references || [],
4317
4319
  a.language
4318
4320
  );
4319
- return n = { messageId: s, events: c }, { messageId: s, sessionId: r, status: "processing" };
4321
+ return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
4320
4322
  },
4321
4323
  async subscribeStream(r, a) {
4322
4324
  t = new AbortController(), await te(100);
@@ -4326,24 +4328,24 @@ function Vs() {
4326
4328
  return rt([{ type: "done" }]);
4327
4329
  const s = n.events;
4328
4330
  n = null;
4329
- const c = rt(s, 18), l = `${a}_a`;
4330
- let o = "";
4331
+ const o = rt(s, 18), l = `${a}_a`;
4332
+ let c = "";
4331
4333
  for (const d of s)
4332
- d.type === "delta" && (o += d.content);
4334
+ d.type === "delta" && (c += d.content);
4333
4335
  return i.messages.push({
4334
4336
  messageId: l,
4335
4337
  role: "assistant",
4336
- content: o,
4338
+ content: c,
4337
4339
  status: "done",
4338
4340
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4339
- }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
4341
+ }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
4340
4342
  },
4341
4343
  abort() {
4342
4344
  t == null || t.abort(), t = null;
4343
4345
  }
4344
4346
  };
4345
4347
  }
4346
- function bi(e) {
4348
+ function vi(e) {
4347
4349
  const t = [], n = e.replace(/\r\n/g, `
4348
4350
  `).trim();
4349
4351
  if (!n) return t;
@@ -4358,78 +4360,78 @@ function bi(e) {
4358
4360
  if (a.length === 0)
4359
4361
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4360
4362
  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 });
4363
+ 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, u = wi(c, d);
4364
+ t.push({ number: d, text: c, dependsOn: u });
4363
4365
  }
4364
4366
  return t;
4365
4367
  }
4366
- function vi(e, t) {
4368
+ function wi(e, t) {
4367
4369
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4368
4370
  let a;
4369
4371
  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++)
4372
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4373
+ for (let l = s; l <= o; l++)
4372
4374
  l !== t && l > 0 && n.push(l);
4373
4375
  }
4374
4376
  const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4375
4377
  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++)
4378
+ const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4379
+ for (let l = s; l <= o; l++)
4378
4380
  l !== t && l > 0 && n.push(l);
4379
4381
  }
4380
- return [...new Set(n)].sort((s, c) => s - c);
4382
+ return [...new Set(n)].sort((s, o) => s - o);
4381
4383
  }
4382
- function Js(e) {
4383
- return bi(e).map((n) => ({
4384
+ function Ks(e) {
4385
+ return vi(e).map((n) => ({
4384
4386
  type: "paragraph",
4385
4387
  content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
4386
4388
  }));
4387
4389
  }
4388
- const wi = -1, xi = 1, Ci = 0, at = new we("docDiff");
4390
+ const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
4389
4391
  let Ye = null;
4390
- function Ti() {
4392
+ function Si() {
4391
4393
  return Ye || (Ye = new Pt()), Ye;
4392
4394
  }
4393
- function Si(e, t, n) {
4395
+ function Ei(e, t, n) {
4394
4396
  const r = [];
4395
4397
  return e.nodesBetween(t, n, (a, i) => {
4396
4398
  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;
4399
+ const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
4400
+ return c > l && r.push({ from: l, to: c }), !1;
4399
4401
  }
4400
4402
  return !0;
4401
4403
  }), r;
4402
4404
  }
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);
4405
+ function Xs(e, t) {
4406
+ 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);
4407
+ s.diff_cleanupSemantic(o);
4406
4408
  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) {
4412
- let p = 0;
4413
- for (; p < f.length; ) {
4414
- for (; p < f.length && f[p] === "\0"; ) p++;
4415
- if (p >= f.length) break;
4416
- const b = p;
4417
- for (; p < f.length && f[p] !== "\0"; ) p++;
4418
- const y = ye(i, o + b), w = ye(i, o + p);
4409
+ let c = 0;
4410
+ for (const [m, p] of o)
4411
+ if (m === Ti)
4412
+ c += p.length;
4413
+ else if (m === Ci) {
4414
+ let h = 0;
4415
+ for (; h < p.length; ) {
4416
+ for (; h < p.length && p[h] === "\0"; ) h++;
4417
+ if (h >= p.length) break;
4418
+ const b = h;
4419
+ for (; h < p.length && p[h] !== "\0"; ) h++;
4420
+ const y = ye(i, c + b), w = ye(i, c + h);
4419
4421
  if (y >= 0 && w >= 0 && w > y)
4420
- for (const T of Si(n, y, w))
4422
+ for (const T of Ei(n, y, w))
4421
4423
  l.push(
4422
4424
  re.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4423
4425
  );
4424
4426
  }
4425
- o += f.length;
4426
- } else if (m === wi) {
4427
- const p = ye(i, o);
4428
- if (p >= 0) {
4429
- const b = f.replace(/\0/g, " ");
4427
+ c += p.length;
4428
+ } else if (m === xi) {
4429
+ const h = ye(i, c);
4430
+ if (h >= 0) {
4431
+ const b = p.replace(/\0/g, " ");
4430
4432
  l.push(
4431
4433
  re.widget(
4432
- p,
4434
+ h,
4433
4435
  () => {
4434
4436
  const y = document.createElement("span");
4435
4437
  return y.className = "patch-diff-delete", y.textContent = b, y;
@@ -4443,7 +4445,7 @@ function Ks(e, t) {
4443
4445
  key: at,
4444
4446
  state: {
4445
4447
  init: () => d,
4446
- apply: (m, f) => m.docChanged ? f.map(m.mapping, m.doc) : f
4448
+ apply: (m, p) => m.docChanged ? p.map(m.mapping, m.doc) : p
4447
4449
  },
4448
4450
  props: {
4449
4451
  decorations(m) {
@@ -4453,22 +4455,22 @@ function Ks(e, t) {
4453
4455
  });
4454
4456
  e.registerPlugin(u);
4455
4457
  }
4456
- function Xs(e) {
4458
+ function Ys(e) {
4457
4459
  e.unregisterPlugin(at);
4458
4460
  }
4459
- const Ei = /* @__PURE__ */ new Set([
4461
+ const ki = /* @__PURE__ */ new Set([
4460
4462
  "abstract",
4461
4463
  "abstract_drawing",
4462
4464
  "claims",
4463
4465
  "drawing_figures"
4464
- ]), ki = /* @__PURE__ */ new Set([
4466
+ ]), _i = /* @__PURE__ */ new Set([
4465
4467
  "technical_field",
4466
4468
  "background_art",
4467
4469
  "summary",
4468
4470
  "drawing_description",
4469
4471
  "detailed_description"
4470
4472
  ]);
4471
- function _i(e, t) {
4473
+ function Ii(e, t) {
4472
4474
  const n = H(t), r = [];
4473
4475
  return e.state.doc.descendants((a) => {
4474
4476
  if (a.type.name === "patent_title") {
@@ -4481,11 +4483,11 @@ function _i(e, t) {
4481
4483
  }), !1;
4482
4484
  }
4483
4485
  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();
4486
+ const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, l = [];
4487
+ return a.forEach((c) => {
4488
+ const d = c.textContent.trim();
4487
4489
  d && l.push(d);
4488
- }), r.push({ type: "patent_section", sectionType: i, title: c, paragraphs: l }), !1;
4490
+ }), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: l }), !1;
4489
4491
  }
4490
4492
  return !0;
4491
4493
  }), r;
@@ -4504,7 +4506,7 @@ function Et(e) {
4504
4506
  spacing: { before: 240, after: 120 }
4505
4507
  });
4506
4508
  }
4507
- function Ii(e) {
4509
+ function Ni(e) {
4508
4510
  return new He({
4509
4511
  children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
4510
4512
  alignment: it.CENTER,
@@ -4518,11 +4520,11 @@ function Ze(e) {
4518
4520
  indent: { firstLine: he(7) }
4519
4521
  });
4520
4522
  }
4521
- function Ni(e, t) {
4523
+ function Ai(e, t) {
4522
4524
  const n = H(t), r = [];
4523
4525
  let a = !1;
4524
4526
  for (const i of e) {
4525
- if (Ei.has(i.sectionType)) {
4527
+ if (ki.has(i.sectionType)) {
4526
4528
  r.push(St(i.title));
4527
4529
  for (const s of i.paragraphs)
4528
4530
  r.push(Ze(s));
@@ -4534,10 +4536,10 @@ function Ni(e, t) {
4534
4536
  r.push(St(s)), a = !0;
4535
4537
  }
4536
4538
  for (const s of i.paragraphs)
4537
- r.push(Ii(s));
4539
+ r.push(Ni(s));
4538
4540
  continue;
4539
4541
  }
4540
- if (ki.has(i.sectionType)) {
4542
+ if (_i.has(i.sectionType)) {
4541
4543
  r.push(Et(i.title));
4542
4544
  for (const s of i.paragraphs)
4543
4545
  r.push(Ze(s));
@@ -4549,8 +4551,8 @@ function Ni(e, t) {
4549
4551
  }
4550
4552
  return r;
4551
4553
  }
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 = {
4554
+ async function Zs(e, t) {
4555
+ 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
4556
  properties: {
4555
4557
  page: {
4556
4558
  margin: {
@@ -4562,19 +4564,19 @@ async function Ys(e, t) {
4562
4564
  }
4563
4565
  },
4564
4566
  children: r
4565
- }, c = new Kr({
4567
+ }, o = new Kr({
4566
4568
  sections: [s]
4567
- }), l = await Xr.toBlob(c);
4569
+ }), l = await Xr.toBlob(o);
4568
4570
  Yr(l, i);
4569
4571
  }
4570
- async function Zs(e) {
4572
+ async function Qs(e) {
4571
4573
  window.print();
4572
4574
  }
4573
- function Qs(e, t) {
4575
+ function eo(e, t) {
4574
4576
  const n = [], r = t === "zh";
4575
4577
  let a = 0;
4576
4578
  const i = () => `v_${++a}`;
4577
- return e.state.doc.descendants((s, c) => {
4579
+ return e.state.doc.descendants((s, o) => {
4578
4580
  if (s.type.name === "patent_title") {
4579
4581
  const l = s.textContent.trim();
4580
4582
  if (l.length === 0)
@@ -4583,56 +4585,56 @@ function Qs(e, t) {
4583
4585
  severity: "warning",
4584
4586
  message: r ? "专利名称为空" : "Patent title is empty",
4585
4587
  sectionType: "patent_title",
4586
- pos: c
4588
+ pos: o
4587
4589
  });
4588
4590
  else {
4589
- const o = l.replace(/\s/g, "").length;
4590
- o > 25 && r && n.push({
4591
+ const c = l.replace(/\s/g, "").length;
4592
+ c > 25 && r && n.push({
4591
4593
  id: i(),
4592
4594
  severity: "error",
4593
- message: `专利名称超过25个汉字(当前${o}字)`,
4595
+ message: `专利名称超过25个汉字(当前${c}字)`,
4594
4596
  sectionType: "patent_title",
4595
- pos: c
4597
+ pos: o
4596
4598
  });
4597
4599
  }
4598
4600
  return !1;
4599
4601
  }
4600
4602
  if (s.type.name === "patent_section") {
4601
- const l = s.attrs.sectionType, o = s.textContent.trim();
4602
- if (o.length === 0 && n.push({
4603
+ const l = s.attrs.sectionType, c = s.textContent.trim();
4604
+ if (c.length === 0 && n.push({
4603
4605
  id: i(),
4604
4606
  severity: "warning",
4605
4607
  message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
4606
4608
  sectionType: l,
4607
- pos: c
4609
+ pos: o
4608
4610
  }), l === "abstract") {
4609
- const d = o.replace(/\s/g, "").length;
4611
+ const d = c.replace(/\s/g, "").length;
4610
4612
  d > 0 && d < 50 && n.push({
4611
4613
  id: i(),
4612
4614
  severity: "warning",
4613
4615
  message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
4614
4616
  sectionType: l,
4615
- pos: c
4617
+ pos: o
4616
4618
  }), d > 300 && n.push({
4617
4619
  id: i(),
4618
4620
  severity: "warning",
4619
4621
  message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
4620
4622
  sectionType: l,
4621
- pos: c
4623
+ pos: o
4622
4624
  });
4623
4625
  }
4624
4626
  if (l === "claims") {
4625
4627
  const d = /^(\d+)\s*[.、]/;
4626
4628
  s.forEach((u, m) => {
4627
4629
  if (u.type.name !== "paragraph") return;
4628
- const f = u.textContent.trim(), p = d.exec(f);
4629
- if (!p) return;
4630
- const b = p[1];
4631
- f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
4630
+ const p = u.textContent.trim(), h = d.exec(p);
4631
+ if (!h) return;
4632
+ const b = h[1];
4633
+ p.length > 0 && !p.endsWith("。") && !p.endsWith(".") && n.push({
4632
4634
  id: i(),
4633
4635
  severity: "warning",
4634
4636
  message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
4635
- pos: c + 1 + m
4637
+ pos: o + 1 + m
4636
4638
  });
4637
4639
  });
4638
4640
  }
@@ -4641,8 +4643,8 @@ function Qs(e, t) {
4641
4643
  return !0;
4642
4644
  }), n;
4643
4645
  }
4644
- const Ai = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4645
- function Li(e, t) {
4646
+ const Li = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4647
+ function Pi(e, t) {
4646
4648
  const n = [];
4647
4649
  let r;
4648
4650
  for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
@@ -4659,7 +4661,7 @@ function Li(e, t) {
4659
4661
  }
4660
4662
  const mn = (e) => {
4661
4663
  if (e.type.name === "reference")
4662
- return Pi(e);
4664
+ return Di(e);
4663
4665
  if (e.type.name === "hardBreak")
4664
4666
  return `
4665
4667
  `;
@@ -4669,7 +4671,7 @@ const mn = (e) => {
4669
4671
  return e.forEach((n) => {
4670
4672
  t += mn(n);
4671
4673
  }), t;
4672
- }, Pi = (e) => {
4674
+ }, Di = (e) => {
4673
4675
  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
4676
  if (r)
4675
4677
  return r;
@@ -4679,62 +4681,62 @@ const mn = (e) => {
4679
4681
  }
4680
4682
  const a = Number(e.attrs.resolvedNumber);
4681
4683
  return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
4682
- }, eo = (e) => {
4684
+ }, to = (e) => {
4683
4685
  const t = [];
4684
4686
  return e.state.doc.descendants((n, r) => {
4685
4687
  if (n.type.name === "patent_section")
4686
4688
  return n.attrs.sectionType === "claims";
4687
4689
  if (n.type.name !== "paragraph") return !0;
4688
- const a = mn(n).trim(), i = Ai.exec(a);
4690
+ const a = mn(n).trim(), i = Li.exec(a);
4689
4691
  if (!i) return !0;
4690
4692
  const s = parseInt(i[1], 10);
4691
4693
  if (!Number.isFinite(s) || s <= 0) return !0;
4692
- const c = a.slice(i[0].length).trim(), l = Li(c, s);
4694
+ const o = a.slice(i[0].length).trim(), l = Pi(o, s);
4693
4695
  return t.push({
4694
4696
  claimId: `claim_${s}`,
4695
4697
  number: s,
4696
4698
  dependsOn: l,
4697
- dependsOnClaimIds: l.map((o) => `claim_${o}`),
4698
- body: c,
4699
+ dependsOnClaimIds: l.map((c) => `claim_${c}`),
4700
+ body: o,
4699
4701
  pos: r
4700
4702
  }), !0;
4701
4703
  }), t;
4702
4704
  };
4703
4705
  export {
4704
- mi as EditorView,
4706
+ gi as EditorView,
4705
4707
  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,
4708
+ hi as PatentEditor,
4709
+ Hs as acceptAllPatches,
4710
+ Os as acceptPatch,
4711
+ Xs as applyDocDiffDecorations,
4712
+ Ws as buildAIContext,
4713
+ Ks as buildClaimsJSONContent,
4712
4714
  tn as buildPatentDocument,
4713
- $s as clearPatches,
4714
- fi as createChatSessionAPI,
4715
+ zs as clearPatches,
4716
+ pi as createChatSessionAPI,
4715
4717
  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,
4718
+ Xa as createEditorConfig,
4719
+ Vs as createMockAIService,
4720
+ Js as createMockChatSessionAPI,
4721
+ fi as createSSEAdapter,
4722
+ Qs as exportToPdf,
4723
+ Zs as exportToWord,
4724
+ to as extractClaimsFromEditor,
4723
4725
  on as findSectionAtCursor,
4724
- ei as getAllSections,
4725
- Us as getMissingSectionDeps,
4726
- Ms as getPatches,
4727
- Rs as onPatchChange,
4726
+ ti as getAllSections,
4727
+ qs as getMissingSectionDeps,
4728
+ Fs as getPatches,
4729
+ Ms as onPatchChange,
4728
4730
  B as pluginManager,
4729
- Hs as rejectAllPatches,
4730
- Os as rejectPatch,
4731
- Xs as removeDocDiffDecorations,
4732
- Ds as resolvePatchTarget,
4731
+ Us as rejectAllPatches,
4732
+ Bs as rejectPatch,
4733
+ Ys as removeDocDiffDecorations,
4734
+ Rs as resolvePatchTarget,
4733
4735
  sn as sectionContextDeps,
4734
- Fs as setPatches,
4736
+ $s as setPatches,
4735
4737
  I as useEditorStore,
4736
- Qs as validatePatentDocument,
4737
- Ws as writeStream,
4738
- js as writeStreamFromSSE
4738
+ eo as validatePatentDocument,
4739
+ js as writeStream,
4740
+ Gs as writeStreamFromSSE
4739
4741
  };
4740
4742
  //# sourceMappingURL=lib.js.map