import 'server-only'; import { isoLookupFromCountries, worldPaths } from '@/lib/map-geo'; import type { CountrySummary } from '@/lib/types'; import type { BaseFeature } from './indicator-map'; /** Server-side: world geometry joined with the country list (slug, flag) — values are added client-side. */ export function baseFeatures(countries: CountrySummary[]): { features: BaseFeature[]; sphere: string } { const { paths, sphere } = worldPaths(); const byId = new Map(countries.map((c) => [c.id, c])); const numeric = isoLookupFromCountries(countries as Array<{ id: string; iso_numeric?: string | null }>); const features = paths.map((p) => { const iso3 = p.iso3 ?? (p.numeric ? numeric.get(p.numeric) ?? null : null); const c = iso3 ? byId.get(iso3) : undefined; return { iso3, name: c?.name ?? p.name, slug: c?.slug ?? null, flag: c?.flag ?? null, d: p.d }; }); return { features, sphere }; }