kaabalah 2.1.2 → 3.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.
@@ -22,6 +22,11 @@ var reduceToSingleDigitWithSteps = (num) => {
22
22
  finalValue: currentNum
23
23
  };
24
24
  };
25
+ var getLastArkAnnuStep = (steps) => {
26
+ if (steps.length === 0) return 0;
27
+ const step = steps.sort((a, b) => b - a).find((step2) => step2 <= 22);
28
+ return step ?? steps.at(-1) ?? 0;
29
+ };
25
30
  function normalizeLetter(letter) {
26
31
  if (letter.toUpperCase() === "\xC3") return "\xC3";
27
32
  if (letter.toUpperCase() === "\xC7") return "\xC7";
@@ -201,7 +206,7 @@ var calculateGematria = (phrase, options = {
201
206
  finalState.consonantsSum
202
207
  );
203
208
  const synthesisReduction = reduceToSingleDigitWithSteps(
204
- finalState.vowelsSum + finalState.consonantsSum
209
+ getLastArkAnnuStep(vowelsReduction.steps) + getLastArkAnnuStep(consonantsReduction.steps)
205
210
  );
206
211
  const missingGematriaValues = options?.missing ? getMissingGematriaValues(tree, finalState.includedGematriaValues) : void 0;
207
212
  return {
@@ -227,5 +232,5 @@ var calculateGematria = (phrase, options = {
227
232
  };
228
233
 
229
234
  export { calculateGematria };
230
- //# sourceMappingURL=chunk-WG7FXQ3Z.mjs.map
231
- //# sourceMappingURL=chunk-WG7FXQ3Z.mjs.map
235
+ //# sourceMappingURL=chunk-5ISXTWFX.mjs.map
236
+ //# sourceMappingURL=chunk-5ISXTWFX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gematria/index.ts"],"names":["step","isEnding","latinLetterId","mapping","useWhenEndingValue"],"mappings":";;;AAMA,IAAM,QAAA,uBAAe,GAAY,CAAA;AAAA,EAC/B,aAAc,CAAA,EAAA;AAAA,EACd,aAAc,CAAA,EAAA;AAAA,EACd,aAAc,CAAA,EAAA;AAAA,EACd,aAAc,CAAA,EAAA;AAAA,EACd,aAAc,CAAA,EAAA;AAAA,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AAQ,EAAA;AAAA,MACN,aAAa,UAAW,CAAA,SAAA;AAAA,MACxB,gBAAgB,eAAgB,CAAA,KAAA;AAAA,MAChC,YAAY,eAAgB,CAAA;AAAA,KAC9B;AAAA,IACA,UAAY,EAAA;AAAA,MACV,aAAa,UAAW,CAAA,aAAA;AAAA,MACxB,gBAAgB,mBAAoB,CAAA,KAAA;AAAA,MACpC,YAAY,mBAAoB,CAAA;AAAA,KAClC;AAAA,IACA,SAAW,EAAA;AAAA,MACT,WAAA,EAAa,UAAW,CAAA,SAAA,GAAY,UAAW,CAAA,aAAA;AAAA,MAC/C,gBAAgB,kBAAmB,CAAA,KAAA;AAAA,MACnC,YAAY,kBAAmB,CAAA;AAAA,KACjC;AAAA,IACA,iBAAiB,UAAW,CAAA,eAAA;AAAA,IAC5B,qBAAA;AAAA,IACA,iBAAA,EAAmB,OAAS,EAAA,WAAA,GAAc,iBAAoB,GAAA;AAAA,GAChE;AACF","file":"chunk-5ISXTWFX.mjs","sourcesContent":["import { HEBREW_LETTERS, LATIN_LETTERS } from \"../core/constants\";\nimport { createTree } from \"../core/factory\";\nimport { SYSTEM as KAABALAH_SYSTEM } from \"../core/systems/kaabalah\";\nimport { TreeOfLife } from \"../core/tree-of-life\";\nimport { id, LetterTypes, Node, NodeId, parseId } from \"../core/types\";\n\nconst DIGRAPHS = new Set<string>([\n LATIN_LETTERS.PH,\n LATIN_LETTERS.TS,\n LATIN_LETTERS.TZ,\n LATIN_LETTERS.SH,\n LATIN_LETTERS.CH,\n LATIN_LETTERS.TH,\n LATIN_LETTERS.KH,\n]);\n\nconst reduceToSingleDigitWithSteps = (num: number) => {\n const steps = [num];\n let currentNum = num;\n\n while (currentNum > 9) {\n currentNum = String(currentNum)\n .split(\"\")\n .reduce((acc, digit) => acc + parseInt(digit), 0);\n steps.push(currentNum);\n }\n\n return {\n steps,\n finalValue: currentNum,\n };\n};\n\nconst getLastArkAnnuStep = (steps: number[]) => {\n if (steps.length === 0) return 0;\n\n // reverse sort to get the last step\n const step = steps.sort((a, b) => b - a).find((step) => step <= 22);\n\n return step ?? steps.at(-1) ?? 0;\n}\n\ninterface LetterResult {\n latinLetterId: NodeId<LetterTypes.LATIN_LETTER>;\n value: number;\n hebrewLetterId: NodeId<LetterTypes.HEBREW_LETTER>;\n hebrewCharacter: string;\n isVowel: boolean;\n}\n\ninterface WordResult {\n letters: LetterResult[];\n vowelsSum: number;\n consonantsSum: number;\n includedGematriaValues: Set<number>;\n}\n\ninterface GematriaState {\n includedLetters: LetterResult[];\n vowelsSum: number;\n consonantsSum: number;\n includedGematriaValues: Set<number>;\n}\n\ninterface LetterPercentages {\n percentageOfVowels: number;\n percentageOfConsonants: number;\n letters: Record<string, number>;\n}\n\nfunction normalizeLetter(letter: string): string {\n if (letter.toUpperCase() === \"Ã\") return \"Ã\";\n if (letter.toUpperCase() === \"Ç\") return \"Ç\";\n\n return letter.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n}\n\nfunction getLetterMapping({\n tree,\n letterId,\n isStarting,\n}: {\n tree: TreeOfLife;\n letterId: NodeId<LetterTypes.LATIN_LETTER>;\n isStarting: boolean;\n}): Node<LetterTypes.HEBREW_LETTER> | undefined {\n if (isStarting && parseId(letterId) === \"O\") {\n return tree.getNode(id(LetterTypes.HEBREW_LETTER, HEBREW_LETTERS.AYIN));\n }\n\n return tree.walk(letterId, 2, LetterTypes.HEBREW_LETTER).at(0);\n}\n\nfunction processLetter(\n tree: TreeOfLife,\n letters: string[],\n i: number\n): { result?: LetterResult; skipNext: boolean } {\n const letter = normalizeLetter(letters[i]).toLocaleUpperCase();\n const nextLetter = letters[i + 1]\n ? normalizeLetter(letters[i + 1]).toLocaleLowerCase()\n : \"\";\n const combinedLetter = letter + nextLetter;\n\n if (DIGRAPHS.has(combinedLetter)) {\n const isEnding = i > 0 && i === letters.length - 2;\n const latinLetterId = id(LetterTypes.LATIN_LETTER, combinedLetter);\n const mapping = getLetterMapping({\n tree,\n letterId: latinLetterId,\n isStarting: false,\n });\n\n if (!mapping?.data) {\n return { skipNext: false };\n }\n\n const useWhenEndingValue =\n isEnding &&\n mapping.data.gematriaValueWhenEnding !== undefined &&\n mapping.data.characterWhenEnding !== undefined;\n\n return {\n result: {\n latinLetterId,\n value: useWhenEndingValue\n ? mapping.data.gematriaValueWhenEnding!\n : mapping.data.gematriaValue,\n hebrewCharacter: useWhenEndingValue\n ? mapping.data.characterWhenEnding!\n : mapping.data.character,\n hebrewLetterId: mapping.id,\n isVowel: false,\n },\n skipNext: true,\n };\n }\n\n const isStarting = i === 0;\n const latinLetterId = id(LetterTypes.LATIN_LETTER, letter);\n const mapping = getLetterMapping({\n tree,\n letterId: latinLetterId,\n isStarting,\n });\n\n if (!mapping?.data) {\n return { skipNext: false };\n }\n\n const isEnding = i > 0 && i === letters.length - 1;\n const latinLetter = tree.getNode(latinLetterId);\n const useWhenEndingValue =\n isEnding &&\n mapping.data.gematriaValueWhenEnding !== undefined &&\n mapping.data.characterWhenEnding !== undefined;\n\n return {\n result: {\n latinLetterId,\n value: useWhenEndingValue\n ? mapping.data.gematriaValueWhenEnding!\n : mapping.data.gematriaValue,\n hebrewCharacter: useWhenEndingValue\n ? mapping.data.characterWhenEnding!\n : mapping.data.character,\n hebrewLetterId: mapping.id,\n isVowel: latinLetter?.data?.isVowel ?? false,\n },\n skipNext: false,\n };\n}\n\nfunction processWord(word: string, tree: TreeOfLife): WordResult {\n const letters = word.split(\"\");\n let i = 0;\n\n let wordState: WordResult = {\n letters: [],\n vowelsSum: 0,\n consonantsSum: 0,\n includedGematriaValues: new Set(),\n };\n\n while (i < letters.length) {\n const { result, skipNext } = processLetter(tree, letters, i);\n\n if (result) {\n wordState = {\n letters: [...wordState.letters, result],\n vowelsSum: wordState.vowelsSum + (result.isVowel ? result.value : 0),\n consonantsSum:\n wordState.consonantsSum + (result.isVowel ? 0 : result.value),\n includedGematriaValues: new Set([\n ...wordState.includedGematriaValues,\n result.value,\n ]),\n };\n }\n\n i += skipNext ? 2 : 1;\n }\n\n return wordState;\n}\n\nfunction calculateLetterPercentages(\n word: string,\n tree: TreeOfLife,\n prev: LetterPercentages\n): LetterPercentages {\n const letters = word.split(\"\");\n const letterCount = letters.length;\n\n let vowelsCount = 0;\n let consonantsCount = 0;\n\n const newLetters = { ...prev.letters };\n\n for (const letter of new Set(letters)) {\n const occurrences = letters.filter((l) => l === letter).length;\n const latinLetter = tree.getNode(id(LetterTypes.LATIN_LETTER, letter));\n newLetters[letter] = (occurrences / letterCount) * 100;\n\n if (latinLetter?.data?.isVowel) {\n vowelsCount += occurrences;\n } else {\n consonantsCount += occurrences;\n }\n }\n return {\n percentageOfVowels: (vowelsCount / letterCount) * 100,\n percentageOfConsonants: (consonantsCount / letterCount) * 100,\n letters: newLetters,\n };\n}\n\nfunction getMissingGematriaValues(\n tree: TreeOfLife,\n includedGematriaValues: Set<number>\n) {\n const missingGematriaValues: {\n value: number;\n hebrewLetterId: NodeId<LetterTypes.HEBREW_LETTER>;\n whenEnding: boolean;\n }[] = [];\n\n for (const hebrewLetter of Object.values(HEBREW_LETTERS)) {\n const hebrewLetterId = id(LetterTypes.HEBREW_LETTER, hebrewLetter);\n const hebrewLetterNode = tree.getNode(hebrewLetterId);\n\n if (!hebrewLetterNode?.data) continue;\n\n if (!includedGematriaValues.has(hebrewLetterNode.data.gematriaValue)) {\n missingGematriaValues.push({\n value: hebrewLetterNode.data.gematriaValue,\n hebrewLetterId,\n whenEnding: false,\n });\n }\n\n if (\n hebrewLetterNode.data.gematriaValueWhenEnding &&\n !includedGematriaValues.has(hebrewLetterNode.data.gematriaValueWhenEnding)\n ) {\n missingGematriaValues.push({\n value: hebrewLetterNode.data.gematriaValueWhenEnding,\n hebrewLetterId,\n whenEnding: true,\n });\n }\n }\n\n missingGematriaValues.sort((a, b) => a.value - b.value);\n\n return missingGematriaValues;\n}\n\nexport const calculateGematria = (\n phrase: string,\n options: {\n missing?: boolean;\n percentages?: boolean;\n } = {\n missing: false,\n percentages: false,\n },\n tree?: TreeOfLife\n) => {\n if (!tree) {\n // todo: study the possibility of pre-calculating the mappings\n tree = createTree({ system: KAABALAH_SYSTEM, parts: [] });\n }\n const words = phrase.toUpperCase().trim().split(\" \");\n\n const initialState: GematriaState = {\n includedLetters: [],\n vowelsSum: 0,\n consonantsSum: 0,\n includedGematriaValues: new Set(),\n };\n\n const finalState = words.reduce<GematriaState>((state, word) => {\n const wordResult = processWord(word, tree);\n\n return {\n includedLetters: [...state.includedLetters, ...wordResult.letters],\n vowelsSum: state.vowelsSum + wordResult.vowelsSum,\n consonantsSum: state.consonantsSum + wordResult.consonantsSum,\n includedGematriaValues: new Set([\n ...Array.from(state.includedGematriaValues),\n ...Array.from(wordResult.includedGematriaValues),\n ]),\n };\n }, initialState);\n\n let letterPercentages: LetterPercentages = {\n percentageOfVowels: 0,\n percentageOfConsonants: 0,\n letters: {},\n };\n\n if (options?.percentages) {\n letterPercentages = words.reduce<LetterPercentages>((acc, word) => {\n return calculateLetterPercentages(word, tree, acc);\n }, letterPercentages);\n }\n\n const vowelsReduction = reduceToSingleDigitWithSteps(finalState.vowelsSum);\n const consonantsReduction = reduceToSingleDigitWithSteps(\n finalState.consonantsSum\n );\n const synthesisReduction = reduceToSingleDigitWithSteps(\n getLastArkAnnuStep(vowelsReduction.steps) + getLastArkAnnuStep(consonantsReduction.steps)\n );\n\n const missingGematriaValues = options?.missing\n ? getMissingGematriaValues(tree, finalState.includedGematriaValues)\n : undefined;\n\n return {\n vowels: {\n originalSum: finalState.vowelsSum,\n reductionSteps: vowelsReduction.steps,\n finalValue: vowelsReduction.finalValue,\n },\n consonants: {\n originalSum: finalState.consonantsSum,\n reductionSteps: consonantsReduction.steps,\n finalValue: consonantsReduction.finalValue,\n },\n synthesis: {\n originalSum: finalState.vowelsSum + finalState.consonantsSum,\n reductionSteps: synthesisReduction.steps,\n finalValue: synthesisReduction.finalValue,\n },\n includedLetters: finalState.includedLetters,\n missingGematriaValues,\n letterPercentages: options?.percentages ? letterPercentages : undefined,\n };\n};\n"]}
@@ -24,6 +24,11 @@ var reduceToSingleDigitWithSteps = (num) => {
24
24
  finalValue: currentNum
25
25
  };
26
26
  };
27
+ var getLastArkAnnuStep = (steps) => {
28
+ if (steps.length === 0) return 0;
29
+ const step = steps.sort((a, b) => b - a).find((step2) => step2 <= 22);
30
+ return step ?? steps.at(-1) ?? 0;
31
+ };
27
32
  function normalizeLetter(letter) {
28
33
  if (letter.toUpperCase() === "\xC3") return "\xC3";
29
34
  if (letter.toUpperCase() === "\xC7") return "\xC7";
@@ -203,7 +208,7 @@ var calculateGematria = (phrase, options = {
203
208
  finalState.consonantsSum
204
209
  );
205
210
  const synthesisReduction = reduceToSingleDigitWithSteps(
206
- finalState.vowelsSum + finalState.consonantsSum
211
+ getLastArkAnnuStep(vowelsReduction.steps) + getLastArkAnnuStep(consonantsReduction.steps)
207
212
  );
208
213
  const missingGematriaValues = options?.missing ? getMissingGematriaValues(tree, finalState.includedGematriaValues) : void 0;
209
214
  return {
@@ -229,5 +234,5 @@ var calculateGematria = (phrase, options = {
229
234
  };
230
235
 
231
236
  exports.calculateGematria = calculateGematria;
232
- //# sourceMappingURL=chunk-ADJTMVLA.js.map
233
- //# sourceMappingURL=chunk-ADJTMVLA.js.map
237
+ //# sourceMappingURL=chunk-JJ76YVMI.js.map
238
+ //# sourceMappingURL=chunk-JJ76YVMI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gematria/index.ts"],"names":["LATIN_LETTERS","step","parseId","id","HEBREW_LETTERS","isEnding","latinLetterId","mapping","useWhenEndingValue","createTree","SYSTEM"],"mappings":";;;;;AAMA,IAAM,QAAA,uBAAe,GAAY,CAAA;AAAA,EAC/BA,8BAAc,CAAA,EAAA;AAAA,EACdA,8BAAc,CAAA,EAAA;AAAA,EACdA,8BAAc,CAAA,EAAA;AAAA,EACdA,8BAAc,CAAA,EAAA;AAAA,EACdA,8BAAc,CAAA,EAAA;AAAA,EACdA,8BAAc,CAAA,EAAA;AAAA,E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AA;AAAA,MACN,aAAa,UAAW,CAAA,SAAA;AAAA,MACxB,gBAAgB,eAAgB,CAAA,KAAA;AAAA,MAChC,YAAY,eAAgB,CAAA;AAAA,KAC9B;AAAA,IACA,UAAY,EAAA;AAAA,MACV,aAAa,UAAW,CAAA,aAAA;AAAA,MACxB,gBAAgB,mBAAoB,CAAA,KAAA;AAAA,MACpC,YAAY,mBAAoB,CAAA;AAAA,KAClC;AAAA,IACA,SAAW,EAAA;AAAA,MACT,WAAA,EAAa,UAAW,CAAA,SAAA,GAAY,UAAW,CAAA,aAAA;AAAA,MAC/C,gBAAgB,kBAAmB,CAAA,KAAA;AAAA,MACnC,YAAY,kBAAmB,CAAA;AAAA,KACjC;AAAA,IACA,iBAAiB,UAAW,CAAA,eAAA;AAAA,IAC5B,qBAAA;AAAA,IACA,iBAAA,EAAmB,OAAS,EAAA,WAAA,GAAc,iBAAoB,GAAA;AAAA,GAChE;AACF","file":"chunk-JJ76YVMI.js","sourcesContent":["import { HEBREW_LETTERS, LATIN_LETTERS } from \"../core/constants\";\nimport { createTree } from \"../core/factory\";\nimport { SYSTEM as KAABALAH_SYSTEM } from \"../core/systems/kaabalah\";\nimport { TreeOfLife } from \"../core/tree-of-life\";\nimport { id, LetterTypes, Node, NodeId, parseId } from \"../core/types\";\n\nconst DIGRAPHS = new Set<string>([\n LATIN_LETTERS.PH,\n LATIN_LETTERS.TS,\n LATIN_LETTERS.TZ,\n LATIN_LETTERS.SH,\n LATIN_LETTERS.CH,\n LATIN_LETTERS.TH,\n LATIN_LETTERS.KH,\n]);\n\nconst reduceToSingleDigitWithSteps = (num: number) => {\n const steps = [num];\n let currentNum = num;\n\n while (currentNum > 9) {\n currentNum = String(currentNum)\n .split(\"\")\n .reduce((acc, digit) => acc + parseInt(digit), 0);\n steps.push(currentNum);\n }\n\n return {\n steps,\n finalValue: currentNum,\n };\n};\n\nconst getLastArkAnnuStep = (steps: number[]) => {\n if (steps.length === 0) return 0;\n\n // reverse sort to get the last step\n const step = steps.sort((a, b) => b - a).find((step) => step <= 22);\n\n return step ?? steps.at(-1) ?? 0;\n}\n\ninterface LetterResult {\n latinLetterId: NodeId<LetterTypes.LATIN_LETTER>;\n value: number;\n hebrewLetterId: NodeId<LetterTypes.HEBREW_LETTER>;\n hebrewCharacter: string;\n isVowel: boolean;\n}\n\ninterface WordResult {\n letters: LetterResult[];\n vowelsSum: number;\n consonantsSum: number;\n includedGematriaValues: Set<number>;\n}\n\ninterface GematriaState {\n includedLetters: LetterResult[];\n vowelsSum: number;\n consonantsSum: number;\n includedGematriaValues: Set<number>;\n}\n\ninterface LetterPercentages {\n percentageOfVowels: number;\n percentageOfConsonants: number;\n letters: Record<string, number>;\n}\n\nfunction normalizeLetter(letter: string): string {\n if (letter.toUpperCase() === \"Ã\") return \"Ã\";\n if (letter.toUpperCase() === \"Ç\") return \"Ç\";\n\n return letter.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n}\n\nfunction getLetterMapping({\n tree,\n letterId,\n isStarting,\n}: {\n tree: TreeOfLife;\n letterId: NodeId<LetterTypes.LATIN_LETTER>;\n isStarting: boolean;\n}): Node<LetterTypes.HEBREW_LETTER> | undefined {\n if (isStarting && parseId(letterId) === \"O\") {\n return tree.getNode(id(LetterTypes.HEBREW_LETTER, HEBREW_LETTERS.AYIN));\n }\n\n return tree.walk(letterId, 2, LetterTypes.HEBREW_LETTER).at(0);\n}\n\nfunction processLetter(\n tree: TreeOfLife,\n letters: string[],\n i: number\n): { result?: LetterResult; skipNext: boolean } {\n const letter = normalizeLetter(letters[i]).toLocaleUpperCase();\n const nextLetter = letters[i + 1]\n ? normalizeLetter(letters[i + 1]).toLocaleLowerCase()\n : \"\";\n const combinedLetter = letter + nextLetter;\n\n if (DIGRAPHS.has(combinedLetter)) {\n const isEnding = i > 0 && i === letters.length - 2;\n const latinLetterId = id(LetterTypes.LATIN_LETTER, combinedLetter);\n const mapping = getLetterMapping({\n tree,\n letterId: latinLetterId,\n isStarting: false,\n });\n\n if (!mapping?.data) {\n return { skipNext: false };\n }\n\n const useWhenEndingValue =\n isEnding &&\n mapping.data.gematriaValueWhenEnding !== undefined &&\n mapping.data.characterWhenEnding !== undefined;\n\n return {\n result: {\n latinLetterId,\n value: useWhenEndingValue\n ? mapping.data.gematriaValueWhenEnding!\n : mapping.data.gematriaValue,\n hebrewCharacter: useWhenEndingValue\n ? mapping.data.characterWhenEnding!\n : mapping.data.character,\n hebrewLetterId: mapping.id,\n isVowel: false,\n },\n skipNext: true,\n };\n }\n\n const isStarting = i === 0;\n const latinLetterId = id(LetterTypes.LATIN_LETTER, letter);\n const mapping = getLetterMapping({\n tree,\n letterId: latinLetterId,\n isStarting,\n });\n\n if (!mapping?.data) {\n return { skipNext: false };\n }\n\n const isEnding = i > 0 && i === letters.length - 1;\n const latinLetter = tree.getNode(latinLetterId);\n const useWhenEndingValue =\n isEnding &&\n mapping.data.gematriaValueWhenEnding !== undefined &&\n mapping.data.characterWhenEnding !== undefined;\n\n return {\n result: {\n latinLetterId,\n value: useWhenEndingValue\n ? mapping.data.gematriaValueWhenEnding!\n : mapping.data.gematriaValue,\n hebrewCharacter: useWhenEndingValue\n ? mapping.data.characterWhenEnding!\n : mapping.data.character,\n hebrewLetterId: mapping.id,\n isVowel: latinLetter?.data?.isVowel ?? false,\n },\n skipNext: false,\n };\n}\n\nfunction processWord(word: string, tree: TreeOfLife): WordResult {\n const letters = word.split(\"\");\n let i = 0;\n\n let wordState: WordResult = {\n letters: [],\n vowelsSum: 0,\n consonantsSum: 0,\n includedGematriaValues: new Set(),\n };\n\n while (i < letters.length) {\n const { result, skipNext } = processLetter(tree, letters, i);\n\n if (result) {\n wordState = {\n letters: [...wordState.letters, result],\n vowelsSum: wordState.vowelsSum + (result.isVowel ? result.value : 0),\n consonantsSum:\n wordState.consonantsSum + (result.isVowel ? 0 : result.value),\n includedGematriaValues: new Set([\n ...wordState.includedGematriaValues,\n result.value,\n ]),\n };\n }\n\n i += skipNext ? 2 : 1;\n }\n\n return wordState;\n}\n\nfunction calculateLetterPercentages(\n word: string,\n tree: TreeOfLife,\n prev: LetterPercentages\n): LetterPercentages {\n const letters = word.split(\"\");\n const letterCount = letters.length;\n\n let vowelsCount = 0;\n let consonantsCount = 0;\n\n const newLetters = { ...prev.letters };\n\n for (const letter of new Set(letters)) {\n const occurrences = letters.filter((l) => l === letter).length;\n const latinLetter = tree.getNode(id(LetterTypes.LATIN_LETTER, letter));\n newLetters[letter] = (occurrences / letterCount) * 100;\n\n if (latinLetter?.data?.isVowel) {\n vowelsCount += occurrences;\n } else {\n consonantsCount += occurrences;\n }\n }\n return {\n percentageOfVowels: (vowelsCount / letterCount) * 100,\n percentageOfConsonants: (consonantsCount / letterCount) * 100,\n letters: newLetters,\n };\n}\n\nfunction getMissingGematriaValues(\n tree: TreeOfLife,\n includedGematriaValues: Set<number>\n) {\n const missingGematriaValues: {\n value: number;\n hebrewLetterId: NodeId<LetterTypes.HEBREW_LETTER>;\n whenEnding: boolean;\n }[] = [];\n\n for (const hebrewLetter of Object.values(HEBREW_LETTERS)) {\n const hebrewLetterId = id(LetterTypes.HEBREW_LETTER, hebrewLetter);\n const hebrewLetterNode = tree.getNode(hebrewLetterId);\n\n if (!hebrewLetterNode?.data) continue;\n\n if (!includedGematriaValues.has(hebrewLetterNode.data.gematriaValue)) {\n missingGematriaValues.push({\n value: hebrewLetterNode.data.gematriaValue,\n hebrewLetterId,\n whenEnding: false,\n });\n }\n\n if (\n hebrewLetterNode.data.gematriaValueWhenEnding &&\n !includedGematriaValues.has(hebrewLetterNode.data.gematriaValueWhenEnding)\n ) {\n missingGematriaValues.push({\n value: hebrewLetterNode.data.gematriaValueWhenEnding,\n hebrewLetterId,\n whenEnding: true,\n });\n }\n }\n\n missingGematriaValues.sort((a, b) => a.value - b.value);\n\n return missingGematriaValues;\n}\n\nexport const calculateGematria = (\n phrase: string,\n options: {\n missing?: boolean;\n percentages?: boolean;\n } = {\n missing: false,\n percentages: false,\n },\n tree?: TreeOfLife\n) => {\n if (!tree) {\n // todo: study the possibility of pre-calculating the mappings\n tree = createTree({ system: KAABALAH_SYSTEM, parts: [] });\n }\n const words = phrase.toUpperCase().trim().split(\" \");\n\n const initialState: GematriaState = {\n includedLetters: [],\n vowelsSum: 0,\n consonantsSum: 0,\n includedGematriaValues: new Set(),\n };\n\n const finalState = words.reduce<GematriaState>((state, word) => {\n const wordResult = processWord(word, tree);\n\n return {\n includedLetters: [...state.includedLetters, ...wordResult.letters],\n vowelsSum: state.vowelsSum + wordResult.vowelsSum,\n consonantsSum: state.consonantsSum + wordResult.consonantsSum,\n includedGematriaValues: new Set([\n ...Array.from(state.includedGematriaValues),\n ...Array.from(wordResult.includedGematriaValues),\n ]),\n };\n }, initialState);\n\n let letterPercentages: LetterPercentages = {\n percentageOfVowels: 0,\n percentageOfConsonants: 0,\n letters: {},\n };\n\n if (options?.percentages) {\n letterPercentages = words.reduce<LetterPercentages>((acc, word) => {\n return calculateLetterPercentages(word, tree, acc);\n }, letterPercentages);\n }\n\n const vowelsReduction = reduceToSingleDigitWithSteps(finalState.vowelsSum);\n const consonantsReduction = reduceToSingleDigitWithSteps(\n finalState.consonantsSum\n );\n const synthesisReduction = reduceToSingleDigitWithSteps(\n getLastArkAnnuStep(vowelsReduction.steps) + getLastArkAnnuStep(consonantsReduction.steps)\n );\n\n const missingGematriaValues = options?.missing\n ? getMissingGematriaValues(tree, finalState.includedGematriaValues)\n : undefined;\n\n return {\n vowels: {\n originalSum: finalState.vowelsSum,\n reductionSteps: vowelsReduction.steps,\n finalValue: vowelsReduction.finalValue,\n },\n consonants: {\n originalSum: finalState.consonantsSum,\n reductionSteps: consonantsReduction.steps,\n finalValue: consonantsReduction.finalValue,\n },\n synthesis: {\n originalSum: finalState.vowelsSum + finalState.consonantsSum,\n reductionSteps: synthesisReduction.steps,\n finalValue: synthesisReduction.finalValue,\n },\n includedLetters: finalState.includedLetters,\n missingGematriaValues,\n letterPercentages: options?.percentages ? letterPercentages : undefined,\n };\n};\n"]}
@@ -0,0 +1,488 @@
1
+ 'use strict';
2
+
3
+ var chunkJJ76YVMI_js = require('./chunk-JJ76YVMI.js');
4
+
5
+ // src/numerology/index.ts
6
+ function parseDate(date) {
7
+ if (!date) {
8
+ throw new Error("Date is required");
9
+ }
10
+ if (!(date instanceof Date)) {
11
+ throw new Error("Date must be a Date object");
12
+ }
13
+ const formattedDate = date.toISOString().split("T")[0];
14
+ if (formattedDate.length !== 10) {
15
+ throw new Error("Date must be in the format YYYY-MM-DD or DD-MM-YYYY");
16
+ }
17
+ const parts = formattedDate.split(/[-/]/).map((p) => p.trim());
18
+ const isYYYYMMDD = parts[0].length === 4;
19
+ if (isYYYYMMDD) {
20
+ return { day: parts[2], month: parts[1], year: parts[0] };
21
+ } else {
22
+ return { day: parts[0], month: parts[1], year: parts[2] };
23
+ }
24
+ }
25
+ function mapDatePartsToBlocksOfTwo({
26
+ day,
27
+ month,
28
+ year
29
+ }) {
30
+ return {
31
+ day: day.padStart(2, "0"),
32
+ month: month.padStart(2, "0"),
33
+ year1: year.slice(0, 2),
34
+ year2: year.slice(2)
35
+ };
36
+ }
37
+ function digitSum(n) {
38
+ let s = 0;
39
+ for (const ch of String(Math.abs(n))) {
40
+ s += ch.charCodeAt(0) - 48;
41
+ }
42
+ return s;
43
+ }
44
+ var MASTER_NUMBERS = [11, 22, 33, 44];
45
+ function isMasterNumber(n) {
46
+ return MASTER_NUMBERS.includes(n);
47
+ }
48
+ function reduceToSingle(n, options = { preserveMasters: false }) {
49
+ if (n === 0) {
50
+ return 0;
51
+ }
52
+ let reduced = n;
53
+ while (reduced > 9) {
54
+ if (options?.preserveMasters && isMasterNumber(reduced)) {
55
+ break;
56
+ }
57
+ reduced = digitSum(reduced);
58
+ }
59
+ return reduced;
60
+ }
61
+ function reduceToSingleWithSteps(n, options = { preserveMasters: false }) {
62
+ const steps = [n];
63
+ if (n === 0) {
64
+ return {
65
+ reducedValue: 0,
66
+ reductionSteps: steps
67
+ };
68
+ }
69
+ let reduced = n;
70
+ while (reduced > 9) {
71
+ if (options?.preserveMasters && isMasterNumber(reduced)) {
72
+ break;
73
+ }
74
+ reduced = digitSum(reduced);
75
+ steps.push(reduced);
76
+ }
77
+ return {
78
+ reducedValue: reduced,
79
+ reductionSteps: steps
80
+ };
81
+ }
82
+ function reduceBlock(block) {
83
+ const n = [...block].reduce(
84
+ (acc, curr) => acc + (curr.charCodeAt(0) - 48),
85
+ 0
86
+ );
87
+ if (n === 0) {
88
+ return 0;
89
+ }
90
+ return reduceToSingle(n);
91
+ }
92
+ function calculateKaabalisticLifePath(birthDate) {
93
+ const { day, month, year1, year2 } = mapDatePartsToBlocksOfTwo(
94
+ parseDate(birthDate)
95
+ );
96
+ const reducedDay = reduceBlock(day);
97
+ const reducedMonth = reduceBlock(month);
98
+ const reducedYear1 = reduceBlock(year1);
99
+ const reducedYear2 = reduceBlock(year2);
100
+ const dayMonthSynthesis = parseInt(`${reducedDay}${reducedMonth}`, 10);
101
+ const yearSynthesis = parseInt(`${reducedYear1}${reducedYear2}`, 10);
102
+ const reducedDayMonthSynthesis = reduceToSingle(dayMonthSynthesis);
103
+ const reducedYearSynthesis = reduceToSingle(yearSynthesis);
104
+ const finalSynthesis = parseInt(
105
+ `${reducedDayMonthSynthesis}${reducedYearSynthesis}`,
106
+ 10
107
+ );
108
+ const lifePath = reduceToSingle(finalSynthesis, { preserveMasters: true });
109
+ const isMasterLifePath = isMasterNumber(lifePath);
110
+ const personalMythologyNumbers = [
111
+ parseInt(`${dayMonthSynthesis}${yearSynthesis}`, 10),
112
+ finalSynthesis,
113
+ lifePath
114
+ ];
115
+ const reducedLifePath = reduceToSingle(lifePath);
116
+ if (isMasterLifePath) {
117
+ personalMythologyNumbers.push(reducedLifePath);
118
+ }
119
+ return {
120
+ parts: { day, month, year1, year2 },
121
+ reducedParts: { reducedDay, reducedMonth, reducedYear1, reducedYear2 },
122
+ syntheses: {
123
+ dayMonthSynthesis,
124
+ yearSynthesis,
125
+ reducedDayMonthSynthesis,
126
+ reducedYearSynthesis,
127
+ finalSynthesis
128
+ },
129
+ lifePath,
130
+ personalMythologyNumbers
131
+ };
132
+ }
133
+ function calculateStraightAcrossReductionLifePath(birthDate) {
134
+ const { day, month, year } = parseDate(birthDate);
135
+ const result = reduceToSingleWithSteps(
136
+ parseInt(`${day}${month}${year}`, 10),
137
+ { preserveMasters: true }
138
+ );
139
+ return {
140
+ lifePath: result.reducedValue,
141
+ reductionSteps: result.reductionSteps
142
+ };
143
+ }
144
+ function getDateEnergies(birthDate) {
145
+ const { day, month, year1, year2 } = mapDatePartsToBlocksOfTwo(
146
+ parseDate(birthDate)
147
+ );
148
+ const dayEnergy = reduceToSingleWithSteps(parseInt(day, 10), {
149
+ preserveMasters: true
150
+ });
151
+ const monthEnergy = reduceToSingleWithSteps(parseInt(month, 10), {
152
+ preserveMasters: true
153
+ });
154
+ const yearEnergy = reduceToSingleWithSteps(parseInt(year1 + year2, 10), {
155
+ preserveMasters: true
156
+ });
157
+ return {
158
+ dayEnergy,
159
+ monthEnergy,
160
+ yearEnergy
161
+ };
162
+ }
163
+ function calculateChallenges(birthDate) {
164
+ const { day, month, year } = parseDate(birthDate);
165
+ const reducedDay = reduceToSingle(parseInt(day, 10));
166
+ const reducedMonth = reduceToSingle(parseInt(month, 10));
167
+ const reducedYear = reduceToSingle(parseInt(year, 10));
168
+ const subChallenge1 = Math.abs(reducedMonth - reducedDay);
169
+ const subChallenge2 = Math.abs(reducedDay - reducedYear);
170
+ const mainChallenge = Math.abs(subChallenge1 - subChallenge2);
171
+ return {
172
+ day: reducedDay,
173
+ month: reducedMonth,
174
+ year: reducedYear,
175
+ mainChallenge,
176
+ subChallenge1,
177
+ subChallenge2
178
+ };
179
+ }
180
+ var CYCLE_MEANINGS = [
181
+ {
182
+ title: "Learning",
183
+ shortDescription: "A period for assertive action and learning through direct experience.",
184
+ personalDescription: "This period emphasizes assertive action and learning through direct experience. Utilize personal influence to seek favors, loans, or recognition from influential individuals such as government officials or community leaders. Ideal for enhancing personal reputation and prestige, keeping in mind that all actions carry consequences.",
185
+ businessDescription: "Ideal for promotional activities aimed at building goodwill, public recognition, and securing endorsements from prominent individuals. Prioritize the company's image and reputation over immediate profits.",
186
+ astrologySign: "Aries (Actions Have Consequences)"
187
+ },
188
+ {
189
+ title: "Hard Work",
190
+ shortDescription: "A time for diligent effort and adaptability to temporary changes.",
191
+ personalDescription: "A period where diligent effort and adaptability are crucial. Suitable for temporary changes such as moving homes, short trips, or career shifts. Avoid long-term commitments or significant investments unless carefully formalized.",
192
+ businessDescription: "Ideal for short-term experiments, temporary staffing adjustments, and forming beneficial business connections. Steer clear of verbal agreements or long-term commitments unless formally documented. Flexibility leads to progress.",
193
+ astrologySign: "Taurus (Stop Being Stubborn)"
194
+ },
195
+ {
196
+ title: "Friendship",
197
+ shortDescription: "A dynamic phase for ambitious projects and strengthening relationships.",
198
+ personalDescription: "A dynamic and energetic phase ideal for initiating ambitious projects requiring persistence and physical strength. Effective communication strengthens relationships, but impulsiveness should be avoided to prevent conflicts.",
199
+ businessDescription: "Ideal for expansion, energetic ventures, and assertive promotional activities. Excellent for debt collection but avoid legal conflicts. Maintain vigilance against accidents and disputes while leveraging strong communication.",
200
+ astrologySign: "Gemini (Communication is Power)"
201
+ },
202
+ {
203
+ title: "Opportunities",
204
+ shortDescription: "An intellectually fertile time for creativity and quick decision-making.",
205
+ personalDescription: "An intellectually fertile phase ideal for creative projects, innovation, and quick decision-making. Beware of deception, especially concerning documents or agreements. Foster mental growth and create valuable connections, but remain cautious.",
206
+ businessDescription: "Perfect for launching impactful marketing campaigns and securing new agreements. Excellent for promotional activities and intellectual creativity, but carefully scrutinize documents to avoid fraud.",
207
+ astrologySign: "Cancer (Nurture Mental Growth)"
208
+ },
209
+ {
210
+ title: "Tears/Decision",
211
+ shortDescription: "The most prosperous phase for financial resolution and spiritual advancement.",
212
+ personalDescription: "The most prosperous phase of the year, suitable for resolving financial issues, starting long journeys, and advancing spiritually. Interact with influential figures, manage debts, and engage in expansive social activities. Keep ego and selfishness balanced for optimal outcomes.",
213
+ businessDescription: "A prime time for investments, financial growth, global promotion, debt collection, and favorable legal outcomes. Emphasize fairness and generosity to enhance business success.",
214
+ astrologySign: "Leo (Balance Ego and Generosity)"
215
+ },
216
+ {
217
+ title: "Triple Blessing",
218
+ shortDescription: "Perfect for pleasures, social activities, and creative pursuits.",
219
+ personalDescription: "Ideal for enjoying pleasures, social activities, artistic endeavors, and short travels. Favorable for romantic interactions, relaxation, and creative pursuits. Organize personal life to balance enjoyment and refinement effectively.",
220
+ businessDescription: "Excellent time for promoting luxury products, arts, entertainment, and speculative investments. Ideal for forming friendly business alliances and strategic partnerships.",
221
+ astrologySign: "Virgo (Organize Your Pleasures)"
222
+ },
223
+ {
224
+ title: "Rest",
225
+ shortDescription: "A period of rest, introspection, and preparation for renewal.",
226
+ personalDescription: "A critical period of rest, introspection, and cautious preparation for renewal. Avoid initiating new ventures and instead focus on completing pending matters, managing legal affairs carefully, and protecting existing resources. Balance and patience are essential.",
227
+ businessDescription: "Period to conserve resources, avoid major expansions, and carefully manage internal restructuring. Postpone significant new ventures until the next cycle. Act diplomatically and cautiously to ensure stability.",
228
+ astrologySign: "Libra (Seek Balance and Reconstruction)"
229
+ }
230
+ ];
231
+ function addDays(date, days) {
232
+ const result = new Date(date);
233
+ result.setDate(result.getDate() + days);
234
+ return result;
235
+ }
236
+ function getMostRecentStartDate(startDate, today) {
237
+ const startMonth = startDate.getMonth();
238
+ const startDay = startDate.getDate();
239
+ let recentStart = new Date(today.getFullYear(), startMonth, startDay);
240
+ if (recentStart > today) {
241
+ recentStart = new Date(today.getFullYear() - 1, startMonth, startDay);
242
+ }
243
+ return recentStart;
244
+ }
245
+ function calculateCycles(startDate, today) {
246
+ const mostRecentStart = getMostRecentStartDate(startDate, today);
247
+ const cycleLength = 52;
248
+ const isFutureDate = startDate > today;
249
+ let currentYearlyCycle = null;
250
+ let currentAgeCycle = null;
251
+ const ageCycles = [];
252
+ const yearlyCycles = [];
253
+ if (!isFutureDate) {
254
+ const birthYear = startDate.getFullYear();
255
+ const currentYear = today.getFullYear();
256
+ const ageInYears = currentYear - birthYear;
257
+ currentAgeCycle = Math.floor(ageInYears / 7) % 7 + 1;
258
+ for (let i = 0; i < 7; i++) {
259
+ const cycleStart = new Date(
260
+ birthYear + i * 7,
261
+ startDate.getMonth(),
262
+ startDate.getDate()
263
+ );
264
+ const cycle = i + 1;
265
+ const isCurrentCycle = cycle === currentAgeCycle;
266
+ if (isCurrentCycle) {
267
+ const yearsSinceBirth = ageInYears;
268
+ const yearWithinAgeCycle = yearsSinceBirth % 7;
269
+ currentYearlyCycle = yearWithinAgeCycle + 1;
270
+ for (let j = 0; j < 7; j++) {
271
+ const ageCycleStartYear = birthYear + Math.floor(ageInYears / 7) * 7;
272
+ const yearlyCycleStart = new Date(
273
+ ageCycleStartYear + j,
274
+ startDate.getMonth(),
275
+ startDate.getDate()
276
+ );
277
+ const yearlyCycle = j + 1;
278
+ const isCurrentYearlyCycle = yearlyCycle === currentYearlyCycle;
279
+ yearlyCycles.push({
280
+ number: yearlyCycle,
281
+ description: CYCLE_MEANINGS[j],
282
+ isActive: isCurrentYearlyCycle,
283
+ cycleStart: yearlyCycleStart
284
+ });
285
+ }
286
+ }
287
+ ageCycles.push({
288
+ number: cycle,
289
+ description: CYCLE_MEANINGS[i],
290
+ isActive: isCurrentCycle,
291
+ cycleStart
292
+ });
293
+ }
294
+ }
295
+ const monthlyCycles = [];
296
+ for (let i = 0; i < 7; i++) {
297
+ const cycleStart = addDays(mostRecentStart, i * cycleLength);
298
+ monthlyCycles.push({
299
+ number: i + 1,
300
+ description: CYCLE_MEANINGS[i],
301
+ isActive: false,
302
+ cycleStart
303
+ });
304
+ }
305
+ let currentMonthlyCycle = null;
306
+ let daysInMonthlyCycle = 0;
307
+ for (let i = 0; i < 7; i++) {
308
+ const cycleStart = addDays(mostRecentStart, i * cycleLength);
309
+ const nextCycleStart = i < 6 ? addDays(mostRecentStart, (i + 1) * cycleLength) : addDays(mostRecentStart, 366);
310
+ if (today >= cycleStart && today < nextCycleStart) {
311
+ currentMonthlyCycle = i + 1;
312
+ daysInMonthlyCycle = Math.floor(
313
+ (today.getTime() - cycleStart.getTime()) / (1e3 * 60 * 60 * 24)
314
+ ) + 1;
315
+ monthlyCycles[i].isActive = true;
316
+ break;
317
+ }
318
+ }
319
+ const totalDays = Math.floor(
320
+ (today.getTime() - mostRecentStart.getTime()) / (1e3 * 60 * 60 * 24)
321
+ ) + 1;
322
+ return {
323
+ yearlyCycles,
324
+ ageCycles,
325
+ monthlyCycles,
326
+ currentYearlyCycle,
327
+ currentAgeCycle,
328
+ currentMonthlyCycle,
329
+ daysInMonthlyCycle,
330
+ totalDays
331
+ };
332
+ }
333
+ function calculateAge(birthDate, today = /* @__PURE__ */ new Date()) {
334
+ return today.getFullYear() - birthDate.getFullYear();
335
+ }
336
+ function calculateFibonacciCycle(birthDate, today) {
337
+ const currentAge = calculateAge(birthDate, today);
338
+ const cycle1 = reduceToSingleWithSteps(currentAge);
339
+ const cycle2 = reduceToSingleWithSteps(cycle1.reducedValue + 2);
340
+ const cycle3 = reduceToSingleWithSteps(
341
+ cycle1.reducedValue + cycle2.reductionSteps[0]
342
+ );
343
+ const cycle4 = reduceToSingleWithSteps(
344
+ cycle2.reductionSteps[0] + cycle3.reductionSteps[0]
345
+ );
346
+ const cycle5 = reduceToSingleWithSteps(
347
+ cycle3.reductionSteps[0] + cycle4.reductionSteps[0]
348
+ );
349
+ const cycle6 = reduceToSingleWithSteps(
350
+ cycle4.reductionSteps[0] + cycle5.reductionSteps[0]
351
+ );
352
+ const cycle7 = reduceToSingleWithSteps(
353
+ cycle5.reductionSteps[0] + cycle6.reductionSteps[0]
354
+ );
355
+ return {
356
+ currentAge,
357
+ cycle1,
358
+ cycle2,
359
+ cycle3,
360
+ cycle4,
361
+ cycle5,
362
+ cycle6,
363
+ cycle7
364
+ };
365
+ }
366
+ function calculateSoulNumber(firstName) {
367
+ return chunkJJ76YVMI_js.calculateGematria(firstName).vowels.finalValue;
368
+ }
369
+ function wrapMonth(month) {
370
+ const wrappedMonth = ((month - 1) % 12 + 12) % 12;
371
+ return wrappedMonth + 1;
372
+ }
373
+ function getLastBirthdayYear(birthDate, today) {
374
+ const thisYearsBirthday = new Date(
375
+ today.getFullYear(),
376
+ birthDate.getMonth(),
377
+ birthDate.getDate()
378
+ );
379
+ return today >= thisYearsBirthday ? today.getFullYear() : today.getFullYear() - 1;
380
+ }
381
+ function calculatePersonalYear(birthDate, today = /* @__PURE__ */ new Date()) {
382
+ const { day, month } = parseDate(birthDate);
383
+ const yearToUse = getLastBirthdayYear(birthDate, today);
384
+ return reduceToSingleWithSteps(
385
+ parseInt(day, 10) + parseInt(month, 10) + yearToUse,
386
+ { preserveMasters: true }
387
+ );
388
+ }
389
+ function calculatePersonalPeriods(birthDate, yearToUse, lifePath, soulNumber, currentAge) {
390
+ const { month } = parseDate(birthDate);
391
+ const birthMonth = parseInt(month, 10);
392
+ const periods = [
393
+ {
394
+ startMonth: wrapMonth(birthMonth + 0),
395
+ endMonth: wrapMonth(birthMonth + 3),
396
+ value: reduceToSingleWithSteps(yearToUse + currentAge, {
397
+ preserveMasters: true
398
+ })
399
+ },
400
+ {
401
+ startMonth: wrapMonth(birthMonth + 4),
402
+ endMonth: wrapMonth(birthMonth + 7),
403
+ value: reduceToSingleWithSteps(yearToUse + lifePath, {
404
+ preserveMasters: true
405
+ })
406
+ },
407
+ {
408
+ startMonth: wrapMonth(birthMonth + 8),
409
+ endMonth: wrapMonth(birthMonth + 11),
410
+ value: reduceToSingleWithSteps(yearToUse + soulNumber, {
411
+ preserveMasters: true
412
+ })
413
+ }
414
+ ];
415
+ return periods;
416
+ }
417
+ function diffInPersonalMonths(birthDate, today) {
418
+ const lastYear = getLastBirthdayYear(birthDate, today);
419
+ const base = new Date(lastYear, birthDate.getMonth(), birthDate.getDate());
420
+ let k = (today.getFullYear() - base.getFullYear()) * 12 + (today.getMonth() - base.getMonth());
421
+ if (today.getDate() < birthDate.getDate()) {
422
+ k -= 1;
423
+ }
424
+ if (k < 0) k = 0;
425
+ if (k > 12) k = 12;
426
+ return k;
427
+ }
428
+ function calculatePersonalMonths(birthDate, personalYear, today) {
429
+ const { month } = parseDate(birthDate);
430
+ const firstPersonalMonth = parseInt(month, 10);
431
+ const personalMonths = [];
432
+ for (let i = 0; i < 13; i++) {
433
+ const m = wrapMonth(firstPersonalMonth + i);
434
+ const value = reduceToSingleWithSteps(personalYear.reducedValue + m, {
435
+ preserveMasters: true
436
+ });
437
+ personalMonths.push({ month: m, value });
438
+ }
439
+ const currentPersonalMonthIndex = diffInPersonalMonths(birthDate, today);
440
+ return {
441
+ personalMonths,
442
+ currentPersonalMonthIndex
443
+ };
444
+ }
445
+ function calculatePersonalCycles(birthDate, today = /* @__PURE__ */ new Date(), firstName) {
446
+ const yearToUse = getLastBirthdayYear(birthDate, today);
447
+ const personalYear = calculatePersonalYear(birthDate, today);
448
+ const currentAge = calculateAge(
449
+ birthDate,
450
+ new Date(yearToUse, today.getMonth(), today.getDate())
451
+ );
452
+ const { lifePath } = calculateKaabalisticLifePath(birthDate);
453
+ const soulNumber = calculateSoulNumber(firstName);
454
+ const personalPeriods = calculatePersonalPeriods(birthDate, yearToUse, lifePath, soulNumber, currentAge);
455
+ const {
456
+ personalMonths,
457
+ currentPersonalMonthIndex: currentPersonalMonth
458
+ } = calculatePersonalMonths(birthDate, personalYear, today);
459
+ const currentPersonalPeriod = Math.floor(Math.min(currentPersonalMonth, 11) / 4);
460
+ return {
461
+ currentAge,
462
+ lifePath,
463
+ soulNumber,
464
+ personalYear,
465
+ personalPeriods,
466
+ personalMonths,
467
+ currentPersonalPeriod,
468
+ currentPersonalMonth
469
+ };
470
+ }
471
+
472
+ exports.CYCLE_MEANINGS = CYCLE_MEANINGS;
473
+ exports.MASTER_NUMBERS = MASTER_NUMBERS;
474
+ exports.calculateChallenges = calculateChallenges;
475
+ exports.calculateCycles = calculateCycles;
476
+ exports.calculateFibonacciCycle = calculateFibonacciCycle;
477
+ exports.calculateKaabalisticLifePath = calculateKaabalisticLifePath;
478
+ exports.calculatePersonalCycles = calculatePersonalCycles;
479
+ exports.calculatePersonalMonths = calculatePersonalMonths;
480
+ exports.calculatePersonalPeriods = calculatePersonalPeriods;
481
+ exports.calculatePersonalYear = calculatePersonalYear;
482
+ exports.calculateStraightAcrossReductionLifePath = calculateStraightAcrossReductionLifePath;
483
+ exports.getDateEnergies = getDateEnergies;
484
+ exports.isMasterNumber = isMasterNumber;
485
+ exports.reduceToSingle = reduceToSingle;
486
+ exports.reduceToSingleWithSteps = reduceToSingleWithSteps;
487
+ //# sourceMappingURL=chunk-SHEGSIRU.js.map
488
+ //# sourceMappingURL=chunk-SHEGSIRU.js.map