import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2007-2026 GoodData Corporation
import { FormattedMessage } from "react-intl";
import { Bubble, BubbleHoverTrigger } from "@gooddata/sdk-ui-kit";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectSupportsMultipleDateFilters } from "../../../model/store/backendCapabilities/backendCapabilitiesSelectors.js";
import { selectHasCatalogAttributes, selectHasCatalogDateDatasets, } from "../../../model/store/catalog/catalogSelectors.js";
import { selectIsWhiteLabeled } from "../../../model/store/config/configSelectors.js";
import { selectCanAddMoreFilters } from "../../../model/store/tabs/filterContext/filterContextSelectors.js";
import { DraggableAttributeFilterCreatePanelItem } from "../../dragAndDrop/draggableAttributeFilter/DraggableAttributeFilterCreatePanelItem.js";
import { AddAttributeFilterPlaceholder } from "./addAttributeFilter/AddAttributeFilterPlaceholder.js";
/**
 * @internal
 */
export function CreatableAttributeFilter({ WrapCreatePanelItemWithDragComponent, }) {
    const hasAttributes = useDashboardSelector(selectHasCatalogAttributes);
    const hasDateDataSets = useDashboardSelector(selectHasCatalogDateDatasets);
    const supportsMultipleDateFilters = useDashboardSelector(selectSupportsMultipleDateFilters);
    const canAddMoreFilters = useDashboardSelector(selectCanAddMoreFilters);
    const isWhiteLabeled = useDashboardSelector(selectIsWhiteLabeled);
    const noItems = supportsMultipleDateFilters ? !hasAttributes && !hasDateDataSets : !hasAttributes;
    const disabled = noItems || !canAddMoreFilters;
    const tooltip = disabled && noItems ? (_jsxs("div", { children: [supportsMultipleDateFilters ? (_jsx(FormattedMessage, { id: "addPanel.attributeFilter.tooltip.no_items" })) : (_jsx(FormattedMessage, { id: "addPanel.attributeFilter.tooltip.no_attributes" })), "\u00A0", isWhiteLabeled ? null : (_jsx("a", { href: "https://help.gooddata.com/display/doc/Attributes+in+Logical+Data+Models", rel: "noopener noreferrer", target: "_blank", className: "s-add-attribute-filter-tooltip-link", children: _jsx(FormattedMessage, { id: "addPanel.attributeFilter.tooltip.no_attributes.link" }) }))] })) : undefined;
    return (_jsxs(BubbleHoverTrigger, { eventsOnBubble: true, className: "s-add-attribute-filter-bubble-trigger", children: [
            _jsx(DraggableAttributeFilterCreatePanelItem, { CreatePanelItemComponent: AddAttributeFilterPlaceholder, WrapCreatePanelItemWithDragComponent: WrapCreatePanelItemWithDragComponent, disabled: disabled }), tooltip ? (_jsx(Bubble, { alignPoints: [{ align: "cr cl", offset: { x: -20, y: 0 } }], children: tooltip })) : null] }));
}
//# sourceMappingURL=CreatableAttributeFilter.js.map