//>>built
define("dojo/Deferred",["./has","./_base/lang","./errors/CancelError","./promise/Promise","./promise/instrumentation"],function(r,s,o,p,m){var q=Object.freeze||function(){},k=function(b,a,c,d,f){2===a&&h.instrumentRejected&&0===b.length&&h.instrumentRejected(c,!1,d,f);for(f=0;f<b.length;f++)n(b[f],a,c,d)},n=function(b,a,c,d){var f=b[a],e=b.deferred;if(f)try{var i=f(c);if(0===a)"undefined"!==typeof i&&g(e,a,i);else{if(i&&"function"===typeof i.then){b.cancel=i.cancel;i.then(l(e,1),l(e,2),l(e,0));return}g(e,
1,i)}}catch(j){g(e,2,j)}else g(e,a,c);2===a&&h.instrumentRejected&&h.instrumentRejected(c,!!f,d,e.promise)},l=function(b,a){return function(c){g(b,a,c)}},g=function(b,a,c){if(!b.isCanceled())switch(a){case 0:b.progress(c);break;case 1:b.resolve(c);break;case 2:b.reject(c)}},h=function(b){var a=this.promise=new p,c=this,d,f,e,i=!1,j=[];Error.captureStackTrace&&(Error.captureStackTrace(c,h),Error.captureStackTrace(a,h));this.isResolved=a.isResolved=function(){return 1===d};this.isRejected=a.isRejected=
function(){return 2===d};this.isFulfilled=a.isFulfilled=function(){return!!d};this.isCanceled=a.isCanceled=function(){return i};this.progress=function(b,f){if(d){if(!0===f)throw Error("This deferred has already been fulfilled.");return a}k(j,0,b,null,c);return a};this.resolve=function(b,e){if(d){if(!0===e)throw Error("This deferred has already been fulfilled.");return a}k(j,d=1,f=b,null,c);j=null;return a};var g=this.reject=function(b,h){if(d){if(!0===h)throw Error("This deferred has already been fulfilled.");
return a}Error.captureStackTrace&&Error.captureStackTrace(e={},g);k(j,d=2,f=b,e,c);j=null;return a};this.then=a.then=function(b,c,i){var g=[i,b,c];g.cancel=a.cancel;g.deferred=new h(function(a){return g.cancel&&g.cancel(a)});d&&!j?n(g,d,f,e):j.push(g);return g.deferred.promise};this.cancel=a.cancel=function(a,c){if(d){if(!0===c)throw Error("This deferred has already been fulfilled.");}else{if(b)var e=b(a),a="undefined"===typeof e?a:e;i=!0;if(d){if(2===d&&f===a)return a}else return"undefined"===typeof a&&
(a=new o),g(a),a}};q(a)};h.prototype.toString=function(){return"[object Deferred]"};m&&m(h);return h});