@pie-element/shared-math-rendering-mathjax 0.1.4-next.20261007064237 → 0.1.4-next.20261007201108

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, le = "http://www.w3.org/1998/Math/MathML", ue = /^([a-z_][\w.-]*):math$/, de = /^[a-z][a-z0-9-]*$/;
137
+ function fe(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 = ue.exec(t.tagName.toLowerCase())?.[1];
140
+ !n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(pe(t, `${n}:`));
141
141
  }
142
142
  }
143
- function T(e, t) {
143
+ function pe(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 (!de.test(n)) return e;
146
+ let r = e.ownerDocument.createElementNS(le, 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 ? pe(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 me = /* @__PURE__ */ new Set([
157
157
  "updiagonalstrike",
158
158
  "downdiagonalstrike",
159
159
  "verticalstrike",
160
160
  "horizontalstrike"
161
- ]), ue = {
161
+ ]), he = {
162
162
  thin: "0.035em",
163
163
  medium: "0.07em",
164
164
  thick: "0.14em"
165
- }, de = {
165
+ }, ge = {
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
+ }, _e = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ve = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ye = /^(\d+(\.\d*)?|\.\d+)$/, be = /* @__PURE__ */ new Set([
170
170
  "mn",
171
171
  "mo",
172
172
  "mi",
173
173
  "mtext"
174
- ]), ge = /* @__PURE__ */ new Set([
174
+ ]), xe = /* @__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 x(e, t, n = [], r = {}) {
181
+ let i = e.createElementNS(le, 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 S(e, t) {
187
+ let n = x(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 Se(e) {
191
+ let t = x(e.document, "mn");
192
+ return t.textContent = "0", x(e.document, "mphantom", [t]);
193
193
  }
194
- function k(e, t) {
194
+ function C(e, t) {
195
195
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
196
196
  }
197
- function A(e, t) {
197
+ function w(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 T(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 E(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 D(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 (T(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 be.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: E(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 O(e) {
239
+ return (e ?? "").toLowerCase().split(/\s+/).filter((e) => me.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 Ce(e, t) {
242
+ let n = [...e.children].filter((e) => !T(e));
243
+ return n.length <= 1 ? n[0] ?? null : x(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 we(e, t, n) {
246
+ let r = C(e, "location") ?? "n", i = O(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
247
+ content: Ce(e, n),
248
+ location: C(e, "location") ?? r,
249
+ crossout: e.hasAttribute("crossout") ? O(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: E(a.length, n.stackAlign),
259
259
  position: t,
260
- scale: me.test(o) ? o : "0.6"
260
+ scale: ye.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 k(e) {
264
+ let t = C(e, "mslinethickness") ?? "medium", n = he[t] ?? (_e.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
265
+ return `${n} solid ${ve.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, w(e, "length"));
269
269
  return {
270
270
  kind: "line",
271
271
  length: r,
272
- anchor: M(r, n.stackAlign),
272
+ anchor: E(r, n.stackAlign),
273
273
  position: t,
274
- border: be(e)
274
+ border: k(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 + w(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, w(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(we(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(D([...e.children], o, r));
293
293
  break;
294
- default: i.push(N([e], o, r));
294
+ default: i.push(D([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 M(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 N(e) {
305
+ return j(e) + M(e) - 1;
306
306
  }
307
- function Se(e, t, n, r) {
308
- let i = (e) => E(r.document, "mpadded", [t], {
307
+ function Ee(e, t, n, r) {
308
+ let i = (e) => x(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) => x(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 De(e, t, n) {
334
+ let r = x(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 ? x(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 Oe(e, t, n, r, i) {
345
+ let a = e && t.crossout.length ? De(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 = x(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
348
+ return Ee(a ?? Se(i), o, n, i);
349
349
  }
350
- function R(e, t) {
351
- return e.carries[t - F(e)] ?? null;
350
+ function P(e, t) {
351
+ return e.carries[t - j(e)] ?? null;
352
352
  }
353
- function Te(e, t, n, r) {
353
+ function ke(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 = P(s, t), l = n.slice(0, o).some((e) => P(e, t));
357
357
  if (!c && !l) return;
358
358
  let u = c ?? {
359
- content: O(r),
359
+ content: Se(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 = Oe(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 F(e, t) {
367
+ let n = e.filter((e) => M(e) > 0), r = Math.min(0, ...n.map(j)), i = Math.max(r, ...n.map(N)) - 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
+ ke(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 Ae(e, { rows: t }, n) {
396
+ let r = x(n.document, "mtable", t.map((e) => x(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 x(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]) xe.has(t) || r.setAttribute(t, n);
404
+ let i = C(e, "charspacing") ?? "medium", a = C(e, "charalign");
405
+ return r.setAttribute("columnspacing", ge[i] ?? (_e.test(i) ? i : ge.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 je(e) {
408
408
  return {
409
409
  document: e.ownerDocument,
410
- stackAlign: k(e, "stackalign") ?? "decimalpoint",
410
+ stackAlign: C(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 Me(e) {
415
+ let t = je(e), n = [];
416
+ return A([...e.children], 0, 0, t, n), Ae(e, F(n, t), t);
417
417
  }
418
- function H(e, t, n, r, i, a) {
418
+ function I(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 Ne(e, t) {
422
+ let n = S(t, ")");
423
+ return n.setAttribute("minsize", "1.2em"), [x(t.document, "mrow", [e, x(t.document, "mspace", [], { width: "0.2em" })]), x(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 Pe(e) {
431
+ let t = je(e), [n, r, ...i] = [...e.children], a = n && !T(n) ? n : null, o = r && !T(r) ? r : null, s = C(e, "longdivstyle") ?? "lefttop", c = k(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(...D(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, S(t, "/")), p(S(t, "\\"), o);
449
449
  break;
450
450
  case "left)(right":
451
- f(a, D(t, ")")), p(D(t, "("), o);
451
+ f(a, S(t, ")")), p(S(t, "("), o);
452
452
  break;
453
453
  case ":right=right":
454
- p(D(t, ":"), a, D(t, "="), o);
454
+ p(S(t, ":"), a, S(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(...Ne(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 = F(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 + N(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, I(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, I(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
+ Fe(h, g, s, a, o, c, t);
482
482
  break;
483
- default: H(h, g, _(1), v, "top", c);
483
+ default: I(h, g, _(1), v, "top", c);
484
484
  }
485
- return B(e, m, t);
485
+ return Ae(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 Fe(e, t, n, r, i, a, o) {
488
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && x(o.document, "mpadded", [e], {
489
489
  lspace: "0.2em",
490
490
  width: "+0.4em"
491
491
  });
@@ -504,140 +504,419 @@ 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 Ie(e) {
508
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Me(t) : Pe(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 Le = "PIE-MJX-explorer-styles", L = "var(--pie-text, black)", Re = "var(--pie-background, #ffffff)", ze = "var(--pie-border-dark, #66686A)", R = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", z = `color-mix(in srgb, ${R} 15%, transparent)`, Be = `
513
513
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
514
- color: ${U} !important;
515
- fill: ${U} !important;
514
+ color: ${L} !important;
515
+ fill: ${L} !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: ${z} !important;
519
519
  }
520
520
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
521
- fill: ${G} !important;
521
+ fill: ${z} !important;
522
522
  }
523
523
  :root mjx-container .mjx-selected {
524
- outline: 2px solid ${W} !important;
524
+ outline: 2px solid ${R} !important;
525
525
  }
526
526
  :root mjx-container [data-sre-highlight-2] {
527
- color: ${U} !important;
527
+ color: ${L} !important;
528
528
  background-color: transparent !important;
529
- fill: ${U} !important;
530
- outline: 2px dashed ${W} !important;
529
+ fill: ${L} !important;
530
+ outline: 2px dashed ${R} !important;
531
531
  }
532
532
  :root mjx-container rect[data-sre-highlight-2] {
533
533
  fill: transparent !important;
534
- stroke: ${W} !important;
534
+ stroke: ${R} !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: ${L} !important;
540
+ background-color: ${Re} !important;
541
+ border-color: ${ze} !important;
542
542
  }
543
543
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
544
- color: ${U} !important;
545
- background-color: ${G} !important;
544
+ color: ${L} !important;
545
+ background-color: ${z} !important;
546
546
  }
547
547
  `;
548
- function Fe(e = document) {
548
+ function Ve(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 = Le, t.textContent = Be, e.head.appendChild(t);
552
+ }
553
+ //#endregion
554
+ //#region src/math-speech.ts
555
+ var He = /[⁡-⁤]/g, Ue = {
556
+ "+": "positive",
557
+ "-": "negative",
558
+ "−": "negative",
559
+ "±": "plus or minus",
560
+ "∓": "minus or plus"
561
+ }, We = {
562
+ "(": "open parenthesis",
563
+ "[": "open bracket",
564
+ "{": "open brace",
565
+ "⟨": "open angle bracket",
566
+ "⌊": "open floor",
567
+ "⌈": "open ceiling"
568
+ }, Ge = {
569
+ ")": "close parenthesis",
570
+ "]": "close bracket",
571
+ "}": "close brace",
572
+ "⟩": "close angle bracket",
573
+ "⌋": "close floor",
574
+ "⌉": "close ceiling"
575
+ }, B = {
576
+ "!": "factorial",
577
+ "%": "percent",
578
+ "°": "degrees",
579
+ "′": "prime",
580
+ "″": "double prime"
581
+ }, Ke = {
582
+ "+": "plus",
583
+ "-": "minus",
584
+ "−": "minus",
585
+ "±": "plus or minus",
586
+ "∓": "minus or plus",
587
+ "×": "times",
588
+ "⋅": "times",
589
+ "·": "times",
590
+ "*": "times",
591
+ "÷": "divided by",
592
+ "/": "divided by",
593
+ "=": "equals",
594
+ "≠": "does not equal",
595
+ "<": "is less than",
596
+ ">": "is greater than",
597
+ "≤": "is less than or equal to",
598
+ "≥": "is greater than or equal to",
599
+ "≈": "is approximately equal to",
600
+ "≡": "is equivalent to",
601
+ "∝": "is proportional to",
602
+ "∈": "is an element of",
603
+ "∉": "is not an element of",
604
+ "⊂": "is a subset of",
605
+ "⊆": "is a subset of or equal to",
606
+ "∪": "union",
607
+ "∩": "intersection",
608
+ "→": "right arrow",
609
+ "←": "left arrow",
610
+ "⇒": "implies",
611
+ "⇔": "if and only if",
612
+ "∑": "sum",
613
+ "∏": "product",
614
+ "∫": "integral",
615
+ "∞": "infinity",
616
+ "∠": "angle",
617
+ "⊥": "is perpendicular to",
618
+ "∥": "is parallel to",
619
+ "∴": "therefore",
620
+ ",": "comma",
621
+ ";": "semicolon",
622
+ ":": "colon",
623
+ "|": "vertical bar",
624
+ "‖": "double vertical bar",
625
+ ...We,
626
+ ...Ge,
627
+ ...B
628
+ }, qe = /* @__PURE__ */ new Set(["|", "‖"]), Je = /* @__PURE__ */ new Set([
629
+ "∑",
630
+ "∏",
631
+ "∫",
632
+ "∪",
633
+ "∩"
634
+ ]), Ye = {
635
+ α: "alpha",
636
+ β: "beta",
637
+ γ: "gamma",
638
+ δ: "delta",
639
+ ε: "epsilon",
640
+ θ: "theta",
641
+ λ: "lambda",
642
+ μ: "mu",
643
+ π: "pi",
644
+ ρ: "rho",
645
+ σ: "sigma",
646
+ τ: "tau",
647
+ φ: "phi",
648
+ ω: "omega",
649
+ Δ: "capital delta",
650
+ Σ: "capital sigma",
651
+ Ω: "capital omega",
652
+ "∞": "infinity",
653
+ sin: "sine",
654
+ cos: "cosine",
655
+ tan: "tangent",
656
+ sec: "secant",
657
+ csc: "cosecant",
658
+ cot: "cotangent",
659
+ ln: "natural log",
660
+ lim: "limit"
661
+ }, Xe = {
662
+ "¯": "bar",
663
+ "‾": "bar",
664
+ "―": "bar",
665
+ "^": "hat",
666
+ ˆ: "hat",
667
+ "~": "tilde",
668
+ "˜": "tilde",
669
+ "→": "vector",
670
+ "⃗": "vector",
671
+ "˙": "dot"
672
+ }, V = (e) => (e.textContent ?? "").replace(He, "").replace(/\s+/g, " ").trim(), H = (e) => e.replace(/\s+/g, " ").trim(), U = (e) => [...e.children];
673
+ function W(e) {
674
+ return !e || [
675
+ "mn",
676
+ "mi",
677
+ "mtext",
678
+ "mo"
679
+ ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? W(e.children[0]) : !1;
680
+ }
681
+ function Ze(e) {
682
+ let t = e ? V(e) : "";
683
+ return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
684
+ }
685
+ function Qe(e) {
686
+ return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
687
+ 1: "st",
688
+ 2: "nd",
689
+ 3: "rd"
690
+ }[e % 10] ?? "th"}`;
691
+ }
692
+ function $e(e) {
693
+ return Ye[e] ?? e;
694
+ }
695
+ function G(e) {
696
+ return Ke[e] ?? e;
697
+ }
698
+ function K(e) {
699
+ let t = [], n = !1;
700
+ for (let r of e) {
701
+ if (r.localName !== "mo") {
702
+ t.push(q(r)), n = !0;
703
+ continue;
704
+ }
705
+ let e = V(r);
706
+ e && (!n && Ue[e] ? t.push(Ue[e]) : e in B ? t.push(B[e]) : (t.push(G(e)), n = e in Ge || qe.has(e) && n));
707
+ }
708
+ return t.filter(Boolean).join(" ");
709
+ }
710
+ function et(e) {
711
+ let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(V(e)), a = n.slice(0, -1);
712
+ if (a.length && i(t) && i(r) && V(t) === V(r) && !a.some(i)) {
713
+ let e = H(K(a));
714
+ return V(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
715
+ }
716
+ return K(e);
717
+ }
718
+ function tt(e, t) {
719
+ let n = e ? q(e) : "", r = t ? q(t) : "";
720
+ return W(e) && W(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
721
+ }
722
+ function nt(e, t, n) {
723
+ return n ? `${t} of ${e}` : `${t} of ${e} end root`;
724
+ }
725
+ function rt(e, t) {
726
+ let n = t ? V(t) : "";
727
+ if (t && W(t)) {
728
+ if (n === "2") return `${e} squared`;
729
+ if (n === "3") return `${e} cubed`;
730
+ if (n in B) return `${e} ${B[n]}`;
731
+ }
732
+ let r = t ? q(t) : "";
733
+ return W(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
734
+ }
735
+ function it(e, t) {
736
+ let n = t ? q(t) : "";
737
+ return W(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
738
+ }
739
+ function at(e, t, n) {
740
+ let r = V(e);
741
+ if (r === "lim") return `limit as ${t ? q(t) : ""} of`;
742
+ if (!Je.has(r)) return;
743
+ let i = t ? `from ${q(t)}` : "", a = n ? `to ${q(n)}` : "";
744
+ return `${G(r)} ${i} ${a} of`;
745
+ }
746
+ function ot(e) {
747
+ let t = U(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => U(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) => H(K(U(e)))).join(", ")}`);
748
+ return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
749
+ }
750
+ function st(e) {
751
+ let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = U(e).map((e, t, n) => t < n.length - 1 ? `${q(e)} ${G(r[Math.min(t, r.length - 1)] ?? ",")}` : q(e));
752
+ return [
753
+ G(t),
754
+ ...i,
755
+ G(n)
756
+ ].filter(Boolean).join(" ");
757
+ }
758
+ function q(e) {
759
+ let t = U(e);
760
+ switch (e.localName) {
761
+ case "mi": return $e(V(e));
762
+ case "mn":
763
+ case "mtext":
764
+ case "ms": return V(e);
765
+ case "mo": return G(V(e));
766
+ case "mspace":
767
+ case "mphantom":
768
+ case "annotation":
769
+ case "annotation-xml": return "";
770
+ case "semantics": return t[0] ? q(t[0]) : "";
771
+ case "mfrac": return tt(t[0], t[1]);
772
+ case "msqrt": return nt(H(K(t)), "square root", t.length === 1 && W(t[0]));
773
+ case "mroot": {
774
+ let e = Ze(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Qe(e)} root` : `root with index ${t[1] ? q(t[1]) : ""}`;
775
+ return nt(t[0] ? q(t[0]) : "", n, W(t[0]));
776
+ }
777
+ case "msup": return rt(t[0] ? q(t[0]) : "", t[1]);
778
+ case "msub": return it(t[0] ? q(t[0]) : "", t[1]);
779
+ case "msubsup": return (t[0] ? at(t[0], t[1], t[2]) : void 0) || rt(it(t[0] ? q(t[0]) : "", t[1]), t[2]);
780
+ case "munder":
781
+ case "mover":
782
+ case "munderover": {
783
+ 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 ? at(n, a, o) : void 0;
784
+ if (s) return s;
785
+ let c = n ? q(n) : "", l = e.localName === "mover" && r ? Xe[V(r)] : void 0;
786
+ return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
787
+ c,
788
+ a ? `with ${q(a)} below` : "",
789
+ o ? `with ${q(o)} above` : ""
790
+ ].filter(Boolean).join(" ");
791
+ }
792
+ case "mfenced": return st(e);
793
+ case "mtable": return ot(e);
794
+ case "mrow":
795
+ case "math": return et(t);
796
+ default: return t.length ? K(t) : V(e);
797
+ }
798
+ }
799
+ function ct(e) {
800
+ return H(q(e));
801
+ }
802
+ //#endregion
803
+ //#region src/math-name.ts
804
+ var lt = [
805
+ "a[href]",
806
+ "button",
807
+ "label",
808
+ "summary",
809
+ ...[
810
+ "button",
811
+ "checkbox",
812
+ "combobox",
813
+ "link",
814
+ "menuitem",
815
+ "menuitemcheckbox",
816
+ "menuitemradio",
817
+ "option",
818
+ "radio",
819
+ "switch",
820
+ "tab",
821
+ "treeitem"
822
+ ].map((e) => `[role="${e}"]`)
823
+ ].join(", ");
824
+ function ut(e) {
825
+ if (e.hasAttribute("aria-label") || !e.closest(lt)) return;
826
+ let t = e.querySelector("math"), n = t ? ct(t) : "";
827
+ n && e.setAttribute("aria-label", n);
828
+ }
829
+ function J(e) {
830
+ for (let t of e.querySelectorAll("mjx-container")) ut(t);
552
831
  }
553
832
  //#endregion
554
833
  //#region src/speech-worker.ts
555
- var K = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
556
- function Ie() {
834
+ var dt = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
835
+ function ft() {
557
836
  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}`));
837
+ e[dt] || (e[dt] = !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
838
  }
560
- function Le(e) {
839
+ function pt(e) {
561
840
  let t = e.webworker;
562
841
  if (!t || t.ready) return;
563
842
  e.options ??= {};
564
843
  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();
844
+ n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), ft();
566
845
  }
567
- function Re(e) {
846
+ function mt(e) {
568
847
  let t = e?.adaptor, n = t?.createWorker;
569
848
  !e || !t || !n || (t.createWorker = async (r, i) => {
570
849
  let a = await n.call(t, r, i);
571
- return a.addEventListener("error", () => Le(e), { once: !0 }), a;
850
+ return a.addEventListener("error", () => pt(e), { once: !0 }), a;
572
851
  });
573
852
  }
574
853
  `${i}`;
575
854
  //#endregion
576
855
  //#region src/adapter.ts
577
- var ze = {
856
+ var ht = {
578
857
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
579
858
  overarc: "\\overparen",
580
859
  napprox: "\\not\\approx",
581
860
  longdiv: "\\enclose{longdiv}",
582
861
  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 = [
862
+ }, gt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", _t = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, vt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, yt = /\\embed\{newLine\}\[\]/g, bt = [
584
863
  ["$$", "$$"],
585
864
  ["$", "$"],
586
865
  ["\\[", "\\]"],
587
866
  ["\\(", "\\)"]
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]": {
867
+ ], xt = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), St = "MJX-CHTML-styles", Ct = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", wt = { "mjx-container[overflow=\"linebreak\"][display]": {
589
868
  overflow: "auto clip",
590
869
  "min-width": "initial !important"
591
- } }, Je = 200, Ye = 201;
592
- function Y(e) {
870
+ } }, Tt = 200, Et = 201, Dt = 202;
871
+ function X(e) {
593
872
  let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
594
873
  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
874
  }
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);
875
+ function Ot(e) {
876
+ for (let [t, n] of bt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
598
877
  return e;
599
878
  }
600
- function Xe(e) {
601
- return X(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
879
+ function kt(e) {
880
+ return Ot(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
602
881
  }
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);
882
+ var At = "mathjax_ignore", jt = "mathjax_process";
883
+ function Mt(e, t) {
884
+ let n = e.closest(`.${At}, .${jt}`);
885
+ return n !== null && t.contains(n) && !n.classList.contains(jt);
607
886
  }
608
- function et(e) {
887
+ function Nt(e) {
609
888
  for (let t of e.querySelectorAll("[data-latex]")) {
610
- if (t.dataset.mathHandled || t.closest("mjx-container") || $e(t, e)) continue;
889
+ if (t.dataset.mathHandled || t.closest("mjx-container") || Mt(t, e)) continue;
611
890
  let n = t.textContent;
612
- n && (t.textContent = `\\(${Xe(n)}\\)`.replace(Ue, "\\newline "), t.dataset.mathHandled = "true");
891
+ n && (t.textContent = `\\(${kt(n)}\\)`.replace(yt, "\\newline "), t.dataset.mathHandled = "true");
613
892
  }
614
893
  }
615
- function tt(e) {
894
+ function Pt(e) {
616
895
  for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
617
896
  }
618
- function nt(e, t) {
897
+ function Ft(e, t) {
619
898
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
620
- return (t ? He : Ve).test(e.textContent ?? "");
899
+ return (t ? vt : _t).test(e.textContent ?? "");
621
900
  }
622
- function rt(e) {
901
+ function It(e) {
623
902
  return new Promise((t, n) => {
624
903
  let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = e, s = d(e, import.meta.url), c = {
625
904
  loader: {
626
905
  load: i ? ["a11y/assistive-mml"] : [],
627
906
  failed: (e) => n(e),
628
907
  "output/svg": { ready: (e) => {
629
- let t = S();
630
- return it(t) && at(t), e;
908
+ let t = y();
909
+ return Lt(t) && Rt(t), e;
631
910
  } }
632
911
  },
633
912
  startup: {
634
913
  typeset: !1,
635
914
  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);
915
+ let e = y(), r = e?.startup, i = Lt(e);
916
+ i && (Rt(e), zt(e, s.speechLocales), f(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (Bt(r?.document), Vt(r?.document), r?.document?.addStyles?.(wt), mt(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
638
917
  }
639
918
  },
640
- tex: { macros: { ...ze } },
919
+ tex: { macros: { ...ht } },
641
920
  output: { displayOverflow: "linebreak" },
642
921
  options: {
643
922
  enableMenu: i,
@@ -649,9 +928,9 @@ function rt(e) {
649
928
  a11y: { inTabOrder: !1 }
650
929
  }
651
930
  };
652
- r && c.tex && (console.warn(Be), c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), a || (c.chtml = { fontURL: "" });
931
+ r && c.tex && (console.warn(gt), c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), a || (c.chtml = { fontURL: "" });
653
932
  let l = p(s.speechLocales);
654
- l && c.options && (c.options.sre = { locale: l }), ne(c, {
933
+ l && c.options && (c.options.sre = { locale: l }), ae(c, {
655
934
  ...s,
656
935
  srcUrl: o
657
936
  }).then((e) => {
@@ -659,163 +938,172 @@ function rt(e) {
659
938
  }, n);
660
939
  });
661
940
  }
662
- function it(e) {
941
+ function Lt(e) {
663
942
  return !!e?.version?.startsWith("4.");
664
943
  }
665
- function at(e) {
944
+ function Rt(e) {
666
945
  let t = e?._?.output, n = t?.chtml_ts?.CHTML;
667
- n && (n.STYLESHEETID = C);
946
+ n && (n.STYLESHEETID = b);
668
947
  let r = t?.svg_ts?.SVG;
669
- r && (r.STYLESHEETID = Ke);
948
+ r && (r.STYLESHEETID = Ct);
670
949
  }
671
- function ot(e, t) {
950
+ function zt(e, t) {
672
951
  let n = e?._?.ui?.menu?.Menu?.Menu;
673
952
  if (n) {
674
- n.MENU_STORAGE = J;
953
+ n.MENU_STORAGE = Y;
675
954
  try {
676
- let e = localStorage.getItem(J);
955
+ let e = localStorage.getItem(Y);
677
956
  if (!e) return;
678
957
  let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
679
958
  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);
959
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(Y, JSON.stringify(i)) : localStorage.removeItem(Y);
681
960
  } catch {}
682
961
  }
683
962
  }
684
- function st(e) {
963
+ function Bt(e) {
685
964
  if (!e) return;
686
965
  let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
687
966
  let n = e.typesetRoot;
688
- !n || t.has(n) || (Y(n), t.add(n));
967
+ !n || t.has(n) || (X(n), t.add(n));
689
968
  };
690
- e.addRenderAction?.("pie-strip-latex", Ye, (e) => {
969
+ e.addRenderAction?.("pie-strip-latex", Et, (e) => {
691
970
  for (let t of e.math ?? []) n(t);
692
971
  return !1;
693
972
  }, (e) => {
694
973
  let t = e.typesetRoot;
695
- return t && Y(t), !1;
974
+ return t && X(t), !1;
696
975
  });
697
976
  let r = e.outputJax?.chtmlStyles;
698
- r?.id === Ge && (r.id = C), ut();
977
+ r?.id === St && (r.id = b), Ut();
699
978
  }
700
- function ct(e) {
701
- return e instanceof HTMLStyleElement && ie.includes(e.id);
979
+ function Vt(e) {
980
+ let t = (e) => {
981
+ e.typesetRoot && ut(e.typesetRoot);
982
+ };
983
+ e?.addRenderAction?.("pie-name-math", Dt, (e) => {
984
+ for (let n of e.math ?? []) t(n);
985
+ return !1;
986
+ }, (e) => (t(e), !1));
702
987
  }
703
- function lt(e) {
704
- x("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
988
+ function Z(e) {
989
+ return e instanceof HTMLStyleElement && se.includes(e.id);
705
990
  }
706
- function ut() {
707
- let e = document.head, t = [...e.children].find(ct);
991
+ function Ht(e) {
992
+ ne("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
993
+ }
994
+ function Ut() {
995
+ let e = document.head, t = [...e.children].find(Z);
708
996
  if (t) {
709
- lt(t);
997
+ Ht(t);
710
998
  return;
711
999
  }
712
1000
  let n = new MutationObserver((e) => {
713
1001
  for (let t of e) {
714
- let e = [...t.addedNodes].find(ct);
1002
+ let e = [...t.addedNodes].find(Z);
715
1003
  if (e) {
716
- lt(e), n.disconnect();
1004
+ Ht(e), n.disconnect();
717
1005
  return;
718
1006
  }
719
1007
  }
720
1008
  });
721
1009
  n.observe(e, { childList: !0 });
722
1010
  }
723
- function dt(e) {
1011
+ function Wt(e) {
724
1012
  let t = e?.math;
725
1013
  if (!t?.remove) return;
726
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= Je && e.typesetRoot?.isConnected === !1);
1014
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= Tt && e.typesetRoot?.isConnected === !1);
727
1015
  if (n.length !== 0) {
728
1016
  for (let e of [...n].reverse()) e.clear?.();
729
1017
  t.remove(...n);
730
1018
  }
731
1019
  }
732
- function ft(e) {
1020
+ function Gt(e) {
733
1021
  return new Promise((t, n) => {
734
1022
  let r = e.startup ?? {};
735
1023
  e.startup = r;
736
1024
  let i = r.ready;
737
1025
  r.ready = () => {
738
- let e = S()?.startup;
1026
+ let e = y()?.startup;
739
1027
  i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
740
1028
  };
741
1029
  });
742
1030
  }
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);
1031
+ function Kt(e) {
1032
+ let t = y();
1033
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Gt(t) : It(e);
746
1034
  }
747
- function mt(e) {
748
- return pt(e).then(() => {
749
- let e = S();
1035
+ function qt(e) {
1036
+ return Kt(e).then(() => {
1037
+ let e = y();
750
1038
  e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
751
1039
  });
752
1040
  }
753
- function ht(e) {
754
- let t = re, n = t[q];
755
- return n || (n = mt(e), t[q] = n), n;
1041
+ function Jt(e) {
1042
+ let t = oe, n = t[xt];
1043
+ return n || (n = qt(e), t[xt] = n), n;
756
1044
  }
757
- function gt(e = {}) {
1045
+ function Yt(e = {}) {
758
1046
  let t = e.useSingleDollar ?? !1;
759
1047
  return async (n) => {
760
1048
  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)) {
1049
+ let r = ce();
1050
+ r && ne("mathjax-3-global", `window.MathJax is MathJax ${r}`), Nt(n), fe(n), Pt(n), Ie(n);
1051
+ let i = Jt(e);
1052
+ if (!Ft(n, t)) {
765
1053
  i.catch(() => {});
766
1054
  return;
767
1055
  }
768
1056
  await i;
769
- let a = S();
1057
+ let a = y();
770
1058
  if (await a?.startup?.promise, typeof a?.typesetPromise == "function") {
771
- Fe(), dt(a.startup?.document);
1059
+ Ve(), Wt(a.startup?.document);
772
1060
  try {
773
1061
  await a.typesetPromise([n]);
774
1062
  } catch (e) {
775
1063
  throw a.typesetClear?.([n]), e;
776
1064
  }
777
- Y(n);
1065
+ X(n), J(n);
778
1066
  }
779
1067
  };
780
1068
  }
781
- function _t() {
1069
+ function Xt() {
782
1070
  return [];
783
1071
  }
784
1072
  //#endregion
785
1073
  //#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;
1074
+ var Zt = "@pie-lib/math-rendering", Qt = "@pie-lib/math-rendering@2", $t = "pie-print", en = 50, tn = 1e4, nn = null;
1075
+ function rn() {
1076
+ return !!window[Qt]?.opts?.useSingleDollar;
789
1077
  }
790
- function Tt() {
791
- return Ct ||= gt({ useSingleDollar: wt() }), Ct;
1078
+ function an() {
1079
+ return nn ||= Yt({ useSingleDollar: rn() }), nn;
792
1080
  }
793
- function Z() {
1081
+ function Q() {
794
1082
  if (typeof window > "u") return null;
795
- let e = window[vt];
1083
+ let e = window[Zt];
796
1084
  return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
797
1085
  }
798
- function Et(e) {
1086
+ function on(e) {
799
1087
  let t = e;
800
1088
  for (; t;) {
801
- if (t instanceof Element && t.localName === bt) return t;
1089
+ if (t instanceof Element && t.localName === $t) return t;
802
1090
  t = t instanceof ShadowRoot ? t.host : t.parentNode;
803
1091
  }
804
1092
  return null;
805
1093
  }
806
- function Q() {
1094
+ function sn() {
807
1095
  let e = window.renderMath;
808
1096
  return typeof e == "function" ? e : null;
809
1097
  }
810
- async function Dt(e) {
811
- let t = Et(e);
1098
+ async function cn(e) {
1099
+ let t = on(e);
812
1100
  if (!t) return null;
813
- let n = Q();
1101
+ let n = sn();
814
1102
  if (n || t.mathRenderingModuleUrlImported !== !0) return n;
815
- let r = Date.now() + St;
1103
+ let r = Date.now() + tn;
816
1104
  for (; Date.now() < r;) {
817
- await new Promise((e) => setTimeout(e, xt));
818
- let e = Q();
1105
+ await new Promise((e) => setTimeout(e, en));
1106
+ let e = sn();
819
1107
  if (e) return e;
820
1108
  }
821
1109
  return null;
@@ -824,14 +1112,14 @@ var $ = async (e) => {
824
1112
  if (typeof window > "u") return;
825
1113
  let t = typeof e == "string", n;
826
1114
  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);
1115
+ let r = Q(), i = r || t ? null : await cn(n);
1116
+ return r ? (await r.renderMath?.(n), J(n)) : i && i !== $ ? (await i(n), J(n)) : await an()(n), t ? n.innerHTML : void 0;
1117
+ }, ln = (e, t) => {
1118
+ let n = Q()?.wrapMath?.(e, t);
831
1119
  if (n != null) return n;
832
1120
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
833
- return `${r}${X(e)}${i}`;
834
- }, kt = (e) => {
1121
+ return `${r}${Ot(e)}${i}`;
1122
+ }, un = (e) => {
835
1123
  let t = e.trim();
836
1124
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
837
1125
  unwrapped: t.slice(2, -2).trim(),
@@ -858,6 +1146,6 @@ var $ = async (e) => {
858
1146
  close: "$"
859
1147
  }
860
1148
  } : { unwrapped: t };
861
- }, At = (e) => Z()?.mmlToLatex?.(e) ?? e;
1149
+ }, dn = (e) => Q()?.mmlToLatex?.(e) ?? e;
862
1150
  //#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 };
1151
+ export { ee as MATHJAX_CONFLICT_EVENT, m as NO_ASSET_ROOT_EVENT, v as UNSUPPORTED_PAGE_DOCS_URL, Yt as createMathjaxRenderer, Xt as getMathjaxCssUrls, dn as mmlToLatex, $ as renderMath, ct as speakMathml, un as unWrapMath, ln as wrapMath };