@pie-element/shared-math-rendering-mathjax 0.1.2 → 0.1.3-next.20261007003844
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/adapter.d.ts +16 -3
- package/dist/assets.d.ts +66 -0
- package/dist/browser/index.js +270 -261
- package/dist/browser/{mathjax-D2JHb_R_.js → mathjax-BKrHE4xs.js} +5568 -5531
- package/dist/browser/speech-worker-CP5P4gRS.js +129 -0
- package/dist/engine/page.d.ts +9 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +381 -251
- package/dist/speech-worker.d.ts +42 -0
- package/dist/types.d.ts +30 -2
- package/package.json +10 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,88 +1,89 @@
|
|
|
1
|
+
import { a as e, c as t, s as n, t as r, u as i } from "./speech-worker-CP5P4gRS.js";
|
|
1
2
|
//#region src/engine/bundled.ts
|
|
2
|
-
var
|
|
3
|
-
function
|
|
4
|
-
return
|
|
3
|
+
var a;
|
|
4
|
+
function o() {
|
|
5
|
+
return a;
|
|
5
6
|
}
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
async function
|
|
9
|
-
let { createMathJax:
|
|
10
|
-
|
|
7
|
+
var s = import("./mathjax-BKrHE4xs.js");
|
|
8
|
+
s.catch(() => {});
|
|
9
|
+
async function c(e, t) {
|
|
10
|
+
let { createMathJax: n } = await s;
|
|
11
|
+
return a = n(e, t, f), (e.startup?.ready ?? a.startup?.defaultReady)?.(), !0;
|
|
11
12
|
}
|
|
12
|
-
var
|
|
13
|
-
function
|
|
13
|
+
var l = {}, u = Symbol.for("@pie-element/shared-math-rendering-mathjax/bundled");
|
|
14
|
+
function d() {
|
|
14
15
|
let e = globalThis;
|
|
15
|
-
return e[
|
|
16
|
+
return e[u] = (e[u] ?? 0) + 1, e[u];
|
|
16
17
|
}
|
|
17
|
-
var
|
|
18
|
-
function
|
|
18
|
+
var f = d(), p = `PIE-MJX-CHTML-styles-${f}`, m = ["MJX-CHTML-styles"], h = "http://www.w3.org/1998/Math/MathML", g = /^([a-z_][\w.-]*):math$/, _ = /^[a-z][a-z0-9-]*$/;
|
|
19
|
+
function v(e) {
|
|
19
20
|
for (let t of e.querySelectorAll("*")) {
|
|
20
|
-
let n =
|
|
21
|
-
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(
|
|
21
|
+
let n = g.exec(t.tagName.toLowerCase())?.[1];
|
|
22
|
+
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(ee(t, `${n}:`));
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function ee(e, t) {
|
|
25
26
|
let n = e.tagName.toLowerCase().slice(t.length);
|
|
26
|
-
if (!
|
|
27
|
-
let r = e.ownerDocument.createElementNS(
|
|
27
|
+
if (!_.test(n)) return e;
|
|
28
|
+
let r = e.ownerDocument.createElementNS(h, n);
|
|
28
29
|
for (let t of e.attributes) r.setAttribute(t.name, t.value);
|
|
29
30
|
for (let n of [...e.childNodes]) {
|
|
30
31
|
let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
|
|
31
|
-
r.appendChild(e ?
|
|
32
|
+
r.appendChild(e ? ee(n, t) : n);
|
|
32
33
|
}
|
|
33
34
|
return r;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
//#region src/elementary-math.ts
|
|
37
|
-
var
|
|
38
|
+
var te = /* @__PURE__ */ new Set([
|
|
38
39
|
"updiagonalstrike",
|
|
39
40
|
"downdiagonalstrike",
|
|
40
41
|
"verticalstrike",
|
|
41
42
|
"horizontalstrike"
|
|
42
|
-
]),
|
|
43
|
+
]), ne = {
|
|
43
44
|
thin: "0.035em",
|
|
44
45
|
medium: "0.07em",
|
|
45
46
|
thick: "0.14em"
|
|
46
|
-
},
|
|
47
|
+
}, y = {
|
|
47
48
|
tight: "0em",
|
|
48
49
|
medium: "0.1em",
|
|
49
50
|
loose: "0.2em"
|
|
50
|
-
},
|
|
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([
|
|
51
52
|
"mn",
|
|
52
53
|
"mo",
|
|
53
54
|
"mi",
|
|
54
55
|
"mtext"
|
|
55
|
-
]),
|
|
56
|
+
]), se = /* @__PURE__ */ new Set([
|
|
56
57
|
"stackalign",
|
|
57
58
|
"charalign",
|
|
58
59
|
"charspacing",
|
|
59
60
|
"longdivstyle"
|
|
60
61
|
]);
|
|
61
|
-
function
|
|
62
|
-
let i = e.createElementNS(
|
|
62
|
+
function b(e, t, n = [], r = {}) {
|
|
63
|
+
let i = e.createElementNS(h, t);
|
|
63
64
|
for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
|
|
64
65
|
for (let e of n) e && i.appendChild(e);
|
|
65
66
|
return i;
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
-
let n =
|
|
68
|
+
function x(e, t) {
|
|
69
|
+
let n = b(e.document, "mo");
|
|
69
70
|
return n.textContent = t, n;
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
-
let t =
|
|
73
|
-
return t.textContent = "0",
|
|
72
|
+
function S(e) {
|
|
73
|
+
let t = b(e.document, "mn");
|
|
74
|
+
return t.textContent = "0", b(e.document, "mphantom", [t]);
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function C(e, t) {
|
|
76
77
|
return e.getAttribute(t)?.trim().toLowerCase() || void 0;
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function w(e, t) {
|
|
79
80
|
let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
80
81
|
return Number.isFinite(n) ? n : 0;
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function T(e) {
|
|
83
84
|
return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function E(e, t, n = e) {
|
|
86
87
|
switch (t) {
|
|
87
88
|
case "left": return 0;
|
|
88
89
|
case "center": return Math.floor(e / 2);
|
|
@@ -90,14 +91,14 @@ function T(e, t, n = e) {
|
|
|
90
91
|
default: return n;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function D(e, t, n) {
|
|
94
95
|
let r = [], i, a, o = (e, t) => {
|
|
95
96
|
let s = (e) => t.reduceRight((e, t) => {
|
|
96
97
|
let n = t.cloneNode(!1);
|
|
97
98
|
return n.appendChild(e), n;
|
|
98
99
|
}, e);
|
|
99
100
|
if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
|
|
100
|
-
else if (
|
|
101
|
+
else if (T(e)) r.push(null);
|
|
101
102
|
else if (e.localName === "mn" && e.children.length === 0) {
|
|
102
103
|
let t = [...(e.textContent ?? "").trim()];
|
|
103
104
|
for (let a of t) {
|
|
@@ -106,28 +107,28 @@ function E(e, t, n) {
|
|
|
106
107
|
t.textContent = a, r.push(s(t));
|
|
107
108
|
}
|
|
108
109
|
t.length && (a ??= r.length);
|
|
109
|
-
} else
|
|
110
|
+
} else oe.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
|
|
110
111
|
};
|
|
111
112
|
for (let t of e) o(t, []);
|
|
112
113
|
return {
|
|
113
114
|
kind: "digits",
|
|
114
115
|
cells: r,
|
|
115
|
-
anchor:
|
|
116
|
+
anchor: E(r.length, n.stackAlign, i ?? a),
|
|
116
117
|
position: t
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
return (e ?? "").toLowerCase().split(/\s+/).filter((e) =>
|
|
120
|
+
function O(e) {
|
|
121
|
+
return (e ?? "").toLowerCase().split(/\s+/).filter((e) => te.has(e));
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
-
let n = [...e.children].filter((e) => !
|
|
124
|
-
return n.length <= 1 ? n[0] ?? null :
|
|
123
|
+
function ce(e, t) {
|
|
124
|
+
let n = [...e.children].filter((e) => !T(e));
|
|
125
|
+
return n.length <= 1 ? n[0] ?? null : b(t.document, "mrow", n);
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
-
let r =
|
|
128
|
-
content:
|
|
129
|
-
location:
|
|
130
|
-
crossout: e.hasAttribute("crossout") ?
|
|
127
|
+
function le(e, t, n) {
|
|
128
|
+
let r = C(e, "location") ?? "n", i = O(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
|
|
129
|
+
content: ce(e, n),
|
|
130
|
+
location: C(e, "location") ?? r,
|
|
131
|
+
crossout: e.hasAttribute("crossout") ? O(e.getAttribute("crossout")) : i
|
|
131
132
|
} : {
|
|
132
133
|
content: e,
|
|
133
134
|
location: r,
|
|
@@ -136,60 +137,60 @@ function ie(e, t, n) {
|
|
|
136
137
|
return {
|
|
137
138
|
kind: "carries",
|
|
138
139
|
carries: a,
|
|
139
|
-
anchor:
|
|
140
|
+
anchor: E(a.length, n.stackAlign),
|
|
140
141
|
position: t,
|
|
141
|
-
scale:
|
|
142
|
+
scale: ae.test(o) ? o : "0.6"
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
-
let t =
|
|
146
|
-
return `${n} solid ${
|
|
145
|
+
function k(e) {
|
|
146
|
+
let t = C(e, "mslinethickness") ?? "medium", n = ne[t] ?? (re.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
|
|
147
|
+
return `${n} solid ${ie.test(r) ? r : "currentColor"}`;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
-
let r = Math.max(0,
|
|
149
|
+
function ue(e, t, n) {
|
|
150
|
+
let r = Math.max(0, w(e, "length"));
|
|
150
151
|
return {
|
|
151
152
|
kind: "line",
|
|
152
153
|
length: r,
|
|
153
|
-
anchor:
|
|
154
|
+
anchor: E(r, n.stackAlign),
|
|
154
155
|
position: t,
|
|
155
|
-
border:
|
|
156
|
+
border: k(e)
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
+
function A(e, t, n, r, i) {
|
|
159
160
|
e.forEach((e, a) => {
|
|
160
|
-
let o = t + a * n +
|
|
161
|
+
let o = t + a * n + w(e, "position");
|
|
161
162
|
switch (e.localName) {
|
|
162
163
|
case "msgroup":
|
|
163
|
-
|
|
164
|
+
A([...e.children], o, w(e, "shift"), r, i);
|
|
164
165
|
break;
|
|
165
166
|
case "msline":
|
|
166
|
-
i.push(
|
|
167
|
+
i.push(ue(e, o, r));
|
|
167
168
|
break;
|
|
168
169
|
case "mscarries":
|
|
169
|
-
i.push(
|
|
170
|
+
i.push(le(e, o, r));
|
|
170
171
|
break;
|
|
171
172
|
case "msrow":
|
|
172
173
|
case "mrow":
|
|
173
|
-
i.push(
|
|
174
|
+
i.push(D([...e.children], o, r));
|
|
174
175
|
break;
|
|
175
|
-
default: i.push(
|
|
176
|
+
default: i.push(D([e], o, r));
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function j(e) {
|
|
180
181
|
return -e.anchor - e.position;
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
+
function de(e) {
|
|
183
184
|
return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
186
|
+
function fe(e) {
|
|
187
|
+
return j(e) + de(e) - 1;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
let i = (e) =>
|
|
189
|
+
function pe(e, t, n, r) {
|
|
190
|
+
let i = (e) => b(r.document, "mpadded", [t], {
|
|
190
191
|
width: "0",
|
|
191
192
|
...e ? { lspace: e } : {}
|
|
192
|
-
}), a = (e, t) =>
|
|
193
|
+
}), a = (e, t) => b(r.document, e, t);
|
|
193
194
|
switch (n) {
|
|
194
195
|
case "s": return a("munder", [e, i("-0.5width")]);
|
|
195
196
|
case "ne": return a("msup", [e, i()]);
|
|
@@ -211,49 +212,49 @@ function oe(e, t, n, r) {
|
|
|
211
212
|
default: return a("mover", [e, i("-0.5width")]);
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
function
|
|
215
|
-
let r =
|
|
215
|
+
function me(e, t, n) {
|
|
216
|
+
let r = b(n.document, "menclose", [e], {
|
|
216
217
|
notation: t.join(" "),
|
|
217
218
|
"data-padding": "0.1em",
|
|
218
219
|
"data-thickness": "0.067em"
|
|
219
220
|
}), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
|
|
220
|
-
return i ?
|
|
221
|
+
return i ? b(n.document, "mpadded", [r], {
|
|
221
222
|
lspace: `-${i}em`,
|
|
222
223
|
width: `-${2 * i}em`
|
|
223
224
|
}) : r;
|
|
224
225
|
}
|
|
225
|
-
function
|
|
226
|
-
let a = e && t.crossout.length ?
|
|
226
|
+
function he(e, t, n, r, i) {
|
|
227
|
+
let a = e && t.crossout.length ? me(e, t.crossout, i) : e;
|
|
227
228
|
if (!t.content) return a;
|
|
228
|
-
let o =
|
|
229
|
-
return
|
|
229
|
+
let o = b(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
|
|
230
|
+
return pe(a ?? S(i), o, n, i);
|
|
230
231
|
}
|
|
231
|
-
function
|
|
232
|
-
return e.carries[t -
|
|
232
|
+
function M(e, t) {
|
|
233
|
+
return e.carries[t - j(e)] ?? null;
|
|
233
234
|
}
|
|
234
|
-
function
|
|
235
|
+
function ge(e, t, n, r) {
|
|
235
236
|
let i = e.content;
|
|
236
237
|
n.forEach((e, a) => {
|
|
237
|
-
let o = n.length - 1 - a, s = n[o], c =
|
|
238
|
+
let o = n.length - 1 - a, s = n[o], c = M(s, t), l = n.slice(0, o).some((e) => M(e, t));
|
|
238
239
|
if (!c && !l) return;
|
|
239
240
|
let u = c ?? {
|
|
240
|
-
content:
|
|
241
|
+
content: S(r),
|
|
241
242
|
location: "n",
|
|
242
243
|
crossout: []
|
|
243
244
|
}, d = a === 0 ? u.location : "n";
|
|
244
|
-
i =
|
|
245
|
+
i = he(i, u, d, s.scale, r);
|
|
245
246
|
}), e.content = i;
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
-
let n = e.filter((e) =>
|
|
248
|
+
function N(e, t) {
|
|
249
|
+
let n = e.filter((e) => de(e) > 0), r = Math.min(0, ...n.map(j)), i = Math.max(r, ...n.map(fe)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
|
|
249
250
|
content: null,
|
|
250
251
|
borders: {}
|
|
251
|
-
})), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a +
|
|
252
|
+
})), 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) => {
|
|
252
253
|
let n = c();
|
|
253
254
|
e.cells.forEach((t, r) => {
|
|
254
|
-
n[a +
|
|
255
|
+
n[a + j(e) + r].content = t;
|
|
255
256
|
}), u.length && n.forEach((e, n) => {
|
|
256
|
-
|
|
257
|
+
ge(e, n - a, u, t);
|
|
257
258
|
});
|
|
258
259
|
for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
|
|
259
260
|
u = [], d = [], s.set(e, o.length), o.push(n);
|
|
@@ -273,44 +274,44 @@ function P(e, t) {
|
|
|
273
274
|
origin: a
|
|
274
275
|
};
|
|
275
276
|
}
|
|
276
|
-
function
|
|
277
|
-
let r =
|
|
277
|
+
function P(e, { rows: t }, n) {
|
|
278
|
+
let r = b(n.document, "mtable", t.map((e) => b(n.document, "mtr", e.map((e) => {
|
|
278
279
|
let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
|
|
279
|
-
return
|
|
280
|
+
return b(n.document, "mtd", [e.content], {
|
|
280
281
|
...t ? { style: t } : {},
|
|
281
282
|
...e.align ? { columnalign: e.align } : {}
|
|
282
283
|
});
|
|
283
284
|
}))));
|
|
284
|
-
for (let { name: t, value: n } of [...e.attributes])
|
|
285
|
-
let i =
|
|
286
|
-
return r.setAttribute("columnspacing",
|
|
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", y[i] ?? (re.test(i) ? i : y.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
+
function F(e) {
|
|
289
290
|
return {
|
|
290
291
|
document: e.ownerDocument,
|
|
291
|
-
stackAlign:
|
|
292
|
+
stackAlign: C(e, "stackalign") ?? "decimalpoint",
|
|
292
293
|
decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
|
|
293
294
|
};
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
-
let t =
|
|
297
|
-
return
|
|
296
|
+
function _e(e) {
|
|
297
|
+
let t = F(e), n = [];
|
|
298
|
+
return A([...e.children], 0, 0, t, n), P(e, N(n, t), t);
|
|
298
299
|
}
|
|
299
|
-
function
|
|
300
|
+
function I(e, t, n, r, i, a) {
|
|
300
301
|
for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
|
|
301
302
|
}
|
|
302
|
-
function
|
|
303
|
-
let n =
|
|
304
|
-
return n.setAttribute("minsize", "1.2em"), [
|
|
303
|
+
function ve(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], {
|
|
305
306
|
voffset: "0.1em",
|
|
306
307
|
lspace: "-0.15em",
|
|
307
308
|
depth: "-0.2em",
|
|
308
309
|
height: "-0.2em"
|
|
309
310
|
})];
|
|
310
311
|
}
|
|
311
|
-
function
|
|
312
|
-
let t =
|
|
313
|
-
|
|
312
|
+
function ye(e) {
|
|
313
|
+
let t = F(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 = [];
|
|
314
|
+
A(i, 0, 0, t, l);
|
|
314
315
|
let u = l.find((e) => e.kind === "digits");
|
|
315
316
|
u || (u = {
|
|
316
317
|
kind: "digits",
|
|
@@ -322,51 +323,51 @@ function fe(e) {
|
|
|
322
323
|
u.cells.unshift(...e), u.anchor += e.length;
|
|
323
324
|
}, p = (...e) => {
|
|
324
325
|
let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
|
|
325
|
-
u.cells.push(...
|
|
326
|
+
u.cells.push(...D(n, 0, t).cells);
|
|
326
327
|
};
|
|
327
328
|
switch (s) {
|
|
328
329
|
case "left/\\right":
|
|
329
|
-
f(a,
|
|
330
|
+
f(a, x(t, "/")), p(x(t, "\\"), o);
|
|
330
331
|
break;
|
|
331
332
|
case "left)(right":
|
|
332
|
-
f(a,
|
|
333
|
+
f(a, x(t, ")")), p(x(t, "("), o);
|
|
333
334
|
break;
|
|
334
335
|
case ":right=right":
|
|
335
|
-
p(
|
|
336
|
+
p(x(t, ":"), a, x(t, "="), o);
|
|
336
337
|
break;
|
|
337
338
|
case "righttop":
|
|
338
339
|
case "stackedleftlinetop":
|
|
339
340
|
case "lefttop":
|
|
340
|
-
o &&
|
|
341
|
+
o && A([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...ve(a, t));
|
|
341
342
|
break;
|
|
342
343
|
}
|
|
343
|
-
let m =
|
|
344
|
+
let m = N(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 + fe(e)));
|
|
344
345
|
switch (s) {
|
|
345
346
|
case "left/\\right":
|
|
346
347
|
case "left)(right":
|
|
347
348
|
case ":right=right": break;
|
|
348
349
|
case "righttop": {
|
|
349
350
|
let e = h[g][_(u.cells.length - 1)];
|
|
350
|
-
e.borders.left = c, e.borders.bottom = c,
|
|
351
|
+
e.borders.left = c, e.borders.bottom = c, I(h, g, _(0), _(u.cells.length - 1), "top", c);
|
|
351
352
|
break;
|
|
352
353
|
}
|
|
353
354
|
case "stackedleftlinetop": {
|
|
354
355
|
let e = h[g][_(0)];
|
|
355
|
-
e.borders.right = c, e.borders.bottom = c,
|
|
356
|
+
e.borders.right = c, e.borders.bottom = c, I(h, g, _(1), v, "top", c);
|
|
356
357
|
break;
|
|
357
358
|
}
|
|
358
359
|
case "stackedrightright":
|
|
359
360
|
case "mediumstackedrightright":
|
|
360
361
|
case "shortstackedrightright":
|
|
361
362
|
case "stackedleftleft":
|
|
362
|
-
|
|
363
|
+
be(h, g, s, a, o, c, t);
|
|
363
364
|
break;
|
|
364
|
-
default:
|
|
365
|
+
default: I(h, g, _(1), v, "top", c);
|
|
365
366
|
}
|
|
366
|
-
return
|
|
367
|
+
return P(e, m, t);
|
|
367
368
|
}
|
|
368
|
-
function
|
|
369
|
-
let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e &&
|
|
369
|
+
function be(e, t, n, r, i, a, o) {
|
|
370
|
+
let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && b(o.document, "mpadded", [e], {
|
|
370
371
|
lspace: "0.2em",
|
|
371
372
|
width: "+0.4em"
|
|
372
373
|
});
|
|
@@ -385,307 +386,315 @@ function pe(e, t, n, r, i, a, o) {
|
|
|
385
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);
|
|
386
387
|
});
|
|
387
388
|
}
|
|
388
|
-
function
|
|
389
|
-
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ?
|
|
389
|
+
function xe(e) {
|
|
390
|
+
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? _e(t) : ye(t));
|
|
390
391
|
}
|
|
391
392
|
//#endregion
|
|
392
393
|
//#region src/explorer-styles.ts
|
|
393
|
-
var
|
|
394
|
+
var Se = "PIE-MJX-explorer-styles", L = "var(--pie-text, black)", Ce = "var(--pie-background, #ffffff)", we = "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)`, Te = `
|
|
394
395
|
:root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
|
|
395
|
-
color: ${
|
|
396
|
-
fill: ${
|
|
396
|
+
color: ${L} !important;
|
|
397
|
+
fill: ${L} !important;
|
|
397
398
|
}
|
|
398
399
|
:root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
|
|
399
|
-
background-color: ${
|
|
400
|
+
background-color: ${z} !important;
|
|
400
401
|
}
|
|
401
402
|
:root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
|
|
402
|
-
fill: ${
|
|
403
|
+
fill: ${z} !important;
|
|
403
404
|
}
|
|
404
405
|
:root mjx-container .mjx-selected {
|
|
405
|
-
outline: 2px solid ${
|
|
406
|
+
outline: 2px solid ${R} !important;
|
|
406
407
|
}
|
|
407
408
|
:root mjx-container [data-sre-highlight-2] {
|
|
408
|
-
color: ${
|
|
409
|
+
color: ${L} !important;
|
|
409
410
|
background-color: transparent !important;
|
|
410
|
-
fill: ${
|
|
411
|
-
outline: 2px dashed ${
|
|
411
|
+
fill: ${L} !important;
|
|
412
|
+
outline: 2px dashed ${R} !important;
|
|
412
413
|
}
|
|
413
414
|
:root mjx-container rect[data-sre-highlight-2] {
|
|
414
415
|
fill: transparent !important;
|
|
415
|
-
stroke: ${
|
|
416
|
+
stroke: ${R} !important;
|
|
416
417
|
stroke-width: 2px !important;
|
|
417
418
|
vector-effect: non-scaling-stroke;
|
|
418
419
|
}
|
|
419
420
|
:root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
|
|
420
|
-
color: ${
|
|
421
|
-
background-color: ${
|
|
422
|
-
border-color: ${
|
|
421
|
+
color: ${L} !important;
|
|
422
|
+
background-color: ${Ce} !important;
|
|
423
|
+
border-color: ${we} !important;
|
|
423
424
|
}
|
|
424
425
|
:root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
|
|
425
|
-
color: ${
|
|
426
|
-
background-color: ${
|
|
426
|
+
color: ${L} !important;
|
|
427
|
+
background-color: ${z} !important;
|
|
427
428
|
}
|
|
428
429
|
`;
|
|
429
|
-
function
|
|
430
|
+
function Ee(e = document) {
|
|
430
431
|
if (e.getElementById("PIE-MJX-explorer-styles")) return;
|
|
431
432
|
let t = e.createElement("style");
|
|
432
|
-
t.id =
|
|
433
|
+
t.id = Se, t.textContent = Te, e.head.appendChild(t);
|
|
433
434
|
}
|
|
434
435
|
//#endregion
|
|
435
436
|
//#region src/unsupported-page.ts
|
|
436
|
-
var
|
|
437
|
-
function
|
|
437
|
+
var B = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", V = "pie-mathjax-version-conflict", H = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
|
|
438
|
+
function De(e, t) {
|
|
438
439
|
if (typeof window > "u") return;
|
|
439
440
|
let n = globalThis;
|
|
440
|
-
n[
|
|
441
|
+
n[H] ??= {
|
|
441
442
|
logged: !1,
|
|
442
443
|
conditions: []
|
|
443
444
|
};
|
|
444
|
-
let r = n[
|
|
445
|
+
let r = n[H];
|
|
445
446
|
if (r.conditions.includes(e)) return;
|
|
446
447
|
r.conditions.push(e);
|
|
447
|
-
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 ${
|
|
448
|
-
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(
|
|
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 ${B}`;
|
|
449
|
+
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(V, { detail: {
|
|
449
450
|
condition: e,
|
|
450
451
|
message: i,
|
|
451
|
-
docsUrl:
|
|
452
|
+
docsUrl: B
|
|
452
453
|
} }));
|
|
453
454
|
}
|
|
454
455
|
//#endregion
|
|
455
456
|
//#region src/adapter.ts
|
|
456
|
-
var
|
|
457
|
+
var Oe = {
|
|
457
458
|
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
458
459
|
overarc: "\\overparen",
|
|
459
460
|
napprox: "\\not\\approx",
|
|
460
461
|
longdiv: "\\enclose{longdiv}",
|
|
461
462
|
abs: ["\\left|#1\\right|", 1]
|
|
462
|
-
},
|
|
463
|
+
}, ke = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", Ae = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, je = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, Me = /\\embed\{newLine\}\[\]/g, Ne = [
|
|
463
464
|
["$$", "$$"],
|
|
464
465
|
["$", "$"],
|
|
465
466
|
["\\[", "\\]"],
|
|
466
467
|
["\\(", "\\)"]
|
|
467
|
-
],
|
|
468
|
+
], U = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Pe = "MJX-CHTML-styles", Fe = "PIE-MJX-SVG-styles", W = "PIE-MathJax-Menu-Settings", Ie = { "mjx-container[overflow=\"linebreak\"][display]": {
|
|
468
469
|
overflow: "auto clip",
|
|
469
470
|
"min-width": "initial !important"
|
|
470
|
-
} },
|
|
471
|
-
function
|
|
471
|
+
} }, Le = 200, Re = 201;
|
|
472
|
+
function G(e) {
|
|
472
473
|
let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
|
|
473
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");
|
|
474
475
|
}
|
|
475
|
-
function
|
|
476
|
-
for (let [t, n] of
|
|
476
|
+
function K(e) {
|
|
477
|
+
for (let [t, n] of Ne) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
|
|
477
478
|
return e;
|
|
478
479
|
}
|
|
479
|
-
function
|
|
480
|
-
return
|
|
480
|
+
function ze(e) {
|
|
481
|
+
return K(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
|
|
481
482
|
}
|
|
482
|
-
var
|
|
483
|
-
function
|
|
484
|
-
let n = e.closest(`.${
|
|
485
|
-
return n !== null && t.contains(n) && !n.classList.contains(
|
|
483
|
+
var Be = "mathjax_ignore", q = "mathjax_process";
|
|
484
|
+
function Ve(e, t) {
|
|
485
|
+
let n = e.closest(`.${Be}, .${q}`);
|
|
486
|
+
return n !== null && t.contains(n) && !n.classList.contains(q);
|
|
486
487
|
}
|
|
487
|
-
function
|
|
488
|
+
function He(e) {
|
|
488
489
|
for (let t of e.querySelectorAll("[data-latex]")) {
|
|
489
|
-
if (t.dataset.mathHandled || t.closest("mjx-container") ||
|
|
490
|
+
if (t.dataset.mathHandled || t.closest("mjx-container") || Ve(t, e)) continue;
|
|
490
491
|
let n = t.textContent;
|
|
491
|
-
n && (t.textContent = `\\(${
|
|
492
|
+
n && (t.textContent = `\\(${ze(n)}\\)`.replace(Me, "\\newline "), t.dataset.mathHandled = "true");
|
|
492
493
|
}
|
|
493
494
|
}
|
|
494
|
-
function
|
|
495
|
+
function Ue(e) {
|
|
495
496
|
for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
|
|
496
497
|
}
|
|
497
|
-
function
|
|
498
|
+
function We(e, t) {
|
|
498
499
|
for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
|
|
499
|
-
return (t ?
|
|
500
|
+
return (t ? je : Ae).test(e.textContent ?? "");
|
|
500
501
|
}
|
|
501
|
-
function
|
|
502
|
-
return new Promise((
|
|
503
|
-
let { useSingleDollar:
|
|
502
|
+
function Ge(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 = {
|
|
504
505
|
loader: {
|
|
505
|
-
load:
|
|
506
|
-
failed: (e) =>
|
|
506
|
+
load: u ? ["a11y/assistive-mml"] : [],
|
|
507
|
+
failed: (e) => s(e),
|
|
507
508
|
"output/svg": { ready: (e) => {
|
|
508
|
-
let
|
|
509
|
-
return
|
|
509
|
+
let t = o();
|
|
510
|
+
return J(t) && Y(t), e;
|
|
510
511
|
} }
|
|
511
512
|
},
|
|
512
513
|
startup: {
|
|
513
514
|
typeset: !1,
|
|
514
515
|
ready: () => {
|
|
515
|
-
let e =
|
|
516
|
-
|
|
516
|
+
let e = o(), n = e?.startup, i = J(e);
|
|
517
|
+
i && (Y(e), Ke(e, p.speechLocales), t(e?._?.a11y?.sre_ts?.locales, p.speechLocales)), n?.defaultReady?.(), i && (qe(n?.document), n?.document?.addStyles?.(Ie), r(n?.document)), Promise.resolve(n?.promise).then(() => a(), s);
|
|
517
518
|
}
|
|
518
519
|
},
|
|
519
|
-
tex: { macros: { ...
|
|
520
|
+
tex: { macros: { ...Oe } },
|
|
520
521
|
output: { displayOverflow: "linebreak" },
|
|
521
522
|
options: {
|
|
522
|
-
enableMenu:
|
|
523
|
+
enableMenu: u,
|
|
523
524
|
menuOptions: { settings: {
|
|
524
|
-
assistiveMml:
|
|
525
|
+
assistiveMml: u,
|
|
525
526
|
enrich: !1,
|
|
526
527
|
inTabOrder: !1
|
|
527
528
|
} },
|
|
528
529
|
a11y: { inTabOrder: !1 }
|
|
529
530
|
}
|
|
530
531
|
};
|
|
531
|
-
|
|
532
|
+
l && m.tex && (console.warn(ke), 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);
|
|
532
540
|
});
|
|
533
541
|
}
|
|
534
|
-
function
|
|
542
|
+
function J(e) {
|
|
535
543
|
return !!e?.version?.startsWith("4.");
|
|
536
544
|
}
|
|
537
|
-
function
|
|
545
|
+
function Y(e) {
|
|
538
546
|
let t = e?._?.output, n = t?.chtml_ts?.CHTML;
|
|
539
|
-
n && (n.STYLESHEETID =
|
|
547
|
+
n && (n.STYLESHEETID = p);
|
|
540
548
|
let r = t?.svg_ts?.SVG;
|
|
541
|
-
r && (r.STYLESHEETID =
|
|
549
|
+
r && (r.STYLESHEETID = Fe);
|
|
542
550
|
}
|
|
543
|
-
function
|
|
544
|
-
let
|
|
545
|
-
if (
|
|
546
|
-
|
|
551
|
+
function Ke(e, t) {
|
|
552
|
+
let n = e?._?.ui?.menu?.Menu?.Menu;
|
|
553
|
+
if (n) {
|
|
554
|
+
n.MENU_STORAGE = W;
|
|
547
555
|
try {
|
|
548
|
-
let e = localStorage.getItem(
|
|
556
|
+
let e = localStorage.getItem(W);
|
|
549
557
|
if (!e) return;
|
|
550
|
-
let { assistiveMml:
|
|
551
|
-
if (
|
|
552
|
-
Object.keys(
|
|
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(W, JSON.stringify(i)) : localStorage.removeItem(W);
|
|
553
561
|
} catch {}
|
|
554
562
|
}
|
|
555
563
|
}
|
|
556
|
-
function
|
|
564
|
+
function qe(e) {
|
|
557
565
|
if (!e) return;
|
|
558
566
|
let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
|
|
559
567
|
let n = e.typesetRoot;
|
|
560
|
-
!n || t.has(n) || (
|
|
568
|
+
!n || t.has(n) || (G(n), t.add(n));
|
|
561
569
|
};
|
|
562
|
-
e.addRenderAction?.("pie-strip-latex",
|
|
570
|
+
e.addRenderAction?.("pie-strip-latex", Re, (e) => {
|
|
563
571
|
for (let t of e.math ?? []) n(t);
|
|
564
572
|
return !1;
|
|
565
573
|
}, (e) => {
|
|
566
574
|
let t = e.typesetRoot;
|
|
567
|
-
return t &&
|
|
575
|
+
return t && G(t), !1;
|
|
568
576
|
});
|
|
569
577
|
let r = e.outputJax?.chtmlStyles;
|
|
570
|
-
r?.id ===
|
|
578
|
+
r?.id === Pe && (r.id = p), Ye();
|
|
571
579
|
}
|
|
572
|
-
function
|
|
573
|
-
return e instanceof HTMLStyleElement &&
|
|
580
|
+
function X(e) {
|
|
581
|
+
return e instanceof HTMLStyleElement && m.includes(e.id);
|
|
574
582
|
}
|
|
575
|
-
function
|
|
576
|
-
|
|
583
|
+
function Je(e) {
|
|
584
|
+
De("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
|
|
577
585
|
}
|
|
578
|
-
function
|
|
579
|
-
let e = document.head, t = [...e.children].find(
|
|
586
|
+
function Ye() {
|
|
587
|
+
let e = document.head, t = [...e.children].find(X);
|
|
580
588
|
if (t) {
|
|
581
|
-
|
|
589
|
+
Je(t);
|
|
582
590
|
return;
|
|
583
591
|
}
|
|
584
592
|
let n = new MutationObserver((e) => {
|
|
585
593
|
for (let t of e) {
|
|
586
|
-
let e = [...t.addedNodes].find(
|
|
594
|
+
let e = [...t.addedNodes].find(X);
|
|
587
595
|
if (e) {
|
|
588
|
-
|
|
596
|
+
Je(e), n.disconnect();
|
|
589
597
|
return;
|
|
590
598
|
}
|
|
591
599
|
}
|
|
592
600
|
});
|
|
593
601
|
n.observe(e, { childList: !0 });
|
|
594
602
|
}
|
|
595
|
-
function
|
|
603
|
+
function Xe(e) {
|
|
596
604
|
let t = e?.math;
|
|
597
605
|
if (!t?.remove) return;
|
|
598
|
-
let n = [...t].filter((e) => (e.state?.() ?? 0) >=
|
|
606
|
+
let n = [...t].filter((e) => (e.state?.() ?? 0) >= Le && e.typesetRoot?.isConnected === !1);
|
|
599
607
|
if (n.length !== 0) {
|
|
600
608
|
for (let e of [...n].reverse()) e.clear?.();
|
|
601
609
|
t.remove(...n);
|
|
602
610
|
}
|
|
603
611
|
}
|
|
604
|
-
function
|
|
605
|
-
return new Promise((
|
|
606
|
-
let
|
|
607
|
-
e.startup =
|
|
608
|
-
let
|
|
609
|
-
|
|
610
|
-
let e =
|
|
611
|
-
|
|
612
|
+
function Ze(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);
|
|
612
620
|
};
|
|
613
621
|
});
|
|
614
622
|
}
|
|
615
|
-
function
|
|
616
|
-
let
|
|
617
|
-
return
|
|
623
|
+
function Qe(e) {
|
|
624
|
+
let t = o();
|
|
625
|
+
return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Ze(t) : Ge(e);
|
|
618
626
|
}
|
|
619
|
-
function
|
|
620
|
-
return
|
|
621
|
-
|
|
627
|
+
function $e(e) {
|
|
628
|
+
return Qe(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.");
|
|
622
631
|
});
|
|
623
632
|
}
|
|
624
|
-
function
|
|
625
|
-
let t =
|
|
626
|
-
return n || (n =
|
|
633
|
+
function et(e) {
|
|
634
|
+
let t = l, n = t[U];
|
|
635
|
+
return n || (n = $e(e), t[U] = n), n;
|
|
627
636
|
}
|
|
628
|
-
function
|
|
629
|
-
let
|
|
630
|
-
return async (
|
|
637
|
+
function tt(e = {}) {
|
|
638
|
+
let t = e.useSingleDollar ?? !1;
|
|
639
|
+
return async (n) => {
|
|
631
640
|
if (typeof window > "u") return;
|
|
632
|
-
|
|
633
|
-
let
|
|
634
|
-
if (!
|
|
635
|
-
|
|
641
|
+
He(n), v(n), Ue(n), xe(n);
|
|
642
|
+
let r = et(e);
|
|
643
|
+
if (!We(n, t)) {
|
|
644
|
+
r.catch(() => {});
|
|
636
645
|
return;
|
|
637
646
|
}
|
|
638
|
-
await
|
|
639
|
-
let
|
|
640
|
-
if (await
|
|
641
|
-
|
|
647
|
+
await r;
|
|
648
|
+
let i = o();
|
|
649
|
+
if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
|
|
650
|
+
Ee(), Xe(i.startup?.document);
|
|
642
651
|
try {
|
|
643
|
-
await
|
|
652
|
+
await i.typesetPromise([n]);
|
|
644
653
|
} catch (e) {
|
|
645
|
-
throw
|
|
654
|
+
throw i.typesetClear?.([n]), e;
|
|
646
655
|
}
|
|
647
|
-
|
|
656
|
+
G(n);
|
|
648
657
|
}
|
|
649
658
|
};
|
|
650
659
|
}
|
|
651
|
-
function
|
|
660
|
+
function nt() {
|
|
652
661
|
return [];
|
|
653
662
|
}
|
|
654
663
|
//#endregion
|
|
655
664
|
//#region src/render-math.ts
|
|
656
|
-
var
|
|
657
|
-
function
|
|
658
|
-
return !!window[
|
|
665
|
+
var rt = "@pie-lib/math-rendering", it = "@pie-lib/math-rendering@2", at = "pie-print", ot = 50, st = 1e4, Z = null;
|
|
666
|
+
function ct() {
|
|
667
|
+
return !!window[it]?.opts?.useSingleDollar;
|
|
659
668
|
}
|
|
660
|
-
function
|
|
661
|
-
return
|
|
669
|
+
function lt() {
|
|
670
|
+
return Z ||= tt({ useSingleDollar: ct() }), Z;
|
|
662
671
|
}
|
|
663
672
|
function Q() {
|
|
664
673
|
if (typeof window > "u") return null;
|
|
665
|
-
let e = window[
|
|
674
|
+
let e = window[rt];
|
|
666
675
|
return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
|
|
667
676
|
}
|
|
668
|
-
function
|
|
677
|
+
function ut(e) {
|
|
669
678
|
let t = e;
|
|
670
679
|
for (; t;) {
|
|
671
|
-
if (t instanceof Element && t.localName ===
|
|
680
|
+
if (t instanceof Element && t.localName === at) return t;
|
|
672
681
|
t = t instanceof ShadowRoot ? t.host : t.parentNode;
|
|
673
682
|
}
|
|
674
683
|
return null;
|
|
675
684
|
}
|
|
676
|
-
function
|
|
685
|
+
function dt() {
|
|
677
686
|
let e = window.renderMath;
|
|
678
687
|
return typeof e == "function" ? e : null;
|
|
679
688
|
}
|
|
680
|
-
async function
|
|
681
|
-
let t =
|
|
689
|
+
async function ft(e) {
|
|
690
|
+
let t = ut(e);
|
|
682
691
|
if (!t) return null;
|
|
683
|
-
let n =
|
|
692
|
+
let n = dt();
|
|
684
693
|
if (n || t.mathRenderingModuleUrlImported !== !0) return n;
|
|
685
|
-
let r = Date.now() +
|
|
694
|
+
let r = Date.now() + st;
|
|
686
695
|
for (; Date.now() < r;) {
|
|
687
|
-
await new Promise((e) => setTimeout(e,
|
|
688
|
-
let e =
|
|
696
|
+
await new Promise((e) => setTimeout(e, ot));
|
|
697
|
+
let e = dt();
|
|
689
698
|
if (e) return e;
|
|
690
699
|
}
|
|
691
700
|
return null;
|
|
@@ -694,14 +703,14 @@ var $ = async (e) => {
|
|
|
694
703
|
if (typeof window > "u") return;
|
|
695
704
|
let t = typeof e == "string", n;
|
|
696
705
|
t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
|
|
697
|
-
let r = Q(), i = r || t ? null : await
|
|
698
|
-
return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await
|
|
699
|
-
},
|
|
706
|
+
let r = Q(), i = r || t ? null : await ft(n);
|
|
707
|
+
return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await lt()(n), t ? n.innerHTML : void 0;
|
|
708
|
+
}, pt = (e, t) => {
|
|
700
709
|
let n = Q()?.wrapMath?.(e, t);
|
|
701
710
|
if (n != null) return n;
|
|
702
711
|
let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
|
|
703
|
-
return `${r}${
|
|
704
|
-
},
|
|
712
|
+
return `${r}${K(e)}${i}`;
|
|
713
|
+
}, mt = (e) => {
|
|
705
714
|
let t = e.trim();
|
|
706
715
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
707
716
|
unwrapped: t.slice(2, -2).trim(),
|
|
@@ -728,6 +737,6 @@ var $ = async (e) => {
|
|
|
728
737
|
close: "$"
|
|
729
738
|
}
|
|
730
739
|
} : { unwrapped: t };
|
|
731
|
-
},
|
|
740
|
+
}, ht = (e) => Q()?.mmlToLatex?.(e) ?? e;
|
|
732
741
|
//#endregion
|
|
733
|
-
export {
|
|
742
|
+
export { V as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, B as UNSUPPORTED_PAGE_DOCS_URL, tt as createMathjaxRenderer, nt as getMathjaxCssUrls, ht as mmlToLatex, $ as renderMath, mt as unWrapMath, pt as wrapMath };
|