'use strict';

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

var _RichContentInput = require('../components/RichContentInput');

var _RichContentInput2 = _interopRequireDefault(_RichContentInput);

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

var _formatMessage2 = _interopRequireDefault(_formatMessage);

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

var propsForInteractionEdit = exports.propsForInteractionEdit = function propsForInteractionEdit(props, additionalOptions) {
  var item = props.workingItem.toJS();
  var changeItemState = function changeItemState(newState) {
    props.changeItemState(item.id, newState);
  };

  var mediaUpload = function mediaUpload(file, callback) {
    var onUploadError = function onUploadError() {
      props.addError('\u4E0A\u4F20\u60A8\u7684\u6587\u4EF6\u65F6\u51FA\u9519\u3002');
    };

    props.interactionFileUpload(props.parentType, props.parentId, file, callback, onUploadError);
  };

  var onModalOpen = function onModalOpen() {
    props.occludeQuizEntries(true);
  };

  var onModalClose = function onModalClose() {
    props.occludeQuizEntries(false);
  };

  return {
    additionalOptions: additionalOptions,
    appContainer: props.appContainer,
    changeItemState: changeItemState,
    errors: props.workingItem.getErrors().toJS(),
    errorsAreShowing: props.errorsAreShowing,
    interactionData: item.interactionData,
    // SHIM: canvas-rce breaks on null values now
    // this is a shim until canvas-rce deals with
    // null values better
    itemBody: item.itemBody || '',
    itemId: item.id,
    mediaUpload: mediaUpload,
    notifyScreenreader: props.screenreaderNotification,
    onModalOpen: onModalOpen,
    onModalClose: onModalClose,
    openImportModal: props.openImportModal,
    pointsChange: props.handleQuizEntryPointsChange,
    properties: item.properties,
    override: props.override,
    overrideEditableForItem: props.overrideEditableForItem,
    overrideEditableForRegrading: props.overrideEditableForRegrading,
    richContentEditor: _RichContentInput2.default,
    scoringData: item.scoringData,
    stemErrors: props.workingItem.errorsFor('itemBody').toJS(),
    initialFocusId: props.initialFocusId
  };
};

var propsForInteractionShow = exports.propsForInteractionShow = function propsForInteractionShow(item) {
  return {
    itemId: item.id,
    interactionData: item.interactionData,
    // SHIM: canvas-rce breaks on null values now
    // this is a shim until canvas-rce deals with
    // null values better
    itemBody: item.itemBody || '',
    properties: item.properties,
    notifyScreenreader: true,
    scoringData: item.scoringData
  };
};