"use client"

import { useSearchParams } from "next/navigation"
import { Suspense } from "react"
import { LoginPageContent } from "@/components/auth/login-page-content"
import { useNativeRuntime } from "@/lib/platform"
import { NativeLogin } from "@/components/mobile/native-login"

function LoginContent() {
  const searchParams = useSearchParams()
  const error = searchParams.get("error")
  const returnTo = searchParams.get("returnTo") ?? "/mail/inbox"

  if (useNativeRuntime()) {
    return <NativeLogin returnTo={returnTo} />
  }

  return <LoginPageContent returnTo={returnTo} error={error} />
}

export default function LoginPage() {
  return (
    <Suspense fallback={null}>
      <LoginContent />
    </Suspense>
  )
}
