(function(){"use strict";u8.Crm.FilterSet=function(t){$.extend(this,t);if(!this.items){this.items=[]}};u8.Crm.FilterSet.makeClass({name:"FilterSet"});$.extend(u8.Crm.FilterSet.prototype,{loadFilters:function(t){if(!this.items){return t&&t()}return u8.services.queries.filters.loadForFilterSet(this,t)},findItemByInfoAreaId:function(t){var e=this.indexOfInfoAreaId(t);return e<0?null:this.items[e]},indexOfInfoAreaId:function(t){if(this.items){for(var e=0;e<this.items.length;e++){if(this.items[e].infoAreaId==t){return e}}}return-1},getFilters:function(t){var e=this.items;if(!t){return e.map(function(t){return t?t.filter:null})}return e.map(function(t){return t.filter?t.filter.toStatementString():""})},clone:function(){var t={};for(var e in this){if(this.hasOwnProperty(e)){t[e]=this[e]}}var i=new u8.Crm.FilterSet(t);if(!this.items){i.items=null}else{i.items=[];for(var r=0;r<this.items.length;r++){var n=this.items[r];i.items.push(new u8.Crm.FilterSetItem(n))}}return i},cloneWithInfoAreaIds:function(t){var e=this.clone();e.items=t.map(function(t){return e.findItemByInfoAreaId(t)||u8.create("FilterSetItem",{infoAreaId:t})});return e},toTransport:function(t){var e=t?t.includeFilters:false;var i=this.clone();if(i.items){for(var r=0;r<i.items.length;r++){var n=i.items[r];if(n){var s=n.filter;delete n.filter;if(e&&s){n.filterStatement=s.toStatementString()}}}}i._xsiElementName="FilterSet";return i},equals:function(t){if(this.items.length!=t.items.length){return false}for(var e=0;e<this.items.length;e++){var i=this.items[e].filter;var r=t.items[e].filter;if(!i!=!r){return false}if(i&&i.toStatementString()!=r.toStatementString()){return false}if(this.items[e].infoAreaId!=t.items[e].infoAreaId){return false}if(this.items[e].visible!=t.items[e].visible){return false}}return true}})})();