"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AndroidBottomSheet = AndroidBottomSheet;
exports.IOSBottomSheet = IOSBottomSheet;
var _reactNative = require("react-native");
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _reactNativeSvg = require("react-native-svg");
var _icons = require("../../../../../core/assets/icons");
var _Radio = require("../../../../../core/components/Radio");
var _Typography = require("../../../../../core/components/Typography/Typography");
var _PollDurationPicker = require("./PollDurationPicker");
var _styles = require("../styles");
var _PollPostComposer = require("../PollPostComposer");
function IOSBottomSheet() {
  const {
    styles,
    theme
  } = (0, _styles.useStyles)();
  const {
    duration,
    setDuration,
    bottomSheetRef,
    isShowingDatePicker,
    setIsShowingDatePicker
  } = (0, _PollPostComposer.usePollPostComposerContext)();
  return /*#__PURE__*/React.createElement(_reactNative.View, null, isShowingDatePicker ? /*#__PURE__*/React.createElement(_PollDurationPicker.IOSPollDurationPicker, null) : /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_Radio.Radio.Group, {
    value: duration.value,
    onChange: value => {
      var _bottomSheetRef$curre;
      setDuration(_PollPostComposer.durationOptions.find(option => option.value === value));
      (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.close();
    }
  }, _PollPostComposer.durationOptions.map(option => /*#__PURE__*/React.createElement(_Radio.Radio.Option, {
    value: option.value,
    accessibilityLabel: option.label
  }, /*#__PURE__*/React.createElement(_Radio.Radio.Label, null, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
    style: styles.base
  }, option.label)), /*#__PURE__*/React.createElement(_Radio.Radio.Icon, null)))), /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    style: styles.pickDateTimeButton,
    onPress: () => setIsShowingDatePicker(true)
  }, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
    style: styles.base
  }, "Pick date and time"), /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    width: "24",
    height: "24",
    xml: (0, _icons.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.
function AndroidBottomSheet() {
  const {
    styles,
    theme
  } = (0, _styles.useStyles)();
  const {
    bottom
  } = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
  const {
    duration,
    setDuration,
    bottomSheetRef
  } = (0, _PollPostComposer.usePollPostComposerContext)();
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: {
      paddingBottom: bottom + 8
    }
  }, _PollPostComposer.androidDurationOptions.map(option => {
    const isSelected = duration.value === option.value;
    return /*#__PURE__*/React.createElement(_reactNative.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.Typography.BodyBold, {
      style: styles.base
    }, option.label), /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
      width: 24,
      height: 24,
      xml: isSelected ? (0, _icons.radioChecked)() : (0, _icons.radioUnchecked)(),
      color: isSelected ? theme.colors.primary : theme.colors.baseShade3
    }));
  }));
}
//# sourceMappingURL=PollDurationBottomSheet.js.map