"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getColor = exports.IllustrationBase = void 0;
var _omit2 = _interopRequireDefault(require("ramda/src/omit"));
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _utils = require("../../common/utils");
var _excluded = ["className", "children", "title", "color", "inline"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(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 && Object.prototype.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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
var ALLOWED_COLOR_STRINGS = ['transparent', 'inherit', 'currentColor'];
var getColor = exports.getColor = function getColor(theme, defaultColor, colorFnOrColor) {
  if (typeof colorFnOrColor !== 'undefined') {
    if (typeof colorFnOrColor === 'function') {
      return colorFnOrColor(theme);
    }
    if (ALLOWED_COLOR_STRINGS.includes(colorFnOrColor)) {
      return colorFnOrColor;
    }
    (0, _utils.assert)(ALLOWED_COLOR_STRINGS.includes(colorFnOrColor), "Incorrect string value for color, use t => t.color.<some color> instead. Allowed string values are: ".concat(ALLOWED_COLOR_STRINGS.join(', '), "."));
  }
  return defaultColor;
};
var CleanSvg = _react.default.forwardRef(function (props, ref) {
  return _react.default.createElement("svg", _extends({
    ref: ref
  }, (0, _omit2.default)(['inline'])(props)));
});
var StyledIllustrationBase = (0, _styledComponents.default)(CleanSvg).withConfig({
  displayName: "IllustrationBase__StyledIllustrationBase",
  componentId: "sc-1udvn7x-0"
})(["", ""], function (p) {
  return "\n      color: ".concat(p.$color, ";\n      user-select: none;\n      flex-shrink: 0;\n      display: ").concat(p.inline ? 'inline-block' : 'block', ";\n      ").concat(p.inline ? 'vertical-align: sub;' : '', "\n    ");
});
var IllustrationBase = exports.IllustrationBase = _react.default.forwardRef(function (props, ref) {
  var className = props.className,
    children = props.children,
    title = props.title,
    color = props.color,
    inline = props.inline,
    rest = _objectWithoutProperties(props, _excluded);
  var theme = (0, _styledComponents.useTheme)();
  var illustrationColor = getColor(theme, theme.color.icon, color);
  return _react.default.createElement(StyledIllustrationBase, _extends({
    className: className,
    preserveAspectRatio: "xMidYMid meet",
    focusable: "false",
    "aria-hidden": title ? 'false' : 'true',
    role: title ? 'img' : 'presentation',
    inline: inline,
    ref: ref,
    $color: illustrationColor
  }, rest), children, title ? _react.default.createElement("title", null, title) : null);
});