import ArrowCollapseVerticalIcon from 'mdi-react/ArrowCollapseVerticalIcon';
import ArrowExpandVerticalIcon from 'mdi-react/ArrowExpandVerticalIcon';
import CalculatorIcon from 'mdi-react/CalculatorIcon';
import CheckIcon from 'mdi-react/CheckIcon';
import CloudDownloadIcon from 'mdi-react/CloudDownloadIcon';
import DownloadIcon from 'mdi-react/DownloadIcon';
import MapSearchIcon from 'mdi-react/MapSearchIcon';
import TimerSandIcon from 'mdi-react/TimerSandIcon';
import * as React from 'react';
import { ServerBanner } from '../../marketing/ServerBanner';
import { showDotComMarketing } from '../../util/features';
import { pluralize } from '../../util/strings';
/**
 * The info bar shown over the search results list that displays metadata
 * and a few actions like expand all and save query
 */
export const SearchResultsInfoBar = props => (React.createElement("div", { className: "search-results-info-bar" },
    (props.results.timedout.length > 0 ||
        props.results.cloning.length > 0 ||
        props.results.results.length > 0 ||
        props.results.missing.length > 0) && (React.createElement("small", { className: "search-results-info-bar__row" },
        React.createElement("div", { className: "search-results-info-bar__row-left" },
            React.createElement("div", { className: "search-results-info-bar__notice e2e-search-results-stats" },
                React.createElement("span", null,
                    React.createElement(CalculatorIcon, { className: "icon-inline" }),
                    " ",
                    props.results.approximateResultCount,
                    ' ',
                    pluralize('result', props.results.resultCount),
                    " in",
                    ' ',
                    (props.results.elapsedMilliseconds / 1000).toFixed(2),
                    " seconds",
                    props.results.indexUnavailable && ' (index unavailable)',
                    props.results.limitHit && String.fromCharCode(160)),
                props.results.limitHit && (React.createElement("button", { className: "btn btn-link btn-sm p-0", onClick: props.onShowMoreResultsClick }, "(show more)"))),
            props.results.missing.length > 0 && (React.createElement("div", { className: "search-results-info-bar__notice", "data-tooltip": props.results.missing.map(repo => repo.name).join('\n') },
                React.createElement("span", null,
                    React.createElement(MapSearchIcon, { className: "icon-inline" }),
                    " ",
                    props.results.missing.length,
                    ' ',
                    pluralize('repository', props.results.missing.length, 'repositories'),
                    " not found"))),
            props.results.timedout.length > 0 && (React.createElement("div", { className: "search-results-info-bar__notice", "data-tooltip": props.results.timedout.map(repo => repo.name).join('\n') },
                React.createElement("span", null,
                    React.createElement(TimerSandIcon, { className: "icon-inline" }),
                    " ",
                    props.results.timedout.length,
                    ' ',
                    pluralize('repository', props.results.timedout.length, 'repositories'),
                    " timed out (reload to try again, or specify a longer \"timeout:\" in your query)"))),
            props.results.cloning.length > 0 && (React.createElement("div", { className: "search-results-info-bar__notice", "data-tooltip": props.results.cloning.map(repo => repo.name).join('\n') },
                React.createElement("span", null,
                    React.createElement(CloudDownloadIcon, { className: "icon-inline" }),
                    " ",
                    props.results.cloning.length,
                    ' ',
                    pluralize('repository', props.results.cloning.length, 'repositories'),
                    " cloning (reload to try again)")))),
        React.createElement("div", { className: "search-results-info-bar__row-right" },
            props.results.results.length > 0 && (React.createElement("button", { onClick: props.onExpandAllResultsToggle, className: "btn btn-link" }, props.allExpanded ? (React.createElement(React.Fragment, null,
                React.createElement(ArrowCollapseVerticalIcon, { className: "icon-inline" }),
                " Collapse all")) : (React.createElement(React.Fragment, null,
                React.createElement(ArrowExpandVerticalIcon, { className: "icon-inline" }),
                " Expand all")))),
            props.user && (React.createElement("button", { onClick: props.onSaveQueryClick, className: "btn btn-link", disabled: props.didSave }, props.didSave ? (React.createElement(React.Fragment, null,
                React.createElement(CheckIcon, { className: "icon-inline" }),
                " Query saved")) : (React.createElement(React.Fragment, null,
                React.createElement(DownloadIcon, { className: "icon-inline" }),
                " Save this search query"))))))),
    !props.results.alert && showDotComMarketing && React.createElement(ServerBanner, null)));
//# sourceMappingURL=SearchResultsInfoBar.js.map