"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _teselagenReactComponents = require("teselagen-react-components");
var _reduxForm = require("redux-form");
var _withEditorProps = _interopRequireDefault(require("../../withEditorProps"));
var _recompose = require("recompose");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var GeneralProperties = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(GeneralProperties, _React$Component);
  function GeneralProperties() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    _defineProperty(_assertThisInitialized(_this), "updateSeqDesc", function (val) {
      return _this.props.sequenceDescriptionUpdate(val);
    });
    return _this;
  }
  var _proto = GeneralProperties.prototype;
  _proto.render = function render() {
    var _this$props = this.props,
      readOnly = _this$props.readOnly,
      _this$props$showReadO = _this$props.showReadOnly,
      showReadOnly = _this$props$showReadO === void 0 ? true : _this$props$showReadO,
      updateCircular = _this$props.updateCircular,
      isProtein = _this$props.isProtein,
      disableSetReadOnly = _this$props.disableSetReadOnly,
      updateAvailability = _this$props.updateAvailability,
      sequenceData = _this$props.sequenceData,
      updateReadOnlyMode = _this$props.updateReadOnlyMode,
      onSave = _this$props.onSave,
      showAvailability = _this$props.showAvailability,
      sequenceNameUpdate = _this$props.sequenceNameUpdate;
    var _ref = sequenceData || {},
      description = _ref.description,
      name = _ref.name,
      isOligo = _ref.isOligo,
      isRna = _ref.isRna,
      _ref$sequence = _ref.sequence,
      sequence = _ref$sequence === void 0 ? "" : _ref$sequence,
      _ref$proteinSequence = _ref.proteinSequence,
      proteinSequence = _ref$proteinSequence === void 0 ? "" : _ref$proteinSequence,
      circular = _ref.circular,
      materiallyAvailable = _ref.materiallyAvailable;
    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-flex-row"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-left bp3-label"
    }, "\u540D\u79F0"), " ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-right"
    }, /*#__PURE__*/_react["default"].createElement(_teselagenReactComponents.InputField, {
      disabled: readOnly,
      onFieldSubmit: function onFieldSubmit(val) {
        sequenceNameUpdate(val);
      },
      name: "name",
      enableReinitialize: true,
      defaultValue: name
    }), " ")), !isProtein && !isOligo && !isRna && /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-flex-row circularLinearSelect"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-left bp3-label"
    }, "\u73AF\u5F62/\u7EBF\u5F62"), " ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-right"
    }, " ", /*#__PURE__*/_react["default"].createElement(_teselagenReactComponents.BPSelect, {
      disabled: readOnly,
      onChange: function onChange(val) {
        updateCircular(val === "circular");
      },
      value: circular ? "circular" : "linear",
      options: [{
        label: "环形",
        value: "circular"
      }, {
        label: "线形",
        value: "linear"
      }]
    }))), showAvailability && /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-flex-row"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-left bp3-label"
    }, "Material Availability"), " ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-right"
    }, " ", /*#__PURE__*/_react["default"].createElement(_teselagenReactComponents.BPSelect, {
      disabled: readOnly,
      onChange: function onChange(val) {
        updateAvailability(val === "available");
      },
      value: materiallyAvailable ? "available" : "unavailable",
      options: [{
        label: "Available",
        value: "available"
      }, {
        label: "Unavailable",
        value: "unavailable"
      }]
    }))), /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-flex-row"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-left bp3-label"
    }, "\u957F\u5EA6"), " ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-right"
    }, " ", isProtein ? proteinSequence.length : sequence.length)), showReadOnly && /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-flex-row"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-left bp3-label"
    }, "\u53EF\u7F16\u8F91"), " ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "ve-column-right"
    }, " ", /*#__PURE__*/_react["default"].createElement(_teselagenReactComponents.BPSelect, {
      disabled: !onSave || disableSetReadOnly,
      onChange: function onChange(val) {
        updateReadOnlyMode(val === "readOnly");
      },
      value: readOnly ? "readOnly" : "editable",
      options: [{
        label: "只读",
        value: "readOnly"
      }, {
        label: "可编辑",
        value: "editable"
      }]
    }))), /*#__PURE__*/_react["default"].createElement("div", null, "\u63CF\u8FF0"), /*#__PURE__*/_react["default"].createElement(_teselagenReactComponents.TextareaField, {
      clickToEdit: true,
      name: "description",
      onFieldSubmit: this.updateSeqDesc,
      defaultValue: description,
      disabled: readOnly
    }));
  };
  return GeneralProperties;
}(_react["default"].Component);
var _default = (0, _recompose.compose)(_withEditorProps["default"], (0, _reduxForm.reduxForm)({
  form: "GeneralProperties"
}))(GeneralProperties);
exports["default"] = _default;
module.exports = exports.default;