@zodiacs/engine 2.0.0-rc.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +519 -0
  2. package/LICENSING.md +55 -16
  3. package/NOTICE +28 -10
  4. package/README.md +192 -53
  5. package/dist/{api-C_SVd9BJ.d.ts → api-G8RVGizH.d.ts} +1 -1
  6. package/dist/{ayanamsa-Clgkekhh.d.ts → ayanamsa-C4-pYjzm.d.ts} +2 -2
  7. package/dist/calc.d.ts +4 -4
  8. package/dist/calc.js +13 -9
  9. package/dist/{chunk-WONTOC5W.js → chunk-4RCOOAGI.js} +1 -1
  10. package/dist/{chunk-NX4PHQBL.js → chunk-JY2LU4VC.js} +61 -80
  11. package/dist/{chunk-B5LKF437.js → chunk-M65JXRFN.js} +40 -0
  12. package/dist/{chunk-FVGA776A.js → chunk-PSZAKTDL.js} +2 -2
  13. package/dist/{chunk-T6F4FYYS.js → chunk-SCBK24HR.js} +1 -1
  14. package/dist/{chunk-PNXIA7MI.js → chunk-X5ANRWDK.js} +18 -7
  15. package/dist/{chunk-I3L4POY7.js → chunk-XO7MHH32.js} +2 -1
  16. package/dist/{chunk-N4UQLCBN.js → chunk-ZL74QHBE.js} +1 -1
  17. package/dist/{chunk-IXFUYEUF.js → chunk-ZPHWUFTZ.js} +20 -4
  18. package/dist/core.d.ts +21 -0
  19. package/dist/core.js +2960 -0
  20. package/dist/crossings.d.ts +2 -2
  21. package/dist/de440-pack.d.ts +2 -2
  22. package/dist/de440.d.ts +2 -2
  23. package/dist/{ephemeris-D1lM832F.d.ts → ephemeris-Bnmowcsk.d.ts} +1 -1
  24. package/dist/esm-only.cjs +3 -0
  25. package/dist/geo.d.ts +74 -16
  26. package/dist/geo.js +139 -5
  27. package/dist/{houses-icK01yXi.d.ts → houses-CAiYEICK.d.ts} +1 -1
  28. package/dist/houses-extra.d.ts +3 -3
  29. package/dist/index.d.ts +8 -8
  30. package/dist/index.js +6 -6
  31. package/dist/{internal-math-BGX23p4h.d.ts → internal-math-rq6do9IR.d.ts} +2 -2
  32. package/dist/internal-math.d.ts +4 -4
  33. package/dist/internal-math.js +1 -1
  34. package/dist/internal.d.ts +4 -4
  35. package/dist/internal.js +3 -3
  36. package/dist/receipt.d.ts +3 -3
  37. package/dist/receipt.js +65 -26
  38. package/dist/{rulers-CpS9qkvu.d.ts → rulers-CFGiWJza.d.ts} +1 -1
  39. package/dist/sky.d.ts +4 -4
  40. package/dist/sky.js +3 -3
  41. package/dist/techniques.d.ts +4 -4
  42. package/dist/techniques.js +9 -9
  43. package/dist/{time-bands-CZA9AlLg.d.ts → time-bands-BCmfa8FR.d.ts} +5 -4
  44. package/dist/{time-scale-DIFNa0gz.d.ts → time-scale-9vmKQPCn.d.ts} +14 -4
  45. package/dist/time.d.ts +3 -3
  46. package/dist/time.js +2 -2
  47. package/dist/timing.d.ts +5 -5
  48. package/dist/timing.js +6 -6
  49. package/dist/{types-BCnyWBQZ.d.ts → types-CkuiCcsV.d.ts} +7 -4
  50. package/dist/{tzdb-2025c-00-6GVG6RYL.js → tzdb-2026f-00-RAB4YONA.js} +4 -4
  51. package/dist/{tzdb-2025c-01-CEYMG3LE.js → tzdb-2026f-01-SWR7EW5U.js} +4 -4
  52. package/dist/{tzdb-2025c-02-NWQJCVUU.js → tzdb-2026f-02-SOLHCLDL.js} +3 -3
  53. package/dist/{tzdb-2025c-03-PLHP6VH4.js → tzdb-2026f-03-LYLMCVL7.js} +3 -3
  54. package/dist/{tzdb-2025c-04-MEKUJA6M.js → tzdb-2026f-04-XTKMZPKX.js} +4 -4
  55. package/dist/{tzdb-2025c-05-3K5YKZBL.js → tzdb-2026f-05-EOKCMY5O.js} +4 -4
  56. package/dist/{tzdb-2025c-06-L2VV5XJV.js → tzdb-2026f-06-O4LQW2N6.js} +4 -4
  57. package/dist/{tzdb-2025c-07-H3GLGJGY.js → tzdb-2026f-07-2FDJ5OJ7.js} +4 -4
  58. package/dist/{tzdb-2025c-08-DA7QQIGD.js → tzdb-2026f-08-OKEWSMIX.js} +4 -4
  59. package/dist/{tzdb-2025c-09-MTXIO3QL.js → tzdb-2026f-09-5GB7FKLF.js} +4 -4
  60. package/dist/{tzdb-2025c-10-ASL4UW5C.js → tzdb-2026f-10-GXHCIASR.js} +4 -4
  61. package/dist/{tzdb-2025c-11-EQEOANYB.js → tzdb-2026f-11-66EMKXFG.js} +4 -4
  62. package/dist/{tzdb-2025c-12-NKCCXJ5G.js → tzdb-2026f-12-YK3CZCIY.js} +3 -3
  63. package/dist/{tzdb-2025c-13-DYTF3UC7.js → tzdb-2026f-13-UNZD3QIH.js} +4 -4
  64. package/dist/{tzdb-2025c-14-C25H45R5.js → tzdb-2026f-14-4FQNGNZM.js} +4 -4
  65. package/dist/{tzdb-2025c-15-7OYYZWRY.js → tzdb-2026f-15-5TA3B2WI.js} +4 -4
  66. package/dist/vedic.d.ts +4 -4
  67. package/dist/vedic.js +6 -6
  68. package/dist/window.d.ts +2 -2
  69. package/dist/window.js +8 -5
  70. package/dist/{zone-history-0XzMGx9V.d.ts → zone-history-2UYUKA43.d.ts} +26 -9
  71. package/package.json +47 -22
package/dist/core.js ADDED
@@ -0,0 +1,2960 @@
1
+ // src/ephemeris.ts
2
+ import {
3
+ Body,
4
+ GeoMoon,
5
+ GeoMoonState,
6
+ GeoVector,
7
+ MakeTime,
8
+ SetDeltaTFunction
9
+ } from "astronomy-engine";
10
+
11
+ // src/aspects.ts
12
+ var ASPECT_TYPES = /* @__PURE__ */ Object.freeze([
13
+ "conjunction",
14
+ "sextile",
15
+ "square",
16
+ "trine",
17
+ "opposition"
18
+ ]);
19
+ var ASPECTS = /* @__PURE__ */ Object.freeze([
20
+ /* @__PURE__ */ Object.freeze({ type: "conjunction", angle: 0, orb: 8, luminaryOrb: 10 }),
21
+ /* @__PURE__ */ Object.freeze({ type: "sextile", angle: 60, orb: 4, luminaryOrb: 5 }),
22
+ /* @__PURE__ */ Object.freeze({ type: "square", angle: 90, orb: 7, luminaryOrb: 8 }),
23
+ /* @__PURE__ */ Object.freeze({ type: "trine", angle: 120, orb: 7, luminaryOrb: 8 }),
24
+ /* @__PURE__ */ Object.freeze({ type: "opposition", angle: 180, orb: 8, luminaryOrb: 10 })
25
+ ]);
26
+ var LUMINARIES = /* @__PURE__ */ new Set(["Sun", "Moon"]);
27
+ var ASPECT_BODY_NAMES = /* @__PURE__ */ Object.freeze([
28
+ "Sun",
29
+ "Moon",
30
+ "Mercury",
31
+ "Venus",
32
+ "Mars",
33
+ "Jupiter",
34
+ "Saturn",
35
+ "Uranus",
36
+ "Neptune",
37
+ "Pluto"
38
+ ]);
39
+ var ASPECT_BODY_SET = /* @__PURE__ */ new Set(ASPECT_BODY_NAMES);
40
+ var ASPECT_BODIES = /* @__PURE__ */ new Set(ASPECT_BODY_NAMES);
41
+ var STATIONARY_RELATIVE_SPEED = 1e-9;
42
+ function aspectMotion(a, b, angle) {
43
+ const relative = a.speed - b.speed;
44
+ if (!(Math.abs(relative) >= STATIONARY_RELATIVE_SPEED)) return "stationary";
45
+ const wrapped = ((a.lon - b.lon) % 360 + 360) % 360;
46
+ const signed = wrapped > 180 ? wrapped - 360 : wrapped;
47
+ const deviation = Math.abs(signed) - angle;
48
+ if (deviation === 0) return "separating";
49
+ return Math.sign(deviation) * Math.sign(signed) * relative < 0 ? "applying" : "separating";
50
+ }
51
+ function separation(a, b) {
52
+ const difference = Math.abs(((a - b) % 360 + 360) % 360);
53
+ return difference > 180 ? 360 - difference : difference;
54
+ }
55
+ function matchAspect(aBody, aLongitude, bBody, bLongitude) {
56
+ const distance = separation(aLongitude, bLongitude);
57
+ const hasLuminary = LUMINARIES.has(aBody) || LUMINARIES.has(bBody);
58
+ let best = null;
59
+ for (const definition of ASPECTS) {
60
+ const orb = Math.abs(distance - definition.angle);
61
+ const maximum = hasLuminary ? definition.luminaryOrb : definition.orb;
62
+ if (orb <= maximum && (!best || orb < best.orb)) {
63
+ best = { definition, orb };
64
+ }
65
+ }
66
+ return best;
67
+ }
68
+ function findAspects(bodies) {
69
+ const candidates = bodies.filter((body) => ASPECT_BODY_SET.has(body.body));
70
+ const aspects = [];
71
+ for (let first = 0; first < candidates.length; first += 1) {
72
+ for (let second = first + 1; second < candidates.length; second += 1) {
73
+ const a = candidates[first];
74
+ const b = candidates[second];
75
+ if (!a || !b) continue;
76
+ const match = matchAspect(a.body, a.lon, b.body, b.lon);
77
+ if (!match) continue;
78
+ aspects.push({
79
+ a: a.body,
80
+ b: b.body,
81
+ type: match.definition.type,
82
+ orb: match.orb,
83
+ applying: aspectMotion(a, b, match.definition.angle) === "applying"
84
+ });
85
+ }
86
+ }
87
+ return aspects.sort((a, b) => a.orb - b.orb);
88
+ }
89
+
90
+ // src/body-label.ts
91
+ var MAX_BODY_LABEL_LENGTH = 80;
92
+ function checkedBodyLabel(value) {
93
+ if (typeof value !== "string" || value.length === 0 || value.length > MAX_BODY_LABEL_LENGTH || value.trim() !== value || /[\u0000-\u001f\u007f]/u.test(value)) {
94
+ throw new RangeError(
95
+ "Body labels must be nonempty, trimmed strings of at most 80 characters, without control characters."
96
+ );
97
+ }
98
+ return value;
99
+ }
100
+
101
+ // src/exact.ts
102
+ var SAFE_MAGNITUDE = 2 ** 1e3;
103
+ function add(partials, value) {
104
+ let x = value;
105
+ let kept = 0;
106
+ for (let index = 0; index < partials.length; index += 1) {
107
+ let y = partials[index];
108
+ if (Math.abs(x) < Math.abs(y)) {
109
+ const larger = y;
110
+ y = x;
111
+ x = larger;
112
+ }
113
+ const high = x + y;
114
+ const low = y - (high - x);
115
+ if (low !== 0) partials[kept++] = low;
116
+ x = high;
117
+ }
118
+ partials.length = kept;
119
+ if (x !== 0) partials.push(x);
120
+ }
121
+ function exactSum(...terms) {
122
+ const partials = [];
123
+ for (const term of terms) {
124
+ if (typeof term === "number") add(partials, term);
125
+ else for (const part of term) add(partials, part);
126
+ }
127
+ return partials;
128
+ }
129
+ function negated(sum) {
130
+ return sum.map((part) => -part);
131
+ }
132
+ function signOf(sum) {
133
+ const top = sum[sum.length - 1];
134
+ return top === void 0 ? 0 : top > 0 ? 1 : -1;
135
+ }
136
+ function compareExact(a, b) {
137
+ return signOf(exactSum(a, typeof b === "number" ? -b : negated(b)));
138
+ }
139
+ function absolute(sum) {
140
+ return signOf(sum) < 0 ? negated(sum) : sum;
141
+ }
142
+ function roundedValue(sum) {
143
+ let index = sum.length;
144
+ if (index === 0) return 0;
145
+ let high = sum[--index];
146
+ let low = 0;
147
+ while (index > 0) {
148
+ const x = high;
149
+ const y = sum[--index];
150
+ high = x + y;
151
+ low = y - (high - x);
152
+ if (low !== 0) break;
153
+ }
154
+ const below = index > 0 ? sum[index - 1] : 0;
155
+ if (low < 0 && below < 0 || low > 0 && below > 0) {
156
+ const twice = low * 2;
157
+ const moved = high + twice;
158
+ if (moved - high === twice) high = moved;
159
+ }
160
+ return high;
161
+ }
162
+ function scaledInteger(value) {
163
+ const view = new DataView(new ArrayBuffer(8));
164
+ view.setFloat64(0, value);
165
+ const upper = view.getUint32(0);
166
+ const exponent = upper >>> 20 & 2047;
167
+ let significand = BigInt(upper & 1048575) << 32n | BigInt(view.getUint32(4));
168
+ if (exponent !== 0) significand = (significand | 1n << 52n) << BigInt(exponent - 1);
169
+ return upper >>> 31 === 1 ? -significand : significand;
170
+ }
171
+ function exactSign(terms) {
172
+ if (terms.every((term) => Math.abs(term) < SAFE_MAGNITUDE)) return signOf(exactSum(...terms));
173
+ let total = 0n;
174
+ for (const term of terms) total += scaledInteger(term);
175
+ return total > 0n ? 1 : total < 0n ? -1 : 0;
176
+ }
177
+
178
+ // src/declination.ts
179
+ var DEG = Math.PI / 180;
180
+ var RAD = 180 / Math.PI;
181
+ var DECLINATION_ORB = 1;
182
+ var DECLINATION_ORB_LUMINARY = 1.5;
183
+ var DEFAULT_DECLINATION_ORB_POLICY = /* @__PURE__ */ Object.freeze({
184
+ orb: DECLINATION_ORB,
185
+ luminaryOrb: DECLINATION_ORB_LUMINARY
186
+ });
187
+ var RA_POLE_TOLERANCE = 32 * Number.EPSILON;
188
+ var MAX_DECLINATION_BODIES = 256;
189
+ var SUN_BOUND_LATITUDE = 1e-3;
190
+ function finite(value, label) {
191
+ if (typeof value !== "number" || !Number.isFinite(value)) {
192
+ throw new RangeError(`${label} must be finite.`);
193
+ }
194
+ }
195
+ function obliquity(value) {
196
+ finite(value, "true obliquity");
197
+ if (value < 0 || value > 90) throw new RangeError("true obliquity must be in [0,90] degrees.");
198
+ }
199
+ function normalize(value) {
200
+ const remainder = value % 360;
201
+ if (remainder === 0) return 0;
202
+ return remainder > 0 ? remainder : Math.min(remainder + 360, 359.99999999999994);
203
+ }
204
+ function policyOf(policy) {
205
+ const fields = dataFields(policy, "declination orb policy");
206
+ if (Object.keys(fields).length !== 2 || !Object.hasOwn(fields, "orb") || !Object.hasOwn(fields, "luminaryOrb")) {
207
+ throw new RangeError("declination orb policy requires only orb and luminaryOrb.");
208
+ }
209
+ const checked = { orb: fields.orb.value, luminaryOrb: fields.luminaryOrb.value };
210
+ for (const key of ["orb", "luminaryOrb"]) {
211
+ finite(checked[key], `declination policy ${key}`);
212
+ if (checked[key] < 0 || checked[key] > 90) throw new RangeError("declination orbs must be in [0,90] degrees.");
213
+ }
214
+ return checked;
215
+ }
216
+ function dataFields(value, label) {
217
+ if (value === null || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
218
+ throw new RangeError(`${label} must be a plain data object.`);
219
+ }
220
+ const fields = Object.getOwnPropertyDescriptors(value);
221
+ if (Reflect.ownKeys(value).length !== Object.keys(fields).length || Object.values(fields).some((field) => !Object.hasOwn(field, "value") || !field.enumerable)) {
222
+ throw new RangeError(`${label} must contain only enumerable data properties.`);
223
+ }
224
+ return fields;
225
+ }
226
+ function bodyName(body) {
227
+ checkedBodyLabel(body);
228
+ }
229
+ function eclipticToEquatorial(longitudeDeg, latitudeDeg, trueObliquityDeg) {
230
+ finite(longitudeDeg, "ecliptic longitude");
231
+ finite(latitudeDeg, "ecliptic latitude");
232
+ if (latitudeDeg < -90 || latitudeDeg > 90) throw new RangeError("ecliptic latitude must be in [-90,90] degrees.");
233
+ obliquity(trueObliquityDeg);
234
+ const lon = normalize(longitudeDeg) * DEG;
235
+ const lat = latitudeDeg * DEG;
236
+ const tilt2 = trueObliquityDeg * DEG;
237
+ const cosLat = Math.cos(lat);
238
+ const x = cosLat * Math.cos(lon);
239
+ const y = cosLat * Math.sin(lon) * Math.cos(tilt2) - Math.sin(lat) * Math.sin(tilt2);
240
+ const z = cosLat * Math.sin(lon) * Math.sin(tilt2) + Math.sin(lat) * Math.cos(tilt2);
241
+ const horizontal = Math.hypot(x, y);
242
+ const raDefined = horizontal > RA_POLE_TOLERANCE;
243
+ let dec = trueObliquityDeg === 0 ? latitudeDeg : Math.atan2(z, horizontal) * RAD;
244
+ if (latitudeDeg === 0) dec = Math.max(-trueObliquityDeg, Math.min(trueObliquityDeg, dec));
245
+ return {
246
+ ra: raDefined ? trueObliquityDeg === 0 ? normalize(longitudeDeg) : normalize(Math.atan2(y, x) * RAD) : null,
247
+ dec: dec === 0 ? 0 : dec,
248
+ raDefined
249
+ };
250
+ }
251
+ function declinationOf(lon, lat, trueObliquity) {
252
+ return eclipticToEquatorial(lon, lat, trueObliquity).dec;
253
+ }
254
+ function declinationOrb(a, b, policy = DEFAULT_DECLINATION_ORB_POLICY) {
255
+ bodyName(a);
256
+ bodyName(b);
257
+ const checked = policyOf(policy);
258
+ return a === "Sun" || a === "Moon" || b === "Sun" || b === "Moon" ? checked.luminaryOrb : checked.orb;
259
+ }
260
+ function placeBodies(bodies, trueObliquity, chartSun = false) {
261
+ obliquity(trueObliquity);
262
+ if (!Array.isArray(bodies) || Object.getPrototypeOf(bodies) !== Array.prototype) {
263
+ throw new RangeError("declination bodies must be a standard array.");
264
+ }
265
+ const fields = Object.getOwnPropertyDescriptors(bodies);
266
+ const length = fields.length.value;
267
+ if (length > MAX_DECLINATION_BODIES || Reflect.ownKeys(bodies).length !== length + 1) {
268
+ throw new RangeError("declination bodies must be dense, undecorated, and contain at most 256 entries.");
269
+ }
270
+ const seen = /* @__PURE__ */ new Set();
271
+ const placed = [];
272
+ const longitudes = [];
273
+ for (let index = 0; index < length; index += 1) {
274
+ const field = fields[String(index)];
275
+ if (!field || !Object.hasOwn(field, "value") || !field.enumerable) {
276
+ throw new RangeError("declination bodies must contain only enumerable data entries.");
277
+ }
278
+ const source2 = dataFields(field.value, "declination body");
279
+ const body = { body: source2.body?.value, lon: source2.lon?.value, lat: source2.lat?.value };
280
+ bodyName(body.body);
281
+ if (seen.has(body.body)) throw new RangeError("duplicate declination body identifier.");
282
+ seen.add(body.body);
283
+ const position2 = eclipticToEquatorial(body.lon, body.lat, trueObliquity);
284
+ const exemptSun = body.body === "Sun" && (chartSun || Math.abs(body.lat) <= SUN_BOUND_LATITUDE);
285
+ placed.push({
286
+ body: body.body,
287
+ lon: normalize(body.lon),
288
+ lat: body.lat,
289
+ ...position2,
290
+ outOfBounds: !exemptSun && Math.abs(position2.dec) > trueObliquity,
291
+ boundMarginArcsec: (Math.abs(position2.dec) - trueObliquity) * 3600
292
+ });
293
+ longitudes.push(body.lon);
294
+ }
295
+ return { rows: placed, longitudes };
296
+ }
297
+ function longitudeSeparation(a, b) {
298
+ let difference = exactSum(a % 360, -(b % 360));
299
+ while (signOf(difference) < 0) difference = exactSum(difference, 360);
300
+ while (compareExact(difference, 360) >= 0) difference = exactSum(difference, -360);
301
+ return roundedValue(compareExact(difference, 180) > 0 ? exactSum(360, negated(difference)) : difference);
302
+ }
303
+ function aspectsFor({ rows, longitudes }, policy) {
304
+ const found = [];
305
+ for (let i = 0; i < rows.length; i += 1) {
306
+ for (let j = i + 1; j < rows.length; j += 1) {
307
+ const a = rows[i];
308
+ const b = rows[j];
309
+ const parallel = absolute(exactSum(a.dec, -b.dec));
310
+ const contraparallel = absolute(exactSum(a.dec, b.dec));
311
+ const isParallel = compareExact(parallel, contraparallel) <= 0;
312
+ const exactOrb = isParallel ? parallel : contraparallel;
313
+ const maximumOrb = declinationOrb(a.body, b.body, policy);
314
+ if (compareExact(exactOrb, maximumOrb) > 0) continue;
315
+ found.push({ exactOrb, aspect: {
316
+ a: a.body,
317
+ b: b.body,
318
+ type: isParallel ? "parallel" : "contraparallel",
319
+ orb: roundedValue(exactOrb),
320
+ maximumOrb,
321
+ decA: a.dec,
322
+ decB: b.dec,
323
+ separation: longitudeSeparation(longitudes[i], longitudes[j])
324
+ } });
325
+ }
326
+ }
327
+ return found.sort((x, y) => compareExact(x.exactOrb, y.exactOrb)).map((entry) => entry.aspect);
328
+ }
329
+ function findDeclinationAspects(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
330
+ const checked = policyOf(policy);
331
+ return aspectsFor(placeBodies(bodies, trueObliquity), checked);
332
+ }
333
+ function declinations(bodies, trueObliquity, policy, chartSun) {
334
+ const checked = policyOf(policy);
335
+ const placed = placeBodies(bodies, trueObliquity, chartSun);
336
+ return {
337
+ trueObliquity,
338
+ rows: placed.rows,
339
+ aspects: aspectsFor(placed, checked),
340
+ orbPolicy: checked,
341
+ convention: "true-equator-and-equinox-of-date; full-ecliptic-longitude-and-latitude",
342
+ receiptScope: "not-included-in-natal-receipt"
343
+ };
344
+ }
345
+ function declinationsForBodies(bodies, trueObliquity, policy = DEFAULT_DECLINATION_ORB_POLICY) {
346
+ return declinations(bodies, trueObliquity, policy, false);
347
+ }
348
+ function chartBodyDeclinations(bodies, trueObliquity) {
349
+ return declinations(bodies, trueObliquity, DEFAULT_DECLINATION_ORB_POLICY, true);
350
+ }
351
+
352
+ // src/deltat.ts
353
+ var DELTA_T_MODEL = "zodiacs-deltat/1";
354
+ var DELTA_T_TABLE = /* @__PURE__ */ Object.freeze({
355
+ version: "2026-09-24",
356
+ digest: "6371988c510a1c6c",
357
+ from: 1941,
358
+ observedTo: 61307,
359
+ predictedTo: 61680,
360
+ knots: /* @__PURE__ */ Object.freeze([
361
+ 2482,
362
+ 48,
363
+ 47,
364
+ 50,
365
+ 49,
366
+ 51,
367
+ 50,
368
+ 48,
369
+ 45,
370
+ 45,
371
+ 42,
372
+ 40,
373
+ 39,
374
+ 36,
375
+ 35,
376
+ 28,
377
+ 33,
378
+ 49,
379
+ 50,
380
+ 48,
381
+ 43,
382
+ 42,
383
+ 47,
384
+ 56,
385
+ 71,
386
+ 80,
387
+ 89,
388
+ 87,
389
+ 90,
390
+ 98,
391
+ 99,
392
+ 106,
393
+ 114,
394
+ 111,
395
+ 100,
396
+ 98,
397
+ 106,
398
+ 101,
399
+ 106,
400
+ 95,
401
+ 84,
402
+ 79,
403
+ 79,
404
+ 83,
405
+ 55,
406
+ 53,
407
+ 45,
408
+ 50,
409
+ 48,
410
+ 56,
411
+ 71,
412
+ 74,
413
+ 81,
414
+ 86,
415
+ 81,
416
+ 84,
417
+ 66,
418
+ 68,
419
+ 50,
420
+ 36,
421
+ 26,
422
+ 21,
423
+ 17,
424
+ 10,
425
+ 12,
426
+ 16,
427
+ 30,
428
+ 31,
429
+ 32,
430
+ 29,
431
+ 25,
432
+ 28,
433
+ 31,
434
+ 37,
435
+ 36,
436
+ 46,
437
+ 49,
438
+ 38,
439
+ 25,
440
+ 14,
441
+ 0,
442
+ -7,
443
+ -9,
444
+ -2,
445
+ -4,
446
+ -3,
447
+ 9,
448
+ 10,
449
+ 7,
450
+ 1,
451
+ -5
452
+ ])
453
+ });
454
+ var SX = [-720, 400, 1e3, 1500, 1600, 1650, 1720, 1800, 1810, 1820, 1830, 1840];
455
+ var SY = [
456
+ 2055059,
457
+ 660440,
458
+ 146765,
459
+ 29264,
460
+ 8938,
461
+ 4374,
462
+ 1073,
463
+ 1871,
464
+ 1526,
465
+ 1668,
466
+ 1076,
467
+ 767,
468
+ 932,
469
+ 1038,
470
+ 904,
471
+ 826,
472
+ 237,
473
+ -113,
474
+ -321,
475
+ -439,
476
+ -388,
477
+ -502,
478
+ -198,
479
+ 492,
480
+ 1114,
481
+ 1748,
482
+ 2162,
483
+ 2379,
484
+ 2442,
485
+ 2416,
486
+ 2443,
487
+ 2705
488
+ ];
489
+ var SIG = [
490
+ 640,
491
+ 83,
492
+ 900,
493
+ 230,
494
+ 1240,
495
+ 120,
496
+ 1400,
497
+ 15,
498
+ 1420,
499
+ 7.5,
500
+ 1440,
501
+ 4.2,
502
+ 1500,
503
+ 5.6,
504
+ 1560,
505
+ 27,
506
+ 1670,
507
+ 15,
508
+ 1710,
509
+ 3.3,
510
+ 1720,
511
+ 3.3,
512
+ 1760,
513
+ 1.5,
514
+ 1800,
515
+ 1.5,
516
+ 1810,
517
+ 0.55,
518
+ 1820,
519
+ 0.55,
520
+ 1840,
521
+ 0.46,
522
+ 1956,
523
+ 0.46
524
+ ];
525
+ var X;
526
+ var Y;
527
+ var M;
528
+ var KX;
529
+ var KV;
530
+ var OBS;
531
+ var PRED;
532
+ var SLOPE;
533
+ var yearOfMjd = (mjd) => 2e3 + (mjd - 51544.5) / 365.25;
534
+ var longTerm = (y) => {
535
+ const t = (y - 1825) / 100;
536
+ return 36.525 * (0.89 * t * t + 30 / Math.PI * Math.cos(Math.PI * t / 7.5));
537
+ };
538
+ var longTermRate = (y) => {
539
+ const t = (y - 1825) / 100;
540
+ return 0.36525 * (1.78 * t - 4 * Math.sin(Math.PI * t / 7.5));
541
+ };
542
+ function init() {
543
+ const x = SX.slice();
544
+ for (let year = 1850; year <= 1945; year += 5) x.push(year);
545
+ const y = SY.map((v) => v / 100);
546
+ const n = x.length - 1;
547
+ const m = [0.018915];
548
+ const c = [0];
549
+ const r = [0.018915];
550
+ for (let i = 1; i < n; i++) {
551
+ const a = x[i] - x[i - 1];
552
+ const b = x[i + 1] - x[i];
553
+ const p = 2 * (a + b) - a * c[i - 1];
554
+ c[i] = b / p;
555
+ r[i] = (6 * ((y[i + 1] - y[i]) / b - (y[i] - y[i - 1]) / a) - a * r[i - 1]) / p;
556
+ }
557
+ m[n] = -0.09856;
558
+ for (let i = n - 1; i > 0; i--) m[i] = r[i] - c[i] * m[i + 1];
559
+ const T = DELTA_T_TABLE;
560
+ const obs = yearOfMjd(T.observedTo);
561
+ const pred = yearOfMjd(T.predictedTo);
562
+ const kv = [];
563
+ let total = 0;
564
+ for (const step of T.knots) kv.push((total += step) / 100);
565
+ const years = kv.length - 5;
566
+ const kx = [];
567
+ for (let i = 0; i < years; i++) kx.push(T.from + i);
568
+ for (let k = 0; k < 5; k++) kx.push(obs + k * (pred - obs) / 4);
569
+ X = x;
570
+ Y = y;
571
+ M = m;
572
+ KX = kx;
573
+ KV = kv;
574
+ OBS = obs;
575
+ PRED = pred;
576
+ SLOPE = (kv[years + 4] - kv[years]) / (pred - obs);
577
+ }
578
+ function seconds(t) {
579
+ const x = X;
580
+ const y = Y;
581
+ const m = M;
582
+ const kx = KX;
583
+ const kv = KV;
584
+ if (t < -720) return y[0] + longTerm(t) - longTerm(-720);
585
+ if (t < 1941) {
586
+ let i = x.length - 2;
587
+ while (t < x[i]) i--;
588
+ const h = x[i + 1] - x[i];
589
+ const a = x[i + 1] - t;
590
+ const b = t - x[i];
591
+ return (m[i] * a ** 3 + m[i + 1] * b ** 3) / (6 * h) + (y[i] / h - m[i] * h / 6) * a + (y[i + 1] / h - m[i + 1] * h / 6) * b;
592
+ }
593
+ const n = kx.length - 1;
594
+ if (t <= kx[n]) {
595
+ const i = t < OBS ? Math.floor(t - 1941) : n - 4 + Math.min(3, Math.floor(4 * (t - OBS) / (PRED - OBS)));
596
+ return kv[i] + (t - kx[i]) * (kv[i + 1] - kv[i]) / (kx[i + 1] - kx[i]);
597
+ }
598
+ const g = t - PRED;
599
+ return kv[n] + SLOPE * 15 * (1 - Math.exp(-g / 15)) + longTerm(t) - longTerm(PRED) - longTermRate(PRED) * g;
600
+ }
601
+ function sigma(t) {
602
+ const h = t - OBS;
603
+ if (h > 0) return h <= 1 ? 0.03 + 0.09 * h ** 0.75 : h <= 10 ? 0.12 * h ** 1.5 : 0.61 * h - 2.3052668;
604
+ if (t >= 1956) return 0.03;
605
+ const c = (t - 1825) / 100;
606
+ let v = t < 1620 ? 0.6 * c * c : 0;
607
+ if (t >= 640) {
608
+ let i = 0;
609
+ while (t >= SIG[i + 2]) i += 2;
610
+ v = Math.max(v, SIG[i + 1] + (t - SIG[i]) * (SIG[i + 3] - SIG[i + 1]) / (SIG[i + 2] - SIG[i]));
611
+ }
612
+ return v;
613
+ }
614
+ function deltaTAt(ut) {
615
+ if (!Number.isFinite(ut)) throw new RangeError("deltaTAt takes a finite UT: days since 2000-01-01T12:00 on UT1.");
616
+ const t = 2e3 + ut / 365.25;
617
+ if (!X) init();
618
+ return {
619
+ seconds: seconds(t),
620
+ sigma: sigma(t),
621
+ model: DELTA_T_MODEL,
622
+ table: DELTA_T_TABLE.version,
623
+ tableDigest: DELTA_T_TABLE.digest,
624
+ segment: t < -720 ? "long-term" : t < 1956 ? "reconstructed" : t <= OBS ? "observed" : t <= PRED ? "predicted" : "extrapolated"
625
+ };
626
+ }
627
+ function deltaT(ut) {
628
+ if (!Number.isFinite(ut)) throw new RangeError("deltaT takes a finite UT: days since 2000-01-01T12:00 on UT1.");
629
+ if (!X) init();
630
+ return seconds(2e3 + ut / 365.25);
631
+ }
632
+
633
+ // src/core/ephemeris-shipped.ts
634
+ var INITIAL_DEFAULT_EPHEMERIS = "astronomy-engine";
635
+ function shippedDe440Source() {
636
+ throw new Error("@zodiacs/engine/core carries no DE440 pack; supply one through @zodiacs/engine/de440 and withEphemeris, or import @zodiacs/engine");
637
+ }
638
+
639
+ // src/signs.ts
640
+ var ELEMENTS = /* @__PURE__ */ Object.freeze(["fire", "earth", "air", "water"]);
641
+ var MODALITIES = /* @__PURE__ */ Object.freeze(["cardinal", "fixed", "mutable"]);
642
+ var SIGNS = /* @__PURE__ */ Object.freeze([
643
+ /* @__PURE__ */ Object.freeze({
644
+ slug: "aries",
645
+ name: "Aries",
646
+ element: "fire",
647
+ modality: "cardinal",
648
+ polarity: "day",
649
+ naturalHouse: 1
650
+ }),
651
+ /* @__PURE__ */ Object.freeze({
652
+ slug: "taurus",
653
+ name: "Taurus",
654
+ element: "earth",
655
+ modality: "fixed",
656
+ polarity: "night",
657
+ naturalHouse: 2
658
+ }),
659
+ /* @__PURE__ */ Object.freeze({
660
+ slug: "gemini",
661
+ name: "Gemini",
662
+ element: "air",
663
+ modality: "mutable",
664
+ polarity: "day",
665
+ naturalHouse: 3
666
+ }),
667
+ /* @__PURE__ */ Object.freeze({
668
+ slug: "cancer",
669
+ name: "Cancer",
670
+ element: "water",
671
+ modality: "cardinal",
672
+ polarity: "night",
673
+ naturalHouse: 4
674
+ }),
675
+ /* @__PURE__ */ Object.freeze({
676
+ slug: "leo",
677
+ name: "Leo",
678
+ element: "fire",
679
+ modality: "fixed",
680
+ polarity: "day",
681
+ naturalHouse: 5
682
+ }),
683
+ /* @__PURE__ */ Object.freeze({
684
+ slug: "virgo",
685
+ name: "Virgo",
686
+ element: "earth",
687
+ modality: "mutable",
688
+ polarity: "night",
689
+ naturalHouse: 6
690
+ }),
691
+ /* @__PURE__ */ Object.freeze({
692
+ slug: "libra",
693
+ name: "Libra",
694
+ element: "air",
695
+ modality: "cardinal",
696
+ polarity: "day",
697
+ naturalHouse: 7
698
+ }),
699
+ /* @__PURE__ */ Object.freeze({
700
+ slug: "scorpio",
701
+ name: "Scorpio",
702
+ element: "water",
703
+ modality: "fixed",
704
+ polarity: "night",
705
+ naturalHouse: 8
706
+ }),
707
+ /* @__PURE__ */ Object.freeze({
708
+ slug: "sagittarius",
709
+ name: "Sagittarius",
710
+ element: "fire",
711
+ modality: "mutable",
712
+ polarity: "day",
713
+ naturalHouse: 9
714
+ }),
715
+ /* @__PURE__ */ Object.freeze({
716
+ slug: "capricorn",
717
+ name: "Capricorn",
718
+ element: "earth",
719
+ modality: "cardinal",
720
+ polarity: "night",
721
+ naturalHouse: 10
722
+ }),
723
+ /* @__PURE__ */ Object.freeze({
724
+ slug: "aquarius",
725
+ name: "Aquarius",
726
+ element: "air",
727
+ modality: "fixed",
728
+ polarity: "day",
729
+ naturalHouse: 11
730
+ }),
731
+ /* @__PURE__ */ Object.freeze({
732
+ slug: "pisces",
733
+ name: "Pisces",
734
+ element: "water",
735
+ modality: "mutable",
736
+ polarity: "night",
737
+ naturalHouse: 12
738
+ })
739
+ ]);
740
+ var SIGN_SLUGS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SIGNS.map((sign) => sign.slug));
741
+ var SIGN_NAMES = SIGN_SLUGS;
742
+ function normalizeLongitude(lon) {
743
+ if (!Number.isFinite(lon)) throw new RangeError("Longitude must be finite.");
744
+ return (lon % 360 + 360) % 360;
745
+ }
746
+ function signIndexForLongitude(lon) {
747
+ return Math.floor(normalizeLongitude(lon) / 30);
748
+ }
749
+ function signForLongitude(lon) {
750
+ const sign = SIGNS[signIndexForLongitude(lon)];
751
+ if (!sign) throw new RangeError("Could not resolve zodiac sign.");
752
+ return sign;
753
+ }
754
+ function degreeInSign(lon) {
755
+ return normalizeLongitude(lon) % 30;
756
+ }
757
+
758
+ // src/houses.ts
759
+ var DEG2 = Math.PI / 180;
760
+ var RAD2 = 180 / Math.PI;
761
+ var HOUSE_SYSTEMS = /* @__PURE__ */ Object.freeze([
762
+ "whole",
763
+ "placidus",
764
+ "porphyry",
765
+ "equal",
766
+ "equal-mc",
767
+ "vehlow",
768
+ "koch",
769
+ "regiomontanus",
770
+ "campanus",
771
+ "topocentric",
772
+ "alcabitius",
773
+ "morinus",
774
+ "meridian"
775
+ ]);
776
+ var POLAR_UNDEFINED_HOUSE_SYSTEMS = /* @__PURE__ */ Object.freeze(["placidus", "koch"]);
777
+ var POLAR_FALLBACK = "whole";
778
+ var PLACIDUS_POLAR_FALLBACK = POLAR_FALLBACK;
779
+ var insidePolarCircle = (input) => Math.abs(input.latitude) >= 90 - input.obliquity;
780
+ function isPolarUndefinedHouseSystem(system) {
781
+ return POLAR_UNDEFINED_HOUSE_SYSTEMS.includes(system);
782
+ }
783
+ function meanObliquity(julianCenturies) {
784
+ const t = julianCenturies;
785
+ const arcseconds = 84381.406 - 46.836769 * t - 1831e-7 * t * t + 20034e-7 * t ** 3 - 576e-9 * t ** 4 - 434e-10 * t ** 5;
786
+ return arcseconds / 3600;
787
+ }
788
+ function eclipticLongitudeOfRightAscension(ra, obliquity2) {
789
+ return normalizeLongitude(
790
+ Math.atan2(Math.sin(ra * DEG2), Math.cos(ra * DEG2) * Math.cos(obliquity2 * DEG2)) * RAD2
791
+ );
792
+ }
793
+ function declinationOfLongitude(lon, obliquity2) {
794
+ return Math.asin(Math.sin(obliquity2 * DEG2) * Math.sin(lon * DEG2)) * RAD2;
795
+ }
796
+ function obliqueLongitude(ascension, pole, obliquity2) {
797
+ const a = ascension * DEG2;
798
+ const e = obliquity2 * DEG2;
799
+ return normalizeLongitude(
800
+ Math.atan2(Math.sin(a), Math.cos(a) * Math.cos(e) - Math.tan(pole * DEG2) * Math.sin(e)) * RAD2
801
+ );
802
+ }
803
+ function quadrantCusps(asc, mc, cusp11, cusp12, cusp2, cusp3) {
804
+ return [
805
+ asc,
806
+ cusp2,
807
+ cusp3,
808
+ mc + 180,
809
+ cusp11 + 180,
810
+ cusp12 + 180,
811
+ asc + 180,
812
+ cusp2 + 180,
813
+ cusp3 + 180,
814
+ mc,
815
+ cusp11,
816
+ cusp12
817
+ ].map(normalizeLongitude);
818
+ }
819
+ function ramcOf(input) {
820
+ return normalizeLongitude(input.gastHours * 15 + input.longitude);
821
+ }
822
+ function computeAngles(input) {
823
+ const ramc = ramcOf(input);
824
+ const mc = eclipticLongitudeOfRightAscension(ramc, input.obliquity);
825
+ const ra = ramc * DEG2;
826
+ const eps = input.obliquity * DEG2;
827
+ const phi = input.latitude * DEG2;
828
+ let asc = normalizeLongitude(
829
+ Math.atan2(Math.cos(ra), -(Math.sin(ra) * Math.cos(eps) + Math.tan(phi) * Math.sin(eps))) * RAD2
830
+ );
831
+ if (normalizeLongitude(asc - mc) >= 180) asc = normalizeLongitude(asc + 180);
832
+ return {
833
+ asc,
834
+ mc,
835
+ dsc: normalizeLongitude(asc + 180),
836
+ ic: normalizeLongitude(mc + 180)
837
+ };
838
+ }
839
+ function wholeSignCusps(ascendant) {
840
+ const first = Math.floor(normalizeLongitude(ascendant) / 30) * 30;
841
+ return Array.from({ length: 12 }, (_, index) => normalizeLongitude(first + index * 30));
842
+ }
843
+ function placidusCusps(input, angles) {
844
+ if (insidePolarCircle(input)) return null;
845
+ const ramc = ramcOf(input);
846
+ const phi = input.latitude * DEG2;
847
+ function iterate(offset, multiplier) {
848
+ let ra = ramc + offset;
849
+ let converged = false;
850
+ for (let index = 0; index < 64; index += 1) {
851
+ const lon = eclipticLongitudeOfRightAscension(normalizeLongitude(ra), input.obliquity);
852
+ const declination = declinationOfLongitude(lon, input.obliquity);
853
+ const argument = Math.tan(phi) * Math.tan(declination * DEG2);
854
+ if (Math.abs(argument) >= 1) break;
855
+ const ascensionalDifference = Math.asin(argument) * RAD2;
856
+ const next = ramc + offset + multiplier * ascensionalDifference;
857
+ if (Math.abs(normalizeLongitude(next - ra + 180) - 180) < 1e-9) {
858
+ ra = next;
859
+ converged = true;
860
+ break;
861
+ }
862
+ ra = next;
863
+ }
864
+ return eclipticLongitudeOfRightAscension(
865
+ normalizeLongitude(converged ? ra : bracketed(offset, multiplier)),
866
+ input.obliquity
867
+ );
868
+ }
869
+ function bracketed(offset, multiplier) {
870
+ const centre = ramc + offset;
871
+ let low = centre - 90 * multiplier - 1;
872
+ let high = centre + 90 * multiplier + 1;
873
+ for (let index = 0; index < 128; index += 1) {
874
+ const middle = (low + high) / 2;
875
+ if (!(middle > low && middle < high)) break;
876
+ const lon = eclipticLongitudeOfRightAscension(normalizeLongitude(middle), input.obliquity);
877
+ const declination = declinationOfLongitude(lon, input.obliquity);
878
+ const argument = Math.min(1, Math.max(-1, Math.tan(phi) * Math.tan(declination * DEG2)));
879
+ if (centre + multiplier * Math.asin(argument) * RAD2 > middle) low = middle;
880
+ else high = middle;
881
+ }
882
+ return (low + high) / 2;
883
+ }
884
+ const cusp11 = iterate(30, 1 / 3);
885
+ const cusp12 = iterate(60, 2 / 3);
886
+ const cusp2 = iterate(120, 2 / 3);
887
+ const cusp3 = iterate(150, 1 / 3);
888
+ return [
889
+ angles.asc,
890
+ cusp2,
891
+ cusp3,
892
+ angles.ic,
893
+ normalizeLongitude(cusp11 + 180),
894
+ normalizeLongitude(cusp12 + 180),
895
+ angles.dsc,
896
+ normalizeLongitude(cusp2 + 180),
897
+ normalizeLongitude(cusp3 + 180),
898
+ angles.mc,
899
+ cusp11,
900
+ cusp12
901
+ ];
902
+ }
903
+ function porphyryCusps(angles) {
904
+ const upper = normalizeLongitude(angles.asc - angles.mc);
905
+ const lower = normalizeLongitude(angles.ic - angles.asc);
906
+ const cusp11 = normalizeLongitude(angles.mc + upper / 3);
907
+ const cusp12 = normalizeLongitude(angles.mc + 2 * upper / 3);
908
+ const cusp2 = normalizeLongitude(angles.asc + lower / 3);
909
+ const cusp3 = normalizeLongitude(angles.asc + 2 * lower / 3);
910
+ return [
911
+ angles.asc,
912
+ cusp2,
913
+ cusp3,
914
+ angles.ic,
915
+ normalizeLongitude(cusp11 + 180),
916
+ normalizeLongitude(cusp12 + 180),
917
+ angles.dsc,
918
+ normalizeLongitude(cusp2 + 180),
919
+ normalizeLongitude(cusp3 + 180),
920
+ angles.mc,
921
+ cusp11,
922
+ cusp12
923
+ ];
924
+ }
925
+ function equalCusps(angles) {
926
+ return Array.from({ length: 12 }, (_, index) => normalizeLongitude(angles.asc + index * 30));
927
+ }
928
+ function equalMcCusps(angles) {
929
+ return Array.from({ length: 12 }, (_, index) => normalizeLongitude(angles.mc + (index - 9) * 30));
930
+ }
931
+ function vehlowCusps(angles) {
932
+ return Array.from({ length: 12 }, (_, index) => normalizeLongitude(angles.asc - 15 + index * 30));
933
+ }
934
+ function kochCusps(input, angles) {
935
+ if (insidePolarCircle(input)) return null;
936
+ const ramc = ramcOf(input);
937
+ const argument = Math.tan(input.latitude * DEG2) * Math.tan(declinationOfLongitude(angles.mc, input.obliquity) * DEG2);
938
+ const third = (90 + Math.asin(argument) * RAD2) / 3;
939
+ const at = (offset) => obliqueLongitude(ramc + 90 + offset, input.latitude, input.obliquity);
940
+ return quadrantCusps(angles.asc, angles.mc, at(-2 * third), at(-third), at(third), at(2 * third));
941
+ }
942
+ function circleCusps(input, angles, circles) {
943
+ const ramc = ramcOf(input);
944
+ const [c11, c12, c2, c3] = circles.map(
945
+ ([ascension, pole]) => obliqueLongitude(ramc + ascension, pole, input.obliquity)
946
+ );
947
+ const asc = obliqueLongitude(ramc + 90, input.latitude, input.obliquity);
948
+ const cusps = quadrantCusps(asc, angles.mc, c11, c12, c2, c3);
949
+ const turned = normalizeLongitude(asc - angles.mc) >= 180;
950
+ return turned ? cusps.map((cusp) => normalizeLongitude(cusp + 180)) : cusps;
951
+ }
952
+ function regiomontanusCusps(input, angles) {
953
+ const tangent = Math.tan(input.latitude * DEG2);
954
+ const near = Math.atan(tangent * 0.5) * RAD2;
955
+ const far = Math.atan(tangent * Math.cos(30 * DEG2)) * RAD2;
956
+ return circleCusps(input, angles, [
957
+ [30, near],
958
+ [60, far],
959
+ [120, far],
960
+ [150, near]
961
+ ]);
962
+ }
963
+ function campanusCusps(input, angles) {
964
+ const sine = Math.sin(input.latitude * DEG2);
965
+ const cosine = Math.cos(input.latitude * DEG2);
966
+ const near = Math.asin(sine / 2) * RAD2;
967
+ const far = Math.asin(Math.sqrt(3) / 2 * sine) * RAD2;
968
+ const wide = Math.atan(Math.sqrt(3) / cosine) * RAD2;
969
+ const narrow = Math.atan(1 / (Math.sqrt(3) * cosine)) * RAD2;
970
+ return circleCusps(input, angles, [
971
+ [90 - wide, near],
972
+ [90 - narrow, far],
973
+ [90 + narrow, far],
974
+ [90 + wide, near]
975
+ ]);
976
+ }
977
+ function topocentricCusps(input, angles) {
978
+ const tangent = Math.tan(input.latitude * DEG2);
979
+ const near = Math.atan(tangent / 3) * RAD2;
980
+ const far = Math.atan(tangent * 2 / 3) * RAD2;
981
+ return circleCusps(input, angles, [
982
+ [30, near],
983
+ [60, far],
984
+ [120, far],
985
+ [150, near]
986
+ ]);
987
+ }
988
+ function alcabitiusCusps(input, angles) {
989
+ const ramc = ramcOf(input);
990
+ const declination = declinationOfLongitude(angles.asc, input.obliquity);
991
+ const argument = -Math.tan(input.latitude * DEG2) * Math.tan(declination * DEG2);
992
+ const day = Math.acos(Math.min(1, Math.max(-1, argument))) * RAD2;
993
+ const night = 180 - day;
994
+ const at = (ascension) => obliqueLongitude(ramc + ascension, 0, input.obliquity);
995
+ return quadrantCusps(
996
+ angles.asc,
997
+ angles.mc,
998
+ at(day / 3),
999
+ at(2 * day / 3),
1000
+ at(180 - 2 * night / 3),
1001
+ at(180 - night / 3)
1002
+ );
1003
+ }
1004
+ function equatorialCusps(input, project) {
1005
+ const ramc = ramcOf(input);
1006
+ return Array.from({ length: 12 }, (_, index) => project(ramc + 90 + index * 30));
1007
+ }
1008
+ function meridianCusps(input) {
1009
+ return equatorialCusps(input, (ascension) => obliqueLongitude(ascension, 0, input.obliquity));
1010
+ }
1011
+ function morinusCusps(input) {
1012
+ const e = input.obliquity * DEG2;
1013
+ return equatorialCusps(
1014
+ input,
1015
+ (ascension) => normalizeLongitude(
1016
+ Math.atan2(Math.sin(ascension * DEG2) * Math.cos(e), Math.cos(ascension * DEG2)) * RAD2
1017
+ )
1018
+ );
1019
+ }
1020
+ function eastPointOf(input) {
1021
+ return obliqueLongitude(ramcOf(input) + 90, 0, input.obliquity);
1022
+ }
1023
+ function vertexOf(input, angles) {
1024
+ const colatitude = input.latitude >= 0 ? 90 - input.latitude : -90 - input.latitude;
1025
+ const vertex = obliqueLongitude(ramcOf(input) - 90, colatitude, input.obliquity);
1026
+ return normalizeLongitude(vertex - angles.mc) >= 180 ? vertex : normalizeLongitude(vertex + 180);
1027
+ }
1028
+ function computeHouses(system, input, angles) {
1029
+ const as = (cusps) => ({
1030
+ houses: { system, cusps },
1031
+ fellBack: false,
1032
+ fallbackSystem: null
1033
+ });
1034
+ const polar = (cusps) => cusps ? as(cusps) : {
1035
+ houses: { system: POLAR_FALLBACK, cusps: wholeSignCusps(angles.asc) },
1036
+ fellBack: true,
1037
+ fallbackSystem: POLAR_FALLBACK
1038
+ };
1039
+ switch (system) {
1040
+ case "placidus":
1041
+ return polar(placidusCusps(input, angles));
1042
+ case "koch":
1043
+ return polar(kochCusps(input, angles));
1044
+ case "porphyry":
1045
+ return as(porphyryCusps(angles));
1046
+ case "equal":
1047
+ return as(equalCusps(angles));
1048
+ case "equal-mc":
1049
+ return as(equalMcCusps(angles));
1050
+ case "vehlow":
1051
+ return as(vehlowCusps(angles));
1052
+ case "regiomontanus":
1053
+ return as(regiomontanusCusps(input, angles));
1054
+ case "campanus":
1055
+ return as(campanusCusps(input, angles));
1056
+ case "topocentric":
1057
+ return as(topocentricCusps(input, angles));
1058
+ case "alcabitius":
1059
+ return as(alcabitiusCusps(input, angles));
1060
+ case "morinus":
1061
+ return as(morinusCusps(input));
1062
+ case "meridian":
1063
+ return as(meridianCusps(input));
1064
+ case "whole":
1065
+ return as(wholeSignCusps(angles.asc));
1066
+ default:
1067
+ throw new RangeError(`Unknown house system ${String(system)}.`);
1068
+ }
1069
+ }
1070
+ function houseOf(longitude, cusps) {
1071
+ if (cusps.length !== 12) throw new RangeError("House cusps must contain 12 longitudes.");
1072
+ for (let index = 0; index < 12; index += 1) {
1073
+ const start = cusps[index];
1074
+ const end = cusps[(index + 1) % 12];
1075
+ if (start === void 0 || end === void 0) continue;
1076
+ const span = normalizeLongitude(end - start);
1077
+ const offset = normalizeLongitude(longitude - start);
1078
+ if (offset < span || span === 0) return index + 1;
1079
+ }
1080
+ return 12;
1081
+ }
1082
+
1083
+ // src/nutation.ts
1084
+ var DEG3 = Math.PI / 180;
1085
+ var ARCSEC = DEG3 / 3600;
1086
+ var ARGUMENTS = [
1087
+ 485868.249036,
1088
+ 17179159232178e-4,
1089
+ 128710479305e-5,
1090
+ 1295965810481e-4,
1091
+ 335779.526232,
1092
+ 17395272628478e-4,
1093
+ 107226070369e-5,
1094
+ 1602961601209e-3,
1095
+ 450160.398036,
1096
+ -69628905431e-4
1097
+ ];
1098
+ var MULTIPLIERS = "2222322404224242222423222234043222222423324242140422403124241224232223122231244432423024232224222444204040224242424324041242342222224222322312243244042204232203212231244324222324440242223424224432142422243324034240402243424232140322203112424220332242234033122202424524242124231424222321144412422214440222333424422231323233222324221240332224122322243412464132332040332443024441222433404";
1099
+ var COEFFICIENT_TEXT = "-172064161,-174666,33386,92052331,9086,15377,-13170906,-1675,-13696,5730336,-3015,-4587,-2276413,-234,2796,978459,-485,1374,2074554,207,-698,-897492,470,-291,1475877,-3633,11817,73871,-184,-1924,-516821,1226,-524,224386,-677,-174,711159,73,-872,-6750,0,358,-387298,-367,380,200728,18,318,-301461,-36,816,129025,-63,367,215829,-494,111,-95929,299,132,128227,137,181,-68982,-9,39,123457,11,19,-53311,32,-4,156994,10,-168,-1235,0,82,63110,63,27,-33228,0,-9,-57976,-63,-189,31429,0,-75,-59641,-11,149,25543,-11,66,-51613,-42,129,26366,0,78,45893,50,31,-24236,-10,20,63384,11,-150,-1220,0,29,-38571,-1,158,16452,-11,68,32481,0,0,-13870,0,0,-47722,0,-18,477,0,-25,-31046,-1,131,13238,-11,59,28593,0,-1,-12338,10,-3,20441,21,10,-10758,0,-3,29243,0,-74,-609,0,13,25887,0,-66,-550,0,11,-14053,-25,79,8551,-2,-45,15164,10,11,-8001,0,-1,-15794,72,-16,6850,-42,-5,21783,0,13,-167,0,13,-12873,-10,-37,6953,0,-14,-12654,11,63,6415,0,26,-10204,0,25,5222,0,15,16707,-85,-10,168,-1,10,-7691,0,44,3268,0,19,-11024,0,-14,104,0,2,7566,-21,-11,-3250,0,-5,-6637,-11,25,3353,0,14,-7141,21,8,3070,0,4,-6302,-11,2,3272,0,4,5800,10,2,-3045,0,-1,6443,0,-7,-2768,0,-4,-5774,-11,-15,3041,0,-5,-5350,0,21,2695,0,12,-4752,-11,-3,2719,0,-3,-4940,-11,-21,2720,0,-9,7350,0,-8,-51,0,4,4065,0,6,-2206,0,1,6579,0,-24,-199,0,2,3579,0,5,-1900,0,1,4725,0,-6,-41,0,3,-3075,0,-2,1313,0,-1,-2904,0,15,1233,0,7,4348,0,-10,-81,0,2,-2878,0,8,1232,0,4,-4230,0,5,-20,0,-2,-2819,0,7,1207,0,3,-4056,0,5,40,0,-2,-2647,0,11,1129,0,5,-2294,0,-10,1266,0,-4,2481,0,-7,-1062,0,-3,2179,0,-2,-1129,0,-2,3276,0,1,-9,0,0,-3389,0,5,35,0,-2,3339,0,-13,-107,0,1,-1987,0,-6,1073,0,-2,-1981,0,0,854,0,0,4026,0,-353,-553,0,-139,1660,0,-5,-710,0,-2,-1521,0,9,647,0,4,1314,0,0,-700,0,0,-1283,0,0,672,0,0,-1331,0,8,663,0,4,1383,0,-2,-594,0,-2,1405,0,4,-610,0,2,1290,0,0,-556,0,0";
1100
+ var coefficientValues;
1101
+ function coefficients() {
1102
+ return coefficientValues ??= COEFFICIENT_TEXT.split(",").map(Number);
1103
+ }
1104
+ var OFFSETS = [-135e-6, 388e-6];
1105
+ var NUTATION_TERMS = 77;
1106
+ function nutation(t, terms = NUTATION_TERMS) {
1107
+ const c = coefficients();
1108
+ const re = [];
1109
+ const im = [];
1110
+ let om = 0;
1111
+ for (let j = 0; j < 5; j += 1) {
1112
+ const f = (ARGUMENTS[2 * j] + t * ARGUMENTS[2 * j + 1]) % 1296e3 * ARCSEC;
1113
+ const cos = Math.cos(f);
1114
+ const sin = Math.sin(f);
1115
+ const o = 7 * j;
1116
+ re[o + 1] = cos;
1117
+ im[o + 1] = -sin;
1118
+ re[o + 2] = 1;
1119
+ im[o + 2] = 0;
1120
+ for (let k = o + 3; k < o + 7; k += 1) {
1121
+ re[k] = re[k - 1] * cos - im[k - 1] * sin;
1122
+ im[k] = re[k - 1] * sin + im[k - 1] * cos;
1123
+ }
1124
+ re[o] = re[o + 4];
1125
+ im[o] = -im[o + 4];
1126
+ om = f;
1127
+ }
1128
+ let dp = 0;
1129
+ let de = 0;
1130
+ for (let i = terms - 1; i >= 0; i -= 1) {
1131
+ let cos = 1;
1132
+ let sin = 0;
1133
+ for (let j = 0; j < 5; j += 1) {
1134
+ const k2 = 7 * j + MULTIPLIERS.charCodeAt(5 * i + j) - 48;
1135
+ const next = cos * re[k2] - sin * im[k2];
1136
+ sin = cos * im[k2] + sin * re[k2];
1137
+ cos = next;
1138
+ }
1139
+ const k = 6 * i;
1140
+ dp += (c[k] + c[k + 1] * t) * sin + c[k + 2] * cos;
1141
+ de += (c[k + 3] + c[k + 4] * t) * cos + c[k + 5] * sin;
1142
+ }
1143
+ return { dpsi: dp * 1e-7 + OFFSETS[0], deps: de * 1e-7 + OFFSETS[1], om };
1144
+ }
1145
+ function tilt(tt) {
1146
+ const t = tt / 36525;
1147
+ const { dpsi, deps, om } = nutation(t);
1148
+ const mobl = meanObliquity(t);
1149
+ return {
1150
+ dpsi,
1151
+ deps,
1152
+ mobl,
1153
+ tobl: mobl + deps / 3600,
1154
+ ee: dpsi * Math.cos(mobl * DEG3) + 264096e-8 * Math.sin(om) + 6352e-8 * Math.sin(2 * om)
1155
+ };
1156
+ }
1157
+
1158
+ // src/frame.ts
1159
+ var DEG4 = Math.PI / 180;
1160
+ var ASEC2RAD = DEG4 / 3600;
1161
+ var RAD3 = 180 / Math.PI;
1162
+ var last;
1163
+ function eclipticFrame(tt) {
1164
+ if (last !== void 0 && last.tt === tt) return last;
1165
+ const t = tt / 36525;
1166
+ let eps0 = 84381.406;
1167
+ let psia = ((((-951e-10 * t + 132851e-9) * t - 114045e-8) * t - 1.0790069) * t + 5038.481507) * t;
1168
+ let omegaa = ((((3337e-10 * t - 467e-9) * t - 772503e-8) * t + 0.0512623) * t - 0.025754) * t + eps0;
1169
+ let chia = ((((-56e-9 * t + 170663e-9) * t - 121197e-8) * t - 2.3814292) * t + 10.556403) * t;
1170
+ eps0 *= ASEC2RAD;
1171
+ psia *= ASEC2RAD;
1172
+ omegaa *= ASEC2RAD;
1173
+ chia *= ASEC2RAD;
1174
+ const sa = Math.sin(eps0);
1175
+ const ca = Math.cos(eps0);
1176
+ const sb = Math.sin(-psia);
1177
+ const cb = Math.cos(-psia);
1178
+ const sc = Math.sin(-omegaa);
1179
+ const cc = Math.cos(-omegaa);
1180
+ const sd = Math.sin(chia);
1181
+ const cd = Math.cos(chia);
1182
+ const xx = cd * cb - sb * sd * cc;
1183
+ const yx = cd * sb * ca + sd * cc * cb * ca - sa * sd * sc;
1184
+ const zx = cd * sb * sa + sd * cc * cb * sa + ca * sd * sc;
1185
+ const xy = -sd * cb - sb * cd * cc;
1186
+ const yy = -sd * sb * ca + cd * cc * cb * ca - sa * cd * sc;
1187
+ const zy = -sd * sb * sa + cd * cc * cb * sa + ca * cd * sc;
1188
+ const xz = sb * sc;
1189
+ const yz = -sc * cb * ca - sa * cc;
1190
+ const zz = -sc * cb * sa + cc * ca;
1191
+ const at = tilt(tt);
1192
+ const e = at.mobl * DEG4;
1193
+ const ce = Math.cos(e);
1194
+ const se = Math.sin(e);
1195
+ last = {
1196
+ tt,
1197
+ rows: [
1198
+ xx,
1199
+ yx,
1200
+ zx,
1201
+ ce * xy + se * xz,
1202
+ ce * yy + se * yz,
1203
+ ce * zy + se * zz,
1204
+ ce * xz - se * xy,
1205
+ ce * yz - se * yy,
1206
+ ce * zz - se * zy
1207
+ ],
1208
+ tilt: at
1209
+ };
1210
+ return last;
1211
+ }
1212
+ function meanEcliptic(frame, x, y, z) {
1213
+ const m = frame.rows;
1214
+ return [
1215
+ m[0] * x + m[1] * y + m[2] * z,
1216
+ m[3] * x + m[4] * y + m[5] * z,
1217
+ m[6] * x + m[7] * y + m[8] * z
1218
+ ];
1219
+ }
1220
+ function eclipticOfDate(x, y, z, tt) {
1221
+ const frame = eclipticFrame(tt);
1222
+ const [ex, ey, ez] = meanEcliptic(frame, x, y, z);
1223
+ return {
1224
+ lon: normalizeLongitude(Math.atan2(ey, ex) * RAD3 + frame.tilt.dpsi / 3600),
1225
+ lat: Math.asin(ez / Math.hypot(ex, ey, ez)) * RAD3
1226
+ };
1227
+ }
1228
+
1229
+ // src/points.ts
1230
+ var DEG5 = Math.PI / 180;
1231
+ var RAD4 = 180 / Math.PI;
1232
+ var ARCSEC2 = 1 / 3600;
1233
+ function lunarMeanArguments(centuries) {
1234
+ const t = centuries;
1235
+ const l = 485868.249036 + t * (17179159232178e-4 + t * (31.8792 + t * (0.051635 + t * -2447e-7)));
1236
+ const F = 335779.526232 + t * (17395272628478e-4 + t * (-12.7512 + t * (-1037e-6 + t * 417e-8)));
1237
+ const node = 450160.398036 + t * (-69628905431e-4 + t * (7.4722 + t * (7702e-6 + t * -5939e-8)));
1238
+ return { l: l * ARCSEC2, F: F * ARCSEC2, node: node * ARCSEC2 };
1239
+ }
1240
+ var MEAN_LUNAR_INCLINATION = 5.1453964;
1241
+ function meanNodeLongitude(centuries, nutation2) {
1242
+ return normalizeLongitude(lunarMeanArguments(centuries).node + nutation2);
1243
+ }
1244
+ function meanApogee(centuries, nutation2) {
1245
+ const { l, F, node } = lunarMeanArguments(centuries);
1246
+ const u = (F - l + 180) * DEG5;
1247
+ const i = MEAN_LUNAR_INCLINATION * DEG5;
1248
+ const lon = node + Math.atan2(Math.cos(i) * Math.sin(u), Math.cos(u)) * RAD4 + nutation2;
1249
+ return { lon: normalizeLongitude(lon), lat: Math.asin(Math.sin(i) * Math.sin(u)) * RAD4 };
1250
+ }
1251
+ function sectOf(ascendant, sun) {
1252
+ return normalizeLongitude(sun - ascendant) >= 180 ? "day" : "night";
1253
+ }
1254
+ var LOTS = /* @__PURE__ */ Object.freeze([
1255
+ "Lot of Fortune",
1256
+ "Lot of Spirit",
1257
+ "Lot of Eros",
1258
+ "Lot of Necessity",
1259
+ "Lot of Courage",
1260
+ "Lot of Victory",
1261
+ "Lot of Nemesis"
1262
+ ]);
1263
+ function hellenisticLots(inputs, sect) {
1264
+ const lot = (from, to) => normalizeLongitude(inputs.ascendant + (sect === "day" ? to - from : from - to));
1265
+ const fortune = lot(inputs.sun, inputs.moon);
1266
+ const spirit = lot(inputs.moon, inputs.sun);
1267
+ return [
1268
+ { point: "Lot of Fortune", lon: fortune },
1269
+ { point: "Lot of Spirit", lon: spirit },
1270
+ { point: "Lot of Eros", lon: lot(spirit, inputs.venus) },
1271
+ { point: "Lot of Necessity", lon: lot(inputs.mercury, fortune) },
1272
+ { point: "Lot of Courage", lon: lot(inputs.mars, fortune) },
1273
+ { point: "Lot of Victory", lon: lot(spirit, inputs.jupiter) },
1274
+ { point: "Lot of Nemesis", lon: lot(inputs.saturn, fortune) }
1275
+ ];
1276
+ }
1277
+ function antiscion(longitude) {
1278
+ return normalizeLongitude(180 - longitude);
1279
+ }
1280
+ function contraAntiscion(longitude) {
1281
+ return normalizeLongitude(-longitude);
1282
+ }
1283
+ function midpoint(first, second) {
1284
+ const arc = normalizeLongitude(second - first);
1285
+ return normalizeLongitude(first + (arc > 180 ? arc - 360 : arc) / 2);
1286
+ }
1287
+
1288
+ // src/reference-span.ts
1289
+ var REFERENCE_SPAN = /* @__PURE__ */ Object.freeze({
1290
+ from: "1800-01-01T00:00:00.000Z",
1291
+ to: "2200-01-01T00:00:00.000Z"
1292
+ });
1293
+ var EPHEMERIS_SPAN = /* @__PURE__ */ Object.freeze({
1294
+ /** The scale of the bounds, as a label, like `fromTT` and `toTT`: not a TimeScaleName, which is lowercase. */
1295
+ timeScale: "TT",
1296
+ /** Days of Terrestrial Time from J2000.0, 2000-01-01T12:00 TT, inclusive. */
1297
+ daysFromJ2000: /* @__PURE__ */ Object.freeze({ from: -73e4, to: 73e4 }),
1298
+ /** The same bounds as Terrestrial Time labels (not UTC). */
1299
+ fromTT: "0001-04-30T12:00:00",
1300
+ toTT: "3998-09-03T12:00:00"
1301
+ });
1302
+ var FROM = Date.UTC(1800, 0, 1);
1303
+ var TO = Date.UTC(2200, 0, 1);
1304
+ function outsideReferenceSpan(utc) {
1305
+ const time = Date.prototype.getTime.call(utc);
1306
+ return !(time >= FROM && time < TO);
1307
+ }
1308
+
1309
+ // src/time-scale-data.ts
1310
+ var LEAP_SECOND_LIST = /* @__PURE__ */ Object.freeze({
1311
+ source: "IERS leap-seconds.list, retrieved 2026-09-29",
1312
+ sha256: "db5a895f16853b03bfc865e8d68f9fc8710ef1740e3400c701cd46a5bbbc3433",
1313
+ /** The list's last update. */
1314
+ updated: "2026-07-06",
1315
+ /** The list's expiry: after it the last value is carried, not known. */
1316
+ expires: "2027-06-28",
1317
+ changes: /* @__PURE__ */ Object.freeze(/* @__PURE__ */ [[41317, 10], [41499, 11], [41683, 12], [42048, 13], [42413, 14], [42778, 15], [43144, 16], [43509, 17], [43874, 18], [44239, 19], [44786, 20], [45151, 21], [45516, 22], [46247, 23], [47161, 24], [47892, 25], [48257, 26], [48804, 27], [49169, 28], [49534, 29], [50083, 30], [50630, 31], [51179, 32], [53736, 33], [54832, 34], [56109, 35], [57204, 36], [57754, 37]].map((change) => Object.freeze(change)))
1318
+ });
1319
+ var UT1_DATA = /* @__PURE__ */ Object.freeze({
1320
+ version: "2026-09-24",
1321
+ source: "IERS finals2000A.all (Bulletin A), Last-Modified 2026-09-24T17:37:44Z",
1322
+ sha256: "cc80680ec05c91b65e7d02c6068fe0d44dd0998dc880551975092d2d14aa8e18",
1323
+ /** 1972's source. */
1324
+ earlySource: "IERS EOP 20 C04 (eopc04.1962-now), Last-Modified 2026-09-28T13:21:06Z",
1325
+ earlySha256: "e16cfbba34574b8bad3cf81e2e56a84c2b4bbfd3c822cf9ebdd860bf97d711dc",
1326
+ digest: "064d98b4a531053a",
1327
+ from: 41317,
1328
+ finalsFrom: 41684,
1329
+ observedTo: 61307,
1330
+ to: 61680,
1331
+ step: 3,
1332
+ head: -10045,
1333
+ first: -10048,
1334
+ slope: -9,
1335
+ radix: 9,
1336
+ packed: "DJ9UAUID[CT7iAMAB^B_6_JM[B^B_@MJTS9U:UACRKT0U9V@LTB^8M9UK:SC^8UAURB^9^HUJDS:M1V8LRUSJTKUJDJDTATBMIKK:^9LIMK1T9_8TJMSJTBhBDAMSBL1UAKS:^9T@_K:T:UBLBMSCT:^BLAL[CC8a9CJ;TAT@_JCK:]KL9VITK;SKKAUKBSB^BSQUKKL8_BTJLSSU9UKLIL]BL@NASS:]CC8LSKKAV:LBCTCSBMATJCT;JJMBKK2SSTALKTK9]S^JL[URJTKLB;SKT8U:CB2KCSJLKTT9TKTIMBTSBTCLB;JLK9U:KJCKK]AUB^SB]TUALKMBATCTB;AST8TKLICRUKI]S^BCBDKJKKUBBK;LAKRVC9TB^BKSLSJLCUSKKTTBKKMAJRDLASRMBATBUJCJLSCCCMAKJLTBKB^RSRTTBCAVJCJCUBLBMSKL9^KCJMSJKA_BKILSKC@UKDBCTJTATTBSKTJLAUSSK9^KKILSKSBUBSSC]SU9MCCRK^BSJTSKJBTCC@T]CK9UBUACTKL9LKKS:]KU8UJCJ9^LKILKCSB^KLALLDSJ^KTQKSK]AUJLIBT:U7VATT9UB^@MBLKBLCLJCKB[I^J^ICSDKAMBUK:SK^BDJVJBTB_9;ALJA]J^JCRML8TI_B:SK^9LAUJ:JDUADAMRKL1_9LJUSBTB^K;JMTBU9UB;B;TAU8VBBK9hAT?_KJ^:UIUAL]CLA_IKRD[JL8_JDQDSKM@VRL[CUAUI_JJ[B^ALIDSCL/_AMI<KJ_/VJDK:^9L@WATT1]AV7LSDK9gIVA<SK^7aA^RDTLK@_BDQCT9^8M@UJ9^A_HNAL[AhBVACS;T0UA_J;RMT/UAUR;SB_H_KMK9TB^AMIMS8gBUHLJ;[9UAVA<S;T@_AVIB[L^8UHVIJ]1hAM@VK9^9_AMALU8_9W@LRMSBM/_A;R;]@UHVRCSBV0MHVS:T8i@UQWB8U/a@USC]8V/bAC[:_@_IVRT]:^9LH_RCT1UAL@EJBU/hIMIDT9h9VAK[CT9U?aJCS0hAV@NABT9_BLID^:^9VALHMT:T7aALR:]Ag@LJTSA^BMAERDT1V1LGMIKh8V@V8<SCU7aIVAB]LTAMJL[C]BM8DIEK1TAV7MRLS@_A_AB]D^0M8URK[C]AV0MS1]BV8MIL[BUBh@LKMU8^9V@UJ;L8M/^[:[K^JCIMRCS:^BDIURJT9_ALJLL9L0UKCRBhBUAMRLT;SKLJUJJ[B_8THNSBSBMADHL]J]A^RLBDSI^:MB;ICgA^ALKCT8^BTIMTB]BUJUIMSLK9TJTJB^BL?_BKRBUBM@MKDKATCDALSLK9V9LHCUCL0MJLS2KSUAMKMBB^LKADJTS:U9KQCRLTALJ^IJ^KL@^CKJBSL]JKJUKA]BTBDKCSBLJ^BB]UKBLCMRKSLU@TI^J:KCKILJMKBK;LAKJUSJL;NAKSLL9KA^RB]KTITJUKASS_JLJLTJU:UBBJMTASJUIKJCTBKJMJCL:TKKBKTBL:TSLILKIT9LJSSC]KTBLKKJDTLLBUKAS9^KKJKTCJ9UBLAC^AT9_LBS:UBM8MBKIJ^KSIUKKS:TSLIDTCSAVKTSLTCL9TRTJCTJKAMITRBM:KJCLCSA_JUJCKKTIKSLJCTKT8TKKS:TKMADJMKAUKVACJTT9TBTIDJUJBLAMI:TKL9MJLS:STUADAT]:T:TILSK]A]BTS;KCUATJ_RKSCTRU9TS9SCUILILT0TA^RMJDRJUJUJKKK^AU8LJBT:gJLAUSBT1^BMKEK:KA_JDJLSASBUJKZDL8U7_JLK1_9UHVIJ]C_BC@MSBSAhJMAC]CT@VJCJChCU@TJLS:hAV6VIS]1^BLIC[KT@hJTJ:]B^AUAT[DSBTAMJLJ2^9U@VRLT0^JVJ<SC]BU8UIC[C]@VATR;KCL?aBKS:UAa8<ATZBV8i@DR<T8_?VAC[Lg?_ANJK[KgI^RVJ9]Ah8MAMS1U0UADK;S9M@iACZMT@^@aBBS2]8UBVRB^1^@MIUSJi0hJDIUf:M'_A<IL^8M.b@LS2THa7NJCTBU8VAES9S9_9LPM]BU&iBDQCU1TIaJMRB^8V@VK:[:^AM?MS;J0a9LQESCM'_9MJ;SJT@VAMS;]:L@MRCK9hBTPNKDSJ_9UAL];]8_AUI;RCT7_JLR;TBU7EIWJA^BM@MILT1UAW7MJ;L7iAUIBfC_@_AVJ:T;^8MH_K9TA_6VIMS8^9_IDILTA^B_ICSCgBKA_JA[C^8V@MRB]CV8MANJB_9a9CJC]A^8_ACS:^8UH_JCT:]AUAUJC]9hAT@MT8]Ai:DI<KAU9VJKRDUBUA_RLRKUAU7NJBT1^BKHDSCT8_IV@MSKU0VASSCSKSANADJ:[KU@UKKS9VBTJL]DSB]RTRDKJ]8VALA2[K^HVALSBTKTILJLL1]KU@LTDJAL:LB;SS]JLR^S:TDLJMATS:L:TIM@UJAU:M@DSDJBKBUK;KLL9D9LBKT;T8SKDS:KCUAKSL]:MCTRCKMT9KJUJCJDKATATSJL:]BKRURKLBV8KKUK9TB^IKQMLCC9MBKJJgKTA_SKK;MATBLSKSBMBCADKCC9LKBSCUALJLCCJK^BCBLRKSB^KAJK^KRCUBLB:]UCJUJCJCUCC@UKCB9UJL8MKCBA_BTC:SKT:DBBSDKLS9UITIK]KLAMKK[BUBLIUTTTALLLJBSKT@^JLIKSKT@MCKJB^B]JLKMBAUBUAKKCTATBUACSLC@^SUJJUB_IUCDBJTBUATJTSATBTRDBB]BLA_JA]DU@UCTS9RCUBKKKSJTCLJCBLTA^JUJDKMLAKA_BBSC]JKIVIJSCTJCKDJI^CUILRLSRSBVACJLU9L8^SB]B_9TJEKJU:TR^JMSBSAhBCILTBT8a@LB;T9TJMJK]9^:M?MJK]:]IU@MTCK/iKDHL]CTI_TDK2^BTALIMJB_9KADSCS0^BMA<SCSI_I^S;KKL7V9MR:]CL@UBDJB_:L@UST]AaAUICKCTAV8^B3JJ^?_AUJ9gCTAM@^T1TB_@UJEK0^9_ADJC]AMI^J:TD^AV9UR;RLU7UA_IBS:^ILIEB8h1UQL[ML8U8aADK;SIU7aAB];U8M@_RB[BiAUIVSAgB_?V@M[J]@aHTS2U0]HiIK]BgAU@MRLSBU8V7U]CK7qAMJC]BU8_ATZD^CU@WACR;]JU7_ILJ9^BL@ERLSA^IVIDRC]A_IVHLSB^8VALJ;T:M@MJTT1UBV@NJLS8_1UQEJCS@V9MAC]9]@VAUJ:]K^ADIVR:SJhHUJ<J9^A_@LSK^8^AVIDTDL/V8aI;K9^@V8LK1f9_A<IMT0_8iAEAMT0^8hQLS3T9L@^JMSCUIVAUSA^Ba8EAMSBL0_ILIDTA_/K",
1337
+ /** Largest difference, s, between the table and any daily IERS value it was built from. */
1338
+ bound: 79e-5,
1339
+ /** C04's largest formal error in 1972, µs. */
1340
+ earlyError: 1900,
1341
+ firstYear: 1973,
1342
+ /** Largest observed formal error of each year of finals2000A from firstYear, µs. */
1343
+ observedErrors: [1313, 1515, 994, 1136, 1466, 1434, 1313, 736, 900, 1042, 661, 244, 271, 135, 119, 115, 198, 56, 52, 47, 34, 23, 33, 31, 20, 22, 28, 37, 20, 21, 11, 16, 11, 11, 12, 12, 15, 14, 21, 17, 19, 20, 14, 20, 28, 21, 14, 19, 12, 16, 21, 19, 19, 27],
1344
+ /** The prediction's formal error every 10 days after observedTo, and on its last day, µs. */
1345
+ predictedErrors: [108, 934, 2308, 3408, 4391, 5301, 6160, 6979, 7766, 8526, 9264, 9982, 10683, 11369, 12041, 12701, 13349, 13986, 14614, 15233, 15844, 16447, 17042, 17630, 18212, 18788, 19358, 19922, 20481, 21035, 21584, 22128, 22668, 23203, 23735, 24262, 24786, 25306, 25410]
1346
+ });
1347
+ var UT1_FROM_MS = 63072e6;
1348
+ var UT1_FINALS_FROM_MS = 947808e5;
1349
+ var UT1_OBSERVED_TO_MS = 1790208e6;
1350
+ var UT1_TO_MS = 18224352e5;
1351
+ var UT1_GRID_BEFORE = 122;
1352
+ var LEAP_SECONDS_EXPIRE_MS = 18141408e5;
1353
+
1354
+ // src/time-scale.ts
1355
+ var TIME_SCALE_NAMES = /* @__PURE__ */ Object.freeze(["utc", "ut1", "tt"]);
1356
+ var DELTA_T_IERS_MODEL = "iers-utc/1";
1357
+ var DAY = 864e5;
1358
+ var J2000_MS = Date.UTC(2e3, 0, 1, 12);
1359
+ var MJD_UNIX = 40587;
1360
+ var LEAP_SECONDS_FROM = Date.UTC(1972, 0, 1);
1361
+ var UT1_FALLBACK_BAND = 0.9;
1362
+ var ALPHABET = "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~";
1363
+ var knots;
1364
+ function decode() {
1365
+ const { packed, radix, first, slope } = UT1_DATA;
1366
+ const count = UT1_GRID_BEFORE + Math.ceil((UT1_DATA.to - UT1_DATA.finalsFrom) / UT1_DATA.step) + 1;
1367
+ const values = new Float64Array(count);
1368
+ values[0] = first;
1369
+ let step = slope;
1370
+ const limit = (radix - 1) / 2;
1371
+ for (let index = 1; index < count; index += 1) {
1372
+ values[index] = values[index - 1] + step;
1373
+ const pair = index - 1;
1374
+ if (index + 1 < count) {
1375
+ const code = ALPHABET.indexOf(packed[pair >> 1]);
1376
+ step += (pair & 1 ? code % radix : Math.floor(code / radix)) - limit;
1377
+ }
1378
+ }
1379
+ return values;
1380
+ }
1381
+ function taiMinusUtcAt(utcMs) {
1382
+ const mjd = Math.floor(utcMs / DAY) + MJD_UNIX;
1383
+ const changes = LEAP_SECOND_LIST.changes;
1384
+ let value = changes[0][1];
1385
+ for (const [from, dtai] of changes) if (mjd >= from) value = dtai;
1386
+ return value;
1387
+ }
1388
+ function taiMinusUtcAtTai(taiMs) {
1389
+ const changes = LEAP_SECOND_LIST.changes;
1390
+ let value = changes[0][1];
1391
+ for (const [from, dtai] of changes) if (taiMs >= (from - MJD_UNIX) * DAY + dtai * 1e3) value = dtai;
1392
+ return value;
1393
+ }
1394
+ function ut1MinusTai(utcMs) {
1395
+ knots ??= decode();
1396
+ const days = (utcMs - UT1_FINALS_FROM_MS) / DAY;
1397
+ const gridFrom = -UT1_GRID_BEFORE * UT1_DATA.step;
1398
+ if (days < gridFrom) {
1399
+ const fraction2 = (utcMs - UT1_FROM_MS) / DAY / (gridFrom - (UT1_DATA.from - UT1_DATA.finalsFrom));
1400
+ return (UT1_DATA.head + fraction2 * (knots[0] - UT1_DATA.head)) / 1e3;
1401
+ }
1402
+ const last2 = knots.length - 1;
1403
+ const k = Math.min(last2 - 1, UT1_GRID_BEFORE + Math.floor(days / UT1_DATA.step));
1404
+ const start = (k - UT1_GRID_BEFORE) * UT1_DATA.step;
1405
+ const end = k + 1 === last2 ? UT1_DATA.to - UT1_DATA.finalsFrom : start + UT1_DATA.step;
1406
+ const fraction = (days - start) / (end - start);
1407
+ return (knots[k] + fraction * (knots[k + 1] - knots[k])) / 1e3;
1408
+ }
1409
+ function ut1Sigma(utcMs) {
1410
+ if (utcMs < UT1_FINALS_FROM_MS) return UT1_DATA.earlyError / 1e6 + UT1_DATA.bound;
1411
+ if (utcMs <= UT1_OBSERVED_TO_MS) {
1412
+ const year = new Date(utcMs).getUTCFullYear() - UT1_DATA.firstYear;
1413
+ const errors2 = UT1_DATA.observedErrors;
1414
+ return errors2[Math.max(0, Math.min(errors2.length - 1, year))] / 1e6 + UT1_DATA.bound;
1415
+ }
1416
+ const days = (utcMs - UT1_OBSERVED_TO_MS) / DAY - 1;
1417
+ const errors = UT1_DATA.predictedErrors;
1418
+ const k = Math.max(0, Math.min(errors.length - 2, Math.floor(days / 10)));
1419
+ const span = k + 1 === errors.length - 1 ? UT1_DATA.to - UT1_DATA.observedTo - 1 - 10 * k : 10;
1420
+ const fraction = Math.max(0, Math.min(1, (days - 10 * k) / span));
1421
+ return (errors[k] + fraction * (errors[k + 1] - errors[k])) / 1e6 + UT1_DATA.bound;
1422
+ }
1423
+ var fallback = () => ({ seconds: 0, sigma: UT1_FALLBACK_BAND, source: "fallback" });
1424
+ function tableUt1MinusUtc(utcMs, taiMinusUtc) {
1425
+ return {
1426
+ seconds: ut1MinusTai(utcMs) + taiMinusUtc,
1427
+ sigma: ut1Sigma(utcMs),
1428
+ source: utcMs <= UT1_OBSERVED_TO_MS ? "observed" : "predicted"
1429
+ };
1430
+ }
1431
+ function ut1MinusUtcAt(utcMs) {
1432
+ if (utcMs < UT1_FROM_MS || utcMs > UT1_TO_MS) return fallback();
1433
+ return tableUt1MinusUtc(utcMs, taiMinusUtcAt(utcMs));
1434
+ }
1435
+ var modelDeltaT = (ut1Ms) => deltaTAt((ut1Ms - J2000_MS) / DAY);
1436
+ var TT_MINUS_TAI_MS = 32184;
1437
+ function timeBasis(ms, scale = "utc", pin) {
1438
+ return basisOf(ms, scale, pin, true);
1439
+ }
1440
+ function basisOf(ms, scale, pin, continuous) {
1441
+ const record = (utcMs2, ut1Ms2, deltaT2, basis, ut1MinusUtc, leapSeconds) => {
1442
+ const ut1Days = (ut1Ms2 - J2000_MS) / DAY;
1443
+ return {
1444
+ utcMs: utcMs2,
1445
+ ut1Days,
1446
+ ttDays: ut1Days + deltaT2.seconds / 86400,
1447
+ deltaT: deltaT2,
1448
+ timeScale: { input: scale, basis, ut1MinusUtc, leapSeconds }
1449
+ };
1450
+ };
1451
+ if (pin !== void 0) {
1452
+ const deltaT2 = { seconds: pin, sigma: null, model: "pinned", table: null, tableDigest: null, segment: "pinned" };
1453
+ if (scale === "tt") return record(ms - pin * 1e3, ms - pin * 1e3, deltaT2, "pinned", null, null);
1454
+ const ut1MinusUtc = scale === "utc" && ms >= LEAP_SECONDS_FROM ? ut1MinusUtcAt(ms) : null;
1455
+ return record(ms, ms + (ut1MinusUtc?.seconds ?? 0) * 1e3, deltaT2, "pinned", ut1MinusUtc, null);
1456
+ }
1457
+ const utc = scale === "tt" ? ms - modelDeltaT(ms).seconds * 1e3 : ms;
1458
+ if (continuous && utc > UT1_TO_MS) {
1459
+ const taiMinusUtc2 = taiMinusUtcAt(utc);
1460
+ const ttMinusUtcMs = taiMinusUtc2 * 1e3 + TT_MINUS_TAI_MS;
1461
+ const leapSeconds = { taiMinusUtc: taiMinusUtc2, listed: false };
1462
+ if (scale === "utc") {
1463
+ const ttMs = ms + ttMinusUtcMs;
1464
+ let ut1Ms3 = ttMs;
1465
+ for (let round = 0; round < 4; round += 1) ut1Ms3 = ttMs - modelDeltaT(ut1Ms3).seconds * 1e3;
1466
+ const deltaT3 = modelDeltaT(ut1Ms3);
1467
+ return {
1468
+ utcMs: ms,
1469
+ ut1Days: (ut1Ms3 - J2000_MS) / DAY,
1470
+ ttDays: (ttMs - J2000_MS) / DAY,
1471
+ deltaT: deltaT3,
1472
+ timeScale: {
1473
+ input: scale,
1474
+ basis: "continuous-utc",
1475
+ // From ΔT rather than from UT1 − UTC in milliseconds, so that 32.184 s + TAI − UTC − (UT1 − UTC)
1476
+ // is ΔT to the rounding of seconds; the milliseconds since 1970 round to 8 µs at the far end.
1477
+ ut1MinusUtc: { seconds: ttMinusUtcMs / 1e3 - deltaT3.seconds, sigma: deltaT3.sigma, source: "model" },
1478
+ leapSeconds
1479
+ }
1480
+ };
1481
+ }
1482
+ let ut1Ms2 = ms;
1483
+ if (scale === "tt") for (let round = 0; round < 4; round += 1) ut1Ms2 = ms - modelDeltaT(ut1Ms2).seconds * 1e3;
1484
+ const deltaT2 = modelDeltaT(ut1Ms2);
1485
+ const utcMs2 = (scale === "tt" ? ms : ut1Ms2 + deltaT2.seconds * 1e3) - ttMinusUtcMs;
1486
+ return record(utcMs2, ut1Ms2, deltaT2, "continuous-utc", { seconds: ttMinusUtcMs / 1e3 - deltaT2.seconds, sigma: deltaT2.sigma, source: "model" }, leapSeconds);
1487
+ }
1488
+ if (utc < LEAP_SECONDS_FROM || utc > UT1_TO_MS) {
1489
+ let ut1Ms2 = ms;
1490
+ if (scale === "tt") for (let round = 0; round < 4; round += 1) ut1Ms2 = ms - modelDeltaT(ut1Ms2).seconds * 1e3;
1491
+ return record(ut1Ms2, ut1Ms2, modelDeltaT(ut1Ms2), "delta-t", utc > UT1_TO_MS && scale !== "ut1" ? fallback() : null, null);
1492
+ }
1493
+ let taiMs;
1494
+ let taiMinusUtc;
1495
+ let utcMs = ms;
1496
+ if (scale === "utc") {
1497
+ taiMinusUtc = taiMinusUtcAt(ms);
1498
+ taiMs = ms + taiMinusUtc * 1e3;
1499
+ } else {
1500
+ taiMs = scale === "tt" ? ms - 32184 : ms - ut1MinusTai(ms) * 1e3;
1501
+ taiMinusUtc = taiMinusUtcAtTai(taiMs);
1502
+ utcMs = taiMs - taiMinusUtc * 1e3;
1503
+ }
1504
+ const ut1 = tableUt1MinusUtc(utcMs, taiMinusUtc);
1505
+ const ut1Ms = scale === "ut1" ? ms : utcMs + ut1.seconds * 1e3;
1506
+ return record(
1507
+ utcMs,
1508
+ ut1Ms,
1509
+ {
1510
+ seconds: (taiMs + 32184 - ut1Ms) / 1e3,
1511
+ sigma: ut1.sigma,
1512
+ model: DELTA_T_IERS_MODEL,
1513
+ table: UT1_DATA.version,
1514
+ tableDigest: UT1_DATA.digest,
1515
+ segment: ut1.source
1516
+ },
1517
+ "iers",
1518
+ scale === "ut1" ? { ...ut1, seconds: (ut1Ms - utcMs) / 1e3 } : ut1,
1519
+ { taiMinusUtc, listed: utcMs < LEAP_SECONDS_EXPIRE_MS }
1520
+ );
1521
+ }
1522
+ var MODEL_KNOTS_FROM = (1941 - 2e3) * 365.25;
1523
+ function pieceOf({ timeScale, deltaT: deltaT2, utcMs, ut1Days }) {
1524
+ const { input, basis, ut1MinusUtc } = timeScale;
1525
+ if (input === "tt") return "";
1526
+ if (input === "utc" && (basis === "iers" || basis === "continuous-utc")) return `tai-utc ${taiMinusUtcAt(utcMs)}`;
1527
+ const model = deltaT2.model === DELTA_T_MODEL ? ut1Days < MODEL_KNOTS_FROM ? "spline" : "knots" : deltaT2.model;
1528
+ if (input === "ut1") return `${basis} ${model}`;
1529
+ const reading = ut1MinusUtc === null ? "as-ut1" : ut1MinusUtc.source === "fallback" ? "fallback" : taiMinusUtcAt(utcMs);
1530
+ return `${basis} ${model} ${reading}`;
1531
+ }
1532
+ function elapsedDays(before, after, days) {
1533
+ return pieceOf(before) === pieceOf(after) ? days : after.ttDays - before.ttDays;
1534
+ }
1535
+
1536
+ // src/types.ts
1537
+ var ENGINE_VERSION = "2.0.0";
1538
+ var EPHEMERIS = /* @__PURE__ */ Object.freeze({ name: "astronomy-engine", version: "2.1.19" });
1539
+
1540
+ // src/ephemeris.ts
1541
+ var RAD5 = 180 / Math.PI;
1542
+ var DAY2 = 864e5;
1543
+ var UTC_CLOCK = { scale: "utc", pin: void 0 };
1544
+ var source = null;
1545
+ var defaultName = INITIAL_DEFAULT_EPHEMERIS;
1546
+ var DEFAULT_MARGIN_DAYS = 1;
1547
+ var SECONDS_PER_DAY = 86400;
1548
+ var shipped;
1549
+ var shippedError = null;
1550
+ function shippedDefault() {
1551
+ if (shipped !== void 0) return shipped;
1552
+ try {
1553
+ const opened = shippedDe440Source();
1554
+ shipped = {
1555
+ source: opened,
1556
+ fromTtDays: opened.pack.startEtSecTdb / SECONDS_PER_DAY + DEFAULT_MARGIN_DAYS,
1557
+ toTtDays: opened.pack.stopEtSecTdb / SECONDS_PER_DAY - DEFAULT_MARGIN_DAYS
1558
+ };
1559
+ } catch (error) {
1560
+ shipped = null;
1561
+ shippedError = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
1562
+ }
1563
+ return shipped;
1564
+ }
1565
+ var ON_ASTRONOMY_ENGINE = { from: null, fallback: null };
1566
+ function chosenAt(ttDays) {
1567
+ if (source) return { from: source, fallback: null };
1568
+ if (defaultName !== "de440") return ON_ASTRONOMY_ENGINE;
1569
+ const pack = shippedDefault();
1570
+ if (pack === null) return { from: null, fallback: "de440-unavailable" };
1571
+ return ttDays >= pack.fromTtDays && ttDays <= pack.toTtDays ? { from: pack.source, fallback: null } : { from: null, fallback: "outside-de440-span" };
1572
+ }
1573
+ var noted = null;
1574
+ function sourceAt(ttDays) {
1575
+ const chosen = chosenAt(ttDays);
1576
+ if (chosen.fallback !== null) noted?.add(chosen.fallback);
1577
+ return chosen.from;
1578
+ }
1579
+ function notingFallbacks(run2) {
1580
+ const outer = noted;
1581
+ const mine = /* @__PURE__ */ new Set();
1582
+ noted = mine;
1583
+ try {
1584
+ const value = run2();
1585
+ return { value, fallbacks: EPHEMERIS_FALLBACKS.filter((reason) => mine.has(reason)) };
1586
+ } finally {
1587
+ noted = outer;
1588
+ if (outer) for (const reason of mine) outer.add(reason);
1589
+ }
1590
+ }
1591
+ var EPHEMERIS_FALLBACKS = ["de440-unavailable", "outside-de440-span"];
1592
+ var named = (from) => from ? { name: from.ephemeris.name, version: from.ephemeris.version } : { ...EPHEMERIS };
1593
+ function ephemerisAt(ms, scale = "utc", pin) {
1594
+ const { from, fallback: fallback2 } = chosenAt(timeBasis(ms, scale, pin).ttDays);
1595
+ return { from, ephemeris: named(from), fallback: fallback2 };
1596
+ }
1597
+ function defaultEphemeris() {
1598
+ const pack = shippedDefault();
1599
+ return Object.freeze({
1600
+ name: defaultName,
1601
+ de440: Object.freeze({
1602
+ opened: pack !== null,
1603
+ version: pack?.source.ephemeris.version ?? null,
1604
+ fromTtDays: pack?.fromTtDays ?? null,
1605
+ toTtDays: pack?.toTtDays ?? null,
1606
+ error: shippedError
1607
+ })
1608
+ });
1609
+ }
1610
+ function setDefaultEphemeris(name) {
1611
+ if (name !== "de440" && name !== "astronomy-engine") throw new TypeError('setDefaultEphemeris takes "de440" or "astronomy-engine"');
1612
+ defaultName = name;
1613
+ }
1614
+ function withEphemeris(positionSource, run2) {
1615
+ const named2 = positionSource?.ephemeris;
1616
+ if (typeof positionSource?.place !== "function" || typeof positionSource.trueNode !== "function" || typeof named2?.name !== "string" || typeof named2.version !== "string" || typeof run2 !== "function")
1617
+ throw new TypeError("withEphemeris needs a position source and a function");
1618
+ const previous = source;
1619
+ source = positionSource;
1620
+ let result;
1621
+ try {
1622
+ result = run2();
1623
+ } finally {
1624
+ source = previous;
1625
+ }
1626
+ const later = result;
1627
+ if (typeof later?.then === "function" || typeof later?.next === "function") {
1628
+ if (typeof later.then === "function") later.then(void 0, () => {
1629
+ });
1630
+ throw new TypeError("withEphemeris runs synchronous functions only");
1631
+ }
1632
+ return result;
1633
+ }
1634
+ var tidy = (lon) => lon === 360 ? 0 : lon + 0;
1635
+ function sourceLongitude(from, body, ttDays, behind) {
1636
+ if (body === "North Node") return tidy(from.trueNode(ttDays));
1637
+ return body === "South Node" ? normalizeLongitude(from.trueNode(ttDays) + 180) : tidy(from.place(body, ttDays, behind).lon);
1638
+ }
1639
+ function timeOf(basis) {
1640
+ const { from, to } = EPHEMERIS_SPAN.daysFromJ2000;
1641
+ if (!(basis.ttDays >= from && basis.ttDays <= to)) {
1642
+ throw new RangeError(
1643
+ "The instant is outside the ephemeris span: its Terrestrial Time, and that of each speed sample, must lie between 0001-04-30T12:00 and 3998-09-03T12:00 TT, the years astronomy-engine tabulates (EPHEMERIS_SPAN)."
1644
+ );
1645
+ }
1646
+ const seconds2 = basis.deltaT.seconds;
1647
+ SetDeltaTFunction(() => seconds2);
1648
+ return MakeTime(basis.ut1Days);
1649
+ }
1650
+ function sample(ms, stepDays) {
1651
+ return ms + stepDays * DAY2;
1652
+ }
1653
+ var basisAt = (ms, clock) => timeBasis(ms, clock.scale, clock.pin);
1654
+ var timeAt = (ms, clock) => timeOf(basisAt(ms, clock));
1655
+ function evaluated(run2) {
1656
+ try {
1657
+ return run2();
1658
+ } catch (thrown) {
1659
+ if (thrown instanceof Error) throw thrown;
1660
+ throw new RangeError(`The ephemeris could not evaluate this instant: ${String(thrown)}`, { cause: thrown });
1661
+ } finally {
1662
+ SetDeltaTFunction(deltaT);
1663
+ }
1664
+ }
1665
+ function gastHours(time) {
1666
+ const t = time.tt / 36525;
1667
+ const eqeq = tilt(time.tt).ee;
1668
+ const thet1 = 0.779057273264 + 0.00273781191135448 * time.ut;
1669
+ const thet3 = time.ut % 1;
1670
+ let theta = 360 * ((thet1 + thet3) % 1);
1671
+ if (theta < 0) theta += 360;
1672
+ const st = eqeq + 0.014506 + ((((-368e-10 * t - 29956e-9) * t - 44e-8) * t + 1.3915817) * t + 4612.156534) * t;
1673
+ let gst = (st / 3600 + theta) % 360 / 15;
1674
+ if (gst < 0) gst += 24;
1675
+ return gst;
1676
+ }
1677
+ var PLANETS = [
1678
+ { name: "Sun", body: Body.Sun },
1679
+ { name: "Mercury", body: Body.Mercury },
1680
+ { name: "Venus", body: Body.Venus },
1681
+ { name: "Mars", body: Body.Mars },
1682
+ { name: "Jupiter", body: Body.Jupiter },
1683
+ { name: "Saturn", body: Body.Saturn },
1684
+ { name: "Uranus", body: Body.Uranus },
1685
+ { name: "Neptune", body: Body.Neptune },
1686
+ { name: "Pluto", body: Body.Pluto }
1687
+ ];
1688
+ function planetOfDate(body, time) {
1689
+ const equatorial = GeoVector(body, time, true);
1690
+ return eclipticOfDate(equatorial.x, equatorial.y, equatorial.z, time.tt);
1691
+ }
1692
+ function moonOfDate(time) {
1693
+ const equatorial = GeoMoon(time);
1694
+ return eclipticOfDate(equatorial.x, equatorial.y, equatorial.z, time.tt);
1695
+ }
1696
+ function trueNodeLongitude(time) {
1697
+ const state = GeoMoonState(time);
1698
+ const frame = eclipticFrame(time.tt);
1699
+ const [x, y] = meanEcliptic(
1700
+ frame,
1701
+ state.y * state.vz - state.z * state.vy,
1702
+ state.z * state.vx - state.x * state.vz,
1703
+ state.x * state.vy - state.y * state.vx
1704
+ );
1705
+ return normalizeLongitude(Math.atan2(x, -y) * RAD5 + frame.tilt.dpsi / 3600);
1706
+ }
1707
+ function longitudeAt(body, ms, clock) {
1708
+ const basis = basisAt(ms, clock);
1709
+ return longitudeOn(body, basis, sourceAt(basis.ttDays));
1710
+ }
1711
+ function assertKnownBody(body) {
1712
+ if (body !== "Moon" && body !== "North Node" && body !== "South Node" && !PLANETS.some((p) => p.name === body)) {
1713
+ throw new RangeError(`Unknown body: ${String(body)}`);
1714
+ }
1715
+ }
1716
+ function longitudeOn(body, basis, from, behind) {
1717
+ assertKnownBody(body);
1718
+ if (from) return sourceLongitude(from, body, basis.ttDays, behind);
1719
+ const time = timeOf(basis);
1720
+ if (body === "Moon") return moonOfDate(time).lon;
1721
+ if (body === "North Node") return trueNodeLongitude(time);
1722
+ if (body === "South Node") {
1723
+ return normalizeLongitude(trueNodeLongitude(time) + 180);
1724
+ }
1725
+ return planetOfDate(PLANETS.find((p) => p.name === body).body, time).lon;
1726
+ }
1727
+ function bodyLongitude(body, date) {
1728
+ return evaluated(() => longitudeAt(body, date.getTime(), UTC_CLOCK));
1729
+ }
1730
+ var SPEED_STEP_DAYS = 1e-3;
1731
+ var NODE_SPEED_STEP_DAYS = 0.25;
1732
+ function longitudeSpeed(body, date) {
1733
+ return evaluated(() => speedAt(body, date.getTime(), UTC_CLOCK));
1734
+ }
1735
+ function centralDifference(longitudeOf, ms, clock, stepDays) {
1736
+ const before = basisAt(sample(ms, -stepDays), clock);
1737
+ const lonBefore = longitudeOf(before);
1738
+ const after = basisAt(sample(ms, stepDays), clock);
1739
+ let difference = longitudeOf(after) - lonBefore;
1740
+ if (difference > 180) difference -= 360;
1741
+ if (difference < -180) difference += 360;
1742
+ return difference / elapsedDays(before, after, 2 * stepDays);
1743
+ }
1744
+ function speedAt(body, ms, clock, from = sourceAt(basisAt(ms, clock).ttDays), behind) {
1745
+ assertKnownBody(body);
1746
+ const node = body === "North Node" || body === "South Node";
1747
+ const stepDays = node ? NODE_SPEED_STEP_DAYS : SPEED_STEP_DAYS;
1748
+ const side = from && !node && behind === void 0 ? from.place(body, basisAt(ms, clock).ttDays).behindDisc : behind;
1749
+ return centralDifference((basis) => longitudeOn(body, basis, from, side), ms, clock, stepDays);
1750
+ }
1751
+ function position(body, lon, lat, speed, chosen) {
1752
+ return {
1753
+ body,
1754
+ lon,
1755
+ lat,
1756
+ speed,
1757
+ retrograde: speed < 0,
1758
+ sign: signForLongitude(lon).slug,
1759
+ degree: degreeInSign(lon),
1760
+ ephemeris: chosen.from ? chosen.from.ephemeris.name : EPHEMERIS.name,
1761
+ ...chosen.fallback !== null && { fallback: chosen.fallback }
1762
+ };
1763
+ }
1764
+ function computeBodies(date) {
1765
+ return evaluated(() => {
1766
+ const ms = date.getTime();
1767
+ const basis = basisAt(ms, UTC_CLOCK);
1768
+ const chosen = chosenAt(basis.ttDays);
1769
+ const bodies = bodiesAt(ms, UTC_CLOCK, chosen);
1770
+ const flags = instantFlags(date, basis, chosen, null);
1771
+ return flags.length === 0 ? bodies : bodies.map((row) => ({ ...row, flags: [...flags] }));
1772
+ });
1773
+ }
1774
+ function instantFlags(utc, basis, chosen, angles) {
1775
+ const flags = [];
1776
+ if (outsideReferenceSpan(utc)) flags.push("outside-reference-span");
1777
+ if (deltaTExtrapolated(basis, angles)) flags.push("delta-t-extrapolated");
1778
+ if (chosen.fallback !== null) flags.push(chosen.fallback);
1779
+ return flags;
1780
+ }
1781
+ function bodiesAt(ms, clock, chosen = chosenAt(basisAt(ms, clock).ttDays)) {
1782
+ if (chosen.fallback !== null) noted?.add(chosen.fallback);
1783
+ if (chosen.from) return sourceBodiesAt(chosen, chosen.from, ms, clock);
1784
+ const bodies = [];
1785
+ for (const planet of PLANETS) {
1786
+ const coordinates = planetOfDate(planet.body, timeAt(ms, clock));
1787
+ bodies.push(
1788
+ position(planet.name, coordinates.lon, coordinates.lat, speedAt(planet.name, ms, clock, null), chosen)
1789
+ );
1790
+ }
1791
+ const moon = moonOfDate(timeAt(ms, clock));
1792
+ bodies.splice(1, 0, position("Moon", moon.lon, moon.lat, speedAt("Moon", ms, clock, null), chosen));
1793
+ const northNode = trueNodeLongitude(timeAt(ms, clock));
1794
+ const nodeSpeed = speedAt("North Node", ms, clock, null);
1795
+ bodies.push(
1796
+ position("North Node", northNode, 0, nodeSpeed, chosen),
1797
+ position("South Node", normalizeLongitude(northNode + 180), 0, nodeSpeed, chosen)
1798
+ );
1799
+ return bodies;
1800
+ }
1801
+ function sourceBodiesAt(chosen, from, ms, clock) {
1802
+ const tt = basisAt(ms, clock).ttDays;
1803
+ return ["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "North Node", "South Node"].map(
1804
+ (body) => {
1805
+ const place = body === "North Node" || body === "South Node" ? { lon: sourceLongitude(from, body, tt), lat: 0 } : from.place(body, tt);
1806
+ return position(body, tidy(place.lon), place.lat, speedAt(body, ms, clock, from, "behindDisc" in place ? place.behindDisc : void 0), chosen);
1807
+ }
1808
+ );
1809
+ }
1810
+ var clockOf = (input) => ({
1811
+ scale: input.timeScale ?? "utc",
1812
+ pin: input.deltaT
1813
+ });
1814
+ function computeChart(input) {
1815
+ return evaluated(() => chartAt(input));
1816
+ }
1817
+ function chartAt(input) {
1818
+ const flags = [...input.flags ?? []];
1819
+ const ms = input.utc.getTime();
1820
+ const clock = clockOf(input);
1821
+ const basis = timeBasis(ms, clock.scale, clock.pin);
1822
+ const chosen = chosenAt(basis.ttDays);
1823
+ const { from } = chosen;
1824
+ const bodies = bodiesAt(ms, clock, chosen);
1825
+ let angles = null;
1826
+ let houses = null;
1827
+ if (input.timeKnown && input.latitude !== void 0 && input.longitude !== void 0) {
1828
+ const time = timeOf(basis);
1829
+ const angleInput = {
1830
+ gastHours: gastHours(time),
1831
+ latitude: input.latitude,
1832
+ longitude: input.longitude,
1833
+ obliquity: tilt(time.tt).tobl
1834
+ };
1835
+ angles = computeAngles(angleInput);
1836
+ const result = computeHouses(input.houseSystem, angleInput, angles);
1837
+ houses = result.houses;
1838
+ if (result.fellBack) flags.push("polar-fallback");
1839
+ if (insidePolarCircle(angleInput)) flags.push("polar-angles");
1840
+ } else if (!input.timeKnown) {
1841
+ flags.push("no-time");
1842
+ }
1843
+ flags.push(...instantFlags(input.utc, basis, chosen, angles));
1844
+ return {
1845
+ input,
1846
+ bodies,
1847
+ angles,
1848
+ houses,
1849
+ aspects: findAspects(bodies),
1850
+ flags,
1851
+ deltaT: basis.deltaT,
1852
+ timeScale: basis.timeScale,
1853
+ engineVersion: ENGINE_VERSION,
1854
+ ephemeris: named(from)
1855
+ };
1856
+ }
1857
+ var deltaTExtrapolated = ({ deltaT: d, timeScale: t }, ut1) => (ut1 || t.input != "tt") && (t.basis == "delta-t" || t.basis == "continuous-utc") && /^e/.test(d.segment);
1858
+ function meanLunarPoints(basis) {
1859
+ const time = timeOf(basis);
1860
+ const centuries = time.tt / 36525;
1861
+ const nutation2 = tilt(time.tt).dpsi / 3600;
1862
+ return { node: meanNodeLongitude(centuries, nutation2), apogee: meanApogee(centuries, nutation2) };
1863
+ }
1864
+ function pointPosition(point, lon, lat, speed) {
1865
+ const longitude = normalizeLongitude(lon);
1866
+ return {
1867
+ point,
1868
+ lon: longitude,
1869
+ lat,
1870
+ speed,
1871
+ sign: signForLongitude(longitude).slug,
1872
+ degree: degreeInSign(longitude)
1873
+ };
1874
+ }
1875
+ function computePoints(chart) {
1876
+ return { ...evaluated(() => pointsAt(chart)), ...chartLabel(chart) };
1877
+ }
1878
+ function chartLabel(chart) {
1879
+ const named2 = chart.ephemeris;
1880
+ const flags = Array.isArray(chart.flags) ? chart.flags : [];
1881
+ return {
1882
+ ephemeris: named2 ? { name: named2.name, version: named2.version } : null,
1883
+ flags: EPHEMERIS_FALLBACKS.filter((reason) => flags.includes(reason))
1884
+ };
1885
+ }
1886
+ function computeChartDeclinations(chart) {
1887
+ const input = chart?.input;
1888
+ const sourceDate = input?.utc;
1889
+ const pin = input?.deltaT;
1890
+ const bodies = chart?.bodies;
1891
+ if (!(sourceDate instanceof Date) || !Number.isFinite(Date.prototype.getTime.call(sourceDate))) {
1892
+ throw new RangeError("declination chart must contain a valid input utc Date.");
1893
+ }
1894
+ const date = new Date(Date.prototype.getTime.call(sourceDate));
1895
+ if (pin !== void 0 && (!Number.isFinite(pin) || typeof pin !== "number" || Math.abs(pin) > 1e10)) {
1896
+ throw new RangeError("declination chart deltaT must be finite and at most 1e10 seconds in size.");
1897
+ }
1898
+ const scale = input.timeScale ?? "utc";
1899
+ return evaluated(() => {
1900
+ const basis = timeBasis(date.getTime(), scale, pin);
1901
+ return {
1902
+ ...chartBodyDeclinations(bodies, tilt(timeOf(basis).tt).tobl),
1903
+ utc: date.toISOString(),
1904
+ deltaT: basis.deltaT,
1905
+ ...chartLabel(chart)
1906
+ };
1907
+ });
1908
+ }
1909
+ function pointsAt(chart) {
1910
+ const { utc, latitude, longitude } = chart.input;
1911
+ const ms = utc.getTime();
1912
+ const clock = clockOf(chart.input);
1913
+ const mean = meanLunarPoints(basisAt(ms, clock));
1914
+ const nodeSpeed = centralDifference((basis) => meanLunarPoints(basis).node, ms, clock, SPEED_STEP_DAYS);
1915
+ const apogeeSpeed = centralDifference((basis) => meanLunarPoints(basis).apogee.lon, ms, clock, SPEED_STEP_DAYS);
1916
+ const points = [
1917
+ pointPosition("Mean Node", mean.node, 0, nodeSpeed),
1918
+ pointPosition("Mean South Node", mean.node + 180, 0, nodeSpeed),
1919
+ pointPosition("Black Moon Lilith", mean.apogee.lon, mean.apogee.lat, apogeeSpeed)
1920
+ ];
1921
+ if (chart.angles === null || latitude === void 0 || longitude === void 0) {
1922
+ return { sect: null, points };
1923
+ }
1924
+ const time = timeAt(ms, clock);
1925
+ const angleInput = {
1926
+ gastHours: gastHours(time),
1927
+ latitude,
1928
+ longitude,
1929
+ obliquity: tilt(time.tt).tobl
1930
+ };
1931
+ points.push(
1932
+ pointPosition("Vertex", vertexOf(angleInput, computeAngles(angleInput)), 0, null),
1933
+ pointPosition("East Point", eastPointOf(angleInput), 0, null)
1934
+ );
1935
+ const lon = (body) => {
1936
+ const found = chart.bodies.find((candidate) => candidate.body === body);
1937
+ if (!found) throw new RangeError(`chart has no ${body}.`);
1938
+ return found.lon;
1939
+ };
1940
+ const sect = sectOf(chart.angles.asc, lon("Sun"));
1941
+ const lots = hellenisticLots(
1942
+ {
1943
+ ascendant: chart.angles.asc,
1944
+ sun: lon("Sun"),
1945
+ moon: lon("Moon"),
1946
+ mercury: lon("Mercury"),
1947
+ venus: lon("Venus"),
1948
+ mars: lon("Mars"),
1949
+ jupiter: lon("Jupiter"),
1950
+ saturn: lon("Saturn")
1951
+ },
1952
+ sect
1953
+ );
1954
+ for (const lot of lots) points.push(pointPosition(lot.point, lot.lon, 0, null));
1955
+ return { sect, points };
1956
+ }
1957
+
1958
+ // src/crossings.ts
1959
+ var DAY3 = 864e5;
1960
+ var REFINE_STEPS = 24;
1961
+ var EDGE_PROBE_MAX_MS = 6e4;
1962
+ var DUPLICATE_MS = 1e3;
1963
+ var GOLDEN = (Math.sqrt(5) - 1) / 2;
1964
+ var SampleBudgetReached = class {
1965
+ };
1966
+ function signedDelta(from, to) {
1967
+ const difference = ((to - from) % 360 + 360) % 360;
1968
+ return difference > 180 ? difference - 360 : difference;
1969
+ }
1970
+ function turn(before, after) {
1971
+ if (before > 0 && after <= 0 || before === 0 && after < 0) return 1;
1972
+ if (before < 0 && after >= 0 || before === 0 && after > 0) return -1;
1973
+ return 0;
1974
+ }
1975
+ function sameSideNear(...offsets) {
1976
+ const side = Math.sign(offsets[0] ?? 0);
1977
+ return offsets.every(
1978
+ (offset) => offset !== 0 && Math.abs(offset) < 90 && Math.sign(offset) === side
1979
+ );
1980
+ }
1981
+ function reachOf(before, middle, after) {
1982
+ const g0 = signedDelta(before.longitude, middle.longitude);
1983
+ const g1 = signedDelta(middle.longitude, after.longitude);
1984
+ const h0 = middle.time - before.time;
1985
+ const h1 = after.time - middle.time;
1986
+ return 2 * Math.abs(g1 / h1 - g0 / h0) / (h0 + h1) * Math.max(h0, h1) ** 2;
1987
+ }
1988
+ function windowTime(date, label) {
1989
+ if (!(date instanceof Date)) throw new RangeError(`${label} must be a valid Date.`);
1990
+ const milliseconds = Date.prototype.getTime.call(date);
1991
+ if (!Number.isFinite(milliseconds)) throw new RangeError(`${label} must be a valid Date.`);
1992
+ return milliseconds;
1993
+ }
1994
+ function validWindow(targetLongitude, from, to, stepDays) {
1995
+ const fromTime = windowTime(from, "Crossing window start");
1996
+ const toTime = windowTime(to, "Crossing window end");
1997
+ if (fromTime > toTime) throw new RangeError("Crossing window must have from <= to.");
1998
+ if (!Number.isFinite(targetLongitude)) throw new RangeError("targetLongitude must be finite.");
1999
+ if (typeof stepDays !== "number" || !Number.isFinite(stepDays) || stepDays <= 0) {
2000
+ throw new RangeError("stepDays must be positive.");
2001
+ }
2002
+ const step = stepDays * DAY3;
2003
+ if (!Number.isFinite(step) || step < 1) {
2004
+ throw new RangeError("stepDays must represent a finite step of at least one millisecond.");
2005
+ }
2006
+ return { fromTime, toTime, step };
2007
+ }
2008
+ function validBudget(maxSamples) {
2009
+ if (maxSamples === void 0 || maxSamples === Number.POSITIVE_INFINITY) {
2010
+ return Number.POSITIVE_INFINITY;
2011
+ }
2012
+ if (!Number.isInteger(maxSamples) || maxSamples < 1) {
2013
+ throw new RangeError("maxSamples must be a positive integer or Infinity.");
2014
+ }
2015
+ return maxSamples;
2016
+ }
2017
+ function coarseSampleCount({ fromTime, toTime, step }) {
2018
+ const estimate = Math.ceil((toTime - fromTime) / step) - 1;
2019
+ if (!(estimate < 2 ** 52)) return estimate + 2;
2020
+ let interior = Math.max(0, estimate);
2021
+ while (interior > 0 && fromTime + interior * step >= toTime) interior -= 1;
2022
+ while (fromTime + (interior + 1) * step < toTime) interior += 1;
2023
+ return interior + 2;
2024
+ }
2025
+ function solve(longitudeAt2, targetLongitude, { fromTime, toTime, step }, count) {
2026
+ const found = [];
2027
+ const offsetAt = (time) => signedDelta(targetLongitude, longitudeAt2(time));
2028
+ const sampleAt = (time) => {
2029
+ const longitude = longitudeAt2(time);
2030
+ return { time, longitude, offset: signedDelta(targetLongitude, longitude) };
2031
+ };
2032
+ const keep = (time, retrograde) => {
2033
+ if (time > fromTime && time <= toTime) found.push({ at: new Date(time), retrograde });
2034
+ };
2035
+ const bisect = (low, high, rising) => {
2036
+ let lower = low;
2037
+ let upper = high;
2038
+ for (let iteration = 0; iteration < REFINE_STEPS; iteration += 1) {
2039
+ const middle = (lower + upper) / 2;
2040
+ if (offsetAt(middle) > 0 === rising) upper = middle;
2041
+ else lower = middle;
2042
+ }
2043
+ return upper;
2044
+ };
2045
+ const completePair = (low, high, maximize, side) => {
2046
+ let a = low;
2047
+ let b = high;
2048
+ let x1 = b - GOLDEN * (b - a);
2049
+ let x2 = a + GOLDEN * (b - a);
2050
+ let v1 = offsetAt(x1);
2051
+ let v2 = offsetAt(x2);
2052
+ while (b - a > 1) {
2053
+ if (maximize ? v1 < v2 : v1 > v2) {
2054
+ a = x1;
2055
+ x1 = x2;
2056
+ v1 = v2;
2057
+ x2 = a + GOLDEN * (b - a);
2058
+ v2 = offsetAt(x2);
2059
+ } else {
2060
+ b = x2;
2061
+ x2 = x1;
2062
+ v2 = v1;
2063
+ x1 = b - GOLDEN * (b - a);
2064
+ v1 = offsetAt(x1);
2065
+ }
2066
+ }
2067
+ const extremum = (a + b) / 2;
2068
+ const extremeOffset = offsetAt(extremum);
2069
+ if (extremeOffset === 0) {
2070
+ keep(extremum, false);
2071
+ return;
2072
+ }
2073
+ if (Math.sign(extremeOffset) === side) return;
2074
+ keep(bisect(low, extremum, maximize), !maximize);
2075
+ keep(bisect(extremum, high, !maximize), maximize);
2076
+ };
2077
+ const signChange = (previous2, current) => {
2078
+ if (current.offset === 0 && previous2.offset !== 0 && Math.abs(previous2.offset) < 90) {
2079
+ found.push({ at: new Date(current.time), retrograde: previous2.offset > 0 });
2080
+ } else if (previous2.offset !== 0 && current.offset !== 0 && Math.sign(current.offset) !== Math.sign(previous2.offset) && Math.abs(current.offset) < 90 && Math.abs(previous2.offset) < 90) {
2081
+ const rising = current.offset > previous2.offset;
2082
+ found.push({ at: new Date(bisect(previous2.time, current.time, rising)), retrograde: !rising });
2083
+ }
2084
+ };
2085
+ const interiorTurn = (before, middle, after) => {
2086
+ const kind = turn(
2087
+ signedDelta(before.longitude, middle.longitude),
2088
+ signedDelta(middle.longitude, after.longitude)
2089
+ );
2090
+ if (kind === 0 || !sameSideNear(before.offset, middle.offset, after.offset)) return;
2091
+ const maximize = kind > 0;
2092
+ if (maximize !== middle.offset < 0) return;
2093
+ if (Math.abs(middle.offset) > reachOf(before, middle, after) + 1e-12) return;
2094
+ completePair(before.time, after.time, maximize, Math.sign(middle.offset));
2095
+ };
2096
+ const edgeCell = (low, high, reach, first) => {
2097
+ if (!sameSideNear(low.offset, high.offset)) return;
2098
+ if (Math.min(Math.abs(low.offset), Math.abs(high.offset)) > reach + 1e-12) return;
2099
+ const probe = Math.min(EDGE_PROBE_MAX_MS, (high.time - low.time) / 1e3);
2100
+ if (!(probe > 0)) return;
2101
+ const cell = signedDelta(low.longitude, high.longitude);
2102
+ const probeLongitude = longitudeAt2(first ? low.time + probe : high.time - probe);
2103
+ const local = first ? signedDelta(low.longitude, probeLongitude) : signedDelta(probeLongitude, high.longitude);
2104
+ const kind = first ? turn(local, cell) : turn(cell, local);
2105
+ if (kind === 0) return;
2106
+ const maximize = kind > 0;
2107
+ if (maximize !== low.offset < 0) return;
2108
+ completePair(low.time, high.time, maximize, Math.sign(low.offset));
2109
+ };
2110
+ let secondLast;
2111
+ let last2 = sampleAt(fromTime);
2112
+ for (let index = 1; index < count; index += 1) {
2113
+ const current = sampleAt(index === count - 1 ? toTime : fromTime + index * step);
2114
+ signChange(last2, current);
2115
+ if (secondLast) {
2116
+ interiorTurn(secondLast, last2, current);
2117
+ if (index === 2 || index === count - 1) {
2118
+ const reach = 4 * reachOf(secondLast, last2, current);
2119
+ if (index === 2) edgeCell(secondLast, last2, reach, true);
2120
+ if (index === count - 1) edgeCell(last2, current, reach, false);
2121
+ }
2122
+ }
2123
+ secondLast = last2;
2124
+ last2 = current;
2125
+ }
2126
+ if (count === 2 && secondLast) {
2127
+ edgeCell(secondLast, last2, Number.POSITIVE_INFINITY, true);
2128
+ edgeCell(secondLast, last2, Number.POSITIVE_INFINITY, false);
2129
+ }
2130
+ found.sort((a, b) => a.at.getTime() - b.at.getTime());
2131
+ const crossings = [];
2132
+ let previous;
2133
+ for (const crossing of found) {
2134
+ if (!previous || crossing.at.getTime() - previous.at.getTime() >= DUPLICATE_MS) {
2135
+ crossings.push(crossing);
2136
+ }
2137
+ previous = crossing;
2138
+ }
2139
+ return crossings;
2140
+ }
2141
+ function run(longitudeAt2, body, targetLongitude, window, maxSamples) {
2142
+ const refused = (samples2) => ({
2143
+ status: "refused",
2144
+ reason: "sample-budget",
2145
+ samples: samples2,
2146
+ maxSamples,
2147
+ crossings: []
2148
+ });
2149
+ if (window.toTime === window.fromTime) return { status: "complete", crossings: [], samples: 0 };
2150
+ const count = coarseSampleCount(window);
2151
+ if (count > maxSamples) return refused(0);
2152
+ let samples = 0;
2153
+ const sample2 = (time) => {
2154
+ if (samples >= maxSamples) throw new SampleBudgetReached();
2155
+ samples += 1;
2156
+ const longitude = longitudeAt2(body, new Date(time));
2157
+ if (!Number.isFinite(longitude)) {
2158
+ throw new RangeError("Ephemeris returned a non-finite longitude.");
2159
+ }
2160
+ return longitude;
2161
+ };
2162
+ try {
2163
+ const crossings = solve(sample2, targetLongitude, window, count);
2164
+ return { status: "complete", crossings, samples };
2165
+ } catch (error) {
2166
+ if (error instanceof SampleBudgetReached) return refused(samples);
2167
+ throw error;
2168
+ }
2169
+ }
2170
+ function findLongitudeCrossingsWith(longitudeAt2, body, targetLongitude, from, to, stepDays = 5) {
2171
+ const window = validWindow(targetLongitude, from, to, stepDays);
2172
+ const result = run(longitudeAt2, body, targetLongitude, window, Number.POSITIVE_INFINITY);
2173
+ return result.crossings;
2174
+ }
2175
+ function searchLongitudeCrossingsWith(longitudeAt2, body, targetLongitude, from, to, options = {}) {
2176
+ const prototype = options !== null && typeof options === "object" ? Object.getPrototypeOf(options) : void 0;
2177
+ if (prototype !== Object.prototype && prototype !== null) {
2178
+ throw new RangeError("Crossing search options must be a plain options object.");
2179
+ }
2180
+ for (const key of Reflect.ownKeys(options)) {
2181
+ if (key !== "stepDays" && key !== "maxSamples") throw new RangeError(`Crossing search options has an unknown option: ${String(key)}.`);
2182
+ const slot = Object.getOwnPropertyDescriptor(options, key);
2183
+ if (!slot || !("value" in slot) || !slot.enumerable) throw new RangeError("Crossing search options must contain only plain data properties.");
2184
+ }
2185
+ const stepDays = options.stepDays === void 0 ? 5 : options.stepDays;
2186
+ const window = validWindow(targetLongitude, from, to, stepDays);
2187
+ const maxSamples = validBudget(options.maxSamples);
2188
+ return run(longitudeAt2, body, targetLongitude, window, maxSamples);
2189
+ }
2190
+
2191
+ // src/date-input.ts
2192
+ var ISO_INSTANT = /^(\d{4}|[+-]\d{6})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-](\d{2}):(\d{2})))?$/;
2193
+ function validIsoInput(input) {
2194
+ const match = ISO_INSTANT.exec(input);
2195
+ if (!match || match[0] !== input || match[1] === "-000000") return false;
2196
+ const year = Number(match[1]);
2197
+ const month = Number(match[2]);
2198
+ const day = Number(match[3]);
2199
+ if (month < 1 || month > 12) return false;
2200
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2201
+ const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2202
+ if (day < 1 || day > monthDays[month - 1]) return false;
2203
+ return Number(match[4] ?? 0) <= 23 && Number(match[5] ?? 0) <= 59 && Number(match[6] ?? 0) <= 59 && Number(match[9] ?? 0) <= 23 && Number(match[10] ?? 0) <= 59;
2204
+ }
2205
+ function dateFrom(input, label) {
2206
+ const invalid = () => new RangeError(
2207
+ `${label} must be a valid Date, finite epoch-millisecond timestamp, or ISO calendar date/date-time with an explicit UTC offset.`
2208
+ );
2209
+ let date;
2210
+ if (input instanceof Date) {
2211
+ date = new Date(Date.prototype.getTime.call(input));
2212
+ } else if (typeof input === "number" && Number.isFinite(input)) {
2213
+ date = new Date(input);
2214
+ } else if (typeof input === "string" && validIsoInput(input)) {
2215
+ date = new Date(input);
2216
+ } else {
2217
+ throw invalid();
2218
+ }
2219
+ if (!Number.isFinite(date.getTime())) throw invalid();
2220
+ return date;
2221
+ }
2222
+
2223
+ // src/returns.ts
2224
+ var DAY4 = 864e5;
2225
+ function windowEnd(value, end) {
2226
+ return dateFrom(value, `Crossing window ${end}`);
2227
+ }
2228
+ function validMilliseconds(date, label) {
2229
+ if (!(date instanceof Date)) throw new RangeError(`${label} must be a valid Date.`);
2230
+ const milliseconds = Date.prototype.getTime.call(date);
2231
+ if (!Number.isFinite(milliseconds)) throw new RangeError(`${label} must be a valid Date.`);
2232
+ return milliseconds;
2233
+ }
2234
+ function findLongitudeCrossings(body, targetLongitude, from, to, stepDays = 5) {
2235
+ assertKnownBody(body);
2236
+ return findLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, windowEnd(from, "start"), windowEnd(to, "end"), stepDays);
2237
+ }
2238
+ function searchLongitudeCrossings(body, targetLongitude, from, to, options) {
2239
+ assertKnownBody(body);
2240
+ const { value, fallbacks } = notingFallbacks(
2241
+ () => searchLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, windowEnd(from, "start"), windowEnd(to, "end"), options)
2242
+ );
2243
+ return value.status === "complete" ? { ...value, flags: fallbacks } : value;
2244
+ }
2245
+ function groupIntoSeasons(crossings, gapDays = 400) {
2246
+ if (!Number.isFinite(gapDays) || gapDays <= 0) {
2247
+ throw new RangeError("gapDays must be positive.");
2248
+ }
2249
+ const seasons = [];
2250
+ for (const crossing of crossings) {
2251
+ const current = seasons.at(-1);
2252
+ if (current && crossing.at.getTime() - current.last.getTime() <= gapDays * DAY4) {
2253
+ current.crossings.push(crossing);
2254
+ current.last = crossing.at;
2255
+ } else {
2256
+ seasons.push({
2257
+ index: seasons.length + 1,
2258
+ crossings: [crossing],
2259
+ first: crossing.at,
2260
+ last: crossing.at
2261
+ });
2262
+ }
2263
+ }
2264
+ return seasons;
2265
+ }
2266
+ function computeSaturnReturns(birthUtc) {
2267
+ const birthTime = validMilliseconds(birthUtc, "Birth date");
2268
+ const before = new Date(birthTime - SPEED_STEP_DAYS * DAY4);
2269
+ const after = new Date(birthTime + SPEED_STEP_DAYS * DAY4);
2270
+ const from = new Date(birthTime + 26 * 365.25 * DAY4);
2271
+ const to = new Date(birthTime + 92 * 365.25 * DAY4);
2272
+ validMilliseconds(before, "Natal speed window start");
2273
+ validMilliseconds(after, "Natal speed window end");
2274
+ validMilliseconds(from, "Saturn return window start");
2275
+ validMilliseconds(to, "Saturn return window end");
2276
+ const natalLon = bodyLongitude("Saturn", birthUtc);
2277
+ const speed = longitudeSpeed("Saturn", birthUtc);
2278
+ return {
2279
+ natalLon,
2280
+ natalRetrograde: speed < 0,
2281
+ seasons: groupIntoSeasons(findLongitudeCrossings("Saturn", natalLon, from, to))
2282
+ };
2283
+ }
2284
+
2285
+ // src/synastry.ts
2286
+ function findInterAspects(first, second) {
2287
+ const aBodies = first.filter((body) => ASPECT_BODY_SET.has(body.body));
2288
+ const bBodies = second.filter((body) => ASPECT_BODY_SET.has(body.body));
2289
+ const aspects = [];
2290
+ for (const a of aBodies) {
2291
+ for (const b of bBodies) {
2292
+ const match = matchAspect(a.body, a.lon, b.body, b.lon);
2293
+ if (!match) continue;
2294
+ aspects.push({
2295
+ a: a.body,
2296
+ aLon: a.lon,
2297
+ b: b.body,
2298
+ bLon: b.lon,
2299
+ type: match.definition.type,
2300
+ orb: match.orb
2301
+ });
2302
+ }
2303
+ }
2304
+ return aspects.sort((a, b) => a.orb - b.orb);
2305
+ }
2306
+ function elementBalance(bodies) {
2307
+ const balance = {
2308
+ fire: 0,
2309
+ earth: 0,
2310
+ air: 0,
2311
+ water: 0
2312
+ };
2313
+ for (const body of bodies) {
2314
+ if (!ASPECT_BODY_SET.has(body.body)) continue;
2315
+ balance[signForLongitude(body.lon).element] += 1;
2316
+ }
2317
+ return balance;
2318
+ }
2319
+ function modalityBalance(bodies) {
2320
+ const balance = {
2321
+ cardinal: 0,
2322
+ fixed: 0,
2323
+ mutable: 0
2324
+ };
2325
+ for (const body of bodies) {
2326
+ if (!ASPECT_BODY_SET.has(body.body)) continue;
2327
+ balance[signForLongitude(body.lon).modality] += 1;
2328
+ }
2329
+ return balance;
2330
+ }
2331
+ function summarizePair(first, second, topCount = 8) {
2332
+ if (!Number.isInteger(topCount) || topCount < 0) {
2333
+ throw new RangeError("topCount must be a non-negative integer.");
2334
+ }
2335
+ const aspects = findInterAspects(first, second);
2336
+ const counts = {
2337
+ conjunction: 0,
2338
+ sextile: 0,
2339
+ square: 0,
2340
+ trine: 0,
2341
+ opposition: 0
2342
+ };
2343
+ for (const aspect of aspects) counts[aspect.type] += 1;
2344
+ return {
2345
+ aspects,
2346
+ top: aspects.slice(0, topCount),
2347
+ counts,
2348
+ easeful: counts.trine + counts.sextile,
2349
+ charged: counts.square + counts.opposition,
2350
+ elements: {
2351
+ a: elementBalance(first),
2352
+ b: elementBalance(second)
2353
+ },
2354
+ modalities: {
2355
+ a: modalityBalance(first),
2356
+ b: modalityBalance(second)
2357
+ }
2358
+ };
2359
+ }
2360
+
2361
+ // src/birth-input.ts
2362
+ var HOUSE_SYSTEM_NAMES = [
2363
+ "whole",
2364
+ "placidus",
2365
+ "porphyry",
2366
+ "equal",
2367
+ "equal-mc",
2368
+ "vehlow",
2369
+ "koch",
2370
+ "regiomontanus",
2371
+ "campanus",
2372
+ "topocentric",
2373
+ "alcabitius",
2374
+ "morinus",
2375
+ "meridian"
2376
+ ];
2377
+ function validateBirthSettings(birth) {
2378
+ const { houseSystem, timeKnown, latitude, longitude } = birth;
2379
+ if (houseSystem !== void 0 && !HOUSE_SYSTEM_NAMES.includes(houseSystem)) {
2380
+ throw new RangeError(
2381
+ `houseSystem must be one of ${HOUSE_SYSTEM_NAMES.map((name) => `"${name}"`).join(", ")}.`
2382
+ );
2383
+ }
2384
+ if (timeKnown !== void 0 && typeof timeKnown !== "boolean") {
2385
+ throw new RangeError("timeKnown must be a boolean.");
2386
+ }
2387
+ const hasLatitude = latitude !== void 0;
2388
+ const hasLongitude = longitude !== void 0;
2389
+ if (hasLatitude !== hasLongitude) {
2390
+ throw new RangeError("latitude and longitude must be supplied together.");
2391
+ }
2392
+ if (latitude !== void 0 && (!Number.isFinite(latitude) || latitude < -90 || latitude > 90)) {
2393
+ throw new RangeError("latitude must be between -90 and 90 degrees.");
2394
+ }
2395
+ if (longitude !== void 0 && (!Number.isFinite(longitude) || longitude < -180 || longitude > 180)) {
2396
+ throw new RangeError("longitude must be between -180 and 180 degrees.");
2397
+ }
2398
+ return {
2399
+ ...houseSystem === void 0 ? {} : { houseSystem },
2400
+ ...timeKnown === void 0 ? {} : { timeKnown },
2401
+ ...latitude === void 0 ? {} : { latitude, longitude }
2402
+ };
2403
+ }
2404
+ var DERIVED_FLAGS = [
2405
+ "no-time",
2406
+ "polar-fallback",
2407
+ "polar-angles",
2408
+ "outside-reference-span",
2409
+ "delta-t-extrapolated",
2410
+ "de440-unavailable",
2411
+ "outside-de440-span"
2412
+ ];
2413
+ var FLAGS = ["dst-gap", "dst-fold", "lmt", "calendar-unknown", "host-zone-data-differs", ...DERIVED_FLAGS];
2414
+ function snapshotFlags(value) {
2415
+ const length = Array.isArray(value) ? Object.getOwnPropertyDescriptor(value, "length")?.value : void 0;
2416
+ if (typeof length !== "number" || !Number.isInteger(length) || length < 0 || length > 64) {
2417
+ throw new RangeError("flags must be an array of at most 64 supported chart flags.");
2418
+ }
2419
+ const values = [];
2420
+ for (let index = 0; index < length; index += 1) {
2421
+ const flag = Object.getOwnPropertyDescriptor(value, String(index))?.value;
2422
+ if (typeof flag !== "string" || !FLAGS.includes(flag)) {
2423
+ throw new RangeError("flags must contain only supported chart flag strings.");
2424
+ }
2425
+ if (!values.includes(flag)) values.push(flag);
2426
+ }
2427
+ if (values.includes("dst-gap") && values.includes("dst-fold")) {
2428
+ throw new RangeError('flags cannot contain both "dst-gap" and "dst-fold".');
2429
+ }
2430
+ return { values, hasDuplicates: values.length !== length };
2431
+ }
2432
+ function timeFlags(flags) {
2433
+ return flags.filter((flag) => !DERIVED_FLAGS.includes(flag));
2434
+ }
2435
+ function assertDerivedFlags(supplied, actual) {
2436
+ for (const flag of DERIVED_FLAGS) {
2437
+ if (supplied.includes(flag) && !actual.includes(flag)) {
2438
+ throw new RangeError("flags contradict the birth time or house result.");
2439
+ }
2440
+ }
2441
+ }
2442
+
2443
+ // src/api.ts
2444
+ function isChart(value) {
2445
+ if (!value || typeof value !== "object") return false;
2446
+ const candidate = value;
2447
+ return Array.isArray(candidate.bodies) && Array.isArray(candidate.aspects) && candidate.input?.utc instanceof Date;
2448
+ }
2449
+ function isBirth(value) {
2450
+ return Boolean(value && typeof value === "object" && "utc" in value);
2451
+ }
2452
+ function resolvedChart(source2) {
2453
+ if (!isChart(source2)) {
2454
+ const chart = natalChart(source2);
2455
+ return { chart, utc: chart.input.utc };
2456
+ }
2457
+ const sourceInput = source2.input;
2458
+ const { input, flags: inputFlags } = validateBirth(sourceInput);
2459
+ const resultFlags = snapshotFlags(source2.flags);
2460
+ const expected = timeFlags(inputFlags?.values ?? []);
2461
+ const hasHouses = input.timeKnown && input.latitude !== void 0;
2462
+ const houses = source2.houses;
2463
+ const angles = source2.angles;
2464
+ const actualHouseSystem = houses?.system;
2465
+ if ((hasHouses ? !angles || typeof angles !== "object" || Array.isArray(angles) || !houses || typeof houses !== "object" || Array.isArray(houses) : angles !== null || houses !== null) || houses !== null && actualHouseSystem !== input.houseSystem && !(isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK)) {
2466
+ throw new RangeError("chart flags must agree with its input and supplied house result.");
2467
+ }
2468
+ if (!input.timeKnown) expected.push("no-time");
2469
+ if (isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK) {
2470
+ expected.push("polar-fallback");
2471
+ }
2472
+ const basis = timeBasis(+input.utc, input.timeScale, input.deltaT);
2473
+ if (hasHouses && resultFlags.values.includes("polar-angles") && Math.abs(input.latitude) >= 90 - meanObliquity(basis.ttDays / 36525) - 3e-3)
2474
+ expected.push("polar-angles");
2475
+ if (outsideReferenceSpan(input.utc)) expected.push("outside-reference-span");
2476
+ if (resultFlags.values.length > expected.length && deltaTExtrapolated(basis, hasHouses))
2477
+ expected.push("delta-t-extrapolated");
2478
+ if (source2.ephemeris === void 0 || source2.ephemeris?.name === "astronomy-engine") {
2479
+ for (const reason of ["de440-unavailable", "outside-de440-span"]) if (resultFlags.values.includes(reason)) expected.push(reason);
2480
+ }
2481
+ assertDerivedFlags(inputFlags?.values ?? [], expected);
2482
+ if (resultFlags.values.length !== expected.length || !expected.every((flag) => resultFlags.values.includes(flag))) {
2483
+ throw new RangeError("chart flags must agree with its input and supplied house result.");
2484
+ }
2485
+ const canonicalInputFlags = input.flags ?? [];
2486
+ const inputChanged = inputFlags !== void 0 && (inputFlags.hasDuplicates || inputFlags.values.length !== canonicalInputFlags.length);
2487
+ const resultChanged = resultFlags.hasDuplicates || !expected.every((flag, index) => flag === resultFlags.values[index]);
2488
+ if (!inputChanged && !resultChanged) return { chart: source2, utc: input.utc };
2489
+ return {
2490
+ chart: {
2491
+ ...source2,
2492
+ input: inputChanged ? input : sourceInput,
2493
+ flags: expected
2494
+ },
2495
+ utc: input.utc
2496
+ };
2497
+ }
2498
+ var BIRTH_FIELDS = [
2499
+ "utc",
2500
+ "timeScale",
2501
+ "latitude",
2502
+ "longitude",
2503
+ "houseSystem",
2504
+ "timeKnown",
2505
+ "flags",
2506
+ "deltaT"
2507
+ ];
2508
+ var NEAR_MISS_KEYS = [
2509
+ ["latitude", ["lat"]],
2510
+ ["longitude", ["lng", "lon", "long"]],
2511
+ ["houseSystem", ["house", "houses", "hsys", "housesystem"]],
2512
+ ["timeScale", ["scale", "time_scale"]],
2513
+ ["deltaT", ["delta_t"]],
2514
+ ["timeKnown", ["time_known", "unknownTime"]]
2515
+ ];
2516
+ function noBareDate(value, name) {
2517
+ if (typeof value === "string" && !value.includes("T")) {
2518
+ throw new RangeError(
2519
+ `${name} is a calendar date with no time. Give the birth instant with its UTC offset, such as 1990-05-03T08:30:00+02:00, or set timeKnown: false if the birth time is not known.`
2520
+ );
2521
+ }
2522
+ }
2523
+ function validateBirth(birth) {
2524
+ if (!birth || typeof birth !== "object" || Array.isArray(birth)) {
2525
+ throw new RangeError("birth must be an object containing a resolved utc instant.");
2526
+ }
2527
+ for (const key of Object.keys(birth)) {
2528
+ const field = BIRTH_FIELDS.find((name) => name !== key && name.toLowerCase() === key.toLowerCase());
2529
+ if (field) throw new RangeError(`birth has no field "${key}"; field names are case-sensitive: "${field}".`);
2530
+ }
2531
+ const settings = validateBirthSettings(birth);
2532
+ const supplied = birth.flags;
2533
+ const flags = supplied === void 0 ? void 0 : snapshotFlags(supplied);
2534
+ const suppliedUtc = birth.utc;
2535
+ const utc = dateFrom(suppliedUtc, "birth.utc");
2536
+ for (const key of Object.keys(birth)) {
2537
+ const lower = key.toLowerCase();
2538
+ const near = NEAR_MISS_KEYS.find(([real, names]) => real !== key && names.some((name) => name.toLowerCase() === lower));
2539
+ if (near) throw new RangeError(`birth has no field "${key}"; use "${near[0]}".`);
2540
+ }
2541
+ const pin = birth.deltaT;
2542
+ if (pin !== void 0 && (typeof pin !== "number" || !Number.isFinite(pin) || Math.abs(pin) > 1e10)) {
2543
+ throw new RangeError("deltaT must be a finite number of seconds, at most 1e10 in size.");
2544
+ }
2545
+ const scale = birth.timeScale;
2546
+ if (scale !== void 0 && !TIME_SCALE_NAMES.includes(scale)) {
2547
+ throw new RangeError('timeScale must be "utc", "ut1" or "tt".');
2548
+ }
2549
+ const possible = ["delta-t-extrapolated", "de440-unavailable", "outside-de440-span"];
2550
+ if (settings.timeKnown === false) possible.push("no-time");
2551
+ else if (settings.latitude !== void 0) {
2552
+ possible.push("polar-angles");
2553
+ if (settings.houseSystem !== void 0 && isPolarUndefinedHouseSystem(settings.houseSystem)) possible.push("polar-fallback");
2554
+ }
2555
+ if (outsideReferenceSpan(utc)) possible.push("outside-reference-span");
2556
+ assertDerivedFlags(flags?.values ?? [], possible);
2557
+ if (settings.timeKnown !== false) noBareDate(suppliedUtc, "birth.utc");
2558
+ const input = {
2559
+ utc,
2560
+ houseSystem: settings.houseSystem ?? "whole",
2561
+ timeKnown: settings.timeKnown ?? true,
2562
+ ...settings.latitude === void 0 ? {} : { latitude: settings.latitude, longitude: settings.longitude },
2563
+ ...flags === void 0 ? {} : { flags: timeFlags(flags.values) },
2564
+ ...pin === void 0 ? {} : { deltaT: pin },
2565
+ ...scale === void 0 || scale === "utc" ? {} : { timeScale: scale }
2566
+ };
2567
+ return { input, flags };
2568
+ }
2569
+ function computedBirth({ input, flags }) {
2570
+ const chart = computeChart(input);
2571
+ assertDerivedFlags(flags?.values ?? [], chart.flags);
2572
+ return chart;
2573
+ }
2574
+ function positions(date) {
2575
+ return computeBodies(dateFrom(date, "date"));
2576
+ }
2577
+ function natalChart(birth) {
2578
+ return computedBirth(validateBirth(birth));
2579
+ }
2580
+ function chartDeclinations(natal) {
2581
+ return computeChartDeclinations(resolvedChart(natal).chart);
2582
+ }
2583
+ function chartPoints(natal) {
2584
+ const { chart } = resolvedChart(natal);
2585
+ return computePoints(chart);
2586
+ }
2587
+ function transits(natal, date) {
2588
+ const { chart } = resolvedChart(natal);
2589
+ const at = dateFrom(date, "date");
2590
+ const current = computeBodies(at);
2591
+ return {
2592
+ natal: chart,
2593
+ at,
2594
+ positions: current,
2595
+ aspects: findInterAspects(current, chart.bodies)
2596
+ };
2597
+ }
2598
+ function synastry(first, second) {
2599
+ const { chart: a } = resolvedChart(first);
2600
+ const { chart: b } = resolvedChart(second);
2601
+ return { a, b, ...summarizePair(a.bodies, b.bodies) };
2602
+ }
2603
+ function phaseName(angle) {
2604
+ if (angle < 22.5 || angle >= 337.5) return "New Moon";
2605
+ if (angle < 67.5) return "Waxing Crescent";
2606
+ if (angle < 112.5) return "First Quarter";
2607
+ if (angle < 157.5) return "Waxing Gibbous";
2608
+ if (angle < 202.5) return "Full Moon";
2609
+ if (angle < 247.5) return "Waning Gibbous";
2610
+ if (angle < 292.5) return "Last Quarter";
2611
+ return "Waning Crescent";
2612
+ }
2613
+ function moonPhase(date) {
2614
+ const at = dateFrom(date, "date");
2615
+ const angle = normalizeLongitude(bodyLongitude("Moon", at) - bodyLongitude("Sun", at));
2616
+ const { ephemeris, fallback: fallback2 } = ephemerisAt(at.getTime());
2617
+ return {
2618
+ at,
2619
+ angle,
2620
+ illumination: (1 - Math.cos(angle * Math.PI / 180)) / 2,
2621
+ name: phaseName(angle),
2622
+ waxing: angle < 180,
2623
+ ephemeris: ephemeris.name,
2624
+ ...fallback2 !== null && { fallback: fallback2 }
2625
+ };
2626
+ }
2627
+ function utcOf(input) {
2628
+ if (input.timeScale === void 0) return input.utc;
2629
+ return new Date(Math.round(timeBasis(input.utc.getTime(), input.timeScale, input.deltaT).utcMs));
2630
+ }
2631
+ function saturnReturn(birth) {
2632
+ let utc;
2633
+ if (isChart(birth)) {
2634
+ const { chart } = resolvedChart(birth);
2635
+ utc = utcOf(chart.input);
2636
+ } else if (isBirth(birth)) {
2637
+ const validated = validateBirth(birth);
2638
+ utc = utcOf(
2639
+ validated.flags?.values.some((flag) => flag === "polar-fallback" || flag === "polar-angles") ? computedBirth(validated).input : validated.input
2640
+ );
2641
+ } else {
2642
+ utc = dateFrom(birth, "birth");
2643
+ }
2644
+ const { value, fallbacks } = notingFallbacks(() => computeSaturnReturns(utc));
2645
+ noBareDate(birth, "birth");
2646
+ const ephemeris = fallbacks.length > 0 ? EPHEMERIS.name : ephemerisAt(utc.getTime()).ephemeris.name;
2647
+ return { ...value, ephemeris, flags: fallbacks };
2648
+ }
2649
+
2650
+ // src/progressions.ts
2651
+ var PROGRESSION_DAYS_PER_YEAR = 365.2422;
2652
+ var DAY_MS = 864e5;
2653
+ function progressedInstant(birthUtc, target) {
2654
+ const birth = dateFrom(birthUtc, "birthUtc");
2655
+ const at = dateFrom(target, "target");
2656
+ const yearsLived = (at.getTime() - birth.getTime()) / (PROGRESSION_DAYS_PER_YEAR * DAY_MS);
2657
+ return new Date(birth.getTime() + yearsLived * DAY_MS);
2658
+ }
2659
+ function progressedBodies(birthUtc, target) {
2660
+ return computeBodies(progressedInstant(birthUtc, target));
2661
+ }
2662
+
2663
+ // src/configured-aspects.ts
2664
+ var ASPECT_POLICY_SCHEMA = "zodiacs.aspect-policy.v1";
2665
+ var CONFIGURED_ASPECTS_SCHEMA = "zodiacs.configured-aspects.v1";
2666
+ var CONFIGURED_ASPECT_ANGLES = /* @__PURE__ */ Object.freeze({
2667
+ conjunction: 0,
2668
+ semisextile: 30,
2669
+ semisquare: 45,
2670
+ sextile: 60,
2671
+ quintile: 72,
2672
+ square: 90,
2673
+ trine: 120,
2674
+ sesquiquadrate: 135,
2675
+ biquintile: 144,
2676
+ quincunx: 150,
2677
+ opposition: 180
2678
+ });
2679
+ var PHYSICAL_BODIES = ["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"];
2680
+ var DEFAULT_RULES = [
2681
+ { type: "conjunction", orb: 8, luminaryOrb: 10 },
2682
+ { type: "sextile", orb: 4, luminaryOrb: 5 },
2683
+ { type: "square", orb: 7, luminaryOrb: 8 },
2684
+ { type: "trine", orb: 7, luminaryOrb: 8 },
2685
+ { type: "opposition", orb: 8, luminaryOrb: 10 }
2686
+ ];
2687
+ var POLICIES = /* @__PURE__ */ new WeakSet();
2688
+ var CONVENTIONS = /* @__PURE__ */ Object.freeze({
2689
+ coordinates: "ecliptic-longitude-degrees-[0,360)",
2690
+ speed: "longitude-degrees-per-day;same-time-basis",
2691
+ motion: "instantaneous-orb-rate;right-derivative-at-circular-corners;exact-separating-unless-stationary",
2692
+ orb: "inclusive;luminary-replaces-rule;minimum-of-rule-and-both-body-caps",
2693
+ matching: "one-per-pair;smallest-absolute-orb;definition-order-on-tie",
2694
+ ordering: "ascending-orb;input-pair-order-on-tie",
2695
+ arithmetic: "exact-binary64;reported-orb-rounded-half-even"
2696
+ });
2697
+ function requireValue(condition, message) {
2698
+ if (!condition) throw new RangeError(message);
2699
+ }
2700
+ function dataObject(value, allowed) {
2701
+ requireValue(value !== null && typeof value === "object" && !Array.isArray(value), "Expected an ordinary data object.");
2702
+ const proto = Object.getPrototypeOf(value);
2703
+ requireValue(proto === Object.prototype || proto === null, "Expected an ordinary data object.");
2704
+ const out = /* @__PURE__ */ Object.create(null);
2705
+ for (const key of Reflect.ownKeys(value)) {
2706
+ requireValue(typeof key === "string" && (!allowed || allowed.includes(key)), "Unknown configuration field.");
2707
+ const slot = Object.getOwnPropertyDescriptor(value, key);
2708
+ requireValue(slot && "value" in slot && slot.enumerable, "Expected ordinary enumerable data slots.");
2709
+ out[key] = slot.value;
2710
+ }
2711
+ return out;
2712
+ }
2713
+ function dataArray(value, maximum, label) {
2714
+ requireValue(Array.isArray(value) && value.length <= maximum, `${label} must be an array with at most ${maximum} entries.`);
2715
+ const out = [];
2716
+ for (let i = 0; i < value.length; i += 1) {
2717
+ const slot = Object.getOwnPropertyDescriptor(value, String(i));
2718
+ requireValue(slot && "value" in slot, `${label} must not contain holes or accessor slots.`);
2719
+ out.push(slot.value);
2720
+ }
2721
+ return out;
2722
+ }
2723
+ function numberIn(value, low, high, label) {
2724
+ requireValue(typeof value === "number" && Number.isFinite(value) && value >= low && value <= high, `${label} is outside its finite range.`);
2725
+ return value === 0 ? 0 : value;
2726
+ }
2727
+ var bodyLabel = checkedBodyLabel;
2728
+ function orbLimits(value) {
2729
+ if (typeof value === "number") {
2730
+ const limit = numberIn(value, 0, 180, "Orb");
2731
+ return Object.freeze({ applying: limit, separating: limit, stationary: limit });
2732
+ }
2733
+ const object = dataObject(value, ["applying", "separating", "stationary"]);
2734
+ return Object.freeze({
2735
+ applying: numberIn(object.applying, 0, 180, "Applying orb"),
2736
+ separating: numberIn(object.separating, 0, 180, "Separating orb"),
2737
+ stationary: numberIn(object.stationary, 0, 180, "Stationary orb")
2738
+ });
2739
+ }
2740
+ function createAspectPolicy(input = {}) {
2741
+ const options = dataObject(input, ["aspects", "bodies", "bodyOrbs", "stationaryRelativeSpeed"]);
2742
+ const bodyValues = options.bodies === void 0 ? PHYSICAL_BODIES : options.bodies;
2743
+ const bodies = dataArray(bodyValues, 256, "Bodies").map(bodyLabel);
2744
+ requireValue(new Set(bodies).size === bodies.length, "Body selection contains duplicate labels.");
2745
+ const rules = dataArray(options.aspects === void 0 ? DEFAULT_RULES : options.aspects, 64, "Aspects");
2746
+ const seen = /* @__PURE__ */ new Set();
2747
+ const aspects = rules.map((value) => {
2748
+ const rule = dataObject(value, ["type", "angle", "orb", "luminaryOrb"]);
2749
+ requireValue(typeof rule.type === "string" && /^[a-z][a-z0-9-]{0,63}$/.test(rule.type), "Aspect type must be a lowercase identifier of at most 64 characters.");
2750
+ const type = rule.type;
2751
+ requireValue(!seen.has(type), "Aspect types must be unique.");
2752
+ seen.add(type);
2753
+ const named2 = Object.hasOwn(CONFIGURED_ASPECT_ANGLES, type) ? CONFIGURED_ASPECT_ANGLES[type] : void 0;
2754
+ const angle = numberIn(rule.angle === void 0 ? named2 : rule.angle, 0, 180, "Aspect angle");
2755
+ requireValue(named2 === void 0 || angle === named2, "A named aspect must keep its named angle.");
2756
+ return Object.freeze({
2757
+ type,
2758
+ angle,
2759
+ orb: orbLimits(rule.orb),
2760
+ ...rule.luminaryOrb === void 0 ? {} : { luminaryOrb: orbLimits(rule.luminaryOrb) }
2761
+ });
2762
+ });
2763
+ const caps = options.bodyOrbs === void 0 ? {} : dataObject(options.bodyOrbs);
2764
+ const bodyOrbs = /* @__PURE__ */ Object.create(null);
2765
+ for (const [name, value] of Object.entries(caps)) {
2766
+ bodyLabel(name);
2767
+ requireValue(bodies.includes(name), "A body orb cap must name a selected body.");
2768
+ bodyOrbs[name] = orbLimits(value);
2769
+ }
2770
+ const stationaryRelativeSpeed = options.stationaryRelativeSpeed === void 0 ? 1e-9 : numberIn(options.stationaryRelativeSpeed, 0, Number.MAX_VALUE, "Stationary relative speed");
2771
+ const policy = Object.freeze({
2772
+ schema: ASPECT_POLICY_SCHEMA,
2773
+ aspects: Object.freeze(aspects),
2774
+ bodies: Object.freeze(bodies),
2775
+ bodyOrbs: Object.freeze(bodyOrbs),
2776
+ stationaryRelativeSpeed,
2777
+ conventions: CONVENTIONS
2778
+ });
2779
+ POLICIES.add(policy);
2780
+ return policy;
2781
+ }
2782
+ var DEFAULT_ASPECT_POLICY = /* @__PURE__ */ createAspectPolicy();
2783
+ function signedSeparation(a, b) {
2784
+ const difference = exactSum(a, -b);
2785
+ if (compareExact(difference, 180) > 0) return exactSum(difference, -360);
2786
+ if (compareExact(difference, -180) <= 0) return exactSum(difference, 360);
2787
+ return difference;
2788
+ }
2789
+ function relativeSpeedSign(a, b, threshold) {
2790
+ if (a === b) return 0;
2791
+ const sign = a > b ? 1 : -1;
2792
+ return exactSign([threshold, -sign * a, sign * b]) > 0 ? 0 : sign;
2793
+ }
2794
+ function distanceRateSign(signed, distance, relative) {
2795
+ if (signOf(distance) === 0) return 1;
2796
+ if (compareExact(distance, 180) === 0) return -1;
2797
+ return signOf(signed) * relative > 0 ? 1 : -1;
2798
+ }
2799
+ function motionOf(deviation, rate) {
2800
+ if (rate === null) return "stationary";
2801
+ const deviationSign = signOf(deviation);
2802
+ if (deviationSign === 0) return "separating";
2803
+ return deviationSign * rate < 0 ? "applying" : "separating";
2804
+ }
2805
+ function findConfiguredAspects(positions2, policy) {
2806
+ requireValue(policy !== null && typeof policy === "object" && POLICIES.has(policy), "Policy must be made by createAspectPolicy.");
2807
+ const labels = /* @__PURE__ */ new Set();
2808
+ const all = dataArray(positions2, 256, "Positions").map((value) => {
2809
+ const row = dataObject(value);
2810
+ const body = bodyLabel(row.body);
2811
+ requireValue(!labels.has(body), "Positions contain duplicate body labels.");
2812
+ labels.add(body);
2813
+ const lon = numberIn(row.lon, 0, 360, "Longitude");
2814
+ requireValue(lon < 360, "Longitude must be in [0,360).");
2815
+ requireValue(typeof row.speed === "number" && Number.isFinite(row.speed), "Every position requires a finite longitude speed.");
2816
+ return { body, lon, speed: row.speed };
2817
+ });
2818
+ const selected = new Set(policy.bodies);
2819
+ const candidates = all.filter((row) => selected.has(row.body));
2820
+ const found = [];
2821
+ for (let i = 0; i < candidates.length; i += 1) {
2822
+ for (let j = i + 1; j < candidates.length; j += 1) {
2823
+ const a = candidates[i], b = candidates[j];
2824
+ const signed = signedSeparation(a.lon, b.lon);
2825
+ const distance = absolute(signed);
2826
+ const relative = relativeSpeedSign(a.speed, b.speed, policy.stationaryRelativeSpeed);
2827
+ const rate = relative === 0 ? null : distanceRateSign(signed, distance, relative);
2828
+ const luminary = a.body === "Sun" || a.body === "Moon" || b.body === "Sun" || b.body === "Moon";
2829
+ let best = null;
2830
+ for (const definition of policy.aspects) {
2831
+ const deviation = exactSum(distance, -definition.angle);
2832
+ const exactOrb = absolute(deviation);
2833
+ const motion = motionOf(deviation, rate);
2834
+ const limits = luminary && definition.luminaryOrb ? definition.luminaryOrb : definition.orb;
2835
+ const maximumOrb = Math.min(limits[motion], policy.bodyOrbs[a.body]?.[motion] ?? 180, policy.bodyOrbs[b.body]?.[motion] ?? 180);
2836
+ if (compareExact(exactOrb, maximumOrb) <= 0 && (!best || compareExact(exactOrb, best.exactOrb) < 0)) {
2837
+ best = { definition, exactOrb, maximumOrb, motion };
2838
+ }
2839
+ }
2840
+ if (best) {
2841
+ const { definition, exactOrb, maximumOrb, motion } = best;
2842
+ found.push({ exactOrb, aspect: Object.freeze({
2843
+ a: a.body,
2844
+ b: b.body,
2845
+ type: definition.type,
2846
+ angle: definition.angle,
2847
+ orb: roundedValue(exactOrb),
2848
+ maximumOrb,
2849
+ motion,
2850
+ applying: motion === "applying"
2851
+ }) });
2852
+ }
2853
+ }
2854
+ }
2855
+ found.sort((x, y) => compareExact(x.exactOrb, y.exactOrb));
2856
+ return Object.freeze({ schema: CONFIGURED_ASPECTS_SCHEMA, policy, aspects: Object.freeze(found.map((entry) => entry.aspect)) });
2857
+ }
2858
+ export {
2859
+ ASPECTS,
2860
+ ASPECT_BODIES,
2861
+ ASPECT_POLICY_SCHEMA,
2862
+ ASPECT_TYPES,
2863
+ CONFIGURED_ASPECTS_SCHEMA,
2864
+ CONFIGURED_ASPECT_ANGLES,
2865
+ DECLINATION_ORB,
2866
+ DECLINATION_ORB_LUMINARY,
2867
+ DEFAULT_ASPECT_POLICY,
2868
+ DEFAULT_DECLINATION_ORB_POLICY,
2869
+ DELTA_T_IERS_MODEL,
2870
+ DELTA_T_MODEL,
2871
+ DELTA_T_TABLE,
2872
+ ELEMENTS,
2873
+ ENGINE_VERSION,
2874
+ EPHEMERIS,
2875
+ EPHEMERIS_SPAN,
2876
+ HOUSE_SYSTEMS,
2877
+ LOTS,
2878
+ MEAN_LUNAR_INCLINATION,
2879
+ MODALITIES,
2880
+ PLACIDUS_POLAR_FALLBACK,
2881
+ POLAR_FALLBACK,
2882
+ POLAR_UNDEFINED_HOUSE_SYSTEMS,
2883
+ PROGRESSION_DAYS_PER_YEAR,
2884
+ RA_POLE_TOLERANCE,
2885
+ REFERENCE_SPAN,
2886
+ SIGNS,
2887
+ SIGN_NAMES,
2888
+ SIGN_SLUGS,
2889
+ STATIONARY_RELATIVE_SPEED,
2890
+ SUN_BOUND_LATITUDE,
2891
+ alcabitiusCusps,
2892
+ antiscion,
2893
+ aspectMotion,
2894
+ campanusCusps,
2895
+ chartDeclinations,
2896
+ chartPoints,
2897
+ computeAngles,
2898
+ computeHouses,
2899
+ contraAntiscion,
2900
+ createAspectPolicy,
2901
+ declinationOf,
2902
+ declinationOrb,
2903
+ declinationsForBodies,
2904
+ defaultEphemeris,
2905
+ degreeInSign,
2906
+ deltaT,
2907
+ deltaTAt,
2908
+ eastPointOf,
2909
+ eclipticToEquatorial,
2910
+ elementBalance,
2911
+ equalCusps,
2912
+ equalMcCusps,
2913
+ findAspects,
2914
+ findConfiguredAspects,
2915
+ findDeclinationAspects,
2916
+ findInterAspects,
2917
+ findLongitudeCrossings,
2918
+ findLongitudeCrossingsWith,
2919
+ groupIntoSeasons,
2920
+ hellenisticLots,
2921
+ houseOf,
2922
+ isPolarUndefinedHouseSystem,
2923
+ kochCusps,
2924
+ lunarMeanArguments,
2925
+ matchAspect,
2926
+ meanApogee,
2927
+ meanNodeLongitude,
2928
+ meanObliquity,
2929
+ meridianCusps,
2930
+ midpoint,
2931
+ modalityBalance,
2932
+ moonPhase,
2933
+ morinusCusps,
2934
+ natalChart,
2935
+ normalizeLongitude,
2936
+ outsideReferenceSpan,
2937
+ placidusCusps,
2938
+ porphyryCusps,
2939
+ positions,
2940
+ progressedBodies,
2941
+ progressedInstant,
2942
+ ramcOf,
2943
+ regiomontanusCusps,
2944
+ saturnReturn,
2945
+ searchLongitudeCrossings,
2946
+ searchLongitudeCrossingsWith,
2947
+ sectOf,
2948
+ separation,
2949
+ setDefaultEphemeris,
2950
+ signForLongitude,
2951
+ signIndexForLongitude,
2952
+ summarizePair,
2953
+ synastry,
2954
+ topocentricCusps,
2955
+ transits,
2956
+ vehlowCusps,
2957
+ vertexOf,
2958
+ wholeSignCusps,
2959
+ withEphemeris
2960
+ };