//>>built
define("dojox/data/CsvStore","dojo/_base/lang dojo/_base/declare dojo/_base/xhr dojo/_base/kernel dojo/data/util/filter dojo/data/util/simpleFetch".split(" "),function(u,q,v,z,w,A){q=q("dojox.data.CsvStore",null,{constructor:function(a){this._attributes=[];this._attributeIndexes={};this._dataArray=[];this._arrayOfAllItems=[];this._loadFinished=!1;a.url&&(this.url=a.url);this._csvData=a.data;a.label?this.label=a.label:""===this.label&&(this.label=void 0);this._storeProp="_csvStore";this._idProp="_csvId";
this._features={"dojo.data.api.Read":!0,"dojo.data.api.Identity":!0};this._loadInProgress=!1;this._queuedFetches=[];this.identifier=a.identifier;""===this.identifier?delete this.identifier:this._idMap={};"separator"in a&&(this.separator=a.separator);"urlPreventCache"in a&&(this.urlPreventCache=a.urlPreventCache?!0:!1)},url:"",label:"",identifier:"",separator:",",urlPreventCache:!1,_assertIsItem:function(a){if(!this.isItem(a))throw Error(this.declaredClass+": a function was passed an item argument that was not an item");
},_getIndex:function(a){a=this.getIdentity(a);this.identifier&&(a=this._idMap[a]);return a},getValue:function(a,c,b){this._assertIsItem(a);var d=b;if("string"===typeof c)c=this._attributeIndexes[c],null!=c&&(d=this._dataArray[this._getIndex(a)][c]||b);else throw Error(this.declaredClass+": a function was passed an attribute argument that was not a string");return d},getValues:function(a,c){var b=this.getValue(a,c);return b?[b]:[]},getAttributes:function(a){this._assertIsItem(a);var c=[];a=this._dataArray[this._getIndex(a)];
for(var b=0;b<a.length;b++)""!==a[b]&&c.push(this._attributes[b]);return c},hasAttribute:function(a,c){this._assertIsItem(a);if("string"===typeof c){var b=this._attributeIndexes[c],d=this._dataArray[this._getIndex(a)];return"undefined"!==typeof b&&b<d.length&&""!==d[b]}throw Error(this.declaredClass+": a function was passed an attribute argument that was not a string");},containsValue:function(a,c,b){var d=void 0;"string"===typeof b&&(d=w.patternToRegExp(b,!1));return this._containsValue(a,c,b,d)},
_containsValue:function(a,c,b,d){a=this.getValues(a,c);for(c=0;c<a.length;++c){var e=a[c];if("string"===typeof e&&d)return null!==e.match(d);if(b===e)return!0}return!1},isItem:function(a){if(a&&a[this._storeProp]===this)if(a=a[this._idProp],this.identifier){if(this._dataArray[this._idMap[a]])return!0}else if(0<=a&&a<this._dataArray.length)return!0;return!1},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){},getFeatures:function(){return this._features},getLabel:function(a){if(this.label&&
this.isItem(a))return this.getValue(a,this.label)},getLabelAttributes:function(a){return this.label?[this.label]:null},_fetchItems:function(a,c,b){var d=this,e=function(f,g){var n=null;if(f.query){var m;n=[];var p=f.queryOptions?f.queryOptions.ignoreCase:!1,r={};for(m in f.query){var t=f.query[m];"string"===typeof t&&(r[m]=w.patternToRegExp(t,p))}for(p=0;p<g.length;++p){var x=!0,y=g[p];for(m in f.query)t=f.query[m],d._containsValue(y,m,t,r[m])||(x=!1);x&&n.push(y)}}else n=g.slice(0,g.length);c(n,
f)};if(this._loadFinished)e(a,this._arrayOfAllItems);else if(""!==this.url)if(this._loadInProgress)this._queuedFetches.push({args:a,filter:e});else{this._loadInProgress=!0;var k=v.get({url:d.url,handleAs:"text",preventCache:d.urlPreventCache});k.addCallback(function(f){try{d._processData(f),e(a,d._arrayOfAllItems),d._handleQueuedFetches()}catch(g){b(g,a)}});k.addErrback(function(f){d._loadInProgress=!1;if(b)b(f,a);else throw f;});var h=null;a.abort&&(h=a.abort);a.abort=function(){var f=k;f&&-1===
f.fired&&(f.cancel(),f=null);h&&h.call(a)}}else if(this._csvData)try{this._processData(this._csvData),this._csvData=null,e(a,this._arrayOfAllItems)}catch(f){b(f,a)}else{var l=Error(this.declaredClass+": No CSV source data was provided as either URL or String data input.");if(b)b(l,a);else throw l;}},close:function(a){},_getArrayOfArraysFromCsvFileContents:function(a){if(u.isString(a)){var c=RegExp("^\\s+","g"),b=RegExp("\\s+$","g"),d=RegExp('""',"g"),e=[],k=this._splitLines(a);for(a=0;a<k.length;++a){var h=
k[a];if(0<h.length){h=h.split(this.separator);for(var l=0;l<h.length;){var f=h[l].replace(c,""),g=f.replace(b,""),n=g.charAt(0),m=g.charAt(g.length-1),p=g.charAt(g.length-2),r=g.charAt(g.length-3);if(2===g.length&&'""'==g)h[l]="";else if('"'==n&&('"'!=m||'"'==m&&'"'==p&&'"'!=r)){if(l+1===h.length)return;h[l]=f+this.separator+h[l+1];h.splice(l+1,1)}else'"'==n&&'"'==m&&(g=g.slice(1,g.length-1),g=g.replace(d,'"')),h[l]=g,l+=1}e.push(h)}}this._attributes=e.shift();for(a=0;a<this._attributes.length;a++)this._attributeIndexes[this._attributes[a]]=
a;this._dataArray=e}},_splitLines:function(a){var c=[],b,d="",e=!1;for(b=0;b<a.length;b++){var k=a.charAt(b);switch(k){case '"':e=!e;d+=k;break;case "\r":e?d+=k:(c.push(d),d="",b<a.length-1&&"\n"==a.charAt(b+1)&&b++);break;case "\n":e?d+=k:(c.push(d),d="");break;default:d+=k}}""!==d&&c.push(d);return c},_processData:function(a){this._getArrayOfArraysFromCsvFileContents(a);this._arrayOfAllItems=[];if(this.identifier&&void 0===this._attributeIndexes[this.identifier])throw Error(this.declaredClass+": Identity specified is not a column header in the data set.");
for(a=0;a<this._dataArray.length;a++){var c=a;this.identifier&&(c=this._dataArray[a][this._attributeIndexes[this.identifier]],this._idMap[c]=a);this._arrayOfAllItems.push(this._createItemFromIdentity(c))}this._loadFinished=!0;this._loadInProgress=!1},_createItemFromIdentity:function(a){var c={};c[this._storeProp]=this;c[this._idProp]=a;return c},getIdentity:function(a){return this.isItem(a)?a[this._idProp]:null},fetchItemByIdentity:function(a){var c=a.scope?a.scope:z.global;if(this._loadFinished){var b=
this._createItemFromIdentity(a.identity);this.isItem(b)||(b=null);a.onItem&&a.onItem.call(c,b)}else{var d=this;if(""!==this.url)this._loadInProgress?this._queuedFetches.push({args:a}):(this._loadInProgress=!0,b=v.get({url:d.url,handleAs:"text"}),b.addCallback(function(e){try{d._processData(e);var k=d._createItemFromIdentity(a.identity);d.isItem(k)||(k=null);a.onItem&&a.onItem.call(c,k);d._handleQueuedFetches()}catch(h){a.onError&&a.onError.call(c,h)}}),b.addErrback(function(e){this._loadInProgress=
!1;a.onError&&a.onError.call(c,e)}));else if(this._csvData)try{d._processData(d._csvData),d._csvData=null,b=d._createItemFromIdentity(a.identity),d.isItem(b)||(b=null),a.onItem&&a.onItem.call(c,b)}catch(e){a.onError&&a.onError.call(c,e)}}},getIdentityAttributes:function(a){return this.identifier?[this.identifier]:null},_handleQueuedFetches:function(){if(0<this._queuedFetches.length){for(var a=0;a<this._queuedFetches.length;a++){var c=this._queuedFetches[a],b=c.filter,d=c.args;b?b(d,this._arrayOfAllItems):
this.fetchItemByIdentity(c.args)}this._queuedFetches=[]}}});u.extend(q,A);return q});