import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import cx from "classnames";
import { FormattedMessage } from "react-intl";
import { invariant } from "ts-invariant";
import { areObjRefsEqual } from "@gooddata/sdk-model";
import { Bubble, BubbleHoverTrigger } from "@gooddata/sdk-ui-kit";
import { simplifyText } from "@gooddata/util";
import { useDashboardSelector } from "../../../../../../model/react/DashboardStoreProvider.js";
import { selectCatalogAttributes } from "../../../../../../model/store/catalog/catalogSelectors.js";
import { selectAttributeFilterDisplayFormByLocalId } from "../../../../../../model/store/tabs/filterContext/filterContextSelectors.js";
const ALIGN_POINTS = [{ align: "bc tl" }, { align: "tc bl" }];
const ARROW_OFFSET = {
    "bc tl": [-100, 10],
    "tc bl": [-100, -10],
};
export function ParentFiltersDisabledItem({ itemLocalId, itemTitle, hasConnectingAttributes, }) {
    const itemDisplayForm = useDashboardSelector(selectAttributeFilterDisplayFormByLocalId(itemLocalId || ""));
    const attributes = useDashboardSelector(selectCatalogAttributes);
    const itemAttribute = attributes.find((attr) => attr.displayForms.some((df) => areObjRefsEqual(df.ref, itemDisplayForm)));
    const currentFilterTitle = itemAttribute?.attribute.title;
    invariant(itemTitle, "The parent filter title could not be fetched.");
    const itemClasses = cx("gd-list-item attribute-filter-item s-attribute-filter-dropdown-configuration-item", `s-${simplifyText(itemTitle)}`);
    return (_jsxs(BubbleHoverTrigger, { hideDelay: 0, children: [
            _jsx("div", { className: itemClasses, children: _jsxs("label", { className: "input-checkbox-label configuration-item-title", children: [
                        _jsx("input", { type: "checkbox", className: "input-checkbox s-checkbox", readOnly: true, disabled: true, checked: false }), _jsx("span", { className: "input-label-text", children: itemTitle })
                    ] }) }), _jsx(Bubble, { className: "bubble-primary gd-attribute-filter-dropdown-bubble s-attribute-filter-dropdown-bubble", alignPoints: ALIGN_POINTS, arrowOffsets: ARROW_OFFSET, children: hasConnectingAttributes ? (_jsx("div", { children: _jsx(FormattedMessage, { id: "attributesDropdown.filterConfiguredMessage", values: {
                            childTitle: currentFilterTitle,
                            parentTitle: itemTitle,
                            strong: (chunks) => _jsx("strong", { children: chunks }),
                        } }) })) : (_jsx("div", { children: _jsx(FormattedMessage, { id: "attributesDropdown.noConnectionMessage", values: {
                            childTitle: currentFilterTitle,
                            parentTitle: itemTitle,
                            strong: (chunks) => _jsx("strong", { children: chunks }),
                        } }) })) })
        ] }));
}
//# sourceMappingURL=ParentFiltersDisabledItem.js.map