@zodiacs/engine 0.1.1-rc.14 → 0.1.1-rc.16
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/CHANGELOG.md +797 -6
- package/LICENSING.md +354 -21
- package/NOTICE +166 -9
- package/README.md +327 -84
- package/dist/api-VOW6Umy5.d.ts +197 -0
- package/dist/calc.d.ts +279 -0
- package/dist/calc.js +853 -0
- package/dist/{chunk-NAJ735VN.js → chunk-2OWGBT3O.js} +1 -1
- package/dist/{chunk-4OSOCZY2.js → chunk-4NV4ZEFZ.js} +21 -6
- package/dist/chunk-A3U2ZS2W.js +29 -0
- package/dist/chunk-I7O5EGFV.js +25 -0
- package/dist/chunk-KFTJMMG7.js +61 -0
- package/dist/chunk-KHBLFXFG.js +227 -0
- package/dist/chunk-L6ZHWJZ6.js +355 -0
- package/dist/chunk-N4B5JNMA.js +473 -0
- package/dist/chunk-O3NJRGJ2.js +56 -0
- package/dist/{chunk-RETEVD4F.js → chunk-WOU7JVD3.js} +293 -154
- package/dist/crossings.d.ts +1 -1
- package/dist/deltat.d.ts +8 -8
- package/dist/geo.d.ts +137 -8
- package/dist/geo.js +28 -166
- package/dist/houses-extra.d.ts +81 -0
- package/dist/houses-extra.js +337 -0
- package/dist/houses-q1O2GGp4.d.ts +128 -0
- package/dist/index.d.ts +8 -201
- package/dist/index.js +38 -315
- package/dist/internal-math-CmJ9xtaW.d.ts +160 -0
- package/dist/internal-math.d.ts +3 -2
- package/dist/internal-math.js +2 -2
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +4 -4
- package/dist/receipt.d.ts +74 -29
- package/dist/receipt.js +194 -33
- package/dist/rulers-9wljfVaO.d.ts +10 -0
- package/dist/sky.d.ts +158 -0
- package/dist/sky.js +377 -0
- package/dist/techniques.d.ts +410 -0
- package/dist/techniques.js +830 -0
- package/dist/timing.d.ts +473 -0
- package/dist/timing.js +904 -0
- package/dist/{types-CeafogFp.d.ts → types-B4MCoCCS.d.ts} +35 -4
- package/dist/tzdb-2025c-00-6GVG6RYL.js +6 -0
- package/dist/tzdb-2025c-01-CEYMG3LE.js +6 -0
- package/dist/tzdb-2025c-02-NWQJCVUU.js +6 -0
- package/dist/tzdb-2025c-03-PLHP6VH4.js +6 -0
- package/dist/tzdb-2025c-04-MEKUJA6M.js +6 -0
- package/dist/tzdb-2025c-05-3K5YKZBL.js +6 -0
- package/dist/tzdb-2025c-06-L2VV5XJV.js +6 -0
- package/dist/tzdb-2025c-07-H3GLGJGY.js +6 -0
- package/dist/tzdb-2025c-08-DA7QQIGD.js +6 -0
- package/dist/tzdb-2025c-09-MTXIO3QL.js +6 -0
- package/dist/tzdb-2025c-10-ASL4UW5C.js +6 -0
- package/dist/tzdb-2025c-11-EQEOANYB.js +6 -0
- package/dist/tzdb-2025c-12-NKCCXJ5G.js +6 -0
- package/dist/tzdb-2025c-13-DYTF3UC7.js +6 -0
- package/dist/tzdb-2025c-14-C25H45R5.js +6 -0
- package/dist/tzdb-2025c-15-7OYYZWRY.js +6 -0
- package/dist/vedic.d.ts +393 -0
- package/dist/vedic.js +930 -0
- package/dist/window.d.ts +178 -0
- package/dist/window.js +961 -0
- package/package.json +31 -3
- package/dist/chunk-GFT24GFR.js +0 -25
- package/dist/internal-math-BE2hcSHd.d.ts +0 -271
package/dist/timing.js
ADDED
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHALDEAN_ORDER,
|
|
3
|
+
TRADITIONAL_RULERS
|
|
4
|
+
} from "./chunk-A3U2ZS2W.js";
|
|
5
|
+
import {
|
|
6
|
+
PROGRESSION_DAYS_PER_YEAR,
|
|
7
|
+
progressedBodies,
|
|
8
|
+
progressedInstant
|
|
9
|
+
} from "./chunk-I7O5EGFV.js";
|
|
10
|
+
import {
|
|
11
|
+
chartDeclinations,
|
|
12
|
+
chartPoints,
|
|
13
|
+
findLongitudeCrossings,
|
|
14
|
+
resolvedChart,
|
|
15
|
+
searchLongitudeCrossings,
|
|
16
|
+
utcOf
|
|
17
|
+
} from "./chunk-L6ZHWJZ6.js";
|
|
18
|
+
import {
|
|
19
|
+
dateFrom
|
|
20
|
+
} from "./chunk-CPALRSPC.js";
|
|
21
|
+
import "./chunk-AECKV73C.js";
|
|
22
|
+
import "./chunk-PFGUCNOK.js";
|
|
23
|
+
import {
|
|
24
|
+
bodyLongitude
|
|
25
|
+
} from "./chunk-WOU7JVD3.js";
|
|
26
|
+
import {
|
|
27
|
+
outsideReferenceSpan
|
|
28
|
+
} from "./chunk-KHBLFXFG.js";
|
|
29
|
+
import "./chunk-ONBZ4HK7.js";
|
|
30
|
+
import "./chunk-4NV4ZEFZ.js";
|
|
31
|
+
import {
|
|
32
|
+
SIGN_NAMES,
|
|
33
|
+
degreeInSign,
|
|
34
|
+
normalizeLongitude,
|
|
35
|
+
signForLongitude,
|
|
36
|
+
signIndexForLongitude
|
|
37
|
+
} from "./chunk-2OWGBT3O.js";
|
|
38
|
+
|
|
39
|
+
// src/timing/shared.ts
|
|
40
|
+
var DAY_MS = 864e5;
|
|
41
|
+
var MAX_DATE_MS = 864e13;
|
|
42
|
+
function readOptions(value, allowed, label) {
|
|
43
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
44
|
+
if (value === void 0) return out;
|
|
45
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
46
|
+
throw new RangeError(`${label} must be an options object.`);
|
|
47
|
+
}
|
|
48
|
+
const prototype = Object.getPrototypeOf(value);
|
|
49
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
50
|
+
throw new RangeError(`${label} must be a plain options object.`);
|
|
51
|
+
}
|
|
52
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
53
|
+
if (typeof key !== "string" || !allowed.includes(key)) {
|
|
54
|
+
throw new RangeError(`${label} has an unknown option: ${String(key)}.`);
|
|
55
|
+
}
|
|
56
|
+
const slot = Object.getOwnPropertyDescriptor(value, key);
|
|
57
|
+
if (!slot || !("value" in slot) || !slot.enumerable) {
|
|
58
|
+
throw new RangeError(`${label} must contain only plain data properties.`);
|
|
59
|
+
}
|
|
60
|
+
if (slot.value !== void 0) out[key] = slot.value;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function oneOf(value, allowed, fallback, label) {
|
|
65
|
+
if (value === void 0) return fallback;
|
|
66
|
+
if (typeof value === "string" && allowed.includes(value)) return value;
|
|
67
|
+
throw new RangeError(`${label} must be one of ${allowed.map((name) => `"${name}"`).join(", ")}.`);
|
|
68
|
+
}
|
|
69
|
+
function integerIn(value, minimum, maximum, label) {
|
|
70
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > maximum) {
|
|
71
|
+
throw new RangeError(`${label} must be an integer from ${minimum} to ${maximum}.`);
|
|
72
|
+
}
|
|
73
|
+
return value === 0 ? 0 : value;
|
|
74
|
+
}
|
|
75
|
+
function startSign(value, label) {
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
const index = SIGN_NAMES.indexOf(value);
|
|
78
|
+
if (index >= 0) return { index, lon: null };
|
|
79
|
+
} else if (typeof value === "number" && Number.isFinite(value)) {
|
|
80
|
+
const lon = normalizeLongitude(value);
|
|
81
|
+
return { index: signIndexForLongitude(lon), lon };
|
|
82
|
+
}
|
|
83
|
+
throw new RangeError(`${label} must be a lowercase zodiac sign name or a finite longitude in degrees.`);
|
|
84
|
+
}
|
|
85
|
+
function originOf(index, lon, point) {
|
|
86
|
+
return Object.freeze({ point, lon, sign: signAt(index) });
|
|
87
|
+
}
|
|
88
|
+
function signAt(index) {
|
|
89
|
+
const sign = SIGN_NAMES[(index % 12 + 12) % 12];
|
|
90
|
+
if (sign === void 0) throw new RangeError("Could not resolve zodiac sign.");
|
|
91
|
+
return sign;
|
|
92
|
+
}
|
|
93
|
+
function placeFrom(offset) {
|
|
94
|
+
return (offset % 12 + 12) % 12 + 1;
|
|
95
|
+
}
|
|
96
|
+
function natalContext(source) {
|
|
97
|
+
return guarded(() => {
|
|
98
|
+
const { chart } = resolvedChart(source);
|
|
99
|
+
return { chart, points: chartPoints(chart), birth: utcOf(chart.input) };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var DEG = Math.PI / 180;
|
|
103
|
+
function sectContradictsAltitude(chart, points) {
|
|
104
|
+
const latitude = chart.input.latitude;
|
|
105
|
+
const sun = chart.bodies.find((body) => body.body === "Sun");
|
|
106
|
+
if (points.sect === null || chart.angles === null || latitude === void 0 || !sun) return false;
|
|
107
|
+
const e = chartDeclinations(chart).trueObliquity * DEG;
|
|
108
|
+
const mc = chart.angles.mc * DEG;
|
|
109
|
+
const lon = sun.lon * DEG;
|
|
110
|
+
const hourAngle = Math.atan2(Math.sin(mc) * Math.cos(e), Math.cos(mc)) - Math.atan2(Math.sin(lon) * Math.cos(e), Math.cos(lon));
|
|
111
|
+
const dec = Math.asin(Math.sin(e) * Math.sin(lon));
|
|
112
|
+
const phi = latitude * DEG;
|
|
113
|
+
const sinAltitude = Math.sin(phi) * Math.sin(dec) + Math.cos(phi) * Math.cos(dec) * Math.cos(hourAngle);
|
|
114
|
+
return sinAltitude > 0 !== (points.sect === "day");
|
|
115
|
+
}
|
|
116
|
+
function timingFlags(instants, sectContradicted) {
|
|
117
|
+
const flags = [];
|
|
118
|
+
if (instants.some((milliseconds) => outsideReferenceSpan(new Date(milliseconds)))) {
|
|
119
|
+
flags.push("outside-reference-span");
|
|
120
|
+
}
|
|
121
|
+
if (sectContradicted) flags.push("sect-contradicts-altitude");
|
|
122
|
+
return Object.freeze(flags);
|
|
123
|
+
}
|
|
124
|
+
function chartLongitudes(chart, points) {
|
|
125
|
+
const rows = chart.bodies.map((body) => ({
|
|
126
|
+
name: body.body,
|
|
127
|
+
kind: "body",
|
|
128
|
+
lon: normalizeLongitude(body.lon)
|
|
129
|
+
}));
|
|
130
|
+
if (chart.angles) {
|
|
131
|
+
const { asc, mc, dsc, ic } = chart.angles;
|
|
132
|
+
rows.push(
|
|
133
|
+
{ name: "Ascendant", kind: "angle", lon: normalizeLongitude(asc) },
|
|
134
|
+
{ name: "Midheaven", kind: "angle", lon: normalizeLongitude(mc) },
|
|
135
|
+
{ name: "Descendant", kind: "angle", lon: normalizeLongitude(dsc) },
|
|
136
|
+
{ name: "Imum Coeli", kind: "angle", lon: normalizeLongitude(ic) }
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
for (const point of points.points) {
|
|
140
|
+
rows.push({ name: point.point, kind: "point", lon: normalizeLongitude(point.lon) });
|
|
141
|
+
}
|
|
142
|
+
return rows;
|
|
143
|
+
}
|
|
144
|
+
var LONGITUDE_NAMES = [
|
|
145
|
+
"Sun",
|
|
146
|
+
"Moon",
|
|
147
|
+
"Mercury",
|
|
148
|
+
"Venus",
|
|
149
|
+
"Mars",
|
|
150
|
+
"Jupiter",
|
|
151
|
+
"Saturn",
|
|
152
|
+
"Uranus",
|
|
153
|
+
"Neptune",
|
|
154
|
+
"Pluto",
|
|
155
|
+
"North Node",
|
|
156
|
+
"South Node",
|
|
157
|
+
"Ascendant",
|
|
158
|
+
"Midheaven",
|
|
159
|
+
"Descendant",
|
|
160
|
+
"Imum Coeli",
|
|
161
|
+
"Mean Node",
|
|
162
|
+
"Mean South Node",
|
|
163
|
+
"Black Moon Lilith",
|
|
164
|
+
"Vertex",
|
|
165
|
+
"East Point",
|
|
166
|
+
"Lot of Fortune",
|
|
167
|
+
"Lot of Spirit",
|
|
168
|
+
"Lot of Eros",
|
|
169
|
+
"Lot of Necessity",
|
|
170
|
+
"Lot of Courage",
|
|
171
|
+
"Lot of Victory",
|
|
172
|
+
"Lot of Nemesis"
|
|
173
|
+
];
|
|
174
|
+
function longitudeName(value, label) {
|
|
175
|
+
if (typeof value === "string" && LONGITUDE_NAMES.includes(value)) return value;
|
|
176
|
+
throw new RangeError(`${label} must name a body, an angle or a chart point.`);
|
|
177
|
+
}
|
|
178
|
+
function chartLongitude(chart, points, name, label) {
|
|
179
|
+
const row = chartLongitudes(chart, points).find((candidate) => candidate.name === name);
|
|
180
|
+
if (row) return row;
|
|
181
|
+
throw new RangeError(`${label} "${name}" needs a chart with a birth time and place.`);
|
|
182
|
+
}
|
|
183
|
+
function guarded(run) {
|
|
184
|
+
try {
|
|
185
|
+
return run();
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error instanceof Error) throw error;
|
|
188
|
+
throw new RangeError(`The ephemeris failed: ${String(error)}`, { cause: error });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function dateAt(milliseconds, label) {
|
|
192
|
+
if (!Number.isFinite(milliseconds) || Math.abs(milliseconds) > MAX_DATE_MS) {
|
|
193
|
+
throw new RangeError(`${label} falls outside the range of a JavaScript Date.`);
|
|
194
|
+
}
|
|
195
|
+
return new Date(milliseconds);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/timing/solar-years.ts
|
|
199
|
+
var RETURN_WINDOW_DAYS = 3;
|
|
200
|
+
var STEP_DAYS = 1;
|
|
201
|
+
function solarYears(birth) {
|
|
202
|
+
const birthMs = birth.getTime();
|
|
203
|
+
const natalSun = normalizeLongitude(guarded(() => bodyLongitude("Sun", birth)));
|
|
204
|
+
const cache = /* @__PURE__ */ new Map([[0, birthMs]]);
|
|
205
|
+
const sunReaches = (longitude, around, halfWindowDays) => {
|
|
206
|
+
const from = around - halfWindowDays * DAY_MS;
|
|
207
|
+
const to = around + halfWindowDays * DAY_MS;
|
|
208
|
+
if (!(Math.abs(from) <= MAX_DATE_MS && Math.abs(to) <= MAX_DATE_MS)) {
|
|
209
|
+
throw new RangeError("A solar return falls outside the range of a JavaScript Date.");
|
|
210
|
+
}
|
|
211
|
+
const crossings = guarded(() => findLongitudeCrossings("Sun", longitude, new Date(from), new Date(to), STEP_DAYS));
|
|
212
|
+
const first = crossings[0];
|
|
213
|
+
if (crossings.length !== 1 || first === void 0) {
|
|
214
|
+
throw new RangeError(`Could not isolate the Sun's passage through ${longitude}\xB0.`);
|
|
215
|
+
}
|
|
216
|
+
return first.at.getTime();
|
|
217
|
+
};
|
|
218
|
+
const returnMs = (n) => {
|
|
219
|
+
const known = cache.get(n);
|
|
220
|
+
if (known !== void 0) return known;
|
|
221
|
+
if (!Number.isSafeInteger(n) || n < 0) throw new RangeError("A solar return number must be a non-negative integer.");
|
|
222
|
+
const found = sunReaches(natalSun, birthMs + n * PROGRESSION_DAYS_PER_YEAR * DAY_MS, RETURN_WINDOW_DAYS);
|
|
223
|
+
cache.set(n, found);
|
|
224
|
+
return found;
|
|
225
|
+
};
|
|
226
|
+
const yearAt = (milliseconds) => {
|
|
227
|
+
if (milliseconds < birthMs) throw new RangeError("The date must not precede the birth instant.");
|
|
228
|
+
let age = Math.max(0, Math.floor((milliseconds - birthMs) / (PROGRESSION_DAYS_PER_YEAR * DAY_MS)));
|
|
229
|
+
while (age > 0 && milliseconds < returnMs(age)) age -= 1;
|
|
230
|
+
while (milliseconds >= returnMs(age + 1)) age += 1;
|
|
231
|
+
return { age, start: returnMs(age), end: returnMs(age + 1) };
|
|
232
|
+
};
|
|
233
|
+
const instantOf2 = (age) => {
|
|
234
|
+
if (!Number.isFinite(age) || age < 0) throw new RangeError("An age must be finite and non-negative.");
|
|
235
|
+
const whole = Math.floor(age);
|
|
236
|
+
const fraction = age - whole;
|
|
237
|
+
const start = returnMs(whole);
|
|
238
|
+
if (fraction === 0) return start;
|
|
239
|
+
return Math.round(start + fraction * (returnMs(whole + 1) - start));
|
|
240
|
+
};
|
|
241
|
+
return { birthMs, natalSun, returnMs, yearAt, instantOf: instantOf2, sunReaches };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/timing/profections.ts
|
|
245
|
+
var PROFECTION_MONTH_CONVENTIONS = /* @__PURE__ */ Object.freeze([
|
|
246
|
+
"solar",
|
|
247
|
+
"twelfths",
|
|
248
|
+
"thirteenths"
|
|
249
|
+
]);
|
|
250
|
+
var DEFAULT_PROFECTION_MONTHS = "solar";
|
|
251
|
+
function annualProfection(origin, age) {
|
|
252
|
+
const start = startSign(origin, "origin");
|
|
253
|
+
const years = integerIn(age, 0, Number.MAX_SAFE_INTEGER, "age");
|
|
254
|
+
const sign = signAt(start.index + years % 12);
|
|
255
|
+
return Object.freeze({
|
|
256
|
+
age: years,
|
|
257
|
+
origin: originOf(start.index, start.lon, null),
|
|
258
|
+
sign,
|
|
259
|
+
ruler: TRADITIONAL_RULERS[sign],
|
|
260
|
+
house: placeFrom(years)
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
var CONVENTION_CACHE = /* @__PURE__ */ new Map();
|
|
264
|
+
function conventionsFor(months) {
|
|
265
|
+
let found = CONVENTION_CACHE.get(months);
|
|
266
|
+
if (!found) {
|
|
267
|
+
found = Object.freeze({ year: "solar-return", months, rulers: "traditional-domicile" });
|
|
268
|
+
CONVENTION_CACHE.set(months, found);
|
|
269
|
+
}
|
|
270
|
+
return found;
|
|
271
|
+
}
|
|
272
|
+
function setup(natal, options) {
|
|
273
|
+
const read = readOptions(options, ["point", "months"], "profection options");
|
|
274
|
+
const months = oneOf(read.months, PROFECTION_MONTH_CONVENTIONS, DEFAULT_PROFECTION_MONTHS, "months");
|
|
275
|
+
const point = read.point === void 0 ? "Ascendant" : longitudeName(read.point, "point");
|
|
276
|
+
const { chart, points, birth } = natalContext(natal);
|
|
277
|
+
const row = chartLongitude(chart, points, point, "point");
|
|
278
|
+
const startIndex = Math.floor(row.lon / 30) % 12;
|
|
279
|
+
return {
|
|
280
|
+
years: solarYears(birth),
|
|
281
|
+
origin: originOf(startIndex, row.lon, row.name),
|
|
282
|
+
startIndex,
|
|
283
|
+
months,
|
|
284
|
+
sectContradicted: row.name.startsWith("Lot of") && sectContradictsAltitude(chart, points)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function span(startIndex, offset, start, end) {
|
|
288
|
+
const sign = signAt(startIndex + offset);
|
|
289
|
+
return {
|
|
290
|
+
sign,
|
|
291
|
+
ruler: TRADITIONAL_RULERS[sign],
|
|
292
|
+
house: placeFrom(offset),
|
|
293
|
+
start: dateAt(start, "A profection boundary"),
|
|
294
|
+
end: dateAt(end, "A profection boundary")
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function monthBoundaries(years, age, months) {
|
|
298
|
+
const start = years.returnMs(age);
|
|
299
|
+
const end = years.returnMs(age + 1);
|
|
300
|
+
const count = months === "thirteenths" ? 13 : 12;
|
|
301
|
+
const bounds = [start];
|
|
302
|
+
for (let index = 1; index < count; index += 1) {
|
|
303
|
+
const even = start + index * (end - start) / count;
|
|
304
|
+
bounds.push(
|
|
305
|
+
months === "solar" ? (
|
|
306
|
+
// The Sun's month boundaries lie within about two days of the even
|
|
307
|
+
// twelfths (its equation of centre is under 2°).
|
|
308
|
+
years.sunReaches(years.natalSun + 30 * index, even, 5)
|
|
309
|
+
) : Math.round(even)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
bounds.push(end);
|
|
313
|
+
for (let index = 1; index < bounds.length; index += 1) {
|
|
314
|
+
if (!(bounds[index] > bounds[index - 1])) throw new RangeError("Profection months are out of order.");
|
|
315
|
+
}
|
|
316
|
+
return bounds;
|
|
317
|
+
}
|
|
318
|
+
function monthsOf(startIndex, age, bounds) {
|
|
319
|
+
const months = [];
|
|
320
|
+
for (let index = 0; index + 1 < bounds.length; index += 1) {
|
|
321
|
+
months.push(Object.freeze({ index, ...span(startIndex, age + index, bounds[index], bounds[index + 1]) }));
|
|
322
|
+
}
|
|
323
|
+
return months;
|
|
324
|
+
}
|
|
325
|
+
function profectionYear(natal, age, options) {
|
|
326
|
+
const years = integerIn(age, 0, Number.MAX_SAFE_INTEGER, "age");
|
|
327
|
+
const context = setup(natal, options);
|
|
328
|
+
const bounds = monthBoundaries(context.years, years, context.months);
|
|
329
|
+
return Object.freeze({
|
|
330
|
+
age: years,
|
|
331
|
+
...span(context.startIndex, years, bounds[0], bounds[bounds.length - 1]),
|
|
332
|
+
origin: context.origin,
|
|
333
|
+
months: Object.freeze(monthsOf(context.startIndex, years, bounds)),
|
|
334
|
+
conventions: conventionsFor(context.months),
|
|
335
|
+
flags: timingFlags([context.years.birthMs, bounds[0], bounds[bounds.length - 1]], context.sectContradicted)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function profectionAt(natal, date, options) {
|
|
339
|
+
const at = dateFrom(date, "date");
|
|
340
|
+
const context = setup(natal, options);
|
|
341
|
+
const { age } = context.years.yearAt(at.getTime());
|
|
342
|
+
const bounds = monthBoundaries(context.years, age, context.months);
|
|
343
|
+
const months = monthsOf(context.startIndex, age, bounds);
|
|
344
|
+
const time = at.getTime();
|
|
345
|
+
const month = months.find((candidate) => candidate.start.getTime() <= time && time < candidate.end.getTime());
|
|
346
|
+
if (!month) throw new RangeError("Could not place the date within its profection year.");
|
|
347
|
+
return Object.freeze({
|
|
348
|
+
at,
|
|
349
|
+
origin: context.origin,
|
|
350
|
+
year: Object.freeze({ age, ...span(context.startIndex, age, bounds[0], bounds[bounds.length - 1]) }),
|
|
351
|
+
month,
|
|
352
|
+
conventions: conventionsFor(context.months),
|
|
353
|
+
flags: timingFlags([context.years.birthMs, bounds[0], bounds[bounds.length - 1]], context.sectContradicted)
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// src/timing/firdaria.ts
|
|
358
|
+
var FIRDARIA_VARIANTS = /* @__PURE__ */ Object.freeze(["abu-mashar", "bonatti"]);
|
|
359
|
+
var DEFAULT_FIRDARIA_VARIANT = "abu-mashar";
|
|
360
|
+
var FIRDARIA_YEARS = /* @__PURE__ */ Object.freeze({
|
|
361
|
+
Sun: 10,
|
|
362
|
+
Venus: 8,
|
|
363
|
+
Mercury: 13,
|
|
364
|
+
Moon: 9,
|
|
365
|
+
Saturn: 11,
|
|
366
|
+
Jupiter: 12,
|
|
367
|
+
Mars: 7,
|
|
368
|
+
"North Node": 3,
|
|
369
|
+
"South Node": 2
|
|
370
|
+
});
|
|
371
|
+
var FIRDARIA_CYCLE_YEARS = 75;
|
|
372
|
+
var DAY_SEQUENCE = /* @__PURE__ */ Object.freeze([
|
|
373
|
+
"Sun",
|
|
374
|
+
"Venus",
|
|
375
|
+
"Mercury",
|
|
376
|
+
"Moon",
|
|
377
|
+
"Saturn",
|
|
378
|
+
"Jupiter",
|
|
379
|
+
"Mars",
|
|
380
|
+
"North Node",
|
|
381
|
+
"South Node"
|
|
382
|
+
]);
|
|
383
|
+
var NIGHT_SEQUENCES = /* @__PURE__ */ Object.freeze({
|
|
384
|
+
"abu-mashar": /* @__PURE__ */ Object.freeze([
|
|
385
|
+
"Moon",
|
|
386
|
+
"Saturn",
|
|
387
|
+
"Jupiter",
|
|
388
|
+
"Mars",
|
|
389
|
+
"Sun",
|
|
390
|
+
"Venus",
|
|
391
|
+
"Mercury",
|
|
392
|
+
"North Node",
|
|
393
|
+
"South Node"
|
|
394
|
+
]),
|
|
395
|
+
bonatti: /* @__PURE__ */ Object.freeze([
|
|
396
|
+
"Moon",
|
|
397
|
+
"Saturn",
|
|
398
|
+
"Jupiter",
|
|
399
|
+
"Mars",
|
|
400
|
+
"North Node",
|
|
401
|
+
"South Node",
|
|
402
|
+
"Sun",
|
|
403
|
+
"Venus",
|
|
404
|
+
"Mercury"
|
|
405
|
+
])
|
|
406
|
+
});
|
|
407
|
+
function checkedSect(value) {
|
|
408
|
+
if (value === "day" || value === "night") return value;
|
|
409
|
+
throw new RangeError('sect must be "day" or "night".');
|
|
410
|
+
}
|
|
411
|
+
function variantOf(options, allowed) {
|
|
412
|
+
const read = readOptions(options, allowed, "firdaria options");
|
|
413
|
+
return { variant: oneOf(read.variant, FIRDARIA_VARIANTS, DEFAULT_FIRDARIA_VARIANT, "variant"), read };
|
|
414
|
+
}
|
|
415
|
+
function firdariaSequence(sect, options) {
|
|
416
|
+
const { variant } = variantOf(options, ["variant"]);
|
|
417
|
+
return checkedSect(sect) === "day" ? DAY_SEQUENCE : NIGHT_SEQUENCES[variant];
|
|
418
|
+
}
|
|
419
|
+
function subPeriodsOf(lord, startAge, years) {
|
|
420
|
+
if (lord === "North Node" || lord === "South Node") return [];
|
|
421
|
+
const first = CHALDEAN_ORDER.indexOf(lord);
|
|
422
|
+
const shares = [];
|
|
423
|
+
for (let index = 0; index < 7; index += 1) {
|
|
424
|
+
shares.push(Object.freeze({
|
|
425
|
+
lord: CHALDEAN_ORDER[(first + index) % 7],
|
|
426
|
+
startAge: startAge + index * years / 7,
|
|
427
|
+
endAge: index === 6 ? startAge + years : startAge + (index + 1) * years / 7
|
|
428
|
+
}));
|
|
429
|
+
}
|
|
430
|
+
return shares;
|
|
431
|
+
}
|
|
432
|
+
function periodsOf(sequence, offset) {
|
|
433
|
+
const periods = [];
|
|
434
|
+
let age = offset;
|
|
435
|
+
for (const lord of sequence) {
|
|
436
|
+
const years = FIRDARIA_YEARS[lord];
|
|
437
|
+
periods.push(Object.freeze({
|
|
438
|
+
lord,
|
|
439
|
+
years,
|
|
440
|
+
startAge: age,
|
|
441
|
+
endAge: age + years,
|
|
442
|
+
subPeriods: Object.freeze(subPeriodsOf(lord, age, years))
|
|
443
|
+
}));
|
|
444
|
+
age += years;
|
|
445
|
+
}
|
|
446
|
+
return periods;
|
|
447
|
+
}
|
|
448
|
+
function firdariaPeriods(sect, options) {
|
|
449
|
+
return Object.freeze(periodsOf(firdariaSequence(sect, options), 0));
|
|
450
|
+
}
|
|
451
|
+
function datedPeriod(years, period, cycle) {
|
|
452
|
+
return Object.freeze({
|
|
453
|
+
lord: period.lord,
|
|
454
|
+
years: period.years,
|
|
455
|
+
cycle,
|
|
456
|
+
startAge: period.startAge,
|
|
457
|
+
endAge: period.endAge,
|
|
458
|
+
start: dateAt(years.instantOf(period.startAge), "A firdaria boundary"),
|
|
459
|
+
end: dateAt(years.instantOf(period.endAge), "A firdaria boundary"),
|
|
460
|
+
subPeriods: Object.freeze(period.subPeriods.map((share) => Object.freeze({
|
|
461
|
+
...share,
|
|
462
|
+
start: dateAt(years.instantOf(share.startAge), "A firdaria boundary"),
|
|
463
|
+
end: dateAt(years.instantOf(share.endAge), "A firdaria boundary")
|
|
464
|
+
})))
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function sectFrom(natal) {
|
|
468
|
+
const { chart, points, birth } = natalContext(natal);
|
|
469
|
+
if (points.sect === null) {
|
|
470
|
+
throw new RangeError("Firdaria need the chart's sect, which needs a birth time and place.");
|
|
471
|
+
}
|
|
472
|
+
return { sect: points.sect, birth, sectContradicted: sectContradictsAltitude(chart, points) };
|
|
473
|
+
}
|
|
474
|
+
function conventionsFor2(variant) {
|
|
475
|
+
return Object.freeze({ variant, years: "solar-return", subPeriods: "sevenths-descending-spheres" });
|
|
476
|
+
}
|
|
477
|
+
function firdaria(natal, options) {
|
|
478
|
+
const { variant, read } = variantOf(options, ["variant", "cycles"]);
|
|
479
|
+
const cycles = read.cycles === void 0 ? 1 : integerIn(read.cycles, 1, 4, "cycles");
|
|
480
|
+
const { sect, birth, sectContradicted } = sectFrom(natal);
|
|
481
|
+
const years = solarYears(birth);
|
|
482
|
+
const sequence = firdariaSequence(sect, { variant });
|
|
483
|
+
const periods = [];
|
|
484
|
+
for (let cycle = 0; cycle < cycles; cycle += 1) {
|
|
485
|
+
for (const period of periodsOf(sequence, cycle * FIRDARIA_CYCLE_YEARS)) {
|
|
486
|
+
periods.push(datedPeriod(years, period, cycle));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return Object.freeze({
|
|
490
|
+
birth: new Date(birth.getTime()),
|
|
491
|
+
sect,
|
|
492
|
+
periods: Object.freeze(periods),
|
|
493
|
+
conventions: conventionsFor2(variant),
|
|
494
|
+
flags: timingFlags([birth.getTime(), periods.at(-1).end.getTime()], sectContradicted)
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function firdariaAt(natal, date, options) {
|
|
498
|
+
const at = dateFrom(date, "date");
|
|
499
|
+
const { variant } = variantOf(options, ["variant"]);
|
|
500
|
+
const { sect, birth, sectContradicted } = sectFrom(natal);
|
|
501
|
+
const years = solarYears(birth);
|
|
502
|
+
const time = at.getTime();
|
|
503
|
+
const year = years.yearAt(time);
|
|
504
|
+
const age = year.age + (time - year.start) / (year.end - year.start);
|
|
505
|
+
const sequence = firdariaSequence(sect, { variant });
|
|
506
|
+
const cycle = Math.floor(age / FIRDARIA_CYCLE_YEARS);
|
|
507
|
+
const candidates = [];
|
|
508
|
+
for (const each of [cycle - 1, cycle, cycle + 1]) {
|
|
509
|
+
if (each < 0) continue;
|
|
510
|
+
for (const period2 of periodsOf(sequence, each * FIRDARIA_CYCLE_YEARS)) candidates.push({ period: period2, cycle: each });
|
|
511
|
+
}
|
|
512
|
+
const guess = candidates.findIndex(({ period: period2 }) => period2.startAge <= age && age < period2.endAge);
|
|
513
|
+
const contains = (span2) => span2.start.getTime() <= time && time < span2.end.getTime();
|
|
514
|
+
let period;
|
|
515
|
+
for (const index of [guess, guess - 1, guess + 1]) {
|
|
516
|
+
const candidate = index >= 0 ? candidates[index] : void 0;
|
|
517
|
+
if (!candidate) continue;
|
|
518
|
+
const dated = datedPeriod(years, candidate.period, candidate.cycle);
|
|
519
|
+
if (contains(dated)) {
|
|
520
|
+
period = dated;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (!period) throw new RangeError("Could not place the date within its firdaria period.");
|
|
525
|
+
return Object.freeze({
|
|
526
|
+
at,
|
|
527
|
+
sect,
|
|
528
|
+
age,
|
|
529
|
+
period,
|
|
530
|
+
subPeriod: period.subPeriods.find(contains) ?? null,
|
|
531
|
+
conventions: conventionsFor2(variant),
|
|
532
|
+
flags: timingFlags(
|
|
533
|
+
[birth.getTime(), year.start, year.end, period.start.getTime(), period.end.getTime()],
|
|
534
|
+
sectContradicted
|
|
535
|
+
)
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/timing/releasing.ts
|
|
540
|
+
var VALENS_MINOR_YEARS = /* @__PURE__ */ Object.freeze({
|
|
541
|
+
aries: 15,
|
|
542
|
+
taurus: 8,
|
|
543
|
+
gemini: 20,
|
|
544
|
+
cancer: 25,
|
|
545
|
+
leo: 19,
|
|
546
|
+
virgo: 20,
|
|
547
|
+
libra: 8,
|
|
548
|
+
scorpio: 15,
|
|
549
|
+
sagittarius: 12,
|
|
550
|
+
capricorn: 27,
|
|
551
|
+
aquarius: 30,
|
|
552
|
+
pisces: 12
|
|
553
|
+
});
|
|
554
|
+
var RELEASING_CYCLE_UNITS = 211;
|
|
555
|
+
var RELEASING_YEAR_CONVENTIONS = /* @__PURE__ */ Object.freeze([
|
|
556
|
+
"valens-360",
|
|
557
|
+
"julian-365.25"
|
|
558
|
+
]);
|
|
559
|
+
var DEFAULT_RELEASING_YEARS = "valens-360";
|
|
560
|
+
var RELEASING_UNIT_DAYS = /* @__PURE__ */ Object.freeze({
|
|
561
|
+
"valens-360": /* @__PURE__ */ Object.freeze([360, 30, 2.5, 5 / 24]),
|
|
562
|
+
"julian-365.25": /* @__PURE__ */ Object.freeze([365.25, 365.25 / 12, 365.25 / 144, 365.25 / 1728])
|
|
563
|
+
});
|
|
564
|
+
var LEVEL4_UNIT_MS = /* @__PURE__ */ Object.freeze({
|
|
565
|
+
"valens-360": 18e6,
|
|
566
|
+
"julian-365.25": 18262500
|
|
567
|
+
});
|
|
568
|
+
var LEVEL_SCALE = /* @__PURE__ */ Object.freeze({ 1: 1728, 2: 144, 3: 12, 4: 1 });
|
|
569
|
+
var MINOR = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SIGN_NAMES.map((sign) => VALENS_MINOR_YEARS[sign]));
|
|
570
|
+
var MAX_PERIODS = 1e5;
|
|
571
|
+
var CONVENTIONS = /* @__PURE__ */ new Map();
|
|
572
|
+
function conventionsFor3(years) {
|
|
573
|
+
let found = CONVENTIONS.get(years);
|
|
574
|
+
if (!found) {
|
|
575
|
+
found = Object.freeze({
|
|
576
|
+
years,
|
|
577
|
+
unitDays: RELEASING_UNIT_DAYS[years],
|
|
578
|
+
loosingOfTheBond: "levels-2-to-4;once-per-period;opposite-of-starting-sign",
|
|
579
|
+
rulers: "traditional-domicile"
|
|
580
|
+
});
|
|
581
|
+
CONVENTIONS.set(years, found);
|
|
582
|
+
}
|
|
583
|
+
return found;
|
|
584
|
+
}
|
|
585
|
+
function overlaps(walk, span2) {
|
|
586
|
+
const startMs = walk.birthMs + span2.start * walk.unitMs;
|
|
587
|
+
const endMs = walk.birthMs + span2.end * walk.unitMs;
|
|
588
|
+
return startMs <= walk.toMs && endMs > walk.fromMs;
|
|
589
|
+
}
|
|
590
|
+
function emit(walk, span2) {
|
|
591
|
+
if (walk.out.length >= MAX_PERIODS) {
|
|
592
|
+
throw new RangeError(
|
|
593
|
+
`The window holds more than ${MAX_PERIODS} releasing periods; narrow it or ask for fewer levels.`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
const sign = signAt(span2.sign);
|
|
597
|
+
walk.out.push(Object.freeze({
|
|
598
|
+
level: span2.level,
|
|
599
|
+
sign,
|
|
600
|
+
ruler: TRADITIONAL_RULERS[sign],
|
|
601
|
+
units: MINOR[span2.sign],
|
|
602
|
+
start: dateAt(walk.birthMs + span2.start * walk.unitMs, "A releasing boundary"),
|
|
603
|
+
end: dateAt(walk.birthMs + span2.end * walk.unitMs, "A releasing boundary"),
|
|
604
|
+
// Exact integers of milliseconds, so whole days come out whole.
|
|
605
|
+
startDays: span2.start * walk.unitMs / DAY_MS,
|
|
606
|
+
endDays: span2.end * walk.unitMs / DAY_MS,
|
|
607
|
+
truncated: span2.truncated,
|
|
608
|
+
loosingOfTheBond: span2.loosing
|
|
609
|
+
}));
|
|
610
|
+
}
|
|
611
|
+
function visit(walk, span2) {
|
|
612
|
+
if (!overlaps(walk, span2)) return;
|
|
613
|
+
emit(walk, span2);
|
|
614
|
+
if (span2.level >= walk.levels) return;
|
|
615
|
+
const level = span2.level + 1;
|
|
616
|
+
const scale = LEVEL_SCALE[level];
|
|
617
|
+
let position = span2.start;
|
|
618
|
+
let sign = span2.sign;
|
|
619
|
+
let emitted = 0;
|
|
620
|
+
let loosed = false;
|
|
621
|
+
while (position < span2.end) {
|
|
622
|
+
let loosing = false;
|
|
623
|
+
if (!loosed && emitted === 12) {
|
|
624
|
+
sign = (span2.sign + 6) % 12;
|
|
625
|
+
loosed = true;
|
|
626
|
+
loosing = true;
|
|
627
|
+
}
|
|
628
|
+
const nominal = MINOR[sign] * scale;
|
|
629
|
+
const end = Math.min(position + nominal, span2.end);
|
|
630
|
+
visit(walk, { level, sign, start: position, end, truncated: end < position + nominal, loosing });
|
|
631
|
+
position = end;
|
|
632
|
+
sign = (sign + 1) % 12;
|
|
633
|
+
emitted += 1;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function walkFrom(startIndex, walk) {
|
|
637
|
+
const scale = LEVEL_SCALE[1];
|
|
638
|
+
let position = 0;
|
|
639
|
+
let sign = startIndex;
|
|
640
|
+
while (walk.birthMs + position * walk.unitMs <= walk.toMs) {
|
|
641
|
+
const end = position + MINOR[sign] * scale;
|
|
642
|
+
visit(walk, { level: 1, sign, start: position, end, truncated: false, loosing: false });
|
|
643
|
+
position = end;
|
|
644
|
+
sign = (sign + 1) % 12;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function windowOf(options, from, to) {
|
|
648
|
+
const read = readOptions(options, ["levels", "years"], "releasing options");
|
|
649
|
+
const levels = read.levels === void 0 ? 2 : integerIn(read.levels, 1, 4, "levels");
|
|
650
|
+
const years = oneOf(read.years, RELEASING_YEAR_CONVENTIONS, DEFAULT_RELEASING_YEARS, "years");
|
|
651
|
+
const fromDate = dateFrom(from, "from");
|
|
652
|
+
const toDate = dateFrom(to, "to");
|
|
653
|
+
if (toDate.getTime() < fromDate.getTime()) throw new RangeError("to must not precede from.");
|
|
654
|
+
return { levels, years, from: fromDate, to: toDate };
|
|
655
|
+
}
|
|
656
|
+
function instantOf(options, date) {
|
|
657
|
+
const read = readOptions(options, ["years"], "releasing options");
|
|
658
|
+
const years = oneOf(read.years, RELEASING_YEAR_CONVENTIONS, DEFAULT_RELEASING_YEARS, "years");
|
|
659
|
+
const at = dateFrom(date, "date");
|
|
660
|
+
return { levels: 4, years, from: at, to: at };
|
|
661
|
+
}
|
|
662
|
+
function timeline(origin, startIndex, birth, dates, flags) {
|
|
663
|
+
const { levels, years, from: fromDate, to: toDate } = dates;
|
|
664
|
+
const birthMs = birth.getTime();
|
|
665
|
+
if (toDate.getTime() < birthMs) throw new RangeError("to must not precede the birth instant.");
|
|
666
|
+
const fromMs = Math.max(fromDate.getTime(), birthMs);
|
|
667
|
+
const walk = {
|
|
668
|
+
birthMs,
|
|
669
|
+
unitMs: LEVEL4_UNIT_MS[years],
|
|
670
|
+
fromMs,
|
|
671
|
+
toMs: toDate.getTime(),
|
|
672
|
+
levels,
|
|
673
|
+
out: []
|
|
674
|
+
};
|
|
675
|
+
walkFrom(startIndex, walk);
|
|
676
|
+
return Object.freeze({
|
|
677
|
+
origin,
|
|
678
|
+
birth: new Date(birthMs),
|
|
679
|
+
from: new Date(fromMs),
|
|
680
|
+
to: toDate,
|
|
681
|
+
levels,
|
|
682
|
+
periods: Object.freeze(walk.out),
|
|
683
|
+
conventions: conventionsFor3(years),
|
|
684
|
+
flags
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
function chain(origin, startIndex, birth, instant, flags) {
|
|
688
|
+
const { years, from: at } = instant;
|
|
689
|
+
if (at.getTime() < birth.getTime()) throw new RangeError("The date must not precede the birth instant.");
|
|
690
|
+
const result = timeline(origin, startIndex, birth, instant, flags);
|
|
691
|
+
const periods = result.periods;
|
|
692
|
+
if (periods.length !== 4 || periods.some((period, index) => period.level !== index + 1)) {
|
|
693
|
+
throw new RangeError("Could not place the date within one period of each level.");
|
|
694
|
+
}
|
|
695
|
+
const elapsedDays = (at.getTime() - birth.getTime()) / DAY_MS;
|
|
696
|
+
return Object.freeze({
|
|
697
|
+
origin,
|
|
698
|
+
birth: new Date(birth.getTime()),
|
|
699
|
+
at,
|
|
700
|
+
elapsedDays,
|
|
701
|
+
elapsedYears: elapsedDays / RELEASING_UNIT_DAYS[years][0],
|
|
702
|
+
periods,
|
|
703
|
+
conventions: result.conventions,
|
|
704
|
+
flags
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
function releasingPeriods(origin, birthUtc, from, to, options) {
|
|
708
|
+
const sign = startSign(origin, "origin");
|
|
709
|
+
const birth = dateFrom(birthUtc, "birthUtc");
|
|
710
|
+
return timeline(originOf(sign.index, sign.lon, null), sign.index, birth, windowOf(options, from, to), timingFlags([], false));
|
|
711
|
+
}
|
|
712
|
+
function releasingAt(origin, birthUtc, date, options) {
|
|
713
|
+
const sign = startSign(origin, "origin");
|
|
714
|
+
const birth = dateFrom(birthUtc, "birthUtc");
|
|
715
|
+
return chain(originOf(sign.index, sign.lon, null), sign.index, birth, instantOf(options, date), timingFlags([], false));
|
|
716
|
+
}
|
|
717
|
+
function checkedLot(lot) {
|
|
718
|
+
if (lot !== "Lot of Fortune" && lot !== "Lot of Spirit") {
|
|
719
|
+
throw new RangeError('lot must be "Lot of Fortune" or "Lot of Spirit".');
|
|
720
|
+
}
|
|
721
|
+
return lot;
|
|
722
|
+
}
|
|
723
|
+
function lotStart(natal, lot) {
|
|
724
|
+
const { chart, points, birth } = natalContext(natal);
|
|
725
|
+
const row = chartLongitude(chart, points, lot, "lot");
|
|
726
|
+
const index = Math.floor(row.lon / 30) % 12;
|
|
727
|
+
const flags = timingFlags([birth.getTime()], sectContradictsAltitude(chart, points));
|
|
728
|
+
return { origin: originOf(index, row.lon, lot), index, birth, flags };
|
|
729
|
+
}
|
|
730
|
+
function zodiacalReleasing(natal, lot, from, to, options) {
|
|
731
|
+
const name = checkedLot(lot);
|
|
732
|
+
const dates = windowOf(options, from, to);
|
|
733
|
+
const { origin, index, birth, flags } = lotStart(natal, name);
|
|
734
|
+
return timeline(origin, index, birth, dates, flags);
|
|
735
|
+
}
|
|
736
|
+
function zodiacalReleasingAt(natal, lot, date, options) {
|
|
737
|
+
const name = checkedLot(lot);
|
|
738
|
+
const instant = instantOf(options, date);
|
|
739
|
+
const { origin, index, birth, flags } = lotStart(natal, name);
|
|
740
|
+
return chain(origin, index, birth, instant, flags);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/timing/solar-arc.ts
|
|
744
|
+
var SUN_MEAN_MOTION = 0.98564736;
|
|
745
|
+
var MAX_ROWS = 256;
|
|
746
|
+
function sunOf(rows) {
|
|
747
|
+
const sun = rows.find((row) => row.body === "Sun");
|
|
748
|
+
if (!sun) throw new RangeError("The ephemeris returned no Sun.");
|
|
749
|
+
return sun.lon;
|
|
750
|
+
}
|
|
751
|
+
function solarArc(birthUtc, target) {
|
|
752
|
+
const birth = dateFrom(birthUtc, "birthUtc");
|
|
753
|
+
const at = dateFrom(target, "target");
|
|
754
|
+
const progressed = progressedInstant(birth, at);
|
|
755
|
+
const natalSun = sunOf(guarded(() => progressedBodies(birth, birth)));
|
|
756
|
+
const progressedSun = sunOf(guarded(() => progressedBodies(birth, at)));
|
|
757
|
+
const days = (progressed.getTime() - birth.getTime()) / DAY_MS;
|
|
758
|
+
const raw = progressedSun - natalSun;
|
|
759
|
+
const arc = raw + 360 * Math.round((SUN_MEAN_MOTION * days - raw) / 360);
|
|
760
|
+
const flags = timingFlags([birth.getTime(), progressed.getTime()], false);
|
|
761
|
+
return Object.freeze({ birth, target: at, progressed, natalSun, progressedSun, arc: arc === 0 ? 0 : arc, flags });
|
|
762
|
+
}
|
|
763
|
+
function direct(name, longitude, arc) {
|
|
764
|
+
const natal = normalizeLongitude(longitude);
|
|
765
|
+
const directed = normalizeLongitude(natal + arc);
|
|
766
|
+
return { name, natal, directed, sign: signForLongitude(directed).slug, degree: degreeInSign(directed) };
|
|
767
|
+
}
|
|
768
|
+
function directLongitudes(rows, arc) {
|
|
769
|
+
if (typeof arc !== "number" || !Number.isFinite(arc)) {
|
|
770
|
+
throw new RangeError("arc must be a finite number of degrees.");
|
|
771
|
+
}
|
|
772
|
+
if (!Array.isArray(rows) || rows.length > MAX_ROWS) {
|
|
773
|
+
throw new RangeError(`rows must be an array of at most ${MAX_ROWS} longitudes.`);
|
|
774
|
+
}
|
|
775
|
+
const seen = /* @__PURE__ */ new Set();
|
|
776
|
+
const out = [];
|
|
777
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
778
|
+
const row = rows[index];
|
|
779
|
+
if (row === null || typeof row !== "object") {
|
|
780
|
+
throw new RangeError("Each row must be an object with a name and a lon.");
|
|
781
|
+
}
|
|
782
|
+
const { name, lon } = row;
|
|
783
|
+
if (typeof name !== "string" || name.length === 0) throw new RangeError("Each row needs a nonempty name.");
|
|
784
|
+
if (seen.has(name)) throw new RangeError(`Row names must be unique; "${name}" repeats.`);
|
|
785
|
+
if (typeof lon !== "number" || !Number.isFinite(lon)) {
|
|
786
|
+
throw new RangeError(`Row "${name}" needs a finite lon.`);
|
|
787
|
+
}
|
|
788
|
+
seen.add(name);
|
|
789
|
+
out.push(Object.freeze(direct(name, lon, arc)));
|
|
790
|
+
}
|
|
791
|
+
return Object.freeze(out);
|
|
792
|
+
}
|
|
793
|
+
function solarArcDirections(natal, target) {
|
|
794
|
+
const at = dateFrom(target, "target");
|
|
795
|
+
const { chart, points, birth } = natalContext(natal);
|
|
796
|
+
const arc = solarArc(birth, at);
|
|
797
|
+
const positions = chartLongitudes(chart, points).map(
|
|
798
|
+
(row) => Object.freeze({ ...direct(row.name, row.lon, arc.arc), name: row.name, kind: row.kind })
|
|
799
|
+
);
|
|
800
|
+
const flags = timingFlags([arc.birth.getTime(), arc.progressed.getTime()], sectContradictsAltitude(chart, points));
|
|
801
|
+
return Object.freeze({ arc, positions: Object.freeze(positions), flags });
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// src/timing/planetary-returns.ts
|
|
805
|
+
var RETURN_BODIES = Object.freeze([
|
|
806
|
+
"Sun",
|
|
807
|
+
"Moon",
|
|
808
|
+
"Mercury",
|
|
809
|
+
"Venus",
|
|
810
|
+
"Mars",
|
|
811
|
+
"Jupiter",
|
|
812
|
+
"Saturn",
|
|
813
|
+
"Uranus",
|
|
814
|
+
"Neptune",
|
|
815
|
+
"Pluto"
|
|
816
|
+
]);
|
|
817
|
+
var RETURN_STEP_DAYS = Object.freeze({
|
|
818
|
+
Sun: 5,
|
|
819
|
+
Moon: 1,
|
|
820
|
+
Mercury: 2,
|
|
821
|
+
Venus: 4,
|
|
822
|
+
Mars: 5,
|
|
823
|
+
Jupiter: 5,
|
|
824
|
+
Saturn: 5,
|
|
825
|
+
Uranus: 5,
|
|
826
|
+
Neptune: 5,
|
|
827
|
+
Pluto: 5
|
|
828
|
+
});
|
|
829
|
+
function planetaryReturns(natal, body, from, to, options) {
|
|
830
|
+
if (typeof body !== "string" || !RETURN_BODIES.includes(body)) {
|
|
831
|
+
throw new RangeError(`body must be one of ${RETURN_BODIES.join(", ")}.`);
|
|
832
|
+
}
|
|
833
|
+
const start = dateFrom(from, "from");
|
|
834
|
+
const end = dateFrom(to, "to");
|
|
835
|
+
const read = readOptions(options, ["stepDays", "maxSamples"], "planetaryReturns options");
|
|
836
|
+
const stepDays = read.stepDays === void 0 ? RETURN_STEP_DAYS[body] : read.stepDays;
|
|
837
|
+
const { chart } = guarded(() => resolvedChart(natal));
|
|
838
|
+
const natalBody = chart.bodies.find((row) => row.body === body);
|
|
839
|
+
if (!natalBody) throw new RangeError(`The chart has no ${body}.`);
|
|
840
|
+
const natalLongitude = natalBody.lon;
|
|
841
|
+
const search = guarded(
|
|
842
|
+
() => searchLongitudeCrossings(body, natalLongitude, start, end, {
|
|
843
|
+
stepDays,
|
|
844
|
+
...read.maxSamples === void 0 ? {} : { maxSamples: read.maxSamples }
|
|
845
|
+
})
|
|
846
|
+
);
|
|
847
|
+
const common = {
|
|
848
|
+
body,
|
|
849
|
+
natalLongitude,
|
|
850
|
+
from: start,
|
|
851
|
+
to: end,
|
|
852
|
+
samples: search.samples,
|
|
853
|
+
flags: timingFlags([utcOf(chart.input).getTime(), start.getTime(), end.getTime()], false)
|
|
854
|
+
};
|
|
855
|
+
if (search.status === "refused") {
|
|
856
|
+
return Object.freeze({
|
|
857
|
+
...common,
|
|
858
|
+
status: "refused",
|
|
859
|
+
reason: search.reason,
|
|
860
|
+
maxSamples: search.maxSamples,
|
|
861
|
+
returns: Object.freeze([])
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
let pass = 0;
|
|
865
|
+
let previousDirect = true;
|
|
866
|
+
const returns = search.crossings.map((crossing) => {
|
|
867
|
+
if (pass === 0 || previousDirect && !crossing.retrograde) pass += 1;
|
|
868
|
+
previousDirect = !crossing.retrograde;
|
|
869
|
+
return Object.freeze({ at: crossing.at, retrograde: crossing.retrograde, pass });
|
|
870
|
+
});
|
|
871
|
+
return Object.freeze({ ...common, status: "complete", returns: Object.freeze(returns) });
|
|
872
|
+
}
|
|
873
|
+
export {
|
|
874
|
+
CHALDEAN_ORDER,
|
|
875
|
+
DEFAULT_FIRDARIA_VARIANT,
|
|
876
|
+
DEFAULT_PROFECTION_MONTHS,
|
|
877
|
+
DEFAULT_RELEASING_YEARS,
|
|
878
|
+
FIRDARIA_CYCLE_YEARS,
|
|
879
|
+
FIRDARIA_VARIANTS,
|
|
880
|
+
FIRDARIA_YEARS,
|
|
881
|
+
PROFECTION_MONTH_CONVENTIONS,
|
|
882
|
+
RELEASING_CYCLE_UNITS,
|
|
883
|
+
RELEASING_UNIT_DAYS,
|
|
884
|
+
RELEASING_YEAR_CONVENTIONS,
|
|
885
|
+
RETURN_BODIES,
|
|
886
|
+
RETURN_STEP_DAYS,
|
|
887
|
+
TRADITIONAL_RULERS,
|
|
888
|
+
VALENS_MINOR_YEARS,
|
|
889
|
+
annualProfection,
|
|
890
|
+
directLongitudes,
|
|
891
|
+
firdaria,
|
|
892
|
+
firdariaAt,
|
|
893
|
+
firdariaPeriods,
|
|
894
|
+
firdariaSequence,
|
|
895
|
+
planetaryReturns,
|
|
896
|
+
profectionAt,
|
|
897
|
+
profectionYear,
|
|
898
|
+
releasingAt,
|
|
899
|
+
releasingPeriods,
|
|
900
|
+
solarArc,
|
|
901
|
+
solarArcDirections,
|
|
902
|
+
zodiacalReleasing,
|
|
903
|
+
zodiacalReleasingAt
|
|
904
|
+
};
|