"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// Define props

// Composing component
const Composing = ({
  usersTyping = ['User'],
  style
}) => {
  const fadeAnim1 = (0, _react.useRef)(new _reactNative.Animated.Value(0.2)).current;
  const fadeAnim2 = (0, _react.useRef)(new _reactNative.Animated.Value(0.2)).current;
  const fadeAnim3 = (0, _react.useRef)(new _reactNative.Animated.Value(0.2)).current;
  const animateDot = (animatedValue, delay) => {
    _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(animatedValue, {
      toValue: 1,
      duration: 300,
      useNativeDriver: true,
      delay
    }), _reactNative.Animated.timing(animatedValue, {
      toValue: 0.2,
      duration: 300,
      useNativeDriver: true
    })])).start();
  };
  (0, _react.useEffect)(() => {
    animateDot(fadeAnim1, 0);
    animateDot(fadeAnim2, 200);
    animateDot(fadeAnim3, 400);
  }, []);
  let typingText;
  if (usersTyping.length === 1) {
    typingText = `${usersTyping[0]} is typing`;
  } else if (usersTyping.length === 2) {
    typingText = `${usersTyping[0]} and ${usersTyping[1]} are typing`;
  } else if (usersTyping.length > 2) {
    typingText = `${usersTyping.length} people are typing`;
  } else {
    typingText = '';
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: [styles.wrapper, style],
    children: [typingText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
      style: styles.typingText,
      children: typingText
    }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: styles.dotsContainer,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.Text, {
        style: [styles.dot, {
          opacity: fadeAnim1
        }],
        children: "."
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.Text, {
        style: [styles.dot, {
          opacity: fadeAnim2
        }],
        children: "."
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.Text, {
        style: [styles.dot, {
          opacity: fadeAnim3
        }],
        children: "."
      })]
    })]
  });
};
const styles = _reactNative.StyleSheet.create({
  wrapper: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingHorizontal: 4
  },
  typingText: {
    marginRight: 4,
    fontSize: 12,
    color: '#71717A',
    fontStyle: 'italic'
  },
  dotsContainer: {
    flexDirection: 'row',
    alignItems: 'center'
  },
  dot: {
    fontSize: 18,
    lineHeight: 18,
    marginHorizontal: 1,
    color: '#71717A'
  }
});
var _default = exports.default = Composing;
//# sourceMappingURL=Composing.js.map