import { memo } from 'react';
import { View } from 'react-native';
import { ComponentID, PageID } from '../../../../enums/enumUIKitID';
import AmityGlobalFeedComponent from '../GlobalFeed/GlobalFeed';
import { useStyles } from './styles';
import { useAmityComponent } from '../../../../hooks';
import { useCustomRankingGlobalFeed } from '../../../../hooks/useCustomRankingGlobalFeed';
import NewsFeedLoadingComponent from '../../../../components/NewsFeedLoadingComponent/NewsFeedLoadingComponent';
import { AmityEmptyNewsFeedComponent } from '../../../..';
const AmityNewsFeedComponent = ({
  pageId = PageID.WildCardPage,
  onPressExploreCommunity
}) => {
  const styles = useStyles();
  const componentId = ComponentID.newsfeed_component;
  const {
    accessibilityId,
    isExcluded
  } = useAmityComponent({
    pageId,
    componentId
  });
  const {
    itemWithAds,
    refresh,
    globalFeedPosts,
    loading,
    onNextPage
  } = 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, null);
  if (!loading && !(globalFeedPosts !== null && globalFeedPosts !== void 0 && globalFeedPosts.length)) return /*#__PURE__*/React.createElement(AmityEmptyNewsFeedComponent, {
    pageId: pageId,
    onPressExploreCommunity: onPressExploreCommunity
  });
  return /*#__PURE__*/React.createElement(View, {
    style: styles.container,
    testID: accessibilityId,
    accessibilityLabel: accessibilityId
  }, /*#__PURE__*/React.createElement(AmityGlobalFeedComponent, {
    pageId: pageId,
    itemWithAds: itemWithAds,
    refresh: refresh,
    loading: loading,
    onNextPage: onNextPage
  }));
};
export default /*#__PURE__*/memo(AmityNewsFeedComponent);
//# sourceMappingURL=NewsFeed.js.map