"use strict";

exports.__esModule = true;
exports.default = exports.BaseIlloUI = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
const BaseIlloUI = (0, _styledComponents.default)('span').withConfig({
  displayName: "baseIllo__BaseIlloUI",
  componentId: "sc-1l3ktmz-0"
})(["width:", "px;height:", "px;display:inline-flex;svg{display:block;height:100%;width:100%;}"], props => props.width, props => props.height);
exports.BaseIlloUI = BaseIlloUI;
class BaseIllo extends _react.default.PureComponent {
  render() {
    const {
      svg,
      size,
      width: propWidth,
      height: propHeight,
      ...rest
    } = this.props;
    const fragment = document.createElement('div');
    fragment.innerHTML = svg;
    const svgNode = fragment.querySelector('svg');
    const viewbox = svgNode.attributes.viewBox;
    let h, w;
    if (viewbox) {
      const [width, height] = viewbox.textContent.split(' ').slice(-2);
      w = width;
      h = height;
    } else {
      w = svgNode.attributes.width.textContent.replace('px', '');
      h = svgNode.attributes.height.textContent.replace('px', '');
    }
    const ratio = w / h;
    const svgWidth = size;
    const svgHeight = size / ratio;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(BaseIlloUI, {
      ...rest,
      "data-cy": "BaseIllo",
      width: svgWidth,
      height: svgHeight,
      dangerouslySetInnerHTML: {
        __html: svg
      }
    });
  }
}
_defineProperty(BaseIllo, "propTypes", {
  svg: _propTypes.default.string,
  size: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
});
_defineProperty(BaseIllo, "defaultProps", {
  size: 80,
  svg: '<svg width="100" height="80">test</svg>'
});
var _default = BaseIllo;
exports.default = _default;