import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import CKIcon from '../ck-icon/index.js';
import Button from '../button/index.js';
import '../extends-C4cduGrv.js';
import '../ck-icon/assets/icon-map/index.js';
import '../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../icon/icons.js';
import '../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../defineProperty-CEd-kZQW.js';
import '@reach/visually-hidden';
import '../slicedToArray-BB-AwwkK.js';
import '../floating-ui.react-cWPyyUrN.js';
import '../typeof-CgC7Bq6K.js';
import '../toConsumableArray-dKQYsfpV.js';
import '../index-qSfOyGhk.js';
import 'react-dom';
import '../button/button-group.js';

var _excluded = ["type", "size", "title", "message", "action", "children", "icon"],
    _excluded2 = ["children"];
var types = {
  success: {
    bg: "bg-green-50",
    iconColor: "text-green-600",
    icon: "check-circle",
    buttonColor: "bg-green-200 text-gray-900 hover:bg-green-300 focus:bg-green-300"
  },
  warning: {
    bg: "bg-yellow-50",
    iconColor: "text-yellow-600",
    icon: "alert-circle",
    buttonColor: "bg-yellow-200 hover:bg-yellow-300"
  },
  info: {
    bg: "bg-blue-50",
    iconColor: "text-blue-600",
    icon: "information-circle",
    buttonColor: "bg-blue-200 hover:bg-blue-300"
  },
  error: {
    bg: "bg-red-50",
    iconColor: "text-red-600",
    icon: "alert-triangle",
    buttonColor: "bg-red-200 hover:bg-red-300"
  }
};
var sizes = {
  sm: "py-2 px-4 items-center",
  lg: "p-4"
};
function Note(_ref) {
  var _ref$type = _ref.type,
      type = _ref$type === void 0 ? "info" : _ref$type,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? "lg" : _ref$size,
      title = _ref.title,
      message = _ref.message,
      action = _ref.action,
      children = _ref.children,
      _ref$icon = _ref.icon,
      icon = _ref$icon === void 0 ? true : _ref$icon,
      props = _objectWithoutProperties(_ref, _excluded);

  var className = cx("rounded-lg text-sm text-gray-800 flex", types[type].bg, sizes[size], props.className);
  var iconName = typeof icon === "string" ? icon : types[type].icon;
  return /*#__PURE__*/React__default.createElement("div", {
    className: className,
    "data-testid": "note",
    style: {
      minHeight: "48px"
    }
  }, icon && /*#__PURE__*/React__default.createElement(CKIcon, {
    name: iconName,
    className: "".concat(types[type].iconColor, " mr-4")
  }), /*#__PURE__*/React__default.createElement("div", {
    className: cx("w-full", size === "sm" && "flex items-center")
  }, size !== "sm" && title && /*#__PURE__*/React__default.createElement(Title, {
    className: "flex-shrink-0"
  }, title), message && /*#__PURE__*/React__default.createElement("p", {
    className: cx("text-gray-700 leading-6", size === "sm" && "flex-grow")
  }, message), action && /*#__PURE__*/React__default.createElement(Button, {
    type: type,
    size: "sm",
    is: "plain",
    className: cx("flex-shrink-0 font-semibold", types[type].buttonColor, {
      "mt-4": size !== "sm",
      "ml-4": size === "sm"
    }),
    onClick: action.onClick
  }, action.label), children));
}
Note.propTypes = {
  type: PropTypes.oneOf(["info", "success", "warning", "error"]).isRequired,
  size: PropTypes.oneOf(["sm", "lg"]),

  /** Only available on `lg` size */
  title: PropTypes.string,
  message: PropTypes.string,

  /** Displays a button. Contains `label` (string) and `onClick` (function) */
  action: PropTypes.object,

  /** Controls if an icon is displayed or not. */
  icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
  className: PropTypes.string,
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
};
function Title(_ref2) {
  var children = _ref2.children,
      props = _objectWithoutProperties(_ref2, _excluded2);

  var className = cx("font-semibold text-sm text-gray-900 leading-6 mb-1", props.className);
  return /*#__PURE__*/React__default.createElement("div", {
    className: className
  }, children);
}

export { Title, Note as default, types };
