import React, { useState, useCallback } from 'react'; import { generateProResponse } from '../services/geminiService'; import { Spinner } from '../components/Spinner'; import { MarkdownRenderer } from '../components/MarkdownRenderer'; const AlchemistsJourneyModule: React.FC = () => { const [theme, setTheme] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [script, setScript] = useState(null); const handleGenerate = useCallback(async () => { if (!theme.trim()) { setError('Please enter a theme for your journey.'); return; } setIsLoading(true); setError(null); setScript(null); const prompt = `You are the Crystal Alchemist within the Sentient Constellation Codex. You guide souls on transformational journeys. A user wishes to embark on a journey with the theme of "${theme}". Generate a beautiful, immersive, and healing guided meditation script. The script should be about 500 words long. Use rich sensory details, metaphors of alchemy and crystals, and guide the user through a journey of self-discovery and empowerment related to their chosen theme. Structure it with an introduction, a main visualization, and a gentle return to awareness.`; try { const result = await generateProResponse(prompt); setScript(result.text); } catch (e: any) { setError(e.message || 'An unknown error occurred while crafting the journey.'); } finally { setIsLoading(false); } }, [theme]); return (

The Crystal Alchemist's Journey

Enter a theme or intention to begin a personalized, AI-generated guided meditation for transformation.

setTheme(e.target.value)} placeholder="e.g., Clarity, Releasing Fear, Embracing Creativity..." className="flex-grow bg-gray-700 border border-gray-600 rounded-md p-3 focus:outline-none focus:ring-2 focus:ring-cyan-500 text-white" disabled={isLoading} onKeyPress={(e) => e.key === 'Enter' && !isLoading && handleGenerate()} />
{isLoading && } {error &&

{error}

} {script && } {!isLoading && !script && !error &&

Your transformational journey awaits.

}
); }; export default AlchemistsJourneyModule;