text: /*
  * Kendo UI v2014.3.1119 (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.dom.min","./kendo.data.min"],e)}(function(){return function(e,t){function n(e){var n="string"==typeof e?[{name:e}]:e,i="[object Array]"===_t.call(n)?n:n!==t?[n]:[];return yt(i,function(e){return"string"==typeof e?{name:e}:{name:e.name,type:e.type}})}function i(e){var n="string"==typeof e?[{name:[e],expand:!1}]:e,i="[object Array]"===_t.call(n)?n:n!==t?[n]:[];return yt(i,function(e){return"string"==typeof e?{name:[e],expand:!1}:{name:"[object Array]"===_t.call(e.name)?e.name.slice():[e.name],expand:e.expand}})}function r(e,t,n,i){var o,a,s,l;if(n||(n=t),i||(i=0),l=n.members[i],l&&!l.measure){if(s=l.children,a=s.length,n===t?e[ft.stringify([l.name])]=!!a:a&&(e[ft.stringify(lt(n,i))]=!0),a)for(o=0;a>o;o++)r(e,t,s[o],i);r(e,t,n,i+1)}}function o(t){var n,i,o={};t.length&&r(o,t[0]),n=[];for(i in o)n.push({name:e.parseJSON(i),expand:o[i]});return n}function a(e,t){var n,i,r,o,a=t.tuples||[],s=a[0];if(s&&s.members.length>e.length)for(n=s.members,i=0;n.length>i;i++)if(!n[i].measure){for(r=!1,o=0;e.length>o;o++)if(0===O(e[o]).indexOf(n[i].hierarchy)){r=!0;break}r||e.push({name:[n[i].name],expand:!1})}}function s(e){var t,n=[],i=e.members;for(t=0;i.length>t;t++)i[t].measure||n.push({name:[i[t].name],expand:i[t].children.length>0});return n}function l(e,t,n){var r,o;return e=e||{},a(t,e),n.length>1&&t.push({name:"Measures",measure:!0,children:i(n)}),r={members:t},e.tuples&&(o=k(e.tuples,r),o.tuple&&(t=s(o.tuple))),t}function c(e,t,n,i,r,o,a){var s,l,c,d,u,h,f,p=0,g=t;for(l in n[i].aggregates)s=n[i].aggregates[l],d=r[l],u=o[l],s=d?d(s):s.accumulator,e[g]={ordinal:g,value:s,fmtValue:u?ft.format(u,s):s},++p,g+=a;h=n[i].items;for(c in h){f=h[c].index*p,f=g+f*a;for(l in h[c].aggregates)s=h[c].aggregates[l],d=r[l],u=o[l],s=d?d(s):s.accumulator,e[f]={ordinal:f,value:s,fmtValue:u?ft.format(u,s):s},f+=a}}function d(e,t,n,i,r,o){var a,s,l,c,d,u,h,f=0;for(s in n[i].aggregates)a=n[i].aggregates[s],c=r[s],d=o[s],a=c?c(a):a.accumulator,e[e.length]={ordinal:t++,value:a,fmtValue:d?ft.format(d,a):a},++f;u=n[i].items;for(l in u){h=u[l].index*f;for(s in u[l].aggregates)a=u[l].aggregates[s],c=r[s],d=o[s],a=c?c(a):a.accumulator,e[e.length]={ordinal:t+h++,value:a,fmtValue:d?ft.format(d,a):a}}}function u(e){var t=ft.getter(e.field,!0);return function(n,i){return e.aggregate(t(n.dataItem),i,n)}}function h(e){return"number"==typeof e&&!isNaN(e)}function f(e){return e&&e.getTime}function p(e,n,i){return e.tuples.length<_(n.tuples,i)?n:t}function g(e,t,n,i,r){var o,a,s,l=e.length,c=_(t,i),d=i.length||1;for(a=0;n>a;a++)for(o=0;l>o;o++)s=v(e[o],t)*d,s+=o%d,r[a*l+o].ordinal=a*c+s}function m(e,t,n,i,r){var o,a,s,l=e.length,c=(_(t,i),i.length||1);for(a=0;l>a;a++)for(s=v(e[a],t),s*=c,s+=a%c,o=0;n>o;o++)r[a*n+o].ordinal=s*n+o}function v(e,t){return k(t,e).index}function _(e,t){var n,i,r;if(!e.length)return 0;for(n=e.slice(),i=n.shift(),r=1;i;)i.members?[].push.apply(n,i.members):i.children&&(i.measure||(r+=i.children.length),[].push.apply(n,i.children)),i=n.shift();return t.length&&(r*=t.length),r}function w(e){return e||(e={tuples:[]}),e.tuples||(e.tuples=[]),e}function y(e,t,n){var i,r,o;if(!e)return 0;for(i=Math.max(n.length,1),r=e.members.slice(0,t),o=r.shift();o;)o.children?[].push.apply(r,o.children):(i++,[].push.apply(r,o.members)),o=r.shift();return i}function b(e,t,n){var i,r,o,a,s,l;if(!t[0])return{parsedRoot:null,tuples:e,memberIndex:0,index:0};if(i=k(e,t[0]),!i.tuple)return{parsedRoot:null,tuples:t,memberIndex:0,index:0};if(r=i.tuple.members,o=t[0].members,a=-1,r.length!==o.length)return{parsedRoot:null,tuples:t,memberIndex:0,index:0};for(s=0,l=r.length;l>s;s++)!r[s].measure&&o[s].children[0]&&(-1==a&&o[s].children.length&&(a=s),r[s].children=o[s].children);return n=Math.max(n.length,1),{parsedRoot:i.tuple,index:i.index*n,memberIndex:a,tuples:e}}function x(e,t){var n,i,r=!0;for(e=e.members,t=t.members,n=0,i=e.length;i>n;n++)e[n].measure||t[n].measure||(r=r&&O(e[n])===O(t[n]));return r}function k(e,t){var n,i,r,o,a,s,l,c=0;for(n=0,i=e.length;i>n;n++){if(r=e[n],x(r,t))return{tuple:r,index:c};for(c++,a=0,s=r.members.length;s>a;a++)if(l=r.members[a],!l.measure&&(o=k(l.children,t),c+=o.index,o.tuple))return{tuple:o.tuple,index:c}}return{index:c}}function C(e,t){var n,i,r,o="";for(i=0,r=e.length;r>i;i++)n=e[i],o+=n.name,t[o]||(t[o]=n)}function S(e,t){var n,i,r,o,a=e.members,s="",l="";for(n=0,i=a.length;i>n;n++){if(r=a[n],o){if(t[s+r.name]){s+=r.name,o=t[s];continue}return t[s+r.parentName]?t[s+r.parentName]:(r.parentName&&(l+=r.parentName),t[l])}if(s+=r.name,o=t[r.parentName],!o&&(o=t[s],!o))return null;o&&(l+=o.name)}return o}function T(e,t){var n,i,r,o;if(0===t.length)return-1;for(n=t[0],i=e.members,r=0,o=i.length;o>r;r++)if(i[r].name==n.name)return r}function D(n,i){if(!(0>i)){var r={name:"Measures",measure:!0,children:[e.extend({members:[],dataIndex:n.dataIndex},n.members[i])]};n.members.splice(i,1,r),n.dataIndex=t}}function A(e,t){var n,i,r,o,a,s;if(1>e.length)return[];for(n=[],i={},r=T(e[0],t),o=0;e.length>o;o++)a=e[o],a.dataIndex=o,D(a,r),s=S(a,i),s?s.children.push(0>r||!s.measure?a:a.members[r].children[0]):n.push(a),C(a.members,i);return n}function E(e,t){var n,i,r,o,a,s,l,c,d;if(!e||!e.length)return t;for(n=[],i=M(e),r=i.length,o=Math.max(t.length/r,1),a=0;r>a;a++)for(l=o*a,c=o*i[a],s=0;o>s;s++)d=parseInt(c+s,10),n[parseInt(l+s,10)]=t[d]||{value:"",fmtValue:"",ordinal:d};return n}function P(e,t){var n,i,r,o,a,s,l,c;if(!e||!e.length)return t;for(n=[],i=M(e),r=i.length,o=Math.max(t.length/r,1),s=0;o>s;s++)for(l=r*s,a=0;r>a;a++)c=i[a]+l,n[l+a]=t[c]||{value:"",fmtValue:"",ordinal:c};return n}function M(e){var n,i,r,o,a,s,l;for(e=e.slice(),n=[],i=e.shift();i;){for(i.dataIndex!==t&&n.push(i.dataIndex),a=0,r=0,o=i.members.length;o>r;r++)l=i.members[r],s=l.children,l.measure?[].splice.apply(e,[0,0].concat(s)):[].splice.apply(e,[a,0].concat(s)),a+=s.length;i=e.shift()}return n}function I(e){var t=e.split(".");return t.length>2?t[0]+"."+t[1]:e}function B(e,t){var n=e.length-1,i=e[n],r=L(t,i);return r&&r.dir?i="ORDER("+i+".Children,"+r.field+".CurrentMember.MEMBER_CAPTION,"+r.dir+")":i+=".Children",e[n]=i,e}function L(e,t){for(var n=0,i=e.length;i>n;n++)if(0===t.indexOf(e[n].field))return e[n];return null}function F(e){var t,n="CROSSJOIN({";return e.length>2?(t=e.pop(),n+=F(e)):(n+=e.shift(),t=e.pop()),n+="},{",n+=t,n+="})"}function z(e,t){var n=e.slice(0);return t.length>1&&n.push("{"+R(t).join(",")+"}"),F(n)}function R(e){for(var n,i=0,r=e.length,o=[];r>i;i++)n=e[i],o.push(n.name!==t?n.name:n);return o}function O(e){return e=e.name||e,"[object Array]"===_t.call(e)&&(e=e[e.length-1]),e}function N(e){for(var t=e.length,n=[],i=0;t>i;i++)n.push(e[i].name[0]);return n}function H(e,t){var n,i,r,o=0,a=e.length,s=t.length;for(t=t.slice(0);a>o;o++)for(n=e[o],r=0;s>r;r++)if(i=I(t[r]),-1!==n.indexOf(i)){t[r]=n;break}return t}function V(e){for(var t,n,i,r,o,a,s=[],l=[],c=[],d=0,u=e.length;u>d;d++)if(t=e[d],r=t.name,a=!1,"[object Array]"!==_t.call(r)&&(t.name=r=[r]),r.length>1)l.push(t);else{for(o=I(r[0]),n=0,i=c.length;i>n;n++)if(0===c[n].name[0].indexOf(o)){a=!0;break}a||c.push(t),t.expand&&s.push(t)}return s=s.concat(l),{root:c,expanded:s}}function U(e,t,n){var i,r,o,a,s,l,c,d,u="";if(e=e||[],i=V(e),r=i.root,o=N(r),a=[],i=i.expanded,s=i.length,l=0,d=[],o.length>1||t.length>1){for(a.push(z(o,t));s>l;l++)c=B(i[l].name,n),d=H(c,o),a.push(z(d,t));u+=a.join(",")}else{for(;s>l;l++)c=B(i[l].name,n),d.push(c[0]);u+=o.concat(d).join(",")}return u}function W(e){var t="",n=e.value,i=e.field,r=e.operator;return"in"==r?(t+="{",t+=n,t+="}"):(t+="Filter(",t+=i+".Children",t+=ft.format(Y[r],i,n),t+=")"),t}function j(e,t){var n,i,r="",o=e.filters,a=o.length;for(i=a-1;i>=0;i--)n="SELECT (",n+=W(o[i]),n+=") ON 0",i==a-1?(n+=" FROM ["+t+"]",r=n):r=n+" FROM ( "+r+" )";return r}function G(e,t,n){var i,r,o="";if(t){o+="<"+e+">";for(r in t)i=t[r],n&&(r=r.replace(/([A-Z]+(?=$|[A-Z][a-z])|[A-Z]?[a-z]+)/g,"$1_").toUpperCase().replace(/_$/,"")),o+="<"+r+">"+i+"</"+r+">";o+="</"+e+">"}else o+="<"+e+"/>";return o}function q(e){if(null==e)return[];var t=_t.call(e);return"[object Array]"!==t?[e]:e}function $(e){var t,n,i,r,o={tuples:[]},a=q(ft.getter("Tuples.Tuple",!0)(e)),s=ft.getter("Caption['#text']"),l=ft.getter("UName['#text']"),c=ft.getter("LName['#text']"),d=ft.getter("LNum['#text']"),u=ft.getter("CHILDREN_CARDINALITY['#text']",!0),h=ft.getter("['@Hierarchy']"),f=ft.getter("PARENT_UNIQUE_NAME['#text']",!0);for(t=0;a.length>t;t++){for(n=[],i=q(a[t].Member),r=0;i.length>r;r++)n.push({children:[],caption:s(i[r]),name:l(i[r]),levelName:c(i[r]),levelNum:d(i[r]),hasChildren:parseInt(u(i[r]),10)>0,parentName:f(i[r]),hierarchy:h(i[r])});o.tuples.push({members:n})}return o}var Y,Q,X,K,Z,J,et,tt,nt,it,rt,ot,at,st,lt,ct,dt,ut,ht,ft=window.kendo,pt=ft.ui,gt=ft.Class,mt=pt.Widget,vt=ft.data.DataSource,_t={}.toString,wt=function(e){return e},yt=e.map,bt=e.extend,xt=ft.isFunction,kt="change",Ct="error",St="progress",Tt="stateReset",Dt="auto",At="<div/>",Et=".kendoPivotGrid",Pt="__row_total__",Mt="dataBinding",It="dataBound",Bt="expandMember",Lt="collapseMember",Ft="k-i-arrow-s",zt="k-i-arrow-e",Rt="#: data.member.caption || data.member.name #",Ot='<span class="k-icon k-i-kpi-#=data.dataItem.value > 0 ? "open" : data.dataItem.value < 0 ? "denied" : "hold"#">#:data.dataItem.value#</span>',Nt='<span class="k-icon k-i-kpi-#=data.dataItem.value > 0 ? "increase" : data.dataItem.value < 0 ? "decrease" : "equal"#">#:data.dataItem.value#</span>',Ht='#= data.dataItem ? kendo.htmlEncode(data.dataItem.fmtValue || data.dataItem.value) || "&nbsp;" : "&nbsp;" #',Vt='<table class="k-pivot-layout"><tr><td><div class="k-pivot-rowheaders"></div></td><td><div class="k-pivot-table k-state-default"></div></td></tr></table>',Ut={sum:function(e,t){var n=t.accumulator;return h(n)?h(e)&&(n+=e):n=e,n},count:function(e,t){return(t.accumulator||0)+1},average:{aggregate:function(e,n){var i=n.accumulator;return n.count===t&&(n.count=0),h(i)?h(e)&&(i+=e):i=e,h(e)&&n.count++,i},result:function(e){var t=e.accumulator;return h(t)&&(t/=e.count),t}},max:function(e,t){var n=t.accumulator;return h(n)||f(n)||(n=e),e>n&&(h(e)||f(e))&&(n=e),n},min:function(e,t){var n=t.accumulator;return h(n)||f(n)||(n=e),n>e&&(h(e)||f(e))&&(n=e),n}},Wt=gt.extend({init:function(e){this.options=bt({},this.options,e),this.dimensions=this._normalizeDescriptors("field",this.options.dimensions),this.measures=this._normalizeDescriptors("name",this.options.measures)},_normalizeDescriptors:function(e,t){var n,i,r,o;if(t=t||{},n={},"[object Array]"===_t.call(t)){for(r=0,o=t.length;o>r;r++)i=t[r],"string"==typeof i?n[i]={}:i[e]&&(n[i[e]]=i);t=n}return t},_asTuples:function(e,n,i){var r,o,a,s,l,c,d,u,h,f;if(i=i||[],r=this.dimensions||[],o=[],h=i.length||1,n.length||i.length)for(c=0;h>c;c++){for(a={members:[]},s=0,l=n.length;l>s;s++)u=O(n[s].name),a.members[a.members.length]={children:[],caption:(r[u]||{}).caption||"All",name:u,levelName:u,levelNum:"0",hasChildren:!0,parentName:t,hierarchy:u};h>1&&(a.members[a.members.length]={children:[],caption:i[c].caption,name:i[c].descriptor.name,levelName:"MEASURES",levelNum:"0",hasChildren:!1,parentName:t,hierarchy:"MEASURES"}),o[o.length]=a}for(f in e)for(c=0;h>c;c++){for(d={members:[]},s=0,l=n.length;l>s;s++)u=O(n[s].name),d.members[d.members.length]=0===e[f].parentName.indexOf(u)?{children:[],caption:e[f].value,name:e[f].name,levelName:e[f].name,levelNum:1,hasChildren:!1,parentName:u,hierarchy:u}:{children:[],caption:(r[u]||{}).caption||"All",name:u,levelName:u,levelNum:"0",hasChildren:!0,parentName:t,hierarchy:u};h>1&&(d.members[d.members.length]={children:[],caption:i[c].caption,name:i[c].descriptor.name,levelName:"MEASURES",levelNum:"0",hasChildren:!0,parentName:t,hierarchy:"MEASURES"}),o[o.length]=d}return o},_toDataArray:function(e,t,n,i,r){var o,a,s,l,c,d,u={},h={},f=0,p=n&&n.length;if(p)for(o=this.measures||{};p>f;f++)s=n[f].name,a=o[s],a.result&&(h[s]=a.result),a.format&&(u[s]=a.format);l=[],c=0,r(l,c,e,Pt,h,u,t);for(d in e)d!==Pt&&(c+=i,r(l,c,e,d,h,u,t));return l},_matchDescriptors:function(e,t,n,i){for(var r,o,a,s,l;i>0;)if(r=t[--i],o=O(r).split("&"),o.length>1&&(a=o[0],s=o[1],l=n[a],l(e)!=s))return!1;return!0},_isExpanded:function(e){for(var t=0,n=e.length;n>t;t++)if(e[t].expand)return!0;return!1},_calculateAggregate:function(e,t,n){var i,r,o,a={};for(o=0;e.length>o;o++)r=e[o].descriptor.name,i=n.aggregates[r]||{},i.accumulator=e[o].aggregator(t,i),a[r]=i;return a},_processColumns:function(e,n,i,r,o,a,s,l){var c,d,u,h,f,p,g=o.dataItem;for(p=0;n.length>p;p++)if(d=n[p],d.expand){if(!this._matchDescriptors(g,n,i,p))continue;u=O(d),c=i[u](g),c=c!==t?""+c:c,u=u+"&"+c,h=r[u]||{index:s.columnIndex,name:u,parentName:u,value:c},f=a.items[u]||{aggregates:{}},a.items[u]={index:h.index,aggregates:this._calculateAggregate(e,o,f)},l&&(r[u]||s.columnIndex++,r[u]=h)}},_measureAggregators:function(e){var t,n,i,r,o,a,s=e.measures||[],l=this.measures||{},c=[];if(s.length){for(i=0,r=s.length;r>i;i++)if(t=s[i],n=l[t.name],o=null,n){if(a=n.aggregate,"string"==typeof a){if(o=Ut[a.toLowerCase()],!o)throw Error("There is no such aggregate function");n.aggregate=o.aggregate||o,n.result=o.result}c.push({descriptor:t,caption:n.caption,result:n.result,aggregator:u(n)})}}else c.push({descriptor:{name:"default"},caption:"default",aggregator:function(){return 1}});return c},_buildGetters:function(e){var t,n,i,r,o,a={};for(r=0,o=e.length;o>r;r++)t=e[r],i=O(t),n=i.split("&"),n.length>1?a[n[0]]=ft.getter(n[0],!0):a[i]=ft.getter(i,!0);return a},process:function(e,n){var r,o,a,s,l,u,h,f,p,g,m,v,_,w,y,b,x,k,C,S,T,D,A,E,P,M;if(e=e||[],n=n||{},r=n.measures||[],o="rows"===n.measuresAxis,a=(o?n.rows:n.columns)||[],s=(o?n.columns:n.rows)||[],!a.length&&s.length&&(!r.length||r.length&&o)&&(a=s,s=[],o=!1),a.length||s.length||(o=!1),!a.length&&r.length&&(a=i(n.measures)),l={},u={},h={},p={columnIndex:0},g=this._measureAggregators(n),m=this._buildGetters(a),v=this._buildGetters(s),_=!1,a.length||s.length)for(b=this._isExpanded(s),_=!0,x=0,k=e.length;k>x;x++)for(w=e[x],y={dataItem:w,index:x},C=l[Pt]||{items:{},aggregates:{}},this._processColumns(g,a,m,u,y,C,p,!b),C.aggregates=this._calculateAggregate(g,y,C),l[Pt]=C,S=0,T=s.length;T>S;S++)if(D=s[S],D.expand){if(!this._matchDescriptors(w,s,v,S))continue;A=O(D),f=v[A](w),f=f!==t?""+f:f,h[f]={name:A+"&"+f,parentName:A,value:f},E=l[f]||{items:{},aggregates:{}},this._processColumns(g,a,m,u,y,E,p,!0),E.aggregates=this._calculateAggregate(g,y,E),l[f]=E}return _&&e.length?(!(g.length>1)||n.columns&&n.columns.length||(a=[]),u=this._asTuples(u,a,g),h=this._asTuples(h,s,[]),P=u.length,o&&(P=1,M=u,u=h,h=M),l=this._toDataArray(l,u.length,n.measures,P,o?c:d),l=this._normalizeData(l,u.length,h.length)):l=u=h=[],{axes:{columns:{tuples:u},rows:{tuples:h}},data:l}},_normalizeData:function(e,t,n){var i,r,o=(t||1)*(n||1),a=Array(o),s=e.length;if(s===o)return e;for(r=0;o>r;r++)a[r]={value:"",fmtValue:"",ordinal:r};for(r=0;s>r;r++)i=e[r],i&&(a[i.ordinal]=i);return a}}),jt=gt.extend({init:function(e,t){this.transport=t,this.options=t.options||{},this.transport.discover||xt(e.discover)&&(this.discover=e.discover)},read:function(e){return this.transport.read(e)},update:function(e){return this.transport.update(e)},create:function(e){return this.transport.create(e)},destroy:function(e){return this.transport.destroy(e)},discover:function(e){return this.transport.discover?this.transport.discover(e):(e.success({}),t)},catalog:function(n){var i,r=this.options||{};return n===t?(r.connection||{}).catalog:(i=r.connection||{},i.catalog=n,this.options.connection=i,e.extend(this.transport.options,{connection:i}),t)},cube:function(e){var n,i=this.options||{};return e===t?(i.connection||{}).cube:(n=i.connection||{},n.cube=e,this.options.connection=n,bt(!0,this.transport.options,{connection:n}),t)}}),Gt=vt.extend({init:function(t){var r,o=((t||{}).schema||{}).cube,a="columns",s={axes:wt,cubes:wt,catalogs:wt,measures:wt,dimensions:wt,hierarchies:wt,levels:wt,members:wt};o&&(s=e.extend(s,this._cubeSchema(o)),this.cubeBuilder=new Wt(o)),vt.fn.init.call(this,bt(!0,{},{schema:s},t)),this.transport=new jt(this.options.transport||{},this.transport),this._columns=i(this.options.columns),this._rows=i(this.options.rows),r=this.options.measures||[],null!==this.options.measures&&"[object Object]"===_t.call(this.options.measures)&&(r=this.options.measures.values||[],a=this.options.measures.axis||"columns"),this._measures=n(r||[]),this._measuresAxis=a,this._axes={}},_cubeSchema:function(e){return{dimensions:function(){var t,n=[],i=e.dimensions;for(t in i)n.push({name:t,caption:i[t].caption||t,uniqueName:t,defaultHierarchy:t,type:1});return e.measures&&n.push({name:"Measures",caption:"Measures",uniqueName:"Measures",type:2}),n},hierarchies:function(){return[]},measures:function(){var t,n=[],i=e.measures;for(t in i)n.push({name:t,caption:t,uniqueName:t,aggregator:t});return n}}},options:{serverSorting:!0,serverPaging:!0,serverFiltering:!0,serverGrouping:!0,serverAggregates:!0},catalog:function(e){return e===t?this.transport.catalog():(this.transport.catalog(e),this._mergeState({}),this._axes={},this.data([]),t)},cube:function(e){return e===t?this.transport.cube():(this.transport.cube(e),this._axes={},this._mergeState({}),this.data([]),t)},axes:function(){return this._axes},columns:function(e){return e===t?this._columns:(this._clearAxesData=!0,this._columns=i(e),this.query({columns:e,rows:this.rowsAxisDescriptors(),measures:this.measures()}),t)},rows:function(e){return e===t?this._rows:(this._clearAxesData=!0,this._rows=i(e),this.query({columns:this.columnsAxisDescriptors(),rows:e,measures:this.measures()}),t)},measures:function(e){return e===t?this._measures:(this._clearAxesData=!0,this.query({columns:this.columnsAxisDescriptors(),rows:this.rowsAxisDescriptors(),measures:n(e)}),t)},measuresAxis:function(){return this._measuresAxis||"columns"},_expandPath:function(e,t){var n,r,o,a="columns"===t?"columns":"rows",s="columns"===t?"rows":"columns",c=i(e),d=O(c[c.length-1]);for(this._lastExpanded=a,c=l(this.axes()[a],c,this.measures()),n=0;c.length>n;n++)if(r=O(c[n]),r===d){if(c[n].expand)return;c[n].expand=!0}else c[n].expand=!1;o={},o[a]=c,o[s]=this._descriptorsForAxis(s),this._query(o)},_descriptorsForAxis:function(e){var t=this.axes(),n=this[e]()||[];return t&&t[e]&&t[e].tuples&&t[e].tuples[0]&&(n=o(t[e].tuples||[])),n},columnsAxisDescriptors:function(){return this._descriptorsForAxis("columns")},rowsAxisDescriptors:function(){return this._descriptorsForAxis("rows")},_process:function(e,t){this._view=e,t=t||{},t.items=t.items||this._view,this.trigger(kt,t)},_query:function(e){var t=this;return e||(this._clearAxesData=!0),t.query(bt({},{page:t.page(),pageSize:t.pageSize(),sort:t.sort(),filter:t.filter(),group:t.group(),aggregate:t.aggregate(),columns:this.columnsAxisDescriptors(),rows:this.rowsAxisDescriptors(),measures:this.measures()},e))},query:function(t){var n=this._mergeState(t);return this._data.length&&this.cubeBuilder?(this._params(n),this._updateLocalData(this._pristineData),e.Deferred().resolve().promise()):this.read(n)},_mergeState:function(e){return e=vt.fn._mergeState.call(this,e),e!==t&&(this._measures=n(e.measures),e.columns?e.columns=i(e.columns):e.columns||(this._columns=[]),e.rows?e.rows=i(e.rows):e.rows||(this._rows=[])),e},filter:function(e){return e===t?this._filter:(this._clearAxesData=!0,this._query({filter:e,page:1}),t)},expandColumn:function(e){this._expandPath(e,"columns")},expandRow:function(e){this._expandPath(e,"rows")},success:function(e){var t;this.cubeBuilder&&(t=(this.reader.data(e)||[]).slice(0)),vt.fn.success.call(this,e),t&&(this._pristineData=t)},_processResult:function(e,t){var n,i,r,o,a,s,l,c,d,u,h;return this.cubeBuilder&&(n=this.cubeBuilder.process(e,this._requestData),e=n.data,t=n.axes),c=this.columns().length,d=this.rows().length,u=t.columns&&t.columns.tuples,c||!d||!u||!this._rowMeasures().length&&this.measures().length||(t={columns:{},rows:t.columns}),c||d||"rows"!==this.measuresAxis()||!u||(t={columns:{},rows:t.columns}),this._axes={columns:w(this._axes.columns),rows:w(this._axes.rows)},t={columns:w(t.columns),rows:w(t.rows)},i=this._normalizeTuples(t.columns.tuples,this._axes.columns.tuples,this._columnMeasures()),r=this._normalizeTuples(t.rows.tuples,this._axes.rows.tuples,this._rowMeasures()),this.cubeBuilder||(e=this._normalizeData({columnsLength:t.columns.tuples.length,rowsLength:t.rows.tuples.length,columnIndexes:i,rowIndexes:r,data:e})),"rows"==this._lastExpanded?(o=t.columns.tuples,s=this._columnMeasures(),a=p(t.columns,this._axes.columns,s),a&&(l="columns",t.columns=a,g(o,a.tuples,t.rows.tuples.length,s,e),e=this._normalizeData({columnsLength:_(t.columns.tuples,s),rowsLength:t.rows.tuples.length,data:e}))):"columns"==this._lastExpanded&&(o=t.rows.tuples,s=this._rowMeasures(),a=p(t.rows,this._axes.rows,s),a&&(l="rows",t.rows=a,m(o,a.tuples,t.columns.tuples.length,s,e),e=this._normalizeData({columnsLength:_(t.rows.tuples,s),rowsLength:t.columns.tuples.length,data:e}))),this._lastExpanded=null,h=this._mergeAxes(t,e,l),this._axes=h.axes,h.data},_readData:function(e){var t=this.reader.axes(e),n=this.reader.data(e);return this._processResult(n,t)},_createTuple:function(e,t,n){var i,r,o,a,s,l=e.members,c=l.length,d={members:[]},u=0;for(t&&(c-=1);c>u;u++)r=l[u],a=+r.levelNum,i=r.name,o=r.parentName,s=r.caption||i,n&&(s="All",0===a?o=r.name:a-=1,i=o),d.members.push({name:i,children:[],caption:s,levelName:o,levelNum:""+a,hasChildren:n,hierarchy:o,parentName:n?"":o});return t&&d.members.push({name:t.name,children:[]}),d},_hasRoot:function(e,t){var n,i,r,o,a,s;if(t.length)return k(t,e).tuple;for(n=e.members,r=!0,a=0,s=n.length;s>a;a++)if(i=n[a],o=+i.levelNum||0,0!==o){r=!1;break}return r},_mergeAxes:function(e,t,n){var i,r,o,a,s,l=this._columnMeasures(),c=this._rowMeasures(),d=this.axes(),u=e.rows.tuples.length,h=_(d.columns.tuples,l),f=e.columns.tuples.length;return"columns"==n?(f=h,r=e.columns.tuples):(r=A(e.columns.tuples,l),t=P(r,t)),o=b(d.columns.tuples,r,l),"rows"==n?(u=_(e.rows.tuples,c),r=e.rows.tuples):(r=A(e.rows.tuples,c),t=E(r,t)),a=b(d.rows.tuples,r,c),d.columns.tuples=o.tuples,d.rows.tuples=a.tuples,h!==_(d.columns.tuples,l)?(i=o.index+y(o.parsedRoot,o.memberIndex,l),s=h+f,t=this._mergeColumnData(t,i,u,f,s)):(i=a.index+y(a.parsedRoot,a.memberIndex,c),t=this._mergeRowData(t,i,u,f)),{axes:d,data:t}},_mergeColumnData:function(e,t,n,i,r){var o,a,s,l=this.data().toJSON(),c=0,d=Math.max(this._columnMeasures().length,1);for(n=Math.max(n,1),l.length>0&&(c=d,r-=d),o=0;n>o;o++)a=t+o*r,s=e.splice(0,i),s.splice(0,c),[].splice.apply(l,[a,0].concat(s));return l},_mergeRowData:function(e,t,n,i){var r,o,a,s=this.data().toJSON(),l=Math.max(this._rowMeasures().length,1);for(i=Math.max(i,1),s.length>0&&(n-=l,e.splice(0,i*l)),r=0;n>r;r++)a=e.splice(0,i),o=t*i+r*i,[].splice.apply(s,[o,0].concat(a));return s},_columnMeasures:function(){var e=this.measures(),t=[];return"columns"===this.measuresAxis()&&(0===this.columns().length?t=e:e.length>1&&(t=e)),t},_rowMeasures:function(){var e=this.measures(),t=[];return"rows"===this.measuresAxis()&&(0===this.rows().length?t=e:e.length>1&&(t=e)),t},_updateLocalData:function(e,t){this.cubeBuilder&&(t&&(this._requestData=t),e=this._processResult(e)),this._data=this._observe(e),this._ranges=[],this._addRange(this._data),this._total=this._data.length,this._pristineTotal=this._total,this._process(this._data)},data:function(e){var n=this;return e===t?n._data:(this._pristineData=e.slice(0),this._updateLocalData(e,{columns:this.columns(),rows:this.rows(),measures:this.measures()}),t)},_normalizeTuples:function(e,t,n){var i,r,o,a=n.length||1,s=0,l=[],c={},d=0;if(e.length){if(!this._hasRoot(e[0],t)){for(;a>s;s++)l.push(this._createTuple(e[0],n[s],!0)),c[s]=s;e.splice.apply(e,[0,e.length].concat(l).concat(e)),s=a}if(n.length)for(o=i=e[s],r=i.members.length-1;i;){if(d>=a&&(d=0),i.members[r].name!==n[d].name&&(e.splice(s,0,this._createTuple(i,n[d])),c[s]=s),s+=1,d+=1,i=e[s],a>d&&(!i||ct(o,r-1)!==ct(i,r-1))){for(;a>d;d++)e.splice(s,0,this._createTuple(o,n[d])),c[s]=s,s+=1;i=e[s]}o=i}return c}},_normalizeData:function(e){var n,i,r=e.data,o=e.columnIndexes||{},a=e.rowIndexes||{},s=e.columnsLength||1,l=s*(e.rowsLength||1),c=0,d=0,u=0,h=Array(l);if(r.length===l)return r;for(;l>c;c++){if(a[parseInt(c/s,10)]!==t)for(i=0;s>i;i++)h[c]={value:"",fmtValue:"",ordinal:c},c+=1;if(o[c%s]!==t&&(h[c]={value:"",fmtValue:"",ordinal:c},c+=1),n=r[d]){if(n.ordinal-u>1)for(u+=1;n.ordinal>u;u++)h[c]={value:"",fmtValue:"",ordinal:c},c+=1;u=n.ordinal,n.ordinal=c,h[c]=n,d+=1}else h[c]={value:"",fmtValue:"",ordinal:c}}return h},discover:function(t,n){var i=this,r=i.transport;return e.Deferred(function(e){r.discover(bt({success:function(t){t=i.reader.parse(t),i._handleCustomErrors(t)||(n&&(t=n(t)),e.resolve(t))},error:function(t,n,r){e.reject(t),i.error(t,n,r)}},t))}).promise().done(function(){i.trigger("schemaChange")})},schemaMeasures:function(){var e=this;return e.discover({data:{command:"schemaMeasures",restrictions:{catalogName:e.transport.catalog(),cubeName:e.transport.cube()}}},function(t){return e.reader.measures(t)})},schemaKPIs:function(){var e=this;return e.discover({data:{command:"schemaKPIs",restrictions:{catalogName:e.transport.catalog(),cubeName:e.transport.cube()}}},function(t){return e.reader.kpis(t)})},schemaDimensions:function(){var e=this;return e.discover({data:{command:"schemaDimensions",restrictions:{catalogName:e.transport.catalog(),cubeName:e.transport.cube()}}},function(t){return e.reader.dimensions(t)})},schemaHierarchies:function(e){var t=this;return t.discover({data:{command:"schemaHierarchies",restrictions:{catalogName:t.transport.catalog(),cubeName:t.transport.cube(),dimensionUniqueName:e}}},function(e){return t.reader.hierarchies(e)})},schemaLevels:function(e){var t=this;return t.discover({data:{command:"schemaLevels",restrictions:{catalogName:t.transport.catalog(),cubeName:t.transport.cube(),hierarchyUniqueName:e}}},function(e){return t.reader.levels(e)})},schemaCubes:function(){var e=this;return e.discover({data:{command:"schemaCubes",restrictions:{catalogName:e.transport.catalog()}}},function(t){return e.reader.cubes(t)})},schemaCatalogs:function(){var e=this;return e.discover({data:{command:"schemaCatalogs"}},function(t){return e.reader.catalogs(t)})},schemaMembers:function(e){var t=this;return t.discover({data:{command:"schemaMembers",restrictions:bt({catalogName:t.transport.catalog(),cubeName:t.transport.cube()},e)}},function(e){return t.reader.members(e)})},_params:function(e){this._clearAxesData&&(this._axes={},this._data=this._observe([]),this._clearAxesData=!1,this.trigger(Tt));var t=vt.fn._params.call(this,e);return t=bt({measures:this.measures(),measuresAxis:this.measuresAxis(),columns:this.columns(),rows:this.rows()},t),this.cubeBuilder&&(this._requestData=t),t}});Gt.create=function(e){e=e&&e.push?{data:e}:e;var t=e||{},n=t.data;if(t.data=n,!(t instanceof Gt)&&t instanceof ft.data.DataSource)throw Error("Incorrect DataSource type. Only PivotDataSource instances are supported");return t instanceof Gt?t:new Gt(t)},Y={contains:', InStr({0}.CurrentMember.MEMBER_CAPTION,"{1}") > 0',doesnotcontain:', InStr({0}.CurrentMember.MEMBER_CAPTION,"{1}") = 0',startswith:', Left({0}.CurrentMember.MEMBER_CAPTION,Len("{1}"))="{1}"',endswith:', Right({0}.CurrentMember.MEMBER_CAPTION,Len("{1}"))="{1}"',eq:', {0}.CurrentMember.MEMBER_CAPTION = "{1}"',neq:', NOT {0}.CurrentMember.MEMBER_CAPTION = "{1}"'},Q={schemaCubes:"MDSCHEMA_CUBES",schemaCatalogs:"DBSCHEMA_CATALOGS",schemaMeasures:"MDSCHEMA_MEASURES",schemaDimensions:"MDSCHEMA_DIMENSIONS",schemaHierarchies:"MDSCHEMA_HIERARCHIES",schemaLevels:"MDSCHEMA_LEVELS",schemaMembers:"MDSCHEMA_MEMBERS",schemaKPIs:"MDSCHEMA_KPIS"},X={read:function(e){var t,n,i,r,o,a='<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><Execute xmlns="urn:schemas-microsoft-com:xml-analysis"><Command><Statement>';return a+="SELECT NON EMPTY {",t=e.columns||[],n=e.rows||[],i=e.measures||[],r="rows"===e.measuresAxis,o=e.sort||[],!t.length&&n.length&&(!i.length||i.length&&r)&&(t=n,n=[],r=!1),t.length||n.length||(r=!1),t.length?a+=U(t,r?[]:i,o):i.length&&!r&&(a+=R(i).join(",")),a+="} DIMENSION PROPERTIES CHILDREN_CARDINALITY, PARENT_UNIQUE_NAME ON COLUMNS",(n.length||r&&i.length>1)&&(a+=", NON EMPTY {",a+=n.length?U(n,r?i:[],o):R(i).join(","),a+="} DIMENSION PROPERTIES CHILDREN_CARDINALITY, PARENT_UNIQUE_NAME ON ROWS"),e.filter?(a+=" FROM ",a+="(",a+=j(e.filter,e.connection.cube),a+=")"):a+=" FROM ["+e.connection.cube+"]",1==i.length&&t.length&&(a+=" WHERE ("+R(i).join(",")+")"),a+="</Statement></Command><Properties><PropertyList><Catalog>"+e.connection.catalog+"</Catalog><Format>Multidimensional</Format></PropertyList></Properties></Execute></Body></Envelope>",a.replace(/\&/g,"&amp;")},discover:function(t){t=t||{};var n='<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><Discover xmlns="urn:schemas-microsoft-com:xml-analysis">';return n+="<RequestType>"+(Q[t.command]||t.command)+"</RequestType>",n+="<Restrictions>"+G("RestrictionList",t.restrictions,!0)+"</Restrictions>",t.connection&&t.connection.catalog&&(t.properties=e.extend({},{Catalog:t.connection.catalog},t.properties)),n+="<Properties>"+G("PropertyList",t.properties)+"</Properties>",n+="</Discover></Body></Envelope>"}},K=ft.data.RemoteTransport.extend({init:function(e){var t=e;e=this.options=bt(!0,{},this.options,e),ft.data.RemoteTransport.call(this,e),xt(t.discover)?this.discover=t.discover:"string"==typeof t.discover?this.options.discover={url:t.discover}:t.discover||(this.options.discover=this.options.read)},setup:function(t,n){return t.data=t.data||{},e.extend(!0,t.data,{connection:this.options.connection}),ft.data.RemoteTransport.fn.setup.call(this,t,n)},options:{read:{dataType:"text",contentType:"text/xml",type:"POST"},discover:{dataType:"text",contentType:"text/xml",type:"POST"},parameterMap:function(e,t){return X[t](e,t)}},discover:function(t){return e.ajax(this.setup(t,"discover"))}}),Z={cubes:{name:ft.getter("CUBE_NAME['#text']",!0),caption:ft.getter("CUBE_CAPTION['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0),type:ft.getter("CUBE_TYPE['#text']",!0)},catalogs:{name:ft.getter("CATALOG_NAME['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0)},measures:{name:ft.getter("MEASURE_NAME['#text']",!0),caption:ft.getter("MEASURE_CAPTION['#text']",!0),uniqueName:ft.getter("MEASURE_UNIQUE_NAME['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0),aggregator:ft.getter("MEASURE_AGGREGATOR['#text']",!0),groupName:ft.getter("MEASUREGROUP_NAME['#text']",!0),displayFolder:ft.getter("MEASURE_DISPLAY_FOLDER['#text']",!0),defaultFormat:ft.getter("DEFAULT_FORMAT_STRING['#text']",!0)},kpis:{name:ft.getter("KPI_NAME['#text']",!0),caption:ft.getter("KPI_CAPTION['#text']",!0),value:ft.getter("KPI_VALUE['#text']",!0),goal:ft.getter("KPI_GOAL['#text']",!0),status:ft.getter("KPI_STATUS['#text']",!0),trend:ft.getter("KPI_TREND['#text']",!0),statusGraphic:ft.getter("KPI_STATUS_GRAPHIC['#text']",!0),trendGraphic:ft.getter("KPI_TREND_GRAPHIC['#text']",!0),description:ft.getter("KPI_DESCRIPTION['#text']",!0),groupName:ft.getter("MEASUREGROUP_NAME['#text']",!0)},dimensions:{name:ft.getter("DIMENSION_NAME['#text']",!0),caption:ft.getter("DIMENSION_CAPTION['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0),uniqueName:ft.getter("DIMENSION_UNIQUE_NAME['#text']",!0),defaultHierarchy:ft.getter("DEFAULT_HIERARCHY['#text']",!0),type:ft.getter("DIMENSION_TYPE['#text']",!0)},hierarchies:{name:ft.getter("HIERARCHY_NAME['#text']",!0),caption:ft.getter("HIERARCHY_CAPTION['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0),uniqueName:ft.getter("HIERARCHY_UNIQUE_NAME['#text']",!0),dimensionUniqueName:ft.getter("DIMENSION_UNIQUE_NAME['#text']",!0),displayFolder:ft.getter("HIERARCHY_DISPLAY_FOLDER['#text']",!0),origin:ft.getter("HIERARCHY_ORIGIN['#text']",!0),defaultMember:ft.getter("DEFAULT_MEMBER['#text']",!0)},levels:{name:ft.getter("LEVEL_NAME['#text']",!0),caption:ft.getter("LEVEL_CAPTION['#text']",!0),description:ft.getter("DESCRIPTION['#text']",!0),uniqueName:ft.getter("LEVEL_UNIQUE_NAME['#text']",!0),dimensionUniqueName:ft.getter("DIMENSION_UNIQUE_NAME['#text']",!0),displayFolder:ft.getter("LEVEL_DISPLAY_FOLDER['#text']",!0),orderingProperty:ft.getter("LEVEL_ORDERING_PROPERTY['#text']",!0),origin:ft.getter("LEVEL_ORIGIN['#text']",!0),hierarchyUniqueName:ft.getter("HIERARCHY_UNIQUE_NAME['#text']",!0)},members:{name:ft.getter("MEMBER_NAME['#text']",!0),caption:ft.getter("MEMBER_CAPTION['#text']",!0),uniqueName:ft.getter("MEMBER_UNIQUE_NAME['#text']",!0),dimensionUniqueName:ft.getter("DIMENSION_UNIQUE_NAME['#text']",!0),hierarchyUniqueName:ft.getter("HIERARCHY_UNIQUE_NAME['#text']",!0),levelUniqueName:ft.getter("LEVEL_UNIQUE_NAME['#text']",!0),childrenCardinality:ft.getter("CHILDREN_CARDINALITY['#text']",!0)}},J=["axes","catalogs","cubes","dimensions","hierarchies","levels","measures"],et=ft.data.XmlDataReader.extend({init:function(e){ft.data.XmlDataReader.call(this,e),this._extend(e)
  },_extend:function(e){for(var t,n,i=0,r=J.length;r>i;i++)t=J[i],n=e[t],n&&n!==wt&&(this[t]=n)},parse:function(e){var t=ft.data.XmlDataReader.fn.parse(e.replace(/<(\/?)(\w|-)+:/g,"<$1"));return ft.getter("['Envelope']['Body']",!0)(t)},errors:function(e){var t=ft.getter("['Fault']",!0)(e);return t?[{faultstring:ft.getter("faultstring['#text']",!0)(t),faultcode:ft.getter("faultcode['#text']",!0)(t)}]:null},axes:function(e){var t,n,i;return e=ft.getter("ExecuteResponse.return.root",!0)(e),t=q(ft.getter("Axes.Axis",!0)(e)),n=$(t[0]),i={},t.length>2&&(i=$(t[1])),{columns:n,rows:i}},data:function(e){var t,n,i,r,o,a;for(e=ft.getter("ExecuteResponse.return.root",!0)(e),t=q(ft.getter("CellData.Cell",!0)(e)),n=[],i=ft.getter("['@CellOrdinal']"),r=ft.getter("Value['#text']"),o=ft.getter("FmtValue['#text']"),a=0;t.length>a;a++)n.push({value:r(t[a]),fmtValue:o(t[a]),ordinal:parseInt(i(t[a]),10)});return n},_mapSchema:function(e,t){var n,i,r,o,a;for(e=ft.getter("DiscoverResponse.return.root",!0)(e),n=q(ft.getter("row",!0)(e)),i=[],r=0;n.length>r;r++){o={};for(a in t)o[a]=t[a](n[r]);i.push(o)}return i},measures:function(e){return this._mapSchema(e,Z.measures)},kpis:function(e){return this._mapSchema(e,Z.kpis)},hierarchies:function(e){return this._mapSchema(e,Z.hierarchies)},levels:function(e){return this._mapSchema(e,Z.levels)},dimensions:function(e){return this._mapSchema(e,Z.dimensions)},cubes:function(e){return this._mapSchema(e,Z.cubes)},catalogs:function(e){return this._mapSchema(e,Z.catalogs)},members:function(e){return this._mapSchema(e,Z.members)}}),bt(!0,ft.data,{PivotDataSource:Gt,XmlaTransport:K,XmlaDataReader:et,PivotCubeBuilder:Wt,transports:{xmla:K},readers:{xmla:et}}),tt=function(e,t){if(!e)return null;for(var n=0,i=e.length;i>n;n++)if(e[n].field===t)return e[n];return null},nt=function(e,t){var n,i,r=[];for(n=0,i=e.length;i>n;n++)e[n].field!==t&&r.push(e[n]);return r},ft.ui.PivotSettingTarget=mt.extend({init:function(t,n){var i=this;mt.fn.init.call(i,t,n),i.element.addClass("k-pivot-setting"),i.dataSource=ft.data.PivotDataSource.create(n.dataSource),i._refreshHandler=e.proxy(i.refresh,i),i.dataSource.first(kt,i._refreshHandler),n.template||(i.options.template="<div data-"+ft.ns+'name="${data.name || data}">${data.name || data}'+(i.options.enabled?'<a class="k-button k-button-icon k-button-bare"><span class="k-icon k-setting-delete"></span></a>':"")+"</div>"),i.template=ft.template(i.options.template),i.emptyTemplate=ft.template(i.options.emptyTemplate),i._sortable(),i.element.on("click"+Et,".k-button,.k-item",function(t){var n=e(t.target),r=n.closest("["+ft.attr("name")+"]").attr(ft.attr("name"));r&&(n.hasClass("k-setting-delete")?i.remove(r):i.options.sortable&&n[0]===t.currentTarget&&i.sort({field:r,dir:n.find(".k-i-sort-asc")[0]?"desc":"asc"}))}),(n.filterable||n.sortable)&&(i.fieldMenu=new pt.PivotFieldMenu(i.element,{messages:i.options.messages.fieldMenu,filter:".k-setting-fieldmenu",filterable:n.filterable,sortable:n.sortable,dataSource:i.dataSource})),i.refresh()},options:{name:"PivotSettingTarget",template:null,filterable:!1,sortable:!1,emptyTemplate:"<div class='k-empty'>${data}</div>",setting:"columns",enabled:!0,messages:{empty:"Drop Fields Here"}},setDataSource:function(e){this.dataSource.unbind(kt,this._refreshHandler),this.dataSource=this.options.dataSource=e,this.fieldMenu&&this.fieldMenu.setDataSource(e),e.first(kt,this._refreshHandler),this.refresh()},_sortable:function(){var e=this;e.options.enabled&&(this.sortable=this.element.kendoSortable({connectWith:this.options.connectWith,filter:">:not(.k-empty)",hint:e.options.hint,cursor:"move",start:function(e){e.item.focus().blur()},change:function(t){var n=t.item.attr(ft.attr("name"));"receive"==t.action?e.add(n):"remove"==t.action?e.remove(n):"sort"==t.action&&e.move(n,t.newIndex)}}).data("kendoSortable"))},_indexOf:function(e,t){var n,i,r=-1;for(n=0,i=t.length;i>n;n++)if(O(t[n])===e){r=n;break}return r},_isKPI:function(e){return"kpi"===e.type||e.measure},validate:function(e){var t,n,i=2==e.type||"aggregator"in e||this._isKPI(e);return i?"measures"===this.options.setting:"measures"===this.options.setting?i:(t=this.dataSource[this.options.setting](),n=e.defaultHierarchy||e.uniqueName,this._indexOf(n,t)>-1?!1:(t=this.dataSource["columns"===this.options.setting?"rows":"columns"](),this._indexOf(n,t)>-1?!1:!0))},add:function(t){var n,i,r=this.dataSource[this.options.setting]();for(t=e.isArray(t)?t.slice(0):[t],n=0,i=t.length;i>n;n++)-1!==this._indexOf(t[n],r)&&(t.splice(n,1),n-=1,i-=1);t.length&&(r=r.concat(t),this.dataSource[this.options.setting](r))},move:function(e,t){var n=this.dataSource[this.options.setting](),i=this._indexOf(e,n);i>-1&&(e=n.splice(i,1)[0],n.splice(t,0,e),this.dataSource[this.options.setting](n))},remove:function(e){var t=this.dataSource[this.options.setting](),n=this._indexOf(e,t);n>-1&&(t.splice(n,1),this.dataSource[this.options.setting](t))},sort:function(e){var t=this.options.sortable,n=t===!0||t.allowUnsort,i=n&&"asc"===e.dir,r=this.dataSource.sort()||[],o=nt(r,e.field);i&&r.length!==o.length&&(e=null),e&&o.push(e),this.dataSource.sort(o)},refresh:function(){var e,n="",i=this.dataSource[this.options.setting](),r=i.length,o=0;if(r)for(;r>o;o++)e=i[o],e=e.name===t?{name:e}:e,n+=this.template(bt({sortIcon:this._sortIcon(e.name)},e));else n=this.emptyTemplate(this.options.messages.empty);this.element.html(n)},destroy:function(){mt.fn.destroy.call(this),this.dataSource.unbind(kt,this._refreshHandler),this.element.off(Et),this.sortable&&this.sortable.destroy(),this.fieldMenu&&this.fieldMenu.destroy(),this.element=null,this._refreshHandler=null},_sortIcon:function(e){var t=this.dataSource.sort(),n=tt(t,O(e)),i="";return n&&(i="k-i-sort-"+n.dir),i}}),it=mt.extend({init:function(n,i){var r,o,a=this;mt.fn.init.call(a,n,i),a._dataSource(),a._bindConfigurator(),a._wrapper(),a._createLayout(),a._columnBuilder=r=new dt,a._rowBuilder=o=new ut,a._contentBuilder=new ht,a._templates(),a.columnsHeader.add(a.rowsHeader).on("click","span.k-icon",function(){var n,i,s,l,c=e(this),d=r,u="expandColumn",h=c.attr(ft.attr("path")),f={axis:"columns",path:e.parseJSON(h)};c.parent().is("td")&&(d=o,u="expandRow",f.axis="rows"),i=c.hasClass(Ft),s=d.metadata[h],l=s.expanded===t,n=i?Lt:Bt,a.trigger(n,f)||(d.metadata[h].expanded=!i,c.toggleClass(Ft,!i).toggleClass(zt,i),!i&&l?a.dataSource[u](f.path):a.refresh())}),a._scrollable(),a.options.autoBind&&a.dataSource.fetch(),ft.notify(a)},events:[Mt,It,Bt,Lt],options:{name:"PivotGrid",autoBind:!0,reorderable:!0,filterable:!1,sortable:!1,height:null,columnWidth:100,configurator:"",columnHeaderTemplate:null,rowHeaderTemplate:null,dataCellTemplate:null,kpiStatusTemplate:null,kpiTrendTemplate:null,messages:{measureFields:"Drop Data Fields Here",columnFields:"Drop Column Fields Here",rowFields:"Drop Rows Fields Here"}},_templates:function(){var e=this.options.columnHeaderTemplate,t=this.options.rowHeaderTemplate,n=this.options.dataCellTemplate,i=this.options.kpiStatusTemplate,r=this.options.kpiTrendTemplate;this._columnBuilder.template=ft.template(e||Rt,{useWithBlock:!!e}),this._contentBuilder.dataTemplate=ft.template(n||Ht,{useWithBlock:!!n}),this._contentBuilder.kpiStatusTemplate=ft.template(i||Ot,{useWithBlock:!!i}),this._contentBuilder.kpiTrendTemplate=ft.template(r||Nt,{useWithBlock:!!r}),this._rowBuilder.template=ft.template(t||Rt,{useWithBlock:!!t})},_bindConfigurator:function(){var t=this.options.configurator;t&&e(t).kendoPivotConfigurator("setDataSource",this.dataSource)},cellInfoByElement:function(t){return t=e(t),this.cellInfo(t.index(),t.parent("tr").index())},cellInfo:function(e,t){var n,i=this._contentBuilder,r=i.columnIndexes[e||0],o=i.rowIndexes[t||0];return r&&o?(n=o.index*i.rowLength+r.index,{columnTuple:r.tuple,rowTuple:o.tuple,measure:r.measure||o.measure,dataItem:this.dataSource.view()[n]}):null},setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this.measuresTarget&&this.measuresTarget.setDataSource(e),this.rowsTarget&&this.rowsTarget.setDataSource(e),this.columnsTarget&&this.columnsTarget.setDataSource(e),this._bindConfigurator(),this.options.autoBind&&e.fetch()},setOptions:function(e){mt.fn.setOptions.call(this,e),this._templates()},_dataSource:function(){var t=this,n=t.options.dataSource;n=e.isArray(n)?{data:n}:n,t.dataSource&&this._refreshHandler?t.dataSource.unbind(kt,t._refreshHandler).unbind(Tt,t._stateResetHandler).unbind(St,t._progressHandler).unbind(Ct,t._errorHandler):(t._refreshHandler=e.proxy(t.refresh,t),t._progressHandler=e.proxy(t._requestStart,t),t._stateResetHandler=e.proxy(t._stateReset,t),t._errorHandler=e.proxy(t._error,t)),t.dataSource=ft.data.PivotDataSource.create(n).bind(kt,t._refreshHandler).bind(St,t._progressHandler).bind(Tt,t._stateResetHandler).bind(Ct,t._errorHandler)},_error:function(){this._progress(!1)},_requestStart:function(){this._progress(!0)},_stateReset:function(){this._columnBuilder.reset(),this._rowBuilder.reset()},_wrapper:function(){var e=this.options.height;this.wrapper=this.element.addClass("k-widget k-pivot"),e&&this.wrapper.css("height",e)},_measureFields:function(){this.measureFields=e(At).addClass("k-pivot-toolbar k-header k-settings-measures"),this.measuresTarget=this._createSettingTarget(this.measureFields,{setting:"measures",messages:{empty:this.options.messages.measureFields}})},_createSettingTarget:function(t,n){var i='<span tabindex="0" class="k-button" data-'+ft.ns+'name="${data.name}">${data.name}',r=n.sortable,o="";return r&&(o+="#if (data.sortIcon) {#",o+='<span class="k-icon ${data.sortIcon} k-setting-sort"></span>',o+="#}#"),(n.filterable||r)&&(o+='<span class="k-icon k-i-arrowhead-s k-setting-fieldmenu"></span>'),this.options.reorderable&&(o+='<span class="k-icon k-si-close k-setting-delete"></span>'),o&&(i+='<span class="k-field-actions">'+o+"</span>"),i+="</span>",new ft.ui.PivotSettingTarget(t,e.extend({template:i,emptyTemplate:'<span class="k-empty">${data}</span>',enabled:this.options.reorderable,dataSource:this.dataSource},n))},_initSettingTargets:function(){this.columnsTarget=this._createSettingTarget(this.columnFields,{connectWith:this.rowFields,setting:"columns",filterable:this.options.filterable,sortable:this.options.sortable,messages:{empty:this.options.messages.columnFields,fieldMenu:this.options.messages.fieldMenu}}),this.rowsTarget=this._createSettingTarget(this.rowFields,{connectWith:this.columnFields,setting:"rows",filterable:this.options.filterable,sortable:this.options.sortable,messages:{empty:this.options.messages.rowFields,fieldMenu:this.options.messages.fieldMenu}})},_createLayout:function(){var t=this,n=e(Vt),i=n.find(".k-pivot-rowheaders"),r=n.find(".k-pivot-table"),o=e(At).addClass("k-grid k-widget");t._measureFields(),t.columnFields=e(At).addClass("k-pivot-toolbar k-header k-settings-columns"),t.rowFields=e(At).addClass("k-pivot-toolbar k-header k-settings-rows"),t.columnsHeader=e('<div class="k-grid-header-wrap" />').wrap('<div class="k-grid-header" />'),t.columnsHeader.parent().css("padding-right",ft.support.scrollbar()),t.rowsHeader=e('<div class="k-grid k-widget k-alt"/>'),t.content=e('<div class="k-grid-content" />'),i.append(t.measureFields),i.append(t.rowFields),i.append(t.rowsHeader),o.append(t.columnsHeader.parent()),o.append(t.content),r.append(t.columnFields),r.append(o),t.wrapper.append(n),t.columnsHeaderTree=new ft.dom.Tree(t.columnsHeader[0]),t.rowsHeaderTree=new ft.dom.Tree(t.rowsHeader[0]),t.contentTree=new ft.dom.Tree(t.content[0]),t._initSettingTargets()},_progress:function(e){ft.ui.progress(this.wrapper,e)},_resize:function(){var e=this.columnsHeader.children("table");this.content[0].firstChild&&(this._setSectionsWidth(),this._setSectionsHeight(),this._setContentWidth(),this._setContentHeight(),e.css("table-layout",Dt),clearTimeout(this._layoutTimeout),this._layoutTimeout=setTimeout(function(){e.css("table-layout","fixed")}))},_setSectionsWidth:function(){var e=this.rowsHeader,t=e.parent(".k-pivot-rowheaders").width(Dt),n=Math.max(this.measureFields.outerWidth(),this.rowFields.outerWidth());n=Math.max(e.children("table").width(),n),t.width(n)},_setSectionsHeight:function(){var e=this.measureFields.height(Dt).height(),t=this.columnFields.height(Dt).height(),n=this.rowFields.height(Dt).innerHeight(),i=this.columnsHeader.height(Dt).innerHeight(),r=n-this.rowFields.height(),o=t>e?t:e,a=i>n?i:n;this.measureFields.height(o),this.columnFields.height(o),this.rowFields.height(a-r),this.columnsHeader.height(a)},_setContentWidth:function(){var e=this.content.find("table"),t=this.content.width(),n=e.children("colgroup").children().length,i=100,r=n*this.options.columnWidth;r>t&&(i=Math.ceil(r/t*100)),e.add(this.columnsHeader.children("table")).css("min-width",i+"%")},_setContentHeight:function(){var e=this,n=e.content,i=e.rowsHeader,r=e.wrapper.innerHeight(),o=ft.support.scrollbar(),a=n[0].offsetHeight===n[0].clientHeight;if(e.wrapper.is(":visible")){if(!r)return a&&(o=0),i.height(n.height()-o),t;r-=e.columnFields.outerHeight(),r-=e.columnsHeader.outerHeight(),2*o>=r&&(r=2*o+1,a||(r+=o)),n.height(r),a&&(o=0),i.height(r-o)}},_axisMeasures:function(e){var t=[],n=this.dataSource,i=n.measures(),r=i.length>1||i[0]&&i[0].type;return n.measuresAxis()===e&&(0===n[e]().length||r)&&(t=i),t},refresh:function(){var e,t=this,n=t.dataSource,i=n.axes(),r=(i.columns||{}).tuples||[],o=(i.rows||{}).tuples||[],a=t._columnBuilder,s=t._rowBuilder,l={},c={};t.trigger(Mt,{action:"rebind"})||(a.measures=this._axisMeasures("columns"),t.columnsHeaderTree.render(a.build(r)),t.rowsHeaderTree.render(s.build(o)),l={indexes:a._indexes,measures:a.measures,metadata:a.metadata},c={indexes:s._indexes,measures:this._axisMeasures("rows"),metadata:s.metadata},t.contentTree.render(t._contentBuilder.build(n.view(),l,c)),t._resize(),t.touchScroller?t.touchScroller.contentResized():(e=ft.touchScroller(t.content),e&&e.movable&&(t.touchScroller=e,e.movable.bind("change",function(e){t.columnsHeader.scrollLeft(-e.sender.x),t.rowsHeader.scrollTop(-e.sender.y)}))),t._progress(!1),t.trigger(It))},_scrollable:function(){var t=this,n=t.columnsHeader,i=t.rowsHeader;t.content.scroll(function(){n.scrollLeft(this.scrollLeft),i.scrollTop(this.scrollTop)}),i.bind("DOMMouseScroll"+Et+" mousewheel"+Et,e.proxy(t._wheelScroll,t))},_wheelScroll:function(t){var n,i;t.ctrlKey||(n=ft.wheelDeltaY(t),i=this.content.scrollTop(),n&&(t.preventDefault(),e(t.currentTarget).one("wheel"+Et,!1),this.rowsHeader.scrollTop(i+-n),this.content.scrollTop(i+-n)))}}),rt=ft.dom.element,ot=ft.dom.html,at=ft.dom.text,st=function(e,t){return{maxChildren:0,children:0,maxMembers:0,members:0,measures:1,levelNum:e,parentMember:0!==t}},lt=function(e,t){for(var n=[],i=0;t>=i;i++)n.push(e.members[i].name);return n},ct=function(e,t){for(var n="",i=0;t>=i;i++)n+=e.members[i].name;return n},dt=gt.extend({init:function(){this.measures=1,this.metadata={}},build:function(e){var t=this._tbody(e),n=this._colGroup();return[rt("table",null,[n,t])]},reset:function(){this.metadata={}},_colGroup:function(){for(var e=this._rowLength(),t=[],n=0;e>n;n++)t.push(rt("col",null));return rt("colgroup",null,t)},_tbody:function(e){var t=e[0];return this.map={},this.rows=[],this.rootTuple=t,this._indexes=[],t?(this._buildRows(t,0),this._normalize()):this.rows.push(rt("tr",null,[rt("th",null,[ot("&nbsp;")])])),rt("tbody",null,this.rows)},_normalize:function(){for(var e,t,n,i,r,o=this.rows,a=o.length,s=0;a>s;s++)if(e=o[s],1!==e.rowSpan)for(i=e.children,n=0,t=i.length;t>n;n++)r=i[n],r.tupleAll&&(r.attr.rowSpan=e.rowSpan)},_rowIndex:function(e){for(var t=this.rows,n=t.length,i=0;n>i&&t[i]!==e;i++);return i},_rowLength:function(){var e=this.rows[0]?this.rows[0].children:[],t=e.length,n=0,i=0;if(t)for(;t>i;i++)n+=e[i].attr.colSpan||1;return n||(n=this.measures),n},_row:function(e,t,n){var i,r,o=this.rootTuple.members[t].name,a=e.members[t].levelNum,s=o+a,l=this.map,c=l[s];return c?(c.notFirst=!1,c.parentMember&&c.parentMember===n||(c.parentMember=n,c.colSpan=0)):(c=rt("tr",null,[]),c.parentMember=n,c.colSpan=0,c.rowSpan=1,l[s]=c,i=l[o+(+a-1)],i&&(r=i.children,c.notFirst=r[1]&&-1===r[1].attr.className.indexOf("k-alt")?!0:i.notFirst),this.rows.splice(this._rowIndex(i)+1,0,c)),c},_measures:function(e,t,n){var i,r,o,a=this.map,s=a.measureRow;for(s||(s=rt("tr",null,[]),a.measureRow=s,this.rows.push(s)),r=0,o=e.length;o>r;r++)i=e[r],s.children.push(rt("th",{className:"k-header"+(n||"")},[this._content(i,t)]));return o},_content:function(e,t){return ot(this.template({member:e,tuple:t}))},_cell:function(e,t){return rt("th",{className:"k-header"+e},t)},_buildRows:function(e,n,i){var r,o,a,s,l,c,d,u,h,f,p=e.members,g=p[n],m=p[n+1],v=[],_=0;if(g.measure)return this._measures(g.children,e),t;if(u=ft.stringify(lt(e,n)),r=this._row(e,n,i),a=g.children,s=a.length,f=this.metadata[u],f||(this.metadata[u]=f=st(+g.levelNum,n)),this._indexes.push({path:u,tuple:e}),g.hasChildren&&(f.expanded===!1&&(s=0,f.children=0),d={className:"k-icon "+(s?Ft:zt)},d[ft.attr("path")]=u,v.push(rt("span",d))),v.push(this._content(g,e)),l=this._cell(r.notFirst?" k-first":"",v),r.children.push(l),r.colSpan+=1,s){for(c=this._cell(" k-alt",[this._content(g,e)]),r.children.push(c);s>_;_++)o=this._buildRows(a[_],n,g);h=o.colSpan,l.attr.colSpan=h,f.children=h,f.members=1,r.colSpan+=h,r.rowSpan=o.rowSpan+1,m&&(h=m.measure?this._measures(m.children,e," k-alt"):this._buildRows(e,n+1).colSpan,c.attr.colSpan=h,h-=1,f.members+=h,r.colSpan+=h)}else m&&(h=m.measure?this._measures(m.children,e):this._buildRows(e,n+1).colSpan,f.members=h,h>1&&(l.attr.colSpan=h,r.colSpan+=h-1));return f.children>f.maxChildren&&(f.maxChildren=f.children),f.members>f.maxMembers&&(f.maxMembers=f.members),(c||l).tupleAll=!0,r}}),ut=gt.extend({init:function(){this.metadata={}},build:function(e){var t=this._tbody(e),n=this._colGroup();return[rt("table",null,[n,t])]},reset:function(){this.metadata={}},_colGroup:function(){for(var e=this.rows[0].children.length,t=[],n=0;e>n;n++)t.push(rt("col",null));return rt("colgroup",null,t)},_tbody:function(e){var t=e[0];return this.rootTuple=t,this.rows=[],this.map={},this._indexes=[],t?(this._buildRows(t,0),this._normalize()):this.rows.push(rt("tr",null,[rt("td",null,[ot("&nbsp;")])])),rt("tbody",null,this.rows)},_normalize:function(){for(var e,t,n,i,r=this.rows,o=r.length,a=0,s=this.rootTuple.members,l=s[0].name,c=s.length,d=0,u=this.map;o>a;a++)for(e=r[a],d=0;c>d;d++)n=this[s[d].name],t=e.colSpan["dim"+d],t&&n>t.levelNum&&(t.attr.colSpan=n-t.levelNum+1);e=u[l],i=u[l+"all"],e&&(e.children[0].attr.className="k-first"),i&&(i.children[0].attr.className+=" k-first")},_row:function(e){var t=rt("tr",null,e);return t.rowSpan=1,t.colSpan={},this.rows.push(t),t},_content:function(e,t){return ot(this.template({member:e,tuple:t}))},_buildRows:function(e,t){var n,i,r,o,a,s,l,c,d,u=this.map,h=e.members,f=h[t],p=h[t+1],g=f.children,m=g.length,v=+f.levelNum+1,_=this.rootTuple.members[t].name,w=lt(e,t-1).join(""),y=w+(f.parentName||""),b=u[y+"all"]||u[y],x=[];if(!b||b.hasChild?b=this._row():b.hasChild=!0,f.measure){for(c={className:b.allCell?"k-grid-footer":""},b.children.push(rt("td",c,[this._content(g[0],e)])),b.rowSpan=m,d=1;m>d;d++)this._row([rt("td",c,[this._content(g[d],e)])]);return b}if(u[w+f.name]=b,n=ft.stringify(lt(e,t)),o=this.metadata[n],o||(this.metadata[n]=o=st(v-1,t)),this._indexes.push({path:n,tuple:e}),f.hasChildren&&(o.expanded===!1&&(m=0,o.children=0),a={className:"k-icon "+(m?Ft:zt)},a[ft.attr("path")]=n,x.push(rt("span",a))),x.push(this._content(f,e)),l=rt("td",{className:b.allCell&&!m?"k-grid-footer":""},x),l.levelNum=v,b.children.push(l),b.colSpan["dim"+t]=l,(!this[_]||v>this[_])&&(this[_]=v),m){for(b.allCell=!1,b.hasChild=!1,d=0;m>d;d++)i=this._buildRows(g[d],t),b!==i&&(b.rowSpan+=i.rowSpan);b.rowSpan>1&&(l.attr.rowSpan=b.rowSpan),o.children=b.rowSpan,s=rt("td",{className:"k-grid-footer"},[this._content(f,e)]),s.levelNum=v,r=this._row([s]),r.colSpan["dim"+t]=s,r.allCell=!0,u[w+f.name+"all"]=r,p&&(i=this._buildRows(e,t+1),s.attr.rowSpan=i.rowSpan),b.rowSpan+=r.rowSpan,o.members=r.rowSpan}else p&&(b.hasChild=!1,this._buildRows(e,t+1),(s||l).attr.rowSpan=b.rowSpan,o.members=b.rowSpan);return o.children>o.maxChildren&&(o.maxChildren=o.children),o.members>o.maxMembers&&(o.maxMembers=o.members),b}}),ht=gt.extend({init:function(){this.columnAxis={},this.rowAxis={}},build:function(e,n,i){var r,o,a=n.indexes[0],s=n.metadata[a?a.path:t];return this.columnAxis=n,this.rowAxis=i,this.data=e,this.rowLength=s?s.maxChildren+s.maxMembers:n.measures.length||1,this.rowLength||(this.rowLength=1),r=this._tbody(),o=this._colGroup(),[rt("table",null,[o,r])]},_colGroup:function(){var e=this.columnAxis.measures.length||1,t=[],n=0;for(this.rows[0]&&(e=this.rows[0].children.length);e>n;n++)t.push(rt("col",null));return rt("colgroup",null,t)},_tbody:function(){return this.rows=[],this.data[0]?(this.columnIndexes=this._indexes(this.columnAxis),this.rowIndexes=this._indexes(this.rowAxis),this._buildRows()):this.rows.push(rt("tr",null,[rt("td",null,[ot("&nbsp;")])])),rt("tbody",null,this.rows)},_indexes:function(e){var n,i,r,o,a,s=[],l=e.indexes,c=e.metadata,d=e.measures,u=d.length||1,h=0,f=0,p=0,g=l.length;if(!g){for(r=0;u>r;r++)s[r]={index:r,measure:d[r],tuple:null};return s}for(;g>p;p++){if(n=l[p],i=c[n.path],o=i.children+i.members,a=0,o&&(o-=u),i.expanded===!1&&i.children!==i.maxChildren&&(a=i.maxChildren),i.parentMember&&0===i.levelNum&&(o=-1),o>-1){for(r=0;u>r;r++)s[o+f+r]={children:o,index:h,measure:d[r],tuple:n.tuple},h+=1;for(;s[f]!==t;)f+=1}h+=a}return s},_buildRows:function(){for(var e=this.rowIndexes,t=e.length,n=0;t>n;n++)this.rows.push(this._buildRow(e[n]))},_buildRow:function(e){for(var t,n,i,r,o,a,s=e.index*this.rowLength,l=this.columnIndexes,c=l.length,d=[],u=0;c>u;u++)t=l[u],r={},t.children&&(r.className="k-alt"),i="",o=this.data[s+t.index],a=t.measure||e.measure,n={columnTuple:t.tuple,rowTuple:e.tuple,measure:a,dataItem:o},""!==o.value&&a&&a.type&&("status"===a.type?i=this.kpiStatusTemplate(n):"trend"===a.type&&(i=this.kpiTrendTemplate(n))),i||(i=this.dataTemplate(n)),d.push(rt("td",r,[ot(i)]));return r={},e.children&&(r.className="k-grid-footer"),rt("tr",r,d)}}),pt.plugin(it)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});