From b6ebc5f88ffe9fb442238f160879ad47dd713d11 Mon Sep 17 00:00:00 2001
From: name <email@example.com>
Date: Fri, 11 Aug 2023 05:09:24 +0000
Subject: 2023-08-10

---
 rust/wolfree_sed_in_place/src/include_str.tsx | 71 +++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 rust/wolfree_sed_in_place/src/include_str.tsx

(limited to 'rust/wolfree_sed_in_place/src/include_str.tsx')

diff --git a/rust/wolfree_sed_in_place/src/include_str.tsx b/rust/wolfree_sed_in_place/src/include_str.tsx
new file mode 100644
index 0000000..3c8ff4e
--- /dev/null
+++ b/rust/wolfree_sed_in_place/src/include_str.tsx
@@ -0,0 +1,71 @@
+/**
+ * @license
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ * This file is part of Wolfree.
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ */
+
+// @ts-check
+
+const wolfreeLexicalScopeName = (() => {
+  const possibleLetters = Array();
+
+  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 = String()) => {
+    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.error({ wolfreeLexicalScopeName });
+    return "";
+  }
+
+  return wolfreeLexicalScopeName;
+})();
+
+(() => {
+  const get = (params = String()) => {
+    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
+ * All instances of $ref in the replacement string are replaced with the substring corresponding to the capture group identified by ref.
+ * ref may be an integer corresponding to the index of the capture group (counted by order of opening parenthesis where 0 is the entire match) or it can be a name (consisting of letters, digits or underscores) corresponding to a named capture group.
+ */
+// @ts-ignore
+$0;
+
+(async () => {
+  (
+    await import(
+      // @ts-ignore
+      "../../../ajax/libs/wolfree/23.7.8/js/Entrypoint.js"
+    )
+  ).default({
+    input: eval(wolfreeLexicalScopeName).value,
+    i2d: eval(wolfreeLexicalScopeName).i2d,
+    extraPodstates: [],
+  });
+})();
-- 
cgit v1.2.3

