import { shopProducts, type ShopProduct } from "@/data/shop";

type ImageOverride = Partial<
  Pick<ShopProduct, "imageSrc" | "imageWidth" | "imageHeight" | "aosDelay">
>;

/**
 * Related products on the product detail page: same catalog ids as the main
 * shop (for cart + pricing) with detail-page imagery (shop2-* webp).
 */
const productDetailRelatedConfig: { id: string; override: ImageOverride }[] =
  [
    {
      id: "yellow-woman-bag",
      override: {
        imageSrc: "/assets/images/shop/shop2-1.webp",
        aosDelay: 300,
      },
    },
    {
      id: "stylish-golden-watch",
      override: {
        imageSrc: "/assets/images/shop/shop2-2.webp",
        aosDelay: 400,
      },
    },
    {
      id: "headphones-djs",
      override: {
        imageSrc: "/assets/images/shop/shop2-3.webp",
        aosDelay: 500,
      },
    },
  ];

export function getProductDetailRelatedProducts(): ShopProduct[] {
  return productDetailRelatedConfig.map(({ id, override }) => {
    const base = shopProducts.find((p) => p.id === id);
    if (!base) {
      throw new Error(`product-detail-related: missing shop product id "${id}"`);
    }
    return { ...base, ...override };
  });
}
