//>>built
define("dojox/grid/enhanced/plugins/Search","dojo/_base/kernel dojo/_base/lang dojo/_base/declare dojo/_base/array dojo/data/util/filter ../../EnhancedGrid ../_Plugin".split(" "),function(k,h,n,l,m,p,q){k=n("dojox.grid.enhanced.plugins.Search",q,{name:"search",constructor:function(a,b){this.grid=a;b=b&&h.isObject(b)?b:{};this._cacheSize=b.cacheSize||-1;a.searchRow=h.hitch(this,"searchRow")},searchRow:function(a,b){if(h.isFunction(b)){h.isString(a)&&(a=m.patternToRegExp(a));var d=!1;if(a instanceof
RegExp)d=!0;else if(h.isObject(a)){var e=!0,f;for(f in a)h.isString(a[f])&&(a[f]=m.patternToRegExp(a[f])),e=!1;if(e)return}else return;this._search(a,0,b,d)}},_search:function(a,b,d,e){var f=this,c=this._cacheSize,g={start:b,query:this.grid.query,sort:this.grid.getSortProps(),queryOptions:this.grid.queryOptions,onBegin:function(a){f._storeSize=a},onComplete:function(g){l.some(g,function(c,g){return f._checkRow(c,a,e)?(d(b+g,c),!0):!1})||(0<c&&b+c<f._storeSize?f._search(a,b+c,d,e):d(-1,null))}};0<
c&&(g.count=c);this.grid._storeLayerFetch(g)},_checkRow:function(a,b,d){var e=this.grid,f=e.store,c,e=l.filter(e.layout.cells,function(a){return!a.hidden});if(d)return l.some(e,function(c){try{if(c.field)return 0<=String(f.getValue(a,c.field)).search(b)}catch(r){console.log("Search._checkRow() error: ",r)}return!1});for(c in b)if(b[c]instanceof RegExp){for(d=e.length-1;0<=d;--d)if(e[d].field==c)try{if(0>String(f.getValue(a,c)).search(b[c]))return!1;break}catch(g){return!1}if(0>d)return!1}return!0}});
p.registerPlugin(k);return k});