'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.SDKSettings = 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 _dec, _class, _class2, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Heading = require('@instructure/ui-elements/lib/components/Heading');

var _Heading2 = _interopRequireDefault(_Heading);

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

var _lib2 = _interopRequireDefault(_lib);

var _IfFeature = require('../../../../common/components/shared/IfFeature');

var _IfFeature2 = _interopRequireDefault(_IfFeature);

var _Page = require('../../../../common/components/layout/Page');

var _Page2 = _interopRequireDefault(_Page);

var _formatMessage = require('../../../../common/format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _IpFilter = require('./components/IpFilter');

var _IpFilter2 = _interopRequireDefault(_IpFilter);

var _OneQuestionAtATime = require('./components/OneQuestionAtATime');

var _OneQuestionAtATime2 = _interopRequireDefault(_OneQuestionAtATime);

var _ShuffleQuestions = require('./components/ShuffleQuestions');

var _ShuffleQuestions2 = _interopRequireDefault(_ShuffleQuestions);

var _StudentAccessCode = require('./components/StudentAccessCode');

var _StudentAccessCode2 = _interopRequireDefault(_StudentAccessCode);

var _Timer = require('./components/Timer');

var _Timer2 = _interopRequireDefault(_Timer);

var _Calculator = require('./components/Calculator');

var _Calculator2 = _interopRequireDefault(_Calculator);

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.Settings__styles__detailsWrapper {\n  margin-left: 4.2rem;\n  padding-top: ' + theme.detailsWrapperTopPadding + ';\n}\n\n.Settings__styles__page {\n  padding: ' + theme.pageTopPadding + ' ' + theme.pagePadding + ' ' + theme.pagePadding + ';\n}\n\n.Settings__styles__list {\n  list-style: none;\n  margin: ' + theme.listTopMargin + ' 0 0 0;\n  padding: 0;\n}\n\n.Settings__styles__listItem {\n  border: ' + theme.listItemBorderWidth + ' solid ' + theme.listItemBorderColor + ';\n  border-left: 0 none;\n  border-right: 0 none;\n  margin: 0;\n  padding: ' + theme.listItemPadding + ';\n}\n\n.Settings__styles__setTimeLabel {\n  display: block;\n}\n';
  },
  'detailsWrapper': 'Settings__styles__detailsWrapper',
  'page': 'Settings__styles__page',
  'list': 'Settings__styles__list',
  'listItem': 'Settings__styles__listItem',
  'setTimeLabel': 'Settings__styles__setTimeLabel'
};

// These are used in a <ul> below, so need keys

var SDKSettings = exports.SDKSettings = [_react2.default.createElement(_ShuffleQuestions2.default, { key: 'shuffle_setting' }), _react2.default.createElement(_OneQuestionAtATime2.default, { key: 'oqaat_setting' }), _react2.default.createElement(_StudentAccessCode2.default, { key: 'accesscode_setting' }), _react2.default.createElement(_Timer2.default, { key: 'timer_setting' }), _react2.default.createElement(
  _IfFeature2.default,
  { name: 'ip_filtering', key: 'ipfilter_setting' },
  _react2.default.createElement(_IpFilter2.default, null)
), _react2.default.createElement(
  _IfFeature2.default,
  { name: 'on_screen_calculator', key: 'calculator_setting' },
  _react2.default.createElement(_Calculator2.default, null)
)];

var Settings = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(Settings, _Component);

  function Settings() {
    (0, _classCallCheck3.default)(this, Settings);
    return (0, _possibleConstructorReturn3.default)(this, (Settings.__proto__ || Object.getPrototypeOf(Settings)).apply(this, arguments));
  }

  (0, _createClass3.default)(Settings, [{
    key: 'componentDidMount',
    value: function componentDidMount() {
      var activeQuizId = this.props.activeQuizId;

      this.props.quizBuildingSession({ activeQuizId: activeQuizId });
    }
  }, {
    key: 'componentWillUpdate',
    value: function componentWillUpdate(nextProps) {
      var activeQuizId = nextProps.activeQuizId;

      if (this.props.activeQuizId !== activeQuizId) {
        this.props.quizBuildingSession({ activeQuizId: activeQuizId });
      }
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        _Page2.default,
        null,
        _react2.default.createElement(
          'div',
          { className: styles.page },
          _react2.default.createElement(
            _Heading2.default,
            { level: 'h1' },
            'Leveringsindstillinger'
          ),
          _react2.default.createElement(
            'ul',
            { className: styles.list },
            this.props.children
          )
        )
      );
    }
  }]);
  Settings.displayName = 'Settings'
  ;
  return Settings;
}(_react.Component), _class2.propTypes = {
  activeQuizId: _propTypes2.default.string.isRequired,
  children: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.node), _propTypes2.default.node]),
  quizBuildingSession: _propTypes2.default.func.isRequired
}, _class2.defaultProps = {
  children: SDKSettings
}, _temp)) || _class);
exports.default = Settings;