// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/async/AsyncQueue","dojo/_base/declare dojo/_base/lang dojo/Deferred dojo/when dijit/Destroyable ../DelayUtil".split(" "),function(m,n,k,f,p,l){var d=m(p,{_lastPromise:null,_isFinished:!1,_isDestroyed:!1,_lastDfd:null,_lastResult:null,constructor:function(a){n.mixin(this,a)},add:function(a,c){function e(){if(!b._isDestroyed){var a;try{a=h()}catch(q){return(new k).reject(q)}return f(a,function(a){return void 0!==c.delayAfter?l.delay(function(){return a},c.delayAfter):
a})}}c=c||{};var b=this;if(!this._isDestroyed){this._lastDfd||(this.onStarted(),this._lastDfd=new k);this._isFinished=!1;var h="function"===typeof a?a:function(){return a};if(void 0!==c.delayBefore)var d=h,h=function(){return l.delay(d,c.delayBefore)};!this._lastPromise||this._lastPromise.isFulfilled()?this._lastPromise=f(e()):this._lastPromise=f(this._lastPromise).then(e);var g=this._lastPromise;f(g,function(a){g!==b._lastPromise||b._isDestroyed||b._isFinished||g&&!g.isFulfilled()||(b._isFinished=
!0,b._lastDfd.resolve(a),b._lastResult=a,b._lastDfd=null,b.onFinished(a))},this._lastDfd.reject);return this._lastDfd&&this._lastDfd.promise}},getPromise:function(){return this._isDestroyed?null:this._lastDfd&&this._lastDfd.promise||this._lastResult},destroy:function(){this._isDestroyed=!0},isDestroyed:function(){return this._isDestroyed},onStarted:function(){},onFinished:function(a){}});d.executeFunctions=function(a,c){var e=new d;a.forEach(function(a,d){e.add(a,{delayBefore:0===d?void 0:c})});return e.getPromise()};
return d});