import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { Action, CloseIcon, tasty } from '@cube-dev/ui-kit';
import { getTypeIcon } from '../utils';
import { useShownMemberName } from '../hooks';
import { MemberLabelText } from './MemberLabelText';
const FilterMemberElement = tasty({
    styles: {
        padding: {
            '': '.75x 1x',
            '[data-size="small"]': '.25x .5x',
        },
        display: 'flex',
        justifyContent: 'space-between',
        position: 'relative',
        radius: true,
        fill: {
            '': '#border',
            '[data-member="measure"]': '#measure-active',
            '[data-member="dimension"]': '#dimension-active',
            '[data-member="timeDimension"]': '#time-dimension-active',
            '[data-member="segment"]': '#segment-active',
        },
    },
});
export function FilterLabel(props) {
    const { type, isMissing, member, name, cubeName = props.name.split('.')[0], cubeTitle, memberName = props.name.split('.')[1], memberTitle, memberViewType, isCompact, size = 'normal', hideIcon = false, onRemove, } = props;
    const { shownMemberName, shownCubeName } = useShownMemberName({
        memberName,
        memberTitle,
        cubeName,
        cubeTitle,
        type: memberViewType,
    });
    return (_jsxs(FilterMemberElement, { "data-member": isMissing ? 'missing' : member, "data-size": size, children: [_jsxs(MemberLabelText, { "data-member": isMissing ? 'missing' : member, "data-size": size, children: [!hideIcon ? getTypeIcon(type) : null, _jsxs("span", { "data-element": "MemberPath", children: [!isCompact ? (_jsxs(_Fragment, { children: [_jsx("span", { "data-element": "CubeName", children: shownCubeName }), _jsx("span", { "data-element": "Divider", children: memberViewType === 'name' ? '.' : _jsx(_Fragment, { children: "\u00A0" }) })] })) : undefined, _jsx("span", { "data-element": "MemberName", children: shownMemberName })] })] }), onRemove ? (_jsx(Action, { preset: "t4", onPress: onRemove, children: _jsx(CloseIcon, {}) })) : null] }));
}
//# sourceMappingURL=FilterLabel.js.map