import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import _ from 'lodash';
import { BlockIdContext } from "../../../context/blockIdContext/index.js";
import { generateChildrenPathFromArray } from "../../../editor-v2/index.js";
import { usePCEditorBlockRegister } from "../../../hooks/usePCEditorBlockRegister.js";
import { usePCEditorStore } from "../../../hooks/usePCEditorStore.js";
import { block } from "../../../utils/index.js";
import './ChildrensWrap.css';
const b = block('childrens-wrap');
const ChildrensWrap = ({ children }) => {
    const { manipulateOverlayMode, content } = usePCEditorStore();
    const parentBlockId = React.useContext(BlockIdContext);
    const newBlockIndex = React.useMemo(() => {
        const contentConfig = _.get(content.blocks, generateChildrenPathFromArray(parentBlockId));
        return contentConfig?.children?.length ?? 0;
    }, [content.blocks, parentBlockId]);
    const path = React.useMemo(() => [...parentBlockId, newBlockIndex], [parentBlockId, newBlockIndex]);
    const blockRef = usePCEditorBlockRegister(path, true);
    if (manipulateOverlayMode === 'insert' && newBlockIndex === 0) {
        return _jsx("div", { ref: blockRef, className: b({ 'drop-zone': true }) });
    }
    if (manipulateOverlayMode === 'insert') {
        return (_jsx("div", { ref: blockRef, className: b(), children: children }));
    }
    return children;
};
export default ChildrensWrap;
//# sourceMappingURL=ChildrensWrap.js.map
