/**
 *
 * MIT License
 *
 * Copyright (c) 2019 Emilio Almansi
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */var SetIntervalAsync=function(a){'use strict';var k=Math.pow;function b(a,b){return b={exports:{}},a(b,b.exports),b.exports}function c(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function d(){return e.apply(this,arguments)}function e(){return e=n(m.mark(function a(b){var c,d,e,f,g,h;return m.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:for(b.stopped=!0,c=0,d=Object.values(b.timeouts);c<d.length;c++)e=d[c],clearTimeout(e);return f=function(){},g=Object.values(b.promises).map(function(a){a.catch(f)}),h=setInterval(f,2147483647),a.next=7,Promise.all(g);case 7:clearInterval(h);case 8:case"end":return a.stop();}},a)})),e.apply(this,arguments)}function f(a){if("function"!=typeof a)throw new z("Invalid argument: \"handler\". Expected a function.")}function g(a){if(!("number"==typeof a&&10<=a))throw new z("Invalid argument: \"interval\". Expected a number greater than or equal to ".concat(10,"."))}function h(a,b,c){for(var d=arguments.length,e=Array(3<d?d-3:0),f=3;f<d;f++)e[f-3]=arguments[f];var g=a.id;a.promises[g]=n(m.mark(function d(){var f,i,j,k;return m.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return f=new Date,d.prev=1,d.next=4,b.apply(void 0,e);case 4:d.next=9;break;case 6:d.prev=6,d.t0=d["catch"](1),console.error(d.t0);case 9:i=new Date,a.stopped||(j=i-f,k=c>j?c-j:0,a.timeouts[g+1]=setTimeout.apply(void 0,[h,k,a,b,c].concat(e))),delete a.timeouts[g],delete a.promises[g];case 13:case"end":return d.stop();}},d,null,[[1,6]])}))(),a.id=g+1}function i(a,b,c){for(var d=arguments.length,e=Array(3<d?d-3:0),f=3;f<d;f++)e[f-3]=arguments[f];var g=a.id;a.promises[g]=n(m.mark(function d(){return m.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.prev=0,d.next=3,b.apply(void 0,e);case 3:d.next=8;break;case 5:d.prev=5,d.t0=d["catch"](0),console.error(d.t0);case 8:a.stopped||(a.timeouts[g+1]=setTimeout.apply(void 0,[i,c,a,b,c].concat(e))),delete a.timeouts[g],delete a.promises[g];case 11:case"end":return d.stop();}},d,null,[[0,5]])}))(),a.id=g+1}function j(a,b,c){for(var d=arguments.length,e=Array(3<d?d-3:0),f=3;f<d;f++)e[f-3]=arguments[f];var g=a.id;a.promises[g]=n(m.mark(function d(){return m.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return a.timeouts[g+1]=setTimeout.apply(void 0,[j,c,a,b,c].concat(e)),d.prev=1,d.next=4,b.apply(void 0,e);case 4:d.next=9;break;case 6:d.prev=6,d.t0=d["catch"](1),console.error(d.t0);case 9:delete a.timeouts[g],delete a.promises[g];case 11:case"end":return d.stop();}},d,null,[[1,6]])}))(),a.id=g+1}var l=b(function(a){var b=function(a){function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return g._invoke=i(a,c,h),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(a){["next","throw","return"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"===i.type)h(i.arg);else{var j=i.arg,k=j.value;return k&&"object"==typeof k&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}}function e(a,c){function e(){return new b(function(b,e){d(a,c,b,e)})}return f=f?f.then(e,e):e()}var f;this._invoke=e}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===w)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===w)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=a.iterator[b.method];if(d===p){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=p,j(a,b),"throw"===b.method))return w;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return w}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,w;var f=e.arg;if(!f)return b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,w;if(f.done)b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=p);else return f;return b.delegate=null,w}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[t];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=p,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:p,done:!0}}var p,q=Object.prototype,r=q.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},t=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",v=s.toStringTag||"@@toStringTag";a.wrap=b;var w={},x={};x[t]=function(){return this};var y=Object.getPrototypeOf,z=y&&y(y(n([])));z&&z!==q&&r.call(z,t)&&(x=z);var A=f.prototype=d.prototype=Object.create(x);return e.prototype=A.constructor=f,f.constructor=e,f[v]=e.displayName="GeneratorFunction",a.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},a.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,f):(a.__proto__=f,!(v in a)&&(a[v]="GeneratorFunction")),a.prototype=Object.create(A),a},a.awrap=function(a){return{__await:a}},g(h.prototype),h.prototype[u]=function(){return this},a.AsyncIterator=h,a.async=function(c,d,e,f,g){void 0===g&&(g=Promise);var i=new h(b(c,d,e,f),g);return a.isGeneratorFunction(d)?i:i.next().then(function(a){return a.done?a.value:i.next()})},g(A),A[v]="Generator",A[t]=function(){return this},A.toString=function(){return"[object Generator]"},a.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},a.values=n,m.prototype={constructor:m,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=p,this.done=!1,this.delegate=null,this.method="next",this.arg=p,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=p)},stop:function(){this.done=!0;var a=this.tryEntries[0],b=a.completion;if("throw"===b.type)throw b.arg;return this.rval},dispatchException:function(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=p),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(g){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);}else if(!h)throw new Error("try statement without catch or finally");else if(this.prev<e.finallyLoc)return b(e.finallyLoc)}}},abrupt:function(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,w):this.complete(f)},complete:function(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),w},finish:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),w},catch:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=p),w}},a}(a.exports);try{regeneratorRuntime=b}catch(a){Function("r","regeneratorRuntime = r")(b)}}),m=l,n=function(a){return function(){var b=this,d=arguments;return new Promise(function(e,f){function g(a){c(i,e,f,g,h,"next",a)}function h(a){c(i,e,f,g,h,"throw",a)}var i=a.apply(b,d);g(void 0)})}},o=k(2,31)-1,p=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},q=b(function(a){function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(d){return a.exports="function"==typeof Symbol&&"symbol"===b(Symbol.iterator)?c=function(a){return b(a)}:c=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":b(a)},c(d)}a.exports=c}),r=function(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a},s=function(a,b){return b&&("object"===q(b)||"function"==typeof b)?b:r(a)},t=b(function(a){function b(c){return a.exports=b=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},b(c)}a.exports=b}),u=b(function(a){function b(c,d){return a.exports=b=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},b(c,d)}a.exports=b}),v=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&u(a,b)},w=function(a){return-1!==Function.toString.call(a).indexOf("[native code]")},x=b(function(a){function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function c(){return a.exports=b()?c=Reflect.construct:c=function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&u(f,d.prototype),f},c.apply(null,arguments)}a.exports=c}),y=b(function(a){function b(c){var d="function"==typeof Map?new Map:void 0;return a.exports=b=function(a){function b(){return x(a,arguments,t(this).constructor)}if(null===a||!w(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof d){if(d.has(a))return d.get(a);d.set(a,b)}return b.prototype=Object.create(a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),u(b,a)},b(c)}a.exports=b}),z=function(a){function b(){return p(this,b),s(this,t(b).apply(this,arguments))}return v(b,a),b}(y(Error));Object.defineProperty(z.prototype,"name",{value:"SetIntervalAsyncError"});var A=function a(){p(this,a),this.stopped=!1,this.id=0,this.timeouts={},this.promises={}};return a.SetIntervalAsyncError=z,a.SetIntervalAsyncTimer=A,a.clearIntervalAsync=d,a.dynamic={setIntervalAsync:function(a,b){f(a),g(b);for(var c=new A,d=c.id,e=arguments.length,i=Array(2<e?e-2:0),j=2;j<e;j++)i[j-2]=arguments[j];return c.timeouts[d]=setTimeout.apply(void 0,[h,b,c,a,b].concat(i)),c}},a.fixed={setIntervalAsync:function(a,b){f(a),g(b);for(var c=new A,d=c.id,e=arguments.length,h=Array(2<e?e-2:0),j=2;j<e;j++)h[j-2]=arguments[j];return c.timeouts[d]=setTimeout.apply(void 0,[i,b,c,a,b].concat(h)),c}},a.legacy={setIntervalAsync:function(a,b){f(a),g(b);for(var c=new A,d=c.id,e=arguments.length,h=Array(2<e?e-2:0),i=2;i<e;i++)h[i-2]=arguments[i];return c.timeouts[d]=setTimeout.apply(void 0,[j,b,c,a,b].concat(h)),c}},a}({});
//# sourceMappingURL=set-interval-async.iife.js.map
