//>>built
define("dojox/data/KeyValueStore","dojo/_base/declare,dojo/_base/lang,dojo/_base/xhr,dojo/_base/kernel,dojo/data/util/simpleFetch,dojo/data/util/filter".split(","),function(f,h,m,n,o,k){f=f("dojox.data.KeyValueStore",null,{constructor:function(a){if(a.url)this.url=a.url;this._keyValueString=a.data;this._keyValueVar=a.dataVar;this._keyAttribute="key";this._valueAttribute="value";this._storeProp="_keyValueStore";this._features={"dojo.data.api.Read":!0,"dojo.data.api.Identity":!0};this._loadInProgress=
!1;this._queuedFetches=[];if(a&&"urlPreventCache"in a)this.urlPreventCache=a.urlPreventCache?!0:!1},url:"",data:"",urlPreventCache:!1,_assertIsItem:function(a){if(!this.isItem(a))throw Error("dojox.data.KeyValueStore: a function was passed an item argument that was not an item");},_assertIsAttribute:function(a,b){if(!h.isString(b))throw Error("dojox.data.KeyValueStore: a function was passed an attribute argument that was not an attribute object nor an attribute name string");},getValue:function(a,
b,c){this._assertIsItem(a);this._assertIsAttribute(a,b);a=b==this._keyAttribute?a[this._keyAttribute]:a[this._valueAttribute];void 0===a&&(a=c);return a},getValues:function(a,b){var c=this.getValue(a,b);return c?[c]:[]},getAttributes:function(a){return[this._keyAttribute,this._valueAttribute,a[this._keyAttribute]]},hasAttribute:function(a,b){this._assertIsItem(a);this._assertIsAttribute(a,b);return b==this._keyAttribute||b==this._valueAttribute||b==a[this._keyAttribute]},containsValue:function(a,
b,c){var d=void 0;"string"===typeof c&&(d=k.patternToRegExp(c,!1));return this._containsValue(a,b,c,d)},_containsValue:function(a,b,c,d){a=this.getValues(a,b);for(b=0;b<a.length;++b){var e=a[b];if("string"===typeof e&&d)return null!==e.match(d);if(c===e)return!0}return!1},isItem:function(a){return a&&a[this._storeProp]===this?!0:!1},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(){},getFeatures:function(){return this._features},close:function(){},getLabel:function(a){return a[this._keyAttribute]},
getLabelAttributes:function(){return[this._keyAttribute]},_fetchItems:function(a,b){var c=this,d=function(a,d){var e=null;if(a.query){var e=[],i=a.queryOptions?a.queryOptions.ignoreCase:!1,j={},g;for(g in a.query){var f=a.query[g];"string"===typeof f&&(j[g]=k.patternToRegExp(f,i))}for(i=0;i<d.length;++i){var h=!0,l=d[i];for(g in a.query)f=a.query[g],c._containsValue(l,g,f,j[g])||(h=!1);h&&e.push(l)}}else if(a.identity)for(g in e=[],d){if(j=d[g],j[c._keyAttribute]==a.identity){e.push(j);break}}else 0<
d.length&&(e=d.slice(0,d.length));b(e,a)};if(this._loadFinished)d(a,this._arrayOfAllItems);else if(""!==this.url)if(this._loadInProgress)this._queuedFetches.push({args:a,filter:d});else{this._loadInProgress=!0;var e=m.get({url:c.url,handleAs:"json-comment-filtered",preventCache:this.urlPreventCache});e.addCallback(function(b){c._processData(b);d(a,c._arrayOfAllItems);c._handleQueuedFetches()});e.addErrback(function(a){c._loadInProgress=!1;throw a;})}else if(this._keyValueString)this._processData(eval(this._keyValueString)),
this._keyValueString=null,d(a,this._arrayOfAllItems);else if(this._keyValueVar)this._processData(this._keyValueVar),this._keyValueVar=null,d(a,this._arrayOfAllItems);else throw Error("dojox.data.KeyValueStore: No source data was provided as either URL, String, or Javascript variable data input.");},_handleQueuedFetches:function(){if(0<this._queuedFetches.length){for(var a=0;a<this._queuedFetches.length;a++){var b=this._queuedFetches[a],c=b.filter,d=b.args;c?c(d,this._arrayOfAllItems):this.fetchItemByIdentity(b.args)}this._queuedFetches=
[]}},_processData:function(a){this._arrayOfAllItems=[];for(var b=0;b<a.length;b++)this._arrayOfAllItems.push(this._createItem(a[b]));this._loadFinished=!0;this._loadInProgress=!1},_createItem:function(a){var b={};b[this._storeProp]=this;for(var c in a){b[this._keyAttribute]=c;b[this._valueAttribute]=a[c];break}return b},getIdentity:function(a){return this.isItem(a)?a[this._keyAttribute]:null},getIdentityAttributes:function(){return[this._keyAttribute]},fetchItemByIdentity:function(a){a.oldOnItem=
a.onItem;a.onItem=null;a.onComplete=this._finishFetchItemByIdentity;this.fetch(a)},_finishFetchItemByIdentity:function(a,b){var c=b.scope||n.global;a.length?b.oldOnItem.call(c,a[0]):b.oldOnItem.call(c,null)}});h.extend(f,o);return f});