@zodiacs/engine 0.1.1-rc.16 → 1.1.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 (80) hide show
  1. package/CHANGELOG.md +1478 -0
  2. package/LICENSING.md +184 -30
  3. package/NOTICE +81 -14
  4. package/README.md +345 -67
  5. package/dist/{api-VOW6Umy5.d.ts → api-ChL1N2Sr.d.ts} +44 -7
  6. package/dist/ayanamsa-ClFzkKmV.d.ts +135 -0
  7. package/dist/calc.d.ts +218 -21
  8. package/dist/calc.js +580 -160
  9. package/dist/chunk-2PZYJQV5.js +83 -0
  10. package/dist/chunk-47ERTK5X.js +27 -0
  11. package/dist/{chunk-O3NJRGJ2.js → chunk-4XOYTBLS.js} +1 -1
  12. package/dist/chunk-767FTO7O.js +48 -0
  13. package/dist/{chunk-N4B5JNMA.js → chunk-7Y2F2IWN.js} +40 -28
  14. package/dist/chunk-B4M2Y7FT.js +96 -0
  15. package/dist/{chunk-KHBLFXFG.js → chunk-B5LKF437.js} +29 -28
  16. package/dist/{chunk-ONBZ4HK7.js → chunk-BHJXUY67.js} +4 -2
  17. package/dist/{chunk-PFGUCNOK.js → chunk-BMDASNPB.js} +6 -6
  18. package/dist/chunk-I3L4POY7.js +18 -0
  19. package/dist/{chunk-I7O5EGFV.js → chunk-LNGURVNH.js} +3 -3
  20. package/dist/{chunk-4NV4ZEFZ.js → chunk-NNOSOOWS.js} +4 -4
  21. package/dist/chunk-OVXQQEXL.js +41 -0
  22. package/dist/{chunk-WOU7JVD3.js → chunk-QLIEEICB.js} +205 -194
  23. package/dist/chunk-RMBWKZI2.js +130 -0
  24. package/dist/{chunk-AECKV73C.js → chunk-TSS2SZWQ.js} +8 -2
  25. package/dist/{chunk-L6ZHWJZ6.js → chunk-TZVPZHZM.js} +51 -29
  26. package/dist/chunk-WBTWY2OB.js +478 -0
  27. package/dist/chunk-Y4E3WJU5.js +87 -0
  28. package/dist/chunk-YPU3MDNI.js +852 -0
  29. package/dist/conventions.d.ts +70 -0
  30. package/dist/conventions.js +26 -0
  31. package/dist/crossings.d.ts +22 -10
  32. package/dist/crossings.js +1 -1
  33. package/dist/de440-pack.d.ts +43 -0
  34. package/dist/de440-pack.js +16 -0
  35. package/dist/de440.d.ts +113 -0
  36. package/dist/de440.js +19 -0
  37. package/dist/deltat.d.ts +28 -3
  38. package/dist/deltat.js +1 -1
  39. package/dist/ephemeris-exTSqBgb.d.ts +60 -0
  40. package/dist/geo.d.ts +46 -13
  41. package/dist/geo.js +4 -2
  42. package/dist/{houses-q1O2GGp4.d.ts → houses-Bh7GCnPi.d.ts} +14 -4
  43. package/dist/houses-extra.d.ts +22 -7
  44. package/dist/houses-extra.js +4 -2
  45. package/dist/index.d.ts +36 -49
  46. package/dist/index.js +54 -34
  47. package/dist/{internal-math-CmJ9xtaW.d.ts → internal-math-CxenuGfm.d.ts} +41 -27
  48. package/dist/internal-math.d.ts +4 -3
  49. package/dist/internal-math.js +14 -12
  50. package/dist/internal.d.ts +16 -7
  51. package/dist/internal.js +27 -6
  52. package/dist/lite-composite.js +114 -0
  53. package/dist/lite-declinations.js +253 -0
  54. package/dist/lite-dignities.js +333 -0
  55. package/dist/lite-sect.js +72 -0
  56. package/dist/lite.d.ts +82 -0
  57. package/dist/lite.js +4 -0
  58. package/dist/receipt.d.ts +3 -268
  59. package/dist/receipt.js +202 -89
  60. package/dist/reference-span-CILpclrz.d.ts +40 -0
  61. package/dist/{rulers-9wljfVaO.d.ts → rulers-CSSWtiWF.d.ts} +7 -2
  62. package/dist/sky.d.ts +26 -10
  63. package/dist/sky.js +23 -14
  64. package/dist/techniques.d.ts +160 -21
  65. package/dist/techniques.js +157 -89
  66. package/dist/time-bands-CZA9AlLg.d.ts +36 -0
  67. package/dist/time-scale-DIFNa0gz.d.ts +47 -0
  68. package/dist/time.d.ts +81 -0
  69. package/dist/time.js +74 -0
  70. package/dist/timing.d.ts +55 -17
  71. package/dist/timing.js +33 -45
  72. package/dist/types-DpPdtXgO.d.ts +335 -0
  73. package/dist/vedic.d.ts +150 -123
  74. package/dist/vedic.js +398 -440
  75. package/dist/window.d.ts +102 -80
  76. package/dist/window.js +108 -51
  77. package/dist/zone-history-BxmDCcTK.d.ts +290 -0
  78. package/package.json +26 -3
  79. package/dist/chunk-2OWGBT3O.js +0 -219
  80. package/dist/types-B4MCoCCS.d.ts +0 -228
package/dist/receipt.js CHANGED
@@ -1,30 +1,35 @@
1
- import {
2
- julianToGregorian,
3
- parseCalendarDate
4
- } from "./chunk-KFTJMMG7.js";
5
1
  import {
6
2
  dateFrom
7
3
  } from "./chunk-CPALRSPC.js";
4
+ import {
5
+ ASPECTS,
6
+ ASPECT_BODY_SET,
7
+ ASPECT_TYPES,
8
+ EPHEMERIS,
9
+ aspectMotion
10
+ } from "./chunk-B4M2Y7FT.js";
8
11
  import {
9
12
  DELTA_T_IERS_MODEL,
10
13
  TIME_SCALE_NAMES,
11
14
  UT1_DATA,
12
15
  outsideReferenceSpan,
13
16
  timeBasis
14
- } from "./chunk-KHBLFXFG.js";
17
+ } from "./chunk-B5LKF437.js";
18
+ import {
19
+ natalConventionIds
20
+ } from "./chunk-OVXQQEXL.js";
21
+ import {
22
+ SIGNS
23
+ } from "./chunk-RMBWKZI2.js";
15
24
  import {
16
25
  DELTA_T_MODEL,
17
26
  DELTA_T_TABLE,
18
27
  deltaTAt
19
- } from "./chunk-ONBZ4HK7.js";
28
+ } from "./chunk-BHJXUY67.js";
20
29
  import {
21
- ASPECTS,
22
- ASPECT_BODIES,
23
- ASPECT_TYPES,
24
- EPHEMERIS,
25
- SIGNS,
26
- aspectMotion
27
- } from "./chunk-2OWGBT3O.js";
30
+ julianToGregorian,
31
+ parseCalendarDate
32
+ } from "./chunk-KFTJMMG7.js";
28
33
 
29
34
  // src/receipt-json.ts
30
35
  function parseReceiptJson(json, limits) {
@@ -159,7 +164,7 @@ function compareVersions(a, b) {
159
164
  var NATAL_ENVELOPE_SCHEMA = "zodiacs.natal-envelope.draft-v1";
160
165
  var NATAL_RECEIPT_SCHEMA = "zodiacs.calculation-receipt.draft-v1";
161
166
  var NATAL_DIAGNOSTIC_SCHEMA = "zodiacs.natal-diagnostic.draft-v1";
162
- var NATAL_ENVELOPE_LIMITS = Object.freeze({ bytes: 65536, depth: 12, nodes: 4096 });
167
+ var NATAL_ENVELOPE_LIMITS = /* @__PURE__ */ Object.freeze({ bytes: 65536, depth: 12, nodes: 4096 });
163
168
  var ERROR_CODES = /* @__PURE__ */ new Set([
164
169
  "invalid_json",
165
170
  "invalid_shape",
@@ -182,7 +187,7 @@ var NatalEnvelopeError = class extends Error {
182
187
  ERROR_BRAND.set(this, fixed);
183
188
  }
184
189
  };
185
- var CONVENTIONS_RC3 = Object.freeze({
190
+ var CONVENTIONS_RC3 = /* @__PURE__ */ Object.freeze({
186
191
  calendar: "proleptic-gregorian",
187
192
  zodiac: "tropical",
188
193
  planetPositions: "apparent-geocentric-ecliptic-of-date",
@@ -193,39 +198,62 @@ var CONVENTIONS_RC3 = Object.freeze({
193
198
  speed: "degrees-per-day;central-difference-plus-minus-0.25-day",
194
199
  aspects: "major-aspects;sun-moon-eight-planets;no-nodes"
195
200
  });
196
- var CONVENTIONS_RC7 = Object.freeze({
201
+ var CONVENTIONS_RC7 = /* @__PURE__ */ (() => Object.freeze({
197
202
  ...CONVENTIONS_RC3,
198
203
  angles: "gast-and-true-obliquity",
199
204
  speed: "degrees-per-day;central-difference-plus-minus-0.001-day;nodes-plus-minus-0.25-day",
200
205
  aspects: "major-aspects;sun-moon-eight-planets;no-nodes;applying-instantaneous-orb-rate"
201
- });
202
- var CONVENTIONS_RC8 = Object.freeze({
206
+ }))();
207
+ var CONVENTIONS_RC8 = /* @__PURE__ */ (() => Object.freeze({
203
208
  ...CONVENTIONS_RC7,
204
209
  planetPositions: "aberrated-geocentric-ecliptic-of-date;no-deflection",
205
210
  moonPosition: "astronomy-engine-ecliptic-geo-moon;no-light-time;no-aberration",
206
211
  deltaT: "tt-minus-ut1;ut1-read-as-utc;value-in-result"
207
- });
208
- var CONVENTIONS_RC15 = Object.freeze({
212
+ }))();
213
+ var CONVENTIONS_RC15 = /* @__PURE__ */ (() => Object.freeze({
209
214
  ...CONVENTIONS_RC8,
210
215
  deltaT: "tt-minus-ut1;value-in-result",
211
216
  timeScale: "tt-from-leap-seconds-and-ut1-from-iers-1972-to-table-end;delta-t-model-otherwise;in-result",
212
217
  localTime: "tzdb-shards-before-1970;host-intl-from-1970;flags-from-transition-record"
213
- });
214
- var CONVENTIONS = Object.freeze({
218
+ }))();
219
+ var CONVENTIONS_RC16 = /* @__PURE__ */ (() => Object.freeze({
215
220
  ...CONVENTIONS_RC15,
216
221
  moonPosition: "astronomy-engine-geo-moon;no-light-time;no-aberration",
217
222
  nutation: "iau2000b;equation-of-equinoxes-with-two-complementary-terms"
218
- });
219
- var NATAL_RECEIPT_CONVENTION_SETS = Object.freeze([CONVENTIONS, CONVENTIONS_RC15, CONVENTIONS_RC8, CONVENTIONS_RC7, CONVENTIONS_RC3]);
223
+ }))();
224
+ var CONVENTIONS = /* @__PURE__ */ (() => Object.freeze({
225
+ ...CONVENTIONS_RC16,
226
+ conventionIds: "zodiacs-conventions-registry;receipt-and-result;sorted-unique;in-receipt"
227
+ }))();
228
+ var CONVENTIONS_DE440 = /* @__PURE__ */ (() => Object.freeze({
229
+ ...CONVENTIONS,
230
+ planetPositions: "apparent-geocentric-ecliptic-of-date;light-time;solar-deflection;relativistic-aberration;barycentres-mars-to-pluto",
231
+ moonPosition: "ephemeris-geocentric-moon;light-time;solar-deflection;relativistic-aberration",
232
+ positionFrame: "icrf-to-true-ecliptic-of-date;iau2006-precession-with-bias;iau2000b-nutation-p03;tdb-three-term"
233
+ }))();
234
+ var NATAL_RECEIPT_CONVENTION_SETS = /* @__PURE__ */ Object.freeze([
235
+ CONVENTIONS,
236
+ CONVENTIONS_RC16,
237
+ CONVENTIONS_RC15,
238
+ CONVENTIONS_RC8,
239
+ CONVENTIONS_RC7,
240
+ CONVENTIONS_RC3,
241
+ CONVENTIONS_DE440
242
+ ]);
220
243
  var RC3_TO_RC6 = /^0\.1\.1-rc\.[3-6](?:\+[A-Za-z0-9.-]+)?$/;
221
244
  var RC7 = /^0\.1\.1-rc\.7(?:\+[A-Za-z0-9.-]+)?$/;
222
245
  var RC8_TO_RC14 = /^0\.1\.1-rc\.(?:[89]|1[0-4])(?:\+[A-Za-z0-9.-]+)?$/;
223
246
  var RC15 = /^0\.1\.1-rc\.15(?:\+[A-Za-z0-9.-]+)?$/;
224
247
  var before = (version2, release) => compareVersions(version2, release) < 0;
225
248
  var NUTATION_RELEASE = "0.1.1-rc.16";
249
+ var IDS_FEATURE = "convention-ids";
250
+ var DE440_FEATURE = "ephemeris-jpl-de440";
251
+ var DE440_EPHEMERIS = "jpl-de440";
252
+ var DE440_RELEASE = "1.1.0-rc.3";
253
+ var SHA256_HEX = /^[0-9a-f]{64}$/;
226
254
  var RC9_RELEASE = "0.1.1-rc.9";
227
255
  var RC10_RELEASE = "0.1.1-rc.10";
228
- var COVERAGE = Object.freeze({
256
+ var COVERAGE = /* @__PURE__ */ Object.freeze({
229
257
  assessment: "finite-reference-cases-only",
230
258
  broadDateRange: "not-certified",
231
259
  angleExclusions: "exact-geographic-poles-and-ecliptic-horizon-coincidence",
@@ -247,6 +275,8 @@ var BODIES = [
247
275
  ];
248
276
  var FLAGS_RC7 = ["dst-gap", "dst-fold", "lmt", "no-time", "polar-fallback"];
249
277
  var FLAGS = [...FLAGS_RC7, "outside-reference-span"];
278
+ var FLAGS_TIME_BASIS = [...FLAGS, "delta-t-extrapolated", "de440-unavailable", "outside-de440-span"];
279
+ var FALLBACK_FLAGS = ["de440-unavailable", "outside-de440-span"];
250
280
  var TIME_FLAGS = ["dst-gap", "dst-fold", "lmt"];
251
281
  var HOUSE_SYSTEMS = [
252
282
  "whole",
@@ -270,6 +300,14 @@ var HOUSE_SYSTEMS_BEFORE_RC10 = HOUSE_SYSTEMS.filter(
270
300
  var POLAR_UNDEFINED = ["placidus", "koch"];
271
301
  var TURNING_WITH_ASCENDANT = ["regiomontanus", "campanus", "topocentric"];
272
302
  var HOSTILE_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
303
+ var BODY_RECORD = ["body", "lon", "lat", "speed", "retrograde", "sign", "degree"];
304
+ var ANGLES_RECORD = ["asc", "mc", "dsc", "ic"];
305
+ var HOUSES_RECORD = ["system", "cusps"];
306
+ var ASPECT_RECORD = ["a", "b", "type", "orb", "applying"];
307
+ var DELTA_T_RECORD = ["seconds", "sigma", "model", "table", "tableDigest", "segment"];
308
+ var TIME_SCALE_RECORD = ["input", "basis", "ut1MinusUtc", "leapSeconds"];
309
+ var UT1_RECORD = ["seconds", "sigma", "source"];
310
+ var LEAP_SECONDS_RECORD = ["taiMinusUtc", "listed"];
273
311
  function fail(code) {
274
312
  throw new NatalEnvelopeError(code);
275
313
  }
@@ -351,6 +389,24 @@ function fields(value, required, optional = []) {
351
389
  if (required.some((key) => !Object.hasOwn(value, key)) || Object.keys(value).some((key) => !required.includes(key) && !optional.includes(key)))
352
390
  fail("invalid_shape");
353
391
  }
392
+ function list(value) {
393
+ if (!Array.isArray(value)) fail("invalid_shape");
394
+ return value;
395
+ }
396
+ function kept(value, keys) {
397
+ const from = record(value);
398
+ const out = {};
399
+ for (const key of keys) if (Object.hasOwn(from, key)) out[key] = from[key];
400
+ return out;
401
+ }
402
+ function timeScaleKept(value) {
403
+ const timeScale = kept(value, TIME_SCALE_RECORD);
404
+ if (timeScale.ut1MinusUtc !== null && timeScale.ut1MinusUtc !== void 0)
405
+ timeScale.ut1MinusUtc = kept(timeScale.ut1MinusUtc, UT1_RECORD);
406
+ if (timeScale.leapSeconds !== null && timeScale.leapSeconds !== void 0)
407
+ timeScale.leapSeconds = kept(timeScale.leapSeconds, LEAP_SECONDS_RECORD);
408
+ return timeScale;
409
+ }
354
410
  function choice(value, choices) {
355
411
  if (typeof value !== "string" || !choices.includes(value)) fail("invalid_value");
356
412
  return value;
@@ -431,7 +487,7 @@ var J2000_MS = Date.UTC(2e3, 0, 1, 12);
431
487
  var IERS_SEGMENTS = ["observed", "predicted", "fallback"];
432
488
  function validateDeltaT(value, instant, timeBasis2) {
433
489
  const deltaT = record(value);
434
- fields(deltaT, ["seconds", "sigma", "model", "table", "tableDigest", "segment"]);
490
+ fields(deltaT, DELTA_T_RECORD);
435
491
  const seconds = number(deltaT.seconds, -1e10, 1e10);
436
492
  if (deltaT.model === "pinned") {
437
493
  if (deltaT.sigma !== null || deltaT.table !== null || deltaT.tableDigest !== null || deltaT.segment !== "pinned")
@@ -461,19 +517,19 @@ function same(actual, expected) {
461
517
  }
462
518
  function validateTimeScale(value, deltaT, instant, scale) {
463
519
  const timeScale = record(value);
464
- fields(timeScale, ["input", "basis", "ut1MinusUtc", "leapSeconds"]);
520
+ fields(timeScale, TIME_SCALE_RECORD);
465
521
  const basis = choice(timeScale.basis, ["iers", "delta-t", "pinned"]);
466
522
  const { ut1MinusUtc, leapSeconds } = timeScale;
467
523
  if (ut1MinusUtc !== null) {
468
524
  const ut1 = record(ut1MinusUtc);
469
- fields(ut1, ["seconds", "sigma", "source"]);
525
+ fields(ut1, UT1_RECORD);
470
526
  number(ut1.seconds, -1, 1);
471
527
  number(ut1.sigma, 0, 1);
472
528
  choice(ut1.source, IERS_SEGMENTS);
473
529
  }
474
530
  if (leapSeconds !== null) {
475
531
  const leap = record(leapSeconds);
476
- fields(leap, ["taiMinusUtc", "listed"]);
532
+ fields(leap, LEAP_SECONDS_RECORD);
477
533
  if (!Number.isInteger(number(leap.taiMinusUtc, 10, 100))) fail("invalid_value");
478
534
  bool(leap.listed);
479
535
  }
@@ -482,7 +538,8 @@ function validateTimeScale(value, deltaT, instant, scale) {
482
538
  fail("inconsistent_result");
483
539
  if (deltaT.tableDigest === UT1_DATA.digest || deltaT.tableDigest === DELTA_T_TABLE.digest) {
484
540
  const expected = timeBasis(Date.parse(instant), scale);
485
- if (!same(deltaT, expected.deltaT) || !same(timeScale, expected.timeScale)) fail("inconsistent_result");
541
+ if (!same(deltaT, kept(expected.deltaT, DELTA_T_RECORD)) || !same(timeScale, timeScaleKept(expected.timeScale)))
542
+ fail("inconsistent_result");
486
543
  }
487
544
  }
488
545
  function validateResult(value, instantaneousApplying, instant, scale) {
@@ -505,7 +562,7 @@ function validateResult(value, instantaneousApplying, instant, scale) {
505
562
  const speeds = /* @__PURE__ */ new Map();
506
563
  for (const item of result.bodies) {
507
564
  const body = record(item);
508
- fields(body, ["body", "lon", "lat", "speed", "retrograde", "sign", "degree"]);
565
+ fields(body, BODY_RECORD);
509
566
  const name = choice(body.body, BODIES);
510
567
  if (names.has(name)) fail("invalid_value");
511
568
  names.add(name);
@@ -521,12 +578,12 @@ function validateResult(value, instantaneousApplying, instant, scale) {
521
578
  if (result.angles === null !== (result.houses === null)) fail("inconsistent_result");
522
579
  if (result.angles !== null) {
523
580
  const angles = record(result.angles);
524
- fields(angles, ["asc", "mc", "dsc", "ic"]);
581
+ fields(angles, ANGLES_RECORD);
525
582
  for (const angle of Object.values(angles)) longitude(angle);
526
583
  if (!angularClose(angles.dsc, angles.asc + 180) || !angularClose(angles.ic, angles.mc + 180))
527
584
  fail("inconsistent_result");
528
585
  const houses = record(result.houses);
529
- fields(houses, ["system", "cusps"]);
586
+ fields(houses, HOUSES_RECORD);
530
587
  const system = choice(houses.system, HOUSE_SYSTEMS);
531
588
  if (!Array.isArray(houses.cusps) || houses.cusps.length !== 12) fail("invalid_shape");
532
589
  const cusps = houses.cusps.map(longitude);
@@ -572,14 +629,14 @@ function validateResult(value, instantaneousApplying, instant, scale) {
572
629
  const pairs = /* @__PURE__ */ new Set();
573
630
  for (const item of result.aspects) {
574
631
  const aspect = record(item);
575
- fields(aspect, ["a", "b", "type", "orb", "applying"]);
632
+ fields(aspect, ASPECT_RECORD);
576
633
  const a = choice(
577
634
  aspect.a,
578
- BODIES.filter((body) => ASPECT_BODIES.has(body))
635
+ BODIES.filter((body) => ASPECT_BODY_SET.has(body))
579
636
  );
580
637
  const b = choice(
581
638
  aspect.b,
582
- BODIES.filter((body) => ASPECT_BODIES.has(body))
639
+ BODIES.filter((body) => ASPECT_BODY_SET.has(body))
583
640
  );
584
641
  const key = [a, b].sort().join("/");
585
642
  if (a === b || pairs.has(key)) fail("inconsistent_result");
@@ -641,16 +698,22 @@ function validateLocal(value, receipt, timeBasis2) {
641
698
  fail("invalid_context");
642
699
  if (wall + Math.round(shiftMs) - Math.round(offsetMs) !== dateFrom(receipt.instant, "instant").getTime())
643
700
  fail("invalid_context");
644
- fixedFields(local.policy, { fold: "earlier", gap: "shift-forward" });
701
+ const policy = record(local.policy);
702
+ fields(policy, ["fold", "gap"]);
703
+ if (policy.fold !== "earlier" && policy.fold !== "later" || policy.gap !== "shift-forward")
704
+ fail("unsupported_feature");
705
+ const later = policy.fold === "later";
706
+ if (later && !timeBasis2) fail("unsupported_feature");
707
+ if (later && !receipt.inputFlags.includes("dst-fold")) fail("invalid_context");
645
708
  if (receipt.inputFlags.includes("dst-gap") !== shift > 0) fail("invalid_context");
646
709
  if (receipt.reference === "local-noon" && time !== "12:00") fail("invalid_context");
647
710
  if (!timeBasis2) {
648
711
  if (receipt.inputFlags.includes("lmt") !== Math.abs(offset % 1) > 1e-9) fail("invalid_context");
649
712
  return;
650
713
  }
651
- validateLocalRecord(local, receipt, date, offset, shift);
714
+ validateLocalRecord(local, receipt, date, offset, shift, later);
652
715
  }
653
- function validateLocalRecord(local, receipt, date, offset, shift) {
716
+ function validateLocalRecord(local, receipt, date, offset, shift, later) {
654
717
  const has = (key) => Object.hasOwn(local, key);
655
718
  const calendar = has("calendar") ? choice(local.calendar, ["gregorian", "julian"]) : "gregorian";
656
719
  const written = has("writtenDate") ? text(local.writtenDate, 10) : null;
@@ -678,7 +741,10 @@ function validateLocalRecord(local, receipt, date, offset, shift) {
678
741
  const near = (a, b) => Math.abs(a - b) <= 1e-9;
679
742
  if (
680
743
  // A change of half a day or more moves the date: a move across the date line.
681
- choice(transition.cause, ["dst", "legal-change", "date-line"]) === "date-line" !== Math.abs(after - before2) >= 720 || !(gap ? after > before2 && near(after - before2, shift) && near(offset, after) && at <= instant : fold ? after < before2 && near(offset, before2) && at > instant : near(offset, after) && at <= instant)
744
+ choice(transition.cause, ["dst", "legal-change", "date-line"]) === "date-line" !== Math.abs(after - before2) >= 720 || !(gap ? after > before2 && near(after - before2, shift) && near(offset, after) && at <= instant : fold ? after < before2 && // The first pass is before the clock went back, on the offset it
745
+ // left; the second is after it, within the repeated span, on the
746
+ // offset it took.
747
+ (later ? near(offset, after) && at <= instant && instant - at < (before2 - after) * 6e4 : near(offset, before2) && at > instant) : near(offset, after) && at <= instant)
682
748
  )
683
749
  fail("invalid_context");
684
750
  }
@@ -707,7 +773,7 @@ function commit(value) {
707
773
  if (typeof value !== "string" || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value))
708
774
  fail("invalid_value");
709
775
  }
710
- function validateProvenance(value, engineVersion) {
776
+ function validateProvenance(value, engineVersion, de440Version) {
711
777
  if (value === null) return;
712
778
  const facts = record(value);
713
779
  fields(facts, ["status"], ["source", "artifact", "runtime", "ephemeris"]);
@@ -743,16 +809,20 @@ function validateProvenance(value, engineVersion) {
743
809
  if (facts.ephemeris !== void 0) {
744
810
  const ephemeris = record(facts.ephemeris);
745
811
  fields(ephemeris, ["name", "version"]);
746
- if (ephemeris.name !== "astronomy-engine") fail("unsupported_feature");
747
- version(ephemeris.version);
812
+ if (de440Version !== null) {
813
+ if (ephemeris.name !== DE440_EPHEMERIS || ephemeris.version !== de440Version) fail("invalid_context");
814
+ } else {
815
+ if (ephemeris.name !== "astronomy-engine") fail("unsupported_feature");
816
+ version(ephemeris.version);
817
+ }
748
818
  }
749
819
  }
750
820
  function validateEnvelope(input) {
751
821
  const envelope = record(input);
752
822
  if (envelope.schema !== NATAL_ENVELOPE_SCHEMA) fail("unsupported_version");
753
823
  fields(envelope, ["schema", "requiredFeatures", "receipt", "result"], ["extensions"]);
754
- if (!Array.isArray(envelope.requiredFeatures)) fail("invalid_shape");
755
- if (envelope.requiredFeatures.length !== 0) fail("unsupported_feature");
824
+ const features = list(envelope.requiredFeatures);
825
+ if (features.some((feature) => feature !== IDS_FEATURE && feature !== DE440_FEATURE)) fail("unsupported_feature");
756
826
  const receipt = record(envelope.receipt);
757
827
  if (receipt.schema !== NATAL_RECEIPT_SCHEMA) fail("unsupported_version");
758
828
  fields(receipt, [
@@ -770,7 +840,7 @@ function validateEnvelope(input) {
770
840
  "provenance",
771
841
  "conventions",
772
842
  "coverage"
773
- ], ["timeScale"]);
843
+ ], ["timeScale", "conventionIds"]);
774
844
  canonicalInstant(receipt.instant);
775
845
  if (receipt.sourceInstant !== null) {
776
846
  if (typeof receipt.sourceInstant !== "string" || receipt.sourceInstant.length > 40)
@@ -795,9 +865,15 @@ function validateEnvelope(input) {
795
865
  if (timeKnown && Math.abs(coords.latitude) === 90) fail("unsupported_feature");
796
866
  }
797
867
  const conventions = conventionSet(receipt.conventions);
798
- const timeBasis2 = conventions === CONVENTIONS || conventions === CONVENTIONS_RC15;
868
+ const de440 = conventions === CONVENTIONS_DE440;
869
+ const withIds = conventions === CONVENTIONS || de440;
870
+ const timeBasis2 = withIds || conventions === CONVENTIONS_RC16 || conventions === CONVENTIONS_RC15;
799
871
  const current = timeBasis2 || conventions === CONVENTIONS_RC8;
800
872
  if (timeBasis2 !== Object.hasOwn(receipt, "timeScale")) fail("invalid_shape");
873
+ if (withIds !== Object.hasOwn(receipt, "conventionIds")) fail("invalid_shape");
874
+ const expectedFeatures = de440 ? [IDS_FEATURE, DE440_FEATURE] : withIds ? [IDS_FEATURE] : [];
875
+ if (features.length !== expectedFeatures.length || features.some((feature, index) => feature !== expectedFeatures[index]))
876
+ fail("inconsistent_result");
801
877
  const scale = timeBasis2 ? choice(receipt.timeScale, TIME_SCALE_NAMES) : null;
802
878
  const result = validateResult(
803
879
  envelope.result,
@@ -817,29 +893,46 @@ function validateEnvelope(input) {
817
893
  if (result.houses && result.angles && TURNING_WITH_ASCENDANT.includes(result.houses.system) && !angularClose(result.houses.cusps[9], result.angles.mc) && Math.abs(receipt.coordinates.latitude) < 65)
818
894
  fail("inconsistent_result");
819
895
  const inputFlags = flagList(receipt.inputFlags, TIME_FLAGS);
820
- const resultFlags = flagList(receipt.resultFlags, current ? FLAGS : FLAGS_RC7);
896
+ const resultFlags = flagList(receipt.resultFlags, timeBasis2 ? FLAGS_TIME_BASIS : current ? FLAGS : FLAGS_RC7);
821
897
  const expected = [...inputFlags];
822
898
  if (!timeKnown) expected.push("no-time");
823
899
  if (POLAR_UNDEFINED.includes(requested) && result.houses?.system === "whole")
824
900
  expected.push("polar-fallback");
825
901
  if (current && outsideReferenceSpan(new Date(receipt.instant)))
826
902
  expected.push("outside-reference-span");
827
- if (!sameFlags(expected, resultFlags)) fail("inconsistent_result");
828
903
  const engine = record(receipt.engine);
829
904
  fields(engine, current ? ["name", "version", "ephemeris"] : ["name", "version"]);
830
905
  if (engine.name !== "@zodiacs/engine") fail("unsupported_feature");
831
906
  const engineVersion = version(engine.version);
907
+ if (timeBasis2 && (scale !== "tt" || result.houses) && result.timeScale?.basis === "delta-t" && result.deltaT?.segment === "extrapolated" && (resultFlags.includes("delta-t-extrapolated") || compareVersions(engineVersion, "1.1.0-rc.9") > 0))
908
+ expected.push("delta-t-extrapolated");
909
+ if (!de440) {
910
+ for (const reason2 of FALLBACK_FLAGS) if (resultFlags.includes(reason2)) expected.push(reason2);
911
+ }
912
+ if (!sameFlags(expected, resultFlags)) fail("inconsistent_result");
832
913
  if (current) {
833
914
  const ephemeris = record(engine.ephemeris);
834
915
  fields(ephemeris, ["name", "version"]);
835
- if (ephemeris.name !== "astronomy-engine") fail("unsupported_feature");
836
- version(ephemeris.version);
916
+ if (de440) {
917
+ if (ephemeris.name !== DE440_EPHEMERIS) fail("unsupported_feature");
918
+ if (typeof ephemeris.version !== "string" || !SHA256_HEX.test(ephemeris.version)) fail("invalid_value");
919
+ } else {
920
+ if (ephemeris.name !== "astronomy-engine") fail("unsupported_feature");
921
+ version(ephemeris.version);
922
+ }
837
923
  }
838
- validateProvenance(receipt.provenance, engineVersion);
924
+ validateProvenance(receipt.provenance, engineVersion, de440 ? record(engine.ephemeris).version : null);
839
925
  validateLocal(receipt.localResolution, receipt, timeBasis2);
840
- if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) || conventions === CONVENTIONS_RC8 && !RC8_TO_RC14.test(engineVersion) || conventions === CONVENTIONS_RC15 && !RC15.test(engineVersion) || conventions === CONVENTIONS && before(engineVersion, NUTATION_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC9.includes(requested) && before(engineVersion, RC9_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC10.includes(requested) && before(engineVersion, RC10_RELEASE))
926
+ if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) || conventions === CONVENTIONS_RC8 && !RC8_TO_RC14.test(engineVersion) || conventions === CONVENTIONS_RC15 && !RC15.test(engineVersion) || (conventions === CONVENTIONS || conventions === CONVENTIONS_RC16) && before(engineVersion, NUTATION_RELEASE) || de440 && before(engineVersion, DE440_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC9.includes(requested) && before(engineVersion, RC9_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC10.includes(requested) && before(engineVersion, RC10_RELEASE))
841
927
  fail("inconsistent_result");
842
928
  fixedFields(receipt.coverage, COVERAGE);
929
+ if (withIds) {
930
+ const ids = list(receipt.conventionIds);
931
+ if (ids.some((id) => typeof id !== "string")) fail("invalid_value");
932
+ const named = natalConventionIds({ receipt, result });
933
+ if (ids.length !== named.length || ids.some((id, index) => id !== named[index]))
934
+ fail("inconsistent_result");
935
+ }
843
936
  if (envelope.extensions !== void 0) record(envelope.extensions);
844
937
  return envelope;
845
938
  }
@@ -856,7 +949,7 @@ function checked(input) {
856
949
  function createNatalEnvelope(chart, context = {}) {
857
950
  return guarded(() => {
858
951
  const source = record(cloneData(chart, true));
859
- fields(source, [
952
+ const required = [
860
953
  "input",
861
954
  "bodies",
862
955
  "angles",
@@ -866,7 +959,8 @@ function createNatalEnvelope(chart, context = {}) {
866
959
  "deltaT",
867
960
  "timeScale",
868
961
  "engineVersion"
869
- ]);
962
+ ];
963
+ if (required.some((key) => !Object.hasOwn(source, key))) fail("invalid_shape");
870
964
  const input = record(source.input);
871
965
  fields(
872
966
  input,
@@ -874,6 +968,18 @@ function createNatalEnvelope(chart, context = {}) {
874
968
  ["latitude", "longitude", "flags", "deltaT", "timeScale"]
875
969
  );
876
970
  if (!(input.utc instanceof Date)) fail("invalid_value");
971
+ const ephemerisNamed = source.ephemeris === void 0 ? null : record(source.ephemeris);
972
+ let de440 = false;
973
+ if (ephemerisNamed !== null) {
974
+ fields(ephemerisNamed, ["name", "version"]);
975
+ if (ephemerisNamed.name === EPHEMERIS.name) {
976
+ if (ephemerisNamed.version !== EPHEMERIS.version) fail("unsupported_feature");
977
+ } else {
978
+ if (ephemerisNamed.name !== DE440_EPHEMERIS) fail("unsupported_feature");
979
+ if (typeof ephemerisNamed.version !== "string" || !SHA256_HEX.test(ephemerisNamed.version)) fail("invalid_value");
980
+ de440 = true;
981
+ }
982
+ }
877
983
  const supplied = record(cloneData(context));
878
984
  fields(
879
985
  supplied,
@@ -884,42 +990,49 @@ function createNatalEnvelope(chart, context = {}) {
884
990
  fields(record(supplied.provenance), [], ["source", "artifact", "runtime", "ephemeris"]);
885
991
  if (input.latitude === void 0 !== (input.longitude === void 0)) fail("invalid_value");
886
992
  const houses = source.houses === null ? null : record(source.houses);
887
- const envelope = {
888
- schema: NATAL_ENVELOPE_SCHEMA,
889
- requiredFeatures: [],
890
- receipt: {
891
- schema: NATAL_RECEIPT_SCHEMA,
892
- instant: Date.prototype.toISOString.call(input.utc),
893
- timeScale: input.timeScale ?? "utc",
894
- sourceInstant: supplied.sourceInstant === void 0 ? null : supplied.sourceInstant,
895
- timeKnown: input.timeKnown,
896
- reference: supplied.reference === void 0 ? "supplied-instant" : supplied.reference,
897
- localResolution: supplied.localResolution ?? null,
898
- coordinates: input.latitude === void 0 ? null : { latitude: input.latitude, longitude: input.longitude },
899
- houses: {
900
- requested: input.houseSystem,
901
- actual: houses?.system ?? null,
902
- absenceReason: !input.timeKnown ? "unknown-time" : input.latitude === void 0 ? "missing-location" : null
903
- },
904
- inputFlags: input.flags ?? [],
905
- resultFlags: source.flags,
906
- engine: {
907
- name: "@zodiacs/engine",
908
- version: source.engineVersion,
909
- ephemeris: { ...EPHEMERIS }
910
- },
911
- provenance: supplied.provenance === void 0 ? null : { ...record(supplied.provenance), status: "claimed" },
912
- conventions: { ...CONVENTIONS },
913
- coverage: { ...COVERAGE }
993
+ const receipt = {
994
+ schema: NATAL_RECEIPT_SCHEMA,
995
+ instant: Date.prototype.toISOString.call(input.utc),
996
+ timeScale: input.timeScale ?? "utc",
997
+ sourceInstant: supplied.sourceInstant === void 0 ? null : supplied.sourceInstant,
998
+ timeKnown: input.timeKnown,
999
+ reference: supplied.reference === void 0 ? "supplied-instant" : supplied.reference,
1000
+ localResolution: supplied.localResolution ?? null,
1001
+ coordinates: input.latitude === void 0 ? null : { latitude: input.latitude, longitude: input.longitude },
1002
+ houses: {
1003
+ requested: input.houseSystem,
1004
+ actual: houses?.system ?? null,
1005
+ absenceReason: !input.timeKnown ? "unknown-time" : input.latitude === void 0 ? "missing-location" : null
914
1006
  },
915
- result: {
916
- bodies: source.bodies,
917
- angles: source.angles,
918
- houses: source.houses,
919
- aspects: source.aspects,
920
- deltaT: source.deltaT,
921
- timeScale: source.timeScale
1007
+ inputFlags: input.flags ?? [],
1008
+ resultFlags: source.flags,
1009
+ engine: {
1010
+ name: "@zodiacs/engine",
1011
+ version: source.engineVersion,
1012
+ ephemeris: de440 ? { name: DE440_EPHEMERIS, version: ephemerisNamed.version } : { ...EPHEMERIS }
922
1013
  },
1014
+ provenance: supplied.provenance === void 0 ? null : { ...record(supplied.provenance), status: "claimed" },
1015
+ conventions: { ...de440 ? CONVENTIONS_DE440 : CONVENTIONS },
1016
+ coverage: { ...COVERAGE }
1017
+ };
1018
+ const result = {
1019
+ bodies: list(source.bodies).map((body) => kept(body, BODY_RECORD)),
1020
+ angles: source.angles === null ? null : kept(source.angles, ANGLES_RECORD),
1021
+ houses: houses === null ? null : kept(houses, HOUSES_RECORD),
1022
+ aspects: list(source.aspects).map((aspect) => kept(aspect, ASPECT_RECORD)),
1023
+ deltaT: kept(source.deltaT, DELTA_T_RECORD),
1024
+ timeScale: timeScaleKept(source.timeScale)
1025
+ };
1026
+ let conventionIds = [];
1027
+ try {
1028
+ conventionIds = natalConventionIds({ receipt, result });
1029
+ } catch {
1030
+ }
1031
+ const envelope = {
1032
+ schema: NATAL_ENVELOPE_SCHEMA,
1033
+ requiredFeatures: de440 ? [IDS_FEATURE, DE440_FEATURE] : [IDS_FEATURE],
1034
+ receipt: { ...receipt, conventionIds },
1035
+ result,
923
1036
  ...supplied.extensions === void 0 ? {} : { extensions: supplied.extensions }
924
1037
  };
925
1038
  return checked(envelope);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The span over which this engine's positions have been compared with an
3
+ * independent ephemeris: from 1800-01-01T00:00Z up to, not including,
4
+ * 2200-01-01T00:00Z. Charts outside it are still computed, and carry the
5
+ * `outside-reference-span` flag.
6
+ */
7
+ declare const REFERENCE_SPAN: Readonly<{
8
+ readonly from: "1800-01-01T00:00:00.000Z";
9
+ readonly to: "2200-01-01T00:00:00.000Z";
10
+ }>;
11
+ /**
12
+ * The span of Terrestrial Time over which the ephemeris is evaluated at all:
13
+ * the years astronomy-engine 2.1.19 itself tabulates, J2000 ± 730,000 days of
14
+ * TT (0001-04-30T12:00 to 3998-09-03T12:00 TT). That is the range of its Pluto
15
+ * model's state table; for any other time its source says: "The target time is
16
+ * outside the year range 0000..4000. Calculate it by crawling backward from 0000
17
+ * or forward from 4000. ... This is super slow." Beyond the table its other
18
+ * series diverge as well: on 30000-06-01 the Sun came out 29° off the ecliptic.
19
+ *
20
+ * Every instant a calculation evaluates, the instant and its speed samples, must
21
+ * lie inside on the calculation's own ΔT clock, or the call throws RangeError.
22
+ * With the model ΔT, instants from 0001-05-01T00:00Z to 3998-09-02T00:00Z are
23
+ * always inside. Being inside is not an accuracy claim: see REFERENCE_SPAN.
24
+ */
25
+ declare const EPHEMERIS_SPAN: Readonly<{
26
+ /** The scale of the bounds, as a label, like `fromTT` and `toTT`: not a TimeScaleName, which is lowercase. */
27
+ readonly timeScale: "TT";
28
+ /** Days of Terrestrial Time from J2000.0, 2000-01-01T12:00 TT, inclusive. */
29
+ readonly daysFromJ2000: Readonly<{
30
+ readonly from: -730000;
31
+ readonly to: 730000;
32
+ }>;
33
+ /** The same bounds as Terrestrial Time labels (not UTC). */
34
+ readonly fromTT: "0001-04-30T12:00:00";
35
+ readonly toTT: "3998-09-03T12:00:00";
36
+ }>;
37
+ /** True when the instant lies outside REFERENCE_SPAN. */
38
+ declare function outsideReferenceSpan(utc: Date): boolean;
39
+
40
+ export { EPHEMERIS_SPAN as E, REFERENCE_SPAN as R, outsideReferenceSpan as o };
@@ -1,8 +1,13 @@
1
- import { Z as ZodiacSign } from './types-B4MCoCCS.js';
1
+ import { Z as ZodiacSign } from './types-DpPdtXgO.js';
2
2
 
3
3
  /** The seven visible planets of the traditional rulership scheme. */
4
4
  type TraditionalPlanet = "Sun" | "Moon" | "Mercury" | "Venus" | "Mars" | "Jupiter" | "Saturn";
5
- /** The traditional domicile ruler of each sign; the outer planets rule none. */
5
+ /**
6
+ * The traditional domicile ruler of each sign; the outer planets rule none.
7
+ * The same rulers as `@zodiacs/engine/techniques`'s DOMICILE_RULERS and
8
+ * `@zodiacs/engine/vedic`'s SIGN_LORDS. Each entry point carries its own copy,
9
+ * so that none imports another; a test keeps the three equal.
10
+ */
6
11
  declare const TRADITIONAL_RULERS: Readonly<Record<ZodiacSign, TraditionalPlanet>>;
7
12
  /** The seven planets in descending order of their spheres, Saturn to the Moon. */
8
13
  declare const CHALDEAN_ORDER: readonly TraditionalPlanet[];