@pie-element/simple-cloze 0.1.4-next.14 → 0.1.4-next.16

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.
@@ -4668,131 +4668,212 @@ function create_custom_element(Component, props_definition, slots, exports, shad
4668
4668
  }
4669
4669
  //#endregion
4670
4670
  //#region ../../shared/math-rendering-mathjax/dist/index.js
4671
- var e$3 = {
4671
+ var e$3 = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page";
4672
+ var t$3 = "pie-mathjax-version-conflict";
4673
+ var n = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
4674
+ function r$2(r, i) {
4675
+ if (typeof window > "u") return;
4676
+ let a = globalThis;
4677
+ a[n] ?? (a[n] = {
4678
+ logged: !1,
4679
+ conditions: []
4680
+ });
4681
+ let o = a[n];
4682
+ if (o.conditions.includes(r)) return;
4683
+ o.conditions.push(r);
4684
+ let s = `[math-rendering] Unsupported page (${r}): ${i}. 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$3}`;
4685
+ o.logged || (o.logged = !0, console.error(s)), window.dispatchEvent(new CustomEvent(t$3, { detail: {
4686
+ condition: r,
4687
+ message: s,
4688
+ docsUrl: e$3
4689
+ } }));
4690
+ }
4691
+ function i() {
4692
+ let e = window.MathJax?.version;
4693
+ return typeof e == "string" && e.startsWith("3.") ? e : void 0;
4694
+ }
4695
+ var a = "https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js";
4696
+ var o = {
4672
4697
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
4673
4698
  overarc: "\\overparen",
4674
4699
  napprox: "\\not\\approx",
4675
4700
  longdiv: "\\enclose{longdiv}",
4676
4701
  abs: ["\\left|#1\\right|", 1]
4677
4702
  };
4678
- var t$3 = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)";
4679
- var n = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/;
4680
- var r$2 = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/;
4681
- var i = /\\embed\{newLine\}\[\]/g;
4682
- var a = [
4703
+ var s$1 = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)";
4704
+ var c$1 = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/;
4705
+ var l = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/;
4706
+ var u = /\\embed\{newLine\}\[\]/g;
4707
+ var d = [
4683
4708
  ["$$", "$$"],
4684
4709
  ["$", "$"],
4685
4710
  ["\\[", "\\]"],
4686
4711
  ["\\(", "\\)"]
4687
4712
  ];
4688
- var o = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
4689
- function s$1() {
4713
+ var f = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
4714
+ var p = "PIE-MJX-CHTML-styles";
4715
+ var m = "MJX-CHTML-styles";
4716
+ var h = [m, "MJX-SVG-styles"];
4717
+ var g = 201;
4718
+ function _(e) {
4719
+ let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
4720
+ 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");
4721
+ }
4722
+ function v() {
4690
4723
  return window.MathJax;
4691
4724
  }
4692
- function c$1(e) {
4725
+ function y(e) {
4693
4726
  let t = e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e;
4694
- for (let [e, n] of a) if (t.startsWith(e) && t.endsWith(n)) return t.substring(e.length, t.length - n.length);
4727
+ for (let [e, n] of d) if (t.startsWith(e) && t.endsWith(n)) return t.substring(e.length, t.length - n.length);
4695
4728
  return t;
4696
4729
  }
4697
- function l(e) {
4730
+ function b(e) {
4698
4731
  for (let t of e.querySelectorAll("[data-latex]")) {
4699
4732
  if (t.dataset.mathHandled || t.closest("mjx-container")) continue;
4700
4733
  let e = t.textContent;
4701
- e && (t.textContent = `\\(${c$1(e)}\\)`.replace(i, "\\newline "), t.dataset.mathHandled = "true");
4734
+ e && (t.textContent = `\\(${y(e)}\\)`.replace(u, "\\newline "), t.dataset.mathHandled = "true");
4702
4735
  }
4703
4736
  }
4704
- function u(e, t) {
4737
+ function x(e, t) {
4705
4738
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
4706
- return (t ? r$2 : n).test(e.textContent ?? "");
4739
+ return (t ? l : c$1).test(e.textContent ?? "");
4707
4740
  }
4708
- function d(n) {
4709
- return new Promise((r, i) => {
4710
- let { useSingleDollar: a = !1, accessibility: o = !0, loadFonts: c = !0, srcUrl: l } = n, u = {
4741
+ function S(e) {
4742
+ return new Promise((t, n) => {
4743
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: c = !0, srcUrl: l } = e, u = {
4711
4744
  loader: {
4712
- load: o ? ["a11y/assistive-mml"] : [],
4713
- failed: (e) => i(e)
4745
+ load: i ? ["a11y/assistive-mml"] : [],
4746
+ failed: (e) => n(e)
4714
4747
  },
4715
4748
  startup: {
4716
4749
  typeset: !1,
4717
4750
  ready: () => {
4718
- let e = s$1()?.startup;
4719
- e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => r(), i);
4751
+ let e = v(), r = e?.startup, i = !!e?.version?.startsWith("4.");
4752
+ i && C(e), r?.defaultReady?.(), i && w(r?.document), Promise.resolve(r?.promise).then(() => t(), n);
4720
4753
  }
4721
4754
  },
4722
- tex: { macros: { ...e$3 } },
4755
+ tex: { macros: { ...o } },
4723
4756
  options: {
4724
- enableMenu: o,
4757
+ enableMenu: i,
4725
4758
  menuOptions: { settings: {
4726
- assistiveMml: o,
4759
+ assistiveMml: i,
4727
4760
  enrich: !1,
4728
4761
  inTabOrder: !1
4729
4762
  } }
4730
4763
  }
4731
4764
  };
4732
- a && u.tex && (console.warn(t$3), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), c || (u.chtml = { fontURL: "" }), window.MathJax = u;
4765
+ r && u.tex && (console.warn(s$1), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), c || (u.chtml = { fontURL: "" }), window.MathJax = u;
4733
4766
  let d = document.createElement("script");
4734
- d.src = l || "https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js", d.async = !0, d.onerror = () => i(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(d);
4767
+ d.src = l || a, d.async = !0, d.onerror = () => n(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(d);
4735
4768
  });
4736
4769
  }
4737
- function f(e) {
4770
+ function C(e) {
4771
+ let t = e?._?.output?.chtml_ts?.CHTML;
4772
+ t && (t.STYLESHEETID = p);
4773
+ }
4774
+ function w(e) {
4775
+ if (!e) return;
4776
+ let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
4777
+ let n = e.typesetRoot;
4778
+ !n || t.has(n) || (_(n), t.add(n));
4779
+ };
4780
+ e.addRenderAction?.("pie-strip-latex", g, (e) => {
4781
+ for (let t of e.math ?? []) n(t);
4782
+ return !1;
4783
+ }, (e) => {
4784
+ let t = e.typesetRoot;
4785
+ return t && _(t), !1;
4786
+ });
4787
+ let r = e.outputJax?.chtmlStyles;
4788
+ r?.id === m && (r.id = p), D();
4789
+ }
4790
+ function T(e) {
4791
+ return e instanceof HTMLStyleElement && h.includes(e.id);
4792
+ }
4793
+ function E(e) {
4794
+ r$2("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
4795
+ }
4796
+ function D() {
4797
+ let e = document.head, t = [...e.children].find(T);
4798
+ if (t) {
4799
+ E(t);
4800
+ return;
4801
+ }
4802
+ let n = new MutationObserver((e) => {
4803
+ for (let t of e) {
4804
+ let e = [...t.addedNodes].find(T);
4805
+ if (e) {
4806
+ E(e), n.disconnect();
4807
+ return;
4808
+ }
4809
+ }
4810
+ });
4811
+ n.observe(e, { childList: !0 });
4812
+ }
4813
+ function O(e) {
4738
4814
  return new Promise((t, n) => {
4739
4815
  let r = e.startup ?? {};
4740
4816
  e.startup = r;
4741
4817
  let i = r.ready;
4742
4818
  r.ready = () => {
4743
- let e = s$1()?.startup;
4819
+ let e = v()?.startup;
4744
4820
  i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
4745
4821
  };
4746
4822
  });
4747
4823
  }
4748
- function p(e) {
4749
- let t = s$1();
4750
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : f(t) : d(e);
4824
+ function k(e) {
4825
+ let t = v();
4826
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : O(t) : S(e);
4751
4827
  }
4752
- function m(e) {
4753
- return p(e).then(() => {
4754
- typeof s$1()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
4828
+ function A(e) {
4829
+ return k(e).then(() => {
4830
+ typeof v()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
4755
4831
  });
4756
4832
  }
4757
- function h(e) {
4758
- let t = globalThis, n = t[o];
4759
- return n || (n = m(e), t[o] = n), n;
4833
+ function j(e) {
4834
+ let t = globalThis, n = t[f];
4835
+ return n || (n = A(e), t[f] = n), n;
4760
4836
  }
4761
- function g(e = {}) {
4837
+ function M(e = {}) {
4762
4838
  let t = e.useSingleDollar ?? !1;
4763
4839
  return async (n) => {
4764
4840
  if (typeof window > "u") return;
4765
- l(n);
4766
- let r = h(e);
4767
- if (!u(n, t)) {
4768
- r.catch(() => {});
4841
+ let a = i();
4842
+ a && r$2("mathjax-3-global", `window.MathJax is MathJax ${a}`), b(n);
4843
+ let o = j(e);
4844
+ if (!x(n, t)) {
4845
+ o.catch(() => {});
4769
4846
  return;
4770
4847
  }
4771
- await r;
4772
- let i = s$1();
4773
- await i?.startup?.promise, typeof i?.typesetPromise == "function" && await i.typesetPromise([n]);
4848
+ await o;
4849
+ let s = v();
4850
+ await s?.startup?.promise, typeof s?.typesetPromise == "function" && (await s.typesetPromise([n]), _(n));
4774
4851
  };
4775
4852
  }
4776
- var v = "@pie-lib/math-rendering";
4777
- var y = "@pie-lib/math-rendering@2";
4778
- var b = null;
4779
- function x() {
4780
- return !!window[y]?.opts?.useSingleDollar;
4853
+ var P = "@pie-lib/math-rendering";
4854
+ var F = "@pie-lib/math-rendering@2";
4855
+ var I = null;
4856
+ function L() {
4857
+ return !!window[F]?.opts?.useSingleDollar;
4781
4858
  }
4782
- function S() {
4783
- return b || (b = g({ useSingleDollar: x() })), b;
4859
+ function R() {
4860
+ return I || (I = M({ useSingleDollar: L() })), I;
4784
4861
  }
4785
- function C() {
4862
+ function z() {
4786
4863
  if (typeof window > "u") return null;
4787
- let e = window[v];
4864
+ let e = window[P];
4788
4865
  return typeof e?.renderMath == "function" ? e : null;
4789
4866
  }
4790
- var w = async (e) => {
4867
+ function B() {
4868
+ let e = i();
4869
+ e && r$2("legacy-renderer-delegation", `window['${P}'] renders this element's math with MathJax ${e}`);
4870
+ }
4871
+ var V = async (e) => {
4791
4872
  if (typeof window > "u") return;
4792
4873
  let t = typeof e == "string", n;
4793
4874
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
4794
- let r = C();
4795
- return r ? await r.renderMath?.(n) : await S()(n), t ? n.innerHTML : void 0;
4875
+ let r = z();
4876
+ return r ? (B(), await r.renderMath?.(n)) : await R()(n), t ? n.innerHTML : void 0;
4796
4877
  };
4797
4878
  //#endregion
4798
4879
  //#region ../../shared/translator/dist/en.js
@@ -7233,7 +7314,7 @@ function SimpleCloze($$anchor, $$props) {
7233
7314
  if (!get$1(promptElement) || !get$1(prompt)) return;
7234
7315
  const warn = (err) => console.warn("simple-cloze: MathJax render failed", err);
7235
7316
  try {
7236
- Promise.resolve(w(get$1(promptElement))).catch(warn);
7317
+ Promise.resolve(V(get$1(promptElement))).catch(warn);
7237
7318
  } catch (err) {
7238
7319
  warn(err);
7239
7320
  }