"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _enums = require("../../../enums");
var _BehaviourProvider = require("../../../providers/BehaviourProvider");
var _TargetSelectionPage = _interopRequireDefault(require("../../../components/TargetSelectionPage/TargetSelectionPage"));
var _native = require("@react-navigation/native");
var _utils = require("../../../utils");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityPostTargetSelectionPage = ({
  postType
}) => {
  const {
    AmityPostTargetSelectionPageBehavior
  } = (0, _BehaviourProvider.useBehaviour)();
  const navigation = (0, _native.useNavigation)();
  const onSelectFeed = ({
    targetId,
    targetName,
    targetType,
    community,
    postSetting,
    needApprovalOnPostCreation,
    isPublic
  }) => {
    if (postType === _enums.AmityPostTargetSelectionPageType.post) {
      if (AmityPostTargetSelectionPageBehavior.goToPostComposerPage) {
        return AmityPostTargetSelectionPageBehavior.goToPostComposerPage({
          community: (0, _utils.serializeCommunity)(community),
          targetId,
          targetType
        });
      }
      return navigation.navigate('CreatePost', {
        community: (0, _utils.serializeCommunity)(community),
        targetType,
        targetId
      });
    }
    if (postType === _enums.AmityPostTargetSelectionPageType.poll) {
      if (AmityPostTargetSelectionPageBehavior.goToPollComposerPage) {
        return AmityPostTargetSelectionPageBehavior.goToPollComposerPage({
          targetId,
          targetType,
          targetName,
          postSetting,
          needApprovalOnPostCreation,
          isPublic
        });
      }
      return navigation.navigate('CreatePoll', {
        targetId,
        targetType,
        targetName,
        postSetting,
        needApprovalOnPostCreation,
        isPublic
      });
    }
    if (postType === _enums.AmityPostTargetSelectionPageType.livestream) {
      if (AmityPostTargetSelectionPageBehavior.goToCreateLivestreamPage) {
        return AmityPostTargetSelectionPageBehavior.goToCreateLivestreamPage({
          targetId,
          targetType,
          targetName
        });
      }
      return navigation.navigate('CreateLivestream', {
        targetId,
        targetType,
        targetName
      });
    }
  };
  const onClickClose = () => {
    if (AmityPostTargetSelectionPageBehavior !== null && AmityPostTargetSelectionPageBehavior !== void 0 && AmityPostTargetSelectionPageBehavior.onClickClose) {
      AmityPostTargetSelectionPageBehavior.onClickClose();
    }
  };
  return /*#__PURE__*/_react.default.createElement(_TargetSelectionPage.default, {
    pageId: _enums.PageID.select_post_target_page,
    onSelectFeed: onSelectFeed,
    onClickClose: onClickClose
  });
};
var _default = exports.default = /*#__PURE__*/_react.default.memo(AmityPostTargetSelectionPage);
//# sourceMappingURL=TargetSelection.js.map