kaabalah 5.3.0 → 5.5.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.
- package/dist/astrology/index.d.mts +340 -1
- package/dist/astrology/index.d.ts +340 -1
- package/dist/astrology/index.js +138 -22
- package/dist/astrology/index.mjs +1 -1
- package/dist/{chunk-AHUZONHJ.js → chunk-HGEWHDIX.js} +974 -3
- package/dist/chunk-HGEWHDIX.js.map +1 -0
- package/dist/{chunk-VSTGPXLM.mjs → chunk-T6Y4DLMA.mjs} +946 -4
- package/dist/chunk-T6Y4DLMA.mjs.map +1 -0
- package/dist/cli.js +2059 -57
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +138 -22
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-AHUZONHJ.js.map +0 -1
- package/dist/chunk-VSTGPXLM.mjs.map +0 -1
|
@@ -78,6 +78,17 @@ var CalcFlag = /* @__PURE__ */ ((CalcFlag2) => {
|
|
|
78
78
|
CalcFlag2[CalcFlag2["SIDEREAL"] = 65536] = "SIDEREAL";
|
|
79
79
|
return CalcFlag2;
|
|
80
80
|
})(CalcFlag || {});
|
|
81
|
+
var RiseTransitFlag = /* @__PURE__ */ ((RiseTransitFlag2) => {
|
|
82
|
+
RiseTransitFlag2[RiseTransitFlag2["RISE"] = 1] = "RISE";
|
|
83
|
+
RiseTransitFlag2[RiseTransitFlag2["SET"] = 2] = "SET";
|
|
84
|
+
RiseTransitFlag2[RiseTransitFlag2["UPPER_MERIDIAN"] = 4] = "UPPER_MERIDIAN";
|
|
85
|
+
RiseTransitFlag2[RiseTransitFlag2["LOWER_MERIDIAN"] = 8] = "LOWER_MERIDIAN";
|
|
86
|
+
RiseTransitFlag2[RiseTransitFlag2["DISC_CENTER"] = 256] = "DISC_CENTER";
|
|
87
|
+
RiseTransitFlag2[RiseTransitFlag2["NO_REFRACTION"] = 512] = "NO_REFRACTION";
|
|
88
|
+
return RiseTransitFlag2;
|
|
89
|
+
})(RiseTransitFlag || {});
|
|
90
|
+
var SE_ECL2HOR = 0;
|
|
91
|
+
var SE_EQU2HOR = 1;
|
|
81
92
|
var SE_AST_OFFSET = 1e4;
|
|
82
93
|
var BODY = {
|
|
83
94
|
MEAN_APOGEE: 12,
|
|
@@ -97,6 +108,8 @@ var SwissEph = class {
|
|
|
97
108
|
this.swe_close = null;
|
|
98
109
|
this.swe_set_topo = null;
|
|
99
110
|
this.swe_set_sid_mode = null;
|
|
111
|
+
this.swe_azalt_fn = null;
|
|
112
|
+
this.swe_rise_trans_fn = null;
|
|
100
113
|
this.module = module;
|
|
101
114
|
this.swe_julday = this.module.cwrap("swe_julday", "number", [
|
|
102
115
|
"number",
|
|
@@ -141,6 +154,16 @@ var SwissEph = class {
|
|
|
141
154
|
null,
|
|
142
155
|
["number", "number", "number"]
|
|
143
156
|
);
|
|
157
|
+
this.swe_azalt_fn = this.module.cwrap(
|
|
158
|
+
"swe_azalt",
|
|
159
|
+
null,
|
|
160
|
+
["number", "number", "number", "number", "number", "number", "number"]
|
|
161
|
+
);
|
|
162
|
+
this.swe_rise_trans_fn = this.module.cwrap(
|
|
163
|
+
"swe_rise_trans",
|
|
164
|
+
"number",
|
|
165
|
+
["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]
|
|
166
|
+
);
|
|
144
167
|
}
|
|
145
168
|
checkInitialized() {
|
|
146
169
|
if (!this.module) {
|
|
@@ -347,6 +370,105 @@ var SwissEph = class {
|
|
|
347
370
|
const id = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE;
|
|
348
371
|
return this.calculatePlanetPosition(julday, id, flags);
|
|
349
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Convert ecliptic (or equatorial) coordinates to horizon coordinates.
|
|
375
|
+
* Returns azimuth (0=south, 90=west, 180=north, 270=east) and altitude.
|
|
376
|
+
*/
|
|
377
|
+
azalt(julday, longitude, latitude, altitude, xinLon, xinLat, xinDist, fromEquatorial = false) {
|
|
378
|
+
this.checkInitialized();
|
|
379
|
+
if (!this.swe_azalt_fn) {
|
|
380
|
+
throw new Error("swe_azalt function not available");
|
|
381
|
+
}
|
|
382
|
+
const BYTES = 8;
|
|
383
|
+
const geoPtr = this.module._malloc(3 * BYTES);
|
|
384
|
+
const xinPtr = this.module._malloc(3 * BYTES);
|
|
385
|
+
const xazPtr = this.module._malloc(3 * BYTES);
|
|
386
|
+
if (!geoPtr || !xinPtr || !xazPtr) {
|
|
387
|
+
if (geoPtr) this.module._free(geoPtr);
|
|
388
|
+
if (xinPtr) this.module._free(xinPtr);
|
|
389
|
+
if (xazPtr) this.module._free(xazPtr);
|
|
390
|
+
throw new Error("Memory allocation failed for azalt");
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
this.module.setValue(geoPtr, longitude, "double");
|
|
394
|
+
this.module.setValue(geoPtr + BYTES, latitude, "double");
|
|
395
|
+
this.module.setValue(geoPtr + 2 * BYTES, altitude, "double");
|
|
396
|
+
this.module.setValue(xinPtr, xinLon, "double");
|
|
397
|
+
this.module.setValue(xinPtr + BYTES, xinLat, "double");
|
|
398
|
+
this.module.setValue(xinPtr + 2 * BYTES, xinDist, "double");
|
|
399
|
+
this.swe_azalt_fn(
|
|
400
|
+
julday,
|
|
401
|
+
fromEquatorial ? SE_EQU2HOR : SE_ECL2HOR,
|
|
402
|
+
geoPtr,
|
|
403
|
+
0,
|
|
404
|
+
// atpress (0 = default 1013.25 mbar)
|
|
405
|
+
0,
|
|
406
|
+
// attemp (0 = default 15°C)
|
|
407
|
+
xinPtr,
|
|
408
|
+
xazPtr
|
|
409
|
+
);
|
|
410
|
+
return {
|
|
411
|
+
azimuth: this.module.getValue(xazPtr, "double"),
|
|
412
|
+
trueAltitude: this.module.getValue(xazPtr + BYTES, "double"),
|
|
413
|
+
apparentAltitude: this.module.getValue(xazPtr + 2 * BYTES, "double")
|
|
414
|
+
};
|
|
415
|
+
} finally {
|
|
416
|
+
this.module._free(geoPtr);
|
|
417
|
+
this.module._free(xinPtr);
|
|
418
|
+
this.module._free(xazPtr);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Find the next rise, set, or meridian transit of a planet.
|
|
423
|
+
* Returns the Julian day of the event.
|
|
424
|
+
*/
|
|
425
|
+
riseTransit(julday, planet, rsmi, longitude, latitude, altitude = 0, flags = 2 /* SWISS_EPH */) {
|
|
426
|
+
this.checkInitialized();
|
|
427
|
+
if (!this.swe_rise_trans_fn) {
|
|
428
|
+
throw new Error("swe_rise_trans function not available");
|
|
429
|
+
}
|
|
430
|
+
const BYTES = 8;
|
|
431
|
+
const geoPtr = this.module._malloc(3 * BYTES);
|
|
432
|
+
const tretPtr = this.module._malloc(BYTES);
|
|
433
|
+
const ERR_BYTES = 512;
|
|
434
|
+
const errPtr = this.module._malloc(ERR_BYTES);
|
|
435
|
+
if (!geoPtr || !tretPtr || !errPtr) {
|
|
436
|
+
if (geoPtr) this.module._free(geoPtr);
|
|
437
|
+
if (tretPtr) this.module._free(tretPtr);
|
|
438
|
+
if (errPtr) this.module._free(errPtr);
|
|
439
|
+
throw new Error("Memory allocation failed for riseTransit");
|
|
440
|
+
}
|
|
441
|
+
this.module.HEAP8.fill(0, errPtr, errPtr + ERR_BYTES);
|
|
442
|
+
try {
|
|
443
|
+
this.module.setValue(geoPtr, longitude, "double");
|
|
444
|
+
this.module.setValue(geoPtr + BYTES, latitude, "double");
|
|
445
|
+
this.module.setValue(geoPtr + 2 * BYTES, altitude, "double");
|
|
446
|
+
const ret = this.swe_rise_trans_fn(
|
|
447
|
+
julday,
|
|
448
|
+
planet,
|
|
449
|
+
0,
|
|
450
|
+
// starname pointer (0 = planet, not fixed star)
|
|
451
|
+
flags,
|
|
452
|
+
rsmi,
|
|
453
|
+
geoPtr,
|
|
454
|
+
0,
|
|
455
|
+
// atpress
|
|
456
|
+
0,
|
|
457
|
+
// attemp
|
|
458
|
+
tretPtr,
|
|
459
|
+
errPtr
|
|
460
|
+
);
|
|
461
|
+
if (ret < 0) {
|
|
462
|
+
const msg = this.module.UTF8ToString(errPtr);
|
|
463
|
+
throw new Error(msg || `swe_rise_trans failed with code ${ret}`);
|
|
464
|
+
}
|
|
465
|
+
return this.module.getValue(tretPtr, "double");
|
|
466
|
+
} finally {
|
|
467
|
+
this.module._free(geoPtr);
|
|
468
|
+
this.module._free(tretPtr);
|
|
469
|
+
this.module._free(errPtr);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
350
472
|
};
|
|
351
473
|
function parsFortunae(asc, sunLon, moonLon, diurnal) {
|
|
352
474
|
const val = diurnal ? asc + moonLon - sunLon : asc + sunLon - moonLon;
|
|
@@ -587,6 +709,29 @@ async function getSwissEph(options = {}) {
|
|
|
587
709
|
throw error;
|
|
588
710
|
}
|
|
589
711
|
}
|
|
712
|
+
function calculateSinglePlanetPosition(date, planet) {
|
|
713
|
+
checkInitialization();
|
|
714
|
+
const julday = swissEph.getJulianDay(date);
|
|
715
|
+
return swissEph.calculatePlanetPosition(julday, planet, DEFAULT_FLAGS);
|
|
716
|
+
}
|
|
717
|
+
function calculateEquatorialPosition(date, planet) {
|
|
718
|
+
checkInitialization();
|
|
719
|
+
const julday = swissEph.getJulianDay(date);
|
|
720
|
+
const pos = swissEph.calculatePlanetPosition(
|
|
721
|
+
julday,
|
|
722
|
+
planet,
|
|
723
|
+
2 /* SWISS_EPH */ | 2048 /* EQUATORIAL */
|
|
724
|
+
);
|
|
725
|
+
return {
|
|
726
|
+
rightAscension: pos.longitude,
|
|
727
|
+
declination: pos.latitude,
|
|
728
|
+
distance: pos.distance
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
function getJulianDay(date) {
|
|
732
|
+
checkInitialization();
|
|
733
|
+
return swissEph.getJulianDay(date);
|
|
734
|
+
}
|
|
590
735
|
async function calculatePlanetaryPositions(date) {
|
|
591
736
|
try {
|
|
592
737
|
checkInitialization();
|
|
@@ -706,6 +851,9 @@ function getTimeZoneOffsetMs(instant, timeZone) {
|
|
|
706
851
|
return asUTC - instant.getTime();
|
|
707
852
|
}
|
|
708
853
|
async function localToUtcDate(local, latitude, longitude, opts = {}) {
|
|
854
|
+
if (opts.treatAsUTC === true) {
|
|
855
|
+
return local instanceof Date ? local : createUtcDateFromParts(buildLocalParts(local));
|
|
856
|
+
}
|
|
709
857
|
const parts = buildLocalParts(local);
|
|
710
858
|
const auto = opts.autoTimeZone !== false;
|
|
711
859
|
if (typeof opts.utcOffsetMinutes === "number" && Number.isFinite(opts.utcOffsetMinutes)) {
|
|
@@ -750,6 +898,181 @@ async function toUtcDate(local, latitude, longitude, options = {}) {
|
|
|
750
898
|
return localToUtcDate(local, latitude, longitude, options);
|
|
751
899
|
}
|
|
752
900
|
|
|
901
|
+
// src/astrology/astrocartography.ts
|
|
902
|
+
var ASTROCARTOGRAPHY_DEFAULT_PLANETS = [
|
|
903
|
+
0 /* SUN */,
|
|
904
|
+
1 /* MOON */,
|
|
905
|
+
2 /* MERCURY */,
|
|
906
|
+
3 /* VENUS */,
|
|
907
|
+
4 /* MARS */,
|
|
908
|
+
5 /* JUPITER */,
|
|
909
|
+
6 /* SATURN */,
|
|
910
|
+
7 /* URANUS */,
|
|
911
|
+
8 /* NEPTUNE */,
|
|
912
|
+
9 /* PLUTO */,
|
|
913
|
+
15 /* CHIRON */,
|
|
914
|
+
11 /* TRUE_NODE */
|
|
915
|
+
];
|
|
916
|
+
var DEG = Math.PI / 180;
|
|
917
|
+
function computeGMST(julianDay) {
|
|
918
|
+
return normalizeAngle(
|
|
919
|
+
280.46061837 + 360.98564736629 * (julianDay - 2451545)
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
function computeMCLongitude(gmst, ra) {
|
|
923
|
+
return toGeoLon(normalizeAngle(gmst - ra));
|
|
924
|
+
}
|
|
925
|
+
function computeICLongitude(gmst, ra) {
|
|
926
|
+
return toGeoLon(normalizeAngle(gmst - ra + 180));
|
|
927
|
+
}
|
|
928
|
+
function computeHorizonLongitude(gmst, ra, dec, latitude, angle) {
|
|
929
|
+
const tanPhi = Math.tan(latitude * DEG);
|
|
930
|
+
const tanDelta = Math.tan(dec * DEG);
|
|
931
|
+
const cosH = -(tanPhi * tanDelta);
|
|
932
|
+
if (Math.abs(cosH) > 1) return null;
|
|
933
|
+
const H = Math.acos(cosH) / DEG;
|
|
934
|
+
const lon = angle === "AC" ? normalizeAngle(gmst - ra - H) : normalizeAngle(gmst - ra + H);
|
|
935
|
+
return toGeoLon(lon);
|
|
936
|
+
}
|
|
937
|
+
function geographicAngularDifference(a, b) {
|
|
938
|
+
const d = normalizeAngle(a - b);
|
|
939
|
+
return d > 180 ? 360 - d : d;
|
|
940
|
+
}
|
|
941
|
+
function toGeoLon(deg360) {
|
|
942
|
+
const n = normalizeAngle(deg360);
|
|
943
|
+
return n > 180 ? n - 360 : n;
|
|
944
|
+
}
|
|
945
|
+
function computeEquatorialPositions(date, planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS) {
|
|
946
|
+
const result = {};
|
|
947
|
+
for (const p of planets) {
|
|
948
|
+
const name = PLANET_AND_NODE_NAMES[p];
|
|
949
|
+
const eq = calculateEquatorialPosition(date, p);
|
|
950
|
+
result[name] = {
|
|
951
|
+
ra: eq.rightAscension,
|
|
952
|
+
dec: eq.declination,
|
|
953
|
+
planetId: p
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
return result;
|
|
957
|
+
}
|
|
958
|
+
function findParansAtLatitude(equatorialPositions, gmst, latitude, paranOrb = 1) {
|
|
959
|
+
const ANGLES = ["MC", "IC", "AC", "DC"];
|
|
960
|
+
const lines = [];
|
|
961
|
+
for (const [name, eq] of Object.entries(equatorialPositions)) {
|
|
962
|
+
for (const angle of ANGLES) {
|
|
963
|
+
let lon;
|
|
964
|
+
if (angle === "MC") lon = computeMCLongitude(gmst, eq.ra);
|
|
965
|
+
else if (angle === "IC") lon = computeICLongitude(gmst, eq.ra);
|
|
966
|
+
else lon = computeHorizonLongitude(gmst, eq.ra, eq.dec, latitude, angle);
|
|
967
|
+
if (lon !== null) {
|
|
968
|
+
lines.push({ planet: name, angle, longitude: lon });
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
const parans = [];
|
|
973
|
+
for (let i = 0; i < lines.length; i++) {
|
|
974
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
975
|
+
const a = lines[i];
|
|
976
|
+
const b = lines[j];
|
|
977
|
+
if (a.planet === b.planet) continue;
|
|
978
|
+
if (a.angle === b.angle) continue;
|
|
979
|
+
const dist = geographicAngularDifference(a.longitude, b.longitude);
|
|
980
|
+
if (dist <= paranOrb) {
|
|
981
|
+
parans.push({
|
|
982
|
+
latitude,
|
|
983
|
+
planetA: a.planet,
|
|
984
|
+
angleA: a.angle,
|
|
985
|
+
longitudeA: a.longitude,
|
|
986
|
+
planetB: b.planet,
|
|
987
|
+
angleB: b.angle,
|
|
988
|
+
longitudeB: b.longitude
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
return parans;
|
|
994
|
+
}
|
|
995
|
+
function queryAstrocartographyLocation(date, options) {
|
|
996
|
+
const {
|
|
997
|
+
latitude,
|
|
998
|
+
longitude,
|
|
999
|
+
orb = 2,
|
|
1000
|
+
planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS,
|
|
1001
|
+
paranOrb = 1
|
|
1002
|
+
} = options;
|
|
1003
|
+
const jd = getJulianDay(date);
|
|
1004
|
+
const gmst = computeGMST(jd);
|
|
1005
|
+
const positions = computeEquatorialPositions(date, planets);
|
|
1006
|
+
const lines = [];
|
|
1007
|
+
const ANGLES = ["MC", "IC", "AC", "DC"];
|
|
1008
|
+
for (const [name, eq] of Object.entries(positions)) {
|
|
1009
|
+
for (const angle of ANGLES) {
|
|
1010
|
+
let lineLon;
|
|
1011
|
+
if (angle === "MC") lineLon = computeMCLongitude(gmst, eq.ra);
|
|
1012
|
+
else if (angle === "IC") lineLon = computeICLongitude(gmst, eq.ra);
|
|
1013
|
+
else
|
|
1014
|
+
lineLon = computeHorizonLongitude(
|
|
1015
|
+
gmst,
|
|
1016
|
+
eq.ra,
|
|
1017
|
+
eq.dec,
|
|
1018
|
+
latitude,
|
|
1019
|
+
angle
|
|
1020
|
+
);
|
|
1021
|
+
if (lineLon === null) continue;
|
|
1022
|
+
const dist = geographicAngularDifference(longitude, lineLon);
|
|
1023
|
+
lines.push({
|
|
1024
|
+
planet: name,
|
|
1025
|
+
angle,
|
|
1026
|
+
distance: Math.round(dist * 1e3) / 1e3,
|
|
1027
|
+
active: dist <= orb,
|
|
1028
|
+
longitude: Math.round(lineLon * 1e3) / 1e3
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
lines.sort((a, b) => a.distance - b.distance);
|
|
1033
|
+
const activeLines = lines.filter((l) => l.active);
|
|
1034
|
+
const parans = findParansAtLatitude(positions, gmst, latitude, paranOrb);
|
|
1035
|
+
return { queryLatitude: latitude, queryLongitude: longitude, orb, lines, activeLines, parans };
|
|
1036
|
+
}
|
|
1037
|
+
function computeAstrocartographyMap(date, options = {}) {
|
|
1038
|
+
const {
|
|
1039
|
+
latitudeStep = 1,
|
|
1040
|
+
latitudeRange = 66.5,
|
|
1041
|
+
planets = ASTROCARTOGRAPHY_DEFAULT_PLANETS
|
|
1042
|
+
} = options;
|
|
1043
|
+
const jd = getJulianDay(date);
|
|
1044
|
+
const gmst = computeGMST(jd);
|
|
1045
|
+
const positions = computeEquatorialPositions(date, planets);
|
|
1046
|
+
const meridianLines = [];
|
|
1047
|
+
const horizonLines = [];
|
|
1048
|
+
for (const [name, eq] of Object.entries(positions)) {
|
|
1049
|
+
meridianLines.push({
|
|
1050
|
+
planet: name,
|
|
1051
|
+
angle: "MC",
|
|
1052
|
+
longitude: Math.round(computeMCLongitude(gmst, eq.ra) * 1e3) / 1e3
|
|
1053
|
+
});
|
|
1054
|
+
meridianLines.push({
|
|
1055
|
+
planet: name,
|
|
1056
|
+
angle: "IC",
|
|
1057
|
+
longitude: Math.round(computeICLongitude(gmst, eq.ra) * 1e3) / 1e3
|
|
1058
|
+
});
|
|
1059
|
+
for (const angle of ["AC", "DC"]) {
|
|
1060
|
+
const points = [];
|
|
1061
|
+
for (let lat = -latitudeRange; lat <= latitudeRange; lat += latitudeStep) {
|
|
1062
|
+
const lon = computeHorizonLongitude(gmst, eq.ra, eq.dec, lat, angle);
|
|
1063
|
+
if (lon !== null) {
|
|
1064
|
+
points.push({
|
|
1065
|
+
latitude: Math.round(lat * 1e3) / 1e3,
|
|
1066
|
+
longitude: Math.round(lon * 1e3) / 1e3
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
horizonLines.push({ planet: name, angle, points });
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return { meridianLines, horizonLines };
|
|
1074
|
+
}
|
|
1075
|
+
|
|
753
1076
|
// src/astrology/aspects.ts
|
|
754
1077
|
var DEFAULT_ASPECT_SPECS = [
|
|
755
1078
|
{ name: "conjunction", angle: 0, orb: 8 },
|
|
@@ -840,6 +1163,308 @@ function computeMidpoints(planetsA, planetsB) {
|
|
|
840
1163
|
}
|
|
841
1164
|
return result;
|
|
842
1165
|
}
|
|
1166
|
+
var SLOW_PLANETS = /* @__PURE__ */ new Set([
|
|
1167
|
+
"pluto",
|
|
1168
|
+
"neptune",
|
|
1169
|
+
"uranus",
|
|
1170
|
+
"saturn",
|
|
1171
|
+
"jupiter",
|
|
1172
|
+
"chiron",
|
|
1173
|
+
"mean node",
|
|
1174
|
+
"true node",
|
|
1175
|
+
"lilith true",
|
|
1176
|
+
"lilith mean"
|
|
1177
|
+
]);
|
|
1178
|
+
function computeTransitAspects(transitPlanets, natalPlanets, specs = DEFAULT_ASPECT_SPECS) {
|
|
1179
|
+
const keysT = Object.keys(transitPlanets);
|
|
1180
|
+
const keysN = Object.keys(natalPlanets);
|
|
1181
|
+
const edges = [];
|
|
1182
|
+
for (const kT of keysT) {
|
|
1183
|
+
const t = transitPlanets[kT];
|
|
1184
|
+
for (const kN of keysN) {
|
|
1185
|
+
const n = natalPlanets[kN];
|
|
1186
|
+
const match = getAspectMatch(t.longitude, n.longitude, specs);
|
|
1187
|
+
if (!match) continue;
|
|
1188
|
+
const tSpeed = t.longitudeSpeed ?? 0;
|
|
1189
|
+
const nSpeed = n.longitudeSpeed ?? 0;
|
|
1190
|
+
const dt = 0.01;
|
|
1191
|
+
const tLonFuture = t.longitude + tSpeed * dt;
|
|
1192
|
+
const nLonFuture = n.longitude + nSpeed * dt;
|
|
1193
|
+
const futureMatch = getAspectMatch(tLonFuture, nLonFuture, [match.spec]);
|
|
1194
|
+
const applying = futureMatch != null ? futureMatch.orb < match.orb : false;
|
|
1195
|
+
edges.push({
|
|
1196
|
+
planetA: kT,
|
|
1197
|
+
planetB: kN,
|
|
1198
|
+
longitudeA: t.longitude,
|
|
1199
|
+
longitudeB: n.longitude,
|
|
1200
|
+
aspect: match.spec.name,
|
|
1201
|
+
aspectAngle: match.spec.angle,
|
|
1202
|
+
delta: match.delta,
|
|
1203
|
+
orb: match.orb,
|
|
1204
|
+
applying,
|
|
1205
|
+
retrograde: tSpeed < 0,
|
|
1206
|
+
category: SLOW_PLANETS.has(kT) ? "slow" : "fast"
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
return edges;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// src/astrology/dignity.ts
|
|
1214
|
+
var DOMICILE_RULERS = {
|
|
1215
|
+
Aries: "Mars",
|
|
1216
|
+
Taurus: "Venus",
|
|
1217
|
+
Gemini: "Mercury",
|
|
1218
|
+
Cancer: "Moon",
|
|
1219
|
+
Leo: "Sun",
|
|
1220
|
+
Virgo: "Mercury",
|
|
1221
|
+
Libra: "Venus",
|
|
1222
|
+
Scorpio: "Mars",
|
|
1223
|
+
Sagittarius: "Jupiter",
|
|
1224
|
+
Capricorn: "Saturn",
|
|
1225
|
+
Aquarius: "Saturn",
|
|
1226
|
+
Pisces: "Jupiter"
|
|
1227
|
+
};
|
|
1228
|
+
var EXALTATIONS = {
|
|
1229
|
+
Sun: { sign: "Aries", degree: 19 },
|
|
1230
|
+
Moon: { sign: "Taurus", degree: 3 },
|
|
1231
|
+
Mercury: { sign: "Virgo", degree: 15 },
|
|
1232
|
+
Venus: { sign: "Pisces", degree: 27 },
|
|
1233
|
+
Mars: { sign: "Capricorn", degree: 28 },
|
|
1234
|
+
Jupiter: { sign: "Cancer", degree: 15 },
|
|
1235
|
+
Saturn: { sign: "Libra", degree: 21 }
|
|
1236
|
+
};
|
|
1237
|
+
function getDomicileRuler(sign) {
|
|
1238
|
+
return DOMICILE_RULERS[sign];
|
|
1239
|
+
}
|
|
1240
|
+
function getExaltation(planet) {
|
|
1241
|
+
return EXALTATIONS[planet];
|
|
1242
|
+
}
|
|
1243
|
+
function getOppositeSign(sign) {
|
|
1244
|
+
const idx = SIGNS.indexOf(sign);
|
|
1245
|
+
return SIGNS[(idx + 6) % 12];
|
|
1246
|
+
}
|
|
1247
|
+
function getDetriment(planet) {
|
|
1248
|
+
const signs = [];
|
|
1249
|
+
for (const [sign, ruler] of Object.entries(DOMICILE_RULERS)) {
|
|
1250
|
+
if (ruler === planet) {
|
|
1251
|
+
signs.push(getOppositeSign(sign));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return signs;
|
|
1255
|
+
}
|
|
1256
|
+
function getFall(planet) {
|
|
1257
|
+
return getOppositeSign(EXALTATIONS[planet].sign);
|
|
1258
|
+
}
|
|
1259
|
+
function getEssentialDignity(planet, sign) {
|
|
1260
|
+
const domicile = DOMICILE_RULERS[sign] === planet;
|
|
1261
|
+
const exaltation = EXALTATIONS[planet].sign === sign;
|
|
1262
|
+
const detrimentSigns = getDetriment(planet);
|
|
1263
|
+
const detriment = detrimentSigns.includes(sign);
|
|
1264
|
+
const fallSign = getFall(planet);
|
|
1265
|
+
const fall = fallSign === sign;
|
|
1266
|
+
const domicileRuler = DOMICILE_RULERS[sign];
|
|
1267
|
+
const peregrine = !domicile && !exaltation && !detriment && !fall;
|
|
1268
|
+
return { domicile, exaltation, detriment, fall, domicileRuler, peregrine };
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// src/astrology/decans.ts
|
|
1272
|
+
var CHALDEAN_RULERS = [
|
|
1273
|
+
"Mars",
|
|
1274
|
+
"Sun",
|
|
1275
|
+
"Venus",
|
|
1276
|
+
"Mercury",
|
|
1277
|
+
"Moon",
|
|
1278
|
+
"Saturn",
|
|
1279
|
+
"Jupiter"
|
|
1280
|
+
];
|
|
1281
|
+
var SIGN_SUITS = {
|
|
1282
|
+
Aries: "Wands",
|
|
1283
|
+
Taurus: "Pentacles",
|
|
1284
|
+
Gemini: "Swords",
|
|
1285
|
+
Cancer: "Cups",
|
|
1286
|
+
Leo: "Wands",
|
|
1287
|
+
Virgo: "Pentacles",
|
|
1288
|
+
Libra: "Swords",
|
|
1289
|
+
Scorpio: "Cups",
|
|
1290
|
+
Sagittarius: "Wands",
|
|
1291
|
+
Capricorn: "Pentacles",
|
|
1292
|
+
Aquarius: "Swords",
|
|
1293
|
+
Pisces: "Cups"
|
|
1294
|
+
};
|
|
1295
|
+
var RANK_NAMES = ["Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"];
|
|
1296
|
+
function getDecan(longitude) {
|
|
1297
|
+
const L = normalizeAngle(longitude);
|
|
1298
|
+
const signIndex = Math.floor(L / 30) % 12;
|
|
1299
|
+
const degreeWithinSign = L - signIndex * 30;
|
|
1300
|
+
const decanIndex = Math.min(Math.floor(degreeWithinSign / 10), 2);
|
|
1301
|
+
const globalDecanIndex = signIndex * 3 + decanIndex;
|
|
1302
|
+
const sign = SIGNS[signIndex];
|
|
1303
|
+
const ruler = CHALDEAN_RULERS[globalDecanIndex % 7];
|
|
1304
|
+
const suit = SIGN_SUITS[sign];
|
|
1305
|
+
const rank = RANK_NAMES[globalDecanIndex % 9];
|
|
1306
|
+
const tarotCard = `${rank} of ${suit}`;
|
|
1307
|
+
return {
|
|
1308
|
+
sign,
|
|
1309
|
+
decanNumber: decanIndex + 1,
|
|
1310
|
+
ruler,
|
|
1311
|
+
tarotCard,
|
|
1312
|
+
startDegree: signIndex * 30 + decanIndex * 10,
|
|
1313
|
+
endDegree: signIndex * 30 + (decanIndex + 1) * 10,
|
|
1314
|
+
degreeWithinSign
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// src/astrology/dodecatemoria.ts
|
|
1319
|
+
function getDodecatemoria(longitude) {
|
|
1320
|
+
const L = normalizeAngle(longitude);
|
|
1321
|
+
const signIndex = Math.floor(L / 30) % 12;
|
|
1322
|
+
const degreeWithinSign = L - signIndex * 30;
|
|
1323
|
+
const index = Math.min(Math.floor(degreeWithinSign / 2.5), 11);
|
|
1324
|
+
const dodecatemoriaSignIndex = (signIndex + index) % 12;
|
|
1325
|
+
return {
|
|
1326
|
+
originalSign: SIGNS[signIndex],
|
|
1327
|
+
originalDegree: degreeWithinSign,
|
|
1328
|
+
dodecatemoriaSign: SIGNS[dodecatemoriaSignIndex],
|
|
1329
|
+
dodecatemoriaIndex: index
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// src/astrology/profections.ts
|
|
1334
|
+
function getAnnualProfection(natalChart, birthDate, targetYear) {
|
|
1335
|
+
const year = targetYear ?? (/* @__PURE__ */ new Date()).getFullYear();
|
|
1336
|
+
const birthYear = birthDate.getFullYear();
|
|
1337
|
+
const age = year - birthYear;
|
|
1338
|
+
if (age < 0) {
|
|
1339
|
+
throw new Error(`Target year (${year}) is before birth year (${birthYear}).`);
|
|
1340
|
+
}
|
|
1341
|
+
const house = age % 12 + 1;
|
|
1342
|
+
const sign = natalChart.houses.houses[house - 1].sign;
|
|
1343
|
+
const ruler = getDomicileRuler(sign);
|
|
1344
|
+
return { age, house, sign, ruler, targetYear: year };
|
|
1345
|
+
}
|
|
1346
|
+
function getMonthlyProfections(natalChart, birthDate, targetYear) {
|
|
1347
|
+
const annualProfection = getAnnualProfection(natalChart, birthDate, targetYear);
|
|
1348
|
+
const annualSignIndex = SIGNS.indexOf(annualProfection.sign);
|
|
1349
|
+
const bdMonth = birthDate.getMonth();
|
|
1350
|
+
const bdDay = birthDate.getDate();
|
|
1351
|
+
const year = annualProfection.targetYear;
|
|
1352
|
+
const months = [];
|
|
1353
|
+
for (let i = 0; i < 12; i++) {
|
|
1354
|
+
const monthDate = new Date(year, bdMonth + i, bdDay);
|
|
1355
|
+
if (monthDate.getDate() !== bdDay) {
|
|
1356
|
+
monthDate.setDate(0);
|
|
1357
|
+
}
|
|
1358
|
+
const signIndex = (annualSignIndex + i) % 12;
|
|
1359
|
+
const sign = SIGNS[signIndex];
|
|
1360
|
+
months.push({
|
|
1361
|
+
month: i + 1,
|
|
1362
|
+
startDate: monthDate,
|
|
1363
|
+
sign,
|
|
1364
|
+
ruler: getDomicileRuler(sign)
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
return { annualProfection, months };
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// src/astrology/firdaria.ts
|
|
1371
|
+
var DAY_SEQUENCE = [
|
|
1372
|
+
{ planet: "Sun", years: 10 },
|
|
1373
|
+
{ planet: "Venus", years: 8 },
|
|
1374
|
+
{ planet: "Mercury", years: 13 },
|
|
1375
|
+
{ planet: "Moon", years: 9 },
|
|
1376
|
+
{ planet: "Saturn", years: 11 },
|
|
1377
|
+
{ planet: "Jupiter", years: 12 },
|
|
1378
|
+
{ planet: "Mars", years: 7 },
|
|
1379
|
+
{ planet: "NorthNode", years: 3 },
|
|
1380
|
+
{ planet: "SouthNode", years: 2 }
|
|
1381
|
+
];
|
|
1382
|
+
var NIGHT_SEQUENCE = [
|
|
1383
|
+
{ planet: "Moon", years: 9 },
|
|
1384
|
+
{ planet: "Saturn", years: 11 },
|
|
1385
|
+
{ planet: "Jupiter", years: 12 },
|
|
1386
|
+
{ planet: "Mars", years: 7 },
|
|
1387
|
+
{ planet: "NorthNode", years: 3 },
|
|
1388
|
+
{ planet: "SouthNode", years: 2 },
|
|
1389
|
+
{ planet: "Sun", years: 10 },
|
|
1390
|
+
{ planet: "Venus", years: 8 },
|
|
1391
|
+
{ planet: "Mercury", years: 13 }
|
|
1392
|
+
];
|
|
1393
|
+
var CHALDEAN_ORDER = [
|
|
1394
|
+
"Saturn",
|
|
1395
|
+
"Jupiter",
|
|
1396
|
+
"Mars",
|
|
1397
|
+
"Sun",
|
|
1398
|
+
"Venus",
|
|
1399
|
+
"Mercury",
|
|
1400
|
+
"Moon"
|
|
1401
|
+
];
|
|
1402
|
+
function addYears(date, years) {
|
|
1403
|
+
const ms = years * 365.25 * 24 * 60 * 60 * 1e3;
|
|
1404
|
+
return new Date(date.getTime() + ms);
|
|
1405
|
+
}
|
|
1406
|
+
function getSubPeriodStart(planet, options) {
|
|
1407
|
+
const mode = options?.nodeSubPeriodStart ?? "jupiter-saturn";
|
|
1408
|
+
if (planet === "NorthNode") {
|
|
1409
|
+
if (mode === "sun-mars") {
|
|
1410
|
+
return CHALDEAN_ORDER.indexOf("Sun");
|
|
1411
|
+
}
|
|
1412
|
+
return CHALDEAN_ORDER.indexOf("Jupiter");
|
|
1413
|
+
}
|
|
1414
|
+
if (planet === "SouthNode") {
|
|
1415
|
+
if (mode === "sun-mars") {
|
|
1416
|
+
return CHALDEAN_ORDER.indexOf("Mars");
|
|
1417
|
+
}
|
|
1418
|
+
return CHALDEAN_ORDER.indexOf("Saturn");
|
|
1419
|
+
}
|
|
1420
|
+
return CHALDEAN_ORDER.indexOf(planet);
|
|
1421
|
+
}
|
|
1422
|
+
function buildSubPeriods(major, majorStart, majorEnd, options) {
|
|
1423
|
+
const startIdx = getSubPeriodStart(major.planet, options);
|
|
1424
|
+
const totalMs = majorEnd.getTime() - majorStart.getTime();
|
|
1425
|
+
const subMs = totalMs / 7;
|
|
1426
|
+
const subs = [];
|
|
1427
|
+
for (let i = 0; i < 7; i++) {
|
|
1428
|
+
const subPlanet = CHALDEAN_ORDER[(startIdx + i) % 7];
|
|
1429
|
+
const subStart = new Date(majorStart.getTime() + i * subMs);
|
|
1430
|
+
const subEnd = new Date(majorStart.getTime() + (i + 1) * subMs);
|
|
1431
|
+
subs.push({ planet: subPlanet, startDate: subStart, endDate: subEnd });
|
|
1432
|
+
}
|
|
1433
|
+
return subs;
|
|
1434
|
+
}
|
|
1435
|
+
function getFirdaria(birthDate, isDiurnal, targetDate, options) {
|
|
1436
|
+
const target = targetDate ?? /* @__PURE__ */ new Date();
|
|
1437
|
+
const sequence = isDiurnal ? DAY_SEQUENCE : NIGHT_SEQUENCE;
|
|
1438
|
+
const sect = isDiurnal ? "diurnal" : "nocturnal";
|
|
1439
|
+
const allPeriods = [];
|
|
1440
|
+
let cursor = new Date(birthDate.getTime());
|
|
1441
|
+
let foundCurrent = false;
|
|
1442
|
+
for (let cycle = 0; cycle < 3 && !foundCurrent; cycle++) {
|
|
1443
|
+
for (const entry of sequence) {
|
|
1444
|
+
const start = new Date(cursor.getTime());
|
|
1445
|
+
const end = addYears(start, entry.years);
|
|
1446
|
+
const subPeriods = buildSubPeriods(entry, start, end, options);
|
|
1447
|
+
allPeriods.push({
|
|
1448
|
+
planet: entry.planet,
|
|
1449
|
+
years: entry.years,
|
|
1450
|
+
startDate: start,
|
|
1451
|
+
endDate: end,
|
|
1452
|
+
subPeriods
|
|
1453
|
+
});
|
|
1454
|
+
cursor = end;
|
|
1455
|
+
if (target.getTime() >= start.getTime() && target.getTime() < end.getTime()) {
|
|
1456
|
+
foundCurrent = true;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
const currentMajor = allPeriods.find(
|
|
1461
|
+
(p) => target.getTime() >= p.startDate.getTime() && target.getTime() < p.endDate.getTime()
|
|
1462
|
+
) ?? allPeriods[0];
|
|
1463
|
+
const currentSub = currentMajor.subPeriods.find(
|
|
1464
|
+
(s) => target.getTime() >= s.startDate.getTime() && target.getTime() < s.endDate.getTime()
|
|
1465
|
+
) ?? currentMajor.subPeriods[0];
|
|
1466
|
+
return { sect, currentMajor, currentSub, allPeriods };
|
|
1467
|
+
}
|
|
843
1468
|
|
|
844
1469
|
// src/astrology/index.ts
|
|
845
1470
|
function validateInputs(options) {
|
|
@@ -938,7 +1563,8 @@ async function getBirthChart(options) {
|
|
|
938
1563
|
planets,
|
|
939
1564
|
houses,
|
|
940
1565
|
nodes,
|
|
941
|
-
aspects
|
|
1566
|
+
aspects,
|
|
1567
|
+
sect: isDiurnal ? "diurnal" : "nocturnal"
|
|
942
1568
|
};
|
|
943
1569
|
} catch (error) {
|
|
944
1570
|
console.error("Error calculating birth chart:", error);
|
|
@@ -1044,27 +1670,372 @@ async function getCompositeChart(options) {
|
|
|
1044
1670
|
aspects
|
|
1045
1671
|
};
|
|
1046
1672
|
}
|
|
1673
|
+
function getTransitAspectPoints(planets) {
|
|
1674
|
+
const points = {};
|
|
1675
|
+
for (const [key, p] of Object.entries(planets)) {
|
|
1676
|
+
points[key] = { longitude: p.longitude, longitudeSpeed: p.longitudeSpeed };
|
|
1677
|
+
}
|
|
1678
|
+
return points;
|
|
1679
|
+
}
|
|
1680
|
+
function getNatalAspectPoints(planets, ascLon, mcLon) {
|
|
1681
|
+
const points = {};
|
|
1682
|
+
for (const [key, p] of Object.entries(planets)) {
|
|
1683
|
+
points[key] = { longitude: p.longitude, longitudeSpeed: 0 };
|
|
1684
|
+
}
|
|
1685
|
+
points.ascendant = { longitude: ascLon, longitudeSpeed: 0 };
|
|
1686
|
+
points.mc = { longitude: mcLon, longitudeSpeed: 0 };
|
|
1687
|
+
return points;
|
|
1688
|
+
}
|
|
1689
|
+
function filterByNames(points, names) {
|
|
1690
|
+
if (!names || names.length === 0) return points;
|
|
1691
|
+
const allowed = new Set(names.map((n) => n.toLowerCase()));
|
|
1692
|
+
const result = {};
|
|
1693
|
+
for (const [key, val] of Object.entries(points)) {
|
|
1694
|
+
if (allowed.has(key)) result[key] = val;
|
|
1695
|
+
}
|
|
1696
|
+
return result;
|
|
1697
|
+
}
|
|
1698
|
+
async function getTransitChart(options) {
|
|
1699
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1700
|
+
const transitChart = await getBirthChart({
|
|
1701
|
+
date: options.transitDate,
|
|
1702
|
+
latitude: options.transitLatitude ?? options.natal.latitude,
|
|
1703
|
+
longitude: options.transitLongitude ?? options.natal.longitude,
|
|
1704
|
+
houseSystem: options.natal.houseSystem,
|
|
1705
|
+
timeZoneSettings: options.transitTimeZoneSettings ?? { autoTimeZone: true }
|
|
1706
|
+
});
|
|
1707
|
+
const natalCusps = natalChart.houses.houses.map((h) => h.longitude);
|
|
1708
|
+
const transitPlanets = {};
|
|
1709
|
+
for (const [key, planet] of Object.entries(transitChart.planets)) {
|
|
1710
|
+
const natalZodiac = getZodiacPosition(planet.longitude, natalCusps);
|
|
1711
|
+
transitPlanets[key] = {
|
|
1712
|
+
...planet,
|
|
1713
|
+
retrograde: (planet.longitudeSpeed ?? 0) < 0,
|
|
1714
|
+
natalHouse: natalZodiac.house,
|
|
1715
|
+
zodiacPosition: {
|
|
1716
|
+
...planet.zodiacPosition,
|
|
1717
|
+
house: natalZodiac.house
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
let tPoints = getTransitAspectPoints(transitChart.planets);
|
|
1722
|
+
let nPoints = getNatalAspectPoints(
|
|
1723
|
+
natalChart.planets,
|
|
1724
|
+
natalChart.houses.ascendant.longitude,
|
|
1725
|
+
natalChart.houses.mc.longitude
|
|
1726
|
+
);
|
|
1727
|
+
tPoints = filterByNames(tPoints, options.transitPlanets);
|
|
1728
|
+
nPoints = filterByNames(nPoints, options.natalPlanets);
|
|
1729
|
+
let aspects = computeTransitAspects(tPoints, nPoints, options.aspectSpecs);
|
|
1730
|
+
if (options.maxOrb != null) {
|
|
1731
|
+
aspects = aspects.filter((a) => a.orb <= options.maxOrb);
|
|
1732
|
+
}
|
|
1733
|
+
if (options.aspectFilter && options.aspectFilter.length > 0) {
|
|
1734
|
+
const allowed = new Set(options.aspectFilter);
|
|
1735
|
+
aspects = aspects.filter((a) => allowed.has(a.aspect));
|
|
1736
|
+
}
|
|
1737
|
+
return {
|
|
1738
|
+
natalChart,
|
|
1739
|
+
transitDateUtc: transitChart.dateUtc,
|
|
1740
|
+
transitPlanets,
|
|
1741
|
+
aspects
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
async function getTransitRange(options) {
|
|
1745
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1746
|
+
natalChart.houses.houses.map((h) => h.longitude);
|
|
1747
|
+
const nPoints = filterByNames(
|
|
1748
|
+
getNatalAspectPoints(
|
|
1749
|
+
natalChart.planets,
|
|
1750
|
+
natalChart.houses.ascendant.longitude,
|
|
1751
|
+
natalChart.houses.mc.longitude
|
|
1752
|
+
),
|
|
1753
|
+
options.natalPlanets
|
|
1754
|
+
);
|
|
1755
|
+
const natalKeys = Object.keys(nPoints);
|
|
1756
|
+
const rawStep = options.stepDays ?? 1;
|
|
1757
|
+
if (rawStep <= 0) throw new Error("stepDays must be greater than 0");
|
|
1758
|
+
const fromMs = options.from.getTime();
|
|
1759
|
+
const toMs = options.to.getTime();
|
|
1760
|
+
const specs = options.aspectSpecs;
|
|
1761
|
+
const steps = [];
|
|
1762
|
+
const transitLat = options.transitLatitude ?? options.natal.latitude;
|
|
1763
|
+
const transitLon = options.transitLongitude ?? options.natal.longitude;
|
|
1764
|
+
const transitTz = options.transitTimeZoneSettings ?? { autoTimeZone: true };
|
|
1765
|
+
const FAST_PLANET_MAX_STEP = 0.25;
|
|
1766
|
+
let effectiveStepDays = rawStep;
|
|
1767
|
+
const requestedTransitPlanets = options.transitPlanets?.map((n) => n.toLowerCase());
|
|
1768
|
+
const hasFastPlanets = requestedTransitPlanets ? requestedTransitPlanets.some((n) => !SLOW_PLANETS.has(n)) : true;
|
|
1769
|
+
if (hasFastPlanets && effectiveStepDays > FAST_PLANET_MAX_STEP) {
|
|
1770
|
+
effectiveStepDays = FAST_PLANET_MAX_STEP;
|
|
1771
|
+
}
|
|
1772
|
+
const stepMs = effectiveStepDays * 864e5;
|
|
1773
|
+
const scanEndMs = toMs + stepMs;
|
|
1774
|
+
for (let ms = fromMs; ms <= scanEndMs; ms += stepMs) {
|
|
1775
|
+
const date = new Date(ms);
|
|
1776
|
+
const utcDate = await toUtcDate(date, transitLat, transitLon, transitTz ?? { autoTimeZone: true });
|
|
1777
|
+
const positions = await calculatePlanetaryPositions(utcDate);
|
|
1778
|
+
if (!positions) continue;
|
|
1779
|
+
const points = {};
|
|
1780
|
+
for (const [planetId, pos] of Object.entries(positions)) {
|
|
1781
|
+
const id = planetId;
|
|
1782
|
+
const name = PLANET_AND_NODE_NAMES[id].toLowerCase();
|
|
1783
|
+
points[name] = { longitude: pos.longitude, longitudeSpeed: pos.longitudeSpeed };
|
|
1784
|
+
}
|
|
1785
|
+
steps.push({ time: ms, positions: filterByNames(points, options.transitPlanets) });
|
|
1786
|
+
}
|
|
1787
|
+
const perfections = [];
|
|
1788
|
+
const transitKeys = steps.length > 0 ? Object.keys(steps[0].positions) : [];
|
|
1789
|
+
for (const tKey of transitKeys) {
|
|
1790
|
+
for (const nKey of natalKeys) {
|
|
1791
|
+
let prevOrb = null;
|
|
1792
|
+
let prevDecreasing = false;
|
|
1793
|
+
let prevStep = null;
|
|
1794
|
+
for (const step of steps) {
|
|
1795
|
+
const tPos = step.positions[tKey];
|
|
1796
|
+
const nPos = nPoints[nKey];
|
|
1797
|
+
if (!tPos || !nPos) continue;
|
|
1798
|
+
const match = specs ? findClosestAspectOrb(tPos.longitude, nPos.longitude, specs) : findClosestAspectOrb(tPos.longitude, nPos.longitude);
|
|
1799
|
+
if (!match) {
|
|
1800
|
+
prevOrb = null;
|
|
1801
|
+
prevStep = step;
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
const currentOrb = match.orb;
|
|
1805
|
+
if (prevOrb != null && prevStep) {
|
|
1806
|
+
const wasDecreasing = prevOrb > currentOrb;
|
|
1807
|
+
if (prevDecreasing && !wasDecreasing && currentOrb <= match.spec.orb) {
|
|
1808
|
+
const exactResult = await binarySearchPerfection(
|
|
1809
|
+
tKey,
|
|
1810
|
+
nKey,
|
|
1811
|
+
match.spec,
|
|
1812
|
+
prevStep.time,
|
|
1813
|
+
step.time,
|
|
1814
|
+
nPos,
|
|
1815
|
+
transitLat,
|
|
1816
|
+
transitLon,
|
|
1817
|
+
transitTz
|
|
1818
|
+
);
|
|
1819
|
+
if (exactResult) perfections.push(exactResult);
|
|
1820
|
+
}
|
|
1821
|
+
prevDecreasing = wasDecreasing;
|
|
1822
|
+
} else {
|
|
1823
|
+
prevDecreasing = false;
|
|
1824
|
+
}
|
|
1825
|
+
prevOrb = currentOrb;
|
|
1826
|
+
prevStep = step;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
let filtered = perfections.filter((p) => {
|
|
1831
|
+
const t = p.exactDate.getTime();
|
|
1832
|
+
return t >= fromMs && t <= toMs;
|
|
1833
|
+
});
|
|
1834
|
+
if (options.maxOrb != null) {
|
|
1835
|
+
filtered = filtered.filter((p) => p.exactOrb <= options.maxOrb);
|
|
1836
|
+
}
|
|
1837
|
+
if (options.aspectFilter && options.aspectFilter.length > 0) {
|
|
1838
|
+
const allowed = new Set(options.aspectFilter);
|
|
1839
|
+
filtered = filtered.filter((p) => allowed.has(p.aspect));
|
|
1840
|
+
}
|
|
1841
|
+
filtered.sort((a, b) => a.exactDate.getTime() - b.exactDate.getTime());
|
|
1842
|
+
return {
|
|
1843
|
+
natalChart,
|
|
1844
|
+
from: options.from,
|
|
1845
|
+
to: options.to,
|
|
1846
|
+
perfections: filtered
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
function findClosestAspectOrb(lonA, lonB, specs = DEFAULT_ASPECT_SPECS) {
|
|
1850
|
+
const a = normalizeAngle(lonA);
|
|
1851
|
+
const b = normalizeAngle(lonB);
|
|
1852
|
+
const delta = Math.min(normalizeAngle(b - a), normalizeAngle(a - b));
|
|
1853
|
+
let best = null;
|
|
1854
|
+
for (const spec of specs) {
|
|
1855
|
+
const orb = Math.abs(delta - spec.angle);
|
|
1856
|
+
if (orb <= spec.orb + 2) {
|
|
1857
|
+
if (!best || orb < best.orb) {
|
|
1858
|
+
best = { spec, orb, delta };
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
return best;
|
|
1863
|
+
}
|
|
1864
|
+
function computeOrbForAspect(transitLon, natalLon, aspectAngle) {
|
|
1865
|
+
const delta = Math.min(
|
|
1866
|
+
normalizeAngle(transitLon - natalLon),
|
|
1867
|
+
normalizeAngle(natalLon - transitLon)
|
|
1868
|
+
);
|
|
1869
|
+
return Math.abs(delta - aspectAngle);
|
|
1870
|
+
}
|
|
1871
|
+
var NAME_TO_PLANET = {};
|
|
1872
|
+
for (const [id, name] of Object.entries(PLANET_AND_NODE_NAMES)) {
|
|
1873
|
+
const numId = Number(id);
|
|
1874
|
+
if (!isNaN(numId)) NAME_TO_PLANET[name.toLowerCase()] = numId;
|
|
1875
|
+
}
|
|
1876
|
+
async function getTransitLongitudeAt(ms, transitKey, transitLat, transitLon, transitTz) {
|
|
1877
|
+
const date = new Date(ms);
|
|
1878
|
+
const utc = await toUtcDate(date, transitLat, transitLon, transitTz);
|
|
1879
|
+
const planetId = NAME_TO_PLANET[transitKey];
|
|
1880
|
+
if (planetId != null) {
|
|
1881
|
+
try {
|
|
1882
|
+
return calculateSinglePlanetPosition(utc, planetId);
|
|
1883
|
+
} catch {
|
|
1884
|
+
return null;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
const positions = await calculatePlanetaryPositions(utc);
|
|
1888
|
+
if (!positions) return null;
|
|
1889
|
+
return findPlanetByName(positions, transitKey) ?? null;
|
|
1890
|
+
}
|
|
1891
|
+
async function binarySearchPerfection(transitKey, natalKey, spec, startMs, endMs, natalPoint, transitLat, transitLon, transitTz) {
|
|
1892
|
+
const tz = transitTz ?? { autoTimeZone: true };
|
|
1893
|
+
const maxIterations = 30;
|
|
1894
|
+
let lo = startMs;
|
|
1895
|
+
let hi = endMs;
|
|
1896
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
1897
|
+
if (hi - lo < 6e4) break;
|
|
1898
|
+
const m1 = lo + Math.floor((hi - lo) / 3);
|
|
1899
|
+
const m2 = hi - Math.floor((hi - lo) / 3);
|
|
1900
|
+
const pos1 = await getTransitLongitudeAt(m1, transitKey, transitLat, transitLon, tz);
|
|
1901
|
+
const pos2 = await getTransitLongitudeAt(m2, transitKey, transitLat, transitLon, tz);
|
|
1902
|
+
if (!pos1 || !pos2) break;
|
|
1903
|
+
const orb1 = computeOrbForAspect(pos1.longitude, natalPoint.longitude, spec.angle);
|
|
1904
|
+
const orb2 = computeOrbForAspect(pos2.longitude, natalPoint.longitude, spec.angle);
|
|
1905
|
+
if (orb1 < orb2) {
|
|
1906
|
+
hi = m2;
|
|
1907
|
+
} else {
|
|
1908
|
+
lo = m1;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
const finalMs = Math.floor((lo + hi) / 2);
|
|
1912
|
+
const finalPos = await getTransitLongitudeAt(finalMs, transitKey, transitLat, transitLon, tz);
|
|
1913
|
+
if (!finalPos) return null;
|
|
1914
|
+
const finalOrb = computeOrbForAspect(finalPos.longitude, natalPoint.longitude, spec.angle);
|
|
1915
|
+
if (finalOrb > spec.orb) return null;
|
|
1916
|
+
return {
|
|
1917
|
+
transitPlanet: transitKey,
|
|
1918
|
+
natalPlanet: natalKey,
|
|
1919
|
+
aspect: spec.name,
|
|
1920
|
+
exactDate: new Date(finalMs),
|
|
1921
|
+
exactOrb: finalOrb,
|
|
1922
|
+
retrograde: (finalPos.longitudeSpeed ?? 0) < 0,
|
|
1923
|
+
category: SLOW_PLANETS.has(transitKey) ? "slow" : "fast"
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function findPlanetByName(positions, name) {
|
|
1927
|
+
for (const [planetId, pos] of Object.entries(positions)) {
|
|
1928
|
+
const id = planetId;
|
|
1929
|
+
if (PLANET_AND_NODE_NAMES[id].toLowerCase() === name) return pos;
|
|
1930
|
+
}
|
|
1931
|
+
return void 0;
|
|
1932
|
+
}
|
|
1933
|
+
async function getSunLongitudeAtMs(ms) {
|
|
1934
|
+
const positions = await calculatePlanetaryPositions(new Date(ms));
|
|
1935
|
+
const sun = findPlanetByName(positions, "sun");
|
|
1936
|
+
if (!sun) throw new Error("Failed to compute Sun position");
|
|
1937
|
+
return sun.longitude;
|
|
1938
|
+
}
|
|
1939
|
+
function signedAngularDelta(current, target) {
|
|
1940
|
+
let d = normalizeAngle(current - target);
|
|
1941
|
+
if (d > 180) d -= 360;
|
|
1942
|
+
return d;
|
|
1943
|
+
}
|
|
1944
|
+
async function getSolarReturnChart(options) {
|
|
1945
|
+
const natalChart = await getBirthChart(options.natal);
|
|
1946
|
+
const natalSunLongitude = natalChart.planets.sun.longitude;
|
|
1947
|
+
const natalDate = options.natal.date;
|
|
1948
|
+
const approxReturn = new Date(Date.UTC(
|
|
1949
|
+
options.year,
|
|
1950
|
+
natalDate.getMonth(),
|
|
1951
|
+
natalDate.getDate(),
|
|
1952
|
+
12,
|
|
1953
|
+
0,
|
|
1954
|
+
0
|
|
1955
|
+
));
|
|
1956
|
+
let lo = approxReturn.getTime() - 2 * 864e5;
|
|
1957
|
+
let hi = approxReturn.getTime() + 2 * 864e5;
|
|
1958
|
+
for (let i = 0; i < 30; i++) {
|
|
1959
|
+
if (hi - lo < 6e4) break;
|
|
1960
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
1961
|
+
const sunLon = await getSunLongitudeAtMs(mid);
|
|
1962
|
+
const delta = signedAngularDelta(sunLon, natalSunLongitude);
|
|
1963
|
+
if (delta < 0) {
|
|
1964
|
+
lo = mid;
|
|
1965
|
+
} else {
|
|
1966
|
+
hi = mid;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
const exactMs = Math.floor((lo + hi) / 2);
|
|
1970
|
+
const exactReturnDate = new Date(exactMs);
|
|
1971
|
+
const solarReturnChart = await getBirthChart({
|
|
1972
|
+
date: exactReturnDate,
|
|
1973
|
+
latitude: options.solarReturnLatitude ?? options.natal.latitude,
|
|
1974
|
+
longitude: options.solarReturnLongitude ?? options.natal.longitude,
|
|
1975
|
+
houseSystem: options.solarReturnHouseSystem ?? options.natal.houseSystem,
|
|
1976
|
+
// Always treatAsUTC: the binary search converged on a UTC millisecond timestamp.
|
|
1977
|
+
// Passing a caller timezone here would re-interpret the already-UTC instant as local,
|
|
1978
|
+
// shifting planetary positions by hours.
|
|
1979
|
+
timeZoneSettings: { treatAsUTC: true }
|
|
1980
|
+
});
|
|
1981
|
+
return {
|
|
1982
|
+
natalChart,
|
|
1983
|
+
solarReturnChart,
|
|
1984
|
+
exactReturnDate,
|
|
1985
|
+
natalSunLongitude,
|
|
1986
|
+
year: options.year
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1047
1989
|
|
|
1990
|
+
exports.ASTROCARTOGRAPHY_DEFAULT_PLANETS = ASTROCARTOGRAPHY_DEFAULT_PLANETS;
|
|
1048
1991
|
exports.CalcFlag = CalcFlag;
|
|
1049
1992
|
exports.DEFAULT_ASPECT_SPECS = DEFAULT_ASPECT_SPECS;
|
|
1993
|
+
exports.DOMICILE_RULERS = DOMICILE_RULERS;
|
|
1994
|
+
exports.EXALTATIONS = EXALTATIONS;
|
|
1050
1995
|
exports.HouseSystem = HouseSystem;
|
|
1051
1996
|
exports.PLANET_AND_NODE_NAMES = PLANET_AND_NODE_NAMES;
|
|
1052
1997
|
exports.Planet = Planet;
|
|
1998
|
+
exports.RiseTransitFlag = RiseTransitFlag;
|
|
1053
1999
|
exports.SIGNS = SIGNS;
|
|
2000
|
+
exports.SLOW_PLANETS = SLOW_PLANETS;
|
|
1054
2001
|
exports.VirtualNodes = VirtualNodes;
|
|
1055
2002
|
exports.closeSwissEph = closeSwissEph;
|
|
1056
2003
|
exports.computeAspects = computeAspects;
|
|
2004
|
+
exports.computeAstrocartographyMap = computeAstrocartographyMap;
|
|
2005
|
+
exports.computeEquatorialPositions = computeEquatorialPositions;
|
|
2006
|
+
exports.computeGMST = computeGMST;
|
|
2007
|
+
exports.computeHorizonLongitude = computeHorizonLongitude;
|
|
2008
|
+
exports.computeICLongitude = computeICLongitude;
|
|
2009
|
+
exports.computeMCLongitude = computeMCLongitude;
|
|
1057
2010
|
exports.computeMidpoints = computeMidpoints;
|
|
1058
2011
|
exports.computeSynastryAspects = computeSynastryAspects;
|
|
2012
|
+
exports.computeTransitAspects = computeTransitAspects;
|
|
1059
2013
|
exports.findHouseOf = findHouseOf;
|
|
2014
|
+
exports.findParansAtLatitude = findParansAtLatitude;
|
|
1060
2015
|
exports.formatDegreeMinutes = formatDegreeMinutes;
|
|
2016
|
+
exports.geographicAngularDifference = geographicAngularDifference;
|
|
2017
|
+
exports.getAnnualProfection = getAnnualProfection;
|
|
1061
2018
|
exports.getAspectMatch = getAspectMatch;
|
|
1062
2019
|
exports.getBirthChart = getBirthChart;
|
|
1063
2020
|
exports.getCompositeChart = getCompositeChart;
|
|
2021
|
+
exports.getDecan = getDecan;
|
|
2022
|
+
exports.getDetriment = getDetriment;
|
|
2023
|
+
exports.getDodecatemoria = getDodecatemoria;
|
|
2024
|
+
exports.getDomicileRuler = getDomicileRuler;
|
|
2025
|
+
exports.getEssentialDignity = getEssentialDignity;
|
|
2026
|
+
exports.getExaltation = getExaltation;
|
|
2027
|
+
exports.getFall = getFall;
|
|
2028
|
+
exports.getFirdaria = getFirdaria;
|
|
2029
|
+
exports.getMonthlyProfections = getMonthlyProfections;
|
|
2030
|
+
exports.getOppositeSign = getOppositeSign;
|
|
2031
|
+
exports.getSolarReturnChart = getSolarReturnChart;
|
|
1064
2032
|
exports.getSwissEph = getSwissEph;
|
|
1065
2033
|
exports.getSynastryChart = getSynastryChart;
|
|
2034
|
+
exports.getTransitChart = getTransitChart;
|
|
2035
|
+
exports.getTransitRange = getTransitRange;
|
|
1066
2036
|
exports.getZodiacPosition = getZodiacPosition;
|
|
1067
2037
|
exports.normalizeAngle = normalizeAngle;
|
|
2038
|
+
exports.queryAstrocartographyLocation = queryAstrocartographyLocation;
|
|
1068
2039
|
exports.shorterArcMidpoint = shorterArcMidpoint;
|
|
1069
|
-
//# sourceMappingURL=chunk-
|
|
1070
|
-
//# sourceMappingURL=chunk-
|
|
2040
|
+
//# sourceMappingURL=chunk-HGEWHDIX.js.map
|
|
2041
|
+
//# sourceMappingURL=chunk-HGEWHDIX.js.map
|