"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _base = _interopRequireDefault(require("@emotion/styled/base"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _immutable = require("immutable");
var _decapCmsUiDefault = require("decap-cms-ui-default");
var _react2 = require("@emotion/react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const StyledImage = /*#__PURE__*/(0, _base.default)(({
  src
}) => (0, _react2.jsx)("img", {
  src: src || '',
  role: "presentation"
}), {
  target: "eeuykvb0",
  label: "StyledImage"
})(process.env.NODE_ENV === "production" ? {
  name: "waguu7",
  styles: "display:block;max-width:100%;height:auto"
} : {
  name: "waguu7",
  styles: "display:block;max-width:100%;height:auto",
  map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9JbWFnZVByZXZpZXcuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBTW9GIiwiZmlsZSI6Ii4uLy4uL3NyYy9JbWFnZVByZXZpZXcuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuaW1wb3J0IFByb3BUeXBlcyBmcm9tICdwcm9wLXR5cGVzJztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCB7IExpc3QgfSBmcm9tICdpbW11dGFibGUnO1xuaW1wb3J0IHsgV2lkZ2V0UHJldmlld0NvbnRhaW5lciB9IGZyb20gJ2RlY2FwLWNtcy11aS1kZWZhdWx0JztcblxuY29uc3QgU3R5bGVkSW1hZ2UgPSBzdHlsZWQoKHsgc3JjIH0pID0+ID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HJvcFR5cGVzLm5vZGUsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBJbWFnZVByZXZpZXc7XG4iXX0= */",
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
function StyledImageAsset({
  getAsset,
  value,
  field
}) {
  return (0, _react2.jsx)(StyledImage, {
    src: getAsset(value, field)
  });
}
function ImagePreviewContent(props) {
  const {
    value,
    getAsset,
    field
  } = props;
  if (Array.isArray(value) || _immutable.List.isList(value)) {
    return value.map((val, index) => (0, _react2.jsx)(StyledImageAsset, {
      key: index,
      value: val,
      getAsset: getAsset,
      field: field
    }));
  }
  return (0, _react2.jsx)(StyledImageAsset, props);
}
function ImagePreview(props) {
  return (0, _react2.jsx)(_decapCmsUiDefault.WidgetPreviewContainer, null, props.value ? (0, _react2.jsx)(ImagePreviewContent, props) : null);
}
ImagePreview.propTypes = {
  getAsset: _propTypes.default.func.isRequired,
  value: _propTypes.default.node
};
var _default = exports.default = ImagePreview;