"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IconButtonSolid = void 0;
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
var _context = require("../../context");
var _core = require("../../core");
var _IOColors = require("../../core/IOColors");
var _hooks = require("../../hooks");
var _icons = require("../icons");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const IconButtonSolid = ({
  icon,
  color = "primary",
  disabled = false,
  onPress,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const theme = (0, _context.useIOTheme)();
  const {
    progress,
    onPressIn,
    onPressOut,
    scaleAnimatedStyle
  } = (0, _hooks.useScaleAnimation)("exaggerated");
  const reducedMotion = (0, _reactNativeReanimated.useReducedMotion)();
  const mapColorStates = {
    // Primary button
    primary: {
      background: {
        default: _IOColors.IOColors[theme["interactiveElem-default"]],
        pressed: _IOColors.IOColors[theme["interactiveElem-pressed"]],
        disabled: _IOColors.IOColors[theme["interactiveElem-disabled"]]
      },
      icon: {
        default: _IOColors.IOColors[theme["buttonText-default"]],
        disabled: _IOColors.IOColors[theme["buttonText-disabled"]]
      }
    },
    contrast: {
      background: {
        default: _IOColors.IOColors.white,
        pressed: _IOColors.IOColors["blueIO-50"],
        disabled: (0, _IOColors.hexToRgba)(_IOColors.IOColors.white, 0.25)
      },
      icon: {
        default: _IOColors.IOColors["blueIO-500"],
        disabled: _IOColors.IOColors["blueIO-500"]
      }
    }
  };
  const backgroundColorAnimationStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
    backgroundColor: (0, _reactNativeReanimated.interpolateColor)(progress.value, [0, 1], [mapColorStates[color].background.default, mapColorStates[color].background.pressed])
  }));
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
    accessibilityLabel: accessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    accessibilityState: {
      disabled
    },
    testID: testID,
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    accessible: true,
    disabled: disabled,
    style: {
      alignSelf: "flex-start"
    },
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
      style: [_core.IOIconButtonStyles.button, _core.IOIconButtonStyles.buttonSizeLarge, !disabled && !reducedMotion && scaleAnimatedStyle, !disabled && backgroundColorAnimationStyle, disabled ? {
        backgroundColor: mapColorStates[color]?.background?.disabled
      } : {
        backgroundColor: mapColorStates[color]?.background?.default
      }],
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.AnimatedIcon, {
        allowFontScaling: true,
        name: icon,
        color: !disabled ? mapColorStates[color]?.icon?.default : mapColorStates[color]?.icon?.disabled
      })
    })
  });
};
exports.IconButtonSolid = IconButtonSolid;
//# sourceMappingURL=IconButtonSolid.js.map