"""Starting point for lichess-bot."""
from lib.lichess_bot import start_program
import threading
import gradio as gr

def launch_gradio():
    # This keeps Hugging Face happy in the background
    with gr.Blocks() as demo:
        gr.Markdown("# 🤖 Stockfish 18 Lichess Bot")
        gr.Markdown("Status: **Healthy & Running**")
    demo.launch(server_name="0.0.0.0", server_port=7860)

if __name__ == "__main__":
    # 1. Start Gradio in the background first
    gradio_thread = threading.Thread(target=launch_gradio, daemon=True)
    gradio_thread.start()

    # 2. Run the original bot logic EXACTLY how it used to run
    start_program()