/** * Kendo UI v2018.1.117 (http://www.telerik.com/kendo-ui) * Copyright 2018 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(t,define){define("util/text-metrics.min",["kendo.core.min"],t)}(function(){!function(t){function e(t){return(t+"").replace(a,h)}function i(t){var e,i=[];for(e in t)i.push(e+t[e]);return i.sort().join("")}function n(t){var e,i=2166136261;for(e=0;e>>0}function o(){return{width:0,height:0,baseline:0}}function s(t,e,i){return l.current.measure(t,e,i)}var r,a,h,c,d,l;window.kendo.util=window.kendo.util||{},r=kendo.Class.extend({init:function(t){this._size=t,this._length=0,this._map={}},put:function(t,e){var i=this._map,n={key:t,value:e};i[t]=n,this._head?(this._tail.newer=n,n.older=this._tail,this._tail=n):this._head=this._tail=n,this._length>=this._size?(i[this._head.key]=null,this._head=this._head.newer,this._head.older=null):this._length++},get:function(t){var e=this._map[t];if(e)return e===this._head&&e!==this._tail&&(this._head=e.newer,this._head.older=null),e!==this._tail&&(e.older&&(e.older.newer=e.newer,e.newer.older=e.older),e.older=this._tail,e.newer=null,this._tail.newer=e,this._tail=e),e.value}}),a=/\r?\n|\r|\t/g,h=" ",c={baselineMarkerSize:1},"undefined"!=typeof document&&(d=document.createElement("div"),d.style.cssText="position: absolute !important; top: -4000px !important; width: auto !important; height: auto !important;padding: 0 !important; margin: 0 !important; border: 0 !important;line-height: normal !important; visibility: hidden !important; white-space: pre!important;"),l=kendo.Class.extend({init:function(e){this._cache=new r(1e3),this.options=t.extend({},c,e)},measure:function(t,s,r){var a,h,c,l,u,f,p,g,m;if(void 0===r&&(r={}),!t)return o();if(a=i(s),h=n(t+a),c=this._cache.get(h))return c;l=o(),u=r.box||d,f=this._baselineMarker().cloneNode(!1);for(p in s)g=s[p],void 0!==g&&(u.style[p]=g);return m=r.normalizeText!==!1?e(t):t+"",u.textContent=m,u.appendChild(f),document.body.appendChild(u),m.length&&(l.width=u.offsetWidth-this.options.baselineMarkerSize,l.height=u.offsetHeight,l.baseline=f.offsetTop+this.options.baselineMarkerSize),l.width>0&&l.height>0&&this._cache.put(h,l),u.parentNode.removeChild(u),l},_baselineMarker:function(){var t=document.createElement("div");return t.style.cssText="display: inline-block; vertical-align: baseline;width: "+this.options.baselineMarkerSize+"px; height: "+this.options.baselineMarkerSize+"px;overflow: hidden;",t}}),l.current=new l,kendo.deepExtend(kendo.util,{LRUCache:r,TextMetrics:l,measureText:s,objectKey:i,hashKey:n,normalizeText:e})}(window.kendo.jQuery)},"function"==typeof define&&define.amd?define:function(t,e,i){(i||e)()}),function(t,define){define("dataviz/diagram/utils.min",["kendo.core.min"],t)}(function(){!function(t,e){function i(t,i,n){function o(t){for(var e=1;t*e%1;)e*=10;return e}var s,r,a,h;if(e===t||e===i)return[];if(n&&l.sign(i-t)!=l.sign(n))throw"The sign of the increment should allow to reach the stop-value.";if(n=n||1,t=t||0,i=i||t,(i-t)/n===1/0)throw"Infinite range defined.";if(s=[],r=-1,h=o(Math.abs(n)),t*=h,i*=h,n*=h,t>i&&n>0&&(n=-n),n<0)for(;(a=t+n*++r)>=i;)s.push(a/h);else for(;(a=t+n*++r)<=i;)s.push(a/h);return s}function n(t,e){if(t==e)return 0;var i=e.x-t.x,n=t.y-e.y,o=Math.atan(i/n);return n>=0?i<0?o+2*Math.PI:o:o+Math.PI}var o,s,r=window.kendo,a=r.dataviz.diagram={},h=r.deepExtend,c=t.isArray,d=1e-6,l={};h(l,{isNearZero:function(t){return Math.abs(t)2;for(o=0;o=Math.abs(this.tick-this.target)?this.tick=this.target:this.tick+=t;try{this.propagate()}finally{this.onStep.call(this),this.target==this.tick&&this.stop()}}}),r.deepExtend(a,{init:function(t){r.init(t,a.ui)},Utils:l,Range:i,Ticker:s})}(window.kendo.jQuery)},"function"==typeof define&&define.amd?define:function(t,e,i){(i||e)()}),function(t,define){define("dataviz/diagram/math.min",["dataviz/diagram/utils.min","kendo.dataviz.core.min"],t)}(function(){!function(t,e){function i(t){return Math.abs(t)1||c<0||c>1)))return new D(t.x+h*(e.x-t.x),t.y+h*(e.y-t.y))}function o(t,e){var i,n,o;do i=2*Math.random()-1,n=2*Math.random()-1,o=i*i+n*n;while(!o||o>1);return t+e*i*Math.sqrt(-2*Math.log(o)/o)}function s(t){var e,i,n;for(M.isUndefined(t)&&(t=10),e="",i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=t;n>0;--n)e+=i.charAt(Math.round(Math.random()*(i.length-1)));return e}var r,a,h,c,d,l,u,f,p,g,m,_,v,y,w,x,b=window.kendo,C=b.dataviz.diagram,S=b.Class,k=b.deepExtend,T=b.dataviz,M=C.Utils,D=T.Point2D,I=b.isFunction,P=M.contains,L=t.map,E=3,z=1e-6;k(D.fn,{plus:function(t){return new D(this.x+t.x,this.y+t.y)},minus:function(t){return new D(this.x-t.x,this.y-t.y)},offset:function(t){return new D(this.x-t,this.y-t)},times:function(t){return new D(this.x*t,this.y*t)},normalize:function(){return 0===this.length()?new D: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,e){return new D(e.x-t.x,e.y-t.y).times(.5).plus(t)},toPolar:function(t){var e,i,n,o=1;if(t&&(o=180/Math.PI),e=Math.atan2(Math.abs(this.y),Math.abs(this.x)),i=Math.PI/2,n=this.length(),0===this.x){if(0===this.y)return new l(0,0);if(this.y>0)return new l(n,o*i);if(this.y<0)return new l(n,3*o*i)}else if(this.x>0){if(0===this.y)return new l(n,0);if(this.y>0)return new l(n,o*e);if(this.y<0)return new l(n,o*(4*i-e))}else{if(0===this.y)return new l(n,2*i);if(this.y>0)return new l(n,o*(2*i-e));if(this.y<0)return new l(n,o*(2*i+e))}},isOnLine:function(t,e){var i,n,o,s,r;return t.x>e.x&&(i=e,e=t,t=i),n=new a(t.x,t.y).inflate(E,E),o=new a(e.x,e.y).inflate(E,E),!!n.union(o).contains(this)&&(t.x===e.x||t.y===e.y||(t.ys&&this.x=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},inflate:function(t,i){return i===e&&(i=t),this.x-=t,this.y-=i,this.width+=2*t+1,this.height+=2*i+1,this},offset:function(t,e){var i=t,n=e;return t instanceof D&&(i=t.x,n=t.y),this.x+=i,this.y+=n,this},union:function(t){var e=Math.min(this.x,t.x),i=Math.min(this.y,t.y),n=Math.max(this.x+this.width,t.x+t.width),o=Math.max(this.y+this.height,t.y+t.height);return new a(e,i,n-e,o-i)},center:function(){return new D(this.x+this.width/2,this.y+this.height/2)},top:function(){return new D(this.x+this.width/2,this.y)},right:function(){return new D(this.x+this.width,this.y+this.height/2)},bottom:function(){return new D(this.x+this.width/2,this.y+this.height)},left:function(){return new D(this.x,this.y+this.height/2)},topLeft:function(){return new D(this.x,this.y)},topRight:function(){return new D(this.x+this.width,this.y)},bottomLeft:function(){return new D(this.x,this.y+this.height)},bottomRight:function(){return new D(this.x+this.width,this.y+this.height)},clone:function(){return new a(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 e=this.clone(),i=this.rotatedPoints(t),n=i[0],o=i[1],s=i[2],r=i[3];return e.x=Math.min(s.x,n.x,o.x,r.x),e.y=Math.min(s.y,n.y,o.y,r.y),e.width=Math.max(s.x,n.x,o.x,r.x)-e.x,e.height=Math.max(s.y,n.y,o.y,r.y)-e.y,e},rotatedPoints:function(t){var e=this,i=e.center(),n=e.bottomRight().rotate(i,360-t),o=e.topLeft().rotate(i,360-t),s=e.topRight().rotate(i,360-t),r=e.bottomLeft().rotate(i,360-t);return[o,s,n,r]},toString:function(t){return t=t||" ",this.x+t+this.y+t+this.width+t+this.height},scale:function(t,e,i,n,o){var s,r,a,h=this.topLeft(),c=this.center();h.rotate(c,360-o).rotate(n,o),s=i.minus(h),r=new D(s.x*t,s.y*e),a=s.minus(r),h=h.plus(a),h.rotate(n,360-o).rotate(c,o),this.x=h.x,this.y=h.y,this.width*=t,this.height*=e},zoom:function(t){return this.x*=t,this.y*=t,this.width*=t,this.height*=t,this},overlaps:function(t){var e=this.bottomRight(),i=t.bottomRight(),n=!(e.x0&&(e=t.split(","),6===e.length))return u.fromList(L(e,function(t){return parseFloat(t)}));if(t.indexOf(" ")>0&&(e=t.split(" "),6===e.length))return u.fromList(L(e,function(t){return parseFloat(t)}))}return e}}),f=S.extend({init:function(t,e,i,n,o,s){this.a=t||0,this.b=e||0,this.c=i||0,this.d=n||0,this.e=o||0,this.f=s||0},fromMatrix:function(t){var e=new f;return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.e=t.e,e.f=t.f,e}}),p={_distanceToLineSquared:function(t,e,i){function n(t,e){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)}if(e===i)return n(t,e);var o=i.x-e.x,s=i.y-e.y,r=(t.x-e.x)*o+(t.y-e.y)*s;return r<0?n(e,t):(r=(i.x-t.x)*o+(i.y-t.y)*s,r<0?n(i,t):(r=(i.x-t.x)*s-(i.y-t.y)*o,r*r/(o*o+s*s)))},distanceToLine:function(t,e,i){return Math.sqrt(this._distanceToLineSquared(t,e,i))},distanceToPolyline:function(t,e){var i,n,o,s,r=Number.MAX_VALUE;if(M.isUndefined(e)||0===e.length)return Number.MAX_VALUE;for(i=0;i"+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,e){return this.source===t&&this.target===e||this.source===e&&this.target===t},getNodes:function(){return[this.source,this.target]},incidentWith:function(t){return this.source===t||this.target===t},adjacentTo:function(t){return P(this.source.links,t)||P(this.target.links,t)},changeSource:function(t){M.remove(this.source.links,this),M.remove(this.source.outgoing,this),t.links.push(this),t.outgoing.push(this),this.source=t},changeTarget:function(t){M.remove(this.target.links,this),M.remove(this.target.incoming,this),t.links.push(this),t.incoming.push(this),this.target=t},changesNodes:function(t,e){this.source===t?this.changeSource(e):this.target===t&&this.changeTarget(e)},reverse:function(){var t=this.source,e=this.target;return this.source=e,M.remove(t.outgoing,this),this.source.outgoing.push(this),this.target=t,M.remove(e.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}}),x=b.Class.extend({init:function(t){this.links=[],this.nodes=[],this._nodeMap=new m,this.diagram=null,this._root=null,M.isDefined(t)?M.isString(t)?this.id=t:(this.diagram=t,this.id=t.id):this.id=s(),this.bounds=new a,this._hasCachedRelationships=!1,this.type="Graph"},cacheRelationships:function(t){var e,i,n;if(M.isUndefined(t)&&(t=!1),!this._hasCachedRelationships||t){for(e=0,i=this.nodes.length;e0;)for(r=o.pop(),a=0;a0;){var t=this.links[0];this.removeLink(t)}},addExistingLink:function(t){var e,i;this.hasLink(t)||(this.links.push(t),this.hasNode(t.source.id)?(e=this.getNode(t.source.id),t.changeSource(e)):this.addNode(t.source),this.hasNode(t.target.id)?(i=this.getNode(t.target.id),t.changeTarget(i)):this.addNode(t.target))},hasLink:function(t){if(M.isString(t))return M.any(this.links,function(e){return e.id===t});if("Link"===t.type)return P(this.links,t);throw"The given object is neither an identifier nor a Link."},getNode:function(t){var e=t.id||t;if(this._nodeMap.containsKey(e))return this._nodeMap.get(e)},hasNode:function(t){var e=t.id||t;return this._nodeMap.containsKey(e)},_addNode:function(t){this.nodes.push(t),this._nodeMap.add(t.id,t)},_removeNode:function(t){M.remove(this.nodes,t),this._nodeMap.remove(t.id)},removeNode:function(t){var e,i,n,o,s=t;if(M.isString(t)&&(s=this.getNode(t)),!M.isDefined(s))throw"The identifier should be a Node or the Id (string) of a node.";for(e=s.links,s.links=[],i=0,n=e.length;i0;)for(s=n.dequeue(),e(s),o.push(s),r=s.getChildren(),a=0,h=r.length;a1)&&o.push(l)}},findCycles:function(t){var e,i,n,o,s,r,a;for(M.isUndefined(t)&&(t=!0),e=new m,i=new m,n=[],o=[],s=0,r=this.nodes.length;s1)for(e=this.links[0],i=e.source,n=0,o=this.links.length;n0;){if(c.containsKey(2-h))for(v=c.get(2-h);v.length>0;){for(g=v.pop(),y=0;y0;){for(p=x.pop(),b=0;b0)for(S=h-3;S>2-h;S--)if(c.containsKey(S)&&c.get(S).length>0){for(k=c.get(S),T=k.pop(),D=0;DL.get(t.target)&&(t.reverse(),z.push(t))}),z}}),x.Predefined={EightGraph:function(){return x.Utils.parse(["1->2","2->3","3->4","4->1","3->5","5->6","6->7","7->3"])},Mindmap:function(){return x.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 x.Utils.parse(["1->2","2->3","3->1"])},BinaryTree:function(t){return M.isUndefined(t)&&(t=5),x.Utils.createBalancedTree(t,2)},Linear:function(t){return M.isUndefined(t)&&(t=10),x.Utils.createBalancedTree(t,1)},Tree:function(t,e){return x.Utils.createBalancedTree(t,e)},Forest:function(t,e,i){return x.Utils.createBalancedForest(t,e,i)},Workflow:function(){return x.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,e){var i,n,o,s,r,a=new C.Graph;if(t<=0&&e<=0)return a;for(i=0;i0&&(r=a.getNode(""+(i-1)+"."+o),a.addLink(r,s)),n=s;return a}},x.Utils={parse:function(t){var e,i,n,o,s,r=new C.Graph,a=t.slice();for(i=0,n=a.length;i")<0)throw"The link should be specified as 'a->b'.";if(s=o.split("->"),2!=s.length)throw"The link should be specified as 'a->b'.";e=new w(s[0],s[1]),r.addLink(e)}if(M.isObject(o)){if(!e)throw"Specification found before Link definition.";b.deepExtend(e,o)}}return r},linearize:function(t,e){var i,n,o,s;if(M.isUndefined(t))throw"Expected an instance of a Graph object in slot one.";for(M.isUndefined(e)&&(e=!1),i=[],n=0,o=t.links.length;n"+s.target.id),e&&i.push({id:s.id});return i},_addShape:function(t,e,i,n){return M.isUndefined(e)&&(e=new C.Point(0,0)),M.isUndefined(i)&&(i=s()),n=b.deepExtend({width:20,height:20,id:i,radius:10,fill:"#778899",data:"circle",undoable:!1,x:e.x,y:e.y},n),t.addShape(n)},_addConnection:function(t,e,i,n){return t.connect(e,i,n)},createDiagramFromGraph:function(t,e,i,n){var o,s,r,h,c,d,l,u,f,p,g,m,_,v,y,w;if(M.isUndefined(t))throw"The diagram surface is undefined.";if(M.isUndefined(e))throw"No graph specification defined.";for(M.isUndefined(i)&&(i=!0),M.isUndefined(n)&&(n=!1),o=t.element.clientWidth||200,s=t.element.clientHeight||200,r=[],d=0,l=e.nodes.length;d1){for(r=1;r1)for(c=M.randomInteger(1,t),d=0;d0&&(e={color:t.color,width:t.width,opacity:t.opacity,dashType:t.dashType}),this.drawingElement.options.set("stroke",e)},_fill:function(t){var e,i,n,o=this.options;z(o,{fill:t||{}}),e=o.fill,e.gradient?(i=e.gradient,n="radial"===i.type?F.RadialGradient:F.LinearGradient,this.drawingElement.fill(new n(i))):this.drawingElement.fill(e.color,e.opacity)}}),m=g.extend({init:function(t){t=this._textColor(t),g.fn.init.call(this,t),this._font(),this._initText(),this._initSize()},options:{fontSize:15,fontFamily:"sans-serif",stroke:{width:0},fill:{color:"black"},autoSize:!0},_initText:function(){var t=this.options;this.drawingElement=new F.Text(G(t.text)?t.text:"",new H.Point,{font:t.font}),this._fill(),this._stroke()},_textColor:function(t){return t&&t.color&&(t=z({},t,{fill:{color:t.color}})),t},_font:function(){var t,e=this.options;e.fontFamily&&G(e.fontSize)?(t=[],e.fontStyle&&t.push(e.fontStyle),e.fontWeight&&t.push(e.fontWeight),t.push(e.fontSize+(A(e.fontSize)?"px":"")),t.push(e.fontFamily),e.font=t.join(" ")):delete e.font},content:function(t){return this.drawingElement.content(t)},redraw:function(t){var e,i;t&&(e=!1,i=this.options,t=this._textColor(t),g.fn.redraw.call(this,t),(t.fontFamily||G(t.fontSize)||t.fontStyle||t.fontWeight)&&(z(i,{fontFamily:t.fontFamily,fontSize:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight}),this._font(),this.drawingElement.options.set("font",i.font),e=!0),t.text&&(this.content(t.text),e=!0),!this._updateSize(t)&&e&&this._initSize())}}),z(m.fn,f),_=g.extend({init:function(t){g.fn.init.call(this,t),this._initPath(),this._setPosition()},_setPosition:function(){var t=this.options,e=t.x,i=t.y;(G(e)||G(i))&&this.position(e||0,i||0)},redraw:function(t){t&&(g.fn.redraw.call(this,t),this._diffNumericOptions(t,[Q,J])&&this._drawPath(),this._diffNumericOptions(t,[Z,$])&&this._setPosition())},_initPath:function(){var t=this.options;this.drawingElement=new F.Path({stroke:t.stroke,closed:!0}),this._fill(),this._drawPath()},_drawPath:function(){var t=this.drawingElement,e=n(this.options),i=e.width,o=e.height;t.segments.elements([a(0,0),a(i,0),a(i,o),a(0,o)])}}),v=g.extend({init:function(t){g.fn.init.call(this,t);var e=this.options.anchor;this.anchor=new H.Point(e.x,e.y),this.createElement()},options:{stroke:{color:K,width:0},fill:{color:"black"}},_transformToPath:function(t,e){var i=e.transform();return t&&i&&(t=t.transformCopy(i)),t},redraw:function(t){t&&(t.position&&(this.options.position=t.position),g.fn.redraw.call(this,t))}}),y=v.extend({options:{radius:4,anchor:{x:0,y:0}},createElement:function(){var t=this.options;this.drawingElement=new F.Circle(new H.Circle(this.anchor,t.radius),{fill:t.fill,stroke:t.stroke})},positionMarker:function(t){var e,i,n=this.options,o=n.position,s=t.segments;e=o==Y?s[0]:s[s.length-1],e&&(i=this._transformToPath(e.anchor(),t),this.drawingElement.transform(H.transform().translate(i.x,i.y)))}}),w=v.extend({options:{path:"M 0 0 L 10 5 L 0 10 L 3 5 z",anchor:{x:10,y:5}},createElement:function(){var t=this.options;this.drawingElement=F.Path.parse(t.path,{fill:t.fill,stroke:t.stroke})},positionMarker:function(t){var e,i,n=this._linePoints(t),o=n.start,s=n.end,a=H.transform();o&&a.rotate(r(o,s),s),s&&(e=this.anchor,i=s.clone().translate(-e.x,-e.y),a.translate(i.x,i.y)),this.drawingElement.transform(a)},_linePoints:function(t){var e,i,n,o,s,r=this.options,a=t.segments;if(r.position==Y?(n=a[0],n&&(i=n.anchor(),e=n.controlOut(),o=a[1],!e&&o&&(e=o.anchor()))):(n=a[a.length-1],n&&(i=n.anchor(),e=n.controlIn(),s=a[a.length-2],!e&&s&&(e=s.anchor()))),i)return{start:this._transformToPath(e,t),end:this._transformToPath(i,t)}}}),x={_getPath:function(t){var e=this.drawingElement;if(e instanceof F.MultiPath&&(e=t==Y?e.paths[0]:e.paths[e.paths.length-1]),e&&e.segments.length)return e},_normalizeMarkerOptions:function(t){var e=t.startCap,i=t.endCap;U(e)&&(t.startCap={type:e}),U(i)&&(t.endCap={type:i})},_removeMarker:function(t){var e=this._markers[t];e&&(this.drawingContainer().remove(e.drawingElement),delete this._markers[t])},_createMarkers:function(){var t=this.options;this._normalizeMarkerOptions(t),this._markers={},this._markers[Y]=this._createMarker(t.startCap,Y),this._markers[j]=this._createMarker(t.endCap,j)},_createMarker:function(t,i){var n,o,s=(t||{}).type,r=this._getPath(i);return r?(s==W.filledCircle?n=y:s==W.arrowStart||s==W.arrowEnd?n=w:this._removeMarker(i),n?(o=new n(z({},t,{position:i})),o.positionMarker(r),this.drawingContainer().append(o.drawingElement),o):e):(this._removeMarker(i),e)},_positionMarker:function(t){var e,i=this._markers[t];i&&(e=this._getPath(t),e?i.positionMarker(e):this._removeMarker(t))},_capMap:{start:"startCap",end:"endCap"},_redrawMarker:function(t,e,i){var n,o,s,r,a;return this._normalizeMarkerOptions(i),n=this.options,o=this._capMap[e],s=(n[o]||{}).type,r=i[o],a=!1,r?(n[o]=z({},n[o],r),r.type&&s!=r.type?(this._removeMarker(e),this._markers[e]=this._createMarker(n[o],e),a=!0):this._markers[e]&&this._markers[e].redraw(r)):t&&!this._markers[e]&&n[o]&&(this._markers[e]=this._createMarker(n[o],e),a=!0),a},_redrawMarkers:function(t,e){!this._redrawMarker(t,Y,e)&&t&&this._positionMarker(Y),!this._redrawMarker(t,j,e)&&t&&this._positionMarker(j)}},b=g.extend({init:function(t){g.fn.init.call(this,t),this.container=new F.Group,this._createElements(),this._initSize()},options:{autoSize:!0},drawingContainer:function(){return this.container},data:function(t){var i=this.options;return t?(i.data!=t&&(i.data=t,this._setData(t),this._initSize(),this._redrawMarkers(!0,{})),e):i.data},redraw:function(t){var e,i;t&&(g.fn.redraw.call(this,t),e=this.options,i=t.data,G(i)&&e.data!=i?(e.data=i,this._setData(i),this._updateSize(t)||this._initSize(),this._redrawMarkers(!0,t)):(this._updateSize(t),this._redrawMarkers(!1,t)))},_createElements:function(){var t=this.options;this.drawingElement=F.Path.parse(t.data||"",{stroke:t.stroke}),this._fill(),this.container.append(this.drawingElement),this._createMarkers()},_setData:function(t){var e=this.drawingElement,i=F.Path.parse(t||""),n=i.paths.slice(0);i.paths.elements([]),e.paths.elements(n)}}),z(b.fn,f),z(b.fn,x),C=g.extend({init:function(t){g.fn.init.call(this,t),this.container=new F.Group,this._initPath(),this._createMarkers()},drawingContainer:function(){return this.container},redraw:function(t){var e,i;t&&(t=t||{},e=t.from,i=t.to,e&&(this.options.from=e),i&&(this.options.to=i),e||i?(this._drawPath(),this._redrawMarkers(!0,t)):this._redrawMarkers(!1,t),g.fn.redraw.call(this,t))},_initPath:function(){var t=this.options,e=this.drawingElement=new F.Path({stroke:t.stroke});this._fill(),this._drawPath(),this.container.append(e)},_drawPath:function(){var t=this.options,e=this.drawingElement,i=t.from||new B,n=t.to||new B;e.segments.elements([a(i.x,i.y),a(n.x,n.y)])}}),z(C.fn,x),S=g.extend({init:function(t){g.fn.init.call(this,t),this.container=new F.Group,this._initPath(),this._createMarkers()},drawingContainer:function(){return this.container},points:function(t){var i=this.options;return t?(i.points=t,this._updatePath(),e):i.points},redraw:function(t){if(t){var e=t.points;g.fn.redraw.call(this,t),e&&this._pointsDiffer(e)?(this.points(e),this._redrawMarkers(!0,t)):this._redrawMarkers(!1,t)}},_initPath:function(){var t=this.options;this.drawingElement=new F.Path({stroke:t.stroke}),this._fill(),this.container.append(this.drawingElement),t.points&&this._updatePath()},_pointsDiffer:function(t){var e,i=this.options.points,n=i.length!==t.length;if(!n)for(e=0;e=0)return this.drawingElement.removeAt(e),this.children.splice(e,1),!0},clear:function(){this.drawingElement.clear(),this.children=[],this._childrenChange=!0},toFront:function(t){var e,i;for(i=0;i=0&&(h.splice(n,1),c.splice(n,1),o=d?e:e[i],h.splice(o,0,s),c.splice(o,0,r));a.clear(),a.append.apply(a,h)},redraw:function(t){t&&(this._childrenChange?(this._childrenChange=!1,this._updateSize(t)||this._initSize()):this._updateSize(t),p.fn.redraw.call(this,t))},_boundingBox:function(){var t,e,i,n,o=this.children;for(n=0;n0&&this._restart(this.composite,t),this.composite=e},addCompositeItem:function(t){this.composite?this.composite.add(t):this.add(t)},add:function(t,e){this._restart(t,e)},pop:function(){this.index>0&&(this.stack.pop(),this.index--)},count:function(){return this.stack.length},undo:function(){this.index>0&&(this.index--,this.stack[this.index].undo(),this.trigger("undone"))},redo:function(){this.stack.length>0&&this.indexthis.capacity&&(this.stack.splice(0,this.stack.length-this.capacity),this.index=this.capacity)},clear:function(){this.stack=[],this.index=0}}),b=F.extend({init:function(t){this.toolService=t},start:function(){},move:function(){},end:function(){},tryActivate:function(){return!1},getCursor:function(){return ot.arrow}}),C=b.extend({init:function(e){var i,n,o,s,r=this,a=U.support.mobileOS?Mt:Tt;b.fn.init.call(r,e),i=r.toolService.diagram,n=i.canvas,o=i.scroller=r.scroller=t(i.scrollable).kendoMobileScroller({friction:a,velocityMultiplier:Dt,mousewheelScrolling:!1,zoom:!1,scroll:nt(r._move,r)}).data("kendoMobileScroller"),n.translate&&(r.movableCanvas=new Z(n.element)),s=function(t,e,i){t.makeVirtual(),t.virtualSize(e||St,i||kt)},s(o.dimensions.x),s(o.dimensions.y),o.disable()},tryActivate:function(t,e){var i=this.toolService,n=i.diagram.options.pannable,o=e.ctrlKey;return et(n.key)&&(o=n.key&&"none"!=n.key?e[n.key+"Key"]:r(e)&&!et(i.hoveredItem)),n!==!1&&o&&!et(i.hoveredAdorner)&&!et(i._hoveredConnector)},start:function(){this.scroller.enable()},move:function(){},_move:function(t){var e=this,i=e.toolService.diagram,n=i.canvas,o=new Y(t.scrollLeft,t.scrollTop);n.translate?(i._storePan(o.times(-1)),e.movableCanvas.moveTo(o),n.translate(o.x,o.y)):o=o.plus(i._pan.times(-1)),i.trigger(Pt,{pan:o})},end:function(){this.scroller.disable()},getCursor:function(){return ot.move}}),S=F.extend({init:function(t){this.toolService=t},tryActivate:function(){return!0},start:function(t,e){var i=this.toolService,n=i.diagram,o=i.hoveredItem;o&&(i.selectSingle(o,e),o.adorner&&(this.adorner=o.adorner,this.handle=this.adorner._hitTest(t))),this.handle||(this.handle=n._resizingAdorner._hitTest(t),this.handle&&(this.adorner=n._resizingAdorner)),this.adorner&&(this.adorner.isDragHandle(this.handle)&&n.trigger(ft,{shapes:this.adorner.shapes,connections:[]})?(i.startPoint=t,i.end(t)):this.adorner.start(t))},move:function(t){this.adorner&&(this.adorner.move(this.handle,t),this.adorner.isDragHandle(this.handle)&&this.toolService.diagram.trigger(pt,{shapes:this.adorner.shapes,connections:[]}))},end:function(){var t,i=this.toolService.diagram,n=this.adorner;n&&(n.isDragHandle(this.handle)&&i.trigger(gt,{shapes:n.shapes,connections:[]})?n.cancel():(t=n.stop(),t&&i.undoRedoService.add(t,!1))),this.adorner=e,this.handle=e},getCursor:function(t){return this.toolService.hoveredItem?this.toolService.hoveredItem._getCursor(t):ot.arrow}}),k=F.extend({init:function(t){this.toolService=t},tryActivate:function(t,e){var i=this.toolService,n=i.diagram.options.selectable,o=n&&n.multiple!==!1;return o&&(o=n.key&&"none"!=n.key?e[n.key+"Key"]:r(e)),o&&!et(i.hoveredItem)&&!et(i.hoveredAdorner)},start:function(t){var e=this.toolService.diagram;e.deselect(),e.selector.start(t)},move:function(t){var e=this.toolService.diagram;e.selector.move(t)},end:function(t,e){var i=this.toolService.diagram,n=this.toolService.hoveredItem,o=i.selector.bounds();n&&n.isSelected||e.ctrlKey||i.deselect(),o.isEmpty()||i.selectArea(o),i.selector.end()},getCursor:function(){return ot.arrow}}),T=F.extend({init:function(t){this.toolService=t,this.type="ConnectionTool"},tryActivate:function(){return this.toolService._hoveredConnector},start:function(t,e){var i=this.toolService,n=i.diagram,s=i._hoveredConnector,r=n._createConnection({},s._c,t);o(r)&&!n.trigger(ft,{shapes:[],connections:[r],connectionHandle:zt})&&n._addConnection(r)?(i._connectionManipulation(r,s._c.shape,!0),i._removeHover(),i.selectSingle(i.activeConnection,e),"touchmove"==e.type&&(n._cachedTouchTarget=s.visual)):(r.source(null),i.end(t))},move:function(t){var e=this.toolService,i=e.activeConnection;return i.target(t),e.diagram.trigger(pt,{shapes:[],connections:[i],connectionHandle:zt}),!0},end:function(t){var e,i=this.toolService,n=i.diagram,o=i.activeConnection,s=i.hoveredItem,r=i._hoveredConnector,a=n._cachedTouchTarget;o&&(e=r&&r._c!=o.sourceConnector?r._c:s&&s instanceof H.Shape?s.getConnector(rt)||s.getConnector(t):t,o.target(e),n.trigger(gt,{shapes:[],connections:[o],connectionHandle:zt})?(n.remove(o,!1),n.undoRedoService.pop()):(o.updateModel(),n._syncConnectionChanges()),i._connectionManipulation(),a&&(n._connectorsAdorner.visual.remove(a),n._cachedTouchTarget=null))},getCursor:function(){return ot.arrow}}),M=F.extend({init:function(t){this.toolService=t,this.type="ConnectionTool"},tryActivate:function(t,e){var i=this.toolService,n=i.diagram,o=n.options.selectable,s=i.hoveredItem,r=o!==!1&&s&&s.path&&!(s.isSelected&&e.ctrlKey);return r&&(this._c=s),r},start:function(t,e){var i,n,s,r=this.toolService,a=this._c;r.selectSingle(a,e),i=a.adorner,i&&(n=i._hitTest(t),s=Bt[n]),o(a)&&i&&!r.diagram.trigger(ft,{shapes:[],connections:[a],connectionHandle:s})?(this.handle=n,this.handleName=s,i.start(t)):(r.startPoint=t,r.end(t))},move:function(t){var e=this._c.adorner;if(o(this._c)&&e)return e.move(this.handle,t),this.toolService.diagram.trigger(pt,{shapes:[],connections:[this._c],connectionHandle:this.handleName}),!0},end:function(t){var e,i=this._c,n=i.adorner,s=this.toolService,r=s.diagram;n&&o(i)&&(e=n.stop(t),r.trigger(gt,{shapes:[],connections:[i],connectionHandle:this.handleName})?e.undo():(r.undoRedoService.add(e,!1),i.updateModel(),r._syncConnectionChanges()))},getCursor:function(){return ot.move}}),D=F.extend({init:function(t){this.diagram=t,this.tools=[new C(this),new M(this),new T(this),new k(this),new S(this)],this.activeTool=e},start:function(t,e){return e=J({},e),this.activeTool&&this.activeTool.end(t,e),this._updateHoveredItem(t),this._activateTool(t,e),this.activeTool.start(t,e),this._updateCursor(t),this.diagram.focus(),this.diagram.canvas.surface.suspendTracking(),this.startPoint=t,!0},move:function(t,e){e=J({},e);var i=!0;return this.activeTool&&(i=this.activeTool.move(t,e)),i&&this._updateHoveredItem(t),this._updateCursor(t),!0},end:function(t,i){return i=J({},i),this.activeTool&&this.activeTool.end(t,i),this.diagram.canvas.surface.resumeTracking(),this.activeTool=e,this._updateCursor(t),!0},keyDown:function(t,e){var n,o=this.diagram;if(e=J({ctrlKey:!1,metaKey:!1,altKey:!1},e),!e.ctrlKey&&!e.metaKey||e.altKey){if(46===t||8===t)return n=this.diagram._triggerRemove(o.select()),n.length&&(this.diagram.remove(n,!0),this.diagram._syncChanges(),this.diagram._destroyToolBar()),!0;if(27===t)return this._discardNewConnection(),o.deselect(),o._destroyToolBar(),!0}else{if(i(t,"a"))return o.selectAll(),o._destroyToolBar(),!0;if(i(t,"z"))return o.undo(),o._destroyToolBar(),!0;if(i(t,"y"))return o.redo(),o._destroyToolBar(),!0;i(t,"c")?(o.copy(),o._destroyToolBar()):i(t,"x")?(o.cut(),o._destroyToolBar()):i(t,"v")?(o.paste(),o._destroyToolBar()):i(t,"l")?(o.layout(),o._destroyToolBar()):i(t,"d")&&(o._destroyToolBar(),o.copy(),o.paste())}},wheel:function(t,e){var i=this.diagram,n=e.delta,o=i.zoom(),s=i.options,r=s.zoomRate,a={point:t,meta:e,zoom:o};if(!i.trigger(bt,a))return n<0?o+=r:o-=r,o=U.dataviz.round(Math.max(s.zoomMin,Math.min(s.zoomMax,o)),2),a.zoom=o,i.zoom(o,a),i.trigger(Ct,a),!0},setTool:function(t,e){t.toolService=this,this.tools[e]=t},selectSingle:function(t,e){var i,n=this.diagram,o=n.options.selectable;o&&!t.isSelected&&t.options.selectable!==!1&&(i=e.ctrlKey&&o.multiple!==!1,n.select(t,{addToSelection:i}))},_discardNewConnection:function(){this.newConnection&&(this.diagram.remove(this.newConnection),this.newConnection=e)},_activateTool:function(t,e){var i,n;for(i=0;io?a:h),e||a||h},_hitTestItems:function(t,e){var i,n,o;for(i=t.length-1;i>=0;i--)if(n=t[i],o=n._hitTest(e))return o}}),I=U.Class.extend({init:function(){}}),P=I.extend({init:function(t){var e=this;I.fn.init.call(e),this.connection=t},hitTest:function(t){var e=this.getBounds().inflate(st);return!!e.contains(t)&&H.Geometry.distanceToPolyline(t,this.connection.allPoints())(a[n.axis]-e[n.axis])*n.secondarySign&&(n=s);return n.name},_sameSideDistance:function(t){var e=t.shape.bounds(Lt);return Math.min(e.width,e.height)/this.SAME_SIDE_DISTANCE_RATIO},_connectorPoints:function(t,e,i,n){var o,s,r=this._connectorSide(i,e),a=this._connectorSide(n,t),h=e.x-t.x,c=e.y-t.y,d=this._sameSideDistance(i),l=[];return r===at||r==dt?a==at||a==dt?r==a?(s=r==at?Math.min(t.y,e.y)-d:Math.max(t.y,e.y)+d,l=[new Y(t.x,s),new Y(e.x,s)]):l=[new Y(t.x,t.y+c/2),new Y(e.x,t.y+c/2)]:l=[new Y(t.x,e.y)]:a==ct||a==ht?r==a?(o=r==ct?Math.min(t.x,e.x)-d:Math.max(t.x,e.x)+d,l=[new Y(o,t.y),new Y(o,e.y)]):l=[new Y(t.x+h/2,t.y),new Y(t.x+h/2,t.y+c)]:l=[new Y(e.x,t.y)],l},_floatingPoints:function(t,e,i){var n,o,s,r=i?this._connectorSide(i,e):null,a=this._startHorizontal(t,e,r),h=[t,t,e,e],c=e.x-t.x,d=e.y-t.y,l=h.length;for(s=1;sMath.abs(t.y-e.y)}}),z=F.extend({init:function(t,e){var i=this;i.diagram=t,i.options=J({},i.options,e),i.visual=new G,i.diagram._adorners.push(i)},refresh:function(){}}),B=z.extend({init:function(t,e){var i,n,o,s=this;s.connection=t,i=s.connection.diagram,s._ts=i.toolService,z.fn.init.call(s,i,e),n=s.connection.sourcePoint(),o=s.connection.targetPoint(),s.spVisual=new j(J(s.options.handles,{center:n})),s.epVisual=new j(J(s.options.handles,{center:o})),s.visual.append(s.spVisual),s.visual.append(s.epVisual)},options:{handles:{}},_getCursor:function(){return ot.move},start:function(t){switch(this.handle=this._hitTest(t),this.startPoint=t,this._initialSource=this.connection.source(),this._initialTarget=this.connection.target(),this.handle){case-1:this.connection.targetConnector&&this._ts._connectionManipulation(this.connection,this.connection.targetConnector.shape);break;case 1:this.connection.sourceConnector&&this._ts._connectionManipulation(this.connection,this.connection.sourceConnector.shape)}},move:function(t,e){switch(t){case-1:this.connection.source(e);break;case 1:this.connection.target(e);break;default:var i=e.minus(this.startPoint);this.startPoint=e,this.connection.sourceConnector||this.connection.source(this.connection.sourcePoint().plus(i)),this.connection.targetConnector||this.connection.target(this.connection.targetPoint().plus(i))}return this.refresh(),!0},stop:function(t){var i,n=this.diagram.toolService,o=n.hoveredItem;return i=n._hoveredConnector?n._hoveredConnector._c:o&&o instanceof H.Shape?o.getConnector(rt)||o.getConnector(t):t,this.handle===-1?this.connection.source(i):1===this.handle&&this.connection.target(i),this.handle=e,this._ts._connectionManipulation(),new l(this.connection,this._initialSource,this._initialTarget)},_hitTest:function(t){var e=this.connection.sourcePoint(),i=this.connection.targetPoint(),n=this.options.handles.width/2+st,o=this.options.handles.height/2+st,s=e.distanceTo(t),r=i.distanceTo(t),a=new q(e.x,e.y).inflate(n,o).contains(t),h=new q(i.x,i.y).inflate(n,o).contains(t),c=0;return a&&(!h||s=0;t--)t!=o&&e.visual.remove(i[t])},destroy:function(){var t=this;t.diagram.unbind(_t,t._refreshHandler),t.shape=e,t._visible=e,t.visual.visible(!1)},_hitTest:function(t){var e,i;for(i=0;i0&&(o.x=this._bounds.width+1-i/2),t.y<0?o.y=-n/2:0===t.y?o.y=Math.floor(this._bounds.height/2)-n/2:t.y>0&&(o.y=this._bounds.height+1-n/2),o}},_getCursor:function(t){var e,i=this._hitTest(t);if(i&&i.x>=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&this._resizable()){if(e=this._angle,e&&(e=360-e,i.rotate(new Y(0,0),e),i=new Y(Math.round(i.x),Math.round(i.y))),i.x==-1&&i.y==-1)return"nw-resize";if(1==i.x&&1==i.y)return"se-resize";if(i.x==-1&&1==i.y)return"sw-resize";if(1==i.x&&i.y==-1)return"ne-resize";if(0===i.x&&i.y==-1)return"n-resize";if(0===i.x&&1==i.y)return"s-resize";if(1==i.x&&0===i.y)return"e-resize";if(i.x==-1&&0===i.y)return"w-resize"}return this._manipulating?ot.move:ot.select},_initialize:function(){var t,e,i=this,n=i.diagram.select();for(i.shapes=[],t=0;t=c.options.minWidth&&u.height>=c.options.minHeight&&(v=a,c.bounds(u),c.hasOwnProperty("layout")&&c.layout(c,v,u),v.width===u.width&&v.height===u.height||c.rotate(c.rotate().angle),x+=1)}x&&(x==d?(u=this._displaceBounds(this._innerBounds,y,w,r),this.bounds(u)):this.refreshBounds(),this.refresh()),this._positions()}this._cp=i},isDragHandle:function(t){return 0===t.x&&0===t.y},cancel:function(){var t,i=this.shapes,n=this.shapeStates;for(t=0;t0?(i=this.bounds(),this.visual.visible(!0),this.visual.position(i.topLeft()),t.each(this.map,function(){e=s._getHandleBounds(new Y(this.x,this.y)),this.visual.position(e.topLeft())}),this.visual.position(i.topLeft()),n=new Y(i.width/2,i.height/2),this.visual.rotate(this._angle,n),this.rect.redraw({width:i.width,height:i.height}),this.rotationThumb&&(o=this.options.editable.rotate.thumb,this._rotationThumbBounds=new q(i.center().x,i.y+o.y,0,0).inflate(o.width),this.rotationThumb.redraw({x:i.width/2-o.width/2}))):this.visual.visible(!1)}}),O=F.extend({init:function(t){var e=t.options.selectable;this.options=J({},this.options,e),this.visual=new K(this.options),this.diagram=t},options:{stroke:{color:"#778899",width:1,dashType:"dash"},fill:{color:It}},start:function(t){this._sp=this._ep=t,this.refresh(),this.diagram._adorn(this,!0)},end:function(){this._sp=this._ep=e,this.diagram._adorn(this,!1)},bounds:function(t){return t&&(this._bounds=t),this._bounds},move:function(t){this._ep=t,this.refresh()},refresh:function(){if(this._sp){var t=q.fromPoints(this.diagram.modelToLayer(this._sp),this.diagram.modelToLayer(this._ep));this.bounds(q.fromPoints(this._sp,this._ep)),this.visual.position(t.topLeft()),this.visual.redraw({height:t.height+1,width:t.width+1})}}}),A=F.extend({init:function(t){this.options=J({},t.options),this._c=t,this.visual=new j(this.options),this.refresh()},_hover:function(t){var e=this.options,i=e.hover,n=e.stroke,o=e.fill;t&&W.isDefined(i.stroke)&&(n=J({},n,i.stroke)),t&&W.isDefined(i.fill)&&(o=i.fill),this.visual.redraw({stroke:n,fill:o})},refresh:function(){var t=this._c.shape.diagram.modelToView(this._c.position()),e=t.minus(this._c.shape.bounds("transformed").topLeft()),i=new q(t.x,t.y,0,0);i.inflate(this.options.width/2,this.options.height/2),this._visualBounds=i,this.visual.redraw({center:new Y(e.x,e.y)})},_hitTest:function(t){var e=this._c.shape.diagram.modelToView(t);return this._visualBounds.contains(e)}}),J(H,{CompositeUnit:c,TransformUnit:p,PanUndoUnit:_,AddShapeUnit:m,AddConnectionUnit:g,DeleteShapeUnit:f,DeleteConnectionUnit:u,ConnectionEditAdorner:B,ConnectionTool:T,ConnectorVisual:A,UndoRedoService:x,ResizingAdorner:N,Selector:O,ToolService:D,ConnectorsAdorner:R,LayoutUndoUnit:h,ConnectionEditUnit:d,ToFrontUnit:y,ToBackUnit:w,ConnectionRouterBase:I,PolylineRouter:L,CascadingRouter:E,SelectionTool:k,ScrollerTool:C,PointerTool:S,ConnectionEditTool:M,RotateUnit:v})}(window.kendo.jQuery)},"function"==typeof define&&define.amd?define:function(t,e,i){(i||e)()}),function(t,define){define("dataviz/diagram/layout.min",["dataviz/diagram/math.min"],t)}(function(){!function(t,e){var i=window.kendo,n=i.dataviz.diagram,o=n.Graph,s=n.Node,r=n.Link,a=i.deepExtend,h=n.Size,c=n.Rect,d=n.Dictionary,l=n.Set,u=n.Graph,f=n.Utils,p=n.Point,g=1e-6,m=Math.PI/180,_=f.contains,v=t.grep,y=i.Class.extend({defaultOptions:{type:"Tree",subtype:"Down",roots:null,animate:!1,limitToView:!1,friction:.9,nodeDistance:50,iterations:300,horizontalSeparation:90,verticalSeparation:50,underneathVerticalTopOffset:15,underneathHorizontalOffset:15,underneathVerticalSeparation:15,grid:{width:1500,offsetX:50,offsetY:50,componentSpacingX:20,componentSpacingY:20},layerSeparation:50,layeredIterations:2,startRadialAngle:0,endRadialAngle:360,radialSeparation:150,radialFirstLevelSeparation:200,keepComponentsInOneRadialLayout:!1,ignoreContainers:!0,layoutContainerChildren:!1,ignoreInvisible:!0,animateTransitions:!1},init:function(){},gridLayoutComponents:function(t){var e,i,n,o,s,r,a,h,c,d,l,u,g,m,_;if(!t)throw"No components supplied.";for(f.forEach(t,function(t){t.calcBounds()}),t.sort(function(t,e){return e.bounds.width-t.bounds.width}),e=this.options.grid.width,i=this.options.grid.componentSpacingX,n=this.options.grid.componentSpacingY,o=0,s=this.options.grid.offsetX,r=this.options.grid.offsetY,a=s,h=r,d=[],l=[];t.length>0;){for(a>=e&&(a=s,h+=o+n,o=0),u=t.pop(),this.moveToOffset(u,new p(a,h)),c=0;c=o&&(o=m),a+=_+i}return{nodes:l,links:d}},moveToOffset:function(t,e){var i,n,o,s,r,a,h,d,l=t.bounds,u=e.x-l.x,f=e.y-l.y;for(i=0;i0},isIgnorableItem:function(t){return this.options.ignoreInvisible?(!t.isCollapsed||!this._isVisible(t))&&!(!t.isCollapsed&&this._isVisible(t)):t.isCollapsed&&!this._isTop(t)},isShapeMapped:function(t){return t.isCollapsed&&!this._isVisible(t)&&!this._isTop(t)},leastCommonAncestor:function(t,e){var i,n,o,s,r,a;if(!t)throw"Parameter should not be null.";if(!e)throw"Parameter should not be null.";if(!this.hyperTree)throw"No hypertree available.";if(i=this.listToRoot(t),n=this.listToRoot(e),o=null,f.isEmpty(i)||f.isEmpty(n))return this.hyperTree.root.data;for(s=i[0],r=n[0],a=0;s===r&&(o=i[a],a++,!(a>=i.length||a>=n.length));)s=i[a],r=n[a];return o?v(this.hyperTree.nodes,function(t){return t.data.container===o}):this.hyperTree.root.data},_isTop:function(t){return!t.parentContainer},_isVisible:function(t){return!!t.visible()&&(t.parentContainer?this._isVisible(t.parentContainer):t.visible())},_isCollapsed:function(t){return!(!t.isContainer||!t.isCollapsed)||t.parentContainer&&this._isCollapsed(t.parentContainer)},_renormalizeShapes:function(){var t,e,i,n;if(!this.options.ignoreContainers)throw"Containers are not supported yet, but stay tuned.";for(t=0,e=this.diagram.shapes.length;t=5*this.options.iterations/6,this.tick(),this.temperature=this.refineStage?i/30:i*(1-o/(2*this.options.iterations))},tick:function(){var t,e,i;for(t=0;t0?t+=Math.sqrt(i):0},0,this),e=t/s,i=e*Math.ceil(Math.sqrt(s)),n=i*Math.sqrt(r),o=i/Math.sqrt(r),{width:n*a,height:o*a})}}),b=i.Class.extend({init:function(t){this.center=null,this.options=t},layout:function(t,e){if(this.graph=t,this.graph.nodes&&0!==this.graph.nodes.length){if(!_(this.graph.nodes,e))throw"The given root is not in the graph.";this.center=e,this.graph.cacheRelationships(),this.layoutSwitch()}},layoutLeft:function(t){var e,i,n,o,s,r,a,c;for(this.setChildrenDirection(this.center,"Left",!1),this.setChildrenLayout(this.center,"Default",!1),e=0,i=0,o=0;o0&&this.radialLayout(this.center,this.options.radialFirstLevelSeparation,t,e),this.center.Angle=e-t},tipOverTree:function(t,e){var i,n,o,s,r,a,c;for(f.isUndefined(e)&&(e=0),this.setChildrenDirection(this.center,"Down",!1),this.setChildrenLayout(this.center,"Default",!1),this.setChildrenLayout(this.center,"Underneath",!1,e),i=0,s=0;sthis.maxDepth&&(this.maxDepth=e),i=0,n=1e3,o=1e3,s=0===e?0:Math.sqrt(n*n+o*o)/e,t.children.length>0){for(r=0,a=t.children.length;r1)throw"Node is not part of a tree.";if(i=t.parents[0],i&&(n=new p(i.x,i.y),o=new p(t.x,t.y),u=this.normalizeAngle(Math.atan2(n.y-o.y,n.x-o.x))),s=t.children.length,0===s)return null;for(r=[],a=[],e=0;e2*Math.PI;)t-=2*Math.PI;for(;t<0;)t+=2*Math.PI;return t},radialLayout:function(t,e,i,n){var o,s,r,a,h,c=n-i,d=c/2,l=t.sectorAngle,u=0,f=this.sortChildren(t);for(o=0,s=f.length;o0&&this.radialLayout(r,e+this.options.radialSeparation,i+u*c,i+(u+h)*c),this.setPolarLocation(r,e,i+u*c+h*d),a.angle=h*c,u+=h},setPolarLocation:function(t,e,i){t.x=this.origin.x+e*Math.cos(i),t.y=this.origin.y+e*Math.sin(i),t.BoundingRectangle=new c(t.x,t.y,t.width,t.height)},setChildrenDirection:function(t,e,i){var n=t.treeDirection;this.graph.depthFirstTraversal(t,function(t){t.treeDirection=e}),i||(t.treeDirection=n)},setChildrenLayout:function(t,e,i,n){f.isUndefined(n)&&(n=0);var o=t.childrenLayout;n>0?(this.graph.assignLevels(t),this.graph.depthFirstTraversal(t,function(t){t.level>=n+1&&(t.childrenLayout=e)})):(this.graph.depthFirstTraversal(t,function(t){t.childrenLayout=e}),i||(t.childrenLayout=o))},measure:function(t,e){var i,n,o,s,r,a,c,d=0,l=0,u=new h(0,0);if(!t)throw"";if(n=t.associatedShape.bounds(),o=n.width,s=n.height,1!==t.parents.length)throw"Node not in a spanning tree.";if(r=t.parents[0],"Undefined"===t.treeDirection&&(t.treeDirection=r.treeDirection),f.isEmpty(t.children))u=new h(Math.abs(o)=o}),this.layoutLeft(i),this.layoutRight(n));break;case"mindmapvertical":e=this.center.children,1===this.center.children.length?this.layoutDown(e):(o=s.length/2,i=v(this.center.children,function(t){return f.indexOf(s,t)=o}),this.layoutUp(i),this.layoutDown(n));break;case"right":this.layoutRight(this.center.children);break;case"left":this.layoutLeft(this.center.children);break;case"up":case"bottom":this.layoutUp(this.center.children);break;case"down":case"top":this.layoutDown(this.center.children);break;case"tipover":case"tipovertree":if(this.options.tipOverTreeStartLevel<0)throw"The tip-over level should be a positive integer.";this.tipOverTree(this.center.children,this.options.tipOverTreeStartLevel);break;case"undefined":case"none":}}}),C=y.extend({init:function(t){var e=this;if(y.fn.init.call(e),f.isUndefined(t))throw"No diagram specified.";this.diagram=t},layout:function(t){var e,i;return this.transferOptions(t),e=new w(this.diagram),this.graph=e.convert(),i=this.layoutComponents(),new n.LayoutState(this.diagram,i)},layoutComponents:function(){var t,e,i,n,o,s,r,a;if(!this.graph.isEmpty()&&(t=this.graph.getConnectedComponents(),!f.isEmpty(t))){for(e=new b(this.options),i=[],n=0;n0)for(e=0,i=t.nodes.length;e0;)for(s=p.shift(),e=0;em&&(m=o),_(p,r)||p.push(r);for(a=g.keys(),a.sort(function(t,e){var i=g.get(t),n=g.get(e);return f.sign(n-i)}),h=0;h1&&g.set(c,l-1)}for(this.layers=[],e=0;ei.layer?(n=t.source,o=t.target):(o=t.source,n=t.target),this.downNodes.get(o).push(n),this.upNodes.get(n).push(o)},this),this.downNodes.forEachValue(function(t){t.sort(this._gridPositionComparer)},this),this.upNodes.forEachValue(function(t){t.sort(this._gridPositionComparer)},this),i=0;ic.gridPosition&&(l=h.gridPosition,h.gridPosition=c.gridPosition,c.gridPosition=l,u=h.layerIndex,p=c.layerIndex,this.layers[i+1][u]=c,this.layers[i+1][p]=h,h.layerIndex=p,c.layerIndex=u));for(g=this._getLeftWing(),m=this._getRightWing(),_=this.placeLeftToRight(g),v=this.placeRightToLeft(m),y=new d,f.forEach(this.graph.nodes,function(t){y.set(t,(_.get(t)+v.get(t))/2)}),w=new d,x=new d,i=0;i0){for(this._sequencer(y,null,s,t,r),e=0;e0&&this._sequencer(y,s,a,t,r),x.set(s,!0)}}else{for(o=s.layerIndex,r=[],e=o+1;e0){for(this._sequencer(y,s,null,t,r),e=0;e=0},M=this._isIncreasingLayout()?1:-1,D=0,e=k;T(e,this);e+=M){for(o=this.layers[e],I=t(o,this),s=0;s=this.layers.length))for(o=null,s=null,r=this.layers[t+e],a=0;a1){var s=o.length,r=this.intDiv(s,2);this._sequencer(t,e,i,n,o.slice(0,r)),this._sequencer(t,e,i,n,o.slice(r)),this.combineSequences(t,e,i,n,o)}},_sequenceSingle:function(t,e,i,n,o){var s=n===-1?this.downNodes.get(o):this.upNodes.get(o),r=s.length;0!==r&&(r%2===1?t.set(o,t.get(s[this.intDiv(r,2)])):t.set(o,(t.get(s[this.intDiv(r,2)-1])+t.get(s[this.intDiv(r,2)]))/2),e&&t.set(o,Math.max(t.get(o),t.get(e)+this.getMinDist(e,o))),i&&t.set(o,Math.min(t.get(o),t.get(i)-this.getMinDist(o,i))))},combineSequences:function(t,e,i,n,o){var s,r,a,h,c,d,l,u,f,p,g=o.length,m=this.intDiv(g,2),_=[];for(s=0;s=t.get(o[s])?r++:(r--,_.push({k:t.get(c)+this.getMinDist(o[s],o[m-1]),v:2}));_.push({k:t.get(o[s])+this.getMinDist(o[s],o[m-1]),v:r})}for(e&&_.push({k:t.get(e)+this.getMinDist(e,o[m-1]),v:Number.MAX_VALUE}),_.sort(this._positionDescendingComparer),l=[],s=m;s=0;s--)t.set(o[s],Math.min(t.get(o[s]),t.get(o[m-1])-this.getMinDist(o[s],o[m-1])));for(s=m+1;s=1;t--)this.layoutLayer(!1,t);for(t=0;ti&&this.moveLeft(t,n,o);)e=t.gridPosition},this),i>0&&this.calcDownData(i-1),it.gridPosition+1?(t.gridPosition=t.gridPosition+.5,!0):!(o>i||Math.abs(o-i)<1e-4)&&(!!this.moveRight(n,e,i)&&(t.gridPosition=t.gridPosition+.5,!0)))},moveLeft:function(t,e,i){var n,o,s=f.indexOf(e,t);return 0===s?(t.gridPosition=t.gridPosition-.5,!0):(n=e[s-1],o=(n.upstreamPriority+n.downstreamPriority)/2,n.gridPositioni||Math.abs(o-i)<1e-4)&&(!!this.moveLeft(n,e,i)&&(t.gridPosition=t.gridPosition-.5,!0)))},mapVirtualNode:function(t,e){this.nodeToLinkMap.set(t,e),this.linkToNodeMap.containsKey(e)||this.linkToNodeMap.set(e,[]),this.linkToNodeMap.get(e).push(t)},_nodesInLink:function(t){return this.linkToNodeMap.get(this.nodeToLinkMap.get(t))},_dummify:function(){var t,e,i,n,o,a,h,c,l,u,p,g,m,_,v,y,w,x,b,C;for(this.linkToNodeMap=new d,this.nodeToLinkMap=new d,l=this.graph.links.slice(0),u=this.layers,p=function(t,e,i){u[t].linksTo[e]=u[t].linksTo[e]||[],u[t].linksTo[e].push(i)},c=0;c1){for(h=v-1;h>y;h--){for(i=new s,i.x=m.x,i.y=m.y,i.width=m.width/100,i.height=m.height/100,t=u[h],e=(h-y)*b+w,e>t.length&&(e=t.length),w>=u[v].length-1&&x>=u[y].length-1?e=t.length:0===w&&0===x&&(e=0),i.layer=h,i.uBaryCenter=0,i.dBaryCenter=0,i.upstreamLinkCount=0,i.downstreamLinkCount=0,i.gridPosition=e,i.isVirtual=!0,f.insert(t,i,e),o=e+1;ot.length&&(e=t.length),w>=u[v].length-1&&x>=u[y].length-1?e=t.length:0===w&&0===x&&(e=0),i.layer=h,i.uBaryCenter=0,i.dBaryCenter=0,i.upstreamLinkCount=0,i.downstreamLinkCount=0,i.gridPosition=e,i.isVirtual=!0,e&=e,f.insert(t,i,e),o=e+1;o2?(i.splice(0,1),i.splice(i.length-1),e.points=i):e.points=[],h=!0;break}},_optimizeCrossings:function(){for(var t,e=-1,i=3,n=0;0!==e&&!(n++>i);){for(e=0,t=this.layers.length-1;t>=1;t--)e+=this.optimizeLayerCrossings(!1,t);for(t=0;t0?(a.uBaryCenter=h/c,a.upstreamLinkCount=c):(a.uBaryCenter=i,a.upstreamLinkCount=0)}}},calcDownData:function(t){var e,i,n,o,s,r,a,h,c;if(t!==this.layers.length-1){for(e=this.layers[t],s=new l,r=this.layers[t+1],i=0;i0?(a.dBaryCenter=h/c,a.downstreamLinkCount=c):(a.dBaryCenter=i,a.downstreamLinkCount=0)}}},optimizeLayerCrossings:function(t,e){var i,n,o,s,r,a,h,c;for(n=t?this.layers[i=e+1]:this.layers[i=e-1],o=n.slice(0),t?this.calcUpData(i):this.calcDownData(i),s=this,n.sort(function(t,e){var i,n=s.calcBaryCenter(t),o=s.calcBaryCenter(e);return Math.abs(n-o)<1e-4?t.degree()===e.degree()?s.compareByIndex(t,e):t.degree()0?-1:i<0?1:s.compareByIndex(t,e))}),a=0,r=0;r0)for(h=0,r=0;r_)break;for(t=v%4<=1,e=v%4===1,i=t?0:this.layers.length-1;t?i<=this.layers.length-1:i>=0;i+=t?1:-1){for(n=this.layers[i],o=!1,s=!0,r=0,a=0;a=d:g>d,m?(l=n[a],u=n[a+1],f=l.gridPosition,p=u.gridPosition,n[a]=u,n[a+1]=l,l.gridPosition=p,u.gridPosition=f,r=d,s=!1):(o=!0,s=!0));o&&(i!==this.layers.length-1&&this.calcUpData(i+1),0!==i&&this.calcDownData(i-1))}}},countLinksCrossingBetweenTwoLayers:function(t,e){var i,n,o,s,r,a,h,c,d,l,u,f,p=this.layers[t].linksTo[e],g=0,m=p.length;for(h=0;h0&&i>0?(n+o)/2:e>0?n:i>0?o:0},_gridPositionComparer:function(t,e){return t.gridPositione.gridPosition?1:0},_positionAscendingComparer:function(t,e){return t.ke.k?1:0},_positionDescendingComparer:function(t,e){return t.ke.k?-1:0},_firstVirtualNode:function(t){for(var e=0;en?-1:0},intDiv:function(t,e){return(t-t%e)/e},nextVirtualNode:function(t,e){var i,n=e.layerIndex;for(i=n+1;i0?xt.ceil(i):xt.floor(i)):e.detail&&(i=e.detail),i}function n(t){return t.options.name.toLowerCase()===Bt.toLowerCase()}function o(t,e){var i,o,s,r,a=Ut;for(s=0;s").appendTo(e).kendoDropDownList({dataValueField:o.idField,dataTextField:n,dataSource:this.dataSource.data().toJSON(),optionLabel:" ",valuePrimitive:!0}))}function c(t){this.dataItem=t,this.callbacks=[]}function d(){this.items={}}function l(t){var e=t;return t instanceof kendo.data.Model&&(e=t.toJSON(),e[t.idField]=t._defaultId),e}function u(t){var e,i,n=[],o=[];for(i=0;i#=text#',ge=5;z.DefaultConnectors=[{name:Rt},{name:At},{name:Ot},{name:Nt},{name:Bt,position:function(t){return t.getPosition("center")}}],v={cancel:{text:"Cancel",imageClass:"k-i-cancel",className:"k-diagram-cancel",iconClass:"k-icon"},update:{text:"Update",imageClass:"k-i-checkmark",className:"k-diagram-update",iconClass:"k-icon"}},z.shapeDefaults=function(t){var e={type:Yt,path:"",autoSize:!0,visual:null,x:$t,y:$t,minWidth:Jt,minHeight:Zt,width:jt,height:Qt,hover:{},editable:{connect:!0,tools:[]},connectors:z.DefaultConnectors,rotation:{angle:0}};return ht.simpleExtend(e,t),e},y=ct.extend({init:function(t){var e=this;e.dataItem=(t||{}).dataItem,ct.fn.init.call(e),e.options=O({id:z.randomId()},e.options,t),e.isSelected=!1,e.visual=new G({id:e.options.id,autoSize:e.options.autoSize}),e.id=e.options.id,e._template()},options:{hover:{},cursor:at.grip,content:{align:"center middle"},selectable:!0,serializable:!0,enable:!0},_getCursor:function(t){return this.adorner?this.adorner._getCursor(t):this.options.cursor},visible:function(t){return pt(t)?this.visual.visible():(this.visual.visible(t),e)},bounds:function(){},refresh:function(){this.visual.redraw()},position:function(t){this.options.x=t.x,this.options.y=t.y,this.visual.position(t)},toString:function(){return this.options.id},serialize:function(){var t=O({},{options:this.options});return this.dataItem&&(t.dataItem=""+this.dataItem),t},_content:function(t){var i,n,o;return t!==e&&(i=this.options,z.Utils.isString(t)?i.content.text=t:O(i.content,t),n=i.content,o=this._contentVisual,o?this._updateContentVisual(n):this._createContentVisual(n)),this.options.content.text},_createContentVisual:function(t){t.text&&(this._contentVisual=new J(t),this._contentVisual._includeInBBox=!1,this.visual.append(this._contentVisual))},_updateContentVisual:function(t){this._contentVisual.redraw(t)},_hitTest:function(t){var e=this.bounds();return this.visible()&&e.contains(t)&&this.options.enable},_template:function(){var t,e,i=this;i.options.content.template&&(t=i.dataItem||{},e=kendo.template(i.options.content.template,{paramName:"dataItem"}),i.options.content.text=e(t))},_canSelect:function(){return this.options.selectable!==!1},toJSON:function(){return{id:this.options.id}}}),w=R.extend({init:function(t,e){this.options=O({},this.options,e),this.connections=[],this.shape=t},options:{width:7,height:7,fill:{color:te},hover:{}},position:function(){return this.options.position?this.options.position(this.shape):this.shape.getPosition(this.options.name)},toJSON:function(){return{shapeId:""+this.shape,connector:this.options.name}}}),w.parse=function(t,e){var i,n,o=e.split(":"),s=o[0],r=o[1]||Bt;for(i=0;i0&&e[n].equals(e[i]);)n--,i++;o=e[i],s=e[n],r=this._contentVisual._measure(),a=r.width,h=r.height,c=e.length%2===0,d=s.distanceTo(o),c&&e.length>2&&d>0&&(s.y===o.y&&d90)&&(l.x-=a,l.y-=h)):(f=xt.floor(e.length/2),l=e[f].clone(),s=e[f-1],o=e[f+1],p=s.x<=l.x&&o.x<=l.x?t:-r.width-t,g=s.y<=l.y&&o.y<=l.y?t:-r.height-t,l.x+=p,l.y+=g),this._contentVisual.position(l)}},select:function(t){var i,n,o=this.diagram;if(this._canSelect()&&this.isSelected!==t)return this.isSelected=t,i=[],n=[],this.isSelected?(this.adorner=new et(this,this.options.selection),o._adorn(this.adorner,!0),o._selectedItems.push(this),i.push(this)):this.adorner&&(o._adorn(this.adorner,!1),ht.remove(o._selectedItems,this),this.adorner=e,n.push(this)),this.adorner&&this.adorner.refresh(),o._internalSelection||o._selectionChanged(i,n),!0},bounds:function(t){return!t||yt(t)?this._bounds:(this._bounds=t,e)},type:function(t){var i=this.options;return t?(t!==i.type&&(i.type=t,this._initRouter(),this.refresh()),e):i.type},_initRouter:function(){var t=(this.options.type||"").toLowerCase();this._router=t==St?new ft(this):new ut(this)},points:function(t){var e,i,n,o;if(!t){if(n=[],gt(this.definers))for(o=0;o0&&(a.x++,a.width-=2),a.height>0&&(a.y++,a.height-=2),!a.isEmpty()&&this.diagram._shapesQuadTree.hitTestRect(a,h)){l=!1;break}return l},_getRouteExclude:function(t,e,i,n){var o=[];return this._isPointInsideShape(t,i)&&o.push(i),this._isPointInsideShape(e,n)&&o.push(n),o},_isPointInsideShape:function(t,e){var i,n,o,s=e.bounds(),r=e.rotate().angle,a=s.x,h=s.y;return i=t.clone().rotate(s.center(),r),n=i.x,o=i.y,n>a&&nh&&o0&&(this.points(e),this._refreshPath()),(t&&t.content||t.text)&&this.content(t.content),this.path.redraw({fill:t.fill,stroke:t.stroke,startCap:t.startCap,endCap:t.endCap})}},clone:function(){var t=this.serialize();return this.diagram&&this.diagram._isEditable&&mt(this.dataItem)&&(t.options.dataItem=l(this.dataItem)),new b(this.from,this.to,t.options)},serialize:function(){var t=this.from.toJSON?this.from.toJSON:""+this.from,e=this.to.toJSON?this.to.toJSON:""+this.to,i=O({},{options:this.options,from:t,to:e});return mt(this.dataItem)&&(i.dataItem=""+this.dataItem),i.options.points=this.points(),i},_hitTest:function(t){if(this.visible()){var e=new $(t.x,t.y),i=this.sourcePoint(),n=this.targetPoint();if(t.isEmpty&&!t.isEmpty()&&t.contains(i)&&t.contains(n))return this;if(this._router.hitTest(e))return this}},_hover:function(t){var e=(this.options.stroke||{}).color;t&>(this.options.hover.stroke.color)&&(e=this.options.hover.stroke.color),this.path.redraw({stroke:{color:e}})},_refreshPath:function(){mt(this.path)&&(this._drawPath(),this.bounds(this._router.getBounds()))},_drawPath:function(){var t,e,i;this._router&&this._router.route(),t=this.sourcePoint(),e=this.targetPoint(),i=this.points(),this.path.redraw({points:[t].concat(i,[e])})},_clearSourceConnector:function(){this.sourceConnector=e,this._resolvedSourceConnector=e},_clearTargetConnector:function(){this.targetConnector=e,this._resolvedTargetConnector=e},_removeFromSourceConnector:function(){this.sourceConnector&&ht.remove(this.sourceConnector.connections,this)},_removeFromTargetConnector:function(){this.targetConnector&&ht.remove(this.targetConnector.connections,this)},toJSON:function(){var t,e,i,n=this;return n.from&&n.from.toJSON?t=n.from.toJSON():(i=n._sourcePoint,t={x:i.x,y:i.y}),n.to&&n.to.toJSON?e=n.to.toJSON():(i=n._targetPoint,e={x:i.x,y:i.y}),{from:t,to:e}}}),C=B.extend({init:function(t,e){var i=this;kendo.destroy(t),B.fn.init.call(i,t,e),i._initTheme(),i._initElements(),i._extendLayoutOptions(i.options),i._initDefaults(e),i._interactionDefaults(),i._initCanvas(),i.mainLayer=new G({id:"main-layer"}),i.canvas.append(i.mainLayer),i._shapesQuadTree=new I(i),i._pan=new $,i._adorners=[],i.adornerLayer=new G({id:"adorner-layer"}),i.canvas.append(i.adornerLayer),i._createHandlers(),i._initialize(),i._resizingAdorner=new st(i,{editable:i.options.editable}),i._connectorsAdorner=new rt(i),i._adorn(i._resizingAdorner,!0),i._adorn(i._connectorsAdorner,!0),i.selector=new ot(i),i._clipboard=[],i.pauseMouseHandlers=!1,i._fetchFreshData(),i._createGlobalToolBar(),i._createOptionElements(),i.zoom(i.options.zoom),i.canvas.draw()},options:{name:"Diagram",theme:"default",layout:"",zoomRate:.1,zoom:1,zoomMin:0,zoomMax:2,dataSource:{},draggable:!0,template:"",autoBind:!0,editable:{rotate:{},resize:{},text:!0,tools:[],drag:{snap:{size:10,angle:10}},remove:!0},pannable:{},selectable:{key:"none"},tooltip:{enabled:!0,format:"{0}"},copy:{enabled:!0,offsetX:20,offsetY:20},shapeDefaults:z.shapeDefaults({undoable:!0}),connectionDefaults:{editable:{tools:[]},type:St},shapes:[],connections:[]},events:[qt,Gt,Ft,Vt,Ht,kt,Tt,Mt,Lt,Et,"toolBarClick","save","cancel","edit","remove","add","dataBound",Pt,Dt,It],items:function(){return t()},_createGlobalToolBar:function(){var t,e=this.options.editable;e&&(t=e.tools,!this._isEditable||t===!1||t&&0!==t.length||(t=["createShape","undo","redo","rotateClockwise","rotateAnticlockwise"]),t&&t.length&&(this.toolBar=new S(this,{tools:t||{},click:N(this._toolBarClick,this),modal:!1}),this.toolBar.element.css({textAlign:"left"}),this.element.prepend(this.toolBar.element),this._resize()))},createShape:function(){var t,e,i,n,o,s;(this.editor&&this.editor.end()||!this.editor)&&(t=this.dataSource,e=t.view()||[],i=e.length,n=f(t,{}),o=this._createShape(n,{}),this.trigger("add",{shape:o})||(t.insert(i,n),s=this._inactiveShapeItems.getByUid(n.uid),s.element=o,this.edit(o)))},_createShape:function(t,e){e=O({},this.options.shapeDefaults,e),e.dataItem=t;var i=new x(e,this);return i},createConnection:function(){var t,e,i,n,o;(this.editor&&this.editor.end()||!this.editor)&&(t=this.connectionsDataSource,e=t.view()||[],i=e.length,n=f(t,{}),o=this._createConnection(n),this.trigger("add",{connection:o})||(this._connectionsDataMap[n.uid]=o,t.insert(i,n),this.addConnection(o,!1),this.edit(o)))},_createConnection:function(t,e,i){var n,o=O({},this.options.connectionDefaults);return o.dataItem=t,n=new b(e||new $,i||new $,o)},editModel:function(t,e){var i,n,o,s;if(this.cancelEdit(),o=this.options.editable,"shape"==e)i=o.shapeEditors,n=o.shapeTemplate;else{if("connection"!=e)return;s=N(h,this),i=O({},{from:s,to:s},o.connectionEditors),n=o.connectionTemplate}this.editor=new T(this.element,{update:N(this._update,this),cancel:N(this._cancel,this),model:t,type:e,target:this,editors:i,template:n}),this.trigger("edit",this._editArgs())},edit:function(t){if(t.dataItem){var e=t instanceof x?"shape":"connection";this.editModel(t.dataItem,e)}},cancelEdit:function(){this.editor&&(this._getEditDataSource().cancelChanges(this.editor.model),this._destroyEditor())},saveEdit:function(){this.editor&&this.editor.end()&&!this.trigger("save",this._editArgs())&&this._getEditDataSource().sync()},_update:function(){this.editor&&this.editor.end()&&!this.trigger("save",this._editArgs())&&(this._getEditDataSource().sync(),this._destroyEditor())},_cancel:function(){var t,e;this.editor&&!this.trigger("cancel",this._editArgs())&&(t=this.editor.model,this._getEditDataSource().cancelChanges(t),e=this._connectionsDataMap[t.uid]||this._dataMap[t.id],e&&e._setOptionsFromModel(t),this._destroyEditor())},_getEditDataSource:function(){return"shape"===this.editor.options.type?this.dataSource:this.connectionsDataSource},_editArgs:function(){var t={container:this.editor.wrapper};return t[this.editor.options.type]=this.editor.model,t},_destroyEditor:function(){this.editor&&(this.editor.close(),this.editor=null)},_initElements:function(){this.wrapper=this.element.empty().css("position","relative").attr("tabindex",0).addClass("k-widget k-diagram"),this.scrollable=t("
").appendTo(this.element)},_initDefaults:function(t){var e=this.options,i=e.editable,n=e.shapeDefaults,o=e.connectionDefaults,s=(t||{}).shapeDefaults;i===!1?(n.editable=!1,o.editable=!1):(g(i,n.editable,["drag","remove","connect"]),g(i,o.editable,["drag","remove"])),s&&s.connectors&&(e.shapeDefaults.connectors=s.connectors)},_interactionDefaults:function(){var t=this.options,e=t.selectable,i=t.pannable,n=kendo.support.mobileOS;e&&!mt(e.multiple)&&(t.selectable=O({multiple:!n},t.selectable)),i&&!mt(i.key)&&(t.pannable=O({key:n?"none":"ctrl"},t.pannable))},_initCanvas:function(){var e=t("
").appendTo(this.scrollable)[0],i=this.viewport();this.canvas=new F(e,{width:i.width||Wt,height:i.height||Xt})},_createHandlers:function(){var t=this,e=t.element;e.on(le,N(t._wheel,t)).on("keydown"+Ct,N(t._keydown,t)),t._userEvents=new kendo.UserEvents(this.scrollable,{multiTouch:!0,fastTap:!0,tap:N(t._tap,t),start:N(t._dragStart,t),move:N(t._drag,t),end:N(t._dragEnd,t),gesturestart:N(t._gestureStart,t),gesturechange:N(t._gestureChange,t),gestureend:N(t._gestureEnd,t)}),t.toolService=new nt(t),this.scrollable.on("mouseover"+Ct,N(t._mouseover,t)).on("mouseout"+Ct,N(t._mouseout,t)).on("mousemove"+Ct,N(t._mouseMove,t)).on("mousedown"+Ct,N(t._mouseDown,t)).on("mouseup"+Ct,N(t._mouseUp,t)),this._syncHandler=N(t._syncChanges,t),t._resizeHandler=N(t.resize,t,!1),kendo.onResize(t._resizeHandler),this.bind(Gt,N(t._destroyToolBar,t)),this.bind(Ft,N(t._destroyToolBar,t))},_dragStart:function(t){var e,i;this._pauseMouseHandlers=!0,e=this._eventPositions(t,!0),i=t.event,this.toolService.start(e,this._meta(i))&&(this._destroyToolBar(),i.preventDefault())},_drag:function(t){var e=this._eventPositions(t),i=t.event;this.toolService.move(e,this._meta(i))&&i.preventDefault()},_dragEnd:function(t){var e,i;this._pauseMouseHandlers=!1,e=this._eventPositions(t),i=t.event,this.toolService.end(e,this._meta(i))&&(this._createToolBar(),i.preventDefault())},_mouseMove:function(t){if(!this._pauseMouseHandlers){var e=this._eventPositions(t);this.toolService._updateHoveredItem(e),this.toolService._updateCursor(e)}},_mouseDown:function(){this._pauseMouseHandlers=!0},_mouseUp:function(){this._pauseMouseHandlers=!1},_tap:function(t){var e,i,n,o=this.toolService,s=this.options.selectable,r=this._eventPositions(t),a=this.focus();o._updateHoveredItem(r),o.hoveredItem?(e=o.hoveredItem,this.trigger("click",{item:e,point:r}),s&&e.options.selectable!==!1&&(i=s.multiple!==!1,n=kendo.support.mobileOS||this._meta(t.event).ctrlKey,e.isSelected?n?(this._destroyToolBar(),e.select(!1)):this._createToolBar(a):(this._destroyToolBar(),this.select(e,{addToSelection:i&&n}),this._createToolBar(a)))):s&&(this._destroyToolBar(),this.deselect())},_keydown:function(t){this.toolService.keyDown(t.keyCode,this._meta(t))&&t.preventDefault()},_wheel:function(t){var e=i(t),n=this._eventPositions(t),o=O(this._meta(t),{delta:e});this.toolService.wheel(n,o)&&t.preventDefault()},_meta:function(t){return{ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,shiftKey:t.shiftKey,type:t.type}},_eventPositions:function(t,e){var i,n,o;return t.touch?(n=e?"startLocation":"location",i=new $(t.x[n],t.y[n])):(o=t.originalEvent,i=new $(o.pageX,o.pageY)),this.documentToModel(i)},_gestureStart:function(t){var e,i;this._destroyToolBar(),this.scroller.disable(),e=this.documentToModel(new $(t.center.x,t.center.y)),i={point:e,zoom:this.zoom()},this.trigger(Gt,i)||(this._gesture=t,this._initialCenter=e)},_gestureChange:function(t){var e,i,n=this._gesture,o=this._initialCenter,s=this.documentToView(new $(t.center.x,t.center.y)),r=t.distance/n.distance,a=this._zoom,h=!1;xt.abs(r-1)>=ue&&(this._zoom=a=this._getValidZoom(a*r),this.options.zoom=a,this._gesture=t,h=!0),e=o.times(a),i=s.minus(e),(h||this._pan.distanceTo(i)>=fe)&&(this._panTransform(i),this._updateAdorners()),t.preventDefault()},_gestureEnd:function(){this.options.pannable!==!1&&this.scroller.enable(),this.trigger(qt,{point:this._initialCenter,zoom:this.zoom()})},_resize:function(){var t=this.viewport();this.canvas&&this.canvas.size(t),this.scrollable&&this.toolBar&&this.scrollable.height(t.height)},_mouseover:function(t){var e=t.target._kendoNode;e&&e.srcElement._hover&&e.srcElement._hover(!0,e.srcElement)},_mouseout:function(t){var e=t.target._kendoNode;e&&e.srcElement._hover&&e.srcElement._hover(!1,e.srcElement)},_initTheme:function(){var t,e=this,i=((e.options||{}).theme||"").toLowerCase(),n=P.ui.themes||{};t=bt.indexOf(i)!=-1?P.autoTheme().diagram:(n[i]||{}).diagram,e.options=O({},t,e.options),e.options.editable===!0&&O(e.options,{editable:(t||{}).editable})},_createOptionElements:function(){var t=this.options,e=t.shapes.length;e&&this._createShapes(),t.connections.length&&this._createConnections(),e&&t.layout&&this.layout(t.layout)},_createShapes:function(){var t,e,i=this,n=i.options,o=n.shapes;for(e=0;ei.clientHeight&&(n.push(i),o.push(i.scrollTop));while(i!=s);for(e.focus(),t=0;t=0;s--)this._removeItem(n[s],e,o);for(s=o.length-1;s>=0;s--)this._removeItem(o[s],e);this._resumeModelRefresh(),e&&this.undoRedoService.commit(!1),this.trigger(Tt,{added:[],removed:t})},_removeShapeDataItem:function(t){this._isEditable&&(this.dataSource.remove(t.dataItem),delete this._dataMap[t.dataItem.id])},_removeConnectionDataItem:function(t){this._isEditable&&(this.connectionsDataSource.remove(t.dataItem),delete this._connectionsDataMap[t.dataItem.uid])},_triggerRemove:function(t){var e,i,n,o,s=[];for(o=0;or.width||n.height>r.height)&&(this._zoom=this._getValidZoom(xt.min(r.width/o.width,r.height/o.height)),n=o.clone().zoom(this._zoom)),this._zoomMainLayer(),i=n.clone(),a.align(n,e.align),s=n.topLeft().minus(i.topLeft()),this.pan(s.times(-1),e.animate))},alignShapes:function(t){var e,i,n,o,s,r,a;if(pt(t)&&(t="Left"),e=this.select(),0!==e.length){switch(t.toLowerCase()){case"left":case"top":i=ee;break;case"right":case"bottom":i=ie}for(o=0;o0){for(n={},o=u(this._clipboard),s=o.connections,r=o.shapes,a={x:this._copyOffset*this.options.copy.offsetX,y:this._copyOffset*this.options.copy.offsetY},this.deselect(),i=0;i0)for(n=r.shapes[0],s=n.bounds(se),o=1;o").append(this.element),this._popup=this.container.kendoPopup({}).getKendoPopup()},appendTools:function(){var t,e;for(t=0;t"),this._toolBar=this.element.kendoToolBar({click:N(this.click,this),resizable:!1}).getKendoToolBar(),this.element.css("border","none")},createTools:function(){for(var t=0;t').attr(kendo.attr("uid"),this.model.uid),e="",this.options.template?(e+=this._renderTemplate(),this.fields=[]):e+=this._renderFields(),e+=this._renderButtons(),this.wrapper.append(t('
').append(e)),this.window=new kendo.ui.Window(this.wrapper.appendTo(this.element),this.options.window),this.window.bind("close",function(t){t.userTriggered&&(t.sender.element.focus(),i._cancelClick(t))}),this._attachButtonEvents()},_renderTemplate:function(){var t=this.options.template;return"string"==typeof t&&(t=window.unescape(t)),t=kendo.template(t)(this.model)},_renderFields:function(){var t,e,i="";for(t=0;t
",this._isEditable(e.field)&&(i+="
');return i},_renderButtons:function(){var t='
';return t+=this._createButton("update"),t+=this._createButton("cancel"),t+="
"},_createButton:function(t){return kendo.template(pe)(v[t])},_attachButtonEvents:function(){this._cancelClickHandler=N(this._cancelClick,this),this.window.element.on(Mt+Ct,"a.k-diagram-cancel",this._cancelClickHandler),this._updateClickHandler=N(this._updateClick,this),this.window.element.on(Mt+Ct,"a.k-diagram-update",this._updateClickHandler)},_updateClick:function(t){t.preventDefault(),this.trigger("update")},_cancelClick:function(t){t.preventDefault(),this.trigger("cancel")},open:function(){this.window.center().open()},close:function(){this.window.bind("deactivate",N(this.destroy,this)).close()},destroy:function(){this.window.close().destroy(),this.window.element.off(Mt+Ct,"a.k-diagram-cancel",this._cancelClickHandler),this.window.element.off(Mt+Ct,"a.k-diagram-update",this._updateClickHandler),this._cancelClickHandler=null,this._editUpdateClickHandler=null,this.window=null,k.fn.destroy.call(this)}}),c.fn=c.prototype={onActivate:function(e){var i=t.Deferred();return this.callbacks.push({callback:e,deferred:i}),i},activate:function(){var t,e,i=this.callbacks;for(e=0;e=0;e--)for(t=0;t1||t[1].length>1},getSectors:function(t){var e,i,n=this.ROOT_SIZE,o=t.bottomRight(),s=xt.floor(o.x/n),r=xt.floor(o.y/n),a=[[],[]];for(e=xt.floor(t.x/n);e<=s;e++)a[0].push(e);for(i=xt.floor(t.y/n);i<=r;i++)a[1].push(i);return a},hitTestRect:function(t,e){var i,n,o,s,r,a=this.getSectors(t);if(this.root.hitTestRect(t,e))return!0;for(i=0;i