"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _styles = require("./styles");
var _enums = require("../../../../../enums");
var _FormLabel = _interopRequireDefault(require("../../../../../elements/FormLabel"));
var _native = require("@react-navigation/native");
var _BehaviourProvider = require("../../../../../providers/BehaviourProvider");
var _MemberChip = require("../../../../../components/MemberChip/MemberChip");
var _CommunityAddMemberButton = _interopRequireDefault(require("../../../../../elements/CommunityAddMemberButton"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function Members({
  value,
  goBack,
  onChange
}) {
  const {
    styles
  } = (0, _styles.useStyles)();
  const {
    AmityCommunitySetupPageBehavior
  } = (0, _BehaviourProvider.useBehaviour)();
  const navigation = (0, _native.useNavigation)();
  const onAddedAction = users => {
    goBack();
    onChange(users);
  };
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_FormLabel.default, {
    pageId: _enums.PageID.community_setup_page,
    elementId: _enums.ElementID.community_add_member_title
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.memberContainer
  }, /*#__PURE__*/React.createElement(_CommunityAddMemberButton.default, {
    pageId: _enums.PageID.community_setup_page,
    onPress: () => {
      if (AmityCommunitySetupPageBehavior.goToAddMemberPage) {
        return AmityCommunitySetupPageBehavior.goToAddMemberPage({
          users: value,
          onAddedAction
        });
      }
      navigation.navigate('CommunityAddMember', {
        users: value,
        onAddedAction
      });
    }
  }), value.length > 0 && value.map(member => /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.selectedMemberContainer,
    key: member.userId
  }, /*#__PURE__*/React.createElement(_MemberChip.MemberChip, {
    member: member,
    onPress: deletedMember => {
      onChange(value.filter(m => m.userId !== deletedMember.userId));
    }
  })))));
}
var _default = exports.default = Members;
//# sourceMappingURL=index.js.map