define(["exports"],(function(n){"use strict";function r(n,r){return null!=n?n:r}var t,e,u;function o(n,r,t,e){return i(n).then(r,t,e)}function i(n){var r,t;return n instanceof c?r=n:a(n)?(t=s(),n.then((function(n){t.resolve(n)}),(function(n){t.reject(n)}),(function(n){t.progress(n)})),r=t.promise):r=function(n){var r=new c((function(r){try{return i(r?r(n):n)}catch(n){return f(n)}}));return r}(n),r}function c(n){this.then=n}function f(n){var r=new c((function(r,t){try{return t?i(t(n)):f(n)}catch(n){return f(n)}}));return r}function s(){var n,r,t,e,o,a;return n=new c(h),r=[],t=[],e=function(n,e,u){var o,i;return o=s(),i="function"==typeof u?function(n){try{o.progress(u(n))}catch(n){o.progress(n)}}:function(n){o.progress(n)},r.push((function(r){r.then(n,e).then(o.resolve,o.reject,i)})),t.push(i),o.promise},o=function(n){return v(t,n),n},a=function(n){return n=i(n),e=n.then,a=i,o=y,v(r,n),t=r=u,n},{then:h,resolve:l,reject:p,progress:g,promise:n,resolver:{resolve:l,reject:p,progress:g}};function h(n,r,t){return e(n,r,t)}function l(n){return a(n)}function p(n){return a(f(n))}function g(n){return o(n)}}function a(n){return n&&"function"==typeof n.then}function h(n,r,t,e,u){return g(2,arguments),o(n,(function(n){var i,c,f,a,h,l,p,v,g,j;if(g=n.length>>>0,i=Math.max(0,Math.min(r,g)),f=[],c=g-i+1,a=[],h=s(),i)for(v=h.progress,p=function(n){a.push(n),--c||(l=p=y,h.reject(a))},l=function(n){f.push(n),--i||(l=p=y,h.resolve(f))},j=0;j<g;++j)j in n&&o(n[j],w,m,v);else h.resolve(f);return h.then(t,e,u);function m(n){p(n)}function w(n){l(n)}}))}function l(n,r,t,e){return g(1,arguments),p(n,j).then(r,t,e)}function p(n,r){return o(n,(function(n){var t,e,u,i,c,f;if(u=e=n.length>>>0,t=[],f=s(),u)for(i=function(n,e){o(n,r).then((function(n){t[e]=n,--u||f.resolve(t)}),f.reject)},c=0;c<e;c++)c in n?i(n[c],c):--u;else f.resolve(t);return f.promise}))}function v(n,r){for(var t,e=0;t=n[e++];)t(r)}function g(n,r){for(var t,e=r.length;e>n;)if(null!=(t=r[--e])&&"function"!=typeof t)throw new Error("arg "+e+" must be a function")}function y(){}function j(n){return n}r.EMPTY_OBJECT=Object.freeze({}),o.defer=s,o.resolve=i,o.reject=function(n){return o(n,f)},o.join=function(){return p(arguments,j)},o.all=l,o.map=p,o.reduce=function(n,r){var u=e.call(arguments,1);return o(n,(function(n){var e;return e=n.length,u[0]=function(n,t,u){return o(n,(function(n){return o(t,(function(t){return r(n,t,u,e)}))}))},t.apply(n,u)}))},o.any=function(n,r,t,e){return h(n,1,(function(n){return r?r(n[0]):n[0]}),t,e)},o.some=h,o.allSettled=function(n,r,t,e){return g(1,arguments),o(n,(function(n){var u,i,c,f,a,h,l,p,v;for(l=n.length>>>0,p=n.length>>>0,u=[],i=[],h=(c=s()).progress,a=function(n){i.push(n),--p||(f=a=y,c.resolve(u))},f=function(n,r){u[r]=n,--p||(f=a=y,c.resolve(u))},v=0;v<l;++v)switch(v){case 0:o(n[v],m,g,h);break;case 1:o(n[v],w,g,h);break;case 2:o(n[v],b,g,h);break;case 3:o(n[v],d,g,h);break;case 4:o(n[v],k,g,h);break;default:o(n[v],j,g,h)}return c.then(r,t,e);function g(n){a(n)}function j(n){f(n,0)}function m(n){f(n,0)}function w(n){f(n,1)}function b(n){f(n,2)}function d(n){f(n,3)}function k(n){f(n,4)}}))},o.chain=function(n,r,t){var e=arguments.length>2;return o(n,(function(n){return n=e?t:n,r.resolve(n),n}),(function(n){return r.reject(n),f(n)}),r.progress)},o.isPromise=a,c.prototype={always:function(n,r){return this.then(n,n,r)},otherwise:function(n){return this.then(u,n)},yield:function(n){return this.then((function(){return n}))},spread:function(n){return this.then((function(r){return l(r,(function(r){return n.apply(u,r)}))}))}},e=[].slice,t=[].reduce||function(n){var r,t,e,u,o;if(o=0,u=(r=Object(this)).length>>>0,(t=arguments).length<=1)for(;;){if(o in r){e=r[o++];break}if(++o>=u)throw new TypeError}else e=t[1];for(;o<u;++o)o in r&&(e=n(e,r[o],o,r));return e},n.e=function(n){return null!=n},n.o=o,n.u=r}));
