import dayjs from 'dayjs';
import { View, TouchableOpacity, Platform } from 'react-native';
import { SvgXml } from 'react-native-svg';
import { arrowDown } from '../../../../../core/assets/icons';
import { Typography } from '../../../../../core/components/Typography/Typography';
import { usePollPostComposerContext } from '../PollPostComposer';
import { useStyles } from '../styles';
import { AndroidPollDurationPicker } from './PollDurationPicker';
import FormLabel from '../../../../elements/FormLabel';
import { ElementID, PageID } from '../../../../enums';
import FormDescription from '../../../../elements/FormDescription';
export function PollDuration() {
  const {
    styles,
    theme
  } = useStyles();
  const {
    duration,
    bottomSheetRef
  } = usePollPostComposerContext();
  return /*#__PURE__*/React.createElement(View, {
    style: styles.fieldContainer
  }, /*#__PURE__*/React.createElement(FormLabel, {
    style: styles.base,
    pageId: PageID.poll_post_composer_page,
    elementId: ElementID.poll_duration_title
  }), /*#__PURE__*/React.createElement(FormDescription, {
    style: styles.baseShade1,
    pageId: PageID.poll_post_composer_page,
    elementId: ElementID.poll_duration_desc
  }), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: styles.durationButton,
    onPress: () => {
      var _bottomSheetRef$curre;
      return (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 ? void 0 : _bottomSheetRef$curre.open();
    }
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.rowContainer
  }, /*#__PURE__*/React.createElement(Typography.Body, {
    style: styles.base
  }, duration.label), /*#__PURE__*/React.createElement(SvgXml, {
    width: "24",
    height: "24",
    xml: arrowDown(),
    color: theme.colors.baseShade2
  }))), Platform.OS === 'ios' && duration.value > 0 && /*#__PURE__*/React.createElement(Typography.Caption, {
    style: styles.base
  }, "Ends on ", dayjs().add(duration.value, 'day').format('DD MMM'), " at", ' ', dayjs().add(duration.value, 'day').format('HH:mm A')), Platform.OS === 'android' && /*#__PURE__*/React.createElement(AndroidPollDurationPicker, null)));
}
//# sourceMappingURL=PollDuration.js.map