import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { getTypeIcon } from '../utils';
import { useShownMemberName } from '../hooks';
import { MemberLabelText } from './MemberLabelText';
import { MemberBadge } from './Badge';
function StyledTypeIcon(props) {
    const { type, memberType, isMissing } = props;
    const memberColorName = isMissing ? 'danger' : memberType;
    return (_jsx("span", { style: {
            display: 'grid',
            color: `var(--${memberColorName}-text-color)`,
            placeSelf: 'center',
        }, children: getTypeIcon(type) }));
}
export function MemberLabel(props) {
    const { name, cubeName = props.name.split('.')[0], cubeTitle, memberName = props.name.split('.')[1], memberTitle, isCompact, memberType, type, memberViewType, isMissing, children, } = props;
    const arr = name.split('.');
    const { shownMemberName, shownCubeName } = useShownMemberName({
        cubeName,
        cubeTitle,
        memberName,
        memberTitle,
        type: memberViewType,
    });
    return (_jsxs(MemberLabelText, { "data-member": memberType, mods: { missing: isMissing }, children: [memberType ? (_jsx(StyledTypeIcon, { isMissing: isMissing, type: type, memberType: memberType })) : null, !isCompact || !cubeName ? (_jsxs(_Fragment, { children: [_jsxs("span", { "data-element": "Name", children: [_jsx("span", { "data-element": "CubeName", children: shownCubeName }), _jsx("span", { "data-element": "Divider", children: memberViewType === 'name' ? '.' : _jsx(_Fragment, { children: "\u00A0" }) }), _jsx("span", { "data-element": "MemberName", children: shownMemberName })] }), arr[2] ? (_jsx("span", { "data-element": "Grouping", children: _jsx(MemberBadge, { isSpecial: true, type: memberType, children: arr[2] }) })) : null] })) : (_jsx("span", { "data-element": "MemberName", children: shownMemberName })), children] }));
}
//# sourceMappingURL=MemberLabel.js.map