"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _enumUIKitID = require("../../../../enums/enumUIKitID");
var _GlobalFeed = _interopRequireDefault(require("../GlobalFeed/GlobalFeed"));
var _styles = require("./styles");
var _hooks = require("../../../../hooks");
var _useCustomRankingGlobalFeed = require("../../../../hooks/useCustomRankingGlobalFeed");
var _NewsFeedLoadingComponent = _interopRequireDefault(require("../../../../components/NewsFeedLoadingComponent/NewsFeedLoadingComponent"));
var _ = require("../../../..");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityNewsFeedComponent = ({
  pageId = _enumUIKitID.PageID.WildCardPage,
  onPressExploreCommunity
}) => {
  const styles = (0, _styles.useStyles)();
  const componentId = _enumUIKitID.ComponentID.newsfeed_component;
  const {
    accessibilityId,
    isExcluded
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const {
    itemWithAds,
    refresh,
    globalFeedPosts,
    loading,
    onNextPage
  } = (0, _useCustomRankingGlobalFeed.useCustomRankingGlobalFeed)();
  if (isExcluded) return null;
  if (loading && !(globalFeedPosts !== null && globalFeedPosts !== void 0 && globalFeedPosts.length) || !itemWithAds && globalFeedPosts !== null && globalFeedPosts !== void 0 && globalFeedPosts.length) return /*#__PURE__*/React.createElement(_NewsFeedLoadingComponent.default, null);
  if (!loading && !(globalFeedPosts !== null && globalFeedPosts !== void 0 && globalFeedPosts.length)) return /*#__PURE__*/React.createElement(_.AmityEmptyNewsFeedComponent, {
    pageId: pageId,
    onPressExploreCommunity: onPressExploreCommunity
  });
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container,
    testID: accessibilityId,
    accessibilityLabel: accessibilityId
  }, /*#__PURE__*/React.createElement(_GlobalFeed.default, {
    pageId: pageId,
    itemWithAds: itemWithAds,
    refresh: refresh,
    loading: loading,
    onNextPage: onNextPage
  }));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityNewsFeedComponent);
//# sourceMappingURL=NewsFeed.js.map