"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FooterActionsInline = void 0;
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _buttons = require("../buttons");
var _useBottomMargins = require("./hooks/useBottomMargins");
var _jsxRuntime = require("react/jsx-runtime");
const styles = _reactNative.StyleSheet.create({
  buttonContainer: {
    paddingHorizontal: _core.IOVisualCostants.appMarginDefault,
    width: "100%",
    flexShrink: 0
  },
  buttonWrapper: {
    flex: 1
  },
  blockShadow: {
    shadowColor: _core.IOColors.black,
    shadowOffset: {
      width: 0,
      height: -4
    },
    shadowOpacity: 0.1,
    shadowRadius: 32,
    elevation: 10 // Prop supported on Android only
  }
});
const FooterActionsInline = ({
  startAction,
  endAction,
  excludeSafeAreaMargins = false,
  fixed = true,
  onMeasure,
  testID
}) => {
  const theme = (0, _context.useIOTheme)();
  const {
    themeType
  } = (0, _context.useIOThemeContext)();
  const {
    bottomMargin
  } = (0, _useBottomMargins.useBottomMargins)(false, excludeSafeAreaMargins);

  /* Margin between `solid` and `outline` variant */
  const spaceBetweenActions = 16;
  /* Top padding applied above the actions */
  const topSpacingValue = 16;
  const topSpacing = fixed ? topSpacingValue : 0;

  /* Background color should be app main background
     (both light and dark themes) */
  const HEADER_BG_COLOR = _core.IOColors[theme["appBackground-primary"]];
  const getActionBlockMeasurements = event => {
    const {
      height
    } = event.nativeEvent.layout;
    /* Height of the safe bottom area, applied to the ScrollView:
       Actions + Screen end margin */
    const safeBottomAreaHeight = bottomMargin + height + _core.IOSpacing.screenEndMargin;
    onMeasure?.({
      safeBottomAreaHeight
    });
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
    style: [{
      width: "100%",
      paddingBottom: bottomMargin
    }, fixed ? {
      position: "absolute",
      bottom: 0,
      backgroundColor: HEADER_BG_COLOR
    } : {
      marginTop: _core.IOSpacing.screenEndMargin
    }, /* Apply shadow only on light theme OR if fixed */
    fixed || themeType === "light" ? styles.blockShadow : {}, /* Apply bottom border only on dark theme */
    themeType === "dark" && {
      borderTopColor: _core.IOColors[theme["divider-bottomBar"]],
      borderTopWidth: 1
    }],
    testID: testID,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: [styles.buttonContainer, {
        paddingTop: topSpacing
      }],
      onLayout: getActionBlockMeasurements,
      pointerEvents: "box-none",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
        style: {
          flexDirection: "row",
          gap: spaceBetweenActions
        },
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: styles.buttonWrapper,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.IOButton, {
            variant: "outline",
            fullWidth: true,
            ...startAction
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: styles.buttonWrapper,
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.IOButton, {
            variant: "solid",
            fullWidth: true,
            ...endAction
          })
        })]
      })
    })
  });
};
exports.FooterActionsInline = FooterActionsInline;
//# sourceMappingURL=FooterActionsInline.js.map