import type { AppConfig } from "@wrnexus/styles";

const config: AppConfig = {
  seo: {
    title: "WRNexus CAPTCHA Showcase",
    description:
      "Number, text, calculation, image, audio, invisible, managed, and third-party CAPTCHA examples.",
    canonicalBase: "http://localhost:3000",
    robots: "noindex,nofollow",
  },
  theme: { palette: "blue", default: "dark" },
  styles: {
    entry: "app/styles/global.css",
    process: async ({ entryPath, appRoot, mode }) => {
      if (!entryPath) throw new Error("CAPTCHA showcase stylesheet entry was not resolved.");
      const args = ["@tailwindcss/cli", "-i", entryPath];
      if (mode === "production") args.push("--minify");
      const result = await Bun.$.cwd(appRoot).nothrow()`bunx ${args}`;
      if (result.exitCode !== 0) {
        throw new Error(
          result.stderr.toString().trim() ||
            result.stdout.toString().trim() ||
            "Tailwind CSS processing failed.",
        );
      }
      return result.stdout.toString();
    },
    failureMode: "throw",
  },
};

export default config;
