import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
import { useCallback, useContext } from 'react';
import { useCommander } from '../../../../hooks';
import { EntitySelectionContext, HotkeysSectionProvider } from '../../../../providers';
import { copyByPaths, moveByPaths, deleteTemplates, } from '../../../../commands/templates';
import { CHILDREN_FIELD_MAP } from '../../consts';
import { getSelectedPaths } from './utils';
import { ActionBar } from './action-bar';
import { TemplatesTree } from './tree';
const ROOT_PATH = ['templates'];
export const TemplatesExplorer = () => {
    const { paths: selectedPaths } = useContext(EntitySelectionContext);
    const { dispatch } = useCommander();
    const handleCopyTo = useCallback((source, destination) => dispatch(copyByPaths(source, destination)), []);
    const handleMoveTo = useCallback((source, destination) => dispatch(moveByPaths(source, destination)), []);
    const handleRemove = useCallback((paths) => dispatch(deleteTemplates(paths)), []);
    return (_jsxs(HotkeysSectionProvider, { childrenFieldMap: CHILDREN_FIELD_MAP, rootPath: ROOT_PATH, selectedPaths: getSelectedPaths(selectedPaths), onCopyTo: handleCopyTo, onMoveTo: handleMoveTo, onRemove: handleRemove, children: [_jsx(ActionBar, {}), _jsx(TemplatesTree, { onDrop: handleMoveTo })] }));
};
