@zodiacs/engine 0.1.1-rc.15 → 1.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 (54) hide show
  1. package/CHANGELOG.md +891 -0
  2. package/LICENSING.md +192 -12
  3. package/NOTICE +96 -2
  4. package/README.md +296 -66
  5. package/dist/{api-CoB_kqE3.d.ts → api-WbxJ4Wj-.d.ts} +15 -10
  6. package/dist/ayanamsa--YQ46fET.d.ts +134 -0
  7. package/dist/calc.d.ts +390 -0
  8. package/dist/calc.js +1039 -0
  9. package/dist/chunk-47ERTK5X.js +27 -0
  10. package/dist/chunk-7TRLIFFI.js +56 -0
  11. package/dist/chunk-A3U2ZS2W.js +29 -0
  12. package/dist/{chunk-KHBLFXFG.js → chunk-B5LKF437.js} +29 -28
  13. package/dist/{chunk-ONBZ4HK7.js → chunk-BHJXUY67.js} +4 -2
  14. package/dist/{chunk-OYGRVGXD.js → chunk-CHSYDKBL.js} +3 -3
  15. package/dist/{chunk-ZHVI3KWJ.js → chunk-DMGHYCDI.js} +4 -4
  16. package/dist/{chunk-CWI4YUDL.js → chunk-FTX3JDJA.js} +21 -18
  17. package/dist/{chunk-MFF3VKO3.js → chunk-OG4OYTJJ.js} +47 -42
  18. package/dist/{chunk-ZZPITHQS.js → chunk-SRXBTP5H.js} +199 -65
  19. package/dist/{chunk-AECKV73C.js → chunk-TSS2SZWQ.js} +8 -2
  20. package/dist/chunk-WS3TDSP3.js +474 -0
  21. package/dist/chunk-YIITY7Q7.js +483 -0
  22. package/dist/crossings.d.ts +8 -7
  23. package/dist/crossings.js +1 -1
  24. package/dist/deltat.d.ts +28 -3
  25. package/dist/deltat.js +1 -1
  26. package/dist/geo.d.ts +33 -12
  27. package/dist/geo.js +17 -458
  28. package/dist/{internal-math-BbktkHCc.d.ts → houses-CFERsAlK.d.ts} +14 -160
  29. package/dist/houses-extra.d.ts +95 -0
  30. package/dist/houses-extra.js +339 -0
  31. package/dist/index.d.ts +34 -48
  32. package/dist/index.js +31 -23
  33. package/dist/internal-math-DJJ8BYex.d.ts +174 -0
  34. package/dist/internal-math.d.ts +3 -2
  35. package/dist/internal-math.js +2 -2
  36. package/dist/internal.d.ts +1 -1
  37. package/dist/internal.js +5 -5
  38. package/dist/receipt.d.ts +2 -243
  39. package/dist/receipt.js +78 -37
  40. package/dist/reference-span-CILpclrz.d.ts +40 -0
  41. package/dist/rulers-Dla6h_Sm.d.ts +15 -0
  42. package/dist/sky.d.ts +173 -0
  43. package/dist/sky.js +379 -0
  44. package/dist/techniques.d.ts +453 -0
  45. package/dist/techniques.js +823 -0
  46. package/dist/timing.d.ts +113 -17
  47. package/dist/timing.js +98 -64
  48. package/dist/{types-BsWaqwU_.d.ts → types-B-yb_tGL.d.ts} +23 -11
  49. package/dist/vedic.d.ts +42 -124
  50. package/dist/vedic.js +44 -458
  51. package/dist/window.d.ts +180 -0
  52. package/dist/window.js +960 -0
  53. package/dist/zone-history-ghdyO0Sc.d.ts +268 -0
  54. package/package.json +25 -3
@@ -0,0 +1,483 @@
1
+ import {
2
+ civilDateOf,
3
+ format,
4
+ julianDayNumber,
5
+ parseCalendarDate
6
+ } from "./chunk-KFTJMMG7.js";
7
+ import {
8
+ validateBirthSettings
9
+ } from "./chunk-PFGUCNOK.js";
10
+
11
+ // src/geo/calendar.ts
12
+ var GREGORIAN_ADOPTION_SOURCES = /* @__PURE__ */ Object.freeze({
13
+ tzdb: "IANA tzdata 2025c, file calendars, quoting H. Grotefend, Taschenbuch der Zeitrechnung, ed. O. Grotefend (1941), pp. 26-28",
14
+ "grotefend-1891": "H. Grotefend, Zeitrechnung des deutschen Mittelalters und der Neuzeit, vol. 1 (1891), pp. 133-134",
15
+ "grotefend-1898": "H. Grotefend, Taschenbuch der Zeitrechnung des deutschen Mittelalters und der Neuzeit (1898), pp. 23-24"
16
+ });
17
+ var ROWS = `AT|Austria|Austria|1584-01-17|t|Grotefend 1898: 1583-10-16, with Bavaria. Salzburg 1583-10-16; Styria 1583-12-25.
18
+ BE|Belgium|Brabant, Flanders, Hainaut|1583-01-01|t|Grotefend 1891, 1898: 1582-12-25. Bishopric of Li\xE8ge 1583-02-21.
19
+ CH|Switzerland|Z\xFCrich, Bern, Basel, Schaffhausen|1701-01-12|t18|Also Geneva and Thurgau. Catholic cantons 1584-01-22 (Grotefend 1891: 1584-01-23); Unterwalden June 1584; Glarus, Appenzell, St. Gallen city 1724; Valais 1655 (Grotefend 1898: 1622); Graub\xFCnden 1760-1812 (Grotefend 1898: to 1811); bishopric of Basel 1583-10-31.
20
+ CZ|Czech Republic|Bohemia|1584-01-17|t18|Silesia 1584-01-23. Moravia is not dated.
21
+ DE|Germany|Protestant states|1700-03-01|t18|Catholic states from 1583: bishopric of Augsburg 1583-02-24, Bavaria 1583-10-16, the latest listed the bishopric of Hildesheim 1631-03-26.
22
+ DK|Denmark|-|1700-03-01|t18|
23
+ ES|Spain|-|1582-10-15|t18|
24
+ FI|Finland|-|1753-03-01|t|With Sweden; see Sweden. tzdb's list says the Russian empire, Finland included, kept the Julian calendar until 1917.
25
+ FR|France|France, Lorraine|1582-12-20|t18|City of Strasbourg 1682-02-16; bishopric of Strasbourg 1583-11-27 (Grotefend 1898: 1583-11-22); Austrian Upper Alsace 1583-10-24. Republican calendar 1793-11-24 to 1805-12-31, in Paris also 1871-05-06 to 1871-05-23: not converted.
26
+ GB|Britain (UK)|Great Britain|1752-09-14|t18|
27
+ HU|Hungary|-|1587-11-01|t18|The legal change. tzdb's list also gives 1584-02-02, "legally on 21 Oct 1587".
28
+ IT|Italy|Italy, with exceptions|1582-10-15|t18|Bishopric of Brixen (Bressanone) 1583-10-16.
29
+ NL|Netherlands|Holland|1583-01-01|t|Grotefend 1891, 1898: 1582-12-25. Gelderland 1700-07-12; Zutphen 1700-07-12 (Grotefend 1898: 1700-12-12); Utrecht, Overijssel 1700-12-12; Friesland, Groningen 1701-01-12; Grotefend 1891: 1700-12-12 for all six. Zeeland and Drenthe are not dated.
30
+ NO|Norway|-|1700-03-01|t|Grotefend 1891, 1898 name Denmark only.
31
+ PL|Poland|Roman Catholics, and Danzig|1582-10-15|t|Grotefend 1898: not everywhere, notably not among Protestants and the Greek Church; Grotefend 1891: 1586. Silesia 1584-01-23; duchy of Prussia 1612-09-02 (Grotefend 1898: 1612-09-01).
32
+ PT|Portugal|-|1582-10-15|t18|
33
+ RU|Russia|Soviet Russia|1918-02-14|t|Grotefend 1891, 1898: still Julian. Duchy of Prussia, now partly Kaliningrad, 1612-09-02 (Grotefend 1898: 1612-09-01).
34
+ SE|Sweden|-|1753-03-01|t18|From 1 March 1700 to 30 February 1712 Swedish dates are one day ahead of the Julian (Grotefend 1898).`;
35
+ var SOURCE_KEYS = { t: "tzdb", 1: "grotefend-1891", 8: "grotefend-1898" };
36
+ var GREGORIAN_ADOPTION = /* @__PURE__ */ Object.freeze(
37
+ /* @__PURE__ */ ROWS.split("\n").map((line) => {
38
+ const [code, country, region, firstGregorian, sources, note] = line.split("|");
39
+ const day = julianDayNumber(parseCalendarDate(firstGregorian, "gregorian"), "gregorian");
40
+ return Object.freeze({
41
+ code,
42
+ country,
43
+ region: region === "-" ? null : region,
44
+ firstGregorian,
45
+ lastJulian: format(civilDateOf(day - 1, "julian")),
46
+ sources: Object.freeze([...sources].map((key) => SOURCE_KEYS[key])),
47
+ note
48
+ });
49
+ })
50
+ );
51
+ function gregorianAdoption(country) {
52
+ return GREGORIAN_ADOPTION.find((row) => row.code === country || row.country === country);
53
+ }
54
+ function calendarNote(gregorianDate, calendar, country) {
55
+ if (!parseCalendarDate(gregorianDate, "gregorian")) throw new RangeError("gregorianDate must be a valid Gregorian date, YYYY-MM-DD.");
56
+ if (calendar !== "gregorian" && calendar !== "julian") throw new RangeError('calendar must be "gregorian" or "julian".');
57
+ if (typeof country !== "string" || !country.trim()) throw new RangeError("country must be a nonempty string.");
58
+ return noteFor(gregorianDate, calendar, country);
59
+ }
60
+ function noteFor(gregorianDate, calendar, country) {
61
+ const adoption = gregorianAdoption(country);
62
+ if (!adoption) return null;
63
+ const julian = calendar === "julian";
64
+ if (gregorianDate.length > 10 || gregorianDate >= adoption.firstGregorian) return julian ? { kind: "new-style", adoption } : null;
65
+ return julian ? null : { kind: "old-style", adoption };
66
+ }
67
+
68
+ // src/tzdb/tzdb-2025c.ts
69
+ var TZDB = /* @__PURE__ */ Object.freeze({
70
+ version: "2025c",
71
+ sha256: "4aa79e4effee53fc4029ffe5f6ebe97937282ebcdf386d5d2da91ce84142f957",
72
+ form: "main+backzone"
73
+ });
74
+ var SHARD_LOADERS = [
75
+ () => import("./tzdb-2025c-00-6GVG6RYL.js"),
76
+ () => import("./tzdb-2025c-01-CEYMG3LE.js"),
77
+ () => import("./tzdb-2025c-02-NWQJCVUU.js"),
78
+ () => import("./tzdb-2025c-03-PLHP6VH4.js"),
79
+ () => import("./tzdb-2025c-04-MEKUJA6M.js"),
80
+ () => import("./tzdb-2025c-05-3K5YKZBL.js"),
81
+ () => import("./tzdb-2025c-06-L2VV5XJV.js"),
82
+ () => import("./tzdb-2025c-07-H3GLGJGY.js"),
83
+ () => import("./tzdb-2025c-08-DA7QQIGD.js"),
84
+ () => import("./tzdb-2025c-09-MTXIO3QL.js"),
85
+ () => import("./tzdb-2025c-10-ASL4UW5C.js"),
86
+ () => import("./tzdb-2025c-11-EQEOANYB.js"),
87
+ () => import("./tzdb-2025c-12-NKCCXJ5G.js"),
88
+ () => import("./tzdb-2025c-13-DYTF3UC7.js"),
89
+ () => import("./tzdb-2025c-14-C25H45R5.js"),
90
+ () => import("./tzdb-2025c-15-7OYYZWRY.js")
91
+ ];
92
+ var LATER_CAUSES = "26z1v3r9wo.2lzdo.2092c.51mzc.;4omh4gkhm0.;8i4hw7ji4c.8fno.94cvo.;emnzt8v8m6.;pibsacwtc0.;shzcp6wjs0.609ic.14eec.;qn9anc1rqo.;hr04d6wjeo.609ic.14eec.;iwfdj6f1oo.;jxme485390.;vxtl73htjc.;zmgwf7egs0!;008wxcglro.4g1o.ie6c.3m1o.;xgck2d5eqc!;x90aj50d2u.;e4lpj23xc0.;n97c09emgo.6l9mc.;c1i1b2i6cc.;srkypcglq0.4970.il10.3lyc.1glac.fl5o.6hh0.4ypc.67h0.4t70.6hc1.4yqz.69p1.4yqz.69p1.4vjz.;6bx5p6nh2c.69c80.14eec.fzlo.;d7foo4bvj0.;da48bez4xo.;cc60723xc0.;r2ctm3r9wo.2lzdo.2092c.51mzc.;09xrhgo29o.;23q2c4g4g0.;2fq0m6nh2c.69c80.14eec.nrlo.;73ubg6wji0.609ic.14eec.;glme93r9mo.;iztuh9nq0c.;yksj0kmbc.;94mmz6nh2c.69c80.14eec.195lo.oeuc.;c9gx56mm3c.74rc.3y7yc.l5o.;ftdfk2i6cc.;fyvor6f1oo.;oqbaz9c9u0.;upch43ip7c.;4tlos3ofjo.38450.;bzp0f6wjn0.8fhf0.;cwffa6mm3c.74rc.;lal8k92wc0.;oyxuu31w40.4rwuc!;z0hat2fygi.bwwu.;091etgo29o.;blqvj6wjlc.f49c.5l5ao.14eec.jnto.;tgp36clt30.;9wqor23xc0.;vma32kmbc.;6vjgid5eoo!;agkxx6wji0.609ic.14eec.fznc.;bt63w1yu1o.;6fyvm6dbgo.;93ycg6f1oo.;jenq11pdmo.;kikwv6wjjo.609ic.14eec.;6i87mkmbc.;ktr4c6bdnc.tlnc.3mpic.3w1o.;lnqdp1pdmo.;x5jk0173j0.;ylrpy4bvj0.;yvsdoecogo.10ao0.;51sa56mm3c.74rc.3y7yc.l5o.;imjhpc1rsc.1onac.;xgvkj6tqo0.632mc.;4rg6l6wjd0.609k0.;cx7tr6mm3c.74rc.;e7mcw6wjlc.609ic.14eec.;3se9a6dbgo.;8k2bmkmbc.;nkww16bdnc.hxnc.;sjll11ibsc.856ho.12w0.;tbefcc1rsc.1onac.;v730i4n7yc.;dvg44kmbc.;v977f6mm3c.74rc.3y7yc.ddo.;7egrqe35eo.;lgxqt4g4g0.k8uc.;8hz4v6mm3c.74rc.3y7yc.l5o.;pyva5q8v0.;npf8s6wjn0.a2170.;x1w033is10.3drdo.609ic.58r0.z5p0.;068n925yo0.;kjcdu4m9pu.;b0ken2i6e0.;e0yew2i6cc.;pfxgu6wjn0.609ic.14eec.;4oapw3r3pc.9lic.;9linmuzqo.gvqc.;z70s311v0q6_;zme5q6wjoo.a215c.;oh15y11je0.k8uc.5a80c.88fo.321o.193ac.;blv5h6mjvc.22jc.43cec.l5o.;d7hxtkmbc.;jvnzr6f1oo.;wrz6f32nac.h2ho.;x7xki3r9mo.;0aanqasrbo.8fio.;foc486wjoo.609ic.14eec.;wh9055mw2o.;04yj4kmbc.;31xyt6wjeo.609ic.14eec.gurc.;k0dlb4n7yc.;k4x616wjeo.609k0.14eec.fzlo.;qsklxf141o.b9k0.;d90416wjlc.11sxc.4ygmo.14eec.fzlo.;diqxz9emgo.5klmc.;hqu65r7tc.;r60tt9c9u0.;7hozj7egs0!;n4f883r3pc.bjf0.4vl5o.560rc.;rcx29bn8lc.;tyfb56wjoo.;3mwwdr7tc.;h2j0f6wjoo.;n3exs6wjgc.609ic.14eec.;pf3zccwtc0.14eec.;3wlms4692o.8kazc.;hjhq6852vo.;yded86mm3c.74rc.;cshzubvnvo.2mmo0.;mkxe53htjc.;u226p6mm3c.74rc.;v8ck8774zc.5b2c.;xy1qbcgltc.;s3w2g3ofjo.38450.u8uc.;58co631w1s.4rwuw!;x8ghc1uhio.;y3thu2fygi.bwwu.;u3e1j1qwm9.57t4f.;cga095k1yu.;7xj8c6wjs0.609ic.14eec.;5m66y6wjlc.37w6c.2sddo.14eec.hxlo.;69icl31w40.4rwuc!;mu12m6bdnc.tlnc.3mpic.3w1o.;odp3marwl0.ndo.;otx0189jyu.4r36.2yq8u.;sxc0n6nh2c.69c80.14eec.;mez0y6wjoo.;tsxgk3r9mo.;2447s1zep0.7ms9o.;3s5e6c1rsc.1onac.;983km2uo86.;qbuhn50d2u.;qslwbe5bvo.;u0hxf6wji0.3qpv0.29jlo.58r0.z5p0.;cft6i6borc.dpfc.42jic.1p5o.13cko.jezc.;6o3pl3uzh0.;ertoo6wjs0.609ic.14eec.fzlo.;h5uvn5k1yu.;sa6yk50dkc.;4q92r6bdnc.hxnc.;wfyr46wjoo.;7zfow2rx5i.;j06xje5c0o.;teiet4bvo0.;6v8ej6mjvc.22jc.43bac.1p5o.;ajtnw2x3so.;ttwf6ea8x0.uog0.;o6n0f6wjlc.609k0.;4bqjbaryt0.l5o.;j9sdo38geo.;0hdnqebsg6.;6qmtw6f1qc.177go.68h90.6h8o.;asm1e4n7yc.;kzndtc1rsc.1onac.;mmp3d1kcxo.;pjzkh6wjd0.609k0.";
93
+
94
+ // src/geo/zone-history.ts
95
+ var CAUSES = { d: "dst", l: "legal-change", x: "date-line" };
96
+ function nameHash(name) {
97
+ const key = name.toLowerCase();
98
+ let hash = 2166136261;
99
+ for (let index = 0; index < key.length; index += 1) {
100
+ hash ^= key.charCodeAt(index);
101
+ hash = Math.imul(hash, 16777619) >>> 0;
102
+ }
103
+ return hash;
104
+ }
105
+ function decode(entry) {
106
+ const times = [];
107
+ let previous = 0;
108
+ if (entry.t) {
109
+ entry.t.split(",").forEach((part, index) => {
110
+ const value = parseInt(part, 36);
111
+ previous = index === 0 ? value : previous + value;
112
+ times.push(previous * 1e3);
113
+ });
114
+ }
115
+ const types = [0];
116
+ const causes = [];
117
+ for (let index = 0; index < entry.k.length; index += 2) {
118
+ types.push(parseInt(entry.k[index], 36));
119
+ causes.push(CAUSES[entry.k[index + 1]]);
120
+ }
121
+ return {
122
+ name: entry.n,
123
+ source: entry.s,
124
+ hostLegal: entry.h === 1,
125
+ zoneEraEnd: entry.f === null ? null : entry.f * 1e3,
126
+ era: entry.e ? entry.e.map(([until, offset]) => [until * 1e3, offset]) : null,
127
+ times,
128
+ types,
129
+ causes,
130
+ offsets: entry.y.map((type) => type[0]),
131
+ dst: entry.y.map((type) => type[1] === 1),
132
+ abbreviations: entry.y.map((type) => type[2])
133
+ };
134
+ }
135
+ var histories = /* @__PURE__ */ new Map();
136
+ var loads = /* @__PURE__ */ new Map();
137
+ function loadedHistory(timeZone) {
138
+ return histories.get(timeZone.toLowerCase());
139
+ }
140
+ function loadHistory(timeZone) {
141
+ const key = timeZone.toLowerCase();
142
+ if (histories.has(key)) return Promise.resolve();
143
+ const bucket = nameHash(timeZone) % SHARD_LOADERS.length;
144
+ let pending = loads.get(bucket);
145
+ if (!pending) {
146
+ const load = SHARD_LOADERS[bucket]().then((module) => module.default);
147
+ loads.set(bucket, load);
148
+ void load.catch(() => {
149
+ if (loads.get(bucket) === load) loads.delete(bucket);
150
+ });
151
+ pending = load;
152
+ }
153
+ const ready = pending.then((zones) => {
154
+ const entry = Object.prototype.hasOwnProperty.call(zones, key) ? zones[key] : void 0;
155
+ histories.set(key, entry ? decode(entry) : null);
156
+ });
157
+ void ready.catch(() => {
158
+ });
159
+ return ready;
160
+ }
161
+ function typeIndexAt(history, ms) {
162
+ let lo = 0;
163
+ let hi = history.times.length;
164
+ while (lo < hi) {
165
+ const mid = lo + hi >> 1;
166
+ if (history.times[mid] <= ms) lo = mid + 1;
167
+ else hi = mid;
168
+ }
169
+ return lo;
170
+ }
171
+ function transitionAt(history, ms) {
172
+ const index = typeIndexAt(history, ms) - 1;
173
+ return index >= 0 && history.times[index] === ms ? index : -1;
174
+ }
175
+ var later;
176
+ function laterCause(timeZone, ms) {
177
+ if (!later) {
178
+ later = /* @__PURE__ */ new Map();
179
+ for (const row of LATER_CAUSES.split(";")) {
180
+ const causes = /* @__PURE__ */ new Map();
181
+ let at = 0;
182
+ for (const [, digits, mark] of row.slice(5).matchAll(/([0-9a-z]+)([.!_~])/g)) {
183
+ const kind = ".!_~".indexOf(mark);
184
+ at += parseInt(digits, 36) * (kind < 2 ? 6e4 : 1e3);
185
+ causes.set(at, kind % 2 ? "date-line" : "legal-change");
186
+ }
187
+ later.set(parseInt(row.slice(0, 5), 36), causes);
188
+ }
189
+ }
190
+ return later.get(nameHash(timeZone) % 36 ** 5)?.get(ms) ?? "dst";
191
+ }
192
+
193
+ // src/geo/timezone.ts
194
+ var offsetFormatters = /* @__PURE__ */ new Map();
195
+ function validateTimeZone(timeZone) {
196
+ if (typeof timeZone !== "string" || timeZone.trim().length === 0) {
197
+ throw new RangeError("timeZone must be an explicit nonempty timezone string.");
198
+ }
199
+ }
200
+ function offsetFormatter(timeZone) {
201
+ validateTimeZone(timeZone);
202
+ let formatter = offsetFormatters.get(timeZone);
203
+ if (!formatter) {
204
+ formatter = new Intl.DateTimeFormat("en-US", {
205
+ timeZone,
206
+ calendar: "gregory",
207
+ numberingSystem: "latn",
208
+ timeZoneName: "longOffset"
209
+ });
210
+ offsetFormatters.set(timeZone, formatter);
211
+ }
212
+ return formatter;
213
+ }
214
+ function validateInstant(utcMilliseconds) {
215
+ if (typeof utcMilliseconds !== "number" || !Number.isFinite(utcMilliseconds)) {
216
+ throw new RangeError("utcMilliseconds must be a finite epoch-millisecond timestamp.");
217
+ }
218
+ }
219
+ function offsetAt(timeZone, utcMilliseconds) {
220
+ validateInstant(utcMilliseconds);
221
+ const name = offsetFormatter(timeZone).formatToParts(utcMilliseconds).find((part) => part.type === "timeZoneName")?.value;
222
+ const match = (name ?? "GMT").match(/^GMT(?:([+-])(\d{1,2})(?::(\d{2}))?(?::(\d{2}))?)?$/u);
223
+ if (!match) {
224
+ throw new RangeError(`Could not read UTC offset for timezone: ${timeZone}`);
225
+ }
226
+ const sign = match[1] === "-" ? -1 : 1;
227
+ return sign * (Number(match[2] ?? 0) * 60 + Number(match[3] ?? 0) + Number(match[4] ?? 0) / 60);
228
+ }
229
+ var DAY = 864e5;
230
+ var PROBE = 36 * 36e5;
231
+ var MAX_DEPARTURE_SECONDS = 180 * 60;
232
+ var FIXED_ZONE = /^(?:etc\/)?(?:utc|uct|gmt|gmt0|gmt[+-]0|greenwich|universal|zulu)$|^etc\/gmt[+-]\d{1,2}$/iu;
233
+ function hostTzdbVersion() {
234
+ const tz = globalThis.process?.versions?.tz;
235
+ return typeof tz === "string" && /^\d{4}[a-z]$/u.test(tz) ? tz : null;
236
+ }
237
+ function firstChange(clockAt, lo, hi) {
238
+ const from = clockAt(lo);
239
+ while (hi - lo > 1) {
240
+ const mid = Math.floor((lo + hi) / 2);
241
+ if (clockAt(mid) === from) lo = mid;
242
+ else hi = mid;
243
+ }
244
+ return hi;
245
+ }
246
+ function readClock(wallMs, clockAt, samples) {
247
+ const readings = [];
248
+ for (const offset of new Set(samples.map(clockAt))) {
249
+ const utcMs2 = wallMs - offset * 1e3;
250
+ if (clockAt(utcMs2) === offset && !readings.some((reading) => reading.utcMs === utcMs2)) {
251
+ readings.push({ utcMs: utcMs2, offset });
252
+ }
253
+ }
254
+ const [first, second] = readings.sort((a, b) => a.utcMs - b.utcMs);
255
+ if (first) {
256
+ return second ? { chosen: first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
257
+ }
258
+ let lo = wallMs - PROBE - DAY;
259
+ let hi = wallMs + PROBE + DAY;
260
+ while (hi - lo > 1) {
261
+ const mid = Math.floor((lo + hi) / 2);
262
+ if (mid + clockAt(mid) * 1e3 > wallMs) hi = mid;
263
+ else lo = mid;
264
+ }
265
+ const utcMs = wallMs - clockAt(lo) * 1e3;
266
+ return { chosen: { utcMs, offset: clockAt(utcMs) }, kind: "gap", at: hi };
267
+ }
268
+ function zoneClock(timeZone, history) {
269
+ return (ms) => {
270
+ const offset = history && ms < 0 ? history.offsets[history.types[typeIndexAt(history, ms)]] : null;
271
+ return offset ?? Math.round(offsetAt(timeZone, ms) * 60);
272
+ };
273
+ }
274
+ function birthplaceClock(history, wallMs, longitude, zoneAt) {
275
+ const era = history.era;
276
+ if (!era) return null;
277
+ const endMs = era[era.length - 1][0];
278
+ if (wallMs - PROBE > endMs) return null;
279
+ const meanSeconds = Math.round(longitude * 240);
280
+ const eraOffset = (ms) => (era.find(([until]) => ms < until) ?? era[era.length - 1])[1];
281
+ const place = (ms) => meanSeconds + Math.round((eraOffset(ms) - meanSeconds) / 86400) * 86400;
282
+ const sample = Math.min(wallMs, endMs - 1);
283
+ if (Math.abs(place(sample) - eraOffset(sample)) > MAX_DEPARTURE_SECONDS) return null;
284
+ const legalFrom = history.hostLegal && zoneAt(endMs + PROBE) !== zoneAt(endMs) ? firstChange(zoneAt, endMs, endMs + PROBE) : endMs;
285
+ return {
286
+ clockAt: (ms) => ms < endMs ? place(ms) : zoneAt(Math.max(ms, legalFrom)),
287
+ endMs,
288
+ legalFrom,
289
+ /** The era's own line ends before endMs: moves across the date line. */
290
+ lineEnds: era.slice(0, -1).map(([until]) => until)
291
+ };
292
+ }
293
+ function readOptions(options) {
294
+ if (options === void 0) return { calendar: "gregorian" };
295
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
296
+ throw new RangeError("options must be an object.");
297
+ }
298
+ for (const key of Object.getOwnPropertyNames(options)) {
299
+ if (!["longitude", "calendar", "country"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
300
+ }
301
+ const { longitude, calendar = "gregorian", country } = options;
302
+ if (longitude !== void 0 && !(typeof longitude === "number" && Math.abs(longitude) <= 180)) {
303
+ throw new RangeError("longitude must be between -180 and 180 degrees.");
304
+ }
305
+ if (calendar !== "gregorian" && calendar !== "julian") throw new RangeError('calendar must be "gregorian" or "julian".');
306
+ if (country !== void 0 && (typeof country !== "string" || !country.trim())) {
307
+ throw new RangeError("country must be a nonempty string.");
308
+ }
309
+ return { longitude, calendar, country };
310
+ }
311
+ var pad = (value, width = 2) => String(value).padStart(width, "0");
312
+ function resolveLocalToUtc(date, time, timeZone, options) {
313
+ offsetFormatter(timeZone);
314
+ const { longitude, calendar, country } = readOptions(options);
315
+ const written = parseCalendarDate(date, calendar);
316
+ const hhmm = typeof time === "string" ? /^([01]\d|2[0-3]):([0-5]\d)$/u.exec(time) : null;
317
+ if (!written || !hhmm) {
318
+ throw new RangeError(`Local date/time must be a ${calendar === "julian" ? "Julian" : "Gregorian"} date YYYY-MM-DD and a time HH:MM.`);
319
+ }
320
+ const civil = calendar === "julian" ? civilDateOf(julianDayNumber(written, "julian"), "gregorian") : written;
321
+ if (civil.year < 0) throw new RangeError("The Julian date falls before the Gregorian year 0000.");
322
+ const gregorianDate = `${pad(civil.year, 4)}-${pad(civil.month)}-${pad(civil.day)}`;
323
+ const wall = /* @__PURE__ */ new Date(0);
324
+ wall.setUTCFullYear(civil.year, civil.month - 1, civil.day);
325
+ const wallMs = wall.setUTCHours(Number(hhmm[1]), Number(hhmm[2]));
326
+ const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
327
+ if (loaded === void 0 && wallMs < DAY) throw new ZoneHistoryNotLoadedError();
328
+ const history = loaded ?? null;
329
+ const zoneAt = zoneClock(timeZone, history);
330
+ const place = longitude !== void 0 && history ? birthplaceClock(history, wallMs, longitude, zoneAt) : null;
331
+ const samples = [wallMs - PROBE, wallMs, wallMs + PROBE, ...place ? [place.endMs - 1, place.endMs, place.legalFrom] : []];
332
+ const clockAt = place ? place.clockAt : zoneAt;
333
+ const zoneReading = readClock(wallMs, zoneAt, samples);
334
+ const reading = place ? readClock(wallMs, clockAt, samples) : zoneReading;
335
+ const { chosen, kind } = reading;
336
+ const inEra = !!place && chosen.utcMs < place.endMs;
337
+ const count = history && chosen.utcMs < 0 ? typeIndexAt(history, chosen.utcMs) : -1;
338
+ const type = count < 0 ? -1 : history.types[count];
339
+ const shipped = inEra || type >= 0 && history.offsets[type] !== null;
340
+ let applied = reading.at;
341
+ if (applied === null && shipped) {
342
+ const recorded = count > 0 ? history.times[count - 1] : null;
343
+ const marks = place ? [...place.lineEnds, place.endMs, place.legalFrom].filter((at) => at <= chosen.utcMs) : [];
344
+ if (recorded !== null && (!place || recorded >= place.legalFrom)) marks.push(recorded);
345
+ applied = marks.length ? Math.max(...marks) : null;
346
+ }
347
+ let transition = null;
348
+ if (applied !== null) {
349
+ const at = applied;
350
+ const before = clockAt(at - 1);
351
+ const after = clockAt(at);
352
+ const recorded = history && at < 0 ? transitionAt(history, at) : -1;
353
+ transition = {
354
+ at: new Date(at).toISOString(),
355
+ offsetBeforeMinutes: before / 60,
356
+ offsetAfterMinutes: after / 60,
357
+ cause: Math.abs(after - before) >= 43200 ? "date-line" : place && (at === place.endMs || at === place.legalFrom) ? "legal-change" : recorded >= 0 ? history.causes[recorded] : laterCause(timeZone, at)
358
+ };
359
+ }
360
+ const lmt = inEra || !place && history?.zoneEraEnd != null && chosen.utcMs < history.zoneEraEnd;
361
+ const flags = kind ? [kind === "gap" ? "dst-gap" : "dst-fold"] : [];
362
+ if (lmt) flags.push("lmt");
363
+ const localMeanTime = longitude !== void 0 && place && (inEra || kind === "gap" && reading.at === place.endMs) ? { longitude, zoneOffsetMinutes: zoneReading.chosen.offset / 60 } : null;
364
+ const zone = shipped ? {
365
+ source: "tzdb",
366
+ tzdbVersion: TZDB.version,
367
+ dataForm: history.hostLegal ? "main" : "main+backzone",
368
+ abbreviation: inEra ? null : history.abbreviations[type],
369
+ dst: !inEra && history.dst[type]
370
+ } : { source: "intl", tzdbVersion: hostTzdbVersion(), dataForm: "host", abbreviation: null, dst: null };
371
+ const offsetMinutes = chosen.offset / 60;
372
+ return {
373
+ utc: new Date(chosen.utcMs),
374
+ offsetMinutes,
375
+ flags,
376
+ date: gregorianDate,
377
+ writtenDate: date,
378
+ calendar,
379
+ jump: kind && transition ? { kind, cause: transition.cause } : null,
380
+ transition,
381
+ localMeanTime,
382
+ zone,
383
+ intlOffsetMinutes: shipped ? offsetAt(timeZone, chosen.utcMs) : null,
384
+ calendarNote: country === void 0 ? null : noteFor(gregorianDate, calendar, country),
385
+ localResolution: {
386
+ date: gregorianDate,
387
+ time,
388
+ timeZone,
389
+ offsetMinutes,
390
+ gapShiftMinutes: kind === "gap" && transition ? transition.offsetAfterMinutes - transition.offsetBeforeMinutes : 0,
391
+ policy: { fold: "earlier", gap: "shift-forward" },
392
+ calendar,
393
+ writtenDate: date,
394
+ tzdbVersion: zone.tzdbVersion,
395
+ dataForm: zone.dataForm,
396
+ clock: lmt ? "local-mean-time" : "legal",
397
+ transition,
398
+ localMeanTime
399
+ }
400
+ };
401
+ }
402
+ function prepareLocalTime(date, timeZone) {
403
+ try {
404
+ if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/u.test(date)) throw new RangeError("date must be YYYY-MM-DD.");
405
+ offsetFormatter(timeZone);
406
+ } catch (error) {
407
+ return Promise.reject(error);
408
+ }
409
+ return Number(date.slice(0, 4)) > 1970 || FIXED_ZONE.test(timeZone) ? Promise.resolve() : loadHistory(timeZone);
410
+ }
411
+ function zoneOffsetAt(timeZone, utcMilliseconds) {
412
+ validateInstant(utcMilliseconds);
413
+ offsetFormatter(timeZone);
414
+ const loaded = FIXED_ZONE.test(timeZone) ? null : loadedHistory(timeZone);
415
+ if (loaded === void 0 && utcMilliseconds < 0) throw new ZoneHistoryNotLoadedError();
416
+ return zoneClock(timeZone, loaded ?? null)(utcMilliseconds) / 60;
417
+ }
418
+ var ZoneHistoryNotLoadedError = class extends Error {
419
+ name = "ZoneHistoryNotLoadedError";
420
+ constructor() {
421
+ super("The zone's history before 1970 is not loaded: await prepareLocalTime(date, timeZone) first.");
422
+ }
423
+ };
424
+ var LOCAL_BIRTH_KEYS = [
425
+ "date",
426
+ "time",
427
+ "timeZone",
428
+ "latitude",
429
+ "longitude",
430
+ "houseSystem",
431
+ "timeKnown",
432
+ "calendar",
433
+ "country"
434
+ ];
435
+ function resolveLocalBirth(input) {
436
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
437
+ throw new RangeError("birth must be an object containing a local date and timezone.");
438
+ }
439
+ for (const key of Object.getOwnPropertyNames(input)) {
440
+ if (!LOCAL_BIRTH_KEYS.includes(key)) throw new RangeError(`Unknown local birth field "${key}".`);
441
+ }
442
+ const fields = Object.fromEntries(LOCAL_BIRTH_KEYS.map((key) => [key, input[key]]));
443
+ const settings = validateBirthSettings(fields);
444
+ const time = fields.time;
445
+ const timeKnown = settings.timeKnown ?? time !== void 0;
446
+ if (timeKnown && time === void 0) {
447
+ throw new RangeError("time is required when timeKnown is true.");
448
+ }
449
+ const resolution = resolveLocalToUtc(fields.date, time === void 0 ? "12:00" : time, fields.timeZone, {
450
+ longitude: settings.longitude,
451
+ calendar: fields.calendar,
452
+ country: fields.country
453
+ });
454
+ return {
455
+ birth: {
456
+ utc: resolution.utc,
457
+ timeKnown,
458
+ houseSystem: settings.houseSystem ?? "whole",
459
+ flags: resolution.flags,
460
+ ...settings.latitude === void 0 ? {} : { latitude: settings.latitude, longitude: settings.longitude }
461
+ },
462
+ resolution,
463
+ reference: time === void 0 ? "local-noon" : "supplied-instant"
464
+ };
465
+ }
466
+ function resolveBirth(input) {
467
+ return resolveLocalBirth(input).birth;
468
+ }
469
+
470
+ export {
471
+ GREGORIAN_ADOPTION_SOURCES,
472
+ GREGORIAN_ADOPTION,
473
+ gregorianAdoption,
474
+ calendarNote,
475
+ TZDB,
476
+ offsetAt,
477
+ resolveLocalToUtc,
478
+ prepareLocalTime,
479
+ zoneOffsetAt,
480
+ ZoneHistoryNotLoadedError,
481
+ resolveLocalBirth,
482
+ resolveBirth
483
+ };
@@ -1,4 +1,4 @@
1
- import { B as BodyName } from './types-BsWaqwU_.js';
1
+ import { B as BodyName } from './types-B-yb_tGL.js';
2
2
  import './deltat.js';
3
3
 
4
4
  /**
@@ -19,15 +19,16 @@ interface LongitudeCrossing {
19
19
  retrograde: boolean;
20
20
  }
21
21
  /** A longitude source: the ecliptic longitude of `body` at `date`, in degrees. */
22
- type BodyLongitudeAt = (body: BodyName, date: Date) => number;
22
+ type BodyLongitudeAt<B extends string = BodyName> = (body: B, date: Date) => number;
23
+ /** A key not named here is refused with a RangeError. */
23
24
  interface CrossingSearchOptions {
24
25
  /** Days between coarse samples. Defaults to 5. */
25
- stepDays?: number;
26
+ readonly stepDays?: number | undefined;
26
27
  /**
27
28
  * The most longitude evaluations the search may make, refinements
28
29
  * included: a positive integer, or `Infinity`. Defaults to no limit.
29
30
  */
30
- maxSamples?: number;
31
+ readonly maxSamples?: number | undefined;
31
32
  }
32
33
  /**
33
34
  * A search either completes, with every crossing it found, or is refused
@@ -77,7 +78,7 @@ type CrossingSearchResult = {
77
78
  * {@link searchLongitudeCrossingsWith} bounds it. Throws RangeError for an
78
79
  * invalid window, target or step, and for a non-finite longitude.
79
80
  */
80
- declare function findLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body: BodyName, targetLongitude: number, from: Date, to: Date, stepDays?: number): LongitudeCrossing[];
81
+ declare function findLongitudeCrossingsWith<B extends string = BodyName>(longitudeAt: BodyLongitudeAt<B>, body: B, targetLongitude: number, from: Date, to: Date, stepDays?: number): LongitudeCrossing[];
81
82
  /**
82
83
  * The search {@link findLongitudeCrossingsWith} makes, with the step as
83
84
  * `options.stepDays` (default 5), under an optional budget of longitude
@@ -86,6 +87,6 @@ declare function findLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body:
86
87
  * refinement would pass it; either way it returns a typed refusal with no
87
88
  * crossings rather than throwing. Invalid input still throws RangeError.
88
89
  */
89
- declare function searchLongitudeCrossingsWith(longitudeAt: BodyLongitudeAt, body: BodyName, targetLongitude: number, from: Date, to: Date, options?: CrossingSearchOptions): CrossingSearchResult;
90
+ declare function searchLongitudeCrossingsWith<B extends string = BodyName>(longitudeAt: BodyLongitudeAt<B>, body: B, targetLongitude: number, from: Date, to: Date, options?: CrossingSearchOptions): CrossingSearchResult;
90
91
 
91
- export { type BodyLongitudeAt, type CrossingSearchOptions, type CrossingSearchResult, type LongitudeCrossing, findLongitudeCrossingsWith, searchLongitudeCrossingsWith };
92
+ export { type BodyLongitudeAt, BodyName, type CrossingSearchOptions, type CrossingSearchResult, type LongitudeCrossing, findLongitudeCrossingsWith, searchLongitudeCrossingsWith };
package/dist/crossings.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  findLongitudeCrossingsWith,
3
3
  searchLongitudeCrossingsWith
4
- } from "./chunk-AECKV73C.js";
4
+ } from "./chunk-TSS2SZWQ.js";
5
5
  export {
6
6
  findLongitudeCrossingsWith,
7
7
  searchLongitudeCrossingsWith
package/dist/deltat.d.ts CHANGED
@@ -30,6 +30,14 @@
30
30
  * a calibrated 1-σ. Sources, licences and every number:
31
31
  * docs/platform/evidence/deltat-2026-09-25/ in the Zodiacs site repository.
32
32
  */
33
+ /**
34
+ * Where a ΔT came from: one of the model's segments above; "pinned", a
35
+ * caller's pin; or, on the IERS basis ("iers-utc/1", docs/time.md), the source
36
+ * of its UT1 − UTC, "observed" or "predicted". "fallback" is the IERS basis
37
+ * with UT1 − UTC taken as 0 ± 0.9 s past the table's ends, which rc.15's first
38
+ * cut recorded and receipts from it carry; later releases do not give it, and
39
+ * keep it so those records stay readable.
40
+ */
33
41
  type DeltaTSegment = "long-term" | "reconstructed" | "observed" | "predicted" | "extrapolated" | "pinned" | "fallback";
34
42
  /** ΔT with its band and provenance: this model, "iers-utc/1" (docs/time.md), or a caller's pin, whose sigma, table and tableDigest are null. */
35
43
  interface DeltaT {
@@ -43,7 +51,14 @@ interface DeltaT {
43
51
  tableDigest: string | null;
44
52
  segment: DeltaTSegment;
45
53
  }
46
- /** The part of the model refreshed from IERS. It changes only with an engine release. */
54
+ /**
55
+ * The part of the model refreshed from IERS. It changes only with an engine
56
+ * release. Its shape is the model's, "zodiacs-deltat/1": yearly knots to the
57
+ * last observed day, then four to the last predicted one, with `from` a year
58
+ * and the two ends MJDs. A refresh keeps that shape; a model that needs
59
+ * another would be a new model, with a new name and its own export beside
60
+ * this one. Each ΔT names the table it came from (`table`, `tableDigest`).
61
+ */
47
62
  interface DeltaTTable {
48
63
  /** Date of the last observed IERS day (YYYY-MM-DD). */
49
64
  readonly version: string;
@@ -65,9 +80,19 @@ interface DeltaTTable {
65
80
  declare const DELTA_T_MODEL = "zodiacs-deltat/1";
66
81
  /** This release's table: IERS files of 2026-09-24. Frozen. */
67
82
  declare const DELTA_T_TABLE: DeltaTTable;
68
- /** ΔT at astronomy-engine's UT (days since J2000.0), with its band and the part of the model that answered. */
83
+ /**
84
+ * ΔT of the model alone at astronomy-engine's UT, days since 2000-01-01T12:00
85
+ * on UT1 (not epoch milliseconds), with its band and the part of the model
86
+ * that answered. A chart from 1972 to the end of the IERS UT1 table uses IERS
87
+ * instead (`iers-utc/1`; docs/time.md), so its ΔT can differ from this.
88
+ * RangeError for a non-finite input.
89
+ */
69
90
  declare function deltaTAt(ut: number): DeltaT;
70
- /** For astronomy-engine's SetDeltaTFunction: UT days in, seconds out. Allocation-free. */
91
+ /**
92
+ * For astronomy-engine's SetDeltaTFunction: UT days since 2000-01-01T12:00
93
+ * in, the model's seconds out. Allocation-free. RangeError for a non-finite
94
+ * input.
95
+ */
71
96
  declare function deltaT(ut: number): number;
72
97
 
73
98
  export { DELTA_T_MODEL, DELTA_T_TABLE, type DeltaT, type DeltaTSegment, type DeltaTTable, deltaT, deltaTAt };
package/dist/deltat.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DELTA_T_TABLE,
4
4
  deltaT,
5
5
  deltaTAt
6
- } from "./chunk-ONBZ4HK7.js";
6
+ } from "./chunk-BHJXUY67.js";
7
7
  export {
8
8
  DELTA_T_MODEL,
9
9
  DELTA_T_TABLE,