{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "countries",
  "title": "Countries",
  "description": "A country's flag, drawn as an SVG so it shows on Windows too, its name in the reader's language, and the short names people search by.",
  "dependencies": [
    "country-flag-icons"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/lib/countries.tsx",
      "content": "import * as flags from 'country-flag-icons/string/3x2'\nimport type { ComponentProps } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * Countries as people see them and look for them: a flag drawn as an SVG,\n * since Windows has no flag emoji and shows two letters in their place, a\n * name in the reader's language from the browser's own `Intl.DisplayNames`,\n * and the short names people search by.\n */\n\nconst flagSvgs = flags as unknown as Record<string, string | undefined>\nconst flagUrls = new Map<string, string>()\n\n/** `country`'s flag as an image URL: one element per flag, never an SVG tree of hundreds, so a list of every country opens at once. */\nfunction flagUrl(country: string): string | undefined {\n  const code = country.toUpperCase().replace('-', '_')\n  let url = flagUrls.get(code)\n  if (url === undefined) {\n    const svg = flagSvgs[code]\n    if (!svg) return undefined\n    url = `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`\n    flagUrls.set(code, url)\n  }\n  return url\n}\n\n/**\n * `country`'s flag, as an ISO 3166-1 code such as `GB`, at 3:2 in a hairline\n * frame, so a white flag still has an edge on a white page. It is decorative:\n * name the country beside it. A code with no flag keeps its room, empty.\n */\nfunction CountryFlag({\n  country,\n  className,\n  style,\n  ...props\n}: Omit<ComponentProps<'span'>, 'children'> & { country: string }) {\n  return (\n    <span\n      data-slot='country-flag'\n      aria-hidden\n      className={cn(\n        // 1.125rem by 0.75rem: a row's icon width at 3:2. Its own corner, a\n        // flag's, not a control's: it stays square in the Round shape.\n        'bg-muted relative inline-flex h-3 w-4.5 shrink-0 overflow-hidden rounded-[2px] bg-cover bg-center after:absolute after:inset-0 after:rounded-[inherit] after:shadow-[inset_0_0_0_1px] after:shadow-foreground/15 forced-colors:after:shadow-none',\n        className,\n      )}\n      style={{ backgroundImage: flagUrl(country), ...style }}\n      {...props}\n    />\n  )\n}\n\nconst namesByLocale = new Map<string, Intl.DisplayNames>()\n\n/** `country`'s name in `locale`, such as \"United Kingdom\" for `GB` in English, or the code when the browser has no name for it. */\nfunction countryName(country: string, locale: string): string {\n  let names = namesByLocale.get(locale)\n  if (!names) {\n    names = new Intl.DisplayNames([locale], { type: 'region', fallback: 'code' })\n    namesByLocale.set(locale, names)\n  }\n  return names.of(country) ?? country\n}\n\n/** Short names people search by that aren't in the country's own name. */\nconst ALIASES: Partial<Record<string, readonly string[]>> = {\n  AE: ['UAE'],\n  CD: ['DRC'],\n  GB: ['UK', 'Great Britain', 'England', 'Scotland', 'Wales'],\n  KR: ['South Korea'],\n  KP: ['North Korea'],\n  NL: ['Holland'],\n  US: ['USA', 'America'],\n}\n\n/** Other names `country` is searched by, such as UK for `GB`, in English. */\nfunction countryAliases(country: string): readonly string[] {\n  return ALIASES[country.toUpperCase()] ?? []\n}\n\nexport { CountryFlag, countryAliases, countryName }\n",
      "type": "registry:lib",
      "target": "@lib/countries.tsx"
    }
  ],
  "type": "registry:lib"
}