@pie-qti/default-components 0.1.28 → 1.0.0-beta.1

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.
@@ -6857,7 +6857,7 @@ function Ue(e) {
6857
6857
  let t = e.codePointAt(0) ?? 0, n = Re[t];
6858
6858
  if (n) return n;
6859
6859
  let { char: r, variant: i, style: a } = He(t);
6860
- if (!(!i && !a)) {
6860
+ if (i || a) {
6861
6861
  switch (n = r, i) {
6862
6862
  case "double-struck":
6863
6863
  n = `\\mathbb{${n}}`;
@@ -7210,14 +7210,11 @@ function $e(e, t, n = "mord", r) {
7210
7210
  }, Ge[t] || (Ge[t] = e));
7211
7211
  }
7212
7212
  function T(e, t, n) {
7213
- if (typeof e == "string") {
7214
- for (let t = 0; t < e.length; t++) {
7215
- let n = e.charAt(t);
7216
- $e(n, n.codePointAt(0));
7217
- }
7218
- return;
7213
+ if (typeof e == "string") for (let t = 0; t < e.length; t++) {
7214
+ let n = e.charAt(t);
7215
+ $e(n, n.codePointAt(0));
7219
7216
  }
7220
- for (let [r, i, a, o] of e) $e(r, i, a ?? t, o ?? n);
7217
+ else for (let [r, i, a, o] of e) $e(r, i, a ?? t, o ?? n);
7221
7218
  }
7222
7219
  function et(e, t) {
7223
7220
  for (let n = e; n <= t; n++) $e(String.fromCodePoint(n), n);
@@ -17438,19 +17435,14 @@ function Cs(e) {
17438
17435
  return n.height = t + .166, n.depth = t - .166, n.svgBody = e, n;
17439
17436
  }
17440
17437
  function ws(e, t) {
17441
- if (e.type === "latex") {
17442
- e.height = .9, e.depth = .2, e._width = 1;
17443
- return;
17444
- }
17445
- if (e.value) {
17438
+ if (e.type === "latex") e.height = .9, e.depth = .2, e._width = 1;
17439
+ else if (e.value) {
17446
17440
  e.height = -1 / 0, e.depth = -1 / 0, e._width = 0, e.skew = -1 / 0, e.italic = -1 / 0;
17447
17441
  for (let n = 0; n < e.value.length; n++) {
17448
17442
  let r = Wo(e.value.codePointAt(n), t);
17449
17443
  e.height = Math.max(e.height, r.height), e.depth = Math.max(e.depth, r.depth), e._width += r.width, e.skew = r.skew, e.italic = r.italic;
17450
17444
  }
17451
- return;
17452
- }
17453
- if (e.children && e.children.length > 0) {
17445
+ } else if (e.children && e.children.length > 0) {
17454
17446
  let t = -1 / 0, n = -1 / 0, r = 0;
17455
17447
  for (let i of e.children) i.height > t && (t = i.height), i.depth > n && (n = i.depth), r = Math.max(r, i.maxFontSize ?? 0);
17456
17448
  e.height = t, e.depth = n, e._width = e.children.reduce((e, t) => e + t.width, 0), e.maxFontSize = r;
@@ -17974,9 +17966,7 @@ var P = class e {
17974
17966
  case "numerator":
17975
17967
  i = i.fracNum;
17976
17968
  break;
17977
- case "denominator":
17978
- i = i.fracDen;
17979
- break;
17969
+ case "denominator": i = i.fracDen;
17980
17970
  }
17981
17971
  switch (t.mathstyle) {
17982
17972
  case "textstyle":
@@ -18048,11 +18038,7 @@ var P = class e {
18048
18038
  if (this.parent) return this.parent.getRegisterAsDimension(e);
18049
18039
  }
18050
18040
  setRegister(e, t) {
18051
- if (t === void 0) {
18052
- delete this.registers[e];
18053
- return;
18054
- }
18055
- this.registers[e] = t;
18041
+ t === void 0 ? delete this.registers[e] : this.registers[e] = t;
18056
18042
  }
18057
18043
  evaluate(e) {
18058
18044
  if (!e || !("register" in e)) return e;
@@ -18496,16 +18482,11 @@ var F = class e {
18496
18482
  };
18497
18483
  function ec(e) {
18498
18484
  let t, n = [], r = [];
18499
- for (let i of e) {
18500
- if (i.type === "first") {
18501
- r.push(i);
18502
- continue;
18503
- }
18504
- if (!t && !i.style) r.push(i);
18505
- else {
18506
- let e = i.style;
18507
- t && e.color === t.color && e.backgroundColor === t.backgroundColor && e.fontSize === t.fontSize ? r.push(i) : (r.length > 0 && n.push(r), r = [i], t = e);
18508
- }
18485
+ for (let i of e) if (i.type === "first") r.push(i);
18486
+ else if (!t && !i.style) r.push(i);
18487
+ else {
18488
+ let e = i.style;
18489
+ t && e.color === t.color && e.backgroundColor === t.backgroundColor && e.fontSize === t.fontSize ? r.push(i) : (r.length > 0 && n.push(r), r = [i], t = e);
18509
18490
  }
18510
18491
  return r.length > 0 && n.push(r), n;
18511
18492
  }
@@ -22164,8 +22145,8 @@ var z = {
22164
22145
  "roman numeral": /^[IVX]+/,
22165
22146
  "1/2$": /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,
22166
22147
  amount: function(e) {
22167
- var t;
22168
- if (t = e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/), t) return {
22148
+ var t = e.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);
22149
+ if (t) return {
22169
22150
  match_: t[0],
22170
22151
  remainder: e.substr(t[0].length)
22171
22152
  };
@@ -22236,14 +22217,10 @@ var z = {
22236
22217
  if (n === void 0) throw ["MhchemBugP", "mhchem bug P. Please report. (" + e + ")"];
22237
22218
  if (typeof n == "function") return z.patterns.patterns[e](t);
22238
22219
  var r = t.match(n);
22239
- if (r) {
22240
- var i;
22241
- return i = r[2] ? [r[1], r[2]] : r[1] ? r[1] : r[0], {
22242
- match_: i,
22243
- remainder: t.substr(r[0].length)
22244
- };
22245
- }
22246
- return null;
22220
+ return r ? {
22221
+ match_: r[2] ? [r[1], r[2]] : r[1] ? r[1] : r[0],
22222
+ remainder: t.substr(r[0].length)
22223
+ } : null;
22247
22224
  }
22248
22225
  },
22249
22226
  actions: {
@@ -24356,11 +24333,7 @@ function xu(e, t) {
24356
24333
  if (!e.parent) return;
24357
24334
  let n = e.parent.children, r = n.indexOf(e), i = r - 1;
24358
24335
  for (; i >= 0 && n[i].type === "ignore";) --i;
24359
- if (i < 0 && e.parent.parent && e.parent.type === "lift") {
24360
- xu(e.parent, t);
24361
- return;
24362
- }
24363
- r > 0 && n[r - 1].type === "skip" ? n[r - 1].width += t : n.splice(r, 0, new bu(t));
24336
+ i < 0 && e.parent.parent && e.parent.type === "lift" ? xu(e.parent, t) : r > 0 && n[r - 1].type === "skip" ? n[r - 1].width += t : n.splice(r, 0, new bu(t));
24364
24337
  }
24365
24338
  var Su = {
24366
24339
  ord: {
@@ -24853,7 +24826,7 @@ E(Object.keys(Fu), "{body:auto}", { createAtom: (e) => new rl(c(s({}, e), {
24853
24826
  "\\\\",
24854
24827
  "\\tabularnewline"
24855
24828
  ].includes(e)));
24856
- } while (!0);
24829
+ } while (1);
24857
24830
  e.endContext(), t.push([n]);
24858
24831
  let r = e.scan();
24859
24832
  return r.length > 0 && t.push([r]), t;
@@ -27446,11 +27419,7 @@ var cd = class e {
27446
27419
  function ld(e, t, n) {
27447
27420
  let r = null, i = null, a = !1, o = !1, s = !1, c = new AbortController(), l = c.signal;
27448
27421
  return e.addEventListener("keydown", (t) => {
27449
- if (a || t.key === "Process" || t.code === "CapsLock" || /(Control|Meta|Alt|Shift)(Left|Right)/.test(t.code)) {
27450
- r = null;
27451
- return;
27452
- }
27453
- r = t, i = null, n.onKeystroke(t) ? e.textContent = "" : r = null;
27422
+ a || t.key === "Process" || t.code === "CapsLock" || /(Control|Meta|Alt|Shift)(Left|Right)/.test(t.code) ? r = null : (r = t, i = null, n.onKeystroke(t) ? e.textContent = "" : r = null);
27454
27423
  }, {
27455
27424
  capture: !0,
27456
27425
  signal: l
@@ -27508,15 +27477,7 @@ function ld(e, t, n) {
27508
27477
  return;
27509
27478
  }
27510
27479
  let u = cd.state;
27511
- if (u === "open" || u === "opening") {
27512
- a.preventDefault(), a.stopPropagation();
27513
- return;
27514
- }
27515
- if (a.relatedTarget === a.target.getRootNode().host) {
27516
- a.preventDefault(), a.stopPropagation();
27517
- return;
27518
- }
27519
- s || o || (s = !0, r = null, i = null, n.onBlur(), s = !1);
27480
+ u === "open" || u === "opening" || a.relatedTarget === a.target.getRootNode().host ? (a.preventDefault(), a.stopPropagation()) : s || o || (s = !0, r = null, i = null, n.onBlur(), s = !1);
27520
27481
  }, {
27521
27482
  capture: !0,
27522
27483
  signal: l
@@ -27958,11 +27919,8 @@ async function Jd() {
27958
27919
  }
27959
27920
  async function Yd() {
27960
27921
  if (qd === "not-loaded") {
27961
- if (qd = "loading", getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts") ?? !1) {
27962
- qd = "ready";
27963
- return;
27964
- }
27965
- if (document.body.classList.remove("ML__fonts-did-not-load"), "fonts" in document) {
27922
+ if (qd = "loading", getComputedStyle(document.documentElement).getPropertyValue("--ML__static-fonts") ?? !1) qd = "ready";
27923
+ else if (document.body.classList.remove("ML__fonts-did-not-load"), "fonts" in document) {
27966
27924
  let e = [
27967
27925
  "KaTeX_Main",
27968
27926
  "KaTeX_Math",
@@ -28372,16 +28330,7 @@ var _f = class e {
28372
28330
  if (t === "execute-command") {
28373
28331
  let { command: t } = e;
28374
28332
  lf(t) === "virtual-keyboard" && this.executeCommand(t);
28375
- return;
28376
- }
28377
- if (t === "synchronize-proxy") {
28378
- this._boundingRect = e.boundingRect, this._isShifted = e.isShifted;
28379
- return;
28380
- }
28381
- if (t === "geometry-changed") {
28382
- this._boundingRect = e.boundingRect, this.dispatchEvent(new Event("geometrychange"));
28383
- return;
28384
- }
28333
+ } else t === "synchronize-proxy" ? (this._boundingRect = e.boundingRect, this._isShifted = e.isShifted) : t === "geometry-changed" && (this._boundingRect = e.boundingRect, this.dispatchEvent(new Event("geometrychange")));
28385
28334
  }
28386
28335
  sendMessage(e, t = {}) {
28387
28336
  if (!this.targetWindow) throw new DOMException("A frame does not have access to the top window and can't communicate with the keyboard.", "SecurityError");
@@ -30875,9 +30824,7 @@ var rp = class e {
30875
30824
  case "keydown":
30876
30825
  e.key === "Shift" && !e.repeat && (this.shiftPressCount = 1);
30877
30826
  break;
30878
- case "keyup":
30879
- (e.key === "Shift" || !e.getModifierState("Shift") && this.shiftPressCount !== 2) && (this.shiftPressCount = 0);
30880
- break;
30827
+ case "keyup": (e.key === "Shift" || !e.getModifierState("Shift") && this.shiftPressCount !== 2) && (this.shiftPressCount = 0);
30881
30828
  }
30882
30829
  }
30883
30830
  handleMessage(e, t) {
@@ -30886,9 +30833,7 @@ var rp = class e {
30886
30833
  let { command: n } = e, r = lf(n);
30887
30834
  if (window === window.top && t !== window || t === window && r !== "virtual-keyboard") return;
30888
30835
  this.executeCommand(n);
30889
- return;
30890
- }
30891
- if ((n === "connect" || n === "show") && this.sendMessage("synchronize-proxy", {
30836
+ } else if ((n === "connect" || n === "show") && this.sendMessage("synchronize-proxy", {
30892
30837
  boundingRect: this.boundingRect,
30893
30838
  alphabeticLayout: this._alphabeticLayout,
30894
30839
  layouts: this._layouts,
@@ -30921,18 +30866,15 @@ var rp = class e {
30921
30866
  }
30922
30867
  }
30923
30868
  sendMessage(e, t, n) {
30924
- if (t.command && this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command", { detail: t.command })), n || (n = this.connectedMathfieldWindow), this.targetOrigin === null || this.targetOrigin === "null" || n === window) {
30925
- window.dispatchEvent(new MessageEvent("message", {
30926
- source: window,
30927
- origin: window.origin,
30928
- data: s({
30929
- type: hf,
30930
- action: e
30931
- }, t)
30932
- }));
30933
- return;
30934
- }
30935
- if (n) n.postMessage(s({
30869
+ if (t.command && this.dispatchEvent(new CustomEvent("math-virtual-keyboard-command", { detail: t.command })), n || (n = this.connectedMathfieldWindow), this.targetOrigin === null || this.targetOrigin === "null" || n === window) window.dispatchEvent(new MessageEvent("message", {
30870
+ source: window,
30871
+ origin: window.origin,
30872
+ data: s({
30873
+ type: hf,
30874
+ action: e
30875
+ }, t)
30876
+ }));
30877
+ else if (n) n.postMessage(s({
30936
30878
  type: hf,
30937
30879
  action: e
30938
30880
  }, t), { targetOrigin: this.targetOrigin });
@@ -31166,7 +31108,6 @@ function vp(e, t) {
31166
31108
  return;
31167
31109
  }
31168
31110
  n.addColumnBefore(i), _p(e, n, r, i, "start");
31169
- break;
31170
31111
  }
31171
31112
  }
31172
31113
  function yp(e) {
@@ -32480,19 +32421,14 @@ function vm(e, t, n) {
32480
32421
  for (; t >= 0;) {
32481
32422
  let r = e.at(t);
32482
32423
  if (r.type === "first") break;
32483
- if (r.type === "mord" && r.value && /^[\d]$/.test(r.value)) {
32484
- --t;
32485
- continue;
32486
- }
32487
- if (r.type === "group" && r.body?.length === 2 && r.body[0].type === "first" && r.body[1].value === ",") {
32488
- n = !0;
32489
- break;
32490
- }
32491
- if (r.type === "mord" && (r.value === "," || r.value === ".")) {
32492
- n = !0;
32424
+ if (r.type === "mord" && r.value && /^[\d]$/.test(r.value)) --t;
32425
+ else {
32426
+ if (r.type === "group" && r.body?.length === 2 && r.body[0].type === "first" && r.body[1].value === "," || r.type === "mord" && (r.value === "," || r.value === ".")) {
32427
+ n = !0;
32428
+ break;
32429
+ }
32493
32430
  break;
32494
32431
  }
32495
- break;
32496
32432
  }
32497
32433
  if (n) return !1;
32498
32434
  }
@@ -32512,11 +32448,8 @@ function vm(e, t, n) {
32512
32448
  for (; t >= 0;) {
32513
32449
  let r = e.at(t);
32514
32450
  if (r.type === "first") break;
32515
- if (r.type === "mord" && r.value && /^[\d]$/.test(r.value)) {
32516
- n = !0, --t;
32517
- continue;
32518
- }
32519
- break;
32451
+ if (r.type === "mord" && r.value && /^[\d]$/.test(r.value)) n = !0, --t;
32452
+ else break;
32520
32453
  }
32521
32454
  if (n && e.at(t).type === "mopen" && e.at(t).value === "(") return !1;
32522
32455
  }
@@ -32684,7 +32617,7 @@ function Sm(e, t, n) {
32684
32617
  if (!i) return t;
32685
32618
  let a = n === "forward" ? 1 : -1;
32686
32619
  if (i.mode === "text") {
32687
- for (; i && !(i.mode !== "text" || !Qe.test(i.value));) t += a, i = e.at(t);
32620
+ for (; i && i.mode === "text" && Qe.test(i.value);) t += a, i = e.at(t);
32688
32621
  return n === "backward" ? t - 1 : t;
32689
32622
  }
32690
32623
  if (i.mode === "latex") {
@@ -33568,11 +33501,7 @@ var wh = 80, Th = class {
33568
33501
  }
33569
33502
  updateState(e) {
33570
33503
  let t = this._declaration;
33571
- if (bh(t)) {
33572
- this.enabled = !1, this.checked = !1;
33573
- return;
33574
- }
33575
- xh(t) && (this.enabled = !1, this.checked = !1, this.visible = !0), yh(t) && (this.checked = Dh(t.checked, e) ?? !1), (yh(t) || vh(t)) && (this.enabled = Dh(t.enabled, e) ?? !0, this.visible = Dh(t.visible, e) ?? !0, this.visible && this.enabled && this.submenu && (this.submenu.updateState(e), this.submenu.visible || (this.visible = !1))), (yh(t) || xh(t) || vh(t)) && (this.label = Dh(t.label, e), this._className = Dh(t.class, e), this.tooltip = Dh(t.tooltip, e), this.ariaLabel = Dh(t.ariaLabel, e)), this._element && this.updateElement();
33504
+ bh(t) ? (this.enabled = !1, this.checked = !1) : (xh(t) && (this.enabled = !1, this.checked = !1, this.visible = !0), yh(t) && (this.checked = Dh(t.checked, e) ?? !1), (yh(t) || vh(t)) && (this.enabled = Dh(t.enabled, e) ?? !0, this.visible = Dh(t.visible, e) ?? !0, this.visible && this.enabled && this.submenu && (this.submenu.updateState(e), this.submenu.visible || (this.visible = !1))), (yh(t) || xh(t) || vh(t)) && (this.label = Dh(t.label, e), this._className = Dh(t.class, e), this.tooltip = Dh(t.tooltip, e), this.ariaLabel = Dh(t.ariaLabel, e)), this._element && this.updateElement());
33576
33505
  }
33577
33506
  set dirty(e) {
33578
33507
  e && this.parentMenu && (this.parentMenu.dirty = !0);
@@ -33619,7 +33548,7 @@ var wh = 80, Th = class {
33619
33548
  }
33620
33549
  handleEvent(e) {
33621
33550
  var t;
33622
- if (!(!this.visible || !this.enabled)) {
33551
+ if (this.visible && this.enabled) {
33623
33552
  if (e.type === "click") {
33624
33553
  this.rootMenu.state === "modal" && this.select(), e.stopPropagation(), e.preventDefault();
33625
33554
  return;
@@ -33642,15 +33571,11 @@ var wh = 80, Th = class {
33642
33571
  }
33643
33572
  }
33644
33573
  select() {
33645
- if (this.rootMenu.cancelDelayedOperation(), this.type === "submenu") {
33646
- this.openSubmenu();
33647
- return;
33648
- }
33649
- this.active = !1, setTimeout(() => {
33574
+ this.rootMenu.cancelDelayedOperation(), this.type === "submenu" ? this.openSubmenu() : (this.active = !1, setTimeout(() => {
33650
33575
  this.active = !0, setTimeout(() => {
33651
33576
  this.active = !1, this.rootMenu.hide(), this.dispatchSelect();
33652
33577
  }, wh);
33653
- }, wh);
33578
+ }, wh));
33654
33579
  }
33655
33580
  openSubmenu(e) {
33656
33581
  var t;
@@ -33855,7 +33780,7 @@ var Oh = class e {
33855
33780
  }
33856
33781
  hide() {
33857
33782
  var e, t, n, r;
33858
- this.openSubmenu = null, this.activeMenuItem = null, this.parentMenu && (this.parentMenu.openSubmenu = null), !(!((e = this._element) != null && e.isConnected) || !this._element.parentElement) && (_() && (t = this._element) != null && t.popover && this._element.hidePopover(), kh(), (n = this.parentMenu?.element) == null || n.focus(), (r = this._element?.parentNode) == null || r.removeChild(this._element), jh());
33783
+ this.openSubmenu = null, this.activeMenuItem = null, this.parentMenu && (this.parentMenu.openSubmenu = null), (e = this._element) != null && e.isConnected && this._element.parentElement && (_() && (t = this._element) != null && t.popover && this._element.hidePopover(), kh(), (n = this.parentMenu?.element) == null || n.focus(), (r = this._element?.parentNode) == null || r.removeChild(this._element), jh());
33859
33784
  }
33860
33785
  set openSubmenu(e) {
33861
33786
  var t, n;
@@ -34019,11 +33944,7 @@ var Mh = class e extends Oh {
34019
33944
  scheduleOperation(t) {
34020
33945
  this.cancelDelayedOperation();
34021
33946
  let n = e.SUBMENU_DELAY;
34022
- if (n <= 0) {
34023
- t();
34024
- return;
34025
- }
34026
- this.hysteresisTimer = setTimeout(() => {
33947
+ n <= 0 ? t() : this.hysteresisTimer = setTimeout(() => {
34027
33948
  this.hysteresisTimer = 0, t();
34028
33949
  }, n);
34029
33950
  }
@@ -35740,17 +35661,13 @@ function Hg(e) {
35740
35661
  visible: () => e.isSelectionEditable && globalThis.MathfieldElement.computeEngine !== null,
35741
35662
  onMenuSelect: () => {
35742
35663
  let t = Yg(e);
35743
- if (!t) {
35744
- e.model.announce("plonk");
35745
- return;
35746
- }
35747
- e.model.selectionIsCollapsed ? (e.model.position = e.model.lastOffset, e.insert(`=${t}`, {
35664
+ t ? e.model.selectionIsCollapsed ? (e.model.position = e.model.lastOffset, e.insert(`=${t}`, {
35748
35665
  insertionMode: "insertAfter",
35749
35666
  selectionMode: "item"
35750
35667
  })) : e.insert(t, {
35751
35668
  insertionMode: "replaceSelection",
35752
35669
  selectionMode: "item"
35753
- });
35670
+ }) : e.model.announce("plonk");
35754
35671
  }
35755
35672
  },
35756
35673
  {
@@ -35796,14 +35713,10 @@ function Hg(e) {
35796
35713
  visible: () => e.isSelectionEditable && globalThis.MathfieldElement.computeEngine !== null && e.expression?.unknowns.length === 1 && e.expression.unknowns[0] !== "Nothing",
35797
35714
  onMenuSelect: () => {
35798
35715
  let t = e.expression, n = t?.unknowns[0], r = t.solve(n), i = Array.isArray(r) ? r.map((e) => e.simplify().latex ?? "") : null;
35799
- if (!i) {
35800
- e.model.announce("plonk");
35801
- return;
35802
- }
35803
- e.insert(`${n}=${i.length === 1 ? i[0] : "\\left\\lbrace" + i?.join(", ") + "\\right\\rbrace"}`, {
35716
+ i ? e.insert(`${n}=${i.length === 1 ? i[0] : "\\left\\lbrace" + i?.join(", ") + "\\right\\rbrace"}`, {
35804
35717
  insertionMode: "replaceAll",
35805
35718
  selectionMode: "item"
35806
- });
35719
+ }) : e.model.announce("plonk");
35807
35720
  }
35808
35721
  },
35809
35722
  { type: "divider" },
@@ -36427,20 +36340,19 @@ function l_(e) {
36427
36340
  }
36428
36341
  function u_(e, t, n, r) {
36429
36342
  let i = "";
36430
- if (t === "plonk") {
36431
- globalThis.MathfieldElement.playSound("plonk"), e.flushInlineShortcutBuffer();
36432
- return;
36433
- }
36434
- if (t === "delete") i = c_("deleted: ", r);
36435
- else if (t === "focus" || t.includes("move")) i = d_(e.model, n), i += f_(e.model);
36436
- else if (t === "replacement") i = c_(e.model.at(e.model.position));
36437
- else if (t === "line") {
36438
- let t = c_(e.model.root);
36439
- e.keyboardDelegate.setAriaLabel(t);
36440
- } else i = r ? c_(t + " ", r) : t;
36441
- if (i && e.ariaLiveText) {
36442
- let t = e.ariaLiveText.textContent.includes("\xA0") ? "   " : " \xA0 ";
36443
- e.ariaLiveText.textContent = i + t;
36343
+ if (t === "plonk") globalThis.MathfieldElement.playSound("plonk"), e.flushInlineShortcutBuffer();
36344
+ else {
36345
+ if (t === "delete") i = c_("deleted: ", r);
36346
+ else if (t === "focus" || t.includes("move")) i = d_(e.model, n), i += f_(e.model);
36347
+ else if (t === "replacement") i = c_(e.model.at(e.model.position));
36348
+ else if (t === "line") {
36349
+ let t = c_(e.model.root);
36350
+ e.keyboardDelegate.setAriaLabel(t);
36351
+ } else i = r ? c_(t + " ", r) : t;
36352
+ if (i && e.ariaLiveText) {
36353
+ let t = e.ariaLiveText.textContent.includes("\xA0") ? "   " : " \xA0 ";
36354
+ e.ariaLiveText.textContent = i + t;
36355
+ }
36444
36356
  }
36445
36357
  }
36446
36358
  function d_(e, t) {
@@ -36615,10 +36527,10 @@ var p_ = class {
36615
36527
  if (n === "forward") {
36616
36528
  for (let n = t; n <= i; n++) if (r = this.atoms[n], e(r)) return r;
36617
36529
  for (let n = 0; n < t; n++) if (r = this.atoms[n], e(r)) return r;
36618
- return;
36530
+ } else {
36531
+ for (let n = t; n >= 0; n--) if (r = this.atoms[n], e(r)) return r;
36532
+ for (let n = i; n > t; n--) if (r = this.atoms[n], e(r)) return r;
36619
36533
  }
36620
- for (let n = t; n >= 0; n--) if (r = this.atoms[n], e(r)) return r;
36621
- for (let n = i; n > t; n--) if (r = this.atoms[n], e(r)) return r;
36622
36534
  }
36623
36535
  extractAtoms(e) {
36624
36536
  let t = this.getAtoms(e);
@@ -36933,11 +36845,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
36933
36845
  onDismiss: () => this.element.classList.remove("tracking")
36934
36846
  }), e.preventDefault(), e.stopPropagation();
36935
36847
  }, { signal: n }), (this.disabled || this.readOnly && !this.hasEditableContent || this.userSelect === "none") && (f.style.display = "none"), this.ariaLiveText = this.element.querySelector("[role=status]") ?? void 0, this.keyboardDelegate = ld(this.element.querySelector(".ML__keyboard-sink"), this.element, this), window.addEventListener("resize", this, { signal: n }), document.addEventListener("scroll", this, { signal: n }), this.resizeObserver = new ResizeObserver((e) => {
36936
- if (this.resizeObserverStarted) {
36937
- this.resizeObserverStarted = !1;
36938
- return;
36939
- }
36940
- this.updateToggleLayout(), H(this);
36848
+ this.resizeObserverStarted ? this.resizeObserverStarted = !1 : (this.updateToggleLayout(), H(this));
36941
36849
  }), this.resizeObserverStarted = !0, this.resizeObserver.observe(this.field), this.resizeObserver.observe(this.container), setTimeout(() => this.updateToggleLayout(), 100), window.mathVirtualKeyboard.addEventListener("virtual-keyboard-toggle", this, { signal: n }), me && !S.locale.startsWith(me.locale) && be(S.locale), qd !== "ready" && document.fonts.ready.then(() => ef(this)), e.querySelector("[part=container]").style.removeProperty("visibility"), this.undoManager.startRecording(), this.undoManager.snapshot("set-value"), H(this);
36942
36850
  }
36943
36851
  connectToVirtualKeyboard() {
@@ -37022,13 +36930,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37022
36930
  let a = this.model.getAtoms(this.model.selection, { includeChildren: !0 }), o = a.length;
37023
36931
  if (o === 0) return "none";
37024
36932
  let s = 0;
37025
- for (let e of a) {
37026
- if (e.type === "first") {
37027
- --o;
37028
- continue;
37029
- }
37030
- e.style[r] === i && (s += 1);
37031
- }
36933
+ for (let e of a) e.type === "first" ? --o : e.style[r] === i && (s += 1);
37032
36934
  return s === 0 ? "none" : s === o ? "all" : "some";
37033
36935
  }
37034
36936
  get keybindings() {
@@ -37118,11 +37020,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37118
37020
  delete e.mathfield, this.element = void 0, this.host = void 0, this.field = void 0, this.ariaLiveText = void 0, lm(), Vd(), ch();
37119
37021
  }
37120
37022
  flushInlineShortcutBuffer(e) {
37121
- if (e ?? (e = { defer: !1 }), !e.defer) {
37122
- this.inlineShortcutBuffer.length = 0, clearTimeout(this.inlineShortcutBufferFlushTimer), this.inlineShortcutBufferFlushTimer = 0;
37123
- return;
37124
- }
37125
- this.options.inlineShortcutTimeout > 0 && (clearTimeout(this.inlineShortcutBufferFlushTimer), this.inlineShortcutBufferFlushTimer = setTimeout(() => this.flushInlineShortcutBuffer(), this.options.inlineShortcutTimeout));
37023
+ e ?? (e = { defer: !1 }), e.defer ? this.options.inlineShortcutTimeout > 0 && (clearTimeout(this.inlineShortcutBufferFlushTimer), this.inlineShortcutBufferFlushTimer = setTimeout(() => this.flushInlineShortcutBuffer(), this.options.inlineShortcutTimeout)) : (this.inlineShortcutBuffer.length = 0, clearTimeout(this.inlineShortcutBufferFlushTimer), this.inlineShortcutBufferFlushTimer = 0);
37126
37024
  }
37127
37025
  executeCommand(e) {
37128
37026
  return lf(e) === "virtual-keyboard" ? (this.focus({ preventScroll: !0 }), window.mathVirtualKeyboard.executeCommand(e), requestAnimationFrame(() => window.mathVirtualKeyboard.update(Um(this))), !1) : uf(this, e);
@@ -37199,15 +37097,11 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37199
37097
  switchMode(e, t = "", n = "") {
37200
37098
  if (this.model.mode === e || !this.hasEditableContent || !this.contentEditable || this.disabled) return;
37201
37099
  let { model: r } = this, i = r.mode;
37202
- if (r.mode = e, this.host && !this.host.dispatchEvent(new Event("mode-change", {
37100
+ r.mode = e, this.host && !this.host.dispatchEvent(new Event("mode-change", {
37203
37101
  bubbles: !0,
37204
37102
  composed: !0,
37205
37103
  cancelable: !0
37206
- }))) {
37207
- r.mode = i;
37208
- return;
37209
- }
37210
- r.mode = i, r.deferNotifications({
37104
+ })) ? r.mode = i : (r.mode = i, r.deferNotifications({
37211
37105
  content: !!n || !!t,
37212
37106
  selection: !0,
37213
37107
  type: "insertText"
@@ -37233,7 +37127,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37233
37127
  r.mode = e, e === "latex" ? o(t, { select: !0 }) : a(t, { select: !0 });
37234
37128
  }
37235
37129
  return H(this), this.undoManager.snapshot(e === "latex" ? "insert-latex" : "insert"), c;
37236
- }), r.mode = e, window.mathVirtualKeyboard.update(Um(this));
37130
+ }), r.mode = e, window.mathVirtualKeyboard.update(Um(this)));
37237
37131
  }
37238
37132
  hasFocus() {
37239
37133
  return !this.blurred;
@@ -37261,9 +37155,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37261
37155
  let e = Ed(this), t = s({}, this.defaultStyle);
37262
37156
  for (let n of Object.keys(a)) e[n] === a[n] ? (n === "color" && delete t.verbatimColor, n === "backgroundColor" && delete t.verbatimBackgroundColor, delete t[n]) : t[n] = a[n];
37263
37157
  this.defaultStyle = t, this.styleBias = "none";
37264
- return;
37265
- }
37266
- this.model.deferNotifications({
37158
+ } else this.model.deferNotifications({
37267
37159
  content: !i,
37268
37160
  type: "insertText"
37269
37161
  }, () => {
@@ -37313,11 +37205,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37313
37205
  }
37314
37206
  setPromptState(e, t, n) {
37315
37207
  let r = this.getPrompt(e);
37316
- if (!r) {
37317
- console.error(`MathLive 0.110.0: unknown prompt ${e}`);
37318
- return;
37319
- }
37320
- t === "undefined" ? r.correctness = void 0 : typeof t == "string" && (r.correctness = t), typeof n == "boolean" && (r.locked = n, r.captureSelection = n), H(this);
37208
+ r ? (t === "undefined" ? r.correctness = void 0 : typeof t == "string" && (r.correctness = t), typeof n == "boolean" && (r.locked = n, r.captureSelection = n), H(this)) : console.error(`MathLive 0.110.0: unknown prompt ${e}`);
37321
37209
  }
37322
37210
  getPromptState(e) {
37323
37211
  let t = this.getPrompt(e);
@@ -37467,11 +37355,7 @@ var b_ = `<svg xmlns="http://www.w3.org/2000/svg" style="width: 21px;" viewBox=
37467
37355
  dp(this.model), mm(this, e, { simulateKeystroke: !0 });
37468
37356
  }
37469
37357
  onCut(e) {
37470
- if (!this.isSelectionEditable) {
37471
- this.model.announce("plonk");
37472
- return;
37473
- }
37474
- this.model.contentWillChange({ inputType: "deleteByCut" }) && (this.stopCoalescingUndo(), e.clipboardData ? I.onCopy(this, e) : I.copyToClipboard(this, "latex"), Np(this.model, sc(this.model.selection), "deleteByCut"), this.snapshot("cut"), H(this));
37358
+ this.isSelectionEditable ? this.model.contentWillChange({ inputType: "deleteByCut" }) && (this.stopCoalescingUndo(), e.clipboardData ? I.onCopy(this, e) : I.copyToClipboard(this, "latex"), Np(this.model, sc(this.model.selection), "deleteByCut"), this.snapshot("cut"), H(this)) : this.model.announce("plonk");
37475
37359
  }
37476
37360
  onCopy(e) {
37477
37361
  e.clipboardData ? I.onCopy(this, e) : I.copyToClipboard(this, "latex");
@@ -38232,27 +38116,26 @@ var Q = /* @__PURE__ */ new WeakMap(), O_ = .5, k_ = {
38232
38116
  this.upgradeProperty("disabled"), this.upgradeProperty("readonly");
38233
38117
  for (let t of Object.keys(e.optionsAttributes)) this.upgradeProperty(j_(t));
38234
38118
  }
38235
- if (!((t = this._mathfield) != null && t.model)) {
38236
- this._mathfield = null;
38237
- return;
38238
- }
38239
- if (Q.has(this)) {
38240
- let e = this._mathfield, t = Q.get(this), n = t.menuItems;
38241
- e.model.deferNotifications({
38242
- content: !1,
38243
- selection: !1
38244
- }, () => {
38245
- let n = t.value;
38246
- n !== void 0 && e.setValue(n), e.model.selection = t.selection, Q.delete(this);
38247
- }), n && (this.menuItems = n);
38119
+ if (!((t = this._mathfield) != null && t.model)) this._mathfield = null;
38120
+ else {
38121
+ if (Q.has(this)) {
38122
+ let e = this._mathfield, t = Q.get(this), n = t.menuItems;
38123
+ e.model.deferNotifications({
38124
+ content: !1,
38125
+ selection: !1
38126
+ }, () => {
38127
+ let n = t.value;
38128
+ n !== void 0 && e.setValue(n), e.model.selection = t.selection, Q.delete(this);
38129
+ }), n && (this.menuItems = n);
38130
+ }
38131
+ window.queueMicrotask(() => {
38132
+ this.isConnected && this.dispatchEvent(new Event("mount", {
38133
+ cancelable: !1,
38134
+ bubbles: !0,
38135
+ composed: !0
38136
+ }));
38137
+ }), Yd();
38248
38138
  }
38249
- window.queueMicrotask(() => {
38250
- this.isConnected && this.dispatchEvent(new Event("mount", {
38251
- cancelable: !1,
38252
- bubbles: !0,
38253
- composed: !0
38254
- }));
38255
- }), Yd();
38256
38139
  }
38257
38140
  disconnectedCallback() {
38258
38141
  var t;
@@ -38529,15 +38412,7 @@ var Q = /* @__PURE__ */ new WeakMap(), O_ = .5, k_ = {
38529
38412
  };
38530
38413
  }
38531
38414
  set selection(e) {
38532
- if (typeof e == "number" && (e = { ranges: [[e, e]] }), this._mathfield) {
38533
- this._mathfield.model.selection = e, H(this._mathfield);
38534
- return;
38535
- }
38536
- if (Q.has(this)) {
38537
- Q.set(this, c(s({}, Q.get(this)), { selection: e }));
38538
- return;
38539
- }
38540
- Q.set(this, {
38415
+ typeof e == "number" && (e = { ranges: [[e, e]] }), this._mathfield ? (this._mathfield.model.selection = e, H(this._mathfield)) : Q.has(this) ? Q.set(this, c(s({}, Q.get(this)), { selection: e })) : Q.set(this, {
38541
38416
  value: void 0,
38542
38417
  selection: e,
38543
38418
  options: M_(this),
@@ -38552,11 +38427,7 @@ var Q = /* @__PURE__ */ new WeakMap(), O_ = .5, k_ = {
38552
38427
  return this._mathfield ? this._mathfield.model.position : Q.has(this) ? Q.get(this).selection.ranges[0][0] : 0;
38553
38428
  }
38554
38429
  set position(e) {
38555
- if (this._mathfield && (this._mathfield.model.position = e, H(this._mathfield)), Q.has(this)) {
38556
- Q.set(this, c(s({}, Q.get(this)), { selection: { ranges: [[e, e]] } }));
38557
- return;
38558
- }
38559
- Q.set(this, {
38430
+ this._mathfield && (this._mathfield.model.position = e, H(this._mathfield)), Q.has(this) ? Q.set(this, c(s({}, Q.get(this)), { selection: { ranges: [[e, e]] } })) : Q.set(this, {
38560
38431
  value: void 0,
38561
38432
  selection: { ranges: [[e, e]] },
38562
38433
  options: M_(this),
@@ -38570,15 +38441,11 @@ var Q = /* @__PURE__ */ new WeakMap(), O_ = .5, k_ = {
38570
38441
  $.version = "0.110.0", $.openUrl = (e) => {
38571
38442
  if (!e) return;
38572
38443
  let t = new URL(e);
38573
- if (![
38444
+ [
38574
38445
  "http:",
38575
38446
  "https:",
38576
38447
  "file:"
38577
- ].includes(t.protocol.toLowerCase())) {
38578
- $.playSound("plonk");
38579
- return;
38580
- }
38581
- window.open(t, "_blank");
38448
+ ].includes(t.protocol.toLowerCase()) ? window.open(t, "_blank") : $.playSound("plonk");
38582
38449
  }, $._fontsDirectory = "./fonts/", $._soundsDirectory = "./sounds", $.keypressVibration = !0, $._keypressSound = {
38583
38450
  spacebar: "keypress-spacebar.wav",
38584
38451
  return: "keypress-return.wav",
@@ -38793,4 +38660,4 @@ function q_() {
38793
38660
  }
38794
38661
  //#endregion
38795
38662
 
38796
- //# sourceMappingURL=mathlive.min-3RSVNrlY.js.map
38663
+ //# sourceMappingURL=mathlive.min-CVIUc7ff.js.map