import { useCallback, memo } from 'react';
import { StyleSheet, View } from 'react-native';
import { ComponentID, PageID } from '../../../../enums/enumUIKitID';
import { useAmityComponent, useStoryPermission } from '../../../../hooks';
import { useBehaviour } from '../../../../providers/BehaviourProvider';
import { useNavigation } from '@react-navigation/native';
import { AmityPostTargetSelectionPageType } from '../../../../enums';
import { livestream, poll, post, story } from '../../../../../core/assets/icons';
import MenuAction from '../../../../elements/MenuAction';
const AmityCreatePostMenuComponent = ({
  pageId = PageID.WildCardPage,
  componentId = ComponentID.WildCardComponent
}) => {
  const navigation = useNavigation();
  const {
    themeStyles
  } = useAmityComponent({
    pageId,
    componentId
  });
  const {
    AmityCreatePostMenuComponentBehavior
  } = useBehaviour();
  const {
    hasStoryPermission
  } = useStoryPermission();
  const styles = StyleSheet.create({
    container: {
      paddingVertical: 12,
      width: 200,
      backgroundColor: themeStyles.colors.background,
      borderRadius: 12
    },
    menu: {
      gap: 12,
      paddingVertical: 12,
      paddingHorizontal: 16,
      flexDirection: 'row',
      alignItems: 'center'
    }
  });
  const onPressCreatePost = useCallback(postType => {
    var _postTypeHandlers$pos;
    const postTypeHandlers = {
      [AmityPostTargetSelectionPageType.post]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectPostTargetPage({
            postType
          });
        }
        navigation.navigate('PostTargetSelection', {
          postType
        });
      },
      [AmityPostTargetSelectionPageType.story]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectStoryTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectStoryTargetPage();
        }
        navigation.navigate('StoryTargetSelection');
      },
      [AmityPostTargetSelectionPageType.poll]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectPollPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectPollPostTargetPage();
        }
        navigation.navigate('PollTargetSelection');
      },
      [AmityPostTargetSelectionPageType.livestream]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectLivestreamPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectLivestreamPostTargetPage();
        }
        navigation.navigate('LivestreamPostTargetSelection');
      }
    };
    (_postTypeHandlers$pos = postTypeHandlers[postType]) === null || _postTypeHandlers$pos === void 0 || _postTypeHandlers$pos.call(postTypeHandlers);
  }, [AmityCreatePostMenuComponentBehavior, navigation]);
  return /*#__PURE__*/React.createElement(View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(MenuAction, {
    onPress: () => onPressCreatePost(AmityPostTargetSelectionPageType.post),
    style: styles.menu,
    label: "Post",
    iconProps: {
      xml: post()
    }
  }), hasStoryPermission && /*#__PURE__*/React.createElement(MenuAction, {
    style: styles.menu,
    label: "Story",
    iconProps: {
      xml: story()
    },
    onPress: () => onPressCreatePost(AmityPostTargetSelectionPageType.story)
  }), /*#__PURE__*/React.createElement(MenuAction, {
    style: styles.menu,
    label: "Poll",
    iconProps: {
      xml: poll()
    },
    onPress: () => onPressCreatePost(AmityPostTargetSelectionPageType.poll)
  }), /*#__PURE__*/React.createElement(MenuAction, {
    style: styles.menu,
    label: "Livestream",
    iconProps: {
      xml: livestream()
    },
    onPress: () => onPressCreatePost(AmityPostTargetSelectionPageType.livestream)
  }));
};
export default /*#__PURE__*/memo(AmityCreatePostMenuComponent);
//# sourceMappingURL=CreatePostMenu.js.map