// JayData 1.3.6
// Dual licensed under MIT and GPL v2
// Copyright JayStack Technologies (http://jaydata.org/licensing)
//
// JayData is a standards-based, cross-platform Javascript library and a set of
// practices to access and manipulate data from various online and offline sources.
//
// Credits:
//     Hajnalka Battancs, Dániel József, János Roden, László Horváth, Péter Nochta
//     Péter Zentai, Róbert Bónay, Szabolcs Czinege, Viktor Borza, Viktor Lázár,
//     Zoltán Gyebrovszki, Gábor Dolla
//
// More info: http://jaydata.org
(function(h,e){h.Entity.buildExtFields=function(b,a){if(!b.isAssignableTo)return[];var c=b.memberDefinitions.getPublicMappedProperties().map(function(a){return a.name});a instanceof h.Array&&a.forEach(function(a){if("object"===typeof a&&a.name){var b=c.indexOf(a.name);0<=b?c[b]=a:c.push(a)}});return c};e.define("Ext.data.proxy.JayData",{extend:"Ext.data.proxy.Server",alias:"proxy.JayData",alternateClassName:["Ext.data.JayData"],config:{queryable:null},doRequest:function(b,a,c){var d=this.buildRequest(b);
this.config.queryable||this.processResponse(!1,b,d,null,a,c);return"read"==b.getAction()?this.doRead(d,b,a,c):d},buildRequest:function(b){var a=e.applyIf(b.getParams()||{},this.getExtraParams()||{}),a=e.applyIf(a,this.getParams(b)),a=e.create("Ext.data.Request",{params:a,action:b.getAction(),records:b.getRecords(),operation:b,proxy:this});b.setRequest(a);return a},doRead:function(b,a,c,d){var f=this;f.buildQueryable(a,f.getQueryable()).toArray({success:function(g){f.processResponse(!0,a,b,g,c,d)},
error:function(g){f.processResponse(!1,a,b,g,c,d)}});return b},buildQueryable:function(b,a){if(!a)return a;var c=b.getFilters();c&&c.forEach(function(b){b.config.hasOwnProperty("scope")?a=a.filter(b.getFilterFn(),b.getScope()):b.getProperty()&&b.getValue()&&(a=a.filter("it."+b.getProperty()+" == this.value",{value:b.getValue()}))});(c=b.getSorters())&&c.forEach(function(b){var c="ASC"===b.getDirection()?a.orderBy:a.orderByDescending;a=b.getSorterFn()?c.call(a,b.getSorterFn()):c.call(a,"it."+b.getProperty())});
var c=b.getPage(),d=b.getLimit();1<c&&(a=a.skip((c-1)*d));return a=a.take(d)}})})($data,Ext);
