import { n as useTranslation } from "./i18n-DoP1NB7u.js";
import { d as T, v as u } from "./vendor-preact-DThS2ZQ_.js";
import { t as DropdownComposed } from "./dropdownComposed-ZdNkbyDs.js";
//#region src/shared/countrySelector/countrySelector.tsx
var DEFAULT_COUNTRY_CODES = [
	"BR",
	"CN",
	"FR",
	"DE",
	"IL",
	"IT",
	"MX",
	"ES",
	"GB",
	"US"
];
var DEFAULT_DEV_ONLY_COUNTRY_CODES = [
	"CM",
	"KE",
	"NG"
];
function countryFlag(code) {
	return [...code.toUpperCase()].map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
}
function isDevEnvironment() {
	if (typeof window === "undefined") return false;
	const { hostname } = window.location;
	return hostname === "localhost" || hostname.includes("stage") || hostname.includes("demo");
}
var CountrySelector = ({ value, onChange, label, id = "country-selector", countryCodes = DEFAULT_COUNTRY_CODES, devOnlyCountryCodes = DEFAULT_DEV_ONLY_COUNTRY_CODES, "data-testid": testId }) => {
	const { i18n } = useTranslation();
	const locale = i18n.language || "en";
	return /* @__PURE__ */ u("div", {
		class: "IncodeCountrySelector",
		children: /* @__PURE__ */ u(DropdownComposed, {
			id,
			label,
			value,
			options: T(() => {
				const displayNames = new Intl.DisplayNames([locale, "en"], { type: "region" });
				return (isDevEnvironment() ? [...countryCodes, ...devOnlyCountryCodes] : [...countryCodes]).map((code) => {
					const name = displayNames.of(code) ?? code;
					return {
						value: code,
						label: `${countryFlag(code)} ${name}`,
						ariaLabel: name
					};
				}).sort((a, b) => a.label.localeCompare(b.label, locale));
			}, [
				countryCodes,
				devOnlyCountryCodes,
				locale
			]),
			onChange,
			"data-testid": testId
		})
	});
};
//#endregion
export { CountrySelector as t };
