"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _react = _interopRequireWildcard(require("react"));
var _ChatStore = _interopRequireDefault(require("../../screens/chat/ChatStore"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const AnimatedSoundBars = _ref => {
  var _chatStore$soundBarsR;
  let {
    barColor = 'gray',
    isPlay,
    id
  } = _ref;
  const loopAnimation = node => {
    const keyframes = [1.2, 0.7, 1];
    const loop = _reactNative.Animated.sequence(keyframes.map(toValue => _reactNative.Animated.timing(node, {
      toValue,
      easing: _reactNative.Easing.ease,
      useNativeDriver: true
    })));
    return loop;
  };
  const loadAnimation = nodes => {
    if (isPlay) {
      _reactNative.Animated.loop(_reactNative.Animated.stagger(100, nodes.map(loopAnimation))).start();
    }
  };
  _react.default.useEffect(() => {
    _ChatStore.default.soundBarsRefs[id] = Array.from({
      length: 16
    }).map(() => new _reactNative.Animated.Value(1));
    loadAnimation(_ChatStore.default.soundBarsRefs[id]);
  }, [isPlay]);
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.row
  }, (_chatStore$soundBarsR = _ChatStore.default.soundBarsRefs[id]) === null || _chatStore$soundBarsR === void 0 ? void 0 : _chatStore$soundBarsR.map((animation, index) => {
    return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
      key: `${index}`,
      style: [styles.bar, {
        backgroundColor: barColor
      }, {
        transform: [{
          scale: animation
        }]
      }]
    });
  }));
};
var _default = AnimatedSoundBars;
exports.default = _default;
const styles = _reactNative.StyleSheet.create({
  row: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'center'
  },
  bar: {
    height: 20,
    width: 4,
    borderRadius: 2,
    marginHorizontal: 2
  }
});
//# sourceMappingURL=index.js.map