"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _icons = require("../../../../../core/assets/icons");
var _CategoryChip = _interopRequireDefault(require("../../../../components/CategoryChip/CategoryChip"));
var _enums = require("../../../../enums");
var _styles = require("./styles");
var _Typography = require("../../../../../core/components/Typography/Typography");
var _reactNativeSvg = require("react-native-svg");
var _hooks = require("../../../../hooks");
var _ExploreProvider = require("../../../../providers/ExploreProvider");
var _native = require("@react-navigation/native");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityCommunityCategoriesComponent = ({
  pageId = _enums.PageID.WildCardPage
}) => {
  const {
    categories,
    hasMoreCategories
  } = (0, _ExploreProvider.useExplore)();
  const componentId = _enums.ComponentID.explore_community_categories;
  const {
    isExcluded,
    accessibilityId,
    themeStyles
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const styles = (0, _styles.useStyles)(themeStyles);
  const navigation = (0, _native.useNavigation)();
  const onPressCategory = (0, _react.useCallback)(category => {
    navigation.navigate('CommunitiesByCategoryPage', {
      category
    });
  }, [navigation]);
  const onPressSeeMore = (0, _react.useCallback)(() => {
    navigation.navigate('AllCategoriesPage');
  }, [navigation]);
  if (isExcluded && categories.length === 0) return null;
  return /*#__PURE__*/React.createElement(_reactNative.FlatList, {
    testID: accessibilityId,
    data: categories,
    renderItem: ({
      item
    }) => /*#__PURE__*/React.createElement(_reactNative.Pressable, {
      onPress: () => onPressCategory(item)
    }, /*#__PURE__*/React.createElement(_CategoryChip.default, {
      category: item
    })),
    keyExtractor: item => item.categoryId,
    horizontal: true,
    showsHorizontalScrollIndicator: false,
    contentContainerStyle: styles.categoryChipsContentContainer,
    ListFooterComponent: hasMoreCategories ? /*#__PURE__*/React.createElement(_reactNative.Pressable, {
      onPress: onPressSeeMore
    }, /*#__PURE__*/React.createElement(_reactNative.View, {
      style: styles.seeMoreCategoryButton
    }, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
      style: styles.seeMoreCategoryText
    }, 'See more'), /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
      width: 20,
      height: 20,
      xml: (0, _icons.arrowRight)(),
      color: themeStyles.colors.base
    }))) : null
  });
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityCommunityCategoriesComponent);
//# sourceMappingURL=Categories.js.map