@pie-element/shared-math-rendering-mathjax 0.1.3 → 0.1.4-next.20261007175429

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -82,34 +82,34 @@ function _(e) {
82
82
  }
83
83
  //#endregion
84
84
  //#region src/unsupported-page.ts
85
- var v = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", y = "pie-mathjax-version-conflict", b = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
86
- function x(e, t) {
85
+ var v = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ee = "pie-mathjax-version-conflict", te = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
86
+ function ne(e, t) {
87
87
  if (typeof window > "u") return;
88
88
  let n = globalThis;
89
- n[b] ??= {
89
+ n[te] ??= {
90
90
  logged: !1,
91
91
  conditions: []
92
92
  };
93
- let r = n[b];
93
+ let r = n[te];
94
94
  if (r.conditions.includes(e)) return;
95
95
  r.conditions.push(e);
96
96
  let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${v}`;
97
- r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(y, { detail: {
97
+ r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(ee, { detail: {
98
98
  condition: e,
99
99
  message: i,
100
100
  docsUrl: v
101
101
  } }));
102
102
  }
103
- function ee() {
103
+ function re() {
104
104
  let e = window.MathJax?.version;
105
105
  return typeof e == "string" && e.startsWith("3.") ? e : void 0;
106
106
  }
107
107
  //#endregion
108
108
  //#region src/engine/page.ts
109
- function S() {
109
+ function y() {
110
110
  return window.MathJax;
111
111
  }
112
- function te(t, { root: n, speechPath: r }) {
112
+ function ie(t, { root: n, speechPath: r }) {
113
113
  n && (t.loader = {
114
114
  ...t.loader,
115
115
  paths: {
@@ -125,83 +125,83 @@ function te(t, { root: n, speechPath: r }) {
125
125
  }
126
126
  });
127
127
  }
128
- function ne(e, t) {
128
+ function ae(e, t) {
129
129
  let n = t.srcUrl || (t.root ? `${t.root}/mathjax@4.1.3/tex-mml-chtml.js` : void 0);
130
- return n ? (te(e, t), new Promise((t, r) => {
130
+ return n ? (ie(e, t), new Promise((t, r) => {
131
131
  window.MathJax = e;
132
132
  let i = document.createElement("script");
133
133
  i.src = n, i.async = !0, i.onload = () => t(!0), i.onerror = () => r(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(i);
134
134
  })) : (_("untypeset"), Promise.resolve(!1));
135
135
  }
136
- var re = globalThis, C = "PIE-MJX-CHTML-styles", ie = ["MJX-CHTML-styles", "MJX-SVG-styles"], ae = ee, w = "http://www.w3.org/1998/Math/MathML", oe = /^([a-z_][\w.-]*):math$/, se = /^[a-z][a-z0-9-]*$/;
137
- function ce(e) {
136
+ var oe = globalThis, b = "PIE-MJX-CHTML-styles", se = ["MJX-CHTML-styles", "MJX-SVG-styles"], ce = re, x = "http://www.w3.org/1998/Math/MathML", le = /^([a-z_][\w.-]*):math$/, ue = /^[a-z][a-z0-9-]*$/;
137
+ function de(e) {
138
138
  for (let t of e.querySelectorAll("*")) {
139
- let n = oe.exec(t.tagName.toLowerCase())?.[1];
140
- !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(T(t, `${n}:`));
139
+ let n = le.exec(t.tagName.toLowerCase())?.[1];
140
+ !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(S(t, `${n}:`));
141
141
  }
142
142
  }
143
- function T(e, t) {
143
+ function S(e, t) {
144
144
  let n = e.tagName.toLowerCase().slice(t.length);
145
- if (!se.test(n)) return e;
146
- let r = e.ownerDocument.createElementNS(w, n);
145
+ if (!ue.test(n)) return e;
146
+ let r = e.ownerDocument.createElementNS(x, n);
147
147
  for (let t of e.attributes) r.setAttribute(t.name, t.value);
148
148
  for (let n of [...e.childNodes]) {
149
149
  let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
150
- r.appendChild(e ? T(n, t) : n);
150
+ r.appendChild(e ? S(n, t) : n);
151
151
  }
152
152
  return r;
153
153
  }
154
154
  //#endregion
155
155
  //#region src/elementary-math.ts
156
- var le = /* @__PURE__ */ new Set([
156
+ var fe = /* @__PURE__ */ new Set([
157
157
  "updiagonalstrike",
158
158
  "downdiagonalstrike",
159
159
  "verticalstrike",
160
160
  "horizontalstrike"
161
- ]), ue = {
161
+ ]), pe = {
162
162
  thin: "0.035em",
163
163
  medium: "0.07em",
164
164
  thick: "0.14em"
165
- }, de = {
165
+ }, me = {
166
166
  tight: "0em",
167
167
  medium: "0.1em",
168
168
  loose: "0.2em"
169
- }, fe = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, pe = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, me = /^(\d+(\.\d*)?|\.\d+)$/, he = /* @__PURE__ */ new Set([
169
+ }, he = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ge = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, _e = /^(\d+(\.\d*)?|\.\d+)$/, ve = /* @__PURE__ */ new Set([
170
170
  "mn",
171
171
  "mo",
172
172
  "mi",
173
173
  "mtext"
174
- ]), ge = /* @__PURE__ */ new Set([
174
+ ]), ye = /* @__PURE__ */ new Set([
175
175
  "stackalign",
176
176
  "charalign",
177
177
  "charspacing",
178
178
  "longdivstyle"
179
179
  ]);
180
- function E(e, t, n = [], r = {}) {
181
- let i = e.createElementNS(w, t);
180
+ function C(e, t, n = [], r = {}) {
181
+ let i = e.createElementNS(x, t);
182
182
  for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
183
183
  for (let e of n) e && i.appendChild(e);
184
184
  return i;
185
185
  }
186
- function D(e, t) {
187
- let n = E(e.document, "mo");
186
+ function w(e, t) {
187
+ let n = C(e.document, "mo");
188
188
  return n.textContent = t, n;
189
189
  }
190
- function O(e) {
191
- let t = E(e.document, "mn");
192
- return t.textContent = "0", E(e.document, "mphantom", [t]);
190
+ function be(e) {
191
+ let t = C(e.document, "mn");
192
+ return t.textContent = "0", C(e.document, "mphantom", [t]);
193
193
  }
194
- function k(e, t) {
194
+ function T(e, t) {
195
195
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
196
196
  }
197
- function A(e, t) {
197
+ function E(e, t) {
198
198
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
199
199
  return Number.isFinite(n) ? n : 0;
200
200
  }
201
- function j(e) {
201
+ function D(e) {
202
202
  return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
203
203
  }
204
- function M(e, t, n = e) {
204
+ function O(e, t, n = e) {
205
205
  switch (t) {
206
206
  case "left": return 0;
207
207
  case "center": return Math.floor(e / 2);
@@ -209,14 +209,14 @@ function M(e, t, n = e) {
209
209
  default: return n;
210
210
  }
211
211
  }
212
- function N(e, t, n) {
212
+ function k(e, t, n) {
213
213
  let r = [], i, a, o = (e, t) => {
214
214
  let s = (e) => t.reduceRight((e, t) => {
215
215
  let n = t.cloneNode(!1);
216
216
  return n.appendChild(e), n;
217
217
  }, e);
218
218
  if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
219
- else if (j(e)) r.push(null);
219
+ else if (D(e)) r.push(null);
220
220
  else if (e.localName === "mn" && e.children.length === 0) {
221
221
  let t = [...(e.textContent ?? "").trim()];
222
222
  for (let a of t) {
@@ -225,28 +225,28 @@ function N(e, t, n) {
225
225
  t.textContent = a, r.push(s(t));
226
226
  }
227
227
  t.length && (a ??= r.length);
228
- } else he.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
228
+ } else ve.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
229
229
  };
230
230
  for (let t of e) o(t, []);
231
231
  return {
232
232
  kind: "digits",
233
233
  cells: r,
234
- anchor: M(r.length, n.stackAlign, i ?? a),
234
+ anchor: O(r.length, n.stackAlign, i ?? a),
235
235
  position: t
236
236
  };
237
237
  }
238
- function _e(e) {
239
- return (e ?? "").toLowerCase().split(/\s+/).filter((e) => le.has(e));
238
+ function xe(e) {
239
+ return (e ?? "").toLowerCase().split(/\s+/).filter((e) => fe.has(e));
240
240
  }
241
- function ve(e, t) {
242
- let n = [...e.children].filter((e) => !j(e));
243
- return n.length <= 1 ? n[0] ?? null : E(t.document, "mrow", n);
241
+ function Se(e, t) {
242
+ let n = [...e.children].filter((e) => !D(e));
243
+ return n.length <= 1 ? n[0] ?? null : C(t.document, "mrow", n);
244
244
  }
245
- function ye(e, t, n) {
246
- let r = k(e, "location") ?? "n", i = _e(e.getAttribute("crossout")), a = [...e.children].map((e) => j(e) ? null : e.localName === "mscarry" ? {
247
- content: ve(e, n),
248
- location: k(e, "location") ?? r,
249
- crossout: e.hasAttribute("crossout") ? _e(e.getAttribute("crossout")) : i
245
+ function Ce(e, t, n) {
246
+ let r = T(e, "location") ?? "n", i = xe(e.getAttribute("crossout")), a = [...e.children].map((e) => D(e) ? null : e.localName === "mscarry" ? {
247
+ content: Se(e, n),
248
+ location: T(e, "location") ?? r,
249
+ crossout: e.hasAttribute("crossout") ? xe(e.getAttribute("crossout")) : i
250
250
  } : {
251
251
  content: e,
252
252
  location: r,
@@ -255,60 +255,60 @@ function ye(e, t, n) {
255
255
  return {
256
256
  kind: "carries",
257
257
  carries: a,
258
- anchor: M(a.length, n.stackAlign),
258
+ anchor: O(a.length, n.stackAlign),
259
259
  position: t,
260
- scale: me.test(o) ? o : "0.6"
260
+ scale: _e.test(o) ? o : "0.6"
261
261
  };
262
262
  }
263
- function be(e) {
264
- let t = k(e, "mslinethickness") ?? "medium", n = ue[t] ?? (fe.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
265
- return `${n} solid ${pe.test(r) ? r : "currentColor"}`;
263
+ function we(e) {
264
+ let t = T(e, "mslinethickness") ?? "medium", n = pe[t] ?? (he.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
265
+ return `${n} solid ${ge.test(r) ? r : "currentColor"}`;
266
266
  }
267
- function xe(e, t, n) {
268
- let r = Math.max(0, A(e, "length"));
267
+ function Te(e, t, n) {
268
+ let r = Math.max(0, E(e, "length"));
269
269
  return {
270
270
  kind: "line",
271
271
  length: r,
272
- anchor: M(r, n.stackAlign),
272
+ anchor: O(r, n.stackAlign),
273
273
  position: t,
274
- border: be(e)
274
+ border: we(e)
275
275
  };
276
276
  }
277
- function P(e, t, n, r, i) {
277
+ function A(e, t, n, r, i) {
278
278
  e.forEach((e, a) => {
279
- let o = t + a * n + A(e, "position");
279
+ let o = t + a * n + E(e, "position");
280
280
  switch (e.localName) {
281
281
  case "msgroup":
282
- P([...e.children], o, A(e, "shift"), r, i);
282
+ A([...e.children], o, E(e, "shift"), r, i);
283
283
  break;
284
284
  case "msline":
285
- i.push(xe(e, o, r));
285
+ i.push(Te(e, o, r));
286
286
  break;
287
287
  case "mscarries":
288
- i.push(ye(e, o, r));
288
+ i.push(Ce(e, o, r));
289
289
  break;
290
290
  case "msrow":
291
291
  case "mrow":
292
- i.push(N([...e.children], o, r));
292
+ i.push(k([...e.children], o, r));
293
293
  break;
294
- default: i.push(N([e], o, r));
294
+ default: i.push(k([e], o, r));
295
295
  }
296
296
  });
297
297
  }
298
- function F(e) {
298
+ function j(e) {
299
299
  return -e.anchor - e.position;
300
300
  }
301
- function I(e) {
301
+ function Ee(e) {
302
302
  return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
303
303
  }
304
- function L(e) {
305
- return F(e) + I(e) - 1;
304
+ function De(e) {
305
+ return j(e) + Ee(e) - 1;
306
306
  }
307
- function Se(e, t, n, r) {
308
- let i = (e) => E(r.document, "mpadded", [t], {
307
+ function Oe(e, t, n, r) {
308
+ let i = (e) => C(r.document, "mpadded", [t], {
309
309
  width: "0",
310
310
  ...e ? { lspace: e } : {}
311
- }), a = (e, t) => E(r.document, e, t);
311
+ }), a = (e, t) => C(r.document, e, t);
312
312
  switch (n) {
313
313
  case "s": return a("munder", [e, i("-0.5width")]);
314
314
  case "ne": return a("msup", [e, i()]);
@@ -330,49 +330,49 @@ function Se(e, t, n, r) {
330
330
  default: return a("mover", [e, i("-0.5width")]);
331
331
  }
332
332
  }
333
- function Ce(e, t, n) {
334
- let r = E(n.document, "menclose", [e], {
333
+ function ke(e, t, n) {
334
+ let r = C(n.document, "menclose", [e], {
335
335
  notation: t.join(" "),
336
336
  "data-padding": "0.1em",
337
337
  "data-thickness": "0.067em"
338
338
  }), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
339
- return i ? E(n.document, "mpadded", [r], {
339
+ return i ? C(n.document, "mpadded", [r], {
340
340
  lspace: `-${i}em`,
341
341
  width: `-${2 * i}em`
342
342
  }) : r;
343
343
  }
344
- function we(e, t, n, r, i) {
345
- let a = e && t.crossout.length ? Ce(e, t.crossout, i) : e;
344
+ function Ae(e, t, n, r, i) {
345
+ let a = e && t.crossout.length ? ke(e, t.crossout, i) : e;
346
346
  if (!t.content) return a;
347
- let o = E(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
348
- return Se(a ?? O(i), o, n, i);
347
+ let o = C(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
348
+ return Oe(a ?? be(i), o, n, i);
349
349
  }
350
- function R(e, t) {
351
- return e.carries[t - F(e)] ?? null;
350
+ function je(e, t) {
351
+ return e.carries[t - j(e)] ?? null;
352
352
  }
353
- function Te(e, t, n, r) {
353
+ function Me(e, t, n, r) {
354
354
  let i = e.content;
355
355
  n.forEach((e, a) => {
356
- let o = n.length - 1 - a, s = n[o], c = R(s, t), l = n.slice(0, o).some((e) => R(e, t));
356
+ let o = n.length - 1 - a, s = n[o], c = je(s, t), l = n.slice(0, o).some((e) => je(e, t));
357
357
  if (!c && !l) return;
358
358
  let u = c ?? {
359
- content: O(r),
359
+ content: be(r),
360
360
  location: "n",
361
361
  crossout: []
362
362
  }, d = a === 0 ? u.location : "n";
363
- i = we(i, u, d, s.scale, r);
363
+ i = Ae(i, u, d, s.scale, r);
364
364
  }), e.content = i;
365
365
  }
366
- function z(e, t) {
367
- let n = e.filter((e) => I(e) > 0), r = Math.min(0, ...n.map(F)), i = Math.max(r, ...n.map(L)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
366
+ function Ne(e, t) {
367
+ let n = e.filter((e) => Ee(e) > 0), r = Math.min(0, ...n.map(j)), i = Math.max(r, ...n.map(De)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
368
368
  content: null,
369
369
  borders: {}
370
- })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + F(e) + n), u = [], d = [], f = (e) => {
370
+ })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + j(e) + n), u = [], d = [], f = (e) => {
371
371
  let n = c();
372
372
  e.cells.forEach((t, r) => {
373
- n[a + F(e) + r].content = t;
373
+ n[a + j(e) + r].content = t;
374
374
  }), u.length && n.forEach((e, n) => {
375
- Te(e, n - a, u, t);
375
+ Me(e, n - a, u, t);
376
376
  });
377
377
  for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
378
378
  u = [], d = [], s.set(e, o.length), o.push(n);
@@ -392,44 +392,44 @@ function z(e, t) {
392
392
  origin: a
393
393
  };
394
394
  }
395
- function B(e, { rows: t }, n) {
396
- let r = E(n.document, "mtable", t.map((e) => E(n.document, "mtr", e.map((e) => {
395
+ function Pe(e, { rows: t }, n) {
396
+ let r = C(n.document, "mtable", t.map((e) => C(n.document, "mtr", e.map((e) => {
397
397
  let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
398
- return E(n.document, "mtd", [e.content], {
398
+ return C(n.document, "mtd", [e.content], {
399
399
  ...t ? { style: t } : {},
400
400
  ...e.align ? { columnalign: e.align } : {}
401
401
  });
402
402
  }))));
403
- for (let { name: t, value: n } of [...e.attributes]) ge.has(t) || r.setAttribute(t, n);
404
- let i = k(e, "charspacing") ?? "medium", a = k(e, "charalign");
405
- return r.setAttribute("columnspacing", de[i] ?? (fe.test(i) ? i : de.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
403
+ for (let { name: t, value: n } of [...e.attributes]) ye.has(t) || r.setAttribute(t, n);
404
+ let i = T(e, "charspacing") ?? "medium", a = T(e, "charalign");
405
+ return r.setAttribute("columnspacing", me[i] ?? (he.test(i) ? i : me.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
406
406
  }
407
- function V(e) {
407
+ function Fe(e) {
408
408
  return {
409
409
  document: e.ownerDocument,
410
- stackAlign: k(e, "stackalign") ?? "decimalpoint",
410
+ stackAlign: T(e, "stackalign") ?? "decimalpoint",
411
411
  decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
412
412
  };
413
413
  }
414
- function Ee(e) {
415
- let t = V(e), n = [];
416
- return P([...e.children], 0, 0, t, n), B(e, z(n, t), t);
414
+ function Ie(e) {
415
+ let t = Fe(e), n = [];
416
+ return A([...e.children], 0, 0, t, n), Pe(e, Ne(n, t), t);
417
417
  }
418
- function H(e, t, n, r, i, a) {
418
+ function M(e, t, n, r, i, a) {
419
419
  for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
420
420
  }
421
- function De(e, t) {
422
- let n = D(t, ")");
423
- return n.setAttribute("minsize", "1.2em"), [E(t.document, "mrow", [e, E(t.document, "mspace", [], { width: "0.2em" })]), E(t.document, "mpadded", [n], {
421
+ function Le(e, t) {
422
+ let n = w(t, ")");
423
+ return n.setAttribute("minsize", "1.2em"), [C(t.document, "mrow", [e, C(t.document, "mspace", [], { width: "0.2em" })]), C(t.document, "mpadded", [n], {
424
424
  voffset: "0.1em",
425
425
  lspace: "-0.15em",
426
426
  depth: "-0.2em",
427
427
  height: "-0.2em"
428
428
  })];
429
429
  }
430
- function Oe(e) {
431
- let t = V(e), [n, r, ...i] = [...e.children], a = n && !j(n) ? n : null, o = r && !j(r) ? r : null, s = k(e, "longdivstyle") ?? "lefttop", c = be(e), l = [];
432
- P(i, 0, 0, t, l);
430
+ function Re(e) {
431
+ let t = Fe(e), [n, r, ...i] = [...e.children], a = n && !D(n) ? n : null, o = r && !D(r) ? r : null, s = T(e, "longdivstyle") ?? "lefttop", c = we(e), l = [];
432
+ A(i, 0, 0, t, l);
433
433
  let u = l.find((e) => e.kind === "digits");
434
434
  u || (u = {
435
435
  kind: "digits",
@@ -441,51 +441,51 @@ function Oe(e) {
441
441
  u.cells.unshift(...e), u.anchor += e.length;
442
442
  }, p = (...e) => {
443
443
  let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
444
- u.cells.push(...N(n, 0, t).cells);
444
+ u.cells.push(...k(n, 0, t).cells);
445
445
  };
446
446
  switch (s) {
447
447
  case "left/\\right":
448
- f(a, D(t, "/")), p(D(t, "\\"), o);
448
+ f(a, w(t, "/")), p(w(t, "\\"), o);
449
449
  break;
450
450
  case "left)(right":
451
- f(a, D(t, ")")), p(D(t, "("), o);
451
+ f(a, w(t, ")")), p(w(t, "("), o);
452
452
  break;
453
453
  case ":right=right":
454
- p(D(t, ":"), a, D(t, "="), o);
454
+ p(w(t, ":"), a, w(t, "="), o);
455
455
  break;
456
456
  case "righttop":
457
457
  case "stackedleftlinetop":
458
458
  case "lefttop":
459
- o && P([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...De(a, t));
459
+ o && A([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...Le(a, t));
460
460
  break;
461
461
  }
462
- let m = z(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + F(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + L(e)));
462
+ let m = Ne(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + j(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + De(e)));
463
463
  switch (s) {
464
464
  case "left/\\right":
465
465
  case "left)(right":
466
466
  case ":right=right": break;
467
467
  case "righttop": {
468
468
  let e = h[g][_(u.cells.length - 1)];
469
- e.borders.left = c, e.borders.bottom = c, H(h, g, _(0), _(u.cells.length - 1), "top", c);
469
+ e.borders.left = c, e.borders.bottom = c, M(h, g, _(0), _(u.cells.length - 1), "top", c);
470
470
  break;
471
471
  }
472
472
  case "stackedleftlinetop": {
473
473
  let e = h[g][_(0)];
474
- e.borders.right = c, e.borders.bottom = c, H(h, g, _(1), v, "top", c);
474
+ e.borders.right = c, e.borders.bottom = c, M(h, g, _(1), v, "top", c);
475
475
  break;
476
476
  }
477
477
  case "stackedrightright":
478
478
  case "mediumstackedrightright":
479
479
  case "shortstackedrightright":
480
480
  case "stackedleftleft":
481
- ke(h, g, s, a, o, c, t);
481
+ ze(h, g, s, a, o, c, t);
482
482
  break;
483
- default: H(h, g, _(1), v, "top", c);
483
+ default: M(h, g, _(1), v, "top", c);
484
484
  }
485
- return B(e, m, t);
485
+ return Pe(e, m, t);
486
486
  }
487
- function ke(e, t, n, r, i, a, o) {
488
- let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && E(o.document, "mpadded", [e], {
487
+ function ze(e, t, n, r, i, a, o) {
488
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && C(o.document, "mpadded", [e], {
489
489
  lspace: "0.2em",
490
490
  width: "+0.4em"
491
491
  });
@@ -504,140 +504,140 @@ function ke(e, t, n, r, i, a, o) {
504
504
  }) : o === t + 1 ? (u.content = l(i), n !== "shortstackedrightright" && (u.borders[c] = a)) : o > t + 1 && (n === "stackedrightright" || s) && (u.borders[c] = a), s ? e.unshift(u) : e.push(u);
505
505
  });
506
506
  }
507
- function Ae(e) {
508
- for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Ee(t) : Oe(t));
507
+ function Be(e) {
508
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Ie(t) : Re(t));
509
509
  }
510
510
  //#endregion
511
511
  //#region src/explorer-styles.ts
512
- var je = "PIE-MJX-explorer-styles", U = "var(--pie-text, black)", Me = "var(--pie-background, #ffffff)", Ne = "var(--pie-border-dark, #66686A)", W = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", G = `color-mix(in srgb, ${W} 15%, transparent)`, Pe = `
512
+ var Ve = "PIE-MJX-explorer-styles", N = "var(--pie-text, black)", He = "var(--pie-background, #ffffff)", Ue = "var(--pie-border-dark, #66686A)", P = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", F = `color-mix(in srgb, ${P} 15%, transparent)`, We = `
513
513
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
514
- color: ${U} !important;
515
- fill: ${U} !important;
514
+ color: ${N} !important;
515
+ fill: ${N} !important;
516
516
  }
517
517
  :root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
518
- background-color: ${G} !important;
518
+ background-color: ${F} !important;
519
519
  }
520
520
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
521
- fill: ${G} !important;
521
+ fill: ${F} !important;
522
522
  }
523
523
  :root mjx-container .mjx-selected {
524
- outline: 2px solid ${W} !important;
524
+ outline: 2px solid ${P} !important;
525
525
  }
526
526
  :root mjx-container [data-sre-highlight-2] {
527
- color: ${U} !important;
527
+ color: ${N} !important;
528
528
  background-color: transparent !important;
529
- fill: ${U} !important;
530
- outline: 2px dashed ${W} !important;
529
+ fill: ${N} !important;
530
+ outline: 2px dashed ${P} !important;
531
531
  }
532
532
  :root mjx-container rect[data-sre-highlight-2] {
533
533
  fill: transparent !important;
534
- stroke: ${W} !important;
534
+ stroke: ${P} !important;
535
535
  stroke-width: 2px !important;
536
536
  vector-effect: non-scaling-stroke;
537
537
  }
538
538
  :root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
539
- color: ${U} !important;
540
- background-color: ${Me} !important;
541
- border-color: ${Ne} !important;
539
+ color: ${N} !important;
540
+ background-color: ${He} !important;
541
+ border-color: ${Ue} !important;
542
542
  }
543
543
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
544
- color: ${U} !important;
545
- background-color: ${G} !important;
544
+ color: ${N} !important;
545
+ background-color: ${F} !important;
546
546
  }
547
547
  `;
548
- function Fe(e = document) {
548
+ function Ge(e = document) {
549
549
  if (e.getElementById("PIE-MJX-explorer-styles")) return;
550
550
  let t = e.createElement("style");
551
- t.id = je, t.textContent = Pe, e.head.appendChild(t);
551
+ t.id = Ve, t.textContent = We, e.head.appendChild(t);
552
552
  }
553
553
  //#endregion
554
554
  //#region src/speech-worker.ts
555
- var K = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
556
- function Ie() {
555
+ var I = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
556
+ function Ke() {
557
557
  let e = globalThis;
558
- e[K] || (e[K] = !0, console.warn(`[math-rendering] MathJax's speech worker did not start, so speech, braille and the explorer are off. A content security policy must allow blob: workers, and scripts and fetches from the asset root. See ${t}`));
558
+ e[I] || (e[I] = !0, console.warn(`[math-rendering] MathJax's speech worker did not start, so speech, braille and the explorer are off. A content security policy must allow blob: workers, and scripts and fetches from the asset root. See ${t}`));
559
559
  }
560
- function Le(e) {
560
+ function qe(e) {
561
561
  let t = e.webworker;
562
562
  if (!t || t.ready) return;
563
563
  e.options ??= {};
564
564
  let n = e.options;
565
- n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), Ie();
565
+ n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), Ke();
566
566
  }
567
- function Re(e) {
567
+ function Je(e) {
568
568
  let t = e?.adaptor, n = t?.createWorker;
569
569
  !e || !t || !n || (t.createWorker = async (r, i) => {
570
570
  let a = await n.call(t, r, i);
571
- return a.addEventListener("error", () => Le(e), { once: !0 }), a;
571
+ return a.addEventListener("error", () => qe(e), { once: !0 }), a;
572
572
  });
573
573
  }
574
574
  `${i}`;
575
575
  //#endregion
576
576
  //#region src/adapter.ts
577
- var ze = {
577
+ var Ye = {
578
578
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
579
579
  overarc: "\\overparen",
580
580
  napprox: "\\not\\approx",
581
581
  longdiv: "\\enclose{longdiv}",
582
582
  abs: ["\\left|#1\\right|", 1]
583
- }, Be = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Ve = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, He = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, Ue = /\\embed\{newLine\}\[\]/g, We = [
583
+ }, Xe = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Ze = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, Qe = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, $e = /\\embed\{newLine\}\[\]/g, et = [
584
584
  ["$$", "$$"],
585
585
  ["$", "$"],
586
586
  ["\\[", "\\]"],
587
587
  ["\\(", "\\)"]
588
- ], q = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Ge = "MJX-CHTML-styles", Ke = "PIE-MJX-SVG-styles", J = "PIE-MathJax-Menu-Settings", qe = { "mjx-container[overflow=\"linebreak\"][display]": {
588
+ ], L = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), tt = "MJX-CHTML-styles", nt = "PIE-MJX-SVG-styles", R = "PIE-MathJax-Menu-Settings", rt = { "mjx-container[overflow=\"linebreak\"][display]": {
589
589
  overflow: "auto clip",
590
590
  "min-width": "initial !important"
591
- } }, Je = 200, Ye = 201;
592
- function Y(e) {
591
+ } }, it = 200, at = 201;
592
+ function z(e) {
593
593
  let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
594
594
  for (let e of t) for (let t of [e, ...e.querySelectorAll("[data-latex],[data-latex-item]")]) t.removeAttribute("data-latex"), t.removeAttribute("data-latex-item");
595
595
  }
596
- function X(e) {
597
- for (let [t, n] of We) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
596
+ function B(e) {
597
+ for (let [t, n] of et) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
598
598
  return e;
599
599
  }
600
- function Xe(e) {
601
- return X(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
600
+ function ot(e) {
601
+ return B(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
602
602
  }
603
- var Ze = "mathjax_ignore", Qe = "mathjax_process";
604
- function $e(e, t) {
605
- let n = e.closest(`.${Ze}, .${Qe}`);
606
- return n !== null && t.contains(n) && !n.classList.contains(Qe);
603
+ var st = "mathjax_ignore", V = "mathjax_process";
604
+ function ct(e, t) {
605
+ let n = e.closest(`.${st}, .${V}`);
606
+ return n !== null && t.contains(n) && !n.classList.contains(V);
607
607
  }
608
- function et(e) {
608
+ function lt(e) {
609
609
  for (let t of e.querySelectorAll("[data-latex]")) {
610
- if (t.dataset.mathHandled || t.closest("mjx-container") || $e(t, e)) continue;
610
+ if (t.dataset.mathHandled || t.closest("mjx-container") || ct(t, e)) continue;
611
611
  let n = t.textContent;
612
- n && (t.textContent = `\\(${Xe(n)}\\)`.replace(Ue, "\\newline "), t.dataset.mathHandled = "true");
612
+ n && (t.textContent = `\\(${ot(n)}\\)`.replace($e, "\\newline "), t.dataset.mathHandled = "true");
613
613
  }
614
614
  }
615
- function tt(e) {
615
+ function ut(e) {
616
616
  for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
617
617
  }
618
- function nt(e, t) {
618
+ function dt(e, t) {
619
619
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
620
- return (t ? He : Ve).test(e.textContent ?? "");
620
+ return (t ? Qe : Ze).test(e.textContent ?? "");
621
621
  }
622
- function rt(e) {
622
+ function ft(e) {
623
623
  return new Promise((t, n) => {
624
624
  let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = e, s = d(e, import.meta.url), c = {
625
625
  loader: {
626
626
  load: i ? ["a11y/assistive-mml"] : [],
627
627
  failed: (e) => n(e),
628
628
  "output/svg": { ready: (e) => {
629
- let t = S();
630
- return it(t) && at(t), e;
629
+ let t = y();
630
+ return pt(t) && mt(t), e;
631
631
  } }
632
632
  },
633
633
  startup: {
634
634
  typeset: !1,
635
635
  ready: () => {
636
- let e = S(), r = e?.startup, i = it(e);
637
- i && (at(e), ot(e, s.speechLocales), f(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (st(r?.document), r?.document?.addStyles?.(qe), Re(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
636
+ let e = y(), r = e?.startup, i = pt(e);
637
+ i && (mt(e), ht(e, s.speechLocales), f(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (gt(r?.document), r?.document?.addStyles?.(rt), Je(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
638
638
  }
639
639
  },
640
- tex: { macros: { ...ze } },
640
+ tex: { macros: { ...Ye } },
641
641
  output: { displayOverflow: "linebreak" },
642
642
  options: {
643
643
  enableMenu: i,
@@ -649,9 +649,9 @@ function rt(e) {
649
649
  a11y: { inTabOrder: !1 }
650
650
  }
651
651
  };
652
- r && c.tex && (console.warn(Be), c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), a || (c.chtml = { fontURL: "" });
652
+ r && c.tex && (console.warn(Xe), c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), a || (c.chtml = { fontURL: "" });
653
653
  let l = p(s.speechLocales);
654
- l && c.options && (c.options.sre = { locale: l }), ne(c, {
654
+ l && c.options && (c.options.sre = { locale: l }), ae(c, {
655
655
  ...s,
656
656
  srcUrl: o
657
657
  }).then((e) => {
@@ -659,163 +659,452 @@ function rt(e) {
659
659
  }, n);
660
660
  });
661
661
  }
662
- function it(e) {
662
+ function pt(e) {
663
663
  return !!e?.version?.startsWith("4.");
664
664
  }
665
- function at(e) {
665
+ function mt(e) {
666
666
  let t = e?._?.output, n = t?.chtml_ts?.CHTML;
667
- n && (n.STYLESHEETID = C);
667
+ n && (n.STYLESHEETID = b);
668
668
  let r = t?.svg_ts?.SVG;
669
- r && (r.STYLESHEETID = Ke);
669
+ r && (r.STYLESHEETID = nt);
670
670
  }
671
- function ot(e, t) {
671
+ function ht(e, t) {
672
672
  let n = e?._?.ui?.menu?.Menu?.Menu;
673
673
  if (n) {
674
- n.MENU_STORAGE = J;
674
+ n.MENU_STORAGE = R;
675
675
  try {
676
- let e = localStorage.getItem(J);
676
+ let e = localStorage.getItem(R);
677
677
  if (!e) return;
678
678
  let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
679
679
  if (n === void 0 && a) return;
680
- a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(J, JSON.stringify(i)) : localStorage.removeItem(J);
680
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(R, JSON.stringify(i)) : localStorage.removeItem(R);
681
681
  } catch {}
682
682
  }
683
683
  }
684
- function st(e) {
684
+ function gt(e) {
685
685
  if (!e) return;
686
686
  let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
687
687
  let n = e.typesetRoot;
688
- !n || t.has(n) || (Y(n), t.add(n));
688
+ !n || t.has(n) || (z(n), t.add(n));
689
689
  };
690
- e.addRenderAction?.("pie-strip-latex", Ye, (e) => {
690
+ e.addRenderAction?.("pie-strip-latex", at, (e) => {
691
691
  for (let t of e.math ?? []) n(t);
692
692
  return !1;
693
693
  }, (e) => {
694
694
  let t = e.typesetRoot;
695
- return t && Y(t), !1;
695
+ return t && z(t), !1;
696
696
  });
697
697
  let r = e.outputJax?.chtmlStyles;
698
- r?.id === Ge && (r.id = C), ut();
698
+ r?.id === tt && (r.id = b), yt();
699
699
  }
700
- function ct(e) {
701
- return e instanceof HTMLStyleElement && ie.includes(e.id);
700
+ function _t(e) {
701
+ return e instanceof HTMLStyleElement && se.includes(e.id);
702
702
  }
703
- function lt(e) {
704
- x("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
703
+ function vt(e) {
704
+ ne("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
705
705
  }
706
- function ut() {
707
- let e = document.head, t = [...e.children].find(ct);
706
+ function yt() {
707
+ let e = document.head, t = [...e.children].find(_t);
708
708
  if (t) {
709
- lt(t);
709
+ vt(t);
710
710
  return;
711
711
  }
712
712
  let n = new MutationObserver((e) => {
713
713
  for (let t of e) {
714
- let e = [...t.addedNodes].find(ct);
714
+ let e = [...t.addedNodes].find(_t);
715
715
  if (e) {
716
- lt(e), n.disconnect();
716
+ vt(e), n.disconnect();
717
717
  return;
718
718
  }
719
719
  }
720
720
  });
721
721
  n.observe(e, { childList: !0 });
722
722
  }
723
- function dt(e) {
723
+ function bt(e) {
724
724
  let t = e?.math;
725
725
  if (!t?.remove) return;
726
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= Je && e.typesetRoot?.isConnected === !1);
726
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= it && e.typesetRoot?.isConnected === !1);
727
727
  if (n.length !== 0) {
728
728
  for (let e of [...n].reverse()) e.clear?.();
729
729
  t.remove(...n);
730
730
  }
731
731
  }
732
- function ft(e) {
732
+ function xt(e) {
733
733
  return new Promise((t, n) => {
734
734
  let r = e.startup ?? {};
735
735
  e.startup = r;
736
736
  let i = r.ready;
737
737
  r.ready = () => {
738
- let e = S()?.startup;
738
+ let e = y()?.startup;
739
739
  i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
740
740
  };
741
741
  });
742
742
  }
743
- function pt(e) {
744
- let t = S();
745
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : ft(t) : rt(e);
743
+ function St(e) {
744
+ let t = y();
745
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : xt(t) : ft(e);
746
746
  }
747
- function mt(e) {
748
- return pt(e).then(() => {
749
- let e = S();
747
+ function Ct(e) {
748
+ return St(e).then(() => {
749
+ let e = y();
750
750
  e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
751
751
  });
752
752
  }
753
- function ht(e) {
754
- let t = re, n = t[q];
755
- return n || (n = mt(e), t[q] = n), n;
753
+ function wt(e) {
754
+ let t = oe, n = t[L];
755
+ return n || (n = Ct(e), t[L] = n), n;
756
756
  }
757
- function gt(e = {}) {
757
+ function Tt(e = {}) {
758
758
  let t = e.useSingleDollar ?? !1;
759
759
  return async (n) => {
760
760
  if (typeof window > "u") return;
761
- let r = ae();
762
- r && x("mathjax-3-global", `window.MathJax is MathJax ${r}`), et(n), ce(n), tt(n), Ae(n);
763
- let i = ht(e);
764
- if (!nt(n, t)) {
761
+ let r = ce();
762
+ r && ne("mathjax-3-global", `window.MathJax is MathJax ${r}`), lt(n), de(n), ut(n), Be(n);
763
+ let i = wt(e);
764
+ if (!dt(n, t)) {
765
765
  i.catch(() => {});
766
766
  return;
767
767
  }
768
768
  await i;
769
- let a = S();
769
+ let a = y();
770
770
  if (await a?.startup?.promise, typeof a?.typesetPromise == "function") {
771
- Fe(), dt(a.startup?.document);
771
+ Ge(), bt(a.startup?.document);
772
772
  try {
773
773
  await a.typesetPromise([n]);
774
774
  } catch (e) {
775
775
  throw a.typesetClear?.([n]), e;
776
776
  }
777
- Y(n);
777
+ z(n);
778
778
  }
779
779
  };
780
780
  }
781
- function _t() {
781
+ function Et() {
782
782
  return [];
783
783
  }
784
784
  //#endregion
785
+ //#region src/math-speech.ts
786
+ var Dt = /[⁡-⁤]/g, Ot = {
787
+ "+": "positive",
788
+ "-": "negative",
789
+ "−": "negative",
790
+ "±": "plus or minus",
791
+ "∓": "minus or plus"
792
+ }, kt = {
793
+ "(": "open parenthesis",
794
+ "[": "open bracket",
795
+ "{": "open brace",
796
+ "⟨": "open angle bracket",
797
+ "⌊": "open floor",
798
+ "⌈": "open ceiling"
799
+ }, At = {
800
+ ")": "close parenthesis",
801
+ "]": "close bracket",
802
+ "}": "close brace",
803
+ "⟩": "close angle bracket",
804
+ "⌋": "close floor",
805
+ "⌉": "close ceiling"
806
+ }, H = {
807
+ "!": "factorial",
808
+ "%": "percent",
809
+ "°": "degrees",
810
+ "′": "prime",
811
+ "″": "double prime"
812
+ }, jt = {
813
+ "+": "plus",
814
+ "-": "minus",
815
+ "−": "minus",
816
+ "±": "plus or minus",
817
+ "∓": "minus or plus",
818
+ "×": "times",
819
+ "⋅": "times",
820
+ "·": "times",
821
+ "*": "times",
822
+ "÷": "divided by",
823
+ "/": "divided by",
824
+ "=": "equals",
825
+ "≠": "does not equal",
826
+ "<": "is less than",
827
+ ">": "is greater than",
828
+ "≤": "is less than or equal to",
829
+ "≥": "is greater than or equal to",
830
+ "≈": "is approximately equal to",
831
+ "≡": "is equivalent to",
832
+ "∝": "is proportional to",
833
+ "∈": "is an element of",
834
+ "∉": "is not an element of",
835
+ "⊂": "is a subset of",
836
+ "⊆": "is a subset of or equal to",
837
+ "∪": "union",
838
+ "∩": "intersection",
839
+ "→": "right arrow",
840
+ "←": "left arrow",
841
+ "⇒": "implies",
842
+ "⇔": "if and only if",
843
+ "∑": "sum",
844
+ "∏": "product",
845
+ "∫": "integral",
846
+ "∞": "infinity",
847
+ "∠": "angle",
848
+ "⊥": "is perpendicular to",
849
+ "∥": "is parallel to",
850
+ "∴": "therefore",
851
+ ",": "comma",
852
+ ";": "semicolon",
853
+ ":": "colon",
854
+ "|": "vertical bar",
855
+ "‖": "double vertical bar",
856
+ ...kt,
857
+ ...At,
858
+ ...H
859
+ }, Mt = /* @__PURE__ */ new Set(["|", "‖"]), Nt = /* @__PURE__ */ new Set([
860
+ "∑",
861
+ "∏",
862
+ "∫",
863
+ "∪",
864
+ "∩"
865
+ ]), Pt = {
866
+ α: "alpha",
867
+ β: "beta",
868
+ γ: "gamma",
869
+ δ: "delta",
870
+ ε: "epsilon",
871
+ θ: "theta",
872
+ λ: "lambda",
873
+ μ: "mu",
874
+ π: "pi",
875
+ ρ: "rho",
876
+ σ: "sigma",
877
+ τ: "tau",
878
+ φ: "phi",
879
+ ω: "omega",
880
+ Δ: "capital delta",
881
+ Σ: "capital sigma",
882
+ Ω: "capital omega",
883
+ "∞": "infinity",
884
+ sin: "sine",
885
+ cos: "cosine",
886
+ tan: "tangent",
887
+ sec: "secant",
888
+ csc: "cosecant",
889
+ cot: "cotangent",
890
+ ln: "natural log",
891
+ lim: "limit"
892
+ }, Ft = {
893
+ "¯": "bar",
894
+ "‾": "bar",
895
+ "―": "bar",
896
+ "^": "hat",
897
+ ˆ: "hat",
898
+ "~": "tilde",
899
+ "˜": "tilde",
900
+ "→": "vector",
901
+ "⃗": "vector",
902
+ "˙": "dot"
903
+ }, It = {
904
+ 2: ["half", "halves"],
905
+ 3: ["third", "thirds"],
906
+ 4: ["quarter", "quarters"],
907
+ 5: ["fifth", "fifths"],
908
+ 6: ["sixth", "sixths"],
909
+ 7: ["seventh", "sevenths"],
910
+ 8: ["eighth", "eighths"],
911
+ 9: ["ninth", "ninths"],
912
+ 10: ["tenth", "tenths"]
913
+ }, U = (e) => (e.textContent ?? "").replace(Dt, "").replace(/\s+/g, " ").trim(), W = (e) => e.replace(/\s+/g, " ").trim(), G = (e) => [...e.children];
914
+ function K(e) {
915
+ return !e || [
916
+ "mn",
917
+ "mi",
918
+ "mtext",
919
+ "mo"
920
+ ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? K(e.children[0]) : !1;
921
+ }
922
+ function q(e) {
923
+ let t = e ? U(e) : "";
924
+ return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
925
+ }
926
+ function Lt(e) {
927
+ return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
928
+ 1: "st",
929
+ 2: "nd",
930
+ 3: "rd"
931
+ }[e % 10] ?? "th"}`;
932
+ }
933
+ function Rt(e) {
934
+ return Pt[e] ?? e;
935
+ }
936
+ function J(e) {
937
+ return jt[e] ?? e;
938
+ }
939
+ function Y(e) {
940
+ let t = [], n = !1;
941
+ for (let r of e) {
942
+ if (r.localName !== "mo") {
943
+ t.push(X(r)), n = !0;
944
+ continue;
945
+ }
946
+ let e = U(r);
947
+ e && (!n && Ot[e] ? t.push(Ot[e]) : e in H ? t.push(H[e]) : (t.push(J(e)), n = e in At || Mt.has(e) && n));
948
+ }
949
+ return t.filter(Boolean).join(" ");
950
+ }
951
+ function zt(e) {
952
+ let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(U(e)), a = n.slice(0, -1);
953
+ if (a.length && i(t) && i(r) && U(t) === U(r) && !a.some(i)) {
954
+ let e = W(Y(a));
955
+ return U(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
956
+ }
957
+ return Y(e);
958
+ }
959
+ function Bt(e, t) {
960
+ let n = q(e), r = q(t), i = r === void 0 ? void 0 : It[r];
961
+ if (n !== void 0 && i) return `${n} ${n === 1 ? i[0] : i[1]}`;
962
+ let a = e ? X(e) : "", o = t ? X(t) : "";
963
+ return K(e) && K(t) ? `${a} over ${o}` : `the fraction with numerator ${a} and denominator ${o}`;
964
+ }
965
+ function Vt(e, t, n) {
966
+ return n ? `${t} of ${e}` : `${t} of ${e} end root`;
967
+ }
968
+ function Ht(e, t) {
969
+ let n = t ? U(t) : "";
970
+ if (t && K(t)) {
971
+ if (n === "2") return `${e} squared`;
972
+ if (n === "3") return `${e} cubed`;
973
+ if (n in H) return `${e} ${H[n]}`;
974
+ }
975
+ let r = t ? X(t) : "";
976
+ return K(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
977
+ }
978
+ function Ut(e, t) {
979
+ let n = t ? X(t) : "";
980
+ return K(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
981
+ }
982
+ function Wt(e, t, n) {
983
+ let r = U(e);
984
+ if (r === "lim") return `limit as ${t ? X(t) : ""} of`;
985
+ if (!Nt.has(r)) return;
986
+ let i = t ? `from ${X(t)}` : "", a = n ? `to ${X(n)}` : "";
987
+ return `${J(r)} ${i} ${a} of`;
988
+ }
989
+ function Gt(e) {
990
+ let t = G(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => G(e).filter((e) => e.localName === "mtd")), r = Math.max(0, ...n.map((e) => e.length)), i = n.map((e, t) => `row ${t + 1}: ${e.map((e) => W(Y(G(e)))).join(", ")}`);
991
+ return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
992
+ }
993
+ function Kt(e) {
994
+ let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = G(e).map((e, t, n) => t < n.length - 1 ? `${X(e)} ${J(r[Math.min(t, r.length - 1)] ?? ",")}` : X(e));
995
+ return [
996
+ J(t),
997
+ ...i,
998
+ J(n)
999
+ ].filter(Boolean).join(" ");
1000
+ }
1001
+ function X(e) {
1002
+ let t = G(e);
1003
+ switch (e.localName) {
1004
+ case "mi": return Rt(U(e));
1005
+ case "mn":
1006
+ case "mtext":
1007
+ case "ms": return U(e);
1008
+ case "mo": return J(U(e));
1009
+ case "mspace":
1010
+ case "mphantom":
1011
+ case "annotation":
1012
+ case "annotation-xml": return "";
1013
+ case "semantics": return t[0] ? X(t[0]) : "";
1014
+ case "mfrac": return Bt(t[0], t[1]);
1015
+ case "msqrt": return Vt(W(Y(t)), "square root", t.length === 1 && K(t[0]));
1016
+ case "mroot": {
1017
+ let e = q(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Lt(e)} root` : `root with index ${t[1] ? X(t[1]) : ""}`;
1018
+ return Vt(t[0] ? X(t[0]) : "", n, K(t[0]));
1019
+ }
1020
+ case "msup": return Ht(t[0] ? X(t[0]) : "", t[1]);
1021
+ case "msub": return Ut(t[0] ? X(t[0]) : "", t[1]);
1022
+ case "msubsup": return (t[0] ? Wt(t[0], t[1], t[2]) : void 0) || Ht(Ut(t[0] ? X(t[0]) : "", t[1]), t[2]);
1023
+ case "munder":
1024
+ case "mover":
1025
+ case "munderover": {
1026
+ let [n, r, i] = t, a = e.localName === "mover" ? void 0 : r, o = e.localName === "munder" ? void 0 : e.localName === "mover" ? r : i, s = n ? Wt(n, a, o) : void 0;
1027
+ if (s) return s;
1028
+ let c = n ? X(n) : "", l = e.localName === "mover" && r ? Ft[U(r)] : void 0;
1029
+ return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
1030
+ c,
1031
+ a ? `with ${X(a)} below` : "",
1032
+ o ? `with ${X(o)} above` : ""
1033
+ ].filter(Boolean).join(" ");
1034
+ }
1035
+ case "mfenced": return Kt(e);
1036
+ case "mtable": return Gt(e);
1037
+ case "mrow":
1038
+ case "math": return zt(t);
1039
+ default: return t.length ? Y(t) : U(e);
1040
+ }
1041
+ }
1042
+ function qt(e) {
1043
+ return W(X(e));
1044
+ }
1045
+ //#endregion
1046
+ //#region src/math-name.ts
1047
+ var Jt = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.article.aside.blockquote.br.dd.div.dl.dt.fieldset.figure.footer.h1.h2.h3.h4.h5.h6.header.hr.li.ol.p.pre.section.table.td.th.tr.ul".split(".")), Yt = (e) => e.replace(/\s+/g, " ").trim();
1048
+ function Xt(e) {
1049
+ return e.getAttribute("aria-hidden") === "true" || e.hidden === !0 || e.style?.display === "none";
1050
+ }
1051
+ function Zt(e) {
1052
+ return e.localName === "math" ? e : e.querySelector("math");
1053
+ }
1054
+ function Z(e, t, n) {
1055
+ if (e.nodeType === 3) return e.textContent ?? "";
1056
+ if (!(e instanceof Element) || Xt(e)) return "";
1057
+ let r = e.localName === "mjx-container" || e.localName === "math" ? Zt(e) : null;
1058
+ if (r) {
1059
+ let e = Yt(t(r) ?? r.textContent ?? "");
1060
+ return e && (n.math = !0), ` ${e} `;
1061
+ }
1062
+ if (e.localName === "mjx-container") return " ";
1063
+ let i = e.getAttribute("aria-label")?.trim();
1064
+ if (i) return ` ${i} `;
1065
+ if (e.localName === "img") return ` ${e.getAttribute("alt") ?? ""} `;
1066
+ let a = [...e.childNodes].map((e) => Z(e, t, n)).join("");
1067
+ return Jt.has(e.localName) ? ` ${a} ` : a;
1068
+ }
1069
+ function Qt(e, t = {}) {
1070
+ let n = t.speak ?? qt, r = { math: !1 }, i = Yt([...e.childNodes].map((e) => Z(e, n, r)).join(""));
1071
+ return r.math && i ? i : void 0;
1072
+ }
1073
+ //#endregion
785
1074
  //#region src/render-math.ts
786
- var vt = "@pie-lib/math-rendering", yt = "@pie-lib/math-rendering@2", bt = "pie-print", xt = 50, St = 1e4, Ct = null;
787
- function wt() {
788
- return !!window[yt]?.opts?.useSingleDollar;
1075
+ var $t = "@pie-lib/math-rendering", en = "@pie-lib/math-rendering@2", tn = "pie-print", nn = 50, rn = 1e4, an = null;
1076
+ function on() {
1077
+ return !!window[en]?.opts?.useSingleDollar;
789
1078
  }
790
- function Tt() {
791
- return Ct ||= gt({ useSingleDollar: wt() }), Ct;
1079
+ function sn() {
1080
+ return an ||= Tt({ useSingleDollar: on() }), an;
792
1081
  }
793
- function Z() {
1082
+ function Q() {
794
1083
  if (typeof window > "u") return null;
795
- let e = window[vt];
1084
+ let e = window[$t];
796
1085
  return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
797
1086
  }
798
- function Et(e) {
1087
+ function cn(e) {
799
1088
  let t = e;
800
1089
  for (; t;) {
801
- if (t instanceof Element && t.localName === bt) return t;
1090
+ if (t instanceof Element && t.localName === tn) return t;
802
1091
  t = t instanceof ShadowRoot ? t.host : t.parentNode;
803
1092
  }
804
1093
  return null;
805
1094
  }
806
- function Q() {
1095
+ function ln() {
807
1096
  let e = window.renderMath;
808
1097
  return typeof e == "function" ? e : null;
809
1098
  }
810
- async function Dt(e) {
811
- let t = Et(e);
1099
+ async function un(e) {
1100
+ let t = cn(e);
812
1101
  if (!t) return null;
813
- let n = Q();
1102
+ let n = ln();
814
1103
  if (n || t.mathRenderingModuleUrlImported !== !0) return n;
815
- let r = Date.now() + St;
1104
+ let r = Date.now() + rn;
816
1105
  for (; Date.now() < r;) {
817
- await new Promise((e) => setTimeout(e, xt));
818
- let e = Q();
1106
+ await new Promise((e) => setTimeout(e, nn));
1107
+ let e = ln();
819
1108
  if (e) return e;
820
1109
  }
821
1110
  return null;
@@ -824,14 +1113,14 @@ var $ = async (e) => {
824
1113
  if (typeof window > "u") return;
825
1114
  let t = typeof e == "string", n;
826
1115
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
827
- let r = Z(), i = r || t ? null : await Dt(n);
828
- return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await Tt()(n), t ? n.innerHTML : void 0;
829
- }, Ot = (e, t) => {
830
- let n = Z()?.wrapMath?.(e, t);
1116
+ let r = Q(), i = r || t ? null : await un(n);
1117
+ return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await sn()(n), t ? n.innerHTML : void 0;
1118
+ }, dn = (e, t) => {
1119
+ let n = Q()?.wrapMath?.(e, t);
831
1120
  if (n != null) return n;
832
1121
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
833
- return `${r}${X(e)}${i}`;
834
- }, kt = (e) => {
1122
+ return `${r}${B(e)}${i}`;
1123
+ }, fn = (e) => {
835
1124
  let t = e.trim();
836
1125
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
837
1126
  unwrapped: t.slice(2, -2).trim(),
@@ -858,6 +1147,6 @@ var $ = async (e) => {
858
1147
  close: "$"
859
1148
  }
860
1149
  } : { unwrapped: t };
861
- }, At = (e) => Z()?.mmlToLatex?.(e) ?? e;
1150
+ }, pn = (e) => Q()?.mmlToLatex?.(e) ?? e;
862
1151
  //#endregion
863
- export { y as MATHJAX_CONFLICT_EVENT, m as NO_ASSET_ROOT_EVENT, v as UNSUPPORTED_PAGE_DOCS_URL, gt as createMathjaxRenderer, _t as getMathjaxCssUrls, At as mmlToLatex, $ as renderMath, kt as unWrapMath, Ot as wrapMath };
1152
+ export { ee as MATHJAX_CONFLICT_EVENT, m as NO_ASSET_ROOT_EVENT, v as UNSUPPORTED_PAGE_DOCS_URL, Tt as createMathjaxRenderer, Et as getMathjaxCssUrls, Qt as mathContentName, pn as mmlToLatex, $ as renderMath, qt as speakMathml, fn as unWrapMath, dn as wrapMath };