'use client';


import { useEditorLocale } from "../@intlayer/editor-react/dist/esm/useEditorLocale.mjs";
import { getContent } from "../@intlayer/core/dist/esm/interpreter/getContent/getContent.mjs";
import { getMarkdownMetadata } from "../@intlayer/core/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs";
import { useEditedContentRenderer } from "../editor/useEditedContentRenderer.mjs";
import { getContentNodeByKeyPath } from "../@intlayer/core/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs";
import { useMarkdownContext } from "./MarkdownProvider.mjs";

//#region ../react-intlayer/dist/esm/markdown/MarkdownRenderer.mjs
const MarkdownRenderer = ({ dictionaryKey, keyPath, children, locale }) => {
	const { renderMarkdown } = useMarkdownContext();
	const editedContentContext = useEditedContentRenderer({
		dictionaryKey,
		keyPath,
		children
	});
	if (typeof editedContentContext !== "string") {
		const transformedEditedContent = getContent(editedContentContext, {
			dictionaryKey,
			keyPath
		}, locale);
		if (typeof transformedEditedContent !== "string") {
			console.error(`Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`);
			return renderMarkdown(children);
		}
		return renderMarkdown(transformedEditedContent);
	}
	return renderMarkdown(editedContentContext);
};
const MarkdownMetadataRenderer = ({ dictionaryKey, keyPath, children, metadataKeyPath }) => {
	const editedContentContext = useEditedContentRenderer({
		dictionaryKey,
		keyPath,
		children
	});
	const currentLocale = useEditorLocale();
	return getContentNodeByKeyPath(getMarkdownMetadata(editedContentContext), metadataKeyPath, currentLocale);
};

//#endregion
export { MarkdownMetadataRenderer, MarkdownRenderer };
//# sourceMappingURL=MarkdownRenderer.mjs.map