@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
2 lines • 32.4 kB
JavaScript
module.exports=function(t){function i(n){if(e[n])return e[n].exports;var s=e[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}({0:function(t,i,e){t.exports=e(878)},3:function(t,i){t.exports=function(){throw Error("define cannot be used indirect")}},857:function(t,i){t.exports=require("../../kendo.dataviz.core")},878:function(t,i,e){var n,s,h;!function(r,define){s=[e(879),e(857)],n=r,h="function"==typeof n?n.apply(i,s):n,!(void 0!==h&&(t.exports=h))}(function(){!function(t,i){function e(t){return Math.abs(t)<D}function n(t,i,n,s,h){var r,o,a,u,d=(i.x-t.x)*(s.y-n.y)-(i.y-t.y)*(s.x-n.x);if(!e(d)&&(r=(t.y-n.y)*(s.x-n.x)-(t.x-n.x)*(s.y-n.y),o=(t.y-n.y)*(i.x-t.x)-(t.x-n.x)*(i.y-t.y),a=r/d,u=o/d,!h||!(a<0||a>1||u<0||u>1)))return new M(t.x+a*(i.x-t.x),t.y+a*(i.y-t.y))}function s(t,i){var e,n,s;do e=2*Math.random()-1,n=2*Math.random()-1,s=e*e+n*n;while(!s||s>1);return t+i*e*Math.sqrt(-2*Math.log(s)/s)}function h(t){var i,e,n;for(U.isUndefined(t)&&(t=10),i="",e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=t;n>0;--n)i+=e.charAt(Math.round(Math.random()*(e.length-1)));return i}var r,o,a,u,d,c,f,l,g,p,y,m,x,v,w,k,b=window.kendo,_=b.dataviz.diagram,N=b.Class,L=b.deepExtend,T=b.dataviz,U=_.Utils,M=T.Point2D,C=b.isFunction,E=U.contains,S=t.map,R=3,D=1e-6;L(M.fn,{plus:function(t){return new M(this.x+t.x,this.y+t.y)},minus:function(t){return new M(this.x-t.x,this.y-t.y)},offset:function(t){return new M(this.x-t,this.y-t)},times:function(t){return new M(this.x*t,this.y*t)},normalize:function(){return 0===this.length()?new M:this.times(1/this.length())},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},toString:function(){return"("+this.x+","+this.y+")"},lengthSquared:function(){return this.x*this.x+this.y*this.y},middleOf:function(t,i){return new M(i.x-t.x,i.y-t.y).times(.5).plus(t)},toPolar:function(t){var i,e,n,s=1;if(t&&(s=180/Math.PI),i=Math.atan2(Math.abs(this.y),Math.abs(this.x)),e=Math.PI/2,n=this.length(),0===this.x){if(0===this.y)return new c(0,0);if(this.y>0)return new c(n,s*e);if(this.y<0)return new c(n,3*s*e)}else if(this.x>0){if(0===this.y)return new c(n,0);if(this.y>0)return new c(n,s*i);if(this.y<0)return new c(n,s*(4*e-i))}else{if(0===this.y)return new c(n,2*e);if(this.y>0)return new c(n,s*(2*e-i));if(this.y<0)return new c(n,s*(2*e+i))}},isOnLine:function(t,i){var e,n,s,h,r;return t.x>i.x&&(e=i,i=t,t=e),n=new o(t.x,t.y).inflate(R,R),s=new o(i.x,i.y).inflate(R,R),!!n.union(s).contains(this)&&(t.x===i.x||t.y===i.y||(t.y<i.y?(h=n.x+(s.x-n.x)*(this.y-(n.y+n.height))/(s.y+s.height-(n.y+n.height)),r=n.x+n.width+(s.x+s.width-(n.x+n.width))*(this.y-n.y)/(s.y-n.y)):(h=n.x+(s.x-n.x)*(this.y-n.y)/(s.y-n.y),r=n.x+n.width+(s.x+s.width-(n.x+n.width))*(this.y-(n.y+n.height))/(s.y+s.height-(n.y+n.height))),this.x>h&&this.x<r))}}),L(M,{parse:function(t){var i=t.slice(1,t.length-1),e=i.split(","),n=parseInt(e[0],10),s=parseInt(e[1],10);if(!isNaN(n)&&!isNaN(s))return new M(n,s)}}),r=N.extend({init:function(t,i,e){this.point=t,this.left=i,this.right=e}}),o=N.extend({init:function(t,i,e,n){this.x=t||0,this.y=i||0,this.width=e||0,this.height=n||0},contains:function(t){return t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},inflate:function(t,e){return e===i&&(e=t),this.x-=t,this.y-=e,this.width+=2*t+1,this.height+=2*e+1,this},offset:function(t,i){var e=t,n=i;return t instanceof M&&(e=t.x,n=t.y),this.x+=e,this.y+=n,this},union:function(t){var i=Math.min(this.x,t.x),e=Math.min(this.y,t.y),n=Math.max(this.x+this.width,t.x+t.width),s=Math.max(this.y+this.height,t.y+t.height);return new o(i,e,n-i,s-e)},center:function(){return new M(this.x+this.width/2,this.y+this.height/2)},top:function(){return new M(this.x+this.width/2,this.y)},right:function(){return new M(this.x+this.width,this.y+this.height/2)},bottom:function(){return new M(this.x+this.width/2,this.y+this.height)},left:function(){return new M(this.x,this.y+this.height/2)},topLeft:function(){return new M(this.x,this.y)},topRight:function(){return new M(this.x+this.width,this.y)},bottomLeft:function(){return new M(this.x,this.y+this.height)},bottomRight:function(){return new M(this.x+this.width,this.y+this.height)},clone:function(){return new o(this.x,this.y,this.width,this.height)},isEmpty:function(){return!this.width&&!this.height},equals:function(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},rotatedBounds:function(t){var i=this.clone(),e=this.rotatedPoints(t),n=e[0],s=e[1],h=e[2],r=e[3];return i.x=Math.min(h.x,n.x,s.x,r.x),i.y=Math.min(h.y,n.y,s.y,r.y),i.width=Math.max(h.x,n.x,s.x,r.x)-i.x,i.height=Math.max(h.y,n.y,s.y,r.y)-i.y,i},rotatedPoints:function(t){var i=this,e=i.center(),n=i.bottomRight().rotate(e,360-t),s=i.topLeft().rotate(e,360-t),h=i.topRight().rotate(e,360-t),r=i.bottomLeft().rotate(e,360-t);return[s,h,n,r]},toString:function(t){return t=t||" ",this.x+t+this.y+t+this.width+t+this.height},scale:function(t,i,e,n,s){var h,r,o,a=this.topLeft(),u=this.center();a.rotate(u,360-s).rotate(n,s),h=e.minus(a),r=new M(h.x*t,h.y*i),o=h.minus(r),a=a.plus(o),a.rotate(n,360-s).rotate(u,s),this.x=a.x,this.y=a.y,this.width*=t,this.height*=i},zoom:function(t){return this.x*=t,this.y*=t,this.width*=t,this.height*=t,this},overlaps:function(t){var i=this.bottomRight(),e=t.bottomRight(),n=!(i.x<t.x||i.y<t.y||e.x<this.x||e.y<this.y);return n}}),a=N.extend({init:function(t,i){this.width=t,this.height=i}}),a.prototype.Empty=new a(0,0),o.toRect=function(t){return t instanceof o||(t=new o(t.x,t.y,t.width,t.height)),t},o.empty=function(){return new o(0,0,0,0)},o.fromPoints=function(t,i){if(isNaN(t.x)||isNaN(t.y)||isNaN(i.x)||isNaN(i.y))throw"Some values are NaN.";return new o(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.abs(t.x-i.x),Math.abs(t.y-i.y))},u={lines:function(t,i,e,s){return n(t,i,e,s)},segments:function(t,i,e,s){return n(t,i,e,s,!0)},rectWithLine:function(t,i,e){return u.segments(i,e,t.topLeft(),t.topRight())||u.segments(i,e,t.topRight(),t.bottomRight())||u.segments(i,e,t.bottomLeft(),t.bottomRight())||u.segments(i,e,t.topLeft(),t.bottomLeft())},rects:function(t,i,e){var n,s,h=i.topLeft(),r=i.topRight(),o=i.bottomLeft(),a=i.bottomRight(),d=i.center();return e&&(h=h.rotate(d,e),r=r.rotate(d,e),o=o.rotate(d,e),a=a.rotate(d,e)),n=t.contains(h)||t.contains(r)||t.contains(o)||t.contains(a)||u.rectWithLine(t,h,r)||u.rectWithLine(t,h,o)||u.rectWithLine(t,r,a)||u.rectWithLine(t,o,a),n||(h=t.topLeft(),r=t.topRight(),o=t.bottomLeft(),a=t.bottomRight(),e&&(s=360-e,h=h.rotate(d,s),r=r.rotate(d,s),o=o.rotate(d,s),a=a.rotate(d,s)),n=i.contains(h)||i.contains(r)||i.contains(o)||i.contains(a)),n}},d=N.extend({init:function(t){this.container=o.toRect(t)},align:function(t,i){var e,n=i.toLowerCase().split(" ");for(e=0;e<n.length;e++)t=this._singleAlign(t,n[e]);return t},_singleAlign:function(t,i){return C(this[i])?this[i](t):t},left:function(t){return this._align(t,this._left)},center:function(t){return this._align(t,this._center)},right:function(t){return this._align(t,this._right)},stretch:function(t){return this._align(t,this._stretch)},top:function(t){return this._align(t,this._top)},middle:function(t){return this._align(t,this._middle)},bottom:function(t){return this._align(t,this._bottom)},_left:function(t,i){i.x=t.x},_center:function(t,i){i.x=(t.width-i.width)/2||0},_right:function(t,i){i.x=t.width-i.width},_top:function(t,i){i.y=t.y},_middle:function(t,i){i.y=(t.height-i.height)/2||0},_bottom:function(t,i){i.y=t.height-i.height},_stretch:function(t,i){i.x=0,i.y=0,i.height=t.height,i.width=t.width},_align:function(t,i){return t=o.toRect(t),i(this.container,t),t}}),c=N.extend({init:function(t,i){this.r=t,this.angle=i}}),f=N.extend({init:function(t,i,e,n,s,h){this.a=t||0,this.b=i||0,this.c=e||0,this.d=n||0,this.e=s||0,this.f=h||0},plus:function(t){this.a+=t.a,this.b+=t.b,this.c+=t.c,this.d+=t.d,this.e+=t.e,this.f+=t.f},minus:function(t){this.a-=t.a,this.b-=t.b,this.c-=t.c,this.d-=t.d,this.e-=t.e,this.f-=t.f},times:function(t){return new f(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)},apply:function(t){return new M(this.a*t.x+this.c*t.y+this.e,this.b*t.x+this.d*t.y+this.f)},applyRect:function(t){return o.fromPoints(this.apply(t.topLeft()),this.apply(t.bottomRight()))},toString:function(){return"matrix("+this.a+" "+this.b+" "+this.c+" "+this.d+" "+this.e+" "+this.f+")"}}),L(f,{fromSVGMatrix:function(t){var i=new f;return i.a=t.a,i.b=t.b,i.c=t.c,i.d=t.d,i.e=t.e,i.f=t.f,i},fromMatrixVector:function(t){var i=new f;return i.a=t.a,i.b=t.b,i.c=t.c,i.d=t.d,i.e=t.e,i.f=t.f,i},fromList:function(t){if(6!==t.length)throw"The given list should consist of six elements.";var i=new f;return i.a=t[0],i.b=t[1],i.c=t[2],i.d=t[3],i.e=t[4],i.f=t[5],i},translation:function(t,i){var e=new f;return e.a=1,e.b=0,e.c=0,e.d=1,e.e=t,e.f=i,e},unit:function(){return new f(1,0,0,1,0,0)},rotation:function(t,i,e){var n=new f;return n.a=Math.cos(t*Math.PI/180),n.b=Math.sin(t*Math.PI/180),n.c=-n.b,n.d=n.a,n.e=i-i*n.a+e*n.b||0,n.f=e-e*n.a-i*n.b||0,n},scaling:function(t,i){var e=new f;return e.a=t,e.b=0,e.c=0,e.d=i,e.e=0,e.f=0,e},parse:function(t){var i,e;if(t){if(t=t.trim(),"matrix"===t.slice(0,6).toLowerCase()){if(e=t.slice(7,t.length-1).trim(),i=e.split(","),6===i.length)return f.fromList(S(i,function(t){return parseFloat(t)}));if(i=e.split(" "),6===i.length)return f.fromList(S(i,function(t){return parseFloat(t)}))}if("("===t.slice(0,1)&&")"===t.slice(t.length-1)&&(t=t.substr(1,t.length-1)),t.indexOf(",")>0&&(i=t.split(","),6===i.length))return f.fromList(S(i,function(t){return parseFloat(t)}));if(t.indexOf(" ")>0&&(i=t.split(" "),6===i.length))return f.fromList(S(i,function(t){return parseFloat(t)}))}return i}}),l=N.extend({init:function(t,i,e,n,s,h){this.a=t||0,this.b=i||0,this.c=e||0,this.d=n||0,this.e=s||0,this.f=h||0},fromMatrix:function(t){var i=new l;return i.a=t.a,i.b=t.b,i.c=t.c,i.d=t.d,i.e=t.e,i.f=t.f,i}}),g={_distanceToLineSquared:function(t,i,e){function n(t,i){return(t.x-i.x)*(t.x-i.x)+(t.y-i.y)*(t.y-i.y)}if(i===e)return n(t,i);var s=e.x-i.x,h=e.y-i.y,r=(t.x-i.x)*s+(t.y-i.y)*h;return r<0?n(i,t):(r=(e.x-t.x)*s+(e.y-t.y)*h,r<0?n(e,t):(r=(e.x-t.x)*h-(e.y-t.y)*s,r*r/(s*s+h*h)))},distanceToLine:function(t,i,e){return Math.sqrt(this._distanceToLineSquared(t,i,e))},distanceToPolyline:function(t,i){var e,n,s,h,r=Number.MAX_VALUE;if(U.isUndefined(i)||0===i.length)return Number.MAX_VALUE;for(e=0;e<i.length-1;e++)n=i[e],s=i[e+1],h=this._distanceToLineSquared(t,n,s),h<r&&(r=h);return Math.sqrt(r)}},p=b.Class.extend({init:function(){this._buckets=[],this.length=0},add:function(t,i){var e=this._createGetBucket(t);return U.isDefined(i)&&(e.value=i),e},get:function(t){return this._bucketExists(t)?this._createGetBucket(t):null},set:function(t,i){this.add(t,i)},containsKey:function(t){return this._bucketExists(t)},remove:function(t){if(this._bucketExists(t)){var i=this._hash(t);return delete this._buckets[i],this.length--,t}},forEach:function(t){var i,e,n,s,h=this._hashes();for(i=0,e=h.length;i<e;i++)n=h[i],s=this._buckets[n],U.isUndefined(s)||t(s)},clone:function(){var t,i,e,n,s=new p,h=this._hashes();for(t=0,i=h.length;t<i;t++)e=h[t],n=this._buckets[e],U.isUndefined(n)||s.add(n.key,n.value);return s},_hashes:function(){var t,i=[];for(t in this._buckets)this._buckets.hasOwnProperty(t)&&i.push(t);return i},_bucketExists:function(t){var i=this._hash(t);return U.isDefined(this._buckets[i])},_createGetBucket:function(t){var i=this._hash(t),e=this._buckets[i];return U.isUndefined(e)&&(e={key:t},this._buckets[i]=e,this.length++),e},_hash:function(t){if(U.isNumber(t))return t;if(U.isString(t))return this._hashString(t);if(U.isObject(t))return this._objectHashId(t);throw"Unsupported key type."},_hashString:function(t){var i,e,n=0;if(0===t.length)return n;for(i=0;i<t.length;i++)e=t.charCodeAt(i),n=32*n-n+e;return n},_objectHashId:function(t){var i=t._hashId;return U.isUndefined(i)&&(i=h(),t._hashId=i),i}}),y=b.Observable.extend({init:function(i){var e,n=this;if(b.Observable.fn.init.call(n),this._hashTable=new p,this.length=0,U.isDefined(i))if(t.isArray(i))for(e=0;e<i.length;e++)this.add(i[e]);else i.forEach(function(t,i){this.add(t,i)},this)},add:function(t,i){var e=this._hashTable.get(t);e||(e=this._hashTable.add(t),this.length++,this.trigger("changed")),e.value=i},set:function(t,i){this.add(t,i)},get:function(t){var i=this._hashTable.get(t);if(i)return i.value;throw Error("Cannot find key "+t)},containsKey:function(t){return this._hashTable.containsKey(t)},remove:function(t){if(this.containsKey(t))return this.trigger("changed"),this.length--,this._hashTable.remove(t)},forEach:function(t,i){this._hashTable.forEach(function(e){t.call(i,e.key,e.value)})},forEachValue:function(t,i){this._hashTable.forEach(function(e){t.call(i,e.value)})},forEachKey:function(t,i){this._hashTable.forEach(function(e){t.call(i,e.key)})},keys:function(){var t=[];return this.forEachKey(function(i){t.push(i)}),t}}),m=b.Class.extend({init:function(){this._tail=null,this._head=null,this.length=0},enqueue:function(t){var i={value:t,next:null};this._head?(this._tail.next=i,this._tail=this._tail.next):(this._head=i,this._tail=this._head),this.length++},dequeue:function(){if(this.length<1)throw Error("The queue is empty.");var t=this._head.value;return this._head=this._head.next,this.length--,t},contains:function(t){for(var i=this._head;i;){if(i.value===t)return!0;i=i.next}return!1}}),x=b.Observable.extend({init:function(t){var i=this;b.Observable.fn.init.call(i),this._hashTable=new p,this.length=0,U.isDefined(t)&&(t instanceof p?t.forEach(function(t){this.add(t)}):t instanceof y&&t.forEach(function(t,i){this.add({key:t,value:i})},this))},contains:function(t){return this._hashTable.containsKey(t)},add:function(t){var i=this._hashTable.get(t);i||(this._hashTable.add(t,t),this.length++,this.trigger("changed"))},get:function(t){return this.contains(t)?this._hashTable.get(t).value:null},hash:function(t){return this._hashTable._hash(t)},remove:function(t){this.contains(t)&&(this._hashTable.remove(t),this.length--,this.trigger("changed"))},forEach:function(t,i){this._hashTable.forEach(function(i){t(i.value)},i)},toArray:function(){var t=[];return this.forEach(function(i){t.push(i)}),t}}),v=b.Class.extend({init:function(t,i){if(this.links=[],this.outgoing=[],this.incoming=[],this.weight=1,this.id=U.isDefined(t)?t:h(),U.isDefined(i)){this.associatedShape=i;var e=i.bounds();this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y}else this.associatedShape=null;this.data=null,this.type="Node",this.shortForm="Node '"+this.id+"'",this.isVirtual=!1},isIsolated:function(){return U.isEmpty(this.links)},bounds:function(t){return U.isDefined(t)?(this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,i):new _.Rect(this.x,this.y,this.width,this.height)},isLinkedTo:function(t){var i=this;return U.any(i.links,function(e){return e.getComplement(i)===t})},getChildren:function(){var t,i,e,n;if(0===this.outgoing.length)return[];for(t=[],i=0,e=this.outgoing.length;i<e;i++)n=this.outgoing[i],t.push(n.getComplement(this));return t},getParents:function(){var t,i,e,n;if(0===this.incoming.length)return[];for(t=[],i=0,e=this.incoming.length;i<e;i++)n=this.incoming[i],t.push(n.getComplement(this));return t},clone:function(){var t=new v;return U.isDefined(this.weight)&&(t.weight=this.weight),U.isDefined(this.balance)&&(t.balance=this.balance),U.isDefined(this.owner)&&(t.owner=this.owner),t.associatedShape=this.associatedShape,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},adjacentTo:function(t){return null!==this.isLinkedTo(t)},removeLink:function(t){t.source===this&&(U.remove(this.links,t),U.remove(this.outgoing,t),t.source=null),t.target===this&&(U.remove(this.links,t),U.remove(this.incoming,t),t.target=null)},hasLinkTo:function(t){return U.any(this.outgoing,function(i){return i.target===t})},degree:function(){return this.links.length},incidentWith:function(t){return E(this.links,t)},getLinksWith:function(t){return U.all(this.links,function(i){return i.getComplement(this)===t},this)},getNeighbors:function(){var t=[];return U.forEach(this.incoming,function(i){t.push(i.getComplement(this))},this),U.forEach(this.outgoing,function(i){t.push(i.getComplement(this))},this),t}}),w=b.Class.extend({init:function(t,i,e,n){if(U.isUndefined(t))throw"The source of the new link is not set.";if(U.isUndefined(i))throw"The target of the new link is not set.";var s,r;s=U.isString(t)?new v(t):t,r=U.isString(i)?new v(i):i,this.source=s,this.target=r,this.source.links.push(this),this.target.links.push(this),this.source.outgoing.push(this),this.target.incoming.push(this),this.id=U.isDefined(e)?e:h(),this.associatedConnection=U.isDefined(n)?n:null,this.type="Link",this.shortForm="Link '"+this.source.id+"->"+this.target.id+"'"},getComplement:function(t){if(this.source!==t&&this.target!==t)throw"The given node is not incident with this link.";return this.source===t?this.target:this.source},getCommonNode:function(t){return this.source===t.source||this.source===t.target?this.source:this.target===t.source||this.target===t.target?this.target:null},isBridging:function(t,i){return this.source===t&&this.target===i||this.source===i&&this.target===t},getNodes:function(){return[this.source,this.target]},incidentWith:function(t){return this.source===t||this.target===t},adjacentTo:function(t){return E(this.source.links,t)||E(this.target.links,t)},changeSource:function(t){U.remove(this.source.links,this),U.remove(this.source.outgoing,this),t.links.push(this),t.outgoing.push(this),this.source=t},changeTarget:function(t){U.remove(this.target.links,this),U.remove(this.target.incoming,this),t.links.push(this),t.incoming.push(this),this.target=t},changesNodes:function(t,i){this.source===t?this.changeSource(i):this.target===t&&this.changeTarget(i)},reverse:function(){var t=this.source,i=this.target;return this.source=i,U.remove(t.outgoing,this),this.source.outgoing.push(this),this.target=t,U.remove(i.incoming,this),this.target.incoming.push(this),this},directTo:function(t){if(this.source!==t&&this.target!==t)throw"The given node is not incident with this link.";this.target!==t&&this.reverse()},createReverseEdge:function(){var t=this.clone();return t.reverse(),t.reversed=!0,t},clone:function(){var t=new w(this.source,this.target);return t}}),k=b.Class.extend({init:function(t){this.links=[],this.nodes=[],this._nodeMap=new y,this.diagram=null,this._root=null,U.isDefined(t)?U.isString(t)?this.id=t:(this.diagram=t,this.id=t.id):this.id=h(),this.bounds=new o,this._hasCachedRelationships=!1,this.type="Graph"},cacheRelationships:function(t){var i,e,n;if(U.isUndefined(t)&&(t=!1),!this._hasCachedRelationships||t){for(i=0,e=this.nodes.length;i<e;i++)n=this.nodes[i],n.children=this.getChildren(n),n.parents=this.getParents(n);this._hasCachedRelationships=!0}},assignLevels:function(t,i,e){var n,s,h,r;if(!t)throw"Start node not specified.";for(U.isUndefined(i)&&(i=0),this.cacheRelationships(),U.isUndefined(e)&&(e=new y,U.forEach(this.nodes,function(t){e.add(t,!1)})),e.set(t,!0),t.level=i,n=t.children,s=0,h=n.length;s<h;s++)r=n[s],r&&!e.get(r)&&this.assignLevels(r,i+1,e)},root:function(t){if(U.isUndefined(t)){if(this._root)return this._root;var i=U.first(this.nodes,function(t){return 0===t.incoming.length});return i?i:U.first(this.nodes)}this._root=t},getConnectedComponents:function(){var t,i,e,n,s;for(this.componentIndex=0,this.setItemIndices(),t=U.initArray(this.nodes.length,-1),i=0;i<this.nodes.length;i++)t[i]===-1&&(this._collectConnectedNodes(t,i),this.componentIndex++);for(e=[],n=0;n<this.componentIndex;++n)e[n]=new k;for(n=0;n<t.length;++n)s=e[t[n]],s.addNodeAndOutgoings(this.nodes[n]);return e.sort(function(t,i){return i.nodes.length-t.nodes.length}),e},_collectConnectedNodes:function(t,i){t[i]=this.componentIndex;var e=this.nodes[i];U.forEach(e.links,function(i){var n=i.getComplement(e),s=n.index;t[s]===-1&&this._collectConnectedNodes(t,s)},this)},calcBounds:function(){var t,i,e,n;if(this.isEmpty())return this.bounds=new o;for(t=null,i=0,e=this.nodes.length;i<e;i++)n=this.nodes[i],t=t?t.union(n.bounds()):n.bounds();return this.bounds=t},getSpanningTree:function(t){var i,e,n,s,h,r,o,a,u,d,c,f,l=new k,g=new y;for(l.root=t.clone(),l.root.level=0,l.root.id=t.id,g.add(t,l.root),t.level=0,n=[],s=[],l._addNode(l.root),n.push(t),s.push(t),h=1;s.length>0;)for(r=s.pop(),o=0;o<r.links.length;o++)a=r.links[o],u=a.getComplement(r),E(n,u)||(u.level=r.level+1,h<u.level+1&&(h=u.level+1),E(s,u)||s.push(u),E(n,u)||n.push(u),g.containsKey(r)?i=g.get(r):(i=r.clone(),i.level=r.level,i.id=r.id,g.add(r,i)),g.containsKey(u)?e=g.get(u):(e=u.clone(),e.level=u.level,e.id=u.id,g.add(u,e)),d=new w(i,e),l.addLink(d));for(c=[],f=0;f<h;f++)c.push([]);return U.forEach(l.nodes,function(t){c[t.level].push(t)}),l.treeLevels=c,l.cacheRelationships(),l},takeRandomNode:function(i,e){if(U.isUndefined(i)&&(i=[]),U.isUndefined(e)&&(e=4),0===this.nodes.length)return null;if(1===this.nodes.length)return E(i,this.nodes[0])?null:this.nodes[0];var n=t.grep(this.nodes,function(t){return!E(i,t)&&t.degree()<=e});return U.isEmpty(n)?null:n[U.randomInteger(0,n.length)]},isEmpty:function(){return U.isEmpty(this.nodes)},isHealthy:function(){return U.all(this.links,function(t){return E(this.nodes,t.source)&&E(this.nodes,t.target)},this)},getParents:function(t){if(!this.hasNode(t))throw"The given node is not part of this graph.";return t.getParents()},getChildren:function(t){if(!this.hasNode(t))throw"The given node is not part of this graph.";return t.getChildren()},addLink:function(t,e,n){var s,h,r;if(U.isUndefined(t))throw"The source of the link is not defined.";if(U.isUndefined(e)){if(U.isDefined(t.type)&&"Link"===t.type)return this.addExistingLink(t),i;throw"The target of the link is not defined."}return s=this.getNode(t),U.isUndefined(s)&&(s=this.addNode(t)),h=this.getNode(e),U.isUndefined(h)&&(h=this.addNode(e)),r=new w(s,h),U.isDefined(n)&&(r.owner=n),this.links.push(r),r},removeAllLinks:function(){for(;this.links.length>0;){var t=this.links[0];this.removeLink(t)}},addExistingLink:function(t){var i,e;this.hasLink(t)||(this.links.push(t),this.hasNode(t.source.id)?(i=this.getNode(t.source.id),t.changeSource(i)):this.addNode(t.source),this.hasNode(t.target.id)?(e=this.getNode(t.target.id),t.changeTarget(e)):this.addNode(t.target))},hasLink:function(t){if(U.isString(t))return U.any(this.links,function(i){return i.id===t});if("Link"===t.type)return E(this.links,t);throw"The given object is neither an identifier nor a Link."},getNode:function(t){var i=t.id||t;if(this._nodeMap.containsKey(i))return this._nodeMap.get(i)},hasNode:function(t){var i=t.id||t;return this._nodeMap.containsKey(i)},_addNode:function(t){this.nodes.push(t),this._nodeMap.add(t.id,t)},_removeNode:function(t){U.remove(this.nodes,t),this._nodeMap.remove(t.id)},removeNode:function(t){var i,e,n,s,h=t;if(U.isString(t)&&(h=this.getNode(t)),!U.isDefined(h))throw"The identifier should be a Node or the Id (string) of a node.";for(i=h.links,h.links=[],e=0,n=i.length;e<n;e++)s=i[e],this.removeLink(s);this._removeNode(h)},areConnected:function(t,i){return U.any(this.links,function(e){return e.source==t&&e.target==i||e.source==i&&e.target==t})},removeLink:function(t){U.remove(this.links,t),U.remove(t.source.outgoing,t),U.remove(t.source.links,t),U.remove(t.target.incoming,t),U.remove(t.target.links,t)},addNode:function(t,i,e){var n=null;if(!U.isDefined(t))throw"No Node or identifier for a new Node is given.";if(U.isString(t)){if(this.hasNode(t))return this.getNode(t);n=new v(t)}else{if(this.hasNode(t))return this.getNode(t);n=t}return U.isDefined(i)&&n.bounds(i),U.isDefined(e)&&(n.owner=e),this._addNode(n),n},addNodeAndOutgoings:function(t){this.hasNode(t)||this._addNode(t);var i=t.outgoing;t.outgoing=[],U.forEach(i,function(t){this.addExistingLink(t)},this)},setItemIndices:function(){var t;for(t=0;t<this.nodes.length;++t)this.nodes[t].index=t;for(t=0;t<this.links.length;++t)this.links[t].index=t},clone:function(t){var i,e=new k,n=U.isDefined(t)&&t===!0;return n&&(e.nodeMap=new y,e.linkMap=new y),i=new y,U.forEach(this.nodes,function(t){var s=t.clone();i.set(t,s),e._addNode(s),n&&e.nodeMap.set(s,t)}),U.forEach(this.links,function(t){if(i.containsKey(t.source)&&i.containsKey(t.target)){var s=e.addLink(i.get(t.source),i.get(t.target));n&&e.linkMap.set(s,t)}}),e},linearize:function(t){return k.Utils.linearize(this,t)},depthFirstTraversal:function(t,i){var e,n;if(U.isUndefined(t))throw"You need to supply a starting node.";if(U.isUndefined(i))throw"You need to supply an action.";if(!this.hasNode(t))throw"The given start-node is not part of this graph";e=this.getNode(t),n=[],this._dftIterator(e,i,n)},_dftIterator:function(t,i,e){var n,s,h,r;for(i(t),e.push(t),n=t.getChildren(),s=0,h=n.length;s<h;s++)r=n[s],E(e,r)||this._dftIterator(r,i,e)},breadthFirstTraversal:function(t,i){var e,n,s,h,r,o,a,u;if(U.isUndefined(t))throw"You need to supply a starting node.";if(U.isUndefined(i))throw"You need to supply an action.";if(!this.hasNode(t))throw"The given start-node is not part of this graph";for(e=this.getNode(t),n=new m,s=[],n.enqueue(e);n.length>0;)for(h=n.dequeue(),i(h),s.push(h),r=h.getChildren(),o=0,a=r.length;o<a;o++)u=r[o],E(s,u)||E(n,u)||n.enqueue(u)},_stronglyConnectedComponents:function(t,i,e,n,s,h,r){var o,a,u,d,c;for(e.add(i,r),n.add(i,r),r++,h.push(i),o=i.getChildren(),u=0,d=o.length;u<d;u++)a=o[u],e.containsKey(a)?E(h,a)&&n.add(i,Math.min(n.get(i),e.get(a))):(this._stronglyConnectedComponents(t,a,e,n,s,h,r),n.add(i,Math.min(n.get(i),n.get(a))));if(n.get(i)===e.get(i)){c=[];do a=h.pop(),c.push(a);while(a!==i);(!t||c.length>1)&&s.push(c)}},findCycles:function(t){var i,e,n,s,h,r,o;for(U.isUndefined(t)&&(t=!0),i=new y,e=new y,n=[],s=[],h=0,r=this.nodes.length;h<r;h++)o=this.nodes[h],i.containsKey(o)||this._stronglyConnectedComponents(t,o,i,e,n,s,0);return n},isAcyclic:function(){return U.isEmpty(this.findCycles())},isSubGraph:function(t){var i=t.linearize(),e=this.linearize();return U.all(i,function(t){return E(e,t)})},makeAcyclic:function(){var t,i,e,n,s,h,r,o,a,u,d,c,f,l,g,p,m,x,v,w,k,b,_,N,L,T,M,C,E,S,R,D;if(this.isEmpty()||this.nodes.length<=1||this.links.length<=1)return[];if(2==this.nodes.length){if(t=[],this.links.length>1)for(i=this.links[0],e=i.source,n=0,s=this.links.length;n<s;n++)h=this.links[n],h.source!=e&&(r=h.reverse(),t.push(r));return t}for(o=this.clone(!0),a=this.nodes.length,u=new y,d=function(t){return 0===t.outgoing.length?2-a:0===t.incoming.length?a-2:t.outgoing.length-t.incoming.length},c=function(t,i){var e=d(t,a);i.containsKey(e)||i.set(e,[]),i.get(e).push(t)},U.forEach(o.nodes,function(t){c(t,u)}),f=[],l=[];o.nodes.length>0;){if(u.containsKey(2-a))for(x=u.get(2-a);x.length>0;){for(p=x.pop(),v=0;v<p.links.length;v++)w=p.links[v],g=w.getComplement(p),m=d(g,a),U.remove(u.get(m),g),g.removeLink(w),c(g,u);o._removeNode(p),l.unshift(p)}if(u.containsKey(a-2))for(k=u.get(a-2);k.length>0;){for(g=k.pop(),b=0;b<g.links.length;b++)_=g.links[b],p=_.getComplement(g),m=d(p,a),U.remove(u.get(m),p),p.removeLink(_),c(p,u);f.push(g),o._removeNode(g)}if(o.nodes.length>0)for(N=a-3;N>2-a;N--)if(u.containsKey(N)&&u.get(N).length>0){for(L=u.get(N),T=L.pop(),M=0;M<T.links.length;M++)C=T.links[M],E=C.getComplement(T),m=d(E,a),U.remove(u.get(m),E),E.removeLink(C),c(E,u);f.push(T),o._removeNode(T);break}}for(f=f.concat(l),S=new y,R=0;R<this.nodes.length;R++)S.set(o.nodeMap.get(f[R]),R);return D=[],U.forEach(this.links,function(t){S.get(t.source)>S.get(t.target)&&(t.reverse(),D.push(t))}),D}}),k.Predefined={EightGraph:function(){return k.Utils.parse(["1->2","2->3","3->4","4->1","3->5","5->6","6->7","7->3"])},Mindmap:function(){return k.Utils.parse(["0->1","0->2","0->3","0->4","0->5","1->6","1->7","7->8","2->9","9->10","9->11","3->12","12->13","13->14","4->15","4->16","15->17","15->18","18->19","18->20","14->21","14->22","5->23","23->24","23->25","6->26"])},ThreeGraph:function(){return k.Utils.parse(["1->2","2->3","3->1"])},BinaryTree:function(t){return U.isUndefined(t)&&(t=5),k.Utils.createBalancedTree(t,2)},Linear:function(t){return U.isUndefined(t)&&(t=10),k.Utils.createBalancedTree(t,1)},Tree:function(t,i){return k.Utils.createBalancedTree(t,i)},Forest:function(t,i,e){return k.Utils.createBalancedForest(t,i,e)},Workflow:function(){return k.Utils.parse(["0->1","1->2","2->3","1->4","4->3","3->5","5->6","6->3","6->7","5->4"])},Grid:function(t,i){var e,n,s,h,r,o=new _.Graph;if(t<=0&&i<=0)return o;for(e=0;e<t+1;e++)for(n=null,s=0;s<i+1;s++)h=new v(""+e+"."+s),o.addNode(h),n&&o.addLink(n,h),e>0&&(r=o.getNode(""+(e-1)+"."+s),o.addLink(r,h)),n=h;return o}},k.Utils={parse:function(t){var i,e,n,s,h,r=new _.Graph,o=t.slice();for(e=0,n=o.length;e<n;e++){if(s=o[e],U.isString(s)){if(s.indexOf("->")<0)throw"The link should be specified as 'a->b'.";if(h=s.split("->"),2!=h.length)throw"The link should be specified as 'a->b'.";i=new w(h[0],h[1]),r.addLink(i)}if(U.isObject(s)){if(!i)throw"Specification found before Link definition.";b.deepExtend(i,s)}}return r},linearize:function(t,i){var e,n,s,h;if(U.isUndefined(t))throw"Expected an instance of a Graph object in slot one.";for(U.isUndefined(i)&&(i=!1),e=[],n=0,s=t.links.length;n<s;n++)h=t.links[n],e.push(h.source.id+"->"+h.target.id),i&&e.push({id:h.id});return e},_addShape:function(t,i,e,n){return U.isUndefined(i)&&(i=new _.Point(0,0)),U.isUndefined(e)&&(e=h()),n=b.deepExtend({width:20,height:20,id:e,radius:10,fill:"#778899",data:"circle",undoable:!1,x:i.x,y:i.y},n),t.addShape(n)},_addConnection:function(t,i,e,n){return t.connect(i,e,n)},createDiagramFromGraph:function(t,i,e,n){var s,h,r,a,u,d,c,f,l,g,p,y,m,x,v,w;if(U.isUndefined(t))throw"The diagram surface is undefined.";if(U.isUndefined(i))throw"No graph specification defined.";for(U.isUndefined(e)&&(e=!0),U.isUndefined(n)&&(n=!1),s=t.element.clientWidth||200,h=t.element.clientHeight||200,r=[],d=0,c=i.nodes.length;d<c;d++)a=i.nodes[d],f=a.position,U.isUndefined(f)&&(f=U.isDefined(a.x)&&U.isDefined(a.y)?new M(a.x,a.y):new M(U.randomInteger(10,s-20),U.randomInteger(10,h-20))),l={},"0"===a.id||n&&b.deepExtend(l,{width:150*Math.random()+20,height:80*Math.random()+50,data:"rectangle",fill:{color:"#778899"}}),u=this._addShape(t,f,a.id,l),g=u.bounds(),U.isDefined(g)&&(a.x=g.x,a.y=g.y,a.width=g.width,a.height=g.height),r[a.id]=u;for(p=0;p<i.links.length;p++)y=i.links[p],m=r[y.source.id],U.isUndefined(m)||(x=r[y.target.id],U.isUndefined(x)||this._addConnection(t,m,x,{id:y.id}));if(e)for(v=new t.SpringLayout(t),v.layoutGraph(i,{limitToView:!1}),w=0;w<i.nodes.length;w++)a=i.nodes[w],u=r[a.id],u.bounds(new o(a.x,a.y,a.width,a.height))},createBalancedTree:function(t,i){var e,n,s,h,r,o,a,u,d,c;if(U.isUndefined(t)&&(t=3),U.isUndefined(i)&&(i=3),e=new _.Graph,n=-1,s=[],t<=0||i<=0)return e;for(r=new v(""+ ++n),e.addNode(r),e.root=r,s.push(r),o=0;o<t;o++){for(h=[],a=0;a<s.length;a++)for(u=s[a],d=0;d<i;d++)c=new v(""+ ++n),e.addLink(u,c),h.push(c);s=h}return e},createBalancedForest:function(t,i,e){var n,s,h,r,o,a,u,d,c,f,l;if(U.isUndefined(t)&&(t=3),U.isUndefined(i)&&(i=3),U.isUndefined(e)&&(e=5),n=new _.Graph,s=-1,h=[],t<=0||i<=0||e<=0)return n;for(o=0;o<e;o++)for(a=new v(""+ ++s),n.addNode(a),h=[a],u=0;u<t;u++){for(r=[],d=0;d<h.length;d++)for(c=h[d],f=0;f<i;f++)l=new v(""+ ++s),n.addLink(c,l),r.push(l);h=r}return n},createRandomConnectedGraph:function(t,i,e){var n,s,h,r,o,a,u,d,c,f;if(U.isUndefined(t)&&(t=40),U.isUndefined(i)&&(i=4),U.isUndefined(e)&&(e=!1),n=new _.Graph,s=-1,t<=0)return n;if(h=new v(""+ ++s),n.addNode(h),1===t)return n;if(t>1){for(r=1;r<t&&(o=n.takeRandomNode([],i),o);r++)a=n.addNode(""+r),n.addLink(o,a);if(!e&&t>1)for(u=U.randomInteger(1,t),d=0;d<u;d++)c=n.takeRandomNode([],i),f=n.takeRandomNode([],i),c&&f&&!n.areConnected(c,f)&&n.addLink(c,f);return n}},randomDiagram:function(t,i,e,n,s){var h=b.dataviz.diagram.Graph.Utils.createRandomConnectedGraph(i,e,n);
k.Utils.createDiagramFromGraph(t,h,!1,s)}},b.deepExtend(_,{init:function(t){b.init(t,_.ui)},Point:M,Intersect:u,Geometry:g,Rect:o,Size:a,RectAlign:d,Matrix:f,MatrixVector:l,normalVariable:s,randomId:h,Dictionary:y,HashTable:p,Queue:m,Set:x,Node:v,Link:w,Graph:k,PathDefiner:r})}(window.kendo.jQuery)},e(3))},879:function(t,i){t.exports=require("./utils")}});