export interface LifeArea { id: string; label: string; vargas: string[]; description: string; promptGuidance: string; } export const LIFE_AREAS: LifeArea[] = [ { id: 'career', label: 'Career, Status & Life Purpose', vargas: ['D1', 'D9', 'D10'], description: 'Synthesize how the native\'s innate spiritual path manifests in their daily career and public impact.', promptGuidance: ` SPECIFIC FOCUS FOR CAREER & LIFE PURPOSE: Examine the D10 (Dashamsha) to determine the exact field of action, level of authority, and public status. Cross-reference this heavily with the D9 (Navamsha) to ensure the career aligns with their spiritual Dharma and deeper destiny. `.trim() }, { id: 'wealth', label: 'Wealth & Financial Capacity', vargas: ['D1', 'D2', 'D4'], description: 'Evaluate the capacity to generate liquid wealth (Hora) versus holding fixed real estate and assets.', promptGuidance: ` SPECIFIC FOCUS FOR WEALTH & FINANCES: Examine the D2 (Hora) for liquid cash flow, resources, and their ability to take on financial responsibilities. Examine the D4 (Chaturthamsha) for their capacity to accumulate fixed assets and property. `.trim() }, { id: 'relationships', label: 'Marriage & Committed Relationships', vargas: ['D1', 'D9'], description: 'Analyze relationship quality, partner traits, and spiritual lessons learned through unions.', promptGuidance: ` SPECIFIC FOCUS FOR MARRIAGE & RELATIONSHIPS: Deeply analyze the D9 (Navamsha) as the primary chart of marriage and devoted partnership. `.trim() }, { id: 'health', label: 'Health, Obstacles & Misfortune', vargas: ['D1', 'D3', 'D30'], description: 'Uncover hidden vulnerabilities, accident-proneness, and the capacity to overcome fated suffering.', promptGuidance: ` SPECIFIC FOCUS FOR HEALTH & OBSTACLES: Examine the D3 (Drekkana) for baseline vitality and the D30 (Trishamsha) for fated evils/subconscious diseases. `.trim() }, { id: 'spirituality', label: 'Spiritual Calling & Root Karma', vargas: ['D1', 'D9', 'D60'], description: 'Examine the deep, lingering past life karma and what the soul is supposed to learn in this incarnation.', promptGuidance: ` SPECIFIC FOCUS FOR ROOT KARMA & SPIRITUALITY: Examine the D60 (Shashtiamsha) to uncover the hidden past-life actions forcing current life circumstances. `.trim() } ]; export function getLifeAreaById(id: string): LifeArea | undefined { return LIFE_AREAS.find(area => area.id === id); } export const ZODIAC_SIGNS = [ "ARIES", "TAURUS", "GEMINI", "CANCER", "LEO", "VIRGO", "LIBRA", "SCORPIO", "SAGITTARIUS", "CAPRICORN", "AQUARIUS", "PISCES" ]; const SIGN_LORDS: Record = { ARIES: "Mars", TAURUS: "Venus", GEMINI: "Mercury", CANCER: "Moon", LEO: "Sun", VIRGO: "Mercury", LIBRA: "Venus", SCORPIO: "Mars", SAGITTARIUS: "Jupiter", CAPRICORN: "Saturn", AQUARIUS: "Saturn", PISCES: "Jupiter" }; export function getHouseToSignMap(lagnaSign: string): Record { const normalizedLagna = lagnaSign.toUpperCase().trim(); const startIndex = ZODIAC_SIGNS.indexOf(normalizedLagna); if (startIndex === -1) return {}; const map: Record = {}; for (let i = 0; i < 12; i++) { const houseNum = i + 1; const signIndex = (startIndex + i) % 12; map[houseNum] = ZODIAC_SIGNS[signIndex]; } return map; } export function formatHouseMapForAI(map: Record): string { return Object.entries(map) .map(([house, sign]) => `House ${house}: ${sign}`) .join('\n'); } export function getLordshipMap(lagnaSign: string): Record { const houseToSign = getHouseToSignMap(lagnaSign); const lordshipMap: Record = {}; for (let house = 1; house <= 12; house++) { const sign = houseToSign[house]; lordshipMap[house] = SIGN_LORDS[sign]; } return lordshipMap; } export function formatLordshipMapForAI(map: Record): string { return Object.entries(map) .map(([house, lord]) => `House ${house} Lord: ${lord}`) .join('\n'); } export interface PlanetPosition { name: string; sign: string; degree: number; minutes: number; seconds: number; totalDecimal: number; } export function extractPlanetsFromLongitudes(table: string): Record { const planets: Record = {}; const lines = table.split('\n'); const signMap: Record = { 'Ar': 'ARIES', 'Ta': 'TAURUS', 'Ge': 'GEMINI', 'Cn': 'CANCER', 'Le': 'LEO', 'Vi': 'VIRGO', 'Li': 'LIBRA', 'Sc': 'SCORPIO', 'Sg': 'SAGITTARIUS', 'Cp': 'CAPRICORN', 'Aq': 'AQUARIUS', 'Pi': 'PISCES' }; const planetNames = ['Sun', 'Moon', 'Mars', 'Mercury', 'Jupiter', 'Venus', 'Saturn', 'Rahu', 'Ketu']; for (const line of lines) { const foundPlanet = planetNames.find(p => line.includes(p)); if (!foundPlanet) continue; if (planets[foundPlanet]) continue; const match = line.match(/(\d+)[\s°]+(Ar|Ta|Ge|Cn|Le|Vi|Li|Sc|Sg|Cp|Aq|Pi|Aries|Taurus|Gemini|Cancer|Leo|Virgo|Libra|Scorpio|Sagittarius|Capricorn|Aquarius|Pisces)\s*(?:(\d+)'\s*)?(?:([\d.]+)")?/i); if (match) { const deg = parseInt(match[1]); const rawSign = match[2]; const min = match[3] ? parseInt(match[3]) : 0; const sec = match[4] ? parseFloat(match[4]) : 0; const fullSign = signMap[rawSign] || rawSign.toUpperCase(); planets[foundPlanet] = { name: foundPlanet, sign: fullSign, degree: deg, minutes: min, seconds: sec, totalDecimal: deg + (min / 60) + (sec / 3600) }; } if (Object.keys(planets).length === 9) break; } return planets; } export function calculateAtmakaraka(planets: Record): string { let ak = ""; let maxDeg = -1; Object.entries(planets).forEach(([name, pos]) => { if (name === 'Rahu' || name === 'Ketu') return; if (pos.totalDecimal > maxDeg) { maxDeg = pos.totalDecimal; ak = name; } }); return ak; } export function getPlanetHouse(planetSign: string, lagnaSign: string): number { const lagnaIdx = ZODIAC_SIGNS.indexOf(lagnaSign.toUpperCase()); const planetIdx = ZODIAC_SIGNS.indexOf(planetSign.toUpperCase()); if (lagnaIdx === -1 || planetIdx === -1) return 0; return ((planetIdx - lagnaIdx + 12) % 12) + 1; } export interface NaturalQualities { benefics: string[]; malefics: string[]; } export function getNaturalQualities(planets: Record): NaturalQualities { const benefics: string[] = []; const malefics: string[] = []; Object.keys(planets).forEach(name => { if (name === 'Jupiter' || name === 'Venus') { benefics.push(name); } else if (name === 'Sun' || name === 'Mars' || name === 'Saturn' || name === 'Rahu' || name === 'Ketu') { malefics.push(name); } else if (name === 'Moon' || name === 'Mercury') { benefics.push(name); } }); return { benefics, malefics }; }