"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _PulseAnimationSt = require("./PulseAnimation.st.css.js");
var _Animate = _interopRequireDefault(require("../Animate"));
var _constants = require("./constants");
var _utils = require("../Animate/utils");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/PulseAnimation/PulseAnimation.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/** PulseAnimation*/
var PulseAnimation = /*#__PURE__*/function (_React$PureComponent) {
  function PulseAnimation(props) {
    var _this;
    (0, _classCallCheck2["default"])(this, PulseAnimation);
    _this = _callSuper(this, PulseAnimation, [props]);
    _this._getAnimationSize = function () {
      var childWidth = _this.rootRef.current.offsetWidth;
      var _childWidthRange$medi = _constants.childWidthRange.medium,
        from = _childWidthRange$medi.from,
        to = _childWidthRange$medi.to;
      return (0, _utils.isValueInRange)(childWidth, from, to) ? _constants.childSize.medium : _constants.childSize.small;
    };
    _this.state = {
      animationSize: undefined
    };
    _this.rootRef = /*#__PURE__*/_react["default"].createRef();
    return _this;
  }
  (0, _inherits2["default"])(PulseAnimation, _React$PureComponent);
  return (0, _createClass2["default"])(PulseAnimation, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var animationSize = this._getAnimationSize();
      this.setState({
        animationSize: animationSize
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
        dataHook = _this$props.dataHook,
        active = _this$props.active,
        onEnd = _this$props.onEnd,
        onStart = _this$props.onStart,
        loop = _this$props.loop,
        children = _this$props.children,
        delay = _this$props.delay,
        color = _this$props.color,
        borderRadius = _this$props.borderRadius,
        fluid = _this$props.fluid;
      var animationSize = this.state.animationSize;
      return /*#__PURE__*/_react["default"].createElement(_Animate["default"], {
        dataHook: dataHook,
        animateClasses: (0, _PulseAnimationSt.st)(_PulseAnimationSt.classes.root, {
          active: active,
          loop: loop,
          size: animationSize,
          fluid: fluid,
          color: color
        }),
        animateInlineStyle: {
          borderRadius: borderRadius
        },
        onEnd: onEnd,
        onStart: onStart,
        delay: delay,
        ref: this.rootRef,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 48,
          columnNumber: 7
        }
      }, children);
    }
  }]);
}(_react["default"].PureComponent);
PulseAnimation.displayName = 'PulseAnimation';
PulseAnimation.defaultProps = {
  loop: true,
  fluid: false
};
var _default = exports["default"] = PulseAnimation;