text: 'use strict';
  
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  
  var React = _interopDefault(require('react'));
  
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation. All rights reserved.
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of the
  License at http://www.apache.org/licenses/LICENSE-2.0
  
  THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  MERCHANTABLITY OR NON-INFRINGEMENT.
  
  See the Apache Version 2.0 License for specific language governing permissions
  and limitations under the License.
  ***************************************************************************** */
  /* global Reflect, Promise */
  
  var extendStatics = function(d, b) {
      extendStatics = Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
      return extendStatics(d, b);
  };
  
  function __extends(d, b) {
      extendStatics(d, b);
      function __() { this.constructor = d; }
      d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  }
  
  var VIEWBOX_WIDTH = 100;
  var VIEWBOX_HEIGHT = 100;
  var VIEWBOX_HEIGHT_HALF = 50;
  var VIEWBOX_CENTER_X = 50;
  var VIEWBOX_CENTER_Y = 50;
  
  var MIN_PERCENTAGE = 0;
  var MAX_PERCENTAGE = 100;
  function Path(_a) {
      var className = _a.className, counterClockwise = _a.counterClockwise, pathRadius = _a.pathRadius, percentage = _a.percentage, strokeWidth = _a.strokeWidth, style = _a.style;
      return (React.createElement("path", { className: className, style: Object.assign({}, style, getDashStyle({ pathRadius: pathRadius, percentage: percentage, counterClockwise: counterClockwise })), d: getPathDescription({
              pathRadius: pathRadius,
              counterClockwise: counterClockwise,
          }), strokeWidth: strokeWidth, fillOpacity: 0 }));
  }
  function getPathDescription(_a) {
      var pathRadius = _a.pathRadius, counterClockwise = _a.counterClockwise;
      var radius = pathRadius;
      var rotation = counterClockwise ? 1 : 0;
      return "\n      M " + VIEWBOX_CENTER_X + "," + VIEWBOX_CENTER_Y + "\n      m 0,-" + radius + "\n      a " + radius + "," + radius + " " + rotation + " 1 1 0," + 2 * radius + "\n      a " + radius + "," + radius + " " + rotation + " 1 1 0,-" + 2 * radius + "\n    ";
  }
  function getDashStyle(_a) {
      var pathRadius = _a.pathRadius, percentage = _a.percentage, counterClockwise = _a.counterClockwise;
      var diameter = Math.PI * 2 * pathRadius;
      var truncatedPercentage = Math.min(Math.max(percentage, MIN_PERCENTAGE), MAX_PERCENTAGE);
      var gapLength = (1 - truncatedPercentage / 100) * diameter;
      return {
          strokeDasharray: diameter + "px " + diameter + "px",
          strokeDashoffset: (counterClockwise ? -gapLength : gapLength) + "px",
      };
  }
  
  var CircularProgressbar = (function (_super) {
      __extends(CircularProgressbar, _super);
      function CircularProgressbar(props) {
          var _this = _super.call(this, props) || this;
          _this.initialTimeout = undefined;
          _this.requestAnimationFrame = undefined;
          _this.state = {
              percentage: props.initialAnimation ? 0 : props.percentage,
          };
          return _this;
      }
      CircularProgressbar.prototype.componentDidMount = function () {
          var _this = this;
          if (this.props.initialAnimation) {
              this.initialTimeout = window.setTimeout(function () {
                  _this.requestAnimationFrame = window.requestAnimationFrame(function () {
                      _this.setState({
                          percentage: _this.props.percentage,
                      });
                  });
              }, 0);
          }
      };
      CircularProgressbar.prototype.componentWillReceiveProps = function (nextProps) {
          this.setState({
              percentage: nextProps.percentage,
          });
      };
      CircularProgressbar.prototype.componentWillUnmount = function () {
          clearTimeout(this.initialTimeout);
          if (this.requestAnimationFrame) {
              window.cancelAnimationFrame(this.requestAnimationFrame);
          }
      };
      CircularProgressbar.prototype.getBackgroundPadding = function () {
          if (this.props.background) {
              if (this.props.backgroundPadding == null) {
                  return this.props.strokeWidth;
              }
              return this.props.backgroundPadding;
          }
          return 0;
      };
      CircularProgressbar.prototype.getPathRadius = function () {
          return VIEWBOX_HEIGHT_HALF - this.props.strokeWidth / 2 - this.getBackgroundPadding();
      };
      CircularProgressbar.prototype.render = function () {
          var _a = this.props, className = _a.className, classes = _a.classes, counterClockwise = _a.counterClockwise, percentage = _a.percentage, styles = _a.styles, strokeWidth = _a.strokeWidth, text = _a.text, circleRatio = _a.circleRatio;
          var pathRadius = this.getPathRadius();
          return (React.createElement("svg", { className: classes.root + " " + className, style: styles.root, viewBox: "0 0 " + VIEWBOX_WIDTH + " " + VIEWBOX_HEIGHT },
              this.props.background ? (React.createElement("circle", { className: classes.background, style: styles.background, cx: VIEWBOX_CENTER_X, cy: VIEWBOX_CENTER_Y, r: VIEWBOX_HEIGHT_HALF })) : null,
              React.createElement(Path, { className: classes.trail, counterClockwise: counterClockwise, pathRadius: pathRadius, percentage: 100 * circleRatio, strokeWidth: strokeWidth, style: styles.trail }),
              React.createElement(Path, { className: classes.path, counterClockwise: counterClockwise, pathRadius: pathRadius, percentage: percentage * circleRatio, strokeWidth: strokeWidth, style: styles.path }),
              text ? (React.createElement("text", { className: classes.text, style: styles.text, x: VIEWBOX_CENTER_X, y: VIEWBOX_CENTER_Y }, text)) : null));
      };
      CircularProgressbar.defaultProps = {
          strokeWidth: 8,
          className: '',
          text: '',
          background: false,
          backgroundPadding: 0,
          initialAnimation: false,
          counterClockwise: false,
          circleRatio: 1,
          classes: {
              root: 'CircularProgressbar',
              trail: 'CircularProgressbar-trail',
              path: 'CircularProgressbar-path',
              text: 'CircularProgressbar-text',
              background: 'CircularProgressbar-background',
          },
          styles: {
              root: {},
              trail: {},
              path: {},
              text: {},
              background: {},
          },
      };
      return CircularProgressbar;
  }(React.Component));
  
  module.exports = CircularProgressbar;
  //# sourceMappingURL=index.js.map
  