"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 _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var tmpResolve;
var tmpReject;

/**
 * Creates a promise where resolve can be manually executed
 */
var ManualPromise = /*#__PURE__*/function (_Promise) {
  function ManualPromise(value) {
    var _this;
    (0, _classCallCheck2.default)(this, ManualPromise);
    _this = _callSuper(this, ManualPromise, [function (resolve, reject) {
      tmpResolve = resolve;
      tmpReject = reject;
    }]);
    (0, _defineProperty2.default)(_this, "_resolve", function () {});
    (0, _defineProperty2.default)(_this, "_reject", function () {});
    _this.value = value;
    _this._resolve = tmpResolve;
    _this._reject = tmpReject;
    return _this;
  }
  (0, _inherits2.default)(ManualPromise, _Promise);
  return (0, _createClass2.default)(ManualPromise, [{
    key: "resolve",
    value: function resolve(value) {
      this._resolve(value !== null && value !== void 0 ? value : this.value);
      return this;
    }
  }, {
    key: "reject",
    value: function reject(err) {
      this._reject(err !== null && err !== void 0 ? err : new Error('Manually rejected'));
      return this;
    }
  }, {
    key: Symbol.toStringTag,
    get: function get() {
      return 'ManualPromise';
    }
  }], [{
    key: Symbol.species,
    get: function get() {
      return Promise;
    }
  }]);
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Promise));
var _default = exports.default = ManualPromise;