vue3-math-editor 0.2.1 → 0.2.3

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.
@@ -1,23 +1,23 @@
1
- import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createStaticVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ee, onMounted as te, onScopeDispose as h, openBlock as g, ref as _, renderList as v, renderSlot as ne, shallowRef as re, toDisplayString as y, toRaw as b, toValue as x, unref as S, useId as C, useModel as ie, vModelSelect as w, vModelText as T, watch as ae, withCtx as E, withDirectives as D, withModifiers as O } from "vue";
2
- import oe from "katex";
3
- import k from "primevue/button";
4
- import se from "primevue/card";
5
- import ce from "primevue/menu";
6
- import le from "primevue/popover";
7
- import ue from "primevue/tab";
8
- import de from "primevue/tablist";
9
- import fe from "primevue/tabpanel";
10
- import pe from "primevue/tabpanels";
11
- import me from "primevue/tabs";
12
- import he from "primevue/tag";
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createStaticVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ee, onMounted as te, onScopeDispose as h, openBlock as g, ref as _, renderList as v, renderSlot as ne, shallowRef as re, toDisplayString as y, toRaw as b, toValue as x, unref as S, useId as C, useModel as ie, vModelSelect as ae, vModelText as w, watch as oe, withCtx as T, withDirectives as E, withModifiers as D } from "vue";
2
+ import se from "katex";
3
+ import O from "primevue/button";
4
+ import ce from "primevue/card";
5
+ import le from "primevue/menu";
6
+ import ue from "primevue/popover";
7
+ import de from "primevue/tab";
8
+ import fe from "primevue/tablist";
9
+ import pe from "primevue/tabpanel";
10
+ import me from "primevue/tabpanels";
11
+ import he from "primevue/tabs";
12
+ import ge from "primevue/tag";
13
13
  //#region src/editor/layout.ts
14
- var ge = {
14
+ var _e = {
15
15
  "(": ")",
16
16
  "|": "|",
17
17
  "⌊": "⌋",
18
18
  "⌈": "⌉"
19
19
  };
20
- function A(e) {
20
+ function k(e) {
21
21
  switch (e.kind) {
22
22
  case "fraction": return [["num", e.num], ["den", e.den]];
23
23
  case "superscript": return [["sup", e.sup]];
@@ -29,7 +29,7 @@ function A(e) {
29
29
  default: return [];
30
30
  }
31
31
  }
32
- function _e(e) {
32
+ function A(e) {
33
33
  if (e === "otherwise") return { part: "otherwise" };
34
34
  let t = /^(value|cond)(\d+)$/.exec(e);
35
35
  return t ? {
@@ -37,9 +37,9 @@ function _e(e) {
37
37
  piece: Number(t[2])
38
38
  } : null;
39
39
  }
40
- function j(e, t, n) {
40
+ function ve(e, t, n) {
41
41
  if (e.kind === "piecewise") {
42
- let r = _e(t);
42
+ let r = A(t);
43
43
  if (!r) throw Error(`No branch ${t} in a piecewise`);
44
44
  if (r.part === "otherwise") return {
45
45
  ...e,
@@ -62,93 +62,93 @@ function j(e, t, n) {
62
62
  [t]: n
63
63
  };
64
64
  }
65
- function M(e, t) {
66
- return A(e).find(([e]) => e === t)?.[1] ?? null;
65
+ function j(e, t) {
66
+ return k(e).find(([e]) => e === t)?.[1] ?? null;
67
67
  }
68
- function N(e, t) {
68
+ function M(e, t) {
69
69
  let n = e;
70
70
  for (let e of t) {
71
71
  let t = n[e.atom];
72
72
  if (!t) return null;
73
- let r = M(t, e.branch);
73
+ let r = j(t, e.branch);
74
74
  if (!r) return null;
75
75
  n = r;
76
76
  }
77
77
  return n;
78
78
  }
79
- function ve(e, t) {
79
+ function ye(e, t) {
80
80
  return e.length === t.length && e.every((e, n) => e.atom === t[n].atom && e.branch === t[n].branch);
81
81
  }
82
- var P = 0;
83
- function F() {
84
- return P += 1, `a${P}`;
82
+ var be = 0;
83
+ function N() {
84
+ return be += 1, `a${be}`;
85
85
  }
86
- function I(e) {
86
+ function P(e) {
87
87
  return {
88
88
  kind: "symbol",
89
- id: F(),
89
+ id: N(),
90
90
  value: e
91
91
  };
92
92
  }
93
- function ye(e) {
93
+ function F(e) {
94
94
  return {
95
95
  kind: "function",
96
- id: F(),
96
+ id: N(),
97
97
  name: e
98
98
  };
99
99
  }
100
- function L(e = [], t = []) {
100
+ function xe(e = [], t = []) {
101
101
  return {
102
102
  kind: "fraction",
103
- id: F(),
103
+ id: N(),
104
104
  num: e,
105
105
  den: t
106
106
  };
107
107
  }
108
- function be(e = []) {
108
+ function I(e = []) {
109
109
  return {
110
110
  kind: "superscript",
111
- id: F(),
111
+ id: N(),
112
112
  sup: e
113
113
  };
114
114
  }
115
- function xe(e = [], t = null) {
115
+ function Se(e = [], t = null) {
116
116
  return {
117
117
  kind: "root",
118
- id: F(),
118
+ id: N(),
119
119
  index: t,
120
120
  body: e
121
121
  };
122
122
  }
123
- function R(e = [], t = "(", n) {
124
- let r = n ?? ge[t] ?? t;
123
+ function L(e = [], t = "(", n) {
124
+ let r = n ?? _e[t] ?? t;
125
125
  return {
126
126
  kind: "group",
127
- id: F(),
127
+ id: N(),
128
128
  open: t,
129
129
  close: r,
130
130
  body: e
131
131
  };
132
132
  }
133
- function Se(e = [], t = []) {
133
+ function Ce(e = [], t = []) {
134
134
  return {
135
135
  kind: "derivative",
136
- id: F(),
136
+ id: N(),
137
137
  expr: e,
138
138
  variable: t
139
139
  };
140
140
  }
141
- function Ce(e = []) {
141
+ function we(e = []) {
142
142
  return {
143
143
  kind: "units",
144
- id: F(),
144
+ id: N(),
145
145
  units: e
146
146
  };
147
147
  }
148
- function we(e = [[[], []]], t = null) {
148
+ function Te(e = [[[], []]], t = null) {
149
149
  return {
150
150
  kind: "piecewise",
151
- id: F(),
151
+ id: N(),
152
152
  pieces: e.map(([e, t]) => ({
153
153
  value: e,
154
154
  condition: t
@@ -156,12 +156,12 @@ function we(e = [[[], []]], t = null) {
156
156
  otherwise: t
157
157
  };
158
158
  }
159
- function z(...e) {
160
- return e.flatMap((e) => typeof e == "string" ? Array.from(e).map((e) => I(e)) : [e]);
159
+ function R(...e) {
160
+ return e.flatMap((e) => typeof e == "string" ? Array.from(e).map((e) => P(e)) : [e]);
161
161
  }
162
162
  //#endregion
163
163
  //#region src/editor/constants.ts
164
- var Te = [
164
+ var Ee = [
165
165
  {
166
166
  symbol: "pi",
167
167
  latex: "\\pi",
@@ -212,7 +212,7 @@ var Te = [
212
212
  mathJson: "False",
213
213
  commands: ["false"]
214
214
  }
215
- ], Ee = new Map(Te.map((e) => [e.symbol, e])), De = new Map(Te.flatMap((e) => e.commands.map((t) => [t, e]))), Oe = (e) => Ee.get(e), ke = (e) => De.get(e), Ae = /* @__PURE__ */ new Map([["pi", "pi"], ["infty", "infinity"]]), je = /* @__PURE__ */ new Map([
215
+ ], De = new Map(Ee.map((e) => [e.symbol, e])), Oe = new Map(Ee.flatMap((e) => e.commands.map((t) => [t, e]))), z = (e) => De.get(e), ke = (e) => Oe.get(e), Ae = /* @__PURE__ */ new Map([["pi", "pi"], ["infty", "infinity"]]), je = /* @__PURE__ */ new Map([
216
216
  ["e", "exponentiale"],
217
217
  ["NaN", "notanumber"],
218
218
  ["true", "true"],
@@ -521,7 +521,7 @@ for (let e of Object.values(ze)) {
521
521
  function Je(e) {
522
522
  return qe.get(e);
523
523
  }
524
- var Ye = (e, t) => e?.kind === "symbol" && t.test(e.value), Xe = (e) => e?.kind === "symbol" && Ke.has(e.value) && !Oe(e.value), Ze = (e) => Ye(e, /^[A-Za-z]$/), Qe = (e) => Ze(e) || Xe(e), $e = (e) => Ye(e, /^[A-Za-z0-9_]$/) || Xe(e);
524
+ var Ye = (e, t) => e?.kind === "symbol" && t.test(e.value), Xe = (e) => e?.kind === "symbol" && Ke.has(e.value) && !z(e.value), Ze = (e) => Ye(e, /^[A-Za-z]$/), Qe = (e) => Ze(e) || Xe(e), $e = (e) => Ye(e, /^[A-Za-z0-9_]$/) || Xe(e);
525
525
  function et(e, t) {
526
526
  let n = t;
527
527
  for (; n < e.length && $e(e[n]);) {
@@ -532,7 +532,7 @@ function et(e, t) {
532
532
  return n;
533
533
  }
534
534
  function tt(e) {
535
- return Oe(e)?.symbol;
535
+ return z(e)?.symbol;
536
536
  }
537
537
  function nt(e) {
538
538
  let t = [], n = 0;
@@ -576,9 +576,9 @@ function at(e) {
576
576
  let t = e.pieces[0]?.value ?? [], n = Le(t, +(t[0]?.kind === "symbol" && t[0].value === "-")), r = t[t.length - 1];
577
577
  return !n || n.end !== t.length - 1 || r?.kind !== "units" ? null : it(r) || null;
578
578
  }
579
- var V = /* @__PURE__ */ new WeakMap(), ot = /^[A-Za-z][A-Za-z0-9_]*$/;
580
- function st(e) {
581
- let t = V.get(e);
579
+ var ot = /* @__PURE__ */ new WeakMap(), st = /^[A-Za-z][A-Za-z0-9_]*$/;
580
+ function ct(e) {
581
+ let t = ot.get(e);
582
582
  if (t) return t;
583
583
  let n = /* @__PURE__ */ new Map(), r = (e, t) => {
584
584
  let r = n.get(e);
@@ -595,12 +595,12 @@ function st(e) {
595
595
  n = o.end - 1;
596
596
  continue;
597
597
  }
598
- if (a.kind === "symbol" && ot.test(a.value) && !Oe(a.value) && r(a.value, [a.id]), a.kind !== "units") for (let [, e] of A(a)) i(e);
598
+ if (a.kind === "symbol" && st.test(a.value) && !z(a.value) && r(a.value, [a.id]), a.kind !== "units") for (let [, e] of k(a)) i(e);
599
599
  }
600
600
  };
601
- return i(e), V.set(e, n), n;
601
+ return i(e), ot.set(e, n), n;
602
602
  }
603
- function ct(e) {
603
+ function lt(e) {
604
604
  let t = [], n = (e, r = null) => {
605
605
  for (let n of rt(e)) {
606
606
  let i = e[n.end], a = i?.kind === "units" ? i : null, o = e.slice(n.start, n.end + +!!a).map((e) => e.id), s = e.slice(n.start, n.end).map((e) => e.id), c = Number(n.text);
@@ -622,14 +622,14 @@ function ct(e) {
622
622
  units: null
623
623
  });
624
624
  }
625
- for (let t of e) if (t.kind !== "units") for (let [e, r] of A(t)) {
625
+ for (let t of e) if (t.kind !== "units") for (let [e, r] of k(t)) {
626
626
  let i = t.kind === "piecewise" && e === "otherwise";
627
627
  n(r, i ? at(t) : null);
628
628
  }
629
629
  };
630
630
  return n(e), t;
631
631
  }
632
- function lt(e, t) {
632
+ function ut(e, t) {
633
633
  let n = e[t - 1];
634
634
  if (n?.kind === "function") {
635
635
  let e = Ue(n.name);
@@ -646,22 +646,22 @@ function lt(e, t) {
646
646
  }
647
647
  //#endregion
648
648
  //#region src/editor/names.ts
649
- var ut = /^([A-Za-z]+?)(\d*)$/;
650
- function dt(e) {
651
- let t = ut.exec(e);
649
+ var dt = /^([A-Za-z]+?)(\d*)$/;
650
+ function ft(e) {
651
+ let t = dt.exec(e);
652
652
  if (!t) return null;
653
653
  let [, n] = t;
654
- return Ke.has(n) && !Oe(n) ? n : null;
654
+ return Ke.has(n) && !z(n) ? n : null;
655
655
  }
656
- function ft(e, t = {}) {
656
+ function V(e, t = {}) {
657
657
  let n = tt(e);
658
- return n ? [I(n)] : t.greekNames === !1 ? z(e) : e.split("_").flatMap((e, t) => {
659
- let n = t > 0 ? [I("_")] : [], r = dt(e);
658
+ return n ? [P(n)] : t.greekNames === !1 ? R(e) : e.split("_").flatMap((e, t) => {
659
+ let n = t > 0 ? [P("_")] : [], r = ft(e);
660
660
  return r ? [
661
661
  ...n,
662
- I(r),
663
- ...z(e.slice(r.length))
664
- ] : [...n, ...z(e)];
662
+ P(r),
663
+ ...R(e.slice(r.length))
664
+ ] : [...n, ...R(e)];
665
665
  });
666
666
  }
667
667
  var pt = (e) => e.map((e) => `${e.atom}.${e.branch}`).join("/");
@@ -681,7 +681,7 @@ function gt(e, t, n, r, i) {
681
681
  let a = pt(t), o = (e, i) => !r.cursorAway && (mt(n.cursor, t, e, i) || mt(n.anchor, t, e, i)), s = [];
682
682
  for (let t of nt(e)) {
683
683
  if (t.functionName || o(t.start, t.end)) continue;
684
- let n = e.slice(t.start, t.end), i = ft(t.name, r), a = i.length === n.length && i.every((e, t) => e.kind === "symbol" && n[t].kind === "symbol" && e.value === n[t].value), c = r.greekNames === !1 && n.some(Xe);
684
+ let n = e.slice(t.start, t.end), i = V(t.name, r), a = i.length === n.length && i.every((e, t) => e.kind === "symbol" && n[t].kind === "symbol" && e.value === n[t].value), c = r.greekNames === !1 && n.some(Xe);
685
685
  !a && !c && s.push({
686
686
  start: t.start,
687
687
  end: t.end,
@@ -690,12 +690,12 @@ function gt(e, t, n, r, i) {
690
690
  }
691
691
  let c = e, l = !1, u = e.map((e, a) => {
692
692
  let o = e;
693
- for (let [s, c] of A(e)) {
693
+ for (let [s, c] of k(e)) {
694
694
  let e = gt(c, [...t, {
695
695
  atom: a,
696
696
  branch: s
697
697
  }], n, r, i);
698
- e !== c && (o = j(o, s, e));
698
+ e !== c && (o = ve(o, s, e));
699
699
  }
700
700
  return o !== e && (l = !0), o;
701
701
  });
@@ -925,7 +925,7 @@ function Vt(e, t, n = {}) {
925
925
  if (t in Mt) return `\\mathrel{${H(e, Mt[t])}}`;
926
926
  if (t === ",") return `\\mathpunct{${H(e, ",")}}`;
927
927
  if (t in Nt) return H(e, Nt[t]);
928
- let r = Oe(t);
928
+ let r = z(t);
929
929
  return r ? H(e, r.latex) : /^[0-9.]$/.test(t) || /^[A-Za-z]$/.test(t) ? H(e, t) : Ke.has(t) && n.greekNames !== !1 ? H(e, `\\${t}`) : /^[A-Za-z]+$/.test(t) ? H(e, `\\mathit{${t}}`) : H(e, `\\text{${Array.from(t).map((e) => Pt[e] ?? e).join("")}}`);
930
930
  }
931
931
  function Ht(e, t = {}) {
@@ -933,7 +933,7 @@ function Ht(e, t = {}) {
933
933
  }
934
934
  function Ut(e, t, n) {
935
935
  let r;
936
- if (e.length === 0) r = `\\htmlClass{me-ph${n.activeRow && ve(n.activeRow, t) ? " me-ph-active" : ""}}{\\square}`;
936
+ if (e.length === 0) r = `\\htmlClass{me-ph${n.activeRow && ye(n.activeRow, t) ? " me-ph-active" : ""}}{\\square}`;
937
937
  else {
938
938
  let i = [], a = new Map(nt(e).map((e) => [e.start, e])), o = new Map(rt(e).filter((e) => e.exponent !== null).map((e) => [e.start, e]));
939
939
  for (let r = 0; r < e.length; r++) {
@@ -990,7 +990,7 @@ function Wt(e, t, n) {
990
990
  }
991
991
  function Gt(e, t, n) {
992
992
  if (e.length === 0) {
993
- let e = `me-ph me-units-ph${n.activeRow && ve(n.activeRow, t) ? " me-ph-active" : ""}`;
993
+ let e = `me-ph me-units-ph${n.activeRow && ye(n.activeRow, t) ? " me-ph-active" : ""}`;
994
994
  return `\\htmlData{row=${kt(t)}}{\\htmlClass{${e}}{\\text{\\scriptsize units}}}`;
995
995
  }
996
996
  let r = e.map((e, r) => {
@@ -1050,7 +1050,7 @@ function Qt(e, t) {
1050
1050
  }
1051
1051
  var $t = (e) => e?.kind === "symbol" || e?.kind === "function";
1052
1052
  function en(e, t, n, r) {
1053
- let i = N(t, n);
1053
+ let i = M(t, n);
1054
1054
  if (!i) return null;
1055
1055
  if (i.length === 0) {
1056
1056
  let t = Zt(e, n), r = t ? Yt(t) : null;
@@ -1090,7 +1090,7 @@ function tn(e, t, n) {
1090
1090
  };
1091
1091
  }
1092
1092
  function nn(e, t, n, r) {
1093
- let i = N(t, n);
1093
+ let i = M(t, n);
1094
1094
  if (!i) return 0;
1095
1095
  let a = 0, o = Infinity;
1096
1096
  for (let s = 0; s <= i.length; s++) {
@@ -1113,7 +1113,7 @@ function an(e, t, n, r) {
1113
1113
  let i = [];
1114
1114
  for (let a of Array.from(e.querySelectorAll("[data-row]"))) {
1115
1115
  let e = At(a.getAttribute("data-row"));
1116
- if (!e || e.length <= i.length || !N(t, e) || rn(a, n, r)) continue;
1116
+ if (!e || e.length <= i.length || !M(t, e) || rn(a, n, r)) continue;
1117
1117
  let o = Yt(a);
1118
1118
  o && n >= o.left - 2 && n <= o.right + 2 && r >= o.top - 2 && r <= o.bottom + 2 && (i = e);
1119
1119
  }
@@ -1123,7 +1123,7 @@ function an(e, t, n, r) {
1123
1123
  };
1124
1124
  }
1125
1125
  function on(e, t, n) {
1126
- let r = N(t, n.path);
1126
+ let r = M(t, n.path);
1127
1127
  return r ? sn(e, r.slice(n.start, n.end).map((e) => e.id)) : null;
1128
1128
  }
1129
1129
  function sn(e, t, n = 2) {
@@ -1198,9 +1198,9 @@ function mn(e) {
1198
1198
  return e.map((e) => {
1199
1199
  let t = {
1200
1200
  ...e,
1201
- id: F()
1201
+ id: N()
1202
1202
  };
1203
- for (let [n, r] of A(e)) t = j(t, n, mn(r));
1203
+ for (let [n, r] of k(e)) t = ve(t, n, mn(r));
1204
1204
  return t;
1205
1205
  });
1206
1206
  }
@@ -1225,7 +1225,7 @@ var hn = {
1225
1225
  function _n(e, t = {}) {
1226
1226
  if (e in hn) return hn[e];
1227
1227
  if (/^[A-Za-z0-9.+\-=,]$/.test(e)) return e;
1228
- let n = Oe(e);
1228
+ let n = z(e);
1229
1229
  return n ? /[a-z]$/i.test(n.latex) ? `${n.latex} ` : n.latex : Ke.has(e) && t.greekNames !== !1 ? `\\${e} ` : /^[A-Za-z]+$/.test(e) ? `\\mathit{${e}}` : `\\text{${Array.from(e, (e) => gn[e] ?? e).join("")}}`;
1230
1230
  }
1231
1231
  var vn = (e) => e?.kind === "symbol" && (/^[+\-−=,·*×]$/.test(e.value) || Ct(e.value) !== void 0);
@@ -1254,13 +1254,13 @@ function yn(e, t, n) {
1254
1254
  let i = n.typesetNames === !1 ? null : bn(e, n);
1255
1255
  if (i) return i;
1256
1256
  let a = e.split("_");
1257
- return n.greekNames !== !1 && a.some((e) => dt(e)) ? a.map((e) => {
1258
- let t = dt(e);
1257
+ return n.greekNames !== !1 && a.some((e) => ft(e)) ? a.map((e) => {
1258
+ let t = ft(e);
1259
1259
  return t ? `\\${t}${e.slice(t.length) || " "}` : e.length === 1 ? e : `\\mathit{${e}}`;
1260
1260
  }).join("\\_") : e.length === 1 ? e : `\\mathit{${e.replace(/_/g, "\\_")}}`;
1261
1261
  }
1262
1262
  function bn(e, t) {
1263
- let n = ft(e, t).map((e) => e.value), r = vt(n);
1263
+ let n = V(e, t).map((e) => e.value), r = vt(n);
1264
1264
  if (!r) return null;
1265
1265
  let i = ([e, r]) => xn(n.slice(e, r), t), a = (e) => r.parts.filter((t) => t.role === e).map((e) => i(e.text)).join(","), o = a("sub"), s = a("sup"), c = `${i(r.base)}${o ? `_{${o}}` : ""}${s ? `^{${s}}` : ""}`;
1266
1266
  return s ? `{${c}}` : c;
@@ -1394,7 +1394,7 @@ var wn = [
1394
1394
  break;
1395
1395
  }
1396
1396
  }
1397
- return this.casesDepth--, we(e.length > 0 ? e : [[[], []]], t);
1397
+ return this.casesDepth--, Te(e.length > 0 ? e : [[[], []]], t);
1398
1398
  }
1399
1399
  readConditionWord() {
1400
1400
  let e = this.peek();
@@ -1440,42 +1440,42 @@ var wn = [
1440
1440
  case "|": {
1441
1441
  this.absDepth++;
1442
1442
  let e = this.readUntilChar("|");
1443
- this.absDepth--, t.push(R(e, "|"));
1443
+ this.absDepth--, t.push(L(e, "|"));
1444
1444
  return;
1445
1445
  }
1446
1446
  case ")":
1447
1447
  case "]": return;
1448
1448
  case "^":
1449
- t.push(be(this.readScript()));
1449
+ t.push(I(this.readScript()));
1450
1450
  return;
1451
1451
  case "_":
1452
- t.push(I("_"), ...jn(this.readScript(), 1));
1452
+ t.push(P("_"), ...jn(this.readScript(), 1));
1453
1453
  return;
1454
1454
  case "/":
1455
1455
  t.push(this.readInfixFraction(t));
1456
1456
  return;
1457
1457
  case "*":
1458
- t.push(I("·"));
1458
+ t.push(P("·"));
1459
1459
  return;
1460
1460
  case "=": {
1461
1461
  let e = t[t.length - 1], n = e?.kind === "symbol" ? e.value : "", r = Dt(n === "!" ? "¬" : n);
1462
- r ? t[t.length - 1] = I(r) : n !== "=" && t.push(I("="));
1462
+ r ? t[t.length - 1] = P(r) : n !== "=" && t.push(P("="));
1463
1463
  return;
1464
1464
  }
1465
1465
  case "!":
1466
- t.push(I("¬"));
1466
+ t.push(P("¬"));
1467
1467
  return;
1468
1468
  case "&": {
1469
1469
  let e = t[t.length - 1];
1470
- (e?.kind !== "symbol" || e.value !== "∧") && t.push(I("∧"));
1470
+ (e?.kind !== "symbol" || e.value !== "∧") && t.push(P("∧"));
1471
1471
  return;
1472
1472
  }
1473
- default: t.push(I(e === "−" ? "-" : e));
1473
+ default: t.push(P(e === "−" ? "-" : e));
1474
1474
  }
1475
1475
  }
1476
1476
  pushBrackets(e, t, n) {
1477
- let r = n === "(" ? lt(e, e.length) : null;
1478
- r ? e.splice(r.start, e.length - r.start, R(t, r.open)) : e.push(R(t, n === "[" ? "(" : n));
1477
+ let r = n === "(" ? ut(e, e.length) : null;
1478
+ r ? e.splice(r.start, e.length - r.start, L(t, r.open)) : e.push(L(t, n === "[" ? "(" : n));
1479
1479
  }
1480
1480
  readUntilChar(e) {
1481
1481
  let t = this.readRow({ char: e });
@@ -1492,7 +1492,7 @@ var wn = [
1492
1492
  close: !0,
1493
1493
  right: !0
1494
1494
  }), a = i[0];
1495
- return i.length === 1 && a.kind === "group" && a.open === "(" && (i = a.body), L(n, i);
1495
+ return i.length === 1 && a.kind === "group" && a.open === "(" && (i = a.body), xe(n, i);
1496
1496
  }
1497
1497
  readScript() {
1498
1498
  let e = this.peek();
@@ -1500,7 +1500,7 @@ var wn = [
1500
1500
  if (e.kind === "char" && /[0-9]/.test(e.value)) {
1501
1501
  let e = "";
1502
1502
  for (; this.peek()?.kind === "char" && /[0-9.]/.test(this.peek().value);) e += this.next().value;
1503
- return Array.from(e, (e) => I(e));
1503
+ return Array.from(e, (e) => P(e));
1504
1504
  }
1505
1505
  return this.readArgument();
1506
1506
  }
@@ -1538,7 +1538,7 @@ var wn = [
1538
1538
  if (Dn.has(e)) return;
1539
1539
  let r = Tt(e);
1540
1540
  if (r) {
1541
- t.push(I(r.symbol));
1541
+ t.push(P(r.symbol));
1542
1542
  return;
1543
1543
  }
1544
1544
  switch (e) {
@@ -1554,12 +1554,12 @@ var wn = [
1554
1554
  case "dfrac":
1555
1555
  case "tfrac": {
1556
1556
  let e = this.readArgument(), n = this.readArgument(), r = (e) => e[0] !== void 0 && this.uprightD.has(e[0]);
1557
- t.push(r(e) && r(n) ? Se(e.slice(1), n.slice(1)) : L(e, n));
1557
+ t.push(r(e) && r(n) ? Ce(e.slice(1), n.slice(1)) : xe(e, n));
1558
1558
  return;
1559
1559
  }
1560
1560
  case "sqrt": {
1561
1561
  let e = null;
1562
- this.peek()?.kind === "char" && this.peek().value === "[" && (this.next(), e = this.readUntilChar("]")), t.push(xe(this.readArgument(), e));
1562
+ this.peek()?.kind === "char" && this.peek().value === "[" && (this.next(), e = this.readUntilChar("]")), t.push(Se(this.readArgument(), e));
1563
1563
  return;
1564
1564
  }
1565
1565
  case "left": {
@@ -1572,7 +1572,7 @@ var wn = [
1572
1572
  case "lfloor":
1573
1573
  case "lceil": {
1574
1574
  let n = this.readRow({ command: e === "lfloor" ? "rfloor" : "rceil" });
1575
- this.next(), t.push(R(n, e === "lfloor" ? "⌊" : "⌈"));
1575
+ this.next(), t.push(L(n, e === "lfloor" ? "⌊" : "⌈"));
1576
1576
  return;
1577
1577
  }
1578
1578
  case "rfloor":
@@ -1580,17 +1580,17 @@ var wn = [
1580
1580
  case "right": return;
1581
1581
  case "cdot":
1582
1582
  case "ast":
1583
- t.push(I("·"));
1583
+ t.push(P("·"));
1584
1584
  return;
1585
1585
  case "times":
1586
- t.push(I("×"));
1586
+ t.push(P("×"));
1587
1587
  return;
1588
1588
  case "square":
1589
1589
  case "Box": return;
1590
1590
  case "{":
1591
1591
  case "}":
1592
1592
  case "|":
1593
- t.push(I(e));
1593
+ t.push(P(e));
1594
1594
  return;
1595
1595
  case "mathrm":
1596
1596
  case "operatorname":
@@ -1605,37 +1605,37 @@ var wn = [
1605
1605
  }
1606
1606
  let i = Je(e);
1607
1607
  if (i) {
1608
- t.push(ye(i));
1608
+ t.push(F(i));
1609
1609
  return;
1610
1610
  }
1611
1611
  let a = Me(e);
1612
- t.push(I(a ?? e));
1612
+ t.push(P(a ?? e));
1613
1613
  }
1614
1614
  readNamed(e, t, n) {
1615
1615
  if (!t) return;
1616
1616
  if (e === "mathrm" && (t === "E" || t === "e" && this.peek()?.kind === "open")) {
1617
- n.push(I(t));
1617
+ n.push(P(t));
1618
1618
  return;
1619
1619
  }
1620
1620
  let r = e === "mathrm" ? Ne(t) : void 0;
1621
1621
  if (r) {
1622
- n.push(I(r));
1622
+ n.push(P(r));
1623
1623
  return;
1624
1624
  }
1625
1625
  if (e === "mathrm" && t === "d") {
1626
- let e = I("d");
1626
+ let e = P("d");
1627
1627
  this.uprightD.add(e), n.push(e);
1628
1628
  return;
1629
1629
  }
1630
1630
  if (e === "operatorname" || e === "mathrm") {
1631
- n.push(ye(Je(t) ?? t));
1631
+ n.push(F(Je(t) ?? t));
1632
1632
  return;
1633
1633
  }
1634
1634
  if (e === "text" || e === "textrm") {
1635
- n.push(...Array.from(t, (e) => I(e)));
1635
+ n.push(...Array.from(t, (e) => P(e)));
1636
1636
  return;
1637
1637
  }
1638
- n.push(...Array.from(t, (e) => I(e)));
1638
+ n.push(...Array.from(t, (e) => P(e)));
1639
1639
  }
1640
1640
  };
1641
1641
  function An(e) {
@@ -1643,21 +1643,21 @@ function An(e) {
1643
1643
  return t.length > 0 && t[t.length - 1].end === e.length;
1644
1644
  }
1645
1645
  function jn(e, t) {
1646
- return e.flatMap((e) => e.kind === "symbol" && e.value === "," ? Array.from({ length: t }, () => I("_")) : [e]);
1646
+ return e.flatMap((e) => e.kind === "symbol" && e.value === "," ? Array.from({ length: t }, () => P("_")) : [e]);
1647
1647
  }
1648
1648
  function Mn(e) {
1649
1649
  let t = e[e.length - 1];
1650
1650
  if (t?.kind !== "superscript" || e.length < 2) return e;
1651
1651
  let n = [
1652
1652
  ...e.slice(0, -1),
1653
- I("_"),
1654
- I("_"),
1653
+ P("_"),
1654
+ P("_"),
1655
1655
  ...jn(t.sup, 2)
1656
1656
  ], r = nt(n);
1657
1657
  return r.length !== 1 || r[0].start !== 0 || r[0].end !== n.length || r[0].functionName ? e : vt(n.map((e) => e.value))?.parts.filter((e) => e.role === "sup").every((e) => Qe(n[e.text[0]])) ? n : e;
1658
1658
  }
1659
1659
  function Nn(e) {
1660
- return Ce(Array.from(e.trim(), (e) => I(e)));
1660
+ return we(Array.from(e.trim(), (e) => P(e)));
1661
1661
  }
1662
1662
  function Pn(e) {
1663
1663
  return new kn(Cn(e)).readAll();
@@ -1671,7 +1671,7 @@ function Ln(e, t) {
1671
1671
  let t = n?.[e.atom];
1672
1672
  if (!t) return null;
1673
1673
  if (t.kind === "units") return t.id;
1674
- n = A(t).find(([t]) => t === e.branch)?.[1] ?? null;
1674
+ n = k(t).find(([t]) => t === e.branch)?.[1] ?? null;
1675
1675
  }
1676
1676
  return null;
1677
1677
  }
@@ -1695,7 +1695,7 @@ function Un(e, t, n) {
1695
1695
  return r !== null && Vn.test(r + n);
1696
1696
  }
1697
1697
  function Wn(e, t) {
1698
- let n = N(e, t.path);
1698
+ let n = M(e, t.path);
1699
1699
  return n && Fn(n[t.offset]) ? {
1700
1700
  ...t,
1701
1701
  offset: t.offset + 1
@@ -1722,12 +1722,12 @@ function qn(e, t, n, r) {
1722
1722
  return (s.units.length === 0 || !Hn(e, c)) && !r ? (a.push(c), []) : [s];
1723
1723
  }
1724
1724
  let l = s;
1725
- for (let [e, i] of A(s)) {
1725
+ for (let [e, i] of k(s)) {
1726
1726
  let a = qn(i, [...t, {
1727
1727
  atom: c,
1728
1728
  branch: e
1729
1729
  }], n, r);
1730
- a !== i && (l = j(l, e, a));
1730
+ a !== i && (l = ve(l, e, a));
1731
1731
  }
1732
1732
  return l !== s && (o = !0), [l];
1733
1733
  });
@@ -1764,7 +1764,7 @@ function Xn(e) {
1764
1764
  };
1765
1765
  }
1766
1766
  function Zn(e, t) {
1767
- return e.offset === t.offset && ve(e.path, t.path);
1767
+ return e.offset === t.offset && ye(e.path, t.path);
1768
1768
  }
1769
1769
  function Qn(e) {
1770
1770
  return `${e.path.map((e) => `${e.atom}.${e.branch}`).join(" › ") || "root"} @ ${e.offset}`;
@@ -1774,7 +1774,7 @@ function $n(e) {
1774
1774
  for (let i = 0; i <= e.length; i++) if (!Fn(e[i]) && (t.push({
1775
1775
  path: r,
1776
1776
  offset: i
1777
- }), i < e.length)) for (let [t, a] of A(e[i])) n(a, [...r, {
1777
+ }), i < e.length)) for (let [t, a] of k(e[i])) n(a, [...r, {
1778
1778
  atom: i,
1779
1779
  branch: t
1780
1780
  }]);
@@ -1783,7 +1783,7 @@ function $n(e) {
1783
1783
  }
1784
1784
  function er(e, t) {
1785
1785
  if (t.length === 0) return null;
1786
- let n = t.slice(0, -1), r = N(e, n), { atom: i, branch: a } = t[t.length - 1];
1786
+ let n = t.slice(0, -1), r = M(e, n), { atom: i, branch: a } = t[t.length - 1];
1787
1787
  if (!r || !r[i]) throw Error("Cursor path does not resolve");
1788
1788
  return {
1789
1789
  rowPath: n,
@@ -1794,14 +1794,14 @@ function er(e, t) {
1794
1794
  };
1795
1795
  }
1796
1796
  function tr(e, t) {
1797
- let n = N(e, t);
1797
+ let n = M(e, t);
1798
1798
  if (!n) throw Error("Cursor path does not resolve");
1799
1799
  return n;
1800
1800
  }
1801
1801
  function nr(e, t) {
1802
1802
  let n = tr(e, t.path);
1803
1803
  if (t.offset < n.length) {
1804
- let e = n[t.offset], r = Fn(e) ? [] : A(e);
1804
+ let e = n[t.offset], r = Fn(e) ? [] : k(e);
1805
1805
  if (r.length > 0) return {
1806
1806
  path: [...t.path, {
1807
1807
  atom: t.offset,
@@ -1817,7 +1817,7 @@ function nr(e, t) {
1817
1817
  }
1818
1818
  let r = er(e, t.path);
1819
1819
  if (!r) return null;
1820
- let i = A(r.atom), a = i[i.findIndex(([e]) => e === r.branch) + 1];
1820
+ let i = k(r.atom), a = i[i.findIndex(([e]) => e === r.branch) + 1];
1821
1821
  return a ? {
1822
1822
  path: [...r.rowPath, {
1823
1823
  atom: r.atomIndex,
@@ -1837,7 +1837,7 @@ function rr(e, t) {
1837
1837
  path: t.path,
1838
1838
  offset: r
1839
1839
  });
1840
- let i = A(n[r]);
1840
+ let i = k(n[r]);
1841
1841
  if (i.length > 0) {
1842
1842
  let [e, n] = i[i.length - 1];
1843
1843
  return {
@@ -1855,7 +1855,7 @@ function rr(e, t) {
1855
1855
  }
1856
1856
  let r = er(e, t.path);
1857
1857
  if (!r) return null;
1858
- let i = A(r.atom), a = i[i.findIndex(([e]) => e === r.branch) - 1];
1858
+ let i = k(r.atom), a = i[i.findIndex(([e]) => e === r.branch) - 1];
1859
1859
  if (a) {
1860
1860
  let [e, t] = a;
1861
1861
  return {
@@ -1881,7 +1881,7 @@ var ir = {
1881
1881
  };
1882
1882
  function ar(e, t) {
1883
1883
  if (e.kind !== "piecewise") return ir[e.kind] ?? null;
1884
- let n = _e(t);
1884
+ let n = A(t);
1885
1885
  if (!n) return null;
1886
1886
  let r = n.part === "otherwise" ? "value" : n.part, i = e.pieces.map((e, t) => `${r}${t}`);
1887
1887
  return e.otherwise ? [...i, "otherwise"] : i;
@@ -1891,7 +1891,7 @@ function sr(e, t, n, r) {
1891
1891
  for (let i = t.path.length; i > 0; i--) {
1892
1892
  let a = er(e, t.path.slice(0, i)), o = ar(a.atom, a.branch);
1893
1893
  if (!o) continue;
1894
- let s = A(a.atom).map(([e]) => e), c = o.filter((e) => s.includes(e)), l = c.indexOf(a.branch), u = c[l + n];
1894
+ let s = k(a.atom).map(([e]) => e), c = o.filter((e) => s.includes(e)), l = c.indexOf(a.branch), u = c[l + n];
1895
1895
  if (l < 0 || !u) continue;
1896
1896
  let d = [...a.rowPath, {
1897
1897
  atom: a.atomIndex,
@@ -1926,7 +1926,7 @@ function G(e) {
1926
1926
  }
1927
1927
  function ur(e) {
1928
1928
  let t = G(e);
1929
- return t ? N(e.root, t.path).slice(t.start, t.end) : [];
1929
+ return t ? M(e.root, t.path).slice(t.start, t.end) : [];
1930
1930
  }
1931
1931
  function dr(e) {
1932
1932
  return `${e.path.map((e) => `${e.atom}.${e.branch}`).join(" › ") || "root"} ${e.start}–${e.end}`;
@@ -1944,7 +1944,7 @@ function fr(e, t, n) {
1944
1944
  };
1945
1945
  }
1946
1946
  function pr(e, t) {
1947
- let n = e.anchor ?? e.cursor, { path: r, offset: i } = e.cursor, a = N(e.root, r), o;
1947
+ let n = e.anchor ?? e.cursor, { path: r, offset: i } = e.cursor, a = M(e.root, r), o;
1948
1948
  if (t === "forward" ? i < a.length : i > 0) {
1949
1949
  let e = i + (t === "forward" ? 1 : -1);
1950
1950
  t === "backward" && Fn(a[i - 1]) && (e = Math.max(0, i - 2)), t === "forward" && Fn(a[e]) && e++, o = {
@@ -2010,16 +2010,16 @@ function br() {
2010
2010
  };
2011
2011
  }
2012
2012
  function K(e, t) {
2013
- let n = N(e, t);
2013
+ let n = M(e, t);
2014
2014
  if (!n) throw Error("Cursor path does not resolve");
2015
2015
  return n;
2016
2016
  }
2017
2017
  function xr(e, t, n) {
2018
2018
  if (t.length === 0) return n(e);
2019
- let [r, ...i] = t, a = e[r.atom], o = M(a, r.branch);
2019
+ let [r, ...i] = t, a = e[r.atom], o = j(a, r.branch);
2020
2020
  if (!o) throw Error("Cursor path does not resolve");
2021
2021
  let s = e.slice();
2022
- return s[r.atom] = j(a, r.branch, xr(o, i, n)), s;
2022
+ return s[r.atom] = ve(a, r.branch, xr(o, i, n)), s;
2023
2023
  }
2024
2024
  function q(e, t, n, r, i, a) {
2025
2025
  return {
@@ -2045,10 +2045,13 @@ function Cr(e) {
2045
2045
  return e?.kind === "symbol" && Sr.has(e.value);
2046
2046
  }
2047
2047
  function wr(e) {
2048
- let t = A(e);
2048
+ return !e || Cr(e) ? !1 : e.kind !== "symbol" || !Ct(e.value);
2049
+ }
2050
+ function Tr(e) {
2051
+ let t = k(e);
2049
2052
  return t.length > 0 && t.every(([, e]) => e.length === 0);
2050
2053
  }
2051
- function Tr(e, t = e.cursor.path.length) {
2054
+ function Er(e, t = e.cursor.path.length) {
2052
2055
  if (t === 0) return null;
2053
2056
  let n = e.cursor.path, r = n.slice(0, t - 1), { atom: i, branch: a } = n[t - 1];
2054
2057
  return {
@@ -2058,7 +2061,7 @@ function Tr(e, t = e.cursor.path.length) {
2058
2061
  branch: a
2059
2062
  };
2060
2063
  }
2061
- function Er(e, t, n) {
2064
+ function Dr(e, t, n) {
2062
2065
  if (t.atom.kind === "piecewise" || t.atom.kind === "units") {
2063
2066
  let r = n === 0 ? t.index : t.index + 1;
2064
2067
  return {
@@ -2069,26 +2072,26 @@ function Er(e, t, n) {
2069
2072
  }
2070
2073
  };
2071
2074
  }
2072
- let r = A(t.atom).flatMap(([, e]) => e);
2075
+ let r = k(t.atom).flatMap(([, e]) => e);
2073
2076
  return q(e, t.rowPath, t.index, 1, r, {
2074
2077
  path: t.rowPath,
2075
2078
  offset: t.index + n
2076
2079
  });
2077
2080
  }
2078
- function Dr(e) {
2081
+ function Or(e) {
2079
2082
  for (let t = e.cursor.path.length; t > 0; t--) {
2080
- let n = Tr(e, t);
2083
+ let n = Er(e, t);
2081
2084
  if (n?.atom.kind === "piecewise") return n;
2082
2085
  }
2083
2086
  return null;
2084
2087
  }
2085
- var Or = (e, t) => [...e.rowPath, {
2088
+ var kr = (e, t) => [...e.rowPath, {
2086
2089
  atom: e.index,
2087
2090
  branch: t
2088
- }], kr = (e) => e.value.length === 0 && e.condition.length === 0, Ar = (e) => {
2089
- let t = Dr(e);
2091
+ }], Ar = (e) => e.value.length === 0 && e.condition.length === 0, jr = (e) => {
2092
+ let t = Or(e);
2090
2093
  if (!t) return e;
2091
- let n = _e(t.branch), { pieces: r } = t.atom, i = n.part === "otherwise" ? r.length : n.piece + 1, a = {
2094
+ let n = A(t.branch), { pieces: r } = t.atom, i = n.part === "otherwise" ? r.length : n.piece + 1, a = {
2092
2095
  ...t.atom,
2093
2096
  pieces: [
2094
2097
  ...r.slice(0, i),
@@ -2100,13 +2103,13 @@ var Or = (e, t) => [...e.rowPath, {
2100
2103
  ]
2101
2104
  };
2102
2105
  return q(e, t.rowPath, t.index, 1, [a], {
2103
- path: Or(t, `value${i}`),
2106
+ path: kr(t, `value${i}`),
2104
2107
  offset: 0
2105
2108
  });
2106
- }, jr = (e) => {
2107
- let t = Dr(e);
2109
+ }, Mr = (e) => {
2110
+ let t = Or(e);
2108
2111
  if (!t) return e;
2109
- let n = Or(t, "otherwise");
2112
+ let n = kr(t, "otherwise");
2110
2113
  if (t.atom.otherwise) return {
2111
2114
  root: e.root,
2112
2115
  cursor: {
@@ -2114,7 +2117,7 @@ var Or = (e, t) => [...e.rowPath, {
2114
2117
  offset: t.atom.otherwise.length
2115
2118
  }
2116
2119
  };
2117
- let r = z("0.0");
2120
+ let r = R("0.0");
2118
2121
  return {
2119
2122
  ...q(e, t.rowPath, t.index, 1, [{
2120
2123
  ...t.atom,
@@ -2129,8 +2132,8 @@ var Or = (e, t) => [...e.rowPath, {
2129
2132
  }
2130
2133
  };
2131
2134
  };
2132
- function Mr(e, t) {
2133
- let n = _e(t.branch), { pieces: r, otherwise: i } = t.atom;
2135
+ function Nr(e, t) {
2136
+ let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
2134
2137
  if (n.part === "otherwise") {
2135
2138
  if (!i || i.length > 0) return null;
2136
2139
  let n = r.length - 1;
@@ -2138,25 +2141,25 @@ function Mr(e, t) {
2138
2141
  ...t.atom,
2139
2142
  otherwise: null
2140
2143
  }], {
2141
- path: Or(t, `cond${n}`),
2144
+ path: kr(t, `cond${n}`),
2142
2145
  offset: r[n].condition.length
2143
2146
  });
2144
2147
  }
2145
- if (n.part !== "value" || r.length < 2 || !kr(r[n.piece])) return null;
2148
+ if (n.part !== "value" || r.length < 2 || !Ar(r[n.piece])) return null;
2146
2149
  let a = {
2147
2150
  ...t.atom,
2148
2151
  pieces: r.filter((e, t) => t !== n.piece)
2149
2152
  }, o = n.piece > 0 ? {
2150
- path: Or(t, `cond${n.piece - 1}`),
2153
+ path: kr(t, `cond${n.piece - 1}`),
2151
2154
  offset: r[n.piece - 1].condition.length
2152
2155
  } : {
2153
- path: Or(t, "value0"),
2156
+ path: kr(t, "value0"),
2154
2157
  offset: 0
2155
2158
  };
2156
2159
  return q(e, t.rowPath, t.index, 1, [a], o);
2157
2160
  }
2158
- function Nr(e, t) {
2159
- let n = _e(t.branch), { pieces: r, otherwise: i } = t.atom;
2161
+ function Pr(e, t) {
2162
+ let n = A(t.branch), { pieces: r, otherwise: i } = t.atom;
2160
2163
  if (n.part === "otherwise") return !i || i.length > 0 ? null : q(e, t.rowPath, t.index, 1, [{
2161
2164
  ...t.atom,
2162
2165
  otherwise: null
@@ -2164,15 +2167,15 @@ function Nr(e, t) {
2164
2167
  path: t.rowPath,
2165
2168
  offset: t.index + 1
2166
2169
  });
2167
- if (r.length < 2 || !kr(r[n.piece])) return null;
2170
+ if (r.length < 2 || !Ar(r[n.piece])) return null;
2168
2171
  let a = {
2169
2172
  ...t.atom,
2170
2173
  pieces: r.filter((e, t) => t !== n.piece)
2171
2174
  }, o = n.piece < a.pieces.length ? {
2172
- path: Or(t, `value${n.piece}`),
2175
+ path: kr(t, `value${n.piece}`),
2173
2176
  offset: 0
2174
2177
  } : a.otherwise ? {
2175
- path: Or(t, "otherwise"),
2178
+ path: kr(t, "otherwise"),
2176
2179
  offset: 0
2177
2180
  } : {
2178
2181
  path: t.rowPath,
@@ -2180,7 +2183,7 @@ function Nr(e, t) {
2180
2183
  };
2181
2184
  return q(e, t.rowPath, t.index, 1, [a], o);
2182
2185
  }
2183
- function Pr(e) {
2186
+ function Fr(e) {
2184
2187
  let t = G(e);
2185
2188
  return t ? q(e, t.path, t.start, t.end - t.start, [], {
2186
2189
  path: t.path,
@@ -2190,15 +2193,15 @@ function Pr(e) {
2190
2193
  cursor: e.cursor
2191
2194
  } : e;
2192
2195
  }
2193
- function Fr(e) {
2196
+ function Ir(e) {
2194
2197
  let t = e[0];
2195
2198
  return e.length === 1 && t.kind === "group" && t.open === "(" ? t.body : e;
2196
2199
  }
2197
- function Ir(e, t, n) {
2200
+ function Lr(e, t, n) {
2198
2201
  return (r) => {
2199
2202
  let i = G(r);
2200
2203
  if (!i) {
2201
- let t = Pr(r), { path: i, offset: a } = t.cursor;
2204
+ let t = Fr(r), { path: i, offset: a } = t.cursor;
2202
2205
  return q(t, i, a, 0, [e([])], {
2203
2206
  path: [...i, {
2204
2207
  atom: a,
@@ -2220,12 +2223,12 @@ function Ir(e, t, n) {
2220
2223
  return q(r, a, o, s - o, [e(c)], l);
2221
2224
  };
2222
2225
  }
2223
- function Lr(e) {
2226
+ function Rr(e) {
2224
2227
  return Be(e)?.latexName ?? e;
2225
2228
  }
2226
- function Rr(e) {
2229
+ function zr(e) {
2227
2230
  return (t) => {
2228
- let n = Pr(t);
2231
+ let n = Fr(t);
2229
2232
  if (e.length === 0) return n;
2230
2233
  let { path: r, offset: i } = n.cursor;
2231
2234
  return q(n, r, i, 0, e, {
@@ -2236,29 +2239,29 @@ function Rr(e) {
2236
2239
  }
2237
2240
  function J(e) {
2238
2241
  return (t) => {
2239
- let n = Pr(t), { path: r, offset: i } = n.cursor;
2240
- return q(n, r, i, 0, [I(e)], {
2242
+ let n = Fr(t), { path: r, offset: i } = n.cursor;
2243
+ return q(n, r, i, 0, [P(e)], {
2241
2244
  path: r,
2242
2245
  offset: i + 1
2243
2246
  });
2244
2247
  };
2245
2248
  }
2246
- var zr = (e) => {
2249
+ var Br = (e) => {
2247
2250
  if (!G(e)) {
2248
2251
  let { path: t, offset: n } = e.cursor, r = K(e.root, t)[n - 1], i = r?.kind === "symbol" ? Dt(r.value) : void 0;
2249
2252
  if (i) return q({
2250
2253
  root: e.root,
2251
2254
  cursor: e.cursor
2252
- }, t, n - 1, 1, [I(i)], {
2255
+ }, t, n - 1, 1, [P(i)], {
2253
2256
  path: t,
2254
2257
  offset: n
2255
2258
  });
2256
2259
  }
2257
2260
  return J("=")(e);
2258
- }, Br = (e) => {
2261
+ }, Vr = (e) => {
2259
2262
  let t = G(e);
2260
2263
  if (t) {
2261
- let { path: n, start: r, end: i } = t, a = we([[K(e.root, n).slice(r, i), []]], z("0.0"));
2264
+ let { path: n, start: r, end: i } = t, a = Te([[K(e.root, n).slice(r, i), []]], R("0.0"));
2262
2265
  return q(e, n, r, i - r, [a], {
2263
2266
  path: [...n, {
2264
2267
  atom: r,
@@ -2267,11 +2270,11 @@ var zr = (e) => {
2267
2270
  offset: 0
2268
2271
  });
2269
2272
  }
2270
- return Vr(we([[[], []]], z("0.0")), "value0")(e);
2273
+ return Hr(Te([[[], []]], R("0.0")), "value0")(e);
2271
2274
  };
2272
- function Vr(e, t) {
2275
+ function Hr(e, t) {
2273
2276
  return (n) => {
2274
- let r = Pr(n), { path: i, offset: a } = r.cursor;
2277
+ let r = Fr(n), { path: i, offset: a } = r.cursor;
2275
2278
  return q(r, i, a, 0, [e], {
2276
2279
  path: [...i, {
2277
2280
  atom: a,
@@ -2281,23 +2284,23 @@ function Vr(e, t) {
2281
2284
  });
2282
2285
  };
2283
2286
  }
2284
- var Hr = Ir((e) => L(Fr(e), []), "den", "num"), Ur = (e) => {
2285
- if (G(e)) return Hr(e);
2286
- let t = Pr(e), { path: n, offset: r } = t.cursor, i = K(t.root, n), a = r;
2287
+ var Ur = Lr((e) => xe(Ir(e), []), "den", "num"), Wr = (e) => {
2288
+ if (G(e)) return Ur(e);
2289
+ let t = Fr(e), { path: n, offset: r } = t.cursor, i = K(t.root, n), a = r;
2287
2290
  for (; a > 0 && !Cr(i[a - 1]);) a--;
2288
- let o = Fr(i.slice(a, r)), s = o.length > 0 ? "den" : "num";
2289
- return q(t, n, a, r - a, [L(o, [])], {
2291
+ let o = Ir(i.slice(a, r)), s = o.length > 0 ? "den" : "num";
2292
+ return q(t, n, a, r - a, [xe(o, [])], {
2290
2293
  path: [...n, {
2291
2294
  atom: a,
2292
2295
  branch: s
2293
2296
  }],
2294
2297
  offset: 0
2295
2298
  });
2296
- }, Wr = (e) => {
2299
+ }, Gr = (e) => {
2297
2300
  let t = G(e);
2298
2301
  if (t) {
2299
- let { path: n, start: r, end: i } = t, a = K(e.root, n).slice(r, i), o = a.length === 1 ? a : [R(a, "(")];
2300
- return q(e, n, r, i - r, [...o, be()], {
2302
+ let { path: n, start: r, end: i } = t, a = K(e.root, n).slice(r, i), o = a.length === 1 ? a : [L(a, "(")];
2303
+ return q(e, n, r, i - r, [...o, I()], {
2301
2304
  path: [...n, {
2302
2305
  atom: r + o.length,
2303
2306
  branch: "sup"
@@ -2305,7 +2308,7 @@ var Hr = Ir((e) => L(Fr(e), []), "den", "num"), Ur = (e) => {
2305
2308
  offset: 0
2306
2309
  });
2307
2310
  }
2308
- let n = Pr(e), { path: r, offset: i } = n.cursor, a = K(n.root, r), o = a[i], s = a[i - 1];
2311
+ let n = Fr(e), { path: r, offset: i } = n.cursor, a = K(n.root, r), o = a[i], s = a[i - 1];
2309
2312
  return o?.kind === "superscript" ? {
2310
2313
  root: n.root,
2311
2314
  cursor: {
@@ -2324,11 +2327,11 @@ var Hr = Ir((e) => L(Fr(e), []), "den", "num"), Ur = (e) => {
2324
2327
  }],
2325
2328
  offset: s.sup.length
2326
2329
  }
2327
- } : Vr(be(), "sup")(n);
2330
+ } : wr(s) ? Hr(I(), "sup")(n) : e;
2328
2331
  };
2329
- function Gr(e, t) {
2332
+ function Kr(e, t) {
2330
2333
  for (let n = e.cursor.path.length; n > 0; n--) {
2331
- let r = Tr(e, n);
2334
+ let r = Er(e, n);
2332
2335
  if (r.atom.kind === "group" && t.includes(r.atom.open)) return {
2333
2336
  owner: r,
2334
2337
  depth: n
@@ -2336,9 +2339,9 @@ function Gr(e, t) {
2336
2339
  }
2337
2340
  return null;
2338
2341
  }
2339
- function Kr(e) {
2342
+ function qr(e) {
2340
2343
  return (t) => {
2341
- let n = t.anchor ? _r(t, "end") : t, r = Gr(n, e);
2344
+ let n = t.anchor ? _r(t, "end") : t, r = Kr(n, e);
2342
2345
  if (!r) return t;
2343
2346
  let { owner: i, depth: a } = r, o = {
2344
2347
  path: i.rowPath,
@@ -2355,10 +2358,10 @@ function Kr(e) {
2355
2358
  return q(n, i.rowPath, i.index, 1, [l, ...s.slice(c)], o);
2356
2359
  };
2357
2360
  }
2358
- var qr = (e) => Ir((t) => R(t, e), "after", "body"), Jr = (e) => {
2361
+ var Jr = (e) => Lr((t) => L(t, e), "after", "body"), Yr = (e) => {
2359
2362
  if (!G(e)) {
2360
- let { path: t, offset: n } = e.cursor, r = lt(K(e.root, t), n);
2361
- if (r) return q(e, t, r.start, n - r.start, [R([], r.open)], {
2363
+ let { path: t, offset: n } = e.cursor, r = ut(K(e.root, t), n);
2364
+ if (r) return q(e, t, r.start, n - r.start, [L([], r.open)], {
2362
2365
  path: [...t, {
2363
2366
  atom: r.start,
2364
2367
  branch: "body"
@@ -2366,8 +2369,8 @@ var qr = (e) => Ir((t) => R(t, e), "after", "body"), Jr = (e) => {
2366
2369
  offset: 0
2367
2370
  });
2368
2371
  }
2369
- return qr("(")(e);
2370
- }, Yr = (e) => {
2372
+ return Jr("(")(e);
2373
+ }, Xr = (e) => {
2371
2374
  if (In(e.cursor)) return e;
2372
2375
  let { path: t, offset: n } = e.cursor, r = K(e.root, t)[n - 1];
2373
2376
  if (!G(e) && r?.kind === "units") {
@@ -2387,22 +2390,22 @@ var qr = (e) => Ir((t) => R(t, e), "after", "body"), Jr = (e) => {
2387
2390
  } : null
2388
2391
  };
2389
2392
  }
2390
- let i = Pr(e), a = i.cursor.offset;
2391
- return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ? Vr(Ce(), "units")(i) : e;
2393
+ let i = Fr(e), a = i.cursor.offset;
2394
+ return rt(K(i.root, i.cursor.path).slice(0, a)).find((e) => e.end === a) ? Hr(we(), "units")(i) : e;
2392
2395
  };
2393
- function Xr(e) {
2396
+ function Zr(e) {
2394
2397
  return (t) => {
2395
2398
  let { path: n, offset: r } = t.cursor, i = K(t.root, n);
2396
- return !G(t) && Fn(i[r - 1]) && Un(i, r - 1, e) ? q(t, n, r - 1, 0, [I(e)], {
2399
+ return !G(t) && Fn(i[r - 1]) && Un(i, r - 1, e) ? q(t, n, r - 1, 0, [P(e)], {
2397
2400
  path: n,
2398
2401
  offset: r + 1
2399
2402
  }) : J(e)(t);
2400
2403
  };
2401
2404
  }
2402
- var Zr = (e) => {
2405
+ var Qr = (e) => {
2403
2406
  let t = e.anchor ? _r(e, "end") : e;
2404
2407
  for (let e = t.cursor.path.length; e > 0; e--) {
2405
- let n = Tr(t, e);
2408
+ let n = Er(t, e);
2406
2409
  if (n.atom.kind === "units") return {
2407
2410
  root: t.root,
2408
2411
  cursor: {
@@ -2412,17 +2415,17 @@ var Zr = (e) => {
2412
2415
  };
2413
2416
  }
2414
2417
  return e;
2415
- }, Qr = qr("⌊"), $r = qr("⌈"), ei = Kr([
2418
+ }, $r = Jr("⌊"), ei = Jr("⌈"), ti = qr([
2416
2419
  "(",
2417
2420
  "⌊",
2418
2421
  "⌈"
2419
- ]), ti = (e) => {
2420
- if (G(e)) return li(e);
2421
- let t = Tr(e);
2422
- return t?.atom.kind === "group" && t.atom.open === "|" ? Kr(["|"])(e) : Vr(R([], "|"), "body")(e);
2423
- }, ni = (e) => {
2422
+ ]), ni = (e) => {
2423
+ if (G(e)) return ui(e);
2424
+ let t = Er(e);
2425
+ return t?.atom.kind === "group" && t.atom.open === "|" ? qr(["|"])(e) : Hr(L([], "|"), "body")(e);
2426
+ }, ri = (e) => {
2424
2427
  if (G(e)) return _r(e, "end");
2425
- let t = Tr(e);
2428
+ let t = Er(e);
2426
2429
  return t ? {
2427
2430
  root: e.root,
2428
2431
  cursor: {
@@ -2430,8 +2433,8 @@ var Zr = (e) => {
2430
2433
  offset: t.index + 1
2431
2434
  }
2432
2435
  } : e;
2433
- }, ri = (e) => {
2434
- if (G(e)) return Pr(e);
2436
+ }, ii = (e) => {
2437
+ if (G(e)) return Fr(e);
2435
2438
  let { path: t, offset: n } = e.cursor, r = K(e.root, t);
2436
2439
  if (n > 0) {
2437
2440
  let i = r[n - 1], a = n - 1;
@@ -2450,17 +2453,17 @@ var Zr = (e) => {
2450
2453
  offset: a
2451
2454
  });
2452
2455
  if (i.kind === "function") {
2453
- let n = z(Lr(i.name).slice(0, -1));
2456
+ let n = R(Rr(i.name).slice(0, -1));
2454
2457
  return q(e, t, a, 1, n, {
2455
2458
  path: t,
2456
2459
  offset: a + n.length
2457
2460
  });
2458
2461
  }
2459
- if (wr(i)) return q(e, t, a, 1, [], {
2462
+ if (Tr(i)) return q(e, t, a, 1, [], {
2460
2463
  path: t,
2461
2464
  offset: a
2462
2465
  });
2463
- let o = A(i), [s, c] = o[o.length - 1];
2466
+ let o = k(i), [s, c] = o[o.length - 1];
2464
2467
  return {
2465
2468
  root: e.root,
2466
2469
  cursor: {
@@ -2472,17 +2475,17 @@ var Zr = (e) => {
2472
2475
  }
2473
2476
  };
2474
2477
  }
2475
- let i = Tr(e);
2478
+ let i = Er(e);
2476
2479
  if (!i) return e;
2477
2480
  if (i.atom.kind === "piecewise") {
2478
- let t = Mr(e, i);
2481
+ let t = Nr(e, i);
2479
2482
  if (t) return t;
2480
2483
  }
2481
- if (wr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
2484
+ if (Tr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
2482
2485
  path: i.rowPath,
2483
2486
  offset: i.index
2484
2487
  });
2485
- let a = A(i.atom), o = a.findIndex(([e]) => e === i.branch);
2488
+ let a = k(i.atom), o = a.findIndex(([e]) => e === i.branch);
2486
2489
  if (o > 0) {
2487
2490
  let [t, n] = a[o - 1];
2488
2491
  return {
@@ -2496,9 +2499,9 @@ var Zr = (e) => {
2496
2499
  }
2497
2500
  };
2498
2501
  }
2499
- return Er(e, i, 0);
2500
- }, ii = (e) => {
2501
- if (G(e)) return Pr(e);
2502
+ return Dr(e, i, 0);
2503
+ }, ai = (e) => {
2504
+ if (G(e)) return Fr(e);
2502
2505
  let { path: t, offset: n } = e.cursor, r = K(e.root, t);
2503
2506
  if (n < r.length) {
2504
2507
  let i = r[n];
@@ -2506,15 +2509,15 @@ var Zr = (e) => {
2506
2509
  path: t,
2507
2510
  offset: n
2508
2511
  });
2509
- if (i.kind === "function") return q(e, t, n, 1, z(Lr(i.name).slice(1)), {
2512
+ if (i.kind === "function") return q(e, t, n, 1, R(Rr(i.name).slice(1)), {
2510
2513
  path: t,
2511
2514
  offset: n
2512
2515
  });
2513
- if (wr(i)) return q(e, t, n, 1, [], {
2516
+ if (Tr(i)) return q(e, t, n, 1, [], {
2514
2517
  path: t,
2515
2518
  offset: n
2516
2519
  });
2517
- let [a] = A(i)[0];
2520
+ let [a] = k(i)[0];
2518
2521
  return {
2519
2522
  root: e.root,
2520
2523
  cursor: {
@@ -2526,17 +2529,17 @@ var Zr = (e) => {
2526
2529
  }
2527
2530
  };
2528
2531
  }
2529
- let i = Tr(e);
2532
+ let i = Er(e);
2530
2533
  if (!i) return e;
2531
2534
  if (i.atom.kind === "piecewise") {
2532
- let t = Nr(e, i);
2535
+ let t = Pr(e, i);
2533
2536
  if (t) return t;
2534
2537
  }
2535
- if (wr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
2538
+ if (Tr(i.atom)) return q(e, i.rowPath, i.index, 1, [], {
2536
2539
  path: i.rowPath,
2537
2540
  offset: i.index
2538
2541
  });
2539
- let a = A(i.atom), o = a.findIndex(([e]) => e === i.branch);
2542
+ let a = k(i.atom), o = a.findIndex(([e]) => e === i.branch);
2540
2543
  if (o < a.length - 1) {
2541
2544
  let [t] = a[o + 1];
2542
2545
  return {
@@ -2550,9 +2553,9 @@ var Zr = (e) => {
2550
2553
  }
2551
2554
  };
2552
2555
  }
2553
- return Er(e, i, a.reduce((e, [, t]) => e + t.length, 0));
2556
+ return Dr(e, i, a.reduce((e, [, t]) => e + t.length, 0));
2554
2557
  };
2555
- function ai(e) {
2558
+ function oi(e) {
2556
2559
  return (t) => {
2557
2560
  let n = $n(t.root);
2558
2561
  if (n.filter(({ path: e }) => K(t.root, e).length === 0).length === 0) return t;
@@ -2563,18 +2566,18 @@ function ai(e) {
2563
2566
  };
2564
2567
  };
2565
2568
  }
2566
- function oi(e) {
2569
+ function si(e) {
2567
2570
  return (t) => {
2568
2571
  let n = G(t);
2569
2572
  if (n) {
2570
2573
  let { path: r, start: i, end: a } = n, o = K(t.root, r).slice(i, a);
2571
- return q(t, r, i, a - i, [ye(e), R(o, "(")], {
2574
+ return q(t, r, i, a - i, [F(e), L(o, "(")], {
2572
2575
  path: r,
2573
2576
  offset: i + 2
2574
2577
  });
2575
2578
  }
2576
- let r = Pr(t), { path: i, offset: a } = r.cursor;
2577
- return q(r, i, a, 0, [ye(e), R([], "(")], {
2579
+ let r = Fr(t), { path: i, offset: a } = r.cursor;
2580
+ return q(r, i, a, 0, [F(e), L([], "(")], {
2578
2581
  path: [...i, {
2579
2582
  atom: a + 1,
2580
2583
  branch: "body"
@@ -2583,39 +2586,39 @@ function oi(e) {
2583
2586
  });
2584
2587
  };
2585
2588
  }
2586
- var si = Ir((e) => xe(e), "after", "body"), ci = Ir((e) => xe(e, []), "index", "index"), li = Ir((e) => R(e, "|"), "after", "body"), ui = Ir((e) => Se(e, []), "variable", "expr");
2587
- function di(e) {
2589
+ var ci = Lr((e) => Se(e), "after", "body"), li = Lr((e) => Se(e, []), "index", "index"), ui = Lr((e) => L(e, "|"), "after", "body"), di = Lr((e) => Ce(e, []), "variable", "expr");
2590
+ function fi(e) {
2588
2591
  switch (e) {
2589
2592
  case "frac":
2590
- case "fraction": return Hr;
2591
- case "sqrt": return si;
2592
- case "root": return ci;
2593
- case "abs": return li;
2593
+ case "fraction": return Ur;
2594
+ case "sqrt": return ci;
2595
+ case "root": return li;
2596
+ case "abs": return ui;
2594
2597
  case "dd":
2595
2598
  case "diff":
2596
- case "derivative": return ui;
2599
+ case "derivative": return di;
2597
2600
  case "pow":
2598
- case "power": return Wr;
2601
+ case "power": return Gr;
2599
2602
  case "cases":
2600
- case "piecewise": return Br;
2601
- case "otherwise": return jr;
2602
- case "units": return Yr;
2603
+ case "piecewise": return Vr;
2604
+ case "otherwise": return Mr;
2605
+ case "units": return Xr;
2603
2606
  case "floor":
2604
- case "lfloor": return Qr;
2607
+ case "lfloor": return $r;
2605
2608
  case "ceil":
2606
2609
  case "ceiling":
2607
- case "lceil": return $r;
2610
+ case "lceil": return ei;
2608
2611
  }
2609
2612
  let t = Tt(e);
2610
2613
  if (t) return J(t.symbol);
2611
2614
  let n = ke(e);
2612
2615
  if (n) return J(n.symbol);
2613
2616
  let r = Je(e);
2614
- return r ? oi(r) : Rr(Ke.has(e) ? [I(e)] : z(e));
2617
+ return r ? si(r) : zr(Ke.has(e) ? [P(e)] : R(e));
2615
2618
  }
2616
2619
  //#endregion
2617
2620
  //#region src/editor/history.ts
2618
- var fi = { kind: "other" }, pi = /* @__PURE__ */ new Set([
2621
+ var pi = { kind: "other" }, mi = /* @__PURE__ */ new Set([
2619
2622
  "+",
2620
2623
  "-",
2621
2624
  "=",
@@ -2631,11 +2634,11 @@ var fi = { kind: "other" }, pi = /* @__PURE__ */ new Set([
2631
2634
  "⊻",
2632
2635
  "¬"
2633
2636
  ]);
2634
- function mi(e, t) {
2637
+ function hi(e, t) {
2635
2638
  switch (t.kind) {
2636
2639
  case "type": return {
2637
2640
  key: `type:${e}`,
2638
- fresh: !!t.replacedSelection || pi.has(t.text ?? "") && !t.exponentSign
2641
+ fresh: !!t.replacedSelection || mi.has(t.text ?? "") && !t.exponentSign
2639
2642
  };
2640
2643
  case "deleteBackward":
2641
2644
  case "deleteForward": return t.replacedSelection ? {
@@ -2651,7 +2654,7 @@ function mi(e, t) {
2651
2654
  };
2652
2655
  }
2653
2656
  }
2654
- var hi = class {
2657
+ var gi = class {
2655
2658
  undoStack = [];
2656
2659
  redoStack = [];
2657
2660
  openGroup = null;
@@ -2689,43 +2692,43 @@ var hi = class {
2689
2692
  let t = this.redoStack.pop();
2690
2693
  return t === void 0 ? null : (this.undoStack.push(e), this.breakGroup(), t);
2691
2694
  }
2692
- }, gi = /^[A-Za-z0-9_.+\-=,]$/;
2693
- function _i(e) {
2694
- return gi.test(e.key) ? e.key : e.key in Ot ? Ot[e.key] : e.key === "*" ? "·" : null;
2695
- }
2695
+ }, _i = /^[A-Za-z0-9_.+\-=,]$/;
2696
2696
  function vi(e) {
2697
- let { key: t } = e, n = _i(e);
2698
- if (n === "=") return zr;
2699
- if (n !== null) return Xr(n);
2697
+ return _i.test(e.key) ? e.key : e.key in Ot ? Ot[e.key] : e.key === "*" ? "·" : null;
2698
+ }
2699
+ function yi(e) {
2700
+ let { key: t } = e, n = vi(e);
2701
+ if (n === "=") return Br;
2702
+ if (n !== null) return Zr(n);
2700
2703
  switch (t) {
2701
- case "/": return Ur;
2702
- case "^": return Wr;
2703
- case "(": return Jr;
2704
- case ")": return ei;
2705
- case "{": return Yr;
2706
- case "}": return Zr;
2707
- case "|": return ti;
2708
- case " ": return ni;
2709
- case "Backspace": return ri;
2710
- case "Delete": return ii;
2711
- case "Tab": return ai(e.shiftKey ? "backward" : "forward");
2712
- case "Enter": return e.shiftKey ? null : Ar;
2704
+ case "/": return Wr;
2705
+ case "^": return Gr;
2706
+ case "(": return Yr;
2707
+ case ")": return ti;
2708
+ case "{": return Xr;
2709
+ case "}": return Qr;
2710
+ case "|": return ni;
2711
+ case " ": return ri;
2712
+ case "Backspace": return ii;
2713
+ case "Delete": return ai;
2714
+ case "Tab": return oi(e.shiftKey ? "backward" : "forward");
2715
+ case "Enter": return e.shiftKey ? null : jr;
2713
2716
  default: return null;
2714
2717
  }
2715
2718
  }
2716
2719
  //#endregion
2717
2720
  //#region src/editor/mathmlImport.ts
2718
- var yi = "http://www.w3.org/1998/Math/MathML", bi = "http://www.cellml.org/cellml/2.0#";
2719
- function xi(e) {
2721
+ var bi = "http://www.w3.org/1998/Math/MathML", xi = "http://www.cellml.org/cellml/2.0#";
2722
+ function Si(e) {
2720
2723
  return /^\s*(<\?xml[^>]*\?>\s*)?(<!--[\s\S]*?-->\s*)*<([A-Za-z_][\w.-]*:)?(math|apply|piecewise|ci|cn)\b/.test(e);
2721
2724
  }
2722
- function Si(e) {
2723
- let t = `<wrapper xmlns="${yi}" xmlns:cellml="${bi}">${e.replace(/^\s*<\?xml[^>]*\?>/, "")}</wrapper>`, n = new DOMParser().parseFromString(t, "application/xml");
2725
+ function Ci(e) {
2726
+ let t = `<wrapper xmlns="${bi}" xmlns:cellml="${xi}">${e.replace(/^\s*<\?xml[^>]*\?>/, "")}</wrapper>`, n = new DOMParser().parseFromString(t, "application/xml");
2724
2727
  if (n.getElementsByTagName("parsererror").length > 0) return null;
2725
- let r = n.documentElement, i = Ci(r).filter((e) => e.localName === "math"), a = (i.length ? i.flatMap(Ci) : Ci(r)).map((e) => {
2728
+ let r = n.documentElement, i = wi(r).filter((e) => e.localName === "math"), a = (i.length ? i.flatMap(wi) : wi(r)).map((e) => {
2726
2729
  let t = /* @__PURE__ */ new Set();
2727
2730
  return {
2728
- row: new ki(t).expression(e).row,
2731
+ row: new Ai(t).expression(e).row,
2729
2732
  problems: [...t]
2730
2733
  };
2731
2734
  });
@@ -2735,7 +2738,7 @@ function Si(e) {
2735
2738
  lineProblems: a.map((e) => e.problems)
2736
2739
  };
2737
2740
  }
2738
- var Ci = (e) => Array.from(e.children), Y = {
2741
+ var wi = (e) => Array.from(e.children), Y = {
2739
2742
  Or: 1,
2740
2743
  Xor: 2,
2741
2744
  And: 3,
@@ -2745,7 +2748,7 @@ var Ci = (e) => Array.from(e.children), Y = {
2745
2748
  Unary: 7,
2746
2749
  Term: 8,
2747
2750
  Primary: 9
2748
- }, wi = {
2751
+ }, Ti = {
2749
2752
  or: {
2750
2753
  symbol: "∨",
2751
2754
  level: Y.Or
@@ -2758,7 +2761,7 @@ var Ci = (e) => Array.from(e.children), Y = {
2758
2761
  symbol: "∧",
2759
2762
  level: Y.And
2760
2763
  }
2761
- }, Ti = new Map(yt.filter((e) => e.role === "comparison").map((e) => [e.mathml, e.symbol])), Ei = new Map(Te.map((e) => [e.mathml, e.symbol])), Di = new Map(Object.values(ze).map((e) => [e.mathMlTag, e.name])), Oi = /^[A-Za-z_][A-Za-z0-9_]*$/, ki = class {
2764
+ }, Ei = new Map(yt.filter((e) => e.role === "comparison").map((e) => [e.mathml, e.symbol])), Di = new Map(Ee.map((e) => [e.mathml, e.symbol])), Oi = new Map(Object.values(ze).map((e) => [e.mathMlTag, e.name])), ki = /^[A-Za-z_][A-Za-z0-9_]*$/, Ai = class {
2762
2765
  problems;
2763
2766
  constructor(e) {
2764
2767
  this.problems = e;
@@ -2770,8 +2773,8 @@ var Ci = (e) => Array.from(e.children), Y = {
2770
2773
  case "apply": return this.apply(e);
2771
2774
  case "piecewise": return this.piecewise(e);
2772
2775
  default: {
2773
- let t = Ei.get(e.localName);
2774
- return t ? X([I(t)]) : this.unsupported(`<${e.localName}>`);
2776
+ let t = Di.get(e.localName);
2777
+ return t ? X([P(t)]) : this.unsupported(`<${e.localName}>`);
2775
2778
  }
2776
2779
  }
2777
2780
  }
@@ -2780,43 +2783,43 @@ var Ci = (e) => Array.from(e.children), Y = {
2780
2783
  }
2781
2784
  identifier(e) {
2782
2785
  let t = (e.textContent ?? "").trim();
2783
- return t === "_" ? X([]) : Oi.test(t) ? (Je(t) ? this.problems.add(`The variable ${t} has the name of a function, so it reads as one here`) : tt(t) && this.problems.add(`The variable ${t} has a reserved name, so it reads as the constant here`), X(ft(t))) : (this.problems.add(`"${t}" isn't a CellML variable name`), X(z(t)));
2786
+ return t === "_" ? X([]) : ki.test(t) ? (Je(t) ? this.problems.add(`The variable ${t} has the name of a function, so it reads as one here`) : tt(t) && this.problems.add(`The variable ${t} has a reserved name, so it reads as the constant here`), X(V(t))) : (this.problems.add(`"${t}" isn't a CellML variable name`), X(R(t)));
2784
2787
  }
2785
2788
  number(e) {
2786
- let t = Pi(e), n;
2789
+ let t = Fi(e), n;
2787
2790
  if (e.getAttribute("type") === "e-notation") {
2788
- let t = Ci(e).find((e) => e.localName === "sep"), r = t ? Fi(e, t) : e.textContent ?? "", i = t ? Ii(e, t) : "0";
2791
+ let t = wi(e).find((e) => e.localName === "sep"), r = t ? Ii(e, t) : e.textContent ?? "", i = t ? Li(e, t) : "0";
2789
2792
  n = `${r.trim()}e${i.trim()}`;
2790
2793
  } else n = (e.textContent ?? "").trim();
2791
2794
  let r = n.startsWith("-"), i = r ? n.slice(1) : n.replace(/^\+/, "");
2792
2795
  /^(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(i) || this.problems.add(`"${n}" isn't a number`);
2793
- let a = z(i);
2794
- return t && t !== "dimensionless" && (Oi.test(t) || this.problems.add(`"${t}" isn't a units name`), a.push(Ce(z(t)))), r ? {
2795
- row: [I("-"), ...a],
2796
+ let a = R(i);
2797
+ return t && t !== "dimensionless" && (ki.test(t) || this.problems.add(`"${t}" isn't a units name`), a.push(we(R(t)))), r ? {
2798
+ row: [P("-"), ...a],
2796
2799
  level: Y.Unary
2797
2800
  } : X(a);
2798
2801
  }
2799
2802
  apply(e) {
2800
- let [t, ...n] = Ci(e);
2803
+ let [t, ...n] = wi(e);
2801
2804
  if (!t) return this.unsupported("An empty <apply>");
2802
- let r = n.filter((e) => Ai.has(e.localName)), i = n.filter((e) => !Ai.has(e.localName)), a = () => i.map((e) => this.expression(e)), o = t.localName;
2803
- if (o === "eq" || Ti.has(o)) {
2805
+ let r = n.filter((e) => ji.has(e.localName)), i = n.filter((e) => !ji.has(e.localName)), a = () => i.map((e) => this.expression(e)), o = t.localName;
2806
+ if (o === "eq" || Ei.has(o)) {
2804
2807
  let [e, t] = a();
2805
2808
  if (!e || !t || i.length !== 2) return this.unsupported(`<${o}> without two operands`);
2806
- let n = o === "eq" ? "=" : Ti.get(o);
2809
+ let n = o === "eq" ? "=" : Ei.get(o);
2807
2810
  return {
2808
2811
  row: [
2809
- ...Mi(e, Y.Additive),
2810
- I(n),
2811
- ...Mi(t, Y.Additive)
2812
+ ...Ni(e, Y.Additive),
2813
+ P(n),
2814
+ ...Ni(t, Y.Additive)
2812
2815
  ],
2813
2816
  level: Y.Comparison
2814
2817
  };
2815
2818
  }
2816
- if (wi[o]) {
2817
- let { symbol: e, level: t } = wi[o];
2819
+ if (Ti[o]) {
2820
+ let { symbol: e, level: t } = Ti[o];
2818
2821
  return {
2819
- row: Ni(a(), e, t),
2822
+ row: Pi(a(), e, t),
2820
2823
  level: t
2821
2824
  };
2822
2825
  }
@@ -2824,111 +2827,111 @@ var Ci = (e) => Array.from(e.children), Y = {
2824
2827
  case "not": {
2825
2828
  let [e] = a();
2826
2829
  return e ? {
2827
- row: [I("¬"), ...Mi(e, Y.Not)],
2830
+ row: [P("¬"), ...Ni(e, Y.Not)],
2828
2831
  level: Y.Not
2829
2832
  } : this.unsupported("<not> without an operand");
2830
2833
  }
2831
2834
  case "plus": return {
2832
- row: Ni(a(), "+", Y.Additive),
2835
+ row: Pi(a(), "+", Y.Additive),
2833
2836
  level: Y.Additive
2834
2837
  };
2835
2838
  case "minus": {
2836
2839
  let e = a();
2837
2840
  if (e.length === 1) return {
2838
- row: [I("-"), ...Mi(e[0], Y.Term)],
2841
+ row: [P("-"), ...Ni(e[0], Y.Term)],
2839
2842
  level: Y.Unary
2840
2843
  };
2841
2844
  if (e.length !== 2) return this.unsupported("<minus> with more than two operands");
2842
2845
  let [t, n] = e;
2843
2846
  return {
2844
2847
  row: [
2845
- ...Mi(t, Y.Additive),
2846
- I("-"),
2847
- ...Mi(n, Y.Term)
2848
+ ...Ni(t, Y.Additive),
2849
+ P("-"),
2850
+ ...Ni(n, Y.Term)
2848
2851
  ],
2849
2852
  level: Y.Additive
2850
2853
  };
2851
2854
  }
2852
2855
  case "times": return {
2853
- row: Ni(a(), "·", Y.Term),
2856
+ row: Pi(a(), "·", Y.Term),
2854
2857
  level: Y.Term
2855
2858
  };
2856
2859
  case "divide": {
2857
2860
  let [e, t] = a();
2858
- return !e || !t ? this.unsupported("<divide> without two operands") : X([L(e.row, t.row)]);
2861
+ return !e || !t ? this.unsupported("<divide> without two operands") : X([xe(e.row, t.row)]);
2859
2862
  }
2860
2863
  case "power": {
2861
2864
  let [e, t] = a();
2862
- return !e || !t ? this.unsupported("<power> without two operands") : X([...Mi(e, Y.Primary), be(t.row)]);
2865
+ return !e || !t ? this.unsupported("<power> without two operands") : X([...Ni(e, Y.Primary), I(t.row)]);
2863
2866
  }
2864
2867
  case "root": {
2865
2868
  let [e] = a();
2866
2869
  if (!e) return this.unsupported("<root> without an operand");
2867
- let t = ji(r, "degree"), n = t ? this.inner(t) : null;
2868
- return X([xe(e.row, n)]);
2870
+ let t = Mi(r, "degree"), n = t ? this.inner(t) : null;
2871
+ return X([Se(e.row, n)]);
2869
2872
  }
2870
2873
  case "abs": {
2871
2874
  let [e] = a();
2872
- return e ? X([R(e.row, "|")]) : this.unsupported("<abs> without an operand");
2875
+ return e ? X([L(e.row, "|")]) : this.unsupported("<abs> without an operand");
2873
2876
  }
2874
2877
  case "diff": return this.derivative(r, i);
2875
2878
  default: return this.functionCall(o, r, a());
2876
2879
  }
2877
2880
  }
2878
2881
  functionCall(e, t, n) {
2879
- let r = Di.get(e);
2882
+ let r = Oi.get(e);
2880
2883
  if (!r) return this.unsupported(`<${e}>`);
2881
2884
  if (n.length === 0) return this.unsupported(`<${e}> without an operand`);
2882
2885
  let i = Ue(r);
2883
- if (i && n.length === 1) return X([R(n[0].row, i.open, i.close)]);
2884
- let a = e === "log" ? ji(t, "logbase") : void 0, o = (a ? [n[0], {
2886
+ if (i && n.length === 1) return X([L(n[0].row, i.open, i.close)]);
2887
+ let a = e === "log" ? Mi(t, "logbase") : void 0, o = (a ? [n[0], {
2885
2888
  row: this.inner(a),
2886
2889
  level: Y.Primary
2887
- }] : n).flatMap((e, t) => t === 0 ? e.row : [I(","), ...e.row]);
2888
- return X([ye(r), R(o)]);
2890
+ }] : n).flatMap((e, t) => t === 0 ? e.row : [P(","), ...e.row]);
2891
+ return X([F(r), L(o)]);
2889
2892
  }
2890
2893
  derivative(e, t) {
2891
- let n = ji(e, "bvar"), [r] = t;
2894
+ let n = Mi(e, "bvar"), [r] = t;
2892
2895
  if (!n || !r) return this.unsupported("<diff> without <bvar> and an operand");
2893
- let i = Ci(n).find((e) => e.localName === "ci"), a = Ci(n).find((e) => e.localName === "degree");
2894
- return a && (a.textContent ?? "").trim() !== "1" ? this.unsupported("A derivative of order other than 1") : i ? X([Se(this.expression(r).row, this.expression(i).row)]) : this.unsupported("<bvar> without a <ci>");
2896
+ let i = wi(n).find((e) => e.localName === "ci"), a = wi(n).find((e) => e.localName === "degree");
2897
+ return a && (a.textContent ?? "").trim() !== "1" ? this.unsupported("A derivative of order other than 1") : i ? X([Ce(this.expression(r).row, this.expression(i).row)]) : this.unsupported("<bvar> without a <ci>");
2895
2898
  }
2896
2899
  piecewise(e) {
2897
2900
  let t = [], n = null, r = (e) => e ? this.expression(e).row : [];
2898
- for (let i of Ci(e)) {
2899
- let [e, a] = Ci(i);
2901
+ for (let i of wi(e)) {
2902
+ let [e, a] = wi(i);
2900
2903
  i.localName === "piece" ? ((!e || !a) && this.problems.add("A <piece> without a value and a condition"), t.push([r(e), r(a)])) : i.localName === "otherwise" ? (e || this.problems.add("An <otherwise> without a value"), n = r(e)) : this.problems.add(`<${i.localName}> in <piecewise> isn't supported; it was left out`);
2901
2904
  }
2902
- return t.length === 0 ? this.unsupported("A <piecewise> without a <piece>") : X([we(t, n)]);
2905
+ return t.length === 0 ? this.unsupported("A <piecewise> without a <piece>") : X([Te(t, n)]);
2903
2906
  }
2904
2907
  inner(e) {
2905
- let [t] = Ci(e);
2908
+ let [t] = wi(e);
2906
2909
  return t ? this.expression(t).row : [];
2907
2910
  }
2908
- }, Ai = /* @__PURE__ */ new Set([
2911
+ }, ji = /* @__PURE__ */ new Set([
2909
2912
  "bvar",
2910
2913
  "degree",
2911
2914
  "logbase"
2912
- ]), ji = (e, t) => e.find((e) => e.localName === t), X = (e) => ({
2915
+ ]), Mi = (e, t) => e.find((e) => e.localName === t), X = (e) => ({
2913
2916
  row: e,
2914
2917
  level: Y.Primary
2915
2918
  });
2916
- function Mi(e, t) {
2917
- return e.level < t ? [R(e.row)] : e.row;
2919
+ function Ni(e, t) {
2920
+ return e.level < t ? [L(e.row)] : e.row;
2918
2921
  }
2919
- function Ni(e, t, n) {
2922
+ function Pi(e, t, n) {
2920
2923
  let r = [];
2921
2924
  return e.forEach((e, i) => {
2922
- i > 0 && r.push(I(t));
2925
+ i > 0 && r.push(P(t));
2923
2926
  let a = e.level === Y.Unary && (t === "+" && i > 0 || t === "·" && i === 0) ? Y.Unary : n;
2924
- r.push(...Mi(e, a));
2927
+ r.push(...Ni(e, a));
2925
2928
  }), r;
2926
2929
  }
2927
- function Pi(e) {
2930
+ function Fi(e) {
2928
2931
  for (let t of Array.from(e.attributes)) if (t.localName === "units" && (t.prefix === "cellml" || t.namespaceURI?.includes("cellml.org"))) return t.value.trim();
2929
2932
  return null;
2930
2933
  }
2931
- function Fi(e, t) {
2934
+ function Ii(e, t) {
2932
2935
  let n = "";
2933
2936
  for (let r of Array.from(e.childNodes)) {
2934
2937
  if (r === t) break;
@@ -2936,14 +2939,14 @@ function Fi(e, t) {
2936
2939
  }
2937
2940
  return n;
2938
2941
  }
2939
- function Ii(e, t) {
2942
+ function Li(e, t) {
2940
2943
  let n = "", r = !1;
2941
2944
  for (let i of Array.from(e.childNodes)) r && (n += i.textContent ?? ""), i === t && (r = !0);
2942
2945
  return n;
2943
2946
  }
2944
2947
  //#endregion
2945
2948
  //#region src/editor/marks.ts
2946
- var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-invalid"], Bi = ["data-kind"], Vi = ["innerHTML"], Hi = /*@__PURE__*/ l({
2949
+ var Ri = (e) => e.kind ?? "error", zi = (e) => Ri(e) !== "hint", Bi = ["aria-invalid"], Vi = ["data-kind"], Hi = ["innerHTML"], Ui = /*@__PURE__*/ l({
2947
2950
  __name: "MathField",
2948
2951
  props: {
2949
2952
  modelValue: {},
@@ -2973,7 +2976,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
2973
2976
  "import"
2974
2977
  ],
2975
2978
  setup(n, { expose: o, emit: s }) {
2976
- let c = n, l = s, u = _(null), d = _(!1), h = _(null), ne = _(!1), re = _(null), b = _(null), x = _([]), C = _(null), ie = _(0);
2979
+ let c = n, l = s, u = _(null), d = _(!1), h = _(null), ne = _(!1), re = _(null), b = _(null), x = _([]), C = _(null), ie = _(null), ae = _(0);
2977
2980
  function w() {
2978
2981
  return {
2979
2982
  root: c.modelValue,
@@ -2982,23 +2985,23 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
2982
2985
  };
2983
2986
  }
2984
2987
  let T = t(() => G(w())), E = t(() => {
2985
- let e = new Set(c.marks.filter(Ri).flatMap((e) => e.atomIds)), t = c.active ? Ln(c.modelValue, c.cursor) : null;
2988
+ let e = new Set(c.marks.filter(zi).flatMap((e) => e.atomIds)), t = c.active ? Ln(c.modelValue, c.cursor) : null;
2986
2989
  return t && e.add(t), e;
2987
- }), D = t(() => oe.renderToString(Ht(c.modelValue, {
2990
+ }), D = t(() => se.renderToString(Ht(c.modelValue, {
2988
2991
  activeRow: c.active ? c.cursor.path : null,
2989
2992
  shownUnits: E.value,
2990
2993
  greekNames: c.greekNames,
2991
2994
  typesetNames: c.typesetNames,
2992
2995
  cursors: c.active ? [c.cursor, c.anchor] : []
2993
- }), Kt)), O = t(() => c.active && d.value && !T.value && h.value !== null && !ne.value), k = t(() => c.active && d.value && b.value !== null), se = t(() => c.active && re.value !== null);
2994
- function ce() {
2996
+ }), Kt)), O = t(() => c.active && d.value && !T.value && h.value !== null && !ne.value), ce = t(() => c.active && d.value && b.value !== null), le = t(() => c.active && re.value !== null);
2997
+ function ue() {
2995
2998
  let e = u.value, t = e ? tn(e, c.modelValue, c.cursor) : null;
2996
2999
  h.value = t ? {
2997
3000
  left: `${t.left}px`,
2998
3001
  top: `${t.top}px`,
2999
3002
  height: `${t.height}px`
3000
3003
  } : null, ne.value = t?.placeholder ?? !1;
3001
- let n = c.cursor.path, r = e && n.length > 0 && N(c.modelValue, n)?.length ? cn(e, n) : null;
3004
+ let n = c.cursor.path, r = e && n.length > 0 && M(c.modelValue, n)?.length ? cn(e, n) : null;
3002
3005
  b.value = r ? {
3003
3006
  left: `${r.left}px`,
3004
3007
  top: `${r.top}px`,
@@ -3016,11 +3019,11 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3016
3019
  return n ? [{
3017
3020
  box: n,
3018
3021
  message: t.message,
3019
- kind: Li(t)
3022
+ kind: Ri(t)
3020
3023
  }] : [];
3021
3024
  }) : [], C.value = null;
3022
3025
  }
3023
- function le(e) {
3026
+ function de(e) {
3024
3027
  return {
3025
3028
  left: `${e.left}px`,
3026
3029
  top: `${e.top}px`,
@@ -3028,51 +3031,54 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3028
3031
  height: `${e.height + 4}px`
3029
3032
  };
3030
3033
  }
3031
- function ue(e) {
3034
+ function fe(e) {
3032
3035
  let t = u.value;
3033
3036
  if (!t || A || x.value.length === 0) {
3034
3037
  C.value = null;
3035
3038
  return;
3036
3039
  }
3037
- let n = t.getBoundingClientRect(), r = e.clientX - n.left + t.scrollLeft, i = e.clientY - n.top + t.scrollTop, a = x.value.filter(({ box: e }) => r >= e.left && r <= e.left + e.width && i >= e.top && i <= e.top + e.height + 4), o = a.find((e) => e.kind !== "hint") ?? a[0];
3040
+ let n = t.getBoundingClientRect(), r = e.clientX - n.left + t.scrollLeft, i = e.clientY - n.top + t.scrollTop, a = x.value.filter(({ box: e }) => r >= e.left && r <= e.left + e.width && i >= e.top && i <= e.top + e.height + 4), o = a.find((e) => e.kind !== "hint") ?? a[0], s = ie.value?.getBoundingClientRect() ?? {
3041
+ left: 0,
3042
+ top: 0
3043
+ };
3038
3044
  C.value = o ? {
3039
3045
  message: o.message,
3040
- left: n.left + o.box.left - t.scrollLeft,
3041
- top: n.top + o.box.top + o.box.height + 6 - t.scrollTop
3046
+ left: n.left + o.box.left - t.scrollLeft - s.left,
3047
+ top: n.top + o.box.top + o.box.height + 6 - t.scrollTop - s.top
3042
3048
  } : null;
3043
3049
  }
3044
- ae([
3050
+ oe([
3045
3051
  D,
3046
3052
  () => c.cursor,
3047
3053
  () => c.anchor,
3048
3054
  () => c.active,
3049
3055
  () => c.marks
3050
3056
  ], async () => {
3051
- await f(), ce(), ie.value++;
3057
+ await f(), ue(), ae.value++;
3052
3058
  }, {
3053
3059
  immediate: !0,
3054
3060
  deep: !0
3055
3061
  }), te(() => {
3056
- window.addEventListener("resize", ce), document.addEventListener("copy", I), document.addEventListener("cut", ye), document.addEventListener("paste", L), document.fonts?.ready.then(ce);
3062
+ window.addEventListener("resize", ue), document.addEventListener("copy", F), document.addEventListener("cut", xe), document.addEventListener("paste", I), document.fonts?.ready.then(ue);
3057
3063
  }), ee(() => {
3058
- window.removeEventListener("resize", ce), document.removeEventListener("copy", I), document.removeEventListener("cut", ye), document.removeEventListener("paste", L), ve();
3064
+ window.removeEventListener("resize", ue), document.removeEventListener("copy", F), document.removeEventListener("cut", xe), document.removeEventListener("paste", I), be();
3059
3065
  });
3060
- let de = (e, t) => {
3066
+ let pe = (e, t) => {
3061
3067
  let n = u.value, r = n ? tn(n, c.modelValue, c.cursor) : null;
3062
3068
  if (!n || !r) return c.cursor.offset;
3063
3069
  let i = n.getBoundingClientRect().left + r.left - n.scrollLeft;
3064
3070
  return nn(n, c.modelValue, t, i);
3065
3071
  };
3066
- function fe(e) {
3072
+ function me(e) {
3067
3073
  l("navigate", {
3068
3074
  cursor: e.cursor,
3069
3075
  anchor: e.anchor ?? null
3070
3076
  });
3071
3077
  }
3072
- function pe(e) {
3078
+ function he(e) {
3073
3079
  let t = w();
3074
3080
  if ((e.ctrlKey || e.metaKey) && !e.altKey && e.key.toLowerCase() === "a") {
3075
- e.preventDefault(), fe(hr(t));
3081
+ e.preventDefault(), me(hr(t));
3076
3082
  return;
3077
3083
  }
3078
3084
  if (e.altKey || e.ctrlKey || e.metaKey) return;
@@ -3086,7 +3092,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3086
3092
  }
3087
3093
  case "ArrowUp":
3088
3094
  case "ArrowDown":
3089
- if (n = yr(t, e.key === "ArrowUp" ? "up" : "down", de), !n) return;
3095
+ if (n = yr(t, e.key === "ArrowUp" ? "up" : "down", pe), !n) return;
3090
3096
  break;
3091
3097
  case "Home":
3092
3098
  case "End": {
@@ -3103,32 +3109,32 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3103
3109
  n = _r(t);
3104
3110
  break;
3105
3111
  default:
3106
- he(e, t);
3112
+ _e(e, t);
3107
3113
  return;
3108
3114
  }
3109
- e.preventDefault(), n && fe(n);
3115
+ e.preventDefault(), n && me(n);
3110
3116
  }
3111
- let me = /* @__PURE__ */ new Set([
3117
+ let ge = /* @__PURE__ */ new Set([
3112
3118
  "Backspace",
3113
3119
  "Delete",
3114
3120
  "Tab",
3115
3121
  "Enter"
3116
3122
  ]);
3117
- function he(e, t) {
3123
+ function _e(e, t) {
3118
3124
  if (c.readonly) return;
3119
- let n = vi(e);
3125
+ let n = yi(e);
3120
3126
  if (!n) return;
3121
3127
  let r = n(t);
3122
3128
  if (r === t) {
3123
- me.has(e.key) || e.preventDefault();
3129
+ ge.has(e.key) || e.preventDefault();
3124
3130
  return;
3125
3131
  }
3126
- e.preventDefault(), l("edit", r, ge(e, t));
3132
+ e.preventDefault(), l("edit", r, k(e, t));
3127
3133
  }
3128
- function ge(e, t) {
3129
- let n = G(t) !== null, r = _i(e);
3134
+ function k(e, t) {
3135
+ let n = G(t) !== null, r = vi(e);
3130
3136
  if (r !== null) {
3131
- let e = N(t.root, t.cursor.path), i = t.cursor.offset - +!!Fn(e?.[t.cursor.offset - 1]);
3137
+ let e = M(t.root, t.cursor.path), i = t.cursor.offset - +!!Fn(e?.[t.cursor.offset - 1]);
3132
3138
  return {
3133
3139
  kind: "type",
3134
3140
  text: r,
@@ -3142,49 +3148,49 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3142
3148
  } : e.key === "Delete" ? {
3143
3149
  kind: "deleteForward",
3144
3150
  replacedSelection: n
3145
- } : fi;
3151
+ } : pi;
3146
3152
  }
3147
3153
  let A = null;
3148
- function _e(e) {
3154
+ function ve(e) {
3149
3155
  let t = u.value;
3150
3156
  return t ? an(t, c.modelValue, e.clientX, e.clientY) : null;
3151
3157
  }
3152
3158
  function j(e) {
3153
3159
  if (e.preventDefault(), C.value = null, e.button !== 0) return;
3154
- let t = _e(e);
3160
+ let t = ve(e);
3155
3161
  if (!t) return;
3156
3162
  u.value?.focus();
3157
3163
  let n = w();
3158
- A = e.shiftKey ? n.anchor ?? n.cursor : t, fe(gr(n, A, t)), window.addEventListener("mousemove", M), window.addEventListener("mouseup", ve);
3164
+ A = e.shiftKey ? n.anchor ?? n.cursor : t, me(gr(n, A, t)), window.addEventListener("mousemove", ye), window.addEventListener("mouseup", be);
3159
3165
  }
3160
- function M(e) {
3166
+ function ye(e) {
3161
3167
  if (!A) return;
3162
- let t = _e(e);
3163
- t && fe(gr(w(), A, t));
3168
+ let t = ve(e);
3169
+ t && me(gr(w(), A, t));
3164
3170
  }
3165
- function ve() {
3166
- A = null, window.removeEventListener("mousemove", M), window.removeEventListener("mouseup", ve);
3171
+ function be() {
3172
+ A = null, window.removeEventListener("mousemove", ye), window.removeEventListener("mouseup", be);
3167
3173
  }
3168
- let P = () => !!u.value && document.activeElement === u.value;
3169
- function F(e) {
3174
+ let N = () => !!u.value && document.activeElement === u.value;
3175
+ function P(e) {
3170
3176
  let t = ur(w());
3171
3177
  return t.length === 0 || !e.clipboardData ? !1 : (e.preventDefault(), e.clipboardData.setData("text/plain", W(t, {
3172
3178
  greekNames: c.greekNames,
3173
3179
  typesetNames: c.typesetNames
3174
3180
  })), e.clipboardData.setData(ln, un(t)), !0);
3175
3181
  }
3176
- function I(e) {
3177
- P() && F(e);
3182
+ function F(e) {
3183
+ N() && P(e);
3178
3184
  }
3179
- function ye(e) {
3180
- P() && !c.readonly && F(e) && l("edit", ri(w()), fi);
3185
+ function xe(e) {
3186
+ N() && !c.readonly && P(e) && l("edit", ii(w()), pi);
3181
3187
  }
3182
- function L(e) {
3183
- if (!P() || c.readonly || !e.clipboardData) return;
3188
+ function I(e) {
3189
+ if (!N() || c.readonly || !e.clipboardData) return;
3184
3190
  e.preventDefault();
3185
3191
  let t = e.clipboardData, n = dn(t.getData(ln)), r = t.getData("text/plain");
3186
- if (!n && xi(r)) {
3187
- l("import", Si(r) ?? {
3192
+ if (!n && Si(r)) {
3193
+ l("import", Ci(r) ?? {
3188
3194
  equations: [],
3189
3195
  problems: ["The pasted MathML isn't well-formed XML, so nothing was imported"],
3190
3196
  lineProblems: []
@@ -3192,7 +3198,7 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3192
3198
  return;
3193
3199
  }
3194
3200
  let i = n ?? Pn(r);
3195
- i.length > 0 && l("edit", Rr(i)(w()), fi);
3201
+ i.length > 0 && l("edit", zr(i)(w()), pi);
3196
3202
  }
3197
3203
  return o({ focus: () => u.value?.focus() }), (t, o) => (g(), i("div", {
3198
3204
  ref_key: "surfaceEl",
@@ -3204,21 +3210,22 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3204
3210
  tabindex: "0",
3205
3211
  role: "textbox",
3206
3212
  "aria-label": "Equation",
3207
- "aria-invalid": n.marks.some(S(Ri)) || void 0,
3208
- onKeydown: pe,
3213
+ "aria-invalid": n.marks.some(S(zi)) || void 0,
3214
+ onKeydown: he,
3209
3215
  onMousedown: j,
3210
- onMousemove: ue,
3216
+ onMouseenter: ue,
3217
+ onMousemove: fe,
3211
3218
  onMouseleave: o[0] ||= (e) => C.value = null,
3212
3219
  onFocus: o[1] ||= (e) => d.value = !0,
3213
3220
  onBlur: o[2] ||= (e) => d.value = !1
3214
3221
  }, [
3215
- k.value ? (g(), i("div", {
3222
+ ce.value ? (g(), i("div", {
3216
3223
  key: 0,
3217
3224
  class: "row-tint",
3218
3225
  "data-role": "active-row",
3219
3226
  style: m(b.value)
3220
3227
  }, null, 4)) : r("", !0),
3221
- se.value ? (g(), i("div", {
3228
+ le.value ? (g(), i("div", {
3222
3229
  key: 1,
3223
3230
  class: "selection",
3224
3231
  style: m(re.value)
@@ -3228,17 +3235,17 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3228
3235
  class: p(["mark", `mark-${t.kind}`]),
3229
3236
  "data-role": "mark",
3230
3237
  "data-kind": t.kind,
3231
- style: m(le(t.box))
3232
- }, null, 14, Bi))], 64))), 128)),
3238
+ style: m(de(t.box))
3239
+ }, null, 14, Vi))], 64))), 128)),
3233
3240
  O.value ? (g(), i("div", {
3234
- key: ie.value,
3241
+ key: ae.value,
3235
3242
  class: "caret",
3236
3243
  style: m(h.value)
3237
3244
  }, null, 4)) : r("", !0),
3238
3245
  a("div", {
3239
3246
  class: "math-content",
3240
3247
  innerHTML: D.value
3241
- }, null, 8, Vi),
3248
+ }, null, 8, Hi),
3242
3249
  C.value ? (g(), i("div", {
3243
3250
  key: 3,
3244
3251
  class: "mark-tip",
@@ -3248,17 +3255,23 @@ var Li = (e) => e.kind ?? "error", Ri = (e) => Li(e) !== "hint", zi = ["aria-inv
3248
3255
  left: `${C.value.left}px`,
3249
3256
  top: `${C.value.top}px`
3250
3257
  })
3251
- }, y(C.value.message), 5)) : r("", !0)
3252
- ], 42, zi));
3253
- }
3254
- }), Ui = (e, t) => {
3258
+ }, y(C.value.message), 5)) : r("", !0),
3259
+ a("span", {
3260
+ ref_key: "fixedOriginEl",
3261
+ ref: ie,
3262
+ class: "fixed-origin",
3263
+ "aria-hidden": "true"
3264
+ }, null, 512)
3265
+ ], 42, Bi));
3266
+ }
3267
+ }), Wi = (e, t) => {
3255
3268
  let n = e.__vccOpts || e;
3256
3269
  for (let [e, r] of t) n[e] = r;
3257
3270
  return n;
3258
- }, Wi = /*#__PURE__*/ Ui(Hi, [["__scopeId", "data-v-5f9cc824"]]);
3271
+ }, Gi = /*#__PURE__*/ Wi(Ui, [["__scopeId", "data-v-c390dc95"]]);
3259
3272
  //#endregion
3260
3273
  //#region src/components/contentStable.ts
3261
- function Gi(e) {
3274
+ function Ki(e) {
3262
3275
  let n = null;
3263
3276
  return t(() => {
3264
3277
  let t = e(), r = JSON.stringify(t) ?? "";
@@ -3270,14 +3283,14 @@ function Gi(e) {
3270
3283
  }
3271
3284
  //#endregion
3272
3285
  //#region src/editor/parse.ts
3273
- function Ki(e) {
3286
+ function qi(e) {
3274
3287
  let t = [];
3275
3288
  return {
3276
- ast: ea(e, t),
3289
+ ast: ta(e, t),
3277
3290
  diagnostics: t
3278
3291
  };
3279
3292
  }
3280
- var qi = {
3293
+ var Ji = {
3281
3294
  "+": "+",
3282
3295
  "-": "-",
3283
3296
  "−": "-",
@@ -3287,7 +3300,7 @@ var qi = {
3287
3300
  "×": "*",
3288
3301
  ",": ",",
3289
3302
  ...Object.fromEntries(yt.map((e) => [e.symbol, e.symbol]))
3290
- }, Ji = /^[A-Za-z_][A-Za-z0-9_]*$/, Yi = [
3303
+ }, Yi = /^[A-Za-z_][A-Za-z0-9_]*$/, Xi = [
3291
3304
  {
3292
3305
  symbol: "∨",
3293
3306
  type: "Or"
@@ -3301,7 +3314,7 @@ var qi = {
3301
3314
  type: "And"
3302
3315
  }
3303
3316
  ];
3304
- function Xi(e, t) {
3317
+ function Zi(e, t) {
3305
3318
  let n = [], r = 0;
3306
3319
  for (; r < e.length;) {
3307
3320
  let i = e[r];
@@ -3375,12 +3388,12 @@ function Xi(e, t) {
3375
3388
  });
3376
3389
  continue;
3377
3390
  }
3378
- let o = qi[i.value], s = [i.id];
3391
+ let o = Ji[i.value], s = [i.id];
3379
3392
  o ? n.push({
3380
3393
  kind: "operator",
3381
3394
  op: o,
3382
3395
  atomIds: s
3383
- }) : Oe(i.value) ? n.push({
3396
+ }) : z(i.value) ? n.push({
3384
3397
  kind: "constant",
3385
3398
  name: i.value,
3386
3399
  atomIds: s
@@ -3396,19 +3409,19 @@ function Xi(e, t) {
3396
3409
  }
3397
3410
  return n;
3398
3411
  }
3399
- function Zi(e) {
3412
+ function Qi(e) {
3400
3413
  if (e === "=") return "Equal";
3401
3414
  let t = Ct(e);
3402
3415
  return t?.role === "comparison" ? t.type : null;
3403
3416
  }
3404
- var Qi = (e) => e === "*" ? "×" : e === "-" ? "−" : e;
3405
- function $i() {
3417
+ var $i = (e) => e === "*" ? "×" : e === "-" ? "−" : e;
3418
+ function ea() {
3406
3419
  return { type: "Placeholder" };
3407
3420
  }
3408
- function ea(e, t) {
3409
- return e.length === 0 ? $i() : new ta(Xi(e, t), t).parseAll();
3421
+ function ta(e, t) {
3422
+ return e.length === 0 ? ea() : new na(Zi(e, t), t).parseAll();
3410
3423
  }
3411
- var ta = class {
3424
+ var na = class {
3412
3425
  tokens;
3413
3426
  diagnostics;
3414
3427
  index = 0;
@@ -3421,8 +3434,8 @@ var ta = class {
3421
3434
  return e;
3422
3435
  }
3423
3436
  parseLogic(e) {
3424
- if (e === Yi.length) return this.parseNot();
3425
- let { symbol: t, type: n } = Yi[e], r = [this.parseLogic(e + 1)];
3437
+ if (e === Xi.length) return this.parseNot();
3438
+ let { symbol: t, type: n } = Xi[e], r = [this.parseLogic(e + 1)];
3426
3439
  for (; this.peekOperator(t);) this.next(), r.push(this.parseLogic(e + 1));
3427
3440
  return r.length === 1 ? r[0] : {
3428
3441
  type: n,
@@ -3438,7 +3451,7 @@ var ta = class {
3438
3451
  parseComparison() {
3439
3452
  let e = this.parseAdditive(), t = 0;
3440
3453
  for (;;) {
3441
- let n = this.peek(), r = n?.kind === "operator" ? Zi(n.op) : null;
3454
+ let n = this.peek(), r = n?.kind === "operator" ? Qi(n.op) : null;
3442
3455
  if (!n || !r) return e;
3443
3456
  this.next(), t++ > 0 && this.diagnostics.push({
3444
3457
  message: "Comparisons can't be chained: join them with ∧",
@@ -3511,12 +3524,12 @@ var ta = class {
3511
3524
  }
3512
3525
  parseSuperscript() {
3513
3526
  let e = this.next(), t = e.atom;
3514
- return t.kind === "superscript" ? this.child(t.sup, "Empty exponent", e.atomIds) : $i();
3527
+ return t.kind === "superscript" ? this.child(t.sup, "Empty exponent", e.atomIds) : ea();
3515
3528
  }
3516
3529
  parsePrimary() {
3517
3530
  this.skipInvalid();
3518
3531
  let e = this.peek();
3519
- if (!e || !this.startsPrimary(e)) return this.reportMissing(e), $i();
3532
+ if (!e || !this.startsPrimary(e)) return this.reportMissing(e), ea();
3520
3533
  switch (this.next(), e.kind) {
3521
3534
  case "number": return this.parseNumber(e);
3522
3535
  case "identifier": return {
@@ -3529,7 +3542,7 @@ var ta = class {
3529
3542
  };
3530
3543
  case "function": return this.parseFunction(e.name, e.atomIds);
3531
3544
  case "structure": return this.parseStructure(e.atom, e.atomIds);
3532
- default: return $i();
3545
+ default: return ea();
3533
3546
  }
3534
3547
  }
3535
3548
  parseNumber(e) {
@@ -3545,7 +3558,7 @@ var ta = class {
3545
3558
  }
3546
3559
  unitsName(e) {
3547
3560
  let t = e.atom.units.map((e) => e.kind === "symbol" ? e.value : "?").join("");
3548
- return Ji.test(t) ? t : (t && this.diagnostics.push({
3561
+ return Yi.test(t) ? t : (t && this.diagnostics.push({
3549
3562
  message: `"${t}" isn't a units name`,
3550
3563
  atomIds: e.atomIds
3551
3564
  }), null);
@@ -3558,7 +3571,7 @@ var ta = class {
3558
3571
  message: `${e} needs an argument`,
3559
3572
  atomIds: t,
3560
3573
  incomplete: !0
3561
- }), r = [$i()]);
3574
+ }), r = [ea()]);
3562
3575
  let a = {
3563
3576
  type: "FunctionCall",
3564
3577
  name: e,
@@ -3625,10 +3638,10 @@ var ta = class {
3625
3638
  }
3626
3639
  case "superscript": return {
3627
3640
  type: "Power",
3628
- base: $i(),
3641
+ base: ea(),
3629
3642
  exponent: this.child(e.sup)
3630
3643
  };
3631
- case "units": return $i();
3644
+ case "units": return ea();
3632
3645
  }
3633
3646
  }
3634
3647
  child(e, t, n) {
@@ -3636,13 +3649,13 @@ var ta = class {
3636
3649
  message: t,
3637
3650
  atomIds: n,
3638
3651
  incomplete: !0
3639
- }), ea(e, this.diagnostics);
3652
+ }), ta(e, this.diagnostics);
3640
3653
  }
3641
3654
  reportMissing(e) {
3642
3655
  let t = this.tokens[this.index - 1], n, r;
3643
- if (t?.kind === "operator" && t.op !== ",") n = Zi(t.op) ? t.op === "=" ? "Missing right-hand side" : `Missing right-hand side of ${t.op}` : `Missing operand after ${Qi(t.op)}`, r = t.atomIds;
3656
+ if (t?.kind === "operator" && t.op !== ",") n = Qi(t.op) ? t.op === "=" ? "Missing right-hand side" : `Missing right-hand side of ${t.op}` : `Missing operand after ${$i(t.op)}`, r = t.atomIds;
3644
3657
  else if (t) return;
3645
- else if (e?.kind === "operator") n = Zi(e.op) ? e.op === "=" ? "Missing left-hand side" : `Missing left-hand side of ${e.op}` : `Missing operand before ${Qi(e.op)}`, r = e.atomIds;
3658
+ else if (e?.kind === "operator") n = Qi(e.op) ? e.op === "=" ? "Missing left-hand side" : `Missing left-hand side of ${e.op}` : `Missing operand before ${$i(e.op)}`, r = e.atomIds;
3646
3659
  else if (e?.kind === "structure" && e.atom.kind === "superscript") n = "Missing base for the exponent", r = e.atomIds;
3647
3660
  else return;
3648
3661
  this.diagnostics.push({
@@ -3696,14 +3709,14 @@ var ta = class {
3696
3709
  };
3697
3710
  //#endregion
3698
3711
  //#region src/renderers/mathjson.ts
3699
- function na(e) {
3712
+ function ra(e) {
3700
3713
  return Be(e)?.mathJson ?? e;
3701
3714
  }
3702
3715
  function Z(e) {
3703
3716
  switch (e.type) {
3704
3717
  case "Number": return e.value;
3705
3718
  case "Identifier": return e.name;
3706
- case "Constant": return Oe(e.name).mathJson;
3719
+ case "Constant": return z(e.name).mathJson;
3707
3720
  case "Add": return ["Add", ...e.children.map(Z)];
3708
3721
  case "Multiply": return ["Multiply", ...e.children.map(Z)];
3709
3722
  case "Subtract": return [
@@ -3719,7 +3732,7 @@ function Z(e) {
3719
3732
  Z(e.radicand),
3720
3733
  Z(e.degree)
3721
3734
  ] : ["Sqrt", Z(e.radicand)];
3722
- case "FunctionCall": return [na(e.name), ...e.args.map(Z)];
3735
+ case "FunctionCall": return [ra(e.name), ...e.args.map(Z)];
3723
3736
  case "Equal":
3724
3737
  case "Less":
3725
3738
  case "Greater":
@@ -3758,12 +3771,12 @@ function Z(e) {
3758
3771
  default: return null;
3759
3772
  }
3760
3773
  }
3761
- function ra(e) {
3774
+ function ia(e) {
3762
3775
  return JSON.stringify(Z(e), null, 2);
3763
3776
  }
3764
3777
  //#endregion
3765
3778
  //#region src/renderers/mathml.ts
3766
- function ia(e) {
3779
+ function aa(e) {
3767
3780
  throw Error(`Unsupported AST node: ${JSON.stringify(e)}`);
3768
3781
  }
3769
3782
  function Q(e, t) {
@@ -3774,7 +3787,7 @@ function Q(e, t) {
3774
3787
  </apply>
3775
3788
  `;
3776
3789
  }
3777
- function aa(e, t) {
3790
+ function oa(e, t) {
3778
3791
  let n = t.cellml ? ` cellml:units="${e.units ?? "dimensionless"}"` : "", [r, i] = String(e.value).split("e"), a = e.scientific ? {
3779
3792
  mantissa: e.scientific.mantissa,
3780
3793
  exponent: e.scientific.exponent
@@ -3786,9 +3799,9 @@ function aa(e, t) {
3786
3799
  }
3787
3800
  function $(e, t = {}) {
3788
3801
  switch (e.type) {
3789
- case "Number": return aa(e, t);
3802
+ case "Number": return oa(e, t);
3790
3803
  case "Identifier": return `<ci>${e.name}</ci>`;
3791
- case "Constant": return `<${Oe(e.name).mathml}/>`;
3804
+ case "Constant": return `<${z(e.name).mathml}/>`;
3792
3805
  case "Add": return Q("plus", e.children.map((e) => $(e, t)));
3793
3806
  case "Multiply": return Q("times", e.children.map((e) => $(e, t)));
3794
3807
  case "Subtract": return Q("minus", [$(e.minuend, t), $(e.subtrahend, t)]);
@@ -3847,12 +3860,12 @@ function $(e, t = {}) {
3847
3860
  </apply>
3848
3861
  `;
3849
3862
  case "Placeholder": return "<ci>_</ci>";
3850
- default: return ia(e);
3863
+ default: return aa(e);
3851
3864
  }
3852
3865
  }
3853
3866
  //#endregion
3854
3867
  //#region src/editor/exports.ts
3855
- var oa = [
3868
+ var sa = [
3856
3869
  {
3857
3870
  format: "latex",
3858
3871
  label: "LaTeX"
@@ -3865,19 +3878,19 @@ var oa = [
3865
3878
  format: "mathml",
3866
3879
  label: "Content MathML"
3867
3880
  }
3868
- ], sa = "http://www.w3.org/1998/Math/MathML", ca = "http://www.cellml.org/cellml/2.0#";
3869
- function la(e, t, n = {}) {
3881
+ ], ca = "http://www.w3.org/1998/Math/MathML", la = "http://www.cellml.org/cellml/2.0#";
3882
+ function ua(e, t, n = {}) {
3870
3883
  switch (t) {
3871
3884
  case "latex": return W(e, n);
3872
- case "mathjson": return ra(Ki(e).ast);
3873
- case "mathml": return ua(e, n);
3885
+ case "mathjson": return ia(qi(e).ast);
3886
+ case "mathml": return da(e, n);
3874
3887
  }
3875
3888
  }
3876
- function ua(e, t = {}) {
3877
- let n = $(Ki(e).ast, t);
3878
- return da(`<math ${t.cellml ? `xmlns="${sa}" xmlns:cellml="${ca}"` : `xmlns="${sa}"`}>${n}</math>`);
3889
+ function da(e, t = {}) {
3890
+ let n = $(qi(e).ast, t);
3891
+ return fa(`<math ${t.cellml ? `xmlns="${ca}" xmlns:cellml="${la}"` : `xmlns="${ca}"`}>${n}</math>`);
3879
3892
  }
3880
- function da(e, t = " ") {
3893
+ function fa(e, t = " ") {
3881
3894
  let n = e.match(/<[^>]+>|[^<]+/g) ?? [], r = [], i = 0;
3882
3895
  for (let e = 0; e < n.length; e++) {
3883
3896
  let a = n[e];
@@ -3912,7 +3925,7 @@ function da(e, t = " ") {
3912
3925
  }
3913
3926
  //#endregion
3914
3927
  //#region src/editor/units.ts
3915
- function fa(e, t, n, r = 0) {
3928
+ function pa(e, t, n, r = 0) {
3916
3929
  if (!n) return {
3917
3930
  id: e,
3918
3931
  mathml: "",
@@ -3922,20 +3935,20 @@ function fa(e, t, n, r = 0) {
3922
3935
  };
3923
3936
  let i = [], a = [], o = 0, s = (e) => {
3924
3937
  e.type === "Identifier" && !i.includes(e.name) && i.push(e.name), e.type === "Number" && e.units && !a.includes(e.units) && a.push(e.units), e.type === "Placeholder" && o++;
3925
- for (let t of ma(e)) s(t);
3938
+ for (let t of ha(e)) s(t);
3926
3939
  };
3927
3940
  return s(n.ast), {
3928
3941
  id: e,
3929
- mathml: ua(t, { cellml: !0 }),
3942
+ mathml: da(t, { cellml: !0 }),
3930
3943
  variables: i,
3931
3944
  units: a,
3932
- complete: n.diagnostics.length === 0 && r === 0 && o === 0 && !pa(t)
3945
+ complete: n.diagnostics.length === 0 && r === 0 && o === 0 && !ma(t)
3933
3946
  };
3934
3947
  }
3935
- function pa(e) {
3936
- return e.some((e) => e.kind === "units" && e.units.length === 0 || A(e).some(([, e]) => pa(e)));
3937
- }
3938
3948
  function ma(e) {
3949
+ return e.some((e) => e.kind === "units" && e.units.length === 0 || k(e).some(([, e]) => ma(e)));
3950
+ }
3951
+ function ha(e) {
3939
3952
  switch (e.type) {
3940
3953
  case "Add":
3941
3954
  case "Multiply":
@@ -3962,8 +3975,8 @@ function ma(e) {
3962
3975
  default: return [];
3963
3976
  }
3964
3977
  }
3965
- function ha(e, t) {
3966
- let n = [], r = t.some((e) => e.numbers?.length || e.units?.length) ? ct(e) : [], i = t.some((e) => e.variables?.length) ? st(e) : null;
3978
+ function ga(e, t) {
3979
+ let n = [], r = t.some((e) => e.numbers?.length || e.units?.length) ? lt(e) : [], i = t.some((e) => e.variables?.length) ? ct(e) : null;
3967
3980
  for (let e of t) {
3968
3981
  for (let t of e.variables ?? []) for (let r of i?.get(t) ?? []) n.push({
3969
3982
  message: e.message,
@@ -3978,9 +3991,9 @@ function ha(e, t) {
3978
3991
  }
3979
3992
  return n;
3980
3993
  }
3981
- function ga(e, t) {
3994
+ function _a(e, t) {
3982
3995
  let n = [];
3983
- if (t) for (let [r, i] of st(e)) {
3996
+ if (t) for (let [r, i] of ct(e)) {
3984
3997
  if (!Object.hasOwn(t, r)) continue;
3985
3998
  let e = t[r];
3986
3999
  for (let t of i) n.push({
@@ -3989,7 +4002,7 @@ function ga(e, t) {
3989
4002
  kind: "hint"
3990
4003
  });
3991
4004
  }
3992
- for (let r of ct(e)) {
4005
+ for (let r of lt(e)) {
3993
4006
  if (!r.units && !t) continue;
3994
4007
  let e = r.inherited ? ", as in the first piece" : "";
3995
4008
  n.push({
@@ -4002,40 +4015,40 @@ function ga(e, t) {
4002
4015
  }
4003
4016
  //#endregion
4004
4017
  //#region src/editor/toolbar.ts
4005
- function _a(e, t) {
4018
+ function va(e, t) {
4006
4019
  let { latexName: n, latexCommand: r } = ze[e];
4007
4020
  return {
4008
4021
  latex: r ? `\\${n}` : `\\operatorname{${n}}`,
4009
4022
  title: `${t} ( ${n} )`,
4010
- command: oi(e)
4023
+ command: si(e)
4011
4024
  };
4012
4025
  }
4013
- var va = [
4026
+ var ya = [
4014
4027
  ["sin", "Sine"],
4015
4028
  ["cos", "Cosine"],
4016
4029
  ["tan", "Tangent"],
4017
4030
  ["sec", "Secant"],
4018
4031
  ["csc", "Cosecant"],
4019
4032
  ["cot", "Cotangent"]
4020
- ], ya = (e, t) => va.map(([n, r]) => {
4033
+ ], ba = (e, t) => ya.map(([n, r]) => {
4021
4034
  let i = [
4022
4035
  t && "inverse",
4023
4036
  e && "hyperbolic",
4024
4037
  r.toLowerCase()
4025
4038
  ].filter(Boolean).join(" ");
4026
- return _a(`${t ? "a" : ""}${n}${e}`, i[0].toUpperCase() + i.slice(1));
4027
- }), ba = [
4039
+ return va(`${t ? "a" : ""}${n}${e}`, i[0].toUpperCase() + i.slice(1));
4040
+ }), xa = [
4028
4041
  {
4029
4042
  id: "fraction",
4030
4043
  title: "Fraction ( / )",
4031
4044
  latex: "\\frac{a}{b}",
4032
- command: Ur
4045
+ command: Wr
4033
4046
  },
4034
4047
  {
4035
4048
  id: "script",
4036
4049
  title: "Power ( ^ )",
4037
4050
  latex: "x^{n}",
4038
- command: Wr
4051
+ command: Gr
4039
4052
  },
4040
4053
  {
4041
4054
  id: "radical",
@@ -4044,11 +4057,11 @@ var va = [
4044
4057
  sections: [{ items: [{
4045
4058
  latex: "\\sqrt{x}",
4046
4059
  title: "Square root ( \\sqrt )",
4047
- command: si
4060
+ command: ci
4048
4061
  }, {
4049
4062
  latex: "\\sqrt[n]{x}",
4050
4063
  title: "nth root ( \\root )",
4051
- command: ci
4064
+ command: li
4052
4065
  }] }]
4053
4066
  },
4054
4067
  {
@@ -4059,17 +4072,17 @@ var va = [
4059
4072
  {
4060
4073
  latex: "|x|",
4061
4074
  title: "Absolute value ( | )",
4062
- command: li
4075
+ command: ui
4063
4076
  },
4064
4077
  {
4065
4078
  latex: "\\lfloor x\\rfloor",
4066
4079
  title: "Floor ( floor( or \\floor )",
4067
- command: Qr
4080
+ command: $r
4068
4081
  },
4069
4082
  {
4070
4083
  latex: "\\lceil x\\rceil",
4071
4084
  title: "Ceiling ( ceil( or \\ceil )",
4072
- command: $r
4085
+ command: ei
4073
4086
  }
4074
4087
  ] }]
4075
4088
  },
@@ -4080,26 +4093,26 @@ var va = [
4080
4093
  sections: [
4081
4094
  {
4082
4095
  label: "Trigonometric",
4083
- items: ya("", !1)
4096
+ items: ba("", !1)
4084
4097
  },
4085
4098
  {
4086
4099
  label: "Hyperbolic",
4087
- items: ya("h", !1)
4100
+ items: ba("h", !1)
4088
4101
  },
4089
4102
  {
4090
4103
  label: "Inverse trigonometric",
4091
- items: ya("", !0)
4104
+ items: ba("", !0)
4092
4105
  },
4093
4106
  {
4094
4107
  label: "Inverse hyperbolic",
4095
- items: ya("h", !0)
4108
+ items: ba("h", !0)
4096
4109
  },
4097
4110
  {
4098
4111
  label: "Exponential and logarithm",
4099
4112
  items: [
4100
- _a("exp", "Exponential"),
4101
- _a("ln", "Natural logarithm"),
4102
- _a("log", "Logarithm")
4113
+ va("exp", "Exponential"),
4114
+ va("ln", "Natural logarithm"),
4115
+ va("log", "Logarithm")
4103
4116
  ]
4104
4117
  }
4105
4118
  ]
@@ -4108,13 +4121,13 @@ var va = [
4108
4121
  id: "derivative",
4109
4122
  title: "Derivative ( \\dd )",
4110
4123
  latex: "\\frac{\\mathrm{d}y}{\\mathrm{d}x}",
4111
- command: ui
4124
+ command: di
4112
4125
  },
4113
4126
  {
4114
4127
  id: "cases",
4115
4128
  title: "Piecewise ( \\cases )",
4116
4129
  latex: "\\left\\{\\begin{smallmatrix}a&p\\\\b&q\\end{smallmatrix}\\right.",
4117
- command: Br
4130
+ command: Vr
4118
4131
  },
4119
4132
  {
4120
4133
  id: "symbols",
@@ -4223,51 +4236,47 @@ var va = [
4223
4236
  }
4224
4237
  ]
4225
4238
  }
4226
- ], xa = { class: "editor-panel" }, Sa = {
4227
- class: "toolbar",
4228
- role: "toolbar",
4229
- "aria-label": "Equation tools"
4230
- }, Ca = { class: "toolbar-group" }, wa = [
4239
+ ], Sa = { class: "toolbar-group" }, Ca = [
4231
4240
  "title",
4232
4241
  "data-role",
4233
4242
  "aria-haspopup",
4234
4243
  "disabled",
4235
4244
  "onClick"
4236
- ], Ta = ["innerHTML"], Ea = {
4245
+ ], wa = ["innerHTML"], Ta = {
4237
4246
  key: 0,
4238
4247
  class: "pi pi-chevron-down tool-chevron",
4239
4248
  "aria-hidden": "true"
4240
- }, Da = { class: "toolbar-group toolbar-lines" }, Oa = {
4249
+ }, Ea = { class: "toolbar-group toolbar-lines" }, Da = {
4241
4250
  key: 0,
4242
4251
  class: "toolbar-group"
4243
- }, ka = {
4252
+ }, Oa = {
4244
4253
  key: 0,
4245
4254
  class: "gallery"
4246
- }, Aa = {
4255
+ }, ka = {
4247
4256
  key: 0,
4248
4257
  class: "gallery-label"
4249
- }, ja = { class: "gallery-items" }, Ma = ["title", "onClick"], Na = ["innerHTML"], Pa = [
4258
+ }, Aa = { class: "gallery-items" }, ja = ["title", "onClick"], Ma = ["innerHTML"], Na = [
4250
4259
  "data-line",
4251
4260
  "data-line-id",
4252
4261
  "onFocusin"
4253
- ], Fa = { class: "equation-label" }, Ia = ["data-kind", "title"], La = {
4262
+ ], Pa = { class: "equation-label" }, Fa = ["data-kind", "title"], Ia = {
4254
4263
  key: 0,
4255
4264
  class: "command-chip",
4256
4265
  "data-role": "command"
4257
- }, Ra = { class: "status-text" }, za = {
4266
+ }, La = { class: "status-text" }, Ra = {
4258
4267
  key: 0,
4259
4268
  class: "status-more"
4260
- }, Ba = {
4269
+ }, za = {
4261
4270
  key: 0,
4262
4271
  class: "focus-meta"
4263
- }, Va = { "data-role": "cursor" }, Ha = { "data-role": "selection" }, Ua = {
4272
+ }, Ba = { "data-role": "cursor" }, Va = { "data-role": "selection" }, Ha = {
4264
4273
  class: "key-help",
4265
4274
  "data-role": "key-help"
4266
- }, Wa = { class: "key-hint" }, Ga = {
4275
+ }, Ua = { class: "key-hint" }, Wa = {
4267
4276
  key: 0,
4268
4277
  class: "side-column",
4269
4278
  "data-role": "side"
4270
- }, Ka = { "data-role": "mathml" }, qa = { class: "output-actions" }, Ja = { "data-role": "mathjson" }, Ya = { "data-role": "latex" }, Xa = { "data-role": "ast" }, Za = "A CellML line must be an equation (… = …)", Qa = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
4279
+ }, Ga = { "data-role": "mathml" }, Ka = { class: "output-actions" }, qa = { "data-role": "mathjson" }, Ja = { "data-role": "latex" }, Ya = { "data-role": "ast" }, Xa = "A CellML line must be an equation (… = …)", Za = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
4271
4280
  __name: "EquationWorkbench",
4272
4281
  props: {
4273
4282
  cellml: {
@@ -4308,146 +4317,161 @@ var va = [
4308
4317
  },
4309
4318
  emits: ["equations-change", "line-commit"],
4310
4319
  setup(l, { expose: u, emit: d }) {
4311
- let m = l, ee = d, h = t(() => ({
4320
+ let m = l, h = d, x = t(() => ({
4312
4321
  cellml: m.cellml,
4313
4322
  greekNames: m.greekNames,
4314
4323
  typesetNames: m.typesetNames
4315
- })), x = re([br()]), C = (e, t) => x.value.map((n, r) => r === e ? t : n), ie = 0, w = () => `line-${++ie}`, T = _([w()]), D = _(/* @__PURE__ */ new Map()), ge = _(/* @__PURE__ */ new Map()), A = _(0), _e = _([]), j = _(null);
4324
+ })), C = re([br()]), ie = (e, t) => C.value.map((n, r) => r === e ? t : n), ae = 0, w = () => `line-${++ae}`, E = _([w()]), _e = _(/* @__PURE__ */ new Map()), k = _(/* @__PURE__ */ new Map()), A = _(0), ve = _([]), j = _(null);
4316
4325
  function M() {
4317
- return x.value[A.value];
4326
+ return C.value[A.value];
4318
4327
  }
4319
- function N(e, t) {
4320
- x.value = C(e, ve(t));
4328
+ function ye(e, t) {
4329
+ C.value = ie(e, be(t));
4321
4330
  }
4322
- let ve = (e, t = !1) => ht(Gn(e), {
4331
+ let be = (e, t = !1) => ht(Gn(e), {
4323
4332
  greekNames: m.greekNames,
4324
4333
  cursorAway: t
4325
4334
  });
4326
- ae(A, (e, t) => {
4327
- let n = x.value[t];
4328
- n && (x.value = C(t, ve(n, !0)));
4329
- }), ae(() => m.greekNames, () => {
4330
- x.value = x.value.map((e, t) => ve(e, t !== A.value));
4335
+ oe(A, (e, t) => {
4336
+ let n = C.value[t];
4337
+ n && (C.value = ie(t, be(n, !0)));
4338
+ }), oe(() => m.greekNames, () => {
4339
+ C.value = C.value.map((e, t) => be(e, t !== A.value));
4331
4340
  });
4332
- function P() {
4333
- f(() => _e.value[A.value]?.focus());
4341
+ function N() {
4342
+ f(() => ve.value[A.value]?.focus());
4334
4343
  }
4335
- let F = new hi(), I = _(0);
4336
- function ye() {
4344
+ let P = new gi(), F = _(0);
4345
+ function xe() {
4337
4346
  return JSON.parse(JSON.stringify({
4338
- equations: x.value,
4339
- lineIds: T.value,
4347
+ equations: C.value,
4348
+ lineIds: E.value,
4340
4349
  active: A.value
4341
4350
  }));
4342
4351
  }
4343
- function L(e = A.value, t = fi) {
4344
- m.history && (F.checkpoint(ye, mi(e, t)), I.value++);
4352
+ function I(e = A.value, t = pi) {
4353
+ m.history && (P.checkpoint(xe, hi(e, t)), F.value++);
4345
4354
  }
4346
- function be(e) {
4347
- e && (x.value = e.equations, T.value = e.lineIds, A.value = Math.min(e.active, e.equations.length - 1), I.value++, P());
4355
+ function Se(e) {
4356
+ e && (C.value = e.equations, E.value = e.lineIds, A.value = Math.min(e.active, e.equations.length - 1), F.value++, N());
4348
4357
  }
4349
- let xe = () => be(F.undo(ye())), R = () => be(F.redo(ye())), Se = t(() => I.value >= 0 && F.canUndo), Ce = t(() => I.value >= 0 && F.canRedo);
4350
- function we(e, t, n) {
4351
- if (b(t.root) === b(x.value[e].root)) {
4352
- Te(e, {
4358
+ let L = () => Se(P.undo(xe())), Ce = () => Se(P.redo(xe())), we = t(() => F.value >= 0 && P.canUndo), Te = t(() => F.value >= 0 && P.canRedo);
4359
+ function R(e, t, n) {
4360
+ if (b(t.root) === b(C.value[e].root)) {
4361
+ De(e, {
4353
4362
  cursor: t.cursor,
4354
4363
  anchor: t.anchor ?? null
4355
4364
  });
4356
4365
  return;
4357
4366
  }
4358
- L(e, n), N(e, t), z(e);
4367
+ I(e, n), ye(e, t), Ee(e);
4359
4368
  }
4360
- function z(e) {
4361
- ge.value.delete(T.value[e]), De.value = null;
4369
+ function Ee(e) {
4370
+ k.value.delete(E.value[e]), z.value = null;
4362
4371
  }
4363
- function Te(e, { cursor: t, anchor: n }) {
4364
- F.breakGroup(), N(e, {
4365
- ...x.value[e],
4372
+ function De(e, { cursor: t, anchor: n }) {
4373
+ P.breakGroup(), ye(e, {
4374
+ ...C.value[e],
4366
4375
  cursor: t,
4367
4376
  anchor: n
4368
4377
  });
4369
4378
  }
4370
- function Ee(e, t = []) {
4371
- let n = e.map((e) => ve({
4379
+ function Oe(e, t = []) {
4380
+ let n = e.map((e) => be({
4372
4381
  root: e,
4373
4382
  cursor: Xn(e),
4374
4383
  anchor: null
4375
4384
  }, !0));
4376
- x.value = n.length ? n : [br()], T.value = x.value.map(() => w()), A.value = 0, ge.value = new Map(T.value.flatMap((e, n) => t[n]?.length ? [[e, t[n]]] : [])), D.value = new Map(lt.value.map((e) => [e.id, e.mathml]));
4385
+ C.value = n.length ? n : [br()], E.value = C.value.map(() => w()), A.value = 0, k.value = new Map(E.value.flatMap((e, n) => t[n]?.length ? [[e, t[n]]] : [])), _e.value = new Map(_t.value.map((e) => [e.id, e.mathml]));
4377
4386
  }
4378
- let De = _(null);
4379
- function Oe(e, t) {
4387
+ let z = _(null);
4388
+ function ke(e, t) {
4380
4389
  if (m.readonly) return;
4381
4390
  let n = t.equations.length;
4382
- if (n === 1) we(e, Rr(t.equations[0])(x.value[e]), fi), t.problems.length && ge.value.set(T.value[e], t.problems);
4391
+ if (n === 1) R(e, zr(t.equations[0])(C.value[e]), pi), t.problems.length && k.value.set(E.value[e], t.problems);
4383
4392
  else if (n > 1) {
4384
- L(e), Ee(t.equations, t.lineProblems);
4385
- for (let e of lt.value) ee("line-commit", e, { reason: "paste" });
4386
- P();
4393
+ I(e), Oe(t.equations, t.lineProblems);
4394
+ for (let e of _t.value) h("line-commit", e, { reason: "paste" });
4395
+ N();
4387
4396
  }
4388
- De.value = n > 1 ? `Imported ${n} equations from Content MathML, replacing the lines there were.` : n === 0 ? t.problems[0] ?? "Nothing was imported." : null;
4397
+ z.value = n > 1 ? `Imported ${n} equations from Content MathML, replacing the lines there were.` : n === 0 ? t.problems[0] ?? "Nothing was imported." : null;
4389
4398
  }
4390
- function ke(e) {
4391
- let t = Si(e);
4392
- return t ? (dt = "load", Ee(t.equations, t.lineProblems), j.value = null, De.value = null, F.clear(), I.value++, t) : {
4399
+ function Ae(e) {
4400
+ let t = Ci(e);
4401
+ return t ? (yt = "load", Oe(t.equations, t.lineProblems), j.value = null, z.value = null, P.clear(), F.value++, t) : {
4393
4402
  equations: [],
4394
4403
  problems: ["The MathML isn't well-formed XML, so nothing was loaded"],
4395
4404
  lineProblems: []
4396
4405
  };
4397
4406
  }
4398
4407
  u({
4399
- setMathML: ke,
4400
- focus: P
4401
- }), te(() => {
4402
- m.autofocus && P();
4408
+ setMathML: Ae,
4409
+ focus: N
4403
4410
  });
4404
- function Ae(e) {
4411
+ let je = _(null), Me = _(null), Ne = _(!1), B = 0;
4412
+ function Pe() {
4413
+ if (B = 0, !je.value || !Me.value) return;
4414
+ let e = Me.value.getBoundingClientRect().top - je.value.getBoundingClientRect().top;
4415
+ Ne.value = e > .5;
4416
+ }
4417
+ function Fe() {
4418
+ B ||= requestAnimationFrame(Pe);
4419
+ }
4420
+ te(() => {
4421
+ m.autofocus && N(), document.addEventListener("scroll", Fe, {
4422
+ capture: !0,
4423
+ passive: !0
4424
+ }), window.addEventListener("resize", Fe, { passive: !0 }), Pe();
4425
+ }), ee(() => {
4426
+ document.removeEventListener("scroll", Fe, { capture: !0 }), window.removeEventListener("resize", Fe), B && cancelAnimationFrame(B);
4427
+ });
4428
+ function Ie(e) {
4405
4429
  if (m.readonly) return;
4406
4430
  let t = M(), n = e(t);
4407
- n !== t && (L(), N(A.value, n), z(A.value)), P();
4431
+ n !== t && (I(), ye(A.value, n), Ee(A.value)), N();
4408
4432
  }
4409
- function je(e) {
4433
+ function Le(e) {
4410
4434
  if (m.readonly) return;
4411
- Fe(A.value, e), L();
4435
+ He(A.value, e), I();
4412
4436
  let t = A.value + 1;
4413
- x.value = [
4414
- ...x.value.slice(0, t),
4437
+ C.value = [
4438
+ ...C.value.slice(0, t),
4415
4439
  br(),
4416
- ...x.value.slice(t)
4417
- ], T.value.splice(t, 0, w()), A.value = t, P();
4440
+ ...C.value.slice(t)
4441
+ ], E.value.splice(t, 0, w()), A.value = t, N();
4418
4442
  }
4419
- function Me(e) {
4420
- e < 0 || e >= x.value.length || (e !== A.value && Fe(A.value, "navigate"), F.breakGroup(), A.value = e, P());
4443
+ function Re(e) {
4444
+ e < 0 || e >= C.value.length || (e !== A.value && He(A.value, "navigate"), P.breakGroup(), A.value = e, N());
4421
4445
  }
4422
- function Ne(e) {
4423
- e !== A.value && (Fe(A.value, "navigate"), A.value = e);
4446
+ function ze(e) {
4447
+ e !== A.value && (He(A.value, "navigate"), A.value = e);
4424
4448
  }
4425
- let B = _(null);
4426
- function Pe(e) {
4449
+ let Be = _(null);
4450
+ function Ve(e) {
4427
4451
  let t = e.relatedTarget;
4428
- t && (B.value?.contains(t) || t.closest("[data-me-popover]")) || Fe(A.value, "blur");
4452
+ t && (Be.value?.contains(t) || t.closest("[data-me-popover]")) || He(A.value, "blur");
4429
4453
  }
4430
- function Fe(e, t) {
4431
- let n = lt.value[e];
4432
- n && (D.value.get(n.id) ?? "") !== n.mathml && (D.value.set(n.id, n.mathml), ee("line-commit", n, { reason: t }));
4454
+ function He(e, t) {
4455
+ let n = _t.value[e];
4456
+ n && (_e.value.get(n.id) ?? "") !== n.mathml && (_e.value.set(n.id, n.mathml), h("line-commit", n, { reason: t }));
4433
4457
  }
4434
- function Ie() {
4435
- if (m.readonly || x.value.length <= 1) return;
4436
- L();
4458
+ function Ue() {
4459
+ if (m.readonly || C.value.length <= 1) return;
4460
+ I();
4437
4461
  let e = A.value;
4438
- x.value = x.value.filter((t, n) => n !== e), T.value.splice(A.value, 1), A.value = Math.max(0, A.value - 1);
4462
+ C.value = C.value.filter((t, n) => n !== e), E.value.splice(A.value, 1), A.value = Math.max(0, A.value - 1);
4439
4463
  let t = M();
4440
- N(A.value, {
4464
+ ye(A.value, {
4441
4465
  ...t,
4442
4466
  cursor: Xn(t.root),
4443
4467
  anchor: null
4444
- }), P();
4468
+ }), N();
4445
4469
  }
4446
- function Le() {
4470
+ function We() {
4447
4471
  let e = (j.value ?? "").trim();
4448
- j.value = null, e && Ae(di(e));
4472
+ j.value = null, e && Ie(fi(e));
4449
4473
  }
4450
- function Re(e) {
4474
+ function Ge(e) {
4451
4475
  if (/^[a-zA-Z0-9]$/.test(e.key)) j.value += e.key;
4452
4476
  else if (e.key === "Backspace") j.value = j.value ? j.value.slice(0, -1) : null;
4453
4477
  else if ([
@@ -4455,156 +4479,156 @@ var va = [
4455
4479
  " ",
4456
4480
  "Tab",
4457
4481
  "("
4458
- ].includes(e.key)) Le();
4482
+ ].includes(e.key)) We();
4459
4483
  else if (e.key === "Escape") j.value = null;
4460
4484
  else return;
4461
4485
  e.preventDefault(), e.stopPropagation();
4462
4486
  }
4463
- function ze(e) {
4487
+ function Ke(e) {
4464
4488
  if (!e.target?.closest?.("[data-role=\"side\"]")) {
4465
4489
  if (j.value !== null) {
4466
- Re(e);
4490
+ Ge(e);
4467
4491
  return;
4468
4492
  }
4469
4493
  if ((e.ctrlKey || e.metaKey) && !e.altKey) {
4470
4494
  let t = e.key.toLowerCase();
4471
4495
  if ((t === "z" || t === "y") && m.history) {
4472
4496
  if (e.preventDefault(), e.stopPropagation(), m.readonly) return;
4473
- t === "y" || e.shiftKey ? R() : xe();
4497
+ t === "y" || e.shiftKey ? Ce() : L();
4474
4498
  }
4475
4499
  return;
4476
4500
  }
4477
4501
  e.key === "\\" && !e.altKey && !m.readonly && (e.preventDefault(), e.stopPropagation(), j.value = "");
4478
4502
  }
4479
4503
  }
4480
- function Be(e) {
4504
+ function qe(e) {
4481
4505
  if (!e.defaultPrevented) switch (e.key) {
4482
4506
  case "Enter":
4483
- e.preventDefault(), je("enter");
4507
+ e.preventDefault(), Le("enter");
4484
4508
  return;
4485
4509
  case "ArrowUp":
4486
- e.preventDefault(), Me(A.value - 1);
4510
+ e.preventDefault(), Re(A.value - 1);
4487
4511
  return;
4488
4512
  case "ArrowDown":
4489
- e.preventDefault(), Me(A.value + 1);
4513
+ e.preventDefault(), Re(A.value + 1);
4490
4514
  return;
4491
4515
  case "Backspace":
4492
- M().root.length === 0 && (e.preventDefault(), Ie());
4516
+ M().root.length === 0 && (e.preventDefault(), Ue());
4493
4517
  return;
4494
4518
  }
4495
4519
  }
4496
- let Ve = _(null), He = _(null);
4497
- function Ue(e, t) {
4520
+ let Je = _(null), Ye = _(null);
4521
+ function Xe(e, t) {
4498
4522
  if (e.command) {
4499
- Ae(e.command);
4523
+ Ie(e.command);
4500
4524
  return;
4501
4525
  }
4502
- He.value?.id !== e.id && Ve.value?.hide(), He.value = e, f(() => Ve.value?.toggle(t));
4526
+ Ye.value?.id !== e.id && Je.value?.hide(), Ye.value = e, f(() => Je.value?.toggle(t));
4503
4527
  }
4504
- function We(e) {
4505
- Ve.value?.hide(), Ae(e);
4528
+ function Ze(e) {
4529
+ Je.value?.hide(), Ie(e);
4506
4530
  }
4507
- function Ge(e) {
4508
- return oe.renderToString(e, {
4531
+ function Qe(e) {
4532
+ return se.renderToString(e, {
4509
4533
  throwOnError: !1,
4510
4534
  strict: "ignore"
4511
4535
  });
4512
4536
  }
4513
- let Ke = /* @__PURE__ */ new WeakMap();
4514
- function qe(e) {
4537
+ let $e = /* @__PURE__ */ new WeakMap();
4538
+ function et(e) {
4515
4539
  if (e.length === 0) return null;
4516
- let t = Ke.get(e);
4517
- return t || (t = Ki(e), Ke.set(e, t)), t;
4540
+ let t = $e.get(e);
4541
+ return t || (t = qi(e), $e.set(e, t)), t;
4518
4542
  }
4519
- let Je = t(() => x.value.map((e) => qe(e.root))), Ye = t(() => Je.value[A.value] ?? null);
4520
- function Xe(e, t) {
4521
- let n = Je.value[t]?.ast;
4543
+ let tt = t(() => C.value.map((e) => et(e.root))), nt = t(() => tt.value[A.value] ?? null);
4544
+ function rt(e, t) {
4545
+ let n = tt.value[t]?.ast;
4522
4546
  return !m.cellml || !n || n.type === "Equal" ? null : {
4523
- message: Za,
4547
+ message: Xa,
4524
4548
  atomIds: e.map((e) => e.id),
4525
4549
  incomplete: !0
4526
4550
  };
4527
4551
  }
4528
- let Ze = Gi(() => m.issues), Qe = Gi(() => m.variableUnits ?? null), $e = t(() => {
4552
+ let it = Ki(() => m.issues), at = Ki(() => m.variableUnits ?? null), ot = t(() => {
4529
4553
  let e = /* @__PURE__ */ new Map();
4530
- for (let t of Ze.value) e.set(t.lineId, [...e.get(t.lineId) ?? [], t]);
4554
+ for (let t of it.value) e.set(t.lineId, [...e.get(t.lineId) ?? [], t]);
4531
4555
  return e;
4532
- }), et = t(() => ($e.value, Qe.value, m.cellml, /* @__PURE__ */ new WeakMap())), tt = t(() => x.value.map((e, t) => {
4533
- let n = e.root, r = et.value.get(n);
4556
+ }), st = t(() => (ot.value, at.value, m.cellml, /* @__PURE__ */ new WeakMap())), ct = t(() => C.value.map((e, t) => {
4557
+ let n = e.root, r = st.value.get(n);
4534
4558
  if (!r) {
4535
- let e = Xe(n, t), i = [
4536
- ...Je.value[t]?.diagnostics ?? [],
4559
+ let e = rt(n, t), i = [
4560
+ ...tt.value[t]?.diagnostics ?? [],
4537
4561
  ...e ? [e] : [],
4538
- ...ha(n, $e.value.get(T.value[t]) ?? [])
4539
- ], a = ga(n, Qe.value);
4562
+ ...ga(n, ot.value.get(E.value[t]) ?? [])
4563
+ ], a = _a(n, at.value);
4540
4564
  r = {
4541
4565
  all: [...i, ...a],
4542
4566
  complete: [...i.filter((e) => !e.incomplete), ...a],
4543
4567
  hints: a
4544
- }, et.value.set(n, r);
4568
+ }, st.value.set(n, r);
4545
4569
  }
4546
4570
  return r;
4547
4571
  }));
4548
- function nt(e) {
4572
+ function lt(e) {
4549
4573
  if (m.validate === "commit") {
4550
- let t = lt.value[e];
4551
- return (D.value.get(t.id) ?? "") === t.mathml ? "all" : "hints";
4574
+ let t = _t.value[e];
4575
+ return (_e.value.get(t.id) ?? "") === t.mathml ? "all" : "hints";
4552
4576
  }
4553
4577
  return e === A.value ? "complete" : "all";
4554
4578
  }
4555
- let rt = t(() => tt.value.map((e, t) => e[nt(t)])), it = t(() => rt.value.map((e, t) => {
4556
- let n = [...(nt(t) === "hints" ? [] : ge.value.get(T.value[t]) ?? []).map((e) => ({
4579
+ let ut = t(() => ct.value.map((e, t) => e[lt(t)])), dt = t(() => ut.value.map((e, t) => {
4580
+ let n = [...(lt(t) === "hints" ? [] : k.value.get(E.value[t]) ?? []).map((e) => ({
4557
4581
  line: t,
4558
4582
  message: e,
4559
4583
  kind: "error"
4560
- })), ...e.filter(Ri).map((e) => ({
4584
+ })), ...e.filter(zi).map((e) => ({
4561
4585
  line: t,
4562
4586
  message: e.message,
4563
- kind: Li(e) === "units" ? "units" : "error"
4587
+ kind: Ri(e) === "units" ? "units" : "error"
4564
4588
  }))];
4565
4589
  return n.filter((e, t) => n.findIndex((t) => t.message === e.message) === t);
4566
- })), at = (e) => {
4567
- let t = it.value[e];
4590
+ })), ft = (e) => {
4591
+ let t = dt.value[e];
4568
4592
  return t.length ? t.some((e) => e.kind === "error") ? "has-error" : "has-units-issue" : null;
4569
4593
  }, V = t(() => {
4570
4594
  if (j.value !== null) return {
4571
4595
  kind: "command",
4572
4596
  text: j.value
4573
4597
  };
4574
- let e = it.value.flat(), t = it.value[A.value][0] ?? e[0];
4598
+ let e = dt.value.flat(), t = dt.value[A.value][0] ?? e[0];
4575
4599
  return t ? {
4576
4600
  kind: t.kind,
4577
4601
  text: `Line ${t.line + 1}: ${t.message}`,
4578
4602
  more: e.length - 1,
4579
4603
  line: t.line
4580
- } : De.value ? {
4604
+ } : z.value ? {
4581
4605
  kind: "info",
4582
- text: De.value
4606
+ text: z.value
4583
4607
  } : null;
4584
- }), ot = t(() => it.value.flat().map((e) => `Line ${e.line + 1}: ${e.message}`).join("\n"));
4585
- function st() {
4608
+ }), pt = t(() => dt.value.flat().map((e) => `Line ${e.line + 1}: ${e.message}`).join("\n"));
4609
+ function mt() {
4586
4610
  let e = V.value?.line;
4587
- e !== void 0 && Me(e);
4611
+ e !== void 0 && Re(e);
4588
4612
  }
4589
- let ct = t(() => (ge.value.size, m.cellml, /* @__PURE__ */ new WeakMap())), lt = t(() => x.value.map((e, t) => {
4590
- let n = T.value[t], r = ct.value.get(e.root);
4613
+ let gt = t(() => (k.value.size, m.cellml, /* @__PURE__ */ new WeakMap())), _t = t(() => C.value.map((e, t) => {
4614
+ let n = E.value[t], r = gt.value.get(e.root);
4591
4615
  if (!r || r.id !== n) {
4592
- let i = (ge.value.get(n)?.length ?? 0) + +!!Xe(e.root, t);
4593
- r = fa(n, e.root, Je.value[t], i), ct.value.set(e.root, r);
4616
+ let i = (k.value.get(n)?.length ?? 0) + +!!rt(e.root, t);
4617
+ r = pa(n, e.root, tt.value[t], i), gt.value.set(e.root, r);
4594
4618
  }
4595
4619
  return r;
4596
- })), ut = "", dt = "load";
4597
- ae(lt, (e) => {
4598
- let t = dt;
4599
- dt = "edit";
4620
+ })), vt = "", yt = "load";
4621
+ oe(_t, (e) => {
4622
+ let t = yt;
4623
+ yt = "edit";
4600
4624
  let n = JSON.stringify(e);
4601
- n !== ut && (ut = n, ee("equations-change", e, { source: t }));
4625
+ n !== vt && (vt = n, h("equations-change", e, { source: t }));
4602
4626
  }, { immediate: !0 });
4603
- let ft = t(() => Ye.value?.ast ?? null), pt = t(() => ft.value ? la(M().root, "latex", h.value) : ""), mt = t(() => ft.value ? ra(ft.value) : ""), gt = t(() => ft.value ? ua(M().root, h.value) : ""), _t = t(() => Qn(M().cursor)), vt = t(() => {
4627
+ let bt = t(() => nt.value?.ast ?? null), xt = t(() => bt.value ? ua(M().root, "latex", x.value) : ""), St = t(() => bt.value ? ia(bt.value) : ""), Ct = t(() => bt.value ? da(M().root, x.value) : ""), wt = t(() => Qn(M().cursor)), Tt = t(() => {
4604
4628
  let e = G(M());
4605
4629
  return e ? dr(e) : null;
4606
- }), yt = _(!1), bt = _("mathml");
4607
- function xt(e) {
4630
+ }), Et = _(!1), Dt = _("mathml");
4631
+ function Ot(e) {
4608
4632
  let t = document.createElement("textarea");
4609
4633
  t.value = e, t.setAttribute("readonly", "true"), t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
4610
4634
  try {
@@ -4615,41 +4639,41 @@ var va = [
4615
4639
  document.body.removeChild(t);
4616
4640
  }
4617
4641
  }
4618
- async function St(e) {
4642
+ async function kt(e) {
4619
4643
  try {
4620
4644
  if (navigator.clipboard?.writeText) {
4621
4645
  await navigator.clipboard.writeText(e);
4622
4646
  return;
4623
4647
  }
4624
4648
  } catch {}
4625
- xt(e);
4649
+ Ot(e);
4626
4650
  }
4627
- async function Ct() {
4628
- if (mt.value) {
4629
- yt.value = !0;
4651
+ async function At() {
4652
+ if (St.value) {
4653
+ Et.value = !0;
4630
4654
  try {
4631
- await St(mt.value);
4655
+ await kt(St.value);
4632
4656
  } finally {
4633
4657
  window.setTimeout(() => {
4634
- yt.value = !1;
4658
+ Et.value = !1;
4635
4659
  }, 1200);
4636
4660
  }
4637
4661
  }
4638
4662
  }
4639
- let wt = _(null), Tt = _(null), Et, Dt = t(() => G(M()) !== null), Ot = t(() => M().root.length > 0), kt = t(() => Tt.value ? `Copied ${Tt.value}` : Dt.value ? "Copy selection as" : "Copy as");
4640
- async function At(e, t) {
4663
+ let jt = _(null), Mt = _(null), Nt, Pt = t(() => G(M()) !== null), Ft = t(() => M().root.length > 0), H = t(() => Mt.value ? `Copied ${Mt.value}` : Pt.value ? "Copy selection as" : "Copy as");
4664
+ async function It(e, t) {
4641
4665
  let n = M(), r = G(n) ? ur(n) : n.root;
4642
- r.length > 0 && (await St(la(r, e, h.value)), Tt.value = t, window.clearTimeout(Et), Et = window.setTimeout(() => Tt.value = null, 1500)), P();
4666
+ r.length > 0 && (await kt(ua(r, e, x.value)), Mt.value = t, window.clearTimeout(Nt), Nt = window.setTimeout(() => Mt.value = null, 1500)), N();
4643
4667
  }
4644
- let jt = t(() => oa.map(({ format: e, label: t }) => {
4668
+ let Lt = t(() => sa.map(({ format: e, label: t }) => {
4645
4669
  let n = e === "mathml" && m.cellml ? `${t} (CellML)` : t;
4646
4670
  return {
4647
4671
  label: n,
4648
- command: () => At(e, n)
4672
+ command: () => It(e, n)
4649
4673
  };
4650
4674
  }));
4651
- function Mt(e) {
4652
- wt.value?.toggle(e);
4675
+ function Rt(e) {
4676
+ jt.value?.toggle(e);
4653
4677
  }
4654
4678
  return (t, u) => (g(), i("section", {
4655
4679
  class: p(["editor-grid", {
@@ -4657,11 +4681,21 @@ var va = [
4657
4681
  "no-outputs": !l.outputs,
4658
4682
  readonly: l.readonly
4659
4683
  }]),
4660
- onKeydownCapture: ze
4684
+ onKeydownCapture: Ke
4661
4685
  }, [
4662
- a("div", xa, [
4663
- a("div", Sa, [
4664
- a("div", Ca, [(g(!0), i(e, null, v(S(ba), (e) => (g(), i("button", {
4686
+ a("div", {
4687
+ ref_key: "panelEl",
4688
+ ref: je,
4689
+ class: "editor-panel"
4690
+ }, [
4691
+ a("div", {
4692
+ ref_key: "toolbarEl",
4693
+ ref: Me,
4694
+ class: p(["toolbar", { stuck: Ne.value }]),
4695
+ role: "toolbar",
4696
+ "aria-label": "Equation tools"
4697
+ }, [
4698
+ a("div", Sa, [(g(!0), i(e, null, v(S(xa), (e) => (g(), i("button", {
4665
4699
  key: e.id,
4666
4700
  type: "button",
4667
4701
  class: p(["tool-button", { "has-gallery": !!e.sections }]),
@@ -4669,11 +4703,11 @@ var va = [
4669
4703
  "data-role": `toolbar-${e.id}`,
4670
4704
  "aria-haspopup": e.sections ? "true" : void 0,
4671
4705
  disabled: l.readonly,
4672
- onMousedown: u[0] ||= O(() => {}, ["prevent"]),
4673
- onClick: (t) => Ue(e, t)
4674
- }, [a("span", { innerHTML: Ge(e.latex) }, null, 8, Ta), e.sections ? (g(), i("i", Ea)) : r("", !0)], 42, wa))), 128))]),
4675
- a("div", Da, [
4676
- c(S(k), {
4706
+ onMousedown: u[0] ||= D(() => {}, ["prevent"]),
4707
+ onClick: (t) => Xe(e, t)
4708
+ }, [a("span", { innerHTML: Qe(e.latex) }, null, 8, wa), e.sections ? (g(), i("i", Ta)) : r("", !0)], 42, Ca))), 128))]),
4709
+ a("div", Ea, [
4710
+ c(S(O), {
4677
4711
  icon: "pi pi-plus",
4678
4712
  size: "small",
4679
4713
  text: "",
@@ -4681,96 +4715,96 @@ var va = [
4681
4715
  "aria-label": "Add equation line",
4682
4716
  "data-role": "add-line",
4683
4717
  disabled: l.readonly,
4684
- onMousedown: u[1] ||= O(() => {}, ["prevent"]),
4685
- onClick: u[2] ||= (e) => je("new-line")
4718
+ onMousedown: u[1] ||= D(() => {}, ["prevent"]),
4719
+ onClick: u[2] ||= (e) => Le("new-line")
4686
4720
  }, null, 8, ["disabled"]),
4687
- c(S(k), {
4721
+ c(S(O), {
4688
4722
  icon: "pi pi-trash",
4689
4723
  size: "small",
4690
4724
  text: "",
4691
4725
  severity: "danger",
4692
4726
  title: "Remove equation line",
4693
4727
  "aria-label": "Remove equation line",
4694
- disabled: l.readonly || x.value.length <= 1,
4695
- onMousedown: u[3] ||= O(() => {}, ["prevent"]),
4696
- onClick: Ie
4728
+ disabled: l.readonly || C.value.length <= 1,
4729
+ onMousedown: u[3] ||= D(() => {}, ["prevent"]),
4730
+ onClick: Ue
4697
4731
  }, null, 8, ["disabled"]),
4698
- m.history ? (g(), n(S(k), {
4732
+ m.history ? (g(), n(S(O), {
4699
4733
  key: 0,
4700
4734
  icon: "pi pi-undo",
4701
4735
  size: "small",
4702
4736
  text: "",
4703
4737
  title: "Undo (Ctrl+Z)",
4704
- disabled: l.readonly || !Se.value,
4705
- onMousedown: u[4] ||= O(() => {}, ["prevent"]),
4706
- onClick: xe
4738
+ disabled: l.readonly || !we.value,
4739
+ onMousedown: u[4] ||= D(() => {}, ["prevent"]),
4740
+ onClick: L
4707
4741
  }, null, 8, ["disabled"])) : r("", !0),
4708
- m.history ? (g(), n(S(k), {
4742
+ m.history ? (g(), n(S(O), {
4709
4743
  key: 1,
4710
4744
  icon: "pi pi-refresh",
4711
4745
  size: "small",
4712
4746
  text: "",
4713
4747
  title: "Redo (Ctrl+Shift+Z)",
4714
- disabled: l.readonly || !Ce.value,
4715
- onMousedown: u[5] ||= O(() => {}, ["prevent"]),
4716
- onClick: R
4748
+ disabled: l.readonly || !Te.value,
4749
+ onMousedown: u[5] ||= D(() => {}, ["prevent"]),
4750
+ onClick: Ce
4717
4751
  }, null, 8, ["disabled"])) : r("", !0)
4718
4752
  ]),
4719
- l.outputs ? (g(), i("div", Oa, [c(S(k), {
4753
+ l.outputs ? (g(), i("div", Da, [c(S(O), {
4720
4754
  icon: "pi pi-copy",
4721
- label: kt.value,
4755
+ label: H.value,
4722
4756
  size: "small",
4723
4757
  text: "",
4724
4758
  title: "Copy the selection, or the whole equation, as LaTeX, MathJSON or Content MathML",
4725
4759
  "aria-haspopup": "true",
4726
4760
  "aria-controls": "copy-as-menu",
4727
4761
  "data-role": "copy-as",
4728
- disabled: !Ot.value,
4729
- onMousedown: u[6] ||= O(() => {}, ["prevent"]),
4730
- onClick: Mt
4731
- }, null, 8, ["label", "disabled"]), c(S(ce), {
4762
+ disabled: !Ft.value,
4763
+ onMousedown: u[6] ||= D(() => {}, ["prevent"]),
4764
+ onClick: Rt
4765
+ }, null, 8, ["label", "disabled"]), c(S(le), {
4732
4766
  id: "copy-as-menu",
4733
4767
  ref_key: "copyMenu",
4734
- ref: wt,
4735
- model: jt.value,
4768
+ ref: jt,
4769
+ model: Lt.value,
4736
4770
  popup: !0
4737
4771
  }, null, 8, ["model"])])) : r("", !0)
4738
- ]),
4739
- c(S(le), {
4772
+ ], 2),
4773
+ c(S(ue), {
4740
4774
  ref_key: "gallery",
4741
- ref: Ve,
4775
+ ref: Je,
4742
4776
  "data-me-popover": "",
4743
4777
  "data-role": "gallery",
4744
4778
  class: "me-gallery"
4745
4779
  }, {
4746
- default: E(() => [He.value ? (g(), i("div", ka, [(g(!0), i(e, null, v(He.value.sections, (t, n) => (g(), i("div", {
4780
+ default: T(() => [Ye.value ? (g(), i("div", Oa, [(g(!0), i(e, null, v(Ye.value.sections, (t, n) => (g(), i("div", {
4747
4781
  key: n,
4748
4782
  class: "gallery-section"
4749
- }, [t.label ? (g(), i("div", Aa, y(t.label), 1)) : r("", !0), a("div", ja, [(g(!0), i(e, null, v(t.items, (e) => (g(), i("button", {
4783
+ }, [t.label ? (g(), i("div", ka, y(t.label), 1)) : r("", !0), a("div", Aa, [(g(!0), i(e, null, v(t.items, (e) => (g(), i("button", {
4750
4784
  key: e.title,
4751
4785
  type: "button",
4752
4786
  class: "tool-button",
4753
4787
  title: e.title,
4754
- onMousedown: u[7] ||= O(() => {}, ["prevent"]),
4755
- onClick: (t) => We(e.command)
4756
- }, [a("span", { innerHTML: Ge(e.latex) }, null, 8, Na)], 40, Ma))), 128))])]))), 128))])) : r("", !0)]),
4788
+ onMousedown: u[7] ||= D(() => {}, ["prevent"]),
4789
+ onClick: (t) => Ze(e.command)
4790
+ }, [a("span", { innerHTML: Qe(e.latex) }, null, 8, Ma)], 40, ja))), 128))])]))), 128))])) : r("", !0)]),
4757
4791
  _: 1
4758
4792
  }, 512),
4759
4793
  a("div", {
4760
4794
  ref_key: "stackEl",
4761
- ref: B,
4795
+ ref: Be,
4762
4796
  class: "equations-stack",
4763
- onKeydown: Be,
4764
- onFocusout: Pe
4765
- }, [(g(!0), i(e, null, v(x.value, (e, t) => (g(), i("div", {
4766
- key: T.value[t],
4767
- class: p(["equation-row", [{ active: t === A.value }, at(t)]]),
4797
+ onKeydown: qe,
4798
+ onFocusout: Ve
4799
+ }, [(g(!0), i(e, null, v(C.value, (e, t) => (g(), i("div", {
4800
+ key: E.value[t],
4801
+ class: p(["equation-row", [{ active: t === A.value }, ft(t)]]),
4768
4802
  "data-line": t,
4769
- "data-line-id": T.value[t],
4770
- onFocusin: (e) => Ne(t)
4771
- }, [a("div", Fa, y(t + 1), 1), c(Wi, {
4803
+ "data-line-id": E.value[t],
4804
+ onFocusin: (e) => ze(t)
4805
+ }, [a("div", Pa, y(t + 1), 1), c(Gi, {
4772
4806
  ref_for: !0,
4773
- ref: (e) => _e.value[t] = e,
4807
+ ref: (e) => ve.value[t] = e,
4774
4808
  class: "equation-field",
4775
4809
  "model-value": e.root,
4776
4810
  cursor: e.cursor,
@@ -4778,12 +4812,12 @@ var va = [
4778
4812
  active: t === A.value,
4779
4813
  readonly: l.readonly,
4780
4814
  autofocus: l.autofocus && t === A.value ? !0 : void 0,
4781
- marks: rt.value[t],
4815
+ marks: ut.value[t],
4782
4816
  "greek-names": l.greekNames,
4783
4817
  "typeset-names": l.typesetNames,
4784
- onNavigate: (e) => Te(t, e),
4785
- onEdit: (e, n) => we(t, e, n),
4786
- onImport: (e) => Oe(t, e)
4818
+ onNavigate: (e) => De(t, e),
4819
+ onEdit: (e, n) => R(t, e, n),
4820
+ onImport: (e) => ke(t, e)
4787
4821
  }, null, 8, [
4788
4822
  "model-value",
4789
4823
  "cursor",
@@ -4797,50 +4831,50 @@ var va = [
4797
4831
  "onNavigate",
4798
4832
  "onEdit",
4799
4833
  "onImport"
4800
- ])], 42, Pa))), 128))], 544),
4834
+ ])], 42, Na))), 128))], 544),
4801
4835
  a("div", {
4802
4836
  class: p(["status-bar", V.value ? `status-${V.value.kind}` : null]),
4803
4837
  "data-role": "status",
4804
4838
  "data-kind": V.value?.kind,
4805
- title: ot.value || void 0,
4839
+ title: pt.value || void 0,
4806
4840
  role: "status",
4807
- onMousedown: u[8] ||= O(() => {}, ["prevent"]),
4808
- onClick: st
4809
- }, [V.value?.kind === "command" ? (g(), i("span", La, [
4841
+ onMousedown: u[8] ||= D(() => {}, ["prevent"]),
4842
+ onClick: mt
4843
+ }, [V.value?.kind === "command" ? (g(), i("span", Ia, [
4810
4844
  u[10] ||= a("span", { class: "command-slash" }, "\\", -1),
4811
4845
  s(y(V.value.text), 1),
4812
4846
  u[11] ||= a("span", { class: "command-caret" }, null, -1)
4813
- ])) : V.value ? (g(), i(e, { key: 1 }, [a("span", Ra, y(V.value.text), 1), V.value.more ? (g(), i("span", za, "+" + y(V.value.more) + " more", 1)) : r("", !0)], 64)) : r("", !0)], 42, Ia),
4814
- l.debug ? (g(), i("p", Ba, [
4847
+ ])) : V.value ? (g(), i(e, { key: 1 }, [a("span", La, y(V.value.text), 1), V.value.more ? (g(), i("span", Ra, "+" + y(V.value.more) + " more", 1)) : r("", !0)], 64)) : r("", !0)], 42, Fa),
4848
+ l.debug ? (g(), i("p", za, [
4815
4849
  u[13] ||= s(" Cursor: ", -1),
4816
- a("span", Va, y(_t.value), 1),
4817
- vt.value ? (g(), i(e, { key: 0 }, [u[12] ||= s(" · Selection: ", -1), a("span", Ha, y(vt.value), 1)], 64)) : r("", !0)
4850
+ a("span", Ba, y(wt.value), 1),
4851
+ Tt.value ? (g(), i(e, { key: 0 }, [u[12] ||= s(" · Selection: ", -1), a("span", Va, y(Tt.value), 1)], 64)) : r("", !0)
4818
4852
  ])) : r("", !0),
4819
- a("details", Ua, [u[20] ||= o("<summary data-v-9ad8f63a>Keys and typing</summary><p class=\"key-hint\" data-v-9ad8f63a><kbd data-v-9ad8f63a>←</kbd><kbd data-v-9ad8f63a>→</kbd> move through every position · <kbd data-v-9ad8f63a>↑</kbd><kbd data-v-9ad8f63a>↓</kbd> numerator/denominator, else previous/next line · <kbd data-v-9ad8f63a>Home</kbd><kbd data-v-9ad8f63a>End</kbd> start/end · <kbd data-v-9ad8f63a>Tab</kbd> next empty slot · <kbd data-v-9ad8f63a>Space</kbd> step out of a fraction, exponent or bracket · <kbd data-v-9ad8f63a>Enter</kbd> new line (in a piecewise: new piece; <kbd data-v-9ad8f63a>Backspace</kbd> in an empty piece removes it; <code data-v-9ad8f63a>\\otherwise</code> adds one) </p><p class=\"key-hint\" data-v-9ad8f63a> Select with <kbd data-v-9ad8f63a>Shift</kbd>+<kbd data-v-9ad8f63a>←</kbd><kbd data-v-9ad8f63a>→</kbd>, <kbd data-v-9ad8f63a>Shift</kbd>+<kbd data-v-9ad8f63a>Home</kbd><kbd data-v-9ad8f63a>End</kbd>, <kbd data-v-9ad8f63a>Ctrl</kbd>+<kbd data-v-9ad8f63a>A</kbd> or by dragging · <code data-v-9ad8f63a>/</code>, <code data-v-9ad8f63a>^</code>, <code data-v-9ad8f63a>(</code>, <code data-v-9ad8f63a>|</code>, <code data-v-9ad8f63a>\\sqrt</code>, <code data-v-9ad8f63a>\\sin</code>, … or a toolbar button then wraps the selection · typing replaces it · <kbd data-v-9ad8f63a>Esc</kbd> clears it · <kbd data-v-9ad8f63a>Ctrl</kbd>+<kbd data-v-9ad8f63a>C</kbd>/<kbd data-v-9ad8f63a>X</kbd>/<kbd data-v-9ad8f63a>V</kbd> copy, cut and paste (copies as LaTeX for other apps; pastes LaTeX or plain text such as <code data-v-9ad8f63a>(x+1)/2</code>) </p>", 3), a("p", Wa, [u[19] ||= o(" Type letters, numbers and <code data-v-9ad8f63a>+ − * = ,</code> where the caret is · conditions: <code data-v-9ad8f63a>&lt; &gt; &lt;= &gt;= !=</code>, <code data-v-9ad8f63a>&amp;</code> (∧), <code data-v-9ad8f63a>!</code> (¬), <code data-v-9ad8f63a>\\or</code> (∨) · <code data-v-9ad8f63a>/</code> makes a fraction of what&#39;s before the caret · <code data-v-9ad8f63a>^</code> exponent · <code data-v-9ad8f63a>( )</code> and <code data-v-9ad8f63a>| |</code> brackets · <code data-v-9ad8f63a>0.25{mV}</code> a number&#39;s units · letters, digits and <code data-v-9ad8f63a>_</code> with no operator between them are one name (<code data-v-9ad8f63a>Vm_init</code>); multiply names with <code data-v-9ad8f63a>*</code> (<code data-v-9ad8f63a>a*b</code>) · a name spelling a function (<code data-v-9ad8f63a>sin</code>, <code data-v-9ad8f63a>cosh</code>, …) is that function · <code data-v-9ad8f63a>\\</code> commands (<code data-v-9ad8f63a>\\frac \\sqrt \\root \\abs \\dd \\cases \\sin \\pi \\e \\inf \\alpha</code> …) · <kbd data-v-9ad8f63a>Backspace</kbd>/<kbd data-v-9ad8f63a>Delete</kbd> delete", 41), m.history ? (g(), i(e, { key: 0 }, [
4853
+ a("details", Ha, [u[20] ||= o("<summary data-v-2efa820f>Keys and typing</summary><p class=\"key-hint\" data-v-2efa820f><kbd data-v-2efa820f>←</kbd><kbd data-v-2efa820f>→</kbd> move through every position · <kbd data-v-2efa820f>↑</kbd><kbd data-v-2efa820f>↓</kbd> numerator/denominator, else previous/next line · <kbd data-v-2efa820f>Home</kbd><kbd data-v-2efa820f>End</kbd> start/end · <kbd data-v-2efa820f>Tab</kbd> next empty slot · <kbd data-v-2efa820f>Space</kbd> step out of a fraction, exponent or bracket · <kbd data-v-2efa820f>Enter</kbd> new line (in a piecewise: new piece; <kbd data-v-2efa820f>Backspace</kbd> in an empty piece removes it; <code data-v-2efa820f>\\otherwise</code> adds one) </p><p class=\"key-hint\" data-v-2efa820f> Select with <kbd data-v-2efa820f>Shift</kbd>+<kbd data-v-2efa820f>←</kbd><kbd data-v-2efa820f>→</kbd>, <kbd data-v-2efa820f>Shift</kbd>+<kbd data-v-2efa820f>Home</kbd><kbd data-v-2efa820f>End</kbd>, <kbd data-v-2efa820f>Ctrl</kbd>+<kbd data-v-2efa820f>A</kbd> or by dragging · <code data-v-2efa820f>/</code>, <code data-v-2efa820f>^</code>, <code data-v-2efa820f>(</code>, <code data-v-2efa820f>|</code>, <code data-v-2efa820f>\\sqrt</code>, <code data-v-2efa820f>\\sin</code>, … or a toolbar button then wraps the selection · typing replaces it · <kbd data-v-2efa820f>Esc</kbd> clears it · <kbd data-v-2efa820f>Ctrl</kbd>+<kbd data-v-2efa820f>C</kbd>/<kbd data-v-2efa820f>X</kbd>/<kbd data-v-2efa820f>V</kbd> copy, cut and paste (copies as LaTeX for other apps; pastes LaTeX or plain text such as <code data-v-2efa820f>(x+1)/2</code>) </p>", 3), a("p", Ua, [u[19] ||= o(" Type letters, numbers and <code data-v-2efa820f>+ − * = ,</code> where the caret is · conditions: <code data-v-2efa820f>&lt; &gt; &lt;= &gt;= !=</code>, <code data-v-2efa820f>&amp;</code> (∧), <code data-v-2efa820f>!</code> (¬), <code data-v-2efa820f>\\or</code> (∨) · <code data-v-2efa820f>/</code> makes a fraction of what&#39;s before the caret · <code data-v-2efa820f>^</code> exponent · <code data-v-2efa820f>( )</code> and <code data-v-2efa820f>| |</code> brackets · <code data-v-2efa820f>0.25{mV}</code> a number&#39;s units · letters, digits and <code data-v-2efa820f>_</code> with no operator between them are one name (<code data-v-2efa820f>Vm_init</code>); multiply names with <code data-v-2efa820f>*</code> (<code data-v-2efa820f>a*b</code>) · a name spelling a function (<code data-v-2efa820f>sin</code>, <code data-v-2efa820f>cosh</code>, …) is that function · <code data-v-2efa820f>\\</code> commands (<code data-v-2efa820f>\\frac \\sqrt \\root \\abs \\dd \\cases \\sin \\pi \\e \\inf \\alpha</code> …) · <kbd data-v-2efa820f>Backspace</kbd>/<kbd data-v-2efa820f>Delete</kbd> delete", 41), m.history ? (g(), i(e, { key: 0 }, [
4820
4854
  u[14] ||= s(" · ", -1),
4821
4855
  u[15] ||= a("kbd", null, "Ctrl", -1),
4822
4856
  u[16] ||= s("+", -1),
4823
4857
  u[17] ||= a("kbd", null, "Z", -1),
4824
4858
  u[18] ||= s(" undo", -1)
4825
4859
  ], 64)) : r("", !0)])])
4826
- ]),
4827
- t.$slots.side ? (g(), i("aside", Ga, [ne(t.$slots, "side", {}, void 0, !0)])) : r("", !0),
4828
- l.outputs ? (g(), n(S(se), {
4860
+ ], 512),
4861
+ t.$slots.side ? (g(), i("aside", Wa, [ne(t.$slots, "side", {}, void 0, !0)])) : r("", !0),
4862
+ l.outputs ? (g(), n(S(ce), {
4829
4863
  key: 1,
4830
4864
  class: "output-card",
4831
4865
  "data-role": "outputs"
4832
4866
  }, {
4833
- content: E(() => [c(S(me), {
4834
- value: bt.value,
4835
- "onUpdate:value": u[9] ||= (e) => bt.value = e
4867
+ content: T(() => [c(S(he), {
4868
+ value: Dt.value,
4869
+ "onUpdate:value": u[9] ||= (e) => Dt.value = e
4836
4870
  }, {
4837
- default: E(() => [c(S(de), null, {
4838
- default: E(() => [
4839
- c(S(ue), {
4871
+ default: T(() => [c(S(fe), null, {
4872
+ default: T(() => [
4873
+ c(S(de), {
4840
4874
  value: "mathml",
4841
4875
  "data-role": "tab-mathml"
4842
4876
  }, {
4843
- default: E(() => [u[21] ||= s(" Content MathML ", -1), l.cellml ? (g(), n(S(he), {
4877
+ default: T(() => [u[21] ||= s(" Content MathML ", -1), l.cellml ? (g(), n(S(ge), {
4844
4878
  key: 0,
4845
4879
  class: "tab-tag",
4846
4880
  severity: "secondary",
@@ -4849,52 +4883,52 @@ var va = [
4849
4883
  })) : r("", !0)]),
4850
4884
  _: 1
4851
4885
  }),
4852
- c(S(ue), {
4886
+ c(S(de), {
4853
4887
  value: "mathjson",
4854
4888
  "data-role": "tab-mathjson"
4855
4889
  }, {
4856
- default: E(() => [...u[22] ||= [s("MathJSON", -1)]]),
4890
+ default: T(() => [...u[22] ||= [s("MathJSON", -1)]]),
4857
4891
  _: 1
4858
4892
  }),
4859
- c(S(ue), {
4893
+ c(S(de), {
4860
4894
  value: "latex",
4861
4895
  "data-role": "tab-latex"
4862
4896
  }, {
4863
- default: E(() => [...u[23] ||= [s("LaTeX", -1)]]),
4897
+ default: T(() => [...u[23] ||= [s("LaTeX", -1)]]),
4864
4898
  _: 1
4865
4899
  }),
4866
- c(S(ue), {
4900
+ c(S(de), {
4867
4901
  value: "ast",
4868
4902
  "data-role": "tab-ast"
4869
4903
  }, {
4870
- default: E(() => [...u[24] ||= [s("AST", -1)]]),
4904
+ default: T(() => [...u[24] ||= [s("AST", -1)]]),
4871
4905
  _: 1
4872
4906
  })
4873
4907
  ]),
4874
4908
  _: 1
4875
- }), c(S(pe), null, {
4876
- default: E(() => [
4877
- c(S(fe), { value: "mathml" }, {
4878
- default: E(() => [a("pre", Ka, y(gt.value), 1)]),
4909
+ }), c(S(me), null, {
4910
+ default: T(() => [
4911
+ c(S(pe), { value: "mathml" }, {
4912
+ default: T(() => [a("pre", Ga, y(Ct.value), 1)]),
4879
4913
  _: 1
4880
4914
  }),
4881
- c(S(fe), { value: "mathjson" }, {
4882
- default: E(() => [a("div", qa, [c(S(k), {
4915
+ c(S(pe), { value: "mathjson" }, {
4916
+ default: T(() => [a("div", Ka, [c(S(O), {
4883
4917
  icon: "pi pi-copy",
4884
- label: yt.value ? "Copied" : "Copy MathJSON",
4918
+ label: Et.value ? "Copied" : "Copy MathJSON",
4885
4919
  size: "small",
4886
4920
  text: "",
4887
- disabled: !mt.value,
4888
- onClick: Ct
4889
- }, null, 8, ["label", "disabled"])]), a("pre", Ja, y(mt.value), 1)]),
4921
+ disabled: !St.value,
4922
+ onClick: At
4923
+ }, null, 8, ["label", "disabled"])]), a("pre", qa, y(St.value), 1)]),
4890
4924
  _: 1
4891
4925
  }),
4892
- c(S(fe), { value: "latex" }, {
4893
- default: E(() => [a("pre", Ya, y(pt.value), 1)]),
4926
+ c(S(pe), { value: "latex" }, {
4927
+ default: T(() => [a("pre", Ja, y(xt.value), 1)]),
4894
4928
  _: 1
4895
4929
  }),
4896
- c(S(fe), { value: "ast" }, {
4897
- default: E(() => [a("pre", Xa, y(ft.value ? JSON.stringify(ft.value, null, 2) : ""), 1)]),
4930
+ c(S(pe), { value: "ast" }, {
4931
+ default: T(() => [a("pre", Ya, y(bt.value ? JSON.stringify(bt.value, null, 2) : ""), 1)]),
4898
4932
  _: 1
4899
4933
  })
4900
4934
  ]),
@@ -4906,7 +4940,7 @@ var va = [
4906
4940
  })) : r("", !0)
4907
4941
  ], 34));
4908
4942
  }
4909
- }), [["__scopeId", "data-v-9ad8f63a"]]), $a = "new units", eo = [
4943
+ }), [["__scopeId", "data-v-2efa820f"]]), Qa = "new units", $a = [
4910
4944
  "yotta",
4911
4945
  "zetta",
4912
4946
  "exa",
@@ -4927,15 +4961,15 @@ var va = [
4927
4961
  "atto",
4928
4962
  "zepto",
4929
4963
  "yocto"
4930
- ], to = /^[A-Za-z_][A-Za-z0-9_]*$/;
4931
- function no(e, t, n) {
4964
+ ], eo = /^[A-Za-z_][A-Za-z0-9_]*$/;
4965
+ function to(e, t, n) {
4932
4966
  let r = [], { name: i, parts: a } = e;
4933
- return i ? to.test(i) ? (t.some((e) => e.name === i) || n?.includes(i)) && r.push(`There are units called ${i} already`) : r.push(`${i} isn't a units name: use letters, digits and _, not starting with a digit`) : r.push("Give the units a name"), a.length === 0 && r.push("Add what the units are made of"), a.forEach((e, o) => {
4967
+ return i ? eo.test(i) ? (t.some((e) => e.name === i) || n?.includes(i)) && r.push(`There are units called ${i} already`) : r.push(`${i} isn't a units name: use letters, digits and _, not starting with a digit`) : r.push("Give the units a name"), a.length === 0 && r.push("Add what the units are made of"), a.forEach((e, o) => {
4934
4968
  let s = a.length > 1 ? `Part ${o + 1}: ` : "";
4935
- e.units ? e.units === i ? r.push(`${s}units can't be made of themselves`) : n && !n.includes(e.units) && !t.some((t) => t.name === e.units) && r.push(`${s}no units called ${e.units} are defined`) : r.push(`${s}choose the units it is made of`), e.prefix && !eo.includes(e.prefix) && r.push(`${s}${e.prefix} isn't a prefix`), e.exponent !== void 0 && !Number.isFinite(e.exponent) && r.push(`${s}the exponent must be a number`), e.multiplier !== void 0 && !Number.isFinite(e.multiplier) && r.push(`${s}the multiplier must be a number`);
4936
- }), i && to.test(i) && ro(i, a, t) && r.push(`${i} would be made of itself, through other new units`), r;
4969
+ e.units ? e.units === i ? r.push(`${s}units can't be made of themselves`) : n && !n.includes(e.units) && !t.some((t) => t.name === e.units) && r.push(`${s}no units called ${e.units} are defined`) : r.push(`${s}choose the units it is made of`), e.prefix && !$a.includes(e.prefix) && r.push(`${s}${e.prefix} isn't a prefix`), e.exponent !== void 0 && !Number.isFinite(e.exponent) && r.push(`${s}the exponent must be a number`), e.multiplier !== void 0 && !Number.isFinite(e.multiplier) && r.push(`${s}the multiplier must be a number`);
4970
+ }), i && eo.test(i) && no(i, a, t) && r.push(`${i} would be made of itself, through other new units`), r;
4937
4971
  }
4938
- function ro(e, t, n) {
4972
+ function no(e, t, n) {
4939
4973
  let r = /* @__PURE__ */ new Set(), i = (t) => {
4940
4974
  if (t === e) return !0;
4941
4975
  if (r.has(t)) return !1;
@@ -4945,17 +4979,17 @@ function ro(e, t, n) {
4945
4979
  };
4946
4980
  return t.some((t) => t.units !== e && i(t.units));
4947
4981
  }
4948
- function io(e, t) {
4982
+ function ro(e, t) {
4949
4983
  return t.filter((t) => t.parts.some((t) => t.units === e)).map((e) => e.name);
4950
4984
  }
4951
- function ao(e) {
4985
+ function io(e) {
4952
4986
  return e.parts.map((e) => {
4953
4987
  let t = [e.multiplier !== void 0 && e.multiplier !== 1 ? e.multiplier : ""].concat(e.prefix ?? "", e.units).filter((e) => e !== "").join(" "), n = e.exponent ?? 1;
4954
4988
  return n === 1 ? t : t.includes(" ") ? `(${t})^${n}` : `${t}^${n}`;
4955
4989
  }).join(" · ");
4956
4990
  }
4957
- var oo = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
4958
- function so(e, t = "new_units") {
4991
+ var ao = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
4992
+ function oo(e, t = "new_units") {
4959
4993
  let n = [], r = (t, i) => {
4960
4994
  if (!(n.includes(t) || i.has(t.name))) {
4961
4995
  i.add(t.name);
@@ -4969,20 +5003,20 @@ function so(e, t = "new_units") {
4969
5003
  for (let t of e) r(t, /* @__PURE__ */ new Set());
4970
5004
  let i = n.map((e) => {
4971
5005
  let t = e.parts.map((e) => ` <unit${[
4972
- e.prefix ? ` prefix="${oo(e.prefix)}"` : "",
4973
- ` units="${oo(e.units)}"`,
5006
+ e.prefix ? ` prefix="${ao(e.prefix)}"` : "",
5007
+ ` units="${ao(e.units)}"`,
4974
5008
  e.exponent !== void 0 && e.exponent !== 1 ? ` exponent="${e.exponent}"` : "",
4975
5009
  e.multiplier !== void 0 && e.multiplier !== 1 ? ` multiplier="${e.multiplier}"` : ""
4976
5010
  ].join("")}/>`);
4977
5011
  return [
4978
- ` <units name="${oo(e.name)}">`,
5012
+ ` <units name="${ao(e.name)}">`,
4979
5013
  ...t,
4980
5014
  " </units>"
4981
5015
  ].join("\n");
4982
5016
  });
4983
5017
  return [
4984
5018
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
4985
- `<model xmlns="http://www.cellml.org/cellml/2.0#" name="${oo(t)}">`,
5019
+ `<model xmlns="http://www.cellml.org/cellml/2.0#" name="${ao(t)}">`,
4986
5020
  ...i,
4987
5021
  "</model>",
4988
5022
  ""
@@ -4990,15 +5024,15 @@ function so(e, t = "new_units") {
4990
5024
  }
4991
5025
  //#endregion
4992
5026
  //#region src/units/UnitsDefinitionForm.vue?vue&type=script&setup=true&lang.ts
4993
- var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:modelValue", "aria-label"], fo = ["value"], po = [
5027
+ var so = { class: "form-name" }, co = { class: "form-parts" }, lo = ["onUpdate:modelValue", "aria-label"], uo = ["value"], fo = [
4994
5028
  "onUpdate:modelValue",
4995
5029
  "list",
4996
5030
  "aria-label"
4997
- ], mo = ["onUpdate:modelValue", "aria-label"], ho = ["onUpdate:modelValue", "aria-label"], go = ["id"], _o = ["value"], vo = {
5031
+ ], po = ["onUpdate:modelValue", "aria-label"], mo = ["onUpdate:modelValue", "aria-label"], ho = ["id"], go = ["value"], _o = {
4998
5032
  key: 0,
4999
5033
  class: "form-problems",
5000
5034
  "data-role": "units-form-problems"
5001
- }, yo = { class: "form-actions" }, bo = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
5035
+ }, vo = { class: "form-actions" }, yo = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
5002
5036
  __name: "UnitsDefinitionForm",
5003
5037
  props: {
5004
5038
  definition: {},
@@ -5025,7 +5059,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5025
5059
  ...n !== void 0 && n !== 1 ? { multiplier: n } : {}
5026
5060
  };
5027
5061
  })
5028
- })), h = t(() => no(te.value, s.others, s.known));
5062
+ })), h = t(() => to(te.value, s.others, s.known));
5029
5063
  function ne() {
5030
5064
  m.value = !0, h.value.length === 0 && l("save", te.value);
5031
5065
  }
@@ -5033,17 +5067,17 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5033
5067
  return (t, o) => (g(), i("form", {
5034
5068
  class: "units-form",
5035
5069
  "data-role": "units-form",
5036
- onSubmit: O(ne, ["prevent"])
5070
+ onSubmit: D(ne, ["prevent"])
5037
5071
  }, [
5038
- a("label", co, [o[3] ||= a("span", null, "Name", -1), D(a("input", {
5072
+ a("label", so, [o[3] ||= a("span", null, "Name", -1), E(a("input", {
5039
5073
  "onUpdate:modelValue": o[0] ||= (e) => f.value = e,
5040
5074
  type: "text",
5041
5075
  spellcheck: "false",
5042
5076
  autocomplete: "off",
5043
5077
  placeholder: "mV_per_ms",
5044
5078
  "data-role": "units-form-name"
5045
- }, null, 512), [[T, f.value]])]),
5046
- a("table", lo, [o[5] ||= a("thead", null, [a("tr", null, [
5079
+ }, null, 512), [[w, f.value]])]),
5080
+ a("table", co, [o[5] ||= a("thead", null, [a("tr", null, [
5047
5081
  a("th", { scope: "col" }, "Prefix"),
5048
5082
  a("th", { scope: "col" }, "Units"),
5049
5083
  a("th", {
@@ -5059,14 +5093,14 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5059
5093
  key: t.key,
5060
5094
  "data-role": "units-form-part"
5061
5095
  }, [
5062
- a("td", null, [D(a("select", {
5096
+ a("td", null, [E(a("select", {
5063
5097
  "onUpdate:modelValue": (e) => t.prefix = e,
5064
5098
  "aria-label": `Prefix of part ${n + 1}`
5065
- }, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S(eo), (e) => (g(), i("option", {
5099
+ }, [o[4] ||= a("option", { value: "" }, "—", -1), (g(!0), i(e, null, v(S($a), (e) => (g(), i("option", {
5066
5100
  key: e,
5067
5101
  value: e
5068
- }, y(e), 9, fo))), 128))], 8, uo), [[w, t.prefix]])]),
5069
- a("td", null, [D(a("input", {
5102
+ }, y(e), 9, uo))), 128))], 8, lo), [[ae, t.prefix]])]),
5103
+ a("td", null, [E(a("input", {
5070
5104
  "onUpdate:modelValue": (e) => t.units = e,
5071
5105
  type: "text",
5072
5106
  list: S(re),
@@ -5074,24 +5108,24 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5074
5108
  autocomplete: "off",
5075
5109
  placeholder: "second",
5076
5110
  "aria-label": `Units of part ${n + 1}`
5077
- }, null, 8, po), [[T, t.units]])]),
5078
- a("td", null, [D(a("input", {
5111
+ }, null, 8, fo), [[w, t.units]])]),
5112
+ a("td", null, [E(a("input", {
5079
5113
  "onUpdate:modelValue": (e) => t.exponent = e,
5080
5114
  class: "number",
5081
5115
  type: "text",
5082
5116
  inputmode: "decimal",
5083
5117
  placeholder: "1",
5084
5118
  "aria-label": `Exponent of part ${n + 1}`
5085
- }, null, 8, mo), [[T, t.exponent]])]),
5086
- a("td", null, [D(a("input", {
5119
+ }, null, 8, po), [[w, t.exponent]])]),
5120
+ a("td", null, [E(a("input", {
5087
5121
  "onUpdate:modelValue": (e) => t.multiplier = e,
5088
5122
  class: "number",
5089
5123
  type: "text",
5090
5124
  inputmode: "decimal",
5091
5125
  placeholder: "1",
5092
5126
  "aria-label": `Multiplier of part ${n + 1}`
5093
- }, null, 8, ho), [[T, t.multiplier]])]),
5094
- a("td", null, [c(S(k), {
5127
+ }, null, 8, mo), [[w, t.multiplier]])]),
5128
+ a("td", null, [c(S(O), {
5095
5129
  icon: "pi pi-times",
5096
5130
  size: "small",
5097
5131
  text: "",
@@ -5110,10 +5144,10 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5110
5144
  a("datalist", { id: S(re) }, [(g(!0), i(e, null, v(n.choices, (e) => (g(), i("option", {
5111
5145
  key: e,
5112
5146
  value: e
5113
- }, null, 8, _o))), 128))], 8, go),
5114
- m.value && h.value.length ? (g(), i("ul", vo, [(g(!0), i(e, null, v(h.value, (e) => (g(), i("li", { key: e }, y(e), 1))), 128))])) : r("", !0),
5115
- a("div", yo, [
5116
- c(S(k), {
5147
+ }, null, 8, go))), 128))], 8, ho),
5148
+ m.value && h.value.length ? (g(), i("ul", _o, [(g(!0), i(e, null, v(h.value, (e) => (g(), i("li", { key: e }, y(e), 1))), 128))])) : r("", !0),
5149
+ a("div", vo, [
5150
+ c(S(O), {
5117
5151
  icon: "pi pi-plus",
5118
5152
  label: "Part",
5119
5153
  size: "small",
@@ -5123,7 +5157,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5123
5157
  onClick: o[1] ||= (e) => p.value.push(d())
5124
5158
  }),
5125
5159
  o[6] ||= a("span", { class: "spacer" }, null, -1),
5126
- c(S(k), {
5160
+ c(S(O), {
5127
5161
  label: "Cancel",
5128
5162
  size: "small",
5129
5163
  text: "",
@@ -5131,7 +5165,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5131
5165
  type: "button",
5132
5166
  onClick: o[2] ||= (e) => l("cancel")
5133
5167
  }),
5134
- c(S(k), {
5168
+ c(S(O), {
5135
5169
  label: n.definition ? "Save" : "Add",
5136
5170
  size: "small",
5137
5171
  type: "submit",
@@ -5143,7 +5177,7 @@ var co = { class: "form-name" }, lo = { class: "form-parts" }, uo = ["onUpdate:m
5143
5177
  }), [["__scopeId", "data-v-effe158e"]]);
5144
5178
  //#endregion
5145
5179
  //#region src/units/panel.ts
5146
- function xo(e, t, n) {
5180
+ function bo(e, t, n) {
5147
5181
  let r = [...new Set(e.flatMap((e) => e.variables))], i = Object.keys(t).filter((e) => !r.includes(e)), a = n ? new Set(n) : null;
5148
5182
  return [...r, ...i].map((e) => {
5149
5183
  let n = t[e] ?? "", i = n ? a && !a.has(n) ? "unknown" : "ok" : "missing";
@@ -5155,11 +5189,11 @@ function xo(e, t, n) {
5155
5189
  };
5156
5190
  });
5157
5191
  }
5158
- function So(e, t, n) {
5192
+ function xo(e, t, n) {
5159
5193
  let r = { ...e }, i = n.trim();
5160
5194
  return i ? r[t] = i : delete r[t], r;
5161
5195
  }
5162
- function Co(e, t) {
5196
+ function So(e, t) {
5163
5197
  let n = [...e];
5164
5198
  for (let e of t) {
5165
5199
  let t = n.findIndex((t) => t.name === e.name);
@@ -5169,67 +5203,67 @@ function Co(e, t) {
5169
5203
  }
5170
5204
  //#endregion
5171
5205
  //#region src/units/UnitsPanel.vue?vue&type=script&setup=true&lang.ts
5172
- var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5206
+ var Co = { class: "units-title" }, wo = { "data-role": "units-summary" }, To = {
5173
5207
  class: "units-section",
5174
5208
  "aria-labelledby": "units-files-title"
5175
- }, Do = { class: "section-head" }, Oo = { class: "section-actions" }, ko = {
5209
+ }, Eo = { class: "section-head" }, Do = { class: "section-actions" }, Oo = {
5176
5210
  key: 0,
5177
5211
  class: "hint"
5178
- }, Ao = {
5212
+ }, ko = {
5179
5213
  key: 1,
5180
5214
  class: "files",
5181
5215
  "data-role": "units-files"
5182
- }, jo = ["data-file"], Mo = { class: "file-head" }, No = { class: "file-name" }, Po = { class: "file-count" }, Fo = {
5216
+ }, Ao = ["data-file"], jo = { class: "file-head" }, Mo = { class: "file-name" }, No = { class: "file-count" }, Po = {
5183
5217
  key: 0,
5184
5218
  class: "units-names"
5185
- }, Io = {
5219
+ }, Fo = {
5186
5220
  key: 1,
5187
5221
  class: "problems",
5188
5222
  "data-role": "units-problems"
5189
- }, Lo = {
5223
+ }, Io = {
5190
5224
  class: "units-section",
5191
5225
  "aria-labelledby": "units-new-title",
5192
5226
  "data-role": "new-units"
5193
- }, Ro = { class: "section-head" }, zo = { class: "section-actions" }, Bo = {
5227
+ }, Lo = { class: "section-head" }, Ro = { class: "section-actions" }, zo = {
5194
5228
  key: 0,
5195
5229
  class: "hint"
5196
- }, Vo = {
5230
+ }, Bo = {
5197
5231
  key: 1,
5198
5232
  class: "new-units"
5199
- }, Ho = ["data-units"], Uo = {
5233
+ }, Vo = ["data-units"], Ho = {
5200
5234
  key: 1,
5201
5235
  class: "new-units-row"
5202
- }, Wo = { class: "new-units-name" }, Go = {
5236
+ }, Uo = { class: "new-units-name" }, Wo = {
5203
5237
  class: "new-units-definition",
5204
5238
  "data-role": "new-units-definition"
5205
- }, Ko = {
5239
+ }, Go = {
5206
5240
  key: 3,
5207
5241
  class: "problems",
5208
5242
  "data-role": "new-units-problems"
5209
- }, qo = {
5243
+ }, Ko = {
5210
5244
  class: "units-section",
5211
5245
  "aria-labelledby": "units-variables-title"
5212
- }, Jo = { class: "section-head" }, Yo = {
5246
+ }, qo = { class: "section-head" }, Jo = {
5213
5247
  key: 0,
5214
5248
  class: "missing-count",
5215
5249
  "data-role": "missing-count"
5216
- }, Xo = {
5250
+ }, Yo = {
5217
5251
  key: 0,
5218
5252
  class: "hint"
5219
- }, Zo = {
5253
+ }, Xo = {
5220
5254
  key: 1,
5221
5255
  class: "variables",
5222
5256
  "data-role": "variables"
5223
- }, Qo = ["data-variable", "data-state"], $o = {
5257
+ }, Zo = ["data-variable", "data-state"], Qo = {
5224
5258
  scope: "row",
5225
5259
  class: "variable-name"
5226
- }, es = [
5260
+ }, $o = [
5227
5261
  "value",
5228
5262
  "list",
5229
5263
  "aria-label",
5230
5264
  "aria-invalid",
5231
5265
  "onChange"
5232
- ], ts = { class: "variable-state" }, ns = ["id"], rs = ["value"], is = /*#__PURE__*/ Ui(/* @__PURE__ */ l({
5266
+ ], es = { class: "variable-state" }, ts = ["id"], ns = ["value"], rs = /*#__PURE__*/ Wi(/* @__PURE__ */ l({
5233
5267
  __name: "UnitsPanel",
5234
5268
  props: /*@__PURE__*/ d({
5235
5269
  status: {},
@@ -5256,7 +5290,7 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5256
5290
  "update:newUnits"
5257
5291
  ],
5258
5292
  setup(o) {
5259
- let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() => xo(l.lines, d.value, m.value ? l.unitsNames : null)), te = t(() => ee.value.filter((e) => e.state === "missing").length), h = t(() => ({
5293
+ let l = o, u = ie(o, "sources"), d = ie(o, "variableUnits"), f = ie(o, "newUnits"), m = t(() => l.status === "ready"), ee = t(() => bo(l.lines, d.value, m.value ? l.unitsNames : null)), te = t(() => ee.value.filter((e) => e.state === "missing").length), h = t(() => ({
5260
5294
  ready: {
5261
5295
  value: "libCellML",
5262
5296
  severity: "success"
@@ -5278,21 +5312,21 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5278
5312
  let t = new Set(l.issues.map((e) => e.lineId)).size;
5279
5313
  return l.issues.length === 0 ? `No units problems in ${b(e, "equation")}.` : `${b(l.issues.length, "units problem")} in ${b(t, "equation")}.`;
5280
5314
  }), b = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, x = _(null);
5281
- async function w(e) {
5315
+ async function ae(e) {
5282
5316
  let t = e.target, n = [...t.files ?? []];
5283
5317
  t.value = "";
5284
5318
  let r = await Promise.all(n.map(async (e) => ({
5285
5319
  name: e.name,
5286
5320
  text: await e.text()
5287
5321
  })));
5288
- r.length && (u.value = Co(u.value, r));
5322
+ r.length && (u.value = So(u.value, r));
5289
5323
  }
5290
- function T(e) {
5324
+ function w(e) {
5291
5325
  u.value = u.value.filter((t) => t.name !== e);
5292
5326
  }
5293
- let ae = (e) => l.problems.filter((t) => t.source === e), D = (e) => l.files.find((t) => t.name === e)?.units ?? [], O = _(void 0), oe = t(() => O.value === void 0 || O.value === null ? null : f.value[O.value]), ce = t(() => f.value.filter((e, t) => t !== O.value)), le = t(() => m.value ? l.unitsNames.filter((e) => e !== oe.value?.name) : null), ue = t(() => [.../* @__PURE__ */ new Set([...l.unitsNames, ...ce.value.map((e) => e.name)])].filter((e) => e !== oe.value?.name)), de = t(() => ae($a));
5294
- function fe(e) {
5295
- let t = [...f.value], n = O.value;
5327
+ let oe = (e) => l.problems.filter((t) => t.source === e), E = (e) => l.files.find((t) => t.name === e)?.units ?? [], D = _(void 0), se = t(() => D.value === void 0 || D.value === null ? null : f.value[D.value]), le = t(() => f.value.filter((e, t) => t !== D.value)), ue = t(() => m.value ? l.unitsNames.filter((e) => e !== se.value?.name) : null), de = t(() => [.../* @__PURE__ */ new Set([...l.unitsNames, ...le.value.map((e) => e.name)])].filter((e) => e !== se.value?.name)), fe = t(() => oe(Qa));
5328
+ function pe(e) {
5329
+ let t = [...f.value], n = D.value;
5296
5330
  if (n == null) t.push(e);
5297
5331
  else {
5298
5332
  let r = t[n].name;
@@ -5304,35 +5338,35 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5304
5338
  } : t)
5305
5339
  });
5306
5340
  }
5307
- f.value = t, O.value = void 0;
5341
+ f.value = t, D.value = void 0;
5308
5342
  }
5309
- function pe(e) {
5343
+ function me(e) {
5310
5344
  f.value = f.value.filter((t, n) => n !== e);
5311
5345
  }
5312
- let me = C();
5313
- function ge(e, t) {
5314
- d.value = So(d.value, e, t.target.value);
5346
+ let he = C();
5347
+ function _e(e, t) {
5348
+ d.value = xo(d.value, e, t.target.value);
5315
5349
  }
5316
- let A = {
5350
+ let k = {
5317
5351
  ok: "",
5318
5352
  missing: "no units",
5319
5353
  unknown: "unknown units"
5320
5354
  };
5321
- return (t, l) => (g(), n(S(se), {
5355
+ return (t, l) => (g(), n(S(ce), {
5322
5356
  class: "units-panel",
5323
5357
  "data-role": "units-panel",
5324
5358
  "data-status": o.status
5325
5359
  }, {
5326
- title: E(() => [a("div", wo, [l[4] ||= a("span", null, "Units", -1), c(S(he), {
5360
+ title: T(() => [a("div", Co, [l[4] ||= a("span", null, "Units", -1), c(S(ge), {
5327
5361
  severity: h.value.severity,
5328
5362
  value: h.value.value,
5329
5363
  "data-role": "units-status"
5330
5364
  }, null, 8, ["severity", "value"])])]),
5331
- subtitle: E(() => [a("span", To, y(re.value), 1)]),
5332
- content: E(() => [
5333
- a("section", Eo, [a("div", Do, [l[5] ||= a("h3", { id: "units-files-title" }, "Units files", -1), a("div", Oo, [
5365
+ subtitle: T(() => [a("span", wo, y(re.value), 1)]),
5366
+ content: T(() => [
5367
+ a("section", To, [a("div", Eo, [l[5] ||= a("h3", { id: "units-files-title" }, "Units files", -1), a("div", Do, [
5334
5368
  ne(t.$slots, "actions", {}, void 0, !0),
5335
- c(S(k), {
5369
+ c(S(O), {
5336
5370
  icon: "pi pi-folder-open",
5337
5371
  label: "Load units files",
5338
5372
  size: "small",
@@ -5349,9 +5383,9 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5349
5383
  multiple: "",
5350
5384
  hidden: "",
5351
5385
  "data-role": "units-file-input",
5352
- onChange: w
5386
+ onChange: ae
5353
5387
  }, null, 544)
5354
- ])]), u.value.length === 0 ? (g(), i("p", ko, [...l[6] ||= [
5388
+ ])]), u.value.length === 0 ? (g(), i("p", Oo, [...l[6] ||= [
5355
5389
  s(" Built-in units (", -1),
5356
5390
  a("code", null, "second", -1),
5357
5391
  s(", ", -1),
@@ -5359,14 +5393,14 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5359
5393
  s(", ", -1),
5360
5394
  a("code", null, "volt", -1),
5361
5395
  s(", …) are always available. Load CellML files for others; only their units are kept. ", -1)
5362
- ]])) : (g(), i("ul", Ao, [(g(!0), i(e, null, v(u.value, (t) => (g(), i("li", {
5396
+ ]])) : (g(), i("ul", ko, [(g(!0), i(e, null, v(u.value, (t) => (g(), i("li", {
5363
5397
  key: t.name,
5364
5398
  "data-file": t.name
5365
5399
  }, [
5366
- a("div", Mo, [
5367
- a("span", No, y(t.name), 1),
5368
- a("span", Po, y(m.value ? b(D(t.name).length, "units definition") : ""), 1),
5369
- c(S(k), {
5400
+ a("div", jo, [
5401
+ a("span", Mo, y(t.name), 1),
5402
+ a("span", No, y(m.value ? b(E(t.name).length, "units definition") : ""), 1),
5403
+ c(S(O), {
5370
5404
  icon: "pi pi-times",
5371
5405
  size: "small",
5372
5406
  text: "",
@@ -5374,44 +5408,44 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5374
5408
  severity: "secondary",
5375
5409
  "aria-label": `Remove ${t.name}`,
5376
5410
  title: "Remove this file",
5377
- onClick: (e) => T(t.name)
5411
+ onClick: (e) => w(t.name)
5378
5412
  }, null, 8, ["aria-label", "onClick"])
5379
5413
  ]),
5380
- D(t.name).length ? (g(), i("div", Fo, [(g(!0), i(e, null, v(D(t.name), (e) => (g(), i("code", { key: e }, y(e), 1))), 128))])) : r("", !0),
5381
- ae(t.name).length ? (g(), i("ul", Io, [(g(!0), i(e, null, v(ae(t.name), (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
5382
- ], 8, jo))), 128))]))]),
5383
- a("section", Lo, [
5384
- a("div", Ro, [l[7] ||= a("h3", { id: "units-new-title" }, "New units", -1), a("div", zo, [ne(t.$slots, "new-units-actions", { definitions: f.value }, void 0, !0), c(S(k), {
5414
+ E(t.name).length ? (g(), i("div", Po, [(g(!0), i(e, null, v(E(t.name), (e) => (g(), i("code", { key: e }, y(e), 1))), 128))])) : r("", !0),
5415
+ oe(t.name).length ? (g(), i("ul", Fo, [(g(!0), i(e, null, v(oe(t.name), (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
5416
+ ], 8, Ao))), 128))]))]),
5417
+ a("section", Io, [
5418
+ a("div", Lo, [l[7] ||= a("h3", { id: "units-new-title" }, "New units", -1), a("div", Ro, [ne(t.$slots, "new-units-actions", { definitions: f.value }, void 0, !0), c(S(O), {
5385
5419
  icon: "pi pi-plus",
5386
5420
  label: "Define units",
5387
5421
  size: "small",
5388
5422
  text: "",
5389
5423
  "data-role": "define-units",
5390
- disabled: O.value !== void 0,
5424
+ disabled: D.value !== void 0,
5391
5425
  title: "Define units of your own, kept in a file apart from the units files",
5392
- onClick: l[1] ||= (e) => O.value = null
5426
+ onClick: l[1] ||= (e) => D.value = null
5393
5427
  }, null, 8, ["disabled"])])]),
5394
- f.value.length === 0 && O.value === void 0 ? (g(), i("p", Bo, " Units you define are kept in a units file of their own, apart from the files loaded. ")) : r("", !0),
5395
- f.value.length ? (g(), i("ul", Vo, [(g(!0), i(e, null, v(f.value, (e, t) => (g(), i("li", {
5428
+ f.value.length === 0 && D.value === void 0 ? (g(), i("p", zo, " Units you define are kept in a units file of their own, apart from the files loaded. ")) : r("", !0),
5429
+ f.value.length ? (g(), i("ul", Bo, [(g(!0), i(e, null, v(f.value, (e, t) => (g(), i("li", {
5396
5430
  key: e.name,
5397
5431
  "data-units": e.name
5398
- }, [O.value === t ? (g(), n(bo, {
5432
+ }, [D.value === t ? (g(), n(yo, {
5399
5433
  key: 0,
5400
5434
  definition: e,
5401
- others: ce.value,
5402
- known: le.value,
5403
- choices: ue.value,
5404
- onSave: fe,
5405
- onCancel: l[2] ||= (e) => O.value = void 0
5435
+ others: le.value,
5436
+ known: ue.value,
5437
+ choices: de.value,
5438
+ onSave: pe,
5439
+ onCancel: l[2] ||= (e) => D.value = void 0
5406
5440
  }, null, 8, [
5407
5441
  "definition",
5408
5442
  "others",
5409
5443
  "known",
5410
5444
  "choices"
5411
- ])) : (g(), i("div", Uo, [
5412
- a("code", Wo, y(e.name), 1),
5413
- a("span", Go, " = " + y(S(ao)(e)), 1),
5414
- c(S(k), {
5445
+ ])) : (g(), i("div", Ho, [
5446
+ a("code", Uo, y(e.name), 1),
5447
+ a("span", Wo, " = " + y(S(io)(e)), 1),
5448
+ c(S(O), {
5415
5449
  icon: "pi pi-pencil",
5416
5450
  size: "small",
5417
5451
  text: "",
@@ -5419,66 +5453,66 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5419
5453
  severity: "secondary",
5420
5454
  "aria-label": `Change ${e.name}`,
5421
5455
  title: "Change these units",
5422
- disabled: O.value !== void 0,
5423
- onClick: (e) => O.value = t
5456
+ disabled: D.value !== void 0,
5457
+ onClick: (e) => D.value = t
5424
5458
  }, null, 8, [
5425
5459
  "aria-label",
5426
5460
  "disabled",
5427
5461
  "onClick"
5428
5462
  ]),
5429
- c(S(k), {
5463
+ c(S(O), {
5430
5464
  icon: "pi pi-times",
5431
5465
  size: "small",
5432
5466
  text: "",
5433
5467
  rounded: "",
5434
5468
  severity: "secondary",
5435
5469
  "aria-label": `Remove ${e.name}`,
5436
- title: S(io)(e.name, f.value).length ? `Used by ${S(io)(e.name, f.value).join(", ")}` : "Remove these units",
5437
- disabled: O.value !== void 0 || S(io)(e.name, f.value).length > 0,
5438
- onClick: (e) => pe(t)
5470
+ title: S(ro)(e.name, f.value).length ? `Used by ${S(ro)(e.name, f.value).join(", ")}` : "Remove these units",
5471
+ disabled: D.value !== void 0 || S(ro)(e.name, f.value).length > 0,
5472
+ onClick: (e) => me(t)
5439
5473
  }, null, 8, [
5440
5474
  "aria-label",
5441
5475
  "title",
5442
5476
  "disabled",
5443
5477
  "onClick"
5444
5478
  ])
5445
- ]))], 8, Ho))), 128))])) : r("", !0),
5446
- O.value === null ? (g(), n(bo, {
5479
+ ]))], 8, Vo))), 128))])) : r("", !0),
5480
+ D.value === null ? (g(), n(yo, {
5447
5481
  key: 2,
5448
- others: ce.value,
5449
- known: le.value,
5450
- choices: ue.value,
5451
- onSave: fe,
5452
- onCancel: l[3] ||= (e) => O.value = void 0
5482
+ others: le.value,
5483
+ known: ue.value,
5484
+ choices: de.value,
5485
+ onSave: pe,
5486
+ onCancel: l[3] ||= (e) => D.value = void 0
5453
5487
  }, null, 8, [
5454
5488
  "others",
5455
5489
  "known",
5456
5490
  "choices"
5457
5491
  ])) : r("", !0),
5458
- de.value.length ? (g(), i("ul", Ko, [(g(!0), i(e, null, v(de.value, (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
5492
+ fe.value.length ? (g(), i("ul", Go, [(g(!0), i(e, null, v(fe.value, (e, t) => (g(), i("li", { key: t }, y(e.message), 1))), 128))])) : r("", !0)
5459
5493
  ]),
5460
- a("section", qo, [
5461
- a("div", Jo, [l[8] ||= a("h3", { id: "units-variables-title" }, "Variables", -1), te.value ? (g(), i("span", Yo, y(b(te.value, "variable")) + " without units ", 1)) : r("", !0)]),
5462
- ee.value.length === 0 ? (g(), i("p", Xo, " The variables in your equations are listed here, to give each one its units. ")) : (g(), i("table", Zo, [a("tbody", null, [(g(!0), i(e, null, v(ee.value, (t) => (g(), i("tr", {
5494
+ a("section", Ko, [
5495
+ a("div", qo, [l[8] ||= a("h3", { id: "units-variables-title" }, "Variables", -1), te.value ? (g(), i("span", Jo, y(b(te.value, "variable")) + " without units ", 1)) : r("", !0)]),
5496
+ ee.value.length === 0 ? (g(), i("p", Yo, " The variables in your equations are listed here, to give each one its units. ")) : (g(), i("table", Xo, [a("tbody", null, [(g(!0), i(e, null, v(ee.value, (t) => (g(), i("tr", {
5463
5497
  key: t.name,
5464
5498
  class: p([`state-${t.state}`, { unused: !t.used }]),
5465
5499
  "data-variable": t.name,
5466
5500
  "data-state": t.state
5467
5501
  }, [
5468
- a("th", $o, y(t.name), 1),
5502
+ a("th", Qo, y(t.name), 1),
5469
5503
  a("td", null, [a("input", {
5470
5504
  class: "units-input",
5471
5505
  type: "text",
5472
5506
  value: t.units,
5473
- list: S(me),
5507
+ list: S(he),
5474
5508
  placeholder: "units",
5475
5509
  spellcheck: "false",
5476
5510
  autocomplete: "off",
5477
5511
  "aria-label": `Units of ${t.name}`,
5478
5512
  "aria-invalid": t.state !== "ok",
5479
- onChange: (e) => ge(t.name, e)
5480
- }, null, 40, es)]),
5481
- a("td", ts, [t.used ? (g(), i(e, { key: 0 }, [s(y(A[t.state]), 1)], 64)) : (g(), i(e, { key: 1 }, [l[9] ||= s(" not used ", -1), c(S(k), {
5513
+ onChange: (e) => _e(t.name, e)
5514
+ }, null, 40, $o)]),
5515
+ a("td", es, [t.used ? (g(), i(e, { key: 0 }, [s(y(k[t.state]), 1)], 64)) : (g(), i(e, { key: 1 }, [l[9] ||= s(" not used ", -1), c(S(O), {
5482
5516
  icon: "pi pi-times",
5483
5517
  size: "small",
5484
5518
  text: "",
@@ -5486,13 +5520,13 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5486
5520
  severity: "secondary",
5487
5521
  "aria-label": `Forget the units of ${t.name}`,
5488
5522
  title: "Forget these units",
5489
- onClick: (e) => d.value = S(So)(d.value, t.name, "")
5523
+ onClick: (e) => d.value = S(xo)(d.value, t.name, "")
5490
5524
  }, null, 8, ["aria-label", "onClick"])], 64))])
5491
- ], 10, Qo))), 128))])])),
5492
- a("datalist", { id: S(me) }, [(g(!0), i(e, null, v(o.unitsNames, (e) => (g(), i("option", {
5525
+ ], 10, Zo))), 128))])])),
5526
+ a("datalist", { id: S(he) }, [(g(!0), i(e, null, v(o.unitsNames, (e) => (g(), i("option", {
5493
5527
  key: e,
5494
5528
  value: e
5495
- }, null, 8, rs))), 128))], 8, ns)
5529
+ }, null, 8, ns))), 128))], 8, ts)
5496
5530
  ])
5497
5531
  ]),
5498
5532
  _: 3
@@ -5501,7 +5535,7 @@ var wo = { class: "units-title" }, To = { "data-role": "units-summary" }, Eo = {
5501
5535
  }), [["__scopeId", "data-v-ada663af"]]);
5502
5536
  //#endregion
5503
5537
  //#region src/units/libcellml.ts
5504
- function as(e) {
5538
+ function is(e) {
5505
5539
  let t = [];
5506
5540
  for (let n = 0; n < e.issueCount(); n++) {
5507
5541
  let r = e.issue(n), i = r.level(), a = r.referenceRule();
@@ -5509,14 +5543,14 @@ function as(e) {
5509
5543
  message: r.description(),
5510
5544
  level: i.value,
5511
5545
  rule: a?.value ?? -1
5512
- }), os(i), a && os(a), r.delete();
5546
+ }), as(i), a && as(a), r.delete();
5513
5547
  }
5514
5548
  return t;
5515
5549
  }
5516
- function os(e) {
5550
+ function as(e) {
5517
5551
  e.delete?.();
5518
5552
  }
5519
- var ss = class {
5553
+ var os = class {
5520
5554
  held = [];
5521
5555
  track(e) {
5522
5556
  return e && this.held.push(e), e;
@@ -5525,16 +5559,16 @@ var ss = class {
5525
5559
  for (let e of this.held.splice(0).reverse()) e.delete();
5526
5560
  }
5527
5561
  };
5528
- function cs(e) {
5562
+ function ss(e) {
5529
5563
  return Object.keys(e.Units.StandardUnit).filter((e) => /^[A-Z_]+$/.test(e)).map((e) => e.toLowerCase());
5530
5564
  }
5531
5565
  //#endregion
5532
5566
  //#region src/units/messages.ts
5533
- var ls = /'([^']+)' is (?:in )?'([^']+)'(?: \(i\.e\. '[^']*'\))?/g;
5534
- function us(e) {
5567
+ var cs = /'([^']+)' is (?:in )?'([^']+)'(?: \(i\.e\. '[^']*'\))?/g;
5568
+ function ls(e) {
5535
5569
  let t = /^The units in '([^']+)'.* are not equivalent\. (.*)$/s.exec(e), n = /^The unit of '[^']+' in '([^']+)'.* is not dimensionless\. (.*)$/s.exec(e), r = t ?? n;
5536
5570
  if (!r) return null;
5537
- let i = [...r[2].matchAll(ls)].map(([, e, t]) => ({
5571
+ let i = [...r[2].matchAll(cs)].map(([, e, t]) => ({
5538
5572
  text: e,
5539
5573
  units: t
5540
5574
  }));
@@ -5544,27 +5578,27 @@ function us(e) {
5544
5578
  operands: i
5545
5579
  };
5546
5580
  }
5547
- function ds(e) {
5581
+ function us(e) {
5548
5582
  let [t, n] = e.operands;
5549
- return e.kind === "notDimensionless" ? `${t.text} in ${e.expression} must be dimensionless, but is in ${t.units}` : n && t.units === n.units ? `The parts of ${n.text} have different units` : n ? `Units don't match in ${e.expression}: ${fs(t)}, ${fs(n)}` : `Units don't match in ${e.expression}`;
5583
+ return e.kind === "notDimensionless" ? `${t.text} in ${e.expression} must be dimensionless, but is in ${t.units}` : n && t.units === n.units ? `The parts of ${n.text} have different units` : n ? `Units don't match in ${e.expression}: ${ds(t)}, ${ds(n)}` : `Units don't match in ${e.expression}`;
5550
5584
  }
5551
- var fs = (e) => e.units === "dimensionless" ? `${e.text} is dimensionless` : `${e.text} is in ${e.units}`, ps = /[A-Za-z_][A-Za-z0-9_]*/g, ms = /\bd(?:\^\d+)?([A-Za-z_][A-Za-z0-9_]*)\/d([A-Za-z_][A-Za-z0-9_]*)(?:\^\d+)?/g, hs = /(?<![A-Za-z_0-9.])\d+(?:\.\d*)?(?:e[+-]?\d+)?/g;
5552
- function gs(e, t) {
5585
+ var ds = (e) => e.units === "dimensionless" ? `${e.text} is dimensionless` : `${e.text} is in ${e.units}`, fs = /[A-Za-z_][A-Za-z0-9_]*/g, ps = /\bd(?:\^\d+)?([A-Za-z_][A-Za-z0-9_]*)\/d([A-Za-z_][A-Za-z0-9_]*)(?:\^\d+)?/g, ms = /(?<![A-Za-z_0-9.])\d+(?:\.\d*)?(?:e[+-]?\d+)?/g;
5586
+ function hs(e, t) {
5553
5587
  let n = /* @__PURE__ */ new Set(), r = (e) => {
5554
5588
  t.includes(e) && n.add(e);
5555
- }, i = e.replace(ms, (e, n, i) => t.includes(`d${n}`) || t.includes(`d${i}`) ? e : (r(n), r(i), " "));
5556
- for (let [e] of i.replace(hs, " ").matchAll(ps)) r(e);
5589
+ }, i = e.replace(ps, (e, n, i) => t.includes(`d${n}`) || t.includes(`d${i}`) ? e : (r(n), r(i), " "));
5590
+ for (let [e] of i.replace(ms, " ").matchAll(fs)) r(e);
5557
5591
  return [...n];
5558
5592
  }
5559
- function _s(e) {
5560
- return [...e.matchAll(hs)].map(([e]) => Number(e));
5593
+ function gs(e) {
5594
+ return [...e.matchAll(ms)].map(([e]) => Number(e));
5561
5595
  }
5562
5596
  //#endregion
5563
5597
  //#region src/units/check.ts
5564
- function vs(e, t) {
5598
+ function _s(e, t) {
5565
5599
  return e.variables.filter((e) => !t[e]);
5566
5600
  }
5567
- var ys = 500, bs = class {
5601
+ var vs = 500, ys = class {
5568
5602
  lc;
5569
5603
  library;
5570
5604
  cache = /* @__PURE__ */ new Map();
@@ -5581,7 +5615,7 @@ var ys = 500, bs = class {
5581
5615
  })) : [];
5582
5616
  }
5583
5617
  prechecked(e, t) {
5584
- let n = vs(e, t).map((e) => ({
5618
+ let n = _s(e, t).map((e) => ({
5585
5619
  message: `${e} has no units`,
5586
5620
  variables: [e]
5587
5621
  })), r = [.../* @__PURE__ */ new Set([...e.variables.map((e) => t[e]), ...e.units])].filter((e) => e && !this.library.isKnown(e)).map((n) => ({
@@ -5595,10 +5629,10 @@ var ys = 500, bs = class {
5595
5629
  let n = `${e.mathml}\n${e.variables.map((e) => `${e}:${t[e]}`).join(" ")}`, r = this.cache.get(n);
5596
5630
  if (r) return r;
5597
5631
  let i = this.analyse(e, t);
5598
- return this.cache.size >= ys && this.cache.delete(this.cache.keys().next().value), this.cache.set(n, i), i;
5632
+ return this.cache.size >= vs && this.cache.delete(this.cache.keys().next().value), this.cache.set(n, i), i;
5599
5633
  }
5600
5634
  analyse(e, t) {
5601
- let { lc: n } = this, r = new ss();
5635
+ let { lc: n } = this, r = new os();
5602
5636
  try {
5603
5637
  let i = r.track(new n.Model());
5604
5638
  i.setName("units_check"), this.library.addTo(i, [...e.variables.map((e) => t[e]), ...e.units], r);
@@ -5611,12 +5645,12 @@ var ys = 500, bs = class {
5611
5645
  a.setMath(e.mathml), i.addComponent(a), i.linkUnits();
5612
5646
  let o = r.track(new n.Validator());
5613
5647
  o.validateModel(i);
5614
- let s = as(o).filter((e) => e.level === 0);
5615
- if (s.length) return s.map((e) => ({ message: `libCellML: ${Ss(e.message)}` }));
5648
+ let s = is(o).filter((e) => e.level === 0);
5649
+ if (s.length) return s.map((e) => ({ message: `libCellML: ${xs(e.message)}` }));
5616
5650
  let c = r.track(new n.Analyser());
5617
5651
  c.analyseModel(i);
5618
- let l = as(c).filter((e) => e.rule === 112).map((e) => e.message);
5619
- return [...new Set(l)].map((t) => xs(t, e.variables));
5652
+ let l = is(c).filter((e) => e.rule === 112).map((e) => e.message);
5653
+ return [...new Set(l)].map((t) => bs(t, e.variables));
5620
5654
  } finally {
5621
5655
  r.dispose();
5622
5656
  }
@@ -5625,36 +5659,36 @@ var ys = 500, bs = class {
5625
5659
  this.cache.clear();
5626
5660
  }
5627
5661
  };
5628
- function xs(e, t) {
5629
- let n = us(e);
5630
- if (!n) return { message: Ss(e) };
5662
+ function bs(e, t) {
5663
+ let n = ls(e);
5664
+ if (!n) return { message: xs(e) };
5631
5665
  let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
5632
5666
  for (let e of n.operands) {
5633
- let n = gs(e.text, t);
5667
+ let n = hs(e.text, t);
5634
5668
  for (let e of n) r.add(e);
5635
- if (n.length === 0) for (let t of _s(e.text)) i.add(t);
5669
+ if (n.length === 0) for (let t of gs(e.text)) i.add(t);
5636
5670
  }
5637
5671
  return {
5638
- message: ds(n),
5672
+ message: us(n),
5639
5673
  ...r.size ? { variables: [...r] } : {},
5640
5674
  ...i.size ? { numbers: [...i] } : {}
5641
5675
  };
5642
5676
  }
5643
- function Ss(e) {
5677
+ function xs(e) {
5644
5678
  return e.replace(/ in component 'equation'/g, "").replace(/ in model 'units_check'/g, "");
5645
5679
  }
5646
5680
  //#endregion
5647
5681
  //#region src/units/library.ts
5648
- var Cs = class e {
5682
+ var Ss = class e {
5649
5683
  lc;
5650
5684
  names;
5651
5685
  sources;
5652
5686
  problems;
5653
5687
  standard;
5654
5688
  defined = /* @__PURE__ */ new Map();
5655
- handles = new ss();
5689
+ handles = new os();
5656
5690
  constructor(e, t) {
5657
- this.lc = e, this.standard = new Set(cs(e));
5691
+ this.lc = e, this.standard = new Set(ss(e));
5658
5692
  let n = [], r = [], i = /* @__PURE__ */ new Map();
5659
5693
  for (let e of t) {
5660
5694
  let t = [];
@@ -5710,7 +5744,7 @@ var Cs = class e {
5710
5744
  let n = new this.lc.Parser(!1);
5711
5745
  try {
5712
5746
  let r = this.handles.track(n.parseModel(e.text));
5713
- for (let r of as(n)) r.level === 0 && t.push({
5747
+ for (let r of is(n)) r.level === 0 && t.push({
5714
5748
  source: e.name,
5715
5749
  message: r.message
5716
5750
  });
@@ -5719,22 +5753,22 @@ var Cs = class e {
5719
5753
  n.delete();
5720
5754
  }
5721
5755
  }
5722
- }, ws = "$libcellml";
5723
- function Ts(e) {
5724
- let n = e.libcellml === void 0 ? u(ws, null) : e.libcellml, r = e.delay ?? 300, i = t(() => x(e.enabled) ?? !0), a = t(() => Es(n)), o = t(() => n !== null), s = t(() => a.value !== null), c = t(() => s.value ? "ready" : o.value ? "loading" : "unavailable"), l = re(null), d = re([]), f = null, p, m = () => {
5756
+ }, Cs = "$libcellml";
5757
+ function ws(e) {
5758
+ let n = e.libcellml === void 0 ? u(Cs, null) : e.libcellml, r = e.delay ?? 300, i = t(() => x(e.enabled) ?? !0), a = t(() => Ts(n)), o = t(() => n !== null), s = t(() => a.value !== null), c = t(() => s.value ? "ready" : o.value ? "loading" : "unavailable"), l = re(null), d = re([]), f = null, p, m = () => {
5725
5759
  clearTimeout(p), p = void 0, d.value = f && i.value ? f.check(x(e.lines), x(e.variableUnits)) : [];
5726
5760
  }, ee = () => {
5727
5761
  f?.dispose(), l.value?.dispose(), f = null, l.value = null;
5728
5762
  }, te = t(() => {
5729
5763
  let t = x(e.newUnits) ?? [];
5730
- return t.length ? so(t) : "";
5764
+ return t.length ? oo(t) : "";
5731
5765
  });
5732
- return ae([a, () => [...x(e.sources), ...te.value ? [{
5733
- name: $a,
5766
+ return oe([a, () => [...x(e.sources), ...te.value ? [{
5767
+ name: Qa,
5734
5768
  text: te.value
5735
5769
  }] : []]], ([e, t]) => {
5736
- ee(), e && (l.value = Cs.load(e, t), f = new bs(e, l.value)), m();
5737
- }, { immediate: !0 }), ae(i, () => m()), ae([() => x(e.lines), () => x(e.variableUnits)], () => {
5770
+ ee(), e && (l.value = Ss.load(e, t), f = new ys(e, l.value)), m();
5771
+ }, { immediate: !0 }), oe(i, () => m()), oe([() => x(e.lines), () => x(e.variableUnits)], () => {
5738
5772
  clearTimeout(p), p = setTimeout(m, r);
5739
5773
  }), h(() => {
5740
5774
  clearTimeout(p), ee();
@@ -5747,16 +5781,16 @@ function Ts(e) {
5747
5781
  files: t(() => l.value?.sources ?? []),
5748
5782
  problems: t(() => l.value?.problems ?? []),
5749
5783
  newUnitsFile: te,
5750
- unitsNames: t(() => a.value && l.value ? [...cs(a.value), ...l.value.names] : []),
5784
+ unitsNames: t(() => a.value && l.value ? [...ss(a.value), ...l.value.names] : []),
5751
5785
  missing: t(() => {
5752
5786
  let t = x(e.variableUnits);
5753
- return [...new Set(x(e.lines).flatMap((e) => vs(e, t)))];
5787
+ return [...new Set(x(e.lines).flatMap((e) => _s(e, t)))];
5754
5788
  }),
5755
5789
  check: m
5756
5790
  };
5757
5791
  }
5758
- function Es(e) {
5792
+ function Ts(e) {
5759
5793
  return e ? "Parser" in e ? b(e) : e.status === "ready" && e.library ? b(e.library) : null : null;
5760
5794
  }
5761
5795
  //#endregion
5762
- export { Qa as EquationWorkbench, ws as LIBCELLML_KEY, is as UnitsPanel, Si as importContentMathML, Ts as useUnitsChecker };
5796
+ export { Za as EquationWorkbench, Cs as LIBCELLML_KEY, rs as UnitsPanel, Ci as importContentMathML, ws as useUnitsChecker };