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); }
import React, { useCallback, useEffect, useRef } from "react";
import { Animated, Easing, Platform } from "react-native";
/** A component used to provide a visual cue that an action is either processing, awaiting a course of change or a result. */
const Indicator = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  animationEasing = Easing.linear,
  animationDuration = 1200,
  renderComponent = () => {
    return /*#__PURE__*/React.createElement(React.Fragment, null);
  },
  count = 1,
  ...rest
}, ref) => {
  const progress = useRef(new Animated.Value(0)).current;
  const startAnimation = useCallback(() => {
    let animation = Animated.timing(progress, {
      duration: animationDuration,
      easing: animationEasing,
      useNativeDriver: Platform.OS !== "web",
      // Web doesn't support loops if using Native Driver,
      isInteraction: true,
      toValue: 1
    });
    Animated.loop(animation).start();
  }, [animationDuration, animationEasing, progress]);
  const _renderComponent = useCallback((item, index) => {
    if ("function" === typeof renderComponent) {
      return renderComponent({
        index,
        count,
        progress
      });
    }
    return null;
  }, [renderComponent, count, progress]);
  useEffect(() => {
    startAnimation();
  }, []);
  return /*#__PURE__*/React.createElement(Animated.View, _extends({}, rest, {
    ref: ref
  }), /*#__PURE__*/React.createElement(React.Fragment, null, Array.from(new Array(count), _renderComponent, this)));
}));
export default Indicator;
//# sourceMappingURL=indicator.js.map