"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireWildcard(require("react"));

var _enhancer = _interopRequireDefault(require("./enhancer"));

var _types = require("./types");

var _excluded = ["className", "percent", "prefixCls", "strokeColor", "strokeLinecap", "strokeWidth", "style", "trailColor", "trailWidth"];

var Line = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(Line, _Component);

  var _super = (0, _createSuper2["default"])(Line);

  function Line() {
    (0, _classCallCheck2["default"])(this, Line);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(Line, [{
    key: "render",
    value: function render() {
      var _this = this;

      var _this$props = this.props,
          className = _this$props.className,
          percent = _this$props.percent,
          prefixCls = _this$props.prefixCls,
          strokeColor = _this$props.strokeColor,
          strokeLinecap = _this$props.strokeLinecap,
          strokeWidth = _this$props.strokeWidth,
          style = _this$props.style,
          trailColor = _this$props.trailColor,
          trailWidth = _this$props.trailWidth,
          restProps = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
      delete restProps.gapPosition;
      var pathStyle = {
        strokeDasharray: '100px, 100px',
        strokeDashoffset: "".concat(100 - percent, "px"),
        transition: 'stroke-dashoffset 0.3s ease 0s, stroke 0.3s linear'
      };
      var center = strokeWidth / 2;
      var right = 100 - strokeWidth / 2;
      var pathString = "M ".concat(strokeLinecap === 'round' ? center : 0, ",").concat(center, "\n           L ").concat(strokeLinecap === 'round' ? right : 100, ",").concat(center);
      var viewBoxString = "0 0 100 ".concat(strokeWidth);
      return /*#__PURE__*/_react["default"].createElement("svg", (0, _extends2["default"])({
        className: "".concat(prefixCls, "-line ").concat(className),
        viewBox: viewBoxString,
        preserveAspectRatio: "none",
        style: style
      }, restProps), /*#__PURE__*/_react["default"].createElement("path", {
        className: "".concat(prefixCls, "-line-trail"),
        d: pathString,
        strokeLinecap: strokeLinecap,
        stroke: trailColor,
        strokeWidth: trailWidth || strokeWidth,
        fillOpacity: "0"
      }), /*#__PURE__*/_react["default"].createElement("path", {
        className: "".concat(prefixCls, "-line-path"),
        d: pathString,
        strokeLinecap: strokeLinecap,
        stroke: strokeColor,
        strokeWidth: strokeWidth,
        fillOpacity: "0",
        ref: function ref(path) {
          _this.path = path;
        },
        style: pathStyle
      }));
    }
  }]);
  return Line;
}(_react.Component);

(0, _defineProperty2["default"])(Line, "defaultProps", _types.defaultProps);

var _default = (0, _enhancer["default"])(Line);

exports["default"] = _default;
//# sourceMappingURL=Line.js.map
