summaryrefslogtreecommitdiffstats
path: root/rust/wolfree_sed_in_place/src/include_str.js
blob: 9ef3a31e6c75d0c70d9961dcef1ae759caa91a09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* SPDX-License-Identifier: AGPL-3.0-or-later */

// @ts-check

const wolfreeLexicalScopeName = (() => {
  /** @type {string[]} */
  const possibleLetters = [];

  for (let i = 32; i < 127; i++) {
    possibleLetters.push(String.fromCharCode(i));
  }

  const possibleNames = possibleLetters.flatMap((x) =>
    possibleLetters.map((y) => x + y)
  );

  const isValid = (name = "") => {
    try {
      return (
        typeof eval(name).value === "string" &&
        typeof eval(name).i2d === "boolean"
      );
    } catch (error) {
      return false;
    }
  };

  const wolfreeLexicalScopeName = possibleNames.find(isValid);

  if (typeof wolfreeLexicalScopeName !== "string") {
    console.warn({ wolfreeLexicalScopeName });
    return "";
  }

  return wolfreeLexicalScopeName;
})();

(() => {
  const get = (params = "") => {
    return new URLSearchParams(location.search).get(params);
  };

  eval(wolfreeLexicalScopeName).value = get("i") || "topic mathematics";
  eval(wolfreeLexicalScopeName).i2d = get("i2d") === "true";
})();

/**
 * Regex in regex - Rust
 * https://docs.rs/regex/latest/regex/struct.Regex.html#replacement-string-syntax
 */
// @ts-ignore
$0;

(async () => {
  (
    await import(
      // @ts-ignore
      "/ajax/libs/wolfree/2023.8.31/js/entrypoint.js"
    )
  ).default({
    input: eval(wolfreeLexicalScopeName).value,
    ...(eval(wolfreeLexicalScopeName).i2d ? { i2d: true } : {}),
    podstate: ["Step-by-step solution", "Step-by-step", "Show all steps"],
  });
})();