'use client';


import { built_default } from "../@intlayer/config/dist/esm/built.mjs";
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
import { useDictionary } from "./useDictionary.mjs";
import { useContext, useMemo } from "react";

//#region ../react-intlayer/dist/esm/client/useDictionaryAsync.mjs
/**
* On the server side, Hook that transform a dictionary and return the content
*
* If the locale is not provided, it will use the locale from the client context
*/
const useDictionaryAsync = async (dictionaryPromise, locale) => {
	const { locale: currentLocale } = useContext(IntlayerClientContext);
	const localeTarget = useMemo(() => locale ?? currentLocale ?? built_default?.internationalization.defaultLocale, [currentLocale, locale]);
	return useDictionary(await useMemo(async () => await dictionaryPromise[localeTarget]?.(), [dictionaryPromise, localeTarget]), localeTarget);
};

//#endregion
export { useDictionaryAsync };
//# sourceMappingURL=useDictionaryAsync.mjs.map