//#region src/i18n/locale.ts
/** Locales supported by server-side message bundles (extend when adding JSON). */
const SERVER_LOCALES = ["en", "zh"];
const DEFAULT_SERVER_LOCALE = "en";
const SERVER_LOCALE_SET = new Set(SERVER_LOCALES);
function isServerLocale(v) {
	return SERVER_LOCALE_SET.has(v);
}
/** Map `zh-CN`, `EN`, etc. to a supported locale, or `undefined`. */
function normalizeServerLocale(v) {
	if (v === "zh" || v === "en") return v;
	if (typeof v !== "string") return void 0;
	const t = v.trim().toLowerCase();
	if (!t) return void 0;
	for (const loc of SERVER_LOCALES) if (t === loc || t.startsWith(`${loc}-`)) return loc;
}
/** Unknown or missing → `DEFAULT_SERVER_LOCALE`. */
function serverLocaleOrFallback(locale) {
	if (locale && isServerLocale(String(locale))) return locale;
	return normalizeServerLocale(locale) ?? "en";
}
//#endregion
export { DEFAULT_SERVER_LOCALE, SERVER_LOCALES, isServerLocale, normalizeServerLocale, serverLocaleOrFallback };

//# sourceMappingURL=locale.js.map