import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import { forwardRef, useEffect } from "react";
import cx from "classnames";
import { changeFilterContextSelection } from "../../../model/commands/filters.js";
import { useDispatchDashboardCommand } from "../../../model/react/useDispatchDashboardCommand.js";
import { useWidgetSelection } from "../../../model/react/useWidgetSelection.js";
import { useDashboardDrop } from "../../dragAndDrop/useDashboardDrop.js";
import { useWidgetDragHoverHandlers as useFlexibleWidgetDragHoverHandlers } from "../../flexibleLayout/dragAndDrop/draggableWidget/useWidgetDragHoverHandlers.js";
import { DashboardLayout } from "../../widget/dashboardLayout/DashboardLayout.js";
import { DateFilterConfigWarnings } from "./DateFilterConfigWarnings.js";
export const DashboardMainContent = forwardRef(function DashboardMainContent(_, ref) {
    const onFiltersChange = useDispatchDashboardCommand(changeFilterContextSelection);
    const { deselectWidgets } = useWidgetSelection();
    const useWidgetDragHoverHandlers = useFlexibleWidgetDragHoverHandlers;
    const { handleDragHoverEnd } = useWidgetDragHoverHandlers();
    const [{ isOver }, dropRef] = useDashboardDrop([
        "insight",
        "insight-placeholder",
        "insightListItem",
        "kpi",
        "kpi-placeholder",
        "richText",
        "richTextListItem",
        "visualizationSwitcher",
        "visualizationSwitcherListItem",
        "dashboardLayout",
        "dashboardLayoutListItem",
    ], {});
    useEffect(() => {
        if (!isOver) {
            handleDragHoverEnd();
        }
    }, [handleDragHoverEnd, isOver]);
    const classNames = cx("gd-flex-container", "root-flex-maincontent", "gd-grid-layout", "gd-auto-resized-dashboard-descriptions");
    return (_jsx("div", { className: "gd-flex-item-stretch dash-section dash-section-kpis", ref: ref, children: _jsxs("div", { className: classNames, ref: dropRef, onClick: deselectWidgets, children: [
                _jsx(DateFilterConfigWarnings, {}), _jsx(DashboardLayout, { onFiltersChange: onFiltersChange })
            ] }) }));
});
//# sourceMappingURL=DashboardMainContent.js.map