"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Content = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireWildcard(require("react"));
var _cross = _interopRequireDefault(require("@atlaskit/icon/core/migration/cross"));
var _mediaUi = require("@atlaskit/media-ui");
var _styleWrappers = require("./styleWrappers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var Content = exports.Content = /*#__PURE__*/function (_Component) {
  function Content() {
    (0, _classCallCheck2.default)(this, Content);
    return _callSuper(this, Content, arguments);
  }
  (0, _inherits2.default)(Content, _Component);
  return (0, _createClass2.default)(Content, [{
    key: "render",
    value:
    /*
     * Here we get called by InactivityDetector and given a function we
     * pass down as "showControls" to out children.
     */
    function render() {
      var _this = this;
      var _this$props = this.props,
        onClose = _this$props.onClose,
        isSidebarVisible = _this$props.isSidebarVisible;
      return /*#__PURE__*/_react.default.createElement(_styleWrappers.ContentWrapper, {
        isSidebarVisible: isSidebarVisible
      }, /*#__PURE__*/_react.default.createElement(_mediaUi.InactivityDetector, null, function (triggerActivityCallback) {
        var children = /*#__PURE__*/_react.default.cloneElement(_this.props.children, {
          showControls: triggerActivityCallback
        });
        return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styleWrappers.CloseButtonWrapper, {
          className: _mediaUi.hideControlsClassName
        }, /*#__PURE__*/_react.default.createElement(_mediaUi.MediaButton, {
          testId: "media-viewer-close-button",
          onClick: onClose,
          iconBefore: /*#__PURE__*/_react.default.createElement(_cross.default, {
            color: "currentColor",
            spacing: "spacious",
            label: "Close"
          })
        })), children);
      }));
    }
  }]);
}(_react.Component);