import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2026 GoodData Corporation
import { useCallback } from "react";
import classNames from "classnames";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectIsInEditMode } from "../../../model/store/renderMode/renderModeSelectors.js";
import { selectCanAddMoreFilters } from "../../../model/store/tabs/filterContext/filterContextSelectors.js";
import { DraggableFilterDropZoneHint } from "../draggableFilterDropZone/DraggableFilterDropZoneHint.js";
import { useDashboardDrag } from "../useDashboardDrag.js";
/**
 * Mirrors {@link DraggableAttributeFilter} so MVF chips occupy a real draggable slot in
 * the filter list with proper neighbor drop targets.
 *
 * @internal
 */
export function DraggableMeasureValueFilter({ FilterComponent, filter, filterIndex, autoOpen, readonly, onMeasureValueFilterChanged, onMeasureValueFilterAdded, onMeasureValueFilterClose, }) {
    const isInEditMode = useDashboardSelector(selectIsInEditMode);
    const [{ isDragging }, dragRef] = useDashboardDrag({
        dragItem: {
            type: "measureValueFilter",
            filter,
            filterIndex,
        },
        canDrag: isInEditMode,
    }, [filter, filterIndex, isInEditMode]);
    const onClose = useCallback(() => {
        onMeasureValueFilterClose();
    }, [onMeasureValueFilterClose]);
    const canAddMoreFilters = useDashboardSelector(selectCanAddMoreFilters);
    const showDropZones = isInEditMode && !isDragging;
    return (_jsxs("div", { className: "draggable-measure-value-filter", children: [showDropZones ? (_jsx(DraggableFilterDropZoneHint, { hintPosition: "prev", targetIndex: filterIndex, onAddAttributePlaceholder: onMeasureValueFilterAdded, acceptPlaceholder: canAddMoreFilters })) : null, _jsx("div", { className: classNames("dash-filters-notdate", "dash-filters-mvf", {
                    "dash-filter-is-edit-mode": isInEditMode,
                    "is-dragging": isDragging,
                }), ref: dragRef, children: _jsx(FilterComponent, { autoOpen: autoOpen, filter: filter, filterIndex: filterIndex, readonly: readonly, onMeasureValueFilterChanged: onMeasureValueFilterChanged, onMeasureValueFilterClose: onClose }) }), showDropZones ? (_jsx(DraggableFilterDropZoneHint, { hintPosition: "next", targetIndex: filterIndex, onAddAttributePlaceholder: onMeasureValueFilterAdded, acceptPlaceholder: canAddMoreFilters })) : null] }));
}
