import { redirect } from "next/navigation";

import { SetupWizard } from "@/features/setup/components/setup-wizard";
import { getBootstrapSetupStatus } from "@/features/setup/server/setup-bootstrap.service";

export const metadata = {
  title: "ALLA OS Setup",
};

export default async function BootstrapSetupPage() {
  const status = await getBootstrapSetupStatus();

  if (status.initialized) {
    redirect("/auth/sign-in");
  }

  return (
    <main className="min-h-screen bg-background py-8 px-4">
      <div className="flex w-full flex-col gap-6">
        <div className="space-y-2">
          <h1 className="text-3xl font-semibold tracking-normal">
            ALLA OS Setup
          </h1>
          <p className="max-w-3xl text-sm text-muted-foreground">
            Preview setup CSV files from SETUP_IMPORT_DIR, run the import, then
            complete setup.
          </p>
        </div>
        <SetupWizard mode="public" tokenRequired={status.tokenRequired} />
      </div>
    </main>
  );
}
