"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Alert_exports = {};
__export(Alert_exports, {
  default: () => Alert_default
});
module.exports = __toCommonJS(Alert_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_Text = __toESM(require("../../asorted/Text"));
var import_Flex = __toESM(require("../../layout/Flex"));
var import_WarningFill = __toESM(require("@ledgerhq/icons-ui/react/WarningFill"));
var import_InformationFill = __toESM(require("@ledgerhq/icons-ui/react/InformationFill"));
var import_CheckmarkCircleFill = __toESM(require("@ledgerhq/icons-ui/react/CheckmarkCircleFill"));
var import_DeleteCircleFill = __toESM(require("@ledgerhq/icons-ui/react/DeleteCircleFill"));
const StyledIconContainer = import_styled_components.default.div`
  margin-right: 8px;
  display: flex;
  align-items: center;
`;
const icons = {
  info: /* @__PURE__ */ import_react.default.createElement(import_InformationFill.default, { size: "M" }),
  secondary: /* @__PURE__ */ import_react.default.createElement(import_InformationFill.default, { size: "M" }),
  success: /* @__PURE__ */ import_react.default.createElement(import_CheckmarkCircleFill.default, { size: "M" }),
  warning: /* @__PURE__ */ import_react.default.createElement(import_WarningFill.default, { size: "M" }),
  error: /* @__PURE__ */ import_react.default.createElement(import_DeleteCircleFill.default, { size: "M" })
};
const getColors = ({ theme, type }) => {
  switch (type) {
    case "secondary":
      return {
        background: theme.colors.opacityDefault.c05,
        iconColor: theme.colors.neutral.c80
      };
    case "success":
      return {
        background: theme.colors.success.c10,
        iconColor: theme.colors.success.c50
      };
    case "warning":
      return {
        background: theme.colors.warning.c10,
        iconColor: theme.colors.warning.c70
      };
    case "error":
      return {
        background: theme.colors.error.c10,
        iconColor: theme.colors.error.c50
      };
    case "info":
    default:
      return {
        background: theme.colors.primary.c10,
        iconColor: theme.colors.primary.c80
      };
  }
};
const StyledAlertContainer = (0, import_styled_components.default)(import_Flex.default)`
  border-radius: ${(p) => `${p.theme.radii[2]}px`};
  align-items: start;
`;
const AlertBodyText = (0, import_styled_components.default)(import_Text.default).attrs({
  flexShrink: 1,
  variant: "bodyLineHeight",
  fontWeight: "semiBold"
})``;
const AlertUnderlinedText = (0, import_styled_components.default)(AlertBodyText)`
  text-decoration-line: underline;
`;
function Alert({
  type = "info",
  title,
  showIcon = true,
  renderContent,
  renderRight,
  containerProps
}) {
  const theme = (0, import_styled_components.useTheme)();
  const { iconColor, background } = getColors({ theme, type });
  const textProps = {
    variant: "bodyLineHeight",
    fontWeight: "semiBold"
  };
  const textColor = "neutral.c100";
  return /* @__PURE__ */ import_react.default.createElement(
    StyledAlertContainer,
    {
      color: textColor,
      backgroundColor: background,
      padding: 6,
      ...containerProps
    },
    showIcon && !!icons[type] && /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { color: iconColor }, /* @__PURE__ */ import_react.default.createElement(StyledIconContainer, null, icons[type])),
    /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { flexDirection: "column", flex: 1, alignItems: "flex-start", rowGap: "6px" }, title && /* @__PURE__ */ import_react.default.createElement(import_Text.default, { ...textProps, color: textColor }, title), renderContent && renderContent({ textProps })),
    /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { alignSelf: "center" }, renderRight && renderRight({ textProps }))
  );
}
Alert.BodyText = AlertBodyText;
Alert.UnderlinedText = AlertUnderlinedText;
var Alert_default = Alert;
//# sourceMappingURL=index.js.map
