import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "loading", "running"];
import { IconTimerMediumOutline } from '@teamleader/ui-icons';
import cx from 'classnames';
import React, { forwardRef } from 'react';
import Box from '../box';
import Icon from '../icon';
import LoadingSpinner from '../loadingSpinner';
import { Monospaced, UITextBody } from '../typography';
import theme from './theme.css';
var Timer = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var _cx;

  var children = _ref.children,
      className = _ref.className,
      _ref$loading = _ref.loading,
      loading = _ref$loading === void 0 ? false : _ref$loading,
      _ref$running = _ref.running,
      running = _ref$running === void 0 ? false : _ref$running,
      others = _objectWithoutProperties(_ref, _excluded);

  var classNames = cx(theme['timer'], (_cx = {}, _defineProperty(_cx, theme['is-loading'], loading), _defineProperty(_cx, theme['is-running'], running), _cx), className);
  return /*#__PURE__*/React.createElement(Box, _extends({}, others, {
    borderRadius: "rounded",
    className: classNames,
    "data-teamleader-ui": "timer",
    element: "button",
    alignItems: "center",
    display: "flex",
    ref: ref,
    paddingHorizontal: 2
  }), /*#__PURE__*/React.createElement(Icon, {
    color: running ? 'violet' : 'teal',
    tint: "darkest"
  }, /*#__PURE__*/React.createElement(IconTimerMediumOutline, null)), loading ? /*#__PURE__*/React.createElement(Box, {
    flex: 1,
    display: "flex",
    justifyContent: "center"
  }, /*#__PURE__*/React.createElement(LoadingSpinner, {
    color: running ? 'violet' : 'neutral',
    size: "small"
  })) : /*#__PURE__*/React.createElement(UITextBody, {
    element: Monospaced,
    marginLeft: 2,
    color: running ? 'violet' : 'teal'
  }, children));
});
Timer.displayName = 'Timer';
export default Timer;