'use client'; import * as React from 'react'; import { cn } from '../../../lib/utils'; import { FLAG_COMPONENTS } from './flag-map'; import { getLanguageCountryCode } from './language-to-country'; export interface FlagProps extends Omit, 'children'> { /** ISO 3166-1 alpha-2 country code (e.g. `'US'`, `'JP'`). Case-insensitive. */ countryCode: string; /** Optional rounded corners — common for tile / chip presentations. */ rounded?: boolean; } /** * SVG country flag (3:2 aspect). Renders nothing for unknown country codes * — call sites should reserve space if they want a stable layout. */ export function Flag({ countryCode, rounded, className, ...props }: FlagProps) { const code = countryCode?.toUpperCase(); const Component = code ? FLAG_COMPONENTS[code] : undefined; if (!Component) return null; // `country-flag-icons` types its components against an HTML+SVG intersection; // we narrow to plain `SVGAttributes` for our consumers. const Tag = Component as unknown as React.ComponentType>; return (