Socket
Socket
Sign inDemoInstall

@twilio/operation-retrier

Package Overview
Dependencies
3
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.3 to 4.0.4-rc.0

9

CHANGELOG.md

@@ -6,2 +6,11 @@ # Change Log

### [4.0.4-rc.0](https://github.com/twilio/operation-retrier.ts/compare/@twilio/operation-retrier@4.0.3...@twilio/operation-retrier@4.0.4-rc.0) (2021-07-29)
### Bug Fixes
* Add missing browserslist ([173b2cd](https://github.com/twilio/operation-retrier.ts/commit/173b2cdf5c71b3585c6843a6a0852d5839b69ef0))
### [4.0.3](https://github.com/twilio/operation-retrier.ts/compare/@twilio/operation-retrier@4.0.3-rc.0...@twilio/operation-retrier@4.0.3) (2021-07-19)

@@ -8,0 +17,0 @@

453

dist/browser.js

@@ -22,3 +22,11 @@ /*

require('core-js/modules/es.reflect.construct.js');
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
var _inherits = require('@babel/runtime/helpers/inherits');
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/es.promise.js');

@@ -28,2 +36,8 @@

var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

@@ -503,2 +517,5 @@

function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
function _isNativeReflectConstruct$1() { 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; } }
/**

@@ -508,3 +525,7 @@ * Provides retrier service

class Retrier extends EventEmitter {
var Retrier = /*#__PURE__*/function (_EventEmitter) {
_inherits__default['default'](Retrier, _EventEmitter);
var _super = _createSuper$1(Retrier);
// fibonacci strategy

@@ -515,130 +536,151 @@

*/
constructor(options) {
super();
function Retrier(options) {
var _this;
_defineProperty__default['default'](this, "timeout", null);
_classCallCheck__default['default'](this, Retrier);
_defineProperty__default['default'](this, "startTimestamp", -1);
_this = _super.call(this);
this.minDelay = options.min;
this.maxDelay = options.max;
this.initialDelay = options.initial || 0;
this.maxAttemptsCount = options.maxAttemptsCount || 0;
this.maxAttemptsTime = options.maxAttemptsTime || 0;
this.randomness = options.randomness || 0;
this.inProgress = false;
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "timeout", null);
attempt() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "startTimestamp", -1);
this.attemptNum++;
this.emit("attempt", this);
_this.minDelay = options.min;
_this.maxDelay = options.max;
_this.initialDelay = options.initial || 0;
_this.maxAttemptsCount = options.maxAttemptsCount || 0;
_this.maxAttemptsTime = options.maxAttemptsTime || 0;
_this.randomness = options.randomness || 0;
_this.inProgress = false;
_this.attemptNum = 0;
_this.prevDelay = 0;
_this.currDelay = 0;
return _this;
}
nextDelay(delayOverride) {
if (typeof delayOverride === "number") {
this.prevDelay = 0;
this.currDelay = delayOverride;
return delayOverride;
}
_createClass__default['default'](Retrier, [{
key: "attempt",
value: function attempt() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.attemptNum == 0) {
return this.initialDelay;
this.attemptNum++;
this.emit("attempt", this);
}
}, {
key: "nextDelay",
value: function nextDelay(delayOverride) {
if (typeof delayOverride === "number") {
this.prevDelay = 0;
this.currDelay = delayOverride;
return delayOverride;
}
if (this.attemptNum == 1) {
this.currDelay = this.minDelay;
return this.currDelay;
}
if (this.attemptNum == 0) {
return this.initialDelay;
}
this.prevDelay = this.currDelay;
var delay = this.currDelay + this.prevDelay;
if (this.attemptNum == 1) {
this.currDelay = this.minDelay;
return this.currDelay;
}
if (this.maxDelay && delay > this.maxDelay) {
this.currDelay = this.maxDelay;
delay = this.maxDelay;
}
this.prevDelay = this.currDelay;
var delay = this.currDelay + this.prevDelay;
this.currDelay = delay;
return delay;
}
if (this.maxDelay && delay > this.maxDelay) {
this.currDelay = this.maxDelay;
delay = this.maxDelay;
}
randomize(delay) {
var area = delay * this.randomness;
var corr = Math.round(Math.random() * area * 2 - area);
return Math.max(0, delay + corr);
}
scheduleAttempt(delayOverride) {
if (this.maxAttemptsCount && this.attemptNum >= this.maxAttemptsCount) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt count limit reached"));
return;
this.currDelay = delay;
return delay;
}
var delay = this.nextDelay(delayOverride);
delay = this.randomize(delay);
if (this.maxAttemptsTime && this.startTimestamp + this.maxAttemptsTime < Date.now() + delay) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt time limit reached"));
return;
}, {
key: "randomize",
value: function randomize(delay) {
var area = delay * this.randomness;
var corr = Math.round(Math.random() * area * 2 - area);
return Math.max(0, delay + corr);
}
}, {
key: "scheduleAttempt",
value: function scheduleAttempt(delayOverride) {
var _this2 = this;
this.timeout = setTimeout(() => this.attempt(), delay);
}
if (this.maxAttemptsCount && this.attemptNum >= this.maxAttemptsCount) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt count limit reached"));
return;
}
cleanup() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
var delay = this.nextDelay(delayOverride);
delay = this.randomize(delay);
this.inProgress = false;
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
if (this.maxAttemptsTime && this.startTimestamp + this.maxAttemptsTime < Date.now() + delay) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt time limit reached"));
return;
}
start() {
if (this.inProgress) {
throw new Error("Retrier is already in progress");
this.timeout = setTimeout(function () {
return _this2.attempt();
}, delay);
}
}, {
key: "cleanup",
value: function cleanup() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.inProgress = true;
this.startTimestamp = Date.now();
this.scheduleAttempt(this.initialDelay);
}
cancel() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
this.inProgress = false;
this.emit("cancelled");
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
} // @todo Must be a T here, so the entire Retrier must be typed on this value type.
// eslint-disable-next-line
}, {
key: "start",
value: function start() {
if (this.inProgress) {
throw new Error("Retrier is already in progress");
}
this.inProgress = true;
this.startTimestamp = Date.now();
this.scheduleAttempt(this.initialDelay);
}
}, {
key: "cancel",
value: function cancel() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
this.inProgress = false;
this.emit("cancelled");
}
} // @todo Must be a T here, so the entire Retrier must be typed on this value type.
// eslint-disable-next-line
succeeded(arg) {
this.emit("succeeded", arg);
}
}, {
key: "succeeded",
value: function succeeded(arg) {
this.emit("succeeded", arg);
}
}, {
key: "failed",
value: function failed(err, nextAttemptDelayOverride) {
if (this.timeout) {
throw new Error("Retrier attempt is already in progress");
}
failed(err, nextAttemptDelayOverride) {
if (this.timeout) {
throw new Error("Retrier attempt is already in progress");
this.scheduleAttempt(nextAttemptDelayOverride);
}
}]);
this.scheduleAttempt(nextAttemptDelayOverride);
}
}
return Retrier;
}(EventEmitter);
/**

@@ -653,35 +695,70 @@ * Run retrier as an async function with possibility to await for it.

class AsyncRetrier extends EventEmitter {
var AsyncRetrier = /*#__PURE__*/function (_EventEmitter2) {
_inherits__default['default'](AsyncRetrier, _EventEmitter2);
var _super2 = _createSuper$1(AsyncRetrier);
// This any must be T typed directly on the AsyncRetrier
// eslint-disable-next-line
constructor(options) {
super();
function AsyncRetrier(options) {
var _this3;
_defineProperty__default['default'](this, "resolve", () => void 0);
_classCallCheck__default['default'](this, AsyncRetrier);
_defineProperty__default['default'](this, "reject", () => void 0);
_this3 = _super2.call(this);
this.retrier = new Retrier(options);
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this3), "resolve", function () {
return void 0;
});
run(handler) {
this.retrier.on("attempt", () => {
handler().then(v => this.retrier.succeeded(v)).catch(e => this.retrier.failed(e));
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this3), "reject", function () {
return void 0;
});
this.retrier.on("succeeded", arg => this.resolve(arg));
this.retrier.on("cancelled", () => this.reject(new Error("Cancelled")));
this.retrier.on("failed", err => this.reject(err));
return new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.retrier.start();
});
}
cancel() {
this.retrier.cancel();
_this3.retrier = new Retrier(options);
return _this3;
}
}
_createClass__default['default'](AsyncRetrier, [{
key: "run",
value: function run(handler) {
var _this4 = this;
this.retrier.on("attempt", function () {
handler().then(function (v) {
return _this4.retrier.succeeded(v);
}).catch(function (e) {
return _this4.retrier.failed(e);
});
});
this.retrier.on("succeeded", function (arg) {
return _this4.resolve(arg);
});
this.retrier.on("cancelled", function () {
return _this4.reject(new Error("Cancelled"));
});
this.retrier.on("failed", function (err) {
return _this4.reject(err);
});
return new Promise(function (resolve, reject) {
_this4.resolve = resolve;
_this4.reject = reject;
_this4.retrier.start();
});
}
}, {
key: "cancel",
value: function cancel() {
this.retrier.cancel();
}
}]);
return AsyncRetrier;
}(EventEmitter);
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['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; } }
function isDef(value) {

@@ -691,16 +768,24 @@ return value !== undefined && value !== null;

class Backoff extends EventEmitter {
constructor(options) {
super();
var Backoff = /*#__PURE__*/function (_EventEmitter) {
_inherits__default['default'](Backoff, _EventEmitter);
_defineProperty__default['default'](this, "backoffDelay", 0);
var _super = _createSuper(Backoff);
_defineProperty__default['default'](this, "nextBackoffDelay", 0);
function Backoff(options) {
var _this;
_defineProperty__default['default'](this, "backoffNumber", 0);
_classCallCheck__default['default'](this, Backoff);
_defineProperty__default['default'](this, "timeoutID", null);
_this = _super.call(this);
_defineProperty__default['default'](this, "maxNumberOfRetry", -1);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "backoffDelay", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "nextBackoffDelay", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "backoffNumber", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "timeoutID", null);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "maxNumberOfRetry", -1);
options = options || {};

@@ -729,66 +814,78 @@ var _options = options,

this.initialDelay = initialDelay || 100;
this.maxDelay = maxDelay || 10000;
_this.initialDelay = initialDelay || 100;
_this.maxDelay = maxDelay || 10000;
if (this.maxDelay <= this.initialDelay) {
if (_this.maxDelay <= _this.initialDelay) {
throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");
}
this.randomisationFactor = randomisationFactor || 0;
this.factor = factor || 2;
this.reset();
}
_this.randomisationFactor = randomisationFactor || 0;
_this.factor = factor || 2;
static exponential(options) {
return new Backoff(options);
_this.reset();
return _this;
}
backoff(err) {
if (this.timeoutID == null) {
if (this.backoffNumber === this.maxNumberOfRetry) {
this.emit("fail", err);
this.reset();
} else {
this.backoffDelay = this.next();
this.timeoutID = setTimeout(this.onBackoff.bind(this), this.backoffDelay);
this.emit("backoff", this.backoffNumber, this.backoffDelay, err);
_createClass__default['default'](Backoff, [{
key: "backoff",
value: function backoff(err) {
if (this.timeoutID == null) {
if (this.backoffNumber === this.maxNumberOfRetry) {
this.emit("fail", err);
this.reset();
} else {
this.backoffDelay = this.next();
this.timeoutID = setTimeout(this.onBackoff.bind(this), this.backoffDelay);
this.emit("backoff", this.backoffNumber, this.backoffDelay, err);
}
}
}
}
}, {
key: "reset",
value: function reset() {
this.backoffDelay = 0;
this.nextBackoffDelay = this.initialDelay;
this.backoffNumber = 0;
reset() {
this.backoffDelay = 0;
this.nextBackoffDelay = this.initialDelay;
this.backoffNumber = 0;
if (this.timeoutID) {
clearTimeout(this.timeoutID);
}
if (this.timeoutID) {
clearTimeout(this.timeoutID);
this.timeoutID = null;
}
}, {
key: "failAfter",
value: function failAfter(maxNumberOfRetry) {
if (maxNumberOfRetry <= 0) {
throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(maxNumberOfRetry));
}
this.timeoutID = null;
}
failAfter(maxNumberOfRetry) {
if (maxNumberOfRetry <= 0) {
throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(maxNumberOfRetry));
this.maxNumberOfRetry = maxNumberOfRetry;
}
}, {
key: "next",
value: function next() {
this.backoffDelay = Math.min(this.nextBackoffDelay, this.maxDelay);
this.nextBackoffDelay = this.backoffDelay * this.factor;
var randomisationMultiple = 1 + Math.random() * this.randomisationFactor;
return Math.min(this.maxDelay, Math.round(this.backoffDelay * randomisationMultiple));
}
}, {
key: "onBackoff",
value: function onBackoff() {
this.timeoutID = null;
this.emit("ready", this.backoffNumber, this.backoffDelay);
this.backoffNumber++;
}
}], [{
key: "exponential",
value: function exponential(options) {
return new Backoff(options);
}
}]);
this.maxNumberOfRetry = maxNumberOfRetry;
}
return Backoff;
}(EventEmitter);
next() {
this.backoffDelay = Math.min(this.nextBackoffDelay, this.maxDelay);
this.nextBackoffDelay = this.backoffDelay * this.factor;
var randomisationMultiple = 1 + Math.random() * this.randomisationFactor;
return Math.min(this.maxDelay, Math.round(this.backoffDelay * randomisationMultiple));
}
onBackoff() {
this.timeoutID = null;
this.emit("ready", this.backoffNumber, this.backoffDelay);
this.backoffNumber++;
}
}
exports.AsyncRetrier = AsyncRetrier;

@@ -795,0 +892,0 @@ exports.Backoff = Backoff;

@@ -22,3 +22,11 @@ /*

require('core-js/modules/es.reflect.construct.js');
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
var _inherits = require('@babel/runtime/helpers/inherits');
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/es.promise.js');

@@ -29,4 +37,13 @@ var events = require('events');

var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
function _isNativeReflectConstruct$1() { 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; } }
/**

@@ -36,3 +53,7 @@ * Provides retrier service

class Retrier extends events.EventEmitter {
var Retrier = /*#__PURE__*/function (_EventEmitter) {
_inherits__default['default'](Retrier, _EventEmitter);
var _super = _createSuper$1(Retrier);
// fibonacci strategy

@@ -43,130 +64,151 @@

*/
constructor(options) {
super();
function Retrier(options) {
var _this;
_defineProperty__default['default'](this, "timeout", null);
_classCallCheck__default['default'](this, Retrier);
_defineProperty__default['default'](this, "startTimestamp", -1);
_this = _super.call(this);
this.minDelay = options.min;
this.maxDelay = options.max;
this.initialDelay = options.initial || 0;
this.maxAttemptsCount = options.maxAttemptsCount || 0;
this.maxAttemptsTime = options.maxAttemptsTime || 0;
this.randomness = options.randomness || 0;
this.inProgress = false;
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "timeout", null);
attempt() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "startTimestamp", -1);
this.attemptNum++;
this.emit("attempt", this);
_this.minDelay = options.min;
_this.maxDelay = options.max;
_this.initialDelay = options.initial || 0;
_this.maxAttemptsCount = options.maxAttemptsCount || 0;
_this.maxAttemptsTime = options.maxAttemptsTime || 0;
_this.randomness = options.randomness || 0;
_this.inProgress = false;
_this.attemptNum = 0;
_this.prevDelay = 0;
_this.currDelay = 0;
return _this;
}
nextDelay(delayOverride) {
if (typeof delayOverride === "number") {
this.prevDelay = 0;
this.currDelay = delayOverride;
return delayOverride;
}
_createClass__default['default'](Retrier, [{
key: "attempt",
value: function attempt() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
if (this.attemptNum == 0) {
return this.initialDelay;
this.attemptNum++;
this.emit("attempt", this);
}
}, {
key: "nextDelay",
value: function nextDelay(delayOverride) {
if (typeof delayOverride === "number") {
this.prevDelay = 0;
this.currDelay = delayOverride;
return delayOverride;
}
if (this.attemptNum == 1) {
this.currDelay = this.minDelay;
return this.currDelay;
}
if (this.attemptNum == 0) {
return this.initialDelay;
}
this.prevDelay = this.currDelay;
var delay = this.currDelay + this.prevDelay;
if (this.attemptNum == 1) {
this.currDelay = this.minDelay;
return this.currDelay;
}
if (this.maxDelay && delay > this.maxDelay) {
this.currDelay = this.maxDelay;
delay = this.maxDelay;
}
this.prevDelay = this.currDelay;
var delay = this.currDelay + this.prevDelay;
this.currDelay = delay;
return delay;
}
if (this.maxDelay && delay > this.maxDelay) {
this.currDelay = this.maxDelay;
delay = this.maxDelay;
}
randomize(delay) {
var area = delay * this.randomness;
var corr = Math.round(Math.random() * area * 2 - area);
return Math.max(0, delay + corr);
}
scheduleAttempt(delayOverride) {
if (this.maxAttemptsCount && this.attemptNum >= this.maxAttemptsCount) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt count limit reached"));
return;
this.currDelay = delay;
return delay;
}
var delay = this.nextDelay(delayOverride);
delay = this.randomize(delay);
if (this.maxAttemptsTime && this.startTimestamp + this.maxAttemptsTime < Date.now() + delay) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt time limit reached"));
return;
}, {
key: "randomize",
value: function randomize(delay) {
var area = delay * this.randomness;
var corr = Math.round(Math.random() * area * 2 - area);
return Math.max(0, delay + corr);
}
}, {
key: "scheduleAttempt",
value: function scheduleAttempt(delayOverride) {
var _this2 = this;
this.timeout = setTimeout(() => this.attempt(), delay);
}
if (this.maxAttemptsCount && this.attemptNum >= this.maxAttemptsCount) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt count limit reached"));
return;
}
cleanup() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
var delay = this.nextDelay(delayOverride);
delay = this.randomize(delay);
this.inProgress = false;
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
if (this.maxAttemptsTime && this.startTimestamp + this.maxAttemptsTime < Date.now() + delay) {
this.cleanup();
this.emit("failed", new Error("Maximum attempt time limit reached"));
return;
}
start() {
if (this.inProgress) {
throw new Error("Retrier is already in progress");
this.timeout = setTimeout(function () {
return _this2.attempt();
}, delay);
}
}, {
key: "cleanup",
value: function cleanup() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.inProgress = true;
this.startTimestamp = Date.now();
this.scheduleAttempt(this.initialDelay);
}
cancel() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
this.inProgress = false;
this.emit("cancelled");
this.attemptNum = 0;
this.prevDelay = 0;
this.currDelay = 0;
}
} // @todo Must be a T here, so the entire Retrier must be typed on this value type.
// eslint-disable-next-line
}, {
key: "start",
value: function start() {
if (this.inProgress) {
throw new Error("Retrier is already in progress");
}
this.inProgress = true;
this.startTimestamp = Date.now();
this.scheduleAttempt(this.initialDelay);
}
}, {
key: "cancel",
value: function cancel() {
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
this.inProgress = false;
this.emit("cancelled");
}
} // @todo Must be a T here, so the entire Retrier must be typed on this value type.
// eslint-disable-next-line
succeeded(arg) {
this.emit("succeeded", arg);
}
}, {
key: "succeeded",
value: function succeeded(arg) {
this.emit("succeeded", arg);
}
}, {
key: "failed",
value: function failed(err, nextAttemptDelayOverride) {
if (this.timeout) {
throw new Error("Retrier attempt is already in progress");
}
failed(err, nextAttemptDelayOverride) {
if (this.timeout) {
throw new Error("Retrier attempt is already in progress");
this.scheduleAttempt(nextAttemptDelayOverride);
}
}]);
this.scheduleAttempt(nextAttemptDelayOverride);
}
}
return Retrier;
}(events.EventEmitter);
/**

@@ -181,35 +223,70 @@ * Run retrier as an async function with possibility to await for it.

class AsyncRetrier extends events.EventEmitter {
var AsyncRetrier = /*#__PURE__*/function (_EventEmitter2) {
_inherits__default['default'](AsyncRetrier, _EventEmitter2);
var _super2 = _createSuper$1(AsyncRetrier);
// This any must be T typed directly on the AsyncRetrier
// eslint-disable-next-line
constructor(options) {
super();
function AsyncRetrier(options) {
var _this3;
_defineProperty__default['default'](this, "resolve", () => void 0);
_classCallCheck__default['default'](this, AsyncRetrier);
_defineProperty__default['default'](this, "reject", () => void 0);
_this3 = _super2.call(this);
this.retrier = new Retrier(options);
}
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this3), "resolve", function () {
return void 0;
});
run(handler) {
this.retrier.on("attempt", () => {
handler().then(v => this.retrier.succeeded(v)).catch(e => this.retrier.failed(e));
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this3), "reject", function () {
return void 0;
});
this.retrier.on("succeeded", arg => this.resolve(arg));
this.retrier.on("cancelled", () => this.reject(new Error("Cancelled")));
this.retrier.on("failed", err => this.reject(err));
return new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.retrier.start();
});
}
cancel() {
this.retrier.cancel();
_this3.retrier = new Retrier(options);
return _this3;
}
}
_createClass__default['default'](AsyncRetrier, [{
key: "run",
value: function run(handler) {
var _this4 = this;
this.retrier.on("attempt", function () {
handler().then(function (v) {
return _this4.retrier.succeeded(v);
}).catch(function (e) {
return _this4.retrier.failed(e);
});
});
this.retrier.on("succeeded", function (arg) {
return _this4.resolve(arg);
});
this.retrier.on("cancelled", function () {
return _this4.reject(new Error("Cancelled"));
});
this.retrier.on("failed", function (err) {
return _this4.reject(err);
});
return new Promise(function (resolve, reject) {
_this4.resolve = resolve;
_this4.reject = reject;
_this4.retrier.start();
});
}
}, {
key: "cancel",
value: function cancel() {
this.retrier.cancel();
}
}]);
return AsyncRetrier;
}(events.EventEmitter);
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['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; } }
function isDef(value) {

@@ -219,16 +296,24 @@ return value !== undefined && value !== null;

class Backoff extends events.EventEmitter {
constructor(options) {
super();
var Backoff = /*#__PURE__*/function (_EventEmitter) {
_inherits__default['default'](Backoff, _EventEmitter);
_defineProperty__default['default'](this, "backoffDelay", 0);
var _super = _createSuper(Backoff);
_defineProperty__default['default'](this, "nextBackoffDelay", 0);
function Backoff(options) {
var _this;
_defineProperty__default['default'](this, "backoffNumber", 0);
_classCallCheck__default['default'](this, Backoff);
_defineProperty__default['default'](this, "timeoutID", null);
_this = _super.call(this);
_defineProperty__default['default'](this, "maxNumberOfRetry", -1);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "backoffDelay", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "nextBackoffDelay", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "backoffNumber", 0);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "timeoutID", null);
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "maxNumberOfRetry", -1);
options = options || {};

@@ -257,66 +342,78 @@ var _options = options,

this.initialDelay = initialDelay || 100;
this.maxDelay = maxDelay || 10000;
_this.initialDelay = initialDelay || 100;
_this.maxDelay = maxDelay || 10000;
if (this.maxDelay <= this.initialDelay) {
if (_this.maxDelay <= _this.initialDelay) {
throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");
}
this.randomisationFactor = randomisationFactor || 0;
this.factor = factor || 2;
this.reset();
}
_this.randomisationFactor = randomisationFactor || 0;
_this.factor = factor || 2;
static exponential(options) {
return new Backoff(options);
_this.reset();
return _this;
}
backoff(err) {
if (this.timeoutID == null) {
if (this.backoffNumber === this.maxNumberOfRetry) {
this.emit("fail", err);
this.reset();
} else {
this.backoffDelay = this.next();
this.timeoutID = setTimeout(this.onBackoff.bind(this), this.backoffDelay);
this.emit("backoff", this.backoffNumber, this.backoffDelay, err);
_createClass__default['default'](Backoff, [{
key: "backoff",
value: function backoff(err) {
if (this.timeoutID == null) {
if (this.backoffNumber === this.maxNumberOfRetry) {
this.emit("fail", err);
this.reset();
} else {
this.backoffDelay = this.next();
this.timeoutID = setTimeout(this.onBackoff.bind(this), this.backoffDelay);
this.emit("backoff", this.backoffNumber, this.backoffDelay, err);
}
}
}
}
}, {
key: "reset",
value: function reset() {
this.backoffDelay = 0;
this.nextBackoffDelay = this.initialDelay;
this.backoffNumber = 0;
reset() {
this.backoffDelay = 0;
this.nextBackoffDelay = this.initialDelay;
this.backoffNumber = 0;
if (this.timeoutID) {
clearTimeout(this.timeoutID);
}
if (this.timeoutID) {
clearTimeout(this.timeoutID);
this.timeoutID = null;
}
}, {
key: "failAfter",
value: function failAfter(maxNumberOfRetry) {
if (maxNumberOfRetry <= 0) {
throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(maxNumberOfRetry));
}
this.timeoutID = null;
}
failAfter(maxNumberOfRetry) {
if (maxNumberOfRetry <= 0) {
throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(maxNumberOfRetry));
this.maxNumberOfRetry = maxNumberOfRetry;
}
}, {
key: "next",
value: function next() {
this.backoffDelay = Math.min(this.nextBackoffDelay, this.maxDelay);
this.nextBackoffDelay = this.backoffDelay * this.factor;
var randomisationMultiple = 1 + Math.random() * this.randomisationFactor;
return Math.min(this.maxDelay, Math.round(this.backoffDelay * randomisationMultiple));
}
}, {
key: "onBackoff",
value: function onBackoff() {
this.timeoutID = null;
this.emit("ready", this.backoffNumber, this.backoffDelay);
this.backoffNumber++;
}
}], [{
key: "exponential",
value: function exponential(options) {
return new Backoff(options);
}
}]);
this.maxNumberOfRetry = maxNumberOfRetry;
}
return Backoff;
}(events.EventEmitter);
next() {
this.backoffDelay = Math.min(this.nextBackoffDelay, this.maxDelay);
this.nextBackoffDelay = this.backoffDelay * this.factor;
var randomisationMultiple = 1 + Math.random() * this.randomisationFactor;
return Math.min(this.maxDelay, Math.round(this.backoffDelay * randomisationMultiple));
}
onBackoff() {
this.timeoutID = null;
this.emit("ready", this.backoffNumber, this.backoffDelay);
this.backoffNumber++;
}
}
exports.AsyncRetrier = AsyncRetrier;

@@ -323,0 +420,0 @@ exports.Backoff = Backoff;

@@ -18,2 +18,2 @@ /*

*/
var Retrier=function(t){"use strict";function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(t){return t&&t.Math==Math&&t},i=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n&&n)||function(){return this}()||Function("return this")(),o={},s=function(t){try{return!!t()}catch(t){return!0}},a=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),u={},c={}.propertyIsEnumerable,f=Object.getOwnPropertyDescriptor,l=f&&!c.call({1:2},1);u.f=l?function(t){var e=f(this,t);return!!e&&e.enumerable}:c;var h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},p={}.toString,m=function(t){return p.call(t).slice(8,-1)},v=m,y="".split,d=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},g=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==v(t)?y.call(t,""):Object(t)}:Object,b=d,w=function(t){return g(b(t))},x=function(t){return"object"==typeof t?null!==t:"function"==typeof t},D=x,E=function(t,e){if(!D(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!D(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!D(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!D(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},j=d,T=function(t){return Object(j(t))},_={}.hasOwnProperty,O=Object.hasOwn||function(t,e){return _.call(T(t),e)},k=x,L=i.document,S=k(L)&&k(L.createElement),P=function(t){return S?L.createElement(t):{}},M=P,A=!a&&!s((function(){return 7!=Object.defineProperty(M("div"),"a",{get:function(){return 7}}).a})),N=a,C=u,I=h,R=w,F=E,z=O,B=A,U=Object.getOwnPropertyDescriptor;o.f=N?U:function(t,e){if(t=R(t),e=F(e,!0),B)try{return U(t,e)}catch(t){}if(z(t,e))return I(!C.f.call(t,e),t[e])};var W={},q=x,K=function(t){if(!q(t))throw TypeError(String(t)+" is not an object");return t},G=a,H=A,V=K,Y=E,J=Object.defineProperty;W.f=G?J:function(t,e,n){if(V(t),e=Y(e,!0),V(n),H)try{return J(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var Q=W,X=h,Z=a?function(t,e,n){return Q.f(t,e,X(1,n))}:function(t,e,n){return t[e]=n,t},$={exports:{}},tt=i,et=Z,nt=function(t,e){try{et(tt,t,e)}catch(n){tt[t]=e}return e},rt=nt,it="__core-js_shared__",ot=i[it]||rt(it,{}),st=ot,at=Function.toString;"function"!=typeof st.inspectSource&&(st.inspectSource=function(t){return at.call(t)});var ut=st.inspectSource,ct=ut,ft=i.WeakMap,lt="function"==typeof ft&&/native code/.test(ct(ft)),ht={exports:{}},pt=ot;(ht.exports=function(t,e){return pt[t]||(pt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.15.2",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var mt,vt,yt,dt=0,gt=Math.random(),bt=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++dt+gt).toString(36)},wt=ht.exports,xt=bt,Dt=wt("keys"),Et={},jt=lt,Tt=x,_t=Z,Ot=O,kt=ot,Lt=function(t){return Dt[t]||(Dt[t]=xt(t))},St=Et,Pt="Object already initialized",Mt=i.WeakMap;if(jt||kt.state){var At=kt.state||(kt.state=new Mt),Nt=At.get,Ct=At.has,It=At.set;mt=function(t,e){if(Ct.call(At,t))throw new TypeError(Pt);return e.facade=t,It.call(At,t,e),e},vt=function(t){return Nt.call(At,t)||{}},yt=function(t){return Ct.call(At,t)}}else{var Rt=Lt("state");St[Rt]=!0,mt=function(t,e){if(Ot(t,Rt))throw new TypeError(Pt);return e.facade=t,_t(t,Rt,e),e},vt=function(t){return Ot(t,Rt)?t[Rt]:{}},yt=function(t){return Ot(t,Rt)}}var Ft={set:mt,get:vt,has:yt,enforce:function(t){return yt(t)?vt(t):mt(t,{})},getterFor:function(t){return function(e){var n;if(!Tt(e)||(n=vt(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},zt=i,Bt=Z,Ut=O,Wt=nt,qt=ut,Kt=Ft.get,Gt=Ft.enforce,Ht=String(String).split("String");($.exports=function(t,e,n,r){var i,o=!!r&&!!r.unsafe,s=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||Ut(n,"name")||Bt(n,"name",e),(i=Gt(n)).source||(i.source=Ht.join("string"==typeof e?e:""))),t!==zt?(o?!a&&t[e]&&(s=!0):delete t[e],s?t[e]=n:Bt(t,e,n)):s?t[e]=n:Wt(e,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&Kt(this).source||qt(this)}));var Vt=i,Yt=i,Jt=function(t){return"function"==typeof t?t:void 0},Qt=function(t,e){return arguments.length<2?Jt(Vt[t])||Jt(Yt[t]):Vt[t]&&Vt[t][e]||Yt[t]&&Yt[t][e]},Xt={},Zt=Math.ceil,$t=Math.floor,te=function(t){return isNaN(t=+t)?0:(t>0?$t:Zt)(t)},ee=te,ne=Math.min,re=function(t){return t>0?ne(ee(t),9007199254740991):0},ie=te,oe=Math.max,se=Math.min,ae=w,ue=re,ce=function(t,e){var n=ie(t);return n<0?oe(n+e,0):se(n,e)},fe=function(t){return function(e,n,r){var i,o=ae(e),s=ue(o.length),a=ce(r,s);if(t&&n!=n){for(;s>a;)if((i=o[a++])!=i)return!0}else for(;s>a;a++)if((t||a in o)&&o[a]===n)return t||a||0;return!t&&-1}},le={includes:fe(!0),indexOf:fe(!1)},he=O,pe=w,me=le.indexOf,ve=Et,ye=function(t,e){var n,r=pe(t),i=0,o=[];for(n in r)!he(ve,n)&&he(r,n)&&o.push(n);for(;e.length>i;)he(r,n=e[i++])&&(~me(o,n)||o.push(n));return o},de=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype");Xt.f=Object.getOwnPropertyNames||function(t){return ye(t,de)};var ge={};ge.f=Object.getOwnPropertySymbols;var be,we,xe=Xt,De=ge,Ee=K,je=Qt("Reflect","ownKeys")||function(t){var e=xe.f(Ee(t)),n=De.f;return n?e.concat(n(t)):e},Te=O,_e=je,Oe=o,ke=W,Le=s,Se=/#|\.prototype\./,Pe=function(t,e){var n=Ae[Me(t)];return n==Ce||n!=Ne&&("function"==typeof e?Le(e):!!e)},Me=Pe.normalize=function(t){return String(t).replace(Se,".").toLowerCase()},Ae=Pe.data={},Ne=Pe.NATIVE="N",Ce=Pe.POLYFILL="P",Ie=Pe,Re=i,Fe=o.f,ze=Z,Be=$.exports,Ue=nt,We=function(t,e){for(var n=_e(e),r=ke.f,i=Oe.f,o=0;o<n.length;o++){var s=n[o];Te(t,s)||r(t,s,i(e,s))}},qe=Ie,Ke=i.Promise,Ge=$.exports,He=x,Ve=K,Ye=function(t){if(!He(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype");return t},Je=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return Ve(n),Ye(r),e?t.call(n,r):n.__proto__=r,n}}():void 0),Qe=Qt("navigator","userAgent")||"",Xe=Qe,Ze=i.process,$e=Ze&&Ze.versions,tn=$e&&$e.v8;tn?we=(be=tn.split("."))[0]<4?1:be[0]+be[1]:Xe&&(!(be=Xe.match(/Edge\/(\d+)/))||be[1]>=74)&&(be=Xe.match(/Chrome\/(\d+)/))&&(we=be[1]);var en=we&&+we,nn=en,rn=s,on=!!Object.getOwnPropertySymbols&&!rn((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&nn&&nn<41})),sn=on&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,an=i,un=ht.exports,cn=O,fn=bt,ln=on,hn=sn,pn=un("wks"),mn=an.Symbol,vn=hn?mn:mn&&mn.withoutSetter||fn,yn=function(t){return cn(pn,t)&&(ln||"string"==typeof pn[t])||(ln&&cn(mn,t)?pn[t]=mn[t]:pn[t]=vn("Symbol."+t)),pn[t]},dn=W.f,gn=O,bn=yn("toStringTag"),wn=Qt,xn=W,Dn=a,En=yn("species"),jn=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},Tn={},_n=Tn,On=yn("iterator"),kn=Array.prototype,Ln=jn,Sn=function(t,e,n){if(Ln(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},Pn={};Pn[yn("toStringTag")]="z";var Mn="[object z]"===String(Pn),An=m,Nn=yn("toStringTag"),Cn="Arguments"==An(function(){return arguments}()),In=Mn?An:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Nn))?n:Cn?An(e):"Object"==(r=An(e))&&"function"==typeof e.callee?"Arguments":r},Rn=Tn,Fn=yn("iterator"),zn=K,Bn=K,Un=function(t){return void 0!==t&&(_n.Array===t||kn[On]===t)},Wn=re,qn=Sn,Kn=function(t){if(null!=t)return t[Fn]||t["@@iterator"]||Rn[In(t)]},Gn=function(t){var e=t.return;if(void 0!==e)return zn(e.call(t)).value},Hn=function(t,e){this.stopped=t,this.result=e},Vn=yn("iterator"),Yn=!1;try{var Jn=0,Qn={next:function(){return{done:!!Jn++}},return:function(){Yn=!0}};Qn[Vn]=function(){return this},Array.from(Qn,(function(){throw 2}))}catch(t){}var Xn,Zn,$n,tr=K,er=jn,nr=yn("species"),rr=Qt("document","documentElement"),ir=/(?:iphone|ipod|ipad).*applewebkit/i.test(Qe),or="process"==m(i.process),sr=i,ar=s,ur=Sn,cr=rr,fr=P,lr=ir,hr=or,pr=sr.location,mr=sr.setImmediate,vr=sr.clearImmediate,yr=sr.process,dr=sr.MessageChannel,gr=sr.Dispatch,br=0,wr={},xr="onreadystatechange",Dr=function(t){if(wr.hasOwnProperty(t)){var e=wr[t];delete wr[t],e()}},Er=function(t){return function(){Dr(t)}},jr=function(t){Dr(t.data)},Tr=function(t){sr.postMessage(t+"",pr.protocol+"//"+pr.host)};mr&&vr||(mr=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return wr[++br]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},Xn(br),br},vr=function(t){delete wr[t]},hr?Xn=function(t){yr.nextTick(Er(t))}:gr&&gr.now?Xn=function(t){gr.now(Er(t))}:dr&&!lr?($n=(Zn=new dr).port2,Zn.port1.onmessage=jr,Xn=ur($n.postMessage,$n,1)):sr.addEventListener&&"function"==typeof postMessage&&!sr.importScripts&&pr&&"file:"!==pr.protocol&&!ar(Tr)?(Xn=Tr,sr.addEventListener("message",jr,!1)):Xn=xr in fr("script")?function(t){cr.appendChild(fr("script")).onreadystatechange=function(){cr.removeChild(this),Dr(t)}}:function(t){setTimeout(Er(t),0)});var _r,Or,kr,Lr,Sr,Pr,Mr,Ar,Nr={set:mr,clear:vr},Cr=/web0s(?!.*chrome)/i.test(Qe),Ir=i,Rr=o.f,Fr=Nr.set,zr=ir,Br=Cr,Ur=or,Wr=Ir.MutationObserver||Ir.WebKitMutationObserver,qr=Ir.document,Kr=Ir.process,Gr=Ir.Promise,Hr=Rr(Ir,"queueMicrotask"),Vr=Hr&&Hr.value;Vr||(_r=function(){var t,e;for(Ur&&(t=Kr.domain)&&t.exit();Or;){e=Or.fn,Or=Or.next;try{e()}catch(t){throw Or?Lr():kr=void 0,t}}kr=void 0,t&&t.enter()},zr||Ur||Br||!Wr||!qr?Gr&&Gr.resolve?((Mr=Gr.resolve(void 0)).constructor=Gr,Ar=Mr.then,Lr=function(){Ar.call(Mr,_r)}):Lr=Ur?function(){Kr.nextTick(_r)}:function(){Fr.call(Ir,_r)}:(Sr=!0,Pr=qr.createTextNode(""),new Wr(_r).observe(Pr,{characterData:!0}),Lr=function(){Pr.data=Sr=!Sr}));var Yr=Vr||function(t){var e={fn:t,next:void 0};kr&&(kr.next=e),Or||(Or=e,Lr()),kr=e},Jr={},Qr=jn,Xr=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=Qr(e),this.reject=Qr(n)};Jr.f=function(t){return new Xr(t)};var Zr,$r,ti,ei,ni=K,ri=x,ii=Jr,oi=i,si="object"==typeof window,ai=function(t,e){var n,r,i,o,s,a=t.target,u=t.global,c=t.stat;if(n=u?Re:c?Re[a]||Ue(a,{}):(Re[a]||{}).prototype)for(r in e){if(o=e[r],i=t.noTargetGet?(s=Fe(n,r))&&s.value:n[r],!qe(u?r:a+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;We(o,i)}(t.sham||i&&i.sham)&&ze(o,"sham",!0),Be(n,r,o,t)}},ui=i,ci=Qt,fi=Ke,li=$.exports,hi=function(t,e,n){for(var r in e)Ge(t,r,e[r],n);return t},pi=Je,mi=function(t,e,n){t&&!gn(t=n?t:t.prototype,bn)&&dn(t,bn,{configurable:!0,value:e})},vi=function(t){var e=wn(t),n=xn.f;Dn&&e&&!e[En]&&n(e,En,{configurable:!0,get:function(){return this}})},yi=x,di=jn,gi=function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t},bi=ut,wi=function(t,e,n){var r,i,o,s,a,u,c,f=n&&n.that,l=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),m=qn(e,f,1+l+p),v=function(t){return r&&Gn(r),new Hn(!0,t)},y=function(t){return l?(Bn(t),p?m(t[0],t[1],v):m(t[0],t[1])):p?m(t,v):m(t)};if(h)r=t;else{if("function"!=typeof(i=Kn(t)))throw TypeError("Target is not iterable");if(Un(i)){for(o=0,s=Wn(t.length);s>o;o++)if((a=y(t[o]))&&a instanceof Hn)return a;return new Hn(!1)}r=i.call(t)}for(u=r.next;!(c=u.call(r)).done;){try{a=y(c.value)}catch(t){throw Gn(r),t}if("object"==typeof a&&a&&a instanceof Hn)return a}return new Hn(!1)},xi=function(t,e){if(!e&&!Yn)return!1;var n=!1;try{var r={};r[Vn]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},Di=function(t,e){var n,r=tr(t).constructor;return void 0===r||null==(n=tr(r)[nr])?e:er(n)},Ei=Nr.set,ji=Yr,Ti=function(t,e){if(ni(t),ri(e)&&e.constructor===t)return e;var n=ii.f(t);return(0,n.resolve)(e),n.promise},_i=function(t,e){var n=oi.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))},Oi=Jr,ki=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Li=Ft,Si=Ie,Pi=si,Mi=or,Ai=en,Ni=yn("species"),Ci="Promise",Ii=Li.get,Ri=Li.set,Fi=Li.getterFor(Ci),zi=fi&&fi.prototype,Bi=fi,Ui=zi,Wi=ui.TypeError,qi=ui.document,Ki=ui.process,Gi=Oi.f,Hi=Gi,Vi=!!(qi&&qi.createEvent&&ui.dispatchEvent),Yi="function"==typeof PromiseRejectionEvent,Ji="unhandledrejection",Qi=!1,Xi=Si(Ci,(function(){var t=bi(Bi),e=t!==String(Bi);if(!e&&66===Ai)return!0;if(Ai>=51&&/native code/.test(t))return!1;var n=new Bi((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[Ni]=r,!(Qi=n.then((function(){}))instanceof r)||!e&&Pi&&!Yi})),Zi=Xi||!xi((function(t){Bi.all(t).catch((function(){}))})),$i=function(t){var e;return!(!yi(t)||"function"!=typeof(e=t.then))&&e},to=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;ji((function(){for(var r=t.value,i=1==t.state,o=0;n.length>o;){var s,a,u,c=n[o++],f=i?c.ok:c.fail,l=c.resolve,h=c.reject,p=c.domain;try{f?(i||(2===t.rejection&&io(t),t.rejection=1),!0===f?s=r:(p&&p.enter(),s=f(r),p&&(p.exit(),u=!0)),s===c.promise?h(Wi("Promise-chain cycle")):(a=$i(s))?a.call(s,l,h):l(s)):h(r)}catch(t){p&&!u&&p.exit(),h(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&no(t)}))}},eo=function(t,e,n){var r,i;Vi?((r=qi.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),ui.dispatchEvent(r)):r={promise:e,reason:n},!Yi&&(i=ui["on"+t])?i(r):t===Ji&&_i("Unhandled promise rejection",n)},no=function(t){Ei.call(ui,(function(){var e,n=t.facade,r=t.value;if(ro(t)&&(e=ki((function(){Mi?Ki.emit("unhandledRejection",r,n):eo(Ji,n,r)})),t.rejection=Mi||ro(t)?2:1,e.error))throw e.value}))},ro=function(t){return 1!==t.rejection&&!t.parent},io=function(t){Ei.call(ui,(function(){var e=t.facade;Mi?Ki.emit("rejectionHandled",e):eo("rejectionhandled",e,t.value)}))},oo=function(t,e,n){return function(r){t(e,r,n)}},so=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,to(t,!0))},ao=function t(e,n,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===n)throw Wi("Promise can't be resolved itself");var i=$i(n);i?ji((function(){var r={done:!1};try{i.call(n,oo(t,r,e),oo(so,r,e))}catch(t){so(r,t,e)}})):(e.value=n,e.state=1,to(e,!1))}catch(t){so({done:!1},t,e)}}};if(Xi&&(Ui=(Bi=function(t){gi(this,Bi,Ci),di(t),Zr.call(this);var e=Ii(this);try{t(oo(ao,e),oo(so,e))}catch(t){so(e,t)}}).prototype,(Zr=function(t){Ri(this,{type:Ci,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=hi(Ui,{then:function(t,e){var n=Fi(this),r=Gi(Di(this,Bi));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=Mi?Ki.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&to(n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),$r=function(){var t=new Zr,e=Ii(t);this.promise=t,this.resolve=oo(ao,e),this.reject=oo(so,e)},Oi.f=Gi=function(t){return t===Bi||t===ti?new $r(t):Hi(t)},"function"==typeof fi&&zi!==Object.prototype)){ei=zi.then,Qi||(li(zi,"then",(function(t,e){var n=this;return new Bi((function(t,e){ei.call(n,t,e)})).then(t,e)}),{unsafe:!0}),li(zi,"catch",Ui.catch,{unsafe:!0}));try{delete zi.constructor}catch(t){}pi&&pi(zi,Ui)}function uo(){}function co(){co.init.call(this)}function fo(t){return void 0===t._maxListeners?co.defaultMaxListeners:t._maxListeners}function lo(t,e,n){if(e)t.call(n);else for(var r=t.length,i=wo(t,r),o=0;o<r;++o)i[o].call(n)}function ho(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,o=wo(t,i),s=0;s<i;++s)o[s].call(n,r)}function po(t,e,n,r,i){if(e)t.call(n,r,i);else for(var o=t.length,s=wo(t,o),a=0;a<o;++a)s[a].call(n,r,i)}function mo(t,e,n,r,i,o){if(e)t.call(n,r,i,o);else for(var s=t.length,a=wo(t,s),u=0;u<s;++u)a[u].call(n,r,i,o)}function vo(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,o=wo(t,i),s=0;s<i;++s)o[s].apply(n,r)}function yo(t,e,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=new uo,t._eventsCount=0),s){if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=fo(t))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[e]=n,++t._eventsCount;return t}function go(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function bo(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function wo(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}ai({global:!0,wrap:!0,forced:Xi},{Promise:Bi}),mi(Bi,Ci,!1),vi(Ci),ti=ci(Ci),ai({target:Ci,stat:!0,forced:Xi},{reject:function(t){var e=Gi(this);return e.reject.call(void 0,t),e.promise}}),ai({target:Ci,stat:!0,forced:Xi},{resolve:function(t){return Ti(this,t)}}),ai({target:Ci,stat:!0,forced:Zi},{all:function(t){var e=this,n=Gi(e),r=n.resolve,i=n.reject,o=ki((function(){var n=di(e.resolve),o=[],s=0,a=1;wi(t,(function(t){var u=s++,c=!1;o.push(void 0),a++,n.call(e,t).then((function(t){c||(c=!0,o[u]=t,--a||r(o))}),i)})),--a||r(o)}));return o.error&&i(o.value),n.promise},race:function(t){var e=this,n=Gi(e),r=n.reject,i=ki((function(){var i=di(e.resolve);wi(t,(function(t){i.call(e,t).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}}),uo.prototype=Object.create(null),co.EventEmitter=co,co.usingDomains=!1,co.prototype.domain=void 0,co.prototype._events=void 0,co.prototype._maxListeners=void 0,co.defaultMaxListeners=10,co.init=function(){this.domain=null,co.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new uo,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},co.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},co.prototype.getMaxListeners=function(){return fo(this)},co.prototype.emit=function(t){var e,n,r,i,o,s,a,u="error"===t;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(e=arguments[1],!a){if(e instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var f="function"==typeof n;switch(r=arguments.length){case 1:lo(n,f,this);break;case 2:ho(n,f,this,arguments[1]);break;case 3:po(n,f,this,arguments[1],arguments[2]);break;case 4:mo(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];vo(n,f,this,i)}return!0},co.prototype.addListener=function(t,e){return yo(this,t,e,!1)},co.prototype.on=co.prototype.addListener,co.prototype.prependListener=function(t,e){return yo(this,t,e,!0)},co.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,go(this,t,e)),this},co.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,go(this,t,e)),this},co.prototype.removeListener=function(t,e){var n,r,i,o,s;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)0==--this._eventsCount?this._events=new uo:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new uo,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i);r.removeListener&&this.emit("removeListener",t,s||e)}return this},co.prototype.off=function(t,e){return this.removeListener(t,e)},co.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new uo,this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=new uo:delete n[t]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new uo,this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},co.prototype.listeners=function(t){var e,n=this._events;return n&&(e=n[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(e):[]},co.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):bo.call(t,e)},co.prototype.listenerCount=bo,co.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class xo extends co{constructor(t){super(),e(this,"timeout",null),e(this,"startTimestamp",-1),this.minDelay=t.min,this.maxDelay=t.max,this.initialDelay=t.initial||0,this.maxAttemptsCount=t.maxAttemptsCount||0,this.maxAttemptsTime=t.maxAttemptsTime||0,this.randomness=t.randomness||0,this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}attempt(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}nextDelay(t){if("number"==typeof t)return this.prevDelay=0,this.currDelay=t,t;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var e=this.currDelay+this.prevDelay;return this.maxDelay&&e>this.maxDelay&&(this.currDelay=this.maxDelay,e=this.maxDelay),this.currDelay=e,e}randomize(t){var e=t*this.randomness,n=Math.round(Math.random()*e*2-e);return Math.max(0,t+n)}scheduleAttempt(t){if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var e=this.nextDelay(t);if(e=this.randomize(e),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+e)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((()=>this.attempt()),e)}cleanup(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}start(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}cancel(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}succeeded(t){this.emit("succeeded",t)}failed(t,e){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(e)}}function Do(t){return null!=t}class Eo extends co{constructor(t){super(),e(this,"backoffDelay",0),e(this,"nextBackoffDelay",0),e(this,"backoffNumber",0),e(this,"timeoutID",null),e(this,"maxNumberOfRetry",-1);var n=t=t||{},r=n.initialDelay,i=n.maxDelay,o=n.randomisationFactor,s=n.factor;if(Do(r)&&r<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(Do(i)&&i<=1)throw new Error("The maximal timeout must be greater than 1.");if(Do(o)&&(o<0||o>1))throw new Error("The randomisation factor must be between 0 and 1.");if(Do(s)&&s<=1)throw new Error("Exponential factor should be greater than 1.");if(this.initialDelay=r||100,this.maxDelay=i||1e4,this.maxDelay<=this.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");this.randomisationFactor=o||0,this.factor=s||2,this.reset()}static exponential(t){return new Eo(t)}backoff(t){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",t),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,t)))}reset(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}failAfter(t){if(t<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(t));this.maxNumberOfRetry=t}next(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var t=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*t))}onBackoff(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}return t.AsyncRetrier=class extends co{constructor(t){super(),e(this,"resolve",(()=>{})),e(this,"reject",(()=>{})),this.retrier=new xo(t)}run(t){return this.retrier.on("attempt",(()=>{t().then((t=>this.retrier.succeeded(t))).catch((t=>this.retrier.failed(t)))})),this.retrier.on("succeeded",(t=>this.resolve(t))),this.retrier.on("cancelled",(()=>this.reject(new Error("Cancelled")))),this.retrier.on("failed",(t=>this.reject(t))),new Promise(((t,e)=>{this.resolve=t,this.reject=e,this.retrier.start()}))}cancel(){this.retrier.cancel()}},t.Backoff=Eo,t.Retrier=xo,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
var Retrier=function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=function(t){return t&&t.Math==Math&&t},i=r("object"==("undefined"==typeof globalThis?"undefined":n(globalThis))&&globalThis)||r("object"==("undefined"==typeof window?"undefined":n(window))&&window)||r("object"==("undefined"==typeof self?"undefined":n(self))&&self)||r("object"==n(e)&&e)||function(){return this}()||Function("return this")(),o={},u=function(t){try{return!!t()}catch(t){return!0}},a=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),c={},s={}.propertyIsEnumerable,f=Object.getOwnPropertyDescriptor,l=f&&!s.call({1:2},1);c.f=l?function(t){var e=f(this,t);return!!e&&e.enumerable}:s;var h=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},p={}.toString,m=function(t){return p.call(t).slice(8,-1)},v=m,y="".split,d=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},b=u((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==v(t)?y.call(t,""):Object(t)}:Object,g=d,w=function(t){return b(g(t))},x=function(t){return"object"===n(t)?null!==t:"function"==typeof t},j=x,O=function(t,e){if(!j(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!j(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!j(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!j(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},E=d,D=function(t){return Object(E(t))},_={}.hasOwnProperty,k=Object.hasOwn||function(t,e){return _.call(D(t),e)},T=x,S=i.document,P=T(S)&&T(S.createElement),L=function(t){return P?S.createElement(t):{}},M=L,A=!a&&!u((function(){return 7!=Object.defineProperty(M("div"),"a",{get:function(){return 7}}).a})),R=a,C=c,N=h,I=w,F=O,B=k,z=A,U=Object.getOwnPropertyDescriptor;o.f=R?U:function(t,e){if(t=I(t),e=F(e,!0),z)try{return U(t,e)}catch(t){}if(B(t,e))return N(!C.f.call(t,e),t[e])};var W={},q=x,K=function(t){if(!q(t))throw TypeError(String(t)+" is not an object");return t},G=a,H=A,V=K,X=O,Y=Object.defineProperty;W.f=G?Y:function(t,e,n){if(V(t),e=X(e,!0),V(n),H)try{return Y(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var J=W,Q=h,Z=a?function(t,e,n){return J.f(t,e,Q(1,n))}:function(t,e,n){return t[e]=n,t},$={exports:{}},tt=i,et=Z,nt=function(t,e){try{et(tt,t,e)}catch(n){tt[t]=e}return e},rt=nt,it="__core-js_shared__",ot=i[it]||rt(it,{}),ut=ot,at=Function.toString;"function"!=typeof ut.inspectSource&&(ut.inspectSource=function(t){return at.call(t)});var ct=ut.inspectSource,st=ct,ft=i.WeakMap,lt="function"==typeof ft&&/native code/.test(st(ft)),ht={exports:{}},pt=ot;(ht.exports=function(t,e){return pt[t]||(pt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.15.2",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var mt,vt,yt,dt=0,bt=Math.random(),gt=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++dt+bt).toString(36)},wt=ht.exports,xt=gt,jt=wt("keys"),Ot=function(t){return jt[t]||(jt[t]=xt(t))},Et={},Dt=lt,_t=x,kt=Z,Tt=k,St=ot,Pt=Ot,Lt=Et,Mt="Object already initialized",At=i.WeakMap;if(Dt||St.state){var Rt=St.state||(St.state=new At),Ct=Rt.get,Nt=Rt.has,It=Rt.set;mt=function(t,e){if(Nt.call(Rt,t))throw new TypeError(Mt);return e.facade=t,It.call(Rt,t,e),e},vt=function(t){return Ct.call(Rt,t)||{}},yt=function(t){return Nt.call(Rt,t)}}else{var Ft=Pt("state");Lt[Ft]=!0,mt=function(t,e){if(Tt(t,Ft))throw new TypeError(Mt);return e.facade=t,kt(t,Ft,e),e},vt=function(t){return Tt(t,Ft)?t[Ft]:{}},yt=function(t){return Tt(t,Ft)}}var Bt={set:mt,get:vt,has:yt,enforce:function(t){return yt(t)?vt(t):mt(t,{})},getterFor:function(t){return function(e){var n;if(!_t(e)||(n=vt(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},zt=i,Ut=Z,Wt=k,qt=nt,Kt=ct,Gt=Bt.get,Ht=Bt.enforce,Vt=String(String).split("String");($.exports=function(t,e,n,r){var i,o=!!r&&!!r.unsafe,u=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||Wt(n,"name")||Ut(n,"name",e),(i=Ht(n)).source||(i.source=Vt.join("string"==typeof e?e:""))),t!==zt?(o?!a&&t[e]&&(u=!0):delete t[e],u?t[e]=n:Ut(t,e,n)):u?t[e]=n:qt(e,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&Gt(this).source||Kt(this)}));var Xt=i,Yt=i,Jt=function(t){return"function"==typeof t?t:void 0},Qt=function(t,e){return arguments.length<2?Jt(Xt[t])||Jt(Yt[t]):Xt[t]&&Xt[t][e]||Yt[t]&&Yt[t][e]},Zt={},$t=Math.ceil,te=Math.floor,ee=function(t){return isNaN(t=+t)?0:(t>0?te:$t)(t)},ne=ee,re=Math.min,ie=function(t){return t>0?re(ne(t),9007199254740991):0},oe=ee,ue=Math.max,ae=Math.min,ce=w,se=ie,fe=function(t,e){var n=oe(t);return n<0?ue(n+e,0):ae(n,e)},le=function(t){return function(e,n,r){var i,o=ce(e),u=se(o.length),a=fe(r,u);if(t&&n!=n){for(;u>a;)if((i=o[a++])!=i)return!0}else for(;u>a;a++)if((t||a in o)&&o[a]===n)return t||a||0;return!t&&-1}},he={includes:le(!0),indexOf:le(!1)},pe=k,me=w,ve=he.indexOf,ye=Et,de=function(t,e){var n,r=me(t),i=0,o=[];for(n in r)!pe(ye,n)&&pe(r,n)&&o.push(n);for(;e.length>i;)pe(r,n=e[i++])&&(~ve(o,n)||o.push(n));return o},be=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ge=de,we=be.concat("length","prototype");Zt.f=Object.getOwnPropertyNames||function(t){return ge(t,we)};var xe={};xe.f=Object.getOwnPropertySymbols;var je,Oe=Zt,Ee=xe,De=K,_e=Qt("Reflect","ownKeys")||function(t){var e=Oe.f(De(t)),n=Ee.f;return n?e.concat(n(t)):e},ke=k,Te=_e,Se=o,Pe=W,Le=u,Me=/#|\.prototype\./,Ae=function(t,e){var n=Ce[Re(t)];return n==Ie||n!=Ne&&("function"==typeof e?Le(e):!!e)},Re=Ae.normalize=function(t){return String(t).replace(Me,".").toLowerCase()},Ce=Ae.data={},Ne=Ae.NATIVE="N",Ie=Ae.POLYFILL="P",Fe=Ae,Be=i,ze=o.f,Ue=Z,We=$.exports,qe=nt,Ke=function(t,e){for(var n=Te(e),r=Pe.f,i=Se.f,o=0;o<n.length;o++){var u=n[o];ke(t,u)||r(t,u,i(e,u))}},Ge=Fe,He=function(t,e){var r,i,o,u,a,c=t.target,s=t.global,f=t.stat;if(r=s?Be:f?Be[c]||qe(c,{}):(Be[c]||{}).prototype)for(i in e){if(u=e[i],o=t.noTargetGet?(a=ze(r,i))&&a.value:r[i],!Ge(s?i:c+(f?".":"#")+i,t.forced)&&void 0!==o){if(n(u)===n(o))continue;Ke(u,o)}(t.sham||o&&o.sham)&&Ue(u,"sham",!0),We(r,i,u,t)}},Ve=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},Xe=de,Ye=be,Je=Object.keys||function(t){return Xe(t,Ye)},Qe=W,Ze=K,$e=Je,tn=a?Object.defineProperties:function(t,e){Ze(t);for(var n,r=$e(e),i=r.length,o=0;i>o;)Qe.f(t,n=r[o++],e[n]);return t},en=Qt("document","documentElement"),nn=K,rn=tn,on=be,un=Et,an=en,cn=L,sn=Ot("IE_PROTO"),fn=function(){},ln=function(t){return"<script>"+t+"</"+"script>"},hn=function(){try{je=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;hn=je?function(t){t.write(ln("")),t.close();var e=t.parentWindow.Object;return t=null,e}(je):((e=cn("iframe")).style.display="none",an.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(ln("document.F=Object")),t.close(),t.F);for(var n=on.length;n--;)delete hn.prototype[on[n]];return hn()};un[sn]=!0;var pn=Object.create||function(t,e){var n;return null!==t?(fn.prototype=nn(t),n=new fn,fn.prototype=null,n[sn]=t):n=hn(),void 0===e?n:rn(n,e)},mn=Ve,vn=x,yn=[].slice,dn={},bn=function(t,e,n){if(!(e in dn)){for(var r=[],i=0;i<e;i++)r[i]="a["+i+"]";dn[e]=Function("C,a","return new C("+r.join(",")+")")}return dn[e](t,n)},gn=Function.bind||function(t){var e=mn(this),n=yn.call(arguments,1),r=function(){var i=n.concat(yn.call(arguments));return this instanceof r?bn(e,i.length,i):e.apply(t,i)};return vn(e.prototype)&&(r.prototype=e.prototype),r},wn=He,xn=Ve,jn=K,On=x,En=pn,Dn=gn,_n=u,kn=Qt("Reflect","construct"),Tn=_n((function(){function t(){}return!(kn((function(){}),[],t)instanceof t)})),Sn=!_n((function(){kn((function(){}))})),Pn=Tn||Sn;function Ln(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Mn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function An(t,e,n){return e&&Mn(t.prototype,e),n&&Mn(t,n),t}function Rn(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Cn(t,e){return(Cn=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Nn(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Cn(t,e)}function In(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?Rn(t):e}function Fn(t){return(Fn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Bn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}wn({target:"Reflect",stat:!0,forced:Pn,sham:Pn},{construct:function(t,e){xn(t),jn(e);var n=arguments.length<3?t:xn(arguments[2]);if(Sn&&!Tn)return kn(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(Dn.apply(t,r))}var i=n.prototype,o=En(On(i)?i:Object.prototype),u=Function.apply.call(t,o,e);return On(u)?u:o}});var zn,Un,Wn=Qt("navigator","userAgent")||"",qn=Wn,Kn=i.process,Gn=Kn&&Kn.versions,Hn=Gn&&Gn.v8;Hn?Un=(zn=Hn.split("."))[0]<4?1:zn[0]+zn[1]:qn&&(!(zn=qn.match(/Edge\/(\d+)/))||zn[1]>=74)&&(zn=qn.match(/Chrome\/(\d+)/))&&(Un=zn[1]);var Vn=Un&&+Un,Xn=Vn,Yn=u,Jn=!!Object.getOwnPropertySymbols&&!Yn((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Xn&&Xn<41})),Qn=Jn&&!Symbol.sham&&"symbol"==n(Symbol.iterator),Zn=i,$n=ht.exports,tr=k,er=gt,nr=Jn,rr=Qn,ir=$n("wks"),or=Zn.Symbol,ur=rr?or:or&&or.withoutSetter||er,ar=function(t){return tr(ir,t)&&(nr||"string"==typeof ir[t])||(nr&&tr(or,t)?ir[t]=or[t]:ir[t]=ur("Symbol."+t)),ir[t]},cr={};cr[ar("toStringTag")]="z";var sr="[object z]"===String(cr),fr=sr,lr=m,hr=ar("toStringTag"),pr="Arguments"==lr(function(){return arguments}()),mr=fr?lr:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),hr))?n:pr?lr(e):"Object"==(r=lr(e))&&"function"==typeof e.callee?"Arguments":r},vr=mr,yr=sr?{}.toString:function(){return"[object "+vr(this)+"]"},dr=sr,br=$.exports,gr=yr;dr||br(Object.prototype,"toString",gr,{unsafe:!0});var wr=i.Promise,xr=$.exports,jr=x,Or=K,Er=function(t){if(!jr(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype");return t},Dr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return Or(n),Er(r),e?t.call(n,r):n.__proto__=r,n}}():void 0),_r=W.f,kr=k,Tr=ar("toStringTag"),Sr=Qt,Pr=W,Lr=a,Mr=ar("species"),Ar={},Rr=Ar,Cr=ar("iterator"),Nr=Array.prototype,Ir=Ve,Fr=function(t,e,n){if(Ir(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},Br=mr,zr=Ar,Ur=ar("iterator"),Wr=K,qr=K,Kr=function(t){return void 0!==t&&(Rr.Array===t||Nr[Cr]===t)},Gr=ie,Hr=Fr,Vr=function(t){if(null!=t)return t[Ur]||t["@@iterator"]||zr[Br(t)]},Xr=function(t){var e=t.return;if(void 0!==e)return Wr(e.call(t)).value},Yr=function(t,e){this.stopped=t,this.result=e},Jr=ar("iterator"),Qr=!1;try{var Zr=0,$r={next:function(){return{done:!!Zr++}},return:function(){Qr=!0}};$r[Jr]=function(){return this},Array.from($r,(function(){throw 2}))}catch(t){}var ti,ei,ni,ri=K,ii=Ve,oi=ar("species"),ui=/(?:iphone|ipod|ipad).*applewebkit/i.test(Wn),ai="process"==m(i.process),ci=i,si=u,fi=Fr,li=en,hi=L,pi=ui,mi=ai,vi=ci.location,yi=ci.setImmediate,di=ci.clearImmediate,bi=ci.process,gi=ci.MessageChannel,wi=ci.Dispatch,xi=0,ji={},Oi="onreadystatechange",Ei=function(t){if(ji.hasOwnProperty(t)){var e=ji[t];delete ji[t],e()}},Di=function(t){return function(){Ei(t)}},_i=function(t){Ei(t.data)},ki=function(t){ci.postMessage(t+"",vi.protocol+"//"+vi.host)};yi&&di||(yi=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return ji[++xi]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},ti(xi),xi},di=function(t){delete ji[t]},mi?ti=function(t){bi.nextTick(Di(t))}:wi&&wi.now?ti=function(t){wi.now(Di(t))}:gi&&!pi?(ni=(ei=new gi).port2,ei.port1.onmessage=_i,ti=fi(ni.postMessage,ni,1)):ci.addEventListener&&"function"==typeof postMessage&&!ci.importScripts&&vi&&"file:"!==vi.protocol&&!si(ki)?(ti=ki,ci.addEventListener("message",_i,!1)):ti=Oi in hi("script")?function(t){li.appendChild(hi("script")).onreadystatechange=function(){li.removeChild(this),Ei(t)}}:function(t){setTimeout(Di(t),0)});var Ti,Si,Pi,Li,Mi,Ai,Ri,Ci,Ni={set:yi,clear:di},Ii=/web0s(?!.*chrome)/i.test(Wn),Fi=i,Bi=o.f,zi=Ni.set,Ui=ui,Wi=Ii,qi=ai,Ki=Fi.MutationObserver||Fi.WebKitMutationObserver,Gi=Fi.document,Hi=Fi.process,Vi=Fi.Promise,Xi=Bi(Fi,"queueMicrotask"),Yi=Xi&&Xi.value;Yi||(Ti=function(){var t,e;for(qi&&(t=Hi.domain)&&t.exit();Si;){e=Si.fn,Si=Si.next;try{e()}catch(t){throw Si?Li():Pi=void 0,t}}Pi=void 0,t&&t.enter()},Ui||qi||Wi||!Ki||!Gi?Vi&&Vi.resolve?((Ri=Vi.resolve(void 0)).constructor=Vi,Ci=Ri.then,Li=function(){Ci.call(Ri,Ti)}):Li=qi?function(){Hi.nextTick(Ti)}:function(){zi.call(Fi,Ti)}:(Mi=!0,Ai=Gi.createTextNode(""),new Ki(Ti).observe(Ai,{characterData:!0}),Li=function(){Ai.data=Mi=!Mi}));var Ji=Yi||function(t){var e={fn:t,next:void 0};Pi&&(Pi.next=e),Si||(Si=e,Li()),Pi=e},Qi={},Zi=Ve,$i=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=Zi(e),this.reject=Zi(n)};Qi.f=function(t){return new $i(t)};var to,eo,no,ro,io=K,oo=x,uo=Qi,ao=i,co="object"==("undefined"==typeof window?"undefined":n(window)),so=He,fo=i,lo=Qt,ho=wr,po=$.exports,mo=function(t,e,n){for(var r in e)xr(t,r,e[r],n);return t},vo=Dr,yo=function(t,e,n){t&&!kr(t=n?t:t.prototype,Tr)&&_r(t,Tr,{configurable:!0,value:e})},bo=function(t){var e=Sr(t),n=Pr.f;Lr&&e&&!e[Mr]&&n(e,Mr,{configurable:!0,get:function(){return this}})},go=x,wo=Ve,xo=function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t},jo=ct,Oo=function(t,e,r){var i,o,u,a,c,s,f,l=r&&r.that,h=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_ITERATOR),m=!(!r||!r.INTERRUPTED),v=Hr(e,l,1+h+m),y=function(t){return i&&Xr(i),new Yr(!0,t)},d=function(t){return h?(qr(t),m?v(t[0],t[1],y):v(t[0],t[1])):m?v(t,y):v(t)};if(p)i=t;else{if("function"!=typeof(o=Vr(t)))throw TypeError("Target is not iterable");if(Kr(o)){for(u=0,a=Gr(t.length);a>u;u++)if((c=d(t[u]))&&c instanceof Yr)return c;return new Yr(!1)}i=o.call(t)}for(s=i.next;!(f=s.call(i)).done;){try{c=d(f.value)}catch(t){throw Xr(i),t}if("object"==n(c)&&c&&c instanceof Yr)return c}return new Yr(!1)},Eo=function(t,e){if(!e&&!Qr)return!1;var n=!1;try{var r={};r[Jr]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},Do=function(t,e){var n,r=ri(t).constructor;return void 0===r||null==(n=ri(r)[oi])?e:ii(n)},_o=Ni.set,ko=Ji,To=function(t,e){if(io(t),oo(e)&&e.constructor===t)return e;var n=uo.f(t);return(0,n.resolve)(e),n.promise},So=function(t,e){var n=ao.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))},Po=Qi,Lo=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Mo=Bt,Ao=Fe,Ro=co,Co=ai,No=Vn,Io=ar("species"),Fo="Promise",Bo=Mo.get,zo=Mo.set,Uo=Mo.getterFor(Fo),Wo=ho&&ho.prototype,qo=ho,Ko=Wo,Go=fo.TypeError,Ho=fo.document,Vo=fo.process,Xo=Po.f,Yo=Xo,Jo=!!(Ho&&Ho.createEvent&&fo.dispatchEvent),Qo="function"==typeof PromiseRejectionEvent,Zo="unhandledrejection",$o=!1,tu=Ao(Fo,(function(){var t=jo(qo),e=t!==String(qo);if(!e&&66===No)return!0;if(No>=51&&/native code/.test(t))return!1;var n=new qo((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[Io]=r,!($o=n.then((function(){}))instanceof r)||!e&&Ro&&!Qo})),eu=tu||!Eo((function(t){qo.all(t).catch((function(){}))})),nu=function(t){var e;return!(!go(t)||"function"!=typeof(e=t.then))&&e},ru=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;ko((function(){for(var r=t.value,i=1==t.state,o=0;n.length>o;){var u,a,c,s=n[o++],f=i?s.ok:s.fail,l=s.resolve,h=s.reject,p=s.domain;try{f?(i||(2===t.rejection&&au(t),t.rejection=1),!0===f?u=r:(p&&p.enter(),u=f(r),p&&(p.exit(),c=!0)),u===s.promise?h(Go("Promise-chain cycle")):(a=nu(u))?a.call(u,l,h):l(u)):h(r)}catch(t){p&&!c&&p.exit(),h(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&ou(t)}))}},iu=function(t,e,n){var r,i;Jo?((r=Ho.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),fo.dispatchEvent(r)):r={promise:e,reason:n},!Qo&&(i=fo["on"+t])?i(r):t===Zo&&So("Unhandled promise rejection",n)},ou=function(t){_o.call(fo,(function(){var e,n=t.facade,r=t.value;if(uu(t)&&(e=Lo((function(){Co?Vo.emit("unhandledRejection",r,n):iu(Zo,n,r)})),t.rejection=Co||uu(t)?2:1,e.error))throw e.value}))},uu=function(t){return 1!==t.rejection&&!t.parent},au=function(t){_o.call(fo,(function(){var e=t.facade;Co?Vo.emit("rejectionHandled",e):iu("rejectionhandled",e,t.value)}))},cu=function(t,e,n){return function(r){t(e,r,n)}},su=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,ru(t,!0))},fu=function t(e,n,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===n)throw Go("Promise can't be resolved itself");var i=nu(n);i?ko((function(){var r={done:!1};try{i.call(n,cu(t,r,e),cu(su,r,e))}catch(t){su(r,t,e)}})):(e.value=n,e.state=1,ru(e,!1))}catch(t){su({done:!1},t,e)}}};if(tu&&(Ko=(qo=function(t){xo(this,qo,Fo),wo(t),to.call(this);var e=Bo(this);try{t(cu(fu,e),cu(su,e))}catch(t){su(e,t)}}).prototype,(to=function(t){zo(this,{type:Fo,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=mo(Ko,{then:function(t,e){var n=Uo(this),r=Xo(Do(this,qo));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=Co?Vo.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&ru(n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),eo=function(){var t=new to,e=Bo(t);this.promise=t,this.resolve=cu(fu,e),this.reject=cu(su,e)},Po.f=Xo=function(t){return t===qo||t===no?new eo(t):Yo(t)},"function"==typeof ho&&Wo!==Object.prototype)){ro=Wo.then,$o||(po(Wo,"then",(function(t,e){var n=this;return new qo((function(t,e){ro.call(n,t,e)})).then(t,e)}),{unsafe:!0}),po(Wo,"catch",Ko.catch,{unsafe:!0}));try{delete Wo.constructor}catch(t){}vo&&vo(Wo,Ko)}function lu(){}function hu(){hu.init.call(this)}function pu(t){return void 0===t._maxListeners?hu.defaultMaxListeners:t._maxListeners}function mu(t,e,n){if(e)t.call(n);else for(var r=t.length,i=ju(t,r),o=0;o<r;++o)i[o].call(n)}function vu(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,o=ju(t,i),u=0;u<i;++u)o[u].call(n,r)}function yu(t,e,n,r,i){if(e)t.call(n,r,i);else for(var o=t.length,u=ju(t,o),a=0;a<o;++a)u[a].call(n,r,i)}function du(t,e,n,r,i,o){if(e)t.call(n,r,i,o);else for(var u=t.length,a=ju(t,u),c=0;c<u;++c)a[c].call(n,r,i,o)}function bu(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,o=ju(t,i),u=0;u<i;++u)o[u].apply(n,r)}function gu(t,e,n,r){var i,o,u,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),u=o[e]):(o=t._events=new lu,t._eventsCount=0),u){if("function"==typeof u?u=o[e]=r?[n,u]:[u,n]:r?u.unshift(n):u.push(n),!u.warned&&(i=pu(t))&&i>0&&u.length>i){u.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=u.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else u=o[e]=n,++t._eventsCount;return t}function wu(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function xu(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function ju(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}function Ou(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Fn(t);if(e){var i=Fn(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return In(this,n)}}so({global:!0,wrap:!0,forced:tu},{Promise:qo}),yo(qo,Fo,!1),bo(Fo),no=lo(Fo),so({target:Fo,stat:!0,forced:tu},{reject:function(t){var e=Xo(this);return e.reject.call(void 0,t),e.promise}}),so({target:Fo,stat:!0,forced:tu},{resolve:function(t){return To(this,t)}}),so({target:Fo,stat:!0,forced:eu},{all:function(t){var e=this,n=Xo(e),r=n.resolve,i=n.reject,o=Lo((function(){var n=wo(e.resolve),o=[],u=0,a=1;Oo(t,(function(t){var c=u++,s=!1;o.push(void 0),a++,n.call(e,t).then((function(t){s||(s=!0,o[c]=t,--a||r(o))}),i)})),--a||r(o)}));return o.error&&i(o.value),n.promise},race:function(t){var e=this,n=Xo(e),r=n.reject,i=Lo((function(){var i=wo(e.resolve);Oo(t,(function(t){i.call(e,t).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}}),lu.prototype=Object.create(null),hu.EventEmitter=hu,hu.usingDomains=!1,hu.prototype.domain=void 0,hu.prototype._events=void 0,hu.prototype._maxListeners=void 0,hu.defaultMaxListeners=10,hu.init=function(){this.domain=null,hu.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new lu,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},hu.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},hu.prototype.getMaxListeners=function(){return pu(this)},hu.prototype.emit=function(t){var e,n,r,i,o,u,a,c="error"===t;if(u=this._events)c=c&&null==u.error;else if(!c)return!1;if(a=this.domain,c){if(e=arguments[1],!a){if(e instanceof Error)throw e;var s=new Error('Uncaught, unspecified "error" event. ('+e+")");throw s.context=e,s}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=u[t]))return!1;var f="function"==typeof n;switch(r=arguments.length){case 1:mu(n,f,this);break;case 2:vu(n,f,this,arguments[1]);break;case 3:yu(n,f,this,arguments[1],arguments[2]);break;case 4:du(n,f,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];bu(n,f,this,i)}return!0},hu.prototype.addListener=function(t,e){return gu(this,t,e,!1)},hu.prototype.on=hu.prototype.addListener,hu.prototype.prependListener=function(t,e){return gu(this,t,e,!0)},hu.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,wu(this,t,e)),this},hu.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,wu(this,t,e)),this},hu.prototype.removeListener=function(t,e){var n,r,i,o,u;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)0==--this._eventsCount?this._events=new lu:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){u=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new lu,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i);r.removeListener&&this.emit("removeListener",t,u||e)}return this},hu.prototype.off=function(t,e){return this.removeListener(t,e)},hu.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new lu,this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=new lu:delete n[t]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new lu,this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},hu.prototype.listeners=function(t){var e,n=this._events;return n&&(e=n[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(e):[]},hu.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):xu.call(t,e)},hu.prototype.listenerCount=xu,hu.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Eu=function(t){Nn(n,t);var e=Ou(n);function n(t){var r;return Ln(this,n),Bn(Rn(r=e.call(this)),"timeout",null),Bn(Rn(r),"startTimestamp",-1),r.minDelay=t.min,r.maxDelay=t.max,r.initialDelay=t.initial||0,r.maxAttemptsCount=t.maxAttemptsCount||0,r.maxAttemptsTime=t.maxAttemptsTime||0,r.randomness=t.randomness||0,r.inProgress=!1,r.attemptNum=0,r.prevDelay=0,r.currDelay=0,r}return An(n,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(t){if("number"==typeof t)return this.prevDelay=0,this.currDelay=t,t;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var e=this.currDelay+this.prevDelay;return this.maxDelay&&e>this.maxDelay&&(this.currDelay=this.maxDelay,e=this.maxDelay),this.currDelay=e,e}},{key:"randomize",value:function(t){var e=t*this.randomness,n=Math.round(Math.random()*e*2-e);return Math.max(0,t+n)}},{key:"scheduleAttempt",value:function(t){var e=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var n=this.nextDelay(t);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((function(){return e.attempt()}),n)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(t){this.emit("succeeded",t)}},{key:"failed",value:function(t,e){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(e)}}]),n}(hu),Du=function(t){Nn(n,t);var e=Ou(n);function n(t){var r;return Ln(this,n),Bn(Rn(r=e.call(this)),"resolve",(function(){})),Bn(Rn(r),"reject",(function(){})),r.retrier=new Eu(t),r}return An(n,[{key:"run",value:function(t){var e=this;return this.retrier.on("attempt",(function(){t().then((function(t){return e.retrier.succeeded(t)})).catch((function(t){return e.retrier.failed(t)}))})),this.retrier.on("succeeded",(function(t){return e.resolve(t)})),this.retrier.on("cancelled",(function(){return e.reject(new Error("Cancelled"))})),this.retrier.on("failed",(function(t){return e.reject(t)})),new Promise((function(t,n){e.resolve=t,e.reject=n,e.retrier.start()}))}},{key:"cancel",value:function(){this.retrier.cancel()}}]),n}(hu);function _u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Fn(t);if(e){var i=Fn(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return In(this,n)}}function ku(t){return null!=t}var Tu=function(t){Nn(n,t);var e=_u(n);function n(t){var r;Ln(this,n),Bn(Rn(r=e.call(this)),"backoffDelay",0),Bn(Rn(r),"nextBackoffDelay",0),Bn(Rn(r),"backoffNumber",0),Bn(Rn(r),"timeoutID",null),Bn(Rn(r),"maxNumberOfRetry",-1);var i=t=t||{},o=i.initialDelay,u=i.maxDelay,a=i.randomisationFactor,c=i.factor;if(ku(o)&&o<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(ku(u)&&u<=1)throw new Error("The maximal timeout must be greater than 1.");if(ku(a)&&(a<0||a>1))throw new Error("The randomisation factor must be between 0 and 1.");if(ku(c)&&c<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=o||100,r.maxDelay=u||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=a||0,r.factor=c||2,r.reset(),r}return An(n,[{key:"backoff",value:function(t){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",t),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,t)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(t){if(t<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(t));this.maxNumberOfRetry=t}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var t=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*t))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(t){return new n(t)}}]),n}(hu);return t.AsyncRetrier=Du,t.Backoff=Tu,t.Retrier=Eu,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
{
"name": "@twilio/operation-retrier",
"version": "4.0.3",
"version": "4.0.4-rc.0",
"description": "RTD retrier",

@@ -58,3 +58,15 @@ "author": "Sergei Chertkov",

"typescript": "^4.3.2"
}
},
"browserslist": [
"IE 11",
"last 3 Chrome versions",
"last 3 Firefox versions",
"last 3 Safari versions",
"last 3 Edge versions",
"last 2 iOS version",
"last 2 ChromeAndroid version",
"last 2 FirefoxAndroid version",
"last 2 Samsung versions",
"last 2 UCAndroid versions"
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc