import countriesAndLanguages from './countries_and_languages.json'; /** A single picker option - matches the {label, value} shape consumed by the visibility settings dropdowns. */ export interface OptionEntry { label: string; value: string; } interface RawCountry { name_en: string; iso2: string; iso3: string; region: string; languages: string[]; } interface RawLanguage { code: string; name_en: string; name_native: string; } /** * Sentinel "not set" entry rendered first in the country dropdown so the * merchant can clear an existing selection. We only carry it for * countries - language is required (the scanner would refuse to build * grounded queries without one). */ const NOT_SET: OptionEntry = { label: '- not set -', value: '' }; const COUNTRIES = countriesAndLanguages.countries as RawCountry[]; const LANGUAGES = countriesAndLanguages.languages as RawLanguage[]; const SORTED_COUNTRY_OPTIONS: OptionEntry[] = COUNTRIES.map(country => ({ label: `${country.name_en} (${country.iso2})`, value: country.iso2, })).sort((a, b) => a.label.localeCompare(b.label)); const SORTED_LANGUAGE_OPTIONS: OptionEntry[] = LANGUAGES.map(language => ({ label: language.name_en, value: language.code, })).sort((a, b) => a.label.localeCompare(b.label)); /** * Country options for the Visibility settings drawer. Sourced from the * canonical ``countries_and_languages.json`` shared with * ``recomaze-ai-website`` (~200 ISO 3166-1 alpha-2 entries). The "- * not set -" sentinel is prepended so the dropdown can represent a * cleared selection. */ export const COUNTRY_OPTIONS: ReadonlyArray = [ NOT_SET, ...SORTED_COUNTRY_OPTIONS, ]; /** * Language options for the Visibility settings drawer. Sourced from the * canonical ``countries_and_languages.json`` shared with * ``recomaze-ai-website`` (~180 ISO 639-1 entries). */ export const LANGUAGE_OPTIONS: ReadonlyArray = SORTED_LANGUAGE_OPTIONS;