import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import cx from "classnames";
import { areObjRefsEqual } from "@gooddata/sdk-model";
import { useDashboardSelector } from "../../../../../model/react/DashboardStoreProvider.js";
import { selectCatalogDateDatasets } from "../../../../../model/store/catalog/catalogSelectors.js";
export function DrillAttributeSelectorItem(props) {
    const { item } = props;
    const onClick = () => {
        props.onClick(item);
        props.onCloseDropdown();
    };
    const name = item.attribute.attributeHeader.formOf.name;
    const dateAttributes = useDashboardSelector(selectCatalogDateDatasets);
    const isFromDateAttribute = dateAttributes.some((attribute) => attribute.dateAttributes.some((dateAttribute) => areObjRefsEqual(dateAttribute.attribute.ref, item.attribute.attributeHeader.formOf.ref)));
    return (_jsx("a", { onClick: onClick, className: cx("s-drill-attribute-selector-item", {
            "gd-drill-attribute-selector-list-item": !isFromDateAttribute,
            "gd-drill-attribute-date-selector-list-item": isFromDateAttribute,
        }), title: name, children: name }));
}
