text: /*
  * Kendo UI v2014.1.416 (http://www.telerik.com/kendo-ui)
  * Copyright 2014 Telerik AD. All rights reserved.
  *
  * Kendo UI commercial licenses may be obtained at
  * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
  * If you do not own a commercial license, this file shall be governed by the trial license terms.
  */
  !function(e,define){define(["./kendo.core.min","./kendo.data.odata.min","./kendo.data.xml.min"],e)}(function(){return function(e,t){function n(e,t,n,r){return function(i){var o,a={};for(o in i)a[o]=i[o];a.field=r?n+"."+i.field:n,t==vt&&e._notifyChange&&e._notifyChange(a),e.trigger(t,a)}}function r(t,n){if(t===n)return!0;var i,o=e.type(t),a=e.type(n);if(o!==a)return!1;if("date"===o)return t.getTime()===n.getTime();if("object"!==o&&"array"!==o)return!1;for(i in t)if(!r(t[i],n[i]))return!1;return!0}function i(e,t){var n,r;for(r in e){if(n=e[r],et(n)&&n.field&&n.field===t)return n;if(n===t)return n}return null}function o(e){this.data=e||[]}function a(e,n){if(e){var r=typeof e===dt?{field:e,dir:n}:e,i=nt(r)?r:r!==t?[r]:[];return rt(i,function(e){return!!e.dir})}}function s(e){var t,n,r,i,o=e.filters;if(o)for(t=0,n=o.length;n>t;t++)r=o[t],i=r.operator,i&&typeof i===dt&&(r.operator=I[i.toLowerCase()]||i),s(r)}function u(e){return e&&!tt(e)?((nt(e)||!e.filters)&&(e={logic:"and",filters:nt(e)?e:[e]}),s(e),e):t}function l(e){return nt(e)?e:[e]}function c(e,n){var r=typeof e===dt?{field:e,dir:n}:e,i=nt(r)?r:r!==t?[r]:[];return H(i,function(e){return{field:e.field,dir:e.dir||"asc",aggregates:e.aggregates}})}function d(e,t){return e&&e.getTime&&t&&t.getTime?e.getTime()===t.getTime():e===t}function f(e,t,n,r,i,o){var a,s,u,l,c;for(t=t||[],l=t.length,a=0;l>a;a++)s=t[a],u=s.aggregate,c=s.field,e[c]=e[c]||{},o[c]=o[c]||{},o[c][u]=o[c][u]||{},e[c][u]=L[u.toLowerCase()](e[c][u],n,st.accessor(c),r,i,o[c][u])}function h(e){return"number"==typeof e&&!isNaN(e)}function p(e){var t,n=e.length,r=Array(n);for(t=0;n>t;t++)r[t]=e[t].toJSON();return r}function g(e,t){t=t||{};var n=new o(e),r=t.aggregate,i=t.filter;return i&&(n=n.filter(i)),n.aggregate(r)}function m(e,t,n,r,i){var o,a,s,u,l;for(u=0,l=e.length;l>u;u++){o=e[u];for(a in t)s=i[a],s&&s!==a&&(o[s]=t[a](o),delete o[a])}}function v(e,t,n,r,i){var o,a,s,u,l;for(u=0,l=e.length;l>u;u++){o=e[u];for(a in t)o[a]=n._parse(a,t[a](o)),s=i[a],s&&s!==a&&delete o[s]}}function y(e,t,n,r,i){var o,a,s,u;for(a=0,u=e.length;u>a;a++)o=e[a],s=r[o.field],s&&s!=o.field&&(o.field=s),o.value=n._parse(o.field,o.value),o.hasSubgroups?y(o.items,t,n,r,i):v(o.items,t,n,r,i)}function _(e,t,n,r,i,o){return function(a){return a=e(a),a&&!tt(r)&&("[object Array]"===Ht.call(a)||a instanceof Lt||(a=[a]),n(a,r,new t,i,o)),a||[]}}function w(e,t,n,r){for(var i,o,a,s=0;t.length&&r&&(i=t[s],o=i.items,a=o.length,e&&e.field===i.field&&e.value===i.value?(e.hasSubgroups&&e.items.length?w(e.items[e.items.length-1],i.items,n,r):(o=o.slice(n,n+r),e.items=e.items.concat(o)),t.splice(s--,1)):i.hasSubgroups&&o.length?w(i,o,n,r):(o=o.slice(n,n+r),i.items=o,i.items.length||t.splice(s--,1)),0===o.length?n-=a:(n=0,r-=o.length),!(++s>=t.length)););t.length>s&&t.splice(s,t.length-s)}function b(e){var t,n,r=[];for(t=0,n=e.length;n>t;t++)r=e[t].hasSubgroups?r.concat(b(e[t].items)):r.concat(e[t].items.slice());return r}function S(e,t){var n,r,i,o;if(t)for(n=0,r=e.length;r>n;n++)i=e[n],o=i.items,i.hasSubgroups?S(o,t):!o.length||o[0]instanceof t||(o.type=t,o.wrapAll(o,o))}function M(e,t){var n,r;for(n=0,r=e.length;r>n;n++)if(e[n].hasSubgroups){if(M(e[n].items,t))return!0}else if(t(e[n].items,e[n]))return!0}function x(e,t){var n,r;for(n=0,r=e.length;r>n;n++)if(e[n].uid==t.uid)return t=e[n],e.splice(n,1),t}function k(e,t){var n,r,i,o;for(i=e.length-1,o=0;i>=o;i--)r=e[i],n={value:t.get(r.field),field:r.field,items:n?[n]:[t],hasSubgroups:!!n,aggregates:{}};return n}function T(e,t){return t?O(e,function(e){return e[t.idField]===t.id}):-1}function C(e,t){return t?O(e,function(e){return e.uid==t.uid}):-1}function O(e,t){var n,r;for(n=0,r=e.length;r>n;n++)if(t(e[n]))return n;return-1}function z(e,t){var n,r;return e&&!tt(e)?(n=e[t],r=et(n)?n.from||n.field||t:e[t]||t,ut(r)?t:r):t}function D(e,t){var n,r,i,o={};for(i in e)"filters"!==i&&(o[i]=e[i]);if(e.filters)for(o.filters=[],n=0,r=e.filters.length;r>n;n++)o.filters[n]=D(e.filters[n],t);else o.field=z(t.fields,o.field);return o}function P(e,t){var n,r,i,o,a,s=[];for(n=0,r=e.length;r>n;n++){i={},o=e[n];for(a in o)i[a]=o[a];i.field=z(t.fields,i.field),i.aggregates&&nt(i.aggregates)&&(i.aggregates=P(i.aggregates,t)),s.push(i)}return s}function A(t,n){var r,i,o,a,s,u=e(t)[0].children,l=[],c=n[0],d=n[1];for(r=0,i=u.length;i>r;r++)o={},s=u[r],s.disabled||(o[c.field]=s.text,a=s.attributes.value,a=a&&a.specified?s.value:s.text,o[d.field]=a,l.push(o));return l}function F(t,n){var r,i,o,a,s,u,l,c=e(t)[0].tBodies[0],d=c?c.rows:[],f=n.length,h=[];for(r=0,i=d.length;i>r;r++){for(s={},l=!0,a=d[r].cells,o=0;f>o;o++)u=a[o],"th"!==u.nodeName.toLowerCase()&&(l=!1,s[n[o].field]=u.innerHTML);l||h.push(s)}return h}function N(e){return function(){var t=this._data,n=G.fn[e].apply(this,Nt.call(arguments));return this._data!=t&&this._attachBubbleHandlers(),n}}function E(t,n){function r(e,t){return e.filter(t).add(e.find(t))}var i,o,a,s,u,l,c,d,f=e(t).children(),h=[],p=n[0].field,g=n[1]&&n[1].field,m=n[2]&&n[2].field,v=n[3]&&n[3].field;for(i=0,o=f.length;o>i;i++)a={_loaded:!0},s=f.eq(i),l=s[0].firstChild,d=s.children(),t=d.filter("ul"),d=d.filter(":not(ul)"),u=s.attr("data-id"),u&&(a.id=u),l&&(a[p]=3==l.nodeType?l.nodeValue:d.text()),g&&(a[g]=r(d,"a").attr("href")),v&&(a[v]=r(d,"img").attr("src")),m&&(c=r(d,".k-sprite").prop("className"),a[m]=c&&e.trim(c.replace("k-sprite",""))),t.length&&(a.items=E(t.eq(0),n)),"true"==s.attr("data-hasChildren")&&(a.hasChildren=!0),h.push(a);return h}var H,R,q,j,I,L,U,B,W,$,G,J,V,Y,Q,Z,X=e.extend,K=e.proxy,et=e.isPlainObject,tt=e.isEmptyObject,nt=e.isArray,rt=e.grep,it=e.ajax,ot=e.each,at=e.noop,st=window.kendo,ut=st.isFunction,lt=st.Observable,ct=st.Class,dt="string",ft="function",ht="create",pt="read",gt="update",mt="destroy",vt="change",yt="sync",_t="get",wt="error",bt="requestStart",St="progress",Mt="requestEnd",xt=[ht,pt,gt,mt],kt=function(e){return e},Tt=st.getter,Ct=st.stringify,Ot=Math,zt=[].push,Dt=[].join,Pt=[].pop,At=[].splice,Ft=[].shift,Nt=[].slice,Et=[].unshift,Ht={}.toString,Rt=st.support.stableSort,qt=/^\/Date\((.*?)\)\/$/,jt=/(\r+|\n+)/g,It=/(?=['\\])/g,Lt=lt.extend({init:function(e,t){var n=this;n.type=t||Ut,lt.fn.init.call(n),n.length=e.length,n.wrapAll(e,n)},toJSON:function(){var e,t,n=this.length,r=Array(n);for(e=0;n>e;e++)t=this[e],t instanceof Ut&&(t=t.toJSON()),r[e]=t;return r},parent:at,wrapAll:function(e,t){var n,r,i=this,o=function(){return i};for(t=t||[],n=0,r=e.length;r>n;n++)t[n]=i.wrap(e[n],o);return t},wrap:function(e,t){var n,r=this;return null!==e&&"[object Object]"===Ht.call(e)&&(n=e instanceof r.type||e instanceof $t,n||(e=e instanceof Ut?e.toJSON():e,e=new r.type(e)),e.parent=t,e.bind(vt,function(e){r.trigger(vt,{field:e.field,node:e.node,index:e.index,items:e.items||[this],action:e.node?e.action||"itemchange":"itemchange"})})),e},push:function(){var e,t=this.length,n=this.wrapAll(arguments);return e=zt.apply(this,n),this.trigger(vt,{action:"add",index:t,items:n}),e},slice:Nt,join:Dt,pop:function(){var e=this.length,t=Pt.apply(this);return e&&this.trigger(vt,{action:"remove",index:e-1,items:[t]}),t},splice:function(e,t,n){var r,i,o,a=this.wrapAll(Nt.call(arguments,2));if(r=At.apply(this,[e,t].concat(a)),r.length)for(this.trigger(vt,{action:"remove",index:e,items:r}),i=0,o=r.length;o>i;i++)r[i].children&&r[i].unbind(vt);return n&&this.trigger(vt,{action:"add",index:e,items:a}),r},shift:function(){var e=this.length,t=Ft.apply(this);return e&&this.trigger(vt,{action:"remove",index:0,items:[t]}),t},unshift:function(){var e,t=this.wrapAll(arguments);return e=Et.apply(this,t),this.trigger(vt,{action:"add",index:0,items:t}),e},indexOf:function(e){var t,n,r=this;for(t=0,n=r.length;n>t;t++)if(r[t]===e)return t;return-1},forEach:function(e){for(var t=0,n=this.length;n>t;t++)e(this[t],t,this)},map:function(e){for(var t=0,n=[],r=this.length;r>t;t++)n[t]=e(this[t],t,this);return n},filter:function(e){for(var t,n=0,r=[],i=this.length;i>n;n++)t=this[n],e(t,n,this)&&(r[r.length]=t);return r},find:function(e){for(var t,n=0,r=this.length;r>n;n++)if(t=this[n],e(t,n,this))return t},every:function(e){for(var t,n=0,r=this.length;r>n;n++)if(t=this[n],!e(t,n,this))return!1;return!0},some:function(e){for(var t,n=0,r=this.length;r>n;n++)if(t=this[n],e(t,n,this))return!0;return!1},remove:function(e){this.splice(this.indexOf(e),1)},empty:function(){this.splice(0,this.length)}}),Ut=lt.extend({init:function(e){var t,n,r=this,i=function(){return r};lt.fn.init.call(this);for(n in e)t=e[n],"_"!=n.charAt(0)&&(t=r.wrap(t,n,i)),r[n]=t;r.uid=st.guid()},shouldSerialize:function(e){return this.hasOwnProperty(e)&&"_events"!==e&&typeof this[e]!==ft&&"uid"!==e},forEach:function(e){for(var t in this)this.shouldSerialize(t)&&e(this[t],t)},toJSON:function(){var e,t,n={};for(t in this)this.shouldSerialize(t)&&(e=this[t],(e instanceof Ut||e instanceof Lt)&&(e=e.toJSON()),n[t]=e);return n},get:function(e){var t,n=this;return n.trigger(_t,{field:e}),t="this"===e?n:st.getter(e,!0)(n)},_set:function(e,t){var n,r,i,o=this,a=e.indexOf(".")>=0;if(a)for(n=e.split("."),r="";n.length>1;){if(r+=n.shift(),i=st.getter(r,!0)(o),i instanceof Ut)return i.set(n.join("."),t),a;r+="."}return st.setter(e)(o,t),a},set:function(e,t){var n=this,r=e.indexOf(".")>=0,i=st.getter(e,!0)(n);i!==t&&(n.trigger("set",{field:e,value:t})||(r||(t=n.wrap(t,e,function(){return n})),(!n._set(e,t)||e.indexOf("(")>=0||e.indexOf("[")>=0)&&n.trigger(vt,{field:e})))},parent:at,wrap:function(e,t,r){var i,o,a=this,s=Ht.call(e);return null==e||"[object Object]"!==s&&"[object Array]"!==s||(i=e instanceof Lt,o=e instanceof G,"[object Object]"!==s||o||i?("[object Array]"===s||i||o)&&(i||o||(e=new Lt(e)),e.parent()!=r()&&e.bind(vt,n(a,vt,t,!1))):(e instanceof Ut||(e=new Ut(e)),e.parent()!=r()&&(e.bind(_t,n(a,_t,t,!0)),e.bind(vt,n(a,vt,t,!0)))),e.parent=r),e}}),Bt={number:function(e){return st.parseFloat(e)},date:function(e){return st.parseDate(e)},"boolean":function(e){return typeof e===dt?"true"===e.toLowerCase():null!=e?!!e:e},string:function(e){return null!=e?e+"":e},"default":function(e){return e}},Wt={string:"",number:0,date:new Date,"boolean":!1,"default":""},$t=Ut.extend({init:function(n){var r=this;(!n||e.isEmptyObject(n))&&(n=e.extend({},r.defaults,n)),Ut.fn.init.call(r,n),r.dirty=!1,r.idField&&(r.id=r.get(r.idField),r.id===t&&(r.id=r._defaultId))},shouldSerialize:function(e){return Ut.fn.shouldSerialize.call(this,e)&&"uid"!==e&&!("id"!==this.idField&&"id"===e)&&"dirty"!==e&&"_accessors"!==e},_parse:function(e,t){var n,r=this,o=e,a=r.fields||{};return e=a[e],e||(e=i(a,o)),e&&(n=e.parse,!n&&e.type&&(n=Bt[e.type.toLowerCase()])),n?n(t):t},_notifyChange:function(e){var t=e.action;("add"==t||"remove"==t)&&(this.dirty=!0)},editable:function(e){return e=(this.fields||{})[e],e?e.editable!==!1:!0},set:function(e,t,n){var i=this;i.editable(e)&&(t=i._parse(e,t),r(t,i.get(e))||(i.dirty=!0,Ut.fn.set.call(i,e,t,n)))},accept:function(e){var t,n,r=this,i=function(){return r};for(t in e)n=e[t],"_"!=t.charAt(0)&&(n=r.wrap(e[t],t,i)),r._set(t,n);r.idField&&(r.id=r.get(r.idField)),r.dirty=!1},isNew:function(){return this.id===this._defaultId}});$t.define=function(e,n){n===t&&(n=e,e=$t);var r,i,o,a,s,u,l,c,d=X({defaults:{}},n),f={},h=d.id;if(h&&(d.idField=h),d.id&&delete d.id,h&&(d.defaults[h]=d._defaultId=""),"[object Array]"===Ht.call(d.fields)){for(u=0,l=d.fields.length;l>u;u++)o=d.fields[u],typeof o===dt?f[o]={}:o.field&&(f[o.field]=o);d.fields=f}for(i in d.fields)o=d.fields[i],a=o.type||"default",s=null,c=i,i=typeof o.field===dt?o.field:i,o.nullable||(s=d.defaults[c!==i?c:i]=o.defaultValue!==t?o.defaultValue:Wt[a.toLowerCase()]),n.id===i&&(d._defaultId=s),d.defaults[c!==i?c:i]=s,o.parse=o.parse||Bt[a];return r=e.extend(d),r.define=function(e){return $t.define(r,e)},d.fields&&(r.fields=d.fields,r.idField=d.idField),r},R={selector:function(e){return ut(e)?e:Tt(e)},compare:function(e){var t=this.selector(e);return function(e,n){return e=t(e),n=t(n),null==e&&null==n?0:null==e?-1:null==n?1:e.localeCompare?e.localeCompare(n):e>n?1:n>e?-1:0}},create:function(e){var t=e.compare||this.compare(e.field);return"desc"==e.dir?function(e,n){return t(n,e,!0)}:t},combine:function(e){return function(t,n){var r,i,o=e[0](t,n);for(r=1,i=e.length;i>r;r++)o=o||e[r](t,n);return o}}},q=X({},R,{asc:function(e){var t=this.selector(e);return function(e,n){var r=t(e),i=t(n);return r&&r.getTime&&i&&i.getTime&&(r=r.getTime(),i=i.getTime()),r===i?e.__position-n.__position:null==r?-1:null==i?1:r.localeCompare?r.localeCompare(i):r>i?1:-1}},desc:function(e){var t=this.selector(e);return function(e,n){var r=t(e),i=t(n);return r&&r.getTime&&i&&i.getTime&&(r=r.getTime(),i=i.getTime()),r===i?e.__position-n.__position:null==r?1:null==i?-1:i.localeCompare?i.localeCompare(r):i>r?1:-1}},create:function(e){return this[e.dir](e.field)}}),H=function(e,t){var n,r=e.length,i=Array(r);for(n=0;r>n;n++)i[n]=t(e[n],n,e);return i},j=function(){function e(e){return e.replace(It,"\\").replace(jt,"")}function t(t,n,r,i){var o;return null!=r&&(typeof r===dt&&(r=e(r),o=qt.exec(r),o?r=new Date(+o[1]):i?(r="'"+r.toLowerCase()+"'",n="("+n+" || '').toLowerCase()"):r="'"+r+"'"),r.getTime&&(n="("+n+"?"+n+".getTime():"+n+")",r=r.getTime())),n+" "+t+" "+r}return{eq:function(e,n,r){return t("==",e,n,r)},neq:function(e,n,r){return t("!=",e,n,r)},gt:function(e,n,r){return t(">",e,n,r)},gte:function(e,n,r){return t(">=",e,n,r)},lt:function(e,n,r){return t("<",e,n,r)},lte:function(e,n,r){return t("<=",e,n,r)},startswith:function(t,n,r){return r&&(t="("+t+" || '').toLowerCase()",n&&(n=n.toLowerCase())),n&&(n=e(n)),t+".lastIndexOf('"+n+"', 0) == 0"},endswith:function(t,n,r){return r&&(t="("+t+" || '').toLowerCase()",n&&(n=n.toLowerCase())),n&&(n=e(n)),t+".indexOf('"+n+"', "+t+".length - "+(n||"").length+") >= 0"},contains:function(t,n,r){return r&&(t="("+t+" || '').toLowerCase()",n&&(n=n.toLowerCase())),n&&(n=e(n)),t+".indexOf('"+n+"') >= 0"},doesnotcontain:function(t,n,r){return r&&(t="("+t+" || '').toLowerCase()",n&&(n=n.toLowerCase())),n&&(n=e(n)),t+".indexOf('"+n+"') == -1"}}}(),o.filterExpr=function(e){var n,r,i,a,s,u,l=[],c={and:" && ",or:" || "},d=[],f=[],h=e.filters;for(n=0,r=h.length;r>n;n++)i=h[n],s=i.field,u=i.operator,i.filters?(a=o.filterExpr(i),i=a.expression.replace(/__o\[(\d+)\]/g,function(e,t){return t=+t,"__o["+(f.length+t)+"]"}).replace(/__f\[(\d+)\]/g,function(e,t){return t=+t,"__f["+(d.length+t)+"]"}),f.push.apply(f,a.operators),d.push.apply(d,a.fields)):(typeof s===ft?(a="__f["+d.length+"](d)",d.push(s)):a=st.expr(s),typeof u===ft?(i="__o["+f.length+"]("+a+", "+i.value+")",f.push(u)):i=j[(u||"eq").toLowerCase()](a,i.value,i.ignoreCase!==t?i.ignoreCase:!0)),l.push(i);return{expression:"("+l.join(c[e.logic])+")",fields:d,operators:f}},I={"==":"eq",equals:"eq",isequalto:"eq",equalto:"eq",equal:"eq","!=":"neq",ne:"neq",notequals:"neq",isnotequalto:"neq",notequalto:"neq",notequal:"neq","<":"lt",islessthan:"lt",lessthan:"lt",less:"lt","<=":"lte",le:"lte",islessthanorequalto:"lte",lessthanequal:"lte",">":"gt",isgreaterthan:"gt",greaterthan:"gt",greater:"gt",">=":"gte",isgreaterthanorequalto:"gte",greaterthanequal:"gte",ge:"gte",notsubstringof:"doesnotcontain"},o.normalizeFilter=u,o.prototype={toArray:function(){return this.data},range:function(e,t){return new o(this.data.slice(e,e+t))},skip:function(e){return new o(this.data.slice(e))},take:function(e){return new o(this.data.slice(0,e))},select:function(e){return new o(H(this.data,e))},order:function(e,t){var n={dir:t};return e&&(e.compare?n.compare=e.compare:n.field=e),new o(this.data.slice(0).sort(R.create(n)))},orderBy:function(e){return this.order(e,"asc")},orderByDescending:function(e){return this.order(e,"desc")},sort:function(e,t,n){var r,i,o=a(e,t),s=[];if(n=n||R,o.length){for(r=0,i=o.length;i>r;r++)s.push(n.create(o[r]));return this.orderBy({compare:n.combine(s)})}return this},filter:function(e){var t,n,r,i,a,s,l,c,d=this.data,f=[];if(e=u(e),!e||0===e.filters.length)return this;for(i=o.filterExpr(e),s=i.fields,l=i.operators,a=c=Function("d, __f, __o","return "+i.expression),(s.length||l.length)&&(c=function(e){return a(e,s,l)}),t=0,r=d.length;r>t;t++)n=d[t],c(n)&&f.push(n);return new o(f)},group:function(e,t){e=c(e||[]),t=t||this.data;var n,r=this,i=new o(r.data);return e.length>0&&(n=e[0],i=i.groupBy(n).select(function(r){var i=new o(t).filter([{field:r.field,operator:"eq",value:r.value,ignoreCase:!1}]);return{field:r.field,value:r.value,items:e.length>1?new o(r.items).group(e.slice(1),i.toArray()).toArray():r.items,hasSubgroups:e.length>1,aggregates:i.aggregate(n.aggregates)}})),i},groupBy:function(e){if(tt(e)||!this.data.length)return new o([]);var t,n,r,i,a=e.field,s=this._sortForGrouping(a,e.dir||"asc"),u=st.accessor(a),l=u.get(s[0],a),c={field:a,value:l,items:[]},f=[c];for(r=0,i=s.length;i>r;r++)t=s[r],n=u.get(t,a),d(l,n)||(l=n,c={field:a,value:l,items:[]},f.push(c)),c.items.push(t);return new o(f)},_sortForGrouping:function(e,t){var n,r,i=this.data;if(!Rt){for(n=0,r=i.length;r>n;n++)i[n].__position=n;for(i=new o(i).sort(e,t,q).toArray(),n=0,r=i.length;r>n;n++)delete i[n].__position;return i}return this.sort(e,t).toArray()},aggregate:function(e){var t,n,r={},i={};if(e&&e.length)for(t=0,n=this.data.length;n>t;t++)f(r,e,this.data[t],t,n,i);return r}},L={sum:function(e,t,n){var r=n.get(t);return h(e)?h(r)&&(e+=r):e=r,e},count:function(e){return(e||0)+1},average:function(e,n,r,i,o,a){var s=r.get(n);return a.count===t&&(a.count=0),h(e)?h(s)&&(e+=s):e=s,h(s)&&a.count++,i==o-1&&h(e)&&(e/=a.count),e},max:function(e,t,n){var r=n.get(t);return h(e)||(e=r),r>e&&h(r)&&(e=r),e},min:function(e,t,n){var r=n.get(t);return h(e)||(e=r),e>r&&h(r)&&(e=r),e}},o.process=function(e,n){n=n||{};var r,i=new o(e),s=n.group,u=c(s||[]).concat(a(n.sort||[])),l=n.filter,d=n.skip,f=n.take;return l&&(i=i.filter(l),r=i.toArray().length),u&&(i=i.sort(u),s&&(e=i.toArray())),d!==t&&f!==t&&(i=i.range(d,f)),s&&(i=i.group(s,e)),{total:r,data:i.toArray()}},U=ct.extend({init:function(e){this.data=e.data},read:function(e){e.success(this.data)},update:function(e){e.success(e.data)},create:function(e){e.success(e.data)},destroy:function(e){e.success(e.data)}}),B=ct.extend({init:function(e){var t,n=this;e=n.options=X({},n.options,e),ot(xt,function(t,n){typeof e[n]===dt&&(e[n]={url:e[n]})}),n.cache=e.cache?W.create(e.cache):{find:at,add:at},t=e.parameterMap,ut(e.push)&&(n.push=e.push),n.push||(n.push=kt),n.parameterMap=ut(t)?t:function(e){var n={};return ot(e,function(e,r){e in t&&(e=t[e],et(e)&&(r=e.value(r),e=e.key)),n[e]=r}),n}},options:{parameterMap:kt},create:function(e){return it(this.setup(e,ht))},read:function(n){var r,i,o,a=this,s=a.cache;n=a.setup(n,pt),r=n.success||at,i=n.error||at,o=s.find(n.data),o!==t?r(o):(n.success=function(e){s.add(n.data,e),r(e)},e.ajax(n))},update:function(e){return it(this.setup(e,gt))},destroy:function(e){return it(this.setup(e,mt))},setup:function(e,t){e=e||{};var n,r=this,i=r.options[t],o=ut(i.data)?i.data(e.data):i.data;return e=X(!0,{},i,e),n=X(!0,{},o,e.data),e.data=r.parameterMap(n,t),ut(e.url)&&(e.url=e.url(n)),e}}),W=ct.extend({init:function(){this._store={}},add:function(e,n){e!==t&&(this._store[Ct(e)]=n)},find:function(e){return this._store[Ct(e)]},clear:function(){this._store={}},remove:function(e){delete this._store[Ct(e)]}}),W.create=function(e){var t={inmemory:function(){return new W}};return et(e)&&ut(e.find)?e:e===!0?new W:t[e]()},$=ct.extend({init:function(e){var t,n,r,i,o,a,s,u,l,c,d,f,h,p=this;e=e||{};for(t in e)n=e[t],p[t]=typeof n===dt?Tt(n):n;i=e.modelBase||$t,et(p.model)&&(p.model=r=i.define(p.model)),p.model&&(o=K(p.data,p),a=K(p.groups,p),s=K(p.serialize,p),u={},l={},c={},d={},f=!1,r=p.model,r.fields&&(ot(r.fields,function(e,t){var n;h=e,et(t)&&t.field?h=t.field:typeof t===dt&&(h=t),et(t)&&t.from&&(n=t.from),f=f||n&&n!==e||h!==e,l[e]=Tt(n||h),c[e]=Tt(e),u[n||h]=e,d[e]=n||h}),!e.serialize&&f&&(p.serialize=_(s,r,m,c,u,d))),p._dataAccessFunction=o,p.data=_(o,r,v,l,u,d),p.groups=_(a,r,y,l,u,d))},errors:function(e){return e?e.errors:null},parse:kt,data:kt,total:function(e){return e.length},groups:kt,aggregates:function(){return{}},serialize:function(e){return e}}),G=lt.extend({init:function(e){var n,r,i=this;e&&(r=e.data),e=i.options=X({},i.options,e),i._map={},i._prefetch={},i._data=[],i._pristineData=[],i._ranges=[],i._view=[],i._pristineTotal=0,i._destroyed=[],i._pageSize=e.pageSize,i._page=e.page||(e.pageSize?1:t),i._sort=a(e.sort),i._filter=u(e.filter),i._group=c(e.group),i._aggregate=e.aggregate,i._total=e.total,lt.fn.init.call(i),i.transport=J.create(e,r),ut(i.transport.push)&&i.transport.push({pushCreate:K(i._pushCreate,i),pushUpdate:K(i._pushUpdate,i),pushDestroy:K(i._pushDestroy,i)}),i.reader=new st.data.readers[e.schema.type||"json"](e.schema),n=i.reader.model||{},i._data=i._observe(i._data),i.bind(["push",wt,vt,bt,yt,Mt,St],e)},options:{data:[],schema:{modelBase:$t},serverSorting:!1,serverPaging:!1,serverFiltering:!1,serverGrouping:!1,serverAggregates:!1,batch:!1},_isServerGrouped:function(){var e=this.group()||[];return this.options.serverGrouping&&e.length},_pushCreate:function(e){this._push(e,"pushCreate")},_pushUpdate:function(e){this._push(e,"pushUpdate")},_pushDestroy:function(e){this._push(e,"pushDestroy")},_push:function(e,t){var n=this._readData(e);n||(n=e),this[t](n)},_flatData:function(e){return this._isServerGrouped()?b(e):e},parent:at,get:function(e){var t,n,r=this._flatData(this._data);for(t=0,n=r.length;n>t;t++)if(r[t].id==e)return r[t]},getByUid:function(e){var t,n,r=this._flatData(this._data);if(r)for(t=0,n=r.length;n>t;t++)if(r[t].uid==e)return r[t]},indexOf:function(e){return C(this._data,e)},at:function(e){return this._data[e]},data:function(e){var n=this;return e===t?n._data:(n._data=this._observe(e),n._pristineData=e.slice(0),n._ranges=[],n._addRange(n._data),n._total=n._data.length,n._pristineTotal=n._total,n._process(n._data),t)},view:function(){return this._view},add:function(e){return this.insert(this._data.length,e)},_createNewModel:function(e){return this.reader.model?new this.reader.model(e):new Ut(e)},insert:function(e,t){return t||(t=e,e=0),t instanceof $t||(t=this._createNewModel(t)),this._isServerGrouped()?this._data.splice(e,0,k(this.group(),t)):this._data.splice(e,0,t),t},pushCreate:function(e){var t,n,r,i,o;for(nt(e)||(e=[e]),t=[],n=0;e.length>n;n++)r=e[n],i=this.add(r),t.push(i),o=i.toJSON(),this._isServerGrouped()&&(o=k(this.group(),o)),this._pristineData.push(o);t.length&&this.trigger("push",{type:"create",items:t})},pushUpdate:function(e){var t,n,r,i,o;for(nt(e)||(e=[e]),t=[],n=0;e.length>n;n++)r=e[n],i=this._createNewModel(r),o=this.get(i.id),o?(t.push(o),o.accept(r),o.trigger("change"),this._updatePristineForModel(o,r)):this.pushCreate(r);t.length&&this.trigger("push",{type:"update",items:t})},pushDestroy:function(e){var t,n,r,i,o,a;nt(e)||(e=[e]),t=[],n=this.options.autoSync,this.options.autoSync=!1;try{for(r=0;e.length>r;r++)i=e[r],o=this._createNewModel(i),a=!1,this._eachItem(this._data,function(e){for(var n=0;e.length>n;n++)if(e[n].id===o.id){t.push(e[n]),e.splice(n,1),a=!0;break}}),a&&(this._removePristineForModel(o),this._destroyed.pop())}finally{this.options.autoSync=n}t.length&&this.trigger("push",{type:"destroy",items:t})},remove:function(e){var n,r=this,i=r._isServerGrouped();return this._eachItem(r._data,function(o){return n=x(o,e),n&&i?(n.isNew&&n.isNew()||r._destroyed.push(n),!0):t}),this._removeModelFromRanges(e),this._updateRangesLength(),e},sync:function(){var t,n,r,i=this,o=[],a=[],s=i._destroyed,u=i._flatData(i._data);if(i.reader.model){for(t=0,n=u.length;n>t;t++)u[t].isNew()?o.push(u[t]):u[t].dirty&&a.push(u[t]);r=i._send("create",o),r.push.apply(r,i._send("update",a)),r.push.apply(r,i._send("destroy",s)),e.when.apply(null,r).then(function(){var e,t;for(e=0,t=arguments.length;t>e;e++)i._accept(arguments[e]);i._change({action:"sync"}),i.trigger(yt)})}},cancelChanges:function(e){var t=this;e instanceof st.data.Model?t._cancelModel(e):(t._destroyed=[],t._data=t._observe(t._pristineData),t.options.serverPaging&&(t._total=t._pristineTotal),t._change())},hasChanges:function(){var e,t,n=this._data;if(this._destroyed.length)return!0;for(e=0,t=n.length;t>e;e++)if(n[e].isNew()||n[e].dirty)return!0;return!1},_accept:function(t){var n,r=this,i=t.models,o=t.response,a=0,s=r._isServerGrouped(),u=r._pristineData,l=t.type;if(r.trigger(Mt,{response:o,type:l}),o&&!tt(o)){if(o=r.reader.parse(o),r._handleCustomErrors(o))return;o=r.reader.data(o),nt(o)||(o=[o])}else o=e.map(i,function(e){return e.toJSON()});for("destroy"===l&&(r._destroyed=[]),a=0,n=i.length;n>a;a++)"destroy"!==l?(i[a].accept(o[a]),"create"===l?u.push(s?k(r.group(),i[a]):o[a]):"update"===l&&r._updatePristineForModel(i[a],o[a])):r._removePristineForModel(i[a])},_updatePristineForModel:function(e,t){this._executeOnPristineForModel(e,function(e,n){st.deepExtend(n[e],t)})},_executeOnPristineForModel:function(e,n){this._eachPristineItem(function(r){var i=T(r,e);return i>-1?(n(i,r),!0):t})},_removePristineForModel:function(e){this._executeOnPristineForModel(e,function(e,t){t.splice(e,1)})},_readData:function(e){var t=this._isServerGrouped()?this.reader.groups:this.reader.data;return t(e)},_eachPristineItem:function(e){this._eachItem(this._pristineData,e)},_eachItem:function(e,t){e&&e.length&&(this._isServerGrouped()?M(e,t):t(e))},_pristineForModel:function(e){var n,r,i=function(i){return r=T(i,e),r>-1?(n=i[r],!0):t};return this._eachPristineItem(i),n},_cancelModel:function(e){var t,n=this._pristineForModel(e);this._eachItem(this._data,function(r){t=C(r,e),-1!=t&&(!e.isNew()&&n?r[t].accept(n):r.splice(t,1))})},_promise:function(t,n,r){var i=this,o=i.transport;return e.Deferred(function(e){i.trigger(bt,{type:r}),o[r].call(o,X({success:function(t){e.resolve({response:t,models:n,type:r})},error:function(t,n,r){e.reject(t),i.error(t,n,r)}},t))}).promise()},_send:function(e,t){var n,r,i=this,o=[],a=i.reader.serialize(p(t));if(i.options.batch)t.length&&o.push(i._promise({data:{models:a}},t,e));else for(n=0,r=t.length;r>n;n++)o.push(i._promise({data:a[n]},[t[n]],e));return o},read:function(e){var t=this,n=t._params(e);t._queueRequest(n,function(){t.trigger(bt,{type:"read"})?t._dequeueRequest():(t.trigger(St),t._ranges=[],t.transport.read({data:n,success:K(t.success,t),error:K(t.error,t)}))})},success:function(e){var n=this,r=n.options;return n.trigger(Mt,{response:e,type:"read"}),e=n.reader.parse(e),n._handleCustomErrors(e)?(n._dequeueRequest(),t):(n._total=n.reader.total(e),n._pristineTotal=n._total,n._aggregate&&r.serverAggregates&&(n._aggregateResult=n.reader.aggregates(e)),e=n._readData(e),n._pristineData=e.slice(0),n._data=n._observe(e),n._addRange(n._data),n._process(n._data),n._dequeueRequest(),t)},_addRange:function(e){var t=this,n=t._skip||0,r=n+t._flatData(e).length;t._ranges.push({start:n,end:r,data:e}),t._ranges.sort(function(e,t){return e.start-t.start})},error:function(e,t,n){this._dequeueRequest(),this.trigger(Mt,{}),this.trigger(wt,{xhr:e,status:t,errorThrown:n})},_params:function(e){var t=this,n=X({take:t.take(),skip:t.skip(),page:t.page(),pageSize:t.pageSize(),sort:t._sort,filter:t._filter,group:t._group,aggregate:t._aggregate},e);return t.options.serverPaging||(delete n.take,delete n.skip,delete n.page,delete n.pageSize),t.options.serverGrouping?t.reader.model&&n.group&&(n.group=P(n.group,t.reader.model)):delete n.group,t.options.serverFiltering?t.reader.model&&n.filter&&(n.filter=D(n.filter,t.reader.model)):delete n.filter,t.options.serverSorting?t.reader.model&&n.sort&&(n.sort=P(n.sort,t.reader.model)):delete n.sort,t.options.serverAggregates?t.reader.model&&n.aggregate&&(n.aggregate=P(n.aggregate,t.reader.model)):delete n.aggregate,n},_queueRequest:function(e,n){var r=this;r._requestInProgress?r._pending={callback:K(n,r),options:e}:(r._requestInProgress=!0,r._pending=t,n())},_dequeueRequest:function(){var e=this;e._requestInProgress=!1,e._pending&&e._queueRequest(e._pending.options,e._pending.callback)},_handleCustomErrors:function(e){if(this.reader.errors){var t=this.reader.errors(e);if(t)return this.trigger(wt,{xhr:null,status:"customerror",errorThrown:"custom error",errors:t}),!0}return!1},_observe:function(e){var t=this,n=t.reader.model,r=!1;return n&&e.length&&(r=!(e[0]instanceof n)),e instanceof Lt?r&&(e.type=t.reader.model,e.wrapAll(e,e)):(e=new Lt(e,t.reader.model),e.parent=function(){return t.parent()}),t._isServerGrouped()&&S(e,n),t._changeHandler&&t._data&&t._data instanceof Lt?t._data.unbind(vt,t._changeHandler):t._changeHandler=K(t._change,t),e.bind(vt,t._changeHandler)},_change:function(e){var t,n,r,i=this,o=e?e.action:"";if("remove"===o)for(t=0,n=e.items.length;n>t;t++)e.items[t].isNew&&e.items[t].isNew()||i._destroyed.push(e.items[t]);!i.options.autoSync||"add"!==o&&"remove"!==o&&"itemchange"!==o?(r=parseInt(i._total||i._pristineTotal,10),"add"===o?r+=e.items.length:"remove"===o?r-=e.items.length:"itemchange"===o||"sync"===o||i.options.serverPaging?"sync"===o&&(r=i._pristineTotal=parseInt(i._total,10)):r=i._pristineTotal,i._total=r,i._process(i._data,e)):i.sync()},_process:function(e,n){var r,i=this,a={};i.options.serverPaging!==!0&&(a.skip=i._skip,a.take=i._take||i._pageSize,a.skip===t&&i._page!==t&&i._pageSize!==t&&(a.skip=(i._page-1)*i._pageSize)),i.options.serverSorting!==!0&&(a.sort=i._sort),i.options.serverFiltering!==!0&&(a.filter=i._filter),i.options.serverGrouping!==!0&&(a.group=i._group),i.options.serverAggregates!==!0&&(a.aggregate=i._aggregate,i._aggregateResult=g(e,a)),r=o.process(e,a),i._view=r.data,r.total===t||i.options.serverFiltering||(i._total=r.total),n=n||{},n.items=n.items||i._view,i.trigger(vt,n)},_mergeState:function(e){var n=this;return e!==t&&(n._pageSize=e.pageSize,n._page=e.page,n._sort=e.sort,n._filter=e.filter,n._group=e.group,n._aggregate=e.aggregate,n._skip=e.skip,n._take=e.take,n._skip===t&&(n._skip=n.skip(),e.skip=n.skip()),n._take===t&&n._pageSize!==t&&(n._take=n._pageSize,e.take=n._take),e.sort&&(n._sort=e.sort=a(e.sort)),e.filter&&(n._filter=e.filter=u(e.filter)),e.group&&(n._group=e.group=c(e.group)),e.aggregate&&(n._aggregate=e.aggregate=l(e.aggregate))),e},query:function(e){var n,r=this,i=r.options.serverSorting||r.options.serverPaging||r.options.serverFiltering||r.options.serverGrouping||r.options.serverAggregates;i||(r._data===t||0===r._data.length)&&!r._destroyed.length?r.read(r._mergeState(e)):r.trigger(bt,{type:"read"})||(r.trigger(St),n=o.process(r._data,r._mergeState(e)),r.options.serverFiltering||(r._total=n.total!==t?n.total:r._data.length),r._view=n.data,r._aggregateResult=g(r._data,e),r.trigger(Mt,{}),r.trigger(vt,{items:n.data}))},fetch:function(t){var n=this;return e.Deferred(function(e){var r=function(r){n.unbind(wt,i),e.resolve(),t&&t.call(n,r)},i=function(t){e.reject(t)};n.one(vt,r),n.one(wt,i),n._query()}).promise()},_query:function(e){var t=this;t.query(X({},{page:t.page(),pageSize:t.pageSize(),sort:t.sort(),filter:t.filter(),group:t.group(),aggregate:t.aggregate()},e))},next:function(e){var n=this,r=n.page(),i=n.total();return e=e||{},!r||i&&r+1>n.totalPages()?t:(n._skip=r*n.take(),r+=1,e.page=r,n._query(e),r)},prev:function(e){var n=this,r=n.page();return e=e||{},r&&1!==r?(n._skip=n._skip-n.take(),r-=1,e.page=r,n._query(e),r):t},page:function(e){var n,r=this;return e!==t?(e=Ot.max(Ot.min(Ot.max(e,1),r.totalPages()),1),r._query({page:e}),t):(n=r.skip(),n!==t?Ot.round((n||0)/(r.take()||1))+1:t)},pageSize:function(e){var n=this;return e!==t?(n._query({pageSize:e,page:1}),t):n.take()},sort:function(e){var n=this;return e!==t?(n._query({sort:e}),t):n._sort},filter:function(e){var n=this;return e===t?n._filter:(n._query({filter:e,page:1}),t)},group:function(e){var n=this;return e!==t?(n._query({group:e}),t):n._group},total:function(){return parseInt(this._total||0,10)},aggregate:function(e){var n=this;return e!==t?(n._query({aggregate:e}),t):n._aggregate},aggregates:function(){return this._aggregateResult},totalPages:function(){var e=this,t=e.pageSize()||e.total();return Ot.ceil((e.total()||0)/t)},inRange:function(e,t){var n=this,r=Ot.min(e+t,n.total());
  return!n.options.serverPaging&&n._data.length>0?!0:n._findRange(e,r).length>0},lastRange:function(){var e=this._ranges;return e[e.length-1]||{start:0,end:0,data:[]}},firstItemUid:function(){var e=this._ranges;return e.length&&e[0].data.length&&e[0].data[0].uid},range:function(e,n){var r,i,o,a,s,u,l,c;if(e=Ot.min(e||0,this.total()),r=this,i=Ot.max(Ot.floor(e/n),0)*n,o=Ot.min(i+n,r.total()),a=r._findRange(e,Ot.min(e+n,r.total())),a.length){r._skip=e>r.skip()?Ot.min(o,(r.totalPages()-1)*r.take()):i,r._take=n,s=r.options.serverPaging,u=r.options.serverSorting,l=r.options.serverFiltering,c=r.options.serverAggregates;try{r.options.serverPaging=!0,r._isServerGrouped()||r.group()&&r.group().length||(r.options.serverSorting=!0),r.options.serverFiltering=!0,r.options.serverPaging=!0,r.options.serverAggregates=!0,s&&(r._data=a=r._observe(a)),r._process(a)}finally{r.options.serverPaging=s,r.options.serverSorting=u,r.options.serverFiltering=l,r.options.serverAggregates=c}}else n!==t&&(r._rangeExists(i,o)?e>i&&r.prefetch(o,n,function(){r.range(e,n)}):r.prefetch(i,n,function(){e>i&&o<r.total()&&!r._rangeExists(o,Ot.min(o+n,r.total()))?r.prefetch(o,n,function(){r.range(e,n)}):r.range(e,n)}))},_findRange:function(e,n){var r,i,s,u,l,d,f,h,p,g,m,v,y=this,_=y._ranges,w=[],b=y.options,S=b.serverSorting||b.serverPaging||b.serverFiltering||b.serverGrouping||b.serverAggregates;for(i=0,m=_.length;m>i;i++)if(r=_[i],e>=r.start&&r.end>=e){for(g=0,s=i;m>s;s++)if(r=_[s],p=y._flatData(r.data),p.length&&e+g>=r.start&&(d=r.data,f=r.end,S||(v=c(y.group()||[]).concat(a(y.sort()||[])),h=o.process(r.data,{sort:v,filter:y.filter()}),p=d=h.data,h.total!==t&&(f=h.total)),u=0,e+g>r.start&&(u=e+g-r.start),l=p.length,f>n&&(l-=f-n),g+=l-u,w=y._mergeGroups(w,d,u,l),r.end>=n&&g==n-e))return w;break}return[]},_mergeGroups:function(e,t,n,r){if(this._isServerGrouped()){var i,o=t.toJSON();return e.length&&(i=e[e.length-1]),w(i,o,n,r),e.concat(o)}return e.concat(t.slice(n,r))},skip:function(){var e=this;return e._skip===t?e._page!==t?(e._page-1)*(e.take()||1):t:e._skip},take:function(){return this._take||this._pageSize},_prefetchSuccessHandler:function(e,t,n){var r=this;return function(i){var o,a,s,u=!1,l={start:e,end:t,data:[]};if(r._dequeueRequest(),r.trigger(Mt,{response:i,type:"read"}),i=r.reader.parse(i),s=r._readData(i),s.length){for(o=0,a=r._ranges.length;a>o;o++)if(r._ranges[o].start===e){u=!0,l=r._ranges[o];break}u||r._ranges.push(l)}l.data=r._observe(s),l.end=l.start+r._flatData(l.data).length,r._ranges.sort(function(e,t){return e.start-t.start}),r._total=r.reader.total(i),n&&s.length?n():r.trigger(vt,{})}},prefetch:function(e,t,n){var r=this,i=Ot.min(e+t,r.total()),o={take:t,skip:e,page:e/t+1,pageSize:t,sort:r._sort,filter:r._filter,group:r._group,aggregate:r._aggregate};r._rangeExists(e,i)?n&&n():(clearTimeout(r._timeout),r._timeout=setTimeout(function(){r._queueRequest(o,function(){r.trigger(bt,{type:"read"})?r._dequeueRequest():r.transport.read({data:r._params(o),success:r._prefetchSuccessHandler(e,i,n)})})},100))},_rangeExists:function(e,t){var n,r,i=this,o=i._ranges;for(n=0,r=o.length;r>n;n++)if(e>=o[n].start&&o[n].end>=t)return!0;return!1},_removeModelFromRanges:function(e){var t,n,r,i,o;for(i=0,o=this._ranges.length;o>i&&(r=this._ranges[i],this._eachItem(r.data,function(r){t=x(r,e),t&&(n=!0)}),!n);i++);},_updateRangesLength:function(){var e,t,n,r,i=0;for(n=0,r=this._ranges.length;r>n;n++)e=this._ranges[n],e.start=e.start-i,t=this._flatData(e.data).length,i=e.end-t,e.end=e.start+t}}),J={},J.create=function(e,t){var n,r=e.transport;return r?(r.read=typeof r.read===dt?{url:r.read}:r.read,e.type&&(st.data.transports[e.type]&&!et(st.data.transports[e.type])?n=new st.data.transports[e.type](X(r,{data:t})):r=X(!0,{},st.data.transports[e.type],r),e.schema=X(!0,{},st.data.schemas[e.type],e.schema)),n||(n=ut(r.read)?r:new B(r))):n=new U({data:e.data}),n},G.create=function(e){(nt(e)||e instanceof Lt)&&(e={data:e});var t,n,r,i=e||{},o=i.data,a=i.fields,s=i.table,u=i.select,l={};if(o||!a||i.transport||(s?o=F(s,a):u&&(o=A(u,a))),st.data.Model&&a&&(!i.schema||!i.schema.model)){for(t=0,n=a.length;n>t;t++)r=a[t],r.type&&(l[r.field]=r);tt(l)||(i.schema=X(!0,i.schema,{model:{fields:l}}))}return i.data=o,s=null,i.table=null,i instanceof G?i:new G(i)},V=$t.define({init:function(e){var t=this,n=t.hasChildren||e&&e.hasChildren,r="items",i={};st.data.Model.fn.init.call(t,e),typeof t.children===dt&&(r=t.children),i={schema:{data:r,model:{hasChildren:n,id:t.idField}}},typeof t.children!==dt&&X(i,t.children),i.data=e,n||(n=i.schema.data),typeof n===dt&&(n=st.getter(n)),ut(n)&&(t.hasChildren=!!n.call(t,t)),t._childrenOptions=i,t.hasChildren&&t._initChildren(),t._loaded=!(!e||!e[r]&&!e._loaded)},_initChildren:function(){var e,t,n,r=this;r.children instanceof Y||(e=r.children=new Y(r._childrenOptions),t=e.transport,n=t.parameterMap,t.parameterMap=function(e,t){return e[r.idField||"id"]=r.id,n&&(e=n(e,t)),e},e.parent=function(){return r},e.bind(vt,function(e){e.node=e.node||r,r.trigger(vt,e)}),e.bind(wt,function(e){var t=r.parent();t&&(e.node=e.node||r,t.trigger(wt,e))}),r._updateChildrenField())},append:function(e){this._initChildren(),this.loaded(!0),this.children.add(e)},hasChildren:!1,level:function(){for(var e=this.parentNode(),t=0;e&&e.parentNode;)t++,e=e.parentNode?e.parentNode():null;return t},_updateChildrenField:function(){var e=this._childrenOptions.schema.data;this[e||"items"]=this.children.data()},_childrenLoaded:function(){this._loaded=!0,this._updateChildrenField()},load:function(){var e,n={},r="_query";this.hasChildren?(this._initChildren(),e=this.children,n[this.idField||"id"]=this.id,this._loaded||(e._data=t,r="read"),e.one(vt,K(this._childrenLoaded,this)),e[r](n)):this.loaded(!0)},parentNode:function(){var e=this.parent();return e.parent()},loaded:function(e){return e===t?this._loaded:(this._loaded=e,t)},shouldSerialize:function(e){return $t.fn.shouldSerialize.call(this,e)&&"children"!==e&&"_loaded"!==e&&"hasChildren"!==e&&"_childrenOptions"!==e}}),Y=G.extend({init:function(e){var t=V.define({children:e});G.fn.init.call(this,X(!0,{},{schema:{modelBase:t,model:t}},e)),this._attachBubbleHandlers()},_attachBubbleHandlers:function(){var e=this;e._data.bind(wt,function(t){e.trigger(wt,t)})},remove:function(e){var t,n=e.parentNode(),r=this;return n&&n._initChildren&&(r=n.children),t=G.fn.remove.call(r,e),n&&!r.data().length&&(n.hasChildren=!1),t},success:N("success"),data:N("data"),insert:function(e,t){var n=this.parent();return n&&n._initChildren&&(n.hasChildren=!0,n._initChildren()),G.fn.insert.call(this,e,t)},_find:function(e,t){var n,r,i,o,a;if(i=G.fn[e].call(this,t))return i;if(o=this._flatData(this.data()))for(n=0,r=o.length;r>n;n++)if(a=o[n].children,a instanceof Y&&(i=a[e](t)))return i},get:function(e){return this._find("get",e)},getByUid:function(e){return this._find("getByUid",e)}}),Y.create=function(e){e=e&&e.push?{data:e}:e;var t=e||{},n=t.data,r=t.fields,i=t.list;return n&&n._dataSource?n._dataSource:(n||!r||t.transport||i&&(n=E(i,r)),t.data=n,t instanceof Y?t:new Y(t))},Q=st.Observable.extend({init:function(e,t,n){st.Observable.fn.init.call(this),this._prefetching=!1,this.dataSource=e,this.prefetch=!n;var r=this;e.bind("change",function(){r._change()}),this._syncWithDataSource(),this.setViewSize(t)},setViewSize:function(e){this.viewSize=e,this._recalculate()},at:function(e){var n,r,i=this.pageSize;return e>=this.total()?(this.trigger("endreached",{index:e}),t):this.useRanges?(this.useRanges&&((this.dataOffset>e||e>this.skip+i)&&(r=Math.floor(e/i)*i,this.range(r)),e===this.prefetchThreshold&&this._prefetch(),e===this.midPageThreshold?this.range(this.nextMidRange):e===this.nextPageThreshold?this.range(this.nextFullRange):e===this.pullBackThreshold&&(this.offset===this.skip?this.range(this.previousMidRange):this.range(this.previousFullRange)),n=this.dataSource.at(e-this.dataOffset)),n===t&&this.trigger("endreached",{index:e}),n):this.dataSource.view()[e]},indexOf:function(e){return this.dataSource.data().indexOf(e)+this.dataOffset},total:function(){return parseInt(this.dataSource.total(),10)},next:function(){var e=this,t=e.pageSize,n=e.skip-e.viewSize,r=Ot.max(Ot.floor(n/t),0)*t+t;this.offset=n,this.dataSource.prefetch(r,t,function(){e._goToRange(n,!0)})},range:function(e){if(this.offset!==e){var t=this,n=this.pageSize,r=Ot.max(Ot.floor(e/n),0)*n+n,i=this.dataSource;this.offset=e,this._recalculate(),i.inRange(e,n)?this._goToRange(e):this.prefetch&&i.prefetch(r,n,function(){t._goToRange(e,!0)})}},syncDataSource:function(){var e=this.offset;this.offset=null,this.range(e)},destroy:function(){this.unbind()},_prefetch:function(){var e=this,t=this.pageSize,n=this.skip+t,r=this.dataSource;r.inRange(n,t)||this._prefetching||!this.prefetch||(this._prefetching=!0,this.trigger("prefetching",{skip:n,take:t}),r.prefetch(n,t,function(){e._prefetching=!1,e.trigger("prefetched",{skip:n,take:t})}))},_goToRange:function(e,t){this.offset===e&&(this.dataOffset=e,this._expanding=t,this.dataSource.range(e,this.pageSize))},_change:function(){var e=this.dataSource,t=e.firstItemUid();this.length=this.useRanges?e.lastRange().end:e.view().length,this._firstItemUid===t&&this.useRanges||(this._syncWithDataSource(),this._recalculate(),this.trigger("reset",{offset:this.offset})),this.trigger("resize"),this._expanding&&this.trigger("expand"),delete this._expanding},_syncWithDataSource:function(){var e=this.dataSource;this._firstItemUid=e.firstItemUid(),this.dataOffset=this.offset=e.skip()||0,this.pageSize=e.pageSize(),this.useRanges=e.options.serverPaging},_recalculate:function(){var e=this.pageSize,t=this.offset,n=this.viewSize,r=Math.ceil(t/e)*e;this.skip=r,this.midPageThreshold=r+e-1,this.nextPageThreshold=r+n-1,this.prefetchThreshold=r+Math.floor(e/3*2),this.pullBackThreshold=this.offset-1,this.nextMidRange=r+e-n,this.nextFullRange=r,this.previousMidRange=t-n,this.previousFullRange=r-e}}),Z=st.Observable.extend({init:function(e,t){var n=this;st.Observable.fn.init.call(n),this.dataSource=e,this.batchSize=t,this._total=0,this.buffer=new Q(e,3*t),this.buffer.bind({endreached:function(e){n.trigger("endreached",{index:e.index})},prefetching:function(e){n.trigger("prefetching",{skip:e.skip,take:e.take})},prefetched:function(e){n.trigger("prefetched",{skip:e.skip,take:e.take})},reset:function(){n._total=0,n.trigger("reset")},resize:function(){n._total=Math.ceil(this.length/n.batchSize),n.trigger("resize",{total:n.total(),offset:this.offset})}})},syncDataSource:function(){this.buffer.syncDataSource()},at:function(e){var n,r,i=this.buffer,o=e*this.batchSize,a=this.batchSize,s=[];for(i.offset>o&&i.at(i.offset-1),r=0;a>r&&(n=i.at(o+r),n!==t);r++)s.push(n);return s},total:function(){return this._total},destroy:function(){this.buffer.destroy(),this.unbind()}}),X(!0,st.data,{readers:{json:$},Query:o,DataSource:G,HierarchicalDataSource:Y,Node:V,ObservableObject:Ut,ObservableArray:Lt,LocalTransport:U,RemoteTransport:B,Cache:W,DataReader:$,Model:$t,Buffer:Q,BatchBuffer:Z})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});