"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FallbackVisualization = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _styles = require("@material-ui/core/styles");
var _i18n = require("../../../../../Framework/i18n");
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
var _ImageLoader = require("../ImageLoader/ImageLoader");
var _absoluteCenter = require("../../../../../Shared/Styles/absoluteCenter");
var _ReactComponent = _interopRequireDefault(require("../../../../../Shared/PropTypes/ReactComponent"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var styles = function styles() {
  return {
    root: {
      flex: 1,
      display: 'flex',
      flexDirection: 'row',
      '@media (max-aspect-ratio: 10/9)': {
        flexDirection: 'column'
      }
    },
    imageWrapper: {
      flex: '1',
      flexWrap: 'wrap',
      maxHeight: '100%',
      position: 'relative',
      '& > img': _objectSpread({
        maxWidth: '100%',
        maxHeight: '100%'
      }, (0, _absoluteCenter.absoluteCenter)())
    },
    contentWrapper: {
      flex: 1,
      display: 'flex'
    },
    fallbackText: _objectSpread({}, (0, _absoluteCenter.absoluteCenter)())
  };
};
var FallbackVisualization = exports.FallbackVisualization = (0, _styles.withStyles)(styles, {
  name: 'FallbackVisualization'
})(function (_ref) {
  var imageSrc = _ref.imageSrc,
    classes = _ref.classes,
    fallbackMode = _ref.fallbackMode,
    children = _ref.children,
    showContent = _ref.showContent,
    ProgressComponent = _ref.ProgressComponent;
  return fallbackMode ? /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.root
  }, imageSrc && /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.imageWrapper
  }, /*#__PURE__*/_react["default"].createElement(_ImageLoader.ImageLoader, {
    src: imageSrc,
    ProgressComponent: ProgressComponent,
    fallbackElement: /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
      variant: "body1",
      className: classes.fallbackText
    }, (0, _i18n.T)('visualization.errors.visualizationNotPossible'))
  })), showContent && /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.contentWrapper
  }, children)) : children;
});
FallbackVisualization.propTypes = {
  imageSrc: _propTypes["default"].string.isRequired,
  fallbackMode: _propTypes["default"].bool.isRequired,
  showContent: _propTypes["default"].bool,
  ProgressComponent: _ReactComponent["default"]
};
FallbackVisualization.defaultProps = {
  showContent: true,
  ProgressComponent: function ProgressComponent() {
    return null;
  }
};