text: Ext.define("Ext.pivot.filter.Value",{alternateClassName:["Mz.aggregate.filter.Value"],extend:"Ext.pivot.filter.Base",alias:"pivotfilter.value",dimensionId:"",topType:"items",topOrder:"top",topSort:true,isTopFilter:false,constructor:function(){var b=this,a=b.callParent(arguments);if(Ext.isEmpty(b.dimensionId)){Ext.raise("dimensionId is mandatory on Value filters")}else{if(!b.parent.matrix.aggregate.getByKey(b.dimensionId)){Ext.raise("There is no aggregate dimension that matches the dimensionId provided")}}b.dimension=b.parent.matrix.aggregate.getByKey(b.dimensionId);b.isTopFilter=(b.operator==="top10");return a},destroy:function(){this.dimension=null;return this.callParent(arguments)},isMatch:function(d){var c=this,a=c.value,b=c.callParent(arguments);if(!b){c.value=c.dimension.renderer(Ext.isNumeric(a)?parseFloat(a):a);b=c.callParent([c.dimension.renderer(Ext.isNumeric(d)?parseFloat(d):d)]);c.value=a}return b},getSerialArgs:function(){return{dimensionId:this.dimensionId,topType:this.topType,topOrder:this.topOrder}},applyFilter:function(c,e){var d=this,a=d.topSort?e:Ext.Array.clone(e),b=[];if(e.length==0){return b}d.sortItemsByGrandTotal(c,a);switch(d.topType){case"items":b=d.extractTop10Items(a);break;case"sum":b=d.extractTop10Sum(a);break;case"percent":b=d.extractTop10Percent(c,a);break}if(!d.topSort){a.length=0}return b},extractTop10Items:function(a){var c=this,d=[],b;for(b=0;b<a.length;b++){if(d.indexOf(a[b]["tempVar"])<0){d.push(a[b]["tempVar"]);if(d.length>c.value||(c.value<b+1&&b>0)){break}}}return Ext.Array.slice(a,b)},extractTop10Sum:function(a){var d=this,c=0,b;for(b=0;b<a.length;b++){c+=a[b]["tempVar"];if(c>=d.value){break}}return Ext.Array.slice(a,b+1)},extractTop10Percent:function(b,g){var h=this,e=0,k=g[0].key.split(b.matrix.keysSeparator),c,d,f,j,l,a;k.length--;j=(k.length>0?k.join(b.matrix.keysSeparator):b.matrix.grandTotalKey);d=(b.isLeftAxis?j:b.matrix.grandTotalKey);f=(b.isLeftAxis?b.matrix.grandTotalKey:j);l=b.matrix.results.get(d,f);a=(l?l.getValue(h.dimensionId):0);for(c=0;c<g.length;c++){e+=g[c]["tempVar"];if((e*100/a)>=h.value){break}}return Ext.Array.slice(g,c+1)},sortItemsByGrandTotal:function(d,b){var e=this,g,f,a,c;for(c=0;c<b.length;c++){g=(d.isLeftAxis?b[c].key:d.matrix.grandTotalKey);f=(d.isLeftAxis?d.matrix.grandTotalKey:b[c].key);a=d.matrix.results.get(g,f);b[c]["tempVar"]=(a?a.getValue(e.dimensionId):0)}Ext.Array.sort(b,function(j,i){var h=d.matrix.naturalSort(j.tempVar,i.tempVar);if(h<0&&e.topOrder==="top"){return 1}if(h>0&&e.topOrder==="top"){return -1}return h})}});