import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { tasty } from '@cube-dev/ui-kit';
const FilteredPartElement = tasty({
    styles: {
        display: 'inline',
        fill: '#purple.25',
    },
});
export function FilteredLabel({ text, filter }) {
    const lowerText = text.toLowerCase();
    filter = filter.toLowerCase();
    let index = lowerText.indexOf(filter);
    if (index === -1) {
        filter = filter.replace(/\s/g, '_');
        index = lowerText.indexOf(filter);
        if (index === -1) {
            filter = filter.replace(/_/g, ' ');
            index = lowerText.indexOf(filter);
            if (index === -1) {
                return _jsx(_Fragment, { children: text });
            }
        }
    }
    const startPart = text.slice(0, index);
    const filterPart = text.slice(index, index + filter.length);
    const endPart = text.slice(index + filter.length);
    return (_jsxs(_Fragment, { children: [startPart, _jsx(FilteredPartElement, { children: filterPart }), endPart] }));
}
//# sourceMappingURL=FilteredLabel.js.map