import { useRef, useState } from "react" import type { Site } from "@/lib/types" import { CAT_ORDER, catColor } from "@/lib/category" import { full, hfUrl, num } from "@/lib/format" import { href } from "@/lib/route" import { SiteHeader } from "@/components/site-header" import { CommunityChart, type Metric, useDownloadSeries, useSeries } from "@/components/community-chart" import { Segmented } from "@/components/segmented" import { ReleaseRail } from "@/components/release-rail" import { CategoryBlocks } from "@/components/category-blocks" import { CountUp, Stat } from "@/components/layout" import { HeroVideo } from "@/components/media" import { DownloadButton } from "@/components/download-button" import { catName, T } from "@/lib/i18n" export function Home({ site }: { site: Site }) { const [hidden, setHidden] = useState>(new Set()) const chartRef = useRef(null) const models = useSeries(site) const downloads = useDownloadSeries(site, models) const [metric, setMetric] = useState(downloads ? "downloads" : "models") // the headline is the end of this curve const series = metric === "downloads" && downloads ? downloads : models const { cats } = models const now = series.rows.at(-1)! const total = site.releases.reduce((a, r) => a + r.n, 0) const commDl = site.releases.reduce((a, r) => a + r.dlall, 0) const offDl = site.releases.reduce((a, r) => a + (r.official.dlall ?? 0), 0) const repos = site.releases.reduce((a, r) => a + r.models.length, 0) const toggle = (c: string) => setHidden((h) => { const n = new Set(h) if (n.has(c)) n.delete(c) else if (n.size < cats.length - 1) n.add(c) return n }) return ( <> {/* As on minimax.io: the M3.1 footage behind the top of the page, white type on it, and everything with small text in white cards. */}

full(Math.round(v))} /> {T.dlTagline}

{/* phones: the switch and the download button on a row of their own, above the chips */}
{CAT_ORDER.filter((c) => cats.includes(c)).reverse().map((c) => { const off = hidden.has(c) const name = catName(site.categories.find((x) => x.key === c)!) return ( ) })}
{downloads && ( )}
full(Math.round(v))} />} label={T.communityModels} /> } label={T.communityDownloads} /> } label={T.minimaxModelDownloads} /> full(Math.round(v))} />} label={T.builders} />

{T.byModality}

) }