content: import _extends from 'babel-runtime/helpers/extends';
  import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
  import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  import _createClass from 'babel-runtime/helpers/createClass';
  import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  import _inherits from 'babel-runtime/helpers/inherits';
  /* eslint react/prop-types: 0 */
  import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  import enhancer from './enhancer';
  import { propTypes, defaultProps } from './types';
  
  var Circle = function (_Component) {
    _inherits(Circle, _Component);
  
    function Circle() {
      _classCallCheck(this, Circle);
  
      return _possibleConstructorReturn(this, (Circle.__proto__ || Object.getPrototypeOf(Circle)).apply(this, arguments));
    }
  
    _createClass(Circle, [{
      key: 'getPathStyles',
      value: function getPathStyles() {
        var _props = this.props,
            percent = _props.percent,
            strokeWidth = _props.strokeWidth,
            _props$gapDegree = _props.gapDegree,
            gapDegree = _props$gapDegree === undefined ? 0 : _props$gapDegree,
            gapPosition = _props.gapPosition;
  
        var radius = 50 - strokeWidth / 2;
        var beginPositionX = 0;
        var beginPositionY = -radius;
        var endPositionX = 0;
        var endPositionY = -2 * radius;
        switch (gapPosition) {
          case 'left':
            beginPositionX = -radius;
            beginPositionY = 0;
            endPositionX = 2 * radius;
            endPositionY = 0;
            break;
          case 'right':
            beginPositionX = radius;
            beginPositionY = 0;
            endPositionX = -2 * radius;
            endPositionY = 0;
            break;
          case 'bottom':
            beginPositionY = radius;
            endPositionY = 2 * radius;
            break;
          default:
        }
        var pathString = 'M 50,50 m ' + beginPositionX + ',' + beginPositionY + '\n     a ' + radius + ',' + radius + ' 0 1 1 ' + endPositionX + ',' + -endPositionY + '\n     a ' + radius + ',' + radius + ' 0 1 1 ' + -endPositionX + ',' + endPositionY;
        var len = Math.PI * 2 * radius;
        var trailPathStyle = {
          strokeDasharray: len - gapDegree + 'px ' + len + 'px',
          strokeDashoffset: '-' + gapDegree / 2 + 'px',
          transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
        };
        var strokePathStyle = {
          strokeDasharray: percent / 100 * (len - gapDegree) + 'px ' + len + 'px',
          strokeDashoffset: '-' + gapDegree / 2 + 'px',
          transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s'
        };
        return { pathString: pathString, trailPathStyle: trailPathStyle, strokePathStyle: strokePathStyle };
      }
    }, {
      key: 'render',
      value: function render() {
        var _this2 = this;
  
        var _props2 = this.props,
            prefixCls = _props2.prefixCls,
            strokeWidth = _props2.strokeWidth,
            trailWidth = _props2.trailWidth,
            strokeColor = _props2.strokeColor,
            trailColor = _props2.trailColor,
            strokeLinecap = _props2.strokeLinecap,
            style = _props2.style,
            className = _props2.className,
            restProps = _objectWithoutProperties(_props2, ['prefixCls', 'strokeWidth', 'trailWidth', 'strokeColor', 'trailColor', 'strokeLinecap', 'style', 'className']);
  
        var _getPathStyles = this.getPathStyles(),
            pathString = _getPathStyles.pathString,
            trailPathStyle = _getPathStyles.trailPathStyle,
            strokePathStyle = _getPathStyles.strokePathStyle;
  
        var showCirclePath = restProps.percent > 0;
        delete restProps.percent;
        delete restProps.gapDegree;
        delete restProps.gapPosition;
        return React.createElement(
          'svg',
          _extends({
            className: prefixCls + '-circle ' + className,
            viewBox: '0 0 100 100',
            style: style
          }, restProps),
          React.createElement('path', {
            className: prefixCls + '-circle-trail',
            d: pathString,
            stroke: trailColor,
            strokeWidth: trailWidth || strokeWidth,
            fillOpacity: '0',
            style: trailPathStyle
          }),
          showCirclePath && React.createElement('path', {
            className: prefixCls + '-circle-path',
            d: pathString,
            strokeLinecap: strokeLinecap,
            stroke: strokeColor,
            strokeWidth: strokeWidth,
            fillOpacity: '0',
            ref: function ref(path) {
              _this2.path = path;
            },
            style: strokePathStyle
          })
        );
      }
    }]);
  
    return Circle;
  }(Component);
  
  Circle.propTypes = _extends({}, propTypes, {
    gapPosition: PropTypes.oneOf(['top', 'bottom', 'left', 'right'])
  });
  
  Circle.defaultProps = _extends({}, defaultProps, {
    gapPosition: 'top'
  });
  
  export default enhancer(Circle);