(function(l,g){"object"===typeof exports&&"undefined"!==typeof module?g():"function"===typeof define&&define.amd?define(g):g()})(this,function(){function l(a){var b=this.constructor;return this.then(function(c){return b.resolve(a()).then(function(){return c})},function(c){return b.resolve(a()).then(function(){return b.reject(c)})})}function g(){}function r(a,b){return function(){a.apply(b,arguments)}}function d(a){if(!(this instanceof d))throw new TypeError("Promises must be constructed via new"); if("function"!==typeof a)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=void 0;this._deferreds=[];p(a,this)}function q(a,b){for(;3===a._state;)a=a._value;0===a._state?a._deferreds.push(b):(a._handled=!0,d._immediateFn(function(){var c=1===a._state?b.onFulfilled:b.onRejected;if(null===c)(1===a._state?m:e)(b.promise,a._value);else{try{var d=c(a._value)}catch(f){e(b.promise,f);return}m(b.promise,d)}}))}function m(a,b){try{if(b===a)throw new TypeError("A promise cannot be resolved with itself."); if(b&&("object"===typeof b||"function"===typeof b)){var c=b.then;if(b instanceof d){a._state=3;a._value=b;n(a);return}if("function"===typeof c){p(r(c,b),a);return}}a._state=1;a._value=b;n(a)}catch(h){e(a,h)}}function e(a,b){a._state=2;a._value=b;n(a)}function n(a){2===a._state&&0===a._deferreds.length&&d._immediateFn(function(){a._handled||d._unhandledRejectionFn(a._value)});for(var b=0,c=a._deferreds.length;b