@pie-element/element-player 0.1.4-next.20261006160832 → 0.1.4

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