UNPKG

kaabalah

Version:

The de-facto library for any esoteric calculations and tooling

1,205 lines (1,201 loc) 1.1 MB
#!/usr/bin/env node "use strict"; 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 __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // wasm/build/swisseph.node.wasm?url var swisseph_node_default; var init_swisseph_node = __esm({ "wasm/build/swisseph.node.wasm?url"() { swisseph_node_default = "./swisseph.node-2K5IHMKE.wasm?url"; } }); // wasm/build/swisseph.web.wasm?url var swisseph_web_default; var init_swisseph_web = __esm({ "wasm/build/swisseph.web.wasm?url"() { swisseph_web_default = "./swisseph.web-2K5IHMKE.wasm?url"; } }); // wasm/src/swisseph.ts function parsFortunae(asc, sunLon, moonLon, diurnal) { const val = diurnal ? asc + moonLon - sunLon : asc + sunLon - moonLon; return normalizeAngle(val); } var Planet, VirtualNodes, PLANET_AND_NODE_NAMES, HouseSystem, CalcFlag, RiseTransitFlag, SE_ECL2HOR, SE_EQU2HOR, SE_AST_OFFSET, BODY, normalizeAngle, SwissEph; var init_swisseph = __esm({ "wasm/src/swisseph.ts"() { "use strict"; Planet = /* @__PURE__ */ ((Planet2) => { Planet2[Planet2["SUN"] = 0] = "SUN"; Planet2[Planet2["MOON"] = 1] = "MOON"; Planet2[Planet2["MERCURY"] = 2] = "MERCURY"; Planet2[Planet2["VENUS"] = 3] = "VENUS"; Planet2[Planet2["MARS"] = 4] = "MARS"; Planet2[Planet2["JUPITER"] = 5] = "JUPITER"; Planet2[Planet2["SATURN"] = 6] = "SATURN"; Planet2[Planet2["URANUS"] = 7] = "URANUS"; Planet2[Planet2["NEPTUNE"] = 8] = "NEPTUNE"; Planet2[Planet2["PLUTO"] = 9] = "PLUTO"; Planet2[Planet2["MEAN_NODE"] = 10] = "MEAN_NODE"; Planet2[Planet2["TRUE_NODE"] = 11] = "TRUE_NODE"; Planet2[Planet2["LILITH_MEAN"] = 12] = "LILITH_MEAN"; Planet2[Planet2["LILITH_TRUE"] = 13] = "LILITH_TRUE"; Planet2[Planet2["CHIRON"] = 15] = "CHIRON"; return Planet2; })(Planet || {}); VirtualNodes = /* @__PURE__ */ ((VirtualNodes2) => { VirtualNodes2["PARS_FORTUNAE"] = "parsFortunae"; return VirtualNodes2; })(VirtualNodes || {}); PLANET_AND_NODE_NAMES = { [0 /* SUN */]: "Sun", [1 /* MOON */]: "Moon", [2 /* MERCURY */]: "Mercury", [3 /* VENUS */]: "Venus", [4 /* MARS */]: "Mars", [5 /* JUPITER */]: "Jupiter", [6 /* SATURN */]: "Saturn", [7 /* URANUS */]: "Uranus", [8 /* NEPTUNE */]: "Neptune", [9 /* PLUTO */]: "Pluto", [10 /* MEAN_NODE */]: "Mean Node", [11 /* TRUE_NODE */]: "True Node", [12 /* LILITH_MEAN */]: "Lilith Mean", [13 /* LILITH_TRUE */]: "Lilith True", [15 /* CHIRON */]: "Chiron", ["parsFortunae" /* PARS_FORTUNAE */]: "Wheel of Fortune" }; HouseSystem = /* @__PURE__ */ ((HouseSystem2) => { HouseSystem2["PLACIDUS"] = "P"; HouseSystem2["KOCH"] = "K"; HouseSystem2["PORPHYRIUS"] = "O"; HouseSystem2["REGIOMONTANUS"] = "R"; HouseSystem2["CAMPANUS"] = "C"; HouseSystem2["EQUAL"] = "E"; HouseSystem2["WHOLE_SIGN"] = "W"; HouseSystem2["MERIDIAN"] = "X"; HouseSystem2["MORINUS"] = "M"; HouseSystem2["KRUSINSKI"] = "U"; HouseSystem2["ALCABITIUS"] = "B"; return HouseSystem2; })(HouseSystem || {}); CalcFlag = /* @__PURE__ */ ((CalcFlag2) => { CalcFlag2[CalcFlag2["JPL_EPH"] = 1] = "JPL_EPH"; CalcFlag2[CalcFlag2["SWISS_EPH"] = 2] = "SWISS_EPH"; CalcFlag2[CalcFlag2["MOSHIER"] = 4] = "MOSHIER"; CalcFlag2[CalcFlag2["HELIOCENTRIC"] = 8] = "HELIOCENTRIC"; CalcFlag2[CalcFlag2["TRUE_POS"] = 16] = "TRUE_POS"; CalcFlag2[CalcFlag2["J2000"] = 32] = "J2000"; CalcFlag2[CalcFlag2["NONUT"] = 64] = "NONUT"; CalcFlag2[CalcFlag2["SPEED3"] = 128] = "SPEED3"; CalcFlag2[CalcFlag2["SPEED"] = 256] = "SPEED"; CalcFlag2[CalcFlag2["EQUATORIAL"] = 2048] = "EQUATORIAL"; CalcFlag2[CalcFlag2["TOPOCTR"] = 32768] = "TOPOCTR"; CalcFlag2[CalcFlag2["SIDEREAL"] = 65536] = "SIDEREAL"; return CalcFlag2; })(CalcFlag || {}); RiseTransitFlag = /* @__PURE__ */ ((RiseTransitFlag2) => { RiseTransitFlag2[RiseTransitFlag2["RISE"] = 1] = "RISE"; RiseTransitFlag2[RiseTransitFlag2["SET"] = 2] = "SET"; RiseTransitFlag2[RiseTransitFlag2["UPPER_MERIDIAN"] = 4] = "UPPER_MERIDIAN"; RiseTransitFlag2[RiseTransitFlag2["LOWER_MERIDIAN"] = 8] = "LOWER_MERIDIAN"; RiseTransitFlag2[RiseTransitFlag2["DISC_CENTER"] = 256] = "DISC_CENTER"; RiseTransitFlag2[RiseTransitFlag2["NO_REFRACTION"] = 512] = "NO_REFRACTION"; return RiseTransitFlag2; })(RiseTransitFlag || {}); SE_ECL2HOR = 0; SE_EQU2HOR = 1; SE_AST_OFFSET = 1e4; BODY = { MEAN_APOGEE: 12, // Lilith mean OSC_APOGEE: 13, // Lilith true PHOLUS: 16, CERES: 17, PALLAS: 18, JUNO: 19, VESTA: 20 }; normalizeAngle = (deg) => (deg % 360 + 360) % 360; SwissEph = class { /** * Constructor that accepts a pre-initialized Swiss Ephemeris module */ constructor(module2) { this.swe_julday = null; this.swe_calc_ut = null; this.swe_houses = null; this.swe_house_pos = null; this.swe_set_ephe_path = null; this.swe_close = null; this.swe_set_topo = null; this.swe_set_sid_mode = null; this.swe_azalt_fn = null; this.swe_rise_trans_fn = null; this.module = module2; this.swe_julday = this.module.cwrap("swe_julday", "number", [ "number", "number", "number", "number", "number" ]); this.swe_calc_ut = this.module.cwrap("swe_calc_ut", "number", [ "number", "number", "number", "number", "number" ]); this.swe_houses = this.module.cwrap("swe_houses", "number", [ "number", "number", "number", "number", "number", "number" ]); this.swe_house_pos = this.module.cwrap( "swe_house_pos", "number", ["number", "number", "number", "string", "number", "number"] ); this.swe_set_ephe_path = this.module.cwrap( "swe_set_ephe_path", null, ["number"] ); this.swe_close = this.module.cwrap("swe_close", null, []); this.swe_set_topo = this.module.cwrap("swe_set_topo", null, [ "number", "number", "number" ]); this.swe_set_sid_mode = this.module.cwrap( "swe_set_sid_mode", null, ["number", "number", "number"] ); this.swe_azalt_fn = this.module.cwrap( "swe_azalt", null, ["number", "number", "number", "number", "number", "number", "number"] ); this.swe_rise_trans_fn = this.module.cwrap( "swe_rise_trans", "number", ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"] ); } checkInitialized() { if (!this.module) { throw new Error("Swiss Ephemeris module not available."); } } /** * Sets the path to the ephemeris data files. * @param path - The path to the directory containing ephemeris files. */ setEphemerisPath(path) { this.checkInitialized(); if (path && this.swe_set_ephe_path) { const pathPtr = this.module._malloc(path.length + 1); if (!pathPtr) { throw new Error("Failed to allocate memory for ephemeris path"); } this.module.stringToUTF8(path, pathPtr, path.length + 1); this.swe_set_ephe_path(pathPtr); this.module._free(pathPtr); } } /** * Calculate Julian day number for a given date and time */ getJulianDay(date) { this.checkInitialized(); if (!this.swe_julday) { throw new Error("Julian day calculation function not available"); } const year = date.getUTCFullYear(); const month = date.getUTCMonth() + 1; const day = date.getUTCDate(); const hour = date.getUTCHours() + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600; return this.swe_julday(year, month, day, hour, 1); } /** * Calculate planet position at a given Julian day */ calculatePlanetPosition(julday, planet, flags = 2 /* SWISS_EPH */) { this.checkInitialized(); if (!this.swe_calc_ut || !this.module) { throw new Error("Planet calculation function not available"); } const resultPtr = this.module._malloc(6 * 8); if (!resultPtr) { throw new Error("Failed to allocate memory for planet position"); } const ERR_BYTES = 512; const errPtr = this.module._malloc(ERR_BYTES); if (!errPtr) { this.module._free(resultPtr); throw new Error("Failed to allocate memory for error buffer"); } this.module.HEAP8.fill(0, errPtr, errPtr + ERR_BYTES); try { let ret = this.swe_calc_ut(julday, planet, flags, resultPtr, errPtr); if (ret < 0) { const msg = this.module.UTF8ToString(errPtr); throw new Error(msg && msg.length ? msg : `Swiss Ephemeris calculation failed with error code ${ret}`); } const position = { longitude: this.module.getValue(resultPtr, "double"), latitude: this.module.getValue(resultPtr + 8, "double"), distance: this.module.getValue(resultPtr + 16, "double") }; if (flags & 256 /* SPEED */) { position.longitudeSpeed = this.module.getValue(resultPtr + 24, "double"); position.latitudeSpeed = this.module.getValue(resultPtr + 32, "double"); position.distanceSpeed = this.module.getValue(resultPtr + 40, "double"); } return position; } finally { this.module._free(errPtr); this.module._free(resultPtr); } } /** * Calculate houses for a given date, location, and house system */ calculateHouses(julday, latitude, longitude, hsys = "P" /* PLACIDUS */) { this.checkInitialized(); if (!this.swe_houses || !this.module) { throw new Error("Houses calculation function not available"); } if (latitude < -90 || latitude > 90) { throw new Error("Latitude must be between -90 and 90 degrees"); } if (longitude < -180 || longitude > 180) { throw new Error("Longitude must be between -180 and 180 degrees"); } const HOUSES_DOUBLES = 13; const ASCMC_DOUBLES = 10; const BYTES_PER_F64 = 8; const totalBytes = (HOUSES_DOUBLES + ASCMC_DOUBLES) * BYTES_PER_F64; const memoryPtr = this.module._malloc(totalBytes); if (!memoryPtr) throw new Error("Memory allocation failed"); const housesPtr = memoryPtr; const ascmcPtr = memoryPtr + HOUSES_DOUBLES * BYTES_PER_F64; try { const hsysCode = hsys.charCodeAt(0); const ret = this.swe_houses( julday, latitude, longitude, hsysCode, housesPtr, ascmcPtr ); if (ret < 0) { throw new Error(`Houses calculation failed with error code ${ret}`); } const houses = new Array(HOUSES_DOUBLES); for (let i = 0; i < HOUSES_DOUBLES; i++) { houses[i] = this.module.getValue( housesPtr + i * BYTES_PER_F64, "double" ); } const ascendant = this.module.getValue( ascmcPtr + 0 * BYTES_PER_F64, "double" ); const mc = this.module.getValue(ascmcPtr + 1 * BYTES_PER_F64, "double"); const armc = this.module.getValue(ascmcPtr + 2 * BYTES_PER_F64, "double"); const vertex = this.module.getValue( ascmcPtr + 3 * BYTES_PER_F64, "double" ); const equasc = this.module.getValue( ascmcPtr + 4 * BYTES_PER_F64, "double" ); const coasc1 = this.module.getValue( ascmcPtr + 5 * BYTES_PER_F64, "double" ); const coasc2 = this.module.getValue( ascmcPtr + 6 * BYTES_PER_F64, "double" ); const polasc = this.module.getValue( ascmcPtr + 7 * BYTES_PER_F64, "double" ); return { ascendant, mc, houses, ascmc: { armc, vertex, equasc, coasc1, coasc2, polasc } }; } finally { this.module._free(memoryPtr); } } /** * Clean up and close the Swiss Ephemeris */ close() { this.checkInitialized(); if (this.swe_close) { this.swe_close(); } } /** * Set topocentric observer */ setTopocentric(longitude, latitude, altitudeMeters = 0) { this.checkInitialized(); if (!this.swe_set_topo) { throw new Error("Topocentric calculation function not available"); } this.swe_set_topo(longitude, latitude, altitudeMeters); } /** * Set sidereal mode * Ex.: mode=1 (Lahiri). See Swiss Ephemeris mode table. */ setSiderealMode(mode, t0 = 0, ayan_t0 = 0) { this.checkInitialized(); this.swe_set_sid_mode?.(mode, t0, ayan_t0); } /** * Asteroid by MPC number */ calculateAsteroidPosition(julday, mpcNumber, flags = 2 /* SWISS_EPH */) { return this.calculatePlanetPosition( julday, SE_AST_OFFSET + mpcNumber, flags ); } /** * Lilith mean (12) and true (13) */ calculateLilith(julday, kind = "mean", flags = 2 /* SWISS_EPH */) { const id2 = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE; return this.calculatePlanetPosition(julday, id2, flags); } /** * Convert ecliptic (or equatorial) coordinates to horizon coordinates. * Returns azimuth (0=south, 90=west, 180=north, 270=east) and altitude. */ azalt(julday, longitude, latitude, altitude, xinLon, xinLat, xinDist, fromEquatorial = false) { this.checkInitialized(); if (!this.swe_azalt_fn) { throw new Error("swe_azalt function not available"); } const BYTES = 8; const geoPtr = this.module._malloc(3 * BYTES); const xinPtr = this.module._malloc(3 * BYTES); const xazPtr = this.module._malloc(3 * BYTES); if (!geoPtr || !xinPtr || !xazPtr) { if (geoPtr) this.module._free(geoPtr); if (xinPtr) this.module._free(xinPtr); if (xazPtr) this.module._free(xazPtr); throw new Error("Memory allocation failed for azalt"); } try { this.module.setValue(geoPtr, longitude, "double"); this.module.setValue(geoPtr + BYTES, latitude, "double"); this.module.setValue(geoPtr + 2 * BYTES, altitude, "double"); this.module.setValue(xinPtr, xinLon, "double"); this.module.setValue(xinPtr + BYTES, xinLat, "double"); this.module.setValue(xinPtr + 2 * BYTES, xinDist, "double"); this.swe_azalt_fn( julday, fromEquatorial ? SE_EQU2HOR : SE_ECL2HOR, geoPtr, 0, // atpress (0 = default 1013.25 mbar) 0, // attemp (0 = default 15°C) xinPtr, xazPtr ); return { azimuth: this.module.getValue(xazPtr, "double"), trueAltitude: this.module.getValue(xazPtr + BYTES, "double"), apparentAltitude: this.module.getValue(xazPtr + 2 * BYTES, "double") }; } finally { this.module._free(geoPtr); this.module._free(xinPtr); this.module._free(xazPtr); } } /** * Find the next rise, set, or meridian transit of a planet. * Returns the Julian day of the event. */ riseTransit(julday, planet, rsmi, longitude, latitude, altitude = 0, flags = 2 /* SWISS_EPH */) { this.checkInitialized(); if (!this.swe_rise_trans_fn) { throw new Error("swe_rise_trans function not available"); } const BYTES = 8; const geoPtr = this.module._malloc(3 * BYTES); const tretPtr = this.module._malloc(BYTES); const ERR_BYTES = 512; const errPtr = this.module._malloc(ERR_BYTES); if (!geoPtr || !tretPtr || !errPtr) { if (geoPtr) this.module._free(geoPtr); if (tretPtr) this.module._free(tretPtr); if (errPtr) this.module._free(errPtr); throw new Error("Memory allocation failed for riseTransit"); } this.module.HEAP8.fill(0, errPtr, errPtr + ERR_BYTES); try { this.module.setValue(geoPtr, longitude, "double"); this.module.setValue(geoPtr + BYTES, latitude, "double"); this.module.setValue(geoPtr + 2 * BYTES, altitude, "double"); const ret = this.swe_rise_trans_fn( julday, planet, 0, // starname pointer (0 = planet, not fixed star) flags, rsmi, geoPtr, 0, // atpress 0, // attemp tretPtr, errPtr ); if (ret < 0) { const msg = this.module.UTF8ToString(errPtr); throw new Error(msg || `swe_rise_trans failed with code ${ret}`); } return this.module.getValue(tretPtr, "double"); } finally { this.module._free(geoPtr); this.module._free(tretPtr); this.module._free(errPtr); } } }; } }); // wasm/build/swisseph.web.js var require_swisseph_web = __commonJS({ "wasm/build/swisseph.web.js"(exports2, module2) { "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((resolve3, reject) => { readyPromiseResolve = resolve3; 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(id2) { var orig = id2; while (1) { if (!runDependencyTracking[id2]) return id2; id2 = orig + Math.random(); } } function addRunDependency(id2) { runDependencies++; Module["monitorRunDependencies"]?.(runDependencies); if (id2) { assert(!runDependencyTracking[id2]); runDependencyTracking[id2] = 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(id2) { runDependencies--; Module["monitorRunDependencies"]?.(runDependencies); if (id2) { assert(runDependencyTracking[id2]); delete runDependencyTracking[id2]; } 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.web.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, module3) { 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((resolve3, reject) => { try { Module["instantiateWasm"](info, (mod, inst) => { receiveInstance(mod, inst); resolve3(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 exports3 = receiveInstantiationResult(result); return exports3; } 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