"use strict";

import { useCallback } from "react";
import { Pressable } from "react-native";
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
import Animated, { useReducedMotion } from "react-native-reanimated";
import { IOColors, IOModuleIDPSavedVSpacing, IOModuleStyles } from "../../core";
import { useIOTheme } from "../../context";
import { useScaleAnimation } from "../../hooks";
import { jsx as _jsx } from "react/jsx-runtime";
export const PressableModuleBase = ({
  onPress,
  withLooseSpacing = false,
  accessibilityLabel,
  accessibilityHint,
  testID,
  children
}) => {
  const theme = useIOTheme();
  const reducedMotion = useReducedMotion();
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle
  } = useScaleAnimation(reducedMotion ? "slight" : "medium");
  /* We use a slight scaleEffect if `reducedMotion` is enabled.
  We don't disable it completely because that's the only
  difference between the two states "default" and "pressed".
  If we remove it, they they won't be able to understand
  if there's an ongoing interaction. */

  const handleOnPress = useCallback(event => {
    if (onPress) {
      ReactNativeHapticFeedback.trigger("impactLight");
      onPress(event);
    }
  }, [onPress]);
  return /*#__PURE__*/_jsx(Pressable, {
    onPress: handleOnPress,
    testID: testID,
    accessible: true,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessibilityLabel: accessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    children: /*#__PURE__*/_jsx(Animated.View, {
      style: [IOModuleStyles.button, {
        borderColor: IOColors[theme["cardBorder-default"]]
      }, withLooseSpacing && {
        paddingVertical: IOModuleIDPSavedVSpacing
      }, scaleAnimatedStyle],
      children: children
    })
  });
};
//# sourceMappingURL=PressableModuleBase.js.map