"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useFeed = useFeed;
var _react = require("react");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _hooks = require("../../../../../../hooks");
var _enums = require("../../../../../../enums");
var _useFeedState = require("../../../hooks/useFeedState");
var _useUserFeed = _interopRequireDefault(require("../../../../../../hooks/collections/post/useUserFeed"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function useFeed({
  userId,
  isBrand,
  isUserLoading,
  ref
}) {
  const {
    isBlockedByMe,
    isPrivate,
    feedEnabled
  } = (0, _useFeedState.useFeedState)({
    userId,
    isBrand,
    isUserLoading
  });
  const pageId = _enums.PageID.user_profile_page;
  const componentId = _enums.ComponentID.user_feed;
  const {
    accessibilityId: feedId
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const {
    config: emptyConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.empty_user_feed
  });
  const {
    config: privateConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.private_user_feed
  });
  const {
    config: privateInfoConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.private_user_feed_info
  });
  const {
    config: blockedConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.blocked_user_feed
  });
  const {
    config: blockedInfoConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.blocked_user_feed_info
  });
  const {
    posts,
    hasMore,
    loadMore,
    isLoading,
    isLoadingFirstPage
  } = (0, _useUserFeed.default)({
    userId,
    enabled: feedEnabled,
    feedSources: [_tsSdkReactNative.FeedSourceEnum.User],
    matchingOnlyParentPost: true,
    dataTypes: [_tsSdkReactNative.FeedDataTypeEnum.Text, _tsSdkReactNative.FeedDataTypeEnum.Image, _tsSdkReactNative.FeedDataTypeEnum.Video, _tsSdkReactNative.FeedDataTypeEnum.Poll, _tsSdkReactNative.FeedDataTypeEnum.Clip, _tsSdkReactNative.FeedDataTypeEnum.LiveStream, _tsSdkReactNative.FeedDataTypeEnum.Room]
  });
  (0, _react.useImperativeHandle)(ref, () => ({
    loadMore: () => hasMore && !isLoading && !isLoadingFirstPage && (loadMore === null || loadMore === void 0 ? void 0 : loadMore())
  }), [hasMore, isLoadingFirstPage, loadMore, isLoading]);
  return {
    feedId,
    posts,
    hasMore,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  };
}
//# sourceMappingURL=useFeed.js.map