'use strict';

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

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _IconPlus = require('@instructure/ui-icons/lib/Line/IconPlus');

var _IconPlus2 = _interopRequireDefault(_IconPlus);

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

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

var _lib2 = _interopRequireDefault(_lib);

var _formatMessage = require('@instructure/quiz-common/lib/format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.Button__styles__newItemButton {\n  border: none;\n  margin: ' + theme.newItemButtonMargin + ';\n  padding: ' + theme.newItemButtonPadding + ';\n  background-color: ' + theme.newItemButtonBackgroundColor + ';\n  border-radius: ' + theme.newItemButtonBorderRadius + ';\n  line-height: 0;\n  font-size: ' + theme.newItemButtonFontSize + ';\n  font-weight: ' + theme.newItemButtonFontWeight + ';\n  text-align: center;\n  color: ' + theme.newItemButtonColor + ';\n  box-shadow: ' + theme.newItemButtonBoxShadow + ';\n  transform: rotate(0deg);\n  transition: background-color 500ms linear, transform 500ms ease;\n  z-index: ' + theme.newItemButtonZIndex + ';\n}\n\n[dir="ltr"] .Button__styles__newItemButton {\n  text-align: center;\n}\n\n[dir="rtl"] .Button__styles__newItemButton {\n  text-align: center;\n}\n\n.Button__styles__newItemButton:focus {\n  outline: ' + theme.newItemButtonFocusOutline + ';\n}\n\n.Button__styles__newItemButton.Button__styles__newItemButtonEditing {\n  background-color: ' + theme.newItemButtonEditingBackgroundColor + ';\n  transform: rotate(45deg);\n  transition: background-color 500ms linear, transform 500ms ease;\n}\n\n.Button__styles__newItemButtonHolder {\n  display: flex;\n  justify-content: center;\n  width: 100%;\n  z-index: ' + theme.newItemButtonHolderZIndex + ';\n  margin-top: -1.5rem;\n}\n\n.Button__styles__attachQuestionButtonHolder {\n  display: flex;\n  justify-content: center;\n  width: 100%;\n  z-index: ' + theme.attachQuestionButtonHolderZIndex + ';\n}\n';
  },
  'newItemButton': 'Button__styles__newItemButton',
  'newItemButtonEditing': 'Button__styles__newItemButtonEditing',
  'newItemButtonHolder': 'Button__styles__newItemButtonHolder',
  'attachQuestionButtonHolder': 'Button__styles__attachQuestionButtonHolder'
};
var AddContentButton = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp2 = _class2 = function (_Component) {
  (0, _inherits3.default)(AddContentButton, _Component);

  function AddContentButton() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, AddContentButton);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = AddContentButton.__proto__ || Object.getPrototypeOf(AddContentButton)).call.apply(_ref, [this].concat(args))), _this), _this.storeButtonElemRef = function (c) {
      _this.buttonElem = c;
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(AddContentButton, [{
    key: 'focus',
    value: function focus() {
      this.buttonElem.focus();
    }
  }, {
    key: 'renderStimulus',
    value: function renderStimulus() {
      return _react2.default.createElement(
        'div',
        { className: styles.attachQuestionButtonHolder },
        _react2.default.createElement(
          _Button2.default,
          {
            ref: this.storeButtonElemRef,
            variant: 'primary',
            margin: 'medium',
            onClick: this.props.onClick,
            'data-automation': 'sdk-attach-question-button'
          },
          'Legg ved sp\xF8rsm\xE5l'
        )
      );
    }
  }, {
    key: 'renderNonStimulus',
    value: function renderNonStimulus() {
      var _classNames;

      var buttonClasses = (0, _classnames2.default)((_classNames = {}, (0, _defineProperty3.default)(_classNames, styles.newItemButton, true), (0, _defineProperty3.default)(_classNames, 'newItemButton_' + this.props.position, true), (0, _defineProperty3.default)(_classNames, styles.newItemButtonEditing, this.props.isEditing), _classNames));
      return _react2.default.createElement(
        'div',
        { className: styles.newItemButtonHolder },
        _react2.default.createElement(
          'button',
          {
            ref: this.storeButtonElemRef,
            onClick: this.props.onClick,
            className: buttonClasses,
            'data-automation': 'sdk-add-content-button'
          },
          _react2.default.createElement(_IconPlus2.default, { title: 'Legg til innhold' })
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      return this.props.useStimulusTrigger ? this.renderStimulus() : this.renderNonStimulus();
    }
  }]);
  AddContentButton.displayName = 'AddContentButton'
  ;
  return AddContentButton;
}(_react.Component), _class2.propTypes = {
  isEditing: _propTypes2.default.bool.isRequired,
  onClick: _propTypes2.default.func,
  position: _propTypes2.default.number.isRequired,
  useStimulusTrigger: _propTypes2.default.bool.isRequired
}, _class2.defaultProps = {
  onClick: function onClick() {}
}, _temp2)) || _class);
exports.default = AddContentButton;