"use client" import type React from "react" import { useState, useEffect } from "react" import { Key, ExternalLink, ArrowRight } from "lucide-react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog" interface ApiKeyModalProps { isOpen: boolean onClose: () => void onSubmit: (key: string) => void } export function ApiKeyModal({ isOpen, onClose, onSubmit }: ApiKeyModalProps) { const [apiKey, setApiKey] = useState("") const [isLoading, setIsLoading] = useState(false) const [existingKey, setExistingKey] = useState(null) useEffect(() => { if (typeof window !== "undefined" && isOpen) { const storedKey = localStorage.getItem("together_api_key") setExistingKey(storedKey) if (storedKey && apiKey === "") { setApiKey(storedKey) } } }, [isOpen]) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!apiKey.trim()) return setIsLoading(true) await new Promise((resolve) => setTimeout(resolve, 500)) setIsLoading(false) onSubmit(apiKey.trim()) setApiKey("") } return (
{existingKey ? "Update your API key" : "Add your API key to continue"} {existingKey ? "Update your Together API key or add a new one." : "Your first page was free! Add your Together API key to generate more pages."}
setApiKey(e.target.value)} placeholder="Enter your API key..." className="bg-secondary border-border/50 text-white placeholder-muted-foreground py-5" /> Get your free API key

Your API key is stored locally and never sent to our servers.

) }