"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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 _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames3 = _interopRequireDefault(require("classnames"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'cSfbM',
  template: function template(theme) {
    return "\n\n.quiz-core__DragAndDropZone--DnDZone { \n  border: ".concat(theme.DnDZoneBorderWidth || 'inherit', " dashed ").concat(theme.DnDZoneBorderColor || 'inherit', ";\n  background-color: ").concat(theme.DnDZoneBackgroundColor || 'inherit', ";\n  padding: ").concat(theme.DnDZonePadding || 'inherit', ";\n  display: flex;\n  justify-content: center;\n  width: 100%;\n}\n\n.quiz-core__DragAndDropZone--sidebarDnDZone {\n  border: ").concat(theme.sidebarDnDZoneBorderWidth || 'inherit', " dashed ").concat(theme.sidebarDnDZoneBorderColor || 'inherit', ";\n  background-color: ").concat(theme.sidebarDnDZoneBackgroundColor || 'inherit', ";\n  padding: ").concat(theme.sidebarDnDZonePadding || 'inherit', ";\n  margin: ").concat(theme.sidebarDnDZoneMargin || 'inherit', ";\n  color: ").concat(theme.sidebarDnDZoneColor || 'inherit', ";\n  justify-content: center;\n  text-align: center;\n  width: 100%;\n}\n\n[dir=\"ltr\"] .quiz-core__DragAndDropZone--sidebarDnDZone {\n  text-align: center;\n}\n\n[dir=\"rtl\"] .quiz-core__DragAndDropZone--sidebarDnDZone {\n  text-align: center;\n}\n\n.quiz-core__DragAndDropZone--sidebarDnDZone.quiz-core__DragAndDropZone--inSidebarStimulus {\n  margin-left: 10%;\n  width: 90%;\n}\n\n.quiz-core__DragAndDropZone--wrapper {\n  justify-content: center;\n  display: flex;\n  flex: 1 0 100%;\n  width: 100%;\n}\n\n.quiz-core__DragAndDropZone--hide {\n  display: none;\n  width: 100%;\n}\n");
  },
  'DnDZone': 'quiz-core__DragAndDropZone--DnDZone',
  'sidebarDnDZone': 'quiz-core__DragAndDropZone--sidebarDnDZone',
  'inSidebarStimulus': 'quiz-core__DragAndDropZone--inSidebarStimulus',
  'wrapper': 'quiz-core__DragAndDropZone--wrapper',
  'hide': 'quiz-core__DragAndDropZone--hide'
};
var DragAndDropZone = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(DragAndDropZone, _Component);

  function DragAndDropZone() {
    (0, _classCallCheck2.default)(this, DragAndDropZone);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(DragAndDropZone).apply(this, arguments));
  }

  (0, _createClass2.default)(DragAndDropZone, [{
    key: "shouldRender",
    value: function shouldRender() {
      var _this$props = this.props,
          inSidebar = _this$props.inSidebar,
          sidebarOpen = _this$props.sidebarOpen,
          inStimulus = _this$props.inStimulus,
          location = _this$props.location,
          draggingOver = _this$props.draggingOver,
          draggingAboveHalf = _this$props.draggingAboveHalf,
          dropIntoEmptyStimulus = _this$props.dropIntoEmptyStimulus;

      if (inSidebar && !sidebarOpen) {
        return false;
      }

      if (inStimulus) {
        if (location === 'above') {
          return draggingOver && draggingAboveHalf && !dropIntoEmptyStimulus;
        } else if (location === 'below') {
          return draggingOver && !draggingAboveHalf && !dropIntoEmptyStimulus;
        } else if (location === 'in') {
          return draggingOver && dropIntoEmptyStimulus;
        }
      } else if (location === 'above') {
        return draggingOver && draggingAboveHalf;
      } else if (location === 'below') {
        return draggingOver && !draggingAboveHalf;
      }

      return false;
    }
  }, {
    key: "render",
    value: function render() {
      var _classnames;

      var _this$props2 = this.props,
          inSidebar = _this$props2.inSidebar,
          inStimulus = _this$props2.inStimulus;
      var style = (0, _classnames3.default)((_classnames = {}, (0, _defineProperty2.default)(_classnames, styles.DnDZone, !inSidebar), (0, _defineProperty2.default)(_classnames, styles.sidebarDnDZone, inSidebar), (0, _defineProperty2.default)(_classnames, styles.inSidebarStimulus, inSidebar && inStimulus), _classnames));
      var wrapper = (0, _classnames3.default)(styles.wrapper, (0, _defineProperty2.default)({}, styles.hide, !this.shouldRender()));
      return _react.default.createElement("div", {
        className: wrapper
      }, _react.default.createElement("div", {
        className: style
      }, "Arrastar pergunta aqui"));
    }
  }]);
  DragAndDropZone.displayName = "DragAndDropZone";
  return DragAndDropZone;
}(_react.Component), _class2.propTypes = {
  draggingAboveHalf: _propTypes.default.bool.isRequired,
  draggingOver: _propTypes.default.bool.isRequired,
  dropIntoEmptyStimulus: _propTypes.default.bool,
  inSidebar: _propTypes.default.bool,
  inStimulus: _propTypes.default.bool,
  location: _propTypes.default.oneOf(['above', 'below', 'in']).isRequired,
  sidebarOpen: _propTypes.default.bool
}, _class2.defaultProps = {
  draggingAboveHalf: false,
  draggingOver: false,
  dropIntoEmptyStimulus: false,
  inSidebar: false,
  inStimulus: false,
  sidebarOpen: true
}, _temp)) || _class);
exports.default = DragAndDropZone;