import type { NextConfig } from "next";

const defaultAuthMode = process.env.NODE_ENV === "development" ? "mock" : "real";
const authMode = (process.env.NEXT_PUBLIC_AUTH_MODE ?? defaultAuthMode).toLowerCase();

if (!["real", "mock"].includes(authMode)) {
  throw new Error(`Invalid NEXT_PUBLIC_AUTH_MODE "${authMode}". Expected one of: real, mock.`);
}

if (authMode === "mock" && process.env.NODE_ENV !== "development") {
  throw new Error("NEXT_PUBLIC_AUTH_MODE=mock is only allowed for local development.");
}

const nextConfig: NextConfig = {
  transpilePackages: ["@mosaic/ui", "@mosaic/shared"],
};

export default nextConfig;
