patent-editor 0.2.15 → 0.2.17

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
@@ -401,18 +401,8 @@ const ia = Oe.create({
401
401
  setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = ke(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
402
402
  setReplaceTerm: (e) => () => (this.storage.replaceTerm = e, !0),
403
403
  setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results = ke(t.state.doc, this.storage.searchTerm, e), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
404
- nextSearchResult: () => ({ editor: e }) => {
405
- if (this.storage.results.length === 0) return !1;
406
- this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length;
407
- const t = this.storage.results[this.storage.currentIndex];
408
- return t && (e.commands.setTextSelection(t), ft(e)), e.view.dispatch(e.state.tr), !0;
409
- },
410
- previousSearchResult: () => ({ editor: e }) => {
411
- if (this.storage.results.length === 0) return !1;
412
- this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length;
413
- const t = this.storage.results[this.storage.currentIndex];
414
- return t && (e.commands.setTextSelection(t), ft(e)), e.view.dispatch(e.state.tr), !0;
415
- },
404
+ nextSearchResult: () => ({ editor: e }) => this.storage.results.length === 0 ? !1 : (this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length, ft(e, this.storage.results[this.storage.currentIndex]), !0),
405
+ previousSearchResult: () => ({ editor: e }) => this.storage.results.length === 0 ? !1 : (this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length, ft(e, this.storage.results[this.storage.currentIndex]), !0),
416
406
  replaceCurrent: () => ({ editor: e }) => {
417
407
  if (this.storage.results.length === 0 || this.storage.currentIndex < 0) return !1;
418
408
  const t = this.storage.results[this.storage.currentIndex];
@@ -466,22 +456,47 @@ const ia = Oe.create({
466
456
  ];
467
457
  }
468
458
  });
469
- function ft(e) {
470
- requestAnimationFrame(() => {
471
- const t = e.view.domAtPos(e.state.selection.from);
472
- if (t != null && t.node) {
473
- const n = t.node instanceof HTMLElement ? t.node : t.node.parentElement;
474
- n == null || n.scrollIntoView({ behavior: "smooth", block: "center" });
459
+ function sa(e) {
460
+ let t = e;
461
+ for (; t && t !== document.body && t !== document.documentElement; ) {
462
+ const n = getComputedStyle(t).overflowY;
463
+ if ((n === "auto" || n === "scroll" || n === "overlay") && t.scrollHeight > t.clientHeight + 1)
464
+ return t;
465
+ t = t.parentElement;
466
+ }
467
+ return document.scrollingElement || document.documentElement;
468
+ }
469
+ function ft(e, t) {
470
+ if (!t) {
471
+ e.view.dispatch(e.state.tr);
472
+ return;
473
+ }
474
+ const n = e.state.doc.content.size, r = Math.min(Math.max(t.from, 0), n), a = Math.min(Math.max(t.to, r), n);
475
+ e.chain().setTextSelection({ from: r, to: a }).run(), requestAnimationFrame(() => {
476
+ const i = e.view;
477
+ let s;
478
+ try {
479
+ s = i.coordsAtPos(r);
480
+ } catch {
481
+ return;
482
+ }
483
+ const o = sa(i.dom), l = (s.top + s.bottom) / 2;
484
+ if (o === document.scrollingElement || o === document.documentElement) {
485
+ const g = window.scrollY + l - window.innerHeight / 2;
486
+ window.scrollTo({ top: Math.max(0, g), behavior: "smooth" });
487
+ return;
475
488
  }
489
+ const c = o.getBoundingClientRect(), d = o.scrollTop + (l - c.top) - o.clientHeight / 2, m = o.scrollHeight - o.clientHeight;
490
+ o.scrollTo({ top: Math.max(0, Math.min(d, m)), behavior: "smooth" });
476
491
  });
477
492
  }
478
- const sa = -1, oa = 1, pt = 0;
493
+ const oa = -1, ca = 1, pt = 0;
479
494
  let Ge = null;
480
- function ca() {
495
+ function la() {
481
496
  return Ge || (Ge = new Lt()), Ge;
482
497
  }
483
498
  const jt = new we("patchDiff");
484
- function la(e, t) {
499
+ function da(e, t) {
485
500
  let n = null;
486
501
  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;
487
502
  }
@@ -521,7 +536,7 @@ function ht(e, t, n, r, a) {
521
536
  }
522
537
  return null;
523
538
  }
524
- function Rs(e, t, n, r, a) {
539
+ function Ms(e, t, n, r, a) {
525
540
  const i = t.target;
526
541
  let s = null;
527
542
  const o = /* @__PURE__ */ new Set();
@@ -531,7 +546,7 @@ function Rs(e, t, n, r, a) {
531
546
  if (!i)
532
547
  t.from != null && t.to != null && (s = { from: t.from, to: t.to });
533
548
  else if (i.type === "section" && i.sectionType)
534
- s = la(e, i.sectionType);
549
+ s = da(e, i.sectionType);
535
550
  else if (i.type === "ref" && i.refIndex != null) {
536
551
  const d = n[i.refIndex];
537
552
  (d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (s = { from: d.from, to: d.to });
@@ -556,7 +571,7 @@ function Rs(e, t, n, r, a) {
556
571
  }
557
572
  const G = /* @__PURE__ */ new Map();
558
573
  let De = [];
559
- function Ms(e) {
574
+ function Fs(e) {
560
575
  return De.push(e), () => {
561
576
  De = De.filter((t) => t !== e);
562
577
  };
@@ -564,16 +579,16 @@ function Ms(e) {
564
579
  function me() {
565
580
  De.forEach((e) => e());
566
581
  }
567
- function Fs(e = "default") {
582
+ function $s(e = "default") {
568
583
  return [...G.get(e) || []];
569
584
  }
570
- function $s(e, t = "default") {
585
+ function zs(e, t = "default") {
571
586
  G.set(t, e), me();
572
587
  }
573
- function zs(e = "default") {
588
+ function Os(e = "default") {
574
589
  G.delete(e), me();
575
590
  }
576
- function Os(e, t, n = "default") {
591
+ function Bs(e, t, n = "default") {
577
592
  const r = G.get(n) || [], a = r.find((o) => o.id === t);
578
593
  if (!a || a.status !== "pending") return !1;
579
594
  a.status = "accepted";
@@ -596,11 +611,11 @@ function Os(e, t, n = "default") {
596
611
  }
597
612
  return G.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), me(), !0;
598
613
  }
599
- function Bs(e, t, n = "default") {
614
+ function Hs(e, t, n = "default") {
600
615
  const r = G.get(n) || [], a = r.find((i) => i.id === t);
601
616
  return !a || a.status !== "pending" ? !1 : (a.status = "rejected", G.set(n, r.filter((i) => i.id !== t)), qe(e), me(), !0);
602
617
  }
603
- function Hs(e, t = "default") {
618
+ function Us(e, t = "default") {
604
619
  const a = [...(G.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
605
620
  for (const s of a)
606
621
  if (s.type === "delete")
@@ -614,13 +629,13 @@ function Hs(e, t = "default") {
614
629
  i.insertText(s.content, s.from, s.to);
615
630
  e.view.dispatch(i), G.delete(t), qe(e), me();
616
631
  }
617
- function Us(e, t = "default") {
632
+ function qs(e, t = "default") {
618
633
  G.delete(t), qe(e), me();
619
634
  }
620
635
  function qe(e) {
621
636
  e.view.dispatch(e.state.tr.setMeta(jt, !0));
622
637
  }
623
- function da(e, t, n) {
638
+ function ua(e, t, n) {
624
639
  const r = [];
625
640
  return e.nodesBetween(t, n, (a, i) => {
626
641
  if (a.isTextblock) {
@@ -630,7 +645,7 @@ function da(e, t, n) {
630
645
  return !0;
631
646
  }), r;
632
647
  }
633
- function ua(e, t) {
648
+ function ma(e, t) {
634
649
  if (!t.originalText || !t.content) return null;
635
650
  try {
636
651
  const o = e.resolve(t.from), l = e.resolve(t.to);
@@ -638,7 +653,7 @@ function ua(e, t) {
638
653
  } catch {
639
654
  return null;
640
655
  }
641
- const n = ca(), r = n.diff_main(t.originalText, t.content);
656
+ const n = la(), r = n.diff_main(t.originalText, t.content);
642
657
  n.diff_cleanupSemantic(r);
643
658
  const a = r.filter(([o]) => o === pt).reduce((o, [, l]) => o + l.length, 0);
644
659
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
@@ -647,7 +662,7 @@ function ua(e, t) {
647
662
  for (const [o, l] of r)
648
663
  if (o === pt)
649
664
  s += l.length;
650
- else if (o === sa) {
665
+ else if (o === oa) {
651
666
  const c = s + l.length;
652
667
  i.push(
653
668
  ae.inline(s, c, {
@@ -655,7 +670,7 @@ function ua(e, t) {
655
670
  "data-patch-id": t.id
656
671
  })
657
672
  ), s = c;
658
- } else o === oa && i.push(
673
+ } else o === ca && i.push(
659
674
  ae.widget(s, () => {
660
675
  const c = document.createElement("span");
661
676
  return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
@@ -663,7 +678,7 @@ function ua(e, t) {
663
678
  );
664
679
  return i;
665
680
  }
666
- function ma(e = "default") {
681
+ function ga(e = "default") {
667
682
  return new Be({
668
683
  key: jt,
669
684
  props: {
@@ -673,14 +688,14 @@ function ma(e = "default") {
673
688
  const r = [];
674
689
  for (const a of n) {
675
690
  if (a.type === "replace") {
676
- const i = ua(t.doc, a);
691
+ const i = ma(t.doc, a);
677
692
  if (i) {
678
693
  r.push(...i);
679
694
  continue;
680
695
  }
681
696
  }
682
697
  if (a.type === "delete" || a.type === "replace") {
683
- const i = da(t.doc, a.from, a.to);
698
+ const i = ua(t.doc, a.from, a.to);
684
699
  for (const s of i)
685
700
  r.push(
686
701
  ae.inline(s.from, s.to, {
@@ -726,7 +741,7 @@ function Jt(e, t) {
726
741
  );
727
742
  });
728
743
  }
729
- const ga = Q.create({
744
+ const fa = Q.create({
730
745
  name: "hardBreak",
731
746
  inline: !0,
732
747
  group: "inline",
@@ -747,7 +762,7 @@ const ga = Q.create({
747
762
  }
748
763
  };
749
764
  }
750
- }), fa = Oe.create({
765
+ }), pa = Oe.create({
751
766
  name: "dragDropUX",
752
767
  addProseMirrorPlugins() {
753
768
  return [
@@ -758,19 +773,19 @@ const ga = Q.create({
758
773
  Xn()
759
774
  ];
760
775
  }
761
- }), pa = Oe.create({
776
+ }), ha = Oe.create({
762
777
  name: "patchDiff",
763
778
  addOptions() {
764
779
  return { editorId: "default" };
765
780
  },
766
781
  addProseMirrorPlugins() {
767
- return [ma(this.options.editorId)];
782
+ return [ga(this.options.editorId)];
768
783
  }
769
- }), ha = [
784
+ }), ya = [
770
785
  An,
771
786
  Pn,
772
787
  Ln,
773
- fa,
788
+ pa,
774
789
  Dn.configure({
775
790
  levels: [1, 2, 3, 4, 5, 6]
776
791
  }),
@@ -779,7 +794,7 @@ const ga = Q.create({
779
794
  Fn,
780
795
  $n,
781
796
  zn,
782
- ga,
797
+ fa,
783
798
  On,
784
799
  Bn,
785
800
  Hn.configure({ nested: !0 }),
@@ -817,7 +832,7 @@ const ga = Q.create({
817
832
  types: ["heading", "paragraph"],
818
833
  defaultAlignment: "left"
819
834
  })
820
- ], ya = [
835
+ ], ba = [
821
836
  nr,
822
837
  rr,
823
838
  ar,
@@ -831,11 +846,11 @@ const ga = Q.create({
831
846
  dr,
832
847
  ur,
833
848
  mr.configure({ multicolor: !0 })
834
- ], ba = [
835
- ...ha,
836
- ...ya
849
+ ], va = [
850
+ ...ya,
851
+ ...ba
837
852
  ];
838
- class va {
853
+ class wa {
839
854
  constructor() {
840
855
  Se(this, "commands", /* @__PURE__ */ new Map());
841
856
  }
@@ -901,8 +916,8 @@ class va {
901
916
  return Array.from(this.commands.keys()).sort();
902
917
  }
903
918
  }
904
- const le = new va();
905
- class wa {
919
+ const le = new wa();
920
+ class xa {
906
921
  constructor() {
907
922
  Se(this, "plugins", /* @__PURE__ */ new Map());
908
923
  Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
@@ -987,7 +1002,7 @@ class wa {
987
1002
  });
988
1003
  }
989
1004
  }
990
- const B = new wa(), yt = {
1005
+ const B = new xa(), yt = {
991
1006
  zh: {
992
1007
  language: "语言",
993
1008
  bold: "加粗",
@@ -1240,7 +1255,7 @@ const Ie = () => {
1240
1255
  document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1241
1256
  (e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
1242
1257
  }), 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());
1243
- }, xa = Q.create({
1258
+ }, Ca = Q.create({
1244
1259
  name: "mermaid",
1245
1260
  group: "block",
1246
1261
  atom: !0,
@@ -1354,10 +1369,10 @@ const Ie = () => {
1354
1369
  };
1355
1370
  };
1356
1371
  }
1357
- }), Ca = {
1372
+ }), Ta = {
1358
1373
  name: "mermaid",
1359
1374
  version: "1.0.0",
1360
- extensions: [xa],
1375
+ extensions: [Ca],
1361
1376
  toolbarItems: [
1362
1377
  {
1363
1378
  id: "mermaid-insert",
@@ -1382,7 +1397,7 @@ const Ie = () => {
1382
1397
  }
1383
1398
  }
1384
1399
  }
1385
- }, Ve = "https://draw.goatpatent.com", Ta = Q.create({
1400
+ }, Ve = "https://draw.goatpatent.com", Sa = Q.create({
1386
1401
  name: "drawio",
1387
1402
  group: "block",
1388
1403
  atom: !0,
@@ -1478,10 +1493,10 @@ const Ie = () => {
1478
1493
  };
1479
1494
  };
1480
1495
  }
1481
- }), Sa = {
1496
+ }), Ea = {
1482
1497
  name: "drawio",
1483
1498
  version: "1.0.0",
1484
- extensions: [Ta],
1499
+ extensions: [Sa],
1485
1500
  toolbarItems: [
1486
1501
  {
1487
1502
  id: "drawio-insert",
@@ -1584,7 +1599,7 @@ const Ie = () => {
1584
1599
  ] })
1585
1600
  }
1586
1601
  );
1587
- }, Ea = Q.create({
1602
+ }, ka = Q.create({
1588
1603
  name: "math_inline",
1589
1604
  group: "inline",
1590
1605
  inline: !0,
@@ -1617,7 +1632,7 @@ const Ie = () => {
1617
1632
  }
1618
1633
  });
1619
1634
  }
1620
- }), ka = Q.create({
1635
+ }), _a = Q.create({
1621
1636
  name: "math_block",
1622
1637
  group: "block",
1623
1638
  atom: !0,
@@ -1640,10 +1655,10 @@ const Ie = () => {
1640
1655
  }
1641
1656
  });
1642
1657
  }
1643
- }), _a = {
1658
+ }), Ia = {
1644
1659
  name: "math",
1645
1660
  version: "1.0.0",
1646
- extensions: [Ea, ka],
1661
+ extensions: [ka, _a],
1647
1662
  toolbarItems: [
1648
1663
  {
1649
1664
  id: "math-inline-insert",
@@ -1706,7 +1721,7 @@ const Ie = () => {
1706
1721
  };
1707
1722
  }
1708
1723
  return null;
1709
- }, Ia = (e) => {
1724
+ }, Na = (e) => {
1710
1725
  const { $from: t } = e.state.selection;
1711
1726
  for (let n = t.depth; n >= 0; n -= 1) {
1712
1727
  const r = t.node(n);
@@ -1717,7 +1732,7 @@ const Ie = () => {
1717
1732
  };
1718
1733
  }
1719
1734
  return null;
1720
- }, Na = (e, t) => e.state.schema.nodes[t] || null, Aa = (e) => {
1735
+ }, Aa = (e, t) => e.state.schema.nodes[t] || null, Pa = (e) => {
1721
1736
  const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
1722
1737
  return {
1723
1738
  type: e.type,
@@ -1725,7 +1740,7 @@ const Ie = () => {
1725
1740
  content: t
1726
1741
  };
1727
1742
  }, Yt = (e, t) => {
1728
- const n = Aa(t);
1743
+ const n = Pa(t);
1729
1744
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1730
1745
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1731
1746
  var l;
@@ -1745,7 +1760,7 @@ const Ie = () => {
1745
1760
  const s = r.doc.nodeAt(i);
1746
1761
  return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
1747
1762
  }), Qt = (e, t) => {
1748
- const n = Na(e, t.type);
1763
+ const n = Aa(e, t.type);
1749
1764
  return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
1750
1765
  const { from: s, to: o } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1751
1766
  if (!l)
@@ -1753,7 +1768,7 @@ const Ie = () => {
1753
1768
  const c = fr(l, n, t.attrs);
1754
1769
  return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
1755
1770
  }) : !1;
1756
- }, Pa = (e, t) => {
1771
+ }, La = (e, t) => {
1757
1772
  if (t.length === 0)
1758
1773
  return !1;
1759
1774
  const n = e.getJSON();
@@ -1765,13 +1780,13 @@ const Ie = () => {
1765
1780
  let Ne = 0;
1766
1781
  const Qe = [];
1767
1782
  let Ae = !1;
1768
- const La = 2e4, bt = 6e4;
1783
+ const Da = 2e4, bt = 6e4;
1769
1784
  let $ = null, Me = !1, re = null, he = null;
1770
1785
  const et = /* @__PURE__ */ new Map();
1771
1786
  function vt() {
1772
1787
  re && (window.removeEventListener("message", re), re = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1773
1788
  }
1774
- function Da(e, t) {
1789
+ function Ra(e, t) {
1775
1790
  const n = et.get(e);
1776
1791
  if (n) {
1777
1792
  t(n);
@@ -1813,13 +1828,13 @@ function tt() {
1813
1828
  ue
1814
1829
  );
1815
1830
  }, 1500) : o.event === "export" && a(o.data || "");
1816
- }, window.addEventListener("message", re), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
1831
+ }, window.addEventListener("message", re), r = setTimeout(() => a(""), Da), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
1817
1832
  }
1818
1833
  const Pe = () => {
1819
1834
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1820
1835
  (e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
1821
1836
  }), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
1822
- }, Ra = Q.create({
1837
+ }, Ma = Q.create({
1823
1838
  name: "figure",
1824
1839
  group: "block",
1825
1840
  content: "inline*",
@@ -2031,7 +2046,7 @@ const Pe = () => {
2031
2046
  q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2032
2047
  se = null;
2033
2048
  const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2034
- !dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
2049
+ !dt || Tn || xe || (xe = !0, Ra(dt, (ut) => {
2035
2050
  xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, ge = setTimeout(() => {
2036
2051
  ge = null, K();
2037
2052
  }, vn * Ce));
@@ -2060,7 +2075,7 @@ const Pe = () => {
2060
2075
  };
2061
2076
  };
2062
2077
  }
2063
- }), Ma = Q.create({
2078
+ }), Fa = Q.create({
2064
2079
  name: "reference",
2065
2080
  group: "inline",
2066
2081
  inline: !0,
@@ -2161,7 +2176,7 @@ const Pe = () => {
2161
2176
  design_description: "sectionTitle_design_description",
2162
2177
  design_views: "sectionTitle_design_views",
2163
2178
  design_brief: "sectionTitle_design_brief"
2164
- }, Fa = /* @__PURE__ */ new Set([
2179
+ }, $a = /* @__PURE__ */ new Set([
2165
2180
  "abstract",
2166
2181
  "abstract_drawing",
2167
2182
  "claims",
@@ -2172,7 +2187,7 @@ const Pe = () => {
2172
2187
  "design_description",
2173
2188
  "design_views",
2174
2189
  "design_brief"
2175
- ]), $a = /* @__PURE__ */ new Set([
2190
+ ]), za = /* @__PURE__ */ new Set([
2176
2191
  "technical_field",
2177
2192
  "background_art",
2178
2193
  "summary",
@@ -2187,7 +2202,7 @@ const Pe = () => {
2187
2202
  return e.forEach((n) => {
2188
2203
  !t && ot(n) && (t = !0);
2189
2204
  }), t;
2190
- }, za = Q.create({
2205
+ }, Oa = Q.create({
2191
2206
  name: "patent_title",
2192
2207
  group: "block",
2193
2208
  content: "inline*",
@@ -2250,7 +2265,7 @@ const Pe = () => {
2250
2265
  };
2251
2266
  };
2252
2267
  }
2253
- }), Oa = Q.create({
2268
+ }), Ba = Q.create({
2254
2269
  name: "patent_section",
2255
2270
  group: "block",
2256
2271
  content: "block+",
@@ -2335,7 +2350,7 @@ const Pe = () => {
2335
2350
  };
2336
2351
  o.addEventListener("click", m), l.addEventListener("focusin", d), l.addEventListener("click", d);
2337
2352
  const g = () => {
2338
- const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Fa.has(T), x = $a.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
2353
+ const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = $a.has(T), x = za.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
2339
2354
  a.className = `ps${u ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = A, o.textContent = `[${A}]`, o.style.display = u ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !u), l.classList.toggle("ps-content--has-content", u);
2340
2355
  };
2341
2356
  let h = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
@@ -2353,21 +2368,21 @@ const Pe = () => {
2353
2368
  };
2354
2369
  };
2355
2370
  }
2356
- }), Ba = [
2371
+ }), Ha = [
2357
2372
  "abstract",
2358
2373
  // 说明书摘要
2359
2374
  "abstract_drawing"
2360
2375
  // 摘要附图
2361
- ], Ha = [
2376
+ ], Ua = [
2362
2377
  "technical_field",
2363
2378
  "background_art",
2364
2379
  "summary",
2365
2380
  "drawing_description",
2366
2381
  "detailed_description"
2367
- ], Ua = [
2382
+ ], qa = [
2368
2383
  "drawing_figures"
2369
2384
  // 说明书附图
2370
- ], qa = [
2385
+ ], Wa = [
2371
2386
  "design_product_name",
2372
2387
  "design_usage",
2373
2388
  "design_description",
@@ -2387,15 +2402,15 @@ const Pe = () => {
2387
2402
  }), en = () => ({
2388
2403
  type: "patent_title",
2389
2404
  content: []
2390
- }), Wa = () => [
2391
- ...Ba.map(Fe),
2392
- en(),
2405
+ }), ja = () => [
2393
2406
  ...Ha.map(Fe),
2394
- ...Ua.map(Fe)
2395
- ], ja = () => [
2396
2407
  en(),
2408
+ ...Ua.map(Fe),
2397
2409
  ...qa.map(Fe)
2398
- ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2410
+ ], Ga = () => [
2411
+ en(),
2412
+ ...Wa.map(Fe)
2413
+ ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Ga() : ja() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2399
2414
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2400
2415
  ve(e).forEach((i) => {
2401
2416
  const s = J(i.node.attrs.id);
@@ -2405,14 +2420,14 @@ const Pe = () => {
2405
2420
  for (; r.has(`${n}${a}`); )
2406
2421
  a += 1;
2407
2422
  return `${n}${a}`;
2408
- }, Ga = /^(Fig\.|图)(\d+)$/, Va = (e) => {
2423
+ }, Va = /^(Fig\.|图)(\d+)$/, Ja = (e) => {
2409
2424
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2410
2425
  if (r.length === 0) return;
2411
2426
  const a = [];
2412
2427
  let i = 1;
2413
2428
  for (const o of r) {
2414
2429
  const l = J(o.node.attrs.id);
2415
- if (!Ga.exec(l)) continue;
2430
+ if (!Va.exec(l)) continue;
2416
2431
  const d = `${n}${i}`;
2417
2432
  l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
2418
2433
  }
@@ -2457,10 +2472,10 @@ const Pe = () => {
2457
2472
  ) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
2458
2473
  }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2459
2474
  });
2460
- }, Ja = {
2475
+ }, Ka = {
2461
2476
  name: "patent",
2462
2477
  version: "1.0.0",
2463
- extensions: [Ra, Ma, za, Oa],
2478
+ extensions: [Ma, Fa, Oa, Ba],
2464
2479
  toolbarItems: [
2465
2480
  {
2466
2481
  id: "patent-figure-insert",
@@ -2606,13 +2621,13 @@ const Pe = () => {
2606
2621
  }
2607
2622
  },
2608
2623
  onStateChange: (e) => {
2609
- e.isDestroyed || (Va(e), Je(e));
2624
+ e.isDestroyed || (Ja(e), Je(e));
2610
2625
  }
2611
- }, Ka = [Ca, Sa, _a, Ja];
2612
- Ka.forEach((e) => B.register(e));
2613
- const Xa = (e = {}) => {
2626
+ }, Xa = [Ta, Ea, Ia, Ka];
2627
+ Xa.forEach((e) => B.register(e));
2628
+ const Ya = (e = {}) => {
2614
2629
  const t = [
2615
- ...ba,
2630
+ ...va,
2616
2631
  ...B.getExtensions(),
2617
2632
  ...e.extensions || []
2618
2633
  ];
@@ -2636,12 +2651,12 @@ const Xa = (e = {}) => {
2636
2651
  updateNodeAttrs: (t) => ze(e, t),
2637
2652
  removeNode: (t) => Zt(e, t),
2638
2653
  wrapSelection: (t) => Qt(e, t),
2639
- applyTransactionBatch: (t) => Pa(e, t),
2654
+ applyTransactionBatch: (t) => La(e, t),
2640
2655
  findNodeByType: (t, n) => st(e, t, n),
2641
2656
  findAncestorNode: (t) => Re(e, t),
2642
- findCurrentBlock: () => Ia(e),
2657
+ findCurrentBlock: () => Na(e),
2643
2658
  findNodesByPredicate: (t, n) => Xt(e, t, n)
2644
- }), Ya = ["history", "text", "structure", "format", "technical", "patent"], Za = {
2659
+ }), Za = ["history", "text", "structure", "format", "technical", "patent"], Qa = {
2645
2660
  history: "groupHistory",
2646
2661
  text: "groupText",
2647
2662
  structure: "groupStructure",
@@ -2650,7 +2665,7 @@ const Xa = (e = {}) => {
2650
2665
  patent: "groupPatent"
2651
2666
  }, Xe = (e, t) => {
2652
2667
  if (t) {
2653
- const n = Za[e];
2668
+ const n = Qa[e];
2654
2669
  if (n && typeof t[n] == "string") return t[n];
2655
2670
  }
2656
2671
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
@@ -2722,9 +2737,9 @@ const Xa = (e = {}) => {
2722
2737
  document.body
2723
2738
  )
2724
2739
  ] });
2725
- }, Qa = ({
2740
+ }, ei = ({
2726
2741
  editor: e,
2727
- groupOrder: t = Ya,
2742
+ groupOrder: t = Za,
2728
2743
  collapsibleGroups: n = !0,
2729
2744
  defaultCollapsedGroups: r = []
2730
2745
  }) => {
@@ -3124,7 +3139,7 @@ const Xa = (e = {}) => {
3124
3139
  ] }, u.group);
3125
3140
  })
3126
3141
  ] }) });
3127
- }, ei = ({ editor: e }) => {
3142
+ }, ti = ({ editor: e }) => {
3128
3143
  const [t, n] = M(0), [r, a] = M(""), i = I((x) => x.editorLanguage), s = H(i);
3129
3144
  if (F(() => {
3130
3145
  if (!e) return;
@@ -3254,10 +3269,10 @@ const Xa = (e = {}) => {
3254
3269
  design_views: ["design_description"],
3255
3270
  design_brief: ["design_description", "design_views"]
3256
3271
  };
3257
- function qs(e, t) {
3272
+ function Ws(e, t) {
3258
3273
  return (sn[e] || []).filter((r) => !t.has(r));
3259
3274
  }
3260
- function ti(e) {
3275
+ function ni(e) {
3261
3276
  const t = [];
3262
3277
  return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
3263
3278
  sectionType: "patent_title",
@@ -3288,10 +3303,10 @@ function on(e) {
3288
3303
  }
3289
3304
  return null;
3290
3305
  }
3291
- function ni(e, t) {
3306
+ function ri(e, t) {
3292
3307
  const n = sn[t];
3293
3308
  if (!n || n.length === 0) return [];
3294
- const r = ti(e), a = new Map(r.map((i) => [i.sectionType, i]));
3309
+ const r = ni(e), a = new Map(r.map((i) => [i.sectionType, i]));
3295
3310
  return n.map((i) => {
3296
3311
  const s = a.get(i);
3297
3312
  return !s || s.content.trim().length === 0 ? null : {
@@ -3300,14 +3315,14 @@ function ni(e, t) {
3300
3315
  };
3301
3316
  }).filter((i) => i !== null && i.content.length > 0);
3302
3317
  }
3303
- function Ws(e, t = {}) {
3318
+ function js(e, t = {}) {
3304
3319
  const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3305
3320
  let s = t.sectionType, o = t.targetSectionPos;
3306
3321
  if (!s) {
3307
3322
  const m = on(e);
3308
3323
  m && (s = m.sectionType, o = m.pos);
3309
3324
  }
3310
- const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
3325
+ const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ri(e, s) : void 0;
3311
3326
  let d;
3312
3327
  if (l === "selection" && r !== a) {
3313
3328
  const g = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(g, r, " ", "\0"), b = e.state.doc.textBetween(a, h, " ", "\0");
@@ -3324,7 +3339,7 @@ function Ws(e, t = {}) {
3324
3339
  language: n
3325
3340
  };
3326
3341
  }
3327
- const ri = ({ editor: e, onSelectionOptimize: t }) => {
3342
+ const ai = ({ editor: e, onSelectionOptimize: t }) => {
3328
3343
  const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Z(
3329
3344
  "p-1.5 rounded transition-colors",
3330
3345
  c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
@@ -3445,7 +3460,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3445
3460
  ] })
3446
3461
  }
3447
3462
  );
3448
- }, ai = ({ editor: e }) => {
3463
+ }, ii = ({ editor: e }) => {
3449
3464
  var A;
3450
3465
  const [t, n] = M(!1), [r, a] = M(!1), [i, s] = M(""), [o, l] = M(""), [c, d] = M(!1), [, m] = M(0), g = j(() => m((u) => u + 1), []), h = W(null), p = e.extensionStorage.searchReplace, b = ((A = p == null ? void 0 : p.results) == null ? void 0 : A.length) ?? 0, y = (p == null ? void 0 : p.currentIndex) ?? -1, w = j(() => {
3451
3466
  e.commands.nextSearchResult(), g();
@@ -3562,7 +3577,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3562
3577
  )
3563
3578
  ] })
3564
3579
  ] }) : null;
3565
- }, ii = ({ editor: e }) => {
3580
+ }, si = ({ editor: e }) => {
3566
3581
  const { editorLanguage: t } = I(), n = t === "zh", r = At(() => {
3567
3582
  const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: l } = a.selection;
3568
3583
  let c = 0;
@@ -3580,19 +3595,19 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3580
3595
  r.selectionCount
3581
3596
  ] })
3582
3597
  ] });
3583
- }, si = {
3598
+ }, oi = {
3584
3599
  empty: "○",
3585
3600
  filled: "●"
3586
- }, oi = {
3601
+ }, ci = {
3587
3602
  empty: "text-gray-400",
3588
3603
  filled: "text-green-500"
3589
- }, ci = /* @__PURE__ */ new Set([
3604
+ }, li = /* @__PURE__ */ new Set([
3590
3605
  "technical_field",
3591
3606
  "background_art",
3592
3607
  "summary",
3593
3608
  "drawing_description",
3594
3609
  "detailed_description"
3595
- ]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
3610
+ ]), di = ({ editor: e, defaultCollapsed: t = !1 }) => {
3596
3611
  const { editorLanguage: n } = I(), r = H(n), [a, i] = M(t), [s, o] = M(0);
3597
3612
  F(() => {
3598
3613
  const c = () => o((d) => d + 1);
@@ -3625,7 +3640,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3625
3640
  }), !1;
3626
3641
  }
3627
3642
  if (m.type.name === "patent_section") {
3628
- const h = m.attrs.sectionType, p = ci.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
3643
+ const h = m.attrs.sectionType, p = li.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
3629
3644
  return c.push({
3630
3645
  type: "section",
3631
3646
  pos: g,
@@ -3688,7 +3703,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3688
3703
  }));
3689
3704
  },
3690
3705
  children: [
3691
- c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
3706
+ c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", ci[c.state]), children: oi[c.state] || "○" }),
3692
3707
  /* @__PURE__ */ f("span", { className: "outline-item-title", children: c.title }),
3693
3708
  c.type !== "book-group" && /* @__PURE__ */ f("span", { className: "outline-item-count", children: c.charCount })
3694
3709
  ]
@@ -3697,7 +3712,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3697
3712
  ))
3698
3713
  ] })
3699
3714
  ] });
3700
- }, di = ({
3715
+ }, ui = ({
3701
3716
  editor: e,
3702
3717
  mode: t = "edit",
3703
3718
  className: n
@@ -3713,14 +3728,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3713
3728
  ),
3714
3729
  children: /* @__PURE__ */ f(In, { editor: e, className: "h-full" })
3715
3730
  }
3716
- )), cn = "patent-editor-draft", ui = 1500, mi = () => {
3731
+ )), cn = "patent-editor-draft", mi = 1500, gi = () => {
3717
3732
  try {
3718
3733
  const e = localStorage.getItem(cn);
3719
3734
  return e ? JSON.parse(e) : null;
3720
3735
  } catch {
3721
3736
  return null;
3722
3737
  }
3723
- }, gi = ({
3738
+ }, fi = ({
3724
3739
  initialContent: e,
3725
3740
  onChange: t,
3726
3741
  className: n,
@@ -3731,7 +3746,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3731
3746
  patchEditorId: o = "default",
3732
3747
  defaultOutlineCollapsed: l = !1
3733
3748
  }) => {
3734
- const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
3749
+ const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : gi()) || {
3735
3750
  type: "doc",
3736
3751
  content: [
3737
3752
  {
@@ -3746,14 +3761,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3746
3761
  p("error");
3747
3762
  }
3748
3763
  }, [p, b]), C = Nn(
3749
- Xa({
3750
- extensions: [pa.configure({ editorId: o })],
3764
+ Ya({
3765
+ extensions: [ha.configure({ editorId: o })],
3751
3766
  content: w,
3752
3767
  onUpdate: ({ editor: u }) => {
3753
3768
  const v = u.getJSON();
3754
3769
  d(v), B.notifyStateChange(u), t && t(v), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3755
3770
  T(v);
3756
- }, ui));
3771
+ }, mi));
3757
3772
  },
3758
3773
  onCreate: ({ editor: u }) => {
3759
3774
  c(u), i == null || i(u), B.initializePlugins(u), B.notifyStateChange(u);
@@ -3785,23 +3800,23 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3785
3800
  const S = H(m), A = g === "saving" ? S.autoSaveSaving : g === "saved" ? S.autoSaveSaved : g === "error" ? S.autoSaveError : "";
3786
3801
  return /* @__PURE__ */ P("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3787
3802
  !r && /* @__PURE__ */ P("div", { className: "flex items-center", children: [
3788
- /* @__PURE__ */ f(Qa, { editor: C }),
3803
+ /* @__PURE__ */ f(ei, { editor: C }),
3789
3804
  A && /* @__PURE__ */ f("span", { className: `auto-save-indicator auto-save-indicator--${g} ml-2`, children: A })
3790
3805
  ] }),
3791
- !r && C && /* @__PURE__ */ f(ei, { editor: C }),
3792
- !r && C && /* @__PURE__ */ f(ri, { editor: C, onSelectionOptimize: s }),
3793
- !r && C && /* @__PURE__ */ f(ai, { editor: C }),
3806
+ !r && C && /* @__PURE__ */ f(ti, { editor: C }),
3807
+ !r && C && /* @__PURE__ */ f(ai, { editor: C, onSelectionOptimize: s }),
3808
+ !r && C && /* @__PURE__ */ f(ii, { editor: C }),
3794
3809
  /* @__PURE__ */ P("div", { className: "flex flex-1 overflow-hidden", children: [
3795
- !r && C && /* @__PURE__ */ f(li, { editor: C, defaultCollapsed: l }),
3810
+ !r && C && /* @__PURE__ */ f(di, { editor: C, defaultCollapsed: l }),
3796
3811
  /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ f(
3797
- di,
3812
+ ui,
3798
3813
  {
3799
3814
  editor: C,
3800
3815
  mode: r || !a || h.status === "streaming" && h.activeSectionType === "claims" ? "readonly" : "edit"
3801
3816
  }
3802
3817
  ) })
3803
3818
  ] }),
3804
- !r && /* @__PURE__ */ f(ii, { editor: C })
3819
+ !r && /* @__PURE__ */ f(si, { editor: C })
3805
3820
  ] });
3806
3821
  };
3807
3822
  function ln(e) {
@@ -3856,7 +3871,7 @@ function ln(e) {
3856
3871
  }
3857
3872
  });
3858
3873
  }
3859
- function fi(e, t) {
3874
+ function pi(e, t) {
3860
3875
  let n = null;
3861
3876
  return {
3862
3877
  async request(r) {
@@ -3878,7 +3893,7 @@ function fi(e, t) {
3878
3893
  }
3879
3894
  };
3880
3895
  }
3881
- function pi(e, t) {
3896
+ function hi(e, t) {
3882
3897
  let n = null;
3883
3898
  const r = e.replace(/\/+$/, "");
3884
3899
  async function a(i, s) {
@@ -3932,7 +3947,7 @@ function pi(e, t) {
3932
3947
  }
3933
3948
  };
3934
3949
  }
3935
- const hi = It(
3950
+ const yi = It(
3936
3951
  ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: m, patchEditorId: g, defaultOutlineCollapsed: h }, p) => {
3937
3952
  const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), C = j((S) => {
3938
3953
  T.current = S;
@@ -3943,9 +3958,9 @@ const hi = It(
3943
3958
  return Ee.useEffect(() => {
3944
3959
  s && b(s);
3945
3960
  }, [s, b]), Ee.useEffect(() => {
3946
- o ? y(o) : c && y(fi(c, d));
3961
+ o ? y(o) : c && y(pi(c, d));
3947
3962
  }, [o, c, d, y]), Ee.useEffect(() => {
3948
- l ? w(l) : c && w(pi(c, d));
3963
+ l ? w(l) : c && w(hi(c, d));
3949
3964
  }, [l, c, d, w]), Nt(p, () => ({
3950
3965
  getContent: () => {
3951
3966
  var S;
@@ -3962,7 +3977,7 @@ const hi = It(
3962
3977
  (S = T.current) == null || S.commands.focus();
3963
3978
  }
3964
3979
  })), /* @__PURE__ */ f(
3965
- gi,
3980
+ fi,
3966
3981
  {
3967
3982
  initialContent: x,
3968
3983
  onChange: n,
@@ -3977,8 +3992,8 @@ const hi = It(
3977
3992
  );
3978
3993
  }
3979
3994
  );
3980
- hi.displayName = "PatentEditor";
3981
- async function js(e, t, n) {
3995
+ yi.displayName = "PatentEditor";
3996
+ async function Gs(e, t, n) {
3982
3997
  var a, i, s, o;
3983
3998
  let r = !1;
3984
3999
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
@@ -3997,7 +4012,7 @@ async function js(e, t, n) {
3997
4012
  (o = n.onError) == null || o.call(n, l instanceof Error ? l : new Error(String(l)));
3998
4013
  }
3999
4014
  }
4000
- async function Gs(e, t, n, r) {
4015
+ async function Vs(e, t, n, r) {
4001
4016
  var i, s, o, l, c, d, m, g;
4002
4017
  const a = new AbortController();
4003
4018
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
@@ -4227,7 +4242,7 @@ function rt(e, t = 30) {
4227
4242
  }
4228
4243
  });
4229
4244
  }
4230
- function yi(e) {
4245
+ function bi(e) {
4231
4246
  const t = [], n = $e(e, 3);
4232
4247
  for (const r of n)
4233
4248
  t.push({ type: "delta", content: r });
@@ -4239,7 +4254,7 @@ function $e(e, t) {
4239
4254
  n.push(e.slice(r, r + t));
4240
4255
  return n;
4241
4256
  }
4242
- function bi(e, t, n) {
4257
+ function vi(e, t, n) {
4243
4258
  const r = n === "zh", a = [];
4244
4259
  let i;
4245
4260
  if (e.includes("技术方案") || e.includes("draft") ? i = Le["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Le.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Le.claims[r ? "zh" : "en"] : i = Le.default[r ? "zh" : "en"], t.length > 0) {
@@ -4287,7 +4302,7 @@ function bi(e, t, n) {
4287
4302
  a.push({ type: "delta", content: s });
4288
4303
  return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
4289
4304
  }
4290
- function Vs() {
4305
+ function Js() {
4291
4306
  let e = null;
4292
4307
  return {
4293
4308
  async request(t) {
@@ -4301,7 +4316,7 @@ function Vs() {
4301
4316
  ` : `[Generated based on instruction "${t.instruction}"]
4302
4317
 
4303
4318
  `) + a);
4304
- const s = yi(i);
4319
+ const s = bi(i);
4305
4320
  return rt(s, 25);
4306
4321
  },
4307
4322
  abort() {
@@ -4309,7 +4324,7 @@ function Vs() {
4309
4324
  }
4310
4325
  };
4311
4326
  }
4312
- function Js() {
4327
+ function Ks() {
4313
4328
  const e = /* @__PURE__ */ new Map();
4314
4329
  let t = null, n = null;
4315
4330
  return {
@@ -4352,7 +4367,7 @@ function Js() {
4352
4367
  status: "done",
4353
4368
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4354
4369
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4355
- const o = bi(
4370
+ const o = vi(
4356
4371
  a.content,
4357
4372
  a.references || [],
4358
4373
  a.language
@@ -4384,7 +4399,7 @@ function Js() {
4384
4399
  }
4385
4400
  };
4386
4401
  }
4387
- function vi(e) {
4402
+ function wi(e) {
4388
4403
  const t = [], n = e.replace(/\r\n/g, `
4389
4404
  `).trim();
4390
4405
  if (!n) return t;
@@ -4399,12 +4414,12 @@ function vi(e) {
4399
4414
  if (a.length === 0)
4400
4415
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4401
4416
  for (let s = 0; s < a.length; s++) {
4402
- const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = wi(c, d);
4417
+ const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = xi(c, d);
4403
4418
  t.push({ number: d, text: c, dependsOn: m });
4404
4419
  }
4405
4420
  return t;
4406
4421
  }
4407
- function wi(e, t) {
4422
+ function xi(e, t) {
4408
4423
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4409
4424
  let a;
4410
4425
  for (; (a = r.exec(e)) !== null; ) {
@@ -4420,18 +4435,18 @@ function wi(e, t) {
4420
4435
  }
4421
4436
  return [...new Set(n)].sort((s, o) => s - o);
4422
4437
  }
4423
- function Ks(e) {
4424
- return vi(e).map((n) => ({
4438
+ function Xs(e) {
4439
+ return wi(e).map((n) => ({
4425
4440
  type: "paragraph",
4426
4441
  content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
4427
4442
  }));
4428
4443
  }
4429
- const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
4444
+ const Ci = -1, Ti = 1, Si = 0, at = new we("docDiff");
4430
4445
  let Ye = null;
4431
- function Si() {
4446
+ function Ei() {
4432
4447
  return Ye || (Ye = new Lt()), Ye;
4433
4448
  }
4434
- function Ei(e, t, n) {
4449
+ function ki(e, t, n) {
4435
4450
  const r = [];
4436
4451
  return e.nodesBetween(t, n, (a, i) => {
4437
4452
  if (a.isTextblock) {
@@ -4441,15 +4456,15 @@ function Ei(e, t, n) {
4441
4456
  return !0;
4442
4457
  }), r;
4443
4458
  }
4444
- function Xs(e, t) {
4445
- const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Si(), o = s.diff_main(t, a);
4459
+ function Ys(e, t) {
4460
+ const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ei(), o = s.diff_main(t, a);
4446
4461
  s.diff_cleanupSemantic(o);
4447
4462
  const l = [];
4448
4463
  let c = 0;
4449
4464
  for (const [g, h] of o)
4450
- if (g === Ti)
4465
+ if (g === Si)
4451
4466
  c += h.length;
4452
- else if (g === Ci) {
4467
+ else if (g === Ti) {
4453
4468
  let p = 0;
4454
4469
  for (; p < h.length; ) {
4455
4470
  for (; p < h.length && h[p] === "\0"; ) p++;
@@ -4458,13 +4473,13 @@ function Xs(e, t) {
4458
4473
  for (; p < h.length && h[p] !== "\0"; ) p++;
4459
4474
  const y = be(i, c + b), w = be(i, c + p);
4460
4475
  if (y >= 0 && w >= 0 && w > y)
4461
- for (const T of Ei(n, y, w))
4476
+ for (const T of ki(n, y, w))
4462
4477
  l.push(
4463
4478
  ae.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4464
4479
  );
4465
4480
  }
4466
4481
  c += h.length;
4467
- } else if (g === xi) {
4482
+ } else if (g === Ci) {
4468
4483
  const p = be(i, c);
4469
4484
  if (p >= 0) {
4470
4485
  const b = h.replace(/\0/g, " ");
@@ -4494,22 +4509,22 @@ function Xs(e, t) {
4494
4509
  });
4495
4510
  e.registerPlugin(m);
4496
4511
  }
4497
- function Ys(e) {
4512
+ function Zs(e) {
4498
4513
  e.unregisterPlugin(at);
4499
4514
  }
4500
- const ki = /* @__PURE__ */ new Set([
4515
+ const _i = /* @__PURE__ */ new Set([
4501
4516
  "abstract",
4502
4517
  "abstract_drawing",
4503
4518
  "claims",
4504
4519
  "drawing_figures"
4505
- ]), _i = /* @__PURE__ */ new Set([
4520
+ ]), Ii = /* @__PURE__ */ new Set([
4506
4521
  "technical_field",
4507
4522
  "background_art",
4508
4523
  "summary",
4509
4524
  "drawing_description",
4510
4525
  "detailed_description"
4511
4526
  ]);
4512
- function Ii(e, t) {
4527
+ function Ni(e, t) {
4513
4528
  const n = H(t), r = [];
4514
4529
  return e.state.doc.descendants((a) => {
4515
4530
  if (a.type.name === "patent_title") {
@@ -4545,7 +4560,7 @@ function Et(e) {
4545
4560
  spacing: { before: 240, after: 120 }
4546
4561
  });
4547
4562
  }
4548
- function Ni(e) {
4563
+ function Ai(e) {
4549
4564
  return new He({
4550
4565
  children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
4551
4566
  alignment: it.CENTER,
@@ -4559,11 +4574,11 @@ function Ze(e) {
4559
4574
  indent: { firstLine: ye(7) }
4560
4575
  });
4561
4576
  }
4562
- function Ai(e, t) {
4577
+ function Pi(e, t) {
4563
4578
  const n = H(t), r = [];
4564
4579
  let a = !1;
4565
4580
  for (const i of e) {
4566
- if (ki.has(i.sectionType)) {
4581
+ if (_i.has(i.sectionType)) {
4567
4582
  r.push(St(i.title));
4568
4583
  for (const s of i.paragraphs)
4569
4584
  r.push(Ze(s));
@@ -4575,10 +4590,10 @@ function Ai(e, t) {
4575
4590
  r.push(St(s)), a = !0;
4576
4591
  }
4577
4592
  for (const s of i.paragraphs)
4578
- r.push(Ni(s));
4593
+ r.push(Ai(s));
4579
4594
  continue;
4580
4595
  }
4581
- if (_i.has(i.sectionType)) {
4596
+ if (Ii.has(i.sectionType)) {
4582
4597
  r.push(Et(i.title));
4583
4598
  for (const s of i.paragraphs)
4584
4599
  r.push(Ze(s));
@@ -4590,8 +4605,8 @@ function Ai(e, t) {
4590
4605
  }
4591
4606
  return r;
4592
4607
  }
4593
- async function Zs(e, t) {
4594
- const n = Ii(e, t), r = Ai(n, t), a = n.find((c) => c.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4608
+ async function Qs(e, t) {
4609
+ const n = Ni(e, t), r = Pi(n, t), a = n.find((c) => c.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4595
4610
  properties: {
4596
4611
  page: {
4597
4612
  margin: {
@@ -4608,10 +4623,10 @@ async function Zs(e, t) {
4608
4623
  }), l = await Xr.toBlob(o);
4609
4624
  Yr(l, i);
4610
4625
  }
4611
- async function Qs(e) {
4626
+ async function eo(e) {
4612
4627
  window.print();
4613
4628
  }
4614
- function eo(e, t) {
4629
+ function to(e, t) {
4615
4630
  const n = [], r = t === "zh";
4616
4631
  let a = 0;
4617
4632
  const i = () => `v_${++a}`;
@@ -4682,8 +4697,8 @@ function eo(e, t) {
4682
4697
  return !0;
4683
4698
  }), n;
4684
4699
  }
4685
- const Pi = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4686
- function Li(e, t) {
4700
+ const Li = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4701
+ function Di(e, t) {
4687
4702
  const n = [];
4688
4703
  let r;
4689
4704
  for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
@@ -4700,7 +4715,7 @@ function Li(e, t) {
4700
4715
  }
4701
4716
  const mn = (e) => {
4702
4717
  if (e.type.name === "reference")
4703
- return Di(e);
4718
+ return Ri(e);
4704
4719
  if (e.type.name === "hardBreak")
4705
4720
  return `
4706
4721
  `;
@@ -4710,7 +4725,7 @@ const mn = (e) => {
4710
4725
  return e.forEach((n) => {
4711
4726
  t += mn(n);
4712
4727
  }), t;
4713
- }, Di = (e) => {
4728
+ }, Ri = (e) => {
4714
4729
  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() : "";
4715
4730
  if (r)
4716
4731
  return r;
@@ -4720,17 +4735,17 @@ const mn = (e) => {
4720
4735
  }
4721
4736
  const a = Number(e.attrs.resolvedNumber);
4722
4737
  return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
4723
- }, to = (e) => {
4738
+ }, no = (e) => {
4724
4739
  const t = [];
4725
4740
  return e.state.doc.descendants((n, r) => {
4726
4741
  if (n.type.name === "patent_section")
4727
4742
  return n.attrs.sectionType === "claims";
4728
4743
  if (n.type.name !== "paragraph") return !0;
4729
- const a = mn(n).trim(), i = Pi.exec(a);
4744
+ const a = mn(n).trim(), i = Li.exec(a);
4730
4745
  if (!i) return !0;
4731
4746
  const s = parseInt(i[1], 10);
4732
4747
  if (!Number.isFinite(s) || s <= 0) return !0;
4733
- const o = a.slice(i[0].length).trim(), l = Li(o, s);
4748
+ const o = a.slice(i[0].length).trim(), l = Di(o, s);
4734
4749
  return t.push({
4735
4750
  claimId: `claim_${s}`,
4736
4751
  number: s,
@@ -4742,40 +4757,40 @@ const mn = (e) => {
4742
4757
  }), t;
4743
4758
  };
4744
4759
  export {
4745
- gi as EditorView,
4760
+ fi as EditorView,
4746
4761
  jt as PatchDiffPluginKey,
4747
- hi as PatentEditor,
4748
- Hs as acceptAllPatches,
4749
- Os as acceptPatch,
4750
- Xs as applyDocDiffDecorations,
4751
- Ws as buildAIContext,
4752
- Ks as buildClaimsJSONContent,
4762
+ yi as PatentEditor,
4763
+ Us as acceptAllPatches,
4764
+ Bs as acceptPatch,
4765
+ Ys as applyDocDiffDecorations,
4766
+ js as buildAIContext,
4767
+ Xs as buildClaimsJSONContent,
4753
4768
  tn as buildPatentDocument,
4754
- zs as clearPatches,
4755
- pi as createChatSessionAPI,
4769
+ Os as clearPatches,
4770
+ hi as createChatSessionAPI,
4756
4771
  ct as createCommandExecutor,
4757
- Xa as createEditorConfig,
4758
- Vs as createMockAIService,
4759
- Js as createMockChatSessionAPI,
4760
- fi as createSSEAdapter,
4761
- Qs as exportToPdf,
4762
- Zs as exportToWord,
4763
- to as extractClaimsFromEditor,
4772
+ Ya as createEditorConfig,
4773
+ Js as createMockAIService,
4774
+ Ks as createMockChatSessionAPI,
4775
+ pi as createSSEAdapter,
4776
+ eo as exportToPdf,
4777
+ Qs as exportToWord,
4778
+ no as extractClaimsFromEditor,
4764
4779
  on as findSectionAtCursor,
4765
- ti as getAllSections,
4766
- qs as getMissingSectionDeps,
4767
- Fs as getPatches,
4768
- Ms as onPatchChange,
4780
+ ni as getAllSections,
4781
+ Ws as getMissingSectionDeps,
4782
+ $s as getPatches,
4783
+ Fs as onPatchChange,
4769
4784
  B as pluginManager,
4770
- Us as rejectAllPatches,
4771
- Bs as rejectPatch,
4772
- Ys as removeDocDiffDecorations,
4773
- Rs as resolvePatchTarget,
4785
+ qs as rejectAllPatches,
4786
+ Hs as rejectPatch,
4787
+ Zs as removeDocDiffDecorations,
4788
+ Ms as resolvePatchTarget,
4774
4789
  sn as sectionContextDeps,
4775
- $s as setPatches,
4790
+ zs as setPatches,
4776
4791
  I as useEditorStore,
4777
- eo as validatePatentDocument,
4778
- js as writeStream,
4779
- Gs as writeStreamFromSSE
4792
+ to as validatePatentDocument,
4793
+ Gs as writeStream,
4794
+ Vs as writeStreamFromSSE
4780
4795
  };
4781
4796
  //# sourceMappingURL=lib.js.map