import type { NextConfig } from "next";

/**
 * Legacy static-site URLs (`*.html`) → new route paths.
 * Keeps old links, bookmarks and search-engine rankings working.
 */
const legacyHtmlRedirects = [
  ["/index.html", "/"],
  ["/about-us.html", "/about-us"],
  ["/services.html", "/services"],
  ["/membership-benefits.html", "/membership-benefits"],
  ["/partnership-directory.html", "/partnership-directory"],
  ["/privacy-policy.html", "/privacy-policy"],
  ["/service-close-protection.html", "/services/close-protection"],
  ["/service-travel.html", "/services/travel"],
  ["/service-global-risk.html", "/services/global-risk"],
  ["/service-concierge.html", "/services/concierge"],
  ["/service-training.html", "/services/training"],
  ["/service-chauffeur.html", "/services/chauffeur"],
  ["/service-medical.html", "/services/medical"],
  ["/service-hospitality.html", "/services/hospitality"],
] as const;

const nextConfig: NextConfig = {
  cacheComponents: true,
  partialPrefetching: true,
  turbopack: {
    rules: {
      "*.css": {
        loaders: ["@tailwindcss/turbopack"],
        as: "*.css",
      },
    },
  },
  images: {
    formats: ["image/avif", "image/webp"],
    remotePatterns: [
      {
        protocol: "http",
        hostname: "dev.saturncube.com",
        port: "9227",
        pathname: "/**",
      },
      {
        protocol: "https",
        hostname: "**",
      },
    ],
  },
  async redirects() {
    return legacyHtmlRedirects.map(([source, destination]) => ({
      source,
      destination,
      permanent: true,
    }));
  },
};

export default nextConfig;
