import _omit from "ramda/src/omit";
var _excluded = ["className", "children", "title", "color", "inline"];
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); }
import React from 'react';
import styled, { useTheme } from 'styled-components';
import { assert } from '../../common/utils';
var ALLOWED_COLOR_STRINGS = ['transparent', 'inherit', 'currentColor'];
export var 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;
    }
    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.forwardRef(function (props, ref) {
  return React.createElement("svg", _extends({
    ref: ref
  }, _omit(['inline'])(props)));
});
var StyledIllustrationBase = styled(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    ");
});
export var IllustrationBase = React.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 = useTheme();
  var illustrationColor = getColor(theme, theme.color.icon, color);
  return React.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.createElement("title", null, title) : null);
});