kaabalah 5.3.0 → 5.4.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/cli.js CHANGED
@@ -33,6 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
34
  mod
35
35
  ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
37
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
38
 
38
39
  // wasm/build/swisseph.node.wasm?url
@@ -7135,6 +7136,11 @@ async function getSwissEph(options = {}) {
7135
7136
  throw error;
7136
7137
  }
7137
7138
  }
7139
+ function calculateSinglePlanetPosition(date, planet) {
7140
+ checkInitialization();
7141
+ const julday = swissEph.getJulianDay(date);
7142
+ return swissEph.calculatePlanetPosition(julday, planet, DEFAULT_FLAGS);
7143
+ }
7138
7144
  async function calculatePlanetaryPositions(date) {
7139
7145
  try {
7140
7146
  checkInitialization();
@@ -7254,6 +7260,9 @@ function getTimeZoneOffsetMs(instant, timeZone) {
7254
7260
  return asUTC - instant.getTime();
7255
7261
  }
7256
7262
  async function localToUtcDate(local, latitude, longitude, opts = {}) {
7263
+ if (opts.treatAsUTC === true) {
7264
+ return local instanceof Date ? local : createUtcDateFromParts(buildLocalParts(local));
7265
+ }
7257
7266
  const parts = buildLocalParts(local);
7258
7267
  const auto = opts.autoTimeZone !== false;
7259
7268
  if (typeof opts.utcOffsetMinutes === "number" && Number.isFinite(opts.utcOffsetMinutes)) {
@@ -7391,7 +7400,41 @@ function computeMidpoints(planetsA, planetsB) {
7391
7400
  }
7392
7401
  return result;
7393
7402
  }
7394
- var DEFAULT_ASPECT_SPECS;
7403
+ function computeTransitAspects(transitPlanets, natalPlanets, specs = DEFAULT_ASPECT_SPECS) {
7404
+ const keysT = Object.keys(transitPlanets);
7405
+ const keysN = Object.keys(natalPlanets);
7406
+ const edges = [];
7407
+ for (const kT of keysT) {
7408
+ const t = transitPlanets[kT];
7409
+ for (const kN of keysN) {
7410
+ const n = natalPlanets[kN];
7411
+ const match = getAspectMatch(t.longitude, n.longitude, specs);
7412
+ if (!match) continue;
7413
+ const tSpeed = t.longitudeSpeed ?? 0;
7414
+ const nSpeed = n.longitudeSpeed ?? 0;
7415
+ const dt = 0.01;
7416
+ const tLonFuture = t.longitude + tSpeed * dt;
7417
+ const nLonFuture = n.longitude + nSpeed * dt;
7418
+ const futureMatch = getAspectMatch(tLonFuture, nLonFuture, [match.spec]);
7419
+ const applying = futureMatch != null ? futureMatch.orb < match.orb : false;
7420
+ edges.push({
7421
+ planetA: kT,
7422
+ planetB: kN,
7423
+ longitudeA: t.longitude,
7424
+ longitudeB: n.longitude,
7425
+ aspect: match.spec.name,
7426
+ aspectAngle: match.spec.angle,
7427
+ delta: match.delta,
7428
+ orb: match.orb,
7429
+ applying,
7430
+ retrograde: tSpeed < 0,
7431
+ category: SLOW_PLANETS.has(kT) ? "slow" : "fast"
7432
+ });
7433
+ }
7434
+ }
7435
+ return edges;
7436
+ }
7437
+ var DEFAULT_ASPECT_SPECS, SLOW_PLANETS;
7395
7438
  var init_aspects = __esm({
7396
7439
  "src/astrology/aspects.ts"() {
7397
7440
  "use strict";
@@ -7407,6 +7450,309 @@ var init_aspects = __esm({
7407
7450
  { name: "quincunx", angle: 150, orb: 3 },
7408
7451
  { name: "opposition", angle: 180, orb: 8 }
7409
7452
  ];
7453
+ SLOW_PLANETS = /* @__PURE__ */ new Set([
7454
+ "pluto",
7455
+ "neptune",
7456
+ "uranus",
7457
+ "saturn",
7458
+ "jupiter",
7459
+ "chiron",
7460
+ "mean node",
7461
+ "true node",
7462
+ "lilith true",
7463
+ "lilith mean"
7464
+ ]);
7465
+ }
7466
+ });
7467
+
7468
+ // src/astrology/dignity.ts
7469
+ function getDomicileRuler(sign) {
7470
+ return DOMICILE_RULERS[sign];
7471
+ }
7472
+ function getExaltation(planet) {
7473
+ return EXALTATIONS[planet];
7474
+ }
7475
+ function getOppositeSign(sign) {
7476
+ const idx = SIGNS.indexOf(sign);
7477
+ return SIGNS[(idx + 6) % 12];
7478
+ }
7479
+ function getDetriment(planet) {
7480
+ const signs = [];
7481
+ for (const [sign, ruler] of Object.entries(DOMICILE_RULERS)) {
7482
+ if (ruler === planet) {
7483
+ signs.push(getOppositeSign(sign));
7484
+ }
7485
+ }
7486
+ return signs;
7487
+ }
7488
+ function getFall(planet) {
7489
+ return getOppositeSign(EXALTATIONS[planet].sign);
7490
+ }
7491
+ function getEssentialDignity(planet, sign) {
7492
+ const domicile = DOMICILE_RULERS[sign] === planet;
7493
+ const exaltation = EXALTATIONS[planet].sign === sign;
7494
+ const detrimentSigns = getDetriment(planet);
7495
+ const detriment = detrimentSigns.includes(sign);
7496
+ const fallSign = getFall(planet);
7497
+ const fall = fallSign === sign;
7498
+ const domicileRuler = DOMICILE_RULERS[sign];
7499
+ const peregrine = !domicile && !exaltation && !detriment && !fall;
7500
+ return { domicile, exaltation, detriment, fall, domicileRuler, peregrine };
7501
+ }
7502
+ var DOMICILE_RULERS, EXALTATIONS;
7503
+ var init_dignity = __esm({
7504
+ "src/astrology/dignity.ts"() {
7505
+ "use strict";
7506
+ init_astrology();
7507
+ DOMICILE_RULERS = {
7508
+ Aries: "Mars",
7509
+ Taurus: "Venus",
7510
+ Gemini: "Mercury",
7511
+ Cancer: "Moon",
7512
+ Leo: "Sun",
7513
+ Virgo: "Mercury",
7514
+ Libra: "Venus",
7515
+ Scorpio: "Mars",
7516
+ Sagittarius: "Jupiter",
7517
+ Capricorn: "Saturn",
7518
+ Aquarius: "Saturn",
7519
+ Pisces: "Jupiter"
7520
+ };
7521
+ EXALTATIONS = {
7522
+ Sun: { sign: "Aries", degree: 19 },
7523
+ Moon: { sign: "Taurus", degree: 3 },
7524
+ Mercury: { sign: "Virgo", degree: 15 },
7525
+ Venus: { sign: "Pisces", degree: 27 },
7526
+ Mars: { sign: "Capricorn", degree: 28 },
7527
+ Jupiter: { sign: "Cancer", degree: 15 },
7528
+ Saturn: { sign: "Libra", degree: 21 }
7529
+ };
7530
+ }
7531
+ });
7532
+
7533
+ // src/astrology/decans.ts
7534
+ function getDecan(longitude) {
7535
+ const L = normalizeAngle(longitude);
7536
+ const signIndex = Math.floor(L / 30) % 12;
7537
+ const degreeWithinSign = L - signIndex * 30;
7538
+ const decanIndex = Math.min(Math.floor(degreeWithinSign / 10), 2);
7539
+ const globalDecanIndex = signIndex * 3 + decanIndex;
7540
+ const sign = SIGNS[signIndex];
7541
+ const ruler = CHALDEAN_RULERS[globalDecanIndex % 7];
7542
+ const suit = SIGN_SUITS[sign];
7543
+ const rank = RANK_NAMES[globalDecanIndex % 9];
7544
+ const tarotCard = `${rank} of ${suit}`;
7545
+ return {
7546
+ sign,
7547
+ decanNumber: decanIndex + 1,
7548
+ ruler,
7549
+ tarotCard,
7550
+ startDegree: signIndex * 30 + decanIndex * 10,
7551
+ endDegree: signIndex * 30 + (decanIndex + 1) * 10,
7552
+ degreeWithinSign
7553
+ };
7554
+ }
7555
+ var CHALDEAN_RULERS, SIGN_SUITS, RANK_NAMES;
7556
+ var init_decans = __esm({
7557
+ "src/astrology/decans.ts"() {
7558
+ "use strict";
7559
+ init_swisseph2();
7560
+ init_astrology();
7561
+ CHALDEAN_RULERS = [
7562
+ "Mars",
7563
+ "Sun",
7564
+ "Venus",
7565
+ "Mercury",
7566
+ "Moon",
7567
+ "Saturn",
7568
+ "Jupiter"
7569
+ ];
7570
+ SIGN_SUITS = {
7571
+ Aries: "Wands",
7572
+ Taurus: "Pentacles",
7573
+ Gemini: "Swords",
7574
+ Cancer: "Cups",
7575
+ Leo: "Wands",
7576
+ Virgo: "Pentacles",
7577
+ Libra: "Swords",
7578
+ Scorpio: "Cups",
7579
+ Sagittarius: "Wands",
7580
+ Capricorn: "Pentacles",
7581
+ Aquarius: "Swords",
7582
+ Pisces: "Cups"
7583
+ };
7584
+ RANK_NAMES = ["Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"];
7585
+ }
7586
+ });
7587
+
7588
+ // src/astrology/dodecatemoria.ts
7589
+ function getDodecatemoria(longitude) {
7590
+ const L = normalizeAngle(longitude);
7591
+ const signIndex = Math.floor(L / 30) % 12;
7592
+ const degreeWithinSign = L - signIndex * 30;
7593
+ const index = Math.min(Math.floor(degreeWithinSign / 2.5), 11);
7594
+ const dodecatemoriaSignIndex = (signIndex + index) % 12;
7595
+ return {
7596
+ originalSign: SIGNS[signIndex],
7597
+ originalDegree: degreeWithinSign,
7598
+ dodecatemoriaSign: SIGNS[dodecatemoriaSignIndex],
7599
+ dodecatemoriaIndex: index
7600
+ };
7601
+ }
7602
+ var init_dodecatemoria = __esm({
7603
+ "src/astrology/dodecatemoria.ts"() {
7604
+ "use strict";
7605
+ init_swisseph2();
7606
+ init_astrology();
7607
+ }
7608
+ });
7609
+
7610
+ // src/astrology/profections.ts
7611
+ function getAnnualProfection(natalChart, birthDate, targetYear) {
7612
+ const year = targetYear ?? (/* @__PURE__ */ new Date()).getFullYear();
7613
+ const birthYear = birthDate.getFullYear();
7614
+ const age = year - birthYear;
7615
+ if (age < 0) {
7616
+ throw new Error(`Target year (${year}) is before birth year (${birthYear}).`);
7617
+ }
7618
+ const house = age % 12 + 1;
7619
+ const sign = natalChart.houses.houses[house - 1].sign;
7620
+ const ruler = getDomicileRuler(sign);
7621
+ return { age, house, sign, ruler, targetYear: year };
7622
+ }
7623
+ function getMonthlyProfections(natalChart, birthDate, targetYear) {
7624
+ const annualProfection = getAnnualProfection(natalChart, birthDate, targetYear);
7625
+ const annualSignIndex = SIGNS.indexOf(annualProfection.sign);
7626
+ const bdMonth = birthDate.getMonth();
7627
+ const bdDay = birthDate.getDate();
7628
+ const year = annualProfection.targetYear;
7629
+ const months = [];
7630
+ for (let i = 0; i < 12; i++) {
7631
+ const monthDate = new Date(year, bdMonth + i, bdDay);
7632
+ if (monthDate.getDate() !== bdDay) {
7633
+ monthDate.setDate(0);
7634
+ }
7635
+ const signIndex = (annualSignIndex + i) % 12;
7636
+ const sign = SIGNS[signIndex];
7637
+ months.push({
7638
+ month: i + 1,
7639
+ startDate: monthDate,
7640
+ sign,
7641
+ ruler: getDomicileRuler(sign)
7642
+ });
7643
+ }
7644
+ return { annualProfection, months };
7645
+ }
7646
+ var init_profections = __esm({
7647
+ "src/astrology/profections.ts"() {
7648
+ "use strict";
7649
+ init_dignity();
7650
+ init_astrology();
7651
+ }
7652
+ });
7653
+
7654
+ // src/astrology/firdaria.ts
7655
+ function addYears(date, years) {
7656
+ const ms = years * 365.25 * 24 * 60 * 60 * 1e3;
7657
+ return new Date(date.getTime() + ms);
7658
+ }
7659
+ function getSubPeriodStart(planet, options) {
7660
+ const mode = options?.nodeSubPeriodStart ?? "jupiter-saturn";
7661
+ if (planet === "NorthNode") {
7662
+ if (mode === "sun-mars") {
7663
+ return CHALDEAN_ORDER.indexOf("Sun");
7664
+ }
7665
+ return CHALDEAN_ORDER.indexOf("Jupiter");
7666
+ }
7667
+ if (planet === "SouthNode") {
7668
+ if (mode === "sun-mars") {
7669
+ return CHALDEAN_ORDER.indexOf("Mars");
7670
+ }
7671
+ return CHALDEAN_ORDER.indexOf("Saturn");
7672
+ }
7673
+ return CHALDEAN_ORDER.indexOf(planet);
7674
+ }
7675
+ function buildSubPeriods(major, majorStart, majorEnd, options) {
7676
+ const startIdx = getSubPeriodStart(major.planet, options);
7677
+ const totalMs = majorEnd.getTime() - majorStart.getTime();
7678
+ const subMs = totalMs / 7;
7679
+ const subs = [];
7680
+ for (let i = 0; i < 7; i++) {
7681
+ const subPlanet = CHALDEAN_ORDER[(startIdx + i) % 7];
7682
+ const subStart = new Date(majorStart.getTime() + i * subMs);
7683
+ const subEnd = new Date(majorStart.getTime() + (i + 1) * subMs);
7684
+ subs.push({ planet: subPlanet, startDate: subStart, endDate: subEnd });
7685
+ }
7686
+ return subs;
7687
+ }
7688
+ function getFirdaria(birthDate, isDiurnal, targetDate, options) {
7689
+ const target = targetDate ?? /* @__PURE__ */ new Date();
7690
+ const sequence = isDiurnal ? DAY_SEQUENCE : NIGHT_SEQUENCE;
7691
+ const sect = isDiurnal ? "diurnal" : "nocturnal";
7692
+ const allPeriods = [];
7693
+ let cursor = new Date(birthDate.getTime());
7694
+ let foundCurrent = false;
7695
+ for (let cycle = 0; cycle < 3 && !foundCurrent; cycle++) {
7696
+ for (const entry of sequence) {
7697
+ const start = new Date(cursor.getTime());
7698
+ const end = addYears(start, entry.years);
7699
+ const subPeriods = buildSubPeriods(entry, start, end, options);
7700
+ allPeriods.push({
7701
+ planet: entry.planet,
7702
+ years: entry.years,
7703
+ startDate: start,
7704
+ endDate: end,
7705
+ subPeriods
7706
+ });
7707
+ cursor = end;
7708
+ if (target.getTime() >= start.getTime() && target.getTime() < end.getTime()) {
7709
+ foundCurrent = true;
7710
+ }
7711
+ }
7712
+ }
7713
+ const currentMajor = allPeriods.find(
7714
+ (p) => target.getTime() >= p.startDate.getTime() && target.getTime() < p.endDate.getTime()
7715
+ ) ?? allPeriods[0];
7716
+ const currentSub = currentMajor.subPeriods.find(
7717
+ (s) => target.getTime() >= s.startDate.getTime() && target.getTime() < s.endDate.getTime()
7718
+ ) ?? currentMajor.subPeriods[0];
7719
+ return { sect, currentMajor, currentSub, allPeriods };
7720
+ }
7721
+ var DAY_SEQUENCE, NIGHT_SEQUENCE, CHALDEAN_ORDER;
7722
+ var init_firdaria = __esm({
7723
+ "src/astrology/firdaria.ts"() {
7724
+ "use strict";
7725
+ DAY_SEQUENCE = [
7726
+ { planet: "Sun", years: 10 },
7727
+ { planet: "Venus", years: 8 },
7728
+ { planet: "Mercury", years: 13 },
7729
+ { planet: "Moon", years: 9 },
7730
+ { planet: "Saturn", years: 11 },
7731
+ { planet: "Jupiter", years: 12 },
7732
+ { planet: "Mars", years: 7 },
7733
+ { planet: "NorthNode", years: 3 },
7734
+ { planet: "SouthNode", years: 2 }
7735
+ ];
7736
+ NIGHT_SEQUENCE = [
7737
+ { planet: "Moon", years: 9 },
7738
+ { planet: "Saturn", years: 11 },
7739
+ { planet: "Jupiter", years: 12 },
7740
+ { planet: "Mars", years: 7 },
7741
+ { planet: "NorthNode", years: 3 },
7742
+ { planet: "SouthNode", years: 2 },
7743
+ { planet: "Sun", years: 10 },
7744
+ { planet: "Venus", years: 8 },
7745
+ { planet: "Mercury", years: 13 }
7746
+ ];
7747
+ CHALDEAN_ORDER = [
7748
+ "Saturn",
7749
+ "Jupiter",
7750
+ "Mars",
7751
+ "Sun",
7752
+ "Venus",
7753
+ "Mercury",
7754
+ "Moon"
7755
+ ];
7410
7756
  }
7411
7757
  });
7412
7758
 
@@ -7415,22 +7761,40 @@ var astrology_exports = {};
7415
7761
  __export(astrology_exports, {
7416
7762
  CalcFlag: () => CalcFlag,
7417
7763
  DEFAULT_ASPECT_SPECS: () => DEFAULT_ASPECT_SPECS,
7764
+ DOMICILE_RULERS: () => DOMICILE_RULERS,
7765
+ EXALTATIONS: () => EXALTATIONS,
7418
7766
  HouseSystem: () => HouseSystem,
7419
7767
  PLANET_AND_NODE_NAMES: () => PLANET_AND_NODE_NAMES,
7420
7768
  Planet: () => Planet,
7421
7769
  SIGNS: () => SIGNS,
7770
+ SLOW_PLANETS: () => SLOW_PLANETS,
7422
7771
  VirtualNodes: () => VirtualNodes,
7423
7772
  closeSwissEph: () => closeSwissEph,
7424
7773
  computeAspects: () => computeAspects,
7425
7774
  computeMidpoints: () => computeMidpoints,
7426
7775
  computeSynastryAspects: () => computeSynastryAspects,
7776
+ computeTransitAspects: () => computeTransitAspects,
7427
7777
  findHouseOf: () => findHouseOf,
7428
7778
  formatDegreeMinutes: () => formatDegreeMinutes,
7779
+ getAnnualProfection: () => getAnnualProfection,
7429
7780
  getAspectMatch: () => getAspectMatch,
7430
7781
  getBirthChart: () => getBirthChart,
7431
7782
  getCompositeChart: () => getCompositeChart,
7783
+ getDecan: () => getDecan,
7784
+ getDetriment: () => getDetriment,
7785
+ getDodecatemoria: () => getDodecatemoria,
7786
+ getDomicileRuler: () => getDomicileRuler,
7787
+ getEssentialDignity: () => getEssentialDignity,
7788
+ getExaltation: () => getExaltation,
7789
+ getFall: () => getFall,
7790
+ getFirdaria: () => getFirdaria,
7791
+ getMonthlyProfections: () => getMonthlyProfections,
7792
+ getOppositeSign: () => getOppositeSign,
7793
+ getSolarReturnChart: () => getSolarReturnChart,
7432
7794
  getSwissEph: () => getSwissEph,
7433
7795
  getSynastryChart: () => getSynastryChart,
7796
+ getTransitChart: () => getTransitChart,
7797
+ getTransitRange: () => getTransitRange,
7434
7798
  getZodiacPosition: () => getZodiacPosition,
7435
7799
  normalizeAngle: () => normalizeAngle,
7436
7800
  shorterArcMidpoint: () => shorterArcMidpoint
@@ -7531,7 +7895,8 @@ async function getBirthChart(options) {
7531
7895
  planets,
7532
7896
  houses,
7533
7897
  nodes,
7534
- aspects
7898
+ aspects,
7899
+ sect: isDiurnal ? "diurnal" : "nocturnal"
7535
7900
  };
7536
7901
  } catch (error) {
7537
7902
  console.error("Error calculating birth chart:", error);
@@ -7623,12 +7988,328 @@ async function getCompositeChart(options) {
7623
7988
  aspects
7624
7989
  };
7625
7990
  }
7626
- var SIGNS;
7991
+ function getTransitAspectPoints(planets) {
7992
+ const points = {};
7993
+ for (const [key, p] of Object.entries(planets)) {
7994
+ points[key] = { longitude: p.longitude, longitudeSpeed: p.longitudeSpeed };
7995
+ }
7996
+ return points;
7997
+ }
7998
+ function getNatalAspectPoints(planets, ascLon, mcLon) {
7999
+ const points = {};
8000
+ for (const [key, p] of Object.entries(planets)) {
8001
+ points[key] = { longitude: p.longitude, longitudeSpeed: 0 };
8002
+ }
8003
+ points.ascendant = { longitude: ascLon, longitudeSpeed: 0 };
8004
+ points.mc = { longitude: mcLon, longitudeSpeed: 0 };
8005
+ return points;
8006
+ }
8007
+ function filterByNames(points, names) {
8008
+ if (!names || names.length === 0) return points;
8009
+ const allowed = new Set(names.map((n) => n.toLowerCase()));
8010
+ const result = {};
8011
+ for (const [key, val] of Object.entries(points)) {
8012
+ if (allowed.has(key)) result[key] = val;
8013
+ }
8014
+ return result;
8015
+ }
8016
+ async function getTransitChart(options) {
8017
+ const natalChart = await getBirthChart(options.natal);
8018
+ const transitChart = await getBirthChart({
8019
+ date: options.transitDate,
8020
+ latitude: options.transitLatitude ?? options.natal.latitude,
8021
+ longitude: options.transitLongitude ?? options.natal.longitude,
8022
+ houseSystem: options.natal.houseSystem,
8023
+ timeZoneSettings: options.transitTimeZoneSettings ?? { autoTimeZone: true }
8024
+ });
8025
+ const natalCusps = natalChart.houses.houses.map((h) => h.longitude);
8026
+ const transitPlanets = {};
8027
+ for (const [key, planet] of Object.entries(transitChart.planets)) {
8028
+ const natalZodiac = getZodiacPosition(planet.longitude, natalCusps);
8029
+ transitPlanets[key] = {
8030
+ ...planet,
8031
+ retrograde: (planet.longitudeSpeed ?? 0) < 0,
8032
+ natalHouse: natalZodiac.house,
8033
+ zodiacPosition: {
8034
+ ...planet.zodiacPosition,
8035
+ house: natalZodiac.house
8036
+ }
8037
+ };
8038
+ }
8039
+ let tPoints = getTransitAspectPoints(transitChart.planets);
8040
+ let nPoints = getNatalAspectPoints(
8041
+ natalChart.planets,
8042
+ natalChart.houses.ascendant.longitude,
8043
+ natalChart.houses.mc.longitude
8044
+ );
8045
+ tPoints = filterByNames(tPoints, options.transitPlanets);
8046
+ nPoints = filterByNames(nPoints, options.natalPlanets);
8047
+ let aspects = computeTransitAspects(tPoints, nPoints, options.aspectSpecs);
8048
+ if (options.maxOrb != null) {
8049
+ aspects = aspects.filter((a) => a.orb <= options.maxOrb);
8050
+ }
8051
+ if (options.aspectFilter && options.aspectFilter.length > 0) {
8052
+ const allowed = new Set(options.aspectFilter);
8053
+ aspects = aspects.filter((a) => allowed.has(a.aspect));
8054
+ }
8055
+ return {
8056
+ natalChart,
8057
+ transitDateUtc: transitChart.dateUtc,
8058
+ transitPlanets,
8059
+ aspects
8060
+ };
8061
+ }
8062
+ async function getTransitRange(options) {
8063
+ const natalChart = await getBirthChart(options.natal);
8064
+ const natalCusps = natalChart.houses.houses.map((h) => h.longitude);
8065
+ const nPoints = filterByNames(
8066
+ getNatalAspectPoints(
8067
+ natalChart.planets,
8068
+ natalChart.houses.ascendant.longitude,
8069
+ natalChart.houses.mc.longitude
8070
+ ),
8071
+ options.natalPlanets
8072
+ );
8073
+ const natalKeys = Object.keys(nPoints);
8074
+ const rawStep = options.stepDays ?? 1;
8075
+ if (rawStep <= 0) throw new Error("stepDays must be greater than 0");
8076
+ const fromMs = options.from.getTime();
8077
+ const toMs = options.to.getTime();
8078
+ const specs = options.aspectSpecs;
8079
+ const steps = [];
8080
+ const transitLat = options.transitLatitude ?? options.natal.latitude;
8081
+ const transitLon = options.transitLongitude ?? options.natal.longitude;
8082
+ const transitTz = options.transitTimeZoneSettings ?? { autoTimeZone: true };
8083
+ const FAST_PLANET_MAX_STEP = 0.25;
8084
+ let effectiveStepDays = rawStep;
8085
+ const requestedTransitPlanets = options.transitPlanets?.map((n) => n.toLowerCase());
8086
+ const hasFastPlanets = requestedTransitPlanets ? requestedTransitPlanets.some((n) => !SLOW_PLANETS.has(n)) : true;
8087
+ if (hasFastPlanets && effectiveStepDays > FAST_PLANET_MAX_STEP) {
8088
+ effectiveStepDays = FAST_PLANET_MAX_STEP;
8089
+ }
8090
+ const stepMs = effectiveStepDays * 864e5;
8091
+ const scanEndMs = toMs + stepMs;
8092
+ for (let ms = fromMs; ms <= scanEndMs; ms += stepMs) {
8093
+ const date = new Date(ms);
8094
+ const utcDate = await toUtcDate(date, transitLat, transitLon, transitTz ?? { autoTimeZone: true });
8095
+ const positions = await calculatePlanetaryPositions(utcDate);
8096
+ if (!positions) continue;
8097
+ const points = {};
8098
+ for (const [planetId, pos] of Object.entries(positions)) {
8099
+ const id2 = planetId;
8100
+ const name = PLANET_AND_NODE_NAMES[id2].toLowerCase();
8101
+ points[name] = { longitude: pos.longitude, longitudeSpeed: pos.longitudeSpeed };
8102
+ }
8103
+ steps.push({ time: ms, positions: filterByNames(points, options.transitPlanets) });
8104
+ }
8105
+ const perfections = [];
8106
+ const transitKeys = steps.length > 0 ? Object.keys(steps[0].positions) : [];
8107
+ for (const tKey of transitKeys) {
8108
+ for (const nKey of natalKeys) {
8109
+ let prevOrb = null;
8110
+ let prevDecreasing = false;
8111
+ let prevStep = null;
8112
+ for (const step of steps) {
8113
+ const tPos = step.positions[tKey];
8114
+ const nPos = nPoints[nKey];
8115
+ if (!tPos || !nPos) continue;
8116
+ const match = specs ? findClosestAspectOrb(tPos.longitude, nPos.longitude, specs) : findClosestAspectOrb(tPos.longitude, nPos.longitude);
8117
+ if (!match) {
8118
+ prevOrb = null;
8119
+ prevStep = step;
8120
+ continue;
8121
+ }
8122
+ const currentOrb = match.orb;
8123
+ if (prevOrb != null && prevStep) {
8124
+ const wasDecreasing = prevOrb > currentOrb;
8125
+ if (prevDecreasing && !wasDecreasing && currentOrb <= match.spec.orb) {
8126
+ const exactResult = await binarySearchPerfection(
8127
+ tKey,
8128
+ nKey,
8129
+ match.spec,
8130
+ prevStep.time,
8131
+ step.time,
8132
+ nPos,
8133
+ transitLat,
8134
+ transitLon,
8135
+ transitTz
8136
+ );
8137
+ if (exactResult) perfections.push(exactResult);
8138
+ }
8139
+ prevDecreasing = wasDecreasing;
8140
+ } else {
8141
+ prevDecreasing = false;
8142
+ }
8143
+ prevOrb = currentOrb;
8144
+ prevStep = step;
8145
+ }
8146
+ }
8147
+ }
8148
+ let filtered = perfections.filter((p) => {
8149
+ const t = p.exactDate.getTime();
8150
+ return t >= fromMs && t <= toMs;
8151
+ });
8152
+ if (options.maxOrb != null) {
8153
+ filtered = filtered.filter((p) => p.exactOrb <= options.maxOrb);
8154
+ }
8155
+ if (options.aspectFilter && options.aspectFilter.length > 0) {
8156
+ const allowed = new Set(options.aspectFilter);
8157
+ filtered = filtered.filter((p) => allowed.has(p.aspect));
8158
+ }
8159
+ filtered.sort((a, b) => a.exactDate.getTime() - b.exactDate.getTime());
8160
+ return {
8161
+ natalChart,
8162
+ from: options.from,
8163
+ to: options.to,
8164
+ perfections: filtered
8165
+ };
8166
+ }
8167
+ function findClosestAspectOrb(lonA, lonB, specs = DEFAULT_ASPECT_SPECS) {
8168
+ const a = normalizeAngle(lonA);
8169
+ const b = normalizeAngle(lonB);
8170
+ const delta = Math.min(normalizeAngle(b - a), normalizeAngle(a - b));
8171
+ let best = null;
8172
+ for (const spec of specs) {
8173
+ const orb = Math.abs(delta - spec.angle);
8174
+ if (orb <= spec.orb + 2) {
8175
+ if (!best || orb < best.orb) {
8176
+ best = { spec, orb, delta };
8177
+ }
8178
+ }
8179
+ }
8180
+ return best;
8181
+ }
8182
+ function computeOrbForAspect(transitLon, natalLon, aspectAngle) {
8183
+ const delta = Math.min(
8184
+ normalizeAngle(transitLon - natalLon),
8185
+ normalizeAngle(natalLon - transitLon)
8186
+ );
8187
+ return Math.abs(delta - aspectAngle);
8188
+ }
8189
+ async function getTransitLongitudeAt(ms, transitKey, transitLat, transitLon, transitTz) {
8190
+ const date = new Date(ms);
8191
+ const utc = await toUtcDate(date, transitLat, transitLon, transitTz);
8192
+ const planetId = NAME_TO_PLANET[transitKey];
8193
+ if (planetId != null) {
8194
+ try {
8195
+ return calculateSinglePlanetPosition(utc, planetId);
8196
+ } catch {
8197
+ return null;
8198
+ }
8199
+ }
8200
+ const positions = await calculatePlanetaryPositions(utc);
8201
+ if (!positions) return null;
8202
+ return findPlanetByName(positions, transitKey) ?? null;
8203
+ }
8204
+ async function binarySearchPerfection(transitKey, natalKey, spec, startMs, endMs, natalPoint, transitLat, transitLon, transitTz) {
8205
+ const tz = transitTz ?? { autoTimeZone: true };
8206
+ const maxIterations = 30;
8207
+ let lo = startMs;
8208
+ let hi = endMs;
8209
+ for (let i = 0; i < maxIterations; i++) {
8210
+ if (hi - lo < 6e4) break;
8211
+ const m1 = lo + Math.floor((hi - lo) / 3);
8212
+ const m2 = hi - Math.floor((hi - lo) / 3);
8213
+ const pos1 = await getTransitLongitudeAt(m1, transitKey, transitLat, transitLon, tz);
8214
+ const pos2 = await getTransitLongitudeAt(m2, transitKey, transitLat, transitLon, tz);
8215
+ if (!pos1 || !pos2) break;
8216
+ const orb1 = computeOrbForAspect(pos1.longitude, natalPoint.longitude, spec.angle);
8217
+ const orb2 = computeOrbForAspect(pos2.longitude, natalPoint.longitude, spec.angle);
8218
+ if (orb1 < orb2) {
8219
+ hi = m2;
8220
+ } else {
8221
+ lo = m1;
8222
+ }
8223
+ }
8224
+ const finalMs = Math.floor((lo + hi) / 2);
8225
+ const finalPos = await getTransitLongitudeAt(finalMs, transitKey, transitLat, transitLon, tz);
8226
+ if (!finalPos) return null;
8227
+ const finalOrb = computeOrbForAspect(finalPos.longitude, natalPoint.longitude, spec.angle);
8228
+ if (finalOrb > spec.orb) return null;
8229
+ return {
8230
+ transitPlanet: transitKey,
8231
+ natalPlanet: natalKey,
8232
+ aspect: spec.name,
8233
+ exactDate: new Date(finalMs),
8234
+ exactOrb: finalOrb,
8235
+ retrograde: (finalPos.longitudeSpeed ?? 0) < 0,
8236
+ category: SLOW_PLANETS.has(transitKey) ? "slow" : "fast"
8237
+ };
8238
+ }
8239
+ function findPlanetByName(positions, name) {
8240
+ for (const [planetId, pos] of Object.entries(positions)) {
8241
+ const id2 = planetId;
8242
+ if (PLANET_AND_NODE_NAMES[id2].toLowerCase() === name) return pos;
8243
+ }
8244
+ return void 0;
8245
+ }
8246
+ async function getSunLongitudeAtMs(ms) {
8247
+ const positions = await calculatePlanetaryPositions(new Date(ms));
8248
+ const sun = findPlanetByName(positions, "sun");
8249
+ if (!sun) throw new Error("Failed to compute Sun position");
8250
+ return sun.longitude;
8251
+ }
8252
+ function signedAngularDelta(current, target) {
8253
+ let d = normalizeAngle(current - target);
8254
+ if (d > 180) d -= 360;
8255
+ return d;
8256
+ }
8257
+ async function getSolarReturnChart(options) {
8258
+ const natalChart = await getBirthChart(options.natal);
8259
+ const natalSunLongitude = natalChart.planets.sun.longitude;
8260
+ const natalDate = options.natal.date;
8261
+ const approxReturn = new Date(Date.UTC(
8262
+ options.year,
8263
+ natalDate.getMonth(),
8264
+ natalDate.getDate(),
8265
+ 12,
8266
+ 0,
8267
+ 0
8268
+ ));
8269
+ let lo = approxReturn.getTime() - 2 * 864e5;
8270
+ let hi = approxReturn.getTime() + 2 * 864e5;
8271
+ for (let i = 0; i < 30; i++) {
8272
+ if (hi - lo < 6e4) break;
8273
+ const mid = Math.floor((lo + hi) / 2);
8274
+ const sunLon = await getSunLongitudeAtMs(mid);
8275
+ const delta = signedAngularDelta(sunLon, natalSunLongitude);
8276
+ if (delta < 0) {
8277
+ lo = mid;
8278
+ } else {
8279
+ hi = mid;
8280
+ }
8281
+ }
8282
+ const exactMs = Math.floor((lo + hi) / 2);
8283
+ const exactReturnDate = new Date(exactMs);
8284
+ const solarReturnChart = await getBirthChart({
8285
+ date: exactReturnDate,
8286
+ latitude: options.solarReturnLatitude ?? options.natal.latitude,
8287
+ longitude: options.solarReturnLongitude ?? options.natal.longitude,
8288
+ houseSystem: options.solarReturnHouseSystem ?? options.natal.houseSystem,
8289
+ // Always treatAsUTC: the binary search converged on a UTC millisecond timestamp.
8290
+ // Passing a caller timezone here would re-interpret the already-UTC instant as local,
8291
+ // shifting planetary positions by hours.
8292
+ timeZoneSettings: { treatAsUTC: true }
8293
+ });
8294
+ return {
8295
+ natalChart,
8296
+ solarReturnChart,
8297
+ exactReturnDate,
8298
+ natalSunLongitude,
8299
+ year: options.year
8300
+ };
8301
+ }
8302
+ var SIGNS, NAME_TO_PLANET;
7627
8303
  var init_astrology = __esm({
7628
8304
  "src/astrology/index.ts"() {
7629
8305
  "use strict";
7630
8306
  init_swisseph2();
7631
8307
  init_aspects();
8308
+ init_dignity();
8309
+ init_decans();
8310
+ init_dodecatemoria();
8311
+ init_profections();
8312
+ init_firdaria();
7632
8313
  init_aspects();
7633
8314
  SIGNS = [
7634
8315
  "Aries",
@@ -7644,6 +8325,11 @@ var init_astrology = __esm({
7644
8325
  "Aquarius",
7645
8326
  "Pisces"
7646
8327
  ];
8328
+ NAME_TO_PLANET = {};
8329
+ for (const [id2, name] of Object.entries(PLANET_AND_NODE_NAMES)) {
8330
+ const numId = Number(id2);
8331
+ if (!isNaN(numId)) NAME_TO_PLANET[name.toLowerCase()] = numId;
8332
+ }
7647
8333
  }
7648
8334
  });
7649
8335
 
@@ -7653,7 +8339,7 @@ var import_config3 = require("dotenv/config");
7653
8339
  // package.json
7654
8340
  var package_default = {
7655
8341
  name: "kaabalah",
7656
- version: "5.3.0",
8342
+ version: "5.4.0",
7657
8343
  description: "The de-facto library for any esoteric calculations and tooling",
7658
8344
  engines: {
7659
8345
  node: ">=18.18.0"
@@ -7956,6 +8642,152 @@ var COMMANDS = [
7956
8642
  "kaabalah astrology:composite --input-json=- --json --compact < composite.json"
7957
8643
  ]
7958
8644
  },
8645
+ {
8646
+ name: "astrology:transits",
8647
+ description: "Calculate transit aspects to a natal chart",
8648
+ args: [
8649
+ { name: "date", type: "date", required: true, description: "Natal birth date in YYYY-MM-DD format" },
8650
+ { name: "time", type: "string", required: false, description: "Natal birth time in HH:MM format (default: 12:00)" }
8651
+ ],
8652
+ flags: [
8653
+ { name: "lat", type: "number", description: "Natal latitude (-90 to 90)" },
8654
+ { name: "lon", type: "number", description: "Natal longitude (-180 to 180)" },
8655
+ { name: "location", type: "string", description: "Natal location for geocoding (requires GOOGLE_MAPS_API_KEY)" },
8656
+ { name: "house-system", type: "string", default: "placidus", description: "House system" },
8657
+ { name: "timezone", type: "string", description: "Natal IANA timezone (auto-resolved if omitted)" },
8658
+ { name: "transit-date", type: "string", description: "Transit date YYYY-MM-DD (default: today)" },
8659
+ { name: "transit-time", type: "string", description: "Transit time HH:MM (default: 12:00)" },
8660
+ { name: "transit-lat", type: "number", description: "Transit location latitude (default: natal lat)" },
8661
+ { name: "transit-lon", type: "number", description: "Transit location longitude (default: natal lon)" },
8662
+ { name: "transit-timezone", type: "string", description: "Transit IANA timezone (default: natal timezone)" },
8663
+ { name: "max-orb", type: "number", description: "Maximum orb in degrees to include" },
8664
+ { name: "aspects", type: "string", description: "Comma-separated aspect names, or 'major' for conjunction,sextile,square,trine,opposition" },
8665
+ { name: "transit-planets", type: "string", description: "Comma-separated transit planet names to include" },
8666
+ { name: "natal-planets", type: "string", description: "Comma-separated natal planet/point names to include" },
8667
+ { name: "from", type: "string", description: "Range start date YYYY-MM-DD (enables date range mode)" },
8668
+ { name: "to", type: "string", description: "Range end date YYYY-MM-DD (requires --from)" },
8669
+ { name: "step-days", type: "number", description: "Step size in days for range scan (default: 1)" },
8670
+ { name: "wasm-path", type: "string", description: "Override the Swiss Ephemeris WASM runtime path" },
8671
+ { name: "ephe-path", type: "string", description: "Override the ephemeris data directory path" }
8672
+ ],
8673
+ examples: [
8674
+ "kaabalah astrology:transits 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --transit-date=2026-03-17 --json --compact",
8675
+ "kaabalah astrology:transits 1990-01-15 14:30 --lat=40.71 --lon=-74 --from=2026-03-01 --to=2026-04-01 --json",
8676
+ "kaabalah astrology:transits 1990-01-15 --lat=40.71 --lon=-74 --aspects=major --transit-planets=saturn,pluto --json"
8677
+ ]
8678
+ },
8679
+ {
8680
+ name: "astrology:solar-return",
8681
+ description: "Calculate Solar Return chart for a given year",
8682
+ args: [
8683
+ { name: "date", type: "date", required: true, description: "Natal birth date in YYYY-MM-DD format" },
8684
+ { name: "time", type: "string", required: false, description: "Natal birth time in HH:MM format (default: 12:00)" }
8685
+ ],
8686
+ flags: [
8687
+ { name: "lat", type: "number", description: "Natal latitude (-90 to 90)" },
8688
+ { name: "lon", type: "number", description: "Natal longitude (-180 to 180)" },
8689
+ { name: "location", type: "string", description: "Natal location for geocoding (requires GOOGLE_MAPS_API_KEY)" },
8690
+ { name: "house-system", type: "string", default: "placidus", description: "House system for natal chart" },
8691
+ { name: "timezone", type: "string", description: "Natal IANA timezone (auto-resolved if omitted)" },
8692
+ { name: "year", type: "number", description: "Solar return year (default: current year)" },
8693
+ { name: "sr-lat", type: "number", description: "Solar return location latitude (default: natal lat)" },
8694
+ { name: "sr-lon", type: "number", description: "Solar return location longitude (default: natal lon)" },
8695
+ { name: "sr-location", type: "string", description: "Solar return location for geocoding" },
8696
+ { name: "sr-house-system", type: "string", description: "House system for solar return chart (default: natal house system)" },
8697
+ { name: "wasm-path", type: "string", description: "Override the Swiss Ephemeris WASM runtime path" },
8698
+ { name: "ephe-path", type: "string", description: "Override the ephemeris data directory path" }
8699
+ ],
8700
+ examples: [
8701
+ "kaabalah astrology:solar-return 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --year=2025 --json --compact",
8702
+ "kaabalah astrology:solar-return 1990-01-15 14:30 --lat=40.71 --lon=-74 --year=2026 --sr-lat=34.05 --sr-lon=-118.24 --json"
8703
+ ]
8704
+ },
8705
+ {
8706
+ name: "astrology:profections",
8707
+ description: "Calculate annual profection for a given year",
8708
+ args: [
8709
+ { name: "date", type: "date", required: true, description: "Natal birth date in YYYY-MM-DD format" },
8710
+ { name: "time", type: "string", required: false, description: "Natal birth time in HH:MM format (default: 12:00)" }
8711
+ ],
8712
+ flags: [
8713
+ { name: "lat", type: "number", description: "Natal latitude (-90 to 90)" },
8714
+ { name: "lon", type: "number", description: "Natal longitude (-180 to 180)" },
8715
+ { name: "location", type: "string", description: "Natal location for geocoding (requires GOOGLE_MAPS_API_KEY)" },
8716
+ { name: "timezone", type: "string", description: "Natal IANA timezone (auto-resolved if omitted)" },
8717
+ { name: "year", type: "number", description: "Target year (default: current year)" },
8718
+ { name: "wasm-path", type: "string", description: "Override the Swiss Ephemeris WASM runtime path" },
8719
+ { name: "ephe-path", type: "string", description: "Override the ephemeris data directory path" }
8720
+ ],
8721
+ examples: [
8722
+ "kaabalah astrology:profections 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --year=2026 --json --compact"
8723
+ ]
8724
+ },
8725
+ {
8726
+ name: "astrology:profections:monthly",
8727
+ description: "Calculate monthly profections for a given year",
8728
+ args: [
8729
+ { name: "date", type: "date", required: true, description: "Natal birth date in YYYY-MM-DD format" },
8730
+ { name: "time", type: "string", required: false, description: "Natal birth time in HH:MM format (default: 12:00)" }
8731
+ ],
8732
+ flags: [
8733
+ { name: "lat", type: "number", description: "Natal latitude (-90 to 90)" },
8734
+ { name: "lon", type: "number", description: "Natal longitude (-180 to 180)" },
8735
+ { name: "location", type: "string", description: "Natal location for geocoding (requires GOOGLE_MAPS_API_KEY)" },
8736
+ { name: "timezone", type: "string", description: "Natal IANA timezone (auto-resolved if omitted)" },
8737
+ { name: "year", type: "number", description: "Target year (default: current year)" },
8738
+ { name: "wasm-path", type: "string", description: "Override the Swiss Ephemeris WASM runtime path" },
8739
+ { name: "ephe-path", type: "string", description: "Override the ephemeris data directory path" }
8740
+ ],
8741
+ examples: [
8742
+ "kaabalah astrology:profections:monthly 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --year=2026 --json --compact"
8743
+ ]
8744
+ },
8745
+ {
8746
+ name: "astrology:firdaria",
8747
+ description: "Calculate firdaria planetary periods",
8748
+ args: [
8749
+ { name: "date", type: "date", required: true, description: "Natal birth date in YYYY-MM-DD format" },
8750
+ { name: "time", type: "string", required: false, description: "Natal birth time in HH:MM format (default: 12:00)" }
8751
+ ],
8752
+ flags: [
8753
+ { name: "lat", type: "number", description: "Natal latitude (-90 to 90)" },
8754
+ { name: "lon", type: "number", description: "Natal longitude (-180 to 180)" },
8755
+ { name: "location", type: "string", description: "Natal location for geocoding (requires GOOGLE_MAPS_API_KEY)" },
8756
+ { name: "timezone", type: "string", description: "Natal IANA timezone (auto-resolved if omitted)" },
8757
+ { name: "sect", type: "string", description: "Override sect: 'diurnal' or 'nocturnal' (default: auto-detect from chart)" },
8758
+ { name: "target-date", type: "string", description: "Target date YYYY-MM-DD (default: today)" },
8759
+ { name: "wasm-path", type: "string", description: "Override the Swiss Ephemeris WASM runtime path" },
8760
+ { name: "ephe-path", type: "string", description: "Override the ephemeris data directory path" }
8761
+ ],
8762
+ examples: [
8763
+ "kaabalah astrology:firdaria 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --json --compact",
8764
+ "kaabalah astrology:firdaria 2001-10-02 19:45 --lat=-22.738 --lon=-47.334 --target-date=2030-01-01 --json"
8765
+ ]
8766
+ },
8767
+ {
8768
+ name: "astrology:decans",
8769
+ description: "Look up the decan (face) for a zodiacal longitude",
8770
+ args: [
8771
+ { name: "longitude", type: "number", required: true, description: "Ecliptic longitude in degrees (0-360)" }
8772
+ ],
8773
+ flags: [],
8774
+ examples: [
8775
+ "kaabalah astrology:decans 15 --json --compact",
8776
+ "kaabalah astrology:decans 270.5 --json"
8777
+ ]
8778
+ },
8779
+ {
8780
+ name: "astrology:dodecatemoria",
8781
+ description: "Look up the dodecatemoria (12th part) for a zodiacal longitude",
8782
+ args: [
8783
+ { name: "longitude", type: "number", required: true, description: "Ecliptic longitude in degrees (0-360)" }
8784
+ ],
8785
+ flags: [],
8786
+ examples: [
8787
+ "kaabalah astrology:dodecatemoria 5 --json --compact",
8788
+ "kaabalah astrology:dodecatemoria 227.5 --json"
8789
+ ]
8790
+ },
7959
8791
  {
7960
8792
  name: "help",
7961
8793
  description: "Show help message",
@@ -9099,6 +9931,541 @@ Composite Chart (Midpoint Method)
9099
9931
  closeSwissEph2();
9100
9932
  }
9101
9933
  }
9934
+ var MAJOR_ASPECTS = ["conjunction", "sextile", "square", "trine", "opposition"];
9935
+ async function cmdAstrologyTransits(args, flags, inputPayload, executionContext) {
9936
+ const natalPayload = inputPayload?.natal;
9937
+ const effectiveArgs = natalPayload ? [] : args;
9938
+ const effectiveInputPayload = natalPayload ? { ...natalPayload } : inputPayload;
9939
+ const natalInput = await parseSingleChartRequest(effectiveArgs, flags, effectiveInputPayload, executionContext);
9940
+ const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
9941
+ const { getTransitChart: getTransitChart2, getTransitRange: getTransitRange2, closeSwissEph: closeSwissEph2, HouseSystem: HouseSystem2 } = astroModule;
9942
+ const releaseSwissEphCleanup = executionContext.registerCleanup(() => {
9943
+ astroModule.closeSwissEph();
9944
+ });
9945
+ const runtimePaths = getAstrologyRuntimePaths(flags);
9946
+ try {
9947
+ await initWasm(runtimePaths, executionContext);
9948
+ } catch (err) {
9949
+ releaseSwissEphCleanup();
9950
+ closeSwissEph2();
9951
+ executionContext.throwIfInterrupted();
9952
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
9953
+ }
9954
+ try {
9955
+ const transitDateStr = inputPayload?.transitDate ?? getFlagString(flags, "transit-date");
9956
+ const transitTimeStr = inputPayload?.transitTime ?? getFlagString(flags, "transit-time") ?? "12:00";
9957
+ const transitLatFlag = inputPayload?.transitLat != null ? Number(inputPayload.transitLat) : getFlagNumber(flags, "transit-lat");
9958
+ const transitLonFlag = inputPayload?.transitLon != null ? Number(inputPayload.transitLon) : getFlagNumber(flags, "transit-lon");
9959
+ const transitTzStr = inputPayload?.transitTimezone ?? getFlagString(flags, "transit-timezone");
9960
+ const maxOrbFlag = inputPayload?.maxOrb != null ? Number(inputPayload.maxOrb) : getFlagNumber(flags, "max-orb");
9961
+ const aspectsStr = inputPayload?.aspects ?? getFlagString(flags, "aspects");
9962
+ const transitPlanetsStr = inputPayload?.transitPlanets ?? getFlagString(flags, "transit-planets");
9963
+ const natalPlanetsStr = inputPayload?.natalPlanets ?? getFlagString(flags, "natal-planets");
9964
+ const fromStr = inputPayload?.from ?? getFlagString(flags, "from");
9965
+ const toStr = inputPayload?.to ?? getFlagString(flags, "to");
9966
+ const stepDaysFlag = inputPayload?.stepDays != null ? Number(inputPayload.stepDays) : getFlagNumber(flags, "step-days");
9967
+ if (stepDaysFlag != null && (isNaN(stepDaysFlag) || stepDaysFlag <= 0)) {
9968
+ exitWithError("INVALID_ARGUMENT", `--step-days must be a positive number, got "${stepDaysFlag}".`, flags);
9969
+ }
9970
+ let aspectFilter;
9971
+ if (aspectsStr) {
9972
+ const raw = Array.isArray(aspectsStr) ? aspectsStr : aspectsStr.split(",").map((s) => s.trim());
9973
+ aspectFilter = raw.flatMap((a) => a === "major" ? MAJOR_ASPECTS : [a]);
9974
+ }
9975
+ const transitPlanets = transitPlanetsStr ? Array.isArray(transitPlanetsStr) ? transitPlanetsStr : transitPlanetsStr.split(",").map((s) => s.trim().toLowerCase()) : void 0;
9976
+ const natalPlanets = natalPlanetsStr ? Array.isArray(natalPlanetsStr) ? natalPlanetsStr : natalPlanetsStr.split(",").map((s) => s.trim().toLowerCase()) : void 0;
9977
+ const natalOpts = buildBirthChartOptions(natalInput, HouseSystem2);
9978
+ const transitTz = transitTzStr ? { timeZone: transitTzStr } : void 0;
9979
+ const isRangeMode = fromStr != null;
9980
+ if (isRangeMode) {
9981
+ if (!toStr) {
9982
+ exitWithError("MISSING_ARGUMENT", "--to is required when --from is specified.", flags);
9983
+ }
9984
+ parseDate(fromStr, flags);
9985
+ parseDate(toStr, flags);
9986
+ const fromDate = /* @__PURE__ */ new Date(fromStr + "T00:00:00");
9987
+ const toDate = /* @__PURE__ */ new Date(toStr + "T23:59:59.999");
9988
+ debugLog("astrology", "Running astrology:transits (range mode).", {
9989
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr },
9990
+ from: fromStr,
9991
+ to: toStr,
9992
+ stepDays: stepDaysFlag ?? 1
9993
+ });
9994
+ const result = await getTransitRange2({
9995
+ natal: natalOpts,
9996
+ from: fromDate,
9997
+ to: toDate,
9998
+ stepDays: stepDaysFlag ?? void 0,
9999
+ transitLatitude: transitLatFlag ?? void 0,
10000
+ transitLongitude: transitLonFlag ?? void 0,
10001
+ transitTimeZoneSettings: transitTz,
10002
+ aspectSpecs: inputPayload?.aspectSpecs,
10003
+ maxOrb: maxOrbFlag ?? void 0,
10004
+ transitPlanets,
10005
+ natalPlanets,
10006
+ aspectFilter
10007
+ });
10008
+ executionContext.throwIfInterrupted();
10009
+ debugLog("astrology", "Completed astrology:transits (range).", {
10010
+ perfections: result.perfections.length
10011
+ });
10012
+ if (isJsonMode(flags)) {
10013
+ outputJson({
10014
+ ...result,
10015
+ input: {
10016
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr, lat: natalInput.latitude, lon: natalInput.longitude },
10017
+ from: fromStr,
10018
+ to: toStr,
10019
+ stepDays: stepDaysFlag ?? 1
10020
+ }
10021
+ }, flags);
10022
+ return;
10023
+ }
10024
+ console.log(`
10025
+ Transit Range: ${fromStr} to ${toStr}`);
10026
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})
10027
+ `);
10028
+ if (result.perfections.length === 0) {
10029
+ console.log(" No aspect perfections found in range.\n");
10030
+ } else {
10031
+ console.log(` Aspect Perfections (${result.perfections.length}):
10032
+ `);
10033
+ for (const p of result.perfections) {
10034
+ const date = p.exactDate.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, " UTC");
10035
+ const rx = p.retrograde ? " R" : "";
10036
+ console.log(
10037
+ ` ${date} ${p.transitPlanet.padEnd(14)}${rx.padEnd(3)} ${p.aspect.padEnd(12)} ${p.natalPlanet.padEnd(14)} orb ${p.exactOrb.toFixed(3)}\xB0 [${p.category}]`
10038
+ );
10039
+ }
10040
+ console.log();
10041
+ }
10042
+ } else {
10043
+ let transitDate;
10044
+ const effectiveTransitDateStr = transitDateStr ?? (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
10045
+ parseDate(effectiveTransitDateStr, flags);
10046
+ const { hour: tHour, minute: tMin } = parseTimeValue(transitTimeStr, flags, {
10047
+ invalidFormat: (v) => `Invalid transit time format: "${v}". Use HH:MM.`,
10048
+ invalidValue: (v) => `Invalid transit time: "${v}". Hours 0-23, minutes 0-59.`
10049
+ });
10050
+ transitDate = buildBirthDate(effectiveTransitDateStr, tHour, tMin);
10051
+ debugLog("astrology", "Running astrology:transits.", {
10052
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr },
10053
+ transitDate: transitDate.toISOString()
10054
+ });
10055
+ const result = await getTransitChart2({
10056
+ natal: natalOpts,
10057
+ transitDate,
10058
+ transitLatitude: transitLatFlag ?? void 0,
10059
+ transitLongitude: transitLonFlag ?? void 0,
10060
+ transitTimeZoneSettings: transitTz,
10061
+ aspectSpecs: inputPayload?.aspectSpecs,
10062
+ maxOrb: maxOrbFlag ?? void 0,
10063
+ transitPlanets,
10064
+ natalPlanets,
10065
+ aspectFilter
10066
+ });
10067
+ executionContext.throwIfInterrupted();
10068
+ debugLog("astrology", "Completed astrology:transits.", {
10069
+ transitPlanets: Object.keys(result.transitPlanets).length,
10070
+ aspects: result.aspects.length
10071
+ });
10072
+ if (isJsonMode(flags)) {
10073
+ outputJson({
10074
+ ...result,
10075
+ input: {
10076
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr, lat: natalInput.latitude, lon: natalInput.longitude },
10077
+ transitDate: transitDate.toISOString()
10078
+ }
10079
+ }, flags);
10080
+ return;
10081
+ }
10082
+ const tdStr = transitDateStr ?? transitDate.toISOString().split("T")[0];
10083
+ console.log(`
10084
+ Transit Chart for ${tdStr} ${transitTimeStr}`);
10085
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})
10086
+ `);
10087
+ console.log(" Transit Planets (in natal houses):");
10088
+ for (const [name, planet] of Object.entries(result.transitPlanets)) {
10089
+ const zp = planet.zodiacPosition;
10090
+ const rx = planet.retrograde ? " R" : " ";
10091
+ console.log(
10092
+ ` ${name.padEnd(14)}${rx} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} Natal House ${planet.natalHouse}`
10093
+ );
10094
+ }
10095
+ console.log(`
10096
+ Transit-to-Natal Aspects (${result.aspects.length}):
10097
+ `);
10098
+ for (const a of result.aspects) {
10099
+ const dir = a.applying ? "applying " : "separating";
10100
+ const rx = a.retrograde ? " R" : " ";
10101
+ console.log(
10102
+ ` ${a.planetA.padEnd(14)}${rx} ${a.aspect.padEnd(12)} ${a.planetB.padEnd(14)} orb ${a.orb.toFixed(2)}\xB0 ${dir} [${a.category}]`
10103
+ );
10104
+ }
10105
+ console.log();
10106
+ }
10107
+ } catch (err) {
10108
+ rethrowInterruptedOrError(err, executionContext);
10109
+ } finally {
10110
+ releaseSwissEphCleanup();
10111
+ closeSwissEph2();
10112
+ }
10113
+ }
10114
+ async function cmdAstrologySolarReturn(args, flags, inputPayload, executionContext) {
10115
+ const natalPayload = inputPayload?.natal;
10116
+ const effectiveArgs = natalPayload ? [] : args;
10117
+ const effectiveInputPayload = natalPayload ? { ...natalPayload } : inputPayload;
10118
+ const natalInput = await parseSingleChartRequest(effectiveArgs, flags, effectiveInputPayload, executionContext);
10119
+ const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
10120
+ const { getSolarReturnChart: getSolarReturnChart2, closeSwissEph: closeSwissEph2, HouseSystem: HouseSystem2 } = astroModule;
10121
+ const releaseSwissEphCleanup = executionContext.registerCleanup(() => {
10122
+ astroModule.closeSwissEph();
10123
+ });
10124
+ const runtimePaths = getAstrologyRuntimePaths(flags);
10125
+ try {
10126
+ await initWasm(runtimePaths, executionContext);
10127
+ } catch (err) {
10128
+ releaseSwissEphCleanup();
10129
+ closeSwissEph2();
10130
+ executionContext.throwIfInterrupted();
10131
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
10132
+ }
10133
+ try {
10134
+ const yearFlag = inputPayload?.year != null ? Number(inputPayload.year) : getFlagNumber(flags, "year");
10135
+ const year = yearFlag ?? (/* @__PURE__ */ new Date()).getFullYear();
10136
+ const srLatFlag = inputPayload?.srLat != null ? Number(inputPayload.srLat) : getFlagNumber(flags, "sr-lat");
10137
+ const srLonFlag = inputPayload?.srLon != null ? Number(inputPayload.srLon) : getFlagNumber(flags, "sr-lon");
10138
+ const srLocationStr = inputPayload?.srLocation ?? getFlagString(flags, "sr-location");
10139
+ const srHouseSystemStr = inputPayload?.srHouseSystem ?? getFlagString(flags, "sr-house-system");
10140
+ let srLat = srLatFlag;
10141
+ let srLon = srLonFlag;
10142
+ if (srLat == null || srLon == null) {
10143
+ if (srLocationStr) {
10144
+ const geocoded = await geocodeLocation(srLocationStr, flags, executionContext);
10145
+ srLat = geocoded.latitude;
10146
+ srLon = geocoded.longitude;
10147
+ }
10148
+ }
10149
+ const srHouseSystem = srHouseSystemStr ? parseHouseSystem(srHouseSystemStr, flags, (value, valid) => `Unknown SR house system: "${value}". Valid: ${valid.join(", ")}`).houseSystemCode : void 0;
10150
+ debugLog("astrology", "Running astrology:solar-return.", {
10151
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr },
10152
+ year,
10153
+ srLat,
10154
+ srLon
10155
+ });
10156
+ const result = await getSolarReturnChart2({
10157
+ natal: buildBirthChartOptions(natalInput, HouseSystem2),
10158
+ year,
10159
+ solarReturnLatitude: srLat ?? void 0,
10160
+ solarReturnLongitude: srLon ?? void 0,
10161
+ solarReturnHouseSystem: srHouseSystem
10162
+ });
10163
+ executionContext.throwIfInterrupted();
10164
+ debugLog("astrology", "Completed astrology:solar-return.", {
10165
+ exactReturnDate: result.exactReturnDate.toISOString(),
10166
+ natalSunLongitude: result.natalSunLongitude
10167
+ });
10168
+ if (isJsonMode(flags)) {
10169
+ outputJson({
10170
+ ...result,
10171
+ input: {
10172
+ natal: { date: natalInput.dateStr, time: natalInput.timeStr, lat: natalInput.latitude, lon: natalInput.longitude },
10173
+ year,
10174
+ srLat: srLat ?? natalInput.latitude,
10175
+ srLon: srLon ?? natalInput.longitude
10176
+ }
10177
+ }, flags);
10178
+ return;
10179
+ }
10180
+ const srChart = result.solarReturnChart;
10181
+ const natalSun = result.natalChart.planets.sun.zodiacPosition;
10182
+ const returnDateStr = result.exactReturnDate.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, " UTC");
10183
+ console.log(`
10184
+ Solar Return ${year}
10185
+ `);
10186
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})`);
10187
+ console.log(` Natal Sun: ${natalSun.sign} ${natalSun.traditionalFormat} (${result.natalSunLongitude.toFixed(4)}\xB0)`);
10188
+ console.log(` Exact Return: ${returnDateStr}`);
10189
+ console.log(` SR Sun: ${srChart.planets.sun.zodiacPosition.sign} ${srChart.planets.sun.zodiacPosition.traditionalFormat} (${srChart.planets.sun.longitude.toFixed(4)}\xB0)`);
10190
+ console.log(`
10191
+ Solar Return Planets:`);
10192
+ for (const [name, planet] of Object.entries(srChart.planets)) {
10193
+ const zp = planet.zodiacPosition;
10194
+ console.log(` ${name.padEnd(14)} ${zp.sign.padEnd(12)} ${zp.traditionalFormat.padEnd(8)} House ${zp.house}`);
10195
+ }
10196
+ console.log(`
10197
+ Solar Return Houses:`);
10198
+ console.log(` Ascendant: ${srChart.houses.ascendant.sign} ${srChart.houses.ascendant.traditionalFormat}`);
10199
+ console.log(` Midheaven: ${srChart.houses.mc.sign} ${srChart.houses.mc.traditionalFormat}`);
10200
+ console.log(` Descendant: ${srChart.houses.dc.sign} ${srChart.houses.dc.traditionalFormat}`);
10201
+ console.log(` IC: ${srChart.houses.ic.sign} ${srChart.houses.ic.traditionalFormat}`);
10202
+ console.log(`
10203
+ House Cusps:`);
10204
+ for (let i = 0; i < srChart.houses.houses.length; i++) {
10205
+ const house = srChart.houses.houses[i];
10206
+ console.log(` House ${String(i + 1).padStart(2)}: ${house.sign.padEnd(12)} ${house.traditionalFormat}`);
10207
+ }
10208
+ console.log(`
10209
+ Solar Return Aspects (${srChart.aspects.length}):
10210
+ `);
10211
+ for (const aspect of srChart.aspects) {
10212
+ console.log(` ${aspect.planetA.padEnd(14)} ${aspect.aspect.padEnd(12)} ${aspect.planetB.padEnd(14)} orb ${aspect.orb.toFixed(2)}\xB0`);
10213
+ }
10214
+ console.log();
10215
+ } catch (err) {
10216
+ rethrowInterruptedOrError(err, executionContext);
10217
+ } finally {
10218
+ releaseSwissEphCleanup();
10219
+ closeSwissEph2();
10220
+ }
10221
+ }
10222
+ async function cmdAstrologyProfections(args, flags, inputPayload, executionContext) {
10223
+ const natalPayload = inputPayload?.natal;
10224
+ const effectiveArgs = natalPayload ? [] : args;
10225
+ const effectiveInputPayload = natalPayload ? { ...natalPayload } : inputPayload;
10226
+ const natalInput = await parseSingleChartRequest(effectiveArgs, flags, effectiveInputPayload, executionContext);
10227
+ const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
10228
+ const { getBirthChart: getBirthChart2, getAnnualProfection: getAnnualProfection2, closeSwissEph: closeSwissEph2, HouseSystem: HouseSystem2 } = astroModule;
10229
+ const releaseSwissEphCleanup = executionContext.registerCleanup(() => {
10230
+ astroModule.closeSwissEph();
10231
+ });
10232
+ const runtimePaths = getAstrologyRuntimePaths(flags);
10233
+ try {
10234
+ await initWasm(runtimePaths, executionContext);
10235
+ } catch (err) {
10236
+ releaseSwissEphCleanup();
10237
+ closeSwissEph2();
10238
+ executionContext.throwIfInterrupted();
10239
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
10240
+ }
10241
+ try {
10242
+ const yearFlag = inputPayload?.year != null ? Number(inputPayload.year) : getFlagNumber(flags, "year");
10243
+ const year = yearFlag ?? (/* @__PURE__ */ new Date()).getFullYear();
10244
+ const chart = await getBirthChart2({
10245
+ date: natalInput.birthDate,
10246
+ latitude: natalInput.latitude,
10247
+ longitude: natalInput.longitude,
10248
+ houseSystem: HouseSystem2.WHOLE_SIGN,
10249
+ timeZoneSettings: natalInput.timeZoneSettings
10250
+ });
10251
+ executionContext.throwIfInterrupted();
10252
+ const result = getAnnualProfection2(chart, chart.dateUtc, year);
10253
+ if (isJsonMode(flags)) {
10254
+ outputJson({
10255
+ ...result,
10256
+ input: {
10257
+ date: natalInput.dateStr,
10258
+ time: natalInput.timeStr,
10259
+ lat: natalInput.latitude,
10260
+ lon: natalInput.longitude,
10261
+ year
10262
+ }
10263
+ }, flags);
10264
+ return;
10265
+ }
10266
+ console.log(`
10267
+ Annual Profection (${year})
10268
+ `);
10269
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})`);
10270
+ console.log(` Age: ${result.age}`);
10271
+ console.log(` Profected House: ${result.house}`);
10272
+ console.log(` Sign: ${result.sign}`);
10273
+ console.log(` Time Lord: ${result.ruler}`);
10274
+ console.log();
10275
+ } catch (err) {
10276
+ rethrowInterruptedOrError(err, executionContext);
10277
+ } finally {
10278
+ releaseSwissEphCleanup();
10279
+ closeSwissEph2();
10280
+ }
10281
+ }
10282
+ async function cmdAstrologyProfectionsMonthly(args, flags, inputPayload, executionContext) {
10283
+ const natalPayload = inputPayload?.natal;
10284
+ const effectiveArgs = natalPayload ? [] : args;
10285
+ const effectiveInputPayload = natalPayload ? { ...natalPayload } : inputPayload;
10286
+ const natalInput = await parseSingleChartRequest(effectiveArgs, flags, effectiveInputPayload, executionContext);
10287
+ const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
10288
+ const { getBirthChart: getBirthChart2, getMonthlyProfections: getMonthlyProfections2, closeSwissEph: closeSwissEph2, HouseSystem: HouseSystem2 } = astroModule;
10289
+ const releaseSwissEphCleanup = executionContext.registerCleanup(() => {
10290
+ astroModule.closeSwissEph();
10291
+ });
10292
+ const runtimePaths = getAstrologyRuntimePaths(flags);
10293
+ try {
10294
+ await initWasm(runtimePaths, executionContext);
10295
+ } catch (err) {
10296
+ releaseSwissEphCleanup();
10297
+ closeSwissEph2();
10298
+ executionContext.throwIfInterrupted();
10299
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
10300
+ }
10301
+ try {
10302
+ const yearFlag = inputPayload?.year != null ? Number(inputPayload.year) : getFlagNumber(flags, "year");
10303
+ const year = yearFlag ?? (/* @__PURE__ */ new Date()).getFullYear();
10304
+ const chart = await getBirthChart2({
10305
+ date: natalInput.birthDate,
10306
+ latitude: natalInput.latitude,
10307
+ longitude: natalInput.longitude,
10308
+ houseSystem: HouseSystem2.WHOLE_SIGN,
10309
+ timeZoneSettings: natalInput.timeZoneSettings
10310
+ });
10311
+ executionContext.throwIfInterrupted();
10312
+ const result = getMonthlyProfections2(chart, chart.dateUtc, year);
10313
+ if (isJsonMode(flags)) {
10314
+ outputJson({
10315
+ ...result,
10316
+ input: {
10317
+ date: natalInput.dateStr,
10318
+ time: natalInput.timeStr,
10319
+ lat: natalInput.latitude,
10320
+ lon: natalInput.longitude,
10321
+ year
10322
+ }
10323
+ }, flags);
10324
+ return;
10325
+ }
10326
+ const ap = result.annualProfection;
10327
+ console.log(`
10328
+ Monthly Profections (${year})
10329
+ `);
10330
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})`);
10331
+ console.log(` Annual: House ${ap.house}, ${ap.sign} (${ap.ruler}), Age ${ap.age}
10332
+ `);
10333
+ for (const m of result.months) {
10334
+ const dateStr = m.startDate.toISOString().split("T")[0];
10335
+ console.log(` Month ${String(m.month).padStart(2)}: ${dateStr} ${m.sign.padEnd(12)} ${m.ruler}`);
10336
+ }
10337
+ console.log();
10338
+ } catch (err) {
10339
+ rethrowInterruptedOrError(err, executionContext);
10340
+ } finally {
10341
+ releaseSwissEphCleanup();
10342
+ closeSwissEph2();
10343
+ }
10344
+ }
10345
+ async function cmdAstrologyFirdaria(args, flags, inputPayload, executionContext) {
10346
+ const natalPayload = inputPayload?.natal;
10347
+ const effectiveArgs = natalPayload ? [] : args;
10348
+ const effectiveInputPayload = natalPayload ? { ...natalPayload } : inputPayload;
10349
+ const natalInput = await parseSingleChartRequest(effectiveArgs, flags, effectiveInputPayload, executionContext);
10350
+ const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
10351
+ const { getBirthChart: getBirthChart2, getFirdaria: getFirdaria2, closeSwissEph: closeSwissEph2, HouseSystem: HouseSystem2 } = astroModule;
10352
+ const releaseSwissEphCleanup = executionContext.registerCleanup(() => {
10353
+ astroModule.closeSwissEph();
10354
+ });
10355
+ const runtimePaths = getAstrologyRuntimePaths(flags);
10356
+ try {
10357
+ await initWasm(runtimePaths, executionContext);
10358
+ } catch (err) {
10359
+ releaseSwissEphCleanup();
10360
+ closeSwissEph2();
10361
+ executionContext.throwIfInterrupted();
10362
+ exitWithError("WASM_INIT_ERROR", `Failed to initialize Swiss Ephemeris: ${err instanceof Error ? err.message : String(err)}`, flags);
10363
+ }
10364
+ try {
10365
+ const chart = await getBirthChart2(buildBirthChartOptions(natalInput, HouseSystem2));
10366
+ executionContext.throwIfInterrupted();
10367
+ const sectOverride = inputPayload?.sect ?? getFlagString(flags, "sect");
10368
+ let isDiurnal;
10369
+ if (sectOverride === "diurnal") {
10370
+ isDiurnal = true;
10371
+ } else if (sectOverride === "nocturnal") {
10372
+ isDiurnal = false;
10373
+ } else if (sectOverride) {
10374
+ exitWithError("INVALID_ARGUMENT", `Invalid sect value: "${sectOverride}". Use "diurnal" or "nocturnal".`, flags);
10375
+ } else {
10376
+ isDiurnal = chart.sect === "diurnal";
10377
+ }
10378
+ const targetDateStr = inputPayload?.targetDate ?? getFlagString(flags, "target-date");
10379
+ let targetDate;
10380
+ if (targetDateStr) {
10381
+ parseDate(targetDateStr, flags);
10382
+ targetDate = /* @__PURE__ */ new Date(targetDateStr + "T12:00:00");
10383
+ }
10384
+ const result = getFirdaria2(chart.dateUtc, isDiurnal, targetDate);
10385
+ if (isJsonMode(flags)) {
10386
+ outputJson({
10387
+ ...result,
10388
+ input: {
10389
+ date: natalInput.dateStr,
10390
+ time: natalInput.timeStr,
10391
+ lat: natalInput.latitude,
10392
+ lon: natalInput.longitude,
10393
+ sect: isDiurnal ? "diurnal" : "nocturnal",
10394
+ targetDate: targetDateStr ?? "today"
10395
+ }
10396
+ }, flags);
10397
+ return;
10398
+ }
10399
+ console.log(`
10400
+ Firdaria (${isDiurnal ? "Diurnal" : "Nocturnal"})
10401
+ `);
10402
+ console.log(` Natal: ${natalInput.dateStr} ${natalInput.timeStr} (${natalInput.latitude}, ${natalInput.longitude})`);
10403
+ console.log(` Current Major: ${result.currentMajor.planet} (${result.currentMajor.years}y)`);
10404
+ console.log(` Current Sub: ${result.currentSub.planet}`);
10405
+ console.log(`
10406
+ All Periods:
10407
+ `);
10408
+ for (const p of result.allPeriods) {
10409
+ const start = p.startDate.toISOString().split("T")[0];
10410
+ const end = p.endDate.toISOString().split("T")[0];
10411
+ const marker = p === result.currentMajor ? " <--" : "";
10412
+ console.log(` ${p.planet.padEnd(12)} ${start} to ${end} (${p.years}y)${marker}`);
10413
+ }
10414
+ console.log();
10415
+ } catch (err) {
10416
+ rethrowInterruptedOrError(err, executionContext);
10417
+ } finally {
10418
+ releaseSwissEphCleanup();
10419
+ closeSwissEph2();
10420
+ }
10421
+ }
10422
+ function cmdAstrologyDecans(args, flags, inputPayload) {
10423
+ const lonStr = inputPayload?.longitude ?? args[0];
10424
+ if (lonStr == null) {
10425
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah astrology:decans <longitude>", flags);
10426
+ }
10427
+ const longitude = Number(lonStr);
10428
+ if (isNaN(longitude)) {
10429
+ exitWithError("INVALID_ARGUMENT", `Invalid longitude: "${lonStr}". Must be a number.`, flags);
10430
+ }
10431
+ const { getDecan: getDecan2 } = (init_astrology(), __toCommonJS(astrology_exports));
10432
+ const result = getDecan2(longitude);
10433
+ if (isJsonMode(flags)) {
10434
+ outputJson(result, flags);
10435
+ return;
10436
+ }
10437
+ console.log(`
10438
+ Decan for ${longitude}\xB0
10439
+ `);
10440
+ console.log(` Sign: ${result.sign}`);
10441
+ console.log(` Decan: ${result.decanNumber}`);
10442
+ console.log(` Ruler: ${result.ruler}`);
10443
+ console.log(` Tarot: ${result.tarotCard}`);
10444
+ console.log(` Range: ${result.startDegree}\xB0 \u2013 ${result.endDegree}\xB0`);
10445
+ console.log();
10446
+ }
10447
+ function cmdAstrologyDodecatemoria(args, flags, inputPayload) {
10448
+ const lonStr = inputPayload?.longitude ?? args[0];
10449
+ if (lonStr == null) {
10450
+ exitWithError("MISSING_ARGUMENT", "Usage: kaabalah astrology:dodecatemoria <longitude>", flags);
10451
+ }
10452
+ const longitude = Number(lonStr);
10453
+ if (isNaN(longitude)) {
10454
+ exitWithError("INVALID_ARGUMENT", `Invalid longitude: "${lonStr}". Must be a number.`, flags);
10455
+ }
10456
+ const { getDodecatemoria: getDodecatemoria2 } = (init_astrology(), __toCommonJS(astrology_exports));
10457
+ const result = getDodecatemoria2(longitude);
10458
+ if (isJsonMode(flags)) {
10459
+ outputJson(result, flags);
10460
+ return;
10461
+ }
10462
+ console.log(`
10463
+ Dodecatemoria for ${longitude}\xB0
10464
+ `);
10465
+ console.log(` Original Sign: ${result.originalSign} (${result.originalDegree.toFixed(2)}\xB0)`);
10466
+ console.log(` 12th Part: ${result.dodecatemoriaSign} (index ${result.dodecatemoriaIndex})`);
10467
+ console.log();
10468
+ }
9102
10469
  async function cmdAstrology(args, flags, inputPayload, executionContext) {
9103
10470
  const input = await parseSingleChartRequest(args, flags, inputPayload, executionContext);
9104
10471
  const astroModule = await Promise.resolve().then(() => (init_astrology(), astrology_exports));
@@ -19085,6 +20452,27 @@ async function runCli(argv) {
19085
20452
  case "astrology:composite":
19086
20453
  await cmdAstrologyComposite(flags, inputPayload, execution);
19087
20454
  return;
20455
+ case "astrology:transits":
20456
+ await cmdAstrologyTransits(args.slice(1), flags, inputPayload, execution);
20457
+ return;
20458
+ case "astrology:solar-return":
20459
+ await cmdAstrologySolarReturn(args.slice(1), flags, inputPayload, execution);
20460
+ return;
20461
+ case "astrology:profections":
20462
+ await cmdAstrologyProfections(args.slice(1), flags, inputPayload, execution);
20463
+ return;
20464
+ case "astrology:profections:monthly":
20465
+ await cmdAstrologyProfectionsMonthly(args.slice(1), flags, inputPayload, execution);
20466
+ return;
20467
+ case "astrology:firdaria":
20468
+ await cmdAstrologyFirdaria(args.slice(1), flags, inputPayload, execution);
20469
+ return;
20470
+ case "astrology:decans":
20471
+ cmdAstrologyDecans(args.slice(1), flags, inputPayload);
20472
+ return;
20473
+ case "astrology:dodecatemoria":
20474
+ cmdAstrologyDodecatemoria(args.slice(1), flags, inputPayload);
20475
+ return;
19088
20476
  default:
19089
20477
  exitWithError("UNKNOWN_COMMAND", `Unknown command: "${command}". Run "kaabalah help" for usage.`, flags);
19090
20478
  }