'use strict';

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

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 _class, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _formatMessage = require('format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _View = require('@instructure/ui-layout/lib/components/View');

var _View2 = _interopRequireDefault(_View);

var _Tray = require('@instructure/ui-overlays/lib/components/Tray');

var _Tray2 = _interopRequireDefault(_Tray);

var _CloseButton = require('@instructure/ui-buttons/lib/components/CloseButton');

var _CloseButton2 = _interopRequireDefault(_CloseButton);

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

var ModerateTray = (_temp2 = _class = function (_Component) {
  (0, _inherits3.default)(ModerateTray, _Component);

  function ModerateTray() {
    var _ref;

    var _temp, _this, _ret;

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

    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 = ModerateTray.__proto__ || Object.getPrototypeOf(ModerateTray)).call.apply(_ref, [this].concat(args))), _this), _this.onClose = function () {
      _this.props.onClose();
      _this.props.onTrayClosed();
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(ModerateTray, [{
    key: 'labelText',
    value: function labelText() {
      if (this.props.participantName) {
        return '\u5BA1\u6838' + this.props.participantName;
      }

      return '\u8C03\u6574';
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        _Tray2.default,
        {
          label: this.labelText(),
          onClose: this.onClose,
          onDismiss: this.props.closeTray,
          open: this.props.isOpen,
          placement: 'end'
        },
        _react2.default.createElement(
          _CloseButton2.default,
          {
            placement: 'start',
            offset: 'x-small',
            variant: 'icon',
            onClick: this.props.closeTray
          },
          '\u5173\u95ED'
        ),
        _react2.default.createElement(
          _View2.default,
          { as: 'div', padding: 'medium' },
          _react2.default.createElement(
            'h2',
            null,
            this.labelText()
          ),
          this.props.children
        )
      );
    }
  }]);
  ModerateTray.displayName = 'ModerateTray'
  ;
  return ModerateTray;
}(_react.Component), _class.propTypes = {
  children: _react.PropTypes.node.isRequired,
  closeTray: _react.PropTypes.func.isRequired,
  isOpen: _react.PropTypes.bool.isRequired,
  onTrayClosed: _react.PropTypes.func,
  onClose: _react.PropTypes.func,
  participantName: _react.PropTypes.string
}, _class.defaultProps = {
  onTrayClosed: function onTrayClosed() {},
  participantName: null
}, _temp2);
exports.default = ModerateTray;