kaabalah
Version:
The de-facto library for any esoteric calculations and tooling
1 lines • 14.2 kB
Source Map (JSON)
{"version":3,"sources":["../../src/numerology/index.ts"],"sourcesContent":["/**\n * Numerology calculations\n */\n\n/**\n * Calculate the life path number based on a birth date\n * @param birthDate - Birth date as a Date object\n * @returns Life path number (1-9, 11, 22, or 33)\n */\nexport function calculateLifePath(birthDate: Date): number {\n const dateString = birthDate.toISOString().split('T')[0]; // YYYY-MM-DD\n const dateWithoutDashes = dateString.replace(/-/g, '');\n \n // Initial sum of all digits\n let sum = dateWithoutDashes.split('').reduce((total, digit) => {\n return total + parseInt(digit, 10);\n }, 0);\n \n // Reduce to a single digit or master number\n while (sum > 9 && sum !== 11 && sum !== 22 && sum !== 33) {\n sum = sum.toString().split('').reduce((total, digit) => {\n return total + parseInt(digit, 10);\n }, 0);\n }\n \n return sum;\n}\n\n\nexport const CYCLE_MEANINGS = [\n {\n \"title\": \"Learning\",\n \"shortDescription\": \"A period for assertive action and learning through direct experience.\",\n \"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.\",\n \"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.\",\n \"astrologySign\": \"Aries (Actions Have Consequences)\"\n },\n {\n \"title\": \"Hard Work\",\n \"shortDescription\": \"A time for diligent effort and adaptability to temporary changes.\",\n \"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.\",\n \"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.\",\n \"astrologySign\": \"Taurus (Stop Being Stubborn)\"\n },\n {\n \"title\": \"Friendship\",\n \"shortDescription\": \"A dynamic phase for ambitious projects and strengthening relationships.\",\n \"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.\",\n \"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.\",\n \"astrologySign\": \"Gemini (Communication is Power)\"\n },\n {\n \"title\": \"Opportunities\",\n \"shortDescription\": \"An intellectually fertile time for creativity and quick decision-making.\",\n \"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.\",\n \"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.\",\n \"astrologySign\": \"Cancer (Nurture Mental Growth)\"\n },\n {\n \"title\": \"Tears/Decision\",\n \"shortDescription\": \"The most prosperous phase for financial resolution and spiritual advancement.\",\n \"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.\",\n \"businessDescription\": \"A prime time for investments, financial growth, global promotion, debt collection, and favorable legal outcomes. Emphasize fairness and generosity to enhance business success.\",\n \"astrologySign\": \"Leo (Balance Ego and Generosity)\"\n },\n {\n \"title\": \"Triple Blessing\",\n \"shortDescription\": \"Perfect for pleasures, social activities, and creative pursuits.\",\n \"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.\",\n \"businessDescription\": \"Excellent time for promoting luxury products, arts, entertainment, and speculative investments. Ideal for forming friendly business alliances and strategic partnerships.\",\n \"astrologySign\": \"Virgo (Organize Your Pleasures)\"\n },\n {\n \"title\": \"Rest\",\n \"shortDescription\": \"A period of rest, introspection, and preparation for renewal.\",\n \"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.\",\n \"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.\",\n \"astrologySign\": \"Libra (Seek Balance and Reconstruction)\"\n }\n];\n\nexport interface Cycle {\n number: number;\n description: {\n title: string;\n shortDescription: string;\n personalDescription: string;\n businessDescription: string;\n astrologySign: string;\n };\n isActive?: boolean;\n cycleStart?: Date;\n}\n\nexport interface CycleInfo {\n yearlyCycles: Cycle[];\n ageCycles: Cycle[];\n monthlyCycles: Cycle[];\n currentYearlyCycle: number | null;\n currentAgeCycle: number | null;\n currentMonthlyCycle: number | null;\n daysInMonthlyCycle: number;\n totalDays: number;\n}\n\n// Add days to a date\nconst addDays = (date: Date, days: number) => {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n};\n\n// Find the most recent anniversary of the start date\nconst getMostRecentStartDate = (startDate: Date, today: Date) => {\n const startMonth = startDate.getMonth();\n const startDay = startDate.getDate();\n let recentStart = new Date(today.getFullYear(), startMonth, startDay);\n if (recentStart > today) {\n recentStart = new Date(today.getFullYear() - 1, startMonth, startDay);\n }\n return recentStart;\n};\n\n// Calculate cycles (annual and monthly)\nexport const calculateCycles = (startDate: Date, today: Date): CycleInfo => {\n const mostRecentStart = getMostRecentStartDate(startDate, today);\n const cycleLength = 52; // Fixed cycle length for monthly cycles\n\n // Skip annual cycle calculation if start date is in the future\n const isFutureDate = startDate > today;\n let currentYearlyCycle = null;\n let currentAgeCycle = null;\n const ageCycles: Cycle[] = [];\n const yearlyCycles: Cycle[] = [];\n if (!isFutureDate) {\n const birthYear = startDate.getFullYear();\n const currentYear = today.getFullYear();\n const ageInYears = currentYear - birthYear;\n currentAgeCycle = (Math.floor(ageInYears / 7) % 7) + 1;\n for (let i = 0; i < 7; i++) {\n // cycle start for year is which year it started\n const cycleStart = new Date(birthYear + (i * 7), startDate.getMonth(), startDate.getDate());\n\n const cycle = i + 1;\n const isCurrentCycle = cycle === currentAgeCycle;\n\n if (isCurrentCycle) {\n // Calculate yearly cycles within the current age cycle\n // The yearly cycle is based on the person's exact age in years\n // For example, if someone is 6 years old, they're in the 1st age cycle (0-7 years) and the 6th yearly cycle\n const yearsSinceBirth = ageInYears;\n const yearWithinAgeCycle = yearsSinceBirth % 7; // 0-6 representing which year within the current age cycle\n currentYearlyCycle = yearWithinAgeCycle + 1; // Convert to 1-7 range\n \n for (let j = 0; j < 7; j++) {\n // Calculate the start date for each yearly cycle within the current age cycle\n const ageCycleStartYear = birthYear + (Math.floor(ageInYears / 7) * 7); // Start year of current age cycle\n const yearlyCycleStart = new Date(ageCycleStartYear + j, startDate.getMonth(), startDate.getDate());\n const yearlyCycle = j + 1;\n \n const isCurrentYearlyCycle = yearlyCycle === currentYearlyCycle;\n \n yearlyCycles.push({\n number: yearlyCycle,\n description: CYCLE_MEANINGS[j],\n isActive: isCurrentYearlyCycle,\n cycleStart: yearlyCycleStart\n });\n }\n }\n\n ageCycles.push({\n number: cycle,\n description: CYCLE_MEANINGS[i],\n isActive: isCurrentCycle,\n cycleStart,\n });\n }\n }\n\n // Monthly cycles (relative to start date)\n const monthlyCycles: Cycle[] = [];\n for (let i = 0; i < 7; i++) {\n const cycleStart = addDays(mostRecentStart, i * cycleLength);\n \n monthlyCycles.push({\n number: i + 1,\n description: CYCLE_MEANINGS[i],\n isActive: false,\n cycleStart: cycleStart\n });\n }\n\n // Find current monthly cycle\n let currentMonthlyCycle = null;\n let daysInMonthlyCycle = 0;\n for (let i = 0; i < 7; i++) {\n const cycleStart = addDays(mostRecentStart, i * cycleLength);\n const nextCycleStart = i < 6 ? addDays(mostRecentStart, (i + 1) * cycleLength) : addDays(mostRecentStart, 366);\n if (today >= cycleStart && today < nextCycleStart) {\n currentMonthlyCycle = i + 1;\n daysInMonthlyCycle = Math.floor((today.getTime() - cycleStart.getTime()) / (1000 * 60 * 60 * 24)) + 1;\n monthlyCycles[i].isActive = true;\n break;\n }\n }\n\n const totalDays = Math.floor((today.getTime() - mostRecentStart.getTime()) / (1000 * 60 * 60 * 24)) + 1;\n\n return {\n yearlyCycles,\n ageCycles,\n monthlyCycles,\n currentYearlyCycle,\n currentAgeCycle,\n currentMonthlyCycle,\n daysInMonthlyCycle,\n totalDays\n };\n};"],"mappings":";AASO,SAAS,kBAAkB,WAAyB;AACzD,QAAM,aAAa,UAAU,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AACvD,QAAM,oBAAoB,WAAW,QAAQ,MAAM,EAAE;AAGrD,MAAI,MAAM,kBAAkB,MAAM,EAAE,EAAE,OAAO,CAAC,OAAO,UAAU;AAC7D,WAAO,QAAQ,SAAS,OAAO,EAAE;AAAA,EACnC,GAAG,CAAC;AAGJ,SAAO,MAAM,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,IAAI;AACxD,UAAM,IAAI,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,OAAO,UAAU;AACtD,aAAO,QAAQ,SAAS,OAAO,EAAE;AAAA,IACnC,GAAG,CAAC;AAAA,EACN;AAEA,SAAO;AACT;AAGO,IAAM,iBAAiB;AAAA,EAC5B;AAAA,IACE,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,IACE,SAAS;AAAA,IACT,oBAAoB;AAAA,IACpB,uBAAuB;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