import { View, TouchableOpacity } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { SvgXml } from 'react-native-svg';
import { arrowRight, radioChecked, radioUnchecked } from '../../../../../core/assets/icons';
import { Radio } from '../../../../../core/components/Radio';
import { Typography } from '../../../../../core/components/Typography/Typography';
import { IOSPollDurationPicker } from './PollDurationPicker';
import { useStyles } from '../styles';
import { androidDurationOptions, durationOptions, usePollPostComposerContext } from '../PollPostComposer';
export function IOSBottomSheet() {
  const {
    styles,
    theme
  } = useStyles();
  const {
    duration,
    setDuration,
    bottomSheetRef,
    isShowingDatePicker,
    setIsShowingDatePicker
  } = usePollPostComposerContext();
  return /*#__PURE__*/React.createElement(View, null, isShowingDatePicker ? /*#__PURE__*/React.createElement(IOSPollDurationPicker, null) : /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Radio.Group, {
    value: duration.value,
    onChange: value => {
      var _bottomSheetRef$curre;
      setDuration(durationOptions.find(option => option.value === value));
      (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.close();
    }
  }, durationOptions.map(option => /*#__PURE__*/React.createElement(Radio.Option, {
    value: option.value,
    accessibilityLabel: option.label
  }, /*#__PURE__*/React.createElement(Radio.Label, null, /*#__PURE__*/React.createElement(Typography.BodyBold, {
    style: styles.base
  }, option.label)), /*#__PURE__*/React.createElement(Radio.Icon, null)))), /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: styles.pickDateTimeButton,
    onPress: () => setIsShowingDatePicker(true)
  }, /*#__PURE__*/React.createElement(Typography.BodyBold, {
    style: styles.base
  }, "Pick date and time"), /*#__PURE__*/React.createElement(SvgXml, {
    width: "24",
    height: "24",
    xml: arrowRight(),
    color: theme.colors.base
  }))));
}

// Android: Pressable is unreliable inside @devvie/bottom-sheet's PanResponder-
// controlled Animated.View — touches are intercepted before reaching Pressable.
// Use TouchableOpacity rows with explicit radio SVG icons instead.
export function AndroidBottomSheet() {
  const {
    styles,
    theme
  } = useStyles();
  const {
    bottom
  } = useSafeAreaInsets();
  const {
    duration,
    setDuration,
    bottomSheetRef
  } = usePollPostComposerContext();
  return /*#__PURE__*/React.createElement(View, {
    style: {
      paddingBottom: bottom + 8
    }
  }, androidDurationOptions.map(option => {
    const isSelected = duration.value === option.value;
    return /*#__PURE__*/React.createElement(TouchableOpacity, {
      key: option.label,
      style: styles.androidDurationOption,
      accessibilityRole: "radio",
      accessibilityState: {
        selected: isSelected
      },
      accessibilityLabel: option.label,
      onPress: () => {
        var _bottomSheetRef$curre2;
        setDuration(option);
        (_bottomSheetRef$curre2 = bottomSheetRef.current) === null || _bottomSheetRef$curre2 === void 0 || _bottomSheetRef$curre2.close();
      }
    }, /*#__PURE__*/React.createElement(Typography.BodyBold, {
      style: styles.base
    }, option.label), /*#__PURE__*/React.createElement(SvgXml, {
      width: 24,
      height: 24,
      xml: isSelected ? radioChecked() : radioUnchecked(),
      color: isSelected ? theme.colors.primary : theme.colors.baseShade3
    }));
  }));
}
//# sourceMappingURL=PollDurationBottomSheet.js.map