"use strict";

import { Pressable, View } from "react-native";
import Animated from "react-native-reanimated";
import { useIOTheme } from "../../context";
import { IOColors, IOListItemStyles, IOListItemVisualParams } from "../../core";
import { useListItemAnimation } from "../../hooks";
import { useIOFontDynamicScale } from "../../utils/accessibility";
import { AnimatedIcon } from "../icons";
import { ButtonText } from "../typography/ButtonText";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export const ListItemAction = ({
  variant,
  label,
  onPress,
  icon,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = useListItemAnimation();
  const theme = useIOTheme();
  const {
    dynamicFontScale,
    spacingScaleMultiplier
  } = useIOFontDynamicScale();
  const listItemAccessibilityLabel = accessibilityLabel || `${label}`;
  const mapForegroundColor = {
    primary: theme["interactiveElem-default"],
    danger: theme.errorText
  };
  return /*#__PURE__*/_jsx(Pressable, {
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessible: true,
    accessibilityLabel: listItemAccessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    testID: testID,
    children: /*#__PURE__*/_jsx(Animated.View, {
      style: [IOListItemStyles.listItem, backgroundAnimatedStyle],
      importantForAccessibility: "no-hide-descendants",
      accessibilityElementsHidden: true,
      children: /*#__PURE__*/_jsxs(Animated.View, {
        style: [IOListItemStyles.listItemInner, {
          columnGap: IOListItemVisualParams.iconMargin * dynamicFontScale * spacingScaleMultiplier
        }, scaleAnimatedStyle],
        children: [icon && /*#__PURE__*/_jsx(AnimatedIcon, {
          allowFontScaling: true,
          name: icon,
          color: IOColors[mapForegroundColor[variant]],
          size: IOListItemVisualParams.iconSize
        }), /*#__PURE__*/_jsx(View, {
          style: {
            flexGrow: 1,
            flexShrink: 1
          },
          children: /*#__PURE__*/_jsx(ButtonText, {
            color: mapForegroundColor[variant],
            children: label
          })
        })]
      })
    })
  });
};
//# sourceMappingURL=ListItemAction.js.map