kaabalah 3.3.1 → 4.0.0

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.
Files changed (81) hide show
  1. package/dist/astrology/index.d.mts +47 -22
  2. package/dist/astrology/index.d.ts +47 -22
  3. package/dist/astrology/index.js +21 -17
  4. package/dist/astrology/index.mjs +2 -2
  5. package/dist/{chunk-6DHXZLYH.mjs → chunk-2Q6OWZV2.mjs} +3 -3
  6. package/dist/{chunk-6DHXZLYH.mjs.map → chunk-2Q6OWZV2.mjs.map} +1 -1
  7. package/dist/{chunk-JJ76YVMI.js → chunk-4GW52TEP.js} +18 -18
  8. package/dist/{chunk-JJ76YVMI.js.map → chunk-4GW52TEP.js.map} +1 -1
  9. package/dist/chunk-CGCEKFLD.js +685 -0
  10. package/dist/chunk-CGCEKFLD.js.map +1 -0
  11. package/dist/chunk-FM7WUVZV.js +26 -0
  12. package/dist/{chunk-2TUXWMP5.js.map → chunk-FM7WUVZV.js.map} +1 -1
  13. package/dist/{chunk-7CAIYKIO.js → chunk-LWX4YXES.js} +6 -6
  14. package/dist/{chunk-7CAIYKIO.js.map → chunk-LWX4YXES.js.map} +1 -1
  15. package/dist/{chunk-5ISXTWFX.mjs → chunk-MAK5YPPE.mjs} +3 -3
  16. package/dist/{chunk-5ISXTWFX.mjs.map → chunk-MAK5YPPE.mjs.map} +1 -1
  17. package/dist/{chunk-4IMODQPK.js → chunk-MFYKYKWX.js} +4 -4
  18. package/dist/{chunk-4IMODQPK.js.map → chunk-MFYKYKWX.js.map} +1 -1
  19. package/dist/chunk-P7VAKSJY.mjs +671 -0
  20. package/dist/chunk-P7VAKSJY.mjs.map +1 -0
  21. package/dist/chunk-WY6NIR2V.mjs +21 -0
  22. package/dist/{chunk-PY5SMMJB.mjs.map → chunk-WY6NIR2V.mjs.map} +1 -1
  23. package/dist/{chunk-3LUQXNH6.mjs → chunk-XQ6PO4OP.mjs} +3 -3
  24. package/dist/{chunk-3LUQXNH6.mjs.map → chunk-XQ6PO4OP.mjs.map} +1 -1
  25. package/dist/core/index.js +37 -37
  26. package/dist/core/index.mjs +2 -2
  27. package/dist/gematria/index.js +4 -4
  28. package/dist/gematria/index.mjs +3 -3
  29. package/dist/ifa/index.js +1 -1
  30. package/dist/ifa/index.mjs +1 -1
  31. package/dist/index.d.mts +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +75 -71
  34. package/dist/index.mjs +5 -5
  35. package/dist/numerology/index.js +19 -19
  36. package/dist/numerology/index.mjs +4 -4
  37. package/dist/swisseph.js +1 -1
  38. package/dist/swisseph.node-2K5IHMKE.wasm +0 -0
  39. package/dist/swisseph.node-6H4ISR7M.mjs +3356 -0
  40. package/dist/swisseph.node-6H4ISR7M.mjs.map +1 -0
  41. package/dist/swisseph.node-UD2JYYLE.js +3358 -0
  42. package/dist/swisseph.node-UD2JYYLE.js.map +1 -0
  43. package/dist/swisseph.node.js +30 -0
  44. package/dist/swisseph.node.wasm +0 -0
  45. package/dist/swisseph.wasm +0 -0
  46. package/dist/swisseph.web-2K5IHMKE.wasm +0 -0
  47. package/dist/{chunk-T2JS2IJN.js → swisseph.web-MXYBWOOS.js} +43 -472
  48. package/dist/swisseph.web-MXYBWOOS.js.map +1 -0
  49. package/dist/{chunk-S6GM43CR.mjs → swisseph.web-TSFJI7DQ.mjs} +30 -448
  50. package/dist/swisseph.web-TSFJI7DQ.mjs.map +1 -0
  51. package/dist/swisseph.web.js +30 -0
  52. package/dist/swisseph.web.wasm +0 -0
  53. package/dist/tarot/index.js +1 -1
  54. package/dist/tarot/index.mjs +1 -1
  55. package/dist/wasm/build/swisseph.js +1 -1
  56. package/dist/wasm/build/swisseph.node-2K5IHMKE.wasm +0 -0
  57. package/dist/wasm/build/swisseph.node-6H4ISR7M.mjs +3356 -0
  58. package/dist/wasm/build/swisseph.node-6H4ISR7M.mjs.map +1 -0
  59. package/dist/wasm/build/swisseph.node-UD2JYYLE.js +3358 -0
  60. package/dist/wasm/build/swisseph.node-UD2JYYLE.js.map +1 -0
  61. package/dist/wasm/build/swisseph.node.js +30 -0
  62. package/dist/wasm/build/swisseph.node.wasm +0 -0
  63. package/dist/wasm/build/swisseph.wasm +0 -0
  64. package/dist/wasm/build/swisseph.web-2K5IHMKE.wasm +0 -0
  65. package/dist/wasm/build/swisseph.web-MXYBWOOS.js +3055 -0
  66. package/dist/wasm/build/swisseph.web-MXYBWOOS.js.map +1 -0
  67. package/dist/wasm/build/swisseph.web-TSFJI7DQ.mjs +3053 -0
  68. package/dist/wasm/build/swisseph.web-TSFJI7DQ.mjs.map +1 -0
  69. package/dist/wasm/build/swisseph.web.js +30 -0
  70. package/dist/wasm/build/swisseph.web.wasm +0 -0
  71. package/package.json +1 -1
  72. package/wasm/build/swisseph.js +1 -1
  73. package/wasm/build/swisseph.node.js +30 -0
  74. package/wasm/build/swisseph.node.wasm +0 -0
  75. package/wasm/build/swisseph.wasm +0 -0
  76. package/wasm/build/swisseph.web.js +30 -0
  77. package/wasm/build/swisseph.web.wasm +0 -0
  78. package/dist/chunk-2TUXWMP5.js +0 -47
  79. package/dist/chunk-PY5SMMJB.mjs +0 -41
  80. package/dist/chunk-S6GM43CR.mjs.map +0 -1
  81. package/dist/chunk-T2JS2IJN.js.map +0 -1
@@ -0,0 +1,685 @@
1
+ 'use strict';
2
+
3
+ var chunkFM7WUVZV_js = require('./chunk-FM7WUVZV.js');
4
+
5
+ // wasm/build/swisseph.node.wasm?url
6
+ var swisseph_node_default = "./swisseph.node-2K5IHMKE.wasm?url";
7
+
8
+ // wasm/build/swisseph.web.wasm?url
9
+ var swisseph_web_default = "./swisseph.web-2K5IHMKE.wasm?url";
10
+
11
+ // wasm/src/swisseph.ts
12
+ var Planet = /* @__PURE__ */ ((Planet2) => {
13
+ Planet2[Planet2["SUN"] = 0] = "SUN";
14
+ Planet2[Planet2["MOON"] = 1] = "MOON";
15
+ Planet2[Planet2["MERCURY"] = 2] = "MERCURY";
16
+ Planet2[Planet2["VENUS"] = 3] = "VENUS";
17
+ Planet2[Planet2["MARS"] = 4] = "MARS";
18
+ Planet2[Planet2["JUPITER"] = 5] = "JUPITER";
19
+ Planet2[Planet2["SATURN"] = 6] = "SATURN";
20
+ Planet2[Planet2["URANUS"] = 7] = "URANUS";
21
+ Planet2[Planet2["NEPTUNE"] = 8] = "NEPTUNE";
22
+ Planet2[Planet2["PLUTO"] = 9] = "PLUTO";
23
+ Planet2[Planet2["MEAN_NODE"] = 10] = "MEAN_NODE";
24
+ Planet2[Planet2["TRUE_NODE"] = 11] = "TRUE_NODE";
25
+ Planet2[Planet2["LILITH_MEAN"] = 12] = "LILITH_MEAN";
26
+ Planet2[Planet2["LILITH_TRUE"] = 13] = "LILITH_TRUE";
27
+ Planet2[Planet2["CHIRON"] = 15] = "CHIRON";
28
+ return Planet2;
29
+ })(Planet || {});
30
+ var VirtualNodes = /* @__PURE__ */ ((VirtualNodes2) => {
31
+ VirtualNodes2["PARS_FORTUNAE"] = "parsFortunae";
32
+ return VirtualNodes2;
33
+ })(VirtualNodes || {});
34
+ var PLANET_AND_NODE_NAMES = {
35
+ [0 /* SUN */]: "Sun",
36
+ [1 /* MOON */]: "Moon",
37
+ [2 /* MERCURY */]: "Mercury",
38
+ [3 /* VENUS */]: "Venus",
39
+ [4 /* MARS */]: "Mars",
40
+ [5 /* JUPITER */]: "Jupiter",
41
+ [6 /* SATURN */]: "Saturn",
42
+ [7 /* URANUS */]: "Uranus",
43
+ [8 /* NEPTUNE */]: "Neptune",
44
+ [9 /* PLUTO */]: "Pluto",
45
+ [10 /* MEAN_NODE */]: "Mean Node",
46
+ [11 /* TRUE_NODE */]: "True Node",
47
+ [12 /* LILITH_MEAN */]: "Lilith Mean",
48
+ [13 /* LILITH_TRUE */]: "Lilith True",
49
+ [15 /* CHIRON */]: "Chiron",
50
+ ["parsFortunae" /* PARS_FORTUNAE */]: "Wheel of Fortune"
51
+ };
52
+ var HouseSystem = /* @__PURE__ */ ((HouseSystem2) => {
53
+ HouseSystem2["PLACIDUS"] = "P";
54
+ HouseSystem2["KOCH"] = "K";
55
+ HouseSystem2["PORPHYRIUS"] = "O";
56
+ HouseSystem2["REGIOMONTANUS"] = "R";
57
+ HouseSystem2["CAMPANUS"] = "C";
58
+ HouseSystem2["EQUAL"] = "E";
59
+ HouseSystem2["WHOLE_SIGN"] = "W";
60
+ HouseSystem2["MERIDIAN"] = "X";
61
+ HouseSystem2["MORINUS"] = "M";
62
+ HouseSystem2["KRUSINSKI"] = "U";
63
+ HouseSystem2["ALCABITIUS"] = "B";
64
+ return HouseSystem2;
65
+ })(HouseSystem || {});
66
+ var CalcFlag = /* @__PURE__ */ ((CalcFlag2) => {
67
+ CalcFlag2[CalcFlag2["JPL_EPH"] = 1] = "JPL_EPH";
68
+ CalcFlag2[CalcFlag2["SWISS_EPH"] = 2] = "SWISS_EPH";
69
+ CalcFlag2[CalcFlag2["MOSHIER"] = 4] = "MOSHIER";
70
+ CalcFlag2[CalcFlag2["HELIOCENTRIC"] = 8] = "HELIOCENTRIC";
71
+ CalcFlag2[CalcFlag2["TRUE_POS"] = 16] = "TRUE_POS";
72
+ CalcFlag2[CalcFlag2["J2000"] = 32] = "J2000";
73
+ CalcFlag2[CalcFlag2["NONUT"] = 64] = "NONUT";
74
+ CalcFlag2[CalcFlag2["SPEED3"] = 128] = "SPEED3";
75
+ CalcFlag2[CalcFlag2["SPEED"] = 256] = "SPEED";
76
+ CalcFlag2[CalcFlag2["EQUATORIAL"] = 2048] = "EQUATORIAL";
77
+ CalcFlag2[CalcFlag2["TOPOCTR"] = 32768] = "TOPOCTR";
78
+ CalcFlag2[CalcFlag2["SIDEREAL"] = 65536] = "SIDEREAL";
79
+ return CalcFlag2;
80
+ })(CalcFlag || {});
81
+ var SE_AST_OFFSET = 1e4;
82
+ var BODY = {
83
+ MEAN_APOGEE: 12,
84
+ // Lilith mean
85
+ OSC_APOGEE: 13};
86
+ var normalizeAngle = (deg) => (deg % 360 + 360) % 360;
87
+ var SwissEph = class {
88
+ /**
89
+ * Constructor that accepts a pre-initialized Swiss Ephemeris module
90
+ */
91
+ constructor(module) {
92
+ this.swe_julday = null;
93
+ this.swe_calc_ut = null;
94
+ this.swe_houses = null;
95
+ this.swe_house_pos = null;
96
+ this.swe_set_ephe_path = null;
97
+ this.swe_close = null;
98
+ this.swe_set_topo = null;
99
+ this.swe_set_sid_mode = null;
100
+ this.module = module;
101
+ this.swe_julday = this.module.cwrap("swe_julday", "number", [
102
+ "number",
103
+ "number",
104
+ "number",
105
+ "number",
106
+ "number"
107
+ ]);
108
+ this.swe_calc_ut = this.module.cwrap("swe_calc_ut", "number", [
109
+ "number",
110
+ "number",
111
+ "number",
112
+ "number",
113
+ "number"
114
+ ]);
115
+ this.swe_houses = this.module.cwrap("swe_houses", "number", [
116
+ "number",
117
+ "number",
118
+ "number",
119
+ "number",
120
+ "number",
121
+ "number"
122
+ ]);
123
+ this.swe_house_pos = this.module.cwrap(
124
+ "swe_house_pos",
125
+ "number",
126
+ ["number", "number", "number", "string", "number", "number"]
127
+ );
128
+ this.swe_set_ephe_path = this.module.cwrap(
129
+ "swe_set_ephe_path",
130
+ null,
131
+ ["number"]
132
+ );
133
+ this.swe_close = this.module.cwrap("swe_close", null, []);
134
+ this.swe_set_topo = this.module.cwrap("swe_set_topo", null, [
135
+ "number",
136
+ "number",
137
+ "number"
138
+ ]);
139
+ this.swe_set_sid_mode = this.module.cwrap(
140
+ "swe_set_sid_mode",
141
+ null,
142
+ ["number", "number", "number"]
143
+ );
144
+ }
145
+ checkInitialized() {
146
+ if (!this.module) {
147
+ throw new Error("Swiss Ephemeris module not available.");
148
+ }
149
+ }
150
+ /**
151
+ * Sets the path to the ephemeris data files.
152
+ * @param path - The path to the directory containing ephemeris files.
153
+ */
154
+ setEphemerisPath(path) {
155
+ this.checkInitialized();
156
+ if (path && this.swe_set_ephe_path) {
157
+ const pathPtr = this.module._malloc(path.length + 1);
158
+ if (!pathPtr) {
159
+ throw new Error("Failed to allocate memory for ephemeris path");
160
+ }
161
+ this.module.stringToUTF8(path, pathPtr, path.length + 1);
162
+ this.swe_set_ephe_path(pathPtr);
163
+ this.module._free(pathPtr);
164
+ }
165
+ }
166
+ /**
167
+ * Calculate Julian day number for a given date and time
168
+ */
169
+ getJulianDay(date) {
170
+ this.checkInitialized();
171
+ if (!this.swe_julday) {
172
+ throw new Error("Julian day calculation function not available");
173
+ }
174
+ const year = date.getUTCFullYear();
175
+ const month = date.getUTCMonth() + 1;
176
+ const day = date.getUTCDate();
177
+ const hour = date.getUTCHours() + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600;
178
+ return this.swe_julday(year, month, day, hour, 1);
179
+ }
180
+ /**
181
+ * Calculate planet position at a given Julian day
182
+ */
183
+ calculatePlanetPosition(julday, planet, flags = 2 /* SWISS_EPH */) {
184
+ this.checkInitialized();
185
+ if (!this.swe_calc_ut || !this.module) {
186
+ throw new Error("Planet calculation function not available");
187
+ }
188
+ const resultPtr = this.module._malloc(6 * 8);
189
+ if (!resultPtr) {
190
+ throw new Error("Failed to allocate memory for planet position");
191
+ }
192
+ const ERR_BYTES = 512;
193
+ const errPtr = this.module._malloc(ERR_BYTES);
194
+ if (!errPtr) {
195
+ this.module._free(resultPtr);
196
+ throw new Error("Failed to allocate memory for error buffer");
197
+ }
198
+ this.module.HEAP8.fill(0, errPtr, errPtr + ERR_BYTES);
199
+ try {
200
+ let ret = this.swe_calc_ut(julday, planet, flags, resultPtr, errPtr);
201
+ if (ret < 0) {
202
+ const msg = this.module.UTF8ToString(errPtr);
203
+ throw new Error(msg && msg.length ? msg : `Swiss Ephemeris calculation failed with error code ${ret}`);
204
+ }
205
+ const position = {
206
+ longitude: this.module.getValue(resultPtr, "double"),
207
+ latitude: this.module.getValue(resultPtr + 8, "double"),
208
+ distance: this.module.getValue(resultPtr + 16, "double")
209
+ };
210
+ if (flags & 256 /* SPEED */) {
211
+ position.longitudeSpeed = this.module.getValue(resultPtr + 24, "double");
212
+ position.latitudeSpeed = this.module.getValue(resultPtr + 32, "double");
213
+ position.distanceSpeed = this.module.getValue(resultPtr + 40, "double");
214
+ }
215
+ return position;
216
+ } finally {
217
+ this.module._free(errPtr);
218
+ this.module._free(resultPtr);
219
+ }
220
+ }
221
+ /**
222
+ * Calculate houses for a given date, location, and house system
223
+ */
224
+ calculateHouses(julday, latitude, longitude, hsys = "P" /* PLACIDUS */) {
225
+ this.checkInitialized();
226
+ if (!this.swe_houses || !this.module) {
227
+ throw new Error("Houses calculation function not available");
228
+ }
229
+ if (latitude < -90 || latitude > 90) {
230
+ throw new Error("Latitude must be between -90 and 90 degrees");
231
+ }
232
+ if (longitude < -180 || longitude > 180) {
233
+ throw new Error("Longitude must be between -180 and 180 degrees");
234
+ }
235
+ const HOUSES_DOUBLES = 13;
236
+ const ASCMC_DOUBLES = 10;
237
+ const BYTES_PER_F64 = 8;
238
+ const totalBytes = (HOUSES_DOUBLES + ASCMC_DOUBLES) * BYTES_PER_F64;
239
+ const memoryPtr = this.module._malloc(totalBytes);
240
+ if (!memoryPtr) throw new Error("Memory allocation failed");
241
+ const housesPtr = memoryPtr;
242
+ const ascmcPtr = memoryPtr + HOUSES_DOUBLES * BYTES_PER_F64;
243
+ try {
244
+ const hsysCode = hsys.charCodeAt(0);
245
+ const ret = this.swe_houses(
246
+ julday,
247
+ latitude,
248
+ longitude,
249
+ hsysCode,
250
+ housesPtr,
251
+ ascmcPtr
252
+ );
253
+ if (ret < 0) {
254
+ throw new Error(`Houses calculation failed with error code ${ret}`);
255
+ }
256
+ const houses = new Array(HOUSES_DOUBLES);
257
+ for (let i = 0; i < HOUSES_DOUBLES; i++) {
258
+ houses[i] = this.module.getValue(
259
+ housesPtr + i * BYTES_PER_F64,
260
+ "double"
261
+ );
262
+ }
263
+ const ascendant = this.module.getValue(
264
+ ascmcPtr + 0 * BYTES_PER_F64,
265
+ "double"
266
+ );
267
+ const mc = this.module.getValue(ascmcPtr + 1 * BYTES_PER_F64, "double");
268
+ const armc = this.module.getValue(ascmcPtr + 2 * BYTES_PER_F64, "double");
269
+ const vertex = this.module.getValue(
270
+ ascmcPtr + 3 * BYTES_PER_F64,
271
+ "double"
272
+ );
273
+ const equasc = this.module.getValue(
274
+ ascmcPtr + 4 * BYTES_PER_F64,
275
+ "double"
276
+ );
277
+ const coasc1 = this.module.getValue(
278
+ ascmcPtr + 5 * BYTES_PER_F64,
279
+ "double"
280
+ );
281
+ const coasc2 = this.module.getValue(
282
+ ascmcPtr + 6 * BYTES_PER_F64,
283
+ "double"
284
+ );
285
+ const polasc = this.module.getValue(
286
+ ascmcPtr + 7 * BYTES_PER_F64,
287
+ "double"
288
+ );
289
+ return {
290
+ ascendant,
291
+ mc,
292
+ houses,
293
+ ascmc: {
294
+ armc,
295
+ vertex,
296
+ equasc,
297
+ coasc1,
298
+ coasc2,
299
+ polasc
300
+ }
301
+ };
302
+ } finally {
303
+ this.module._free(memoryPtr);
304
+ }
305
+ }
306
+ /**
307
+ * Clean up and close the Swiss Ephemeris
308
+ */
309
+ close() {
310
+ this.checkInitialized();
311
+ if (this.swe_close) {
312
+ this.swe_close();
313
+ }
314
+ }
315
+ /**
316
+ * Set topocentric observer
317
+ */
318
+ setTopocentric(longitude, latitude, altitudeMeters = 0) {
319
+ this.checkInitialized();
320
+ if (!this.swe_set_topo) {
321
+ throw new Error("Topocentric calculation function not available");
322
+ }
323
+ this.swe_set_topo(longitude, latitude, altitudeMeters);
324
+ }
325
+ /**
326
+ * Set sidereal mode
327
+ * Ex.: mode=1 (Lahiri). See Swiss Ephemeris mode table.
328
+ */
329
+ setSiderealMode(mode, t0 = 0, ayan_t0 = 0) {
330
+ this.checkInitialized();
331
+ this.swe_set_sid_mode?.(mode, t0, ayan_t0);
332
+ }
333
+ /**
334
+ * Asteroid by MPC number
335
+ */
336
+ calculateAsteroidPosition(julday, mpcNumber, flags = 2 /* SWISS_EPH */) {
337
+ return this.calculatePlanetPosition(
338
+ julday,
339
+ SE_AST_OFFSET + mpcNumber,
340
+ flags
341
+ );
342
+ }
343
+ /**
344
+ * Lilith mean (12) and true (13)
345
+ */
346
+ calculateLilith(julday, kind = "mean", flags = 2 /* SWISS_EPH */) {
347
+ const id = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE;
348
+ return this.calculatePlanetPosition(julday, id, flags);
349
+ }
350
+ };
351
+ function parsFortunae(asc, sunLon, moonLon, diurnal) {
352
+ const val = diurnal ? asc + moonLon - sunLon : asc + sunLon - moonLon;
353
+ return normalizeAngle(val);
354
+ }
355
+
356
+ // src/astrology/swisseph.ts
357
+ var swissEph = null;
358
+ var DEFAULT_FLAGS = 2 /* SWISS_EPH */ | 256 /* SPEED */;
359
+ async function getSwissEph(options = {}) {
360
+ if (swissEph) {
361
+ return;
362
+ }
363
+ try {
364
+ const isBrowser = typeof window !== "undefined";
365
+ const wasmUrl = isBrowser ? swisseph_web_default : swisseph_node_default;
366
+ const finalWasmPath = options.wasmPath || (isBrowser ? wasmUrl : chunkFM7WUVZV_js.__require("path").resolve(__dirname, wasmUrl));
367
+ const moduleFactory = isBrowser ? (await import('./swisseph.web-MXYBWOOS.js')).default : (await import('./swisseph.node-UD2JYYLE.js')).default;
368
+ const module = await moduleFactory({
369
+ locateFile: () => finalWasmPath
370
+ });
371
+ const instance = new SwissEph(module);
372
+ const defaultEphePath = isBrowser ? "../ephe" : chunkFM7WUVZV_js.__require("path").resolve(__dirname, "../ephe");
373
+ const finalEphePath = options.ephePath || defaultEphePath;
374
+ if (isBrowser) {
375
+ const epheFsPath = "/ephe";
376
+ try {
377
+ module.FS?.mkdir?.(epheFsPath);
378
+ } catch {
379
+ }
380
+ const files = ["seas_18.se1", "semo_18.se1", "sepl_18.se1"];
381
+ await Promise.all(
382
+ files.map(async (name) => {
383
+ const url = `${finalEphePath}/${name}`;
384
+ const res = await fetch(url);
385
+ if (!res.ok) {
386
+ throw new Error(`Failed to fetch ephemeris file: ${url}`);
387
+ }
388
+ const buf = await res.arrayBuffer();
389
+ module.FS?.writeFile?.(
390
+ `${epheFsPath}/${name}`,
391
+ new Uint8Array(buf)
392
+ );
393
+ })
394
+ );
395
+ console.info(`Setting ephemeris path to: ${epheFsPath}`);
396
+ instance.setEphemerisPath(epheFsPath);
397
+ } else {
398
+ console.info(
399
+ "Emscripten FS availability:",
400
+ Boolean(module.FS),
401
+ "mount:",
402
+ Boolean(module.FS?.mount),
403
+ "NODEFS:",
404
+ Boolean(module.FS?.filesystems?.NODEFS)
405
+ );
406
+ if (module.FS?.mount && module.FS?.filesystems?.NODEFS) {
407
+ const mountPoint = "/ephefs";
408
+ try {
409
+ try {
410
+ module.FS.mkdir(mountPoint);
411
+ } catch {
412
+ }
413
+ module.FS.mount(
414
+ module.FS.filesystems.NODEFS,
415
+ { root: finalEphePath },
416
+ mountPoint
417
+ );
418
+ console.info(
419
+ `Setting ephemeris path to: ${mountPoint} (mounted from ${finalEphePath})`
420
+ );
421
+ instance.setEphemerisPath(mountPoint);
422
+ } catch (mountErr) {
423
+ console.warn(
424
+ `Failed to mount ephemeris directory, falling back to host path: ${finalEphePath}`,
425
+ mountErr
426
+ );
427
+ console.info(`Setting ephemeris path to: ${finalEphePath}`);
428
+ instance.setEphemerisPath(finalEphePath);
429
+ }
430
+ } else {
431
+ console.info(`Setting ephemeris path to: ${finalEphePath}`);
432
+ instance.setEphemerisPath(finalEphePath);
433
+ }
434
+ }
435
+ swissEph = instance;
436
+ } catch (error) {
437
+ console.error("Error initializing Swiss Ephemeris:", error);
438
+ throw error;
439
+ }
440
+ }
441
+ async function calculatePlanetaryPositions(date) {
442
+ try {
443
+ checkInitialization();
444
+ const julday = swissEph.getJulianDay(date);
445
+ const flags = DEFAULT_FLAGS;
446
+ const planets = {
447
+ sun: 0 /* SUN */,
448
+ moon: 1 /* MOON */,
449
+ mercury: 2 /* MERCURY */,
450
+ venus: 3 /* VENUS */,
451
+ mars: 4 /* MARS */,
452
+ jupiter: 5 /* JUPITER */,
453
+ saturn: 6 /* SATURN */,
454
+ uranus: 7 /* URANUS */,
455
+ neptune: 8 /* NEPTUNE */,
456
+ pluto: 9 /* PLUTO */,
457
+ meanNode: 10 /* MEAN_NODE */,
458
+ trueNode: 11 /* TRUE_NODE */,
459
+ chiron: 15 /* CHIRON */,
460
+ lilithMean: 12 /* LILITH_MEAN */,
461
+ lilithTrue: 13 /* LILITH_TRUE */
462
+ };
463
+ const positions = {};
464
+ for (const id of Object.values(planets)) {
465
+ try {
466
+ positions[id] = swissEph.calculatePlanetPosition(julday, id, flags);
467
+ } catch (error) {
468
+ throw new Error(
469
+ `Failed to calculate position for ${PLANET_AND_NODE_NAMES[id]}: ${error}`
470
+ );
471
+ }
472
+ }
473
+ return positions;
474
+ } catch (error) {
475
+ console.error("Error calculating planetary positions:", error);
476
+ throw error;
477
+ }
478
+ }
479
+ async function calculateHouses(date, latitude, longitude, houseSystem) {
480
+ try {
481
+ checkInitialization();
482
+ const julday = swissEph.getJulianDay(date);
483
+ return swissEph.calculateHouses(julday, latitude, longitude, houseSystem);
484
+ } catch (error) {
485
+ console.error("Error calculating houses:", error);
486
+ throw error;
487
+ }
488
+ }
489
+ function calcParsFortunae(asc, sunLon, moonLon, isDiurnal) {
490
+ return parsFortunae(asc, sunLon, moonLon, isDiurnal);
491
+ }
492
+ function closeSwissEph() {
493
+ if (swissEph) {
494
+ try {
495
+ swissEph.close();
496
+ swissEph = null;
497
+ } catch (error) {
498
+ console.error("Error closing Swiss Ephemeris:", error);
499
+ throw error;
500
+ }
501
+ }
502
+ }
503
+ function checkInitialization() {
504
+ if (!swissEph) {
505
+ throw new Error(
506
+ "Swiss Ephemeris not initialized. Call getSwissEph() first."
507
+ );
508
+ }
509
+ }
510
+
511
+ // src/astrology/index.ts
512
+ function validateInputs(options) {
513
+ if (!(options.date instanceof Date) || isNaN(options.date.getTime())) {
514
+ throw new Error("Invalid date provided");
515
+ }
516
+ if (typeof options.latitude !== "number" || options.latitude < -90 || options.latitude > 90) {
517
+ throw new Error("Invalid latitude: must be between -90 and 90 degrees");
518
+ }
519
+ if (typeof options.longitude !== "number" || options.longitude < -180 || options.longitude > 180) {
520
+ throw new Error("Invalid longitude: must be between -180 and 180 degrees");
521
+ }
522
+ if (typeof options.timezone !== "number" || options.timezone < -12 || options.timezone > 14) {
523
+ throw new Error("Invalid timezone: must be between -12 and +14");
524
+ }
525
+ }
526
+ function hydratePlanet(id, position, houseCusps) {
527
+ return {
528
+ ...position,
529
+ id,
530
+ name: PLANET_AND_NODE_NAMES[id],
531
+ zodiacPosition: getZodiacPosition(position.longitude, houseCusps)
532
+ };
533
+ }
534
+ async function getBirthChart(options) {
535
+ try {
536
+ validateInputs(options);
537
+ const localDate = new Date(options.date);
538
+ const utcDate = new Date(
539
+ localDate.getTime() - options.timezone * 60 * 60 * 1e3
540
+ );
541
+ const planetPositions = await calculatePlanetaryPositions(utcDate);
542
+ if (!planetPositions) {
543
+ throw new Error("Failed to calculate planetary positions");
544
+ }
545
+ const housesPositions = await calculateHouses(
546
+ utcDate,
547
+ options.latitude,
548
+ options.longitude,
549
+ options.houseSystem || "P" /* PLACIDUS */
550
+ );
551
+ if (!housesPositions) {
552
+ throw new Error("Failed to calculate houses");
553
+ }
554
+ const houseCusps = housesPositions.houses.slice(1, 13).map(normalizeAngle);
555
+ const planets = {};
556
+ for (const [planetId, position] of Object.entries(planetPositions)) {
557
+ const id = planetId;
558
+ const hydratedPlanet = hydratePlanet(id, position, houseCusps);
559
+ planets[hydratedPlanet.name.toLocaleLowerCase()] = hydratedPlanet;
560
+ }
561
+ const houseCuspsPositions = houseCusps.map(
562
+ (lon) => getZodiacPosition(lon, houseCusps)
563
+ );
564
+ const descendant = normalizeAngle(housesPositions.ascendant + 180);
565
+ const imumCoeli = normalizeAngle(housesPositions.mc + 180);
566
+ const ascendantSign = getZodiacPosition(
567
+ housesPositions.ascendant,
568
+ houseCusps
569
+ );
570
+ const midheavenSign = getZodiacPosition(housesPositions.mc, houseCusps);
571
+ const descendantSign = getZodiacPosition(descendant, houseCusps);
572
+ const imumCoeliSign = getZodiacPosition(imumCoeli, houseCusps);
573
+ const houses = {
574
+ ascendant: ascendantSign,
575
+ mc: midheavenSign,
576
+ dc: descendantSign,
577
+ ic: imumCoeliSign,
578
+ houses: houseCuspsPositions,
579
+ ascmc: {
580
+ armc: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.armc, houseCusps) : void 0,
581
+ vertex: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.vertex, houseCusps) : void 0,
582
+ equasc: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.equasc, houseCusps) : void 0,
583
+ coasc1: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.coasc1, houseCusps) : void 0,
584
+ coasc2: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.coasc2, houseCusps) : void 0,
585
+ polasc: housesPositions.ascmc ? getZodiacPosition(housesPositions.ascmc.polasc, houseCusps) : void 0
586
+ }
587
+ };
588
+ const isDiurnal = planets.sun.zodiacPosition.house >= 7 && planets.sun.zodiacPosition.house <= 12;
589
+ const wheelOfFortuneLongitude = calcParsFortunae(
590
+ houses.ascendant.longitude,
591
+ planets.sun.longitude,
592
+ planets.moon.longitude,
593
+ isDiurnal
594
+ );
595
+ const wheelOfFortune = getZodiacPosition(
596
+ wheelOfFortuneLongitude,
597
+ houseCusps
598
+ );
599
+ const nodes = {
600
+ ["parsFortunae" /* PARS_FORTUNAE */]: {
601
+ ...wheelOfFortune,
602
+ id: "parsFortunae" /* PARS_FORTUNAE */,
603
+ name: PLANET_AND_NODE_NAMES["parsFortunae" /* PARS_FORTUNAE */]
604
+ }
605
+ };
606
+ return {
607
+ dateUtc: utcDate,
608
+ planets,
609
+ houses,
610
+ nodes
611
+ };
612
+ } catch (error) {
613
+ console.error("Error calculating birth chart:", error);
614
+ throw error;
615
+ }
616
+ }
617
+ var SIGNS = [
618
+ "Aries",
619
+ "Taurus",
620
+ "Gemini",
621
+ "Cancer",
622
+ "Leo",
623
+ "Virgo",
624
+ "Libra",
625
+ "Scorpio",
626
+ "Sagittarius",
627
+ "Capricorn",
628
+ "Aquarius",
629
+ "Pisces"
630
+ ];
631
+ function formatDegreeMinutes(decimalDegrees) {
632
+ let deg = Math.floor(decimalDegrees);
633
+ let min = Math.round((decimalDegrees - deg) * 60);
634
+ if (min === 60) {
635
+ min = 0;
636
+ deg += 1;
637
+ }
638
+ return `${deg}\xB0${String(min).padStart(2, "0")}'`;
639
+ }
640
+ function getZodiacPosition(longitude, houseCusps) {
641
+ const L = normalizeAngle(longitude);
642
+ const signIndex = Math.floor(L / 30) % 12;
643
+ const within = L - signIndex * 30;
644
+ const house = findHouseOf(L, houseCusps);
645
+ return {
646
+ sign: SIGNS[signIndex],
647
+ decimalDegrees: within,
648
+ traditionalFormat: formatDegreeMinutes(within),
649
+ decimal: within.toFixed(2) + "\xB0",
650
+ longitude: L,
651
+ house
652
+ };
653
+ }
654
+ function findHouseOf(longitude, housePositions) {
655
+ const L = normalizeAngle(longitude);
656
+ if (!housePositions || housePositions.length === 0) {
657
+ throw new Error("House positions are required");
658
+ }
659
+ const H = housePositions.map((c, i) => ({ i: i + 1, L: normalizeAngle(c) })).sort((a, b) => a.L - b.L);
660
+ for (let k = 0; k < H.length; k++) {
661
+ const cur = H[k], nxt = H[(k + 1) % H.length];
662
+ if (nxt.L < cur.L) {
663
+ if (L >= cur.L || L < nxt.L) return cur.i;
664
+ } else {
665
+ if (L >= cur.L && L < nxt.L) return cur.i;
666
+ }
667
+ }
668
+ return 1;
669
+ }
670
+
671
+ exports.CalcFlag = CalcFlag;
672
+ exports.HouseSystem = HouseSystem;
673
+ exports.PLANET_AND_NODE_NAMES = PLANET_AND_NODE_NAMES;
674
+ exports.Planet = Planet;
675
+ exports.SIGNS = SIGNS;
676
+ exports.VirtualNodes = VirtualNodes;
677
+ exports.closeSwissEph = closeSwissEph;
678
+ exports.findHouseOf = findHouseOf;
679
+ exports.formatDegreeMinutes = formatDegreeMinutes;
680
+ exports.getBirthChart = getBirthChart;
681
+ exports.getSwissEph = getSwissEph;
682
+ exports.getZodiacPosition = getZodiacPosition;
683
+ exports.normalizeAngle = normalizeAngle;
684
+ //# sourceMappingURL=chunk-CGCEKFLD.js.map
685
+ //# sourceMappingURL=chunk-CGCEKFLD.js.map