//>>built
define("dojox/store/priority",["dojo/_base/lang","dojo/Deferred","dojo/when"],function(v,r,m){function n(){for(var b=k.length-1;b>=p;b--){var a=k[b],c=a&&a[a.length-1];if(c){a.pop();p++;try{c.executor(function(){p--;n()})}catch(d){c.def.reject(d),n()}}}}function w(){var b=new r;return{promise:{total:{then:function(a,c){return b.then(function(d){return d.results.total}).then(a,c)}},forEach:function(a,c){return b.then(function(d){return d.results.forEach(a,c)})},map:function(a,c){return b.then(function(d){return d.results.map(a,
c)})},filter:function(a,c){return b.then(function(d){return d.results.filter(a,c)})},then:function(a,c){return b.then(function(d){return m(d.results,a,c)})}},resolve:b.resolve,reject:b.reject}}var k=[],p=0;return function(b,a){a=a||{};var c=v.delegate(b);["add","put","query","remove","get"].forEach(function(d){var l=b[d];l&&(c[d]=function(q,e){e=e||{};if(e.immediate)return l.call(b,q,e);e.immediate=!0;if("query"===d){var t=function(h){var f=l.call(b,q,e);g.resolve({results:f});m(f,h,h)};var g=w()}else t=
function(h){m(l.call(b,q,e),function(f){g.resolve(f);h()},function(f){g.reject(f);h()})},g=new r;var u=-1<e.priority?e.priority:-1<a.priority?a.priority:4;(k[u]||(k[u]=[])).push({executor:t,def:g});n();return g.promise})});return c}});