"use strict";

exports.__esModule = true;
exports.default = exports.HOME_ICON_HEIGHT = exports.CLOSE_ICON_HEIGHT = exports.BACK_ICON_HEIGHT = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _novaIcons = require("@coorpacademy/nova-icons");
var _templateContext = require("../../template/app-review/template-context");
var _index = _interopRequireDefault(require("../../hoc/touchable/index.native"));
var _index2 = _interopRequireDefault(require("../header-back-icon/index.native"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const HOME_ICON_HEIGHT = exports.HOME_ICON_HEIGHT = 20;
const CLOSE_ICON_HEIGHT = exports.CLOSE_ICON_HEIGHT = 16;
const BACK_ICON_HEIGHT = exports.BACK_ICON_HEIGHT = 20;
const createStyleSheet = (theme, statusBarHeight) => _reactNative.StyleSheet.create({
  container: {
    paddingLeft: theme.spacing.base
  },
  floating: {
    paddingTop: theme.spacing.base,
    position: 'absolute',
    top: statusBarHeight
  },
  noSafeArea: {
    top: 0
  }
});
const HeaderBackButton = props => {
  const templateContext = (0, _templateContext.useTemplateContext)();
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const {
    theme,
    display: {
      statusBarHeight
    }
  } = templateContext;
  const {
    type,
    color = theme.colors.white,
    onPress,
    isFloating = true,
    noSafeArea = false,
    testID = 'default-header-back-button-test-id'
  } = props;
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(theme, statusBarHeight);
    setStylesheet(_stylesheet);
  }, [theme, statusBarHeight]);
  if (!styleSheet) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.container, isFloating && styleSheet.floating, isFloating && noSafeArea && styleSheet.noSafeArea]
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    testID: testID,
    onPress: onPress,
    analyticsID: "button-close"
  }, type === 'home' ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidPlacesPlacesHome2, {
    height: HOME_ICON_HEIGHT,
    width: HOME_ICON_HEIGHT,
    color: color
  }) : null, type === 'close' ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
    height: CLOSE_ICON_HEIGHT,
    width: CLOSE_ICON_HEIGHT,
    color: color
  }) : null, type === 'back' ? /*#__PURE__*/_react.default.createElement(_index2.default, {
    height: BACK_ICON_HEIGHT,
    width: BACK_ICON_HEIGHT,
    color: color
  }) : null));
};
var _default = exports.default = HeaderBackButton;
//# sourceMappingURL=index.native.js.map