import React, { useState, useCallback } from 'react'; import { generateProResponse } from '../services/geminiService'; import { Spinner } from '../components/Spinner'; import { MarkdownRenderer } from '../components/MarkdownRenderer'; const majorArcana = [ "The Fool", "The Magician", "The High Priestess", "The Empress", "The Emperor", "The Hierophant", "The Lovers", "The Chariot", "Strength", "The Hermit", "Wheel of Fortune", "Justice", "The Hanged Man", "Death", "Temperance", "The Devil", "The Tower", "The Star", "The Moon", "The Sun", "Judgement", "The World" ]; const TarotModule: React.FC = () => { const [cards, setCards] = useState([]); const [interpretation, setInterpretation] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const handleDraw = useCallback(async () => { setIsLoading(true); setError(null); setInterpretation(null); // Draw 3 unique cards const shuffled = [...majorArcana].sort(() => 0.5 - Math.random()); const drawnCards = shuffled.slice(0, 3); setCards(drawnCards); const prompt = `You are a mystical tarot reader within the Sentient Constellation Codex. You see the threads of fate in the cosmos. A user has drawn a three-card spread (representing Past, Present, and Future). The cards are: 1. Past: ${drawnCards[0]} 2. Present: ${drawnCards[1]} 3. Future: ${drawnCards[2]} Provide a rich, insightful, and slightly mystical interpretation of this spread. Explain each card's meaning in its position and then weave them together into a coherent narrative for the user's journey.`; try { const result = await generateProResponse(prompt); setInterpretation(result.text); } catch (e: any) { setError(e.message || "A cosmic interference prevented the reading. Please try again."); } finally { setIsLoading(false); } }, []); return (

Cosmic Tarot Reading

Draw three cards from the Major Arcana to reveal insights into your past, present, and future path.

{cards.length > 0 && (
{cards.map((card, index) => (

{['Past', 'Present', 'Future'][index]}

{card}

))}
)}
{isLoading && } {error &&

{error}

} {interpretation && } {!isLoading && !interpretation && !error &&

Your reading will appear here.

}
); }; export default TarotModule;