"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StyledSpinner = void 0;

var _styles = require("../styles");

var _constants = require("./constants");

/*
Copyright (c) Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
var spin = {
  from: {
    transform: 'rotate(0deg)'
  },
  to: {
    transform: 'rotate(360deg)'
  }
};
var StyledSpinner = (0, _styles.styled)('i', function (_ref) {
  var $theme = _ref.$theme,
      _ref$$color = _ref.$color,
      $color = _ref$$color === void 0 ? $theme.colors.contentAccent : _ref$$color,
      $borderWidth = _ref.$borderWidth,
      _ref$$size = _ref.$size,
      $size = _ref$$size === void 0 ? _constants.SIZE.medium : _ref$$size;
  var borderSize = {
    large: $theme.sizing.scale300,
    medium: $theme.sizing.scale100,
    small: $theme.sizing.scale0
  }[$borderWidth || $size];
  var boxSize = {
    large: $theme.sizing.scale1000,
    medium: $theme.sizing.scale900,
    small: $theme.sizing.scale800
  }[$size];

  if (!borderSize) {
    borderSize = $theme.sizing[$borderWidth];

    if (!borderSize) {
      // @ts-expect-error todo(flow->ts) avoid mixing string with number
      borderSize = "".concat(parseInt($borderWidth), "px");
    }
  }

  if (!boxSize) {
    boxSize = $theme.sizing[$size];

    if (!boxSize) {
      // @ts-expect-error todo(flow->ts) avoid mixing string with number
      boxSize = "".concat(parseInt($size), "px");
    }
  }

  return {
    display: 'block',
    animationName: spin,
    animationDuration: $theme.animation.timing1000,
    animationIterationCount: 'infinite',
    animationTimingFunction: 'linear',
    borderLeftStyle: 'solid',
    borderRightStyle: 'solid',
    borderTopStyle: 'solid',
    borderBottomStyle: 'solid',
    borderRadius: '50%',
    borderTopColor: $color,
    borderRightColor: $theme.colors.backgroundTertiary,
    borderBottomColor: $theme.colors.backgroundTertiary,
    borderLeftColor: $theme.colors.backgroundTertiary,
    borderLeftWidth: borderSize,
    borderRightWidth: borderSize,
    borderTopWidth: borderSize,
    borderBottomWidth: borderSize,
    width: boxSize,
    height: boxSize,
    cursor: 'wait'
  };
});
exports.StyledSpinner = StyledSpinner;
StyledSpinner.displayName = "StyledSpinner";