"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _enums = require("../../../../enums");
var _styles = require("./styles");
var _hooks = require("../../../../hooks");
var _TrendingCommunityTitle = _interopRequireDefault(require("./TrendingCommunityTitle/TrendingCommunityTitle"));
var _CommunityRowItem = _interopRequireDefault(require("../../../../components/CommunityRowItem/CommunityRowItem"));
var _ExploreProvider = require("../../../../providers/ExploreProvider");
var _native = require("@react-navigation/native");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityTrendingCommunitiesCommunity = ({
  pageId = _enums.PageID.WildCardPage
}) => {
  const componentId = _enums.ComponentID.trending_communities;
  const {
    isExcluded,
    accessibilityId
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const {
    trendingCommunities
  } = (0, _ExploreProvider.useExplore)();
  const styles = (0, _styles.useStyles)();
  const navigation = (0, _native.useNavigation)();
  const onPressCommunity = (0, _react.useCallback)(({
    communityId
  }) => {
    navigation.navigate('CommunityProfilePage', {
      communityId
    });
  }, [navigation]);
  if (isExcluded || (trendingCommunities === null || trendingCommunities === void 0 ? void 0 : trendingCommunities.length) === 0) return null;
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    testID: accessibilityId
  }, /*#__PURE__*/React.createElement(_TrendingCommunityTitle.default, {
    pageId: pageId
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, trendingCommunities === null || trendingCommunities === void 0 ? void 0 : trendingCommunities.map((community, index) => {
    return /*#__PURE__*/React.createElement(_reactNative.Pressable, {
      key: community.communityId,
      onPress: () => onPressCommunity({
        communityId: community.communityId
      })
    }, /*#__PURE__*/React.createElement(_CommunityRowItem.default, {
      pageId: pageId,
      community: community,
      label: `0${index + 1}`,
      componentId: componentId
    }));
  })));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityTrendingCommunitiesCommunity);
//# sourceMappingURL=TrendingCommunities.js.map