// NOTE: This file is stable and usually should not be modified. // It is important that all functionality in this file is preserved, and should only be modified if explicitly requested. import React, { useState, useEffect } from 'react'; import { Shield, AlertTriangle, UserPlus, Sparkles } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogHeader, DialogDescription } from "@/components/ui/dialog"; import { Alert, AlertDescription } from '@/components/ui/alert'; import { useLoginActions } from '@/hooks/useLoginActions'; import { cn } from '@/lib/utils'; import LoginPanel from '@/components/auth/LoginPanel'; interface LoginDialogProps { isOpen: boolean; onClose: () => void; onLogin: () => void; onSignup?: () => void; } const LoginDialog: React.FC = ({ isOpen, onClose, onLogin, onSignup }) => { const [isExtensionLoading, setIsExtensionLoading] = useState(false); const [extensionError, setExtensionError] = useState(null); const login = useLoginActions(); useEffect(() => { if (isOpen) { setIsExtensionLoading(false); setExtensionError(null); } }, [isOpen]); const handleExtensionLogin = async () => { setIsExtensionLoading(true); setExtensionError(null); try { if (!('nostr' in window)) { throw new Error('Nostr extension not found. Please install a NIP-07 extension.'); } await login.extension(); onLogin(); onClose(); } catch (e: unknown) { const error = e as Error; console.error('Extension login failed:', error); setExtensionError( error instanceof Error ? error.message : 'Extension login failed', ); } finally { setIsExtensionLoading(false); } }; const handleSignupClick = () => { onClose(); if (onSignup) { onSignup(); } }; const handleLoggedIn = () => { onLogin(); onClose(); }; const hasExtension = typeof window !== 'undefined' && 'nostr' in window; return ( Sign up or log in to continue
{/* Prominent Sign Up Section */}
New to Nostr?

Create a new account to get started. It's free and open.

{/* Divider */}
Or log in
{/* Unified login panel — QR + nsec/bunker input + file upload */} {/* Extension login (only shown when a NIP-07 extension is present) */} {hasExtension && (
{extensionError && ( {extensionError} )}
)}
); }; export default LoginDialog;