"use strict";

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

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

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

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

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

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

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

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

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

var _reactDom = _interopRequireDefault(require("react-dom"));

var _piePlayerEvents = require("@pie-framework/pie-player-events");

var _main = _interopRequireDefault(require("./main"));

var _mathRendering = require("@pie-lib/math-rendering");

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var MultiTraitRubric = /*#__PURE__*/function (_HTMLElement) {
  (0, _inherits2["default"])(MultiTraitRubric, _HTMLElement);

  var _super = _createSuper(MultiTraitRubric);

  function MultiTraitRubric() {
    var _this;

    (0, _classCallCheck2["default"])(this, MultiTraitRubric);
    _this = _super.call(this);
    _this._model = {};
    _this._session = null;
    return _this;
  }

  (0, _createClass2["default"])(MultiTraitRubric, [{
    key: "model",
    set: function set(s) {
      this._model = s;
      this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), this._session, !!this._model));

      this._render();
    }
  }, {
    key: "session",
    get: function get() {
      return this._session;
    },
    set: function set(s) {
      this._session = s;
    }
  }, {
    key: "connectedCallback",
    value: function connectedCallback() {
      this._render();
    }
  }, {
    key: "_render",
    value: function _render() {
      var _this2 = this;

      var el = /*#__PURE__*/_react["default"].createElement(_main["default"], {
        model: this._model,
        session: this._session
      });

      _reactDom["default"].render(el, this, function () {
        (0, _mathRendering.renderMath)(_this2);
      });
    }
  }]);
  return MultiTraitRubric;
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));

exports["default"] = MultiTraitRubric;
//# sourceMappingURL=index.js.map