gt-react 11.1.4 β†’ 11.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # gt-react
2
2
 
3
+ ## 11.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`9b3eb92`](https://github.com/generaltranslation/gt/commit/9b3eb92fb1a916b5f47d15f51a9f39f6c62840a9)]:
8
+ - generaltranslation@9.1.1
9
+ - @generaltranslation/react-core@11.1.5
10
+ - gt-i18n@1.0.11
11
+
3
12
  ## 11.1.4
4
13
 
5
14
  ### Patch Changes
@@ -12,7 +12,7 @@ const DEFAULT_HTML_TAG_OPTIONS = {
12
12
  updateHtmlDirTag: true
13
13
  };
14
14
  //#endregion
15
- //#region ../core/dist/api-BOEGbEF6.mjs
15
+ //#region ../core/dist/api-rqq7klYe.mjs
16
16
  function ensureSentence(text) {
17
17
  const trimmed = text.trim();
18
18
  if (!trimmed) return "";
@@ -28,9 +28,6 @@ function stripSentence(text) {
28
28
  }
29
29
  return trimmed.slice(0, end);
30
30
  }
31
- function lowercaseFirstWord(text) {
32
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
33
- }
34
31
  function formatDetails(details) {
35
32
  if (!details) return "";
36
33
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -39,12 +36,12 @@ function formatDetails(details) {
39
36
  }
40
37
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
41
38
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
42
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
39
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
43
40
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
44
41
  const messageParts = [
45
42
  whatAndWhy,
46
43
  reassurance,
47
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
44
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
48
45
  shouldCombineWayOut ? void 0 : wayOut,
49
46
  formatDetails(details)
50
47
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.cjs","names":["I18nCache","getCookieValue","getCookieValue","defaultResetLocaleCookieName","getCookieValue","getCookieValue","I18nStore","InternalLocaleSelector","InternalRegionSelector","I18nStore","InternalGTProvider"],"sources":["../src/i18n-cache/constants.ts","../../core/dist/api-BOEGbEF6.mjs","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/cookies.ts","../src/condition-store/readBrowserLocale.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/singleton-operations.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRAClient.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/BrowserGTProvider.tsx","../src/index.client.ts"],"sourcesContent":["import type { HtmlTagOptions } from './types';\n\nexport const DEFAULT_HTML_TAG_OPTIONS: HtmlTagOptions = {\n updateHtmlLangTag: true,\n updateHtmlDirTag: true,\n};\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import type {\n I18nCacheConstructorParams,\n TranslationsLoader,\n} from 'gt-i18n/internal/types';\nimport { getI18nConfig, I18nCache } from 'gt-i18n/internal';\nimport type { HtmlTagOptions } from './types';\nimport type { Translation } from 'gt-i18n/types';\nimport { DEFAULT_HTML_TAG_OPTIONS } from './constants';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\n\ntype LocalStorageTranslationCache =\n import('./LocalStorageTranslationCache').LocalStorageTranslationCache;\ntype LocalStorageCachePromises = Record<\n string,\n Promise<LocalStorageTranslationCache>\n>;\n\n// Lazily import the development-only cache so bundlers can keep it out of the initial client chunk.\n// `??=` saves the first import promise, so all cache instances reuse the same lazy module load.\nlet localStorageCacheModulePromise:\n | Promise<typeof import('./LocalStorageTranslationCache')>\n | undefined;\n\n/**\n * The configuration for the BrowserI18nCache\n */\nexport type BrowserI18nCacheParams = I18nCacheConstructorParams & {\n htmlTagOptions?: HtmlTagOptions;\n};\n\n/**\n * I18nCache implementation for Browser.\n */\nexport class BrowserI18nCache extends I18nCache<Translation> {\n /** Customize browser-related behavior */\n private htmlTagOptions?: HtmlTagOptions;\n\n /** Whether dev hot reload JSX (Suspense-based <T>) is active */\n private _devHotReloadJsx = false;\n\n constructor(config: BrowserI18nCacheParams) {\n // Must be initialized before super()\n const { htmlTagOptions, ...managerConfig } = config;\n const localStorageCaches: LocalStorageCachePromises = {};\n const i18nConfig = getI18nConfig();\n const devHotReloadEnabled =\n !!config.loadTranslations && i18nConfig.isDevHotReloadEnabled();\n const projectId = i18nConfig.getProjectId()!;\n const loadTranslations = devHotReloadEnabled\n ? wrapLoaderWithLocalStorage(\n config.loadTranslations!,\n projectId,\n localStorageCaches\n )\n : config.loadTranslations;\n\n // Initialize the I18nCache\n super({\n ...managerConfig,\n loadTranslations,\n });\n\n this._devHotReloadJsx = devHotReloadEnabled;\n\n this.htmlTagOptions = {\n ...DEFAULT_HTML_TAG_OPTIONS,\n ...htmlTagOptions,\n };\n\n // For dev hot reload, we need to write the translations to the localStorage cache\n if (devHotReloadEnabled) {\n this.onTranslationsCacheMiss = ({ locale, hash, translation }) => {\n void getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n }).then((cache) => cache.write(hash, translation));\n };\n }\n }\n\n /**\n * Whether dev hot reload JSX (Suspense-based <T>) is active\n */\n isDevHotReloadJsx(): boolean {\n return this._devHotReloadJsx;\n }\n\n /**\n * Update the html tag (lang, dir)\n *\n * @deprecated, TODO: we should use a different system for managing this html tag\n * this should just be for managing translations\n */\n updateHtmlTag(\n locale: string,\n htmlTagOptions?: { lang?: string; dir?: 'ltr' | 'rtl' } & HtmlTagOptions\n ): void {\n // Get parameters\n const htmlLocale = htmlTagOptions?.lang || locale;\n const i18nConfig = getI18nConfig();\n const canonicalLocale = i18nConfig.resolveCanonicalLocale(htmlLocale);\n\n // Validate parameters\n if (!i18nConfig.isValidLocale(canonicalLocale)) {\n console.warn(createInvalidLocaleWarning(htmlLocale));\n return;\n }\n\n const localeDirection =\n htmlTagOptions?.dir || i18nConfig.getLocaleDirection(canonicalLocale);\n\n // Merge options\n const mergedHtmlTagOptions = {\n ...this.htmlTagOptions,\n ...htmlTagOptions,\n };\n\n // Update html tag\n if (mergedHtmlTagOptions.updateHtmlLangTag) {\n document.documentElement.lang = canonicalLocale;\n }\n if (mergedHtmlTagOptions.updateHtmlDirTag) {\n document.documentElement.dir = localeDirection;\n }\n }\n}\n\n// ===== Helper Functions ===== //\n\n/**\n * Wraps a translation loader to merge localStorage translations in dev mode.\n * On each call: runs the original loader, seeds a LocalStorageTranslationCache\n * with the result (loader wins over stale localStorage), and returns the merged\n * translations β€” preserving runtime tx() translations from previous sessions.\n *\n * TODO: this should be moved to wrapping in I18nStore\n */\nfunction wrapLoaderWithLocalStorage(\n originalLoader: TranslationsLoader,\n projectId: string,\n localStorageCaches: LocalStorageCachePromises\n) {\n return async (locale: string) => {\n const loaderTranslations = await originalLoader(locale);\n const cache = await getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n init: loaderTranslations as Record<string, Translation>,\n });\n return cache.getInternalCache();\n };\n}\n\nfunction getOrCreateLocalStorageCache(\n localStorageCaches: LocalStorageCachePromises,\n params: {\n locale: string;\n projectId: string;\n init?: Record<string, Translation>;\n }\n): Promise<LocalStorageTranslationCache> {\n // `||=` saves the first promise for this locale, so concurrent calls reuse one cache instance.\n return (localStorageCaches[params.locale] ||= loadLocalStorageCache().then(\n ({ LocalStorageTranslationCache }) =>\n new LocalStorageTranslationCache(params)\n ));\n}\n\nfunction loadLocalStorageCache() {\n return (localStorageCacheModulePromise ??=\n import('./LocalStorageTranslationCache'));\n}\n\nconst createInvalidLocaleWarning = (locale: string) =>\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n","import { getCookieValue as getCookieValueFromString } from 'gt-i18n/internal';\n\n/**\n * Minimally parses a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @returns The locale from the cookie or undefined if not found or invalid\n */\nexport function getCookieValue({\n cookieName,\n}: {\n cookieName: string;\n}): string | undefined {\n if (typeof document === 'undefined') return undefined;\n return getCookieValueFromString(document.cookie, cookieName);\n}\n\n/**\n * Sets a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @param value - The value to set\n * @returns The value that was set\n */\nexport function setCookieValue({\n cookieName,\n value,\n}: {\n cookieName: string;\n value: string;\n}): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${cookieName}=${value};path=/`;\n}\n","import { getCookieValue } from './cookies';\n\nexport function readBrowserLocale(localeCookieName: string): string[] {\n const candidates = [];\n // (1) Check cookie\n\n const cookieLocale = getCookieValue({\n cookieName: localeCookieName,\n });\n if (cookieLocale) candidates.push(cookieLocale);\n\n // (2) Check navigator locales\n const navigatorLocales = navigator?.languages || [];\n candidates.push(...navigatorLocales);\n\n return candidates;\n}\n","import {\n defaultResetLocaleCookieName,\n getI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { WritableConditionStoreParams } from 'gt-i18n/internal';\nimport { getCookieValue, setCookieValue } from './cookies';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { GetEnableI18n, GetLocale, GetRegion } from '../i18n-cache/types';\nimport {\n LocaleCandidates,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\n\ntype SerializedBrowserConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\nexport type ReloadType = (state: SerializedBrowserConditionStoreState) => void;\n\n/**\n * The configuration for the BrowserConditionStore\n * @param {GetLocale} getLocale - The function to get the locale\n */\nexport type BrowserConditionStoreParams = WritableConditionStoreParams & {\n _getLocale?: GetLocale;\n _getRegion?: GetRegion;\n _getEnableI18n?: GetEnableI18n;\n _reload?: ReloadType;\n};\n\n/**\n * Condition store implementation for Browser.\n */\nexport class BrowserConditionStore implements WritableConditionStoreInterface {\n private customReload: ReloadType;\n private customGetLocale?: GetLocale;\n private customGetRegion?: GetRegion;\n private customGetEnableI18n?: GetEnableI18n;\n\n constructor(config: BrowserConditionStoreParams) {\n const i18nConfig = getI18nConfig();\n this.customReload =\n config._reload ??\n (() =>\n typeof window !== 'undefined' ? window.location.reload() : undefined);\n this.customGetLocale = config._getLocale;\n this.customGetRegion = config._getRegion;\n this.customGetEnableI18n = config._getEnableI18n;\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(config.locale),\n });\n if (config.region !== undefined) {\n setCookieValue({\n cookieName: i18nConfig.getRegionCookieName(),\n value: config.region,\n });\n }\n this.updateEnableI18n(config.enableI18n ?? true);\n }\n\n getLocale = (): string => {\n return getBrowserLocale(this.customGetLocale);\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n this.updateLocale(locale);\n setCookieValue({\n cookieName: defaultResetLocaleCookieName,\n value: 'true',\n });\n this.reload();\n };\n\n getRegion = (): string | undefined => {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n if (cookieRegion) return cookieRegion;\n return this.customGetRegion?.();\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload();\n };\n\n getEnableI18n = (): boolean => {\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return this.customGetEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload();\n };\n\n /**\n * Soft locale update\n */\n updateLocale = (locale: LocaleCandidates): void => {\n const i18nConfig = getI18nConfig();\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(locale),\n });\n };\n\n /**\n * Soft region update\n */\n updateRegion = (region: string | undefined): void => {\n setCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n value: region ?? '',\n });\n };\n\n /**\n * Soft enableI18n update\n */\n updateEnableI18n = (enableI18n: boolean): void => {\n setCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n value: enableI18n ? 'true' : 'false',\n });\n };\n\n /**\n * Condition store updates come from either the server or the client.\n * Trigger this reload when we update a value in the condition store from\n * the client.\n */\n reload = (): void => {\n const state = {\n locale: this.getLocale(),\n region: this.getRegion(),\n enableI18n: this.getEnableI18n(),\n };\n this.customReload(state);\n };\n}\n\nfunction getBrowserLocale(getLocale?: GetLocale): string {\n const i18nConfig = getI18nConfig();\n const candidates = readBrowserLocale(i18nConfig.getLocaleCookieName());\n if (getLocale) candidates.push(getLocale());\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n ReadonlyConditionStore,\n} from 'gt-i18n/internal';\nimport { BrowserConditionStore } from './BrowserConditionStore';\n\n// Both singletons below are typed views of the same global slot (namespace\n// 'i18n', key 'conditionStore'), so there is a single uninitialized state and\n// one message describes it for both getters.\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Call initializeGT() (or initializeGTSPA() in SPA apps) before rendering and add a <GTProvider> at the root of your component tree.',\n});\n\nexport const {\n setConditionStore: setReadonlyConditionStore,\n isConditionStoreInitialized: isReadonlyConditionStoreInitialized,\n} = createConditionStoreSingleton<ReadonlyConditionStore>(\n conditionStoreNotInitializedError\n);\n\nexport const {\n getConditionStore: getBrowserConditionStore,\n setConditionStore: setBrowserConditionStore,\n isConditionStoreInitialized: isBrowserConditionStoreInitialized,\n} = createConditionStoreSingleton<BrowserConditionStore>(\n conditionStoreNotInitializedError\n);\n","import type { LocaleCandidates } from 'gt-i18n/internal';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport {\n BrowserConditionStore,\n BrowserConditionStoreParams,\n} from './BrowserConditionStore';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { getCookieValue } from './cookies';\nimport {\n getBrowserConditionStore,\n isBrowserConditionStoreInitialized,\n setBrowserConditionStore,\n} from './singleton-operations';\n\nexport type CreateBrowserConditionStoreParams = Omit<\n BrowserConditionStoreParams,\n 'locale' | 'enableI18n'\n> & {\n locale?: LocaleCandidates;\n enableI18n?: boolean;\n};\n\n/**\n * Factory to create a BrowserConditionStore for Singleton\n *\n * This exists so we can keep the locale param as required in the constructor\n *\n * Server-provided props are the first candidates for hydration consistency.\n * Cookies fill in missing values to persist state across page reloads.\n *\n * Cookie names come from the I18nConfig singleton so custom names passed to\n * initializeGT() apply here without being threaded through provider props.\n */\nexport function createOrUpdateBrowserConditionStore(\n config: CreateBrowserConditionStoreParams\n) {\n const locale = determineLocale(config);\n const region = determineRegion(config);\n const enableI18n = determineEnableI18n(config);\n\n if (isBrowserConditionStoreInitialized()) {\n // This represents an update from server\n const conditionStore = getBrowserConditionStore();\n conditionStore.updateLocale(locale);\n if (region !== undefined) conditionStore.updateRegion(region);\n conditionStore.updateEnableI18n(enableI18n);\n return conditionStore;\n }\n\n const conditionStore = new BrowserConditionStore({\n ...config,\n locale,\n region,\n enableI18n,\n });\n setBrowserConditionStore(conditionStore);\n return conditionStore;\n}\n\nfunction determineLocale({\n _getLocale: getLocale,\n locale,\n}: CreateBrowserConditionStoreParams): string {\n const i18nConfig = getI18nConfig();\n const candidates = [];\n if (locale) {\n candidates.push(...(Array.isArray(locale) ? locale : [locale]));\n }\n if (getLocale) candidates.push(getLocale());\n candidates.push(...readBrowserLocale(i18nConfig.getLocaleCookieName()));\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n\nfunction determineRegion({\n _getRegion: getRegion,\n region,\n}: CreateBrowserConditionStoreParams): string | undefined {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n return cookieRegion || getRegion?.() || region;\n}\n\nfunction determineEnableI18n({\n enableI18n,\n _getEnableI18n: getEnableI18n,\n}: CreateBrowserConditionStoreParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return getEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n}\n","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n getTranslationsSnapshot,\n I18nStore,\n setI18nStore,\n setReactI18nCache,\n getReadonlyConditionStore,\n initializeI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { I18nConfigParams } from '@generaltranslation/react-core/pure';\nimport { BrowserI18nCache } from '../i18n-cache/BrowserI18nCache';\nimport type { BrowserI18nCacheParams } from '../i18n-cache/BrowserI18nCache';\nimport {\n createOrUpdateBrowserConditionStore,\n CreateBrowserConditionStoreParams,\n} from '../condition-store/createBrowserConditionStore';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTSPAParams = I18nConfigParams &\n BrowserI18nCacheParams &\n CreateBrowserConditionStoreParams;\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * This is SPA for browser runtime\n */\nexport async function initializeGTSPA(config: InitializeGTSPAParams) {\n const runtimeConfig = addRuntimeCredentials(config);\n initializeI18nConfig(runtimeConfig, 'SPA');\n\n const i18nCache = new BrowserI18nCache(runtimeConfig);\n setReactI18nCache(i18nCache);\n\n createOrUpdateBrowserConditionStore(runtimeConfig);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n\n // Block until translations are loaded\n await getTranslationsSnapshot(getReadonlyConditionStore().getLocale());\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTClientParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for client-side rendering.\n */\nexport function initializeGTSRAClient(config: InitializeGTClientParams): void {\n internalInitializeGTSRA(\n addRuntimeCredentials({\n cacheExpiryTime: null,\n ...config,\n })\n );\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { createOrUpdateBrowserConditionStore } from '../condition-store/createBrowserConditionStore';\n\n/**\n * Consumes snapshot from server\n * Implementation for client-side only\n */\nexport function BrowserGTProvider(props: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return createOrUpdateBrowserConditionStore(props);\n }, [props.locale, props.region, props.enableI18n, props._reload]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n","'use client';\n\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\nexport { initializeGTSPA } from './setup/initializeGTSPA';\nexport { initializeGTSRAClient as initializeGT } from './setup/initializeGTSRAClient';\nexport { createOrUpdateBrowserConditionStore } from './condition-store/createBrowserConditionStore';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\n// ===== Components ===== //\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\nexport { BrowserGTProvider as GTProvider } from './provider/BrowserGTProvider';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type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;;AChBxE,SAAgB,eAAe,EAC7B,SAAS,UACT,GAAG,SAC6C;CAEhD,MAAM,EAAE,QAAQ,SAAS,qBAAqB,cAC5C,kBAAkB,SAAS;AAE7B,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACE;EACU;EACrB,GAAI;EACJ,CAAA;;;;;;;;;;;;;;;;;;;;;;;ACHN,SAAgB,eAAe,EAC7B,SAAS,UACT,eACA,+BACA,2BACA,mBAAmB,OACnB,GAAG,SAC6C;CAEhD,MAAM,EAAE,QAAQ,SAAS,YAAY,QAAQ,WAAW,cACtD,kBAAkB;EAChB,SAAS;EACT;EACA;EACA;EACD,CAAC;CAEJ,MAAM,gBAAgB,WAAmB;AACvC,MAAI,kBAAkB;GACpB,MAAM,eAAe,WAAW,IAAI,OAAO,EAAE;AAE7C,OAAI,gBAAgB,WAAW,aAAc,WAAU,aAAa;;AAEtE,YAAU,OAAO;;AAGnB,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;;;;;AC7CN,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,kBAAA,GAAA,MAAA,eAA+B;AACnC,SAAO,oCAAoC,MAAM;IAChD;EAAC,MAAM;EAAQ,MAAM;EAAQ,MAAM;EAAY,MAAM;EAAQ,CAAC;CAEjE,MAAM,gBAAA,GAAA,MAAA,QAAwC,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAIC,0CAAAA,WAAW;AAGxC,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA;;;;ACKN,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
1
+ {"version":3,"file":"index.client.cjs","names":["I18nCache","getCookieValue","getCookieValue","defaultResetLocaleCookieName","getCookieValue","getCookieValue","I18nStore","InternalLocaleSelector","InternalRegionSelector","I18nStore","InternalGTProvider"],"sources":["../src/i18n-cache/constants.ts","../../core/dist/api-rqq7klYe.mjs","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/cookies.ts","../src/condition-store/readBrowserLocale.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/singleton-operations.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRAClient.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/BrowserGTProvider.tsx","../src/index.client.ts"],"sourcesContent":["import type { HtmlTagOptions } from './types';\n\nexport const DEFAULT_HTML_TAG_OPTIONS: HtmlTagOptions = {\n updateHtmlLangTag: true,\n updateHtmlDirTag: true,\n};\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","import type {\n I18nCacheConstructorParams,\n TranslationsLoader,\n} from 'gt-i18n/internal/types';\nimport { getI18nConfig, I18nCache } from 'gt-i18n/internal';\nimport type { HtmlTagOptions } from './types';\nimport type { Translation } from 'gt-i18n/types';\nimport { DEFAULT_HTML_TAG_OPTIONS } from './constants';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\n\ntype LocalStorageTranslationCache =\n import('./LocalStorageTranslationCache').LocalStorageTranslationCache;\ntype LocalStorageCachePromises = Record<\n string,\n Promise<LocalStorageTranslationCache>\n>;\n\n// Lazily import the development-only cache so bundlers can keep it out of the initial client chunk.\n// `??=` saves the first import promise, so all cache instances reuse the same lazy module load.\nlet localStorageCacheModulePromise:\n | Promise<typeof import('./LocalStorageTranslationCache')>\n | undefined;\n\n/**\n * The configuration for the BrowserI18nCache\n */\nexport type BrowserI18nCacheParams = I18nCacheConstructorParams & {\n htmlTagOptions?: HtmlTagOptions;\n};\n\n/**\n * I18nCache implementation for Browser.\n */\nexport class BrowserI18nCache extends I18nCache<Translation> {\n /** Customize browser-related behavior */\n private htmlTagOptions?: HtmlTagOptions;\n\n /** Whether dev hot reload JSX (Suspense-based <T>) is active */\n private _devHotReloadJsx = false;\n\n constructor(config: BrowserI18nCacheParams) {\n // Must be initialized before super()\n const { htmlTagOptions, ...managerConfig } = config;\n const localStorageCaches: LocalStorageCachePromises = {};\n const i18nConfig = getI18nConfig();\n const devHotReloadEnabled =\n !!config.loadTranslations && i18nConfig.isDevHotReloadEnabled();\n const projectId = i18nConfig.getProjectId()!;\n const loadTranslations = devHotReloadEnabled\n ? wrapLoaderWithLocalStorage(\n config.loadTranslations!,\n projectId,\n localStorageCaches\n )\n : config.loadTranslations;\n\n // Initialize the I18nCache\n super({\n ...managerConfig,\n loadTranslations,\n });\n\n this._devHotReloadJsx = devHotReloadEnabled;\n\n this.htmlTagOptions = {\n ...DEFAULT_HTML_TAG_OPTIONS,\n ...htmlTagOptions,\n };\n\n // For dev hot reload, we need to write the translations to the localStorage cache\n if (devHotReloadEnabled) {\n this.onTranslationsCacheMiss = ({ locale, hash, translation }) => {\n void getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n }).then((cache) => cache.write(hash, translation));\n };\n }\n }\n\n /**\n * Whether dev hot reload JSX (Suspense-based <T>) is active\n */\n isDevHotReloadJsx(): boolean {\n return this._devHotReloadJsx;\n }\n\n /**\n * Update the html tag (lang, dir)\n *\n * @deprecated, TODO: we should use a different system for managing this html tag\n * this should just be for managing translations\n */\n updateHtmlTag(\n locale: string,\n htmlTagOptions?: { lang?: string; dir?: 'ltr' | 'rtl' } & HtmlTagOptions\n ): void {\n // Get parameters\n const htmlLocale = htmlTagOptions?.lang || locale;\n const i18nConfig = getI18nConfig();\n const canonicalLocale = i18nConfig.resolveCanonicalLocale(htmlLocale);\n\n // Validate parameters\n if (!i18nConfig.isValidLocale(canonicalLocale)) {\n console.warn(createInvalidLocaleWarning(htmlLocale));\n return;\n }\n\n const localeDirection =\n htmlTagOptions?.dir || i18nConfig.getLocaleDirection(canonicalLocale);\n\n // Merge options\n const mergedHtmlTagOptions = {\n ...this.htmlTagOptions,\n ...htmlTagOptions,\n };\n\n // Update html tag\n if (mergedHtmlTagOptions.updateHtmlLangTag) {\n document.documentElement.lang = canonicalLocale;\n }\n if (mergedHtmlTagOptions.updateHtmlDirTag) {\n document.documentElement.dir = localeDirection;\n }\n }\n}\n\n// ===== Helper Functions ===== //\n\n/**\n * Wraps a translation loader to merge localStorage translations in dev mode.\n * On each call: runs the original loader, seeds a LocalStorageTranslationCache\n * with the result (loader wins over stale localStorage), and returns the merged\n * translations β€” preserving runtime tx() translations from previous sessions.\n *\n * TODO: this should be moved to wrapping in I18nStore\n */\nfunction wrapLoaderWithLocalStorage(\n originalLoader: TranslationsLoader,\n projectId: string,\n localStorageCaches: LocalStorageCachePromises\n) {\n return async (locale: string) => {\n const loaderTranslations = await originalLoader(locale);\n const cache = await getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n init: loaderTranslations as Record<string, Translation>,\n });\n return cache.getInternalCache();\n };\n}\n\nfunction getOrCreateLocalStorageCache(\n localStorageCaches: LocalStorageCachePromises,\n params: {\n locale: string;\n projectId: string;\n init?: Record<string, Translation>;\n }\n): Promise<LocalStorageTranslationCache> {\n // `||=` saves the first promise for this locale, so concurrent calls reuse one cache instance.\n return (localStorageCaches[params.locale] ||= loadLocalStorageCache().then(\n ({ LocalStorageTranslationCache }) =>\n new LocalStorageTranslationCache(params)\n ));\n}\n\nfunction loadLocalStorageCache() {\n return (localStorageCacheModulePromise ??=\n import('./LocalStorageTranslationCache'));\n}\n\nconst createInvalidLocaleWarning = (locale: string) =>\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n","import { getCookieValue as getCookieValueFromString } from 'gt-i18n/internal';\n\n/**\n * Minimally parses a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @returns The locale from the cookie or undefined if not found or invalid\n */\nexport function getCookieValue({\n cookieName,\n}: {\n cookieName: string;\n}): string | undefined {\n if (typeof document === 'undefined') return undefined;\n return getCookieValueFromString(document.cookie, cookieName);\n}\n\n/**\n * Sets a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @param value - The value to set\n * @returns The value that was set\n */\nexport function setCookieValue({\n cookieName,\n value,\n}: {\n cookieName: string;\n value: string;\n}): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${cookieName}=${value};path=/`;\n}\n","import { getCookieValue } from './cookies';\n\nexport function readBrowserLocale(localeCookieName: string): string[] {\n const candidates = [];\n // (1) Check cookie\n\n const cookieLocale = getCookieValue({\n cookieName: localeCookieName,\n });\n if (cookieLocale) candidates.push(cookieLocale);\n\n // (2) Check navigator locales\n const navigatorLocales = navigator?.languages || [];\n candidates.push(...navigatorLocales);\n\n return candidates;\n}\n","import {\n defaultResetLocaleCookieName,\n getI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { WritableConditionStoreParams } from 'gt-i18n/internal';\nimport { getCookieValue, setCookieValue } from './cookies';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { GetEnableI18n, GetLocale, GetRegion } from '../i18n-cache/types';\nimport {\n LocaleCandidates,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\n\ntype SerializedBrowserConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\nexport type ReloadType = (state: SerializedBrowserConditionStoreState) => void;\n\n/**\n * The configuration for the BrowserConditionStore\n * @param {GetLocale} getLocale - The function to get the locale\n */\nexport type BrowserConditionStoreParams = WritableConditionStoreParams & {\n _getLocale?: GetLocale;\n _getRegion?: GetRegion;\n _getEnableI18n?: GetEnableI18n;\n _reload?: ReloadType;\n};\n\n/**\n * Condition store implementation for Browser.\n */\nexport class BrowserConditionStore implements WritableConditionStoreInterface {\n private customReload: ReloadType;\n private customGetLocale?: GetLocale;\n private customGetRegion?: GetRegion;\n private customGetEnableI18n?: GetEnableI18n;\n\n constructor(config: BrowserConditionStoreParams) {\n const i18nConfig = getI18nConfig();\n this.customReload =\n config._reload ??\n (() =>\n typeof window !== 'undefined' ? window.location.reload() : undefined);\n this.customGetLocale = config._getLocale;\n this.customGetRegion = config._getRegion;\n this.customGetEnableI18n = config._getEnableI18n;\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(config.locale),\n });\n if (config.region !== undefined) {\n setCookieValue({\n cookieName: i18nConfig.getRegionCookieName(),\n value: config.region,\n });\n }\n this.updateEnableI18n(config.enableI18n ?? true);\n }\n\n getLocale = (): string => {\n return getBrowserLocale(this.customGetLocale);\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n this.updateLocale(locale);\n setCookieValue({\n cookieName: defaultResetLocaleCookieName,\n value: 'true',\n });\n this.reload();\n };\n\n getRegion = (): string | undefined => {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n if (cookieRegion) return cookieRegion;\n return this.customGetRegion?.();\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload();\n };\n\n getEnableI18n = (): boolean => {\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return this.customGetEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload();\n };\n\n /**\n * Soft locale update\n */\n updateLocale = (locale: LocaleCandidates): void => {\n const i18nConfig = getI18nConfig();\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(locale),\n });\n };\n\n /**\n * Soft region update\n */\n updateRegion = (region: string | undefined): void => {\n setCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n value: region ?? '',\n });\n };\n\n /**\n * Soft enableI18n update\n */\n updateEnableI18n = (enableI18n: boolean): void => {\n setCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n value: enableI18n ? 'true' : 'false',\n });\n };\n\n /**\n * Condition store updates come from either the server or the client.\n * Trigger this reload when we update a value in the condition store from\n * the client.\n */\n reload = (): void => {\n const state = {\n locale: this.getLocale(),\n region: this.getRegion(),\n enableI18n: this.getEnableI18n(),\n };\n this.customReload(state);\n };\n}\n\nfunction getBrowserLocale(getLocale?: GetLocale): string {\n const i18nConfig = getI18nConfig();\n const candidates = readBrowserLocale(i18nConfig.getLocaleCookieName());\n if (getLocale) candidates.push(getLocale());\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n ReadonlyConditionStore,\n} from 'gt-i18n/internal';\nimport { BrowserConditionStore } from './BrowserConditionStore';\n\n// Both singletons below are typed views of the same global slot (namespace\n// 'i18n', key 'conditionStore'), so there is a single uninitialized state and\n// one message describes it for both getters.\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Call initializeGT() (or initializeGTSPA() in SPA apps) before rendering and add a <GTProvider> at the root of your component tree.',\n});\n\nexport const {\n setConditionStore: setReadonlyConditionStore,\n isConditionStoreInitialized: isReadonlyConditionStoreInitialized,\n} = createConditionStoreSingleton<ReadonlyConditionStore>(\n conditionStoreNotInitializedError\n);\n\nexport const {\n getConditionStore: getBrowserConditionStore,\n setConditionStore: setBrowserConditionStore,\n isConditionStoreInitialized: isBrowserConditionStoreInitialized,\n} = createConditionStoreSingleton<BrowserConditionStore>(\n conditionStoreNotInitializedError\n);\n","import type { LocaleCandidates } from 'gt-i18n/internal';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport {\n BrowserConditionStore,\n BrowserConditionStoreParams,\n} from './BrowserConditionStore';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { getCookieValue } from './cookies';\nimport {\n getBrowserConditionStore,\n isBrowserConditionStoreInitialized,\n setBrowserConditionStore,\n} from './singleton-operations';\n\nexport type CreateBrowserConditionStoreParams = Omit<\n BrowserConditionStoreParams,\n 'locale' | 'enableI18n'\n> & {\n locale?: LocaleCandidates;\n enableI18n?: boolean;\n};\n\n/**\n * Factory to create a BrowserConditionStore for Singleton\n *\n * This exists so we can keep the locale param as required in the constructor\n *\n * Server-provided props are the first candidates for hydration consistency.\n * Cookies fill in missing values to persist state across page reloads.\n *\n * Cookie names come from the I18nConfig singleton so custom names passed to\n * initializeGT() apply here without being threaded through provider props.\n */\nexport function createOrUpdateBrowserConditionStore(\n config: CreateBrowserConditionStoreParams\n) {\n const locale = determineLocale(config);\n const region = determineRegion(config);\n const enableI18n = determineEnableI18n(config);\n\n if (isBrowserConditionStoreInitialized()) {\n // This represents an update from server\n const conditionStore = getBrowserConditionStore();\n conditionStore.updateLocale(locale);\n if (region !== undefined) conditionStore.updateRegion(region);\n conditionStore.updateEnableI18n(enableI18n);\n return conditionStore;\n }\n\n const conditionStore = new BrowserConditionStore({\n ...config,\n locale,\n region,\n enableI18n,\n });\n setBrowserConditionStore(conditionStore);\n return conditionStore;\n}\n\nfunction determineLocale({\n _getLocale: getLocale,\n locale,\n}: CreateBrowserConditionStoreParams): string {\n const i18nConfig = getI18nConfig();\n const candidates = [];\n if (locale) {\n candidates.push(...(Array.isArray(locale) ? locale : [locale]));\n }\n if (getLocale) candidates.push(getLocale());\n candidates.push(...readBrowserLocale(i18nConfig.getLocaleCookieName()));\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n\nfunction determineRegion({\n _getRegion: getRegion,\n region,\n}: CreateBrowserConditionStoreParams): string | undefined {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n return cookieRegion || getRegion?.() || region;\n}\n\nfunction determineEnableI18n({\n enableI18n,\n _getEnableI18n: getEnableI18n,\n}: CreateBrowserConditionStoreParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return getEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n}\n","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n getTranslationsSnapshot,\n I18nStore,\n setI18nStore,\n setReactI18nCache,\n getReadonlyConditionStore,\n initializeI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { I18nConfigParams } from '@generaltranslation/react-core/pure';\nimport { BrowserI18nCache } from '../i18n-cache/BrowserI18nCache';\nimport type { BrowserI18nCacheParams } from '../i18n-cache/BrowserI18nCache';\nimport {\n createOrUpdateBrowserConditionStore,\n CreateBrowserConditionStoreParams,\n} from '../condition-store/createBrowserConditionStore';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTSPAParams = I18nConfigParams &\n BrowserI18nCacheParams &\n CreateBrowserConditionStoreParams;\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * This is SPA for browser runtime\n */\nexport async function initializeGTSPA(config: InitializeGTSPAParams) {\n const runtimeConfig = addRuntimeCredentials(config);\n initializeI18nConfig(runtimeConfig, 'SPA');\n\n const i18nCache = new BrowserI18nCache(runtimeConfig);\n setReactI18nCache(i18nCache);\n\n createOrUpdateBrowserConditionStore(runtimeConfig);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n\n // Block until translations are loaded\n await getTranslationsSnapshot(getReadonlyConditionStore().getLocale());\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTClientParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for client-side rendering.\n */\nexport function initializeGTSRAClient(config: InitializeGTClientParams): void {\n internalInitializeGTSRA(\n addRuntimeCredentials({\n cacheExpiryTime: null,\n ...config,\n })\n );\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { createOrUpdateBrowserConditionStore } from '../condition-store/createBrowserConditionStore';\n\n/**\n * Consumes snapshot from server\n * Implementation for client-side only\n */\nexport function BrowserGTProvider(props: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return createOrUpdateBrowserConditionStore(props);\n }, [props.locale, props.region, props.enableI18n, props._reload]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n","'use client';\n\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\nexport { initializeGTSPA } from './setup/initializeGTSPA';\nexport { initializeGTSRAClient as initializeGT } from './setup/initializeGTSRAClient';\nexport { createOrUpdateBrowserConditionStore } from './condition-store/createBrowserConditionStore';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\n// ===== Components ===== //\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\nexport { BrowserGTProvider as GTProvider } from './provider/BrowserGTProvider';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;AAEA,MAAa,2BAA2C;CACtD,mBAAmB;CACnB,kBAAkB;CACnB;;;ACAD,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AA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AAO;;AAGnB,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;;;;;AC7CN,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,kBAAA,GAAA,MAAA,eAA+B;AACnC,SAAO,oCAAoC,MAAM;IAChD;EAAC,MAAM;EAAQ,MAAM;EAAQ,MAAM;EAAY,MAAM;EAAQ,CAAC;CAEjE,MAAM,gBAAA,GAAA,MAAA,QAAwC,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAIC,0CAAAA,WAAW;AAGxC,QACE,iBAAA,GAAA,kBAAA,KAACC,0CAAAA,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA;;;;ACKN,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
@@ -11,7 +11,7 @@ const DEFAULT_HTML_TAG_OPTIONS = {
11
11
  updateHtmlDirTag: true
12
12
  };
13
13
  //#endregion
14
- //#region ../core/dist/api-BOEGbEF6.mjs
14
+ //#region ../core/dist/api-rqq7klYe.mjs
15
15
  function ensureSentence(text) {
16
16
  const trimmed = text.trim();
17
17
  if (!trimmed) return "";
@@ -27,9 +27,6 @@ function stripSentence(text) {
27
27
  }
28
28
  return trimmed.slice(0, end);
29
29
  }
30
- function lowercaseFirstWord(text) {
31
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
32
- }
33
30
  function formatDetails(details) {
34
31
  if (!details) return "";
35
32
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -38,12 +35,12 @@ function formatDetails(details) {
38
35
  }
39
36
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
40
37
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
41
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
38
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
42
39
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
43
40
  const messageParts = [
44
41
  whatAndWhy,
45
42
  reassurance,
46
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
43
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
47
44
  shouldCombineWayOut ? void 0 : wayOut,
48
45
  formatDetails(details)
49
46
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.client.mjs","names":["getI18nConfig","getCookieValue","getCookieValueFromString","getCookieValue","getCookieValue","getCookieValue","getTranslationsSnapshot","useSetLocale","useSetRegion","useSetLocale","I18nStore"],"sources":["../src/i18n-cache/constants.ts","../../core/dist/api-BOEGbEF6.mjs","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/cookies.ts","../src/condition-store/readBrowserLocale.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/singleton-operations.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRAClient.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/BrowserGTProvider.tsx","../src/index.client.ts"],"sourcesContent":["import type { HtmlTagOptions } from './types';\n\nexport const DEFAULT_HTML_TAG_OPTIONS: HtmlTagOptions = {\n updateHtmlLangTag: true,\n updateHtmlDirTag: true,\n};\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import type {\n I18nCacheConstructorParams,\n TranslationsLoader,\n} from 'gt-i18n/internal/types';\nimport { getI18nConfig, I18nCache } from 'gt-i18n/internal';\nimport type { HtmlTagOptions } from './types';\nimport type { Translation } from 'gt-i18n/types';\nimport { DEFAULT_HTML_TAG_OPTIONS } from './constants';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\n\ntype LocalStorageTranslationCache =\n import('./LocalStorageTranslationCache').LocalStorageTranslationCache;\ntype LocalStorageCachePromises = Record<\n string,\n Promise<LocalStorageTranslationCache>\n>;\n\n// Lazily import the development-only cache so bundlers can keep it out of the initial client chunk.\n// `??=` saves the first import promise, so all cache instances reuse the same lazy module load.\nlet localStorageCacheModulePromise:\n | Promise<typeof import('./LocalStorageTranslationCache')>\n | undefined;\n\n/**\n * The configuration for the BrowserI18nCache\n */\nexport type BrowserI18nCacheParams = I18nCacheConstructorParams & {\n htmlTagOptions?: HtmlTagOptions;\n};\n\n/**\n * I18nCache implementation for Browser.\n */\nexport class BrowserI18nCache extends I18nCache<Translation> {\n /** Customize browser-related behavior */\n private htmlTagOptions?: HtmlTagOptions;\n\n /** Whether dev hot reload JSX (Suspense-based <T>) is active */\n private _devHotReloadJsx = false;\n\n constructor(config: BrowserI18nCacheParams) {\n // Must be initialized before super()\n const { htmlTagOptions, ...managerConfig } = config;\n const localStorageCaches: LocalStorageCachePromises = {};\n const i18nConfig = getI18nConfig();\n const devHotReloadEnabled =\n !!config.loadTranslations && i18nConfig.isDevHotReloadEnabled();\n const projectId = i18nConfig.getProjectId()!;\n const loadTranslations = devHotReloadEnabled\n ? wrapLoaderWithLocalStorage(\n config.loadTranslations!,\n projectId,\n localStorageCaches\n )\n : config.loadTranslations;\n\n // Initialize the I18nCache\n super({\n ...managerConfig,\n loadTranslations,\n });\n\n this._devHotReloadJsx = devHotReloadEnabled;\n\n this.htmlTagOptions = {\n ...DEFAULT_HTML_TAG_OPTIONS,\n ...htmlTagOptions,\n };\n\n // For dev hot reload, we need to write the translations to the localStorage cache\n if (devHotReloadEnabled) {\n this.onTranslationsCacheMiss = ({ locale, hash, translation }) => {\n void getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n }).then((cache) => cache.write(hash, translation));\n };\n }\n }\n\n /**\n * Whether dev hot reload JSX (Suspense-based <T>) is active\n */\n isDevHotReloadJsx(): boolean {\n return this._devHotReloadJsx;\n }\n\n /**\n * Update the html tag (lang, dir)\n *\n * @deprecated, TODO: we should use a different system for managing this html tag\n * this should just be for managing translations\n */\n updateHtmlTag(\n locale: string,\n htmlTagOptions?: { lang?: string; dir?: 'ltr' | 'rtl' } & HtmlTagOptions\n ): void {\n // Get parameters\n const htmlLocale = htmlTagOptions?.lang || locale;\n const i18nConfig = getI18nConfig();\n const canonicalLocale = i18nConfig.resolveCanonicalLocale(htmlLocale);\n\n // Validate parameters\n if (!i18nConfig.isValidLocale(canonicalLocale)) {\n console.warn(createInvalidLocaleWarning(htmlLocale));\n return;\n }\n\n const localeDirection =\n htmlTagOptions?.dir || i18nConfig.getLocaleDirection(canonicalLocale);\n\n // Merge options\n const mergedHtmlTagOptions = {\n ...this.htmlTagOptions,\n ...htmlTagOptions,\n };\n\n // Update html tag\n if (mergedHtmlTagOptions.updateHtmlLangTag) {\n document.documentElement.lang = canonicalLocale;\n }\n if (mergedHtmlTagOptions.updateHtmlDirTag) {\n document.documentElement.dir = localeDirection;\n }\n }\n}\n\n// ===== Helper Functions ===== //\n\n/**\n * Wraps a translation loader to merge localStorage translations in dev mode.\n * On each call: runs the original loader, seeds a LocalStorageTranslationCache\n * with the result (loader wins over stale localStorage), and returns the merged\n * translations β€” preserving runtime tx() translations from previous sessions.\n *\n * TODO: this should be moved to wrapping in I18nStore\n */\nfunction wrapLoaderWithLocalStorage(\n originalLoader: TranslationsLoader,\n projectId: string,\n localStorageCaches: LocalStorageCachePromises\n) {\n return async (locale: string) => {\n const loaderTranslations = await originalLoader(locale);\n const cache = await getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n init: loaderTranslations as Record<string, Translation>,\n });\n return cache.getInternalCache();\n };\n}\n\nfunction getOrCreateLocalStorageCache(\n localStorageCaches: LocalStorageCachePromises,\n params: {\n locale: string;\n projectId: string;\n init?: Record<string, Translation>;\n }\n): Promise<LocalStorageTranslationCache> {\n // `||=` saves the first promise for this locale, so concurrent calls reuse one cache instance.\n return (localStorageCaches[params.locale] ||= loadLocalStorageCache().then(\n ({ LocalStorageTranslationCache }) =>\n new LocalStorageTranslationCache(params)\n ));\n}\n\nfunction loadLocalStorageCache() {\n return (localStorageCacheModulePromise ??=\n import('./LocalStorageTranslationCache'));\n}\n\nconst createInvalidLocaleWarning = (locale: string) =>\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n","import { getCookieValue as getCookieValueFromString } from 'gt-i18n/internal';\n\n/**\n * Minimally parses a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @returns The locale from the cookie or undefined if not found or invalid\n */\nexport function getCookieValue({\n cookieName,\n}: {\n cookieName: string;\n}): string | undefined {\n if (typeof document === 'undefined') return undefined;\n return getCookieValueFromString(document.cookie, cookieName);\n}\n\n/**\n * Sets a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @param value - The value to set\n * @returns The value that was set\n */\nexport function setCookieValue({\n cookieName,\n value,\n}: {\n cookieName: string;\n value: string;\n}): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${cookieName}=${value};path=/`;\n}\n","import { getCookieValue } from './cookies';\n\nexport function readBrowserLocale(localeCookieName: string): string[] {\n const candidates = [];\n // (1) Check cookie\n\n const cookieLocale = getCookieValue({\n cookieName: localeCookieName,\n });\n if (cookieLocale) candidates.push(cookieLocale);\n\n // (2) Check navigator locales\n const navigatorLocales = navigator?.languages || [];\n candidates.push(...navigatorLocales);\n\n return candidates;\n}\n","import {\n defaultResetLocaleCookieName,\n getI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { WritableConditionStoreParams } from 'gt-i18n/internal';\nimport { getCookieValue, setCookieValue } from './cookies';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { GetEnableI18n, GetLocale, GetRegion } from '../i18n-cache/types';\nimport {\n LocaleCandidates,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\n\ntype SerializedBrowserConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\nexport type ReloadType = (state: SerializedBrowserConditionStoreState) => void;\n\n/**\n * The configuration for the BrowserConditionStore\n * @param {GetLocale} getLocale - The function to get the locale\n */\nexport type BrowserConditionStoreParams = WritableConditionStoreParams & {\n _getLocale?: GetLocale;\n _getRegion?: GetRegion;\n _getEnableI18n?: GetEnableI18n;\n _reload?: ReloadType;\n};\n\n/**\n * Condition store implementation for Browser.\n */\nexport class BrowserConditionStore implements WritableConditionStoreInterface {\n private customReload: ReloadType;\n private customGetLocale?: GetLocale;\n private customGetRegion?: GetRegion;\n private customGetEnableI18n?: GetEnableI18n;\n\n constructor(config: BrowserConditionStoreParams) {\n const i18nConfig = getI18nConfig();\n this.customReload =\n config._reload ??\n (() =>\n typeof window !== 'undefined' ? window.location.reload() : undefined);\n this.customGetLocale = config._getLocale;\n this.customGetRegion = config._getRegion;\n this.customGetEnableI18n = config._getEnableI18n;\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(config.locale),\n });\n if (config.region !== undefined) {\n setCookieValue({\n cookieName: i18nConfig.getRegionCookieName(),\n value: config.region,\n });\n }\n this.updateEnableI18n(config.enableI18n ?? true);\n }\n\n getLocale = (): string => {\n return getBrowserLocale(this.customGetLocale);\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n this.updateLocale(locale);\n setCookieValue({\n cookieName: defaultResetLocaleCookieName,\n value: 'true',\n });\n this.reload();\n };\n\n getRegion = (): string | undefined => {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n if (cookieRegion) return cookieRegion;\n return this.customGetRegion?.();\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload();\n };\n\n getEnableI18n = (): boolean => {\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return this.customGetEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload();\n };\n\n /**\n * Soft locale update\n */\n updateLocale = (locale: LocaleCandidates): void => {\n const i18nConfig = getI18nConfig();\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(locale),\n });\n };\n\n /**\n * Soft region update\n */\n updateRegion = (region: string | undefined): void => {\n setCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n value: region ?? '',\n });\n };\n\n /**\n * Soft enableI18n update\n */\n updateEnableI18n = (enableI18n: boolean): void => {\n setCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n value: enableI18n ? 'true' : 'false',\n });\n };\n\n /**\n * Condition store updates come from either the server or the client.\n * Trigger this reload when we update a value in the condition store from\n * the client.\n */\n reload = (): void => {\n const state = {\n locale: this.getLocale(),\n region: this.getRegion(),\n enableI18n: this.getEnableI18n(),\n };\n this.customReload(state);\n };\n}\n\nfunction getBrowserLocale(getLocale?: GetLocale): string {\n const i18nConfig = getI18nConfig();\n const candidates = readBrowserLocale(i18nConfig.getLocaleCookieName());\n if (getLocale) candidates.push(getLocale());\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n ReadonlyConditionStore,\n} from 'gt-i18n/internal';\nimport { BrowserConditionStore } from './BrowserConditionStore';\n\n// Both singletons below are typed views of the same global slot (namespace\n// 'i18n', key 'conditionStore'), so there is a single uninitialized state and\n// one message describes it for both getters.\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Call initializeGT() (or initializeGTSPA() in SPA apps) before rendering and add a <GTProvider> at the root of your component tree.',\n});\n\nexport const {\n setConditionStore: setReadonlyConditionStore,\n isConditionStoreInitialized: isReadonlyConditionStoreInitialized,\n} = createConditionStoreSingleton<ReadonlyConditionStore>(\n conditionStoreNotInitializedError\n);\n\nexport const {\n getConditionStore: getBrowserConditionStore,\n setConditionStore: setBrowserConditionStore,\n isConditionStoreInitialized: isBrowserConditionStoreInitialized,\n} = createConditionStoreSingleton<BrowserConditionStore>(\n conditionStoreNotInitializedError\n);\n","import type { LocaleCandidates } from 'gt-i18n/internal';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport {\n BrowserConditionStore,\n BrowserConditionStoreParams,\n} from './BrowserConditionStore';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { getCookieValue } from './cookies';\nimport {\n getBrowserConditionStore,\n isBrowserConditionStoreInitialized,\n setBrowserConditionStore,\n} from './singleton-operations';\n\nexport type CreateBrowserConditionStoreParams = Omit<\n BrowserConditionStoreParams,\n 'locale' | 'enableI18n'\n> & {\n locale?: LocaleCandidates;\n enableI18n?: boolean;\n};\n\n/**\n * Factory to create a BrowserConditionStore for Singleton\n *\n * This exists so we can keep the locale param as required in the constructor\n *\n * Server-provided props are the first candidates for hydration consistency.\n * Cookies fill in missing values to persist state across page reloads.\n *\n * Cookie names come from the I18nConfig singleton so custom names passed to\n * initializeGT() apply here without being threaded through provider props.\n */\nexport function createOrUpdateBrowserConditionStore(\n config: CreateBrowserConditionStoreParams\n) {\n const locale = determineLocale(config);\n const region = determineRegion(config);\n const enableI18n = determineEnableI18n(config);\n\n if (isBrowserConditionStoreInitialized()) {\n // This represents an update from server\n const conditionStore = getBrowserConditionStore();\n conditionStore.updateLocale(locale);\n if (region !== undefined) conditionStore.updateRegion(region);\n conditionStore.updateEnableI18n(enableI18n);\n return conditionStore;\n }\n\n const conditionStore = new BrowserConditionStore({\n ...config,\n locale,\n region,\n enableI18n,\n });\n setBrowserConditionStore(conditionStore);\n return conditionStore;\n}\n\nfunction determineLocale({\n _getLocale: getLocale,\n locale,\n}: CreateBrowserConditionStoreParams): string {\n const i18nConfig = getI18nConfig();\n const candidates = [];\n if (locale) {\n candidates.push(...(Array.isArray(locale) ? locale : [locale]));\n }\n if (getLocale) candidates.push(getLocale());\n candidates.push(...readBrowserLocale(i18nConfig.getLocaleCookieName()));\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n\nfunction determineRegion({\n _getRegion: getRegion,\n region,\n}: CreateBrowserConditionStoreParams): string | undefined {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n return cookieRegion || getRegion?.() || region;\n}\n\nfunction determineEnableI18n({\n enableI18n,\n _getEnableI18n: getEnableI18n,\n}: CreateBrowserConditionStoreParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return getEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n}\n","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n getTranslationsSnapshot,\n I18nStore,\n setI18nStore,\n setReactI18nCache,\n getReadonlyConditionStore,\n initializeI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { I18nConfigParams } from '@generaltranslation/react-core/pure';\nimport { BrowserI18nCache } from '../i18n-cache/BrowserI18nCache';\nimport type { BrowserI18nCacheParams } from '../i18n-cache/BrowserI18nCache';\nimport {\n createOrUpdateBrowserConditionStore,\n CreateBrowserConditionStoreParams,\n} from '../condition-store/createBrowserConditionStore';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTSPAParams = I18nConfigParams &\n BrowserI18nCacheParams &\n CreateBrowserConditionStoreParams;\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * This is SPA for browser runtime\n */\nexport async function initializeGTSPA(config: InitializeGTSPAParams) {\n const runtimeConfig = addRuntimeCredentials(config);\n initializeI18nConfig(runtimeConfig, 'SPA');\n\n const i18nCache = new BrowserI18nCache(runtimeConfig);\n setReactI18nCache(i18nCache);\n\n createOrUpdateBrowserConditionStore(runtimeConfig);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n\n // Block until translations are loaded\n await getTranslationsSnapshot(getReadonlyConditionStore().getLocale());\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTClientParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for client-side rendering.\n */\nexport function initializeGTSRAClient(config: InitializeGTClientParams): void {\n internalInitializeGTSRA(\n addRuntimeCredentials({\n cacheExpiryTime: null,\n ...config,\n })\n );\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { createOrUpdateBrowserConditionStore } from '../condition-store/createBrowserConditionStore';\n\n/**\n * Consumes snapshot from server\n * Implementation for client-side only\n */\nexport function BrowserGTProvider(props: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return createOrUpdateBrowserConditionStore(props);\n }, [props.locale, props.region, props.enableI18n, props._reload]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n","'use client';\n\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\nexport { initializeGTSPA } from './setup/initializeGTSPA';\nexport { initializeGTSRAClient as initializeGT } from './setup/initializeGTSRAClient';\nexport { createOrUpdateBrowserConditionStore } from './condition-store/createBrowserConditionStore';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\n// ===== Components ===== //\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\nexport { BrowserGTProvider as GTProvider } from './provider/BrowserGTProvider';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAEA,MAAa,2BAA2C;CACtD,mBAAmB;CACnB,kBAAkB;CACnB;;;ACAD,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAAM,aAAa,CAAC;;AAEnE,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAMhD,SAAS,wBAAwB,EAAE,QAAQ,UAAU,cAAc,aAAa,KAAK,KAAK,QAAQ,SAAS,WAAW;CACrH,MAAM,SAAS,SAAS,WAAW,GAAG,OAAO,GAAG,SAAS,KAAK,GAAG,OAAO,KAAK,WAAW,GAAG,SAAS,KAAK;CACzG,MAAM,aAAa,MAAM,GAAG,cAAc,aAAa,CAAC,WAAW,mBAAmB,cAAc,IAAI,CAAC,KAAK;CAC9G,MAAM,sBAAsB,CAAC,CAAC,OAA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EACA;EACA;EACD,CAAC;CAEJ,MAAM,gBAAgB,WAAmB;AACvC,MAAI,kBAAkB;GACpB,MAAM,eAAe,WAAW,IAAI,OAAO,EAAE;AAE7C,OAAI,gBAAgB,WAAW,aAAc,WAAU,aAAa;;AAEtE,YAAU,OAAO;;AAGnB,QACE,oBAAC,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;;;;;AC7CN,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,iBAAiB,cAAc;AACnC,SAAO,oCAAoC,MAAM;IAChD;EAAC,MAAM;EAAQ,MAAM;EAAQ,MAAM;EAAY,MAAM;EAAQ,CAAC;CAEjE,MAAM,eAAe,OAAyB,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAIC,aAAW;AAGxC,QACE,oBAAC,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA;;;;ACKN,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
1
+ {"version":3,"file":"index.client.mjs","names":["getI18nConfig","getCookieValue","getCookieValueFromString","getCookieValue","getCookieValue","getCookieValue","getTranslationsSnapshot","useSetLocale","useSetRegion","useSetLocale","I18nStore"],"sources":["../src/i18n-cache/constants.ts","../../core/dist/api-rqq7klYe.mjs","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/cookies.ts","../src/condition-store/readBrowserLocale.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/singleton-operations.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRAClient.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/BrowserGTProvider.tsx","../src/index.client.ts"],"sourcesContent":["import type { HtmlTagOptions } from './types';\n\nexport const DEFAULT_HTML_TAG_OPTIONS: HtmlTagOptions = {\n updateHtmlLangTag: true,\n updateHtmlDirTag: true,\n};\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","import type {\n I18nCacheConstructorParams,\n TranslationsLoader,\n} from 'gt-i18n/internal/types';\nimport { getI18nConfig, I18nCache } from 'gt-i18n/internal';\nimport type { HtmlTagOptions } from './types';\nimport type { Translation } from 'gt-i18n/types';\nimport { DEFAULT_HTML_TAG_OPTIONS } from './constants';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\n\ntype LocalStorageTranslationCache =\n import('./LocalStorageTranslationCache').LocalStorageTranslationCache;\ntype LocalStorageCachePromises = Record<\n string,\n Promise<LocalStorageTranslationCache>\n>;\n\n// Lazily import the development-only cache so bundlers can keep it out of the initial client chunk.\n// `??=` saves the first import promise, so all cache instances reuse the same lazy module load.\nlet localStorageCacheModulePromise:\n | Promise<typeof import('./LocalStorageTranslationCache')>\n | undefined;\n\n/**\n * The configuration for the BrowserI18nCache\n */\nexport type BrowserI18nCacheParams = I18nCacheConstructorParams & {\n htmlTagOptions?: HtmlTagOptions;\n};\n\n/**\n * I18nCache implementation for Browser.\n */\nexport class BrowserI18nCache extends I18nCache<Translation> {\n /** Customize browser-related behavior */\n private htmlTagOptions?: HtmlTagOptions;\n\n /** Whether dev hot reload JSX (Suspense-based <T>) is active */\n private _devHotReloadJsx = false;\n\n constructor(config: BrowserI18nCacheParams) {\n // Must be initialized before super()\n const { htmlTagOptions, ...managerConfig } = config;\n const localStorageCaches: LocalStorageCachePromises = {};\n const i18nConfig = getI18nConfig();\n const devHotReloadEnabled =\n !!config.loadTranslations && i18nConfig.isDevHotReloadEnabled();\n const projectId = i18nConfig.getProjectId()!;\n const loadTranslations = devHotReloadEnabled\n ? wrapLoaderWithLocalStorage(\n config.loadTranslations!,\n projectId,\n localStorageCaches\n )\n : config.loadTranslations;\n\n // Initialize the I18nCache\n super({\n ...managerConfig,\n loadTranslations,\n });\n\n this._devHotReloadJsx = devHotReloadEnabled;\n\n this.htmlTagOptions = {\n ...DEFAULT_HTML_TAG_OPTIONS,\n ...htmlTagOptions,\n };\n\n // For dev hot reload, we need to write the translations to the localStorage cache\n if (devHotReloadEnabled) {\n this.onTranslationsCacheMiss = ({ locale, hash, translation }) => {\n void getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n }).then((cache) => cache.write(hash, translation));\n };\n }\n }\n\n /**\n * Whether dev hot reload JSX (Suspense-based <T>) is active\n */\n isDevHotReloadJsx(): boolean {\n return this._devHotReloadJsx;\n }\n\n /**\n * Update the html tag (lang, dir)\n *\n * @deprecated, TODO: we should use a different system for managing this html tag\n * this should just be for managing translations\n */\n updateHtmlTag(\n locale: string,\n htmlTagOptions?: { lang?: string; dir?: 'ltr' | 'rtl' } & HtmlTagOptions\n ): void {\n // Get parameters\n const htmlLocale = htmlTagOptions?.lang || locale;\n const i18nConfig = getI18nConfig();\n const canonicalLocale = i18nConfig.resolveCanonicalLocale(htmlLocale);\n\n // Validate parameters\n if (!i18nConfig.isValidLocale(canonicalLocale)) {\n console.warn(createInvalidLocaleWarning(htmlLocale));\n return;\n }\n\n const localeDirection =\n htmlTagOptions?.dir || i18nConfig.getLocaleDirection(canonicalLocale);\n\n // Merge options\n const mergedHtmlTagOptions = {\n ...this.htmlTagOptions,\n ...htmlTagOptions,\n };\n\n // Update html tag\n if (mergedHtmlTagOptions.updateHtmlLangTag) {\n document.documentElement.lang = canonicalLocale;\n }\n if (mergedHtmlTagOptions.updateHtmlDirTag) {\n document.documentElement.dir = localeDirection;\n }\n }\n}\n\n// ===== Helper Functions ===== //\n\n/**\n * Wraps a translation loader to merge localStorage translations in dev mode.\n * On each call: runs the original loader, seeds a LocalStorageTranslationCache\n * with the result (loader wins over stale localStorage), and returns the merged\n * translations β€” preserving runtime tx() translations from previous sessions.\n *\n * TODO: this should be moved to wrapping in I18nStore\n */\nfunction wrapLoaderWithLocalStorage(\n originalLoader: TranslationsLoader,\n projectId: string,\n localStorageCaches: LocalStorageCachePromises\n) {\n return async (locale: string) => {\n const loaderTranslations = await originalLoader(locale);\n const cache = await getOrCreateLocalStorageCache(localStorageCaches, {\n locale,\n projectId,\n init: loaderTranslations as Record<string, Translation>,\n });\n return cache.getInternalCache();\n };\n}\n\nfunction getOrCreateLocalStorageCache(\n localStorageCaches: LocalStorageCachePromises,\n params: {\n locale: string;\n projectId: string;\n init?: Record<string, Translation>;\n }\n): Promise<LocalStorageTranslationCache> {\n // `||=` saves the first promise for this locale, so concurrent calls reuse one cache instance.\n return (localStorageCaches[params.locale] ||= loadLocalStorageCache().then(\n ({ LocalStorageTranslationCache }) =>\n new LocalStorageTranslationCache(params)\n ));\n}\n\nfunction loadLocalStorageCache() {\n return (localStorageCacheModulePromise ??=\n import('./LocalStorageTranslationCache'));\n}\n\nconst createInvalidLocaleWarning = (locale: string) =>\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Warning',\n whatHappened: `Locale \"${locale}\" is not valid`,\n fix: 'Use a valid BCP 47 locale code or add a custom mapping',\n });\n","import { getCookieValue as getCookieValueFromString } from 'gt-i18n/internal';\n\n/**\n * Minimally parses a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @returns The locale from the cookie or undefined if not found or invalid\n */\nexport function getCookieValue({\n cookieName,\n}: {\n cookieName: string;\n}): string | undefined {\n if (typeof document === 'undefined') return undefined;\n return getCookieValueFromString(document.cookie, cookieName);\n}\n\n/**\n * Sets a cookie value for a given cookie name\n * @param cookieName - The name of the cookie\n * @param value - The value to set\n * @returns The value that was set\n */\nexport function setCookieValue({\n cookieName,\n value,\n}: {\n cookieName: string;\n value: string;\n}): void {\n if (typeof document === 'undefined') return;\n document.cookie = `${cookieName}=${value};path=/`;\n}\n","import { getCookieValue } from './cookies';\n\nexport function readBrowserLocale(localeCookieName: string): string[] {\n const candidates = [];\n // (1) Check cookie\n\n const cookieLocale = getCookieValue({\n cookieName: localeCookieName,\n });\n if (cookieLocale) candidates.push(cookieLocale);\n\n // (2) Check navigator locales\n const navigatorLocales = navigator?.languages || [];\n candidates.push(...navigatorLocales);\n\n return candidates;\n}\n","import {\n defaultResetLocaleCookieName,\n getI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { WritableConditionStoreParams } from 'gt-i18n/internal';\nimport { getCookieValue, setCookieValue } from './cookies';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { GetEnableI18n, GetLocale, GetRegion } from '../i18n-cache/types';\nimport {\n LocaleCandidates,\n WritableConditionStoreInterface,\n} from 'gt-i18n/internal/types';\n\ntype SerializedBrowserConditionStoreState = {\n locale: string;\n region: string | undefined;\n enableI18n: boolean;\n};\nexport type ReloadType = (state: SerializedBrowserConditionStoreState) => void;\n\n/**\n * The configuration for the BrowserConditionStore\n * @param {GetLocale} getLocale - The function to get the locale\n */\nexport type BrowserConditionStoreParams = WritableConditionStoreParams & {\n _getLocale?: GetLocale;\n _getRegion?: GetRegion;\n _getEnableI18n?: GetEnableI18n;\n _reload?: ReloadType;\n};\n\n/**\n * Condition store implementation for Browser.\n */\nexport class BrowserConditionStore implements WritableConditionStoreInterface {\n private customReload: ReloadType;\n private customGetLocale?: GetLocale;\n private customGetRegion?: GetRegion;\n private customGetEnableI18n?: GetEnableI18n;\n\n constructor(config: BrowserConditionStoreParams) {\n const i18nConfig = getI18nConfig();\n this.customReload =\n config._reload ??\n (() =>\n typeof window !== 'undefined' ? window.location.reload() : undefined);\n this.customGetLocale = config._getLocale;\n this.customGetRegion = config._getRegion;\n this.customGetEnableI18n = config._getEnableI18n;\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(config.locale),\n });\n if (config.region !== undefined) {\n setCookieValue({\n cookieName: i18nConfig.getRegionCookieName(),\n value: config.region,\n });\n }\n this.updateEnableI18n(config.enableI18n ?? true);\n }\n\n getLocale = (): string => {\n return getBrowserLocale(this.customGetLocale);\n };\n\n setLocale = (locale: LocaleCandidates): void => {\n this.updateLocale(locale);\n setCookieValue({\n cookieName: defaultResetLocaleCookieName,\n value: 'true',\n });\n this.reload();\n };\n\n getRegion = (): string | undefined => {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n if (cookieRegion) return cookieRegion;\n return this.customGetRegion?.();\n };\n\n setRegion = (region: string | undefined): void => {\n this.updateRegion(region);\n this.reload();\n };\n\n getEnableI18n = (): boolean => {\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return this.customGetEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n };\n\n setEnableI18n = (enableI18n: boolean): void => {\n this.updateEnableI18n(enableI18n);\n this.reload();\n };\n\n /**\n * Soft locale update\n */\n updateLocale = (locale: LocaleCandidates): void => {\n const i18nConfig = getI18nConfig();\n setCookieValue({\n cookieName: i18nConfig.getLocaleCookieName(),\n value: i18nConfig.resolveSupportedLocale(locale),\n });\n };\n\n /**\n * Soft region update\n */\n updateRegion = (region: string | undefined): void => {\n setCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n value: region ?? '',\n });\n };\n\n /**\n * Soft enableI18n update\n */\n updateEnableI18n = (enableI18n: boolean): void => {\n setCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n value: enableI18n ? 'true' : 'false',\n });\n };\n\n /**\n * Condition store updates come from either the server or the client.\n * Trigger this reload when we update a value in the condition store from\n * the client.\n */\n reload = (): void => {\n const state = {\n locale: this.getLocale(),\n region: this.getRegion(),\n enableI18n: this.getEnableI18n(),\n };\n this.customReload(state);\n };\n}\n\nfunction getBrowserLocale(getLocale?: GetLocale): string {\n const i18nConfig = getI18nConfig();\n const candidates = readBrowserLocale(i18nConfig.getLocaleCookieName());\n if (getLocale) candidates.push(getLocale());\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n ReadonlyConditionStore,\n} from 'gt-i18n/internal';\nimport { BrowserConditionStore } from './BrowserConditionStore';\n\n// Both singletons below are typed views of the same global slot (namespace\n// 'i18n', key 'conditionStore'), so there is a single uninitialized state and\n// one message describes it for both getters.\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'the internal ConditionStore singleton is unavailable',\n fix: 'Call initializeGT() (or initializeGTSPA() in SPA apps) before rendering and add a <GTProvider> at the root of your component tree.',\n});\n\nexport const {\n setConditionStore: setReadonlyConditionStore,\n isConditionStoreInitialized: isReadonlyConditionStoreInitialized,\n} = createConditionStoreSingleton<ReadonlyConditionStore>(\n conditionStoreNotInitializedError\n);\n\nexport const {\n getConditionStore: getBrowserConditionStore,\n setConditionStore: setBrowserConditionStore,\n isConditionStoreInitialized: isBrowserConditionStoreInitialized,\n} = createConditionStoreSingleton<BrowserConditionStore>(\n conditionStoreNotInitializedError\n);\n","import type { LocaleCandidates } from 'gt-i18n/internal';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport {\n BrowserConditionStore,\n BrowserConditionStoreParams,\n} from './BrowserConditionStore';\nimport { readBrowserLocale } from './readBrowserLocale';\nimport { getCookieValue } from './cookies';\nimport {\n getBrowserConditionStore,\n isBrowserConditionStoreInitialized,\n setBrowserConditionStore,\n} from './singleton-operations';\n\nexport type CreateBrowserConditionStoreParams = Omit<\n BrowserConditionStoreParams,\n 'locale' | 'enableI18n'\n> & {\n locale?: LocaleCandidates;\n enableI18n?: boolean;\n};\n\n/**\n * Factory to create a BrowserConditionStore for Singleton\n *\n * This exists so we can keep the locale param as required in the constructor\n *\n * Server-provided props are the first candidates for hydration consistency.\n * Cookies fill in missing values to persist state across page reloads.\n *\n * Cookie names come from the I18nConfig singleton so custom names passed to\n * initializeGT() apply here without being threaded through provider props.\n */\nexport function createOrUpdateBrowserConditionStore(\n config: CreateBrowserConditionStoreParams\n) {\n const locale = determineLocale(config);\n const region = determineRegion(config);\n const enableI18n = determineEnableI18n(config);\n\n if (isBrowserConditionStoreInitialized()) {\n // This represents an update from server\n const conditionStore = getBrowserConditionStore();\n conditionStore.updateLocale(locale);\n if (region !== undefined) conditionStore.updateRegion(region);\n conditionStore.updateEnableI18n(enableI18n);\n return conditionStore;\n }\n\n const conditionStore = new BrowserConditionStore({\n ...config,\n locale,\n region,\n enableI18n,\n });\n setBrowserConditionStore(conditionStore);\n return conditionStore;\n}\n\nfunction determineLocale({\n _getLocale: getLocale,\n locale,\n}: CreateBrowserConditionStoreParams): string {\n const i18nConfig = getI18nConfig();\n const candidates = [];\n if (locale) {\n candidates.push(...(Array.isArray(locale) ? locale : [locale]));\n }\n if (getLocale) candidates.push(getLocale());\n candidates.push(...readBrowserLocale(i18nConfig.getLocaleCookieName()));\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n\nfunction determineRegion({\n _getRegion: getRegion,\n region,\n}: CreateBrowserConditionStoreParams): string | undefined {\n const cookieRegion = getCookieValue({\n cookieName: getI18nConfig().getRegionCookieName(),\n });\n return cookieRegion || getRegion?.() || region;\n}\n\nfunction determineEnableI18n({\n enableI18n,\n _getEnableI18n: getEnableI18n,\n}: CreateBrowserConditionStoreParams): boolean {\n if (enableI18n !== undefined) return enableI18n;\n\n const cookieEnableI18n = getCookieValue({\n cookieName: getI18nConfig().getEnableI18nCookieName(),\n });\n if (cookieEnableI18n === undefined) {\n return getEnableI18n?.() ?? true;\n }\n return cookieEnableI18n === 'true';\n}\n","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n getTranslationsSnapshot,\n I18nStore,\n setI18nStore,\n setReactI18nCache,\n getReadonlyConditionStore,\n initializeI18nConfig,\n} from '@generaltranslation/react-core/pure';\nimport type { I18nConfigParams } from '@generaltranslation/react-core/pure';\nimport { BrowserI18nCache } from '../i18n-cache/BrowserI18nCache';\nimport type { BrowserI18nCacheParams } from '../i18n-cache/BrowserI18nCache';\nimport {\n createOrUpdateBrowserConditionStore,\n CreateBrowserConditionStoreParams,\n} from '../condition-store/createBrowserConditionStore';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTSPAParams = I18nConfigParams &\n BrowserI18nCacheParams &\n CreateBrowserConditionStoreParams;\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * This is SPA for browser runtime\n */\nexport async function initializeGTSPA(config: InitializeGTSPAParams) {\n const runtimeConfig = addRuntimeCredentials(config);\n initializeI18nConfig(runtimeConfig, 'SPA');\n\n const i18nCache = new BrowserI18nCache(runtimeConfig);\n setReactI18nCache(i18nCache);\n\n createOrUpdateBrowserConditionStore(runtimeConfig);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n\n // Block until translations are loaded\n await getTranslationsSnapshot(getReadonlyConditionStore().getLocale());\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTClientParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for client-side rendering.\n */\nexport function initializeGTSRAClient(config: InitializeGTClientParams): void {\n internalInitializeGTSRA(\n addRuntimeCredentials({\n cacheExpiryTime: null,\n ...config,\n })\n );\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { createOrUpdateBrowserConditionStore } from '../condition-store/createBrowserConditionStore';\n\n/**\n * Consumes snapshot from server\n * Implementation for client-side only\n */\nexport function BrowserGTProvider(props: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return createOrUpdateBrowserConditionStore(props);\n }, [props.locale, props.region, props.enableI18n, props._reload]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n />\n );\n}\n","'use client';\n\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\nexport { initializeGTSPA } from './setup/initializeGTSPA';\nexport { initializeGTSRAClient as initializeGT } from './setup/initializeGTSRAClient';\nexport { createOrUpdateBrowserConditionStore } from './condition-store/createBrowserConditionStore';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\n// ===== Components ===== //\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\nexport { BrowserGTProvider as GTProvider } from './provider/BrowserGTProvider';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAEA,MAAa,2BAA2C;CACtD,mBAAmB;CACnB,kBAAkB;CACnB;;;ACAD,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAMhD,SAAS,wBAAwB,EAAE,QAAQ,UAAU,cAAc,aAAa,KAAK,KAAK,QAAQ,SAAS,WAAW;CACrH,MAAM,SAAS,SAAS,WAAW,GAAG,OAAO,GAAG,SAAS,KAAK,GAAG,OAAO,KAAK,WAAW,GAAG,SAAS,KAAK;CACzG,MAAM,aAAa,MAAM,GAAG,cAAc,aAAa,CAAC,WAAW,cAAc,IAAI,KAAK;CAC1F,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EAChB,SAAS;EACT;EACA;EACA;EACD,CAAC;CAEJ,MAAM,gBAAgB,WAAmB;AACvC,MAAI,kBAAkB;GACpB,MAAM,eAAe,WAAW,IAAI,OAAO,EAAE;AAE7C,OAAI,gBAAgB,WAAW,aAAc,WAAU,aAAa;;AAEtE,YAAU,OAAO;;AAGnB,QACE,oBAAC,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;;;;;AC7CN,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,iBAAiB,cAAc;AACnC,SAAO,oCAAoC,MAAM;IAChD;EAAC,MAAM;EAAQ,MAAM;EAAQ,MAAM;EAAY,MAAM;EAAQ,CAAC;CAEjE,MAAM,eAAe,OAAyB,KAAK;AACnD,KAAI,aAAa,WAAW,KAC1B,cAAa,UAAU,IAAIC,aAAW;AAGxC,QACE,oBAAC,oBAAD;EACE,GAAI;EACY;EAChB,WAAW,aAAa;EACxB,CAAA;;;;ACKN,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
@@ -24,7 +24,7 @@ function parseLocale(request) {
24
24
  return i18nConfig.resolveSupportedLocale(candidates);
25
25
  }
26
26
  //#endregion
27
- //#region ../core/dist/api-BOEGbEF6.mjs
27
+ //#region ../core/dist/api-rqq7klYe.mjs
28
28
  function ensureSentence(text) {
29
29
  const trimmed = text.trim();
30
30
  if (!trimmed) return "";
@@ -40,9 +40,6 @@ function stripSentence(text) {
40
40
  }
41
41
  return trimmed.slice(0, end);
42
42
  }
43
- function lowercaseFirstWord(text) {
44
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
45
- }
46
43
  function formatDetails(details) {
47
44
  if (!details) return "";
48
45
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -51,12 +48,12 @@ function formatDetails(details) {
51
48
  }
52
49
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
53
50
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
54
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
51
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
55
52
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
56
53
  const messageParts = [
57
54
  whatAndWhy,
58
55
  reassurance,
59
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
56
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
60
57
  shouldCombineWayOut ? void 0 : wayOut,
61
58
  formatDetails(details)
62
59
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.rsc.cjs","names":[],"sources":["../src/functions/parseLocale.ts","../../core/dist/api-BOEGbEF6.mjs","../src/index.rsc.ts"],"sourcesContent":["import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","// React Server Component context surface.\n\nexport { parseLocale } from './functions/parseLocale';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { CustomMapping } from 'generaltranslation/types';\nimport {\n getGT,\n getI18nConfig,\n getMessages,\n getTranslations,\n} from 'gt-i18n/internal';\nimport { getLocale, getRegion } from 'gt-i18n';\nimport { use } from 'react';\n\n// ===== Error for client components ===== //\nfunction failClientComponent(componentName: string) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: `${componentName} cannot be consumed via the RSC entry point`,\n fix: 'Import this component from a client or server runtime entry point instead.',\n })\n );\n}\n\nexport function GTProvider() {\n return failClientComponent('GTProvider');\n}\nexport function LocaleSelector() {\n return failClientComponent('LocaleSelector');\n}\nexport function RegionSelector() {\n return failClientComponent('RegionSelector');\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n Num,\n Plural,\n RelativeTime,\n T,\n Var,\n Tx,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Hooks (cannot reference context) ===== //\n\nexport function useGT() {\n return use(getGT());\n}\nexport function useTranslations(rootId?: string) {\n return use(getTranslations(rootId));\n}\nexport function useMessages() {\n return use(getMessages());\n}\nexport function useLocale() {\n return getLocale();\n}\nexport function useRegion() {\n return getRegion();\n}\nexport function useLocales() {\n return getI18nConfig().getLocales();\n}\nexport function useLocaleDirection(locale: string) {\n return getI18nConfig().getGTClass().getLocaleDirection(locale);\n}\nexport function useLocaleProperties(locale: string) {\n return getI18nConfig().getGTClass().getLocaleProperties(locale);\n}\nexport function useDefaultLocale(): string {\n return getI18nConfig().getDefaultLocale();\n}\nexport function useCustomMapping(): CustomMapping {\n return getI18nConfig().getCustomMapping();\n}\n// ===== Internal Components ===== //\nexport {\n T as GtInternalTranslateJsx,\n GtInternalVar,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Render Helpers ===== //\nexport { createRenderPipeline } from '@generaltranslation/react-core/components-rsc';\n\n// ===== Translation Helpers ===== //\nexport {\n getFormatLocales,\n getTranslationsSnapshot,\n t,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Internal ===== //\nexport {\n getReactI18nCache,\n setReactI18nCache,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n gtFallback,\n mFallback,\n msg,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from '@generaltranslation/react-core/pure';\n\n// ===== Setup ===== //\nexport { internalInitializeGTSRA as initializeGT } from '@generaltranslation/react-core/pure';\n\n// ===== Types ===== //\nexport type {\n CurrencyProps,\n DateTimeProps,\n JsxTranslationOptions,\n NumProps,\n PluralProps,\n PreparedT,\n RelativeTimeFormatOptions,\n RelativeTimeProps,\n RenderVariable,\n ResolvedCurrencyProps,\n ResolvedDateTimeProps,\n ResolvedNumProps,\n ResolvedPluralProps,\n ResolvedRelativeTimeProps,\n} from '@generaltranslation/react-core/components-rsc';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nex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pB,SAAgB,aAAa;AAC3B,SAAA,GAAA,iBAAA,gBAAsB,CAAC,YAAY;;AAErC,SAAgB,mBAAmB,QAAgB;AACjD,SAAA,GAAA,iBAAA,gBAAsB,CAAC,YAAY,CAAC,mBAAmB,OAAO;;AAEhE,SAAgB,oBAAoB,QAAgB;AAClD,SAAA,GAAA,iBAAA,gBAAsB,CAAC,YAAY,CAAC,oBAAoB,OAAO;;AAEjE,SAAgB,mBAA2B;AACzC,SAAA,GAAA,iBAAA,gBAAsB,CAAC,kBAAkB;;AAE3C,SAAgB,mBAAkC;AAChD,SAAA,GAAA,iBAAA,gBAAsB,CAAC,kBAAkB"}
1
+ {"version":3,"file":"index.rsc.cjs","names":[],"sources":["../src/functions/parseLocale.ts","../../core/dist/api-rqq7klYe.mjs","../src/index.rsc.ts"],"sourcesContent":["import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","// React Server Component context surface.\n\nexport { parseLocale } from './functions/parseLocale';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { CustomMapping } from 'generaltranslation/types';\nimport {\n getGT,\n getI18nConfig,\n getMessages,\n getTranslations,\n} from 'gt-i18n/internal';\nimport { getLocale, getRegion } from 'gt-i18n';\nimport { use } from 'react';\n\n// ===== Error for client components ===== //\nfunction failClientComponent(componentName: string) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: `${componentName} cannot be consumed via the RSC entry point`,\n fix: 'Import this component from a client or server runtime entry point instead.',\n })\n );\n}\n\nexport function GTProvider() {\n return failClientComponent('GTProvider');\n}\nexport function LocaleSelector() {\n return failClientComponent('LocaleSelector');\n}\nexport function RegionSelector() {\n return failClientComponent('RegionSelector');\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n Num,\n Plural,\n RelativeTime,\n T,\n Var,\n Tx,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Hooks (cannot reference context) ===== //\n\nexport function useGT() {\n return use(getGT());\n}\nexport function useTranslations(rootId?: string) {\n return use(getTranslations(rootId));\n}\nexport function useMessages() {\n return use(getMessages());\n}\nexport function useLocale() {\n return getLocale();\n}\nexport function useRegion() {\n return getRegion();\n}\nexport function useLocales() {\n return getI18nConfig().getLocales();\n}\nexport function useLocaleDirection(locale: string) {\n return getI18nConfig().getGTClass().getLocaleDirection(locale);\n}\nexport function useLocaleProperties(locale: string) {\n return getI18nConfig().getGTClass().getLocaleProperties(locale);\n}\nexport function useDefaultLocale(): string {\n return getI18nConfig().getDefaultLocale();\n}\nexport function useCustomMapping(): CustomMapping {\n return getI18nConfig().getCustomMapping();\n}\n// ===== Internal Components ===== //\nexport {\n T as GtInternalTranslateJsx,\n GtInternalVar,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Render Helpers ===== //\nexport { createRenderPipeline } from '@generaltranslation/react-core/components-rsc';\n\n// ===== Translation Helpers ===== //\nexport {\n getFormatLocales,\n getTranslationsSnapshot,\n t,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Internal ===== //\nexport {\n getReactI18nCache,\n setReactI18nCache,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n gtFallback,\n mFallback,\n msg,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from '@generaltranslation/react-core/pure';\n\n// ===== Setup ===== //\nexport { internalInitializeGTSRA as initializeGT } from '@generaltranslation/react-core/pure';\n\n// ===== Types ===== //\nexport type {\n CurrencyProps,\n DateTimeProps,\n JsxTranslationOptions,\n NumProps,\n PluralProps,\n PreparedT,\n RelativeTimeFormatOptions,\n RelativeTimeProps,\n RenderVariable,\n ResolvedCurrencyProps,\n ResolvedDateTimeProps,\n ResolvedNumProps,\n ResolvedPluralProps,\n ResolvedRelativeTimeProps,\n} from '@generaltranslation/react-core/components-rsc';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,SAAgB,YAAY,SAAqC;CAC/D,MAAM,cAAA,GAAA,oCAAA,gBAA4B;CAClC,MAAM,aAAuB,EAAE;CAC/B,MAAM,gBAAA,GAAA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kBAAkB;;AAE3C,SAAgB,mBAAkC;AAChD,SAAA,GAAA,iBAAA,gBAAsB,CAAC,kBAAkB"}
@@ -23,7 +23,7 @@ function parseLocale(request) {
23
23
  return i18nConfig.resolveSupportedLocale(candidates);
24
24
  }
25
25
  //#endregion
26
- //#region ../core/dist/api-BOEGbEF6.mjs
26
+ //#region ../core/dist/api-rqq7klYe.mjs
27
27
  function ensureSentence(text) {
28
28
  const trimmed = text.trim();
29
29
  if (!trimmed) return "";
@@ -39,9 +39,6 @@ function stripSentence(text) {
39
39
  }
40
40
  return trimmed.slice(0, end);
41
41
  }
42
- function lowercaseFirstWord(text) {
43
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
44
- }
45
42
  function formatDetails(details) {
46
43
  if (!details) return "";
47
44
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -50,12 +47,12 @@ function formatDetails(details) {
50
47
  }
51
48
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
52
49
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
53
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
50
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
54
51
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
55
52
  const messageParts = [
56
53
  whatAndWhy,
57
54
  reassurance,
58
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
55
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
59
56
  shouldCombineWayOut ? void 0 : wayOut,
60
57
  formatDetails(details)
61
58
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.rsc.mjs","names":["getI18nConfig"],"sources":["../src/functions/parseLocale.ts","../../core/dist/api-BOEGbEF6.mjs","../src/index.rsc.ts"],"sourcesContent":["import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","// React Server Component context surface.\n\nexport { parseLocale } from './functions/parseLocale';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { CustomMapping } from 'generaltranslation/types';\nimport {\n getGT,\n getI18nConfig,\n getMessages,\n getTranslations,\n} from 'gt-i18n/internal';\nimport { getLocale, getRegion } from 'gt-i18n';\nimport { use } from 'react';\n\n// ===== Error for client components ===== //\nfunction failClientComponent(componentName: string) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: `${componentName} cannot be consumed via the RSC entry point`,\n fix: 'Import this component from a client or server runtime entry point instead.',\n })\n );\n}\n\nexport function GTProvider() {\n return failClientComponent('GTProvider');\n}\nexport function LocaleSelector() {\n return failClientComponent('LocaleSelector');\n}\nexport function RegionSelector() {\n return failClientComponent('RegionSelector');\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n Num,\n Plural,\n RelativeTime,\n T,\n Var,\n Tx,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Hooks (cannot reference context) ===== //\n\nexport function useGT() {\n return use(getGT());\n}\nexport function useTranslations(rootId?: string) {\n return use(getTranslations(rootId));\n}\nexport function useMessages() {\n return use(getMessages());\n}\nexport function useLocale() {\n return getLocale();\n}\nexport function useRegion() {\n return getRegion();\n}\nexport function useLocales() {\n return getI18nConfig().getLocales();\n}\nexport function useLocaleDirection(locale: string) {\n return getI18nConfig().getGTClass().getLocaleDirection(locale);\n}\nexport function useLocaleProperties(locale: string) {\n return getI18nConfig().getGTClass().getLocaleProperties(locale);\n}\nexport function useDefaultLocale(): string {\n return getI18nConfig().getDefaultLocale();\n}\nexport function useCustomMapping(): CustomMapping {\n return getI18nConfig().getCustomMapping();\n}\n// ===== Internal Components ===== //\nexport {\n T as GtInternalTranslateJsx,\n GtInternalVar,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Render Helpers ===== //\nexport { createRenderPipeline } from '@generaltranslation/react-core/components-rsc';\n\n// ===== Translation Helpers ===== //\nexport {\n getFormatLocales,\n getTranslationsSnapshot,\n t,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Internal ===== //\nexport {\n getReactI18nCache,\n setReactI18nCache,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n gtFallback,\n mFallback,\n msg,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from '@generaltranslation/react-core/pure';\n\n// ===== Setup ===== //\nexport { internalInitializeGTSRA as initializeGT } from '@generaltranslation/react-core/pure';\n\n// ===== Types ===== //\nexport type {\n CurrencyProps,\n DateTimeProps,\n JsxTranslationOptions,\n NumProps,\n PluralProps,\n PreparedT,\n RelativeTimeFormatOptions,\n RelativeTimeProps,\n RenderVariable,\n ResolvedCurrencyProps,\n ResolvedDateTimeProps,\n ResolvedNumProps,\n ResolvedPluralProps,\n ResolvedRelativeTimeProps,\n} from '@generaltranslation/react-core/components-rsc';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,YAAY,SAAqC;CAC/D,MAAM,aAAa,eAAe;CAClC,MAAM,aAAuB,EAAE;CAC/B,MAAM,eAAe,eACnB,QAAQ,QAAQ,IAAI,SAAS,EAC7B,WAAW,qBAAqB,CACjC;AAED,KAAI,aACF,YAAW,KAAK,aAAa;AAG/B,YAAW,KACT,GAAG,oBAAoB,QAAQ,QAAQ,IAAI,kBAAkB,CAAC,CAC/D;AAED,QAAO,WAAW,uBAAuB,WAAW;;;;AC1BtD,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MA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AAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cAAc,GAAG,cAAc;EAC/B,KAAK;EACN,CAAC,CACH;;AAGH,SAAgB,aAAa;AAC3B,QAAO,oBAAoB,aAAa;;AAE1C,SAAgB,iBAAiB;AAC/B,QAAO,oBAAoB,iBAAiB;;AAE9C,SAAgB,iBAAiB;AAC/B,QAAO,oBAAoB,iBAAiB;;AAmB9C,SAAgB,QAAQ;AACtB,QAAO,IAAI,OAAO,CAAC;;AAErB,SAAgB,gBAAgB,QAAiB;AAC/C,QAAO,IAAI,gBAAgB,OAAO,CAAC;;AAErC,SAAgB,cAAc;AAC5B,QAAO,IAAI,aAAa,CAAC;;AAE3B,SAAgB,YAAY;AAC1B,QAAO,WAAW;;AAEpB,SAAgB,YAAY;AAC1B,QAAO,WAAW;;AAEpB,SAAgB,aAAa;AAC3B,QAAOA,iBAAe,CAAC,YAAY;;AAErC,SAAgB,mBAAmB,QAAgB;AACjD,QAAOA,iBAAe,CAAC,YAAY,CAAC,mBAAmB,OAAO;;AAEhE,SAAgB,oBAAoB,QAAgB;AAClD,QAAOA,iBAAe,CAAC,YAAY,CAAC,oBAAoB,OAAO;;AAEjE,SAAgB,mBAA2B;AACzC,QAAOA,iBAAe,CAAC,kBAAkB;;AAE3C,SAAgB,mBAAkC;AAChD,QAAOA,iBAAe,CAAC,kBAAkB"}
1
+ {"version":3,"file":"index.rsc.mjs","names":["getI18nConfig"],"sources":["../src/functions/parseLocale.ts","../../core/dist/api-rqq7klYe.mjs","../src/index.rsc.ts"],"sourcesContent":["import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","// React Server Component context surface.\n\nexport { parseLocale } from './functions/parseLocale';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { CustomMapping } from 'generaltranslation/types';\nimport {\n getGT,\n getI18nConfig,\n getMessages,\n getTranslations,\n} from 'gt-i18n/internal';\nimport { getLocale, getRegion } from 'gt-i18n';\nimport { use } from 'react';\n\n// ===== Error for client components ===== //\nfunction failClientComponent(componentName: string) {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened: `${componentName} cannot be consumed via the RSC entry point`,\n fix: 'Import this component from a client or server runtime entry point instead.',\n })\n );\n}\n\nexport function GTProvider() {\n return failClientComponent('GTProvider');\n}\nexport function LocaleSelector() {\n return failClientComponent('LocaleSelector');\n}\nexport function RegionSelector() {\n return failClientComponent('RegionSelector');\n}\n\n// ===== Components ===== //\nexport {\n Branch,\n Currency,\n DateTime,\n Derive,\n Num,\n Plural,\n RelativeTime,\n T,\n Var,\n Tx,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Hooks (cannot reference context) ===== //\n\nexport function useGT() {\n return use(getGT());\n}\nexport function useTranslations(rootId?: string) {\n return use(getTranslations(rootId));\n}\nexport function useMessages() {\n return use(getMessages());\n}\nexport function useLocale() {\n return getLocale();\n}\nexport function useRegion() {\n return getRegion();\n}\nexport function useLocales() {\n return getI18nConfig().getLocales();\n}\nexport function useLocaleDirection(locale: string) {\n return getI18nConfig().getGTClass().getLocaleDirection(locale);\n}\nexport function useLocaleProperties(locale: string) {\n return getI18nConfig().getGTClass().getLocaleProperties(locale);\n}\nexport function useDefaultLocale(): string {\n return getI18nConfig().getDefaultLocale();\n}\nexport function useCustomMapping(): CustomMapping {\n return getI18nConfig().getCustomMapping();\n}\n// ===== Internal Components ===== //\nexport {\n T as GtInternalTranslateJsx,\n GtInternalVar,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Render Helpers ===== //\nexport { createRenderPipeline } from '@generaltranslation/react-core/components-rsc';\n\n// ===== Translation Helpers ===== //\nexport {\n getFormatLocales,\n getTranslationsSnapshot,\n t,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Internal ===== //\nexport {\n getReactI18nCache,\n setReactI18nCache,\n} from '@generaltranslation/react-core/components-rsc';\n\n// ===== Functions ===== //\nexport {\n decodeMsg,\n decodeOptions,\n decodeVars,\n declareVar,\n derive,\n gtFallback,\n mFallback,\n msg,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getVersionId,\n} from '@generaltranslation/react-core/pure';\n\n// ===== Setup ===== //\nexport { internalInitializeGTSRA as initializeGT } from '@generaltranslation/react-core/pure';\n\n// ===== Types ===== //\nexport type {\n CurrencyProps,\n DateTimeProps,\n JsxTranslationOptions,\n NumProps,\n PluralProps,\n PreparedT,\n RelativeTimeFormatOptions,\n RelativeTimeProps,\n RenderVariable,\n ResolvedCurrencyProps,\n ResolvedDateTimeProps,\n ResolvedNumProps,\n ResolvedPluralProps,\n ResolvedRelativeTimeProps,\n} from '@generaltranslation/react-core/components-rsc';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,YAAY,SAAqC;CAC/D,MAAM,aAAa,eAAe;CAClC,MAAM,aAAuB,EAAE;CAC/B,MAAM,eAAe,eACnB,QAAQ,QAAQ,IAAI,SAAS,EAC7B,WAAW,qBAAqB,CACjC;AAED,KAAI,aACF,YAAW,KAAK,aAAa;AAG/B,YAAW,KACT,GAAG,oBAAoB,QAAQ,QAAQ,IAAI,kBAAkB,CAAC,CAC/D;AAED,QAAO,WAAW,uBAAuB,WAAW;;;;AC1BtD,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAMhD,SAA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;AAC3B,QAAOA,iBAAe,CAAC,YAAY;;AAErC,SAAgB,mBAAmB,QAAgB;AACjD,QAAOA,iBAAe,CAAC,YAAY,CAAC,mBAAmB,OAAO;;AAEhE,SAAgB,oBAAoB,QAAgB;AAClD,QAAOA,iBAAe,CAAC,YAAY,CAAC,oBAAoB,OAAO;;AAEjE,SAAgB,mBAA2B;AACzC,QAAOA,iBAAe,CAAC,kBAAkB;;AAE3C,SAAgB,mBAAkC;AAChD,QAAOA,iBAAe,CAAC,kBAAkB"}
@@ -6,7 +6,7 @@ let _generaltranslation_react_core_hooks = require("@generaltranslation/react-co
6
6
  let _generaltranslation_react_core_components = require("@generaltranslation/react-core/components");
7
7
  let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
- //#region ../core/dist/api-BOEGbEF6.mjs
9
+ //#region ../core/dist/api-rqq7klYe.mjs
10
10
  function ensureSentence(text) {
11
11
  const trimmed = text.trim();
12
12
  if (!trimmed) return "";
@@ -22,9 +22,6 @@ function stripSentence(text) {
22
22
  }
23
23
  return trimmed.slice(0, end);
24
24
  }
25
- function lowercaseFirstWord(text) {
26
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
27
- }
28
25
  function formatDetails(details) {
29
26
  if (!details) return "";
30
27
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -33,12 +30,12 @@ function formatDetails(details) {
33
30
  }
34
31
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
35
32
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
36
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
33
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
37
34
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
38
35
  const messageParts = [
39
36
  whatAndWhy,
40
37
  reassurance,
41
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
38
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
42
39
  shouldCombineWayOut ? void 0 : wayOut,
43
40
  formatDetails(details)
44
41
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.cjs","names":["ReadonlyConditionStore","I18nStore","InternalGTProvider","InternalLocaleSelector","InternalRegionSelector"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\ntype CreateOrUpdateBrowserConditionStore =\n typeof import('./condition-store/createBrowserConditionStore').createOrUpdateBrowserConditionStore;\n\nconst createBrowserConditionStoreServerError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point',\n why: 'createOrUpdateBrowserConditionStore() initializes browser-only condition state.',\n fix: 'Call createOrUpdateBrowserConditionStore() from the browser runtime entry point.',\n});\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\nexport const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore =\n () => {\n throw new Error(createBrowserConditionStoreServerError);\n };\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAA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AAA,GAAA,kBAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;ACtCN,MAAM,yCAAyC,wBAAwB;CACrE,QAAQ;CACR,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC;AAEF,MAAa,kBAAmC,YAAY;AAC1D,OAAM,IAAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAGH,MAAa,4CACL;AACJ,OAAM,IAAI,MAAM,uCAAuC;;AAuB3D,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
1
+ {"version":3,"file":"index.server.cjs","names":["ReadonlyConditionStore","I18nStore","InternalGTProvider","InternalLocaleSelector","InternalRegionSelector"],"sources":["../../core/dist/api-rqq7klYe.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\ntype CreateOrUpdateBrowserConditionStore =\n typeof import('./condition-store/createBrowserConditionStore').createOrUpdateBrowserConditionStore;\n\nconst createBrowserConditionStoreServerError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point',\n why: 'createOrUpdateBrowserConditionStore() initializes browser-only condition state.',\n fix: 'Call createOrUpdateBrowserConditionStore() from the browser runtime entry point.',\n});\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\nexport const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore =\n () => {\n throw new Error(createBrowserConditionStoreServerError);\n };\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,Q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BAAA,KAACC,0CAAAA,wBAAD;EACU;EACC;EACG;EACZ,WAAW;EACX,GAAI;EACJ,CAAA;;;;ACtCN,MAAM,yCAAyC,wBAAwB;CACrE,QAAQ;CACR,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC;AAEF,MAAa,kBAAmC,YAAY;AAC1D,OAAM,IAAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAGH,MAAa,4CACL;AACJ,OAAM,IAAI,MAAM,uCAAuC;;AAuB3D,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
@@ -5,7 +5,7 @@ import { useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, us
5
5
  import { Branch, Currency, DateTime, Derive, GtInternalTranslateJsx, GtInternalVar, I18nStore, InternalGTProvider, InternalLocaleSelector, InternalRegionSelector, Num, Plural, RelativeTime, T, Var } from "@generaltranslation/react-core/components";
6
6
  import { useMemo, useRef } from "react";
7
7
  import { jsx } from "react/jsx-runtime";
8
- //#region ../core/dist/api-BOEGbEF6.mjs
8
+ //#region ../core/dist/api-rqq7klYe.mjs
9
9
  function ensureSentence(text) {
10
10
  const trimmed = text.trim();
11
11
  if (!trimmed) return "";
@@ -21,9 +21,6 @@ function stripSentence(text) {
21
21
  }
22
22
  return trimmed.slice(0, end);
23
23
  }
24
- function lowercaseFirstWord(text) {
25
- return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
26
- }
27
24
  function formatDetails(details) {
28
25
  if (!details) return "";
29
26
  const detailText = Array.isArray(details) ? details.join(", ") : details;
@@ -32,12 +29,12 @@ function formatDetails(details) {
32
29
  }
33
30
  function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
34
31
  const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
35
- const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
32
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;
36
33
  const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
37
34
  const messageParts = [
38
35
  whatAndWhy,
39
36
  reassurance,
40
- shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
37
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,
41
38
  shouldCombineWayOut ? void 0 : wayOut,
42
39
  formatDetails(details)
43
40
  ].filter((part) => !!part).map(ensureSentence);
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.mjs","names":["useSetLocale","useSetRegion","useSetLocale"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\ntype CreateOrUpdateBrowserConditionStore =\n typeof import('./condition-store/createBrowserConditionStore').createOrUpdateBrowserConditionStore;\n\nconst createBrowserConditionStoreServerError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point',\n why: 'createOrUpdateBrowserConditionStore() initializes browser-only condition state.',\n fix: 'Call createOrUpdateBrowserConditionStore() from the browser runtime entry point.',\n});\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\nexport const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore =\n () => {\n throw new Error(createBrowserConditionStoreServerError);\n };\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,M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M,yCAAyC,wBAAwB;CACrE,QAAQ;CACR,UAAU;CACV,cACE;CACF,KAAK;CACL,KAAK;CACN,CAAC;AAEF,MAAa,kBAAmC,YAAY;AAC1D,OAAM,IAAI,MACR,wBAAwB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAGH,MAAa,4CACL;AACJ,OAAM,IAAI,MAAM,uCAAuC;;AAuB3D,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
1
+ {"version":3,"file":"index.server.mjs","names":["useSetLocale","useSetRegion","useSetLocale"],"sources":["../../core/dist/api-rqq7klYe.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${stripSentence(why)}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-rqq7klYe.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"πŸ‡ΊπŸ‡Έ\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\ntype CreateOrUpdateBrowserConditionStore =\n typeof import('./condition-store/createBrowserConditionStore').createOrUpdateBrowserConditionStore;\n\nconst createBrowserConditionStoreServerError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point',\n why: 'createOrUpdateBrowserConditionStore() initializes browser-only condition state.',\n fix: 'Call createOrUpdateBrowserConditionStore() from the browser runtime entry point.',\n});\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\nexport const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore =\n () => {\n throw new Error(createBrowserConditionStoreServerError);\n };\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ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AA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-react",
3
- "version": "11.1.4",
3
+ "version": "11.1.5",
4
4
  "description": "A React library for automatic internationalization.",
5
5
  "main": "./dist/index.server.cjs",
6
6
  "module": "./dist/index.server.mjs",
@@ -17,9 +17,9 @@
17
17
  "react-dom": ">=18.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "generaltranslation": "9.1.0",
21
- "@generaltranslation/react-core": "11.1.4",
22
- "gt-i18n": "1.0.10"
20
+ "generaltranslation": "9.1.1",
21
+ "@generaltranslation/react-core": "11.1.5",
22
+ "gt-i18n": "1.0.11"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",