"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AlertEdgeToEdge = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _core = require("../../core");
var _IOColors = require("../../core/IOColors");
var _IOSpacing = require("../../core/IOSpacing");
var _hooks = require("../../hooks");
var _fonts = require("../../utils/fonts");
var _icons = require("../icons");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const iconSize = 24;
const [spacingDefault] = _IOSpacing.IOAlertSpacing;
const styles = _reactNative.StyleSheet.create({
  alert: {
    flexDirection: "row",
    alignItems: "flex-start",
    alignContent: "center",
    padding: spacingDefault
  }
});
// COMPONENT CONFIGURATION

const mapVariantStates = {
  error: {
    icon: "errorFilled",
    background: "error-100",
    foreground: "error-850"
  },
  warning: {
    icon: "warningFilled",
    background: "warning-100",
    foreground: "warning-850"
  },
  info: {
    icon: "infoFilled",
    background: "info-100",
    foreground: "info-850"
  },
  success: {
    icon: "success",
    background: "success-100",
    foreground: "success-850"
  }
};
const AlertEdgeToEdge = ({
  variant,
  content,
  action,
  onPress,
  accessibilityHint,
  testID
}) => {
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle
  } = (0, _hooks.useScaleAnimation)("slight");
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
  const backgroundColor = (0, _react.useMemo)(() => _IOColors.IOColors[mapVariantStates[variant].background], [variant]);
  const renderMainBlock = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: {
        marginRight: _core.IOVisualCostants.iconMargin,
        alignSelf: "center"
      },
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
        name: mapVariantStates[variant].icon,
        size: iconSize,
        color: mapVariantStates[variant].foreground
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: {
        flex: 1
      },
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_typography.Body, {
        color: mapVariantStates[variant].foreground,
        weight: "Regular",
        accessibilityRole: "text",
        children: [content, action && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
          style: {
            ...(0, _fonts.makeFontStyleObject)(16, "TitilliumSansPro", undefined, "Bold"),
            color: _IOColors.IOColors[mapVariantStates[variant].foreground]
          },
          children: ` ${action}`
        })]
      })
    })]
  });
  const PressableButton = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
    testID: testID,
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut
    // A11y related props
    ,
    accessible: true,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
      entering: _core.enterTransitionAlertEdgeToEdgeContent,
      style: [styles.alert, scaleAnimatedStyle],
      children: renderMainBlock()
    })
  });
  const StaticComponent = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
    entering: _core.enterTransitionAlertEdgeToEdgeContent,
    style: styles.alert,
    testID: testID,
    accessible: false,
    accessibilityRole: "alert",
    accessibilityHint: accessibilityHint,
    children: renderMainBlock()
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
    entering: _core.enterTransitionAlertEdgeToEdge,
    exiting: _core.exitTransitionAlertEdgeToEdge,
    style: {
      paddingTop: insets.top,
      backgroundColor
    },
    children: action ? PressableButton() : StaticComponent()
  });
};
exports.AlertEdgeToEdge = AlertEdgeToEdge;
//# sourceMappingURL=AlertEdgeToEdge.js.map