"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListItemRadioWithAmount = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _reactNativeHapticFeedback = _interopRequireDefault(require("react-native-haptic-feedback"));
var _context = require("../../context");
var _core = require("../../core");
var _accessibility = require("../../utils/accessibility");
var _icons = require("../icons");
var _layout = require("../layout");
var _AnimatedRadio = require("../radio/AnimatedRadio");
var _typography = require("../typography");
var _PressableListItemBase = require("./PressableListItemBase");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ListItemRadioWithAmount = ({
  onValueChange,
  selected,
  label,
  accessibilityLabel,
  isSuggested = false,
  suggestReason,
  formattedAmountString
}) => {
  const {
    dynamicFontScale
  } = (0, _accessibility.useIOFontDynamicScale)();
  const [toggleValue, setToggleValue] = (0, _react.useState)(selected ?? false);
  const pressHandler = () => {
    _reactNativeHapticFeedback.default.trigger("impactLight");
    setToggleValue(val => !val);
    if (onValueChange !== undefined) {
      onValueChange(!toggleValue);
    }
  };
  const theme = (0, _context.useIOTheme)();
  const suggestColor = "hanPurple-500";
  const defaultAccessibilityLabel = `${label} ${formattedAmountString} ${suggestReason ?? ""}`;
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PressableListItemBase.PressableListItemBase, {
    onPress: pressHandler,
    accessibilityRole: "radio",
    accessibilityLabel: accessibilityLabel ?? defaultAccessibilityLabel,
    accessibilityState: {
      checked: selected ?? toggleValue
    },
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: {
        flexShrink: 1
      },
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
        numberOfLines: 1,
        color: theme["textBody-default"],
        children: label
      }), isSuggested && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
        space: 4,
        style: {
          alignItems: "center"
        },
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          name: "sparkles",
          size: 16,
          color: suggestColor
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
          weight: "Regular",
          color: suggestColor,
          children: suggestReason
        })]
      })]
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
      space: 8,
      pointerEvents: "none",
      accessibilityElementsHidden: true,
      importantForAccessibility: "no-hide-descendants",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
        color: theme["interactiveElem-default"],
        children: formattedAmountString
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AnimatedRadio.AnimatedRadio, {
        size: _core.IOSelectionTickVisualParams.size * dynamicFontScale,
        checked: selected ?? toggleValue
      })]
    })]
  });
};
exports.ListItemRadioWithAmount = ListItemRadioWithAmount;
//# sourceMappingURL=ListItemRadioWithAmount.js.map