@pie-element/shared-math-rendering-mathjax 0.1.4-next.20261007175429 → 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.
@@ -44,46 +44,46 @@ var ee = /* @__PURE__ */ new Set([
44
44
  thin: "0.035em",
45
45
  medium: "0.07em",
46
46
  thick: "0.14em"
47
- }, b = {
47
+ }, ne = {
48
48
  tight: "0em",
49
49
  medium: "0.1em",
50
50
  loose: "0.2em"
51
- }, ne = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, re = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ie = /^(\d+(\.\d*)?|\.\d+)$/, ae = /* @__PURE__ */ new Set([
51
+ }, re = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ie = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ae = /^(\d+(\.\d*)?|\.\d+)$/, oe = /* @__PURE__ */ new Set([
52
52
  "mn",
53
53
  "mo",
54
54
  "mi",
55
55
  "mtext"
56
- ]), oe = /* @__PURE__ */ new Set([
56
+ ]), se = /* @__PURE__ */ new Set([
57
57
  "stackalign",
58
58
  "charalign",
59
59
  "charspacing",
60
60
  "longdivstyle"
61
61
  ]);
62
- function x(e, t, n = [], r = {}) {
62
+ function b(e, t, n = [], r = {}) {
63
63
  let i = e.createElementNS(h, t);
64
64
  for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
65
65
  for (let e of n) e && i.appendChild(e);
66
66
  return i;
67
67
  }
68
- function S(e, t) {
69
- let n = x(e.document, "mo");
68
+ function x(e, t) {
69
+ let n = b(e.document, "mo");
70
70
  return n.textContent = t, n;
71
71
  }
72
- function C(e) {
73
- let t = x(e.document, "mn");
74
- return t.textContent = "0", x(e.document, "mphantom", [t]);
72
+ function S(e) {
73
+ let t = b(e.document, "mn");
74
+ return t.textContent = "0", b(e.document, "mphantom", [t]);
75
75
  }
76
- function w(e, t) {
76
+ function C(e, t) {
77
77
  return e.getAttribute(t)?.trim().toLowerCase() || void 0;
78
78
  }
79
- function T(e, t) {
79
+ function w(e, t) {
80
80
  let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
81
81
  return Number.isFinite(n) ? n : 0;
82
82
  }
83
- function E(e) {
83
+ function T(e) {
84
84
  return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
85
85
  }
86
- function D(e, t, n = e) {
86
+ function E(e, t, n = e) {
87
87
  switch (t) {
88
88
  case "left": return 0;
89
89
  case "center": return Math.floor(e / 2);
@@ -91,14 +91,14 @@ function D(e, t, n = e) {
91
91
  default: return n;
92
92
  }
93
93
  }
94
- function O(e, t, n) {
94
+ function D(e, t, n) {
95
95
  let r = [], i, a, o = (e, t) => {
96
96
  let s = (e) => t.reduceRight((e, t) => {
97
97
  let n = t.cloneNode(!1);
98
98
  return n.appendChild(e), n;
99
99
  }, e);
100
100
  if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
101
- else if (E(e)) r.push(null);
101
+ else if (T(e)) r.push(null);
102
102
  else if (e.localName === "mn" && e.children.length === 0) {
103
103
  let t = [...(e.textContent ?? "").trim()];
104
104
  for (let a of t) {
@@ -107,28 +107,28 @@ function O(e, t, n) {
107
107
  t.textContent = a, r.push(s(t));
108
108
  }
109
109
  t.length && (a ??= r.length);
110
- } else ae.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
110
+ } else oe.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
111
111
  };
112
112
  for (let t of e) o(t, []);
113
113
  return {
114
114
  kind: "digits",
115
115
  cells: r,
116
- anchor: D(r.length, n.stackAlign, i ?? a),
116
+ anchor: E(r.length, n.stackAlign, i ?? a),
117
117
  position: t
118
118
  };
119
119
  }
120
- function se(e) {
120
+ function ce(e) {
121
121
  return (e ?? "").toLowerCase().split(/\s+/).filter((e) => ee.has(e));
122
122
  }
123
- function ce(e, t) {
124
- let n = [...e.children].filter((e) => !E(e));
125
- return n.length <= 1 ? n[0] ?? null : x(t.document, "mrow", n);
123
+ function le(e, t) {
124
+ let n = [...e.children].filter((e) => !T(e));
125
+ return n.length <= 1 ? n[0] ?? null : b(t.document, "mrow", n);
126
126
  }
127
- function le(e, t, n) {
128
- let r = w(e, "location") ?? "n", i = se(e.getAttribute("crossout")), a = [...e.children].map((e) => E(e) ? null : e.localName === "mscarry" ? {
129
- content: ce(e, n),
130
- location: w(e, "location") ?? r,
131
- crossout: e.hasAttribute("crossout") ? se(e.getAttribute("crossout")) : i
127
+ function ue(e, t, n) {
128
+ let r = C(e, "location") ?? "n", i = ce(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
129
+ content: le(e, n),
130
+ location: C(e, "location") ?? r,
131
+ crossout: e.hasAttribute("crossout") ? ce(e.getAttribute("crossout")) : i
132
132
  } : {
133
133
  content: e,
134
134
  location: r,
@@ -137,60 +137,60 @@ function le(e, t, n) {
137
137
  return {
138
138
  kind: "carries",
139
139
  carries: a,
140
- anchor: D(a.length, n.stackAlign),
140
+ anchor: E(a.length, n.stackAlign),
141
141
  position: t,
142
- scale: ie.test(o) ? o : "0.6"
142
+ scale: ae.test(o) ? o : "0.6"
143
143
  };
144
144
  }
145
- function ue(e) {
146
- let t = w(e, "mslinethickness") ?? "medium", n = te[t] ?? (ne.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
147
- return `${n} solid ${re.test(r) ? r : "currentColor"}`;
145
+ function de(e) {
146
+ let t = C(e, "mslinethickness") ?? "medium", n = te[t] ?? (re.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
147
+ return `${n} solid ${ie.test(r) ? r : "currentColor"}`;
148
148
  }
149
- function de(e, t, n) {
150
- let r = Math.max(0, T(e, "length"));
149
+ function fe(e, t, n) {
150
+ let r = Math.max(0, w(e, "length"));
151
151
  return {
152
152
  kind: "line",
153
153
  length: r,
154
- anchor: D(r, n.stackAlign),
154
+ anchor: E(r, n.stackAlign),
155
155
  position: t,
156
- border: ue(e)
156
+ border: de(e)
157
157
  };
158
158
  }
159
- function k(e, t, n, r, i) {
159
+ function O(e, t, n, r, i) {
160
160
  e.forEach((e, a) => {
161
- let o = t + a * n + T(e, "position");
161
+ let o = t + a * n + w(e, "position");
162
162
  switch (e.localName) {
163
163
  case "msgroup":
164
- k([...e.children], o, T(e, "shift"), r, i);
164
+ O([...e.children], o, w(e, "shift"), r, i);
165
165
  break;
166
166
  case "msline":
167
- i.push(de(e, o, r));
167
+ i.push(fe(e, o, r));
168
168
  break;
169
169
  case "mscarries":
170
- i.push(le(e, o, r));
170
+ i.push(ue(e, o, r));
171
171
  break;
172
172
  case "msrow":
173
173
  case "mrow":
174
- i.push(O([...e.children], o, r));
174
+ i.push(D([...e.children], o, r));
175
175
  break;
176
- default: i.push(O([e], o, r));
176
+ default: i.push(D([e], o, r));
177
177
  }
178
178
  });
179
179
  }
180
- function A(e) {
180
+ function k(e) {
181
181
  return -e.anchor - e.position;
182
182
  }
183
- function fe(e) {
183
+ function pe(e) {
184
184
  return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
185
185
  }
186
- function pe(e) {
187
- return A(e) + fe(e) - 1;
186
+ function me(e) {
187
+ return k(e) + pe(e) - 1;
188
188
  }
189
- function me(e, t, n, r) {
190
- let i = (e) => x(r.document, "mpadded", [t], {
189
+ function he(e, t, n, r) {
190
+ let i = (e) => b(r.document, "mpadded", [t], {
191
191
  width: "0",
192
192
  ...e ? { lspace: e } : {}
193
- }), a = (e, t) => x(r.document, e, t);
193
+ }), a = (e, t) => b(r.document, e, t);
194
194
  switch (n) {
195
195
  case "s": return a("munder", [e, i("-0.5width")]);
196
196
  case "ne": return a("msup", [e, i()]);
@@ -212,49 +212,49 @@ function me(e, t, n, r) {
212
212
  default: return a("mover", [e, i("-0.5width")]);
213
213
  }
214
214
  }
215
- function he(e, t, n) {
216
- let r = x(n.document, "menclose", [e], {
215
+ function ge(e, t, n) {
216
+ let r = b(n.document, "menclose", [e], {
217
217
  notation: t.join(" "),
218
218
  "data-padding": "0.1em",
219
219
  "data-thickness": "0.067em"
220
220
  }), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
221
- return i ? x(n.document, "mpadded", [r], {
221
+ return i ? b(n.document, "mpadded", [r], {
222
222
  lspace: `-${i}em`,
223
223
  width: `-${2 * i}em`
224
224
  }) : r;
225
225
  }
226
- function ge(e, t, n, r, i) {
227
- let a = e && t.crossout.length ? he(e, t.crossout, i) : e;
226
+ function _e(e, t, n, r, i) {
227
+ let a = e && t.crossout.length ? ge(e, t.crossout, i) : e;
228
228
  if (!t.content) return a;
229
- let o = x(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
230
- return me(a ?? C(i), o, n, i);
229
+ let o = b(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
230
+ return he(a ?? S(i), o, n, i);
231
231
  }
232
- function j(e, t) {
233
- return e.carries[t - A(e)] ?? null;
232
+ function A(e, t) {
233
+ return e.carries[t - k(e)] ?? null;
234
234
  }
235
- function _e(e, t, n, r) {
235
+ function ve(e, t, n, r) {
236
236
  let i = e.content;
237
237
  n.forEach((e, a) => {
238
- let o = n.length - 1 - a, s = n[o], c = j(s, t), l = n.slice(0, o).some((e) => j(e, t));
238
+ let o = n.length - 1 - a, s = n[o], c = A(s, t), l = n.slice(0, o).some((e) => A(e, t));
239
239
  if (!c && !l) return;
240
240
  let u = c ?? {
241
- content: C(r),
241
+ content: S(r),
242
242
  location: "n",
243
243
  crossout: []
244
244
  }, d = a === 0 ? u.location : "n";
245
- i = ge(i, u, d, s.scale, r);
245
+ i = _e(i, u, d, s.scale, r);
246
246
  }), e.content = i;
247
247
  }
248
- function M(e, t) {
249
- let n = e.filter((e) => fe(e) > 0), r = Math.min(0, ...n.map(A)), i = Math.max(r, ...n.map(pe)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
248
+ function j(e, t) {
249
+ let n = e.filter((e) => pe(e) > 0), r = Math.min(0, ...n.map(k)), i = Math.max(r, ...n.map(me)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
250
250
  content: null,
251
251
  borders: {}
252
- })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + A(e) + n), u = [], d = [], f = (e) => {
252
+ })), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + k(e) + n), u = [], d = [], f = (e) => {
253
253
  let n = c();
254
254
  e.cells.forEach((t, r) => {
255
- n[a + A(e) + r].content = t;
255
+ n[a + k(e) + r].content = t;
256
256
  }), u.length && n.forEach((e, n) => {
257
- _e(e, n - a, u, t);
257
+ ve(e, n - a, u, t);
258
258
  });
259
259
  for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
260
260
  u = [], d = [], s.set(e, o.length), o.push(n);
@@ -274,44 +274,44 @@ function M(e, t) {
274
274
  origin: a
275
275
  };
276
276
  }
277
- function N(e, { rows: t }, n) {
278
- let r = x(n.document, "mtable", t.map((e) => x(n.document, "mtr", e.map((e) => {
277
+ function M(e, { rows: t }, n) {
278
+ let r = b(n.document, "mtable", t.map((e) => b(n.document, "mtr", e.map((e) => {
279
279
  let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
280
- return x(n.document, "mtd", [e.content], {
280
+ return b(n.document, "mtd", [e.content], {
281
281
  ...t ? { style: t } : {},
282
282
  ...e.align ? { columnalign: e.align } : {}
283
283
  });
284
284
  }))));
285
- for (let { name: t, value: n } of [...e.attributes]) oe.has(t) || r.setAttribute(t, n);
286
- let i = w(e, "charspacing") ?? "medium", a = w(e, "charalign");
287
- return r.setAttribute("columnspacing", b[i] ?? (ne.test(i) ? i : b.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
285
+ for (let { name: t, value: n } of [...e.attributes]) se.has(t) || r.setAttribute(t, n);
286
+ let i = C(e, "charspacing") ?? "medium", a = C(e, "charalign");
287
+ return r.setAttribute("columnspacing", ne[i] ?? (re.test(i) ? i : ne.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
288
288
  }
289
- function P(e) {
289
+ function N(e) {
290
290
  return {
291
291
  document: e.ownerDocument,
292
- stackAlign: w(e, "stackalign") ?? "decimalpoint",
292
+ stackAlign: C(e, "stackalign") ?? "decimalpoint",
293
293
  decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
294
294
  };
295
295
  }
296
- function ve(e) {
297
- let t = P(e), n = [];
298
- return k([...e.children], 0, 0, t, n), N(e, M(n, t), t);
296
+ function ye(e) {
297
+ let t = N(e), n = [];
298
+ return O([...e.children], 0, 0, t, n), M(e, j(n, t), t);
299
299
  }
300
- function F(e, t, n, r, i, a) {
300
+ function P(e, t, n, r, i, a) {
301
301
  for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
302
302
  }
303
- function ye(e, t) {
304
- let n = S(t, ")");
305
- return n.setAttribute("minsize", "1.2em"), [x(t.document, "mrow", [e, x(t.document, "mspace", [], { width: "0.2em" })]), x(t.document, "mpadded", [n], {
303
+ function be(e, t) {
304
+ let n = x(t, ")");
305
+ return n.setAttribute("minsize", "1.2em"), [b(t.document, "mrow", [e, b(t.document, "mspace", [], { width: "0.2em" })]), b(t.document, "mpadded", [n], {
306
306
  voffset: "0.1em",
307
307
  lspace: "-0.15em",
308
308
  depth: "-0.2em",
309
309
  height: "-0.2em"
310
310
  })];
311
311
  }
312
- function be(e) {
313
- let t = P(e), [n, r, ...i] = [...e.children], a = n && !E(n) ? n : null, o = r && !E(r) ? r : null, s = w(e, "longdivstyle") ?? "lefttop", c = ue(e), l = [];
314
- k(i, 0, 0, t, l);
312
+ function xe(e) {
313
+ let t = N(e), [n, r, ...i] = [...e.children], a = n && !T(n) ? n : null, o = r && !T(r) ? r : null, s = C(e, "longdivstyle") ?? "lefttop", c = de(e), l = [];
314
+ O(i, 0, 0, t, l);
315
315
  let u = l.find((e) => e.kind === "digits");
316
316
  u || (u = {
317
317
  kind: "digits",
@@ -323,51 +323,51 @@ function be(e) {
323
323
  u.cells.unshift(...e), u.anchor += e.length;
324
324
  }, p = (...e) => {
325
325
  let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
326
- u.cells.push(...O(n, 0, t).cells);
326
+ u.cells.push(...D(n, 0, t).cells);
327
327
  };
328
328
  switch (s) {
329
329
  case "left/\\right":
330
- f(a, S(t, "/")), p(S(t, "\\"), o);
330
+ f(a, x(t, "/")), p(x(t, "\\"), o);
331
331
  break;
332
332
  case "left)(right":
333
- f(a, S(t, ")")), p(S(t, "("), o);
333
+ f(a, x(t, ")")), p(x(t, "("), o);
334
334
  break;
335
335
  case ":right=right":
336
- p(S(t, ":"), a, S(t, "="), o);
336
+ p(x(t, ":"), a, x(t, "="), o);
337
337
  break;
338
338
  case "righttop":
339
339
  case "stackedleftlinetop":
340
340
  case "lefttop":
341
- o && k([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...ye(a, t));
341
+ o && O([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...be(a, t));
342
342
  break;
343
343
  }
344
- let m = M(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + A(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + pe(e)));
344
+ let m = j(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + k(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + me(e)));
345
345
  switch (s) {
346
346
  case "left/\\right":
347
347
  case "left)(right":
348
348
  case ":right=right": break;
349
349
  case "righttop": {
350
350
  let e = h[g][_(u.cells.length - 1)];
351
- e.borders.left = c, e.borders.bottom = c, F(h, g, _(0), _(u.cells.length - 1), "top", c);
351
+ e.borders.left = c, e.borders.bottom = c, P(h, g, _(0), _(u.cells.length - 1), "top", c);
352
352
  break;
353
353
  }
354
354
  case "stackedleftlinetop": {
355
355
  let e = h[g][_(0)];
356
- e.borders.right = c, e.borders.bottom = c, F(h, g, _(1), v, "top", c);
356
+ e.borders.right = c, e.borders.bottom = c, P(h, g, _(1), v, "top", c);
357
357
  break;
358
358
  }
359
359
  case "stackedrightright":
360
360
  case "mediumstackedrightright":
361
361
  case "shortstackedrightright":
362
362
  case "stackedleftleft":
363
- xe(h, g, s, a, o, c, t);
363
+ Se(h, g, s, a, o, c, t);
364
364
  break;
365
- default: F(h, g, _(1), v, "top", c);
365
+ default: P(h, g, _(1), v, "top", c);
366
366
  }
367
- return N(e, m, t);
367
+ return M(e, m, t);
368
368
  }
369
- function xe(e, t, n, r, i, a, o) {
370
- let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && x(o.document, "mpadded", [e], {
369
+ function Se(e, t, n, r, i, a, o) {
370
+ let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && b(o.document, "mpadded", [e], {
371
371
  lspace: "0.2em",
372
372
  width: "+0.4em"
373
373
  });
@@ -386,309 +386,81 @@ function xe(e, t, n, r, i, a, o) {
386
386
  }) : 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);
387
387
  });
388
388
  }
389
- function Se(e) {
390
- for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? ve(t) : be(t));
389
+ function Ce(e) {
390
+ for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? ye(t) : xe(t));
391
391
  }
392
392
  //#endregion
393
393
  //#region src/explorer-styles.ts
394
- var Ce = "PIE-MJX-explorer-styles", I = "var(--pie-text, black)", we = "var(--pie-background, #ffffff)", Te = "var(--pie-border-dark, #66686A)", L = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", R = `color-mix(in srgb, ${L} 15%, transparent)`, Ee = `
394
+ var we = "PIE-MJX-explorer-styles", F = "var(--pie-text, black)", Te = "var(--pie-background, #ffffff)", Ee = "var(--pie-border-dark, #66686A)", I = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", L = `color-mix(in srgb, ${I} 15%, transparent)`, De = `
395
395
  :root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
396
- color: ${I} !important;
397
- fill: ${I} !important;
396
+ color: ${F} !important;
397
+ fill: ${F} !important;
398
398
  }
399
399
  :root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
400
- background-color: ${R} !important;
400
+ background-color: ${L} !important;
401
401
  }
402
402
  :root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
403
- fill: ${R} !important;
403
+ fill: ${L} !important;
404
404
  }
405
405
  :root mjx-container .mjx-selected {
406
- outline: 2px solid ${L} !important;
406
+ outline: 2px solid ${I} !important;
407
407
  }
408
408
  :root mjx-container [data-sre-highlight-2] {
409
- color: ${I} !important;
409
+ color: ${F} !important;
410
410
  background-color: transparent !important;
411
- fill: ${I} !important;
412
- outline: 2px dashed ${L} !important;
411
+ fill: ${F} !important;
412
+ outline: 2px dashed ${I} !important;
413
413
  }
414
414
  :root mjx-container rect[data-sre-highlight-2] {
415
415
  fill: transparent !important;
416
- stroke: ${L} !important;
416
+ stroke: ${I} !important;
417
417
  stroke-width: 2px !important;
418
418
  vector-effect: non-scaling-stroke;
419
419
  }
420
420
  :root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
421
- color: ${I} !important;
422
- background-color: ${we} !important;
423
- border-color: ${Te} !important;
421
+ color: ${F} !important;
422
+ background-color: ${Te} !important;
423
+ border-color: ${Ee} !important;
424
424
  }
425
425
  :root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
426
- color: ${I} !important;
427
- background-color: ${R} !important;
426
+ color: ${F} !important;
427
+ background-color: ${L} !important;
428
428
  }
429
429
  `;
430
- function De(e = document) {
430
+ function Oe(e = document) {
431
431
  if (e.getElementById("PIE-MJX-explorer-styles")) return;
432
432
  let t = e.createElement("style");
433
- t.id = Ce, t.textContent = Ee, e.head.appendChild(t);
434
- }
435
- //#endregion
436
- //#region src/unsupported-page.ts
437
- var z = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", Oe = "pie-mathjax-version-conflict", ke = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
438
- function Ae(e, t) {
439
- if (typeof window > "u") return;
440
- let n = globalThis;
441
- n[ke] ??= {
442
- logged: !1,
443
- conditions: []
444
- };
445
- let r = n[ke];
446
- if (r.conditions.includes(e)) return;
447
- r.conditions.push(e);
448
- 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 ${z}`;
449
- r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(Oe, { detail: {
450
- condition: e,
451
- message: i,
452
- docsUrl: z
453
- } }));
454
- }
455
- //#endregion
456
- //#region src/adapter.ts
457
- var je = {
458
- parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
459
- overarc: "\\overparen",
460
- napprox: "\\not\\approx",
461
- longdiv: "\\enclose{longdiv}",
462
- abs: ["\\left|#1\\right|", 1]
463
- }, Me = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Ne = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, Pe = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, Fe = /\\embed\{newLine\}\[\]/g, Ie = [
464
- ["$$", "$$"],
465
- ["$", "$"],
466
- ["\\[", "\\]"],
467
- ["\\(", "\\)"]
468
- ], Le = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Re = "MJX-CHTML-styles", ze = "PIE-MJX-SVG-styles", B = "PIE-MathJax-Menu-Settings", Be = { "mjx-container[overflow=\"linebreak\"][display]": {
469
- overflow: "auto clip",
470
- "min-width": "initial !important"
471
- } }, Ve = 200, He = 201;
472
- function V(e) {
473
- let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
474
- 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");
475
- }
476
- function Ue(e) {
477
- for (let [t, n] of Ie) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
478
- return e;
479
- }
480
- function We(e) {
481
- return Ue(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
482
- }
483
- var Ge = "mathjax_ignore", Ke = "mathjax_process";
484
- function qe(e, t) {
485
- let n = e.closest(`.${Ge}, .${Ke}`);
486
- return n !== null && t.contains(n) && !n.classList.contains(Ke);
487
- }
488
- function Je(e) {
489
- for (let t of e.querySelectorAll("[data-latex]")) {
490
- if (t.dataset.mathHandled || t.closest("mjx-container") || qe(t, e)) continue;
491
- let n = t.textContent;
492
- n && (t.textContent = `\\(${We(n)}\\)`.replace(Fe, "\\newline "), t.dataset.mathHandled = "true");
493
- }
494
- }
495
- function Ye(e) {
496
- for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
497
- }
498
- function Xe(e, t) {
499
- for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
500
- return (t ? Pe : Ne).test(e.textContent ?? "");
501
- }
502
- function Ze(e) {
503
- return new Promise((a, s) => {
504
- let { useSingleDollar: l = !1, accessibility: u = !0, loadFonts: d = !0, srcUrl: f } = e, p = i(e, import.meta.url), m = {
505
- loader: {
506
- load: u ? ["a11y/assistive-mml"] : [],
507
- failed: (e) => s(e),
508
- "output/svg": { ready: (e) => {
509
- let t = o();
510
- return H(t) && Qe(t), e;
511
- } }
512
- },
513
- startup: {
514
- typeset: !1,
515
- ready: () => {
516
- let e = o(), n = e?.startup, i = H(e);
517
- i && (Qe(e), $e(e, p.speechLocales), t(e?._?.a11y?.sre_ts?.locales, p.speechLocales)), n?.defaultReady?.(), i && (et(n?.document), n?.document?.addStyles?.(Be), r(n?.document)), Promise.resolve(n?.promise).then(() => a(), s);
518
- }
519
- },
520
- tex: { macros: { ...je } },
521
- output: { displayOverflow: "linebreak" },
522
- options: {
523
- enableMenu: u,
524
- menuOptions: { settings: {
525
- assistiveMml: u,
526
- enrich: !1,
527
- inTabOrder: !1
528
- } },
529
- a11y: { inTabOrder: !1 }
530
- }
531
- };
532
- l && m.tex && (console.warn(Me), m.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], m.tex.processEscapes = !0), d || (m.chtml = { fontURL: "" });
533
- let h = n(p.speechLocales);
534
- h && m.options && (m.options.sre = { locale: h }), c(m, {
535
- ...p,
536
- srcUrl: f
537
- }).then((e) => {
538
- e || a();
539
- }, s);
540
- });
541
- }
542
- function H(e) {
543
- return !!e?.version?.startsWith("4.");
544
- }
545
- function Qe(e) {
546
- let t = e?._?.output, n = t?.chtml_ts?.CHTML;
547
- n && (n.STYLESHEETID = p);
548
- let r = t?.svg_ts?.SVG;
549
- r && (r.STYLESHEETID = ze);
550
- }
551
- function $e(e, t) {
552
- let n = e?._?.ui?.menu?.Menu?.Menu;
553
- if (n) {
554
- n.MENU_STORAGE = B;
555
- try {
556
- let e = localStorage.getItem(B);
557
- if (!e) return;
558
- let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
559
- if (n === void 0 && a) return;
560
- a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(B, JSON.stringify(i)) : localStorage.removeItem(B);
561
- } catch {}
562
- }
563
- }
564
- function et(e) {
565
- if (!e) return;
566
- let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
567
- let n = e.typesetRoot;
568
- !n || t.has(n) || (V(n), t.add(n));
569
- };
570
- e.addRenderAction?.("pie-strip-latex", He, (e) => {
571
- for (let t of e.math ?? []) n(t);
572
- return !1;
573
- }, (e) => {
574
- let t = e.typesetRoot;
575
- return t && V(t), !1;
576
- });
577
- let r = e.outputJax?.chtmlStyles;
578
- r?.id === Re && (r.id = p), rt();
579
- }
580
- function tt(e) {
581
- return e instanceof HTMLStyleElement && m.includes(e.id);
582
- }
583
- function nt(e) {
584
- Ae("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
585
- }
586
- function rt() {
587
- let e = document.head, t = [...e.children].find(tt);
588
- if (t) {
589
- nt(t);
590
- return;
591
- }
592
- let n = new MutationObserver((e) => {
593
- for (let t of e) {
594
- let e = [...t.addedNodes].find(tt);
595
- if (e) {
596
- nt(e), n.disconnect();
597
- return;
598
- }
599
- }
600
- });
601
- n.observe(e, { childList: !0 });
602
- }
603
- function it(e) {
604
- let t = e?.math;
605
- if (!t?.remove) return;
606
- let n = [...t].filter((e) => (e.state?.() ?? 0) >= Ve && e.typesetRoot?.isConnected === !1);
607
- if (n.length !== 0) {
608
- for (let e of [...n].reverse()) e.clear?.();
609
- t.remove(...n);
610
- }
611
- }
612
- function at(e) {
613
- return new Promise((t, n) => {
614
- let r = e.startup ?? {};
615
- e.startup = r;
616
- let i = r.ready;
617
- r.ready = () => {
618
- let e = o()?.startup;
619
- i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
620
- };
621
- });
622
- }
623
- function ot(e) {
624
- let t = o();
625
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : at(t) : Ze(e);
626
- }
627
- function st(e) {
628
- return ot(e).then(() => {
629
- let e = o();
630
- e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
631
- });
632
- }
633
- function ct(e) {
634
- let t = l, n = t[Le];
635
- return n || (n = st(e), t[Le] = n), n;
636
- }
637
- function lt(e = {}) {
638
- let t = e.useSingleDollar ?? !1;
639
- return async (n) => {
640
- if (typeof window > "u") return;
641
- Je(n), v(n), Ye(n), Se(n);
642
- let r = ct(e);
643
- if (!Xe(n, t)) {
644
- r.catch(() => {});
645
- return;
646
- }
647
- await r;
648
- let i = o();
649
- if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
650
- De(), it(i.startup?.document);
651
- try {
652
- await i.typesetPromise([n]);
653
- } catch (e) {
654
- throw i.typesetClear?.([n]), e;
655
- }
656
- V(n);
657
- }
658
- };
659
- }
660
- function ut() {
661
- return [];
433
+ t.id = we, t.textContent = De, e.head.appendChild(t);
662
434
  }
663
435
  //#endregion
664
436
  //#region src/math-speech.ts
665
- var dt = /[⁡-⁤]/g, ft = {
437
+ var ke = /[⁡-⁤]/g, R = {
666
438
  "+": "positive",
667
439
  "-": "negative",
668
440
  "−": "negative",
669
441
  "±": "plus or minus",
670
442
  "∓": "minus or plus"
671
- }, pt = {
443
+ }, Ae = {
672
444
  "(": "open parenthesis",
673
445
  "[": "open bracket",
674
446
  "{": "open brace",
675
447
  "⟨": "open angle bracket",
676
448
  "⌊": "open floor",
677
449
  "⌈": "open ceiling"
678
- }, mt = {
450
+ }, je = {
679
451
  ")": "close parenthesis",
680
452
  "]": "close bracket",
681
453
  "}": "close brace",
682
454
  "⟩": "close angle bracket",
683
455
  "⌋": "close floor",
684
456
  "⌉": "close ceiling"
685
- }, U = {
457
+ }, z = {
686
458
  "!": "factorial",
687
459
  "%": "percent",
688
460
  "°": "degrees",
689
461
  "′": "prime",
690
462
  "″": "double prime"
691
- }, ht = {
463
+ }, Me = {
692
464
  "+": "plus",
693
465
  "-": "minus",
694
466
  "−": "minus",
@@ -732,16 +504,16 @@ var dt = /[⁡-⁤]/g, ft = {
732
504
  ":": "colon",
733
505
  "|": "vertical bar",
734
506
  "‖": "double vertical bar",
735
- ...pt,
736
- ...mt,
737
- ...U
738
- }, gt = /* @__PURE__ */ new Set(["|", "‖"]), _t = /* @__PURE__ */ new Set([
507
+ ...Ae,
508
+ ...je,
509
+ ...z
510
+ }, Ne = /* @__PURE__ */ new Set(["|", "‖"]), Pe = /* @__PURE__ */ new Set([
739
511
  "∑",
740
512
  "∏",
741
513
  "∫",
742
514
  "∪",
743
515
  "∩"
744
- ]), vt = {
516
+ ]), Fe = {
745
517
  α: "alpha",
746
518
  β: "beta",
747
519
  γ: "gamma",
@@ -768,7 +540,7 @@ var dt = /[⁡-⁤]/g, ft = {
768
540
  cot: "cotangent",
769
541
  ln: "natural log",
770
542
  lim: "limit"
771
- }, yt = {
543
+ }, Ie = {
772
544
  "¯": "bar",
773
545
  "‾": "bar",
774
546
  "―": "bar",
@@ -779,211 +551,438 @@ var dt = /[⁡-⁤]/g, ft = {
779
551
  "→": "vector",
780
552
  "⃗": "vector",
781
553
  "˙": "dot"
782
- }, bt = {
783
- 2: ["half", "halves"],
784
- 3: ["third", "thirds"],
785
- 4: ["quarter", "quarters"],
786
- 5: ["fifth", "fifths"],
787
- 6: ["sixth", "sixths"],
788
- 7: ["seventh", "sevenths"],
789
- 8: ["eighth", "eighths"],
790
- 9: ["ninth", "ninths"],
791
- 10: ["tenth", "tenths"]
792
- }, W = (e) => (e.textContent ?? "").replace(dt, "").replace(/\s+/g, " ").trim(), G = (e) => e.replace(/\s+/g, " ").trim(), K = (e) => [...e.children];
793
- function q(e) {
554
+ }, B = (e) => (e.textContent ?? "").replace(ke, "").replace(/\s+/g, " ").trim(), V = (e) => e.replace(/\s+/g, " ").trim(), H = (e) => [...e.children];
555
+ function U(e) {
794
556
  return !e || [
795
557
  "mn",
796
558
  "mi",
797
559
  "mtext",
798
560
  "mo"
799
- ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? q(e.children[0]) : !1;
561
+ ].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? U(e.children[0]) : !1;
800
562
  }
801
- function J(e) {
802
- let t = e ? W(e) : "";
563
+ function Le(e) {
564
+ let t = e ? B(e) : "";
803
565
  return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
804
566
  }
805
- function xt(e) {
567
+ function Re(e) {
806
568
  return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
807
569
  1: "st",
808
570
  2: "nd",
809
571
  3: "rd"
810
572
  }[e % 10] ?? "th"}`;
811
573
  }
812
- function St(e) {
813
- return vt[e] ?? e;
574
+ function ze(e) {
575
+ return Fe[e] ?? e;
814
576
  }
815
- function Y(e) {
816
- return ht[e] ?? e;
577
+ function W(e) {
578
+ return Me[e] ?? e;
817
579
  }
818
- function X(e) {
580
+ function G(e) {
819
581
  let t = [], n = !1;
820
582
  for (let r of e) {
821
583
  if (r.localName !== "mo") {
822
- t.push(Z(r)), n = !0;
584
+ t.push(K(r)), n = !0;
823
585
  continue;
824
586
  }
825
- let e = W(r);
826
- e && (!n && ft[e] ? t.push(ft[e]) : e in U ? t.push(U[e]) : (t.push(Y(e)), n = e in mt || gt.has(e) && n));
587
+ let e = B(r);
588
+ e && (!n && R[e] ? t.push(R[e]) : e in z ? t.push(z[e]) : (t.push(W(e)), n = e in je || Ne.has(e) && n));
827
589
  }
828
590
  return t.filter(Boolean).join(" ");
829
591
  }
830
- function Ct(e) {
831
- let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(W(e)), a = n.slice(0, -1);
832
- if (a.length && i(t) && i(r) && W(t) === W(r) && !a.some(i)) {
833
- let e = G(X(a));
834
- return W(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
592
+ function Be(e) {
593
+ let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(B(e)), a = n.slice(0, -1);
594
+ if (a.length && i(t) && i(r) && B(t) === B(r) && !a.some(i)) {
595
+ let e = V(G(a));
596
+ return B(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
835
597
  }
836
- return X(e);
598
+ return G(e);
837
599
  }
838
- function wt(e, t) {
839
- let n = J(e), r = J(t), i = r === void 0 ? void 0 : bt[r];
840
- if (n !== void 0 && i) return `${n} ${n === 1 ? i[0] : i[1]}`;
841
- let a = e ? Z(e) : "", o = t ? Z(t) : "";
842
- return q(e) && q(t) ? `${a} over ${o}` : `the fraction with numerator ${a} and denominator ${o}`;
600
+ function Ve(e, t) {
601
+ let n = e ? K(e) : "", r = t ? K(t) : "";
602
+ return U(e) && U(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
843
603
  }
844
- function Tt(e, t, n) {
604
+ function He(e, t, n) {
845
605
  return n ? `${t} of ${e}` : `${t} of ${e} end root`;
846
606
  }
847
- function Et(e, t) {
848
- let n = t ? W(t) : "";
849
- if (t && q(t)) {
607
+ function Ue(e, t) {
608
+ let n = t ? B(t) : "";
609
+ if (t && U(t)) {
850
610
  if (n === "2") return `${e} squared`;
851
611
  if (n === "3") return `${e} cubed`;
852
- if (n in U) return `${e} ${U[n]}`;
612
+ if (n in z) return `${e} ${z[n]}`;
853
613
  }
854
- let r = t ? Z(t) : "";
855
- return q(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
856
- }
857
- function Dt(e, t) {
858
- let n = t ? Z(t) : "";
859
- return q(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
860
- }
861
- function Ot(e, t, n) {
862
- let r = W(e);
863
- if (r === "lim") return `limit as ${t ? Z(t) : ""} of`;
864
- if (!_t.has(r)) return;
865
- let i = t ? `from ${Z(t)}` : "", a = n ? `to ${Z(n)}` : "";
866
- return `${Y(r)} ${i} ${a} of`;
867
- }
868
- function kt(e) {
869
- let t = K(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => K(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) => G(X(K(e)))).join(", ")}`);
614
+ let r = t ? K(t) : "";
615
+ return U(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
616
+ }
617
+ function We(e, t) {
618
+ let n = t ? K(t) : "";
619
+ return U(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
620
+ }
621
+ function Ge(e, t, n) {
622
+ let r = B(e);
623
+ if (r === "lim") return `limit as ${t ? K(t) : ""} of`;
624
+ if (!Pe.has(r)) return;
625
+ let i = t ? `from ${K(t)}` : "", a = n ? `to ${K(n)}` : "";
626
+ return `${W(r)} ${i} ${a} of`;
627
+ }
628
+ function Ke(e) {
629
+ let t = H(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => H(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) => V(G(H(e)))).join(", ")}`);
870
630
  return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
871
631
  }
872
- function At(e) {
873
- let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = K(e).map((e, t, n) => t < n.length - 1 ? `${Z(e)} ${Y(r[Math.min(t, r.length - 1)] ?? ",")}` : Z(e));
632
+ function qe(e) {
633
+ let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = H(e).map((e, t, n) => t < n.length - 1 ? `${K(e)} ${W(r[Math.min(t, r.length - 1)] ?? ",")}` : K(e));
874
634
  return [
875
- Y(t),
635
+ W(t),
876
636
  ...i,
877
- Y(n)
637
+ W(n)
878
638
  ].filter(Boolean).join(" ");
879
639
  }
880
- function Z(e) {
881
- let t = K(e);
640
+ function K(e) {
641
+ let t = H(e);
882
642
  switch (e.localName) {
883
- case "mi": return St(W(e));
643
+ case "mi": return ze(B(e));
884
644
  case "mn":
885
645
  case "mtext":
886
- case "ms": return W(e);
887
- case "mo": return Y(W(e));
646
+ case "ms": return B(e);
647
+ case "mo": return W(B(e));
888
648
  case "mspace":
889
649
  case "mphantom":
890
650
  case "annotation":
891
651
  case "annotation-xml": return "";
892
- case "semantics": return t[0] ? Z(t[0]) : "";
893
- case "mfrac": return wt(t[0], t[1]);
894
- case "msqrt": return Tt(G(X(t)), "square root", t.length === 1 && q(t[0]));
652
+ case "semantics": return t[0] ? K(t[0]) : "";
653
+ case "mfrac": return Ve(t[0], t[1]);
654
+ case "msqrt": return He(V(G(t)), "square root", t.length === 1 && U(t[0]));
895
655
  case "mroot": {
896
- let e = J(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${xt(e)} root` : `root with index ${t[1] ? Z(t[1]) : ""}`;
897
- return Tt(t[0] ? Z(t[0]) : "", n, q(t[0]));
656
+ let e = Le(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Re(e)} root` : `root with index ${t[1] ? K(t[1]) : ""}`;
657
+ return He(t[0] ? K(t[0]) : "", n, U(t[0]));
898
658
  }
899
- case "msup": return Et(t[0] ? Z(t[0]) : "", t[1]);
900
- case "msub": return Dt(t[0] ? Z(t[0]) : "", t[1]);
901
- case "msubsup": return (t[0] ? Ot(t[0], t[1], t[2]) : void 0) || Et(Dt(t[0] ? Z(t[0]) : "", t[1]), t[2]);
659
+ case "msup": return Ue(t[0] ? K(t[0]) : "", t[1]);
660
+ case "msub": return We(t[0] ? K(t[0]) : "", t[1]);
661
+ case "msubsup": return (t[0] ? Ge(t[0], t[1], t[2]) : void 0) || Ue(We(t[0] ? K(t[0]) : "", t[1]), t[2]);
902
662
  case "munder":
903
663
  case "mover":
904
664
  case "munderover": {
905
- 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 ? Ot(n, a, o) : void 0;
665
+ 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 ? Ge(n, a, o) : void 0;
906
666
  if (s) return s;
907
- let c = n ? Z(n) : "", l = e.localName === "mover" && r ? yt[W(r)] : void 0;
667
+ let c = n ? K(n) : "", l = e.localName === "mover" && r ? Ie[B(r)] : void 0;
908
668
  return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
909
669
  c,
910
- a ? `with ${Z(a)} below` : "",
911
- o ? `with ${Z(o)} above` : ""
670
+ a ? `with ${K(a)} below` : "",
671
+ o ? `with ${K(o)} above` : ""
912
672
  ].filter(Boolean).join(" ");
913
673
  }
914
- case "mfenced": return At(e);
915
- case "mtable": return kt(e);
674
+ case "mfenced": return qe(e);
675
+ case "mtable": return Ke(e);
916
676
  case "mrow":
917
- case "math": return Ct(t);
918
- default: return t.length ? X(t) : W(e);
677
+ case "math": return Be(t);
678
+ default: return t.length ? G(t) : B(e);
919
679
  }
920
680
  }
921
- function jt(e) {
922
- return G(Z(e));
681
+ function Je(e) {
682
+ return V(K(e));
923
683
  }
924
684
  //#endregion
925
685
  //#region src/math-name.ts
926
- var Mt = /* @__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(".")), Nt = (e) => e.replace(/\s+/g, " ").trim();
927
- function Pt(e) {
928
- return e.getAttribute("aria-hidden") === "true" || e.hidden === !0 || e.style?.display === "none";
929
- }
930
- function Ft(e) {
931
- return e.localName === "math" ? e : e.querySelector("math");
932
- }
933
- function It(e, t, n) {
934
- if (e.nodeType === 3) return e.textContent ?? "";
935
- if (!(e instanceof Element) || Pt(e)) return "";
936
- let r = e.localName === "mjx-container" || e.localName === "math" ? Ft(e) : null;
937
- if (r) {
938
- let e = Nt(t(r) ?? r.textContent ?? "");
939
- return e && (n.math = !0), ` ${e} `;
686
+ var Ye = [
687
+ "a[href]",
688
+ "button",
689
+ "label",
690
+ "summary",
691
+ ...[
692
+ "button",
693
+ "checkbox",
694
+ "combobox",
695
+ "link",
696
+ "menuitem",
697
+ "menuitemcheckbox",
698
+ "menuitemradio",
699
+ "option",
700
+ "radio",
701
+ "switch",
702
+ "tab",
703
+ "treeitem"
704
+ ].map((e) => `[role="${e}"]`)
705
+ ].join(", ");
706
+ function Xe(e) {
707
+ if (e.hasAttribute("aria-label") || !e.closest(Ye)) return;
708
+ let t = e.querySelector("math"), n = t ? Je(t) : "";
709
+ n && e.setAttribute("aria-label", n);
710
+ }
711
+ function q(e) {
712
+ for (let t of e.querySelectorAll("mjx-container")) Xe(t);
713
+ }
714
+ //#endregion
715
+ //#region src/unsupported-page.ts
716
+ var J = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", Ze = "pie-mathjax-version-conflict", Qe = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
717
+ function $e(e, t) {
718
+ if (typeof window > "u") return;
719
+ let n = globalThis;
720
+ n[Qe] ??= {
721
+ logged: !1,
722
+ conditions: []
723
+ };
724
+ let r = n[Qe];
725
+ if (r.conditions.includes(e)) return;
726
+ r.conditions.push(e);
727
+ 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 ${J}`;
728
+ r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(Ze, { detail: {
729
+ condition: e,
730
+ message: i,
731
+ docsUrl: J
732
+ } }));
733
+ }
734
+ //#endregion
735
+ //#region src/adapter.ts
736
+ var et = {
737
+ parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
738
+ overarc: "\\overparen",
739
+ napprox: "\\not\\approx",
740
+ longdiv: "\\enclose{longdiv}",
741
+ abs: ["\\left|#1\\right|", 1]
742
+ }, tt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", nt = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, rt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, it = /\\embed\{newLine\}\[\]/g, at = [
743
+ ["$$", "$$"],
744
+ ["$", "$"],
745
+ ["\\[", "\\]"],
746
+ ["\\(", "\\)"]
747
+ ], ot = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), st = "MJX-CHTML-styles", ct = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", lt = { "mjx-container[overflow=\"linebreak\"][display]": {
748
+ overflow: "auto clip",
749
+ "min-width": "initial !important"
750
+ } }, ut = 200, dt = 201, ft = 202;
751
+ function X(e) {
752
+ let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
753
+ 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");
754
+ }
755
+ function pt(e) {
756
+ for (let [t, n] of at) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
757
+ return e;
758
+ }
759
+ function mt(e) {
760
+ return pt(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
761
+ }
762
+ var ht = "mathjax_ignore", gt = "mathjax_process";
763
+ function _t(e, t) {
764
+ let n = e.closest(`.${ht}, .${gt}`);
765
+ return n !== null && t.contains(n) && !n.classList.contains(gt);
766
+ }
767
+ function vt(e) {
768
+ for (let t of e.querySelectorAll("[data-latex]")) {
769
+ if (t.dataset.mathHandled || t.closest("mjx-container") || _t(t, e)) continue;
770
+ let n = t.textContent;
771
+ n && (t.textContent = `\\(${mt(n)}\\)`.replace(it, "\\newline "), t.dataset.mathHandled = "true");
940
772
  }
941
- if (e.localName === "mjx-container") return " ";
942
- let i = e.getAttribute("aria-label")?.trim();
943
- if (i) return ` ${i} `;
944
- if (e.localName === "img") return ` ${e.getAttribute("alt") ?? ""} `;
945
- let a = [...e.childNodes].map((e) => It(e, t, n)).join("");
946
- return Mt.has(e.localName) ? ` ${a} ` : a;
947
773
  }
948
- function Lt(e, t = {}) {
949
- let n = t.speak ?? jt, r = { math: !1 }, i = Nt([...e.childNodes].map((e) => It(e, n, r)).join(""));
950
- return r.math && i ? i : void 0;
774
+ function yt(e) {
775
+ for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
776
+ }
777
+ function bt(e, t) {
778
+ for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
779
+ return (t ? rt : nt).test(e.textContent ?? "");
780
+ }
781
+ function xt(e) {
782
+ return new Promise((a, s) => {
783
+ let { useSingleDollar: l = !1, accessibility: u = !0, loadFonts: d = !0, srcUrl: f } = e, p = i(e, import.meta.url), m = {
784
+ loader: {
785
+ load: u ? ["a11y/assistive-mml"] : [],
786
+ failed: (e) => s(e),
787
+ "output/svg": { ready: (e) => {
788
+ let t = o();
789
+ return St(t) && Ct(t), e;
790
+ } }
791
+ },
792
+ startup: {
793
+ typeset: !1,
794
+ ready: () => {
795
+ let e = o(), n = e?.startup, i = St(e);
796
+ i && (Ct(e), wt(e, p.speechLocales), t(e?._?.a11y?.sre_ts?.locales, p.speechLocales)), n?.defaultReady?.(), i && (Tt(n?.document), Et(n?.document), n?.document?.addStyles?.(lt), r(n?.document)), Promise.resolve(n?.promise).then(() => a(), s);
797
+ }
798
+ },
799
+ tex: { macros: { ...et } },
800
+ output: { displayOverflow: "linebreak" },
801
+ options: {
802
+ enableMenu: u,
803
+ menuOptions: { settings: {
804
+ assistiveMml: u,
805
+ enrich: !1,
806
+ inTabOrder: !1
807
+ } },
808
+ a11y: { inTabOrder: !1 }
809
+ }
810
+ };
811
+ l && m.tex && (console.warn(tt), m.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], m.tex.processEscapes = !0), d || (m.chtml = { fontURL: "" });
812
+ let h = n(p.speechLocales);
813
+ h && m.options && (m.options.sre = { locale: h }), c(m, {
814
+ ...p,
815
+ srcUrl: f
816
+ }).then((e) => {
817
+ e || a();
818
+ }, s);
819
+ });
820
+ }
821
+ function St(e) {
822
+ return !!e?.version?.startsWith("4.");
823
+ }
824
+ function Ct(e) {
825
+ let t = e?._?.output, n = t?.chtml_ts?.CHTML;
826
+ n && (n.STYLESHEETID = p);
827
+ let r = t?.svg_ts?.SVG;
828
+ r && (r.STYLESHEETID = ct);
829
+ }
830
+ function wt(e, t) {
831
+ let n = e?._?.ui?.menu?.Menu?.Menu;
832
+ if (n) {
833
+ n.MENU_STORAGE = Y;
834
+ try {
835
+ let e = localStorage.getItem(Y);
836
+ if (!e) return;
837
+ let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
838
+ if (n === void 0 && a) return;
839
+ a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(Y, JSON.stringify(i)) : localStorage.removeItem(Y);
840
+ } catch {}
841
+ }
842
+ }
843
+ function Tt(e) {
844
+ if (!e) return;
845
+ let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
846
+ let n = e.typesetRoot;
847
+ !n || t.has(n) || (X(n), t.add(n));
848
+ };
849
+ e.addRenderAction?.("pie-strip-latex", dt, (e) => {
850
+ for (let t of e.math ?? []) n(t);
851
+ return !1;
852
+ }, (e) => {
853
+ let t = e.typesetRoot;
854
+ return t && X(t), !1;
855
+ });
856
+ let r = e.outputJax?.chtmlStyles;
857
+ r?.id === st && (r.id = p), Ot();
858
+ }
859
+ function Et(e) {
860
+ let t = (e) => {
861
+ e.typesetRoot && Xe(e.typesetRoot);
862
+ };
863
+ e?.addRenderAction?.("pie-name-math", ft, (e) => {
864
+ for (let n of e.math ?? []) t(n);
865
+ return !1;
866
+ }, (e) => (t(e), !1));
867
+ }
868
+ function Dt(e) {
869
+ return e instanceof HTMLStyleElement && m.includes(e.id);
870
+ }
871
+ function Z(e) {
872
+ $e("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
873
+ }
874
+ function Ot() {
875
+ let e = document.head, t = [...e.children].find(Dt);
876
+ if (t) {
877
+ Z(t);
878
+ return;
879
+ }
880
+ let n = new MutationObserver((e) => {
881
+ for (let t of e) {
882
+ let e = [...t.addedNodes].find(Dt);
883
+ if (e) {
884
+ Z(e), n.disconnect();
885
+ return;
886
+ }
887
+ }
888
+ });
889
+ n.observe(e, { childList: !0 });
890
+ }
891
+ function kt(e) {
892
+ let t = e?.math;
893
+ if (!t?.remove) return;
894
+ let n = [...t].filter((e) => (e.state?.() ?? 0) >= ut && e.typesetRoot?.isConnected === !1);
895
+ if (n.length !== 0) {
896
+ for (let e of [...n].reverse()) e.clear?.();
897
+ t.remove(...n);
898
+ }
899
+ }
900
+ function At(e) {
901
+ return new Promise((t, n) => {
902
+ let r = e.startup ?? {};
903
+ e.startup = r;
904
+ let i = r.ready;
905
+ r.ready = () => {
906
+ let e = o()?.startup;
907
+ i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
908
+ };
909
+ });
910
+ }
911
+ function jt(e) {
912
+ let t = o();
913
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : At(t) : xt(e);
914
+ }
915
+ function Mt(e) {
916
+ return jt(e).then(() => {
917
+ let e = o();
918
+ e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
919
+ });
920
+ }
921
+ function Nt(e) {
922
+ let t = l, n = t[ot];
923
+ return n || (n = Mt(e), t[ot] = n), n;
924
+ }
925
+ function Pt(e = {}) {
926
+ let t = e.useSingleDollar ?? !1;
927
+ return async (n) => {
928
+ if (typeof window > "u") return;
929
+ vt(n), v(n), yt(n), Ce(n);
930
+ let r = Nt(e);
931
+ if (!bt(n, t)) {
932
+ r.catch(() => {});
933
+ return;
934
+ }
935
+ await r;
936
+ let i = o();
937
+ if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
938
+ Oe(), kt(i.startup?.document);
939
+ try {
940
+ await i.typesetPromise([n]);
941
+ } catch (e) {
942
+ throw i.typesetClear?.([n]), e;
943
+ }
944
+ X(n), q(n);
945
+ }
946
+ };
947
+ }
948
+ function Ft() {
949
+ return [];
951
950
  }
952
951
  //#endregion
953
952
  //#region src/render-math.ts
954
- var Rt = "@pie-lib/math-rendering", zt = "@pie-lib/math-rendering@2", Bt = "pie-print", Vt = 50, Ht = 1e4, Ut = null;
955
- function Wt() {
956
- return !!window[zt]?.opts?.useSingleDollar;
953
+ var It = "@pie-lib/math-rendering", Lt = "@pie-lib/math-rendering@2", Rt = "pie-print", zt = 50, Bt = 1e4, Vt = null;
954
+ function Ht() {
955
+ return !!window[Lt]?.opts?.useSingleDollar;
957
956
  }
958
- function Gt() {
959
- return Ut ||= lt({ useSingleDollar: Wt() }), Ut;
957
+ function Ut() {
958
+ return Vt ||= Pt({ useSingleDollar: Ht() }), Vt;
960
959
  }
961
960
  function Q() {
962
961
  if (typeof window > "u") return null;
963
- let e = window[Rt];
962
+ let e = window[It];
964
963
  return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
965
964
  }
966
- function Kt(e) {
965
+ function Wt(e) {
967
966
  let t = e;
968
967
  for (; t;) {
969
- if (t instanceof Element && t.localName === Bt) return t;
968
+ if (t instanceof Element && t.localName === Rt) return t;
970
969
  t = t instanceof ShadowRoot ? t.host : t.parentNode;
971
970
  }
972
971
  return null;
973
972
  }
974
- function qt() {
973
+ function Gt() {
975
974
  let e = window.renderMath;
976
975
  return typeof e == "function" ? e : null;
977
976
  }
978
- async function Jt(e) {
979
- let t = Kt(e);
977
+ async function Kt(e) {
978
+ let t = Wt(e);
980
979
  if (!t) return null;
981
- let n = qt();
980
+ let n = Gt();
982
981
  if (n || t.mathRenderingModuleUrlImported !== !0) return n;
983
- let r = Date.now() + Ht;
982
+ let r = Date.now() + Bt;
984
983
  for (; Date.now() < r;) {
985
- await new Promise((e) => setTimeout(e, Vt));
986
- let e = qt();
984
+ await new Promise((e) => setTimeout(e, zt));
985
+ let e = Gt();
987
986
  if (e) return e;
988
987
  }
989
988
  return null;
@@ -992,14 +991,14 @@ var $ = async (e) => {
992
991
  if (typeof window > "u") return;
993
992
  let t = typeof e == "string", n;
994
993
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
995
- let r = Q(), i = r || t ? null : await Jt(n);
996
- return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await Gt()(n), t ? n.innerHTML : void 0;
997
- }, Yt = (e, t) => {
994
+ let r = Q(), i = r || t ? null : await Kt(n);
995
+ return r ? (await r.renderMath?.(n), q(n)) : i && i !== $ ? (await i(n), q(n)) : await Ut()(n), t ? n.innerHTML : void 0;
996
+ }, qt = (e, t) => {
998
997
  let n = Q()?.wrapMath?.(e, t);
999
998
  if (n != null) return n;
1000
999
  let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
1001
- return `${r}${Ue(e)}${i}`;
1002
- }, Xt = (e) => {
1000
+ return `${r}${pt(e)}${i}`;
1001
+ }, Jt = (e) => {
1003
1002
  let t = e.trim();
1004
1003
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
1005
1004
  unwrapped: t.slice(2, -2).trim(),
@@ -1026,6 +1025,6 @@ var $ = async (e) => {
1026
1025
  close: "$"
1027
1026
  }
1028
1027
  } : { unwrapped: t };
1029
- }, Zt = (e) => Q()?.mmlToLatex?.(e) ?? e;
1028
+ }, Yt = (e) => Q()?.mmlToLatex?.(e) ?? e;
1030
1029
  //#endregion
1031
- export { Oe as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, z as UNSUPPORTED_PAGE_DOCS_URL, lt as createMathjaxRenderer, ut as getMathjaxCssUrls, Lt as mathContentName, Zt as mmlToLatex, $ as renderMath, jt as speakMathml, Xt as unWrapMath, Yt as wrapMath };
1030
+ export { Ze as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, J as UNSUPPORTED_PAGE_DOCS_URL, Pt as createMathjaxRenderer, Ft as getMathjaxCssUrls, Yt as mmlToLatex, $ as renderMath, Je as speakMathml, Jt as unWrapMath, qt as wrapMath };