import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { StringTypeIcon, ToggleIcon, HashtagIcon, ClockIcon, Tooltip, } from '@finos/legend-art';
import { Enumeration, PrimitiveType, PrecisePrimitiveType, PRIMITIVE_TYPE, getMultiplicityDescription, } from '@finos/legend-graph';
import { getStandardPrimitiveTypeEquivalent } from '../../stores/QueryBuilderValueSpecificationHelper.js';
import { returnUndefOnError } from '@finos/legend-shared';
import { getColumnMultiplicity } from '../../stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorHelper.js';
export const renderPropertyTypeIcon = (type) => {
    if (type instanceof PrimitiveType || type instanceof PrecisePrimitiveType) {
        const typeName = getStandardPrimitiveTypeEquivalent(type) ?? type.path;
        if (typeName === PRIMITIVE_TYPE.STRING) {
            return _jsx(StringTypeIcon, { className: "query-builder-column-badge__icon" });
        }
        else if (typeName === PRIMITIVE_TYPE.BOOLEAN) {
            return _jsx(ToggleIcon, { className: "query-builder-column-badge__icon" });
        }
        else if (typeName === PRIMITIVE_TYPE.NUMBER ||
            typeName === PRIMITIVE_TYPE.INTEGER ||
            typeName === PRIMITIVE_TYPE.FLOAT ||
            typeName === PRIMITIVE_TYPE.DECIMAL) {
            return _jsx(HashtagIcon, { className: "query-builder-column-badge__icon" });
        }
        else if (typeName === PRIMITIVE_TYPE.DATE ||
            typeName === PRIMITIVE_TYPE.DATETIME ||
            typeName === PRIMITIVE_TYPE.STRICTDATE) {
            return _jsx(ClockIcon, { className: "query-builder-column-badge__icon" });
        }
    }
    else if (type instanceof Enumeration) {
        return _jsx("div", { className: "icon query-builder-column-badge__icon", children: "E" });
    }
    return null;
};
export const QueryBuilderColumnInfoTooltip = (props) => {
    const { columnState, placement, children } = props;
    const type = columnState.getColumnType();
    const multiplicity = returnUndefOnError(() => getColumnMultiplicity(columnState));
    return (_jsx(Tooltip, { arrow: true, ...(placement !== undefined ? { placement } : {}), classes: {
            tooltip: 'query-builder__tooltip',
            arrow: 'query-builder__tooltip__arrow',
            tooltipPlacementRight: 'query-builder__tooltip--right',
        }, slotProps: {
            transition: {
                // disable transition
                // NOTE: somehow, this is the only workaround we have, if for example
                // we set `appear = true`, the tooltip will jump out of position
                timeout: 0,
            },
        }, title: _jsxs("div", { className: "query-builder__tooltip__content", children: [_jsxs("div", { className: "query-builder__tooltip__item", children: [_jsx("div", { className: "query-builder__tooltip__item__label", children: "Name" }), _jsx("div", { className: "query-builder__tooltip__item__value", children: columnState.columnName })] }), _jsxs("div", { className: "query-builder__tooltip__item", children: [_jsx("div", { className: "query-builder__tooltip__item__label", children: "Type" }), _jsx("div", { className: "query-builder__tooltip__item__value", children: type?.path })] }), multiplicity && (_jsxs("div", { className: "query-builder__tooltip__item", children: [_jsx("div", { className: "query-builder__tooltip__item__label", children: "Multiplicity" }), _jsx("div", { className: "query-builder__tooltip__item__value", children: getMultiplicityDescription(multiplicity) })] }))] }), children: children }));
};
//# sourceMappingURL=QueryBuilderTDSComponentHelper.js.map