{"version":3,"file":"useDictionary.cjs","names":["getDictionary","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n  DeclaredLocales,\n  LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n  const T extends Dictionary,\n  const L extends LocalesValues = DeclaredLocales,\n>(\n  dictionary: T,\n  locale?: L,\n  fallbackLocale?: DeclaredLocales\n) => {\n  const localeTarget =\n    locale ??\n    getServerContext<LocalesValues>(IntlayerServerContext) ??\n    fallbackLocale;\n\n  return getDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,iBAIX,YACA,QACA,mBACG;AAMH,QAAOA,oCAAoB,YAJzB,UACAC,8CAAgCC,4DAAsB,IACtD,eAEuD"}