"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = TestSelect;
var _components = require("@storybook/components");
var _theming = require("@storybook/theming");
var _react = _interopRequireDefault(require("react"));
var _utils = require("../utils");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const LinkIconContainer = _theming.styled.span(_ref => {
  let {
    theme
  } = _ref;
  return {
    display: 'inline-block',
    width: '20px',
    color: theme.color.defaultText,
    textAlign: 'center'
  };
});
function TestSelect(props) {
  const testName = props.tests.find(x => x.id === props.selectedTestId)?.testName ?? '';
  return /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
    trigger: "click",
    placement: "bottom",
    closeOnClick: true,
    tooltip: _ref2 => {
      let {
        onHide
      } = _ref2;
      return /*#__PURE__*/_react.default.createElement(_components.TooltipLinkList, {
        links: props.tests.map(x => ({
          id: x.id,
          title: x.testName ?? '',
          active: props.selectedTestId === x.id,
          onClick: () => {
            props.onChangeTest(x.id);
            onHide();
          },
          left: /*#__PURE__*/_react.default.createElement(LinkIconContainer, null, (0, _utils.getEmojiByTestStatus)(x.status, x.skip))
        }))
      });
    }
  }, /*#__PURE__*/_react.default.createElement(_components.Button, {
    outline: true,
    small: true
  }, /*#__PURE__*/_react.default.createElement(_components.Icons, {
    icon: "menu"
  }), testName));
}