@zodiacs/engine 1.0.0 → 2.0.0-rc.2

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 (70) hide show
  1. package/CHANGELOG.md +1244 -0
  2. package/LICENSING.md +172 -27
  3. package/NOTICE +78 -12
  4. package/README.md +344 -59
  5. package/dist/{api-WbxJ4Wj-.d.ts → api-C_SVd9BJ.d.ts} +39 -3
  6. package/dist/{ayanamsa--YQ46fET.d.ts → ayanamsa-Clgkekhh.d.ts} +2 -1
  7. package/dist/calc.d.ts +91 -4
  8. package/dist/calc.js +368 -126
  9. package/dist/chunk-CV53HA7R.js +87 -0
  10. package/dist/chunk-EEW7746S.js +83 -0
  11. package/dist/{chunk-WS3TDSP3.js → chunk-FVGA776A.js} +7 -3
  12. package/dist/chunk-HNVGWN3S.js +852 -0
  13. package/dist/chunk-I3L4POY7.js +18 -0
  14. package/dist/{chunk-FTX3JDJA.js → chunk-IXFUYEUF.js} +65 -29
  15. package/dist/{chunk-7TRLIFFI.js → chunk-LWZS7HI3.js} +1 -1
  16. package/dist/{chunk-CHSYDKBL.js → chunk-N4UQLCBN.js} +3 -3
  17. package/dist/{chunk-YIITY7Q7.js → chunk-NX4PHQBL.js} +34 -22
  18. package/dist/chunk-OVXQQEXL.js +41 -0
  19. package/dist/{chunk-SRXBTP5H.js → chunk-PNXIA7MI.js} +217 -192
  20. package/dist/chunk-RMBWKZI2.js +130 -0
  21. package/dist/{chunk-DMGHYCDI.js → chunk-SCRO6HWB.js} +5 -3
  22. package/dist/{chunk-OG4OYTJJ.js → chunk-T6F4FYYS.js} +1 -129
  23. package/dist/chunk-UXY4RU57.js +48 -0
  24. package/dist/{chunk-PFGUCNOK.js → chunk-WONTOC5W.js} +7 -6
  25. package/dist/conventions.d.ts +70 -0
  26. package/dist/conventions.js +26 -0
  27. package/dist/crossings.d.ts +15 -4
  28. package/dist/de440-pack.d.ts +43 -0
  29. package/dist/de440-pack.js +16 -0
  30. package/dist/de440.d.ts +113 -0
  31. package/dist/de440.js +19 -0
  32. package/dist/ephemeris-D1lM832F.d.ts +64 -0
  33. package/dist/geo.d.ts +28 -7
  34. package/dist/geo.js +2 -2
  35. package/dist/houses-extra.d.ts +5 -4
  36. package/dist/{houses-CFERsAlK.d.ts → houses-icK01yXi.d.ts} +3 -3
  37. package/dist/index.d.ts +8 -6
  38. package/dist/index.js +40 -28
  39. package/dist/{internal-math-DJJ8BYex.d.ts → internal-math-BGX23p4h.d.ts} +2 -2
  40. package/dist/internal-math.d.ts +4 -3
  41. package/dist/internal-math.js +14 -12
  42. package/dist/internal.d.ts +16 -7
  43. package/dist/internal.js +25 -4
  44. package/dist/lite-composite.js +114 -0
  45. package/dist/lite-declinations.js +253 -0
  46. package/dist/lite-dignities.js +333 -0
  47. package/dist/lite-sect.js +72 -0
  48. package/dist/lite.d.ts +82 -0
  49. package/dist/lite.js +4 -0
  50. package/dist/receipt.d.ts +3 -2
  51. package/dist/receipt.js +156 -67
  52. package/dist/{rulers-Dla6h_Sm.d.ts → rulers-CpS9qkvu.d.ts} +1 -1
  53. package/dist/sky.d.ts +4 -3
  54. package/dist/sky.js +17 -10
  55. package/dist/techniques.d.ts +102 -6
  56. package/dist/techniques.js +131 -56
  57. package/dist/time-bands-CZA9AlLg.d.ts +36 -0
  58. package/dist/time-scale-DIFNa0gz.d.ts +47 -0
  59. package/dist/time.d.ts +81 -0
  60. package/dist/time.js +74 -0
  61. package/dist/timing.d.ts +6 -5
  62. package/dist/timing.js +24 -17
  63. package/dist/types-BCnyWBQZ.d.ts +352 -0
  64. package/dist/vedic.d.ts +112 -4
  65. package/dist/vedic.js +369 -14
  66. package/dist/window.d.ts +22 -2
  67. package/dist/window.js +86 -28
  68. package/dist/{zone-history-ghdyO0Sc.d.ts → zone-history-0XzMGx9V.d.ts} +32 -10
  69. package/package.json +24 -3
  70. package/dist/types-B-yb_tGL.d.ts +0 -240
@@ -1,3 +1,13 @@
1
+ import {
2
+ ENGINE_VERSION,
3
+ EPHEMERIS,
4
+ findAspects
5
+ } from "./chunk-T6F4FYYS.js";
6
+ import {
7
+ eclipticFrame,
8
+ eclipticOfDate,
9
+ meanEcliptic
10
+ } from "./chunk-EEW7746S.js";
1
11
  import {
2
12
  EPHEMERIS_SPAN,
3
13
  elapsedDays,
@@ -5,22 +15,26 @@ import {
5
15
  timeBasis
6
16
  } from "./chunk-B5LKF437.js";
7
17
  import {
8
- deltaT
9
- } from "./chunk-BHJXUY67.js";
18
+ shippedDe440Source
19
+ } from "./chunk-UXY4RU57.js";
20
+ import {
21
+ tilt
22
+ } from "./chunk-CV53HA7R.js";
10
23
  import {
11
24
  computeAngles,
12
25
  computeHouses,
13
26
  eastPointOf,
14
- meanObliquity,
27
+ insidePolarCircle,
15
28
  vertexOf
16
- } from "./chunk-DMGHYCDI.js";
29
+ } from "./chunk-SCRO6HWB.js";
17
30
  import {
18
- ENGINE_VERSION,
19
31
  degreeInSign,
20
- findAspects,
21
32
  normalizeLongitude,
22
33
  signForLongitude
23
- } from "./chunk-OG4OYTJJ.js";
34
+ } from "./chunk-RMBWKZI2.js";
35
+ import {
36
+ deltaT
37
+ } from "./chunk-BHJXUY67.js";
24
38
 
25
39
  // src/body-label.ts
26
40
  var MAX_BODY_LABEL_LENGTH = 80;
@@ -210,8 +224,8 @@ function placeBodies(bodies, trueObliquity, chartSun = false) {
210
224
  if (!field || !Object.hasOwn(field, "value") || !field.enumerable) {
211
225
  throw new RangeError("declination bodies must contain only enumerable data entries.");
212
226
  }
213
- const source = dataFields(field.value, "declination body");
214
- const body = { body: source.body?.value, lon: source.lon?.value, lat: source.lat?.value };
227
+ const source2 = dataFields(field.value, "declination body");
228
+ const body = { body: source2.body?.value, lon: source2.lon?.value, lat: source2.lat?.value };
215
229
  bodyName(body.body);
216
230
  if (seen.has(body.body)) throw new RangeError("duplicate declination body identifier.");
217
231
  seen.add(body.body);
@@ -284,173 +298,27 @@ function chartBodyDeclinations(bodies, trueObliquity) {
284
298
  return declinations(bodies, trueObliquity, DEFAULT_DECLINATION_ORB_POLICY, true);
285
299
  }
286
300
 
287
- // src/nutation.ts
301
+ // src/points.ts
288
302
  var DEG2 = Math.PI / 180;
289
- var ARCSEC = DEG2 / 3600;
290
- var ARGUMENTS = [
291
- 485868.249036,
292
- 17179159232178e-4,
293
- 128710479305e-5,
294
- 1295965810481e-4,
295
- 335779.526232,
296
- 17395272628478e-4,
297
- 107226070369e-5,
298
- 1602961601209e-3,
299
- 450160.398036,
300
- -69628905431e-4
301
- ];
302
- var MULTIPLIERS = "2222322404224242222423222234043222222423324242140422403124241224232223122231244432423024232224222444204040224242424324041242342222224222322312243244042204232203212231244324222324440242223424224432142422243324034240402243424232140322203112424220332242234033122202424524242124231424222321144412422214440222333424422231323233222324221240332224122322243412464132332040332443024441222433404";
303
- 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";
304
- var coefficientValues;
305
- function coefficients() {
306
- return coefficientValues ??= COEFFICIENT_TEXT.split(",").map(Number);
307
- }
308
- var OFFSETS = [-135e-6, 388e-6];
309
- var NUTATION_TERMS = 77;
310
- function nutation(t, terms = NUTATION_TERMS) {
311
- const c = coefficients();
312
- const re = [];
313
- const im = [];
314
- let om = 0;
315
- for (let j = 0; j < 5; j += 1) {
316
- const f = (ARGUMENTS[2 * j] + t * ARGUMENTS[2 * j + 1]) % 1296e3 * ARCSEC;
317
- const cos = Math.cos(f);
318
- const sin = Math.sin(f);
319
- const o = 7 * j;
320
- re[o + 1] = cos;
321
- im[o + 1] = -sin;
322
- re[o + 2] = 1;
323
- im[o + 2] = 0;
324
- for (let k = o + 3; k < o + 7; k += 1) {
325
- re[k] = re[k - 1] * cos - im[k - 1] * sin;
326
- im[k] = re[k - 1] * sin + im[k - 1] * cos;
327
- }
328
- re[o] = re[o + 4];
329
- im[o] = -im[o + 4];
330
- om = f;
331
- }
332
- let dp = 0;
333
- let de = 0;
334
- for (let i = terms - 1; i >= 0; i -= 1) {
335
- let cos = 1;
336
- let sin = 0;
337
- for (let j = 0; j < 5; j += 1) {
338
- const k2 = 7 * j + MULTIPLIERS.charCodeAt(5 * i + j) - 48;
339
- const next = cos * re[k2] - sin * im[k2];
340
- sin = cos * im[k2] + sin * re[k2];
341
- cos = next;
342
- }
343
- const k = 6 * i;
344
- dp += (c[k] + c[k + 1] * t) * sin + c[k + 2] * cos;
345
- de += (c[k + 3] + c[k + 4] * t) * cos + c[k + 5] * sin;
346
- }
347
- return { dpsi: dp * 1e-7 + OFFSETS[0], deps: de * 1e-7 + OFFSETS[1], om };
348
- }
349
- function tilt(tt) {
350
- const t = tt / 36525;
351
- const { dpsi, deps, om } = nutation(t);
352
- const mobl = meanObliquity(t);
353
- return {
354
- dpsi,
355
- deps,
356
- mobl,
357
- tobl: mobl + deps / 3600,
358
- ee: dpsi * Math.cos(mobl * DEG2) + 264096e-8 * Math.sin(om) + 6352e-8 * Math.sin(2 * om)
359
- };
360
- }
361
-
362
- // src/frame.ts
363
- var DEG3 = Math.PI / 180;
364
- var ASEC2RAD = DEG3 / 3600;
365
303
  var RAD2 = 180 / Math.PI;
366
- var last;
367
- function eclipticFrame(tt) {
368
- if (last !== void 0 && last.tt === tt) return last;
369
- const t = tt / 36525;
370
- let eps0 = 84381.406;
371
- let psia = ((((-951e-10 * t + 132851e-9) * t - 114045e-8) * t - 1.0790069) * t + 5038.481507) * t;
372
- let omegaa = ((((3337e-10 * t - 467e-9) * t - 772503e-8) * t + 0.0512623) * t - 0.025754) * t + eps0;
373
- let chia = ((((-56e-9 * t + 170663e-9) * t - 121197e-8) * t - 2.3814292) * t + 10.556403) * t;
374
- eps0 *= ASEC2RAD;
375
- psia *= ASEC2RAD;
376
- omegaa *= ASEC2RAD;
377
- chia *= ASEC2RAD;
378
- const sa = Math.sin(eps0);
379
- const ca = Math.cos(eps0);
380
- const sb = Math.sin(-psia);
381
- const cb = Math.cos(-psia);
382
- const sc = Math.sin(-omegaa);
383
- const cc = Math.cos(-omegaa);
384
- const sd = Math.sin(chia);
385
- const cd = Math.cos(chia);
386
- const xx = cd * cb - sb * sd * cc;
387
- const yx = cd * sb * ca + sd * cc * cb * ca - sa * sd * sc;
388
- const zx = cd * sb * sa + sd * cc * cb * sa + ca * sd * sc;
389
- const xy = -sd * cb - sb * cd * cc;
390
- const yy = -sd * sb * ca + cd * cc * cb * ca - sa * cd * sc;
391
- const zy = -sd * sb * sa + cd * cc * cb * sa + ca * cd * sc;
392
- const xz = sb * sc;
393
- const yz = -sc * cb * ca - sa * cc;
394
- const zz = -sc * cb * sa + cc * ca;
395
- const at = tilt(tt);
396
- const e = at.mobl * DEG3;
397
- const ce = Math.cos(e);
398
- const se = Math.sin(e);
399
- last = {
400
- tt,
401
- rows: [
402
- xx,
403
- yx,
404
- zx,
405
- ce * xy + se * xz,
406
- ce * yy + se * yz,
407
- ce * zy + se * zz,
408
- ce * xz - se * xy,
409
- ce * yz - se * yy,
410
- ce * zz - se * zy
411
- ],
412
- tilt: at
413
- };
414
- return last;
415
- }
416
- function meanEcliptic(frame, x, y, z) {
417
- const m = frame.rows;
418
- return [
419
- m[0] * x + m[1] * y + m[2] * z,
420
- m[3] * x + m[4] * y + m[5] * z,
421
- m[6] * x + m[7] * y + m[8] * z
422
- ];
423
- }
424
- function eclipticOfDate(x, y, z, tt) {
425
- const frame = eclipticFrame(tt);
426
- const [ex, ey, ez] = meanEcliptic(frame, x, y, z);
427
- return {
428
- lon: normalizeLongitude(Math.atan2(ey, ex) * RAD2 + frame.tilt.dpsi / 3600),
429
- lat: Math.asin(ez / Math.hypot(ex, ey, ez)) * RAD2
430
- };
431
- }
432
-
433
- // src/points.ts
434
- var DEG4 = Math.PI / 180;
435
- var RAD3 = 180 / Math.PI;
436
- var ARCSEC2 = 1 / 3600;
304
+ var ARCSEC = 1 / 3600;
437
305
  function lunarMeanArguments(centuries) {
438
306
  const t = centuries;
439
307
  const l = 485868.249036 + t * (17179159232178e-4 + t * (31.8792 + t * (0.051635 + t * -2447e-7)));
440
308
  const F = 335779.526232 + t * (17395272628478e-4 + t * (-12.7512 + t * (-1037e-6 + t * 417e-8)));
441
309
  const node = 450160.398036 + t * (-69628905431e-4 + t * (7.4722 + t * (7702e-6 + t * -5939e-8)));
442
- return { l: l * ARCSEC2, F: F * ARCSEC2, node: node * ARCSEC2 };
310
+ return { l: l * ARCSEC, F: F * ARCSEC, node: node * ARCSEC };
443
311
  }
444
312
  var MEAN_LUNAR_INCLINATION = 5.1453964;
445
- function meanNodeLongitude(centuries, nutation2) {
446
- return normalizeLongitude(lunarMeanArguments(centuries).node + nutation2);
313
+ function meanNodeLongitude(centuries, nutation) {
314
+ return normalizeLongitude(lunarMeanArguments(centuries).node + nutation);
447
315
  }
448
- function meanApogee(centuries, nutation2) {
316
+ function meanApogee(centuries, nutation) {
449
317
  const { l, F, node } = lunarMeanArguments(centuries);
450
- const u = (F - l + 180) * DEG4;
451
- const i = MEAN_LUNAR_INCLINATION * DEG4;
452
- const lon = node + Math.atan2(Math.cos(i) * Math.sin(u), Math.cos(u)) * RAD3 + nutation2;
453
- return { lon: normalizeLongitude(lon), lat: Math.asin(Math.sin(i) * Math.sin(u)) * RAD3 };
318
+ const u = (F - l + 180) * DEG2;
319
+ const i = MEAN_LUNAR_INCLINATION * DEG2;
320
+ const lon = node + Math.atan2(Math.cos(i) * Math.sin(u), Math.cos(u)) * RAD2 + nutation;
321
+ return { lon: normalizeLongitude(lon), lat: Math.asin(Math.sin(i) * Math.sin(u)) * RAD2 };
454
322
  }
455
323
  function sectOf(ascendant, sun) {
456
324
  return normalizeLongitude(sun - ascendant) >= 180 ? "day" : "night";
@@ -498,9 +366,116 @@ import {
498
366
  MakeTime,
499
367
  SetDeltaTFunction
500
368
  } from "astronomy-engine";
501
- var RAD4 = 180 / Math.PI;
369
+ var RAD3 = 180 / Math.PI;
502
370
  var DAY = 864e5;
503
371
  var UTC_CLOCK = { scale: "utc", pin: void 0 };
372
+ var source = null;
373
+ var defaultName = "de440";
374
+ var DEFAULT_MARGIN_DAYS = 1;
375
+ var SECONDS_PER_DAY = 86400;
376
+ var shipped;
377
+ var shippedError = null;
378
+ function shippedDefault() {
379
+ if (shipped !== void 0) return shipped;
380
+ try {
381
+ const opened = shippedDe440Source();
382
+ shipped = {
383
+ source: opened,
384
+ fromTtDays: opened.pack.startEtSecTdb / SECONDS_PER_DAY + DEFAULT_MARGIN_DAYS,
385
+ toTtDays: opened.pack.stopEtSecTdb / SECONDS_PER_DAY - DEFAULT_MARGIN_DAYS
386
+ };
387
+ } catch (error) {
388
+ shipped = null;
389
+ shippedError = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
390
+ }
391
+ return shipped;
392
+ }
393
+ var ON_ASTRONOMY_ENGINE = { from: null, fallback: null };
394
+ function chosenAt(ttDays) {
395
+ if (source) return { from: source, fallback: null };
396
+ if (defaultName !== "de440") return ON_ASTRONOMY_ENGINE;
397
+ const pack = shippedDefault();
398
+ if (pack === null) return { from: null, fallback: "de440-unavailable" };
399
+ return ttDays >= pack.fromTtDays && ttDays <= pack.toTtDays ? { from: pack.source, fallback: null } : { from: null, fallback: "outside-de440-span" };
400
+ }
401
+ var noted = null;
402
+ function sourceAt(ttDays) {
403
+ const chosen = chosenAt(ttDays);
404
+ if (chosen.fallback !== null) noted?.add(chosen.fallback);
405
+ return chosen.from;
406
+ }
407
+ function notingFallbacks(run) {
408
+ const outer = noted;
409
+ const mine = /* @__PURE__ */ new Set();
410
+ noted = mine;
411
+ try {
412
+ const value = run();
413
+ return { value, fallbacks: EPHEMERIS_FALLBACKS.filter((reason) => mine.has(reason)) };
414
+ } finally {
415
+ noted = outer;
416
+ if (outer) for (const reason of mine) outer.add(reason);
417
+ }
418
+ }
419
+ function fallbacksAt(instants) {
420
+ const met = new Set(instants.map((ms) => Number.isFinite(ms) ? chosenAt(timeBasis(ms, "utc").ttDays).fallback : null));
421
+ return EPHEMERIS_FALLBACKS.filter((reason) => met.has(reason));
422
+ }
423
+ function ephemerisOver(instants) {
424
+ const sources = instants.filter((ms) => Number.isFinite(ms)).map((ms) => chosenAt(timeBasis(ms, "utc").ttDays).from);
425
+ const first = sources[0];
426
+ return first === void 0 || sources.some((from) => from === null) ? { ...EPHEMERIS } : named(first);
427
+ }
428
+ var EPHEMERIS_FALLBACKS = ["de440-unavailable", "outside-de440-span"];
429
+ var named = (from) => from ? { name: from.ephemeris.name, version: from.ephemeris.version } : { ...EPHEMERIS };
430
+ function ephemerisAt(ms, scale = "utc", pin) {
431
+ const { from, fallback } = chosenAt(timeBasis(ms, scale, pin).ttDays);
432
+ return { from, ephemeris: named(from), fallback };
433
+ }
434
+ function defaultEphemeris() {
435
+ const pack = shippedDefault();
436
+ return Object.freeze({
437
+ name: defaultName,
438
+ de440: Object.freeze({
439
+ opened: pack !== null,
440
+ version: pack?.source.ephemeris.version ?? null,
441
+ fromTtDays: pack?.fromTtDays ?? null,
442
+ toTtDays: pack?.toTtDays ?? null,
443
+ error: shippedError
444
+ })
445
+ });
446
+ }
447
+ function setDefaultEphemeris(name) {
448
+ if (name !== "de440" && name !== "astronomy-engine") throw new TypeError('setDefaultEphemeris takes "de440" or "astronomy-engine"');
449
+ defaultName = name;
450
+ }
451
+ function withEphemeris(positionSource, run) {
452
+ const named2 = positionSource?.ephemeris;
453
+ if (typeof positionSource?.place !== "function" || typeof positionSource.trueNode !== "function" || typeof named2?.name !== "string" || typeof named2.version !== "string" || typeof run !== "function")
454
+ throw new TypeError("withEphemeris needs a position source and a function");
455
+ const previous = source;
456
+ source = positionSource;
457
+ let result;
458
+ try {
459
+ result = run();
460
+ } finally {
461
+ source = previous;
462
+ }
463
+ const later = result;
464
+ if (typeof later?.then === "function" || typeof later?.next === "function") {
465
+ if (typeof later.then === "function") later.then(void 0, () => {
466
+ });
467
+ throw new TypeError("withEphemeris runs synchronous functions only");
468
+ }
469
+ return result;
470
+ }
471
+ function refuseUnderSource(what) {
472
+ if (source) throw new TypeError(`${what} does not run inside withEphemeris: it computes on the engine's own sources, not a caller's`);
473
+ }
474
+ var tidy = (lon) => lon === 360 ? 0 : lon + 0;
475
+ function sourceLongitude(from, body, ttDays, behind) {
476
+ if (body === "North Node") return tidy(from.trueNode(ttDays));
477
+ return body === "South Node" ? normalizeLongitude(from.trueNode(ttDays) + 180) : tidy(from.place(body, ttDays, behind).lon);
478
+ }
504
479
  function timeOf(basis) {
505
480
  const { from, to } = EPHEMERIS_SPAN.daysFromJ2000;
506
481
  if (!(basis.ttDays >= from && basis.ttDays <= to)) {
@@ -573,12 +548,14 @@ function trueNodeLongitude(time) {
573
548
  state.z * state.vx - state.x * state.vz,
574
549
  state.x * state.vy - state.y * state.vx
575
550
  );
576
- return normalizeLongitude(Math.atan2(x, -y) * RAD4 + frame.tilt.dpsi / 3600);
551
+ return normalizeLongitude(Math.atan2(x, -y) * RAD3 + frame.tilt.dpsi / 3600);
577
552
  }
578
553
  function longitudeAt(body, ms, clock) {
579
- return longitudeOn(body, basisAt(ms, clock));
554
+ const basis = basisAt(ms, clock);
555
+ return longitudeOn(body, basis, sourceAt(basis.ttDays));
580
556
  }
581
- function longitudeOn(body, basis) {
557
+ function longitudeOn(body, basis, from, behind) {
558
+ if (from) return sourceLongitude(from, body, basis.ttDays, behind);
582
559
  const time = timeOf(basis);
583
560
  if (body === "Moon") return moonOfDate(time).lon;
584
561
  if (body === "North Node") return trueNodeLongitude(time);
@@ -606,11 +583,13 @@ function centralDifference(longitudeOf, ms, clock, stepDays) {
606
583
  if (difference < -180) difference += 360;
607
584
  return difference / elapsedDays(before, after, 2 * stepDays);
608
585
  }
609
- function speedAt(body, ms, clock) {
610
- const stepDays = body === "North Node" || body === "South Node" ? NODE_SPEED_STEP_DAYS : SPEED_STEP_DAYS;
611
- return centralDifference((basis) => longitudeOn(body, basis), ms, clock, stepDays);
586
+ function speedAt(body, ms, clock, from = sourceAt(basisAt(ms, clock).ttDays), behind) {
587
+ const node = body === "North Node" || body === "South Node";
588
+ const stepDays = node ? NODE_SPEED_STEP_DAYS : SPEED_STEP_DAYS;
589
+ const side = from && !node && behind === void 0 ? from.place(body, basisAt(ms, clock).ttDays).behindDisc : behind;
590
+ return centralDifference((basis) => longitudeOn(body, basis, from, side), ms, clock, stepDays);
612
591
  }
613
- function position(body, lon, lat, speed) {
592
+ function position(body, lon, lat, speed, chosen) {
614
593
  return {
615
594
  body,
616
595
  lon,
@@ -618,30 +597,57 @@ function position(body, lon, lat, speed) {
618
597
  speed,
619
598
  retrograde: speed < 0,
620
599
  sign: signForLongitude(lon).slug,
621
- degree: degreeInSign(lon)
600
+ degree: degreeInSign(lon),
601
+ ephemeris: chosen.from ? chosen.from.ephemeris.name : EPHEMERIS.name,
602
+ ...chosen.fallback !== null && { fallback: chosen.fallback }
622
603
  };
623
604
  }
624
605
  function computeBodies(date) {
625
- return evaluated(() => bodiesAt(date.getTime(), UTC_CLOCK));
606
+ return evaluated(() => {
607
+ const ms = date.getTime();
608
+ const basis = basisAt(ms, UTC_CLOCK);
609
+ const chosen = chosenAt(basis.ttDays);
610
+ const bodies = bodiesAt(ms, UTC_CLOCK, chosen);
611
+ const flags = instantFlags(date, basis, chosen, null);
612
+ return flags.length === 0 ? bodies : bodies.map((row) => ({ ...row, flags: [...flags] }));
613
+ });
626
614
  }
627
- function bodiesAt(ms, clock) {
615
+ function instantFlags(utc, basis, chosen, angles) {
616
+ const flags = [];
617
+ if (outsideReferenceSpan(utc)) flags.push("outside-reference-span");
618
+ if (deltaTExtrapolated(basis, angles)) flags.push("delta-t-extrapolated");
619
+ if (chosen.fallback !== null) flags.push(chosen.fallback);
620
+ return flags;
621
+ }
622
+ function bodiesAt(ms, clock, chosen = chosenAt(basisAt(ms, clock).ttDays)) {
623
+ if (chosen.fallback !== null) noted?.add(chosen.fallback);
624
+ if (chosen.from) return sourceBodiesAt(chosen, chosen.from, ms, clock);
628
625
  const bodies = [];
629
626
  for (const planet of PLANETS) {
630
627
  const coordinates = planetOfDate(planet.body, timeAt(ms, clock));
631
628
  bodies.push(
632
- position(planet.name, coordinates.lon, coordinates.lat, speedAt(planet.name, ms, clock))
629
+ position(planet.name, coordinates.lon, coordinates.lat, speedAt(planet.name, ms, clock, null), chosen)
633
630
  );
634
631
  }
635
632
  const moon = moonOfDate(timeAt(ms, clock));
636
- bodies.splice(1, 0, position("Moon", moon.lon, moon.lat, speedAt("Moon", ms, clock)));
633
+ bodies.splice(1, 0, position("Moon", moon.lon, moon.lat, speedAt("Moon", ms, clock, null), chosen));
637
634
  const northNode = trueNodeLongitude(timeAt(ms, clock));
638
- const nodeSpeed = speedAt("North Node", ms, clock);
635
+ const nodeSpeed = speedAt("North Node", ms, clock, null);
639
636
  bodies.push(
640
- position("North Node", northNode, 0, nodeSpeed),
641
- position("South Node", normalizeLongitude(northNode + 180), 0, nodeSpeed)
637
+ position("North Node", northNode, 0, nodeSpeed, chosen),
638
+ position("South Node", normalizeLongitude(northNode + 180), 0, nodeSpeed, chosen)
642
639
  );
643
640
  return bodies;
644
641
  }
642
+ function sourceBodiesAt(chosen, from, ms, clock) {
643
+ const tt = basisAt(ms, clock).ttDays;
644
+ return ["Sun", "Moon", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "North Node", "South Node"].map(
645
+ (body) => {
646
+ const place = body === "North Node" || body === "South Node" ? { lon: sourceLongitude(from, body, tt), lat: 0 } : from.place(body, tt);
647
+ return position(body, tidy(place.lon), place.lat, speedAt(body, ms, clock, from, "behindDisc" in place ? place.behindDisc : void 0), chosen);
648
+ }
649
+ );
650
+ }
645
651
  var clockOf = (input) => ({
646
652
  scale: input.timeScale ?? "utc",
647
653
  pin: input.deltaT
@@ -653,8 +659,10 @@ function chartAt(input) {
653
659
  const flags = [...input.flags ?? []];
654
660
  const ms = input.utc.getTime();
655
661
  const clock = clockOf(input);
656
- const bodies = bodiesAt(ms, clock);
657
662
  const basis = timeBasis(ms, clock.scale, clock.pin);
663
+ const chosen = chosenAt(basis.ttDays);
664
+ const { from } = chosen;
665
+ const bodies = bodiesAt(ms, clock, chosen);
658
666
  let angles = null;
659
667
  let houses = null;
660
668
  if (input.timeKnown && input.latitude !== void 0 && input.longitude !== void 0) {
@@ -669,10 +677,11 @@ function chartAt(input) {
669
677
  const result = computeHouses(input.houseSystem, angleInput, angles);
670
678
  houses = result.houses;
671
679
  if (result.fellBack) flags.push("polar-fallback");
680
+ if (insidePolarCircle(angleInput)) flags.push("polar-angles");
672
681
  } else if (!input.timeKnown) {
673
682
  flags.push("no-time");
674
683
  }
675
- if (outsideReferenceSpan(input.utc)) flags.push("outside-reference-span");
684
+ flags.push(...instantFlags(input.utc, basis, chosen, angles));
676
685
  return {
677
686
  input,
678
687
  bodies,
@@ -682,14 +691,16 @@ function chartAt(input) {
682
691
  flags,
683
692
  deltaT: basis.deltaT,
684
693
  timeScale: basis.timeScale,
685
- engineVersion: ENGINE_VERSION
694
+ engineVersion: ENGINE_VERSION,
695
+ ephemeris: named(from)
686
696
  };
687
697
  }
698
+ var deltaTExtrapolated = ({ deltaT: d, timeScale: t }, ut1) => (ut1 || t.input != "tt") && t.basis == "delta-t" && /^e/.test(d.segment);
688
699
  function meanLunarPoints(basis) {
689
700
  const time = timeOf(basis);
690
701
  const centuries = time.tt / 36525;
691
- const nutation2 = tilt(time.tt).dpsi / 3600;
692
- return { node: meanNodeLongitude(centuries, nutation2), apogee: meanApogee(centuries, nutation2) };
702
+ const nutation = tilt(time.tt).dpsi / 3600;
703
+ return { node: meanNodeLongitude(centuries, nutation), apogee: meanApogee(centuries, nutation) };
693
704
  }
694
705
  function pointPosition(point, lon, lat, speed) {
695
706
  const longitude = normalizeLongitude(lon);
@@ -703,7 +714,15 @@ function pointPosition(point, lon, lat, speed) {
703
714
  };
704
715
  }
705
716
  function computePoints(chart) {
706
- return evaluated(() => pointsAt(chart));
717
+ return { ...evaluated(() => pointsAt(chart)), ...chartLabel(chart) };
718
+ }
719
+ function chartLabel(chart) {
720
+ const named2 = chart.ephemeris;
721
+ const flags = Array.isArray(chart.flags) ? chart.flags : [];
722
+ return {
723
+ ephemeris: named2 ? { name: named2.name, version: named2.version } : null,
724
+ flags: EPHEMERIS_FALLBACKS.filter((reason) => flags.includes(reason))
725
+ };
707
726
  }
708
727
  function computeChartDeclinations(chart) {
709
728
  const input = chart?.input;
@@ -723,7 +742,8 @@ function computeChartDeclinations(chart) {
723
742
  return {
724
743
  ...chartBodyDeclinations(bodies, tilt(timeOf(basis).tt).tobl),
725
744
  utc: date.toISOString(),
726
- deltaT: basis.deltaT
745
+ deltaT: basis.deltaT,
746
+ ...chartLabel(chart)
727
747
  };
728
748
  });
729
749
  }
@@ -794,10 +814,6 @@ export {
794
814
  declinationOrb,
795
815
  findDeclinationAspects,
796
816
  declinationsForBodies,
797
- tilt,
798
- eclipticFrame,
799
- meanEcliptic,
800
- eclipticOfDate,
801
817
  lunarMeanArguments,
802
818
  MEAN_LUNAR_INCLINATION,
803
819
  meanNodeLongitude,
@@ -808,6 +824,14 @@ export {
808
824
  antiscion,
809
825
  contraAntiscion,
810
826
  midpoint,
827
+ notingFallbacks,
828
+ fallbacksAt,
829
+ ephemerisOver,
830
+ ephemerisAt,
831
+ defaultEphemeris,
832
+ setDefaultEphemeris,
833
+ withEphemeris,
834
+ refuseUnderSource,
811
835
  gastHours,
812
836
  onChartClock,
813
837
  bodyLongitude,
@@ -815,6 +839,7 @@ export {
815
839
  longitudeSpeed,
816
840
  computeBodies,
817
841
  computeChart,
842
+ deltaTExtrapolated,
818
843
  computePoints,
819
844
  computeChartDeclinations
820
845
  };
@@ -0,0 +1,130 @@
1
+ // src/signs.ts
2
+ var ELEMENTS = /* @__PURE__ */ Object.freeze(["fire", "earth", "air", "water"]);
3
+ var MODALITIES = /* @__PURE__ */ Object.freeze(["cardinal", "fixed", "mutable"]);
4
+ var SIGNS = /* @__PURE__ */ Object.freeze([
5
+ /* @__PURE__ */ Object.freeze({
6
+ slug: "aries",
7
+ name: "Aries",
8
+ element: "fire",
9
+ modality: "cardinal",
10
+ polarity: "day",
11
+ naturalHouse: 1
12
+ }),
13
+ /* @__PURE__ */ Object.freeze({
14
+ slug: "taurus",
15
+ name: "Taurus",
16
+ element: "earth",
17
+ modality: "fixed",
18
+ polarity: "night",
19
+ naturalHouse: 2
20
+ }),
21
+ /* @__PURE__ */ Object.freeze({
22
+ slug: "gemini",
23
+ name: "Gemini",
24
+ element: "air",
25
+ modality: "mutable",
26
+ polarity: "day",
27
+ naturalHouse: 3
28
+ }),
29
+ /* @__PURE__ */ Object.freeze({
30
+ slug: "cancer",
31
+ name: "Cancer",
32
+ element: "water",
33
+ modality: "cardinal",
34
+ polarity: "night",
35
+ naturalHouse: 4
36
+ }),
37
+ /* @__PURE__ */ Object.freeze({
38
+ slug: "leo",
39
+ name: "Leo",
40
+ element: "fire",
41
+ modality: "fixed",
42
+ polarity: "day",
43
+ naturalHouse: 5
44
+ }),
45
+ /* @__PURE__ */ Object.freeze({
46
+ slug: "virgo",
47
+ name: "Virgo",
48
+ element: "earth",
49
+ modality: "mutable",
50
+ polarity: "night",
51
+ naturalHouse: 6
52
+ }),
53
+ /* @__PURE__ */ Object.freeze({
54
+ slug: "libra",
55
+ name: "Libra",
56
+ element: "air",
57
+ modality: "cardinal",
58
+ polarity: "day",
59
+ naturalHouse: 7
60
+ }),
61
+ /* @__PURE__ */ Object.freeze({
62
+ slug: "scorpio",
63
+ name: "Scorpio",
64
+ element: "water",
65
+ modality: "fixed",
66
+ polarity: "night",
67
+ naturalHouse: 8
68
+ }),
69
+ /* @__PURE__ */ Object.freeze({
70
+ slug: "sagittarius",
71
+ name: "Sagittarius",
72
+ element: "fire",
73
+ modality: "mutable",
74
+ polarity: "day",
75
+ naturalHouse: 9
76
+ }),
77
+ /* @__PURE__ */ Object.freeze({
78
+ slug: "capricorn",
79
+ name: "Capricorn",
80
+ element: "earth",
81
+ modality: "cardinal",
82
+ polarity: "night",
83
+ naturalHouse: 10
84
+ }),
85
+ /* @__PURE__ */ Object.freeze({
86
+ slug: "aquarius",
87
+ name: "Aquarius",
88
+ element: "air",
89
+ modality: "fixed",
90
+ polarity: "day",
91
+ naturalHouse: 11
92
+ }),
93
+ /* @__PURE__ */ Object.freeze({
94
+ slug: "pisces",
95
+ name: "Pisces",
96
+ element: "water",
97
+ modality: "mutable",
98
+ polarity: "night",
99
+ naturalHouse: 12
100
+ })
101
+ ]);
102
+ var SIGN_SLUGS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SIGNS.map((sign) => sign.slug));
103
+ var SIGN_NAMES = SIGN_SLUGS;
104
+ function normalizeLongitude(lon) {
105
+ if (!Number.isFinite(lon)) throw new RangeError("Longitude must be finite.");
106
+ return (lon % 360 + 360) % 360;
107
+ }
108
+ function signIndexForLongitude(lon) {
109
+ return Math.floor(normalizeLongitude(lon) / 30);
110
+ }
111
+ function signForLongitude(lon) {
112
+ const sign = SIGNS[signIndexForLongitude(lon)];
113
+ if (!sign) throw new RangeError("Could not resolve zodiac sign.");
114
+ return sign;
115
+ }
116
+ function degreeInSign(lon) {
117
+ return normalizeLongitude(lon) % 30;
118
+ }
119
+
120
+ export {
121
+ ELEMENTS,
122
+ MODALITIES,
123
+ SIGNS,
124
+ SIGN_SLUGS,
125
+ SIGN_NAMES,
126
+ normalizeLongitude,
127
+ signIndexForLongitude,
128
+ signForLongitude,
129
+ degreeInSign
130
+ };