"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePressAnimation = usePressAnimation;
var _react = require("react");
var _reactNative = require("react-native");
var _tokens = require("../styles/tokens.js");
var _nativeDriver = require("../styles/native-driver.js");
/**
 * Hook that provides press-scale animation feedback.
 *
 * Returns an `Animated.Value` for the scale transform and press-in/press-out
 * handlers that spring the value between 1 and the target scale.
 *
 * @param pressScale - Scale value when pressed (e.g. 0.97). Pass `undefined` to disable.
 */
function usePressAnimation(pressScale = 0.97) {
  const scaleAnim = (0, _react.useRef)(new _reactNative.Animated.Value(1)).current;
  const enabled = pressScale !== undefined;
  const onPressIn = (0, _react.useCallback)(() => {
    if (!enabled) return;
    _reactNative.Animated.spring(scaleAnim, {
      toValue: pressScale,
      useNativeDriver: _nativeDriver.SUPPORTS_NATIVE_DRIVER,
      ..._tokens.animation.spring.snappy
    }).start();
  }, [scaleAnim, enabled, pressScale]);
  const onPressOut = (0, _react.useCallback)(() => {
    if (!enabled) return;
    _reactNative.Animated.spring(scaleAnim, {
      toValue: 1,
      useNativeDriver: _nativeDriver.SUPPORTS_NATIVE_DRIVER,
      ..._tokens.animation.spring.gentle
    }).start();
  }, [scaleAnim, enabled]);
  return {
    scaleAnim,
    onPressIn,
    onPressOut,
    enabled
  };
}
//# sourceMappingURL=usePressAnimation.js.map