kaabalah 6.15.0 → 6.17.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.
- package/README.md +33 -5
- package/dist/astrology/index.d.mts +3457 -144
- package/dist/astrology/index.d.ts +3457 -144
- package/dist/astrology/index.js +865 -53
- package/dist/astrology/index.mjs +5 -1
- package/dist/{chunk-CFNMEJTR.mjs → chunk-4BKDSA7L.mjs} +625 -166
- package/dist/chunk-4BKDSA7L.mjs.map +1 -0
- package/dist/chunk-4WVN4RMM.mjs +1139 -0
- package/dist/chunk-4WVN4RMM.mjs.map +1 -0
- package/dist/{chunk-NOZKIUGP.mjs → chunk-4ZFY3GBP.mjs} +2296 -1024
- package/dist/chunk-4ZFY3GBP.mjs.map +1 -0
- package/dist/{chunk-OTSJWMWK.mjs → chunk-54QDLBID.mjs} +446 -43
- package/dist/chunk-54QDLBID.mjs.map +1 -0
- package/dist/{chunk-CW6QDSMF.js → chunk-6SBCBVTZ.js} +88 -21
- package/dist/chunk-6SBCBVTZ.js.map +1 -0
- package/dist/{chunk-2WCC2KCJ.js → chunk-BALOSCWQ.mjs} +22 -3
- package/dist/chunk-BALOSCWQ.mjs.map +1 -0
- package/dist/{chunk-ICEVPLT4.mjs → chunk-COEM6U4V.mjs} +2313 -4
- package/dist/chunk-COEM6U4V.mjs.map +1 -0
- package/dist/chunk-DBRPCQRR.mjs +1398 -0
- package/dist/chunk-DBRPCQRR.mjs.map +1 -0
- package/dist/{chunk-XHITSUSQ.js → chunk-DCJYTCJZ.js} +2329 -14
- package/dist/chunk-DCJYTCJZ.js.map +1 -0
- package/dist/{chunk-X5HGLMEF.mjs → chunk-DK2VS36Z.mjs} +770 -3
- package/dist/chunk-DK2VS36Z.mjs.map +1 -0
- package/dist/{chunk-6GDEXIDI.js → chunk-E353GPHE.js} +25 -22
- package/dist/chunk-E353GPHE.js.map +1 -0
- package/dist/chunk-GDJSVV46.js +1413 -0
- package/dist/chunk-GDJSVV46.js.map +1 -0
- package/dist/chunk-ICUDGCYX.js +15 -0
- package/dist/chunk-ICUDGCYX.js.map +1 -0
- package/dist/{chunk-OSMB2MJR.mjs → chunk-IZBM4CPN.mjs} +68 -3
- package/dist/chunk-IZBM4CPN.mjs.map +1 -0
- package/dist/chunk-J3WVI5Y3.mjs +16280 -0
- package/dist/chunk-J3WVI5Y3.mjs.map +1 -0
- package/dist/{chunk-Q7YAKPBH.js → chunk-JFRVH3TD.js} +2296 -1023
- package/dist/chunk-JFRVH3TD.js.map +1 -0
- package/dist/{chunk-URDMOQRN.mjs → chunk-L5EYUE4B.js} +27 -2
- package/dist/chunk-L5EYUE4B.js.map +1 -0
- package/dist/chunk-MZBY6G5S.js +1182 -0
- package/dist/chunk-MZBY6G5S.js.map +1 -0
- package/dist/{chunk-LXJ3THNW.mjs → chunk-NS5AXNEW.mjs} +12 -9
- package/dist/chunk-NS5AXNEW.mjs.map +1 -0
- package/dist/chunk-QU4RKOBD.js +16536 -0
- package/dist/chunk-QU4RKOBD.js.map +1 -0
- package/dist/{chunk-SXARKCYN.js → chunk-UCNBHGIY.js} +566 -158
- package/dist/chunk-UCNBHGIY.js.map +1 -0
- package/dist/chunk-W2N7STO3.mjs +13 -0
- package/dist/chunk-W2N7STO3.mjs.map +1 -0
- package/dist/{chunk-RQLHFFXR.js → chunk-XRSK74V5.js} +644 -185
- package/dist/chunk-XRSK74V5.js.map +1 -0
- package/dist/chunk-YVLKVB6W.js +1600 -0
- package/dist/chunk-YVLKVB6W.js.map +1 -0
- package/dist/cli.js +50087 -23140
- package/dist/cli.js.map +1 -1
- package/dist/core/index.d.mts +24 -1
- package/dist/core/index.d.ts +24 -1
- package/dist/core/index.js +66 -53
- package/dist/core/index.mjs +3 -2
- package/dist/core-B3_-9yli.d.mts +279 -0
- package/dist/core-cWIQtely.d.ts +279 -0
- package/dist/gematria/index.d.mts +153 -1
- package/dist/gematria/index.d.ts +153 -1
- package/dist/gematria/index.js +14 -5
- package/dist/gematria/index.mjs +3 -2
- package/dist/iching/index.d.mts +782 -25
- package/dist/iching/index.d.ts +782 -25
- package/dist/iching/index.js +65 -40
- package/dist/iching/index.mjs +4 -3
- package/dist/ifa/index.d.mts +44 -1
- package/dist/ifa/index.d.ts +44 -1
- package/dist/ifa/index.js +11 -2
- package/dist/ifa/index.mjs +2 -1
- package/dist/index.d.mts +144 -7
- package/dist/index.d.ts +144 -7
- package/dist/index.js +1599 -376
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -10
- package/dist/index.mjs.map +1 -1
- package/dist/numerology/index.d.mts +1296 -240
- package/dist/numerology/index.d.ts +1296 -240
- package/dist/numerology/index.js +113 -23
- package/dist/numerology/index.mjs +5 -3
- package/dist/schedule-types-DsR1_guG.d.mts +200 -0
- package/dist/schedule-types-DsR1_guG.d.ts +200 -0
- package/dist/semantic/index.d.mts +94 -16
- package/dist/semantic/index.d.ts +94 -16
- package/dist/semantic/index.js +57 -35
- package/dist/semantic/index.mjs +9 -7
- package/dist/swisseph.node-734BKSOZ.js +10 -0
- package/dist/swisseph.node-734BKSOZ.js.map +1 -0
- package/dist/swisseph.node-TDPYTBSS.mjs +8 -0
- package/dist/swisseph.node-TDPYTBSS.mjs.map +1 -0
- package/dist/tarot/index.d.mts +9 -4
- package/dist/tarot/index.d.ts +9 -4
- package/dist/tarot/index.js +31 -30
- package/dist/tarot/index.mjs +4 -3
- package/dist/visual/index.d.mts +1 -0
- package/dist/visual/index.d.ts +1 -0
- package/dist/visual/index.js +47 -46
- package/dist/visual/index.mjs +4 -3
- package/dist/wasm/build/swisseph.node-734BKSOZ.js +10 -0
- package/dist/wasm/build/swisseph.node-734BKSOZ.js.map +1 -0
- package/dist/wasm/build/swisseph.node-TDPYTBSS.mjs +8 -0
- package/dist/wasm/build/swisseph.node-TDPYTBSS.mjs.map +1 -0
- package/package.json +10 -4
- package/dist/chunk-2WCC2KCJ.js.map +0 -1
- package/dist/chunk-47BAJUYW.js +0 -830
- package/dist/chunk-47BAJUYW.js.map +0 -1
- package/dist/chunk-6GDEXIDI.js.map +0 -1
- package/dist/chunk-CFNMEJTR.mjs.map +0 -1
- package/dist/chunk-CW6QDSMF.js.map +0 -1
- package/dist/chunk-ICEVPLT4.mjs.map +0 -1
- package/dist/chunk-LXJ3THNW.mjs.map +0 -1
- package/dist/chunk-NOZKIUGP.mjs.map +0 -1
- package/dist/chunk-OSMB2MJR.mjs.map +0 -1
- package/dist/chunk-OTSJWMWK.mjs.map +0 -1
- package/dist/chunk-PEHDLSUH.mjs +0 -2227
- package/dist/chunk-PEHDLSUH.mjs.map +0 -1
- package/dist/chunk-Q7YAKPBH.js.map +0 -1
- package/dist/chunk-RAQDVWNK.mjs +0 -821
- package/dist/chunk-RAQDVWNK.mjs.map +0 -1
- package/dist/chunk-RQLHFFXR.js.map +0 -1
- package/dist/chunk-SWWLTDR6.js +0 -2280
- package/dist/chunk-SWWLTDR6.js.map +0 -1
- package/dist/chunk-SXARKCYN.js.map +0 -1
- package/dist/chunk-UNXDDLZS.js +0 -837
- package/dist/chunk-UNXDDLZS.js.map +0 -1
- package/dist/chunk-URDMOQRN.mjs.map +0 -1
- package/dist/chunk-X5HGLMEF.mjs.map +0 -1
- package/dist/chunk-XHITSUSQ.js.map +0 -1
- package/dist/swisseph.node-53QCJWTI.mjs +0 -3471
- package/dist/swisseph.node-53QCJWTI.mjs.map +0 -1
- package/dist/swisseph.node-CGBZTQ5N.js +0 -3473
- package/dist/swisseph.node-CGBZTQ5N.js.map +0 -1
- package/dist/swisseph.node-GPVFDOB6.wasm +0 -0
- package/dist/wasm/build/swisseph.node-53QCJWTI.mjs +0 -3471
- package/dist/wasm/build/swisseph.node-53QCJWTI.mjs.map +0 -1
- package/dist/wasm/build/swisseph.node-CGBZTQ5N.js +0 -3473
- package/dist/wasm/build/swisseph.node-CGBZTQ5N.js.map +0 -1
- package/dist/wasm/build/swisseph.node-GPVFDOB6.wasm +0 -0
|
@@ -0,0 +1,1139 @@
|
|
|
1
|
+
import { calculateGematria } from './chunk-IZBM4CPN.mjs';
|
|
2
|
+
|
|
3
|
+
// src/civil-date.ts
|
|
4
|
+
var MIN_CIVIL_YEAR = 1;
|
|
5
|
+
var MAX_CIVIL_YEAR = 9999;
|
|
6
|
+
function isLeapYear(year) {
|
|
7
|
+
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
8
|
+
}
|
|
9
|
+
function daysInMonth(year, month) {
|
|
10
|
+
if (month === 2)
|
|
11
|
+
return isLeapYear(year) ? 29 : 28;
|
|
12
|
+
return month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;
|
|
13
|
+
}
|
|
14
|
+
function isValidCivilDate(value) {
|
|
15
|
+
if (value === null || typeof value !== "object")
|
|
16
|
+
return false;
|
|
17
|
+
const { year, month, day } = value;
|
|
18
|
+
return Number.isInteger(year) && Number.isInteger(month) && Number.isInteger(day) && year >= MIN_CIVIL_YEAR && year <= MAX_CIVIL_YEAR && month >= 1 && month <= 12 && day >= 1 && day <= daysInMonth(year, month);
|
|
19
|
+
}
|
|
20
|
+
function civilDate(year, month, day) {
|
|
21
|
+
const value = { year, month, day };
|
|
22
|
+
if (!isValidCivilDate(value)) {
|
|
23
|
+
throw new RangeError(`Invalid civil date: ${year}-${month}-${day}`);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function parseCivilDate(text) {
|
|
28
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
|
|
29
|
+
if (!match)
|
|
30
|
+
return null;
|
|
31
|
+
const value = {
|
|
32
|
+
year: Number.parseInt(match[1], 10),
|
|
33
|
+
month: Number.parseInt(match[2], 10),
|
|
34
|
+
day: Number.parseInt(match[3], 10)
|
|
35
|
+
};
|
|
36
|
+
return isValidCivilDate(value) ? value : null;
|
|
37
|
+
}
|
|
38
|
+
function formatCivilDate(date) {
|
|
39
|
+
const pad = (n, width) => String(n).padStart(width, "0");
|
|
40
|
+
return `${pad(date.year, 4)}-${pad(date.month, 2)}-${pad(date.day, 2)}`;
|
|
41
|
+
}
|
|
42
|
+
function civilDayOrdinal(date) {
|
|
43
|
+
const y = date.month <= 2 ? date.year - 1 : date.year;
|
|
44
|
+
const era = Math.floor(y / 400);
|
|
45
|
+
const yoe = y - era * 400;
|
|
46
|
+
const mp = (date.month + 9) % 12;
|
|
47
|
+
const doy = Math.floor((153 * mp + 2) / 5) + date.day - 1;
|
|
48
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
49
|
+
return era * 146097 + doe - 719468;
|
|
50
|
+
}
|
|
51
|
+
function civilDateFromOrdinal(ordinal) {
|
|
52
|
+
const z = ordinal + 719468;
|
|
53
|
+
const era = Math.floor(z / 146097);
|
|
54
|
+
const doe = z - era * 146097;
|
|
55
|
+
const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
|
|
56
|
+
const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
|
|
57
|
+
const mp = Math.floor((5 * doy + 2) / 153);
|
|
58
|
+
const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
|
|
59
|
+
const month = mp < 10 ? mp + 3 : mp - 9;
|
|
60
|
+
const year = yoe + era * 400 + (month <= 2 ? 1 : 0);
|
|
61
|
+
return { year, month, day };
|
|
62
|
+
}
|
|
63
|
+
function addCivilDays(date, days) {
|
|
64
|
+
return civilDateFromOrdinal(civilDayOrdinal(date) + days);
|
|
65
|
+
}
|
|
66
|
+
function diffCivilDays(a, b) {
|
|
67
|
+
return civilDayOrdinal(b) - civilDayOrdinal(a);
|
|
68
|
+
}
|
|
69
|
+
function compareCivilDates(a, b) {
|
|
70
|
+
return civilDayOrdinal(a) - civilDayOrdinal(b);
|
|
71
|
+
}
|
|
72
|
+
function civilDateFromLocalDate(date) {
|
|
73
|
+
return { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() };
|
|
74
|
+
}
|
|
75
|
+
function civilDateToLocalNoon(date) {
|
|
76
|
+
const result = new Date(2e3, 0, 1, 12, 0, 0, 0);
|
|
77
|
+
result.setFullYear(date.year, date.month - 1, date.day);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function completedYears(from, to) {
|
|
81
|
+
let years = to.year - from.year;
|
|
82
|
+
if (to.month < from.month || to.month === from.month && to.day < from.day) {
|
|
83
|
+
years -= 1;
|
|
84
|
+
}
|
|
85
|
+
return years;
|
|
86
|
+
}
|
|
87
|
+
function anniversaryInYear(birth, year) {
|
|
88
|
+
if (birth.month === 2 && birth.day === 29 && !isLeapYear(year)) {
|
|
89
|
+
return { year, month: 3, day: 1 };
|
|
90
|
+
}
|
|
91
|
+
return { year, month: birth.month, day: birth.day };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/numerology/schedule-types.ts
|
|
95
|
+
var SCHEDULE_METHOD_VERSION = "kaabalah-numerology-schedule/1";
|
|
96
|
+
var MAX_SCHEDULE_YEAR = MAX_CIVIL_YEAR - 1;
|
|
97
|
+
var MAX_TIMELINE_RANGE_DAYS = 36525;
|
|
98
|
+
var MAX_TIMELINE_INTERVALS_HARD_CAP = 1e4;
|
|
99
|
+
var DEFAULT_MAX_TIMELINE_INTERVALS = 2e3;
|
|
100
|
+
var MAX_CANDIDATE_DATES = 366;
|
|
101
|
+
var NumerologyScheduleError = class extends RangeError {
|
|
102
|
+
constructor(code, message) {
|
|
103
|
+
super(message);
|
|
104
|
+
this.name = "NumerologyScheduleError";
|
|
105
|
+
this.code = code;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function unavailable(reason, detail) {
|
|
109
|
+
return { available: false, reason, detail };
|
|
110
|
+
}
|
|
111
|
+
function fmt(date) {
|
|
112
|
+
if (date.year < MIN_CIVIL_YEAR || date.year > MAX_CIVIL_YEAR) {
|
|
113
|
+
throw new NumerologyScheduleError("INVALID_DATE", `Date out of supported range: year ${date.year}`);
|
|
114
|
+
}
|
|
115
|
+
return formatCivilDate(date);
|
|
116
|
+
}
|
|
117
|
+
function resolveCivilDate(input, label = "date") {
|
|
118
|
+
let result;
|
|
119
|
+
if (typeof input === "string") {
|
|
120
|
+
result = parseCivilDate(input);
|
|
121
|
+
if (!result) {
|
|
122
|
+
throw new NumerologyScheduleError(
|
|
123
|
+
"INVALID_DATE",
|
|
124
|
+
`${label} must be a real calendar date formatted YYYY-MM-DD (got ${JSON.stringify(input)})`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
} else if (isValidCivilDate(input)) {
|
|
128
|
+
result = { year: input.year, month: input.month, day: input.day };
|
|
129
|
+
} else {
|
|
130
|
+
throw new NumerologyScheduleError("INVALID_DATE", `${label} is not a valid civil date`);
|
|
131
|
+
}
|
|
132
|
+
if (result.year > MAX_SCHEDULE_YEAR) {
|
|
133
|
+
throw new NumerologyScheduleError("INVALID_DATE", `${label}: years above ${MAX_SCHEDULE_YEAR} are not supported`);
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
function isPartial(input) {
|
|
138
|
+
return typeof input === "object" && input !== null && "kind" in input;
|
|
139
|
+
}
|
|
140
|
+
function normalizeBirth(input) {
|
|
141
|
+
if (input === void 0 || input === null) {
|
|
142
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", 'birth is required (use { kind: "unknown" } for no information)');
|
|
143
|
+
}
|
|
144
|
+
if (!isPartial(input)) {
|
|
145
|
+
return { kind: "full", date: resolveCivilDate(input, "birth date") };
|
|
146
|
+
}
|
|
147
|
+
switch (input.kind) {
|
|
148
|
+
case "full":
|
|
149
|
+
return { kind: "full", date: resolveCivilDate(input.date, "birth date") };
|
|
150
|
+
case "month-day": {
|
|
151
|
+
const { month, day } = input;
|
|
152
|
+
if (!Number.isInteger(month) || !Number.isInteger(day) || month < 1 || month > 12 || day < 1 || day > daysInMonth(2e3, month)) {
|
|
153
|
+
throw new NumerologyScheduleError("INVALID_DATE", `Invalid month/day: ${month}/${day}`);
|
|
154
|
+
}
|
|
155
|
+
return { kind: "month-day", month, day };
|
|
156
|
+
}
|
|
157
|
+
case "year-month": {
|
|
158
|
+
const { year, month } = input;
|
|
159
|
+
assertYear(year);
|
|
160
|
+
if (!Number.isInteger(month) || month < 1 || month > 12) {
|
|
161
|
+
throw new NumerologyScheduleError("INVALID_DATE", `Invalid month: ${month}`);
|
|
162
|
+
}
|
|
163
|
+
return { kind: "year-month", year, month };
|
|
164
|
+
}
|
|
165
|
+
case "year":
|
|
166
|
+
assertYear(input.year);
|
|
167
|
+
return { kind: "year", year: input.year, approximate: input.approximate === true };
|
|
168
|
+
case "unknown":
|
|
169
|
+
return { kind: "unknown" };
|
|
170
|
+
default:
|
|
171
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown birth kind: ${String(input.kind)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function assertYear(year) {
|
|
175
|
+
if (!Number.isInteger(year) || year < MIN_CIVIL_YEAR || year > MAX_SCHEDULE_YEAR) {
|
|
176
|
+
throw new NumerologyScheduleError("INVALID_DATE", `Year must be an integer ${MIN_CIVIL_YEAR}-${MAX_SCHEDULE_YEAR} (got ${year})`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/numerology/core.ts
|
|
181
|
+
function parseDate(date) {
|
|
182
|
+
if (!date) {
|
|
183
|
+
throw new Error("Date is required");
|
|
184
|
+
}
|
|
185
|
+
if (!(date instanceof Date)) {
|
|
186
|
+
throw new Error("Date must be a Date object");
|
|
187
|
+
}
|
|
188
|
+
if (Number.isNaN(date.getTime())) {
|
|
189
|
+
throw new Error("Date must be a valid Date object");
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
day: String(date.getDate()).padStart(2, "0"),
|
|
193
|
+
month: String(date.getMonth() + 1).padStart(2, "0"),
|
|
194
|
+
year: String(date.getFullYear()).padStart(4, "0")
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function mapDatePartsToBlocksOfTwo({
|
|
198
|
+
day,
|
|
199
|
+
month,
|
|
200
|
+
year
|
|
201
|
+
}) {
|
|
202
|
+
return {
|
|
203
|
+
day: day.padStart(2, "0"),
|
|
204
|
+
month: month.padStart(2, "0"),
|
|
205
|
+
year1: year.slice(0, 2),
|
|
206
|
+
year2: year.slice(2)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function digitSum(n) {
|
|
210
|
+
let s = 0;
|
|
211
|
+
for (const ch of String(Math.abs(n))) {
|
|
212
|
+
s += ch.charCodeAt(0) - 48;
|
|
213
|
+
}
|
|
214
|
+
return s;
|
|
215
|
+
}
|
|
216
|
+
var MASTER_NUMBERS = [11, 22, 33, 44];
|
|
217
|
+
function isMasterNumber(n) {
|
|
218
|
+
return MASTER_NUMBERS.includes(n);
|
|
219
|
+
}
|
|
220
|
+
function reduceToSingle(n, options = { preserveMasters: false }) {
|
|
221
|
+
if (n === 0) {
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
let reduced2 = n;
|
|
225
|
+
while (reduced2 > 9) {
|
|
226
|
+
if (options?.preserveMasters && isMasterNumber(reduced2)) {
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
reduced2 = digitSum(reduced2);
|
|
230
|
+
}
|
|
231
|
+
return reduced2;
|
|
232
|
+
}
|
|
233
|
+
function reduceToSingleWithSteps(n, options = { preserveMasters: false }) {
|
|
234
|
+
const steps = [n];
|
|
235
|
+
if (n === 0) {
|
|
236
|
+
return {
|
|
237
|
+
reducedValue: 0,
|
|
238
|
+
reductionSteps: steps
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
let reduced2 = n;
|
|
242
|
+
while (reduced2 > 9) {
|
|
243
|
+
if (options?.preserveMasters && isMasterNumber(reduced2)) {
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
reduced2 = digitSum(reduced2);
|
|
247
|
+
steps.push(reduced2);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
reducedValue: reduced2,
|
|
251
|
+
reductionSteps: steps
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function reduceBlock(block) {
|
|
255
|
+
const n = [...block].reduce(
|
|
256
|
+
(acc, curr) => acc + (curr.charCodeAt(0) - 48),
|
|
257
|
+
0
|
|
258
|
+
);
|
|
259
|
+
if (n === 0) {
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
return reduceToSingle(n);
|
|
263
|
+
}
|
|
264
|
+
function calculateKaabalisticLifePath(birthDate) {
|
|
265
|
+
const { day, month, year1, year2 } = mapDatePartsToBlocksOfTwo(
|
|
266
|
+
parseDate(birthDate)
|
|
267
|
+
);
|
|
268
|
+
const reducedDay = reduceBlock(day);
|
|
269
|
+
const reducedMonth = reduceBlock(month);
|
|
270
|
+
const reducedYear1 = reduceBlock(year1);
|
|
271
|
+
const reducedYear2 = reduceBlock(year2);
|
|
272
|
+
const dayMonthSynthesis = parseInt(`${reducedDay}${reducedMonth}`, 10);
|
|
273
|
+
const yearSynthesis = parseInt(`${reducedYear1}${reducedYear2}`, 10);
|
|
274
|
+
const reducedDayMonthSynthesis = reduceToSingle(dayMonthSynthesis);
|
|
275
|
+
const reducedYearSynthesis = reduceToSingle(yearSynthesis);
|
|
276
|
+
const finalSynthesis = parseInt(
|
|
277
|
+
`${reducedDayMonthSynthesis}${reducedYearSynthesis}`,
|
|
278
|
+
10
|
|
279
|
+
);
|
|
280
|
+
const lifePath = reduceToSingleWithSteps(finalSynthesis, { preserveMasters: true });
|
|
281
|
+
const isMasterLifePath = isMasterNumber(lifePath.reducedValue);
|
|
282
|
+
const personalMythologyNumbers = [
|
|
283
|
+
parseInt(`${dayMonthSynthesis}${yearSynthesis}`, 10),
|
|
284
|
+
finalSynthesis
|
|
285
|
+
];
|
|
286
|
+
if (finalSynthesis !== lifePath.reducedValue) {
|
|
287
|
+
personalMythologyNumbers.push(lifePath.reducedValue);
|
|
288
|
+
}
|
|
289
|
+
const reducedLifePath = reduceToSingle(lifePath.reducedValue);
|
|
290
|
+
if (isMasterLifePath) {
|
|
291
|
+
personalMythologyNumbers.push(reducedLifePath);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
parts: { day, month, year1, year2 },
|
|
295
|
+
reducedParts: { reducedDay, reducedMonth, reducedYear1, reducedYear2 },
|
|
296
|
+
syntheses: {
|
|
297
|
+
dayMonthSynthesis,
|
|
298
|
+
yearSynthesis,
|
|
299
|
+
reducedDayMonthSynthesis,
|
|
300
|
+
reducedYearSynthesis,
|
|
301
|
+
finalSynthesis
|
|
302
|
+
},
|
|
303
|
+
lifePath,
|
|
304
|
+
personalMythologyNumbers
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function calculateStraightAcrossReductionLifePath(birthDate) {
|
|
308
|
+
const { day, month, year } = parseDate(birthDate);
|
|
309
|
+
const result = reduceToSingleWithSteps(
|
|
310
|
+
parseInt(`${day}${month}${year}`, 10),
|
|
311
|
+
{ preserveMasters: true }
|
|
312
|
+
);
|
|
313
|
+
return {
|
|
314
|
+
dayEnergy: reduceToSingleWithSteps(parseInt(day, 10), { preserveMasters: true }),
|
|
315
|
+
monthEnergy: reduceToSingleWithSteps(parseInt(month, 10), { preserveMasters: true }),
|
|
316
|
+
yearEnergy: reduceToSingleWithSteps(parseInt(year, 10), { preserveMasters: true }),
|
|
317
|
+
lifePath: result
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/numerology/life-stages.ts
|
|
322
|
+
var LIFE_STAGE_METHOD_ID = "kaabalah-life-stages/1";
|
|
323
|
+
function reduced(n, masters) {
|
|
324
|
+
const r = reduceToSingleWithSteps(n, { preserveMasters: masters === "preserve" });
|
|
325
|
+
return { value: r.reducedValue, reductionSteps: r.reductionSteps, isMaster: isMasterNumber(r.reducedValue) };
|
|
326
|
+
}
|
|
327
|
+
function computeLifeStages(birth, masters, options = {}) {
|
|
328
|
+
const lifePathMethod = options.lifePathMethod ?? "straight-across";
|
|
329
|
+
const lifePathRule = options.firstPinnacleEndAge === void 0 ? "36-minus-life-path" : "fixed-first-end-age";
|
|
330
|
+
const lifePeriodRule = options.lifePeriodRule ?? "pinnacle-aligned-27";
|
|
331
|
+
if (lifePeriodRule !== "pinnacle-aligned-27" && lifePeriodRule !== "fixed-28-56") {
|
|
332
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown lifePeriodRule: ${String(lifePeriodRule)}`);
|
|
333
|
+
}
|
|
334
|
+
if (lifePathMethod !== "kaabalistic" && lifePathMethod !== "straight-across") {
|
|
335
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown lifePathMethod: ${String(lifePathMethod)}`);
|
|
336
|
+
}
|
|
337
|
+
if (options.firstPinnacleEndAge !== void 0 && (!Number.isInteger(options.firstPinnacleEndAge) || options.firstPinnacleEndAge < 1 || options.firstPinnacleEndAge > 60)) {
|
|
338
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", "firstPinnacleEndAge must be an integer 1-60");
|
|
339
|
+
}
|
|
340
|
+
const noon = civilDateToLocalNoon(birth);
|
|
341
|
+
const lifePathValue = lifePathMethod === "kaabalistic" ? calculateKaabalisticLifePath(noon).lifePath.reducedValue : calculateStraightAcrossReductionLifePath(noon).lifePath.reducedValue;
|
|
342
|
+
const lifePathForTransition = reduceToSingle(lifePathValue);
|
|
343
|
+
const firstEnd = options.firstPinnacleEndAge ?? 36 - lifePathForTransition;
|
|
344
|
+
const m = reduceToSingle(birth.month);
|
|
345
|
+
const d = reduceToSingle(birth.day);
|
|
346
|
+
const y = reduceToSingle(birth.year);
|
|
347
|
+
const dated = (age) => birth.year + age > MAX_CIVIL_YEAR ? null : anniversaryInYear(birth, birth.year + age);
|
|
348
|
+
const span = (index, startAge, endAge) => {
|
|
349
|
+
const start = dated(startAge);
|
|
350
|
+
const end = endAge === null ? null : dated(endAge);
|
|
351
|
+
return {
|
|
352
|
+
index,
|
|
353
|
+
startAge,
|
|
354
|
+
endAgeExclusive: endAge,
|
|
355
|
+
start,
|
|
356
|
+
nominalEndExclusive: end,
|
|
357
|
+
...start === null ? { startBeyondCalendar: true } : {},
|
|
358
|
+
...endAge !== null && end === null ? { nominalEndBeyondCalendar: true } : {}
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
const edges = [0, firstEnd, firstEnd + 9, firstEnd + 18];
|
|
362
|
+
const spans = edges.map((age, i) => span(i + 1, age, i < 3 ? edges[i + 1] : null));
|
|
363
|
+
const p1 = reduced(m + d, masters);
|
|
364
|
+
const p2 = reduced(d + y, masters);
|
|
365
|
+
const pinnacleValues = [p1, p2, reduced(p1.value + p2.value, masters), reduced(m + y, masters)];
|
|
366
|
+
const pinnacles = spans.map((s, i) => ({ ...s, value: pinnacleValues[i] }));
|
|
367
|
+
const c1 = Math.abs(m - d);
|
|
368
|
+
const c2 = Math.abs(d - y);
|
|
369
|
+
const challengeValues = [c1, c2, Math.abs(c1 - c2), Math.abs(m - y)];
|
|
370
|
+
const challenges = spans.map((s, i) => ({ ...s, value: challengeValues[i], isMain: i === 2 }));
|
|
371
|
+
const periodEdges = lifePeriodRule === "fixed-28-56" ? [0, 28, 56] : [0, firstEnd, firstEnd + 27];
|
|
372
|
+
const bases = ["month", "day", "year"];
|
|
373
|
+
const baseValues = [birth.month, birth.day, birth.year];
|
|
374
|
+
const lifePeriods = periodEdges.map((age, i) => ({
|
|
375
|
+
...span(i + 1, age, i < 2 ? periodEdges[i + 1] : null),
|
|
376
|
+
basis: bases[i],
|
|
377
|
+
value: reduced(baseValues[i], masters)
|
|
378
|
+
}));
|
|
379
|
+
return {
|
|
380
|
+
convention: LIFE_STAGE_METHOD_ID,
|
|
381
|
+
lifePathMethod,
|
|
382
|
+
lifePathForTransition,
|
|
383
|
+
transitionRule: lifePathRule,
|
|
384
|
+
firstPinnacleEndAge: firstEnd,
|
|
385
|
+
lifePeriodRule,
|
|
386
|
+
masterPolicy: masters,
|
|
387
|
+
components: { month: m, day: d, year: y },
|
|
388
|
+
pinnacles,
|
|
389
|
+
challenges,
|
|
390
|
+
lifePeriods
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/numerology/schedule.ts
|
|
395
|
+
var TIMELINE_LAYERS = [
|
|
396
|
+
"personal-year",
|
|
397
|
+
"personal-month",
|
|
398
|
+
"personal-period",
|
|
399
|
+
"heptad",
|
|
400
|
+
"age-cycle",
|
|
401
|
+
"fibonacci",
|
|
402
|
+
"calendar-year",
|
|
403
|
+
"calendar-month",
|
|
404
|
+
"calendar-day",
|
|
405
|
+
"pinnacle",
|
|
406
|
+
"challenge",
|
|
407
|
+
"life-period"
|
|
408
|
+
];
|
|
409
|
+
var MASTER_SET = new Set(MASTER_NUMBERS);
|
|
410
|
+
function red(ctx, n) {
|
|
411
|
+
const r = reduceToSingleWithSteps(n, { preserveMasters: ctx.masters === "preserve" });
|
|
412
|
+
return { value: r.reducedValue, reductionSteps: r.reductionSteps, isMaster: MASTER_SET.has(r.reducedValue) };
|
|
413
|
+
}
|
|
414
|
+
function wrapMonth(month) {
|
|
415
|
+
return ((month - 1) % 12 + 12) % 12 + 1;
|
|
416
|
+
}
|
|
417
|
+
function nameToken(raw, kind) {
|
|
418
|
+
const trimmed = raw.trim().replace(/\s+/g, " ");
|
|
419
|
+
return kind === "first-token" ? trimmed.split(" ")[0] ?? "" : trimmed;
|
|
420
|
+
}
|
|
421
|
+
function resolveSoul(firstName, kind) {
|
|
422
|
+
if (firstName === void 0 || firstName === null || typeof firstName !== "string" || firstName.trim() === "") {
|
|
423
|
+
return unavailable("first-name-missing", "No first name supplied; the soul number (personal period 3) is not computed.");
|
|
424
|
+
}
|
|
425
|
+
const used = nameToken(firstName, kind);
|
|
426
|
+
const vowels = calculateGematria(used).vowels;
|
|
427
|
+
if (vowels.originalSum === 0 || vowels.finalValue === 0) {
|
|
428
|
+
return unavailable("first-name-has-no-vowels", "The supplied name has no vowels recognised by the gematria mapping; soul number not computed.");
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
available: true,
|
|
432
|
+
value: vowels.finalValue,
|
|
433
|
+
reductionSteps: vowels.reductionSteps,
|
|
434
|
+
isMaster: false
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function resolveLifePath(full, method, masters, birthKind) {
|
|
438
|
+
if (!full) {
|
|
439
|
+
return unavailable(
|
|
440
|
+
birthKind === "unknown" ? "birth-date-unknown" : birthKind === "month-day" ? "birth-year-unknown" : "birth-day-or-month-unknown",
|
|
441
|
+
"The life path needs the full birth date (day, month and year)."
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
const noon = civilDateToLocalNoon(full);
|
|
445
|
+
const base = method === "kaabalistic" ? calculateKaabalisticLifePath(noon).lifePath : calculateStraightAcrossReductionLifePath(noon).lifePath;
|
|
446
|
+
const r = masters === "preserve" ? base : reduceToSingleWithSteps(base.reducedValue);
|
|
447
|
+
return {
|
|
448
|
+
available: true,
|
|
449
|
+
method,
|
|
450
|
+
value: r.reducedValue,
|
|
451
|
+
reductionSteps: [...r.reductionSteps],
|
|
452
|
+
isMaster: MASTER_SET.has(r.reducedValue)
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function buildMetadata(input, masters, lifePathMethod, nameKind, policy, death, horizon, stages) {
|
|
456
|
+
const methods = {
|
|
457
|
+
"personal-year": {
|
|
458
|
+
id: "birthday-personal-year/v1",
|
|
459
|
+
formula: "reduce(birthDay + birthMonth + birthdayYear); birthdayYear = year of the most recent birthday; masters per policy"
|
|
460
|
+
},
|
|
461
|
+
"personal-month": {
|
|
462
|
+
id: "birthday-personal-month/v1",
|
|
463
|
+
formula: "reduce(personalYear.value + calendarMonthLabel); label = wrap(birthMonth + phase - 1); phase k starts on the birth day of month label k (see shortMonthPolicy)"
|
|
464
|
+
},
|
|
465
|
+
"personal-period": {
|
|
466
|
+
id: "birthday-personal-period/v1",
|
|
467
|
+
formula: "four months each; 1: reduce(birthdayYear + completedAge); 2: reduce(birthdayYear + lifePath); 3: reduce(birthdayYear + firstNameVowelSoulNumber); masters per policy"
|
|
468
|
+
},
|
|
469
|
+
heptad: {
|
|
470
|
+
id: "fixed-52-day-heptad/v1",
|
|
471
|
+
formula: "six 52-day segments from the birthday; segment 7 runs to the next birthday (53/54 days); civil day counts"
|
|
472
|
+
},
|
|
473
|
+
"age-cycle": {
|
|
474
|
+
id: "seven-year-age-cycle/v1",
|
|
475
|
+
formula: "block = floor(completedAge / 7); label = block % 7 + 1; yearPosition = completedAge % 7 + 1; blocks start on the birthday"
|
|
476
|
+
},
|
|
477
|
+
fibonacci: {
|
|
478
|
+
id: "fibonacci-completed-age/v1",
|
|
479
|
+
formula: "c1 = reduce(age); c2 = reduce(c1 + 2); c3 = reduce(c1 + c2.rawSum); c(n) = reduce(c(n-2).rawSum + c(n-1).rawSum); single-digit, masters not preserved; age = completed age"
|
|
480
|
+
},
|
|
481
|
+
"calendar-year": {
|
|
482
|
+
id: "calendar-personal-year-month-day/v1",
|
|
483
|
+
formula: "calendarPY = reduce(birthDay + birthMonth + calendarYear)"
|
|
484
|
+
},
|
|
485
|
+
"calendar-month": {
|
|
486
|
+
id: "calendar-personal-year-month-day/v1",
|
|
487
|
+
formula: "calendarPM = reduce(calendarPY.value + calendarMonth)"
|
|
488
|
+
},
|
|
489
|
+
"calendar-day": {
|
|
490
|
+
id: "calendar-personal-year-month-day/v1",
|
|
491
|
+
formula: "calendarPD = reduce(calendarPM.value + calendarDay). Chosen convention (the library has no personal-day calculator); distinct from the birthday frame"
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
for (const layer of ["pinnacle", "challenge", "life-period"]) {
|
|
495
|
+
methods[layer] = {
|
|
496
|
+
id: LIFE_STAGE_METHOD_ID,
|
|
497
|
+
formula: stages ? `first span ends at age ${stages.firstPinnacleEndAge} (${stages.transitionRule}); see life-stages.ts for the full convention` : "36 - single-digit life path for the first pinnacle end; requires the full birth date"
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
const deathText = death ? fmt(death) : null;
|
|
501
|
+
return {
|
|
502
|
+
methodVersion: SCHEDULE_METHOD_VERSION,
|
|
503
|
+
dateModel: "civil proleptic-Gregorian dates, no timezone; intervals are half-open [start, endExclusive); 29 February birthdays fall on 1 March in common years",
|
|
504
|
+
lifePathMethod,
|
|
505
|
+
lifePathMethodDescription: lifePathMethod === "kaabalistic" ? "kaabalistic concatenation of reduced two-digit blocks (calculateKaabalisticLifePath)" : "straight digit-sum of DDMMYYYY (calculateStraightAcrossReductionLifePath)",
|
|
506
|
+
masterPolicy: masters,
|
|
507
|
+
masterNumbers: [...MASTER_NUMBERS],
|
|
508
|
+
fibonacciReduction: "single digit, master numbers never preserved (unchanged legacy behaviour)",
|
|
509
|
+
nameInput: {
|
|
510
|
+
kind: nameKind,
|
|
511
|
+
provided: typeof input.firstName === "string" && input.firstName.trim() !== "",
|
|
512
|
+
rule: nameKind === "first-token" ? "first whitespace-delimited token of the supplied name" : nameKind === "given-name" ? "the supplied string is the given name (all words used)" : "the supplied string is the full name (all words used)"
|
|
513
|
+
},
|
|
514
|
+
gematria: "kaabalah gematria vowel sum (calculateGematria(...).vowels); diacritic mappings (e.g. \xC3, \xC7) unchanged",
|
|
515
|
+
shortMonthPolicy: policy,
|
|
516
|
+
limits: {
|
|
517
|
+
death: deathText,
|
|
518
|
+
horizonEndExclusive: horizon ? fmt(horizon) : null,
|
|
519
|
+
deathNote: death ? "Coverage ends after the supplied death date (inclusive)." : "No death date supplied. This is NOT evidence of survival; nothing is inferred and no end is imposed."
|
|
520
|
+
},
|
|
521
|
+
methods,
|
|
522
|
+
notes: [
|
|
523
|
+
"Phase numbers (month/period/heptad positions) are separate from reduced values.",
|
|
524
|
+
"Pinnacle, challenge and life-period conventions are named choices, not universal rules."
|
|
525
|
+
]
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function buildCtx(input) {
|
|
529
|
+
if (typeof input !== "object" || input === null) {
|
|
530
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", "A schedule input object is required");
|
|
531
|
+
}
|
|
532
|
+
const birth = normalizeBirth(input.birth);
|
|
533
|
+
const masters = input.masters ?? "preserve";
|
|
534
|
+
const lifePathMethod = input.lifePathMethod ?? "kaabalistic";
|
|
535
|
+
const nameKind = input.nameKind ?? "first-token";
|
|
536
|
+
const policy = input.shortMonthPolicy ?? "next-month-first";
|
|
537
|
+
if (masters !== "preserve" && masters !== "reduce") {
|
|
538
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown masters policy: ${String(masters)}`);
|
|
539
|
+
}
|
|
540
|
+
if (lifePathMethod !== "kaabalistic" && lifePathMethod !== "straight-across") {
|
|
541
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown lifePathMethod: ${String(lifePathMethod)}`);
|
|
542
|
+
}
|
|
543
|
+
if (nameKind !== "first-token" && nameKind !== "given-name" && nameKind !== "full-name") {
|
|
544
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown nameKind: ${String(nameKind)}`);
|
|
545
|
+
}
|
|
546
|
+
if (policy !== "next-month-first" && policy !== "clamp" && policy !== "overflow") {
|
|
547
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown shortMonthPolicy: ${String(policy)}`);
|
|
548
|
+
}
|
|
549
|
+
const full = birth.kind === "full" ? birth.date : null;
|
|
550
|
+
const anchor = birth.kind === "full" ? { month: birth.date.month, day: birth.date.day, year: birth.date.year } : birth.kind === "month-day" ? { month: birth.month, day: birth.day, year: null } : null;
|
|
551
|
+
const death = input.limits?.death ? resolveCivilDate(input.limits.death, "death date") : null;
|
|
552
|
+
const horizon = input.limits?.horizonEndExclusive ? resolveCivilDate(input.limits.horizonEndExclusive, "horizonEndExclusive") : null;
|
|
553
|
+
if (full && death && compareCivilDates(death, full) < 0) {
|
|
554
|
+
throw new NumerologyScheduleError("INVALID_RANGE", "Death date is before the birth date");
|
|
555
|
+
}
|
|
556
|
+
let coverageEnd = null;
|
|
557
|
+
if (death)
|
|
558
|
+
coverageEnd = addCivilDays(death, 1);
|
|
559
|
+
if (horizon && (!coverageEnd || compareCivilDates(horizon, coverageEnd) < 0))
|
|
560
|
+
coverageEnd = horizon;
|
|
561
|
+
const stages = full ? computeLifeStages(full, masters, input.lifeStages) : null;
|
|
562
|
+
return {
|
|
563
|
+
input,
|
|
564
|
+
birth,
|
|
565
|
+
full,
|
|
566
|
+
anchor,
|
|
567
|
+
masters,
|
|
568
|
+
lifePathMethod,
|
|
569
|
+
nameKind,
|
|
570
|
+
policy,
|
|
571
|
+
soul: resolveSoul(input.firstName, nameKind),
|
|
572
|
+
lifePath: resolveLifePath(full, lifePathMethod, masters, birth.kind),
|
|
573
|
+
death,
|
|
574
|
+
horizon,
|
|
575
|
+
coverageStart: full,
|
|
576
|
+
coverageEnd,
|
|
577
|
+
meta: buildMetadata(input, masters, lifePathMethod, nameKind, policy, death, horizon, stages),
|
|
578
|
+
stages
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function getNumerologyMethodMetadata(options = {}) {
|
|
582
|
+
return buildCtx({ ...options, birth: options.birth ?? { kind: "unknown" } }).meta;
|
|
583
|
+
}
|
|
584
|
+
function mkInterval(ctx, nominalStart, nominalEndInput, endBeyondCalendar = false) {
|
|
585
|
+
if (nominalStart.year > MAX_CIVIL_YEAR)
|
|
586
|
+
return null;
|
|
587
|
+
let nominalEnd = nominalEndInput;
|
|
588
|
+
let beyond = endBeyondCalendar;
|
|
589
|
+
if (nominalEnd && nominalEnd.year > MAX_CIVIL_YEAR) {
|
|
590
|
+
nominalEnd = null;
|
|
591
|
+
beyond = true;
|
|
592
|
+
}
|
|
593
|
+
let start = nominalStart;
|
|
594
|
+
let startClipped = false;
|
|
595
|
+
if (ctx.coverageStart && compareCivilDates(start, ctx.coverageStart) < 0) {
|
|
596
|
+
start = ctx.coverageStart;
|
|
597
|
+
startClipped = true;
|
|
598
|
+
}
|
|
599
|
+
let end = nominalEnd;
|
|
600
|
+
let endClipped = false;
|
|
601
|
+
if (ctx.coverageEnd && (end === null || compareCivilDates(end, ctx.coverageEnd) > 0)) {
|
|
602
|
+
end = ctx.coverageEnd;
|
|
603
|
+
endClipped = true;
|
|
604
|
+
}
|
|
605
|
+
if (end !== null && compareCivilDates(start, end) >= 0)
|
|
606
|
+
return null;
|
|
607
|
+
return {
|
|
608
|
+
start: fmt(start),
|
|
609
|
+
endExclusive: end ? fmt(end) : null,
|
|
610
|
+
nominalStart: fmt(nominalStart),
|
|
611
|
+
nominalEndExclusive: nominalEnd ? fmt(nominalEnd) : null,
|
|
612
|
+
...beyond ? { nominalEndBeyondCalendar: true } : {},
|
|
613
|
+
startClipped,
|
|
614
|
+
endClipped,
|
|
615
|
+
clipped: startClipped || endClipped,
|
|
616
|
+
lengthDays: end ? diffCivilDays(start, end) : null,
|
|
617
|
+
nominalLengthDays: nominalEnd ? diffCivilDays(nominalStart, nominalEnd) : null
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function contains(iv, iso) {
|
|
621
|
+
return iv.start <= iso && (iv.endExclusive === null || iso < iv.endExclusive);
|
|
622
|
+
}
|
|
623
|
+
function overlaps(iv, from, toExclusive) {
|
|
624
|
+
return iv.start < toExclusive && (iv.endExclusive === null || iv.endExclusive > from);
|
|
625
|
+
}
|
|
626
|
+
function monthBoundary(anchor, y, j, policy) {
|
|
627
|
+
const absolute = y * 12 + (anchor.month - 1) + j;
|
|
628
|
+
const yy = Math.floor(absolute / 12);
|
|
629
|
+
const mm = absolute % 12 + 1;
|
|
630
|
+
const dim = daysInMonth(yy, mm);
|
|
631
|
+
const nominalText = `${String(yy).padStart(4, "0")}-${String(mm).padStart(2, "0")}-${String(anchor.day).padStart(2, "0")}`;
|
|
632
|
+
if (anchor.day <= dim)
|
|
633
|
+
return { date: { year: yy, month: mm, day: anchor.day }, adjusted: false, nominalText };
|
|
634
|
+
switch (policy) {
|
|
635
|
+
case "clamp":
|
|
636
|
+
return { date: { year: yy, month: mm, day: dim }, adjusted: true, nominalText };
|
|
637
|
+
case "overflow":
|
|
638
|
+
return { date: addCivilDays({ year: yy, month: mm, day: 1 }, anchor.day - 1), adjusted: true, nominalText };
|
|
639
|
+
default:
|
|
640
|
+
return { date: addCivilDays({ year: yy, month: mm, day: dim }, 1), adjusted: true, nominalText };
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function ageCycleRef(completedAge) {
|
|
644
|
+
if (completedAge === null || completedAge < 0)
|
|
645
|
+
return null;
|
|
646
|
+
const block = Math.floor(completedAge / 7);
|
|
647
|
+
return { label: block % 7 + 1, absoluteIndex: block, yearPosition: completedAge % 7 + 1 };
|
|
648
|
+
}
|
|
649
|
+
function fibonacciValues(age) {
|
|
650
|
+
const s1 = reduceToSingleWithSteps(age);
|
|
651
|
+
const s2 = reduceToSingleWithSteps(s1.reducedValue + 2);
|
|
652
|
+
const s3 = reduceToSingleWithSteps(s1.reducedValue + s2.reductionSteps[0]);
|
|
653
|
+
const s4 = reduceToSingleWithSteps(s2.reductionSteps[0] + s3.reductionSteps[0]);
|
|
654
|
+
const s5 = reduceToSingleWithSteps(s3.reductionSteps[0] + s4.reductionSteps[0]);
|
|
655
|
+
const s6 = reduceToSingleWithSteps(s4.reductionSteps[0] + s5.reductionSteps[0]);
|
|
656
|
+
const s7 = reduceToSingleWithSteps(s5.reductionSteps[0] + s6.reductionSteps[0]);
|
|
657
|
+
return [s1, s2, s3, s4, s5, s6, s7].map((s, i) => ({
|
|
658
|
+
phase: i + 1,
|
|
659
|
+
value: s.reducedValue,
|
|
660
|
+
reductionSteps: s.reductionSteps
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
function buildYearRow(ctx, y) {
|
|
664
|
+
const anchor = ctx.anchor;
|
|
665
|
+
if (!anchor)
|
|
666
|
+
return null;
|
|
667
|
+
const start = anniversaryInYear({ month: anchor.month, day: anchor.day }, y);
|
|
668
|
+
const nominalEnd = anniversaryInYear({ month: anchor.month, day: anchor.day }, y + 1);
|
|
669
|
+
const yearBase = mkInterval(ctx, start, nominalEnd);
|
|
670
|
+
if (!yearBase)
|
|
671
|
+
return null;
|
|
672
|
+
const completedAge = ctx.full ? y - ctx.full.year : null;
|
|
673
|
+
const personalYearValue = red(ctx, anchor.day + anchor.month + y);
|
|
674
|
+
const personalYear = {
|
|
675
|
+
layer: "personal-year",
|
|
676
|
+
...yearBase,
|
|
677
|
+
birthdayYear: y,
|
|
678
|
+
completedAge,
|
|
679
|
+
personalYear: personalYearValue,
|
|
680
|
+
ageCycle: ageCycleRef(completedAge)
|
|
681
|
+
};
|
|
682
|
+
const bounds = [];
|
|
683
|
+
const adjusted = [];
|
|
684
|
+
const nominalTexts = [];
|
|
685
|
+
for (let j = 0; j <= 12; j++) {
|
|
686
|
+
if (j === 0) {
|
|
687
|
+
bounds.push(start);
|
|
688
|
+
adjusted.push(false);
|
|
689
|
+
nominalTexts.push(fmt(start));
|
|
690
|
+
} else if (j === 12) {
|
|
691
|
+
bounds.push(nominalEnd);
|
|
692
|
+
adjusted.push(false);
|
|
693
|
+
nominalTexts.push(fmt(nominalEnd));
|
|
694
|
+
} else {
|
|
695
|
+
const b = monthBoundary(anchor, y, j, ctx.policy);
|
|
696
|
+
bounds.push(b.date);
|
|
697
|
+
adjusted.push(b.adjusted);
|
|
698
|
+
nominalTexts.push(b.nominalText);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
const months = [];
|
|
702
|
+
for (let k = 0; k < 12; k++) {
|
|
703
|
+
const iv = mkInterval(ctx, bounds[k], bounds[k + 1]);
|
|
704
|
+
if (!iv)
|
|
705
|
+
continue;
|
|
706
|
+
const label = wrapMonth(anchor.month + k);
|
|
707
|
+
months.push({
|
|
708
|
+
layer: "personal-month",
|
|
709
|
+
...iv,
|
|
710
|
+
birthdayYear: y,
|
|
711
|
+
phase: k + 1,
|
|
712
|
+
calendarMonth: label,
|
|
713
|
+
intendedBirthDay: anchor.day,
|
|
714
|
+
value: red(ctx, personalYearValue.value + label),
|
|
715
|
+
startAdjusted: adjusted[k],
|
|
716
|
+
nominalStartText: nominalTexts[k],
|
|
717
|
+
shortMonthPolicy: ctx.policy
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
const periods = [];
|
|
721
|
+
for (let p = 0; p < 3; p++) {
|
|
722
|
+
const iv = mkInterval(ctx, bounds[p * 4], bounds[p * 4 + 4]);
|
|
723
|
+
if (!iv)
|
|
724
|
+
continue;
|
|
725
|
+
let value;
|
|
726
|
+
if (p === 0) {
|
|
727
|
+
value = completedAge === null ? unavailable("birth-year-unknown", "Period 1 needs the completed age, which needs the full birth date.") : { available: true, ...red(ctx, y + completedAge), addend: completedAge, addendSource: "completed-age" };
|
|
728
|
+
} else if (p === 1) {
|
|
729
|
+
value = ctx.lifePath.available ? { available: true, ...red(ctx, y + ctx.lifePath.value), addend: ctx.lifePath.value, addendSource: "life-path" } : unavailable(ctx.lifePath.reason, "Period 2 needs the life path, which needs the full birth date.");
|
|
730
|
+
} else {
|
|
731
|
+
value = ctx.soul.available ? { available: true, ...red(ctx, y + ctx.soul.value), addend: ctx.soul.value, addendSource: "first-name-soul-number" } : ctx.soul;
|
|
732
|
+
}
|
|
733
|
+
periods.push({
|
|
734
|
+
layer: "personal-period",
|
|
735
|
+
...iv,
|
|
736
|
+
birthdayYear: y,
|
|
737
|
+
phase: p + 1,
|
|
738
|
+
monthPhases: [p * 4 + 1, p * 4 + 4],
|
|
739
|
+
startCalendarMonth: wrapMonth(anchor.month + p * 4),
|
|
740
|
+
endCalendarMonth: wrapMonth(anchor.month + p * 4 + 3),
|
|
741
|
+
value
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
const heptads = [];
|
|
745
|
+
for (let h = 0; h < 7; h++) {
|
|
746
|
+
const hs = addCivilDays(start, h * 52);
|
|
747
|
+
const he = h < 6 ? addCivilDays(start, (h + 1) * 52) : nominalEnd;
|
|
748
|
+
const iv = mkInterval(ctx, hs, he);
|
|
749
|
+
if (!iv)
|
|
750
|
+
continue;
|
|
751
|
+
heptads.push({ layer: "heptad", ...iv, birthdayYear: y, phase: h + 1, isRemainder: h === 6 });
|
|
752
|
+
}
|
|
753
|
+
const fibonacci = completedAge !== null && completedAge >= 0 ? { layer: "fibonacci", ...yearBase, birthdayYear: y, completedAge, cycles: fibonacciValues(completedAge) } : null;
|
|
754
|
+
return { year: y, personalYear, months, periods, heptads, fibonacci };
|
|
755
|
+
}
|
|
756
|
+
function birthdayYearOf(ctx, date) {
|
|
757
|
+
const a = ctx.anchor;
|
|
758
|
+
if (!a)
|
|
759
|
+
return null;
|
|
760
|
+
const anniv = anniversaryInYear({ month: a.month, day: a.day }, date.year);
|
|
761
|
+
const y = compareCivilDates(anniv, date) <= 0 ? date.year : date.year - 1;
|
|
762
|
+
if (ctx.full && y < ctx.full.year)
|
|
763
|
+
return null;
|
|
764
|
+
if (y < 1)
|
|
765
|
+
return null;
|
|
766
|
+
return y;
|
|
767
|
+
}
|
|
768
|
+
function calendarYearValue(ctx, year) {
|
|
769
|
+
return red(ctx, ctx.anchor.day + ctx.anchor.month + year);
|
|
770
|
+
}
|
|
771
|
+
function calendarYearInterval(ctx, year) {
|
|
772
|
+
const iv = mkInterval(ctx, { year, month: 1, day: 1 }, { year: year + 1, month: 1, day: 1 });
|
|
773
|
+
return iv ? { layer: "calendar-year", ...iv, year, personalYear: calendarYearValue(ctx, year) } : null;
|
|
774
|
+
}
|
|
775
|
+
function calendarMonthInterval(ctx, year, month) {
|
|
776
|
+
const next = month === 12 ? { year: year + 1, month: 1, day: 1 } : { year, month: month + 1, day: 1 };
|
|
777
|
+
const iv = mkInterval(ctx, { year, month, day: 1 }, next);
|
|
778
|
+
if (!iv)
|
|
779
|
+
return null;
|
|
780
|
+
const py = calendarYearValue(ctx, year);
|
|
781
|
+
return { layer: "calendar-month", ...iv, year, month, personalYear: py, personalMonth: red(ctx, py.value + month) };
|
|
782
|
+
}
|
|
783
|
+
function calendarDayInterval(ctx, date) {
|
|
784
|
+
const iv = mkInterval(ctx, date, addCivilDays(date, 1));
|
|
785
|
+
if (!iv)
|
|
786
|
+
return null;
|
|
787
|
+
const py = calendarYearValue(ctx, date.year);
|
|
788
|
+
const pm = red(ctx, py.value + date.month);
|
|
789
|
+
return { layer: "calendar-day", ...iv, date: fmt(date), personalYear: py, personalMonth: pm, personalDay: red(ctx, pm.value + date.day) };
|
|
790
|
+
}
|
|
791
|
+
function ageCycleInterval(ctx, block) {
|
|
792
|
+
const birth = ctx.full;
|
|
793
|
+
const iv = mkInterval(ctx, anniversaryInYear(birth, birth.year + block * 7), anniversaryInYear(birth, birth.year + block * 7 + 7));
|
|
794
|
+
return iv ? { layer: "age-cycle", ...iv, label: block % 7 + 1, absoluteIndex: block, startAge: block * 7, endAgeExclusive: block * 7 + 7 } : null;
|
|
795
|
+
}
|
|
796
|
+
function stageIntervals(ctx) {
|
|
797
|
+
const s = ctx.stages;
|
|
798
|
+
const pinnacles = [];
|
|
799
|
+
const challenges = [];
|
|
800
|
+
const lifePeriods = [];
|
|
801
|
+
const skipped = [];
|
|
802
|
+
const make = (layer, p) => {
|
|
803
|
+
if (p.start === null) {
|
|
804
|
+
skipped.push({
|
|
805
|
+
field: `${layer}.${p.index}`,
|
|
806
|
+
reason: "beyond-supported-calendar",
|
|
807
|
+
detail: `Starts at age ${p.startAge}, after the last supported calendar year (${MAX_CIVIL_YEAR}).`
|
|
808
|
+
});
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
return mkInterval(ctx, p.start, p.nominalEndExclusive, p.nominalEndBeyondCalendar === true);
|
|
812
|
+
};
|
|
813
|
+
for (const p of s.pinnacles) {
|
|
814
|
+
const iv = make("pinnacle", p);
|
|
815
|
+
if (iv)
|
|
816
|
+
pinnacles.push({ layer: "pinnacle", ...iv, index: p.index, startAge: p.startAge, endAgeExclusive: p.endAgeExclusive, value: p.value });
|
|
817
|
+
}
|
|
818
|
+
for (const c of s.challenges) {
|
|
819
|
+
const iv = make("challenge", c);
|
|
820
|
+
if (iv)
|
|
821
|
+
challenges.push({ layer: "challenge", ...iv, index: c.index, isMain: c.isMain, startAge: c.startAge, endAgeExclusive: c.endAgeExclusive, value: c.value });
|
|
822
|
+
}
|
|
823
|
+
for (const l of s.lifePeriods) {
|
|
824
|
+
const iv = make("life-period", l);
|
|
825
|
+
if (iv)
|
|
826
|
+
lifePeriods.push({ layer: "life-period", ...iv, index: l.index, basis: l.basis, startAge: l.startAge, endAgeExclusive: l.endAgeExclusive, value: l.value });
|
|
827
|
+
}
|
|
828
|
+
return { pinnacles, challenges, lifePeriods, skipped };
|
|
829
|
+
}
|
|
830
|
+
function birthSummary(birth) {
|
|
831
|
+
switch (birth.kind) {
|
|
832
|
+
case "full":
|
|
833
|
+
return { kind: "full", date: fmt(birth.date) };
|
|
834
|
+
case "month-day":
|
|
835
|
+
return { kind: "month-day", month: birth.month, day: birth.day };
|
|
836
|
+
case "year-month":
|
|
837
|
+
return { kind: "year-month", year: birth.year, month: birth.month };
|
|
838
|
+
case "year":
|
|
839
|
+
return { kind: "year", year: birth.year, approximate: birth.approximate };
|
|
840
|
+
default:
|
|
841
|
+
return { kind: "unknown" };
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
function describeUnavailableBirth(ctx) {
|
|
845
|
+
const kind = ctx.birth.kind;
|
|
846
|
+
const reason = kind === "unknown" ? "birth-date-unknown" : kind === "year" && ctx.birth.approximate ? "birth-year-approximate" : "birth-day-or-month-unknown";
|
|
847
|
+
const detail = kind === "year-month" ? "Birth day unknown: birthday-based personal cycles, heptads and the calendar frame need the birth day and month." : kind === "year" ? "Only the birth year is known: birthday-based cycles need the birth day and month." : "No birth date information: birthday-based cycles need at least the birth day and month.";
|
|
848
|
+
return [
|
|
849
|
+
"personalYear",
|
|
850
|
+
"personalMonth",
|
|
851
|
+
"personalPeriod",
|
|
852
|
+
"heptad",
|
|
853
|
+
"ageCycle",
|
|
854
|
+
"fibonacci",
|
|
855
|
+
"calendar",
|
|
856
|
+
"lifeStages"
|
|
857
|
+
].map((field) => ({ field, reason, detail }));
|
|
858
|
+
}
|
|
859
|
+
function completedAgeRange(birth, asOf) {
|
|
860
|
+
if (birth.kind === "year" && !birth.approximate) {
|
|
861
|
+
const diff = asOf.year - birth.year;
|
|
862
|
+
return { min: Math.max(diff - 1, 0), max: Math.max(diff, 0) };
|
|
863
|
+
}
|
|
864
|
+
if (birth.kind === "year-month") {
|
|
865
|
+
const diff = asOf.year - birth.year;
|
|
866
|
+
if (asOf.month > birth.month)
|
|
867
|
+
return { min: diff, max: diff };
|
|
868
|
+
if (asOf.month < birth.month)
|
|
869
|
+
return { min: Math.max(diff - 1, 0), max: Math.max(diff - 1, 0) };
|
|
870
|
+
return { min: Math.max(diff - 1, 0), max: diff };
|
|
871
|
+
}
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
function emptySnapshot(ctx, asOf, status, unavailableEntries) {
|
|
875
|
+
return {
|
|
876
|
+
asOf: fmt(asOf),
|
|
877
|
+
status,
|
|
878
|
+
birth: birthSummary(ctx.birth),
|
|
879
|
+
meta: ctx.meta,
|
|
880
|
+
completedAge: null,
|
|
881
|
+
completedAgeRange: completedAgeRange(ctx.birth, asOf),
|
|
882
|
+
lastBirthdayYear: null,
|
|
883
|
+
dayInBirthdayYear: null,
|
|
884
|
+
fixedNumbers: { lifePath: ctx.lifePath, firstNameSoulNumber: ctx.soul },
|
|
885
|
+
birthdayYear: null,
|
|
886
|
+
personalMonth: null,
|
|
887
|
+
personalPeriod: null,
|
|
888
|
+
heptad: null,
|
|
889
|
+
ageCycle: null,
|
|
890
|
+
fibonacci: null,
|
|
891
|
+
calendar: null,
|
|
892
|
+
lifeStages: null,
|
|
893
|
+
unavailable: unavailableEntries
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function getNumerologySnapshot(input) {
|
|
897
|
+
const ctx = buildCtx(input);
|
|
898
|
+
const asOf = resolveCivilDate(input.asOf, "asOf");
|
|
899
|
+
const asOfIso = fmt(asOf);
|
|
900
|
+
if (!ctx.anchor) {
|
|
901
|
+
return emptySnapshot(ctx, asOf, "partial", describeUnavailableBirth(ctx));
|
|
902
|
+
}
|
|
903
|
+
if (ctx.full && compareCivilDates(asOf, ctx.full) < 0) {
|
|
904
|
+
return emptySnapshot(ctx, asOf, "before-birth", [
|
|
905
|
+
{ field: "all", reason: "before-birth", detail: "The as-of date is before the birth date." }
|
|
906
|
+
]);
|
|
907
|
+
}
|
|
908
|
+
if (ctx.death && compareCivilDates(asOf, ctx.death) > 0) {
|
|
909
|
+
return emptySnapshot(ctx, asOf, "after-death", [
|
|
910
|
+
{ field: "all", reason: "after-death", detail: "The as-of date is after the supplied death date." }
|
|
911
|
+
]);
|
|
912
|
+
}
|
|
913
|
+
if (ctx.horizon && compareCivilDates(asOf, ctx.horizon) >= 0) {
|
|
914
|
+
return emptySnapshot(ctx, asOf, "after-horizon", [
|
|
915
|
+
{ field: "all", reason: "after-horizon", detail: "The as-of date is at or after the horizon end." }
|
|
916
|
+
]);
|
|
917
|
+
}
|
|
918
|
+
const y = birthdayYearOf(ctx, asOf);
|
|
919
|
+
const row = y === null ? null : buildYearRow(ctx, y);
|
|
920
|
+
if (y === null || row === null) {
|
|
921
|
+
return emptySnapshot(ctx, asOf, "partial", [
|
|
922
|
+
{ field: "all", reason: "birth-year-unknown", detail: "No birthday year exists on or before the as-of date within the supported range." }
|
|
923
|
+
]);
|
|
924
|
+
}
|
|
925
|
+
const by = row.personalYear;
|
|
926
|
+
const heptad = row.heptads.find((h) => contains(h, asOfIso)) ?? null;
|
|
927
|
+
const unavailableEntries = [];
|
|
928
|
+
const period = row.periods.find((p) => contains(p, asOfIso)) ?? null;
|
|
929
|
+
if (period && !period.value.available) {
|
|
930
|
+
unavailableEntries.push({ field: `personalPeriod.${period.phase}`, reason: period.value.reason, detail: period.value.detail });
|
|
931
|
+
}
|
|
932
|
+
if (!ctx.full) {
|
|
933
|
+
for (const field of ["completedAge", "ageCycle", "fibonacci", "lifeStages", "fixedNumbers.lifePath"]) {
|
|
934
|
+
unavailableEntries.push({
|
|
935
|
+
field,
|
|
936
|
+
reason: "birth-year-unknown",
|
|
937
|
+
detail: "Needs the full birth date (the birth year is not known)."
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
let ageCycle = null;
|
|
942
|
+
let lifeStages = null;
|
|
943
|
+
if (ctx.full && by.completedAge !== null) {
|
|
944
|
+
const ref = by.ageCycle;
|
|
945
|
+
const block = ageCycleInterval(ctx, ref.absoluteIndex);
|
|
946
|
+
if (block)
|
|
947
|
+
ageCycle = { ...block, yearPosition: ref.yearPosition };
|
|
948
|
+
const st = stageIntervals(ctx);
|
|
949
|
+
unavailableEntries.push(...st.skipped);
|
|
950
|
+
lifeStages = {
|
|
951
|
+
pinnacle: st.pinnacles.find((p) => contains(p, asOfIso)) ?? null,
|
|
952
|
+
challenge: st.challenges.find((p) => contains(p, asOfIso)) ?? null,
|
|
953
|
+
lifePeriod: st.lifePeriods.find((p) => contains(p, asOfIso)) ?? null,
|
|
954
|
+
mainChallenge: ctx.stages.challenges[2].value,
|
|
955
|
+
transition: {
|
|
956
|
+
rule: ctx.stages.transitionRule,
|
|
957
|
+
lifePathForTransition: ctx.stages.lifePathForTransition,
|
|
958
|
+
firstPinnacleEndAge: ctx.stages.firstPinnacleEndAge
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
const cy = calendarYearValue(ctx, asOf.year);
|
|
963
|
+
const cm = red(ctx, cy.value + asOf.month);
|
|
964
|
+
const cd = red(ctx, cm.value + asOf.day);
|
|
965
|
+
return {
|
|
966
|
+
asOf: asOfIso,
|
|
967
|
+
status: ctx.full ? "ok" : "partial",
|
|
968
|
+
birth: birthSummary(ctx.birth),
|
|
969
|
+
meta: ctx.meta,
|
|
970
|
+
completedAge: by.completedAge,
|
|
971
|
+
completedAgeRange: null,
|
|
972
|
+
lastBirthdayYear: y,
|
|
973
|
+
dayInBirthdayYear: diffCivilDays(parseIso(by.nominalStart), asOf) + 1,
|
|
974
|
+
fixedNumbers: { lifePath: ctx.lifePath, firstNameSoulNumber: ctx.soul },
|
|
975
|
+
birthdayYear: by,
|
|
976
|
+
personalMonth: row.months.find((m) => contains(m, asOfIso)) ?? null,
|
|
977
|
+
personalPeriod: period,
|
|
978
|
+
heptad: heptad ? { ...heptad, dayInHeptad: diffCivilDays(parseIso(heptad.nominalStart), asOf) + 1 } : null,
|
|
979
|
+
ageCycle,
|
|
980
|
+
fibonacci: row.fibonacci,
|
|
981
|
+
calendar: { personalYear: cy, personalMonth: cm, personalDay: cd },
|
|
982
|
+
lifeStages,
|
|
983
|
+
unavailable: unavailableEntries
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
function parseIso(iso) {
|
|
987
|
+
return { year: Number(iso.slice(0, 4)), month: Number(iso.slice(5, 7)), day: Number(iso.slice(8, 10)) };
|
|
988
|
+
}
|
|
989
|
+
var LAYER_ORDER = new Map(TIMELINE_LAYERS.map((l, i) => [l, i]));
|
|
990
|
+
var BIRTHDAY_ROW_LAYERS = /* @__PURE__ */ new Set(["personal-year", "personal-month", "personal-period", "heptad", "fibonacci"]);
|
|
991
|
+
var CALENDAR_LAYERS = /* @__PURE__ */ new Set(["calendar-year", "calendar-month", "calendar-day"]);
|
|
992
|
+
function generateNumerologyTimeline(input) {
|
|
993
|
+
const ctx = buildCtx(input);
|
|
994
|
+
const from = resolveCivilDate(input.from, "from");
|
|
995
|
+
const to = resolveCivilDate(input.toExclusive, "toExclusive");
|
|
996
|
+
const fromIso = fmt(from);
|
|
997
|
+
const toIso = fmt(to);
|
|
998
|
+
if (compareCivilDates(from, to) >= 0) {
|
|
999
|
+
throw new NumerologyScheduleError("INVALID_RANGE", "toExclusive must be after from");
|
|
1000
|
+
}
|
|
1001
|
+
if (diffCivilDays(from, to) > MAX_TIMELINE_RANGE_DAYS) {
|
|
1002
|
+
throw new NumerologyScheduleError("RANGE_TOO_LARGE", `Timeline range is limited to ${MAX_TIMELINE_RANGE_DAYS} days`);
|
|
1003
|
+
}
|
|
1004
|
+
const maxIntervals = input.maxIntervals ?? DEFAULT_MAX_TIMELINE_INTERVALS;
|
|
1005
|
+
if (!Number.isInteger(maxIntervals) || maxIntervals < 1 || maxIntervals > MAX_TIMELINE_INTERVALS_HARD_CAP) {
|
|
1006
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `maxIntervals must be an integer 1-${MAX_TIMELINE_INTERVALS_HARD_CAP}`);
|
|
1007
|
+
}
|
|
1008
|
+
const layers = input.layers ?? ["personal-year"];
|
|
1009
|
+
if (!Array.isArray(layers) || layers.length === 0) {
|
|
1010
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", "layers must be a non-empty array");
|
|
1011
|
+
}
|
|
1012
|
+
for (const layer of layers) {
|
|
1013
|
+
if (!LAYER_ORDER.has(layer)) {
|
|
1014
|
+
throw new NumerologyScheduleError("INVALID_ARGUMENT", `Unknown timeline layer: ${String(layer)}`);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
const wanted = [...new Set(layers)];
|
|
1018
|
+
const intervals = [];
|
|
1019
|
+
const unavailableEntries = [];
|
|
1020
|
+
const push = (iv) => {
|
|
1021
|
+
if (!iv || !overlaps(iv, fromIso, toIso))
|
|
1022
|
+
return;
|
|
1023
|
+
intervals.push(iv);
|
|
1024
|
+
if (intervals.length > maxIntervals) {
|
|
1025
|
+
throw new NumerologyScheduleError("TOO_MANY_INTERVALS", `Timeline would exceed ${maxIntervals} intervals; narrow the range or layers`);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
const needsAnchor = wanted.filter((l) => BIRTHDAY_ROW_LAYERS.has(l) || CALENDAR_LAYERS.has(l));
|
|
1029
|
+
const needsFull = wanted.filter((l) => l === "age-cycle" || l === "pinnacle" || l === "challenge" || l === "life-period");
|
|
1030
|
+
const anchorReason = describeUnavailableBirth(ctx)[0];
|
|
1031
|
+
const fullReason = ctx.birth.kind === "unknown" ? { reason: "birth-date-unknown", detail: "No birth date information." } : { reason: "full-birth-date-required", detail: "This layer needs the full birth date." };
|
|
1032
|
+
if (!ctx.anchor) {
|
|
1033
|
+
for (const l of needsAnchor)
|
|
1034
|
+
unavailableEntries.push({ field: l, reason: anchorReason.reason, detail: anchorReason.detail });
|
|
1035
|
+
}
|
|
1036
|
+
if (!ctx.full) {
|
|
1037
|
+
for (const l of needsFull)
|
|
1038
|
+
unavailableEntries.push({ field: l, ...fullReason });
|
|
1039
|
+
if (ctx.anchor && wanted.includes("fibonacci")) {
|
|
1040
|
+
unavailableEntries.push({ field: "fibonacci", reason: "birth-year-unknown", detail: "Needs the completed age (full birth date)." });
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
const rowLayers = wanted.filter((l) => BIRTHDAY_ROW_LAYERS.has(l));
|
|
1044
|
+
if (ctx.anchor && rowLayers.length > 0) {
|
|
1045
|
+
const first = birthdayYearOf(ctx, from) ?? (ctx.full ? ctx.full.year : from.year - 1);
|
|
1046
|
+
for (let y = first; ; y++) {
|
|
1047
|
+
const start = anniversaryInYear({ month: ctx.anchor.month, day: ctx.anchor.day }, y);
|
|
1048
|
+
if (compareCivilDates(start, to) >= 0 || ctx.coverageEnd && compareCivilDates(start, ctx.coverageEnd) >= 0)
|
|
1049
|
+
break;
|
|
1050
|
+
const row = buildYearRow(ctx, y);
|
|
1051
|
+
if (!row)
|
|
1052
|
+
continue;
|
|
1053
|
+
if (rowLayers.includes("personal-year"))
|
|
1054
|
+
push(row.personalYear);
|
|
1055
|
+
if (rowLayers.includes("personal-month"))
|
|
1056
|
+
row.months.forEach(push);
|
|
1057
|
+
if (rowLayers.includes("personal-period"))
|
|
1058
|
+
row.periods.forEach(push);
|
|
1059
|
+
if (rowLayers.includes("heptad"))
|
|
1060
|
+
row.heptads.forEach(push);
|
|
1061
|
+
if (rowLayers.includes("fibonacci"))
|
|
1062
|
+
push(row.fibonacci);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (ctx.anchor) {
|
|
1066
|
+
if (wanted.includes("calendar-year")) {
|
|
1067
|
+
for (let y = from.year; y <= to.year; y++)
|
|
1068
|
+
push(calendarYearInterval(ctx, y));
|
|
1069
|
+
}
|
|
1070
|
+
if (wanted.includes("calendar-month")) {
|
|
1071
|
+
for (let y = from.year; y <= to.year; y++)
|
|
1072
|
+
for (let m = 1; m <= 12; m++)
|
|
1073
|
+
push(calendarMonthInterval(ctx, y, m));
|
|
1074
|
+
}
|
|
1075
|
+
if (wanted.includes("calendar-day")) {
|
|
1076
|
+
let cursor = from;
|
|
1077
|
+
if (ctx.coverageStart && compareCivilDates(cursor, ctx.coverageStart) < 0)
|
|
1078
|
+
cursor = ctx.coverageStart;
|
|
1079
|
+
for (; compareCivilDates(cursor, to) < 0; cursor = addCivilDays(cursor, 1)) {
|
|
1080
|
+
if (ctx.coverageEnd && compareCivilDates(cursor, ctx.coverageEnd) >= 0)
|
|
1081
|
+
break;
|
|
1082
|
+
push(calendarDayInterval(ctx, cursor));
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
if (ctx.full) {
|
|
1087
|
+
if (wanted.includes("age-cycle")) {
|
|
1088
|
+
const ageAtFrom = Math.max(completedYears(ctx.full, from), 0);
|
|
1089
|
+
for (let b = Math.floor(ageAtFrom / 7); ; b++) {
|
|
1090
|
+
const start = anniversaryInYear(ctx.full, ctx.full.year + b * 7);
|
|
1091
|
+
if (compareCivilDates(start, to) >= 0 || ctx.coverageEnd && compareCivilDates(start, ctx.coverageEnd) >= 0)
|
|
1092
|
+
break;
|
|
1093
|
+
push(ageCycleInterval(ctx, b));
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (wanted.some((l) => l === "pinnacle" || l === "challenge" || l === "life-period")) {
|
|
1097
|
+
const st = stageIntervals(ctx);
|
|
1098
|
+
if (wanted.includes("pinnacle"))
|
|
1099
|
+
st.pinnacles.forEach(push);
|
|
1100
|
+
if (wanted.includes("challenge"))
|
|
1101
|
+
st.challenges.forEach(push);
|
|
1102
|
+
if (wanted.includes("life-period"))
|
|
1103
|
+
st.lifePeriods.forEach(push);
|
|
1104
|
+
for (const u of st.skipped)
|
|
1105
|
+
if (wanted.includes(u.field.split(".")[0]))
|
|
1106
|
+
unavailableEntries.push(u);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
intervals.sort(
|
|
1110
|
+
(a, b) => a.start.localeCompare(b.start) || (LAYER_ORDER.get(a.layer) ?? 0) - (LAYER_ORDER.get(b.layer) ?? 0) || indexOf(a) - indexOf(b)
|
|
1111
|
+
);
|
|
1112
|
+
return {
|
|
1113
|
+
from: fromIso,
|
|
1114
|
+
toExclusive: toIso,
|
|
1115
|
+
layers: wanted,
|
|
1116
|
+
meta: ctx.meta,
|
|
1117
|
+
intervals,
|
|
1118
|
+
caps: { maxIntervals, maxRangeDays: MAX_TIMELINE_RANGE_DAYS },
|
|
1119
|
+
unavailable: unavailableEntries
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
function indexOf(iv) {
|
|
1123
|
+
switch (iv.layer) {
|
|
1124
|
+
case "personal-month":
|
|
1125
|
+
case "personal-period":
|
|
1126
|
+
case "heptad":
|
|
1127
|
+
return iv.phase;
|
|
1128
|
+
case "pinnacle":
|
|
1129
|
+
case "challenge":
|
|
1130
|
+
case "life-period":
|
|
1131
|
+
return iv.index;
|
|
1132
|
+
default:
|
|
1133
|
+
return 0;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
export { DEFAULT_MAX_TIMELINE_INTERVALS, LIFE_STAGE_METHOD_ID, MASTER_NUMBERS, MAX_CANDIDATE_DATES, MAX_CIVIL_YEAR, MAX_SCHEDULE_YEAR, MAX_TIMELINE_INTERVALS_HARD_CAP, MAX_TIMELINE_RANGE_DAYS, MIN_CIVIL_YEAR, NumerologyScheduleError, SCHEDULE_METHOD_VERSION, TIMELINE_LAYERS, addCivilDays, anniversaryInYear, calculateKaabalisticLifePath, calculateStraightAcrossReductionLifePath, civilDate, civilDateFromLocalDate, civilDateFromOrdinal, civilDateToLocalNoon, civilDayOrdinal, compareCivilDates, completedYears, computeLifeStages, daysInMonth, diffCivilDays, fmt, formatCivilDate, generateNumerologyTimeline, getNumerologyMethodMetadata, getNumerologySnapshot, isLeapYear, isMasterNumber, isValidCivilDate, mapDatePartsToBlocksOfTwo, normalizeBirth, parseCivilDate, parseDate, reduceToSingle, reduceToSingleWithSteps, resolveCivilDate, unavailable };
|
|
1138
|
+
//# sourceMappingURL=out.js.map
|
|
1139
|
+
//# sourceMappingURL=chunk-4WVN4RMM.mjs.map
|