import { ImageResponse } from "next/og";
import { getLocalizedProducts } from "@/data/localized-data";

export const alt = "Original Nest Product";
export const size = { width: 1200, height: 630 };
export const contentType = "image/png";

export default async function Image({
  params,
}: {
  params: Promise<{ locale: string; slug: string }>;
}) {
  const { locale, slug } = await params;
  const products = getLocalizedProducts(locale);
  const product = products.find((p) => p.slug === slug);
  const name = product?.name ?? "Original Nest";

  return new ImageResponse(
    (
      <div
        style={{
          background: "#fbfaf7",
          width: "100%",
          height: "100%",
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
        }}
      >
        <div
          style={{
            color: "#2d251a",
            fontWeight: 700,
            fontSize: 56,
            textAlign: "center",
            padding: "0 60px",
            lineHeight: 1.2,
          }}
        >
          {name}
        </div>
        <div
          style={{
            color: "#a6905e",
            fontSize: 20,
            marginTop: 24,
            letterSpacing: "0.15em",
          }}
        >
          ORIGINAL NEST — INDONESIA
        </div>
      </div>
    ),
    { ...size },
  );
}