'use client';


const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
const require_EditedContentContext = require('../@intlayer/editor-react/dist/esm/EditedContentContext.cjs');
const require_getContent = require('../@intlayer/core/dist/esm/interpreter/getContent/getContent.cjs');
const require_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
let react = require("react");

//#region ../react-intlayer/dist/esm/editor/useEditedContentRenderer.mjs
const useEditedContentRenderer = ({ dictionaryKey, keyPath, children }) => {
	const editedContentContext = require_EditedContentContext.useEditedContentActions();
	if (editedContentContext) return editedContentContext.getEditedContentValue(dictionaryKey, keyPath) ?? children;
	return children;
};
const EditedContentRenderer = (props) => {
	const content = useEditedContentRenderer(props);
	if (typeof content === "object") {
		const transformedEditedContent = require_getContent.getContent(content, props, props.locale);
		if (typeof transformedEditedContent !== "string") {
			console.error(`Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`);
			return /* @__PURE__ */ (0, react.createElement)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
				...props,
				key: props.children
			}, props.children);
		}
		return /* @__PURE__ */ (0, react.createElement)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
			...props,
			key: props.children
		}, transformedEditedContent);
	}
	return /* @__PURE__ */ (0, react.createElement)(require_ContentSelectorWrapper.ContentSelectorRenderer, {
		...props,
		key: props.children
	}, content);
};

//#endregion
exports.EditedContentRenderer = EditedContentRenderer;
exports.useEditedContentRenderer = useEditedContentRenderer;
//# sourceMappingURL=useEditedContentRenderer.cjs.map