//>>built
define("dojox/grid/_SelectionPreserver",["dojo/_base/declare","dojo/_base/connect","dojo/_base/lang","dojo/_base/array"],function(g,c,e,h){return g("dojox.grid._SelectionPreserver",null,{constructor:function(a){this.selection=a;var b=this.grid=a.grid;this.reset();this._connects=[c.connect(b,"_setStore",this,"reset"),c.connect(b,"_addItem",this,"_reSelectById"),c.connect(a,"onSelected",e.hitch(this,"_selectById",!0)),c.connect(a,"onDeselected",e.hitch(this,"_selectById",!1)),c.connect(a,"deselectAll",
this,"reset")]},destroy:function(){this.reset();h.forEach(this._connects,c.disconnect);delete this._connects},reset:function(){this._selectedById={}},_reSelectById:function(a,b){a&&this.grid._hasIdentity&&(this.selection.selected[b]=this._selectedById[this.grid.store.getIdentity(a)])},_selectById:function(a,b){if("none"!=this.selection.mode&&this.grid._hasIdentity){var d=b,f=this.grid;if("number"==typeof b||"string"==typeof b)d=(d=f._by_idx[b])&&d.item;d&&(this._selectedById[f.store.getIdentity(d)]=
!!a);return d}}})});