kaabalah
Version:
The de-facto library for any esoteric calculations and tooling
1,110 lines (1,109 loc) • 148 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
// wasm/build/swisseph.js
var require_swisseph = __commonJS({
"wasm/build/swisseph.js"(exports, module) {
"use strict";
var SwissEphemerisModule = (() => {
var _scriptName = typeof document != "undefined" ? document.currentScript?.src : void 0;
if (typeof __filename != "undefined") _scriptName = _scriptName || __filename;
return async function(moduleArg = {}) {
var moduleRtn;
var Module = moduleArg;
var readyPromiseResolve, readyPromiseReject;
var readyPromise = new Promise((resolve, reject) => {
readyPromiseResolve = resolve;
readyPromiseReject = reject;
});
var ENVIRONMENT_IS_WEB = typeof window == "object";
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
if (ENVIRONMENT_IS_NODE) {
}
var moduleOverrides = { ...Module };
var arguments_ = [];
var thisProgram = "./this.program";
var quit_ = (status, toThrow) => {
throw toThrow;
};
var scriptDirectory = "";
function locateFile(path) {
if (Module["locateFile"]) {
return Module["locateFile"](path, scriptDirectory);
}
return scriptDirectory + path;
}
var readAsync, readBinary;
if (ENVIRONMENT_IS_NODE) {
if (typeof process == "undefined" || !process.release || process.release.name !== "node") throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
var nodeVersion = process.versions.node;
var numericVersion = nodeVersion.split(".").slice(0, 3);
numericVersion = numericVersion[0] * 1e4 + numericVersion[1] * 100 + numericVersion[2].split("-")[0] * 1;
if (numericVersion < 16e4) {
throw new Error("This emscripten-generated code requires node v16.0.0 (detected v" + nodeVersion + ")");
}
var fs = __require("fs");
var nodePath = __require("path");
scriptDirectory = __dirname + "/";
readBinary = (filename) => {
filename = isFileURI(filename) ? new URL(filename) : filename;
var ret = fs.readFileSync(filename);
assert(Buffer.isBuffer(ret));
return ret;
};
readAsync = async (filename, binary = true) => {
filename = isFileURI(filename) ? new URL(filename) : filename;
var ret = fs.readFileSync(filename, binary ? void 0 : "utf8");
assert(binary ? Buffer.isBuffer(ret) : typeof ret == "string");
return ret;
};
if (!Module["thisProgram"] && process.argv.length > 1) {
thisProgram = process.argv[1].replace(/\\/g, "/");
}
arguments_ = process.argv.slice(2);
quit_ = (status, toThrow) => {
process.exitCode = status;
throw toThrow;
};
} else if (ENVIRONMENT_IS_SHELL) {
if (typeof process == "object" && typeof __require === "function" || typeof window == "object" || typeof WorkerGlobalScope != "undefined") throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
if (ENVIRONMENT_IS_WORKER) {
scriptDirectory = self.location.href;
} else if (typeof document != "undefined" && document.currentScript) {
scriptDirectory = document.currentScript.src;
}
if (_scriptName) {
scriptDirectory = _scriptName;
}
if (scriptDirectory.startsWith("blob:")) {
scriptDirectory = "";
} else {
scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
}
if (!(typeof window == "object" || typeof WorkerGlobalScope != "undefined")) throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
{
readAsync = async (url) => {
assert(!isFileURI(url), "readAsync does not work with file:// URLs");
var response = await fetch(url, { credentials: "same-origin" });
if (response.ok) {
return response.arrayBuffer();
}
throw new Error(response.status + " : " + response.url);
};
}
} else {
throw new Error("environment detection error");
}
var out = Module["print"] || console.log.bind(console);
var err = Module["printErr"] || console.error.bind(console);
Object.assign(Module, moduleOverrides);
moduleOverrides = null;
checkIncomingModuleAPI();
if (Module["arguments"]) arguments_ = Module["arguments"];
legacyModuleProp("arguments", "arguments_");
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
legacyModuleProp("thisProgram", "thisProgram");
assert(typeof Module["memoryInitializerPrefixURL"] == "undefined", "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead");
assert(typeof Module["pthreadMainPrefixURL"] == "undefined", "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead");
assert(typeof Module["cdInitializerPrefixURL"] == "undefined", "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead");
assert(typeof Module["filePackagePrefixURL"] == "undefined", "Module.filePackagePrefixURL option was removed, use Module.locateFile instead");
assert(typeof Module["read"] == "undefined", "Module.read option was removed");
assert(typeof Module["readAsync"] == "undefined", "Module.readAsync option was removed (modify readAsync in JS)");
assert(typeof Module["readBinary"] == "undefined", "Module.readBinary option was removed (modify readBinary in JS)");
assert(typeof Module["setWindowTitle"] == "undefined", "Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)");
assert(typeof Module["TOTAL_MEMORY"] == "undefined", "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY");
legacyModuleProp("asm", "wasmExports");
legacyModuleProp("readAsync", "readAsync");
legacyModuleProp("readBinary", "readBinary");
legacyModuleProp("setWindowTitle", "setWindowTitle");
assert(!ENVIRONMENT_IS_WORKER, "worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.");
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");
var wasmBinary = Module["wasmBinary"];
legacyModuleProp("wasmBinary", "wasmBinary");
if (typeof WebAssembly != "object") {
err("no native wasm support detected");
}
var wasmMemory;
var ABORT = false;
function assert(condition, text) {
if (!condition) {
abort("Assertion failed" + (text ? ": " + text : ""));
}
}
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAP64, HEAPU64, HEAPF64;
var runtimeInitialized = false;
var isFileURI = (filename) => filename.startsWith("file://");
function writeStackCookie() {
var max = _emscripten_stack_get_end();
assert((max & 3) == 0);
if (max == 0) {
max += 4;
}
SAFE_HEAP_STORE((max >> 2) * 4, 34821223, 4);
SAFE_HEAP_STORE((max + 4 >> 2) * 4, 2310721022, 4);
}
function checkStackCookie() {
if (ABORT) return;
var max = _emscripten_stack_get_end();
if (max == 0) {
max += 4;
}
var cookie1 = SAFE_HEAP_LOAD((max >> 2) * 4, 4, 1);
var cookie2 = SAFE_HEAP_LOAD((max + 4 >> 2) * 4, 4, 1);
if (cookie1 != 34821223 || cookie2 != 2310721022) {
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
}
}
(() => {
var h16 = new Int16Array(1);
var h8 = new Int8Array(h16.buffer);
h16[0] = 25459;
if (h8[0] !== 115 || h8[1] !== 99) throw "Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)";
})();
if (Module["ENVIRONMENT"]) {
throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");
}
function legacyModuleProp(prop, newName, incoming = true) {
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
Object.defineProperty(Module, prop, { configurable: true, get() {
let extra = incoming ? " (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)" : "";
abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
} });
}
}
function consumedModuleProp(prop) {
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
Object.defineProperty(Module, prop, { configurable: true, set() {
abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
} });
}
}
function ignoredModuleProp(prop) {
if (Object.getOwnPropertyDescriptor(Module, prop)) {
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
}
}
function isExportedByForceFilesystem(name) {
return name === "FS_createPath" || name === "FS_createDataFile" || name === "FS_createPreloadedFile" || name === "FS_unlink" || name === "addRunDependency" || name === "FS_createLazyFile" || name === "FS_createDevice" || name === "removeRunDependency";
}
function hookGlobalSymbolAccess(sym, func) {
}
function missingGlobal(sym, msg) {
hookGlobalSymbolAccess(sym, () => {
warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
});
}
missingGlobal("buffer", "Please use HEAP8.buffer or wasmMemory.buffer");
missingGlobal("asm", "Please use wasmExports instead");
function missingLibrarySymbol(sym) {
hookGlobalSymbolAccess(sym, () => {
var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
var librarySymbol = sym;
if (!librarySymbol.startsWith("_")) {
librarySymbol = "$" + sym;
}
msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
warnOnce(msg);
});
unexportedRuntimeSymbol(sym);
}
function unexportedRuntimeSymbol(sym) {
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
Object.defineProperty(Module, sym, { configurable: true, get() {
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
if (isExportedByForceFilesystem(sym)) {
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
}
abort(msg);
} });
}
}
var runtimeDebug = true;
function getSafeHeapType(bytes, isFloat) {
switch (bytes) {
case 1:
return "i8";
case 2:
return "i16";
case 4:
return isFloat ? "float" : "i32";
case 8:
return isFloat ? "double" : "i64";
default:
abort(`getSafeHeapType() invalid bytes=${bytes}`);
}
}
function SAFE_HEAP_STORE(dest, value, bytes, isFloat) {
if (dest <= 0) abort(`segmentation fault storing ${bytes} bytes to address ${dest}`);
if (dest % bytes !== 0) abort(`alignment error storing to address ${dest}, which was expected to be aligned to a multiple of ${bytes}`);
if (runtimeInitialized) {
var brk = _sbrk(0);
if (dest + bytes > brk) abort(`segmentation fault, exceeded the top of the available dynamic heap when storing ${bytes} bytes to address ${dest}. DYNAMICTOP=${brk}`);
if (brk < _emscripten_stack_get_base()) abort(`brk >= _emscripten_stack_get_base() (brk=${brk}, _emscripten_stack_get_base()=${_emscripten_stack_get_base()})`);
if (brk > wasmMemory.buffer.byteLength) abort(`brk <= wasmMemory.buffer.byteLength (brk=${brk}, wasmMemory.buffer.byteLength=${wasmMemory.buffer.byteLength})`);
}
setValue_safe(dest, value, getSafeHeapType(bytes, isFloat));
return value;
}
function SAFE_HEAP_STORE_D(dest, value, bytes) {
return SAFE_HEAP_STORE(dest, value, bytes, true);
}
function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) {
if (dest <= 0) abort(`segmentation fault loading ${bytes} bytes from address ${dest}`);
if (dest % bytes !== 0) abort(`alignment error loading from address ${dest}, which was expected to be aligned to a multiple of ${bytes}`);
if (runtimeInitialized) {
var brk = _sbrk(0);
if (dest + bytes > brk) abort(`segmentation fault, exceeded the top of the available dynamic heap when loading ${bytes} bytes from address ${dest}. DYNAMICTOP=${brk}`);
if (brk < _emscripten_stack_get_base()) abort(`brk >= _emscripten_stack_get_base() (brk=${brk}, _emscripten_stack_get_base()=${_emscripten_stack_get_base()})`);
if (brk > wasmMemory.buffer.byteLength) abort(`brk <= wasmMemory.buffer.byteLength (brk=${brk}, wasmMemory.buffer.byteLength=${wasmMemory.buffer.byteLength})`);
}
var type = getSafeHeapType(bytes, isFloat);
var ret = getValue_safe(dest, type);
if (unsigned) ret = unSign(ret, parseInt(type.slice(1), 10));
return ret;
}
function SAFE_HEAP_LOAD_D(dest, bytes, unsigned) {
return SAFE_HEAP_LOAD(dest, bytes, unsigned, true);
}
function segfault() {
abort("segmentation fault");
}
function alignfault() {
abort("alignment fault");
}
function updateMemoryViews() {
var b = wasmMemory.buffer;
Module["HEAP8"] = HEAP8 = new Int8Array(b);
Module["HEAP16"] = HEAP16 = new Int16Array(b);
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
Module["HEAP32"] = HEAP32 = new Int32Array(b);
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
}
assert(!Module["STACK_SIZE"], "STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time");
assert(typeof Int32Array != "undefined" && typeof Float64Array !== "undefined" && Int32Array.prototype.subarray != void 0 && Int32Array.prototype.set != void 0, "JS engine does not provide full typed array support");
assert(!Module["wasmMemory"], "Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally");
assert(!Module["INITIAL_MEMORY"], "Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");
function preRun() {
if (Module["preRun"]) {
if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
while (Module["preRun"].length) {
addOnPreRun(Module["preRun"].shift());
}
}
consumedModuleProp("preRun");
callRuntimeCallbacks(onPreRuns);
}
function initRuntime() {
assert(!runtimeInitialized);
runtimeInitialized = true;
checkStackCookie();
if (!Module["noFSInit"] && !FS.initialized) FS.init();
TTY.init();
wasmExports["__wasm_call_ctors"]();
FS.ignorePermissions = false;
}
function postRun() {
checkStackCookie();
if (Module["postRun"]) {
if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
while (Module["postRun"].length) {
addOnPostRun(Module["postRun"].shift());
}
}
consumedModuleProp("postRun");
callRuntimeCallbacks(onPostRuns);
}
var runDependencies = 0;
var dependenciesFulfilled = null;
var runDependencyTracking = {};
var runDependencyWatcher = null;
function getUniqueRunDependency(id) {
var orig = id;
while (1) {
if (!runDependencyTracking[id]) return id;
id = orig + Math.random();
}
}
function addRunDependency(id) {
runDependencies++;
Module["monitorRunDependencies"]?.(runDependencies);
if (id) {
assert(!runDependencyTracking[id]);
runDependencyTracking[id] = 1;
if (runDependencyWatcher === null && typeof setInterval != "undefined") {
runDependencyWatcher = setInterval(() => {
if (ABORT) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
return;
}
var shown = false;
for (var dep in runDependencyTracking) {
if (!shown) {
shown = true;
err("still waiting on run dependencies:");
}
err(`dependency: ${dep}`);
}
if (shown) {
err("(end of list)");
}
}, 1e4);
}
} else {
err("warning: run dependency added without ID");
}
}
function removeRunDependency(id) {
runDependencies--;
Module["monitorRunDependencies"]?.(runDependencies);
if (id) {
assert(runDependencyTracking[id]);
delete runDependencyTracking[id];
} else {
err("warning: run dependency removed without ID");
}
if (runDependencies == 0) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
}
if (dependenciesFulfilled) {
var callback = dependenciesFulfilled;
dependenciesFulfilled = null;
callback();
}
}
}
function abort(what) {
Module["onAbort"]?.(what);
what = "Aborted(" + what + ")";
err(what);
ABORT = true;
var e = new WebAssembly.RuntimeError(what);
readyPromiseReject(e);
throw e;
}
function createExportWrapper(name, nargs) {
return (...args) => {
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
var f = wasmExports[name];
assert(f, `exported native function \`${name}\` not found`);
assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
return f(...args);
};
}
var wasmBinaryFile;
function findWasmBinary() {
return locateFile("swisseph.wasm");
}
function getBinarySync(file) {
if (file == wasmBinaryFile && wasmBinary) {
return new Uint8Array(wasmBinary);
}
if (readBinary) {
return readBinary(file);
}
throw "both async and sync fetching of the wasm failed";
}
async function getWasmBinary(binaryFile) {
if (!wasmBinary) {
try {
var response = await readAsync(binaryFile);
return new Uint8Array(response);
} catch {
}
}
return getBinarySync(binaryFile);
}
async function instantiateArrayBuffer(binaryFile, imports) {
try {
var binary = await getWasmBinary(binaryFile);
var instance = await WebAssembly.instantiate(binary, imports);
return instance;
} catch (reason) {
err(`failed to asynchronously prepare wasm: ${reason}`);
if (isFileURI(wasmBinaryFile)) {
err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
}
abort(reason);
}
}
async function instantiateAsync(binary, binaryFile, imports) {
if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !ENVIRONMENT_IS_NODE) {
try {
var response = fetch(binaryFile, { credentials: "same-origin" });
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
return instantiationResult;
} catch (reason) {
err(`wasm streaming compile failed: ${reason}`);
err("falling back to ArrayBuffer instantiation");
}
}
return instantiateArrayBuffer(binaryFile, imports);
}
function getWasmImports() {
return { env: wasmImports, wasi_snapshot_preview1: wasmImports };
}
async function createWasm() {
function receiveInstance(instance, module2) {
wasmExports = instance.exports;
wasmMemory = wasmExports["memory"];
assert(wasmMemory, "memory not found in wasm exports");
updateMemoryViews();
removeRunDependency("wasm-instantiate");
return wasmExports;
}
addRunDependency("wasm-instantiate");
var trueModule = Module;
function receiveInstantiationResult(result2) {
assert(Module === trueModule, "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?");
trueModule = null;
return receiveInstance(result2["instance"]);
}
var info = getWasmImports();
if (Module["instantiateWasm"]) {
return new Promise((resolve, reject) => {
try {
Module["instantiateWasm"](info, (mod, inst) => {
receiveInstance(mod, inst);
resolve(mod.exports);
});
} catch (e) {
err(`Module.instantiateWasm callback failed with error: ${e}`);
reject(e);
}
});
}
wasmBinaryFile ?? (wasmBinaryFile = findWasmBinary());
try {
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
var exports2 = receiveInstantiationResult(result);
return exports2;
} catch (e) {
readyPromiseReject(e);
return Promise.reject(e);
}
}
class ExitStatus {
constructor(status) {
__publicField(this, "name", "ExitStatus");
this.message = `Program terminated with exit(${status})`;
this.status = status;
}
}
var callRuntimeCallbacks = (callbacks) => {
while (callbacks.length > 0) {
callbacks.shift()(Module);
}
};
var onPostRuns = [];
var addOnPostRun = (cb) => onPostRuns.unshift(cb);
var onPreRuns = [];
var addOnPreRun = (cb) => onPreRuns.unshift(cb);
function getValue(ptr, type = "i8") {
if (type.endsWith("*")) type = "*";
switch (type) {
case "i1":
return SAFE_HEAP_LOAD(ptr, 1, 0);
case "i8":
return SAFE_HEAP_LOAD(ptr, 1, 0);
case "i16":
return SAFE_HEAP_LOAD((ptr >> 1) * 2, 2, 0);
case "i32":
return SAFE_HEAP_LOAD((ptr >> 2) * 4, 4, 0);
case "i64":
return HEAP64[ptr >> 3];
case "float":
return SAFE_HEAP_LOAD_D((ptr >> 2) * 4, 4, 0);
case "double":
return SAFE_HEAP_LOAD_D((ptr >> 3) * 8, 8, 0);
case "*":
return SAFE_HEAP_LOAD((ptr >> 2) * 4, 4, 1);
default:
abort(`invalid type for getValue: ${type}`);
}
}
function getValue_safe(ptr, type = "i8") {
if (type.endsWith("*")) type = "*";
switch (type) {
case "i1":
return HEAP8[ptr];
case "i8":
return HEAP8[ptr];
case "i16":
return HEAP16[ptr >> 1];
case "i32":
return HEAP32[ptr >> 2];
case "i64":
return HEAP64[ptr >> 3];
case "float":
return HEAPF32[ptr >> 2];
case "double":
return HEAPF64[ptr >> 3];
case "*":
return HEAPU32[ptr >> 2];
default:
abort(`invalid type for getValue: ${type}`);
}
}
var noExitRuntime = Module["noExitRuntime"] || true;
var ptrToString = (ptr) => {
assert(typeof ptr === "number");
ptr >>>= 0;
return "0x" + ptr.toString(16).padStart(8, "0");
};
function setValue(ptr, value, type = "i8") {
if (type.endsWith("*")) type = "*";
switch (type) {
case "i1":
SAFE_HEAP_STORE(ptr, value, 1);
break;
case "i8":
SAFE_HEAP_STORE(ptr, value, 1);
break;
case "i16":
SAFE_HEAP_STORE((ptr >> 1) * 2, value, 2);
break;
case "i32":
SAFE_HEAP_STORE((ptr >> 2) * 4, value, 4);
break;
case "i64":
HEAP64[ptr >> 3] = BigInt(value);
break;
case "float":
SAFE_HEAP_STORE_D((ptr >> 2) * 4, value, 4);
break;
case "double":
SAFE_HEAP_STORE_D((ptr >> 3) * 8, value, 8);
break;
case "*":
SAFE_HEAP_STORE((ptr >> 2) * 4, value, 4);
break;
default:
abort(`invalid type for setValue: ${type}`);
}
}
function setValue_safe(ptr, value, type = "i8") {
if (type.endsWith("*")) type = "*";
switch (type) {
case "i1":
HEAP8[ptr] = value;
break;
case "i8":
HEAP8[ptr] = value;
break;
case "i16":
HEAP16[ptr >> 1] = value;
break;
case "i32":
HEAP32[ptr >> 2] = value;
break;
case "i64":
HEAP64[ptr >> 3] = BigInt(value);
break;
case "float":
HEAPF32[ptr >> 2] = value;
break;
case "double":
HEAPF64[ptr >> 3] = value;
break;
case "*":
HEAPU32[ptr >> 2] = value;
break;
default:
abort(`invalid type for setValue: ${type}`);
}
}
var stackRestore = (val) => __emscripten_stack_restore(val);
var stackSave = () => _emscripten_stack_get_current();
var unSign = (value, bits) => {
if (value >= 0) {
return value;
}
return bits <= 32 ? 2 * Math.abs(1 << bits - 1) + value : Math.pow(2, bits) + value;
};
var warnOnce = (text) => {
warnOnce.shown || (warnOnce.shown = {});
if (!warnOnce.shown[text]) {
warnOnce.shown[text] = 1;
if (ENVIRONMENT_IS_NODE) text = "warning: " + text;
err(text);
}
};
var syscallGetVarargI = () => {
assert(SYSCALLS.varargs != void 0);
var ret = SAFE_HEAP_LOAD((+SYSCALLS.varargs >> 2) * 4, 4, 0);
SYSCALLS.varargs += 4;
return ret;
};
var syscallGetVarargP = syscallGetVarargI;
var PATH = { isAbs: (path) => path.charAt(0) === "/", splitPath: (filename) => {
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
return splitPathRe.exec(filename).slice(1);
}, normalizeArray: (parts, allowAboveRoot) => {
var up = 0;
for (var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last === ".") {
parts.splice(i, 1);
} else if (last === "..") {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
if (allowAboveRoot) {
for (; up; up--) {
parts.unshift("..");
}
}
return parts;
}, normalize: (path) => {
var isAbsolute = PATH.isAbs(path), trailingSlash = path.slice(-1) === "/";
path = PATH.normalizeArray(path.split("/").filter((p) => !!p), !isAbsolute).join("/");
if (!path && !isAbsolute) {
path = ".";
}
if (path && trailingSlash) {
path += "/";
}
return (isAbsolute ? "/" : "") + path;
}, dirname: (path) => {
var result = PATH.splitPath(path), root = result[0], dir = result[1];
if (!root && !dir) {
return ".";
}
if (dir) {
dir = dir.slice(0, -1);
}
return root + dir;
}, basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1], join: (...paths) => PATH.normalize(paths.join("/")), join2: (l, r) => PATH.normalize(l + "/" + r) };
var initRandomFill = () => {
if (ENVIRONMENT_IS_NODE) {
var nodeCrypto = __require("crypto");
return (view) => nodeCrypto.randomFillSync(view);
}
return (view) => crypto.getRandomValues(view);
};
var randomFill = (view) => {
(randomFill = initRandomFill())(view);
};
var PATH_FS = { resolve: (...args) => {
var resolvedPath = "", resolvedAbsolute = false;
for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = i >= 0 ? args[i] : FS.cwd();
if (typeof path != "string") {
throw new TypeError("Arguments to path.resolve must be strings");
} else if (!path) {
return "";
}
resolvedPath = path + "/" + resolvedPath;
resolvedAbsolute = PATH.isAbs(path);
}
resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter((p) => !!p), !resolvedAbsolute).join("/");
return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
}, relative: (from, to) => {
from = PATH_FS.resolve(from).slice(1);
to = PATH_FS.resolve(to).slice(1);
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== "") break;
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== "") break;
}
if (start > end) return [];
return arr.slice(start, end - start + 1);
}
var fromParts = trim(from.split("/"));
var toParts = trim(to.split("/"));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push("..");
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join("/");
} };
var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder() : void 0;
var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
var endIdx = idx + maxBytesToRead;
var endPtr = idx;
while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
}
var str = "";
while (idx < endPtr) {
var u0 = heapOrArray[idx++];
if (!(u0 & 128)) {
str += String.fromCharCode(u0);
continue;
}
var u1 = heapOrArray[idx++] & 63;
if ((u0 & 224) == 192) {
str += String.fromCharCode((u0 & 31) << 6 | u1);
continue;
}
var u2 = heapOrArray[idx++] & 63;
if ((u0 & 240) == 224) {
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
} else {
if ((u0 & 248) != 240) warnOnce("Invalid UTF-8 leading byte " + ptrToString(u0) + " encountered when deserializing a UTF-8 string in wasm memory to a JS string!");
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
}
if (u0 < 65536) {
str += String.fromCharCode(u0);
} else {
var ch = u0 - 65536;
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
}
}
return str;
};
var FS_stdin_getChar_buffer = [];
var lengthBytesUTF8 = (str) => {
var len = 0;
for (var i = 0; i < str.length; ++i) {
var c = str.charCodeAt(i);
if (c <= 127) {
len++;
} else if (c <= 2047) {
len += 2;
} else if (c >= 55296 && c <= 57343) {
len += 4;
++i;
} else {
len += 3;
}
}
return len;
};
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
assert(typeof str === "string", `stringToUTF8Array expects a string (got ${typeof str})`);
if (!(maxBytesToWrite > 0)) return 0;
var startIdx = outIdx;
var endIdx = outIdx + maxBytesToWrite - 1;
for (var i = 0; i < str.length; ++i) {
var u = str.charCodeAt(i);
if (u >= 55296 && u <= 57343) {
var u1 = str.charCodeAt(++i);
u = 65536 + ((u & 1023) << 10) | u1 & 1023;
}
if (u <= 127) {
if (outIdx >= endIdx) break;
heap[outIdx++] = u;
} else if (u <= 2047) {
if (outIdx + 1 >= endIdx) break;
heap[outIdx++] = 192 | u >> 6;
heap[outIdx++] = 128 | u & 63;
} else if (u <= 65535) {
if (outIdx + 2 >= endIdx) break;
heap[outIdx++] = 224 | u >> 12;
heap[outIdx++] = 128 | u >> 6 & 63;
heap[outIdx++] = 128 | u & 63;
} else {
if (outIdx + 3 >= endIdx) break;
if (u > 1114111) warnOnce("Invalid Unicode code point " + ptrToString(u) + " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).");
heap[outIdx++] = 240 | u >> 18;
heap[outIdx++] = 128 | u >> 12 & 63;
heap[outIdx++] = 128 | u >> 6 & 63;
heap[outIdx++] = 128 | u & 63;
}
}
heap[outIdx] = 0;
return outIdx - startIdx;
};
var intArrayFromString = (stringy, dontAddNull, length) => {
var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
var u8array = new Array(len);
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
if (dontAddNull) u8array.length = numBytesWritten;
return u8array;
};
var FS_stdin_getChar = () => {
if (!FS_stdin_getChar_buffer.length) {
var result = null;
if (ENVIRONMENT_IS_NODE) {
var BUFSIZE = 256;
var buf = Buffer.alloc(BUFSIZE);
var bytesRead = 0;
var fd = process.stdin.fd;
try {
bytesRead = fs.readSync(fd, buf, 0, BUFSIZE);
} catch (e) {
if (e.toString().includes("EOF")) bytesRead = 0;
else throw e;
}
if (bytesRead > 0) {
result = buf.slice(0, bytesRead).toString("utf-8");
}
} else if (typeof window != "undefined" && typeof window.prompt == "function") {
result = window.prompt("Input: ");
if (result !== null) {
result += "\n";
}
} else {
}
if (!result) {
return null;
}
FS_stdin_getChar_buffer = intArrayFromString(result, true);
}
return FS_stdin_getChar_buffer.shift();
};
var TTY = { ttys: [], init() {
}, shutdown() {
}, register(dev, ops) {
TTY.ttys[dev] = { input: [], output: [], ops };
FS.registerDevice(dev, TTY.stream_ops);
}, stream_ops: { open(stream) {
var tty = TTY.ttys[stream.node.rdev];
if (!tty) {
throw new FS.ErrnoError(43);
}
stream.tty = tty;
stream.seekable = false;
}, close(stream) {
stream.tty.ops.fsync(stream.tty);
}, fsync(stream) {
stream.tty.ops.fsync(stream.tty);
}, read(stream, buffer, offset, length, pos) {
if (!stream.tty || !stream.tty.ops.get_char) {
throw new FS.ErrnoError(60);
}
var bytesRead = 0;
for (var i = 0; i < length; i++) {
var result;
try {
result = stream.tty.ops.get_char(stream.tty);
} catch (e) {
throw new FS.ErrnoError(29);
}
if (result === void 0 && bytesRead === 0) {
throw new FS.ErrnoError(6);
}
if (result === null || result === void 0) break;
bytesRead++;
buffer[offset + i] = result;
}
if (bytesRead) {
stream.node.atime = Date.now();
}
return bytesRead;
}, write(stream, buffer, offset, length, pos) {
if (!stream.tty || !stream.tty.ops.put_char) {
throw new FS.ErrnoError(60);
}
try {
for (var i = 0; i < length; i++) {
stream.tty.ops.put_char(stream.tty, buffer[offset + i]);
}
} catch (e) {
throw new FS.ErrnoError(29);
}
if (length) {
stream.node.mtime = stream.node.ctime = Date.now();
}
return i;
} }, default_tty_ops: { get_char(tty) {
return FS_stdin_getChar();
}, put_char(tty, val) {
if (val === null || val === 10) {
out(UTF8ArrayToString(tty.output));
tty.output = [];
} else {
if (val != 0) tty.output.push(val);
}
}, fsync(tty) {
if (tty.output?.length > 0) {
out(UTF8ArrayToString(tty.output));
tty.output = [];
}
}, ioctl_tcgets(tty) {
return { c_iflag: 25856, c_oflag: 5, c_cflag: 191, c_lflag: 35387, c_cc: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
}, ioctl_tcsets(tty, optional_actions, data) {
return 0;
}, ioctl_tiocgwinsz(tty) {
return [24, 80];
} }, default_tty1_ops: { put_char(tty, val) {
if (val === null || val === 10) {
err(UTF8ArrayToString(tty.output));
tty.output = [];
} else {
if (val != 0) tty.output.push(val);
}
}, fsync(tty) {
if (tty.output?.length > 0) {
err(UTF8ArrayToString(tty.output));
tty.output = [];
}
} } };
var alignMemory = (size, alignment) => {
assert(alignment, "alignment argument is required");
return Math.ceil(size / alignment) * alignment;
};
var mmapAlloc = (size) => {
abort("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported");
};
var MEMFS = { ops_table: null, mount(mount) {
return MEMFS.createNode(null, "/", 16895, 0);
}, createNode(parent, name, mode, dev) {
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
throw new FS.ErrnoError(63);
}
MEMFS.ops_table || (MEMFS.ops_table = { dir: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, lookup: MEMFS.node_ops.lookup, mknod: MEMFS.node_ops.mknod, rename: MEMFS.node_ops.rename, unlink: MEMFS.node_ops.unlink, rmdir: MEMFS.node_ops.rmdir, readdir: MEMFS.node_ops.readdir, symlink: MEMFS.node_ops.symlink }, stream: { llseek: MEMFS.stream_ops.llseek } }, file: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: { llseek: MEMFS.stream_ops.llseek, read: MEMFS.stream_ops.read, write: MEMFS.stream_ops.write, mmap: MEMFS.stream_ops.mmap, msync: MEMFS.stream_ops.msync } }, link: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr, readlink: MEMFS.node_ops.readlink }, stream: {} }, chrdev: { node: { getattr: MEMFS.node_ops.getattr, setattr: MEMFS.node_ops.setattr }, stream: FS.chrdev_stream_ops } });
var node = FS.createNode(parent, name, mode, dev);
if (FS.isDir(node.mode)) {
node.node_ops = MEMFS.ops_table.dir.node;
node.stream_ops = MEMFS.ops_table.dir.stream;
node.contents = {};
} else if (FS.isFile(node.mode)) {
node.node_ops = MEMFS.ops_table.file.node;
node.stream_ops = MEMFS.ops_table.file.stream;
node.usedBytes = 0;
node.contents = null;
} else if (FS.isLink(node.mode)) {
node.node_ops = MEMFS.ops_table.link.node;
node.stream_ops = MEMFS.ops_table.link.stream;
} else if (FS.isChrdev(node.mode)) {
node.node_ops = MEMFS.ops_table.chrdev.node;
node.stream_ops = MEMFS.ops_table.chrdev.stream;
}
node.atime = node.mtime = node.ctime = Date.now();
if (parent) {
parent.contents[name] = node;
parent.atime = parent.mtime = parent.ctime = node.atime;
}
return node;
}, getFileDataAsTypedArray(node) {
if (!node.contents) return new Uint8Array(0);
if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes);
return new Uint8Array(node.contents);
}, expandFileStorage(node, newCapacity) {
var prevCapacity = node.contents ? node.contents.length : 0;
if (prevCapacity >= newCapacity) return;
var CAPACITY_DOUBLING_MAX = 1024 * 1024;
newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0);
if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
var oldContents = node.contents;
node.contents = new Uint8Array(newCapacity);
if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
}, resizeFileStorage(node, newSize) {
if (node.usedBytes == newSize) return;
if (newSize == 0) {
node.contents = null;
node.usedBytes = 0;
} else {
var oldContents = node.contents;
node.contents = new Uint8Array(newSize);
if (oldContents) {
node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
}
node.usedBytes = newSize;
}
}, node_ops: { getattr(node) {
var attr = {};
attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
attr.ino = node.id;
attr.mode = node.mode;
attr.nlink = 1;
attr.uid = 0;
attr.gid = 0;
attr.rdev = node.rdev;
if (FS.isDir(node.mode)) {
attr.size = 4096;
} else if (FS.isFile(node.mode)) {
attr.size = node.usedBytes;
} else if (FS.isLink(node.mode)) {
attr.size = node.link.length;
} else {
attr.size = 0;
}
attr.atime = new Date(node.atime);
attr.mtime = new Date(node.mtime);
attr.ctime = new Date(node.ctime);
attr.blksize = 4096;
attr.blocks = Math.ceil(attr.size / attr.blksize);
return attr;
}, setattr(node, attr) {
for (const key of ["mode", "atime", "mtime", "ctime"]) {
if (attr[key] != null) {
node[key] = attr[key];
}
}
if (attr.size !== void 0) {
MEMFS.resizeFileStorage(node, attr.size);
}
}, lookup(parent, name) {
throw new FS.ErrnoError(44);
}, mknod(parent, name, mode, dev) {
return MEMFS.createNode(parent, name, mode, dev);
}, rename(old_node, new_dir, new_name) {
var new_node;
try {
new_node = FS.lookupNode(new_dir, new_name);
} catch (e) {
}
if (new_node) {
if (FS.isDir(old_node.mode)) {
for (var i in new_node.contents) {
throw new FS.ErrnoError(55);
}
}
FS.hashRemoveNode(new_node);
}
delete old_node.pare