'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
var _regeneratorRuntime = require('@babel/runtime/regenerator');
var tslib_es6 = require('../../tslib.es6-0d92ef81.js');
var pixui_aegis_core = require('./core.js');
require('../env.js');
require('../gamelet.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);

var AegisReportInPixui = /*#__PURE__*/function () {
  function AegisReportInPixui() {
    _classCallCheck__default["default"](this, AegisReportInPixui);
  }
  return _createClass__default["default"](AegisReportInPixui, null, [{
    key: "init",
    value: function init(options) {
      return tslib_es6.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
        var aegis;
        return _regeneratorRuntime__default["default"].wrap(function (_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              if (!this.aegis) {
                _context.next = 1;
                break;
              }
              return _context.abrupt("return", this.aegis);
            case 1:
              this.options = options;
              _context.prev = 2;
              _context.next = 3;
              return pixui_aegis_core.initAegis(options);
            case 3:
              aegis = _context.sent;
              _context.next = 5;
              break;
            case 4:
              _context.prev = 4;
              _context["catch"](2);
            case 5:
              if (aegis) {
                this.aegis = aegis;
              }
              return _context.abrupt("return", aegis);
            case 6:
            case "end":
              return _context.stop();
          }
        }, _callee, this, [[2, 4]]);
      }));
    }
  }, {
    key: "report",
    value: function report(info) {
      var _a;
      return tslib_es6.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
        var aegis;
        return _regeneratorRuntime__default["default"].wrap(function (_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              _context2.prev = 0;
              _context2.next = 1;
              return this.init(this.options);
            case 1:
              aegis = _context2.sent;
              _context2.next = 2;
              return (_a = aegis.report) === null || _a === void 0 ? void 0 : _a.call(aegis, Object.assign({}, info));
            case 2:
              _context2.next = 4;
              break;
            case 3:
              _context2.prev = 3;
              _context2["catch"](0);
            case 4:
            case "end":
              return _context2.stop();
          }
        }, _callee2, this, [[0, 3]]);
      }));
    }
  }, {
    key: "info",
    value: function info(_info) {
      var _a;
      return tslib_es6.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
        var aegis;
        return _regeneratorRuntime__default["default"].wrap(function (_context3) {
          while (1) switch (_context3.prev = _context3.next) {
            case 0:
              _context3.prev = 0;
              _context3.next = 1;
              return this.init(this.options);
            case 1:
              aegis = _context3.sent;
              _context3.next = 2;
              return (_a = aegis.info) === null || _a === void 0 ? void 0 : _a.call(aegis, Object.assign({}, _info));
            case 2:
              _context3.next = 4;
              break;
            case 3:
              _context3.prev = 3;
              _context3["catch"](0);
            case 4:
            case "end":
              return _context3.stop();
          }
        }, _callee3, this, [[0, 3]]);
      }));
    }
  }]);
}();

exports.AegisReportInPixui = AegisReportInPixui;
