/**
 * Banner — Server Component
 *
 * Headline and platform statistics come from the CMS (`GET /home/`, ISR 60 s);
 * the slides come from the home placement (`GET /banner-images/`, ISR 60 s,
 * see `toHeroBanners`). Both are fetched on the server, so the first banner
 * image is present in the initial HTML response and the browser can start
 * downloading the LCP image as soon as the first byte arrives.
 *
 * Interactive behaviour (auto-advance, dot clicks) lives in BannerCarousel.
 */
import { fetchHomeCms } from "@/features/cms/services/server";
import { fetchBannerData } from "@/features/home/services/server";
import { toHeroBanners } from "@/features/home/homeHeroBanners";
import BannerCarousel from "./BannerCarousel";

export default async function Banner({ showStatistics = true }: { showStatistics?: boolean } = {}) {
  const [cms, bannerData] = await Promise.all([fetchHomeCms(), fetchBannerData()]);

  return (
    <BannerCarousel
      showStatistics={showStatistics}
      banners={toHeroBanners(bannerData?.banner_images)}
      statistics={cms?.statistics ?? null}
      heroTitleEn={cms?.hero?.title_en}
      heroTitleAr={cms?.hero?.title_ar}
    />
  );
}
