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