"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TitleCard = exports.Card = void 0;

var _preact = require("preact");

var _classnames = _interopRequireDefault(require("classnames"));

var _icon = require("./icon");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/**
 * @typedef CardProps
 * @property {boolean} [white]
 * @property {boolean} [nearWhite]
 * @property {string} [className]
 * @property {string} [href]
 */

/**
 * Card
 *
 * @type {import('preact').FunctionComponent}
 * @param {CardProps} props
 */
const Card = (_ref) => {
  let {
    white = false,
    nearWhite = false,
    className,
    href
  } = _ref,
      props = _objectWithoutProperties(_ref, ["white", "nearWhite", "className", "href"]);

  const classes = (0, _classnames.default)({
    'bg-white': white,
    'bg-near-white': nearWhite
  }, 'pa3 br2 shadow-1', href && 'no-underline color-inherit', className);

  if (href) {
    return (0, _preact.h)("a", _extends({
      className: classes,
      href: href
    }, props));
  }

  return (0, _preact.h)("div", _extends({
    className: classes
  }, props));
};
/**
 * Card
 *
 * @type {import('preact').FunctionComponent}
 * @param {CardProps & {
 *   icon: string
 *   iconColor: import('./icon').CircleIconProps['color']
 * }} props
 */


exports.Card = Card;

const TitleCard = (_ref2) => {
  let {
    children,
    icon,
    iconColor = 'blue',
    topContent,
    titleClassName,
    title
  } = _ref2,
      props = _objectWithoutProperties(_ref2, ["children", "icon", "iconColor", "topContent", "titleClassName", "title"]);

  return (0, _preact.h)(Card, props, (0, _preact.h)("div", {
    className: (0, _classnames.default)('flex items-center', titleClassName, children && 'mb2')
  }, (0, _preact.h)("div", {
    className: "flex items-center"
  }, (0, _preact.h)(_icon.CircledIcon, {
    icon: icon,
    color: iconColor
  }), title && (0, _preact.h)("h4", {
    className: "ml2 mv0 f5 fw4"
  }, title)), topContent), children);
};

exports.TitleCard = TitleCard;