From fa138ea6e1ddcc4bcb748834051bccdf5f4dbc08 Mon Sep 17 00:00:00 2001 From: Roman Bruckner Date: Tue, 8 May 2018 14:07:45 +0800 Subject: [PATCH] Release v2.1.2 --- CHANGELOG | 8 ++++++-- dist/geometry.js | 2 +- dist/geometry.min.js | 2 +- dist/joint.core.css | 2 +- dist/joint.core.js | 12 +++++++++--- dist/joint.core.min.css | 2 +- dist/joint.core.min.js | 6 +++--- dist/joint.css | 2 +- dist/joint.d.ts | 2 +- dist/joint.js | 12 +++++++++--- dist/joint.layout.DirectedGraph.js | 2 +- dist/joint.layout.DirectedGraph.min.js | 2 +- dist/joint.min.css | 2 +- dist/joint.min.js | 6 +++--- dist/joint.nowrap.js | 12 +++++++++--- dist/joint.nowrap.min.js | 6 +++--- dist/joint.shapes.chess.js | 2 +- dist/joint.shapes.chess.min.js | 2 +- dist/joint.shapes.devs.js | 2 +- dist/joint.shapes.devs.min.js | 2 +- dist/joint.shapes.erd.js | 2 +- dist/joint.shapes.erd.min.js | 2 +- dist/joint.shapes.fsa.js | 2 +- dist/joint.shapes.fsa.min.js | 2 +- dist/joint.shapes.logic.js | 2 +- dist/joint.shapes.logic.min.js | 2 +- dist/joint.shapes.org.js | 2 +- dist/joint.shapes.org.min.js | 2 +- dist/joint.shapes.pn.js | 2 +- dist/joint.shapes.pn.min.js | 2 +- dist/joint.shapes.uml.js | 2 +- dist/joint.shapes.uml.min.js | 2 +- dist/vectorizer.js | 2 +- dist/vectorizer.min.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 36 files changed, 71 insertions(+), 49 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 35c6dc482..8163687c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ +8-5-2018 (v2.1.2) + * dia.CellView - fix magnet lookup based on the port property + * docs - fix broken links + 7-5-2018 (v2.1.1) - * layout.PortLabel: fix manual position - * anchors: prevent exception when reference node not in the DOM + * layout.PortLabel - fix manual position + * anchors - prevent exception when reference node not in the DOM 27-4-2018 (v2.1.0) * update Tutorials diff --git a/dist/geometry.js b/dist/geometry.js index aba08ed30..458f2e47b 100644 --- a/dist/geometry.js +++ b/dist/geometry.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/geometry.min.js b/dist/geometry.min.js index 4a8cf74d5..f1c81288a 100644 --- a/dist/geometry.min.js +++ b/dist/geometry.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.core.css b/dist/joint.core.css index bfe8ff910..38a34d1be 100644 --- a/dist/joint.core.css +++ b/dist/joint.core.css @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.core.js b/dist/joint.core.js index 868955013..6c4f1089e 100644 --- a/dist/joint.core.js +++ b/dist/joint.core.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -7745,7 +7745,7 @@ V = Vectorizer = (function() { var joint = { - version: '2.1.1', + version: '2.1.2', config: { // The class name prefix config is for advanced use only. @@ -12557,7 +12557,13 @@ joint.dia.CellView = joint.mvc.View.extend({ if (port != null && this.model.hasPort(port)) { magnet = this.findPortNode(port, selector) || root; } else { - magnet = this.findBySelector(selector || end.selector, root, this.selectors)[0]; + if (!selector) selector = end.selector; + if (!selector && port != null) { + // link end has only `id` and `port` property referencing + // a port created via the `port` attribute (not API). + selector = '[port="' + port + '"]'; + } + magnet = this.findBySelector(selector, root, this.selectors)[0]; } return magnet; diff --git a/dist/joint.core.min.css b/dist/joint.core.min.css index 324ac3be7..c0ab06826 100644 --- a/dist/joint.core.min.css +++ b/dist/joint.core.min.css @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.core.min.js b/dist/joint.core.min.js index 6e251c233..e6a403f9c 100644 --- a/dist/joint.core.min.js +++ b/dist/joint.core.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -47,8 +47,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. var g=function(){function a(a,b){return b.unshift(null),new(Function.prototype.bind.apply(a,b))}function b(a){var b,c,d=[];for(c=arguments.length,b=1;b=1)return[new q(b,c,d,e),new q(e,e,e,e)];var f=this.getSkeletonPoints(a),g=f.startControlPoint1,h=f.startControlPoint2,i=f.divider,j=f.dividerControlPoint1,k=f.dividerControlPoint2;return[new q(b,g,h,i),new q(i,j,k,e)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.controlPoint1.x===a.controlPoint1.x&&this.controlPoint1.y===a.controlPoint1.y&&this.controlPoint2.x===a.controlPoint2.x&&this.controlPoint2.y===a.controlPoint2.y&&this.end.x===a.end.x&&this.end.y===a.end.y},getSkeletonPoints:function(a){var b=this.start,c=this.controlPoint1,d=this.controlPoint2,e=this.end;if(a<=0)return{startControlPoint1:b.clone(),startControlPoint2:b.clone(),divider:b.clone(),dividerControlPoint1:c.clone(),dividerControlPoint2:d.clone()};if(a>=1)return{startControlPoint1:c.clone(),startControlPoint2:d.clone(),divider:e.clone(),dividerControlPoint1:e.clone(),dividerControlPoint2:e.clone()};var f=new s(b,c).pointAt(a),g=new s(c,d).pointAt(a),h=new s(d,e).pointAt(a),i=new s(f,g).pointAt(a),j=new s(g,h).pointAt(a),k=new s(i,j).pointAt(a),l={startControlPoint1:f,startControlPoint2:i,divider:k,dividerControlPoint1:j,dividerControlPoint2:h};return l},getSubdivisions:function(a){a=a||{};var b=void 0===a.precision?this.PRECISION:a.precision,c=[new q(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(0===b)return c;for(var d=this.endpointDistance(),e=p(10,-b),f=0;;){f+=1;for(var g=[],h=c.length,i=0;i1&&r=1)return this.end.clone();var c=this.tAt(a,b);return this.pointAtT(c)},pointAtLength:function(a,b){var c=this.tAtLength(a,b);return this.pointAtT(c)},pointAtT:function(a){return a<=0?this.start.clone():a>=1?this.end.clone():this.getSkeletonPoints(a).divider},PRECISION:3,scale:function(a,b,c){return this.start.scale(a,b,c),this.controlPoint1.scale(a,b,c),this.controlPoint2.scale(a,b,c),this.end.scale(a,b,c),this},tangentAt:function(a,b){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var c=this.tAt(a,b);return this.tangentAtT(c)},tangentAtLength:function(a,b){if(!this.isDifferentiable())return null;var c=this.tAtLength(a,b);return this.tangentAtT(c)},tangentAtT:function(a){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var b=this.getSkeletonPoints(a),c=b.startControlPoint2,d=b.dividerControlPoint1,e=b.divider,f=new s(c,d);return f.translate(e.x-c.x,e.y-c.y),f},tAt:function(a,b){if(a<=0)return 0;if(a>=1)return 1;b=b||{};var c=void 0===b.precision?this.PRECISION:b.precision,d=void 0===b.subdivisions?this.getSubdivisions({precision:c}):b.subdivisions,e={precision:c,subdivisions:d},f=this.length(e),g=f*a;return this.tAtLength(g,e)},tAtLength:function(a,b){var c=!0;a<0&&(c=!1,a=-a),b=b||{};for(var d,e,f,g,h,i=void 0===b.precision?this.PRECISION:b.precision,j=void 0===b.subdivisions?this.getSubdivisions({precision:i}):b.subdivisions,k={precision:i,subdivisions:j},l=0,m=j.length,n=1/m,o=c?0:m-1;c?o=0;c?o++:o--){var q=j[o],r=q.endpointDistance();if(a<=l+r){d=q,e=o*n,f=(o+1)*n,g=c?a-l:r+l-a,h=c?r+l-a:a-l;break}l+=r}if(!d)return c?1:0;for(var s=this.length(k),t=p(10,-i);;){var u;if(u=0!==s?g/s:0,ui.x+g/2,m=ei.x?f-d:f+d,c=g*g/(e-j)-g*g*(f-k)*(b-k)/(h*h*(e-j))+j):(c=f>i.y?e+d:e-d,b=h*h/(f-k)-h*h*(e-j)*(c-j)/(g*g*(f-k))+k),new u(c,b).theta(a)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLine:function(a){var b=[],c=a.start,d=a.end,e=this.a,f=this.b,g=a.vector(),i=c.difference(new u(this)),j=new u(g.x/(e*e),g.y/(f*f)),k=new u(i.x/(e*e),i.y/(f*f)),l=g.dot(j),m=g.dot(k),n=i.dot(k)-1,o=m*m-l*n;if(o<0)return null;if(o>0){var p=h(o),q=(-m-p)/l,r=(-m+p)/l;if((q<0||10){if(f>d||g>d)return null}else if(f=1?c.clone():b.lerp(c,a)},pointAtLength:function(a){var b=this.start,c=this.end,d=!0;a<0&&(d=!1,a=-a);var e=this.length();return a>=e?d?c.clone():b.clone():this.pointAt((d?a:e-a)/e)},pointOffset:function(a){a=new c.Point(a);var b=this.start,d=this.end,e=(d.x-b.x)*(a.y-b.y)-(d.y-b.y)*(a.x-b.x);return e/this.length()},rotate:function(a,b){return this.start.rotate(a,b),this.end.rotate(a,b),this},round:function(a){var b=p(10,a||0);return this.start.x=l(this.start.x*b)/b,this.start.y=l(this.start.y*b)/b,this.end.x=l(this.end.x*b)/b,this.end.y=l(this.end.y*b)/b,this},scale:function(a,b,c){return this.start.scale(a,b,c),this.end.scale(a,b,c),this},setLength:function(a){var b=this.length();if(!b)return this;var c=a/b;return this.scale(c,c,this.start)},squaredLength:function(){var a=this.start.x,b=this.start.y,c=this.end.x,d=this.end.y;return(a-=c)*a+(b-=d)*b},tangentAt:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAt(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},tangentAtLength:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAtLength(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},translate:function(a,b){return this.start.translate(a,b),this.end.translate(a,b),this},vector:function(){return new u(this.end.x-this.start.x,this.end.y-this.start.y)},toString:function(){return this.start.toString()+" "+this.end.toString()}},s.prototype.intersection=s.prototype.intersect;var t=c.Path=function(a){if(!(this instanceof t))return new t(a);if("string"==typeof a)return new t.parse(a);this.segments=[];var b,c;if(a){if(Array.isArray(a)&&0!==a.length)if(c=a.length,a[0].isSegment)for(b=0;b=c||a<0)throw new Error("Index out of range.");return b[a]},getSegmentSubdivisions:function(a){var b=this.segments,c=b.length;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=[],f=0;fd||a<0)throw new Error("Index out of range.");var e,f=null,g=null;if(0!==d&&(a>=1?(f=c[a-1],g=f.nextSegment):g=c[0]),Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");for(var h=b.length,i=0;i=d?(e=d-1,f=1):f<0?f=0:f>1&&(f=1),b=b||{};for(var g,h=void 0===b.precision?this.PRECISION:b.precision,i=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:h}):b.segmentSubdivisions,j=0,k=0;k=1)return this.end.clone();b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.pointAtLength(i,g)},pointAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;if(0===a)return this.start.clone();var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isVisible){if(a<=i+m)return k.pointAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f)return e?f.end:f.start;var n=c[d-1];return n.end.clone()},pointAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].pointAtT(0);if(d>=c)return b[c-1].pointAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].pointAtT(e)},prepareSegment:function(a,b,c){a.previousSegment=b,a.nextSegment=c,b&&(b.nextSegment=a),c&&(c.previousSegment=a);var d=a;return a.isSubpathStart&&(a.subpathStartSegment=a,d=c),d&&this.updateSubpathStartSegment(d),a},PRECISION:3,removeSegment:function(a){var b=this.segments,c=b.length;if(0===c)throw new Error("Path has no segments.");if(a<0&&(a=c+a),a>=c||a<0)throw new Error("Index out of range.");var d=b.splice(a,1)[0],e=d.previousSegment,f=d.nextSegment;e&&(e.nextSegment=f),f&&(f.previousSegment=e),d.isSubpathStart&&f&&this.updateSubpathStartSegment(f)},replaceSegment:function(a,b){var c=this.segments,d=c.length;if(0===d)throw new Error("Path has no segments.");if(a<0&&(a=d+a),a>=d||a<0)throw new Error("Index out of range.");var e,f=c[a],g=f.previousSegment,h=f.nextSegment,i=f.isSubpathStart;if(Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");c.splice(a,1);for(var j=b.length,k=0;k1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.segmentIndexAtLength(i,g)},toPoints:function(a){var b=this.segments,c=b.length;if(0===c)return null;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=void 0===a.segmentSubdivisions?this.getSegmentSubdivisions({precision:d}):a.segmentSubdivisions,f=[],g=[],h=0;h0){var k=j.map(function(a){return a.start});Array.prototype.push.apply(g,k)}else g.push(i.start)}else g.length>0&&(g.push(b[h-1].end),f.push(g),g=[])}return g.length>0&&(g.push(this.end),f.push(g)),f},toPolylines:function(a){var b=[],c=this.toPoints(a);if(!c)return null;for(var d=0,e=c.length;d=0;e?j++:j--){var k=c[j],l=g[j],m=k.length({precision:f,subdivisions:l});if(k.isVisible){if(a<=i+m)return j;h=j}i+=m}return h},tangentAt:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;a<0&&(a=0),a>1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.tangentAtLength(i,g)},tangentAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isDifferentiable()){if(a<=i+m)return k.tangentAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f){var n=e?1:0;return f.tangentAtT(n)}return null},tangentAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].tangentAtT(0);if(d>=c)return b[c-1].tangentAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].tangentAtT(e)},translate:function(a,b){for(var c=this.segments,d=c.length,e=0;e=0;c--){var d=a[c];if(d.isVisible)return d.end}return a[b-1].end}});var u=c.Point=function(a,b){if(!(this instanceof u))return new u(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseFloat(c[0]),b=parseFloat(c[1])}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};u.fromPolar=function(a,b,c){c=c&&new u(c)||new u(0,0);var d=e(a*f(b)),h=e(a*g(b)),i=x(z(b));return i<90?h=-h:i<180?(d=-d,h=-h):i<270&&(d=-d),new u(c.x+d,c.y+h)},u.random=function(a,b,c,d){return new u(m(o()*(b-a+1)+a),m(o()*(d-c+1)+c))},u.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=i(j(this.x,a.x),a.x+a.width),this.y=i(j(this.y,a.y),a.y+a.height),this)},bearing:function(a){return new s(this,a).bearing()},changeInAngle:function(a,b,c){return this.clone().offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return new u(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),new u(this.x-(a||0),this.y-(b||0))},distance:function(a){return new s(this,a).length()},squaredDistance:function(a){return new s(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return h(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return e(a.x-this.x)+e(a.y-this.y)},move:function(a,b){var c=A(new u(a).theta(this)),d=this.offset(f(c)*b,-g(c)*b);return d},normalize:function(a){var b=(a||1)/this.magnitude();return this.scale(b,b)},offset:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),this.x+=a||0,this.y+=b||0,this},reflection:function(a){return new u(a).move(this,this.distance(a))},rotate:function(a,b){a=a||new c.Point(0,0),b=A(x(-b));var d=f(b),e=g(b),h=d*(this.x-a.x)-e*(this.y-a.y)+a.x,i=e*(this.x-a.x)+d*(this.y-a.y)+a.y;return this.x=h,this.y=i,this},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this},scale:function(a,b,c){return c=c&&new u(c)||new u(0,0),this.x=c.x+a*(this.x-c.x),this.y=c.y+b*(this.y-c.y),this},snapToGrid:function(a,b){return this.x=y(this.x,a),this.y=y(this.y,b||a),this},theta:function(a){a=new u(a);var b=-(a.y-this.y),c=a.x-this.x,d=k(b,c);return d<0&&(d=2*n+d),180*d/n},angleBetween:function(a,b){var c=this.equals(a)||this.equals(b)?NaN:this.theta(b)-this.theta(a);return c<0&&(c+=360),c},vectorAngle:function(a){var b=new u(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&new u(a)||new u(0,0);var b=this.x,c=this.y;return this.x=h((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=A(a.theta(new u(b,c))),this},toString:function(){return this.x+"@"+this.y},update:function(a,b){return this.x=a||0,this.y=b||0,this},dot:function(a){return a?this.x*a.x+this.y*a.y:NaN},cross:function(a,b){return a&&b?(b.x-this.x)*(a.y-this.y)-(b.y-this.y)*(a.x-this.x):NaN},lerp:function(a,b){var c=this.x,d=this.y;return new u((1-b)*c+b*a.x,(1-b)*d+b*a.y)}},u.prototype.translate=u.prototype.offset;var v=c.Rect=function(a,b,c,d){return this instanceof v?(Object(a)===a&&(b=a.y,c=a.width,d=a.height,a=a.x),this.x=void 0===a?0:a,this.y=void 0===b?0:b,this.width=void 0===c?0:c,void(this.height=void 0===d?0:d)):new v(a,b,c,d)};v.fromEllipse=function(a){return a=new r(a),new v(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},v.prototype={bbox:function(a){if(!a)return this.clone();var b=A(a||0),c=e(g(b)),d=e(f(b)),h=this.width*d+this.height*c,i=this.width*c+this.height*d;return new v(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return new u(this.x,this.y+this.height)},bottomLine:function(){return new s(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new u(this.x+this.width/2,this.y+this.height); },center:function(){return new u(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new v(this)},containsPoint:function(a){return a=new u(a),a.x>=this.x&&a.x<=this.x+this.width&&a.y>=this.y&&a.y<=this.y+this.height},containsRect:function(a){var b=new v(this).normalize(),c=new v(a).normalize(),d=b.width,e=b.height,f=c.width,g=c.height;if(!(d&&e&&f&&g))return!1;var h=b.x,i=b.y,j=c.x,k=c.y;return f+=j,d+=h,g+=k,e+=i,h<=j&&f<=d&&i<=k&&g<=e},corner:function(){return new u(this.x+this.width,this.y+this.height)},equals:function(a){var b=new v(this).normalize(),c=new v(a).normalize();return b.x===c.x&&b.y===c.y&&b.width===c.width&&b.height===c.height},intersect:function(a){var b=this.origin(),c=this.corner(),d=a.origin(),e=a.corner();if(e.x<=b.x||e.y<=b.y||d.x>=c.x||d.y>=c.y)return null;var f=j(b.x,d.x),g=j(b.y,d.y);return new v(f,g,i(c.x,e.x)-f,i(c.y,e.y)-g)},intersectionWithLine:function(a){var b,c,d=this,e=[d.topLine(),d.rightLine(),d.bottomLine(),d.leftLine()],f=[],g=[],h=e.length;for(c=0;c0?f:null},intersectionWithLineFromCenterToPoint:function(a,b){a=new u(a);var c,d=new u(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],f=new s(d,a),g=e.length-1;g>=0;--g){var h=e[g].intersection(f);if(null!==h){c=h;break}}return c&&b&&c.rotate(d,-b),c},leftLine:function(){return new s(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new u(this.x,this.y+this.height/2)},moveAndExpand:function(a){return this.x+=a.x||0,this.y+=a.y||0,this.width+=a.width||0,this.height+=a.height||0,this},offset:function(a,b){return u.prototype.offset.call(this,a,b)},inflate:function(a,b){return void 0===a&&(a=0),void 0===b&&(b=a),this.x-=a,this.y-=b,this.width+=2*a,this.height+=2*b,this},normalize:function(){var a=this.x,b=this.y,c=this.width,d=this.height;return this.width<0&&(a=this.x+this.width,c=-this.width),this.height<0&&(b=this.y+this.height,d=-this.height),this.x=a,this.y=b,this.width=c,this.height=d,this},origin:function(){return new u(this.x,this.y)},pointNearestToPoint:function(a){if(a=new u(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return new u(this.x+this.width,a.y);case"left":return new u(this.x,a.y);case"bottom":return new u(a.x,this.y+this.height);case"top":return new u(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return new s(this.topRight(),this.bottomRight())},rightMiddle:function(){return new u(this.x+this.width,this.y+this.height/2)},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this.width=l(this.width*b)/b,this.height=l(this.height*b)/b,this},scale:function(a,b,c){return c=this.origin().scale(a,b,c),this.x=c.x,this.y=c.y,this.width*=a,this.height*=b,this},maxRectScaleToFit:function(a,b){a=new v(a),b||(b=a.center());var c,d,e,f,g,h,j,k,l=b.x,m=b.y;c=d=e=f=g=h=j=k=1/0;var n=a.topLeft();n.xl&&(d=(this.x+this.width-l)/(o.x-l)),o.y>m&&(h=(this.y+this.height-m)/(o.y-m));var p=a.topRight();p.x>l&&(e=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:i(c,d,e,f),sy:i(g,h,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return i(c.sx,c.sy)},sideNearestToPoint:function(a){a=new u(a);var b=a.x-this.x,c=this.x+this.width-a.x,d=a.y-this.y,e=this.y+this.height-a.y,f=b,g="left";return cb&&(b=i),jd&&(d=j)}return new v(a,c,b-a,d-c)},clone:function(){var a=this.points,b=a.length;if(0===b)return new w;for(var c=[],d=0;df.x&&(f=c[a]);var g=[];for(a=0;a2){var j=g[g.length-1];g.unshift(j)}for(var k,l,m,n,o,p,q={},r=[];0!==g.length;)if(k=g.pop(),l=k[0],!q.hasOwnProperty(k[0]+"@@"+k[1]))for(var s=!1;!s;)if(r.length<2)r.push(k),s=!0;else{m=r.pop(),n=m[0],o=r.pop(),p=o[0];var t=p.cross(n,l);if(t<0)r.push(o),r.push(m),r.push(k),s=!0;else if(0===t){var u=1e-10,v=n.angleBetween(p,l);e(v-180)2&&r.pop();var x,y=-1;for(b=r.length,a=0;a0){var B=r.slice(y),C=r.slice(0,y);A=B.concat(C)}else A=r;var D=[];for(b=A.length,a=0;a=1)return b[c-1].clone();var d=this.length(),e=d*a;return this.pointAtLength(e)},pointAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return b[0].clone();var d=!0;a<0&&(d=!1,a=-a);for(var e=0,f=c-1,g=d?0:f-1;d?g=0;d?g++:g--){var h=b[g],i=b[g+1],j=new s(h,i),k=h.distance(i);if(a<=e+k)return j.pointAtLength((d?1:-1)*(a-e));e+=k}var l=d?b[c-1]:b[0];return l.clone()},scale:function(a,b,c){var d=this.points,e=d.length;if(0===e)return this;for(var f=0;f1&&(a=1);var d=this.length(),e=d*a;return this.tangentAtLength(e)},tangentAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return null;var d=!0;a<0&&(d=!1,a=-a);for(var e,f=0,g=c-1,h=d?0:g-1;d?h=0;d?h++:h--){var i=b[h],j=b[h+1],k=new s(i,j),l=i.distance(j);if(k.isDifferentiable()){if(a<=f+l)return k.tangentAtLength((d?1:-1)*(a-f));e=k}f+=l}if(e){var m=d?1:0;return e.tangentAt(m)}return null},intersectionWithLine:function(a){for(var b=new s(a),c=[],d=this.points,e=0,f=d.length-1;e0?c:null},translate:function(a,b){var c=this.points,d=c.length;if(0===d)return this;for(var e=0;e=1?b:b*a},pointAtT:function(a){if(this.pointAt)return this.pointAt(a);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,subpathStartSegment:null,tangentAtT:function(a){if(this.tangentAt)return this.tangentAt(a);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},length:function(){throw new Error("Declaration missing for virtual function.")},pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},scale:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},toString:function(){throw new Error("Declaration missing for virtual function.")}},C=function(){for(var b=[],c=arguments.length,d=0;d0)throw new Error("Closepath constructor expects no arguments.");return this},J={clone:function(){return new I},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},scale:function(){return this},translate:function(){return this},type:"Z",serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end}};Object.defineProperty(J,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(J,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),I.prototype=b(B,s.prototype,J);var K=t.segmentTypes={L:C,C:E,M:G,Z:I,z:I};return t.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(K).join("")+",.]*$"),t.isDataSupported=function(a){return"string"==typeof a&&this.regexSupportedData.test(a)},c}(); var V,Vectorizer;V=Vectorizer=function(){"use strict";function a(a,b){a||(a={});var c=q("textPath"),d=a.d;if(d&&void 0===a["xlink:href"]){var e=q("path").attr("d",d).appendTo(b.defs());c.attr("xlink:href","#"+e.id)}return q.isObject(a)&&c.attr(a),c.node}function b(a,b,c){c||(c={});for(var d=c.includeAnnotationIndices,e=c.eol,f=c.lineHeight,g=c.baseSize,h=0,i={},j=b.length-1,k=0;k<=j;k++){var l=b[k],m=null;if(q.isObject(l)){var n=l.attrs,o=q("tspan",n),p=o.node,r=l.t;e&&k===j&&(r+=e),p.textContent=r;var s=n.class;s&&o.addClass(s),d&&o.attr("annotations",l.annotations),m=parseFloat(n["font-size"]),void 0===m&&(m=g),m&&m>h&&(h=m)}else e&&k===j&&(l+=e),p=document.createTextNode(l||" "),g&&g>h&&(h=g);a.appendChild(p)}return h&&(i.maxFontSize=h),f?i.lineHeight=f:h&&(i.lineHeight=1.2*h),i}function c(a,b){var c=parseFloat(a);return s.test(a)?c*b:c}function d(a,b,d,e){if(!Array.isArray(b))return 0;var f=b.length;if(!f)return 0;for(var g=b[0],h=c(g.maxFontSize,d)||d,i=0,j=c(e,d),k=1;k1){var e,g,h=[];for(e=0,g=d.childNodes.length;e0&&D.setAttribute("dy",B),(y>0||g)&&D.setAttribute("x",j),D.className.baseVal=C,r.appendChild(D),v+=E.length+1}if(i)if(l)B=d(h,x,p,o);else if("top"===h)B="0.8em";else{var I;switch(z>0?(I=parseFloat(o)||1,I*=z,s.test(o)||(I/=p)):I=0,h){case"middle":B=.3-I/2+"em";break;case"bottom":B=-I-.3+"em"}}else 0===h?B="0em":h?B=h:(B=0,null===this.attr("y")&&this.attr("y",u||"0.8em"));return r.firstChild.setAttribute("dy",B),this.append(r),this},r.removeAttr=function(a){var b=q.qualifyAttr(a),c=this.node;return b.ns?c.hasAttributeNS(b.ns,b.local)&&c.removeAttributeNS(b.ns,b.local):c.hasAttribute(a)&&c.removeAttribute(a),this},r.attr=function(a,b){if(q.isUndefined(a)){for(var c=this.node.attributes,d={},e=0;e1&&k.push(k[0]),new g.Polyline(k);case"PATH":return l=this.attr("d"),g.Path.isDataSupported(l)||(l=q.normalizePathData(l)),new g.Path(l);case"LINE":return x1=parseFloat(this.attr("x1"))||0,y1=parseFloat(this.attr("y1"))||0,x2=parseFloat(this.attr("x2"))||0,y2=parseFloat(this.attr("y2"))||0,new g.Line({x:x1,y:y1},{x:x2,y:y2})}return this.getBBox()},r.findIntersection=function(a,b){var c=this.svg().node;b=b||c;var d=this.getBBox({target:b}),e=d.center();if(d.intersectionWithLineFromCenterToPoint(a)){var f,h=this.tagName();if("RECT"===h){var i=new g.Rect(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),j=this.getTransformToElement(b),k=q.decomposeMatrix(j),l=c.createSVGTransform();l.setRotate(-k.rotation,e.x,e.y);var m=q.transformRect(i,l.matrix.multiply(j));f=new g.Rect(m).intersectionWithLineFromCenterToPoint(a,k.rotation)}else if("PATH"===h||"POLYGON"===h||"POLYLINE"===h||"CIRCLE"===h||"ELLIPSE"===h){var n,o,p,r,s,t,u="PATH"===h?this:this.convertToPath(),v=u.sample(),w=1/0,x=[];for(n=0;n'+(a||"")+"",c=q.parseXML(b,{async:!1});return c.documentElement},q.idCounter=0,q.uniqueId=function(){return"v-"+ ++q.idCounter},q.toNode=function(a){return q.isV(a)?a.node:a.nodeName&&a||a[0]},q.ensureId=function(a){return a=q.toNode(a),a.id||(a.id=q.uniqueId())},q.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},q.isUndefined=function(a){return"undefined"==typeof a},q.isString=function(a){return"string"==typeof a},q.isObject=function(a){return a&&"object"==typeof a},q.isArray=Array.isArray,q.parseXML=function(a,b){b=b||{};var c;try{var d=new DOMParser;q.isUndefined(b.async)||(d.async=b.async),c=d.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},q.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var b=a.split(":");return{ns:f[b[0]],local:b[1]}}return{ns:null,local:a}},q.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,q.transformSeparatorRegex=/[ ,]+/,q.transformationListRegex=/^(\w+)\((.*)\)/,q.transformStringToMatrix=function(a){var b=q.createSVGMatrix(),c=a&&a.match(q.transformRegex);if(!c)return b;for(var d=0,e=c.length;d=0){var f=q.transformStringToMatrix(a),g=q.decomposeMatrix(f);b=[g.translateX,g.translateY],d=[g.scaleX,g.scaleY],c=[g.rotation];var h=[];0===b[0]&&0===b[0]||h.push("translate("+b+")"),1===d[0]&&1===d[1]||h.push("scale("+d+")"),0!==c[0]&&h.push("rotate("+c+")"),a=h.join(" ")}else{var i=a.match(/translate\((.*?)\)/);i&&(b=i[1].split(e));var j=a.match(/rotate\((.*?)\)/);j&&(c=j[1].split(e));var k=a.match(/scale\((.*?)\)/);k&&(d=k[1].split(e))}}var l=d&&d[0]?parseFloat(d[0]):1;return{value:a,translate:{tx:b&&b[0]?parseInt(b[0],10):0,ty:b&&b[1]?parseInt(b[1],10):0},rotate:{angle:c&&c[0]?parseInt(c[0],10):0,cx:c&&c[1]?parseInt(c[1],10):void 0,cy:c&&c[2]?parseInt(c[2],10):void 0},scale:{sx:l,sy:d&&d[1]?parseFloat(d[1]):l}}},q.deltaTransformPoint=function(a,b){var c=b.x*a.a+b.y*a.c+0,d=b.x*a.b+b.y*a.d+0;return{x:c,y:d}},q.decomposeMatrix=function(a){var b=q.deltaTransformPoint(a,{x:0,y:1}),c=q.deltaTransformPoint(a,{x:1,y:0}),d=180/j*k(b.y,b.x)-90,e=180/j*k(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:l(a.a*a.a+a.b*a.b),scaleY:l(a.c*a.c+a.d*a.d),skewX:d,skewY:e,rotation:d}},q.matrixToScale=function(a){var b,c,d,e;return a?(b=q.isUndefined(a.a)?1:a.a,e=q.isUndefined(a.d)?1:a.d,c=a.b,d=a.c):b=e=1,{sx:c?l(b*b+c*c):b,sy:d?l(d*d+e*e):e}},q.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=q.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(k(b.y,b.x))-90)}},q.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},q.isV=function(a){return a instanceof q},q.isVElement=q.isV;var t=q("svg").node;return q.createSVGMatrix=function(a){var b=t.createSVGMatrix();for(var c in a)b[c]=a[c];return b},q.createSVGTransform=function(a){return q.isUndefined(a)?t.createSVGTransform():(a instanceof SVGMatrix||(a=q.createSVGMatrix(a)),t.createSVGTransformFromMatrix(a))},q.createSVGPoint=function(a,b){var c=t.createSVGPoint();return c.x=a,c.y=b,c},q.transformRect=function(a,b){var c=t.createSVGPoint();c.x=a.x,c.y=a.y;var d=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y;var e=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var f=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var h=c.matrixTransform(b),i=m(d.x,e.x,f.x,h.x),j=n(d.x,e.x,f.x,h.x),k=m(d.y,e.y,f.y,h.y),l=n(d.y,e.y,f.y,h.y);return new g.Rect(i,k,j-i,l-k)},q.transformPoint=function(a,b){return new g.Point(q.createSVGPoint(a.x,a.y).matrixTransform(b))},q.transformLine=function(a,b){return new g.Line(q.transformPoint(a.start,b),q.transformPoint(a.end,b))},q.transformPolyline=function(a,b){var c=a instanceof g.Polyline?a.points:a;q.isArray(c)||(c=[]);for(var d=[],e=0,f=c.length;e=e?f?"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"M0,"+f+"A"+f+","+f+" 0 1,0 0,"+-f+"A"+f+","+f+" 0 1,0 0,"+f+"Z":"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"Z":f?"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L"+f*q+","+f*r+"A"+f+","+f+" 0 "+l+",0 "+f*m+","+f*n+"Z":"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L0,0Z"},q.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?q.isObject(a[c])&&q.isObject(b[c])?a[c]=q.mergeAttrs(a[c],b[c]):q.isObject(a[c])?a[c]=q.mergeAttrs(a[c],q.styleToObject(b[c])):q.isObject(b[c])?a[c]=q.mergeAttrs(q.styleToObject(a[c]),b[c]):a[c]=q.mergeAttrs(q.styleToObject(a[c]),q.styleToObject(b[c])):a[c]=b[c];return a},q.annotateString=function(a,b,c){b=b||[],c=c||{};for(var d,e,f,g=c.offset||0,h=[],i=[],j=0;j=m&&j=a.start&&ba.start&&c<=a.end||a.start>=b&&a.end=b?a.end+=c:a.start>=b&&(a.start+=c,a.end+=c)}),a},q.convertLineToPathData=function(a){a=q(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},q.convertPolygonToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)+" Z"},q.convertPolylineToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)},q.svgPointsToPath=function(a){for(var b=0,c=a.length;b1&&(z=o(z),d*=z,e*=z);var A=d*d,B=e*e,C=(g==h?-1:1)*o(p((A*B-A*y*y-B*x*x)/(A*y*y+B*x*x))),D=C*d*y/e+(a+i)/2,E=C*-e*x/d+(c+q)/2,F=n(((c-E)/e).toFixed(9)),G=n(((q-E)/e).toFixed(9));F=aG&&(F-=2*j),(!h&&G)>F&&(G-=2*j)}var H=G-F;if(p(H)>t){var I=G,J=i,K=q;G=F+t*((h&&G)>F?1:-1),i=D+d*l(G),q=E+e*k(G),v=b(i,q,d,e,f,0,h,J,K,[G,I,D,E])}H=G-F;var L=l(F),M=k(F),N=l(G),O=k(G),P=m(H/4),Q=4/3*(d*P),R=4/3*(e*P),S=[a,c],T=[a+Q*M,c-R*L],U=[i+Q*O,q-R*N],V=[i,q];if(T[0]=2*S[0]-T[0],T[1]=2*S[1]-T[1],r)return[T,U,V].concat(v);v=[T,U,V].concat(v).join().split(",");for(var W=[],X=v.length,Y=0;Y2&&(c.push([d].concat(f.splice(0,2))),g="l",d="m"===d?"l":"L");f.length>=b[g]&&(c.push([d].concat(f.splice(0,b[g]))),b[g]););}),c}function d(a){if(Array.isArray(a)&&Array.isArray(a&&a[0])||(a=c(a)),!a||!a.length)return[["M",0,0]];for(var b,d=[],e=0,f=0,g=0,h=0,i=0,j=a.length,k=i;k7){a[b].shift();for(var c=a[b];c.length;)i[b]="A",a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),l=g.length}}for(var g=d(c),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=[],j="",k="",l=g.length,m=0;m0&&(k=i[m-1])),g[m]=e(g[m],h,k),"A"!==i[m]&&"C"===j&&(i[m]="C"),f(g,m);var n=g[m],o=n.length;h.x=n[o-2],h.y=n[o-1],h.bx=parseFloat(n[o-4])||h.x,h.by=parseFloat(n[o-3])||h.y}return g[0][0]&&"M"===g[0][0]||g.unshift(["M",0,0]),g}var f="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",g=new RegExp("([a-z])["+f+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+f+"]*,?["+f+"]*)+)","ig"),h=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+f+"]*,?["+f+"]*","ig"),i=Math,j=i.PI,k=i.sin,l=i.cos,m=i.tan,n=i.asin,o=i.sqrt,p=i.abs;return function(a){return e(a).join(",").split(",").join(" ")}}(),q.namespace=f,q}(); -var joint={version:"2.1.1",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},anchors:{},connectionPoints:{},connectionStrategies:{},linkTools:{},mvc:{views:{}},setTheme:function(a,b){b=b||{},joint.util.invoke(joint.mvc.views,"setTheme",a,b),joint.mvc.View.prototype.defaultTheme=a},env:{_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(a,b){return joint.env._tests[a]=b},test:function(a){var b=joint.env._tests[a];if(!b)throw new Error('Test not defined ("'+a+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var c=joint.env._results[a];if("undefined"!=typeof c)return c;try{c=b()}catch(a){c=!1}return joint.env._results[a]=c,c}},util:{hashCode:function(a){var b=0;if(0==a.length)return b;for(var c=0;c0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), -d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return b=null!=d&&this.model.hasPort(d)?this.findPortNode(d,e)||c:this.findBySelector(e||a.selector,c,this.selectors)[0]},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), +d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return null!=d&&this.model.hasPort(d)?b=this.findPortNode(d,e)||c:(e||(e=a.selector),e||null==d||(e='[port="'+d+'"]'),b=this.findBySelector(e,c,this.selectors)[0]),b},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){this.startBatch("fit-embeds",a),a.deep&&joint.util.invoke(b,"fitEmbeds",a);var c=this.graph.getCellsBBox(b),d=joint.util.normalizeSides(a.padding);c.moveAndExpand({x:-d.left,y:-d.top,width:d.right+d.left,height:d.bottom+d.top}),this.set({position:{x:c.x,y:c.y},size:{width:c.width,height:c.height}},a),this.stopBatch("fit-embeds")}return this},rotate:function(a,b,c,d){if(c){var e=this.getBBox().center(),f=this.get("size"),g=this.get("position");e.rotate(c,this.get("angle")-a);var h=e.x-f.width/2-g.x,i=e.y-f.height/2-g.y;this.startBatch("rotate",{angle:a,absolute:b,origin:c}),this.position(g.x+h,g.y+i,d),this.rotate(a,b,null,d),this.stopBatch("rotate")}else this.set("angle",b?a:(this.get("angle")+a)%360,d);return this},angle:function(){return g.normalizeAngle(this.get("angle")||0)},getBBox:function(a){if(a=a||{},a.deep&&this.graph){var b=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return b.push(this),this.graph.getCellsBBox(b)}var c=this.get("position"),d=this.get("size");return new g.Rect(c.x,c.y,d.width,d.height)}}),joint.dia.ElementView=joint.dia.CellView.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("element"),a.join(" ")},metrics:null,initialize:function(){joint.dia.CellView.prototype.initialize.apply(this,arguments);var a=this.model;this.listenTo(a,"change:position",this.translate),this.listenTo(a,"change:size",this.resize),this.listenTo(a,"change:angle",this.rotate),this.listenTo(a,"change:markup",this.render),this._initializePorts(),this.metrics={}},_initializePorts:function(){},update:function(a,b){this.metrics={},this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:new g.Rect(c.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.ElementView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.ElementView: ambiguous root selector.");c[d]=this.el,this.rotatableNode=V(c[this.rotatableSelector])||null,this.scalableNode=V(c[this.scalableSelector])||null,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=this.vel;b.append(V(a)),this.rotatableNode=b.findOne(".rotatable"),this.scalableNode=b.findOne(".scalable");var c=this.selectors={};c[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate(),this):(this.updateTransformation(),this)},resize:function(){return this.scalableNode?this.sgResize.apply(this,arguments):(this.model.attributes.angle&&this.rotate(),void this.update())},translate:function(){return this.rotatableNode?this.rgTranslate():void this.updateTransformation()},rotate:function(){return this.rotatableNode?this.rgRotate():void this.updateTransformation()},updateTransformation:function(){var a=this.getTranslateString(),b=this.getRotateString();b&&(a+=" "+b),this.vel.attr("transform",a)},getTranslateString:function(){var a=this.model.attributes.position;return"translate("+a.x+","+a.y+")"},getRotateString:function(){var a=this.model.attributes,b=a.angle;if(!b)return null;var c=a.size;return"rotate("+b+","+c.width/2+","+c.height/2+")"},getBBox:function(a){var b;if(a&&a.useModelGeometry){var c=this.model;b=c.getBBox().bbox(c.angle())}else b=this.getNodeBBox(this.el);return this.paper.localToPaperRect(b)},nodeCache:function(a){var b=V.ensureId(a),c=this.metrics[b];return c||(c=this.metrics[b]={}),c},getNodeData:function(a){var b=this.nodeCache(a);return b.data||(b.data={}),b.data},getNodeBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix(),e=this.getRootRotateMatrix();return V.transformRect(b,d.multiply(e).multiply(c))},getNodeBoundingRect:function(a){var b=this.nodeCache(a);return void 0===b.boundingRect&&(b.boundingRect=V(a).getBBox()),new g.Rect(b.boundingRect)},getNodeUnrotatedBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix();return V.transformRect(b,d.multiply(c))},getNodeShape:function(a){var b=this.nodeCache(a);return void 0===b.geometryShape&&(b.geometryShape=V(a).toGeometryShape()),b.geometryShape.clone()},getNodeMatrix:function(a){var b=this.nodeCache(a);if(void 0===b.magnetMatrix){var c=this.rotatableNode||this.el;b.magnetMatrix=V(a).getTransformToElement(c)}return V.createSVGMatrix(b.magnetMatrix)},getRootTranslateMatrix:function(){var a=this.model,b=a.position(),c=V.createSVGMatrix().translate(b.x,b.y);return c},getRootRotateMatrix:function(){var a=V.createSVGMatrix(),b=this.model,c=b.angle();if(c){var d=b.getBBox(),e=d.width/2,f=d.height/2;a=a.translate(e,f).rotate(c).translate(-e,-f)}return a},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(a,b,c){var d=this.model,e=d.get("angle")||0,f=d.get("size")||{width:1,height:1},g=this.scalableNode,h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=f.width/(i.width||1),k=f.height/(i.height||1);g.attr("transform","scale("+j+","+k+")");var l=this.rotatableNode,m=l&&l.attr("transform");if(m&&null!==m){l.attr("transform",m+" rotate("+-e+","+f.width/2+","+f.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},prepareEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front"),b.toFront({deep:!0,ui:!0});var e=d.get("cells").max("z").get("z"),f=d.getConnectedLinks(b,{deep:!0});joint.util.invoke(f,"set","z",e+1,{ui:!0}),b.stopBatch("to-front");var g=b.parent();g&&d.getCell(g).unembed(b,{ui:!0})},processEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.options,e=[];if(joint.util.isFunction(d.findParentBy)){var f=joint.util.toArray(d.findParentBy.call(c.model,this));e=f.filter(function(a){return a instanceof joint.dia.Cell&&this.model.id!==a.id&&!a.isEmbeddedIn(this.model)}.bind(this))}else e=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var g=null,h=a.candidateEmbedView,i=e.length-1;i>=0;i--){var j=e[i];if(h&&h.model.id==j.id){g=h;break}var k=j.findView(c);if(d.validateEmbedding.call(c,this,k)){g=k;break}}g&&g!=h&&(this.clearEmbedding(a),a.candidateEmbedView=g.highlight(null,{embedding:!0})),!g&&h&&this.clearEmbedding(a)},clearEmbedding:function(a){a||(a={});var b=a.candidateEmbedView;b&&(b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null)},finalizeEmbedding:function(a){a||(a={});var b=a.candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdblclick:function(a,b,c){joint.dia.CellView.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",a,b,c)},pointerclick:function(a,b,c){joint.dia.CellView.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",a,b,c)},contextmenu:function(a,b,c){joint.dia.CellView.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",a,b,c)},pointerdown:function(a,b,c){joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c),this.dragStart(a,b,c)},pointermove:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.drag(a,b,c);break;case"magnet":this.dragMagnet(a,b,c)}d.stopPropagation||(joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)),this.eventData(a,d)},pointerup:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.dragEnd(a,b,c);break;case"magnet":return void this.dragMagnetEnd(a,b,c)}d.stopPropagation||(this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},mouseover:function(a){joint.dia.CellView.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",a)},mouseout:function(a){joint.dia.CellView.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",a)},mouseenter:function(a){joint.dia.CellView.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",a)},mouseleave:function(a){joint.dia.CellView.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",a)},mousewheel:function(a,b,c,d){joint.dia.CellView.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",a,b,c,d)},onmagnet:function(a,b,c){this.dragMagnetStart(a,b,c);var d=this.eventData(a).stopPropagation;d&&a.stopPropagation()},dragStart:function(a,b,c){this.can("elementMove")&&this.eventData(a,{action:"move",x:b,y:c,restrictedArea:this.paper.getRestrictedArea(this)})},dragMagnetStart:function(a,b,c){if(this.can("addLinkFromMagnet")){this.model.startBatch("add-link");var d=this.paper,e=d.model,f=a.target,g=d.getDefaultLink(this,f),h=this.getLinkEnd(f,b,c,g,"source"),i={x:b,y:c};g.set({source:h,target:i}),g.addTo(e,{async:!1,ui:!0});var j=g.findView(d);joint.dia.CellView.prototype.pointerdown.apply(j,arguments),j.notify("link:pointerdown",a,b,c);var k=j.startArrowheadMove("target",{whenNotAllowed:"remove"});j.eventData(a,k),this.eventData(a,{action:"magnet",linkView:j,stopPropagation:!0}),this.paper.delegateDragEvents(this,a.data)}},drag:function(a,b,c){var d=this.paper,e=d.options.gridSize,f=this.model,h=f.position(),i=this.eventData(a),j=g.snapToGrid(h.x,e)-h.x+g.snapToGrid(b-i.x,e),k=g.snapToGrid(h.y,e)-h.y+g.snapToGrid(c-i.y,e);f.translate(j,k,{restrictedArea:i.restrictedArea,ui:!0});var l=!!i.embedding;d.options.embeddingMode&&(l||(this.prepareEmbedding(i),l=!0),this.processEmbedding(i)),this.eventData(a,{x:g.snapToGrid(b,e),y:g.snapToGrid(c,e),embedding:l})},dragMagnet:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointermove(a,b,c)},dragEnd:function(a,b,c){var d=this.eventData(a);d.embedding&&this.finalizeEmbedding(d)},dragMagnetEnd:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointerup(a,b,c),this.model.stopBatch("add-link")}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),doubleToolMarkup:void 0,vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",yAlignment:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,refWidth:1,refHeight:1,refX:0,refY:0}},position:{distance:.5}}},defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(a){return this.set({source:{x:0,y:0},target:{x:0,y:0}},a)},source:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("source"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("source",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("source",d,e)):(d=a,e=b,this.set("source",d,e))},target:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("target"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("target",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("target",d,e)):(d=a,e=b,this.set("target",d,e))},router:function(a,b,c){if(void 0===a){var d=this.get("router");return d?"object"==typeof d?joint.util.clone(d):d:this.get("manhattan")?{name:"orthogonal"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("router",f,g)},connector:function(a,b,c){if(void 0===a){var d=this.get("connector");return d?"object"==typeof d?joint.util.clone(d):d:this.get("smooth")?{name:"smooth"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("connector",f,g)},label:function(a,b,c){var d=this.labels();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},labels:function(a,b){return 0===arguments.length?(a=this.get("labels"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("labels",a,b))},insertLabel:function(a,b,c){if(!b)throw new Error("dia.Link: no label provided");var d=this.labels(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.labels(d,c)},appendLabel:function(a,b){return this.insertLabel(-1,a,b)},removeLabel:function(a,b){var c=this.labels();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.labels(c,b)},vertex:function(a,b,c){var d=this.vertices();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["vertices",a]):this.prop(["vertices",a],b,c)},vertices:function(a,b){return 0===arguments.length?(a=this.get("vertices"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("vertices",a,b))},insertVertex:function(a,b,c){if(!b)throw new Error("dia.Link: no vertex provided");var d=this.vertices(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.vertices(d,c)},removeVertex:function(a,b){var c=this.vertices();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.vertices(c,b)},translate:function(a,b,c){return c=c||{},c.translateBy=c.translateBy||this.id,c.tx=a,c.ty=b,this.applyToPoints(function(c){return{x:(c.x||0)+a,y:(c.y||0)+b}},c)},scale:function(a,b,c,d){return this.applyToPoints(function(d){return g.point(d).scale(a,b,c).toJSON()},d)},applyToPoints:function(a,b){if(!joint.util.isFunction(a))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var c={},d=this.source();d.id||(c.source=a(d));var e=this.target();e.id||(c.target=a(e));var f=this.vertices();return f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.getSourceElement(),d=this.getTargetElement(),e=this.getParentCell();c&&d&&(b=this.graph.getCommonAncestor(c,d)),!e||b&&b.id===e.id||e.unembed(this,a),b&&b.embed(this,a)}return b},hasLoop:function(a){a=a||{};var b=this.source().id,c=this.target().id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.getSourceElement(),f=this.getTargetElement();d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.source(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getTargetElement:function(){var a=this.target(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getRelationshipAncestor:function(){var a;if(this.graph){var b=[this,this.getSourceElement(),this.getTargetElement()].filter(function(a){return!!a});a=this.graph.getCommonAncestor.apply(this.graph,b)}return a||null},isRelationshipEmbeddedIn:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(b))},_getDefaultLabel:function(){var a=this.get("defaultLabel")||this.defaultLabel||{},b={};return b.markup=a.markup||this.get("labelMarkup")||this.labelMarkup,b.position=a.position,b.attrs=a.attrs,b.size=a.size,b}},{endsEqual:function(a,b){var c=a.port===b.port||!a.port&&!b.port;return a.id===b.id&&c}}),joint.dia.LinkView=joint.dia.CellView.extend({className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("link"),a.join(" ")},options:{shortLinkLength:105,doubleLinkTools:!1,longLinkLength:155,linkToolsOffset:40,doubleLinkToolsOffset:65,sampleInterval:50},_labelCache:null,_labelSelectors:null,_markerCache:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(a){joint.dia.CellView.prototype.initialize.apply(this,arguments),"function"!=typeof this.constructor.prototype.watchSource&&(this.constructor.prototype.watchSource=this.createWatcher("source"),this.constructor.prototype.watchTarget=this.createWatcher("target")),this._labelCache={},this._labelSelectors={},this._markerCache={},this._V={},this.metrics={},this.startListening()},startListening:function(){var a=this.model;this.listenTo(a,"change:markup",this.render),this.listenTo(a,"change:smooth change:manhattan change:router change:connector",this.update),this.listenTo(a,"change:toolMarkup",this.onToolsChange),this.listenTo(a,"change:labels change:labelMarkup",this.onLabelsChange),this.listenTo(a,"change:vertices change:vertexMarkup",this.onVerticesChange),this.listenTo(a,"change:source",this.onSourceChange),this.listenTo(a,"change:target",this.onTargetChange)},onSourceChange:function(a,b,c){this.watchSource(a,b);var d=this.model;c.translateBy&&d.get("target").id&&b.id||this.update(d,null,c)},onTargetChange:function(a,b,c){this.watchTarget(a,b);var d=this.model;(!c.translateBy||d.get("source").id&&!b.id&&joint.util.isEmpty(d.get("vertices")))&&this.update(d,null,c)},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||this.update(a,null,c)},onToolsChange:function(){this.renderTools().updateToolsPosition()},onLabelsChange:function(a,b,c){var d=!0,e=this.model.previous("labels");if(e&&"propertyPathArray"in c&&"propertyValue"in c){var f=c.propertyPathArray||[],g=f.length;if(g>1){var h=!!e[f[1]];h&&(2===g?d="markup"in Object(c.propertyValue):"markup"!==f[2]&&(d=!1))}}d?this.renderLabels():this.updateLabels(),this.updateLabelPositions()},render:function(){this.vel.empty(),this._V={},this.renderMarkup(),this.renderLabels();var a=this.model;return this.watchSource(a,a.source()).watchTarget(a,a.target()).update(),this},renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.LinkView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.LinkView: ambiguous root selector.");c[d]=this.el,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=V(a);Array.isArray(b)||(b=[b]);for(var c=this._V,d=0,e=b.length;d1||"G"!==d[0].nodeName.toUpperCase()?(c=V("g"),c.append(b),c.addClass("label")):(c=V(d[0]),c.addClass("label")),{node:c.node,selectors:a.selectors}}},renderLabels:function(){var a=this._V,b=a.labels,c=this._labelCache={},d=this._labelSelectors={};b&&b.empty();var e=this.model,f=e.get("labels")||[],g=f.length;if(0===g)return this;b||(b=a.labels=V("g").addClass("labels").appendTo(this.el));for(var h=0;h=this.options.longLinkLength){var e=this.options.doubleLinkToolsOffset||b;d=this.getPointAtLength(c-e),this._tool2Cache.attr("transform","translate("+d.x+", "+d.y+") "+a),this._tool2Cache.attr("visibility","visible")}else this.options.doubleLinkTools&&this._tool2Cache.attr("visibility","hidden")}return this},updateArrowheadMarkers:function(){if(!this._V.markerArrowheads)return this;if("none"===$.css(this._V.markerArrowheads.node,"display"))return this;var a=this.getConnectionLength()0&&b<=1,d=0,e={x:0,y:0};if(a.offset){var f=a.offset;"number"==typeof f&&(d=f),f.x&&(e.x=f.x),f.y&&(e.y=f.y)}var g,h=0!==e.x||0!==e.y||0===d,i=this.path,j={segmentSubdivisions:this.getConnectionSubdivisions()},k=c?b*this.getConnectionLength():b;if(h)g=i.pointAtLength(k,j),g.offset(e);else{var l=i.tangentAtLength(k,j);l?(l.rotate(l.start,-90),l.setLength(d),g=l.end):g=i.start}return g},getVertexIndex:function(a,b){for(var c=this.model,d=c.vertices(),e=this.getClosestPointLength(new g.Point(a,b)),f=0,h=d.length;f0){for(var j=0,k=i.length;j").addClass(joint.util.addClassNamePrefix("paper-background")),this.options.background&&this.drawBackground(this.options.background),this.$grid=$("
").addClass(joint.util.addClassNamePrefix("paper-grid")),this.options.drawGrid&&this.drawGrid(),this.$el.append(this.$background,this.$grid,this.svg),this},update:function(){return this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background),this},_viewportMatrix:null,_viewportTransformString:null,matrix:function(a){var b=this.viewport;if(void 0===a){var c=b.getAttribute("transform");return(this._viewportTransformString||null)===c?a=this._viewportMatrix:(a=b.getCTM(),this._viewportMatrix=a,this._viewportTransformString=c),V.createSVGMatrix(a)}return a=V.createSVGMatrix(a),ctmString=V.matrixToTransformString(a),b.setAttribute("transform",ctmString),this.tools.setAttribute("transform",ctmString),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_sortDelayingBatches:["add","to-front","to-back"],_onSort:function(){this.model.hasActiveBatch(this._sortDelayingBatches)||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;this._sortDelayingBatches.includes(b)&&!this.model.hasActiveBatch(this._sortDelayingBatches)&&this.sortViews()},onRemove:function(){this.removeViews()},setDimensions:function(a,b){a=this.options.width=a||this.options.width,b=this.options.height=b||this.options.height,this.$el.css({width:Math.round(a),height:Math.round(b)}),this.trigger("resize",a,b)},setOrigin:function(a,b){return this.translate(a||0,b||0,{absolute:!0})},fitToContent:function(a,b,c,d){joint.util.isObject(a)?(d=a,a=d.gridWidth||1,b=d.gridHeight||1,c=d.padding||0):(d=d||{},a=a||1,b=b||1,c=c||0),c=joint.util.normalizeSides(c);var e=V(this.viewport).getBBox(),f=this.scale(),g=this.translate();e.x*=f.sx,e.y*=f.sy,e.width*=f.sx,e.height*=f.sy;var h=Math.max(Math.ceil((e.width+e.x)/a),1)*a,i=Math.max(Math.ceil((e.height+e.y)/b),1)*b,j=0,k=0;("negative"==d.allowNewOrigin&&e.x<0||"positive"==d.allowNewOrigin&&e.x>=0||"any"==d.allowNewOrigin)&&(j=Math.ceil(-e.x/a)*a,j+=c.left,h+=j),("negative"==d.allowNewOrigin&&e.y<0||"positive"==d.allowNewOrigin&&e.y>=0||"any"==d.allowNewOrigin)&&(k=Math.ceil(-e.y/b)*b,k+=c.top,i+=k),h+=c.right,i+=c.bottom,h=Math.max(h,d.minWidth||0),i=Math.max(i,d.minHeight||0),h=Math.min(h,d.maxWidth||Number.MAX_VALUE),i=Math.min(i,d.maxHeight||Number.MAX_VALUE);var l=h!=this.options.width||i!=this.options.height,m=j!=g.tx||k!=g.ty;m&&this.translate(j,k),l&&this.setDimensions(h,i)},scaleContentToFit:function(a){var b=this.getContentBBox();if(b.width&&b.height){a=a||{},joint.util.defaults(a,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE});var c,d=a.padding,e=a.minScaleX||a.minScale,f=a.maxScaleX||a.maxScale,h=a.minScaleY||a.minScale,i=a.maxScaleY||a.maxScale;if(a.fittingBBox)c=a.fittingBBox;else{var j=this.translate();c={x:j.tx,y:j.ty,width:this.options.width,height:this.options.height}}c=g.rect(c).moveAndExpand({x:d,y:d,width:-2*d,height:-2*d});var k=this.scale(),l=c.width/b.width*k.sx,m=c.height/b.height*k.sy;if(a.preserveAspectRatio&&(l=m=Math.min(l,m)),a.scaleGrid){var n=a.scaleGrid;l=n*Math.floor(l/n),m=n*Math.floor(m/n)}l=Math.min(f,Math.max(e,l)),m=Math.min(i,Math.max(h,m)),this.scale(l,m);var o=this.getContentBBox(),p=c.x-o.x,q=c.y-o.y;this.translate(p,q)}},getContentArea:function(){return V(this.viewport).getBBox()},getContentBBox:function(){var a=this.viewport.getBoundingClientRect(),b=this.clientMatrix(),c=this.translate();return g.rect({x:a.left-b.e+c.tx,y:a.top-b.f+c.ty,width:a.width,height:a.height})},getArea:function(){return this.paperToLocalRect({x:0,y:0,width:this.options.width,height:this.options.height})},getRestrictedArea:function(){var a;return a=joint.util.isFunction(this.options.restrictTranslate)?this.options.restrictTranslate.apply(this,arguments):this.options.restrictTranslate===!0?this.getArea():this.options.restrictTranslate||null},createViewForModel:function(a){var b,c,d=this.options.cellViewNamespace,e=a.get("type")+"View",f=joint.util.getByPath(d,e,".");a.isLink()?(b=this.options.linkView,c=joint.dia.LinkView):(b=this.options.elementView,c=joint.dia.ElementView);var g=b.prototype instanceof Backbone.View?f||b:b.call(this,a)||f||c;return new g({model:a,interactive:this.options.interactive})},onCellAdded:function(a,b,c){if(this.options.async&&c.async!==!1&&joint.util.isNumber(c.position)){if(this._asyncCells=this._asyncCells||[],this._asyncCells.push(a),0==c.position){if(this._frameId)throw new Error("another asynchronous rendering in progress");this.asyncRenderViews(this._asyncCells,c),delete this._asyncCells}}else this.renderView(a)},removeView:function(a){var b=this._views[a.id];return b&&(b.remove(),delete this._views[a.id]),b},renderView:function(a){var b=this._views[a.id]=this.createViewForModel(a);return V(this.viewport).append(b.el),b.paper=this,b.render(),b},onImageDragStart:function(){return!1},beforeRenderViews:function(a){return a.sort(function(a){return a.isLink()?1:-1}),a},afterRenderViews:function(){this.sortViews()},resetViews:function(a,b){this.removeViews();var c=a.models.slice();if(c=this.beforeRenderViews(c,b)||c,this.cancelRenderViews(),this.options.async)this.asyncRenderViews(c,b);else{for(var d=0,e=c.length;d(e.get("z")||0)?1:-1})},scale:function(a,b,c,d){if(void 0===a)return V.matrixToScale(this.matrix());void 0===b&&(b=a),void 0===c&&(c=0,d=0);var e=this.translate();if(c||d||e.tx||e.ty){var f=e.tx-c*(a-1),g=e.ty-d*(b-1);this.translate(f,g)}var h=this.matrix();return h.a=a||0,h.d=b||0,this.matrix(h),this.trigger("scale",a,b,c,d),this},rotate:function(a,b,c){if(void 0===a)return V.matrixToRotate(this.matrix());if(void 0===b){var d=this.viewport.getBBox();b=d.width/2,c=d.height/2}var e=this.matrix().translate(b,c).rotate(a).translate(-b,-c);return this.matrix(e),this},translate:function(a,b){if(void 0===a)return V.matrixToTranslate(this.matrix());var c=this.matrix();c.e=a||0,c.f=b||0,this.matrix(c);var d=this.translate(),e=this.options.origin;return e.x=d.tx,e.y=d.ty,this.trigger("translate",d.tx,d.ty),this.options.drawGrid&&this.drawGrid(),this},findView:function(a){for(var b=joint.util.isString(a)?this.viewport.querySelector(a):a instanceof $?a[0]:a;b&&b!==this.el&&b!==document;){var c=b.getAttribute("model-id");if(c)return this._views[c];b=b.parentNode}},findViewByModel:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a&&a.id;return this._views[b]},findViewsFromPoint:function(a){a=g.point(a);var b=this.model.getElements().map(this.findViewByModel,this);return b.filter(function(b){return b&&b.vel.getBBox({target:this.viewport}).containsPoint(a)},this)},findViewsInArea:function(a,b){b=joint.util.defaults(b||{},{strict:!1}),a=g.rect(a);var c=this.model.getElements().map(this.findViewByModel,this),d=b.strict?"containsRect":"intersect";return c.filter(function(b){return b&&a[d](b.vel.getBBox({target:this.viewport}))},this)},removeTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"remove"),this},hideTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"hide"),this},showTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"show"),this},getModelById:function(a){return this.model.getCell(a)},snapToGrid:function(a,b){return this.clientToLocalPoint(a,b).snapToGrid(this.options.gridSize)},localToPaperPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix());return g.Point(d)},localToPaperRect:function(a,b,c,d){var e=g.Rect(a,b),f=V.transformRect(e,this.matrix());return g.Rect(f)},paperToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix().inverse());return g.Point(d)},paperToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.matrix().inverse());return g.Rect(f)},localToClientPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix());return g.Point(d)},localToClientRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix());return g.Rect(f)},clientToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix().inverse());return g.Point(d)},clientToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix().inverse());return g.Rect(f)},localToPagePoint:function(a,b){return this.localToPaperPoint(a,b).offset(this.pageOffset())},localToPageRect:function(a,b,c,d){return this.localToPaperRect(a,b,c,d).moveAndExpand(this.pageOffset())},pageToLocalPoint:function(a,b){var c=g.Point(a,b),d=c.difference(this.pageOffset());return this.paperToLocalPoint(d)},pageToLocalRect:function(a,b,c,d){var e=this.pageOffset(),f=g.Rect(a,b,c,d);return f.x-=e.x,f.y-=e.y,this.paperToLocalRect(f)},clientOffset:function(){var a=this.svg.getBoundingClientRect();return g.Point(a.left,a.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(a){if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide a linkView.");var b=a.model,c=this.options,d=this.model,e=d.constructor.validations;return!(!c.multiLinks&&!e.multiLinks.call(this,d,b))&&(!(!c.linkPinning&&!e.linkPinning.call(this,d,b))&&!("function"==typeof c.allowLink&&!c.allowLink.call(this,a,this)))},getDefaultLink:function(a,b){return joint.util.isFunction(this.options.defaultLink)?this.options.defaultLink.call(this,a,b):this.options.defaultLink.clone()},resolveHighlighter:function(a){a=a||{};var b=a.highlighter,c=this.options;if(void 0===b){var d=["embedding","connecting","magnetAvailability","elementAvailability"].find(function(b){return!!a[b]});b=d&&c.highlighting[d]||c.highlighting.default}if(!b)return!1;joint.util.isString(b)&&(b={name:b});var e=b.name,f=c.highlighterNamespace[e];if(!f)throw new Error('Unknown highlighter ("'+e+'")');if("function"!=typeof f.highlight)throw new Error('Highlighter ("'+e+'") is missing required highlight() method');if("function"!=typeof f.unhighlight)throw new Error('Highlighter ("'+e+'") is missing required unhighlight() method');return{highlighter:f,options:b.options||{},name:e}},onCellHighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){b.id||(b.id=V.uniqueId());var d=c.name+b.id+JSON.stringify(c.options);if(!this._highlights[d]){var e=c.highlighter;e.highlight(a,b,joint.util.assign({},c.options)),this._highlights[d]={cellView:a,magnetEl:b,opt:c.options,highlighter:e}}}},onCellUnhighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){var d=c.name+b.id+JSON.stringify(c.options),e=this._highlights[d];e&&(e.highlighter.unhighlight(e.cellView,e.magnetEl,e.opt),this._highlights[d]=null)}},pointerdblclick:function(a){a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerdblclick(a,c.x,c.y):this.trigger("blank:pointerdblclick",a,c.x,c.y)}},pointerclick:function(a){if(this._mousemoved<=this.options.clickThreshold){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(this.guard(a,b))return;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerclick(a,c.x,c.y):this.trigger("blank:pointerclick",a,c.x,c.y)}},contextmenu:function(a){ this.options.preventContextMenu&&a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.contextmenu(a,c.x,c.y):this.trigger("blank:contextmenu",a,c.x,c.y)}},pointerdown:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y)),this.delegateDragEvents(b,a.data)}},pointermove:function(a){a.preventDefault();var b=this.eventData(a);b.mousemoved||(b.mousemoved=0);var c=++b.mousemoved;if(!(c<=this.options.moveThreshold)){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY}),e=b.sourceView;e?e.pointermove(a,d.x,d.y):this.trigger("blank:pointermove",a,d.x,d.y),this.eventData(a,b)}},pointerup:function(a){this.undelegateDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY}),c=this.eventData(a).sourceView;c?c.pointerup(a,b.x,b.y):this.trigger("blank:pointerup",a,b.x,b.y),this.delegateEvents()},mouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseover(a);else{if(this.el===a.target)return;this.trigger("blank:mouseover",a)}},mouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseout(a);else{if(this.el===a.target)return;this.trigger("blank:mouseout",a)}},mouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseenter(a)}else{if(c)return;this.trigger("paper:mouseenter",a)}}},mouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseleave(a)}else{if(c)return;this.trigger("paper:mouseleave",a)}}},mousewheel:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=a.originalEvent,d=this.snapToGrid({x:c.clientX,y:c.clientY}),e=Math.max(-1,Math.min(1,c.wheelDelta||-c.detail));b?b.mousewheel(a,d.x,d.y,e):this.trigger("blank:mousewheel",a,d.x,d.y,e)}},onevent:function(a){var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.onevent(a,c,e.x,e.y)}}},onmagnet:function(a){var b=a.currentTarget,c=b.getAttribute("magnet");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;if(!this.options.validateMagnet(d,b))return;var e=this.snapToGrid(a.clientX,a.clientY);d.onmagnet(a,e.x,e.y)}}},onlabel:function(a){var b=a.currentTarget,c=this.findView(b);if(c){if(a=joint.util.normalizeEvent(a),this.guard(a,c))return;var d=this.snapToGrid(a.clientX,a.clientY);c.onlabel(a,d.x,d.y)}},delegateDragEvents:function(a,b){b||(b={}),this.eventData({data:b},{sourceView:a||null,mousemoved:0}),this.delegateDocumentEvents(null,b),this.undelegateEvents()},guard:function(a,b){return!(!this.options.guard||!this.options.guard(a,b))||(a.data&&void 0!==a.data.guarded?a.data.guarded:!(b&&b.model&&b.model instanceof joint.dia.Cell)&&(this.svg!==a.target&&this.el!==a.target&&!$.contains(this.svg,a.target)))},setGridSize:function(a){return this.options.gridSize=a,this.options.drawGrid&&this.drawGrid(),this},clearGrid:function(){return this.$grid&&this.$grid.css("backgroundImage","none"),this},_getGriRefs:function(){return this._gridCache||(this._gridCache={root:V("svg",{width:"100%",height:"100%"},V("defs")),patterns:{},add:function(a,b){V(this.root.node.childNodes[0]).append(b),this.patterns[a]=b,this.root.append(V("rect",{width:"100%",height:"100%",fill:"url(#"+a+")"}))},get:function(a){return this.patterns[a]},exist:function(a){return void 0!==this.patterns[a]}}),this._gridCache},setGrid:function(a){this.clearGrid(),this._gridCache=null,this._gridSettings=[];var b=Array.isArray(a)?a:[a||{}];return b.forEach(function(a){this._gridSettings.push.apply(this._gridSettings,this._resolveDrawGridOption(a))},this),this},_resolveDrawGridOption:function(a){var b=this.constructor.gridPatterns;if(joint.util.isString(a)&&Array.isArray(b[a]))return b[a].map(function(a){return joint.util.assign({},a)});var c=a||{args:[{}]},d=Array.isArray(c),e=c.name;if(d||e||c.markup||(e="dot"),e&&Array.isArray(b[e])){var f=b[e].map(function(a){return joint.util.assign({},a)}),g=Array.isArray(c.args)?c.args:[c.args||{}];joint.util.defaults(g[0],joint.util.omit(a,"args"));for(var h=0;h'),f=joint.util.toArray(d).map(function(a){return e({offset:a.offset,color:a.color,opacity:Number.isFinite(a.opacity)?a.opacity:1})}),g=["<"+c+">",f.join(""),""].join(""),h=joint.util.assign({id:b},a.attrs);V(g,h).appendTo(this.defs)}return b},defineMarker:function(a){if(!joint.util.isObject(a))throw new TypeError("dia.Paper: defineMarker() requires 1. argument to be an object.");var b=a.id;if(b||(b=this.svg.id+joint.util.hashCode(JSON.stringify(a))),!this.isDefined(b)){var c=joint.util.omit(a,"type","userSpaceOnUse"),d=V("marker",{id:b,orient:"auto",overflow:"visible",markerUnits:a.markerUnits||"userSpaceOnUse"},[V(a.type||"path",c)]);d.appendTo(this.defs)}return b}},{backgroundPatterns:{flipXy:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,-1,b.width,b.height),e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,1,b.width,0),e.drawImage(a,0,0,c,d),e.setTransform(1,0,0,-1,0,b.height),e.drawImage(a,0,0,c,d),b},flipX:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(2*c,0),e.scale(-1,1),e.drawImage(a,0,0,c,d),b},flipY:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(0,2*d),e.scale(1,-1),e.drawImage(a,0,0,c,d),b},watermark:function(a,b){b=b||{};var c=a.width,d=a.height,e=document.createElement("canvas");e.width=3*c,e.height=3*d;for(var f=e.getContext("2d"),h=joint.util.isNumber(b.watermarkAngle)?-b.watermarkAngle:-20,i=g.toRad(h),j=e.width/4,k=e.height/4,l=0;l<4;l++)for(var m=0;m<4;m++)(l+m)%2>0&&(f.setTransform(1,0,0,1,(2*l-1)*j,(2*m-1)*k),f.rotate(i),f.drawImage(a,-c/2,-d/2,c,d));return e}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){V(a).attr({width:b.thickness*b.sx,height:b.thickness*b.sy,fill:b.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){var c=b.sx<=1?b.thickness*b.sx:b.thickness;V(a).attr({width:c,height:c,fill:b.color})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}]}}),function(a,b,c){var d=function(b){var d=c.cloneDeep(b)||{};this.ports=[],this.groups={},this.portLayoutNamespace=a.layout.Port,this.portLabelLayoutNamespace=a.layout.PortLabel,this._init(d)};d.prototype={getPorts:function(){return this.ports},getGroup:function(a){return this.groups[a]||{}},getPortsByGroup:function(a){return this.ports.filter(function(b){return b.group===a})},getGroupPortsMetrics:function(a,b){var d=this.getGroup(a),e=this.getPortsByGroup(a),f=d.position||{},h=f.name,i=this.portLayoutNamespace;i[h]||(h="left");var j=f.args||{},k=e.map(function(a){return a&&a.position&&a.position.args}),l=i[h](k,b,j),m={ports:e,result:[]};return c.toArray(l).reduce(function(a,c,d){var e=a.ports[d];return a.result.push({portId:e.id,portTransformation:c,labelTransformation:this._getPortLabelLayout(e,g.Point(c),b),portAttrs:e.attrs,portSize:e.size,labelSize:e.label.size}),a}.bind(this),m),m.result},_getPortLabelLayout:function(a,b,c){var d=this.portLabelLayoutNamespace,e=a.label.position.name||"left";return d[e]?d[e](b,c,a.label.position.args):null},_init:function(a){if(c.isObject(a.groups))for(var b=Object.keys(a.groups),d=0,e=b.length;d0},hasPort:function(a){return this.getPortIndex(a)!==-1},getPorts:function(){return c.cloneDeep(this.prop("ports/items"))||[]},getPort:function(a){return c.cloneDeep(c.toArray(this.prop("ports/items")).find(function(b){return b.id&&b.id===a}))},getPortsPositions:function(a){var b=this._portSettingsData.getGroupPortsMetrics(a,g.Rect(this.size()));return b.reduce(function(a,b){var c=b.portTransformation;return a[b.portId]={x:c.x,y:c.y,angle:c.angle},a},{})},getPortIndex:function(a){var b=c.isObject(a)?a.id:a;return this._isValidPortId(b)?c.toArray(this.prop("ports/items")).findIndex(function(a){return a.id===b}):-1},addPort:function(a,b){if(!c.isObject(a)||Array.isArray(a))throw new Error("Element: addPort requires an object.");var d=c.assign([],this.prop("ports/items"));return d.push(a),this.prop("ports/items",d,b),this},portProp:function(a,b,d,e){var f=this.getPortIndex(a);if(f===-1)throw new Error("Element: unable to find port with id "+a);var g=Array.prototype.slice.call(arguments,1);return Array.isArray(b)?g[0]=["ports","items",f].concat(b):c.isString(b)?g[0]=["ports/items/",f,"/",b].join(""):(g=["ports/items/"+f],c.isPlainObject(b)&&(g.push(b),g.push(d))),this.prop.apply(this,g)},_validatePorts:function(){var b=this.get("ports")||{},d=[];b=b||{};var e=c.toArray(b.items);return e.forEach(function(a){"object"!=typeof a&&d.push("Element: invalid port ",a),this._isValidPortId(a.id)||(a.id=c.uuid())},this),a.util.uniq(e,"id").length!==e.length&&d.push("Element: found id duplicities in ports."),d},_isValidPortId:function(a){return null!==a&&void 0!==a&&!c.isObject(a)},addPorts:function(a,b){return a.length&&this.prop("ports/items",c.assign([],this.prop("ports/items")).concat(a),b),this},removePort:function(a,b){var d=b||{},e=c.assign([],this.prop("ports/items")),f=this.getPortIndex(a);return f!==-1&&(e.splice(f,1),d.rewrite=!0,this.prop("ports/items",e,d)),this},_createPortData:function(){var a=this._validatePorts();if(a.length>0)throw this.set("ports",this.previous("ports")),new Error(a.join(" "));var b;this._portSettingsData&&(b=this._portSettingsData.getPorts()),this._portSettingsData=new d(this.get("ports"));var c=this._portSettingsData.getPorts();if(b){var e=c.filter(function(a){if(!b.find(function(b){return b.id===a.id}))return a}),f=b.filter(function(a){if(!c.find(function(b){return b.id===a.id}))return a});f.length>0&&this.trigger("ports:remove",this,f),e.length>0&&this.trigger("ports:add",this,e)}}}),c.assign(a.dia.ElementView.prototype,{portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._portElementsCache={},this.listenTo(this.model,"change:ports",function(){this._refreshPorts()})},_refreshPorts:function(){this._removePorts(),this._portElementsCache={},this._renderPorts()},_renderPorts:function(){for(var a=[],b=this._getContainerElement(),d=0,e=b.node.childNodes.length;d1?V("g").append(h):V(h.firstChild),e=g.selectors}else b=V(f),Array.isArray(b)&&(b=V("g").append(b));if(!b)throw new Error("ElementView: Invalid port markup.");b.attr({port:a.id,"port-group":a.group});var i,j=this._getPortLabelMarkup(a.label);if(Array.isArray(j)){var k=c.parseDOMJSON(j),l=k.fragment;d=l.childNodes.length>1?V("g").append(l):V(l.firstChild),i=k.selectors}else d=V(j),Array.isArray(d)&&(d=V("g").append(d));if(!d)throw new Error("ElementView: Invalid port label markup.");var m;if(e&&i){for(var n in i)if(e[n])throw new Error("ElementView: selectors within port must be unique.");m=c.assign({},e,i)}else m=e||i;var o=V(this.portContainerMarkup).addClass("joint-port").append([b.addClass("joint-port-body"),d.addClass("joint-port-label")]);return this._portElementsCache[a.id]={portElement:o,portLabelElement:d,portSelectors:m,portLabelSelectors:i,portContentElement:b,portContentSelectors:e},o},_updatePortGroup:function(a){for(var b=g.Rect(this.model.size()),c=this.model._portSettingsData.getGroupPortsMetrics(a,b),d=0,e=c.length;d'}),joint.shapes.basic.TextView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:attrs",this.resize)}}),joint.shapes.basic.Generic.define("basic.Text",{attrs:{text:{"font-size":18,fill:"#000000"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Circle",{size:{width:60,height:60},attrs:{circle:{fill:"#ffffff",stroke:"#000000",r:30,cx:30,cy:30},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Ellipse",{size:{width:60,height:40},attrs:{ellipse:{fill:"#ffffff",stroke:"#000000",rx:30,ry:20,cx:30,cy:20},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polygon",{size:{width:60,height:40},attrs:{polygon:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polyline",{size:{width:60,height:40},attrs:{polyline:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Image",{attrs:{text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Path",{size:{width:60,height:60},attrs:{path:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle",ref:"path","ref-x":.5,"ref-dy":10,fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Path.define("basic.Rhombus",{attrs:{path:{d:"M 30 0 L 60 30 30 60 0 30 z"},text:{"ref-y":.5,"ref-dy":null,"y-alignment":"middle"}}}),joint.shapes.basic.PortsModelInterface={initialize:function(){this.updatePortsAttrs(),this.on("change:inPorts change:outPorts",this.updatePortsAttrs,this),this.constructor.__super__.constructor.__super__.initialize.apply(this,arguments)},updatePortsAttrs:function(a){if(this._portSelectors){var b=joint.util.omit(this.get("attrs"),this._portSelectors);this.set("attrs",b,{silent:!0})}this._portSelectors=[];var c={};joint.util.toArray(this.get("inPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".inPorts","in");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),joint.util.toArray(this.get("outPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".outPorts","out");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),this.attr(c,{silent:!0}),this.processPorts(),this.trigger("process:ports")},getPortSelector:function(a){var b=".inPorts",c=this.get("inPorts").indexOf(a);if(c<0&&(b=".outPorts",c=this.get("outPorts").indexOf(a),c<0))throw new Error("getPortSelector(): Port doesn't exist.");return b+">g:nth-child("+(c+1)+")>.port-body"}},joint.shapes.basic.PortsViewInterface={initialize:function(){this.listenTo(this.model,"process:ports",this.update),joint.dia.ElementView.prototype.initialize.apply(this,arguments)},update:function(){this.renderPorts(),joint.dia.ElementView.prototype.update.apply(this,arguments)},renderPorts:function(){var a=this.$(".inPorts").empty(),b=this.$(".outPorts").empty(),c=joint.util.template(this.model.portMarkup),d=this.model.ports||[];d.filter(function(a){return"in"===a.type}).forEach(function(b,d){a.append(V(c({id:d,port:b})).node)}),d.filter(function(a){return"out"===a.type}).forEach(function(a,d){b.append(V(c({id:d,port:a})).node)})}},joint.shapes.basic.Generic.define("basic.TextBlock",{attrs:{rect:{fill:"#ffffff",stroke:"#000000",width:80,height:100},text:{fill:"#000000","font-size":14,"font-family":"Arial, helvetica, sans-serif"},".content":{text:"","ref-x":.5,"ref-y":.5,"y-alignment":"middle","x-alignment":"middle"}},content:""},{markup:['','',joint.env.test("svgforeignobject")?'
':'',""].join(""),initialize:function(){this.listenTo(this,"change:size",this.updateSize),this.listenTo(this,"change:content",this.updateContent),this.updateSize(this,this.get("size")),this.updateContent(this,this.get("content")),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},updateSize:function(a,b){this.attr({".fobj":joint.util.assign({},b),div:{style:joint.util.assign({},b)}})},updateContent:function(a,b){joint.env.test("svgforeignobject")?this.attr({".content":{html:joint.util.sanitizeHTML(b)}}):this.attr({".content":{text:b}})},setForeignObjectSize:function(){this.updateSize.apply(this,arguments)},setDivContent:function(){this.updateContent.apply(this,arguments)}}),joint.shapes.basic.TextBlockView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.noSVGForeignObjectElement=!joint.env.test("svgforeignobject"),joint.env.test("svgforeignobject")||this.listenTo(this.model,"change:content change:size",function(a){this.updateContent(a)})},update:function(a,b){var c=this.model;if(joint.env.test("svgforeignobject"))joint.dia.ElementView.prototype.update.call(this,c,b);else{var d=joint.util.omit(b||c.get("attrs"),".content");joint.dia.ElementView.prototype.update.call(this,c,d),b&&!joint.util.has(b,".content")||this.updateContent(c,b)}},updateContent:function(a,b){var c=joint.util.merge({},(b||a.get("attrs"))[".content"]);c=joint.util.omit(c,"text");var d=joint.util.breakText(a.get("content"),a.get("size"),c,{svgDocument:this.paper.svg}),e=joint.util.setByPath({},".content",c,"/");e[".content"].text=d,joint.dia.ElementView.prototype.update.call(this,a,e)}}),function(a,b,c,d){"use strict";var e=a.Element;e.define("standard.Rectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Circle",{attrs:{body:{refCx:"50%",refCy:"50%",refR:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Ellipse",{attrs:{body:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Path",{attrs:{body:{refD:"M 0 0 L 10 0 10 10 0 10 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polygon",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polyline",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10 0 0",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Image",{attrs:{image:{refWidth:"100%",refHeight:"100%"},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.BorderedImage",{attrs:{border:{refWidth:"100%",refHeight:"100%",stroke:"#333333",strokeWidth:2},image:{refWidth:-1,refHeight:-1,x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),e.define("standard.EmbeddedImage",{attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{refWidth:"30%",refHeight:-20,x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",refX:"30%",refX2:20,refY:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.HeaderedRectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{refWidth:"100%",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]});var f=10;joint.dia.Element.define("standard.Cylinder",{attrs:{body:{lateralArea:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{refCx:"50%",cy:f,refRx:"50%",ry:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"100%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(a,c){if(void 0===a)return this.attr("body/lateralArea");var d=b.isPercentage(a),e={lateralArea:a},f=d?{refCy:a,refRy:a,cy:null,ry:null}:{refCy:null,refRy:null,cy:a,ry:a};return this.attr({body:e,top:f},c)}},{attributes:{lateralArea:{set:function(a,c){var e=b.isPercentage(a);e&&(a=parseFloat(a)/100);var f=c.x,g=c.y,h=c.width,i=c.height,j=h/2,k=e?i*a:a,l=d.KAPPA,m=l*j,n=l*(e?i*a:a),o=f,p=f+h/2,q=f+h,r=g+k,s=r-k,t=g+i-k,u=g+i,v=["M",o,r,"L",o,t,"C",f,t+n,p-m,u,p,u,"C",p+m,u,q,t+n,q,t,"L",q,r,"C",q,r-n,p+m,s,p,s,"C",p-m,s,o,r-n,o,r,"Z"]; diff --git a/dist/joint.css b/dist/joint.css index bfe8ff910..38a34d1be 100644 --- a/dist/joint.css +++ b/dist/joint.css @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.d.ts b/dist/joint.d.ts index eb0534204..6133110b0 100644 --- a/dist/joint.d.ts +++ b/dist/joint.d.ts @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.js b/dist/joint.js index fe3bb23e4..b0e0c85b1 100644 --- a/dist/joint.js +++ b/dist/joint.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -7745,7 +7745,7 @@ V = Vectorizer = (function() { var joint = { - version: '2.1.1', + version: '2.1.2', config: { // The class name prefix config is for advanced use only. @@ -12557,7 +12557,13 @@ joint.dia.CellView = joint.mvc.View.extend({ if (port != null && this.model.hasPort(port)) { magnet = this.findPortNode(port, selector) || root; } else { - magnet = this.findBySelector(selector || end.selector, root, this.selectors)[0]; + if (!selector) selector = end.selector; + if (!selector && port != null) { + // link end has only `id` and `port` property referencing + // a port created via the `port` attribute (not API). + selector = '[port="' + port + '"]'; + } + magnet = this.findBySelector(selector, root, this.selectors)[0]; } return magnet; diff --git a/dist/joint.layout.DirectedGraph.js b/dist/joint.layout.DirectedGraph.js index cd3042494..e9d745e32 100644 --- a/dist/joint.layout.DirectedGraph.js +++ b/dist/joint.layout.DirectedGraph.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.layout.DirectedGraph.min.js b/dist/joint.layout.DirectedGraph.min.js index 6788baceb..e5974fa90 100644 --- a/dist/joint.layout.DirectedGraph.min.js +++ b/dist/joint.layout.DirectedGraph.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.min.css b/dist/joint.min.css index 324ac3be7..c0ab06826 100644 --- a/dist/joint.min.css +++ b/dist/joint.min.css @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.min.js b/dist/joint.min.js index a8835286d..6e2318e53 100644 --- a/dist/joint.min.js +++ b/dist/joint.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -47,8 +47,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. var g=function(){function a(a,b){return b.unshift(null),new(Function.prototype.bind.apply(a,b))}function b(a){var b,c,d=[];for(c=arguments.length,b=1;b=1)return[new q(b,c,d,e),new q(e,e,e,e)];var f=this.getSkeletonPoints(a),g=f.startControlPoint1,h=f.startControlPoint2,i=f.divider,j=f.dividerControlPoint1,k=f.dividerControlPoint2;return[new q(b,g,h,i),new q(i,j,k,e)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.controlPoint1.x===a.controlPoint1.x&&this.controlPoint1.y===a.controlPoint1.y&&this.controlPoint2.x===a.controlPoint2.x&&this.controlPoint2.y===a.controlPoint2.y&&this.end.x===a.end.x&&this.end.y===a.end.y},getSkeletonPoints:function(a){var b=this.start,c=this.controlPoint1,d=this.controlPoint2,e=this.end;if(a<=0)return{startControlPoint1:b.clone(),startControlPoint2:b.clone(),divider:b.clone(),dividerControlPoint1:c.clone(),dividerControlPoint2:d.clone()};if(a>=1)return{startControlPoint1:c.clone(),startControlPoint2:d.clone(),divider:e.clone(),dividerControlPoint1:e.clone(),dividerControlPoint2:e.clone()};var f=new s(b,c).pointAt(a),g=new s(c,d).pointAt(a),h=new s(d,e).pointAt(a),i=new s(f,g).pointAt(a),j=new s(g,h).pointAt(a),k=new s(i,j).pointAt(a),l={startControlPoint1:f,startControlPoint2:i,divider:k,dividerControlPoint1:j,dividerControlPoint2:h};return l},getSubdivisions:function(a){a=a||{};var b=void 0===a.precision?this.PRECISION:a.precision,c=[new q(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(0===b)return c;for(var d=this.endpointDistance(),e=p(10,-b),f=0;;){f+=1;for(var g=[],h=c.length,i=0;i1&&r=1)return this.end.clone();var c=this.tAt(a,b);return this.pointAtT(c)},pointAtLength:function(a,b){var c=this.tAtLength(a,b);return this.pointAtT(c)},pointAtT:function(a){return a<=0?this.start.clone():a>=1?this.end.clone():this.getSkeletonPoints(a).divider},PRECISION:3,scale:function(a,b,c){return this.start.scale(a,b,c),this.controlPoint1.scale(a,b,c),this.controlPoint2.scale(a,b,c),this.end.scale(a,b,c),this},tangentAt:function(a,b){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var c=this.tAt(a,b);return this.tangentAtT(c)},tangentAtLength:function(a,b){if(!this.isDifferentiable())return null;var c=this.tAtLength(a,b);return this.tangentAtT(c)},tangentAtT:function(a){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var b=this.getSkeletonPoints(a),c=b.startControlPoint2,d=b.dividerControlPoint1,e=b.divider,f=new s(c,d);return f.translate(e.x-c.x,e.y-c.y),f},tAt:function(a,b){if(a<=0)return 0;if(a>=1)return 1;b=b||{};var c=void 0===b.precision?this.PRECISION:b.precision,d=void 0===b.subdivisions?this.getSubdivisions({precision:c}):b.subdivisions,e={precision:c,subdivisions:d},f=this.length(e),g=f*a;return this.tAtLength(g,e)},tAtLength:function(a,b){var c=!0;a<0&&(c=!1,a=-a),b=b||{};for(var d,e,f,g,h,i=void 0===b.precision?this.PRECISION:b.precision,j=void 0===b.subdivisions?this.getSubdivisions({precision:i}):b.subdivisions,k={precision:i,subdivisions:j},l=0,m=j.length,n=1/m,o=c?0:m-1;c?o=0;c?o++:o--){var q=j[o],r=q.endpointDistance();if(a<=l+r){d=q,e=o*n,f=(o+1)*n,g=c?a-l:r+l-a,h=c?r+l-a:a-l;break}l+=r}if(!d)return c?1:0;for(var s=this.length(k),t=p(10,-i);;){var u;if(u=0!==s?g/s:0,ui.x+g/2,m=ei.x?f-d:f+d,c=g*g/(e-j)-g*g*(f-k)*(b-k)/(h*h*(e-j))+j):(c=f>i.y?e+d:e-d,b=h*h/(f-k)-h*h*(e-j)*(c-j)/(g*g*(f-k))+k),new u(c,b).theta(a)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLine:function(a){var b=[],c=a.start,d=a.end,e=this.a,f=this.b,g=a.vector(),i=c.difference(new u(this)),j=new u(g.x/(e*e),g.y/(f*f)),k=new u(i.x/(e*e),i.y/(f*f)),l=g.dot(j),m=g.dot(k),n=i.dot(k)-1,o=m*m-l*n;if(o<0)return null;if(o>0){var p=h(o),q=(-m-p)/l,r=(-m+p)/l;if((q<0||10){if(f>d||g>d)return null}else if(f=1?c.clone():b.lerp(c,a)},pointAtLength:function(a){var b=this.start,c=this.end,d=!0;a<0&&(d=!1,a=-a);var e=this.length();return a>=e?d?c.clone():b.clone():this.pointAt((d?a:e-a)/e)},pointOffset:function(a){a=new c.Point(a);var b=this.start,d=this.end,e=(d.x-b.x)*(a.y-b.y)-(d.y-b.y)*(a.x-b.x);return e/this.length()},rotate:function(a,b){return this.start.rotate(a,b),this.end.rotate(a,b),this},round:function(a){var b=p(10,a||0);return this.start.x=l(this.start.x*b)/b,this.start.y=l(this.start.y*b)/b,this.end.x=l(this.end.x*b)/b,this.end.y=l(this.end.y*b)/b,this},scale:function(a,b,c){return this.start.scale(a,b,c),this.end.scale(a,b,c),this},setLength:function(a){var b=this.length();if(!b)return this;var c=a/b;return this.scale(c,c,this.start)},squaredLength:function(){var a=this.start.x,b=this.start.y,c=this.end.x,d=this.end.y;return(a-=c)*a+(b-=d)*b},tangentAt:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAt(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},tangentAtLength:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAtLength(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},translate:function(a,b){return this.start.translate(a,b),this.end.translate(a,b),this},vector:function(){return new u(this.end.x-this.start.x,this.end.y-this.start.y)},toString:function(){return this.start.toString()+" "+this.end.toString()}},s.prototype.intersection=s.prototype.intersect;var t=c.Path=function(a){if(!(this instanceof t))return new t(a);if("string"==typeof a)return new t.parse(a);this.segments=[];var b,c;if(a){if(Array.isArray(a)&&0!==a.length)if(c=a.length,a[0].isSegment)for(b=0;b=c||a<0)throw new Error("Index out of range.");return b[a]},getSegmentSubdivisions:function(a){var b=this.segments,c=b.length;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=[],f=0;fd||a<0)throw new Error("Index out of range.");var e,f=null,g=null;if(0!==d&&(a>=1?(f=c[a-1],g=f.nextSegment):g=c[0]),Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");for(var h=b.length,i=0;i=d?(e=d-1,f=1):f<0?f=0:f>1&&(f=1),b=b||{};for(var g,h=void 0===b.precision?this.PRECISION:b.precision,i=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:h}):b.segmentSubdivisions,j=0,k=0;k=1)return this.end.clone();b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.pointAtLength(i,g)},pointAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;if(0===a)return this.start.clone();var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isVisible){if(a<=i+m)return k.pointAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f)return e?f.end:f.start;var n=c[d-1];return n.end.clone()},pointAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].pointAtT(0);if(d>=c)return b[c-1].pointAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].pointAtT(e)},prepareSegment:function(a,b,c){a.previousSegment=b,a.nextSegment=c,b&&(b.nextSegment=a),c&&(c.previousSegment=a);var d=a;return a.isSubpathStart&&(a.subpathStartSegment=a,d=c),d&&this.updateSubpathStartSegment(d),a},PRECISION:3,removeSegment:function(a){var b=this.segments,c=b.length;if(0===c)throw new Error("Path has no segments.");if(a<0&&(a=c+a),a>=c||a<0)throw new Error("Index out of range.");var d=b.splice(a,1)[0],e=d.previousSegment,f=d.nextSegment;e&&(e.nextSegment=f),f&&(f.previousSegment=e),d.isSubpathStart&&f&&this.updateSubpathStartSegment(f)},replaceSegment:function(a,b){var c=this.segments,d=c.length;if(0===d)throw new Error("Path has no segments.");if(a<0&&(a=d+a),a>=d||a<0)throw new Error("Index out of range.");var e,f=c[a],g=f.previousSegment,h=f.nextSegment,i=f.isSubpathStart;if(Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");c.splice(a,1);for(var j=b.length,k=0;k1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.segmentIndexAtLength(i,g)},toPoints:function(a){var b=this.segments,c=b.length;if(0===c)return null;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=void 0===a.segmentSubdivisions?this.getSegmentSubdivisions({precision:d}):a.segmentSubdivisions,f=[],g=[],h=0;h0){var k=j.map(function(a){return a.start});Array.prototype.push.apply(g,k)}else g.push(i.start)}else g.length>0&&(g.push(b[h-1].end),f.push(g),g=[])}return g.length>0&&(g.push(this.end),f.push(g)),f},toPolylines:function(a){var b=[],c=this.toPoints(a);if(!c)return null;for(var d=0,e=c.length;d=0;e?j++:j--){var k=c[j],l=g[j],m=k.length({precision:f,subdivisions:l});if(k.isVisible){if(a<=i+m)return j;h=j}i+=m}return h},tangentAt:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;a<0&&(a=0),a>1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.tangentAtLength(i,g)},tangentAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isDifferentiable()){if(a<=i+m)return k.tangentAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f){var n=e?1:0;return f.tangentAtT(n)}return null},tangentAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].tangentAtT(0);if(d>=c)return b[c-1].tangentAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].tangentAtT(e)},translate:function(a,b){for(var c=this.segments,d=c.length,e=0;e=0;c--){var d=a[c];if(d.isVisible)return d.end}return a[b-1].end}});var u=c.Point=function(a,b){if(!(this instanceof u))return new u(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseFloat(c[0]),b=parseFloat(c[1])}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};u.fromPolar=function(a,b,c){c=c&&new u(c)||new u(0,0);var d=e(a*f(b)),h=e(a*g(b)),i=x(z(b));return i<90?h=-h:i<180?(d=-d,h=-h):i<270&&(d=-d),new u(c.x+d,c.y+h)},u.random=function(a,b,c,d){return new u(m(o()*(b-a+1)+a),m(o()*(d-c+1)+c))},u.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=i(j(this.x,a.x),a.x+a.width),this.y=i(j(this.y,a.y),a.y+a.height),this)},bearing:function(a){return new s(this,a).bearing()},changeInAngle:function(a,b,c){return this.clone().offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return new u(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),new u(this.x-(a||0),this.y-(b||0))},distance:function(a){return new s(this,a).length()},squaredDistance:function(a){return new s(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return h(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return e(a.x-this.x)+e(a.y-this.y)},move:function(a,b){var c=A(new u(a).theta(this)),d=this.offset(f(c)*b,-g(c)*b);return d},normalize:function(a){var b=(a||1)/this.magnitude();return this.scale(b,b)},offset:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),this.x+=a||0,this.y+=b||0,this},reflection:function(a){return new u(a).move(this,this.distance(a))},rotate:function(a,b){a=a||new c.Point(0,0),b=A(x(-b));var d=f(b),e=g(b),h=d*(this.x-a.x)-e*(this.y-a.y)+a.x,i=e*(this.x-a.x)+d*(this.y-a.y)+a.y;return this.x=h,this.y=i,this},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this},scale:function(a,b,c){return c=c&&new u(c)||new u(0,0),this.x=c.x+a*(this.x-c.x),this.y=c.y+b*(this.y-c.y),this},snapToGrid:function(a,b){return this.x=y(this.x,a),this.y=y(this.y,b||a),this},theta:function(a){a=new u(a);var b=-(a.y-this.y),c=a.x-this.x,d=k(b,c);return d<0&&(d=2*n+d),180*d/n},angleBetween:function(a,b){var c=this.equals(a)||this.equals(b)?NaN:this.theta(b)-this.theta(a);return c<0&&(c+=360),c},vectorAngle:function(a){var b=new u(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&new u(a)||new u(0,0);var b=this.x,c=this.y;return this.x=h((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=A(a.theta(new u(b,c))),this},toString:function(){return this.x+"@"+this.y},update:function(a,b){return this.x=a||0,this.y=b||0,this},dot:function(a){return a?this.x*a.x+this.y*a.y:NaN},cross:function(a,b){return a&&b?(b.x-this.x)*(a.y-this.y)-(b.y-this.y)*(a.x-this.x):NaN},lerp:function(a,b){var c=this.x,d=this.y;return new u((1-b)*c+b*a.x,(1-b)*d+b*a.y)}},u.prototype.translate=u.prototype.offset;var v=c.Rect=function(a,b,c,d){return this instanceof v?(Object(a)===a&&(b=a.y,c=a.width,d=a.height,a=a.x),this.x=void 0===a?0:a,this.y=void 0===b?0:b,this.width=void 0===c?0:c,void(this.height=void 0===d?0:d)):new v(a,b,c,d)};v.fromEllipse=function(a){return a=new r(a),new v(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},v.prototype={bbox:function(a){if(!a)return this.clone();var b=A(a||0),c=e(g(b)),d=e(f(b)),h=this.width*d+this.height*c,i=this.width*c+this.height*d;return new v(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return new u(this.x,this.y+this.height)},bottomLine:function(){return new s(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new u(this.x+this.width/2,this.y+this.height); },center:function(){return new u(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new v(this)},containsPoint:function(a){return a=new u(a),a.x>=this.x&&a.x<=this.x+this.width&&a.y>=this.y&&a.y<=this.y+this.height},containsRect:function(a){var b=new v(this).normalize(),c=new v(a).normalize(),d=b.width,e=b.height,f=c.width,g=c.height;if(!(d&&e&&f&&g))return!1;var h=b.x,i=b.y,j=c.x,k=c.y;return f+=j,d+=h,g+=k,e+=i,h<=j&&f<=d&&i<=k&&g<=e},corner:function(){return new u(this.x+this.width,this.y+this.height)},equals:function(a){var b=new v(this).normalize(),c=new v(a).normalize();return b.x===c.x&&b.y===c.y&&b.width===c.width&&b.height===c.height},intersect:function(a){var b=this.origin(),c=this.corner(),d=a.origin(),e=a.corner();if(e.x<=b.x||e.y<=b.y||d.x>=c.x||d.y>=c.y)return null;var f=j(b.x,d.x),g=j(b.y,d.y);return new v(f,g,i(c.x,e.x)-f,i(c.y,e.y)-g)},intersectionWithLine:function(a){var b,c,d=this,e=[d.topLine(),d.rightLine(),d.bottomLine(),d.leftLine()],f=[],g=[],h=e.length;for(c=0;c0?f:null},intersectionWithLineFromCenterToPoint:function(a,b){a=new u(a);var c,d=new u(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],f=new s(d,a),g=e.length-1;g>=0;--g){var h=e[g].intersection(f);if(null!==h){c=h;break}}return c&&b&&c.rotate(d,-b),c},leftLine:function(){return new s(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new u(this.x,this.y+this.height/2)},moveAndExpand:function(a){return this.x+=a.x||0,this.y+=a.y||0,this.width+=a.width||0,this.height+=a.height||0,this},offset:function(a,b){return u.prototype.offset.call(this,a,b)},inflate:function(a,b){return void 0===a&&(a=0),void 0===b&&(b=a),this.x-=a,this.y-=b,this.width+=2*a,this.height+=2*b,this},normalize:function(){var a=this.x,b=this.y,c=this.width,d=this.height;return this.width<0&&(a=this.x+this.width,c=-this.width),this.height<0&&(b=this.y+this.height,d=-this.height),this.x=a,this.y=b,this.width=c,this.height=d,this},origin:function(){return new u(this.x,this.y)},pointNearestToPoint:function(a){if(a=new u(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return new u(this.x+this.width,a.y);case"left":return new u(this.x,a.y);case"bottom":return new u(a.x,this.y+this.height);case"top":return new u(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return new s(this.topRight(),this.bottomRight())},rightMiddle:function(){return new u(this.x+this.width,this.y+this.height/2)},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this.width=l(this.width*b)/b,this.height=l(this.height*b)/b,this},scale:function(a,b,c){return c=this.origin().scale(a,b,c),this.x=c.x,this.y=c.y,this.width*=a,this.height*=b,this},maxRectScaleToFit:function(a,b){a=new v(a),b||(b=a.center());var c,d,e,f,g,h,j,k,l=b.x,m=b.y;c=d=e=f=g=h=j=k=1/0;var n=a.topLeft();n.xl&&(d=(this.x+this.width-l)/(o.x-l)),o.y>m&&(h=(this.y+this.height-m)/(o.y-m));var p=a.topRight();p.x>l&&(e=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:i(c,d,e,f),sy:i(g,h,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return i(c.sx,c.sy)},sideNearestToPoint:function(a){a=new u(a);var b=a.x-this.x,c=this.x+this.width-a.x,d=a.y-this.y,e=this.y+this.height-a.y,f=b,g="left";return cb&&(b=i),jd&&(d=j)}return new v(a,c,b-a,d-c)},clone:function(){var a=this.points,b=a.length;if(0===b)return new w;for(var c=[],d=0;df.x&&(f=c[a]);var g=[];for(a=0;a2){var j=g[g.length-1];g.unshift(j)}for(var k,l,m,n,o,p,q={},r=[];0!==g.length;)if(k=g.pop(),l=k[0],!q.hasOwnProperty(k[0]+"@@"+k[1]))for(var s=!1;!s;)if(r.length<2)r.push(k),s=!0;else{m=r.pop(),n=m[0],o=r.pop(),p=o[0];var t=p.cross(n,l);if(t<0)r.push(o),r.push(m),r.push(k),s=!0;else if(0===t){var u=1e-10,v=n.angleBetween(p,l);e(v-180)2&&r.pop();var x,y=-1;for(b=r.length,a=0;a0){var B=r.slice(y),C=r.slice(0,y);A=B.concat(C)}else A=r;var D=[];for(b=A.length,a=0;a=1)return b[c-1].clone();var d=this.length(),e=d*a;return this.pointAtLength(e)},pointAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return b[0].clone();var d=!0;a<0&&(d=!1,a=-a);for(var e=0,f=c-1,g=d?0:f-1;d?g=0;d?g++:g--){var h=b[g],i=b[g+1],j=new s(h,i),k=h.distance(i);if(a<=e+k)return j.pointAtLength((d?1:-1)*(a-e));e+=k}var l=d?b[c-1]:b[0];return l.clone()},scale:function(a,b,c){var d=this.points,e=d.length;if(0===e)return this;for(var f=0;f1&&(a=1);var d=this.length(),e=d*a;return this.tangentAtLength(e)},tangentAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return null;var d=!0;a<0&&(d=!1,a=-a);for(var e,f=0,g=c-1,h=d?0:g-1;d?h=0;d?h++:h--){var i=b[h],j=b[h+1],k=new s(i,j),l=i.distance(j);if(k.isDifferentiable()){if(a<=f+l)return k.tangentAtLength((d?1:-1)*(a-f));e=k}f+=l}if(e){var m=d?1:0;return e.tangentAt(m)}return null},intersectionWithLine:function(a){for(var b=new s(a),c=[],d=this.points,e=0,f=d.length-1;e0?c:null},translate:function(a,b){var c=this.points,d=c.length;if(0===d)return this;for(var e=0;e=1?b:b*a},pointAtT:function(a){if(this.pointAt)return this.pointAt(a);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,subpathStartSegment:null,tangentAtT:function(a){if(this.tangentAt)return this.tangentAt(a);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},length:function(){throw new Error("Declaration missing for virtual function.")},pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},scale:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},toString:function(){throw new Error("Declaration missing for virtual function.")}},C=function(){for(var b=[],c=arguments.length,d=0;d0)throw new Error("Closepath constructor expects no arguments.");return this},J={clone:function(){return new I},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},scale:function(){return this},translate:function(){return this},type:"Z",serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end}};Object.defineProperty(J,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(J,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),I.prototype=b(B,s.prototype,J);var K=t.segmentTypes={L:C,C:E,M:G,Z:I,z:I};return t.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(K).join("")+",.]*$"),t.isDataSupported=function(a){return"string"==typeof a&&this.regexSupportedData.test(a)},c}(); var V,Vectorizer;V=Vectorizer=function(){"use strict";function a(a,b){a||(a={});var c=q("textPath"),d=a.d;if(d&&void 0===a["xlink:href"]){var e=q("path").attr("d",d).appendTo(b.defs());c.attr("xlink:href","#"+e.id)}return q.isObject(a)&&c.attr(a),c.node}function b(a,b,c){c||(c={});for(var d=c.includeAnnotationIndices,e=c.eol,f=c.lineHeight,g=c.baseSize,h=0,i={},j=b.length-1,k=0;k<=j;k++){var l=b[k],m=null;if(q.isObject(l)){var n=l.attrs,o=q("tspan",n),p=o.node,r=l.t;e&&k===j&&(r+=e),p.textContent=r;var s=n.class;s&&o.addClass(s),d&&o.attr("annotations",l.annotations),m=parseFloat(n["font-size"]),void 0===m&&(m=g),m&&m>h&&(h=m)}else e&&k===j&&(l+=e),p=document.createTextNode(l||" "),g&&g>h&&(h=g);a.appendChild(p)}return h&&(i.maxFontSize=h),f?i.lineHeight=f:h&&(i.lineHeight=1.2*h),i}function c(a,b){var c=parseFloat(a);return s.test(a)?c*b:c}function d(a,b,d,e){if(!Array.isArray(b))return 0;var f=b.length;if(!f)return 0;for(var g=b[0],h=c(g.maxFontSize,d)||d,i=0,j=c(e,d),k=1;k1){var e,g,h=[];for(e=0,g=d.childNodes.length;e0&&D.setAttribute("dy",B),(y>0||g)&&D.setAttribute("x",j),D.className.baseVal=C,r.appendChild(D),v+=E.length+1}if(i)if(l)B=d(h,x,p,o);else if("top"===h)B="0.8em";else{var I;switch(z>0?(I=parseFloat(o)||1,I*=z,s.test(o)||(I/=p)):I=0,h){case"middle":B=.3-I/2+"em";break;case"bottom":B=-I-.3+"em"}}else 0===h?B="0em":h?B=h:(B=0,null===this.attr("y")&&this.attr("y",u||"0.8em"));return r.firstChild.setAttribute("dy",B),this.append(r),this},r.removeAttr=function(a){var b=q.qualifyAttr(a),c=this.node;return b.ns?c.hasAttributeNS(b.ns,b.local)&&c.removeAttributeNS(b.ns,b.local):c.hasAttribute(a)&&c.removeAttribute(a),this},r.attr=function(a,b){if(q.isUndefined(a)){for(var c=this.node.attributes,d={},e=0;e1&&k.push(k[0]),new g.Polyline(k);case"PATH":return l=this.attr("d"),g.Path.isDataSupported(l)||(l=q.normalizePathData(l)),new g.Path(l);case"LINE":return x1=parseFloat(this.attr("x1"))||0,y1=parseFloat(this.attr("y1"))||0,x2=parseFloat(this.attr("x2"))||0,y2=parseFloat(this.attr("y2"))||0,new g.Line({x:x1,y:y1},{x:x2,y:y2})}return this.getBBox()},r.findIntersection=function(a,b){var c=this.svg().node;b=b||c;var d=this.getBBox({target:b}),e=d.center();if(d.intersectionWithLineFromCenterToPoint(a)){var f,h=this.tagName();if("RECT"===h){var i=new g.Rect(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),j=this.getTransformToElement(b),k=q.decomposeMatrix(j),l=c.createSVGTransform();l.setRotate(-k.rotation,e.x,e.y);var m=q.transformRect(i,l.matrix.multiply(j));f=new g.Rect(m).intersectionWithLineFromCenterToPoint(a,k.rotation)}else if("PATH"===h||"POLYGON"===h||"POLYLINE"===h||"CIRCLE"===h||"ELLIPSE"===h){var n,o,p,r,s,t,u="PATH"===h?this:this.convertToPath(),v=u.sample(),w=1/0,x=[];for(n=0;n'+(a||"")+"",c=q.parseXML(b,{async:!1});return c.documentElement},q.idCounter=0,q.uniqueId=function(){return"v-"+ ++q.idCounter},q.toNode=function(a){return q.isV(a)?a.node:a.nodeName&&a||a[0]},q.ensureId=function(a){return a=q.toNode(a),a.id||(a.id=q.uniqueId())},q.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},q.isUndefined=function(a){return"undefined"==typeof a},q.isString=function(a){return"string"==typeof a},q.isObject=function(a){return a&&"object"==typeof a},q.isArray=Array.isArray,q.parseXML=function(a,b){b=b||{};var c;try{var d=new DOMParser;q.isUndefined(b.async)||(d.async=b.async),c=d.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},q.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var b=a.split(":");return{ns:f[b[0]],local:b[1]}}return{ns:null,local:a}},q.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,q.transformSeparatorRegex=/[ ,]+/,q.transformationListRegex=/^(\w+)\((.*)\)/,q.transformStringToMatrix=function(a){var b=q.createSVGMatrix(),c=a&&a.match(q.transformRegex);if(!c)return b;for(var d=0,e=c.length;d=0){var f=q.transformStringToMatrix(a),g=q.decomposeMatrix(f);b=[g.translateX,g.translateY],d=[g.scaleX,g.scaleY],c=[g.rotation];var h=[];0===b[0]&&0===b[0]||h.push("translate("+b+")"),1===d[0]&&1===d[1]||h.push("scale("+d+")"),0!==c[0]&&h.push("rotate("+c+")"),a=h.join(" ")}else{var i=a.match(/translate\((.*?)\)/);i&&(b=i[1].split(e));var j=a.match(/rotate\((.*?)\)/);j&&(c=j[1].split(e));var k=a.match(/scale\((.*?)\)/);k&&(d=k[1].split(e))}}var l=d&&d[0]?parseFloat(d[0]):1;return{value:a,translate:{tx:b&&b[0]?parseInt(b[0],10):0,ty:b&&b[1]?parseInt(b[1],10):0},rotate:{angle:c&&c[0]?parseInt(c[0],10):0,cx:c&&c[1]?parseInt(c[1],10):void 0,cy:c&&c[2]?parseInt(c[2],10):void 0},scale:{sx:l,sy:d&&d[1]?parseFloat(d[1]):l}}},q.deltaTransformPoint=function(a,b){var c=b.x*a.a+b.y*a.c+0,d=b.x*a.b+b.y*a.d+0;return{x:c,y:d}},q.decomposeMatrix=function(a){var b=q.deltaTransformPoint(a,{x:0,y:1}),c=q.deltaTransformPoint(a,{x:1,y:0}),d=180/j*k(b.y,b.x)-90,e=180/j*k(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:l(a.a*a.a+a.b*a.b),scaleY:l(a.c*a.c+a.d*a.d),skewX:d,skewY:e,rotation:d}},q.matrixToScale=function(a){var b,c,d,e;return a?(b=q.isUndefined(a.a)?1:a.a,e=q.isUndefined(a.d)?1:a.d,c=a.b,d=a.c):b=e=1,{sx:c?l(b*b+c*c):b,sy:d?l(d*d+e*e):e}},q.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=q.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(k(b.y,b.x))-90)}},q.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},q.isV=function(a){return a instanceof q},q.isVElement=q.isV;var t=q("svg").node;return q.createSVGMatrix=function(a){var b=t.createSVGMatrix();for(var c in a)b[c]=a[c];return b},q.createSVGTransform=function(a){return q.isUndefined(a)?t.createSVGTransform():(a instanceof SVGMatrix||(a=q.createSVGMatrix(a)),t.createSVGTransformFromMatrix(a))},q.createSVGPoint=function(a,b){var c=t.createSVGPoint();return c.x=a,c.y=b,c},q.transformRect=function(a,b){var c=t.createSVGPoint();c.x=a.x,c.y=a.y;var d=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y;var e=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var f=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var h=c.matrixTransform(b),i=m(d.x,e.x,f.x,h.x),j=n(d.x,e.x,f.x,h.x),k=m(d.y,e.y,f.y,h.y),l=n(d.y,e.y,f.y,h.y);return new g.Rect(i,k,j-i,l-k)},q.transformPoint=function(a,b){return new g.Point(q.createSVGPoint(a.x,a.y).matrixTransform(b))},q.transformLine=function(a,b){return new g.Line(q.transformPoint(a.start,b),q.transformPoint(a.end,b))},q.transformPolyline=function(a,b){var c=a instanceof g.Polyline?a.points:a;q.isArray(c)||(c=[]);for(var d=[],e=0,f=c.length;e=e?f?"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"M0,"+f+"A"+f+","+f+" 0 1,0 0,"+-f+"A"+f+","+f+" 0 1,0 0,"+f+"Z":"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"Z":f?"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L"+f*q+","+f*r+"A"+f+","+f+" 0 "+l+",0 "+f*m+","+f*n+"Z":"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L0,0Z"},q.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?q.isObject(a[c])&&q.isObject(b[c])?a[c]=q.mergeAttrs(a[c],b[c]):q.isObject(a[c])?a[c]=q.mergeAttrs(a[c],q.styleToObject(b[c])):q.isObject(b[c])?a[c]=q.mergeAttrs(q.styleToObject(a[c]),b[c]):a[c]=q.mergeAttrs(q.styleToObject(a[c]),q.styleToObject(b[c])):a[c]=b[c];return a},q.annotateString=function(a,b,c){b=b||[],c=c||{};for(var d,e,f,g=c.offset||0,h=[],i=[],j=0;j=m&&j=a.start&&ba.start&&c<=a.end||a.start>=b&&a.end=b?a.end+=c:a.start>=b&&(a.start+=c,a.end+=c)}),a},q.convertLineToPathData=function(a){a=q(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},q.convertPolygonToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)+" Z"},q.convertPolylineToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)},q.svgPointsToPath=function(a){for(var b=0,c=a.length;b1&&(z=o(z),d*=z,e*=z);var A=d*d,B=e*e,C=(g==h?-1:1)*o(p((A*B-A*y*y-B*x*x)/(A*y*y+B*x*x))),D=C*d*y/e+(a+i)/2,E=C*-e*x/d+(c+q)/2,F=n(((c-E)/e).toFixed(9)),G=n(((q-E)/e).toFixed(9));F=aG&&(F-=2*j),(!h&&G)>F&&(G-=2*j)}var H=G-F;if(p(H)>t){var I=G,J=i,K=q;G=F+t*((h&&G)>F?1:-1),i=D+d*l(G),q=E+e*k(G),v=b(i,q,d,e,f,0,h,J,K,[G,I,D,E])}H=G-F;var L=l(F),M=k(F),N=l(G),O=k(G),P=m(H/4),Q=4/3*(d*P),R=4/3*(e*P),S=[a,c],T=[a+Q*M,c-R*L],U=[i+Q*O,q-R*N],V=[i,q];if(T[0]=2*S[0]-T[0],T[1]=2*S[1]-T[1],r)return[T,U,V].concat(v);v=[T,U,V].concat(v).join().split(",");for(var W=[],X=v.length,Y=0;Y2&&(c.push([d].concat(f.splice(0,2))),g="l",d="m"===d?"l":"L");f.length>=b[g]&&(c.push([d].concat(f.splice(0,b[g]))),b[g]););}),c}function d(a){if(Array.isArray(a)&&Array.isArray(a&&a[0])||(a=c(a)),!a||!a.length)return[["M",0,0]];for(var b,d=[],e=0,f=0,g=0,h=0,i=0,j=a.length,k=i;k7){a[b].shift();for(var c=a[b];c.length;)i[b]="A",a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),l=g.length}}for(var g=d(c),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=[],j="",k="",l=g.length,m=0;m0&&(k=i[m-1])),g[m]=e(g[m],h,k),"A"!==i[m]&&"C"===j&&(i[m]="C"),f(g,m);var n=g[m],o=n.length;h.x=n[o-2],h.y=n[o-1],h.bx=parseFloat(n[o-4])||h.x,h.by=parseFloat(n[o-3])||h.y}return g[0][0]&&"M"===g[0][0]||g.unshift(["M",0,0]),g}var f="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",g=new RegExp("([a-z])["+f+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+f+"]*,?["+f+"]*)+)","ig"),h=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+f+"]*,?["+f+"]*","ig"),i=Math,j=i.PI,k=i.sin,l=i.cos,m=i.tan,n=i.asin,o=i.sqrt,p=i.abs;return function(a){return e(a).join(",").split(",").join(" ")}}(),q.namespace=f,q}(); -var joint={version:"2.1.1",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},anchors:{},connectionPoints:{},connectionStrategies:{},linkTools:{},mvc:{views:{}},setTheme:function(a,b){b=b||{},joint.util.invoke(joint.mvc.views,"setTheme",a,b),joint.mvc.View.prototype.defaultTheme=a},env:{_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(a,b){return joint.env._tests[a]=b},test:function(a){var b=joint.env._tests[a];if(!b)throw new Error('Test not defined ("'+a+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var c=joint.env._results[a];if("undefined"!=typeof c)return c;try{c=b()}catch(a){c=!1}return joint.env._results[a]=c,c}},util:{hashCode:function(a){var b=0;if(0==a.length)return b;for(var c=0;c0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), -d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return b=null!=d&&this.model.hasPort(d)?this.findPortNode(d,e)||c:this.findBySelector(e||a.selector,c,this.selectors)[0]},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), +d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return null!=d&&this.model.hasPort(d)?b=this.findPortNode(d,e)||c:(e||(e=a.selector),e||null==d||(e='[port="'+d+'"]'),b=this.findBySelector(e,c,this.selectors)[0]),b},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){this.startBatch("fit-embeds",a),a.deep&&joint.util.invoke(b,"fitEmbeds",a);var c=this.graph.getCellsBBox(b),d=joint.util.normalizeSides(a.padding);c.moveAndExpand({x:-d.left,y:-d.top,width:d.right+d.left,height:d.bottom+d.top}),this.set({position:{x:c.x,y:c.y},size:{width:c.width,height:c.height}},a),this.stopBatch("fit-embeds")}return this},rotate:function(a,b,c,d){if(c){var e=this.getBBox().center(),f=this.get("size"),g=this.get("position");e.rotate(c,this.get("angle")-a);var h=e.x-f.width/2-g.x,i=e.y-f.height/2-g.y;this.startBatch("rotate",{angle:a,absolute:b,origin:c}),this.position(g.x+h,g.y+i,d),this.rotate(a,b,null,d),this.stopBatch("rotate")}else this.set("angle",b?a:(this.get("angle")+a)%360,d);return this},angle:function(){return g.normalizeAngle(this.get("angle")||0)},getBBox:function(a){if(a=a||{},a.deep&&this.graph){var b=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return b.push(this),this.graph.getCellsBBox(b)}var c=this.get("position"),d=this.get("size");return new g.Rect(c.x,c.y,d.width,d.height)}}),joint.dia.ElementView=joint.dia.CellView.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("element"),a.join(" ")},metrics:null,initialize:function(){joint.dia.CellView.prototype.initialize.apply(this,arguments);var a=this.model;this.listenTo(a,"change:position",this.translate),this.listenTo(a,"change:size",this.resize),this.listenTo(a,"change:angle",this.rotate),this.listenTo(a,"change:markup",this.render),this._initializePorts(),this.metrics={}},_initializePorts:function(){},update:function(a,b){this.metrics={},this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:new g.Rect(c.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.ElementView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.ElementView: ambiguous root selector.");c[d]=this.el,this.rotatableNode=V(c[this.rotatableSelector])||null,this.scalableNode=V(c[this.scalableSelector])||null,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=this.vel;b.append(V(a)),this.rotatableNode=b.findOne(".rotatable"),this.scalableNode=b.findOne(".scalable");var c=this.selectors={};c[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate(),this):(this.updateTransformation(),this)},resize:function(){return this.scalableNode?this.sgResize.apply(this,arguments):(this.model.attributes.angle&&this.rotate(),void this.update())},translate:function(){return this.rotatableNode?this.rgTranslate():void this.updateTransformation()},rotate:function(){return this.rotatableNode?this.rgRotate():void this.updateTransformation()},updateTransformation:function(){var a=this.getTranslateString(),b=this.getRotateString();b&&(a+=" "+b),this.vel.attr("transform",a)},getTranslateString:function(){var a=this.model.attributes.position;return"translate("+a.x+","+a.y+")"},getRotateString:function(){var a=this.model.attributes,b=a.angle;if(!b)return null;var c=a.size;return"rotate("+b+","+c.width/2+","+c.height/2+")"},getBBox:function(a){var b;if(a&&a.useModelGeometry){var c=this.model;b=c.getBBox().bbox(c.angle())}else b=this.getNodeBBox(this.el);return this.paper.localToPaperRect(b)},nodeCache:function(a){var b=V.ensureId(a),c=this.metrics[b];return c||(c=this.metrics[b]={}),c},getNodeData:function(a){var b=this.nodeCache(a);return b.data||(b.data={}),b.data},getNodeBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix(),e=this.getRootRotateMatrix();return V.transformRect(b,d.multiply(e).multiply(c))},getNodeBoundingRect:function(a){var b=this.nodeCache(a);return void 0===b.boundingRect&&(b.boundingRect=V(a).getBBox()),new g.Rect(b.boundingRect)},getNodeUnrotatedBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix();return V.transformRect(b,d.multiply(c))},getNodeShape:function(a){var b=this.nodeCache(a);return void 0===b.geometryShape&&(b.geometryShape=V(a).toGeometryShape()),b.geometryShape.clone()},getNodeMatrix:function(a){var b=this.nodeCache(a);if(void 0===b.magnetMatrix){var c=this.rotatableNode||this.el;b.magnetMatrix=V(a).getTransformToElement(c)}return V.createSVGMatrix(b.magnetMatrix)},getRootTranslateMatrix:function(){var a=this.model,b=a.position(),c=V.createSVGMatrix().translate(b.x,b.y);return c},getRootRotateMatrix:function(){var a=V.createSVGMatrix(),b=this.model,c=b.angle();if(c){var d=b.getBBox(),e=d.width/2,f=d.height/2;a=a.translate(e,f).rotate(c).translate(-e,-f)}return a},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(a,b,c){var d=this.model,e=d.get("angle")||0,f=d.get("size")||{width:1,height:1},g=this.scalableNode,h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=f.width/(i.width||1),k=f.height/(i.height||1);g.attr("transform","scale("+j+","+k+")");var l=this.rotatableNode,m=l&&l.attr("transform");if(m&&null!==m){l.attr("transform",m+" rotate("+-e+","+f.width/2+","+f.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},prepareEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front"),b.toFront({deep:!0,ui:!0});var e=d.get("cells").max("z").get("z"),f=d.getConnectedLinks(b,{deep:!0});joint.util.invoke(f,"set","z",e+1,{ui:!0}),b.stopBatch("to-front");var g=b.parent();g&&d.getCell(g).unembed(b,{ui:!0})},processEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.options,e=[];if(joint.util.isFunction(d.findParentBy)){var f=joint.util.toArray(d.findParentBy.call(c.model,this));e=f.filter(function(a){return a instanceof joint.dia.Cell&&this.model.id!==a.id&&!a.isEmbeddedIn(this.model)}.bind(this))}else e=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var g=null,h=a.candidateEmbedView,i=e.length-1;i>=0;i--){var j=e[i];if(h&&h.model.id==j.id){g=h;break}var k=j.findView(c);if(d.validateEmbedding.call(c,this,k)){g=k;break}}g&&g!=h&&(this.clearEmbedding(a),a.candidateEmbedView=g.highlight(null,{embedding:!0})),!g&&h&&this.clearEmbedding(a)},clearEmbedding:function(a){a||(a={});var b=a.candidateEmbedView;b&&(b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null)},finalizeEmbedding:function(a){a||(a={});var b=a.candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdblclick:function(a,b,c){joint.dia.CellView.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",a,b,c)},pointerclick:function(a,b,c){joint.dia.CellView.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",a,b,c)},contextmenu:function(a,b,c){joint.dia.CellView.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",a,b,c)},pointerdown:function(a,b,c){joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c),this.dragStart(a,b,c)},pointermove:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.drag(a,b,c);break;case"magnet":this.dragMagnet(a,b,c)}d.stopPropagation||(joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)),this.eventData(a,d)},pointerup:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.dragEnd(a,b,c);break;case"magnet":return void this.dragMagnetEnd(a,b,c)}d.stopPropagation||(this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},mouseover:function(a){joint.dia.CellView.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",a)},mouseout:function(a){joint.dia.CellView.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",a)},mouseenter:function(a){joint.dia.CellView.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",a)},mouseleave:function(a){joint.dia.CellView.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",a)},mousewheel:function(a,b,c,d){joint.dia.CellView.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",a,b,c,d)},onmagnet:function(a,b,c){this.dragMagnetStart(a,b,c);var d=this.eventData(a).stopPropagation;d&&a.stopPropagation()},dragStart:function(a,b,c){this.can("elementMove")&&this.eventData(a,{action:"move",x:b,y:c,restrictedArea:this.paper.getRestrictedArea(this)})},dragMagnetStart:function(a,b,c){if(this.can("addLinkFromMagnet")){this.model.startBatch("add-link");var d=this.paper,e=d.model,f=a.target,g=d.getDefaultLink(this,f),h=this.getLinkEnd(f,b,c,g,"source"),i={x:b,y:c};g.set({source:h,target:i}),g.addTo(e,{async:!1,ui:!0});var j=g.findView(d);joint.dia.CellView.prototype.pointerdown.apply(j,arguments),j.notify("link:pointerdown",a,b,c);var k=j.startArrowheadMove("target",{whenNotAllowed:"remove"});j.eventData(a,k),this.eventData(a,{action:"magnet",linkView:j,stopPropagation:!0}),this.paper.delegateDragEvents(this,a.data)}},drag:function(a,b,c){var d=this.paper,e=d.options.gridSize,f=this.model,h=f.position(),i=this.eventData(a),j=g.snapToGrid(h.x,e)-h.x+g.snapToGrid(b-i.x,e),k=g.snapToGrid(h.y,e)-h.y+g.snapToGrid(c-i.y,e);f.translate(j,k,{restrictedArea:i.restrictedArea,ui:!0});var l=!!i.embedding;d.options.embeddingMode&&(l||(this.prepareEmbedding(i),l=!0),this.processEmbedding(i)),this.eventData(a,{x:g.snapToGrid(b,e),y:g.snapToGrid(c,e),embedding:l})},dragMagnet:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointermove(a,b,c)},dragEnd:function(a,b,c){var d=this.eventData(a);d.embedding&&this.finalizeEmbedding(d)},dragMagnetEnd:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointerup(a,b,c),this.model.stopBatch("add-link")}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),doubleToolMarkup:void 0,vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",yAlignment:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,refWidth:1,refHeight:1,refX:0,refY:0}},position:{distance:.5}}},defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(a){return this.set({source:{x:0,y:0},target:{x:0,y:0}},a)},source:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("source"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("source",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("source",d,e)):(d=a,e=b,this.set("source",d,e))},target:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("target"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("target",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("target",d,e)):(d=a,e=b,this.set("target",d,e))},router:function(a,b,c){if(void 0===a){var d=this.get("router");return d?"object"==typeof d?joint.util.clone(d):d:this.get("manhattan")?{name:"orthogonal"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("router",f,g)},connector:function(a,b,c){if(void 0===a){var d=this.get("connector");return d?"object"==typeof d?joint.util.clone(d):d:this.get("smooth")?{name:"smooth"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("connector",f,g)},label:function(a,b,c){var d=this.labels();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},labels:function(a,b){return 0===arguments.length?(a=this.get("labels"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("labels",a,b))},insertLabel:function(a,b,c){if(!b)throw new Error("dia.Link: no label provided");var d=this.labels(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.labels(d,c)},appendLabel:function(a,b){return this.insertLabel(-1,a,b)},removeLabel:function(a,b){var c=this.labels();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.labels(c,b)},vertex:function(a,b,c){var d=this.vertices();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["vertices",a]):this.prop(["vertices",a],b,c)},vertices:function(a,b){return 0===arguments.length?(a=this.get("vertices"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("vertices",a,b))},insertVertex:function(a,b,c){if(!b)throw new Error("dia.Link: no vertex provided");var d=this.vertices(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.vertices(d,c)},removeVertex:function(a,b){var c=this.vertices();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.vertices(c,b)},translate:function(a,b,c){return c=c||{},c.translateBy=c.translateBy||this.id,c.tx=a,c.ty=b,this.applyToPoints(function(c){return{x:(c.x||0)+a,y:(c.y||0)+b}},c)},scale:function(a,b,c,d){return this.applyToPoints(function(d){return g.point(d).scale(a,b,c).toJSON()},d)},applyToPoints:function(a,b){if(!joint.util.isFunction(a))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var c={},d=this.source();d.id||(c.source=a(d));var e=this.target();e.id||(c.target=a(e));var f=this.vertices();return f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.getSourceElement(),d=this.getTargetElement(),e=this.getParentCell();c&&d&&(b=this.graph.getCommonAncestor(c,d)),!e||b&&b.id===e.id||e.unembed(this,a),b&&b.embed(this,a)}return b},hasLoop:function(a){a=a||{};var b=this.source().id,c=this.target().id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.getSourceElement(),f=this.getTargetElement();d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.source(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getTargetElement:function(){var a=this.target(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getRelationshipAncestor:function(){var a;if(this.graph){var b=[this,this.getSourceElement(),this.getTargetElement()].filter(function(a){return!!a});a=this.graph.getCommonAncestor.apply(this.graph,b)}return a||null},isRelationshipEmbeddedIn:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(b))},_getDefaultLabel:function(){var a=this.get("defaultLabel")||this.defaultLabel||{},b={};return b.markup=a.markup||this.get("labelMarkup")||this.labelMarkup,b.position=a.position,b.attrs=a.attrs,b.size=a.size,b}},{endsEqual:function(a,b){var c=a.port===b.port||!a.port&&!b.port;return a.id===b.id&&c}}),joint.dia.LinkView=joint.dia.CellView.extend({className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("link"),a.join(" ")},options:{shortLinkLength:105,doubleLinkTools:!1,longLinkLength:155,linkToolsOffset:40,doubleLinkToolsOffset:65,sampleInterval:50},_labelCache:null,_labelSelectors:null,_markerCache:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(a){joint.dia.CellView.prototype.initialize.apply(this,arguments),"function"!=typeof this.constructor.prototype.watchSource&&(this.constructor.prototype.watchSource=this.createWatcher("source"),this.constructor.prototype.watchTarget=this.createWatcher("target")),this._labelCache={},this._labelSelectors={},this._markerCache={},this._V={},this.metrics={},this.startListening()},startListening:function(){var a=this.model;this.listenTo(a,"change:markup",this.render),this.listenTo(a,"change:smooth change:manhattan change:router change:connector",this.update),this.listenTo(a,"change:toolMarkup",this.onToolsChange),this.listenTo(a,"change:labels change:labelMarkup",this.onLabelsChange),this.listenTo(a,"change:vertices change:vertexMarkup",this.onVerticesChange),this.listenTo(a,"change:source",this.onSourceChange),this.listenTo(a,"change:target",this.onTargetChange)},onSourceChange:function(a,b,c){this.watchSource(a,b);var d=this.model;c.translateBy&&d.get("target").id&&b.id||this.update(d,null,c)},onTargetChange:function(a,b,c){this.watchTarget(a,b);var d=this.model;(!c.translateBy||d.get("source").id&&!b.id&&joint.util.isEmpty(d.get("vertices")))&&this.update(d,null,c)},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||this.update(a,null,c)},onToolsChange:function(){this.renderTools().updateToolsPosition()},onLabelsChange:function(a,b,c){var d=!0,e=this.model.previous("labels");if(e&&"propertyPathArray"in c&&"propertyValue"in c){var f=c.propertyPathArray||[],g=f.length;if(g>1){var h=!!e[f[1]];h&&(2===g?d="markup"in Object(c.propertyValue):"markup"!==f[2]&&(d=!1))}}d?this.renderLabels():this.updateLabels(),this.updateLabelPositions()},render:function(){this.vel.empty(),this._V={},this.renderMarkup(),this.renderLabels();var a=this.model;return this.watchSource(a,a.source()).watchTarget(a,a.target()).update(),this},renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.LinkView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.LinkView: ambiguous root selector.");c[d]=this.el,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=V(a);Array.isArray(b)||(b=[b]);for(var c=this._V,d=0,e=b.length;d1||"G"!==d[0].nodeName.toUpperCase()?(c=V("g"),c.append(b),c.addClass("label")):(c=V(d[0]),c.addClass("label")),{node:c.node,selectors:a.selectors}}},renderLabels:function(){var a=this._V,b=a.labels,c=this._labelCache={},d=this._labelSelectors={};b&&b.empty();var e=this.model,f=e.get("labels")||[],g=f.length;if(0===g)return this;b||(b=a.labels=V("g").addClass("labels").appendTo(this.el));for(var h=0;h=this.options.longLinkLength){var e=this.options.doubleLinkToolsOffset||b;d=this.getPointAtLength(c-e),this._tool2Cache.attr("transform","translate("+d.x+", "+d.y+") "+a),this._tool2Cache.attr("visibility","visible")}else this.options.doubleLinkTools&&this._tool2Cache.attr("visibility","hidden")}return this},updateArrowheadMarkers:function(){if(!this._V.markerArrowheads)return this;if("none"===$.css(this._V.markerArrowheads.node,"display"))return this;var a=this.getConnectionLength()0&&b<=1,d=0,e={x:0,y:0};if(a.offset){var f=a.offset;"number"==typeof f&&(d=f),f.x&&(e.x=f.x),f.y&&(e.y=f.y)}var g,h=0!==e.x||0!==e.y||0===d,i=this.path,j={segmentSubdivisions:this.getConnectionSubdivisions()},k=c?b*this.getConnectionLength():b;if(h)g=i.pointAtLength(k,j),g.offset(e);else{var l=i.tangentAtLength(k,j);l?(l.rotate(l.start,-90),l.setLength(d),g=l.end):g=i.start}return g},getVertexIndex:function(a,b){for(var c=this.model,d=c.vertices(),e=this.getClosestPointLength(new g.Point(a,b)),f=0,h=d.length;f0){for(var j=0,k=i.length;j").addClass(joint.util.addClassNamePrefix("paper-background")),this.options.background&&this.drawBackground(this.options.background),this.$grid=$("
").addClass(joint.util.addClassNamePrefix("paper-grid")),this.options.drawGrid&&this.drawGrid(),this.$el.append(this.$background,this.$grid,this.svg),this},update:function(){return this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background),this},_viewportMatrix:null,_viewportTransformString:null,matrix:function(a){var b=this.viewport;if(void 0===a){var c=b.getAttribute("transform");return(this._viewportTransformString||null)===c?a=this._viewportMatrix:(a=b.getCTM(),this._viewportMatrix=a,this._viewportTransformString=c),V.createSVGMatrix(a)}return a=V.createSVGMatrix(a),ctmString=V.matrixToTransformString(a),b.setAttribute("transform",ctmString),this.tools.setAttribute("transform",ctmString),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_sortDelayingBatches:["add","to-front","to-back"],_onSort:function(){this.model.hasActiveBatch(this._sortDelayingBatches)||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;this._sortDelayingBatches.includes(b)&&!this.model.hasActiveBatch(this._sortDelayingBatches)&&this.sortViews()},onRemove:function(){this.removeViews()},setDimensions:function(a,b){a=this.options.width=a||this.options.width,b=this.options.height=b||this.options.height,this.$el.css({width:Math.round(a),height:Math.round(b)}),this.trigger("resize",a,b)},setOrigin:function(a,b){return this.translate(a||0,b||0,{absolute:!0})},fitToContent:function(a,b,c,d){joint.util.isObject(a)?(d=a,a=d.gridWidth||1,b=d.gridHeight||1,c=d.padding||0):(d=d||{},a=a||1,b=b||1,c=c||0),c=joint.util.normalizeSides(c);var e=V(this.viewport).getBBox(),f=this.scale(),g=this.translate();e.x*=f.sx,e.y*=f.sy,e.width*=f.sx,e.height*=f.sy;var h=Math.max(Math.ceil((e.width+e.x)/a),1)*a,i=Math.max(Math.ceil((e.height+e.y)/b),1)*b,j=0,k=0;("negative"==d.allowNewOrigin&&e.x<0||"positive"==d.allowNewOrigin&&e.x>=0||"any"==d.allowNewOrigin)&&(j=Math.ceil(-e.x/a)*a,j+=c.left,h+=j),("negative"==d.allowNewOrigin&&e.y<0||"positive"==d.allowNewOrigin&&e.y>=0||"any"==d.allowNewOrigin)&&(k=Math.ceil(-e.y/b)*b,k+=c.top,i+=k),h+=c.right,i+=c.bottom,h=Math.max(h,d.minWidth||0),i=Math.max(i,d.minHeight||0),h=Math.min(h,d.maxWidth||Number.MAX_VALUE),i=Math.min(i,d.maxHeight||Number.MAX_VALUE);var l=h!=this.options.width||i!=this.options.height,m=j!=g.tx||k!=g.ty;m&&this.translate(j,k),l&&this.setDimensions(h,i)},scaleContentToFit:function(a){var b=this.getContentBBox();if(b.width&&b.height){a=a||{},joint.util.defaults(a,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE});var c,d=a.padding,e=a.minScaleX||a.minScale,f=a.maxScaleX||a.maxScale,h=a.minScaleY||a.minScale,i=a.maxScaleY||a.maxScale;if(a.fittingBBox)c=a.fittingBBox;else{var j=this.translate();c={x:j.tx,y:j.ty,width:this.options.width,height:this.options.height}}c=g.rect(c).moveAndExpand({x:d,y:d,width:-2*d,height:-2*d});var k=this.scale(),l=c.width/b.width*k.sx,m=c.height/b.height*k.sy;if(a.preserveAspectRatio&&(l=m=Math.min(l,m)),a.scaleGrid){var n=a.scaleGrid;l=n*Math.floor(l/n),m=n*Math.floor(m/n)}l=Math.min(f,Math.max(e,l)),m=Math.min(i,Math.max(h,m)),this.scale(l,m);var o=this.getContentBBox(),p=c.x-o.x,q=c.y-o.y;this.translate(p,q)}},getContentArea:function(){return V(this.viewport).getBBox()},getContentBBox:function(){var a=this.viewport.getBoundingClientRect(),b=this.clientMatrix(),c=this.translate();return g.rect({x:a.left-b.e+c.tx,y:a.top-b.f+c.ty,width:a.width,height:a.height})},getArea:function(){return this.paperToLocalRect({x:0,y:0,width:this.options.width,height:this.options.height})},getRestrictedArea:function(){var a;return a=joint.util.isFunction(this.options.restrictTranslate)?this.options.restrictTranslate.apply(this,arguments):this.options.restrictTranslate===!0?this.getArea():this.options.restrictTranslate||null},createViewForModel:function(a){var b,c,d=this.options.cellViewNamespace,e=a.get("type")+"View",f=joint.util.getByPath(d,e,".");a.isLink()?(b=this.options.linkView,c=joint.dia.LinkView):(b=this.options.elementView,c=joint.dia.ElementView);var g=b.prototype instanceof Backbone.View?f||b:b.call(this,a)||f||c;return new g({model:a,interactive:this.options.interactive})},onCellAdded:function(a,b,c){if(this.options.async&&c.async!==!1&&joint.util.isNumber(c.position)){if(this._asyncCells=this._asyncCells||[],this._asyncCells.push(a),0==c.position){if(this._frameId)throw new Error("another asynchronous rendering in progress");this.asyncRenderViews(this._asyncCells,c),delete this._asyncCells}}else this.renderView(a)},removeView:function(a){var b=this._views[a.id];return b&&(b.remove(),delete this._views[a.id]),b},renderView:function(a){var b=this._views[a.id]=this.createViewForModel(a);return V(this.viewport).append(b.el),b.paper=this,b.render(),b},onImageDragStart:function(){return!1},beforeRenderViews:function(a){return a.sort(function(a){return a.isLink()?1:-1}),a},afterRenderViews:function(){this.sortViews()},resetViews:function(a,b){this.removeViews();var c=a.models.slice();if(c=this.beforeRenderViews(c,b)||c,this.cancelRenderViews(),this.options.async)this.asyncRenderViews(c,b);else{for(var d=0,e=c.length;d(e.get("z")||0)?1:-1})},scale:function(a,b,c,d){if(void 0===a)return V.matrixToScale(this.matrix());void 0===b&&(b=a),void 0===c&&(c=0,d=0);var e=this.translate();if(c||d||e.tx||e.ty){var f=e.tx-c*(a-1),g=e.ty-d*(b-1);this.translate(f,g)}var h=this.matrix();return h.a=a||0,h.d=b||0,this.matrix(h),this.trigger("scale",a,b,c,d),this},rotate:function(a,b,c){if(void 0===a)return V.matrixToRotate(this.matrix());if(void 0===b){var d=this.viewport.getBBox();b=d.width/2,c=d.height/2}var e=this.matrix().translate(b,c).rotate(a).translate(-b,-c);return this.matrix(e),this},translate:function(a,b){if(void 0===a)return V.matrixToTranslate(this.matrix());var c=this.matrix();c.e=a||0,c.f=b||0,this.matrix(c);var d=this.translate(),e=this.options.origin;return e.x=d.tx,e.y=d.ty,this.trigger("translate",d.tx,d.ty),this.options.drawGrid&&this.drawGrid(),this},findView:function(a){for(var b=joint.util.isString(a)?this.viewport.querySelector(a):a instanceof $?a[0]:a;b&&b!==this.el&&b!==document;){var c=b.getAttribute("model-id");if(c)return this._views[c];b=b.parentNode}},findViewByModel:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a&&a.id;return this._views[b]},findViewsFromPoint:function(a){a=g.point(a);var b=this.model.getElements().map(this.findViewByModel,this);return b.filter(function(b){return b&&b.vel.getBBox({target:this.viewport}).containsPoint(a)},this)},findViewsInArea:function(a,b){b=joint.util.defaults(b||{},{strict:!1}),a=g.rect(a);var c=this.model.getElements().map(this.findViewByModel,this),d=b.strict?"containsRect":"intersect";return c.filter(function(b){return b&&a[d](b.vel.getBBox({target:this.viewport}))},this)},removeTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"remove"),this},hideTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"hide"),this},showTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"show"),this},getModelById:function(a){return this.model.getCell(a)},snapToGrid:function(a,b){return this.clientToLocalPoint(a,b).snapToGrid(this.options.gridSize)},localToPaperPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix());return g.Point(d)},localToPaperRect:function(a,b,c,d){var e=g.Rect(a,b),f=V.transformRect(e,this.matrix());return g.Rect(f)},paperToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix().inverse());return g.Point(d)},paperToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.matrix().inverse());return g.Rect(f)},localToClientPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix());return g.Point(d)},localToClientRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix());return g.Rect(f)},clientToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix().inverse());return g.Point(d)},clientToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix().inverse());return g.Rect(f)},localToPagePoint:function(a,b){return this.localToPaperPoint(a,b).offset(this.pageOffset())},localToPageRect:function(a,b,c,d){return this.localToPaperRect(a,b,c,d).moveAndExpand(this.pageOffset())},pageToLocalPoint:function(a,b){var c=g.Point(a,b),d=c.difference(this.pageOffset());return this.paperToLocalPoint(d)},pageToLocalRect:function(a,b,c,d){var e=this.pageOffset(),f=g.Rect(a,b,c,d);return f.x-=e.x,f.y-=e.y,this.paperToLocalRect(f)},clientOffset:function(){var a=this.svg.getBoundingClientRect();return g.Point(a.left,a.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(a){if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide a linkView.");var b=a.model,c=this.options,d=this.model,e=d.constructor.validations;return!(!c.multiLinks&&!e.multiLinks.call(this,d,b))&&(!(!c.linkPinning&&!e.linkPinning.call(this,d,b))&&!("function"==typeof c.allowLink&&!c.allowLink.call(this,a,this)))},getDefaultLink:function(a,b){return joint.util.isFunction(this.options.defaultLink)?this.options.defaultLink.call(this,a,b):this.options.defaultLink.clone()},resolveHighlighter:function(a){a=a||{};var b=a.highlighter,c=this.options;if(void 0===b){var d=["embedding","connecting","magnetAvailability","elementAvailability"].find(function(b){return!!a[b]});b=d&&c.highlighting[d]||c.highlighting.default}if(!b)return!1;joint.util.isString(b)&&(b={name:b});var e=b.name,f=c.highlighterNamespace[e];if(!f)throw new Error('Unknown highlighter ("'+e+'")');if("function"!=typeof f.highlight)throw new Error('Highlighter ("'+e+'") is missing required highlight() method');if("function"!=typeof f.unhighlight)throw new Error('Highlighter ("'+e+'") is missing required unhighlight() method');return{highlighter:f,options:b.options||{},name:e}},onCellHighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){b.id||(b.id=V.uniqueId());var d=c.name+b.id+JSON.stringify(c.options);if(!this._highlights[d]){var e=c.highlighter;e.highlight(a,b,joint.util.assign({},c.options)),this._highlights[d]={cellView:a,magnetEl:b,opt:c.options,highlighter:e}}}},onCellUnhighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){var d=c.name+b.id+JSON.stringify(c.options),e=this._highlights[d];e&&(e.highlighter.unhighlight(e.cellView,e.magnetEl,e.opt),this._highlights[d]=null)}},pointerdblclick:function(a){a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerdblclick(a,c.x,c.y):this.trigger("blank:pointerdblclick",a,c.x,c.y)}},pointerclick:function(a){if(this._mousemoved<=this.options.clickThreshold){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(this.guard(a,b))return;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerclick(a,c.x,c.y):this.trigger("blank:pointerclick",a,c.x,c.y)}},contextmenu:function(a){ this.options.preventContextMenu&&a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.contextmenu(a,c.x,c.y):this.trigger("blank:contextmenu",a,c.x,c.y)}},pointerdown:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y)),this.delegateDragEvents(b,a.data)}},pointermove:function(a){a.preventDefault();var b=this.eventData(a);b.mousemoved||(b.mousemoved=0);var c=++b.mousemoved;if(!(c<=this.options.moveThreshold)){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY}),e=b.sourceView;e?e.pointermove(a,d.x,d.y):this.trigger("blank:pointermove",a,d.x,d.y),this.eventData(a,b)}},pointerup:function(a){this.undelegateDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY}),c=this.eventData(a).sourceView;c?c.pointerup(a,b.x,b.y):this.trigger("blank:pointerup",a,b.x,b.y),this.delegateEvents()},mouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseover(a);else{if(this.el===a.target)return;this.trigger("blank:mouseover",a)}},mouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseout(a);else{if(this.el===a.target)return;this.trigger("blank:mouseout",a)}},mouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseenter(a)}else{if(c)return;this.trigger("paper:mouseenter",a)}}},mouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseleave(a)}else{if(c)return;this.trigger("paper:mouseleave",a)}}},mousewheel:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=a.originalEvent,d=this.snapToGrid({x:c.clientX,y:c.clientY}),e=Math.max(-1,Math.min(1,c.wheelDelta||-c.detail));b?b.mousewheel(a,d.x,d.y,e):this.trigger("blank:mousewheel",a,d.x,d.y,e)}},onevent:function(a){var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.onevent(a,c,e.x,e.y)}}},onmagnet:function(a){var b=a.currentTarget,c=b.getAttribute("magnet");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;if(!this.options.validateMagnet(d,b))return;var e=this.snapToGrid(a.clientX,a.clientY);d.onmagnet(a,e.x,e.y)}}},onlabel:function(a){var b=a.currentTarget,c=this.findView(b);if(c){if(a=joint.util.normalizeEvent(a),this.guard(a,c))return;var d=this.snapToGrid(a.clientX,a.clientY);c.onlabel(a,d.x,d.y)}},delegateDragEvents:function(a,b){b||(b={}),this.eventData({data:b},{sourceView:a||null,mousemoved:0}),this.delegateDocumentEvents(null,b),this.undelegateEvents()},guard:function(a,b){return!(!this.options.guard||!this.options.guard(a,b))||(a.data&&void 0!==a.data.guarded?a.data.guarded:!(b&&b.model&&b.model instanceof joint.dia.Cell)&&(this.svg!==a.target&&this.el!==a.target&&!$.contains(this.svg,a.target)))},setGridSize:function(a){return this.options.gridSize=a,this.options.drawGrid&&this.drawGrid(),this},clearGrid:function(){return this.$grid&&this.$grid.css("backgroundImage","none"),this},_getGriRefs:function(){return this._gridCache||(this._gridCache={root:V("svg",{width:"100%",height:"100%"},V("defs")),patterns:{},add:function(a,b){V(this.root.node.childNodes[0]).append(b),this.patterns[a]=b,this.root.append(V("rect",{width:"100%",height:"100%",fill:"url(#"+a+")"}))},get:function(a){return this.patterns[a]},exist:function(a){return void 0!==this.patterns[a]}}),this._gridCache},setGrid:function(a){this.clearGrid(),this._gridCache=null,this._gridSettings=[];var b=Array.isArray(a)?a:[a||{}];return b.forEach(function(a){this._gridSettings.push.apply(this._gridSettings,this._resolveDrawGridOption(a))},this),this},_resolveDrawGridOption:function(a){var b=this.constructor.gridPatterns;if(joint.util.isString(a)&&Array.isArray(b[a]))return b[a].map(function(a){return joint.util.assign({},a)});var c=a||{args:[{}]},d=Array.isArray(c),e=c.name;if(d||e||c.markup||(e="dot"),e&&Array.isArray(b[e])){var f=b[e].map(function(a){return joint.util.assign({},a)}),g=Array.isArray(c.args)?c.args:[c.args||{}];joint.util.defaults(g[0],joint.util.omit(a,"args"));for(var h=0;h'),f=joint.util.toArray(d).map(function(a){return e({offset:a.offset,color:a.color,opacity:Number.isFinite(a.opacity)?a.opacity:1})}),g=["<"+c+">",f.join(""),""].join(""),h=joint.util.assign({id:b},a.attrs);V(g,h).appendTo(this.defs)}return b},defineMarker:function(a){if(!joint.util.isObject(a))throw new TypeError("dia.Paper: defineMarker() requires 1. argument to be an object.");var b=a.id;if(b||(b=this.svg.id+joint.util.hashCode(JSON.stringify(a))),!this.isDefined(b)){var c=joint.util.omit(a,"type","userSpaceOnUse"),d=V("marker",{id:b,orient:"auto",overflow:"visible",markerUnits:a.markerUnits||"userSpaceOnUse"},[V(a.type||"path",c)]);d.appendTo(this.defs)}return b}},{backgroundPatterns:{flipXy:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,-1,b.width,b.height),e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,1,b.width,0),e.drawImage(a,0,0,c,d),e.setTransform(1,0,0,-1,0,b.height),e.drawImage(a,0,0,c,d),b},flipX:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(2*c,0),e.scale(-1,1),e.drawImage(a,0,0,c,d),b},flipY:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(0,2*d),e.scale(1,-1),e.drawImage(a,0,0,c,d),b},watermark:function(a,b){b=b||{};var c=a.width,d=a.height,e=document.createElement("canvas");e.width=3*c,e.height=3*d;for(var f=e.getContext("2d"),h=joint.util.isNumber(b.watermarkAngle)?-b.watermarkAngle:-20,i=g.toRad(h),j=e.width/4,k=e.height/4,l=0;l<4;l++)for(var m=0;m<4;m++)(l+m)%2>0&&(f.setTransform(1,0,0,1,(2*l-1)*j,(2*m-1)*k),f.rotate(i),f.drawImage(a,-c/2,-d/2,c,d));return e}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){V(a).attr({width:b.thickness*b.sx,height:b.thickness*b.sy,fill:b.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){var c=b.sx<=1?b.thickness*b.sx:b.thickness;V(a).attr({width:c,height:c,fill:b.color})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}]}}),function(a,b,c){var d=function(b){var d=c.cloneDeep(b)||{};this.ports=[],this.groups={},this.portLayoutNamespace=a.layout.Port,this.portLabelLayoutNamespace=a.layout.PortLabel,this._init(d)};d.prototype={getPorts:function(){return this.ports},getGroup:function(a){return this.groups[a]||{}},getPortsByGroup:function(a){return this.ports.filter(function(b){return b.group===a})},getGroupPortsMetrics:function(a,b){var d=this.getGroup(a),e=this.getPortsByGroup(a),f=d.position||{},h=f.name,i=this.portLayoutNamespace;i[h]||(h="left");var j=f.args||{},k=e.map(function(a){return a&&a.position&&a.position.args}),l=i[h](k,b,j),m={ports:e,result:[]};return c.toArray(l).reduce(function(a,c,d){var e=a.ports[d];return a.result.push({portId:e.id,portTransformation:c,labelTransformation:this._getPortLabelLayout(e,g.Point(c),b),portAttrs:e.attrs,portSize:e.size,labelSize:e.label.size}),a}.bind(this),m),m.result},_getPortLabelLayout:function(a,b,c){var d=this.portLabelLayoutNamespace,e=a.label.position.name||"left";return d[e]?d[e](b,c,a.label.position.args):null},_init:function(a){if(c.isObject(a.groups))for(var b=Object.keys(a.groups),d=0,e=b.length;d0},hasPort:function(a){return this.getPortIndex(a)!==-1},getPorts:function(){return c.cloneDeep(this.prop("ports/items"))||[]},getPort:function(a){return c.cloneDeep(c.toArray(this.prop("ports/items")).find(function(b){return b.id&&b.id===a}))},getPortsPositions:function(a){var b=this._portSettingsData.getGroupPortsMetrics(a,g.Rect(this.size()));return b.reduce(function(a,b){var c=b.portTransformation;return a[b.portId]={x:c.x,y:c.y,angle:c.angle},a},{})},getPortIndex:function(a){var b=c.isObject(a)?a.id:a;return this._isValidPortId(b)?c.toArray(this.prop("ports/items")).findIndex(function(a){return a.id===b}):-1},addPort:function(a,b){if(!c.isObject(a)||Array.isArray(a))throw new Error("Element: addPort requires an object.");var d=c.assign([],this.prop("ports/items"));return d.push(a),this.prop("ports/items",d,b),this},portProp:function(a,b,d,e){var f=this.getPortIndex(a);if(f===-1)throw new Error("Element: unable to find port with id "+a);var g=Array.prototype.slice.call(arguments,1);return Array.isArray(b)?g[0]=["ports","items",f].concat(b):c.isString(b)?g[0]=["ports/items/",f,"/",b].join(""):(g=["ports/items/"+f],c.isPlainObject(b)&&(g.push(b),g.push(d))),this.prop.apply(this,g)},_validatePorts:function(){var b=this.get("ports")||{},d=[];b=b||{};var e=c.toArray(b.items);return e.forEach(function(a){"object"!=typeof a&&d.push("Element: invalid port ",a),this._isValidPortId(a.id)||(a.id=c.uuid())},this),a.util.uniq(e,"id").length!==e.length&&d.push("Element: found id duplicities in ports."),d},_isValidPortId:function(a){return null!==a&&void 0!==a&&!c.isObject(a)},addPorts:function(a,b){return a.length&&this.prop("ports/items",c.assign([],this.prop("ports/items")).concat(a),b),this},removePort:function(a,b){var d=b||{},e=c.assign([],this.prop("ports/items")),f=this.getPortIndex(a);return f!==-1&&(e.splice(f,1),d.rewrite=!0,this.prop("ports/items",e,d)),this},_createPortData:function(){var a=this._validatePorts();if(a.length>0)throw this.set("ports",this.previous("ports")),new Error(a.join(" "));var b;this._portSettingsData&&(b=this._portSettingsData.getPorts()),this._portSettingsData=new d(this.get("ports"));var c=this._portSettingsData.getPorts();if(b){var e=c.filter(function(a){if(!b.find(function(b){return b.id===a.id}))return a}),f=b.filter(function(a){if(!c.find(function(b){return b.id===a.id}))return a});f.length>0&&this.trigger("ports:remove",this,f),e.length>0&&this.trigger("ports:add",this,e)}}}),c.assign(a.dia.ElementView.prototype,{portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._portElementsCache={},this.listenTo(this.model,"change:ports",function(){this._refreshPorts()})},_refreshPorts:function(){this._removePorts(),this._portElementsCache={},this._renderPorts()},_renderPorts:function(){for(var a=[],b=this._getContainerElement(),d=0,e=b.node.childNodes.length;d1?V("g").append(h):V(h.firstChild),e=g.selectors}else b=V(f),Array.isArray(b)&&(b=V("g").append(b));if(!b)throw new Error("ElementView: Invalid port markup.");b.attr({port:a.id,"port-group":a.group});var i,j=this._getPortLabelMarkup(a.label);if(Array.isArray(j)){var k=c.parseDOMJSON(j),l=k.fragment;d=l.childNodes.length>1?V("g").append(l):V(l.firstChild),i=k.selectors}else d=V(j),Array.isArray(d)&&(d=V("g").append(d));if(!d)throw new Error("ElementView: Invalid port label markup.");var m;if(e&&i){for(var n in i)if(e[n])throw new Error("ElementView: selectors within port must be unique.");m=c.assign({},e,i)}else m=e||i;var o=V(this.portContainerMarkup).addClass("joint-port").append([b.addClass("joint-port-body"),d.addClass("joint-port-label")]);return this._portElementsCache[a.id]={portElement:o,portLabelElement:d,portSelectors:m,portLabelSelectors:i,portContentElement:b,portContentSelectors:e},o},_updatePortGroup:function(a){for(var b=g.Rect(this.model.size()),c=this.model._portSettingsData.getGroupPortsMetrics(a,b),d=0,e=c.length;d'}),joint.shapes.basic.TextView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:attrs",this.resize)}}),joint.shapes.basic.Generic.define("basic.Text",{attrs:{text:{"font-size":18,fill:"#000000"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Circle",{size:{width:60,height:60},attrs:{circle:{fill:"#ffffff",stroke:"#000000",r:30,cx:30,cy:30},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Ellipse",{size:{width:60,height:40},attrs:{ellipse:{fill:"#ffffff",stroke:"#000000",rx:30,ry:20,cx:30,cy:20},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polygon",{size:{width:60,height:40},attrs:{polygon:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polyline",{size:{width:60,height:40},attrs:{polyline:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Image",{attrs:{text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Path",{size:{width:60,height:60},attrs:{path:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle",ref:"path","ref-x":.5,"ref-dy":10,fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Path.define("basic.Rhombus",{attrs:{path:{d:"M 30 0 L 60 30 30 60 0 30 z"},text:{"ref-y":.5,"ref-dy":null,"y-alignment":"middle"}}}),joint.shapes.basic.PortsModelInterface={initialize:function(){this.updatePortsAttrs(),this.on("change:inPorts change:outPorts",this.updatePortsAttrs,this),this.constructor.__super__.constructor.__super__.initialize.apply(this,arguments)},updatePortsAttrs:function(a){if(this._portSelectors){var b=joint.util.omit(this.get("attrs"),this._portSelectors);this.set("attrs",b,{silent:!0})}this._portSelectors=[];var c={};joint.util.toArray(this.get("inPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".inPorts","in");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),joint.util.toArray(this.get("outPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".outPorts","out");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),this.attr(c,{silent:!0}),this.processPorts(),this.trigger("process:ports")},getPortSelector:function(a){var b=".inPorts",c=this.get("inPorts").indexOf(a);if(c<0&&(b=".outPorts",c=this.get("outPorts").indexOf(a),c<0))throw new Error("getPortSelector(): Port doesn't exist.");return b+">g:nth-child("+(c+1)+")>.port-body"}},joint.shapes.basic.PortsViewInterface={initialize:function(){this.listenTo(this.model,"process:ports",this.update),joint.dia.ElementView.prototype.initialize.apply(this,arguments)},update:function(){this.renderPorts(),joint.dia.ElementView.prototype.update.apply(this,arguments)},renderPorts:function(){var a=this.$(".inPorts").empty(),b=this.$(".outPorts").empty(),c=joint.util.template(this.model.portMarkup),d=this.model.ports||[];d.filter(function(a){return"in"===a.type}).forEach(function(b,d){a.append(V(c({id:d,port:b})).node)}),d.filter(function(a){return"out"===a.type}).forEach(function(a,d){b.append(V(c({id:d,port:a})).node)})}},joint.shapes.basic.Generic.define("basic.TextBlock",{attrs:{rect:{fill:"#ffffff",stroke:"#000000",width:80,height:100},text:{fill:"#000000","font-size":14,"font-family":"Arial, helvetica, sans-serif"},".content":{text:"","ref-x":.5,"ref-y":.5,"y-alignment":"middle","x-alignment":"middle"}},content:""},{markup:['','',joint.env.test("svgforeignobject")?'
':'',""].join(""),initialize:function(){this.listenTo(this,"change:size",this.updateSize),this.listenTo(this,"change:content",this.updateContent),this.updateSize(this,this.get("size")),this.updateContent(this,this.get("content")),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},updateSize:function(a,b){this.attr({".fobj":joint.util.assign({},b),div:{style:joint.util.assign({},b)}})},updateContent:function(a,b){joint.env.test("svgforeignobject")?this.attr({".content":{html:joint.util.sanitizeHTML(b)}}):this.attr({".content":{text:b}})},setForeignObjectSize:function(){this.updateSize.apply(this,arguments)},setDivContent:function(){this.updateContent.apply(this,arguments)}}),joint.shapes.basic.TextBlockView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.noSVGForeignObjectElement=!joint.env.test("svgforeignobject"),joint.env.test("svgforeignobject")||this.listenTo(this.model,"change:content change:size",function(a){this.updateContent(a)})},update:function(a,b){var c=this.model;if(joint.env.test("svgforeignobject"))joint.dia.ElementView.prototype.update.call(this,c,b);else{var d=joint.util.omit(b||c.get("attrs"),".content");joint.dia.ElementView.prototype.update.call(this,c,d),b&&!joint.util.has(b,".content")||this.updateContent(c,b)}},updateContent:function(a,b){var c=joint.util.merge({},(b||a.get("attrs"))[".content"]);c=joint.util.omit(c,"text");var d=joint.util.breakText(a.get("content"),a.get("size"),c,{svgDocument:this.paper.svg}),e=joint.util.setByPath({},".content",c,"/");e[".content"].text=d,joint.dia.ElementView.prototype.update.call(this,a,e)}}),function(a,b,c,d){"use strict";var e=a.Element;e.define("standard.Rectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Circle",{attrs:{body:{refCx:"50%",refCy:"50%",refR:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Ellipse",{attrs:{body:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Path",{attrs:{body:{refD:"M 0 0 L 10 0 10 10 0 10 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polygon",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polyline",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10 0 0",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Image",{attrs:{image:{refWidth:"100%",refHeight:"100%"},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.BorderedImage",{attrs:{border:{refWidth:"100%",refHeight:"100%",stroke:"#333333",strokeWidth:2},image:{refWidth:-1,refHeight:-1,x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),e.define("standard.EmbeddedImage",{attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{refWidth:"30%",refHeight:-20,x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",refX:"30%",refX2:20,refY:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.HeaderedRectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{refWidth:"100%",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]});var f=10;joint.dia.Element.define("standard.Cylinder",{attrs:{body:{lateralArea:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{refCx:"50%",cy:f,refRx:"50%",ry:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"100%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(a,c){if(void 0===a)return this.attr("body/lateralArea");var d=b.isPercentage(a),e={lateralArea:a},f=d?{refCy:a,refRy:a,cy:null,ry:null}:{refCy:null,refRy:null,cy:a,ry:a};return this.attr({body:e,top:f},c)}},{attributes:{lateralArea:{set:function(a,c){var e=b.isPercentage(a);e&&(a=parseFloat(a)/100);var f=c.x,g=c.y,h=c.width,i=c.height,j=h/2,k=e?i*a:a,l=d.KAPPA,m=l*j,n=l*(e?i*a:a),o=f,p=f+h/2,q=f+h,r=g+k,s=r-k,t=g+i-k,u=g+i,v=["M",o,r,"L",o,t,"C",f,t+n,p-m,u,p,u,"C",p+m,u,q,t+n,q,t,"L",q,r,"C",q,r-n,p+m,s,p,s,"C",p-m,s,o,r-n,o,r,"Z"]; diff --git a/dist/joint.nowrap.js b/dist/joint.nowrap.js index df5414a23..a96a00212 100644 --- a/dist/joint.nowrap.js +++ b/dist/joint.nowrap.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -7707,7 +7707,7 @@ V = Vectorizer = (function() { var joint = { - version: '2.1.1', + version: '2.1.2', config: { // The class name prefix config is for advanced use only. @@ -12519,7 +12519,13 @@ joint.dia.CellView = joint.mvc.View.extend({ if (port != null && this.model.hasPort(port)) { magnet = this.findPortNode(port, selector) || root; } else { - magnet = this.findBySelector(selector || end.selector, root, this.selectors)[0]; + if (!selector) selector = end.selector; + if (!selector && port != null) { + // link end has only `id` and `port` property referencing + // a port created via the `port` attribute (not API). + selector = '[port="' + port + '"]'; + } + magnet = this.findBySelector(selector, root, this.selectors)[0]; } return magnet; diff --git a/dist/joint.nowrap.min.js b/dist/joint.nowrap.min.js index ce1a2b363..c8eec47bf 100644 --- a/dist/joint.nowrap.min.js +++ b/dist/joint.nowrap.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -9,8 +9,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. var g=function(){function a(a,b){return b.unshift(null),new(Function.prototype.bind.apply(a,b))}function b(a){var b,c,d=[];for(c=arguments.length,b=1;b=1)return[new q(b,c,d,e),new q(e,e,e,e)];var f=this.getSkeletonPoints(a),g=f.startControlPoint1,h=f.startControlPoint2,i=f.divider,j=f.dividerControlPoint1,k=f.dividerControlPoint2;return[new q(b,g,h,i),new q(i,j,k,e)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.controlPoint1.x===a.controlPoint1.x&&this.controlPoint1.y===a.controlPoint1.y&&this.controlPoint2.x===a.controlPoint2.x&&this.controlPoint2.y===a.controlPoint2.y&&this.end.x===a.end.x&&this.end.y===a.end.y},getSkeletonPoints:function(a){var b=this.start,c=this.controlPoint1,d=this.controlPoint2,e=this.end;if(a<=0)return{startControlPoint1:b.clone(),startControlPoint2:b.clone(),divider:b.clone(),dividerControlPoint1:c.clone(),dividerControlPoint2:d.clone()};if(a>=1)return{startControlPoint1:c.clone(),startControlPoint2:d.clone(),divider:e.clone(),dividerControlPoint1:e.clone(),dividerControlPoint2:e.clone()};var f=new s(b,c).pointAt(a),g=new s(c,d).pointAt(a),h=new s(d,e).pointAt(a),i=new s(f,g).pointAt(a),j=new s(g,h).pointAt(a),k=new s(i,j).pointAt(a),l={startControlPoint1:f,startControlPoint2:i,divider:k,dividerControlPoint1:j,dividerControlPoint2:h};return l},getSubdivisions:function(a){a=a||{};var b=void 0===a.precision?this.PRECISION:a.precision,c=[new q(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(0===b)return c;for(var d=this.endpointDistance(),e=p(10,-b),f=0;;){f+=1;for(var g=[],h=c.length,i=0;i1&&r=1)return this.end.clone();var c=this.tAt(a,b);return this.pointAtT(c)},pointAtLength:function(a,b){var c=this.tAtLength(a,b);return this.pointAtT(c)},pointAtT:function(a){return a<=0?this.start.clone():a>=1?this.end.clone():this.getSkeletonPoints(a).divider},PRECISION:3,scale:function(a,b,c){return this.start.scale(a,b,c),this.controlPoint1.scale(a,b,c),this.controlPoint2.scale(a,b,c),this.end.scale(a,b,c),this},tangentAt:function(a,b){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var c=this.tAt(a,b);return this.tangentAtT(c)},tangentAtLength:function(a,b){if(!this.isDifferentiable())return null;var c=this.tAtLength(a,b);return this.tangentAtT(c)},tangentAtT:function(a){if(!this.isDifferentiable())return null;a<0?a=0:a>1&&(a=1);var b=this.getSkeletonPoints(a),c=b.startControlPoint2,d=b.dividerControlPoint1,e=b.divider,f=new s(c,d);return f.translate(e.x-c.x,e.y-c.y),f},tAt:function(a,b){if(a<=0)return 0;if(a>=1)return 1;b=b||{};var c=void 0===b.precision?this.PRECISION:b.precision,d=void 0===b.subdivisions?this.getSubdivisions({precision:c}):b.subdivisions,e={precision:c,subdivisions:d},f=this.length(e),g=f*a;return this.tAtLength(g,e)},tAtLength:function(a,b){var c=!0;a<0&&(c=!1,a=-a),b=b||{};for(var d,e,f,g,h,i=void 0===b.precision?this.PRECISION:b.precision,j=void 0===b.subdivisions?this.getSubdivisions({precision:i}):b.subdivisions,k={precision:i,subdivisions:j},l=0,m=j.length,n=1/m,o=c?0:m-1;c?o=0;c?o++:o--){var q=j[o],r=q.endpointDistance();if(a<=l+r){d=q,e=o*n,f=(o+1)*n,g=c?a-l:r+l-a,h=c?r+l-a:a-l;break}l+=r}if(!d)return c?1:0;for(var s=this.length(k),t=p(10,-i);;){var u;if(u=0!==s?g/s:0,ui.x+g/2,m=ei.x?f-d:f+d,c=g*g/(e-j)-g*g*(f-k)*(b-k)/(h*h*(e-j))+j):(c=f>i.y?e+d:e-d,b=h*h/(f-k)-h*h*(e-j)*(c-j)/(g*g*(f-k))+k),new u(c,b).theta(a)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLine:function(a){var b=[],c=a.start,d=a.end,e=this.a,f=this.b,g=a.vector(),i=c.difference(new u(this)),j=new u(g.x/(e*e),g.y/(f*f)),k=new u(i.x/(e*e),i.y/(f*f)),l=g.dot(j),m=g.dot(k),n=i.dot(k)-1,o=m*m-l*n;if(o<0)return null;if(o>0){var p=h(o),q=(-m-p)/l,r=(-m+p)/l;if((q<0||10){if(f>d||g>d)return null}else if(f=1?c.clone():b.lerp(c,a)},pointAtLength:function(a){var b=this.start,c=this.end,d=!0;a<0&&(d=!1,a=-a);var e=this.length();return a>=e?d?c.clone():b.clone():this.pointAt((d?a:e-a)/e)},pointOffset:function(a){a=new c.Point(a);var b=this.start,d=this.end,e=(d.x-b.x)*(a.y-b.y)-(d.y-b.y)*(a.x-b.x);return e/this.length()},rotate:function(a,b){return this.start.rotate(a,b),this.end.rotate(a,b),this},round:function(a){var b=p(10,a||0);return this.start.x=l(this.start.x*b)/b,this.start.y=l(this.start.y*b)/b,this.end.x=l(this.end.x*b)/b,this.end.y=l(this.end.y*b)/b,this},scale:function(a,b,c){return this.start.scale(a,b,c),this.end.scale(a,b,c),this},setLength:function(a){var b=this.length();if(!b)return this;var c=a/b;return this.scale(c,c,this.start)},squaredLength:function(){var a=this.start.x,b=this.start.y,c=this.end.x,d=this.end.y;return(a-=c)*a+(b-=d)*b},tangentAt:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAt(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},tangentAtLength:function(a){if(!this.isDifferentiable())return null;var b=this.start,c=this.end,d=this.pointAtLength(a),e=new s(b,c);return e.translate(d.x-b.x,d.y-b.y),e},translate:function(a,b){return this.start.translate(a,b),this.end.translate(a,b),this},vector:function(){return new u(this.end.x-this.start.x,this.end.y-this.start.y)},toString:function(){return this.start.toString()+" "+this.end.toString()}},s.prototype.intersection=s.prototype.intersect;var t=c.Path=function(a){if(!(this instanceof t))return new t(a);if("string"==typeof a)return new t.parse(a);this.segments=[];var b,c;if(a){if(Array.isArray(a)&&0!==a.length)if(c=a.length,a[0].isSegment)for(b=0;b=c||a<0)throw new Error("Index out of range.");return b[a]},getSegmentSubdivisions:function(a){var b=this.segments,c=b.length;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=[],f=0;fd||a<0)throw new Error("Index out of range.");var e,f=null,g=null;if(0!==d&&(a>=1?(f=c[a-1],g=f.nextSegment):g=c[0]),Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");for(var h=b.length,i=0;i=d?(e=d-1,f=1):f<0?f=0:f>1&&(f=1),b=b||{};for(var g,h=void 0===b.precision?this.PRECISION:b.precision,i=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:h}):b.segmentSubdivisions,j=0,k=0;k=1)return this.end.clone();b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.pointAtLength(i,g)},pointAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;if(0===a)return this.start.clone();var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isVisible){if(a<=i+m)return k.pointAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f)return e?f.end:f.start;var n=c[d-1];return n.end.clone()},pointAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].pointAtT(0);if(d>=c)return b[c-1].pointAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].pointAtT(e)},prepareSegment:function(a,b,c){a.previousSegment=b,a.nextSegment=c,b&&(b.nextSegment=a),c&&(c.previousSegment=a);var d=a;return a.isSubpathStart&&(a.subpathStartSegment=a,d=c),d&&this.updateSubpathStartSegment(d),a},PRECISION:3,removeSegment:function(a){var b=this.segments,c=b.length;if(0===c)throw new Error("Path has no segments.");if(a<0&&(a=c+a),a>=c||a<0)throw new Error("Index out of range.");var d=b.splice(a,1)[0],e=d.previousSegment,f=d.nextSegment;e&&(e.nextSegment=f),f&&(f.previousSegment=e),d.isSubpathStart&&f&&this.updateSubpathStartSegment(f)},replaceSegment:function(a,b){var c=this.segments,d=c.length;if(0===d)throw new Error("Path has no segments.");if(a<0&&(a=d+a),a>=d||a<0)throw new Error("Index out of range.");var e,f=c[a],g=f.previousSegment,h=f.nextSegment,i=f.isSubpathStart;if(Array.isArray(b)){if(!b[0].isSegment)throw new Error("Segments required.");c.splice(a,1);for(var j=b.length,k=0;k1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.segmentIndexAtLength(i,g)},toPoints:function(a){var b=this.segments,c=b.length;if(0===c)return null;a=a||{};for(var d=void 0===a.precision?this.PRECISION:a.precision,e=void 0===a.segmentSubdivisions?this.getSegmentSubdivisions({precision:d}):a.segmentSubdivisions,f=[],g=[],h=0;h0){var k=j.map(function(a){return a.start});Array.prototype.push.apply(g,k)}else g.push(i.start)}else g.length>0&&(g.push(b[h-1].end),f.push(g),g=[])}return g.length>0&&(g.push(this.end),f.push(g)),f},toPolylines:function(a){var b=[],c=this.toPoints(a);if(!c)return null;for(var d=0,e=c.length;d=0;e?j++:j--){var k=c[j],l=g[j],m=k.length({precision:f,subdivisions:l});if(k.isVisible){if(a<=i+m)return j;h=j}i+=m}return h},tangentAt:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;a<0&&(a=0),a>1&&(a=1),b=b||{};var e=void 0===b.precision?this.PRECISION:b.precision,f=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):b.segmentSubdivisions,g={precision:e,segmentSubdivisions:f},h=this.length(g),i=h*a;return this.tangentAtLength(i,g)},tangentAtLength:function(a,b){var c=this.segments,d=c.length;if(0===d)return null;var e=!0;a<0&&(e=!1,a=-a),b=b||{};for(var f,g=void 0===b.precision?this.PRECISION:b.precision,h=void 0===b.segmentSubdivisions?this.getSegmentSubdivisions({precision:g}):b.segmentSubdivisions,i=0,j=e?0:d-1;e?j=0;e?j++:j--){var k=c[j],l=h[j],m=k.length({precision:g,subdivisions:l});if(k.isDifferentiable()){if(a<=i+m)return k.tangentAtLength((e?1:-1)*(a-i),{precision:g,subdivisions:l});f=k}i+=m}if(f){var n=e?1:0;return f.tangentAtT(n)}return null},tangentAtT:function(a){var b=this.segments,c=b.length;if(0===c)return null;var d=a.segmentIndex;if(d<0)return b[0].tangentAtT(0);if(d>=c)return b[c-1].tangentAtT(1);var e=a.value;return e<0?e=0:e>1&&(e=1),b[d].tangentAtT(e)},translate:function(a,b){for(var c=this.segments,d=c.length,e=0;e=0;c--){var d=a[c];if(d.isVisible)return d.end}return a[b-1].end}});var u=c.Point=function(a,b){if(!(this instanceof u))return new u(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseFloat(c[0]),b=parseFloat(c[1])}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};u.fromPolar=function(a,b,c){c=c&&new u(c)||new u(0,0);var d=e(a*f(b)),h=e(a*g(b)),i=x(z(b));return i<90?h=-h:i<180?(d=-d,h=-h):i<270&&(d=-d),new u(c.x+d,c.y+h)},u.random=function(a,b,c,d){return new u(m(o()*(b-a+1)+a),m(o()*(d-c+1)+c))},u.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=i(j(this.x,a.x),a.x+a.width),this.y=i(j(this.y,a.y),a.y+a.height),this)},bearing:function(a){return new s(this,a).bearing()},changeInAngle:function(a,b,c){return this.clone().offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return new u(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),new u(this.x-(a||0),this.y-(b||0))},distance:function(a){return new s(this,a).length()},squaredDistance:function(a){return new s(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return h(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return e(a.x-this.x)+e(a.y-this.y)},move:function(a,b){var c=A(new u(a).theta(this)),d=this.offset(f(c)*b,-g(c)*b);return d},normalize:function(a){var b=(a||1)/this.magnitude();return this.scale(b,b)},offset:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),this.x+=a||0,this.y+=b||0,this},reflection:function(a){return new u(a).move(this,this.distance(a))},rotate:function(a,b){a=a||new c.Point(0,0),b=A(x(-b));var d=f(b),e=g(b),h=d*(this.x-a.x)-e*(this.y-a.y)+a.x,i=e*(this.x-a.x)+d*(this.y-a.y)+a.y;return this.x=h,this.y=i,this},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this},scale:function(a,b,c){return c=c&&new u(c)||new u(0,0),this.x=c.x+a*(this.x-c.x),this.y=c.y+b*(this.y-c.y),this},snapToGrid:function(a,b){return this.x=y(this.x,a),this.y=y(this.y,b||a),this},theta:function(a){a=new u(a);var b=-(a.y-this.y),c=a.x-this.x,d=k(b,c);return d<0&&(d=2*n+d),180*d/n},angleBetween:function(a,b){var c=this.equals(a)||this.equals(b)?NaN:this.theta(b)-this.theta(a);return c<0&&(c+=360),c},vectorAngle:function(a){var b=new u(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&new u(a)||new u(0,0);var b=this.x,c=this.y;return this.x=h((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=A(a.theta(new u(b,c))),this},toString:function(){return this.x+"@"+this.y},update:function(a,b){return this.x=a||0,this.y=b||0,this},dot:function(a){return a?this.x*a.x+this.y*a.y:NaN},cross:function(a,b){return a&&b?(b.x-this.x)*(a.y-this.y)-(b.y-this.y)*(a.x-this.x):NaN},lerp:function(a,b){var c=this.x,d=this.y;return new u((1-b)*c+b*a.x,(1-b)*d+b*a.y)}},u.prototype.translate=u.prototype.offset;var v=c.Rect=function(a,b,c,d){return this instanceof v?(Object(a)===a&&(b=a.y,c=a.width,d=a.height,a=a.x),this.x=void 0===a?0:a,this.y=void 0===b?0:b,this.width=void 0===c?0:c,void(this.height=void 0===d?0:d)):new v(a,b,c,d)};v.fromEllipse=function(a){return a=new r(a),new v(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},v.prototype={bbox:function(a){if(!a)return this.clone();var b=A(a||0),c=e(g(b)),d=e(f(b)),h=this.width*d+this.height*c,i=this.width*c+this.height*d;return new v(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return new u(this.x,this.y+this.height)},bottomLine:function(){return new s(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new u(this.x+this.width/2,this.y+this.height); },center:function(){return new u(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new v(this)},containsPoint:function(a){return a=new u(a),a.x>=this.x&&a.x<=this.x+this.width&&a.y>=this.y&&a.y<=this.y+this.height},containsRect:function(a){var b=new v(this).normalize(),c=new v(a).normalize(),d=b.width,e=b.height,f=c.width,g=c.height;if(!(d&&e&&f&&g))return!1;var h=b.x,i=b.y,j=c.x,k=c.y;return f+=j,d+=h,g+=k,e+=i,h<=j&&f<=d&&i<=k&&g<=e},corner:function(){return new u(this.x+this.width,this.y+this.height)},equals:function(a){var b=new v(this).normalize(),c=new v(a).normalize();return b.x===c.x&&b.y===c.y&&b.width===c.width&&b.height===c.height},intersect:function(a){var b=this.origin(),c=this.corner(),d=a.origin(),e=a.corner();if(e.x<=b.x||e.y<=b.y||d.x>=c.x||d.y>=c.y)return null;var f=j(b.x,d.x),g=j(b.y,d.y);return new v(f,g,i(c.x,e.x)-f,i(c.y,e.y)-g)},intersectionWithLine:function(a){var b,c,d=this,e=[d.topLine(),d.rightLine(),d.bottomLine(),d.leftLine()],f=[],g=[],h=e.length;for(c=0;c0?f:null},intersectionWithLineFromCenterToPoint:function(a,b){a=new u(a);var c,d=new u(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],f=new s(d,a),g=e.length-1;g>=0;--g){var h=e[g].intersection(f);if(null!==h){c=h;break}}return c&&b&&c.rotate(d,-b),c},leftLine:function(){return new s(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new u(this.x,this.y+this.height/2)},moveAndExpand:function(a){return this.x+=a.x||0,this.y+=a.y||0,this.width+=a.width||0,this.height+=a.height||0,this},offset:function(a,b){return u.prototype.offset.call(this,a,b)},inflate:function(a,b){return void 0===a&&(a=0),void 0===b&&(b=a),this.x-=a,this.y-=b,this.width+=2*a,this.height+=2*b,this},normalize:function(){var a=this.x,b=this.y,c=this.width,d=this.height;return this.width<0&&(a=this.x+this.width,c=-this.width),this.height<0&&(b=this.y+this.height,d=-this.height),this.x=a,this.y=b,this.width=c,this.height=d,this},origin:function(){return new u(this.x,this.y)},pointNearestToPoint:function(a){if(a=new u(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return new u(this.x+this.width,a.y);case"left":return new u(this.x,a.y);case"bottom":return new u(a.x,this.y+this.height);case"top":return new u(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return new s(this.topRight(),this.bottomRight())},rightMiddle:function(){return new u(this.x+this.width,this.y+this.height/2)},round:function(a){var b=p(10,a||0);return this.x=l(this.x*b)/b,this.y=l(this.y*b)/b,this.width=l(this.width*b)/b,this.height=l(this.height*b)/b,this},scale:function(a,b,c){return c=this.origin().scale(a,b,c),this.x=c.x,this.y=c.y,this.width*=a,this.height*=b,this},maxRectScaleToFit:function(a,b){a=new v(a),b||(b=a.center());var c,d,e,f,g,h,j,k,l=b.x,m=b.y;c=d=e=f=g=h=j=k=1/0;var n=a.topLeft();n.xl&&(d=(this.x+this.width-l)/(o.x-l)),o.y>m&&(h=(this.y+this.height-m)/(o.y-m));var p=a.topRight();p.x>l&&(e=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:i(c,d,e,f),sy:i(g,h,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return i(c.sx,c.sy)},sideNearestToPoint:function(a){a=new u(a);var b=a.x-this.x,c=this.x+this.width-a.x,d=a.y-this.y,e=this.y+this.height-a.y,f=b,g="left";return cb&&(b=i),jd&&(d=j)}return new v(a,c,b-a,d-c)},clone:function(){var a=this.points,b=a.length;if(0===b)return new w;for(var c=[],d=0;df.x&&(f=c[a]);var g=[];for(a=0;a2){var j=g[g.length-1];g.unshift(j)}for(var k,l,m,n,o,p,q={},r=[];0!==g.length;)if(k=g.pop(),l=k[0],!q.hasOwnProperty(k[0]+"@@"+k[1]))for(var s=!1;!s;)if(r.length<2)r.push(k),s=!0;else{m=r.pop(),n=m[0],o=r.pop(),p=o[0];var t=p.cross(n,l);if(t<0)r.push(o),r.push(m),r.push(k),s=!0;else if(0===t){var u=1e-10,v=n.angleBetween(p,l);e(v-180)2&&r.pop();var x,y=-1;for(b=r.length,a=0;a0){var B=r.slice(y),C=r.slice(0,y);A=B.concat(C)}else A=r;var D=[];for(b=A.length,a=0;a=1)return b[c-1].clone();var d=this.length(),e=d*a;return this.pointAtLength(e)},pointAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return b[0].clone();var d=!0;a<0&&(d=!1,a=-a);for(var e=0,f=c-1,g=d?0:f-1;d?g=0;d?g++:g--){var h=b[g],i=b[g+1],j=new s(h,i),k=h.distance(i);if(a<=e+k)return j.pointAtLength((d?1:-1)*(a-e));e+=k}var l=d?b[c-1]:b[0];return l.clone()},scale:function(a,b,c){var d=this.points,e=d.length;if(0===e)return this;for(var f=0;f1&&(a=1);var d=this.length(),e=d*a;return this.tangentAtLength(e)},tangentAtLength:function(a){var b=this.points,c=b.length;if(0===c)return null;if(1===c)return null;var d=!0;a<0&&(d=!1,a=-a);for(var e,f=0,g=c-1,h=d?0:g-1;d?h=0;d?h++:h--){var i=b[h],j=b[h+1],k=new s(i,j),l=i.distance(j);if(k.isDifferentiable()){if(a<=f+l)return k.tangentAtLength((d?1:-1)*(a-f));e=k}f+=l}if(e){var m=d?1:0;return e.tangentAt(m)}return null},intersectionWithLine:function(a){for(var b=new s(a),c=[],d=this.points,e=0,f=d.length-1;e0?c:null},translate:function(a,b){var c=this.points,d=c.length;if(0===d)return this;for(var e=0;e=1?b:b*a},pointAtT:function(a){if(this.pointAt)return this.pointAt(a);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,subpathStartSegment:null,tangentAtT:function(a){if(this.tangentAt)return this.tangentAt(a);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},length:function(){throw new Error("Declaration missing for virtual function.")},pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},scale:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},toString:function(){throw new Error("Declaration missing for virtual function.")}},C=function(){for(var b=[],c=arguments.length,d=0;d0)throw new Error("Closepath constructor expects no arguments.");return this},J={clone:function(){return new I},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},scale:function(){return this},translate:function(){return this},type:"Z",serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end}};Object.defineProperty(J,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(J,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),I.prototype=b(B,s.prototype,J);var K=t.segmentTypes={L:C,C:E,M:G,Z:I,z:I};return t.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(K).join("")+",.]*$"),t.isDataSupported=function(a){return"string"==typeof a&&this.regexSupportedData.test(a)},c}(); var V,Vectorizer;V=Vectorizer=function(){"use strict";function a(a,b){a||(a={});var c=q("textPath"),d=a.d;if(d&&void 0===a["xlink:href"]){var e=q("path").attr("d",d).appendTo(b.defs());c.attr("xlink:href","#"+e.id)}return q.isObject(a)&&c.attr(a),c.node}function b(a,b,c){c||(c={});for(var d=c.includeAnnotationIndices,e=c.eol,f=c.lineHeight,g=c.baseSize,h=0,i={},j=b.length-1,k=0;k<=j;k++){var l=b[k],m=null;if(q.isObject(l)){var n=l.attrs,o=q("tspan",n),p=o.node,r=l.t;e&&k===j&&(r+=e),p.textContent=r;var s=n.class;s&&o.addClass(s),d&&o.attr("annotations",l.annotations),m=parseFloat(n["font-size"]),void 0===m&&(m=g),m&&m>h&&(h=m)}else e&&k===j&&(l+=e),p=document.createTextNode(l||" "),g&&g>h&&(h=g);a.appendChild(p)}return h&&(i.maxFontSize=h),f?i.lineHeight=f:h&&(i.lineHeight=1.2*h),i}function c(a,b){var c=parseFloat(a);return s.test(a)?c*b:c}function d(a,b,d,e){if(!Array.isArray(b))return 0;var f=b.length;if(!f)return 0;for(var g=b[0],h=c(g.maxFontSize,d)||d,i=0,j=c(e,d),k=1;k1){var e,g,h=[];for(e=0,g=d.childNodes.length;e0&&D.setAttribute("dy",B),(y>0||g)&&D.setAttribute("x",j),D.className.baseVal=C,r.appendChild(D),v+=E.length+1}if(i)if(l)B=d(h,x,p,o);else if("top"===h)B="0.8em";else{var I;switch(z>0?(I=parseFloat(o)||1,I*=z,s.test(o)||(I/=p)):I=0,h){case"middle":B=.3-I/2+"em";break;case"bottom":B=-I-.3+"em"}}else 0===h?B="0em":h?B=h:(B=0,null===this.attr("y")&&this.attr("y",u||"0.8em"));return r.firstChild.setAttribute("dy",B),this.append(r),this},r.removeAttr=function(a){var b=q.qualifyAttr(a),c=this.node;return b.ns?c.hasAttributeNS(b.ns,b.local)&&c.removeAttributeNS(b.ns,b.local):c.hasAttribute(a)&&c.removeAttribute(a),this},r.attr=function(a,b){if(q.isUndefined(a)){for(var c=this.node.attributes,d={},e=0;e1&&k.push(k[0]),new g.Polyline(k);case"PATH":return l=this.attr("d"),g.Path.isDataSupported(l)||(l=q.normalizePathData(l)),new g.Path(l);case"LINE":return x1=parseFloat(this.attr("x1"))||0,y1=parseFloat(this.attr("y1"))||0,x2=parseFloat(this.attr("x2"))||0,y2=parseFloat(this.attr("y2"))||0,new g.Line({x:x1,y:y1},{x:x2,y:y2})}return this.getBBox()},r.findIntersection=function(a,b){var c=this.svg().node;b=b||c;var d=this.getBBox({target:b}),e=d.center();if(d.intersectionWithLineFromCenterToPoint(a)){var f,h=this.tagName();if("RECT"===h){var i=new g.Rect(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),j=this.getTransformToElement(b),k=q.decomposeMatrix(j),l=c.createSVGTransform();l.setRotate(-k.rotation,e.x,e.y);var m=q.transformRect(i,l.matrix.multiply(j));f=new g.Rect(m).intersectionWithLineFromCenterToPoint(a,k.rotation)}else if("PATH"===h||"POLYGON"===h||"POLYLINE"===h||"CIRCLE"===h||"ELLIPSE"===h){var n,o,p,r,s,t,u="PATH"===h?this:this.convertToPath(),v=u.sample(),w=1/0,x=[];for(n=0;n'+(a||"")+"",c=q.parseXML(b,{async:!1});return c.documentElement},q.idCounter=0,q.uniqueId=function(){return"v-"+ ++q.idCounter},q.toNode=function(a){return q.isV(a)?a.node:a.nodeName&&a||a[0]},q.ensureId=function(a){return a=q.toNode(a),a.id||(a.id=q.uniqueId())},q.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},q.isUndefined=function(a){return"undefined"==typeof a},q.isString=function(a){return"string"==typeof a},q.isObject=function(a){return a&&"object"==typeof a},q.isArray=Array.isArray,q.parseXML=function(a,b){b=b||{};var c;try{var d=new DOMParser;q.isUndefined(b.async)||(d.async=b.async),c=d.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},q.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var b=a.split(":");return{ns:f[b[0]],local:b[1]}}return{ns:null,local:a}},q.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,q.transformSeparatorRegex=/[ ,]+/,q.transformationListRegex=/^(\w+)\((.*)\)/,q.transformStringToMatrix=function(a){var b=q.createSVGMatrix(),c=a&&a.match(q.transformRegex);if(!c)return b;for(var d=0,e=c.length;d=0){var f=q.transformStringToMatrix(a),g=q.decomposeMatrix(f);b=[g.translateX,g.translateY],d=[g.scaleX,g.scaleY],c=[g.rotation];var h=[];0===b[0]&&0===b[0]||h.push("translate("+b+")"),1===d[0]&&1===d[1]||h.push("scale("+d+")"),0!==c[0]&&h.push("rotate("+c+")"),a=h.join(" ")}else{var i=a.match(/translate\((.*?)\)/);i&&(b=i[1].split(e));var j=a.match(/rotate\((.*?)\)/);j&&(c=j[1].split(e));var k=a.match(/scale\((.*?)\)/);k&&(d=k[1].split(e))}}var l=d&&d[0]?parseFloat(d[0]):1;return{value:a,translate:{tx:b&&b[0]?parseInt(b[0],10):0,ty:b&&b[1]?parseInt(b[1],10):0},rotate:{angle:c&&c[0]?parseInt(c[0],10):0,cx:c&&c[1]?parseInt(c[1],10):void 0,cy:c&&c[2]?parseInt(c[2],10):void 0},scale:{sx:l,sy:d&&d[1]?parseFloat(d[1]):l}}},q.deltaTransformPoint=function(a,b){var c=b.x*a.a+b.y*a.c+0,d=b.x*a.b+b.y*a.d+0;return{x:c,y:d}},q.decomposeMatrix=function(a){var b=q.deltaTransformPoint(a,{x:0,y:1}),c=q.deltaTransformPoint(a,{x:1,y:0}),d=180/j*k(b.y,b.x)-90,e=180/j*k(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:l(a.a*a.a+a.b*a.b),scaleY:l(a.c*a.c+a.d*a.d),skewX:d,skewY:e,rotation:d}},q.matrixToScale=function(a){var b,c,d,e;return a?(b=q.isUndefined(a.a)?1:a.a,e=q.isUndefined(a.d)?1:a.d,c=a.b,d=a.c):b=e=1,{sx:c?l(b*b+c*c):b,sy:d?l(d*d+e*e):e}},q.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=q.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(k(b.y,b.x))-90)}},q.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},q.isV=function(a){return a instanceof q},q.isVElement=q.isV;var t=q("svg").node;return q.createSVGMatrix=function(a){var b=t.createSVGMatrix();for(var c in a)b[c]=a[c];return b},q.createSVGTransform=function(a){return q.isUndefined(a)?t.createSVGTransform():(a instanceof SVGMatrix||(a=q.createSVGMatrix(a)),t.createSVGTransformFromMatrix(a))},q.createSVGPoint=function(a,b){var c=t.createSVGPoint();return c.x=a,c.y=b,c},q.transformRect=function(a,b){var c=t.createSVGPoint();c.x=a.x,c.y=a.y;var d=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y;var e=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var f=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var h=c.matrixTransform(b),i=m(d.x,e.x,f.x,h.x),j=n(d.x,e.x,f.x,h.x),k=m(d.y,e.y,f.y,h.y),l=n(d.y,e.y,f.y,h.y);return new g.Rect(i,k,j-i,l-k)},q.transformPoint=function(a,b){return new g.Point(q.createSVGPoint(a.x,a.y).matrixTransform(b))},q.transformLine=function(a,b){return new g.Line(q.transformPoint(a.start,b),q.transformPoint(a.end,b))},q.transformPolyline=function(a,b){var c=a instanceof g.Polyline?a.points:a;q.isArray(c)||(c=[]);for(var d=[],e=0,f=c.length;e=e?f?"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"M0,"+f+"A"+f+","+f+" 0 1,0 0,"+-f+"A"+f+","+f+" 0 1,0 0,"+f+"Z":"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+-g+"A"+g+","+g+" 0 1,1 0,"+g+"Z":f?"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L"+f*q+","+f*r+"A"+f+","+f+" 0 "+l+",0 "+f*m+","+f*n+"Z":"M"+g*m+","+g*n+"A"+g+","+g+" 0 "+l+",1 "+g*q+","+g*r+"L0,0Z"},q.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?q.isObject(a[c])&&q.isObject(b[c])?a[c]=q.mergeAttrs(a[c],b[c]):q.isObject(a[c])?a[c]=q.mergeAttrs(a[c],q.styleToObject(b[c])):q.isObject(b[c])?a[c]=q.mergeAttrs(q.styleToObject(a[c]),b[c]):a[c]=q.mergeAttrs(q.styleToObject(a[c]),q.styleToObject(b[c])):a[c]=b[c];return a},q.annotateString=function(a,b,c){b=b||[],c=c||{};for(var d,e,f,g=c.offset||0,h=[],i=[],j=0;j=m&&j=a.start&&ba.start&&c<=a.end||a.start>=b&&a.end=b?a.end+=c:a.start>=b&&(a.start+=c,a.end+=c)}),a},q.convertLineToPathData=function(a){a=q(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},q.convertPolygonToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)+" Z"},q.convertPolylineToPathData=function(a){var b=q.getPointsFromSvgNode(a);return 0===b.length?null:q.svgPointsToPath(b)},q.svgPointsToPath=function(a){for(var b=0,c=a.length;b1&&(z=o(z),d*=z,e*=z);var A=d*d,B=e*e,C=(g==h?-1:1)*o(p((A*B-A*y*y-B*x*x)/(A*y*y+B*x*x))),D=C*d*y/e+(a+i)/2,E=C*-e*x/d+(c+q)/2,F=n(((c-E)/e).toFixed(9)),G=n(((q-E)/e).toFixed(9));F=aG&&(F-=2*j),(!h&&G)>F&&(G-=2*j)}var H=G-F;if(p(H)>t){var I=G,J=i,K=q;G=F+t*((h&&G)>F?1:-1),i=D+d*l(G),q=E+e*k(G),v=b(i,q,d,e,f,0,h,J,K,[G,I,D,E])}H=G-F;var L=l(F),M=k(F),N=l(G),O=k(G),P=m(H/4),Q=4/3*(d*P),R=4/3*(e*P),S=[a,c],T=[a+Q*M,c-R*L],U=[i+Q*O,q-R*N],V=[i,q];if(T[0]=2*S[0]-T[0],T[1]=2*S[1]-T[1],r)return[T,U,V].concat(v);v=[T,U,V].concat(v).join().split(",");for(var W=[],X=v.length,Y=0;Y2&&(c.push([d].concat(f.splice(0,2))),g="l",d="m"===d?"l":"L");f.length>=b[g]&&(c.push([d].concat(f.splice(0,b[g]))),b[g]););}),c}function d(a){if(Array.isArray(a)&&Array.isArray(a&&a[0])||(a=c(a)),!a||!a.length)return[["M",0,0]];for(var b,d=[],e=0,f=0,g=0,h=0,i=0,j=a.length,k=i;k7){a[b].shift();for(var c=a[b];c.length;)i[b]="A",a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),l=g.length}}for(var g=d(c),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=[],j="",k="",l=g.length,m=0;m0&&(k=i[m-1])),g[m]=e(g[m],h,k),"A"!==i[m]&&"C"===j&&(i[m]="C"),f(g,m);var n=g[m],o=n.length;h.x=n[o-2],h.y=n[o-1],h.bx=parseFloat(n[o-4])||h.x,h.by=parseFloat(n[o-3])||h.y}return g[0][0]&&"M"===g[0][0]||g.unshift(["M",0,0]),g}var f="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",g=new RegExp("([a-z])["+f+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+f+"]*,?["+f+"]*)+)","ig"),h=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+f+"]*,?["+f+"]*","ig"),i=Math,j=i.PI,k=i.sin,l=i.cos,m=i.tan,n=i.asin,o=i.sqrt,p=i.abs;return function(a){return e(a).join(",").split(",").join(" ")}}(),q.namespace=f,q}(); -var joint={version:"2.1.1",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},anchors:{},connectionPoints:{},connectionStrategies:{},linkTools:{},mvc:{views:{}},setTheme:function(a,b){b=b||{},joint.util.invoke(joint.mvc.views,"setTheme",a,b),joint.mvc.View.prototype.defaultTheme=a},env:{_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(a,b){return joint.env._tests[a]=b},test:function(a){var b=joint.env._tests[a];if(!b)throw new Error('Test not defined ("'+a+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var c=joint.env._results[a];if("undefined"!=typeof c)return c;try{c=b()}catch(a){c=!1}return joint.env._results[a]=c,c}},util:{hashCode:function(a){var b=0;if(0==a.length)return b;for(var c=0;c0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), -d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return b=null!=d&&this.model.hasPort(d)?this.findPortNode(d,e)||c:this.findBySelector(e||a.selector,c,this.selectors)[0]},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){var f=joint.util.getByPath(a,d,c);f&&delete f[e]}else delete a[e];return a},flattenObject:function(a,b,c){b=b||"/";var d={};for(var e in a)if(a.hasOwnProperty(e)){var f="object"==typeof a[e];if(f&&c&&c(a[e])&&(f=!1),f){var g=this.flattenObject(a[e],b,c);for(var h in g)g.hasOwnProperty(h)&&(d[e+b+h]=g[h])}else d[e]=a[e]}return d},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},guid:function(a){return this.guid.id=this.guid.id||1,a.id=void 0===a.id?"j_"+this.guid.id++:a.id,a.id},toKebabCase:function(a){return a.replace(/[A-Z]/g,"-$&").toLowerCase()},mixin:_.assign,supplement:_.defaults,deepMixin:_.mixin,deepSupplement:_.defaultsDeep,normalizeEvent:function(a){var b=a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0];if(b){for(var c in a)void 0===b[c]&&(b[c]=a[c]);return b}return a},nextFrame:function(){var a;if("undefined"!=typeof window&&(a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!a){var b=0;a=function(a){var c=(new Date).getTime(),d=Math.max(0,16-(c-b)),e=setTimeout(function(){a(c+d)},d);return b=c+d,e}}return function(b,c){return a(c?b.bind(c):b)}}(),cancelFrame:function(){var a,b="undefined"!=typeof window;return b&&(a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),a=a||clearTimeout,b?a.bind(window):a}(),shapePerimeterConnectionPoint:function(a,b,c,d){var e,f;if(!c){var g=b.$(".scalable")[0],h=b.$(".rotatable")[0];g&&g.firstChild?c=g.firstChild:h&&h.firstChild&&(c=h.firstChild)}return c?(f=V(c).findIntersection(d,a.paper.viewport),f||(e=V(c).getBBox({target:a.paper.viewport}))):(e=b.model.getBBox(),f=e.intersectionWithLineFromCenterToPoint(d)),f||e.center()},isPercentage:function(a){return joint.util.isString(a)&&"%"===a.slice(-1)},parseCssNumeric:function(a,b){b=b||[];var c={value:parseFloat(a)};if(Number.isNaN(c.value))return null;var d=b.join("|");if(joint.util.isString(a)){var e=new RegExp("(\\d+)("+d+")$").exec(a);if(!e)return null;e[2]&&(c.unit=e[2])}return c},breakText:function(a,b,c,d){d=d||{},c=c||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("tspan").node,i=V("text").attr(c).append(h).node,j=document.createTextNode("");i.style.opacity=0,i.style.display="block",h.style.display="block",h.appendChild(j),g.appendChild(i),d.svgDocument||document.body.appendChild(g);for(var k,l,m=d.separator||" ",n=d.eol||"\n",o=a.split(m),p=[],q=[],r=0,s=0,t=o.length;r=0)if(u.length>1){for(var v=u.split(n),w=0,x=v.length-1;wf){q.splice(Math.floor(f/l));break}}}}return d.svgDocument?g.removeChild(i):document.body.removeChild(g),q.join(n)},sanitizeHTML:function(a){var b=$($.parseHTML("
"+a+"
",null,!1));return b.find("*").each(function(){var a=this;$.each(a.attributes,function(){var b=this,c=b.name,d=b.value;0!==c.indexOf("on")&&0!==d.indexOf("javascript:")||$(a).removeAttr(c)})}),b.html()},downloadBlob:function(a,b){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(a,b);else{var c=window.URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=b,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(c)}},downloadDataUri:function(a,b){var c=joint.util.dataUriToBlob(a);joint.util.downloadBlob(c,b)},dataUriToBlob:function(a){a=a.replace(/\s/g,""),a=decodeURIComponent(a);var b,c=a.indexOf(","),d=a.slice(0,c),e=d.split(":")[1].split(";")[0],f=a.slice(c+1);b=d.indexOf("base64")>=0?atob(f):unescape(encodeURIComponent(f));for(var g=new window.Uint8Array(b.length),h=0;h=1)return 1;var b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)},exponential:function(a){return Math.pow(2,10*(a-1))},bounce:function(a){for(var b=0,c=1;1;b+=c,c/=2)if(a>=(7-4*b)/11){var d=(11-6*b-11*a)/4;return-d*d+c*c}},reverse:function(a){return function(b){return 1-a(1-b)}},reflect:function(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}},clamp:function(a,b,c){return b=b||0,c=c||1,function(d){var e=a(d);return ec?c:e}},back:function(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}},elastic:function(a){return a||(a=1.5),function(b){return Math.pow(2,10*(b-1))*Math.cos(20*Math.PI*a/3*b)}}},interpolate:{number:function(a,b){var c=b-a;return function(b){return a+c*b}},object:function(a,b){var c=Object.keys(a);return function(d){var e,f,g={};for(e=c.length-1;e!=-1;e--)f=c[e],g[f]=a[f]+(b[f]-a[f])*d;return g}},hexColor:function(a,b){var c=parseInt(a.slice(1),16),d=parseInt(b.slice(1),16),e=255&c,f=(255&d)-e,g=65280&c,h=(65280&d)-g,i=16711680&c,j=(16711680&d)-i;return function(a){var b=e+f*a&255,c=g+h*a&65280,d=i+j*a&16711680;return"#"+(1<<24|b|c|d).toString(16).slice(1)}},unit:function(a,b){var c=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,d=c.exec(a),e=c.exec(b),f=e[1].indexOf("."),g=f>0?e[1].length-f-1:0;a=+d[1];var h=+e[1]-a,i=d[2];return function(b){return(a+h*b).toFixed(g)+i}}},filter:{outline:function(a){var b='',c=Number.isFinite(a.margin)?a.margin:2,d=Number.isFinite(a.width)?a.width:1;return joint.util.template(b)({color:a.color||"blue",opacity:Number.isFinite(a.opacity)?a.opacity:1,outerRadius:c+d,innerRadius:c})},highlight:function(a){var b='';return joint.util.template(b)({color:a.color||"red",width:Number.isFinite(a.width)?a.width:1,blur:Number.isFinite(a.blur)?a.blur:0,opacity:Number.isFinite(a.opacity)?a.opacity:1})},blur:function(a){var b=Number.isFinite(a.x)?a.x:2;return joint.util.template('')({stdDeviation:Number.isFinite(a.y)?[b,a.y]:b})},dropShadow:function(a){var b="SVGFEDropShadowElement"in window?'':'';return joint.util.template(b)({dx:a.dx||0,dy:a.dy||0,opacity:Number.isFinite(a.opacity)?a.opacity:1,color:a.color||"black",blur:Number.isFinite(a.blur)?a.blur:4})},grayscale:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.2126+.7874*(1-b),b:.7152-.7152*(1-b),c:.0722-.0722*(1-b),d:.2126-.2126*(1-b),e:.7152+.2848*(1-b),f:.0722-.0722*(1-b),g:.2126-.2126*(1-b),h:.0722+.9278*(1-b)})},sepia:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({a:.393+.607*(1-b),b:.769-.769*(1-b),c:.189-.189*(1-b),d:.349-.349*(1-b),e:.686+.314*(1-b),f:.168-.168*(1-b),g:.272-.272*(1-b),h:.534-.534*(1-b),i:.131+.869*(1-b)})},saturate:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:1-b})},hueRotate:function(a){return joint.util.template('')({angle:a.angle||0})},invert:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:1-b})},brightness:function(a){return joint.util.template('')({amount:Number.isFinite(a.amount)?a.amount:1})},contrast:function(a){var b=Number.isFinite(a.amount)?a.amount:1;return joint.util.template('')({amount:b,amount2:.5-b/2})}},format:{number:function(a,b,c){function d(a){for(var b=a.length,d=[],e=0,f=c.grouping[0];b>0&&f>0;)d.push(a.substring(b-=f,b+f)),f=c.grouping[e=(e+1)%c.grouping.length];return d.reverse().join(c.thousands)}c=c||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var e=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,f=e.exec(a),g=f[1]||" ",h=f[2]||">",i=f[3]||"",j=f[4]||"",k=f[5],l=+f[6],m=f[7],n=f[8],o=f[9],p=1,q="",r="",s=!1;switch(n&&(n=+n.substring(1)),(k||"0"===g&&"="===h)&&(k=g="0",h="=",m&&(l-=Math.floor((l-1)/4))),o){case"n":m=!0,o="g";break;case"%":p=100,r="%",o="f";break;case"p":p=100,r="%",o="r";break;case"b":case"o":case"x":case"X":"#"===j&&(q="0"+o.toLowerCase());break;case"c":case"d":s=!0,n=0;break;case"s":p=-1,o="r"}"$"===j&&(q=c.currency[0],r=c.currency[1]),"r"!=o||n||(o="g"),null!=n&&("g"==o?n=Math.max(1,Math.min(21,n)):"e"!=o&&"f"!=o||(n=Math.max(0,Math.min(20,n))));var t=k&&m;if(s&&b%1)return"";var u=b<0||0===b&&1/b<0?(b=-b,"-"):i,v=r;if(p<0){var w=this.prefix(b,n);b=w.scale(b),v=w.symbol+r}else b*=p;b=this.convert(o,b,n);var x=b.lastIndexOf("."),y=x<0?b:b.substring(0,x),z=x<0?"":c.decimal+b.substring(x+1);!k&&m&&c.grouping&&(y=d(y));var A=q.length+y.length+z.length+(t?0:u.length),B=A"===h?B+u+b:"^"===h?B.substring(0,A>>=1)+u+b+B.substring(A):u+(t?b:B+b))+v},string:function(a,b){for(var c,d="{",e=!1,f=[];(c=a.indexOf(d))!==-1;){var g,h,i;if(g=a.slice(0,c),e){h=g.split(":"),i=h.shift().split("."),g=b;for(var j=0;j8?function(a){return a/c}:function(a){return a*c},symbol:a}}),d=0;return a&&(a<0&&(a*=-1),b&&(a=this.round(a,this.precision(a,b))),d=1+Math.floor(1e-12+Math.log(a)/Math.LN10),d=Math.max(-24,Math.min(24,3*Math.floor((d<=0?d+1:d-1)/3)))),c[8+d/3]}},template:function(a){var b=/<%= ([^ ]+) %>|\$\{ ?([^\{\} ]+) ?\}|\{\{([^\{\} ]+)\}\}/g;return function(c){return c=c||{},a.replace(b,function(a){for(var b=Array.from(arguments),d=b.slice(1,4).find(function(a){return!!a}),e=d.split("."),f=c[e.shift()];void 0!==f&&e.length;)f=f[e.shift()];return void 0!==f?f:""})}},toggleFullScreen:function(a){function b(a,b){for(var c=["webkit","moz","ms","o",""],d=0;d0&&b[0]||[],e=c>1&&b[c-1]||{};return Array.isArray(d)||(e instanceof joint.dia.Cell?d=b:d instanceof joint.dia.Cell&&(b.length>1&&b.pop(),d=b)),e instanceof joint.dia.Cell&&(e={}),a.call(this,d,e)}}},parseDOMJSON:function(a,b){for(var c={},d=V.namespace.xmlns,e=b||d,f=document.createDocumentFragment(),g=[a,f,e];g.length>0;){e=g.pop();for(var h=g.pop(),i=g.pop(),j=0,k=i.length;j0);return this.stopBatch("clear"),this},_prepareCell:function(a,b){var c;if(a instanceof Backbone.Model?(c=a.attributes,a.graph||b&&b.dry||(a.graph=this)):c=a,!joint.util.isString(c.type))throw new TypeError("dia.Graph: cell type must be a string.");return a},minZIndex:function(){var a=this.get("cells").first();return a?a.get("z")||0:0},maxZIndex:function(){var a=this.get("cells").last();return a?a.get("z")||0:0},addCell:function(a,b){return Array.isArray(a)?this.addCells(a,b):(a instanceof Backbone.Model?a.has("z")||a.set("z",this.maxZIndex()+1):void 0===a.z&&(a.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(a,b),b||{}),this)},addCells:function(a,b){return a.length&&(a=joint.util.flattenDeep(a),b.position=a.length,this.startBatch("add"),a.forEach(function(a){b.position--,this.addCell(a,b)},this),this.stopBatch("add")),this},resetCells:function(a,b){var c=joint.util.toArray(a).map(function(a){return this._prepareCell(a,b)},this);return this.get("cells").reset(c,b),this},removeCells:function(a,b){return a.length&&(this.startBatch("remove"),joint.util.invoke(a,"remove",b),this.stopBatch("remove")),this},_removeCell:function(a,b,c){c=c||{},c.clear||(c.disconnectLinks?this.disconnectLinks(a,c):this.removeLinks(a,c)),this.get("cells").remove(a,{silent:!0}),a.graph===this&&(a.graph=null)},getCell:function(a){return this.get("cells").get(a)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return Object.keys(this._nodes).map(this.getCell,this)},getLinks:function(){return Object.keys(this._edges).map(this.getCell,this)},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=[],f={};if(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),b.deep){var g=a.getEmbeddedCells({deep:!0}),h={};g.forEach(function(a){a.isLink()&&(h[a.id]=!0)}),g.forEach(function(a){a.isLink()||(d&&joint.util.forIn(this.getOutboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)),c&&joint.util.forIn(this.getInboundEdges(a.id),function(a,b){f[b]||h[b]||(e.push(this.getCell(b)),f[b]=!0)}.bind(this)))},this)}return e},getNeighbors:function(a,b){b=b||{};var c=b.inbound,d=b.outbound;void 0===c&&void 0===d&&(c=d=!0);var e=this.getConnectedLinks(a,b).reduce(function(e,f){var g=f.get("source"),h=f.get("target"),i=f.hasLoop(b);if(c&&joint.util.has(g,"id")&&!e[g.id]){var j=this.getCell(g.id);!i&&(!j||j===a||b.deep&&j.isEmbeddedIn(a))||(e[g.id]=j)}if(d&&joint.util.has(h,"id")&&!e[h.id]){var k=this.getCell(h.id);!i&&(!k||k===a||b.deep&&k.isEmbeddedIn(a))||(e[h.id]=k)}return e}.bind(this),{});return joint.util.toArray(e)},getCommonAncestor:function(){var a=Array.from(arguments).map(function(a){for(var b=[],c=a.get("parent");c;)b.push(c),c=this.getCell(c).get("parent");return b},this);a=a.sort(function(a,b){return a.length-b.length});var b=joint.util.toArray(a.shift()).find(function(b){return a.every(function(a){return a.includes(b)})});return this.getCell(b)},getSuccessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{outbound:!0})),c},cloneCells:function(a){a=joint.util.uniq(a);var b=joint.util.toArray(a).reduce(function(a,b){return a[b.id]=b.clone(),a},{});return joint.util.toArray(a).forEach(function(a){var c=b[a.id];if(c.isLink()){var d=c.get("source"),e=c.get("target");d.id&&b[d.id]&&c.prop("source/id",b[d.id].id),e.id&&b[e.id]&&c.prop("target/id",b[e.id].id)}var f=a.get("parent");f&&b[f]&&c.set("parent",b[f].id);var g=joint.util.toArray(a.get("embeds")).reduce(function(a,c){return b[c]&&a.push(b[c].id),a},[]);joint.util.isEmpty(g)||c.set("embeds",g)}),b},cloneSubgraph:function(a,b){var c=this.getSubgraph(a,b);return this.cloneCells(c)},getSubgraph:function(a,b){b=b||{};var c=[],d={},e=[],f=[];return joint.util.toArray(a).forEach(function(a){if(d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a)),b.deep){var g=a.getEmbeddedCells({deep:!0});g.forEach(function(a){d[a.id]||(c.push(a),d[a.id]=a,a.isLink()?f.push(a):e.push(a))})}}),f.forEach(function(a){var b=a.get("source"),f=a.get("target");if(b.id&&!d[b.id]){var g=this.getCell(b.id);c.push(g),d[g.id]=g,e.push(g)}if(f.id&&!d[f.id]){var h=this.getCell(f.id);c.push(this.getCell(f.id)), +d[h.id]=h,e.push(h)}},this),e.forEach(function(a){var e=this.getConnectedLinks(a,b);e.forEach(function(a){var b=a.get("source"),e=a.get("target");!d[a.id]&&b.id&&d[b.id]&&e.id&&d[e.id]&&(c.push(a),d[a.id]=a)})},this),c},getPredecessors:function(a,b){b=b||{};var c=[];return this.search(a,function(b){b!==a&&c.push(b)},joint.util.assign({},b,{inbound:!0})),c},search:function(a,b,c){c=c||{},c.breadthFirst?this.bfs(a,b,c):this.dfs(a,b,c)},bfs:function(a,b,c){c=c||{};var d={},e={},f=[];for(f.push(a),e[a.id]=0;f.length>0;){var g=f.shift();if(!d[g.id]){if(d[g.id]=!0,b(g,e[g.id])===!1)return;this.getNeighbors(g,c).forEach(function(a){e[a.id]=e[g.id]+1,f.push(a)})}}},dfs:function(a,b,c,d,e){c=c||{};var f=d||{},g=e||0;b(a,g)!==!1&&(f[a.id]=!0,this.getNeighbors(a,c).forEach(function(a){f[a.id]||this.dfs(a,b,c,f,g+1)},this))},getSources:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._in[c]&&!joint.util.isEmpty(this._in[c])||a.push(this.getCell(c))}.bind(this)),a},getSinks:function(){var a=[];return joint.util.forIn(this._nodes,function(b,c){this._out[c]&&!joint.util.isEmpty(this._out[c])||a.push(this.getCell(c))}.bind(this)),a},isSource:function(a){return!this._in[a.id]||joint.util.isEmpty(this._in[a.id])},isSink:function(a){return!this._out[a.id]||joint.util.isEmpty(this._out[a.id])},isSuccessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{outbound:!0}),c},isPredecessor:function(a,b){var c=!1;return this.search(a,function(d){if(d===b&&d!==a)return c=!0,!1},{inbound:!0}),c},isNeighbor:function(a,b,c){c=c||{};var d=c.inbound,e=c.outbound;void 0===d&&void 0===e&&(d=e=!0);var f=!1;return this.getConnectedLinks(a,c).forEach(function(a){var c=a.get("source"),g=a.get("target");return d&&joint.util.has(c,"id")&&c.id===b.id?(f=!0,!1):e&&joint.util.has(g,"id")&&g.id===b.id?(f=!0,!1):void 0}),f},disconnectLinks:function(a,b){this.getConnectedLinks(a).forEach(function(c){c.set(c.get("source").id===a.id?"source":"target",{x:0,y:0},b)})},removeLinks:function(a,b){joint.util.invoke(this.getConnectedLinks(a),"remove",b)},findModelsFromPoint:function(a){return this.getElements().filter(function(b){return b.getBBox().containsPoint(a)})},findModelsInArea:function(a,b){a=g.rect(a),b=joint.util.defaults(b||{},{strict:!1});var c=b.strict?"containsRect":"intersect";return this.getElements().filter(function(b){return a[c](b.getBBox())})},findModelsUnderElement:function(a,b){b=joint.util.defaults(b||{},{searchBy:"bbox"});var c=a.getBBox(),d="bbox"===b.searchBy?this.findModelsInArea(c):this.findModelsFromPoint(c[b.searchBy]());return d.filter(function(b){return a.id!==b.id&&!b.isEmbeddedIn(a)})},getBBox:function(a,b){return this.getCellsBBox(a||this.getElements(),b)},getCellsBBox:function(a,b){return joint.util.toArray(a).reduce(function(a,c){return c.isLink()?a:a?a.union(c.getBBox(b)):c.getBBox(b)},null)},translate:function(a,b,c){var d=this.getCells().filter(function(a){return!a.isEmbedded()});return joint.util.invoke(d,"translate",a,b,c),this},resize:function(a,b,c){return this.resizeCells(a,b,this.getCells(),c)},resizeCells:function(a,b,c,d){var e=this.getCellsBBox(c);if(e){var f=Math.max(a/e.width,0),g=Math.max(b/e.height,0);joint.util.invoke(c,"scale",f,g,e.origin(),d)}return this},startBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)+1,this.trigger("batch:start",joint.util.assign({},b,{batchName:a}))},stopBatch:function(a,b){return b=b||{},this._batches[a]=(this._batches[a]||0)-1,this.trigger("batch:stop",joint.util.assign({},b,{batchName:a}))},hasActiveBatch:function(a){return 0===arguments.length?joint.util.toArray(this._batches).some(function(a){return a>0}):Array.isArray(a)?a.some(function(a){return!!this._batches[a]},this):!!this._batches[a]}},{validations:{multiLinks:function(a,b){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=a.getConnectedLinks(e,{outbound:!0}),g=f.filter(function(a){var b=a.get("source"),e=a.get("target");return b&&b.id===c.id&&(!b.port||b.port===c.port)&&e&&e.id===d.id&&(!e.port||e.port===d.port)});if(g.length>1)return!1}}return!0},linkPinning:function(a,b){return b.source().id&&b.target().id}}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a,b){return function(c,d){var f=e.isPercentage(c);c=parseFloat(c),f&&(c/=100);var g={};if(isFinite(c)){var h=f||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function g(a,b,d){return function(f,g){var h=e.isPercentage(f);f=parseFloat(f),h&&(f/=100);var i;if(isFinite(f)){var j=g[d]();i=h||f>0&&f<1?j[a]+g[b]*f:j[a]+f}var k=c.Point();return k[a]=i||0,k}}function h(a,b,d){return function(f,g){var h;h="middle"===f?g[b]/2:f===d?g[b]:isFinite(f)?f>-1&&f<1?-g[b]*f:-f:e.isPercentage(f)?g[b]*parseFloat(f)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}function i(a,b){var c="joint-shape",e=b&&b.resetOffset;return function(b,f,g){var h=d(g),i=h.data(c);if(!i||i.value!==b){var j=a(b);i={value:b,shape:j,shapeBBox:j.bbox()},h.data(c,i)}var k=i.shape.clone(),l=i.shapeBBox.clone(),m=l.origin(),n=f.origin();l.x=n.x,l.y=n.y;var o=f.maxRectScaleToFit(l,n),p=0===l.width||0===f.width?1:o.sx,q=0===l.height||0===f.height?1:o.sy;return k.scale(p,q,m),e&&k.translate(-m.x,-m.y),k}}function j(a){function d(a){return new c.Path(b.normalizePathData(a))}var e=i(d,a);return function(a,b,c){var d=e(a,b,c);return{d:d.serialize()}}}function k(a){var b=i(c.Polyline,a);return function(a,c,d){var e=b(a,c,d);return{points:e.serialize()}}}function l(a,b){var d=new c.Point(1,0);return function(c){var e,f,g=this[a](c);return g?(f=b.rotate?g.vector().vectorAngle(d):0,e=g.start):(e=this.path.start,f=0),0===f?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+f+")"}}}function m(a,b,c){return void 0!==c.text}function n(){return this instanceof a.dia.LinkView}function o(a){var b={},c=a.stroke;"string"==typeof c&&(b.stroke=c,b.fill=c);var d=a.strokeOpacity;return void 0===d&&(d=a["stroke-opacity"]),void 0===d&&(d=a.opacity),void 0!==d&&(b["stroke-opacity"]=d,b["fill-opacity"]=d),b}var p=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},filter:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineFilter(a)+")"}},fill:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},stroke:{qualify:e.isPlainObject,set:function(a){return"url(#"+this.paper.defineGradient(a)+")"}},sourceMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),{transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a,b,c,d){return a=e.assign(o(d),a),{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{qualify:function(a,b,c){return!c.textWrap||!e.isPlainObject(c.textWrap)},set:function(c,f,g,h){var i=d(g),j="joint-text",k=i.data(j),l=a.util.pick(h,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol"),m=l.fontSize=h["font-size"]||h.fontSize,n=JSON.stringify([c,l]);if(void 0===k||k!==n){m&&g.setAttribute("font-size",m);var o=l.textPath;if(e.isObject(o)){var p=o.selector;if("string"==typeof p){var q=this.findBySelector(p)[0];q instanceof SVGPathElement&&(l.textPath=e.assign({"xlink:href":"#"+q.id},o))}}b(g).text(""+c,l),i.data(j,n)}}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,f){var g=b.width||0;e.isPercentage(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;e.isPercentage(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=b.text;if(void 0===i&&(i=attr.text),void 0!==i)var j=a.util.breakText(""+i,c,{"font-weight":f["font-weight"]||f.fontWeight,"font-size":f["font-size"]||f.fontSize,"font-family":f["font-family"]||f.fontFamily,lineHeight:f.lineHeight},{svgDocument:this.paper.svg});a.dia.attributes.text.set.call(this,j,c,d,f)}},title:{qualify:function(a,b){return b instanceof SVGElement},set:function(a,b,c){var e=d(c),f="joint-title",g=e.data(f);if(void 0===g||g!==a){e.data(f,a);var h=c.firstChild;if(h&&"TITLE"===h.tagName.toUpperCase())h.textContent=a;else{var i=document.createElementNS(c.namespaceURI,"title");i.textContent=a,c.insertBefore(i,h)}}}},lineHeight:{qualify:m},textVerticalAnchor:{qualify:m},textPath:{qualify:m},annotations:{qualify:m},port:{set:function(a){return null===a||void 0===a.id?a:a.id}},style:{qualify:e.isPlainObject,set:function(a,b,c){d(c).css(a)}},html:{set:function(a,b,c){d(c).html(a+"")}},ref:{},refX:{position:g("x","width","origin")},refY:{position:g("y","height","origin")},refDx:{position:g("x","width","corner")},refDy:{position:g("y","height","corner")},refWidth:{set:f("width","width")},refHeight:{set:f("height","height")},refRx:{set:f("rx","width")},refRy:{set:f("ry","height")},refRInscribed:{set:function(a){var b=f(a,"width"),c=f(a,"height");return function(a,d){var e=d.height>d.width?b:c;return e(a,d)}}("r")},refRCircumscribed:{set:function(a,b){var c=e.isPercentage(a);a=parseFloat(a),c&&(a/=100);var d,f=Math.sqrt(b.height*b.height+b.width*b.width);return isFinite(a)&&(d=c||a>=0&&a<=1?a*f:Math.max(a+f,0)),{r:d}}},refCx:{set:f("cx","width")},refCy:{set:f("cy","height")},xAlignment:{offset:h("x","width","right")},yAlignment:{offset:h("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}},refDResetOffset:{set:j({resetOffset:!0})},refDKeepOffset:{set:j({resetOffset:!1})},refPointsResetOffset:{set:k({resetOffset:!0})},refPointsKeepOffset:{set:k({resetOffset:!1})},connection:{qualify:n,set:function(){return{d:this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:n,set:l("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:n,set:l("getTangentAtRatio",{rotate:!1})}};p.refR=p.refRInscribed,p.refD=p.refDResetOffset,p.refPoints=p.refPointsResetOffset,p.atConnectionLength=p.atConnectionLengthKeepGradient,p.atConnectionRatio=p.atConnectionRatioKeepGradient,p.refX2=p.refX,p.refY2=p.refY,p["ref-x"]=p.refX,p["ref-y"]=p.refY,p["ref-dy"]=p.refDy,p["ref-dx"]=p.refDx,p["ref-width"]=p.refWidth,p["ref-height"]=p.refHeight,p["x-alignment"]=p.xAlignment,p["y-alignment"]=p.yAlignment}(joint,V,g,$,joint.util),function(a,b){var c=a.mvc.View.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var a=this.name;a&&this.vel.attr("data-tool-name",a)},configure:function(a,b){return this.relatedView=a,this.paper=a.paper,this.parentView=b,this.simulateRelatedView(this.el),this},simulateRelatedView:function(a){a&&a.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var a=this.options.focusOpacity;isFinite(a)&&(this.el.style.opacity=a),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){}}),d=a.mvc.View.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,options:{tools:null,relatedView:null,name:null,component:!1},configure:function(d){d=b.assign(this.options,d);var e=d.tools;if(!Array.isArray(e))return this;var f=d.relatedView;if(!(f instanceof a.dia.CellView))return this;for(var g=this.tools=[],h=0,i=e.length;h0;){var d=c.shift();b.push(d),c.push.apply(c,d.getEmbeddedCells())}}else b=this.getEmbeddedCells(),b.forEach(function(c){b.push.apply(b,c.getEmbeddedCells(a))});else b=joint.util.toArray(this.get("embeds")).map(this.graph.getCell,this.graph);return b}return[]},isEmbeddedIn:function(a,b){var c=joint.util.isString(a)?a:a.id,d=this.parent();if(b=joint.util.defaults({deep:!0},b),this.graph&&b.deep){for(;d;){if(d===c)return!0;d=this.graph.getCell(d).parent()}return!1}return d===c},isEmbedded:function(){return!!this.parent()},clone:function(a){if(a=a||{},a.deep)return joint.util.toArray(joint.dia.Graph.prototype.cloneCells.call(null,[this].concat(this.getEmbeddedCells({deep:!0}))));var b=Backbone.Model.prototype.clone.apply(this,arguments);return b.set("id",joint.util.uuid()),b.unset("embeds"),b.unset("parent"),b},prop:function(a,b,c){var d="/",e=joint.util.isString(a);if(e||Array.isArray(a)){if(arguments.length>1){var f,g;e?(f=a,g=f.split("/")):(f=a.join(d),g=a.slice());var h=g[0],i=g.length;if(c=c||{},c.propertyPath=f,c.propertyValue=b,c.propertyPathArray=g,1===i)return this.set(h,b,c);for(var j={},k=j,l=h,m=1;m0)},getSelector:function(a,b){if(a===this.el)return b;var c;if(a){var d=V(a).index()+1;c=a.tagName+":nth-child("+d+")",b&&(c+=" > "+b),c=this.getSelector(a.parentNode,c)}return c},getLinkEnd:function(a,b,c,d,e){var f=this.model,h=f.id,i=this.findAttribute("port",a),j=a.getAttribute("joint-selector"),k={id:h};null!=j&&(k.magnet=j),null!=i?(k.port=i,f.hasPort(i)||j||(k.selector=this.getSelector(a))):null==j&&this.el!==a&&(k.selector=this.getSelector(a));var l=this.paper,m=l.options.connectionStrategy;if("function"==typeof m){var n=m.call(l,k,this,a,new g.Point(b,c),d,e);n&&(k=n)}return k},getMagnetFromLinkEnd:function(a){var b,c=this.el,d=a.port,e=a.magnet;return null!=d&&this.model.hasPort(d)?b=this.findPortNode(d,e)||c:(e||(e=a.selector),e||null==d||(e='[port="'+d+'"]'),b=this.findBySelector(e,c,this.selectors)[0]),b},findAttribute:function(a,b){if(!b)return null;var c=b.getAttribute(a);if(null===c){if(b===this.el)return null;for(var d=b.parentNode;d&&d!==this.el&&1===d.nodeType&&(c=d.getAttribute(a),null===c);)d=d.parentNode}return c},getAttributeDefinition:function(a){return this.model.constructor.getAttributeDefinition(a)},setNodeAttributes:function(a,b){joint.util.isEmpty(b)||(a instanceof SVGElement?V(a).attr(b):$(a).attr(b))},processNodeAttributes:function(a,b){var c,d,e,f,g,h,i,j,k,l=[];for(c in b)b.hasOwnProperty(c)&&(d=b[c],e=this.getAttributeDefinition(c),!e||joint.util.isFunction(e.qualify)&&!e.qualify.call(this,d,a,b)?(h||(h={}),h[joint.util.toKebabCase(c)]=d):(joint.util.isString(e.set)&&(h||(h={}),h[e.set]=d),null!==d&&l.push(c,e)));for(f=0,g=l.length;f0&&x.height>0){var y=V.transformRect(a.getBBox(),p).scale(1/r,1/s);for(e in m)f=m[e],h=this.getAttributeDefinition(e),t=h.offset.call(this,f,y,a,i),t&&(q.offset(g.Point(t).scale(r,s)),w||(w=!0))}}(void 0!==o||v||w)&&(q.round(1),p.e=q.x,p.f=q.y,a.setAttribute("transform",V.matrixToTransformString(p)))},getNodeScale:function(a,b){var c,d;if(b&&b.contains(a)){var e=b.scale();c=1/e.sx,d=1/e.sy}else c=1,d=1;return{sx:c,sy:d}},findNodesAttributes:function(a,b,c,d){var e={};for(var f in a)if(a.hasOwnProperty(f))for(var g=c[f]=this.findBySelector(f,b,d),h=0,i=g.length;h-1?l.splice(t,0,d):l.push(d)}else this.setNodeAttributes(e,i.normal);for(var u=0,v=l.length;u0){this.startBatch("fit-embeds",a),a.deep&&joint.util.invoke(b,"fitEmbeds",a);var c=this.graph.getCellsBBox(b),d=joint.util.normalizeSides(a.padding);c.moveAndExpand({x:-d.left,y:-d.top,width:d.right+d.left,height:d.bottom+d.top}),this.set({position:{x:c.x,y:c.y},size:{width:c.width,height:c.height}},a),this.stopBatch("fit-embeds")}return this},rotate:function(a,b,c,d){if(c){var e=this.getBBox().center(),f=this.get("size"),g=this.get("position");e.rotate(c,this.get("angle")-a);var h=e.x-f.width/2-g.x,i=e.y-f.height/2-g.y;this.startBatch("rotate",{angle:a,absolute:b,origin:c}),this.position(g.x+h,g.y+i,d),this.rotate(a,b,null,d),this.stopBatch("rotate")}else this.set("angle",b?a:(this.get("angle")+a)%360,d);return this},angle:function(){return g.normalizeAngle(this.get("angle")||0)},getBBox:function(a){if(a=a||{},a.deep&&this.graph){var b=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return b.push(this),this.graph.getCellsBBox(b)}var c=this.get("position"),d=this.get("size");return new g.Rect(c.x,c.y,d.width,d.height)}}),joint.dia.ElementView=joint.dia.CellView.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("element"),a.join(" ")},metrics:null,initialize:function(){joint.dia.CellView.prototype.initialize.apply(this,arguments);var a=this.model;this.listenTo(a,"change:position",this.translate),this.listenTo(a,"change:size",this.resize),this.listenTo(a,"change:angle",this.rotate),this.listenTo(a,"change:markup",this.render),this._initializePorts(),this.metrics={}},_initializePorts:function(){},update:function(a,b){this.metrics={},this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:new g.Rect(c.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.ElementView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.ElementView: ambiguous root selector.");c[d]=this.el,this.rotatableNode=V(c[this.rotatableSelector])||null,this.scalableNode=V(c[this.scalableSelector])||null,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=this.vel;b.append(V(a)),this.rotatableNode=b.findOne(".rotatable"),this.scalableNode=b.findOne(".scalable");var c=this.selectors={};c[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate(),this):(this.updateTransformation(),this)},resize:function(){return this.scalableNode?this.sgResize.apply(this,arguments):(this.model.attributes.angle&&this.rotate(),void this.update())},translate:function(){return this.rotatableNode?this.rgTranslate():void this.updateTransformation()},rotate:function(){return this.rotatableNode?this.rgRotate():void this.updateTransformation()},updateTransformation:function(){var a=this.getTranslateString(),b=this.getRotateString();b&&(a+=" "+b),this.vel.attr("transform",a)},getTranslateString:function(){var a=this.model.attributes.position;return"translate("+a.x+","+a.y+")"},getRotateString:function(){var a=this.model.attributes,b=a.angle;if(!b)return null;var c=a.size;return"rotate("+b+","+c.width/2+","+c.height/2+")"},getBBox:function(a){var b;if(a&&a.useModelGeometry){var c=this.model;b=c.getBBox().bbox(c.angle())}else b=this.getNodeBBox(this.el);return this.paper.localToPaperRect(b)},nodeCache:function(a){var b=V.ensureId(a),c=this.metrics[b];return c||(c=this.metrics[b]={}),c},getNodeData:function(a){var b=this.nodeCache(a);return b.data||(b.data={}),b.data},getNodeBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix(),e=this.getRootRotateMatrix();return V.transformRect(b,d.multiply(e).multiply(c))},getNodeBoundingRect:function(a){var b=this.nodeCache(a);return void 0===b.boundingRect&&(b.boundingRect=V(a).getBBox()),new g.Rect(b.boundingRect)},getNodeUnrotatedBBox:function(a){var b=this.getNodeBoundingRect(a),c=this.getNodeMatrix(a),d=this.getRootTranslateMatrix();return V.transformRect(b,d.multiply(c))},getNodeShape:function(a){var b=this.nodeCache(a);return void 0===b.geometryShape&&(b.geometryShape=V(a).toGeometryShape()),b.geometryShape.clone()},getNodeMatrix:function(a){var b=this.nodeCache(a);if(void 0===b.magnetMatrix){var c=this.rotatableNode||this.el;b.magnetMatrix=V(a).getTransformToElement(c)}return V.createSVGMatrix(b.magnetMatrix)},getRootTranslateMatrix:function(){var a=this.model,b=a.position(),c=V.createSVGMatrix().translate(b.x,b.y);return c},getRootRotateMatrix:function(){var a=V.createSVGMatrix(),b=this.model,c=b.angle();if(c){var d=b.getBBox(),e=d.width/2,f=d.height/2;a=a.translate(e,f).rotate(c).translate(-e,-f)}return a},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(a,b,c){var d=this.model,e=d.get("angle")||0,f=d.get("size")||{width:1,height:1},g=this.scalableNode,h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=f.width/(i.width||1),k=f.height/(i.height||1);g.attr("transform","scale("+j+","+k+")");var l=this.rotatableNode,m=l&&l.attr("transform");if(m&&null!==m){l.attr("transform",m+" rotate("+-e+","+f.width/2+","+f.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},prepareEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front"),b.toFront({deep:!0,ui:!0});var e=d.get("cells").max("z").get("z"),f=d.getConnectedLinks(b,{deep:!0});joint.util.invoke(f,"set","z",e+1,{ui:!0}),b.stopBatch("to-front");var g=b.parent();g&&d.getCell(g).unembed(b,{ui:!0})},processEmbedding:function(a){a||(a={});var b=a.model||this.model,c=a.paper||this.paper,d=c.options,e=[];if(joint.util.isFunction(d.findParentBy)){var f=joint.util.toArray(d.findParentBy.call(c.model,this));e=f.filter(function(a){return a instanceof joint.dia.Cell&&this.model.id!==a.id&&!a.isEmbeddedIn(this.model)}.bind(this))}else e=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var g=null,h=a.candidateEmbedView,i=e.length-1;i>=0;i--){var j=e[i];if(h&&h.model.id==j.id){g=h;break}var k=j.findView(c);if(d.validateEmbedding.call(c,this,k)){g=k;break}}g&&g!=h&&(this.clearEmbedding(a),a.candidateEmbedView=g.highlight(null,{embedding:!0})),!g&&h&&this.clearEmbedding(a)},clearEmbedding:function(a){a||(a={});var b=a.candidateEmbedView;b&&(b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null)},finalizeEmbedding:function(a){a||(a={});var b=a.candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),a.candidateEmbedView=null),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdblclick:function(a,b,c){joint.dia.CellView.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",a,b,c)},pointerclick:function(a,b,c){joint.dia.CellView.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",a,b,c)},contextmenu:function(a,b,c){joint.dia.CellView.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",a,b,c)},pointerdown:function(a,b,c){joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c),this.dragStart(a,b,c)},pointermove:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.drag(a,b,c);break;case"magnet":this.dragMagnet(a,b,c)}d.stopPropagation||(joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)),this.eventData(a,d)},pointerup:function(a,b,c){var d=this.eventData(a);switch(d.action){case"move":this.dragEnd(a,b,c);break;case"magnet":return void this.dragMagnetEnd(a,b,c)}d.stopPropagation||(this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},mouseover:function(a){joint.dia.CellView.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",a)},mouseout:function(a){joint.dia.CellView.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",a)},mouseenter:function(a){joint.dia.CellView.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",a)},mouseleave:function(a){joint.dia.CellView.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",a)},mousewheel:function(a,b,c,d){joint.dia.CellView.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",a,b,c,d)},onmagnet:function(a,b,c){this.dragMagnetStart(a,b,c);var d=this.eventData(a).stopPropagation;d&&a.stopPropagation()},dragStart:function(a,b,c){this.can("elementMove")&&this.eventData(a,{action:"move",x:b,y:c,restrictedArea:this.paper.getRestrictedArea(this)})},dragMagnetStart:function(a,b,c){if(this.can("addLinkFromMagnet")){this.model.startBatch("add-link");var d=this.paper,e=d.model,f=a.target,g=d.getDefaultLink(this,f),h=this.getLinkEnd(f,b,c,g,"source"),i={x:b,y:c};g.set({source:h,target:i}),g.addTo(e,{async:!1,ui:!0});var j=g.findView(d);joint.dia.CellView.prototype.pointerdown.apply(j,arguments),j.notify("link:pointerdown",a,b,c);var k=j.startArrowheadMove("target",{whenNotAllowed:"remove"});j.eventData(a,k),this.eventData(a,{action:"magnet",linkView:j,stopPropagation:!0}),this.paper.delegateDragEvents(this,a.data)}},drag:function(a,b,c){var d=this.paper,e=d.options.gridSize,f=this.model,h=f.position(),i=this.eventData(a),j=g.snapToGrid(h.x,e)-h.x+g.snapToGrid(b-i.x,e),k=g.snapToGrid(h.y,e)-h.y+g.snapToGrid(c-i.y,e);f.translate(j,k,{restrictedArea:i.restrictedArea,ui:!0});var l=!!i.embedding;d.options.embeddingMode&&(l||(this.prepareEmbedding(i),l=!0),this.processEmbedding(i)),this.eventData(a,{x:g.snapToGrid(b,e),y:g.snapToGrid(c,e),embedding:l})},dragMagnet:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointermove(a,b,c)},dragEnd:function(a,b,c){var d=this.eventData(a);d.embedding&&this.finalizeEmbedding(d)},dragMagnetEnd:function(a,b,c){var d=this.eventData(a),e=d.linkView;e&&e.pointerup(a,b,c),this.model.stopBatch("add-link")}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),doubleToolMarkup:void 0,vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",yAlignment:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,refWidth:1,refHeight:1,refX:0,refY:0}},position:{distance:.5}}},defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(a){return this.set({source:{x:0,y:0},target:{x:0,y:0}},a)},source:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("source"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("source",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("source",d,e)):(d=a,e=b,this.set("source",d,e))},target:function(a,b,c){if(void 0===a)return joint.util.clone(this.get("target"));var d,e,f=a instanceof joint.dia.Cell;if(f)return d=joint.util.clone(b)||{},d.id=a.id,e=c,this.set("target",d,e);var h=a instanceof g.Point;return h?(d=joint.util.clone(b)||{},d.x=a.x,d.y=a.y,e=c,this.set("target",d,e)):(d=a,e=b,this.set("target",d,e))},router:function(a,b,c){if(void 0===a){var d=this.get("router");return d?"object"==typeof d?joint.util.clone(d):d:this.get("manhattan")?{name:"orthogonal"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("router",f,g)},connector:function(a,b,c){if(void 0===a){var d=this.get("connector");return d?"object"==typeof d?joint.util.clone(d):d:this.get("smooth")?{name:"smooth"}:null}var e="object"==typeof a||"function"==typeof a,f=e?a:{name:a,args:b},g=e?b:c;return this.set("connector",f,g)},label:function(a,b,c){var d=this.labels();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},labels:function(a,b){return 0===arguments.length?(a=this.get("labels"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("labels",a,b))},insertLabel:function(a,b,c){if(!b)throw new Error("dia.Link: no label provided");var d=this.labels(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.labels(d,c)},appendLabel:function(a,b){return this.insertLabel(-1,a,b)},removeLabel:function(a,b){var c=this.labels();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.labels(c,b)},vertex:function(a,b,c){var d=this.vertices();return a=isFinite(a)&&null!==a?0|a:0,a<0&&(a=d.length+a),arguments.length<=1?this.prop(["vertices",a]):this.prop(["vertices",a],b,c)},vertices:function(a,b){return 0===arguments.length?(a=this.get("vertices"),Array.isArray(a)?a.slice():[]):(Array.isArray(a)||(a=[]),this.set("vertices",a,b))},insertVertex:function(a,b,c){if(!b)throw new Error("dia.Link: no vertex provided");var d=this.vertices(),e=d.length;return a=isFinite(a)&&null!==a?0|a:e,a<0&&(a=e+a+1),d.splice(a,0,b),this.vertices(d,c)},removeVertex:function(a,b){var c=this.vertices();return a=isFinite(a)&&null!==a?0|a:-1,c.splice(a,1),this.vertices(c,b)},translate:function(a,b,c){return c=c||{},c.translateBy=c.translateBy||this.id,c.tx=a,c.ty=b,this.applyToPoints(function(c){return{x:(c.x||0)+a,y:(c.y||0)+b}},c)},scale:function(a,b,c,d){return this.applyToPoints(function(d){return g.point(d).scale(a,b,c).toJSON()},d)},applyToPoints:function(a,b){if(!joint.util.isFunction(a))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var c={},d=this.source();d.id||(c.source=a(d));var e=this.target();e.id||(c.target=a(e));var f=this.vertices();return f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.getSourceElement(),d=this.getTargetElement(),e=this.getParentCell();c&&d&&(b=this.graph.getCommonAncestor(c,d)),!e||b&&b.id===e.id||e.unembed(this,a),b&&b.embed(this,a)}return b},hasLoop:function(a){a=a||{};var b=this.source().id,c=this.target().id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.getSourceElement(),f=this.getTargetElement();d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.source(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getTargetElement:function(){var a=this.target(),b=this.graph;return a&&a.id&&b&&b.getCell(a.id)||null},getRelationshipAncestor:function(){var a;if(this.graph){var b=[this,this.getSourceElement(),this.getTargetElement()].filter(function(a){return!!a});a=this.graph.getCommonAncestor.apply(this.graph,b)}return a||null},isRelationshipEmbeddedIn:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(b))},_getDefaultLabel:function(){var a=this.get("defaultLabel")||this.defaultLabel||{},b={};return b.markup=a.markup||this.get("labelMarkup")||this.labelMarkup,b.position=a.position,b.attrs=a.attrs,b.size=a.size,b}},{endsEqual:function(a,b){var c=a.port===b.port||!a.port&&!b.port;return a.id===b.id&&c}}),joint.dia.LinkView=joint.dia.CellView.extend({className:function(){var a=joint.dia.CellView.prototype.className.apply(this).split(" ");return a.push("link"),a.join(" ")},options:{shortLinkLength:105,doubleLinkTools:!1,longLinkLength:155,linkToolsOffset:40,doubleLinkToolsOffset:65,sampleInterval:50},_labelCache:null,_labelSelectors:null,_markerCache:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(a){joint.dia.CellView.prototype.initialize.apply(this,arguments),"function"!=typeof this.constructor.prototype.watchSource&&(this.constructor.prototype.watchSource=this.createWatcher("source"),this.constructor.prototype.watchTarget=this.createWatcher("target")),this._labelCache={},this._labelSelectors={},this._markerCache={},this._V={},this.metrics={},this.startListening()},startListening:function(){var a=this.model;this.listenTo(a,"change:markup",this.render),this.listenTo(a,"change:smooth change:manhattan change:router change:connector",this.update),this.listenTo(a,"change:toolMarkup",this.onToolsChange),this.listenTo(a,"change:labels change:labelMarkup",this.onLabelsChange),this.listenTo(a,"change:vertices change:vertexMarkup",this.onVerticesChange),this.listenTo(a,"change:source",this.onSourceChange),this.listenTo(a,"change:target",this.onTargetChange)},onSourceChange:function(a,b,c){this.watchSource(a,b);var d=this.model;c.translateBy&&d.get("target").id&&b.id||this.update(d,null,c)},onTargetChange:function(a,b,c){this.watchTarget(a,b);var d=this.model;(!c.translateBy||d.get("source").id&&!b.id&&joint.util.isEmpty(d.get("vertices")))&&this.update(d,null,c)},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||this.update(a,null,c)},onToolsChange:function(){this.renderTools().updateToolsPosition()},onLabelsChange:function(a,b,c){var d=!0,e=this.model.previous("labels");if(e&&"propertyPathArray"in c&&"propertyValue"in c){var f=c.propertyPathArray||[],g=f.length;if(g>1){var h=!!e[f[1]];h&&(2===g?d="markup"in Object(c.propertyValue):"markup"!==f[2]&&(d=!1))}}d?this.renderLabels():this.updateLabels(),this.updateLabelPositions()},render:function(){this.vel.empty(),this._V={},this.renderMarkup(),this.renderLabels();var a=this.model;return this.watchSource(a,a.source()).watchTarget(a,a.target()).update(),this},renderMarkup:function(){var a=this.model,b=a.get("markup")||a.markup;if(!b)throw new Error("dia.LinkView: markup required");if(Array.isArray(b))return this.renderJSONMarkup(b);if("string"==typeof b)return this.renderStringMarkup(b);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(a){var b=joint.util.parseDOMJSON(a),c=this.selectors=b.selectors,d=this.selector;if(c[d])throw new Error("dia.LinkView: ambiguous root selector.");c[d]=this.el,this.vel.append(b.fragment)},renderStringMarkup:function(a){var b=V(a);Array.isArray(b)||(b=[b]);for(var c=this._V,d=0,e=b.length;d1||"G"!==d[0].nodeName.toUpperCase()?(c=V("g"),c.append(b),c.addClass("label")):(c=V(d[0]),c.addClass("label")),{node:c.node,selectors:a.selectors}}},renderLabels:function(){var a=this._V,b=a.labels,c=this._labelCache={},d=this._labelSelectors={};b&&b.empty();var e=this.model,f=e.get("labels")||[],g=f.length;if(0===g)return this;b||(b=a.labels=V("g").addClass("labels").appendTo(this.el));for(var h=0;h=this.options.longLinkLength){var e=this.options.doubleLinkToolsOffset||b;d=this.getPointAtLength(c-e),this._tool2Cache.attr("transform","translate("+d.x+", "+d.y+") "+a),this._tool2Cache.attr("visibility","visible")}else this.options.doubleLinkTools&&this._tool2Cache.attr("visibility","hidden")}return this},updateArrowheadMarkers:function(){if(!this._V.markerArrowheads)return this;if("none"===$.css(this._V.markerArrowheads.node,"display"))return this;var a=this.getConnectionLength()0&&b<=1,d=0,e={x:0,y:0};if(a.offset){var f=a.offset;"number"==typeof f&&(d=f),f.x&&(e.x=f.x),f.y&&(e.y=f.y)}var g,h=0!==e.x||0!==e.y||0===d,i=this.path,j={segmentSubdivisions:this.getConnectionSubdivisions()},k=c?b*this.getConnectionLength():b;if(h)g=i.pointAtLength(k,j),g.offset(e);else{var l=i.tangentAtLength(k,j);l?(l.rotate(l.start,-90),l.setLength(d),g=l.end):g=i.start}return g},getVertexIndex:function(a,b){for(var c=this.model,d=c.vertices(),e=this.getClosestPointLength(new g.Point(a,b)),f=0,h=d.length;f0){for(var j=0,k=i.length;j").addClass(joint.util.addClassNamePrefix("paper-background")),this.options.background&&this.drawBackground(this.options.background),this.$grid=$("
").addClass(joint.util.addClassNamePrefix("paper-grid")),this.options.drawGrid&&this.drawGrid(),this.$el.append(this.$background,this.$grid,this.svg),this},update:function(){return this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background),this},_viewportMatrix:null,_viewportTransformString:null,matrix:function(a){var b=this.viewport;if(void 0===a){var c=b.getAttribute("transform");return(this._viewportTransformString||null)===c?a=this._viewportMatrix:(a=b.getCTM(),this._viewportMatrix=a,this._viewportTransformString=c),V.createSVGMatrix(a)}return a=V.createSVGMatrix(a),ctmString=V.matrixToTransformString(a),b.setAttribute("transform",ctmString),this.tools.setAttribute("transform",ctmString),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_sortDelayingBatches:["add","to-front","to-back"],_onSort:function(){this.model.hasActiveBatch(this._sortDelayingBatches)||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;this._sortDelayingBatches.includes(b)&&!this.model.hasActiveBatch(this._sortDelayingBatches)&&this.sortViews()},onRemove:function(){this.removeViews()},setDimensions:function(a,b){a=this.options.width=a||this.options.width,b=this.options.height=b||this.options.height,this.$el.css({width:Math.round(a),height:Math.round(b)}),this.trigger("resize",a,b)},setOrigin:function(a,b){return this.translate(a||0,b||0,{absolute:!0})},fitToContent:function(a,b,c,d){joint.util.isObject(a)?(d=a,a=d.gridWidth||1,b=d.gridHeight||1,c=d.padding||0):(d=d||{},a=a||1,b=b||1,c=c||0),c=joint.util.normalizeSides(c);var e=V(this.viewport).getBBox(),f=this.scale(),g=this.translate();e.x*=f.sx,e.y*=f.sy,e.width*=f.sx,e.height*=f.sy;var h=Math.max(Math.ceil((e.width+e.x)/a),1)*a,i=Math.max(Math.ceil((e.height+e.y)/b),1)*b,j=0,k=0;("negative"==d.allowNewOrigin&&e.x<0||"positive"==d.allowNewOrigin&&e.x>=0||"any"==d.allowNewOrigin)&&(j=Math.ceil(-e.x/a)*a,j+=c.left,h+=j),("negative"==d.allowNewOrigin&&e.y<0||"positive"==d.allowNewOrigin&&e.y>=0||"any"==d.allowNewOrigin)&&(k=Math.ceil(-e.y/b)*b,k+=c.top,i+=k),h+=c.right,i+=c.bottom,h=Math.max(h,d.minWidth||0),i=Math.max(i,d.minHeight||0),h=Math.min(h,d.maxWidth||Number.MAX_VALUE),i=Math.min(i,d.maxHeight||Number.MAX_VALUE);var l=h!=this.options.width||i!=this.options.height,m=j!=g.tx||k!=g.ty;m&&this.translate(j,k),l&&this.setDimensions(h,i)},scaleContentToFit:function(a){var b=this.getContentBBox();if(b.width&&b.height){a=a||{},joint.util.defaults(a,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE});var c,d=a.padding,e=a.minScaleX||a.minScale,f=a.maxScaleX||a.maxScale,h=a.minScaleY||a.minScale,i=a.maxScaleY||a.maxScale;if(a.fittingBBox)c=a.fittingBBox;else{var j=this.translate();c={x:j.tx,y:j.ty,width:this.options.width,height:this.options.height}}c=g.rect(c).moveAndExpand({x:d,y:d,width:-2*d,height:-2*d});var k=this.scale(),l=c.width/b.width*k.sx,m=c.height/b.height*k.sy;if(a.preserveAspectRatio&&(l=m=Math.min(l,m)),a.scaleGrid){var n=a.scaleGrid;l=n*Math.floor(l/n),m=n*Math.floor(m/n)}l=Math.min(f,Math.max(e,l)),m=Math.min(i,Math.max(h,m)),this.scale(l,m);var o=this.getContentBBox(),p=c.x-o.x,q=c.y-o.y;this.translate(p,q)}},getContentArea:function(){return V(this.viewport).getBBox()},getContentBBox:function(){var a=this.viewport.getBoundingClientRect(),b=this.clientMatrix(),c=this.translate();return g.rect({x:a.left-b.e+c.tx,y:a.top-b.f+c.ty,width:a.width,height:a.height})},getArea:function(){return this.paperToLocalRect({x:0,y:0,width:this.options.width,height:this.options.height})},getRestrictedArea:function(){var a;return a=joint.util.isFunction(this.options.restrictTranslate)?this.options.restrictTranslate.apply(this,arguments):this.options.restrictTranslate===!0?this.getArea():this.options.restrictTranslate||null},createViewForModel:function(a){var b,c,d=this.options.cellViewNamespace,e=a.get("type")+"View",f=joint.util.getByPath(d,e,".");a.isLink()?(b=this.options.linkView,c=joint.dia.LinkView):(b=this.options.elementView,c=joint.dia.ElementView);var g=b.prototype instanceof Backbone.View?f||b:b.call(this,a)||f||c;return new g({model:a,interactive:this.options.interactive})},onCellAdded:function(a,b,c){if(this.options.async&&c.async!==!1&&joint.util.isNumber(c.position)){if(this._asyncCells=this._asyncCells||[],this._asyncCells.push(a),0==c.position){if(this._frameId)throw new Error("another asynchronous rendering in progress");this.asyncRenderViews(this._asyncCells,c),delete this._asyncCells}}else this.renderView(a)},removeView:function(a){var b=this._views[a.id];return b&&(b.remove(),delete this._views[a.id]),b},renderView:function(a){var b=this._views[a.id]=this.createViewForModel(a);return V(this.viewport).append(b.el),b.paper=this,b.render(),b},onImageDragStart:function(){return!1},beforeRenderViews:function(a){return a.sort(function(a){return a.isLink()?1:-1}),a},afterRenderViews:function(){this.sortViews()},resetViews:function(a,b){this.removeViews();var c=a.models.slice();if(c=this.beforeRenderViews(c,b)||c,this.cancelRenderViews(),this.options.async)this.asyncRenderViews(c,b);else{for(var d=0,e=c.length;d(e.get("z")||0)?1:-1})},scale:function(a,b,c,d){if(void 0===a)return V.matrixToScale(this.matrix());void 0===b&&(b=a),void 0===c&&(c=0,d=0);var e=this.translate();if(c||d||e.tx||e.ty){var f=e.tx-c*(a-1),g=e.ty-d*(b-1);this.translate(f,g)}var h=this.matrix();return h.a=a||0,h.d=b||0,this.matrix(h),this.trigger("scale",a,b,c,d),this},rotate:function(a,b,c){if(void 0===a)return V.matrixToRotate(this.matrix());if(void 0===b){var d=this.viewport.getBBox();b=d.width/2,c=d.height/2}var e=this.matrix().translate(b,c).rotate(a).translate(-b,-c);return this.matrix(e),this},translate:function(a,b){if(void 0===a)return V.matrixToTranslate(this.matrix());var c=this.matrix();c.e=a||0,c.f=b||0,this.matrix(c);var d=this.translate(),e=this.options.origin;return e.x=d.tx,e.y=d.ty,this.trigger("translate",d.tx,d.ty),this.options.drawGrid&&this.drawGrid(),this},findView:function(a){for(var b=joint.util.isString(a)?this.viewport.querySelector(a):a instanceof $?a[0]:a;b&&b!==this.el&&b!==document;){var c=b.getAttribute("model-id");if(c)return this._views[c];b=b.parentNode}},findViewByModel:function(a){var b=joint.util.isString(a)||joint.util.isNumber(a)?a:a&&a.id;return this._views[b]},findViewsFromPoint:function(a){a=g.point(a);var b=this.model.getElements().map(this.findViewByModel,this);return b.filter(function(b){return b&&b.vel.getBBox({target:this.viewport}).containsPoint(a)},this)},findViewsInArea:function(a,b){b=joint.util.defaults(b||{},{strict:!1}),a=g.rect(a);var c=this.model.getElements().map(this.findViewByModel,this),d=b.strict?"containsRect":"intersect";return c.filter(function(b){return b&&a[d](b.vel.getBBox({target:this.viewport}))},this)},removeTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"remove"),this},hideTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"hide"),this},showTools:function(){return joint.dia.CellView.dispatchToolsEvent(this,"show"),this},getModelById:function(a){return this.model.getCell(a)},snapToGrid:function(a,b){return this.clientToLocalPoint(a,b).snapToGrid(this.options.gridSize)},localToPaperPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix());return g.Point(d)},localToPaperRect:function(a,b,c,d){var e=g.Rect(a,b),f=V.transformRect(e,this.matrix());return g.Rect(f)},paperToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.matrix().inverse());return g.Point(d)},paperToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.matrix().inverse());return g.Rect(f)},localToClientPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix());return g.Point(d)},localToClientRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix());return g.Rect(f)},clientToLocalPoint:function(a,b){var c=g.Point(a,b),d=V.transformPoint(c,this.clientMatrix().inverse());return g.Point(d)},clientToLocalRect:function(a,b,c,d){var e=g.Rect(a,b,c,d),f=V.transformRect(e,this.clientMatrix().inverse());return g.Rect(f)},localToPagePoint:function(a,b){return this.localToPaperPoint(a,b).offset(this.pageOffset())},localToPageRect:function(a,b,c,d){return this.localToPaperRect(a,b,c,d).moveAndExpand(this.pageOffset())},pageToLocalPoint:function(a,b){var c=g.Point(a,b),d=c.difference(this.pageOffset());return this.paperToLocalPoint(d)},pageToLocalRect:function(a,b,c,d){var e=this.pageOffset(),f=g.Rect(a,b,c,d);return f.x-=e.x,f.y-=e.y,this.paperToLocalRect(f)},clientOffset:function(){var a=this.svg.getBoundingClientRect();return g.Point(a.left,a.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(a){if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide a linkView.");var b=a.model,c=this.options,d=this.model,e=d.constructor.validations;return!(!c.multiLinks&&!e.multiLinks.call(this,d,b))&&(!(!c.linkPinning&&!e.linkPinning.call(this,d,b))&&!("function"==typeof c.allowLink&&!c.allowLink.call(this,a,this)))},getDefaultLink:function(a,b){return joint.util.isFunction(this.options.defaultLink)?this.options.defaultLink.call(this,a,b):this.options.defaultLink.clone()},resolveHighlighter:function(a){a=a||{};var b=a.highlighter,c=this.options;if(void 0===b){var d=["embedding","connecting","magnetAvailability","elementAvailability"].find(function(b){return!!a[b]});b=d&&c.highlighting[d]||c.highlighting.default}if(!b)return!1;joint.util.isString(b)&&(b={name:b});var e=b.name,f=c.highlighterNamespace[e];if(!f)throw new Error('Unknown highlighter ("'+e+'")');if("function"!=typeof f.highlight)throw new Error('Highlighter ("'+e+'") is missing required highlight() method');if("function"!=typeof f.unhighlight)throw new Error('Highlighter ("'+e+'") is missing required unhighlight() method');return{highlighter:f,options:b.options||{},name:e}},onCellHighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){b.id||(b.id=V.uniqueId());var d=c.name+b.id+JSON.stringify(c.options);if(!this._highlights[d]){var e=c.highlighter;e.highlight(a,b,joint.util.assign({},c.options)),this._highlights[d]={cellView:a,magnetEl:b,opt:c.options,highlighter:e}}}},onCellUnhighlight:function(a,b,c){if(c=this.resolveHighlighter(c)){var d=c.name+b.id+JSON.stringify(c.options),e=this._highlights[d];e&&(e.highlighter.unhighlight(e.cellView,e.magnetEl,e.opt),this._highlights[d]=null)}},pointerdblclick:function(a){a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerdblclick(a,c.x,c.y):this.trigger("blank:pointerdblclick",a,c.x,c.y)}},pointerclick:function(a){if(this._mousemoved<=this.options.clickThreshold){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(this.guard(a,b))return;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.pointerclick(a,c.x,c.y):this.trigger("blank:pointerclick",a,c.x,c.y)}},contextmenu:function(a){ this.options.preventContextMenu&&a.preventDefault(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?b.contextmenu(a,c.x,c.y):this.trigger("blank:contextmenu",a,c.x,c.y)}},pointerdown:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y)),this.delegateDragEvents(b,a.data)}},pointermove:function(a){a.preventDefault();var b=this.eventData(a);b.mousemoved||(b.mousemoved=0);var c=++b.mousemoved;if(!(c<=this.options.moveThreshold)){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY}),e=b.sourceView;e?e.pointermove(a,d.x,d.y):this.trigger("blank:pointermove",a,d.x,d.y),this.eventData(a,b)}},pointerup:function(a){this.undelegateDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY}),c=this.eventData(a).sourceView;c?c.pointerup(a,b.x,b.y):this.trigger("blank:pointerup",a,b.x,b.y),this.delegateEvents()},mouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseover(a);else{if(this.el===a.target)return;this.trigger("blank:mouseover",a)}},mouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b))if(b)b.mouseout(a);else{if(this.el===a.target)return;this.trigger("blank:mouseout",a)}},mouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseenter(a)}else{if(c)return;this.trigger("paper:mouseenter",a)}}},mouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=this.findView(a.relatedTarget);if(b){if(c===b)return;b.mouseleave(a)}else{if(c)return;this.trigger("paper:mouseleave",a)}}},mousewheel:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){var c=a.originalEvent,d=this.snapToGrid({x:c.clientX,y:c.clientY}),e=Math.max(-1,Math.min(1,c.wheelDelta||-c.detail));b?b.mousewheel(a,d.x,d.y,e):this.trigger("blank:mousewheel",a,d.x,d.y,e)}},onevent:function(a){var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.onevent(a,c,e.x,e.y)}}},onmagnet:function(a){var b=a.currentTarget,c=b.getAttribute("magnet");if(c){var d=this.findView(b);if(d){if(a=joint.util.normalizeEvent(a),this.guard(a,d))return;if(!this.options.validateMagnet(d,b))return;var e=this.snapToGrid(a.clientX,a.clientY);d.onmagnet(a,e.x,e.y)}}},onlabel:function(a){var b=a.currentTarget,c=this.findView(b);if(c){if(a=joint.util.normalizeEvent(a),this.guard(a,c))return;var d=this.snapToGrid(a.clientX,a.clientY);c.onlabel(a,d.x,d.y)}},delegateDragEvents:function(a,b){b||(b={}),this.eventData({data:b},{sourceView:a||null,mousemoved:0}),this.delegateDocumentEvents(null,b),this.undelegateEvents()},guard:function(a,b){return!(!this.options.guard||!this.options.guard(a,b))||(a.data&&void 0!==a.data.guarded?a.data.guarded:!(b&&b.model&&b.model instanceof joint.dia.Cell)&&(this.svg!==a.target&&this.el!==a.target&&!$.contains(this.svg,a.target)))},setGridSize:function(a){return this.options.gridSize=a,this.options.drawGrid&&this.drawGrid(),this},clearGrid:function(){return this.$grid&&this.$grid.css("backgroundImage","none"),this},_getGriRefs:function(){return this._gridCache||(this._gridCache={root:V("svg",{width:"100%",height:"100%"},V("defs")),patterns:{},add:function(a,b){V(this.root.node.childNodes[0]).append(b),this.patterns[a]=b,this.root.append(V("rect",{width:"100%",height:"100%",fill:"url(#"+a+")"}))},get:function(a){return this.patterns[a]},exist:function(a){return void 0!==this.patterns[a]}}),this._gridCache},setGrid:function(a){this.clearGrid(),this._gridCache=null,this._gridSettings=[];var b=Array.isArray(a)?a:[a||{}];return b.forEach(function(a){this._gridSettings.push.apply(this._gridSettings,this._resolveDrawGridOption(a))},this),this},_resolveDrawGridOption:function(a){var b=this.constructor.gridPatterns;if(joint.util.isString(a)&&Array.isArray(b[a]))return b[a].map(function(a){return joint.util.assign({},a)});var c=a||{args:[{}]},d=Array.isArray(c),e=c.name;if(d||e||c.markup||(e="dot"),e&&Array.isArray(b[e])){var f=b[e].map(function(a){return joint.util.assign({},a)}),g=Array.isArray(c.args)?c.args:[c.args||{}];joint.util.defaults(g[0],joint.util.omit(a,"args"));for(var h=0;h'),f=joint.util.toArray(d).map(function(a){return e({offset:a.offset,color:a.color,opacity:Number.isFinite(a.opacity)?a.opacity:1})}),g=["<"+c+">",f.join(""),""].join(""),h=joint.util.assign({id:b},a.attrs);V(g,h).appendTo(this.defs)}return b},defineMarker:function(a){if(!joint.util.isObject(a))throw new TypeError("dia.Paper: defineMarker() requires 1. argument to be an object.");var b=a.id;if(b||(b=this.svg.id+joint.util.hashCode(JSON.stringify(a))),!this.isDefined(b)){var c=joint.util.omit(a,"type","userSpaceOnUse"),d=V("marker",{id:b,orient:"auto",overflow:"visible",markerUnits:a.markerUnits||"userSpaceOnUse"},[V(a.type||"path",c)]);d.appendTo(this.defs)}return b}},{backgroundPatterns:{flipXy:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,-1,b.width,b.height),e.drawImage(a,0,0,c,d),e.setTransform(-1,0,0,1,b.width,0),e.drawImage(a,0,0,c,d),e.setTransform(1,0,0,-1,0,b.height),e.drawImage(a,0,0,c,d),b},flipX:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=2*c,b.height=d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(2*c,0),e.scale(-1,1),e.drawImage(a,0,0,c,d),b},flipY:function(a){var b=document.createElement("canvas"),c=a.width,d=a.height;b.width=c,b.height=2*d;var e=b.getContext("2d");return e.drawImage(a,0,0,c,d),e.translate(0,2*d),e.scale(1,-1),e.drawImage(a,0,0,c,d),b},watermark:function(a,b){b=b||{};var c=a.width,d=a.height,e=document.createElement("canvas");e.width=3*c,e.height=3*d;for(var f=e.getContext("2d"),h=joint.util.isNumber(b.watermarkAngle)?-b.watermarkAngle:-20,i=g.toRad(h),j=e.width/4,k=e.height/4,l=0;l<4;l++)for(var m=0;m<4;m++)(l+m)%2>0&&(f.setTransform(1,0,0,1,(2*l-1)*j,(2*m-1)*k),f.rotate(i),f.drawImage(a,-c/2,-d/2,c,d));return e}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){V(a).attr({width:b.thickness*b.sx,height:b.thickness*b.sy,fill:b.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(a,b){var c=b.sx<=1?b.thickness*b.sx:b.thickness;V(a).attr({width:c,height:c,fill:b.color})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",update:function(a,b){var c,d=b.width,e=b.height,f=b.thickness;c=d-f>=0&&e-f>=0?["M",d,0,"H0 M0 0 V0",e].join(" "):"M 0 0 0 0",V(a).attr({d:c,stroke:b.color,"stroke-width":b.thickness})}}]}}),function(a,b,c){var d=function(b){var d=c.cloneDeep(b)||{};this.ports=[],this.groups={},this.portLayoutNamespace=a.layout.Port,this.portLabelLayoutNamespace=a.layout.PortLabel,this._init(d)};d.prototype={getPorts:function(){return this.ports},getGroup:function(a){return this.groups[a]||{}},getPortsByGroup:function(a){return this.ports.filter(function(b){return b.group===a})},getGroupPortsMetrics:function(a,b){var d=this.getGroup(a),e=this.getPortsByGroup(a),f=d.position||{},h=f.name,i=this.portLayoutNamespace;i[h]||(h="left");var j=f.args||{},k=e.map(function(a){return a&&a.position&&a.position.args}),l=i[h](k,b,j),m={ports:e,result:[]};return c.toArray(l).reduce(function(a,c,d){var e=a.ports[d];return a.result.push({portId:e.id,portTransformation:c,labelTransformation:this._getPortLabelLayout(e,g.Point(c),b),portAttrs:e.attrs,portSize:e.size,labelSize:e.label.size}),a}.bind(this),m),m.result},_getPortLabelLayout:function(a,b,c){var d=this.portLabelLayoutNamespace,e=a.label.position.name||"left";return d[e]?d[e](b,c,a.label.position.args):null},_init:function(a){if(c.isObject(a.groups))for(var b=Object.keys(a.groups),d=0,e=b.length;d0},hasPort:function(a){return this.getPortIndex(a)!==-1},getPorts:function(){return c.cloneDeep(this.prop("ports/items"))||[]},getPort:function(a){return c.cloneDeep(c.toArray(this.prop("ports/items")).find(function(b){return b.id&&b.id===a}))},getPortsPositions:function(a){var b=this._portSettingsData.getGroupPortsMetrics(a,g.Rect(this.size()));return b.reduce(function(a,b){var c=b.portTransformation;return a[b.portId]={x:c.x,y:c.y,angle:c.angle},a},{})},getPortIndex:function(a){var b=c.isObject(a)?a.id:a;return this._isValidPortId(b)?c.toArray(this.prop("ports/items")).findIndex(function(a){return a.id===b}):-1},addPort:function(a,b){if(!c.isObject(a)||Array.isArray(a))throw new Error("Element: addPort requires an object.");var d=c.assign([],this.prop("ports/items"));return d.push(a),this.prop("ports/items",d,b),this},portProp:function(a,b,d,e){var f=this.getPortIndex(a);if(f===-1)throw new Error("Element: unable to find port with id "+a);var g=Array.prototype.slice.call(arguments,1);return Array.isArray(b)?g[0]=["ports","items",f].concat(b):c.isString(b)?g[0]=["ports/items/",f,"/",b].join(""):(g=["ports/items/"+f],c.isPlainObject(b)&&(g.push(b),g.push(d))),this.prop.apply(this,g)},_validatePorts:function(){var b=this.get("ports")||{},d=[];b=b||{};var e=c.toArray(b.items);return e.forEach(function(a){"object"!=typeof a&&d.push("Element: invalid port ",a),this._isValidPortId(a.id)||(a.id=c.uuid())},this),a.util.uniq(e,"id").length!==e.length&&d.push("Element: found id duplicities in ports."),d},_isValidPortId:function(a){return null!==a&&void 0!==a&&!c.isObject(a)},addPorts:function(a,b){return a.length&&this.prop("ports/items",c.assign([],this.prop("ports/items")).concat(a),b),this},removePort:function(a,b){var d=b||{},e=c.assign([],this.prop("ports/items")),f=this.getPortIndex(a);return f!==-1&&(e.splice(f,1),d.rewrite=!0,this.prop("ports/items",e,d)),this},_createPortData:function(){var a=this._validatePorts();if(a.length>0)throw this.set("ports",this.previous("ports")),new Error(a.join(" "));var b;this._portSettingsData&&(b=this._portSettingsData.getPorts()),this._portSettingsData=new d(this.get("ports"));var c=this._portSettingsData.getPorts();if(b){var e=c.filter(function(a){if(!b.find(function(b){return b.id===a.id}))return a}),f=b.filter(function(a){if(!c.find(function(b){return b.id===a.id}))return a});f.length>0&&this.trigger("ports:remove",this,f),e.length>0&&this.trigger("ports:add",this,e)}}}),c.assign(a.dia.ElementView.prototype,{portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._portElementsCache={},this.listenTo(this.model,"change:ports",function(){this._refreshPorts()})},_refreshPorts:function(){this._removePorts(),this._portElementsCache={},this._renderPorts()},_renderPorts:function(){for(var a=[],b=this._getContainerElement(),d=0,e=b.node.childNodes.length;d1?V("g").append(h):V(h.firstChild),e=g.selectors}else b=V(f),Array.isArray(b)&&(b=V("g").append(b));if(!b)throw new Error("ElementView: Invalid port markup.");b.attr({port:a.id,"port-group":a.group});var i,j=this._getPortLabelMarkup(a.label);if(Array.isArray(j)){var k=c.parseDOMJSON(j),l=k.fragment;d=l.childNodes.length>1?V("g").append(l):V(l.firstChild),i=k.selectors}else d=V(j),Array.isArray(d)&&(d=V("g").append(d));if(!d)throw new Error("ElementView: Invalid port label markup.");var m;if(e&&i){for(var n in i)if(e[n])throw new Error("ElementView: selectors within port must be unique.");m=c.assign({},e,i)}else m=e||i;var o=V(this.portContainerMarkup).addClass("joint-port").append([b.addClass("joint-port-body"),d.addClass("joint-port-label")]);return this._portElementsCache[a.id]={portElement:o,portLabelElement:d,portSelectors:m,portLabelSelectors:i,portContentElement:b,portContentSelectors:e},o},_updatePortGroup:function(a){for(var b=g.Rect(this.model.size()),c=this.model._portSettingsData.getGroupPortsMetrics(a,b),d=0,e=c.length;d'}),joint.shapes.basic.TextView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:attrs",this.resize)}}),joint.shapes.basic.Generic.define("basic.Text",{attrs:{text:{"font-size":18,fill:"#000000"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Circle",{size:{width:60,height:60},attrs:{circle:{fill:"#ffffff",stroke:"#000000",r:30,cx:30,cy:30},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Ellipse",{size:{width:60,height:40},attrs:{ellipse:{fill:"#ffffff",stroke:"#000000",rx:30,ry:20,cx:30,cy:20},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polygon",{size:{width:60,height:40},attrs:{polygon:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Polyline",{size:{width:60,height:40},attrs:{polyline:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Image",{attrs:{text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Generic.define("basic.Path",{size:{width:60,height:60},attrs:{path:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle",ref:"path","ref-x":.5,"ref-dy":10,fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:''}),joint.shapes.basic.Path.define("basic.Rhombus",{attrs:{path:{d:"M 30 0 L 60 30 30 60 0 30 z"},text:{"ref-y":.5,"ref-dy":null,"y-alignment":"middle"}}}),joint.shapes.basic.PortsModelInterface={initialize:function(){this.updatePortsAttrs(),this.on("change:inPorts change:outPorts",this.updatePortsAttrs,this),this.constructor.__super__.constructor.__super__.initialize.apply(this,arguments)},updatePortsAttrs:function(a){if(this._portSelectors){var b=joint.util.omit(this.get("attrs"),this._portSelectors);this.set("attrs",b,{silent:!0})}this._portSelectors=[];var c={};joint.util.toArray(this.get("inPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".inPorts","in");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),joint.util.toArray(this.get("outPorts")).forEach(function(a,b,d){var e=this.getPortAttrs(a,b,d.length,".outPorts","out");this._portSelectors=this._portSelectors.concat(Object.keys(e)),joint.util.assign(c,e)},this),this.attr(c,{silent:!0}),this.processPorts(),this.trigger("process:ports")},getPortSelector:function(a){var b=".inPorts",c=this.get("inPorts").indexOf(a);if(c<0&&(b=".outPorts",c=this.get("outPorts").indexOf(a),c<0))throw new Error("getPortSelector(): Port doesn't exist.");return b+">g:nth-child("+(c+1)+")>.port-body"}},joint.shapes.basic.PortsViewInterface={initialize:function(){this.listenTo(this.model,"process:ports",this.update),joint.dia.ElementView.prototype.initialize.apply(this,arguments)},update:function(){this.renderPorts(),joint.dia.ElementView.prototype.update.apply(this,arguments)},renderPorts:function(){var a=this.$(".inPorts").empty(),b=this.$(".outPorts").empty(),c=joint.util.template(this.model.portMarkup),d=this.model.ports||[];d.filter(function(a){return"in"===a.type}).forEach(function(b,d){a.append(V(c({id:d,port:b})).node)}),d.filter(function(a){return"out"===a.type}).forEach(function(a,d){b.append(V(c({id:d,port:a})).node)})}},joint.shapes.basic.Generic.define("basic.TextBlock",{attrs:{rect:{fill:"#ffffff",stroke:"#000000",width:80,height:100},text:{fill:"#000000","font-size":14,"font-family":"Arial, helvetica, sans-serif"},".content":{text:"","ref-x":.5,"ref-y":.5,"y-alignment":"middle","x-alignment":"middle"}},content:""},{markup:['','',joint.env.test("svgforeignobject")?'
':'',""].join(""),initialize:function(){this.listenTo(this,"change:size",this.updateSize),this.listenTo(this,"change:content",this.updateContent),this.updateSize(this,this.get("size")),this.updateContent(this,this.get("content")),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},updateSize:function(a,b){this.attr({".fobj":joint.util.assign({},b),div:{style:joint.util.assign({},b)}})},updateContent:function(a,b){joint.env.test("svgforeignobject")?this.attr({".content":{html:joint.util.sanitizeHTML(b)}}):this.attr({".content":{text:b}})},setForeignObjectSize:function(){this.updateSize.apply(this,arguments)},setDivContent:function(){this.updateContent.apply(this,arguments)}}),joint.shapes.basic.TextBlockView=joint.dia.ElementView.extend({initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.noSVGForeignObjectElement=!joint.env.test("svgforeignobject"),joint.env.test("svgforeignobject")||this.listenTo(this.model,"change:content change:size",function(a){this.updateContent(a)})},update:function(a,b){var c=this.model;if(joint.env.test("svgforeignobject"))joint.dia.ElementView.prototype.update.call(this,c,b);else{var d=joint.util.omit(b||c.get("attrs"),".content");joint.dia.ElementView.prototype.update.call(this,c,d),b&&!joint.util.has(b,".content")||this.updateContent(c,b)}},updateContent:function(a,b){var c=joint.util.merge({},(b||a.get("attrs"))[".content"]);c=joint.util.omit(c,"text");var d=joint.util.breakText(a.get("content"),a.get("size"),c,{svgDocument:this.paper.svg}),e=joint.util.setByPath({},".content",c,"/");e[".content"].text=d,joint.dia.ElementView.prototype.update.call(this,a,e)}}),function(a,b,c,d){"use strict";var e=a.Element;e.define("standard.Rectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Circle",{attrs:{body:{refCx:"50%",refCy:"50%",refR:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Ellipse",{attrs:{body:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Path",{attrs:{body:{refD:"M 0 0 L 10 0 10 10 0 10 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polygon",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Polyline",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10 0 0",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),e.define("standard.Image",{attrs:{image:{refWidth:"100%",refHeight:"100%"},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.BorderedImage",{attrs:{border:{refWidth:"100%",refHeight:"100%",stroke:"#333333",strokeWidth:2},image:{refWidth:-1,refHeight:-1,x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),e.define("standard.EmbeddedImage",{attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{refWidth:"30%",refHeight:-20,x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",refX:"30%",refX2:20,refY:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),e.define("standard.HeaderedRectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{refWidth:"100%",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]});var f=10;joint.dia.Element.define("standard.Cylinder",{attrs:{body:{lateralArea:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{refCx:"50%",cy:f,refRx:"50%",ry:f,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"100%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(a,c){if(void 0===a)return this.attr("body/lateralArea");var d=b.isPercentage(a),e={lateralArea:a},f=d?{refCy:a,refRy:a,cy:null,ry:null}:{refCy:null,refRy:null,cy:a,ry:a};return this.attr({body:e,top:f},c)}},{attributes:{lateralArea:{set:function(a,c){var e=b.isPercentage(a);e&&(a=parseFloat(a)/100);var f=c.x,g=c.y,h=c.width,i=c.height,j=h/2,k=e?i*a:a,l=d.KAPPA,m=l*j,n=l*(e?i*a:a),o=f,p=f+h/2,q=f+h,r=g+k,s=r-k,t=g+i-k,u=g+i,v=["M",o,r,"L",o,t,"C",f,t+n,p-m,u,p,u,"C",p+m,u,q,t+n,q,t,"L",q,r,"C",q,r-n,p+m,s,p,s,"C",p-m,s,o,r-n,o,r,"Z"]; diff --git a/dist/joint.shapes.chess.js b/dist/joint.shapes.chess.js index 3b30fd2f9..953dcbfc3 100644 --- a/dist/joint.shapes.chess.js +++ b/dist/joint.shapes.chess.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.chess.min.js b/dist/joint.shapes.chess.min.js index e08977ba2..7880caf63 100644 --- a/dist/joint.shapes.chess.min.js +++ b/dist/joint.shapes.chess.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.devs.js b/dist/joint.shapes.devs.js index a513bb295..160f594c2 100644 --- a/dist/joint.shapes.devs.js +++ b/dist/joint.shapes.devs.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.devs.min.js b/dist/joint.shapes.devs.min.js index daebb873b..1a9b4fd41 100644 --- a/dist/joint.shapes.devs.min.js +++ b/dist/joint.shapes.devs.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.erd.js b/dist/joint.shapes.erd.js index 6566b6468..bad09cec5 100644 --- a/dist/joint.shapes.erd.js +++ b/dist/joint.shapes.erd.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.erd.min.js b/dist/joint.shapes.erd.min.js index 776884b2e..95a0368b1 100644 --- a/dist/joint.shapes.erd.min.js +++ b/dist/joint.shapes.erd.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.fsa.js b/dist/joint.shapes.fsa.js index 76e896698..3791b4fa5 100644 --- a/dist/joint.shapes.fsa.js +++ b/dist/joint.shapes.fsa.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.fsa.min.js b/dist/joint.shapes.fsa.min.js index 2756a8a43..4a47118c1 100644 --- a/dist/joint.shapes.fsa.min.js +++ b/dist/joint.shapes.fsa.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.logic.js b/dist/joint.shapes.logic.js index 0b894f8dc..8018b1ca1 100644 --- a/dist/joint.shapes.logic.js +++ b/dist/joint.shapes.logic.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.logic.min.js b/dist/joint.shapes.logic.min.js index 896305aec..a907e434c 100644 --- a/dist/joint.shapes.logic.min.js +++ b/dist/joint.shapes.logic.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.org.js b/dist/joint.shapes.org.js index 89becbe4c..938a67589 100644 --- a/dist/joint.shapes.org.js +++ b/dist/joint.shapes.org.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.org.min.js b/dist/joint.shapes.org.min.js index 9e2258055..19439a890 100644 --- a/dist/joint.shapes.org.min.js +++ b/dist/joint.shapes.org.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.pn.js b/dist/joint.shapes.pn.js index 8496f962a..e30012f11 100644 --- a/dist/joint.shapes.pn.js +++ b/dist/joint.shapes.pn.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.pn.min.js b/dist/joint.shapes.pn.min.js index 997eb7768..686e4475b 100644 --- a/dist/joint.shapes.pn.min.js +++ b/dist/joint.shapes.pn.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.uml.js b/dist/joint.shapes.uml.js index 48b8977e6..94e883a95 100644 --- a/dist/joint.shapes.uml.js +++ b/dist/joint.shapes.uml.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/joint.shapes.uml.min.js b/dist/joint.shapes.uml.min.js index 33c5f9a15..469ddb6ae 100644 --- a/dist/joint.shapes.uml.min.js +++ b/dist/joint.shapes.uml.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/vectorizer.js b/dist/vectorizer.js index d3bacf2cd..089fe9445 100644 --- a/dist/vectorizer.js +++ b/dist/vectorizer.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/dist/vectorizer.min.js b/dist/vectorizer.min.js index 78c21b2b6..6baa355a9 100644 --- a/dist/vectorizer.min.js +++ b/dist/vectorizer.min.js @@ -1,4 +1,4 @@ -/*! JointJS v2.1.1 (2018-05-07) - JavaScript diagramming library +/*! JointJS v2.1.2 (2018-05-08) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public diff --git a/package-lock.json b/package-lock.json index 6a279fd28..f4c15919c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jointjs", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c07203063..fbc76c35d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "test": "grunt test" }, - "version": "2.1.1", + "version": "2.1.2", "main": "./dist/joint.min.js", "style": "./dist/joint.min.css", "types": "./dist/joint.d.ts",