"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _indicator = _interopRequireDefault(require("./indicator"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const floatEpsilon = Math.pow(2, -23);
const WaveIndicator = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  size = 30,
  count = 4,
  color = "rgb(0, 0, 0)",
  animationDuration = 1600,
  animationEasing = _reactNative.Easing.out(_reactNative.Easing.ease),
  waveFactor = 0.54,
  waveMode = "fill",
  ...rest
}, ref) => {
  const _renderComponent = _react.default.useCallback(({
    index,
    count,
    progress
  }) => {
    let fill = waveMode === "fill";
    let factor = Math.max(1 - Math.pow(waveFactor, index), floatEpsilon);
    let waveStyle = {
      height: size,
      width: size,
      borderRadius: size / 2,
      borderWidth: fill ? 0 : Math.floor(size / 20),
      [fill ? "backgroundColor" : "borderColor"]: color,
      transform: [{
        scale: progress.interpolate({
          inputRange: [factor, 1],
          outputRange: [0, 1],
          extrapolate: "clamp"
        })
      }],
      opacity: progress.interpolate({
        inputRange: [0, factor, 1],
        outputRange: [0, 1, 0]
      })
    };
    return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
      style: {
        ..._reactNative.StyleSheet.absoluteFillObject,
        justifyContent: "center",
        alignItems: "center"
      },
      key: index
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
      style: waveStyle
    }));
  }, [waveMode, waveFactor, size, color]);
  const {
    style,
    ...props
  } = rest;
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [{
      flex: 1,
      justifyContent: "center",
      alignItems: "center"
    }, style]
  }, /*#__PURE__*/_react.default.createElement(_indicator.default, _extends({}, props, {
    ref: ref,
    style: {
      width: size,
      height: size
    },
    renderComponent: _renderComponent,
    animationDuration: animationDuration,
    animationEasing: animationEasing,
    count: count
  })));
}));
var _default = exports.default = WaveIndicator;
//# sourceMappingURL=wave.js.map