"use strict";

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

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

var _react = _interopRequireDefault(require("react"));

var _dropdown = _interopRequireDefault(require("./components/dropdown"));

var _withMask = require("./with-mask");

// eslint-disable-next-line react/display-name
var _default = (0, _withMask.withMask)('dropdown', function (props) {
  return function (node, data, onChange) {
    var dataset = node.data ? node.data.dataset || {} : {};

    if (dataset.component === 'dropdown') {
      // eslint-disable-next-line react/prop-types
      var choices = props.choices,
          disabled = props.disabled,
          feedback = props.feedback,
          showCorrectAnswer = props.showCorrectAnswer;
      var correctAnswer = choices && choices[dataset.id] && choices[dataset.id].find(function (c) {
        return c.correct;
      });
      var finalChoice = showCorrectAnswer ? correctAnswer && correctAnswer.value : data[dataset.id];
      return /*#__PURE__*/_react["default"].createElement(_dropdown["default"], {
        key: "".concat(node.type, "-dropdown-").concat(dataset.id),
        correct: feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct',
        disabled: disabled || showCorrectAnswer,
        value: finalChoice,
        id: dataset.id,
        onChange: onChange,
        choices: choices[dataset.id],
        showCorrectAnswer: showCorrectAnswer
      });
    }
  };
});

exports["default"] = _default;
//# sourceMappingURL=inline-dropdown.js.map