import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React, { useEffect, useState } from "react";
import { getAssetSrc } from "../../../utils/common";

var OlineImage = function OlineImage(props) {
  var _useState = useState(''),
      _useState2 = _slicedToArray(_useState, 2),
      imageSrc = _useState2[0],
      setImageSrc = _useState2[1];

  var _props$imageInfo = props.imageInfo,
      imageInfo = _props$imageInfo === void 0 ? {} : _props$imageInfo,
      prefix = props.prefix,
      _props$style = props.style,
      style = _props$style === void 0 ? {
    maxWidth: '100%',
    maxHeight: '100%',
    objectFit: 'contain'
  } : _props$style,
      resProps = _objectWithoutProperties(props, ["imageInfo", "prefix", "style"]);

  useEffect(function () {
    if (typeof imageInfo === 'string') {
      setImageSrc(imageInfo);
    } else {
      var src = getAssetSrc(imageInfo.path);

      if (imageInfo.guid && imageInfo.fileName) {
        src = getAssetSrc("/".concat(imageInfo.path, "/").concat(imageInfo.fileName));
      }

      setImageSrc(src);
    }
  }, [imageInfo]);
  return /*#__PURE__*/React.createElement("img", Object.assign({
    alt: "img",
    src: imageSrc,
    style: style
  }, resProps));
};

export default OlineImage;
//# sourceMappingURL=index.js.map