'use client' import { useCallback, useState } from 'react' import clsx from 'clsx' import { Loader2, Shield, Eye, Wand2, Zap, Copy, Check, ShoppingCart, Sparkles, Lock, RefreshCw, Brain, Dices, } from 'lucide-react' import Link from 'next/link' import { api } from '@/lib/api' import { useAnalyzePanelStore } from '@/lib/analyze-store' import { useStore } from '@/lib/store' // ============================================================================ // CONSTANTS // ============================================================================ const PATTERNS = [ { key: 'cvcvc', label: 'CVCVC', example: 'Zalor', desc: 'Classic 5-letter' }, { key: 'cvccv', label: 'CVCCV', example: 'Bento', desc: 'Punchy sound' }, { key: 'human', label: 'Human', example: 'Alexa', desc: 'AI agent names' }, ] const TLDS = ['com', 'io', 'ai', 'co', 'net', 'app'] // ============================================================================ // COMPONENT // ============================================================================ export function BrandableForgeTab({ showToast }: { showToast: (msg: string, type?: any) => void }) { const openAnalyze = useAnalyzePanelStore((s) => s.open) const addDomain = useStore((s) => s.addDomain) const subscription = useStore((s) => s.subscription) const tier = (subscription?.tier || '').toLowerCase() const hasAI = tier === 'trader' || tier === 'tycoon' // Mode selection const [mode, setMode] = useState<'pattern' | 'ai'>('pattern') // Config const [pattern, setPattern] = useState('cvcvc') const [tlds, setTlds] = useState(['com', 'io']) const [concept, setConcept] = useState('') // State const [results, setResults] = useState>([]) const [loading, setLoading] = useState(false) const [aiLoading, setAiLoading] = useState(false) const [copied, setCopied] = useState(null) const [tracking, setTracking] = useState(null) // Generate from pattern const generatePattern = useCallback(async () => { if (tlds.length === 0) { showToast('Select at least one TLD', 'error') return } setLoading(true) setResults([]) try { const res = await api.huntBrandables({ pattern, tlds, limit: 24, max_checks: 300 }) setResults(res.items.map(i => ({ domain: i.domain }))) showToast(`Found ${res.items.length} domains!`, 'success') } catch (e) { showToast('Generation failed', 'error') } finally { setLoading(false) } }, [pattern, tlds, showToast]) // Generate from AI concept const generateFromConcept = useCallback(async () => { if (!concept.trim() || !hasAI) return setAiLoading(true) setResults([]) try { const res = await api.generateBrandableNames(concept.trim(), undefined, 15) if (res.names?.length) { const checkRes = await api.huntKeywords({ keywords: res.names, tlds }) const available = checkRes.items.filter(i => i.status === 'available') setResults(available.map(i => ({ domain: i.domain }))) showToast(`Found ${available.length} available from ${res.names.length} AI names!`, 'success') } } catch (e) { showToast('AI generation failed', 'error') } finally { setAiLoading(false) } }, [concept, hasAI, tlds, showToast]) // Actions const copy = (domain: string) => { navigator.clipboard.writeText(domain) setCopied(domain) setTimeout(() => setCopied(null), 1500) } const copyAll = () => { navigator.clipboard.writeText(results.map(r => r.domain).join('\n')) showToast(`Copied ${results.length} domains`, 'success') } const track = async (domain: string) => { if (tracking) return setTracking(domain) try { await addDomain(domain) showToast(`Added: ${domain}`, 'success') } catch (e) { showToast('Failed', 'error') } finally { setTracking(null) } } const isGenerating = loading || aiLoading return (
{/* ═══════════════════════════════════════════════════════════════════════ */} {/* HEADER */} {/* ═══════════════════════════════════════════════════════════════════════ */}

Brandable Forge

Generate unique, memorable domain names

{/* ═══════════════════════════════════════════════════════════════════════ */} {/* MODE SELECTOR - BIG CLEAR BUTTONS */} {/* ═══════════════════════════════════════════════════════════════════════ */}
{/* Pattern Mode */} {/* AI Mode */}
{/* ═══════════════════════════════════════════════════════════════════════ */} {/* PATTERN MODE */} {/* ═══════════════════════════════════════════════════════════════════════ */} {mode === 'pattern' && (
{/* Pattern Selection */}

Choose Pattern

{PATTERNS.map(p => ( ))}
{/* TLDs */}

Select TLDs

{TLDS.map(tld => ( ))}
{/* Generate */}
)} {/* ═══════════════════════════════════════════════════════════════════════ */} {/* AI MODE */} {/* ═══════════════════════════════════════════════════════════════════════ */} {mode === 'ai' && hasAI && (
{/* Concept Input */}

Describe Your Brand Concept