{"version":3,"file":"t.cjs","names":["getServerContext","IntlayerServerContext"],"sources":["../../../src/server/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type {\n  DeclaredLocales,\n  LocalesValues,\n  StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n *   en: 'Hello',\n *   fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string, L extends LocalesValues = DeclaredLocales>(\n  multilangContent: StrictModeLocaleMap<Content>,\n  locale?: L\n) => {\n  const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n  const localeTarget = locale ?? (currentLocale as LocalesValues);\n\n  return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,KACX,kBACA,WACG;CACH,MAAM,gBAAgBA,8CAAgCC,4DAAsB;AAG5E,uDAA+B,kBAFV,UAAW,cAE8B"}