(function(){u8.Base.SelectionsModelMixIn=function(e){};$.extend(u8.Base.SelectionsModelMixIn,{registerSelection:function(e){if(!this._uniqueId){this._uniqueId=u8.Base.Dom.uniqueId()}if(!this._selections){this._selections={}}e=$.extend({model:this,eventName:"Update",getterName:"getSelection",setterName:"setSelection"},e);if(e.model==this&&(e.filter===null||e.filter===undefined)){e.filter=e.id}if(typeof e.filter=="string"){e.filter=function(e,i,t){return t.what==e}.curry(e.filter)}if(e.filter===null||e.filter===undefined){e.filter=u8._["true"]}var i=this._uniqueId+"_"+e.id;var t=this._selections[e.id];if(t){t.model.unbind(t.eventName,i)}e.model.bind(e.eventName||"Update",this._onSelectionUpdate.bind(this,e),i);this._selections[e.id]=e},clearSelection:function(e){var i=this._selections[e];if(i){i.model[i.setterName]("clear")}},clearAllSelections:function(){for(var e in this._selections){this.clearSelection(e)}},_onSelectionUpdate:function(e,i,t){if(e.eventName=="Update"&&t.reason!="selection"){return}if(!e.filter(i,t)){return}var n=e.model[e.getterName]();if(!n){return}if(u8.tools.isArray(n)&&n.length<1){return}for(var l in this._selections){if(l!=e.id){this.clearSelection(l)}}}})})();