import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import FloatingRect from './FloatingRect';
import useSelector from './use-selector';
import { getSelectedDimensions } from './util';
const Selected = ({ scrollPos = { top: 0, left: 0 }, }) => {
    const selected = useSelector((state) => state.selected);
    const dragging = useSelector((state) => state.dragging);
    const hidden = useSelector((state) => state.selected.size(state.model.data) < 2);
    const dimensions = useSelector((state) => selected &&
        getSelectedDimensions(state.rowDimensions, state.columnDimensions, state.model.data, state.selected));
    const adjustedDimensions = React.useMemo(() => {
        if (!dimensions)
            return undefined;
        return {
            ...dimensions,
            top: dimensions.top - 1,
            left: dimensions.left - 1,
            height: dimensions.height - 1,
            width: dimensions.width - 1,
        };
    }, [dimensions, scrollPos]);
    return (_jsx(FloatingRect, { variant: "selected", dimensions: adjustedDimensions, dragging: dragging, hidden: hidden || !dimensions }));
};
export default Selected;
//# sourceMappingURL=Selected.js.map