import { getAuthMode } from '@/lib/auth.js';
import LoginClient from './login-client.jsx';

export const dynamic = 'force-dynamic';

export const metadata = {
  title: 'Sign in — madarX OS',
  description: 'Supabase-authenticated access to the madarX OS control plane.',
};

export default async function LoginPage({ searchParams }) {
  const params = (await searchParams) || {};
  return (
    <LoginClient
      authMode={getAuthMode()}
      nextPath={params.next || '/'}
      errorCode={params.error || ''}
      forceSupabase={params.supabase === '1'}
      initialView={params.view === 'personal' || params.view === 'team' ? params.view : ''}
    />
  );
}
