'use client';


const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
const require_messagesKeys = require('../@intlayer/editor-react/dist/esm/editor/dist/esm/messagesKeys.cjs');
const require_CommunicatorContext = require('../@intlayer/editor-react/dist/esm/CommunicatorContext.cjs');
const require_EditorEnabledContext = require('../@intlayer/editor-react/dist/esm/EditorEnabledContext.cjs');
const require_FocusDictionaryContext = require('../@intlayer/editor-react/dist/esm/FocusDictionaryContext.cjs');
const require_IntlayerProvider = require('../client/IntlayerProvider.cjs');
const require_nodeType = require('../@intlayer/types/dist/esm/nodeType.cjs');
const require_isSameKeyPath = require('../@intlayer/core/dist/esm/utils/isSameKeyPath.cjs');
const require_ContentSelector = require('../UI/ContentSelector.cjs');
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");

//#region ../react-intlayer/dist/esm/editor/ContentSelectorWrapper.mjs
const ContentSelectorWrapperContent = ({ children, dictionaryKey, keyPath }) => {
	const { focusedContent, setFocusedContent } = require_FocusDictionaryContext.useFocusDictionary();
	const { postMessage, senderId } = require_CommunicatorContext.useCommunicator();
	const filteredKeyPath = (0, react.useMemo)(() => keyPath.filter((key) => key.type !== require_nodeType.NodeType.Translation), [keyPath]);
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ContentSelector.ContentSelector, {
		onPress: (0, react.useCallback)(() => setFocusedContent({
			dictionaryKey,
			keyPath: filteredKeyPath
		}), [dictionaryKey, filteredKeyPath]),
		onHover: (0, react.useCallback)(() => postMessage({
			type: `${require_messagesKeys.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
			data: {
				dictionaryKey,
				keyPath: filteredKeyPath
			},
			senderId
		}), [dictionaryKey, filteredKeyPath]),
		onUnhover: (0, react.useCallback)(() => postMessage({
			type: `${require_messagesKeys.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
			data: null,
			senderId
		}), [senderId]),
		isSelecting: (0, react.useMemo)(() => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && require_isSameKeyPath.isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ?? false, [
			focusedContent,
			filteredKeyPath,
			dictionaryKey
		]),
		children
	});
};
const ContentSelectorRenderer = ({ children,...props }) => {
	const { enabled } = require_EditorEnabledContext.useEditorEnabled();
	const { disableEditor } = require_IntlayerProvider.useIntlayerContext();
	if (enabled && !disableEditor) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContentSelectorWrapperContent, {
		...props,
		children
	});
	return children;
};

//#endregion
exports.ContentSelectorRenderer = ContentSelectorRenderer;
//# sourceMappingURL=ContentSelectorWrapper.cjs.map