From 38edad2ff8cbf44ace1b73d6ce1a3b0eb5eccf61 Mon Sep 17 00:00:00 2001 From: Roman Bruckner Date: Mon, 23 Oct 2017 17:17:48 +0200 Subject: [PATCH] Release v2.0.0 --- CHANGELOG | 21 + dist/geometry.js | 2 +- dist/geometry.min.js | 2 +- dist/joint.core.css | 2 +- dist/joint.core.js | 90 +- dist/joint.core.min.css | 2 +- dist/joint.core.min.js | 12 +- dist/joint.css | 2 +- dist/joint.d.ts | 2026 ++++++++++++++++-------- dist/joint.js | 92 +- dist/joint.layout.DirectedGraph.js | 4 +- dist/joint.layout.DirectedGraph.min.js | 4 +- dist/joint.min.css | 2 +- dist/joint.min.js | 14 +- dist/joint.nowrap.js | 92 +- dist/joint.nowrap.min.js | 14 +- 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.json | 5 +- 35 files changed, 1662 insertions(+), 760 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0356406ad..8a773f83c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,24 @@ +23-10-2017 (v2.0.0) + * Typescript definitions refactored (breaking change of the release) + * JointJS now compatible with Lodash v4 (see `demo/lodash4` for instructions) + * Geometry - add Polyline with pointAtLength(), length(), closesPointLength(), closestPoint() and convexHull() + * Geometry - add cross(), dot(), squaredDistance(), closestPoint(), closestPointNormalizedLength(), vector(), vectorAngle(), angleBetween() to Point + * Vectorizer - add children() and getBBox() + * Vectorizer - fix parseTransformString() and matrixToTransformString() + * Vectorizer - make the text `y` coordinate based on the first line `line-height` in text() + * Vectorizer - add option to define the end-of-line character for text() + * layout.DirectedLayout - add ability to position labels + * layout.DirectedLayout - fix bug when the elements passed do not include their parents + * dia.Paper - add `clickThreshold`, `moveThreshold` and `preventDefaultBlankAction` options + * dia.Paper - add cancelRenderViews() for async mode + * dia.CellView - do not reset node's transform attribute if no transform applied update() + * dia.Element - position() can be called with { deep: true } option to set position of the embeds + * dia.attributes - `text` attribute takes `x` into account + * dia.attributes - add `event` for easier events handling on CellViews and `resetOffset` for paths to start at 0,0 + * dia.LinkView - stop triggering link:connect/link:disconnnect when connection not allowed + * dia.LinkView - can sendToken() backwards + * highlighters.Stroke - fix for magnets inside scalable group and with zero width or height + 31-03-2017 (v1.1.0) * add TypeScript definitions * update jQuery v3.1.1 diff --git a/dist/geometry.js b/dist/geometry.js index 688f74586..1aca7e2c6 100644 --- a/dist/geometry.js +++ b/dist/geometry.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - 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 2324cf646..8b1f935fe 100644 --- a/dist/geometry.min.js +++ b/dist/geometry.min.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - 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 7c230a60e..7c7c1f3e3 100644 --- a/dist/joint.core.css +++ b/dist/joint.core.css @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - 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 a34ecef0e..18dbc2305 100644 --- a/dist/joint.core.js +++ b/dist/joint.core.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -3847,7 +3847,7 @@ V = Vectorizer = (function() { var joint = { - version: '1.2.0-beta', + version: '2.0.0', config: { // The class name prefix config is for advanced use only. @@ -6089,7 +6089,7 @@ joint.dia.Graph = Backbone.Model.extend({ var commonAncestor = joint.util.toArray(cellsAncestors.shift()).find(function(ancestor) { return cellsAncestors.every(function(cellAncestors) { - return cellAncestors.includes(ancestor) + return cellAncestors.includes(ancestor); }); }); @@ -6448,18 +6448,18 @@ joint.dia.Graph = Backbone.Model.extend({ }, // Disconnect links connected to the cell `model`. - disconnectLinks: function(model, options) { + disconnectLinks: function(model, opt) { this.getConnectedLinks(model).forEach(function(link) { - link.set(link.get('source').id === model.id ? 'source' : 'target', { x: 0, y: 0 }, options); + link.set(link.get('source').id === model.id ? 'source' : 'target', { x: 0, y: 0 }, opt); }); }, // Remove links connected to the cell `model` completely. - removeLinks: function(model, options) { + removeLinks: function(model, opt) { - joint.util.invoke(this.getConnectedLinks(model), 'remove', options); + joint.util.invoke(this.getConnectedLinks(model), 'remove', opt); }, // Find all elements at given point @@ -6489,7 +6489,7 @@ joint.dia.Graph = Backbone.Model.extend({ opt = joint.util.defaults(opt || {}, { searchBy: 'bbox' }); var bbox = element.getBBox(); - var elements = (opt.searchBy == 'bbox') + var elements = (opt.searchBy === 'bbox') ? this.findModelsInArea(bbox) : this.findModelsFromPoint(bbox[opt.searchBy]()); @@ -6528,6 +6528,8 @@ joint.dia.Graph = Backbone.Model.extend({ }); joint.util.invoke(cells, 'translate', dx, dy, opt); + + return this; }, resize: function(width, height, opt) { @@ -6567,7 +6569,7 @@ joint.dia.Graph = Backbone.Model.extend({ hasActiveBatch: function(name) { if (name) { - return this._batches[name]; + return !!this._batches[name]; } else { return joint.util.toArray(this._batches).some(function(batches) { return batches > 0; @@ -6660,10 +6662,58 @@ joint.util.wrapWith(joint.dia.Graph.prototype, ['resetCells', 'addCells', 'remov 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: util.isPlainObject, set: function(filter) { @@ -9273,13 +9323,13 @@ joint.dia.Link = joint.dia.Cell.extend({ return connectionAncestor || null; }, - // Is source, target and the link itself embedded in a given element? - isRelationshipEmbeddedIn: function(element) { + // Is source, target and the link itself embedded in a given cell? + isRelationshipEmbeddedIn: function(cell) { - var elementId = joint.util.isString(element) ? element : element.id; + var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id; var ancestor = this.getRelationshipAncestor(); - return !!ancestor && (ancestor.id === elementId || ancestor.isEmbeddedIn(elementId)); + return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId)); } }, { @@ -10392,10 +10442,10 @@ joint.dia.LinkView = joint.dia.CellView.extend({ } else if (paperOptions.linkConnectionPoint) { - var view = end === 'target' ? this.targetView : this.sourceView; - var magnet = end === 'target' ? this.targetMagnet : this.sourceMagnet; + var view = (end === 'target') ? this.targetView : this.sourceView; + var magnet = (end === 'target') ? this.targetMagnet : this.sourceMagnet; - spot = paperOptions.linkConnectionPoint(this, view, magnet, reference); + spot = paperOptions.linkConnectionPoint(this, view, magnet, reference, end); } else { @@ -10520,7 +10570,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ if (availableMagnets.length > 0) { // highlight all available magnets for (var j = 0, m = availableMagnets.length; j < m; j++) { - view.highlight(availableMagnets[j], { magnetAvailability: true }) + view.highlight(availableMagnets[j], { magnetAvailability: true }); } // highlight the entire view view.highlight(null, { elementAvailability: true }); @@ -10543,7 +10593,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ var view = this.paper.findViewByModel(id); if (view) { for (var j = 0, m = markedMagnets.length; j < m; j++) { - view.unhighlight(markedMagnets[j], { magnetAvailability: true }) + view.unhighlight(markedMagnets[j], { magnetAvailability: true }); } view.unhighlight(null, { elementAvailability: true }); } @@ -11235,6 +11285,8 @@ joint.dia.Paper = joint.mvc.View.extend({ if (this._background) { this.updateBackgroundImage(this._background); } + + return this; }, // For storing the current transformation matrix (CTM) of the paper's viewport. @@ -12494,7 +12546,7 @@ joint.dia.Paper = joint.mvc.View.extend({ options.height = gridSize * (ctm.d || 1) * (options.scaleFactor || 1); if (!refs.exist(id)) { - refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))) + refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))); } var patternDefVel = refs.get(id); diff --git a/dist/joint.core.min.css b/dist/joint.core.min.css index 0f8f7602b..60c1c5020 100644 --- a/dist/joint.core.min.css +++ b/dist/joint.core.min.css @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - 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 0ca46f7ab..0c3d348e9 100644 --- a/dist/joint.core.min.js +++ b/dist/joint.core.min.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -46,11 +46,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. !function(){function a(a){this.message=a}var b="undefined"!=typeof exports?exports:this,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a.prototype=new Error,a.prototype.name="InvalidCharacterError",b.btoa||(b.btoa=function(b){for(var d,e,f=String(b),g=0,h=c,i="";f.charAt(0|g)||(h="=",g%1);i+=h.charAt(63&d>>8-g%1*8)){if(e=f.charCodeAt(g+=.75),e>255)throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");d=d<<8|e}return i}),b.atob||(b.atob=function(b){var d=String(b).replace(/=+$/,"");if(d.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,f,g=0,h=0,i="";f=d.charAt(h++);~f&&(e=g%4?64*e+f:f,g++%4)?i+=String.fromCharCode(255&e>>(-2*g&6)):0)f=c.indexOf(f);return i})}(),function(){function a(a,b){return this.slice(a,b)}function b(a,b){arguments.length<2&&(b=0);for(var c=0,d=a.length;c>>0;if(0===e)return!1;for(var f=0|b,g=Math.max(f>=0?f:e-Math.abs(f),0);g>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;e0?1:-1)*Math.floor(Math.abs(b)):b},d=Math.pow(2,53)-1,e=function(a){var b=c(a);return Math.min(Math.max(b,0),d)};return function(a){var c=this,d=Object(a);if(null==a)throw new TypeError("Array.from requires an array-like object - not null or undefined");var f,g=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof g){if(!b(g))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(f=arguments[2])}for(var h,i=e(d.length),j=b(c)?Object(new c(i)):new Array(i),k=0;k>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;ethis.length)&&this.indexOf(a,b)!==-1}),String.prototype.startsWith||(String.prototype.startsWith=function(a,b){return this.substr(b||0,a.length)===a}),Number.isFinite=Number.isFinite||function(a){return"number"==typeof a&&isFinite(a)},Number.isNaN=Number.isNaN||function(a){return a!==a}; var g=function(){var a={},b=Math,c=b.abs,d=b.cos,e=b.sin,f=b.sqrt,g=b.min,h=b.max,i=b.atan2,j=b.round,k=b.floor,l=b.PI,m=b.random,n=b.pow;a.bezier={curveThroughPoints:function(a){for(var b=this.getCurveControlPoints(a),c=["M",a[0].x,a[0].y],d=0;dj.x+h/2,n=fj.x?g-e:g+e,d=h*h/(f-k)-h*h*(g-l)*(c-l)/(i*i*(f-k))+k):(d=g>j.y?f+e:f-e,c=i*i/(g-l)-i*i*(f-k)*(d-k)/(h*h*(g-l))+l),a.point(d,c).theta(b)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a),b&&a.rotate(q(this.x,this.y),b);var c,d=a.x-this.x,e=a.y-this.y;if(0===d)return c=this.bbox().pointNearestToPoint(a),b?c.rotate(q(this.x,this.y),-b):c;var g=e/d,h=g*g,i=this.a*this.a,j=this.b*this.b,k=f(1/(1/i+h/j));k=d<0?-k:k;var l=g*k;return c=q(this.x+k,this.y+l),b?c.rotate(q(this.x,this.y),-b):c},toString:function(){return q(this.x,this.y).toString()+" "+this.a+" "+this.b}};var p=a.Line=function(a,b){return this instanceof p?a instanceof p?p(a.start,a.end):(this.start=q(a),void(this.end=q(b))):new p(a,b)};a.Line.prototype={bearing:function(){var a=w(this.start.y),b=w(this.end.y),c=this.start.x,f=this.end.x,g=w(f-c),h=e(g)*d(b),j=d(a)*e(b)-e(a)*d(b)*d(g),k=v(i(h,j)),l=["NE","E","SE","S","SW","W","NW","N"],m=k-22.5;return m<0&&(m+=360),m=parseInt(m/45),l[m]},clone:function(){return p(this.start,this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.end.x===a.end.x&&this.end.y===a.end.y},intersect:function(a){if(a instanceof p){var b=q(this.end.x-this.start.x,this.end.y-this.start.y),c=q(a.end.x-a.start.x,a.end.y-a.start.y),d=b.x*c.y-b.y*c.x,e=q(a.start.x-this.start.x,a.start.y-this.start.y),f=e.x*c.y-e.y*c.x,g=e.x*b.y-e.y*b.x;if(0===d||f*d<0||g*d<0)return null;if(d>0){if(f>d||g>d)return null}else if(f0?l:null}return null},length:function(){return f(this.squaredLength())},midpoint:function(){return q((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},pointAt:function(a){var b=(1-a)*this.start.x+a*this.end.x,c=(1-a)*this.start.y+a*this.end.y;return q(b,c)},pointOffset:function(a){return((this.end.x-this.start.x)*(a.y-this.start.y)-(this.end.y-this.start.y)*(a.x-this.start.x))/2},vector:function(){return q(this.end.x-this.start.x,this.end.y-this.start.y)},closestPoint:function(a){return this.pointAt(this.closestPointNormalizedLength(a))},closestPointNormalizedLength:function(a){var b=this.vector().dot(p(this.start,a).vector());return Math.min(1,Math.max(0,b/this.squaredLength()))},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},toString:function(){return this.start.toString()+" "+this.end.toString()}},a.Line.prototype.intersection=a.Line.prototype.intersect;var q=a.Point=function(a,b){if(!(this instanceof q))return new q(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseInt(c[0],10),b=parseInt(c[1],10)}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};a.Point.fromPolar=function(a,b,f){f=f&&q(f)||q(0,0);var g=c(a*d(b)),h=c(a*e(b)),i=t(v(b));return i<90?h=-h:i<180?(g=-g,h=-h):i<270&&(g=-g),q(f.x+g,f.y+h)},a.Point.random=function(a,b,c,d){return q(k(m()*(b-a+1)+a),k(m()*(d-c+1)+c))},a.Point.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=g(h(this.x,a.x),a.x+a.width),this.y=g(h(this.y,a.y),a.y+a.height),this)},bearing:function(a){return p(this,a).bearing()},changeInAngle:function(a,b,c){return q(this).offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return q(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),q(this.x-(a||0),this.y-(b||0))},distance:function(a){return p(this,a).length()},squaredDistance:function(a){return p(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return f(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return c(a.x-this.x)+c(a.y-this.y)},move:function(a,b){var c=w(q(a).theta(this));return this.offset(d(c)*b,-e(c)*b)},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 q(a).move(this,this.distance(a))},rotate:function(a,b){b=(b+360)%360,this.toPolar(a),this.y+=w(b);var c=q.fromPolar(this.x,this.y,a);return this.x=c.x,this.y=c.y,this},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this},scale:function(a,b,c){return c=c&&q(c)||q(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=u(this.x,a),this.y=u(this.y,b||a),this},theta:function(a){a=q(a);var b=-(a.y-this.y),c=a.x-this.x,d=i(b,c);return d<0&&(d=2*l+d),180*d/l},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=q(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&q(a)||q(0,0);var b=this.x,c=this.y;return this.x=f((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=w(a.theta(q(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}};var r=a.Rect=function(a,b,c,d){return this instanceof r?(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 r(a,b,c,d)};a.Rect.fromEllipse=function(a){return a=o(a),r(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},a.Rect.prototype={bbox:function(a){var b=w(a||0),f=c(e(b)),g=c(d(b)),h=this.width*g+this.height*f,i=this.width*f+this.height*g;return r(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return q(this.x,this.y+this.height)},bottomLine:function(){return p(this.bottomLeft(),this.corner())},bottomMiddle:function(){return q(this.x+this.width/2,this.y+this.height)},center:function(){return q(this.x+this.width/2,this.y+this.height/2)},clone:function(){return r(this)},containsPoint:function(a){return a=q(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=r(this).normalize(),c=r(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 q(this.x+this.width,this.y+this.height)},equals:function(a){var b=r(this).normalize(),c=r(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=Math.max(b.x,d.x),g=Math.max(b.y,d.y);return r(f,g,Math.min(c.x,e.x)-f,Math.min(c.y,e.y)-g)},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a);var c,d=q(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[p(this.origin(),this.topRight()),p(this.topRight(),this.corner()),p(this.corner(),this.bottomLeft()),p(this.bottomLeft(),this.origin())],f=p(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 p(this.origin(),this.bottomLeft())},leftMiddle:function(){return q(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 q.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 q(this.x,this.y)},pointNearestToPoint:function(a){if(a=q(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return q(this.x+this.width,a.y);case"left":return q(this.x,a.y);case"bottom":return q(a.x,this.y+this.height);case"top":return q(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return p(this.topRight(),this.corner())},rightMiddle:function(){return q(this.x+this.width,this.y+this.height/2)},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this.width=j(this.width*b)/b,this.height=j(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(b,c){b=a.Rect(b),c||(c=b.center());var d,e,f,g,h,i,j,k,l=c.x,m=c.y;d=e=f=g=h=i=j=k=1/0;var n=b.origin();n.xl&&(e=(this.x+this.width-l)/(o.x-l)),o.y>m&&(i=(this.y+this.height-m)/(o.y-m));var p=b.topRight();p.x>l&&(f=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:Math.min(d,e,f,g),sy:Math.min(h,i,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return Math.min(c.sx,c.sy)},sideNearestToPoint:function(a){a=q(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 cc.x&&(c=d[a]);var e=[];for(b=d.length,a=0;a2){var h=e[e.length-1];e.unshift(h)}for(var i,j,k,l,m,n,o={},p=[];0!==e.length;)if(i=e.pop(),j=i[0],!o.hasOwnProperty(i[0]+"@@"+i[1]))for(var q=!1;!q;)if(p.length<2)p.push(i),q=!0;else{k=p.pop(),l=k[0],m=p.pop(),n=m[0];var r=n.cross(l,j);if(r<0)p.push(m),p.push(k),p.push(i),q=!0;else if(0===r){var t=1e-10,u=l.angleBetween(n,j);Math.abs(u-180)2&&p.pop();var v,w=-1;for(b=p.length,a=0;a0){var z=p.slice(w),A=p.slice(0,w);y=z.concat(A)}else y=p;var B=[];for(b=y.length,a=0;a1){var g,h,i=[];for(g=0,h=f.childNodes.length;gu&&(u=z),c=d("tspan",y.attrs),b.includeAnnotationIndices&&c.attr("annotations",y.annotations),y.attrs.class&&c.addClass(y.attrs.class),e&&x===w&&p!==s&&(y.t+=e),c.node.textContent=y.t}else e&&x===w&&p!==s&&(y+=e),c=document.createTextNode(y||" ");r.append(c)}"auto"===b.lineHeight&&u&&0!==p&&r.attr("dy",1.2*u+"px")}else e&&p!==s&&(t+=e),r.node.textContent=t;0===p&&(o=u)}else r.addClass("v-empty-line"),r.node.style.fillOpacity=0,r.node.style.strokeOpacity=0,r.node.textContent="-";d(g).append(r),l+=t.length+1}var A=this.attr("y");return null===A&&this.attr("y",o||"0.8em"),this},d.prototype.removeAttr=function(a){var b=d.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},d.prototype.attr=function(a,b){if(d.isUndefined(a)){for(var c=this.node.attributes,e={},f=0;f'+(a||"")+"",f=d.parseXML(e,{async:!1});return f.documentElement},d.idCounter=0,d.uniqueId=function(){return"v-"+ ++d.idCounter},d.toNode=function(a){return d.isV(a)?a.node:a.nodeName&&a||a[0]},d.ensureId=function(a){return a=d.toNode(a),a.id||(a.id=d.uniqueId())},d.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},d.isUndefined=function(a){return"undefined"==typeof a},d.isString=function(a){return"string"==typeof a},d.isObject=function(a){return a&&"object"==typeof a},d.isArray=Array.isArray,d.parseXML=function(a,b){b=b||{};var c;try{var e=new DOMParser;d.isUndefined(b.async)||(e.async=b.async),c=e.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},d.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var c=a.split(":");return{ns:b[c[0]],local:c[1]}}return{ns:null,local:a}},d.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,d.transformSeparatorRegex=/[ ,]+/,d.transformationListRegex=/^(\w+)\((.*)\)/,d.transformStringToMatrix=function(a){var b=d.createSVGMatrix(),c=a&&a.match(d.transformRegex);if(!c)return b;for(var e=0,f=c.length;e=0){var g=d.transformStringToMatrix(a),h=d.decomposeMatrix(g);b=[h.translateX,h.translateY],e=[h.scaleX,h.scaleY],c=[h.rotation];var i=[];0===b[0]&&0===b[0]||i.push("translate("+b+")"),1===e[0]&&1===e[1]||i.push("scale("+e+")"),0!==c[0]&&i.push("rotate("+c+")"),a=i.join(" ")}else{var j=a.match(/translate\((.*?)\)/);j&&(b=j[1].split(f));var k=a.match(/rotate\((.*?)\)/);k&&(c=k[1].split(f));var l=a.match(/scale\((.*?)\)/);l&&(e=l[1].split(f))}}var m=e&&e[0]?parseFloat(e[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:m,sy:e&&e[1]?parseFloat(e[1]):m}}},d.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}},d.decomposeMatrix=function(a){var b=d.deltaTransformPoint(a,{x:0,y:1}),c=d.deltaTransformPoint(a,{x:1,y:0}),e=180/Math.PI*Math.atan2(b.y,b.x)-90,f=180/Math.PI*Math.atan2(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:Math.sqrt(a.a*a.a+a.b*a.b),scaleY:Math.sqrt(a.c*a.c+a.d*a.d),skewX:e,skewY:f,rotation:e}},d.matrixToScale=function(a){var b,c,e,f;return a?(b=d.isUndefined(a.a)?1:a.a,f=d.isUndefined(a.d)?1:a.d,c=a.b,e=a.c):b=f=1,{sx:c?Math.sqrt(b*b+c*c):b,sy:e?Math.sqrt(e*e+f*f):f}},d.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=d.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(Math.atan2(b.y,b.x))-90)}},d.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},d.isV=function(a){return a instanceof d},d.isVElement=d.isV;var e=d("svg").node;return d.createSVGMatrix=function(a){var b=e.createSVGMatrix();for(var c in a)b[c]=a[c];return b},d.createSVGTransform=function(a){return d.isUndefined(a)?e.createSVGTransform():(a instanceof SVGMatrix||(a=d.createSVGMatrix(a)),e.createSVGTransformFromMatrix(a))},d.createSVGPoint=function(a,b){var c=e.createSVGPoint();return c.x=a,c.y=b,c},d.transformRect=function(a,b){var c=e.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 f=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var h=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var i=c.matrixTransform(b),j=Math.min(d.x,f.x,h.x,i.x),k=Math.max(d.x,f.x,h.x,i.x),l=Math.min(d.y,f.y,h.y,i.y),m=Math.max(d.y,f.y,h.y,i.y);return g.Rect(j,l,k-j,m-l)},d.transformPoint=function(a,b){return g.Point(d.createSVGPoint(a.x,a.y).matrixTransform(b))},d.styleToObject=function(a){for(var b={},c=a.split(";"),d=0;d=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*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L"+f*n+","+f*o+"A"+f+","+f+" 0 "+k+",0 "+f*l+","+f*m+"Z":"M"+g*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L0,0Z"},d.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?d.isObject(a[c])&&d.isObject(b[c])?a[c]=d.mergeAttrs(a[c],b[c]):d.isObject(a[c])?a[c]=d.mergeAttrs(a[c],d.styleToObject(b[c])):d.isObject(b[c])?a[c]=d.mergeAttrs(d.styleToObject(a[c]),b[c]):a[c]=d.mergeAttrs(d.styleToObject(a[c]),d.styleToObject(b[c])):a[c]=b[c];return a},d.annotateString=function(a,b,c){b=b||[],c=c||{};for(var e,f,g,h=c.offset||0,i=[],j=[],k=0;k=n&&k=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},d.convertLineToPathData=function(a){a=d(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},d.convertPolygonToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b)+" Z":null},d.convertPolylineToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b):null},d.svgPointsToPath=function(a){var b;for(b=0;b0){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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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()});joint.util.invoke(d,"translate",a,b,c)},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 a?this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xmlSpace:{set:"xml:space"},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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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(){this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background)},_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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; +var joint={version:"2.0.0",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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 a?!!this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){ +var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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))}},{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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e,a)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; joint.g = g; joint.V = joint.Vectorizer = V; diff --git a/dist/joint.css b/dist/joint.css index 7c230a60e..7c7c1f3e3 100644 --- a/dist/joint.css +++ b/dist/joint.css @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - 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 f1de87520..0aaf29333 100644 --- a/dist/joint.d.ts +++ b/dist/joint.d.ts @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -380,9 +380,6 @@ export namespace Vectorizer { 'bottom-ry'?: number; } - // Backwards compatibility - interface Rect extends RoundedRect {} - interface Rotation { angle: number; cx?: number; @@ -594,56 +591,49 @@ export class Vectorizer { } export namespace dia { - interface Size { - width: number; - height: number; - } - interface Point { - x: number; - y: number; - } + type Point = g.PlainPoint; - interface BBox extends Point, Size { - } + type BBox = g.PlainRect; - interface TranslateOptions { - restrictedArea?: BBox; - transition?: TransitionOptions; - } + type Size = Pick; - interface TransitionOptions { - delay?: number; - duration?: number; - timingFunction?: (t: number) => number; - valueFunction?: (a: any, b: any) => (t: number) => any; - } + type PaddingJSON = { + top?: number; + right?: number; + bottom?: number; + left?: number + }; - interface DfsBfsOptions { - inbound?: boolean; - outbound?: boolean; - deep?: boolean; - } + type Padding = number | PaddingJSON; - interface ExploreOptions { - breadthFirst?: boolean; - deep?: boolean; - } + type Direction = + 'left' | 'right' | 'top' | 'bottom' | 'top-right' | + 'top-left' | 'bottom-left' | 'bottom-right'; + + export namespace Graph { - interface EdgeMap { - [key: string]: boolean; + interface ConnectionOptions extends Cell.EmbeddableOptions { + inbound?: boolean; + outbound?: boolean; + } + + interface ExploreOptions extends ConnectionOptions { + breadthFirst?: boolean; + } } class Graph extends Backbone.Model { - constructor(attributes?: any, options?: { cellNamespace: any, cellModel: typeof Cell }); - addCell(cell: Cell | Cell[], opt?: object): this; + constructor(attributes?: any, opt?: { cellNamespace?: any, cellModel?: typeof Cell }); - addCells(cells: Cell[], opt: object): this; + addCell(cell: Cell | Cell[], opt?: { [key: string]: any }): this; - resetCells(cells: Cell[], options?: object): this; + addCells(cells: Cell[], opt?: { [key: string]: any }): this; - getCell(id: string): Cell; + resetCells(cells: Cell[], opt?: { [key: string]: any }): this; + + getCell(id: string | number | Cell): Cell; getElements(): Element[]; @@ -651,33 +641,33 @@ export namespace dia { getCells(): Cell[]; - getFirstCell(): Cell; + getFirstCell(): Cell | undefined; - getLastCell(): Cell; + getLastCell(): Cell | undefined; - getConnectedLinks(element: Cell, options?: { inbound?: boolean, outbound?: boolean, deep?: boolean }): Link[]; + getConnectedLinks(cell: Cell, opt?: Graph.ConnectionOptions): Link[]; - disconnectLinks(cell: Cell, options?: object): void; + disconnectLinks(cell: Cell, opt?: { [key: string]: any }): void; - removeLinks(cell: Cell, options?: object): void; + removeLinks(cell: Cell, opt?: { [key: string]: any }): void; - translate(tx: number, ty?: number, options?: TranslateOptions): void; + translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this; cloneCells(cells: Cell[]): { [id: string]: Cell }; - getSubgraph(cells: Cell[], options?: { deep?: boolean }): Cell[]; + getSubgraph(cells: Cell[], opt?: Cell.EmbeddableOptions): Cell[]; - cloneSubgraph(cells: Cell[], options?: { deep?: boolean }): { [id: string]: Cell }; + cloneSubgraph(cells: Cell[], opt?: Cell.EmbeddableOptions): { [id: string]: Cell }; - dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions, visited?: any, distance?: number): void; + dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ConnectionOptions): void; - bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions): void; + bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ConnectionOptions): void; - search(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: { breadthFirst?: boolean }): void; + search(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ExploreOptions): void; - getSuccessors(element: Element, options?: ExploreOptions): Element[]; + getSuccessors(element: Element, opt?: Graph.ExploreOptions): Element[]; - getPredecessors(element: Element, options?: ExploreOptions): Element[]; + getPredecessors(element: Element, opt?: Graph.ExploreOptions): Element[]; isSuccessor(elementA: Element, elementB: Element): boolean; @@ -691,115 +681,150 @@ export namespace dia { getSinks(): Element[]; - getNeighbors(element: Element, options?: DfsBfsOptions): Element[]; + getNeighbors(element: Element, opt?: Graph.ConnectionOptions): Element[]; - isNeighbor(elementA: Element, elementB: Element, options?: { inbound?: boolean, outbound?: boolean; }): boolean; + isNeighbor(elementA: Element, elementB: Element, opt?: Graph.ConnectionOptions): boolean; - getCommonAncestor(...cells: Cell[]): Element; + getCommonAncestor(...cells: Cell[]): Element | undefined; - toJSON(): object; + toJSON(): any; - fromJSON(json: { cells: Cell[] }, options?: object): this; + fromJSON(json: any, opt?: { [key: string]: any }): this; - clear(options?: object): this; + clear(opt?: { [key: string]: any }): this; findModelsFromPoint(p: Point): Element[]; - findModelsUnderElement(element: Element, options?: { + findModelsInArea(rect: BBox, opt?: { strict?: boolean }): Element[]; + + findModelsUnderElement(element: Element, opt?: { searchBy?: 'bottomLeft' | 'bottomMiddle' | 'center' | 'corner' | 'leftMiddle' | 'origin' | 'rightMiddle' | - 'topMiddle' | 'topRight' + 'topMiddle' | 'topRight' | 'bbox' }): Element[]; - getBBox(elements: Element[], options?: { deep?: boolean }): g.Rect; + getBBox(cells?: Cell[], opt?: Cell.EmbeddableOptions): g.Rect | null; - toGraphLib(): object; // graphlib graph object - findModelsInArea(rect: g.Rect | BBox, options?: { strict?: boolean }): BBox | boolean; + getCellsBBox(cells: Cell[], opt?: Cell.EmbeddableOptions): g.Rect | null; - getCellsBBox(cells: Cell[], options?: { deep?: boolean }): g.Rect; + hasActiveBatch(name?: string): boolean; - getInboundEdges(node: string): EdgeMap; + maxZIndex(): number; - getOutboundEdges(node: string): EdgeMap; + removeCells(cells: Cell[], opt?: Cell.DisconnectableOptions): this; - hasActiveBatch(name?: string): number | boolean; + resize(width: number, height: number, opt?: { [key: string]: any }): this; - maxZIndex(): number; + resizeCells(width: number, height: number, cells: Cell[], opt?: { [key: string]: any }): this; - removeCells(cells: Cell[], options?: object): this; + startBatch(name: string, data?: { [key: string]: any }): this; - resize(width: number, height: number, options?: object): this; + stopBatch(name: string, data?: { [key: string]: any }): this; - resizeCells(width: number, height: number, cells: Cell[], options?: object): this; + toGraphLib(opt?: { [key: string]: any }): any; - set(key: object | string, value: any, options?: object): this; + fromGraphLib(glGraph: any, opt?: { [key: string]: any }): this; + } + + // dia.Cell - startBatch(name: string, data?: {[key: string]: any}): any; + export namespace Cell { - stopBatch(name: string, data?: {[key: string]: any}): any; + interface GenericAttributes { + attrs?: T; + z?: number; + } + + interface Selectors { + [selector: string]: attributes.SVGAttributes; + } + + interface Attributes extends GenericAttributes { + [key: string]: any; + } + + interface Constructor { + new (options?: { id: string }): T + } + + interface EmbeddableOptions { + deep?: boolean; + } + + interface DisconnectableOptions { + disconnectLinks?: boolean; + } + + interface TransitionOptions { + delay?: number; + duration?: number; + timingFunction?: util.timing.TimingFunction; + valueFunction?: util.interpolate.InterpolateFunction; + } } class Cell extends Backbone.Model { - constructor(attributes?: object, options?: object); - id: string; + constructor(attributes?: Cell.Attributes, opt?: { [key: string]: any }); + + id: string | number; - graph: dia.Graph; + graph: Graph; - toJSON(): object; + toJSON(): any; - remove(options?: { disconnectLinks?: boolean }): this; + remove(opt?: Cell.DisconnectableOptions): this; - toFront(options?: { deep?: boolean }): this; + toFront(opt?: Cell.EmbeddableOptions): this; - toBack(options?: { deep?: boolean }): this; + toBack(opt?: Cell.EmbeddableOptions): this; getAncestors(): Cell[]; - isEmbeddedIn(element: Element, options?: { deep: boolean }): boolean; + getEmbeddedCells(opt?: { deep?: boolean, breadthFirst?: boolean }): Cell[]; + + isEmbeddedIn(cell: Cell, opt?: Cell.EmbeddableOptions): boolean; + + isEmbedded(): boolean; prop(key: string | string[]): any; - prop(object: object): this; - prop(key: string | string[], value: any, options?: object): this; + prop(object: Cell.Attributes): this; + prop(key: string | string[], value: any, opt?: { [key: string]: any }): this; - removeProp(path: string | string[], options?: object): this; + removeProp(path: string | string[], opt?: { [key: string]: any }): this; - attr(key: string): any; - attr(object: SVGAttributes): this; + attr(key?: string): any; + attr(object: Cell.Selectors): this; attr(key: string, value: any): this; clone(): Cell; - clone(opt: { deep?: boolean }): Cell | Cell[]; + clone(opt: Cell.EmbeddableOptions): Cell | Cell[]; - removeAttr(path: string | string[], options?: object): this; + removeAttr(path: string | string[], opt?: { [key: string]: any }): this; - transition(path: string, value?: any, options?: TransitionOptions, delim?: string): number; + transition(path: string, value?: any, opt?: Cell.TransitionOptions, delim?: string): number; getTransitions(): string[]; stopTransitions(path?: string, delim?: string): this; - addTo(graph: Graph, options?: object): this; + embed(cell: Cell, opt?: { [key: string]: any }): this; - isLink(): boolean; + unembed(cell: Cell, opt?: { [key: string]: any }): this; - embed(cell: Cell, options?: object): this; + addTo(graph: Graph, opt?: { [key: string]: any }): this; findView(paper: Paper): CellView; - getEmbeddedCells(options?: { deep?: boolean, breadthFirst?: boolean }): Cell[]; + isLink(): boolean; isElement(): boolean; - isEmbedded(): boolean; - - startBatch(name: string, options?: object): this; - - stopBatch(name: string, options?: object): this; + startBatch(name: string, opt?: { [key: string]: any }): this; - unembed(cell: Cell, options?: object): this; + stopBatch(name: string, opt?: { [key: string]: any }): this; - static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): CellConstructor; + static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor; /** * @deprecated @@ -807,554 +832,575 @@ export namespace dia { protected processPorts(): void; } - interface CellConstructor { - new (options?: { id: string }): T - } + // dia.Element - type Padding = number | { - top?: number; - right?: number; - bottom?: number; - left?: number - }; + export namespace Element { - type Direction = 'left' - | 'right' - | 'top' - | 'bottom' - | 'top-right' - | 'top-left' - | 'bottom-left' - | 'bottom-right'; - - interface Port { - id?: string; - markup?: string; - group?: string; - attrs?: object; - args?: object; - size?: Size; - label: { + interface GenericAttributes extends Cell.GenericAttributes { + position?: Point; size?: Size; - markup?: string; - position?: any; - args?: any; + angle?: number; + ports?: { + groups?: { [key: string]: Port }, + items?: Port[] + } } - z?: number | 'auto'; - } - interface PortPosition extends Point { - angle: number; - } + interface Attributes extends GenericAttributes { + [key: string]: any + } - class Element extends Cell { - constructor(attributes?: object, options?: object); + interface Port { + id?: string; + markup?: string; + group?: string; + attrs?: Cell.Selectors; + args?: { [key: string]: any }; + size?: Size; + label?: { + size?: Size; + markup?: string; + position?: any; + args?: any; + } + z?: number | 'auto'; + } - translate(tx: number, ty?: number, options?: TranslateOptions): this; + interface PortPosition extends Point { + angle: number; + } - position(options?: { parentRelative: boolean }): g.Point; - position(x: number, y: number, options?: { parentRelative?: boolean }): this; + interface TranslateOptions { + restrictedArea?: BBox; + transition?: Cell.TransitionOptions; + } + } - size(): Size; - size(width: number, height?: number, options?: { direction?: Direction }): this; + class Element extends Cell { - resize(width: number, height: number, options?: { direction?: Direction }): this; + constructor(attributes?: Element.Attributes, opt?: { [key: string]: any }); - rotate(deg: number, absolute?: boolean, origin?: Point, opt?: { parentRelative?: boolean }): this; + translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this; - embed(cell: Cell): this; + position(opt?: { parentRelative?: boolean, [key: string]: any }): g.Point; + position(x: number, y: number, opt?: { parentRelative?: boolean, deep?: boolean, [key: string]: any }): this; - unembed(cell: Cell): this; + size(): Size; + size(width: number, height?: number, opt?: { direction?: Direction, [key: string]: any }): this; - getEmbeddedCells(options?: ExploreOptions): Cell[]; + resize(width: number, height: number, opt?: { direction?: Direction, [key: string]: any }): this; - fitEmbeds(options?: { deep?: boolean, padding?: Padding }): this; + rotate(deg: number, absolute?: boolean, origin?: Point, opt?: { [key: string]: any }): this; - getBBox(options?: { deep?: boolean }): g.Rect; + scale(scaleX: number, scaleY: number, origin?: Point, opt?: { [key: string]: any }): this; - isElement(): boolean; + fitEmbeds(opt?: { deep?: boolean, padding?: Padding }): this; - scale(scaleX: number, scaleY: number, origin?: Point, options?: { direction?: Direction, parentRelative?: boolean }): this; + getBBox(opt?: Cell.EmbeddableOptions): g.Rect; - addPort(port: Port, opt?: object): this; + addPort(port: Element.Port, opt?: { [key: string]: any }): this; - addPorts(ports: Port[], opt?: object): this; + addPorts(ports: Element.Port[], opt?: { [key: string]: any }): this; - removePort(port: string | Port, opt?: object): this; + removePort(port: string | Element.Port, opt?: { [key: string]: any }): this; hasPorts(): boolean; hasPort(id: string): boolean; - getPorts(): Port[]; + getPorts(): Element.Port[]; - getPort(id: string): Port; + getPort(id: string): Element.Port; - getPortsPositions(groupName: string): { [id: string]: PortPosition }; + getPortsPositions(groupName: string): { [id: string]: Element.PortPosition }; - getPortIndex(port: string | Port): number; + getPortIndex(port: string | Element.Port): number; - portProp(portId: string, path: any, value?: any, opt?: any): dia.Element; + portProp(portId: string, path: any, value?: any, opt?: { [key: string]: any }): Element; - static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): CellConstructor; + static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor; } - interface CSSSelector { - [key: string]: string | number | Object; // Object added to support special attributes like filter http://jointjs.com/api#SpecialAttributes:filter - } + // dia.Link - interface SVGAttributes { - [selector: string]: CSSSelector; - } + export namespace Link { - interface CellAttributes { - [key: string]: any; - } + interface GenericAttributes extends Cell.GenericAttributes { + source?: Point | { id: string, selector?: string, port?: string }; + target?: Point | { id: string, selector?: string, port?: string }; + labels?: Label[]; + vertices?: Point[]; + smooth?: boolean; + router?: routers.RouterJSON; + connector?: connectors.ConnectorJSON; + } - interface TextAttrs extends SVGAttributes { - text?: { - [key: string]: string | number; - text?: string; - }; - } + interface LinkSelectors extends Cell.Selectors { + '.connection'?: attributes.SVGPathAttributes; + '.connection-wrap'?: attributes.SVGPathAttributes; + '.marker-source'?: attributes.SVGPathAttributes; + '.marker-target'?: attributes.SVGPathAttributes; + '.labels'?: attributes.SVGAttributes; + '.marker-vertices'?: attributes.SVGAttributes; + '.marker-arrowheads'?: attributes.SVGAttributes; + '.link-tools'?: attributes.SVGAttributes; + } - interface LabelPosition { - distance: number; - offset: number | { x: number; y: number; } - } + interface Attributes extends Cell.GenericAttributes { + [key: string]: any; + } - interface Label { - position: LabelPosition | number; - attrs?: TextAttrs; - } + interface LabelPosition { + distance: number; + offset: number | { x: number; y: number; } + } - interface LinkAttributes extends CellAttributes { - source?: Point | { id: string, selector?: string, port?: string }; - target?: Point | { id: string, selector?: string, port?: string }; - labels?: Label[]; - vertices?: Point[]; - smooth?: boolean; - attrs?: TextAttrs; - z?: number; + interface Label { + position: LabelPosition | number; + attrs?: Cell.Selectors; + size?: Size; + } } class Link extends Cell { + markup: string; labelMarkup: string; toolMarkup: string; vertexMarkup: string; arrowHeadMarkup: string; - constructor(attributes?: LinkAttributes, options?: {[key: string]: any}); - - applyToPoints(fn: (p: Point) => Point, opt?: object): this; + constructor(attributes?: Link.Attributes, opt?: { [key: string]: any }); disconnect(): this; label(index?: number): any; - label(index: number, value: Label, opt?: object): this; + label(index: number, value: Link.Label, opt?: { [key: string]: any }): this; - reparent(options?: object): Element; + reparent(opt?: { [key: string]: any }): Element; - getSourceElement(): undefined | Element | Graph; + getSourceElement(): null | Element; - getTargetElement(): undefined | Element | Graph; + getTargetElement(): null | Element; - hasLoop(options?: { deep?: boolean }): boolean; - - applyToPoints(fn: Function, options?: any): this; + hasLoop(opt?: Cell.EmbeddableOptions): boolean; getRelationshipAncestor(): undefined | Element; - isLink(): boolean; + isRelationshipEmbeddedIn(cell: Cell): boolean; - isRelationshipEmbeddedIn(element: Element): boolean; + applyToPoints(fn: (p: Point) => Point, opt?: { [key: string]: any }): this; - scale(sx: number, sy: number, origin: Point | g.Point | string, opt?: object): this; + scale(sx: number, sy: number, origin?: Point, opt?: { [key: string]: any }): this; - translate(tx: number, ty: number, options?: object): this; + translate(tx: number, ty: number, opt?: { [key: string]: any }): this; - static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): CellConstructor; + static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor; } - interface ManhattanRouterArgs { - excludeTypes?: string[]; - excludeEnds?: 'source' | 'target'; - startDirections?: ['left' | 'right' | 'top' | 'bottom']; - endDirections?: ['left' | 'right' | 'top' | 'bottom']; - } + // dia.CellView - interface GridOptions { - color?: string; - thickness?: number; - name?: 'dot' | 'fixedDot' | 'mesh' | 'doubleMesh'; - args?: object[] | object; - } - - interface PaperOptions extends Backbone.ViewOptions { - el?: string | JQuery | HTMLElement; - width?: number | string; - height?: number | string; - origin?: Point; - gridSize?: number; - drawGrid?: boolean | GridOptions; - perpendicularLinks?: boolean; - elementView?: (element: Element) => typeof ElementView | typeof ElementView; - linkView?: (link: Link) => typeof LinkView | typeof LinkView; - defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; - defaultRouter?: ((vertices: Point[], args: {[key: string]: any}, linkView: LinkView) => Point[]) - | { name: string, args?: ManhattanRouterArgs }; - defaultConnector?: - ((sourcePoint: Point, targetPoint: Point, vertices: Point[], args: {[key: string]: any}, linkView: LinkView) => string) - | { name: string, args?: { radius?: number } }; - interactive?: ((cellView: CellView, event: string) => boolean) - | boolean - | { vertexAdd?: boolean, vertexMove?: boolean, vertexRemove?: boolean, arrowheadMove?: boolean }; - validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; - validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: - 'source' - | 'target', linkView: LinkView) => boolean; - linkConnectionPoint?: (linkView: LinkView, view: ElementView, magnet: SVGElement, reference: Point) => Point; - snapLinks?: boolean | { radius: number }; - linkPinning?: boolean; - markAvailable?: boolean; - async?: boolean | { batchZise: number }; - embeddingMode?: boolean; - findParentBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft'; - validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; - restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; - guard?: (evt: Event, view: CellView) => boolean; - multiLinks?: boolean; - cellViewNamespace?: object; - highlighterNamespace?: object; - /** useful undocumented option */ - clickThreshold?: number; - highlighting?: any; - preventContextMenu?: boolean; - } - - interface ScaleContentOptions { - padding?: number; - preserveAspectRatio?: boolean; - minScale?: number; - minScaleX?: number; - minScaleY?: number; - maxScale?: number; - maxScaleX?: number; - maxScaleY?: number; - scaleGrid?: number; - fittingBBox?: BBox; - } - - interface FitToContentOptions { - gridWidth?: number; - gridHeight?: number; - padding?: Padding; - allowNewOrigin?: 'negative' | 'positive' | 'any'; - minWidth?: number; - minHeight?: number; - maxWidth?: number; - maxHeight?: number; - } - - interface Highlighter { - name: string; - options?: object; - } - - interface GradientOptions { - type: 'linearGradient' | 'radialGradient'; - stops: Array<{ - offset: string; - color: string; - opacity?: number; - }>; - } + export namespace CellView { - abstract class CellViewGeneric extends Backbone.View { - constructor(options?: { id: string }); + interface Options extends mvc.ViewOptions { + id?: string + } - unhighlight(el?: any, options?: any): this; + interface InteractivityOptions extends ElementView.InteractivityOptions, LinkView.InteractivityOptions { - can(feature: string): boolean; + } + } - findMagnet(el: any): HTMLElement; + abstract class CellViewGeneric extends mvc.View { - getSelector(el: HTMLElement, prevSelector: string): string; + constructor(opt?: CellView.Options); - getStrokeBBox(el: any): BBox; // string|HTMLElement|Vectorizer + highlight(el?: SVGElement | JQuery | string, opt?: { [key: string]: any }): this; - remove(): this; + unhighlight(el?: SVGElement | JQuery | string, opt?: { [key: string]: any }): this; - setInteractivity(value: any): void; + can(feature: string): boolean; - setTheme(theme: string, options?: any): this; + findMagnet(el: SVGElement | JQuery | string): SVGElement | undefined; - protected mouseover(evt: Event): void; + findBySelector(selector: string, root?: SVGElement | JQuery | string): JQuery; - protected mousewheel(evt: Event, x: number, y: number, delta: number): void + getSelector(el: SVGElement, prevSelector?: string): string; - protected notify(eventName: string): void; + getStrokeBBox(el?: SVGElement): g.Rect; - protected onSetTheme(oldTheme: string, newTheme: string): void; + notify(eventName: string, ...eventArguments: any[]): void; - protected pointerclick(evt: Event, x: number, y: number): void; + protected mouseover(evt: JQuery.Event): void; - protected pointerdblclick(evt: Event, x: number, y: number): void; + protected mousewheel(evt: JQuery.Event, x: number, y: number, delta: number): void - protected pointerdown(evt: Event, x: number, y: number): void; + protected pointerclick(evt: JQuery.Event, x: number, y: number): void; - protected pointermove(evt: Event, x: number, y: number): void; + protected pointerdblclick(evt: JQuery.Event, x: number, y: number): void; - protected pointerup(evt: Event, x: number, y: number): void; + protected pointerdown(evt: JQuery.Event, x: number, y: number): void; + + protected pointermove(evt: JQuery.Event, x: number, y: number): void; + + protected pointerup(evt: JQuery.Event, x: number, y: number): void; } class CellView extends CellViewGeneric { + } - interface ElementViewAttributes { - style?: string; - text?: string; - html?: string; - "ref-x"?: string | number; - "ref-y"?: string | number; - "ref-dx"?: number; - "ref-dy"?: number; - "ref-width"?: string | number; - "ref-height"?: string | number; - ref?: string; - "x-alignment"?: 'middle' | 'right' | number; - "y-alignment"?: 'middle' | 'bottom' | number; - port?: string; + // dia.ElementView + + + export namespace ElementView { + + interface InteractivityOptions { + elementMove?: boolean; + addLinkFromMagnet?: boolean; + } } class ElementView extends CellViewGeneric { - getBBox(options?: { useModelGeometry?: boolean }): g.Rect; + getBBox(opt?: { useModelGeometry?: boolean }): g.Rect; + + update(element: Element, renderingOnlyAttrs?: { [key: string]: any }): void; - update(cell: Cell, renderingOnlyAttrs?: object): void; + setInteractivity(value: boolean | ElementView.InteractivityOptions): void; - protected mouseenter(evt: Event): void; + protected renderMarkup(): void; + } - protected mouseleave(evt: Event): void; + // dia.LinkView - protected pointerdown(evt: Event, x: number, y: number): void; - protected pointermove(evt: Event, x: number, y: number): void; + export namespace LinkView { - protected pointerup(evt: Event, x: number, y: number): void; + interface InteractivityOptions { + vertexAdd?: boolean, + vertexMove?: boolean, + vertexRemove?: boolean; + arrowheadMove?: boolean; + labelMove?: boolean; + useLinkTools?: boolean; + } - protected renderMarkup(): void; + interface GetConnectionPoint { + ( + linkView: LinkView, + view: ElementView, + magnet: SVGElement, + reference: Point, + end: 'source' | 'target' + ): Point; + } } class LinkView extends CellViewGeneric { + options: { shortLinkLength?: number, doubleLinkTools?: boolean, longLinkLength?: number, linkToolsOffset?: number, doubleLinkToolsOffset?: number, - sampleInterval: number + sampleInterval?: number }; - getConnectionLength(): number; - sendToken(token: SVGElement, duration?: number, callback?: () => void): void; + sendToken(token: SVGElement, opt?: { duration?: number, direction?: string; }, callback?: () => void): void; addVertex(vertex: Point): number; - getPointAtLength(length: number): g.Point; // Marked as public api in source but not in the documents + getConnectionLength(): number; + + getPointAtLength(length: number): g.Point; - update(model: Cell, attributes: object, options?: object): this; + update(link: Link, attributes: any, opt?: { [key: string]: any }): this; - protected mouseenter(evt: Event): void; + setInteractivity(value: boolean | LinkView.InteractivityOptions): void; - protected mouseleave(evt: Event): void; + protected onLabelsChange(link: Link, labels: Link.Label[], opt: { [key: string]: any }): void; - protected onEndModelChange(endType: 'source' | 'target', endModel?: Element, - opt?: { cacheOnly?: boolean, handleBy?: string, translateBy?: boolean, tx?: number, ty?: number }): void; + protected onToolsChange(link: Link, toolsMarkup: string, opt: { [key: string]: any }): void; - protected onLabelsChange(): void; + protected onVerticesChange(link: Link, vertices: Point[], opt: { [key: string]: any }): void; - protected onSourceChange(cell: Cell, sourceEnd: { id: string }, options: object): void; + protected onSourceChange(element: Element, sourceEnd: any, opt: { [key: string]: any }): void; - protected onTargetChange(cell: Cell, targetEnd: { id: string }, options: object): void; + protected onTargetChange(element: Element, targetEnd: any, opt: { [key: string]: any }): void; + } - protected onToolsChange(): void; + // dia.Paper - // changed is not used in function body. - protected onVerticesChange(cell: Cell, changed: any, options: object): void; + export namespace Paper { - protected pointerdown(evt: Event, x: number, y: number): void; + interface GradientOptions { + id?: string; + type: 'linearGradient' | 'radialGradient'; + stops: Array<{ + offset: string; + color: string; + opacity?: number; + }>; + } + + interface GridOptions { + color?: string; + thickness?: number; + name?: 'dot' | 'fixedDot' | 'mesh' | 'doubleMesh'; + args?: Array<{ [key: string]: any }> | { [key: string]: any }; + } - protected pointermove(evt: Event, x: number, y: number): void; + interface BackgroundOptions { + color?: string; + image?: string; + quality?: number; + position?: Point | string; + size?: Size | string; + repeat?: string; + opacity?: number; + waterMarkAngle?: number; + } + + interface Options extends mvc.ViewOptions { + // appearance + width?: number; + height?: number; + origin?: Point; + perpendicularLinks?: boolean; + linkConnectionPoint?: LinkView.GetConnectionPoint; + drawGrid?: boolean | GridOptions | GridOptions[]; + background?: BackgroundOptions; + async?: boolean | { batchSize: number }; + // interactions + gridSize?: number; + highlighting?: { [type: string]: highlighters.HighlighterJSON }; + interactive?: ((cellView: CellView, event: string) => boolean) | boolean | CellView.InteractivityOptions + snapLinks?: boolean | { radius: number }; + markAvailable?: boolean; + // validations + validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; + validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: 'source' | 'target', linkView: LinkView) => boolean; + restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; + multiLinks?: boolean; + linkPinning?: boolean; + // events + guard?: (evt: JQuery.Event, view: CellView) => boolean; + preventContextMenu?: boolean; + preventDefaultBlankAction?: boolean; + clickThreshold?: number; + moveThreshold?: number; + // views + elementView?: typeof ElementView | ((element: Element) => typeof ElementView); + linkView?: typeof LinkView | ((link: Link) => typeof LinkView); + // embedding + embeddingMode?: boolean; + findParentBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft'; + validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; + // default views, models & attributes + cellViewNamespace?: any; + highlighterNamespace?: any; + defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; + defaultRouter?: routers.Router | routers.RouterJSON; + defaultConnector?: connectors.Connector | connectors.ConnectorJSON; + } + + interface ScaleContentOptions { + padding?: number; + preserveAspectRatio?: boolean; + minScale?: number; + minScaleX?: number; + minScaleY?: number; + maxScale?: number; + maxScaleX?: number; + maxScaleY?: number; + scaleGrid?: number; + fittingBBox?: BBox; + } + + interface FitToContentOptions { + gridWidth?: number; + gridHeight?: number; + padding?: Padding; + allowNewOrigin?: 'negative' | 'positive' | 'any'; + minWidth?: number; + minHeight?: number; + maxWidth?: number; + maxHeight?: number; + } - protected pointerup(evt: Event, x: number, y: number): void; } class Paper extends mvc.View { - constructor(options: PaperOptions); - options: dia.PaperOptions; + constructor(opt: Paper.Options); + + options: Paper.Options; svg: SVGElement; viewport: SVGGElement; defs: SVGDefsElement; - clientMatrix(): SVGMatrix; - - clientToLocalPoint(x: number | g.Point, y?: number): g.Point; + matrix(): SVGMatrix; + matrix(ctm: SVGMatrix | Vectorizer.Matrix): this; - clientToLocalRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + clientMatrix(): SVGMatrix; clientOffset(): g.Point; - cloneOptions(): dia.PaperOptions; + pageOffset(): g.Point; - cancelRenderViews(): void; + clientToLocalPoint(x: number, y: number): g.Point; + clientToLocalPoint(point: Point): g.Point; - createViewForModel(cell: dia.Cell): dia.CellView; + clientToLocalRect(x: number, y: number, width: number, height: number): g.Rect; + clientToLocalRect(rect: BBox): g.Rect; - defineFilter(filter: object): string; + localToClientPoint(x: number, y: number): g.Point; + localToClientPoint(point: Point): g.Point; - defineGradient(gradient: object): string; + localToClientRect(x: number, y: number, width: number, height: number): g.Rect; + localToClientRect(rect: BBox): g.Rect; - defineMarker(marker: object): string; + localToPagePoint(x: number, y: number): g.Point; + localToPagePoint(point: Point): g.Point; - drawBackground(opt?: { color?: string, img?: string }): Paper; + localToPageRect(x: number, y: number, width: number, height: number): g.Rect; + localToPageRect(rect: BBox): g.Rect; - drawBackgroundImage(img: HTMLImageElement, opt: object): void; + localToPaperPoint(x: number, y: number): g.Point; + localToPaperPoint(point: Point): g.Point; - drawGrid(options?: { - width?: number, height?: number, scaleFactor?: number, - update: any, ox?: number, oy?: number - }): Paper; + localToPaperRect(x: number, y: number, width: number, height: number): g.Rect; + localToPaperRect(rect: BBox): g.Rect; - findView(element: string | JQuery | SVGElement): T; + pageToLocalPoint(x: number, y: number): g.Point; + pageToLocalPoint(point: Point): g.Point; - findViewByModel(model: Element | string | dia.Link): T; + pageToLocalRect(x: number, y: number, width: number, height: number): g.Rect; + pageToLocalRect(rect: BBox): g.Rect; - findViewsFromPoint(point: string | dia.Point | g.Point): dia.ElementView[]; + paperToLocalPoint(x: number, y: number): g.Point; + paperToLocalPoint(point: Point): g.Point; - findViewsInArea(rect: g.Rect | dia.BBox, options?: { strict?: boolean }): dia.CellView[]; + paperToLocalRect(x: number, y: number, width: number, height: number): g.Rect; + paperToLocalRect(x: BBox): g.Rect; - fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, options?: any): void; + snapToGrid(x: number, y: number): g.Point; + snapToGrid(point: Point): g.Point; - fitToContent(options?: dia.FitToContentOptions): void; + defineFilter(filter: { [key: string]: any }): string; - getArea(): g.Rect; + defineGradient(gradient: Paper.GradientOptions): string; - getContentBBox(): g.Rect; + defineMarker(marker: { [key: string]: any }): string; - getDefaultLink(cellView: dia.CellView, magnet: HTMLElement): dia.Link; + isDefined(defId: string): boolean; - getModelById(id: string): dia.Cell; + getArea(): g.Rect; getRestrictedArea(): g.Rect | undefined; - guard(evt: Event, view: dia.CellView): boolean; + getContentBBox(): g.Rect; - isDefined(defId: string): boolean; + findView(element: string | JQuery | SVGElement): T; - localToClientPoint(x: number | g.Point, y?: number): g.Point; + findViewByModel(model: Cell | string | number): T; - localToClientRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + findViewsFromPoint(point: string | Point): ElementView[]; - localToPagePoint(x: number | g.Point, y?: number): g.Point; + findViewsInArea(rect: BBox, opt?: { strict?: boolean }): ElementView[]; - localToPageRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + fitToContent(opt?: Paper.FitToContentOptions): void; + fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, opt?: any): void; - localToPaperPoint(x: number | g.Point, y?: number): g.Point; + scaleContentToFit(opt?: Paper.ScaleContentOptions): void; - localToPaperRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + cancelRenderViews(): void; - matrix(): SVGMatrix; + drawBackground(opt?: Paper.BackgroundOptions): this; - matrix(ctm: SVGMatrix | Vectorizer.Matrix): Paper; + drawGrid(opt?: Paper.GridOptions | Paper.GridOptions[]): this; - pageOffset(): g.Point; + clearGrid(): this; - pageToLocalPoint(x: number | g.Point, y?: number): g.Point; + getDefaultLink(cellView: CellView, magnet: SVGElement): Link; - pageToLocalRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + getModelById(id: string | number | Cell): Cell; - paperToLocalPoint(x: number | g.Point, y?: number): g.Point; + setDimensions(width: number, height: number): void; - paperToLocalRect(x: number | g.Rect, y?: number, width?: number, height?: number): g.Rect; + setGridSize(gridSize: number): this; - remove(): Paper; + setInteractivity(value: any): void; - render(): Paper; + setOrigin(x: number, y: number): this; scale(): Vectorizer.Scale; + scale(sx: number, sy?: number, ox?: number, oy?: number): this; - scale(sx: number, sy?: number, ox?: number, oy?: number): Paper; - - scaleContentToFit(options?: dia.ScaleContentOptions): void; - - setDimensions(width: number, height: number): void; + translate(): Vectorizer.Translation; + translate(tx: number, ty?: number): this; - setGridSize(gridSize: number): Paper; + update(): this; - setInteractivity(value: any): void; - - setOrigin(x: number, y: number): Paper; + // protected + protected guard(evt: JQuery.Event, view: CellView): boolean; - snapToGrid(x: g.Point | number, y?: number): g.Point; + protected sortViews(): void; - sortViews(): void; + protected drawBackgroundImage(img: HTMLImageElement, opt: { [key: string]: any }): void; - translate(): Vectorizer.Translation; + protected createViewForModel(cell: Cell): CellView; - translate(tx: number, ty?: number): Paper; + protected cloneOptions(): Paper.Options; - update(): void; - - // protected protected afterRenderViews(): void; - protected asyncRenderViews(cells: dia.Cell[], options?: object): void; + protected asyncRenderViews(cells: Cell[], opt?: { [key: string]: any }): void; - protected beforeRenderViews(cells: dia.Cell[]): dia.Cell[]; + protected beforeRenderViews(cells: Cell[]): Cell[]; - protected cellMouseEnter(evt: Event): void; + protected cellMouseEnter(evt: JQuery.Event): void; - protected cellMouseleave(evt: Event): void; + protected cellMouseleave(evt: JQuery.Event): void; - protected cellMouseout(evt: Event): void; + protected cellMouseout(evt: JQuery.Event): void; - protected cellMouseover(evt: Event): void; + protected cellMouseover(evt: JQuery.Event): void; - protected contextmenu(evt: Event): void; + protected contextmenu(evt: JQuery.Event): void; protected init(): void; - protected mouseclick(evt: Event): void; + protected mouseclick(evt: JQuery.Event): void; - protected mousedblclick(evt: Event): void; + protected mousedblclick(evt: JQuery.Event): void; - protected mousewheel(evt: Event): void; + protected mousewheel(evt: JQuery.Event): void; - protected onCellAdded(cell: dia.Cell, graph: dia.Graph, options: { async?: boolean, position?: number }): void; + protected onCellAdded(cell: Cell, graph: Graph, opt: { async?: boolean, position?: number }): void; - protected onCellHighlight(cellView: dia.CellView, magnetEl: HTMLElement, options?: { highlighter?: dia.Highlighter }): void; + protected onCellHighlight(cellView: CellView, magnetEl: SVGElement, opt?: { highlighter?: highlighters.HighlighterJSON }): void; - protected onCellUnhighlight(cellView: dia.CellView, magnetEl: HTMLElement, options?: { highlighter?: dia.Highlighter }): void; + protected onCellUnhighlight(cellView: CellView, magnetEl: SVGElement, opt?: { highlighter?: highlighters.HighlighterJSON }): void; protected onRemove(): void; - protected pointerdown(evt: Event): void; + protected pointerdown(evt: JQuery.Event): void; - protected pointermove(evt: Event): void; + protected pointermove(evt: JQuery.Event): void; - protected pointerup(evt: Event): void; + protected pointerup(evt: JQuery.Event): void; - protected removeView(cell: dia.Cell): dia.CellView; + protected removeView(cell: Cell): CellView; protected removeViews(): void; - protected renderView(cell: dia.Cell): dia.CellView; + protected renderView(cell: Cell): CellView; - protected resetViews(cellsCollection: dia.Cell[], options: object): void; + protected resetViews(cellsCollection: Cell[], opt: { [key: string]: any }): void; protected updateBackgroundColor(color: string): void; @@ -1362,182 +1408,217 @@ export namespace dia { } } -export namespace ui { -} - export namespace shapes { - interface GenericAttributes extends dia.CellAttributes { - position?: dia.Point; - size?: dia.Size; - angle?: number; - attrs?: T; + + interface SVGTextSelector extends dia.Cell.Selectors { + text?: attributes.SVGTextAttributes; } - interface ShapeAttrs extends dia.CSSSelector { - fill?: string; - stroke?: string; - r?: string | number; - rx?: string | number; - ry?: string | number; - cx?: string | number; - cy?: string | number; - height?: string | number; - width?: string | number; - transform?: string; - points?: string; - 'stroke-width'?: string | number; - 'ref-x'?: string | number; - 'ref-y'?: string | number; - ref?: string + interface SVGRectSelector extends dia.Cell.Selectors { + rect?: attributes.SVGRectAttributes; + } + + interface SVGCircleSelector extends dia.Cell.Selectors { + circle?: attributes.SVGCircleAttributes; + } + + interface SVGEllipseSelector extends dia.Cell.Selectors { + ellipse?: attributes.SVGEllipseAttributes; + } + + interface SVGPolygonSelector extends dia.Cell.Selectors { + polygon?: attributes.SVGPolygonAttributes; + } + + interface SVGPolylineSelector extends dia.Cell.Selectors { + polyline?: attributes.SVGPolylineAttributes; + } + + interface SVGImageSelector extends dia.Cell.Selectors { + image?: attributes.SVGImageAttributes; + } + + interface SVGPathSelector extends dia.Cell.Selectors { + path?: attributes.SVGPathAttributes; } namespace basic { + class Generic extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } - interface RectAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; + class Text extends Generic { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - class Rect extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + interface RectSelectors extends SVGTextSelector, SVGRectSelector { + } - class Text extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + class Rect extends Generic { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface CircleAttrs extends dia.TextAttrs { - circle?: ShapeAttrs; + interface CircleSelectors extends SVGTextSelector, SVGCircleSelector { + } class Circle extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface EllipseAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; + interface EllipseSelectors extends SVGTextSelector, SVGEllipseSelector { + } + class Ellipse extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface PolygonAttrs extends dia.TextAttrs { - polygon?: ShapeAttrs; + interface PolygonSelectors extends SVGTextSelector, SVGPolygonSelector { + } + class Polygon extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface PolylineAttrs extends dia.TextAttrs { - polyline?: ShapeAttrs; + interface PolylineSelectors extends SVGTextSelector, SVGPolylineSelector { + } class Polyline extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - class Image extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + interface ImageSelectors extends SVGTextSelector, SVGImageSelector { + } - interface PathAttrs extends dia.TextAttrs { - path?: ShapeAttrs; + class Image extends Generic { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - class Path extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + interface PathSelectors extends SVGTextSelector, SVGPathSelector { + } - interface RhombusAttrs extends dia.TextAttrs { - path?: ShapeAttrs; + class Path extends Generic { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Rhombus extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface TextBlockAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; + interface TextBlockSelectors extends SVGTextSelector, SVGRectSelector { + '.content'?: attributes.SVGTextAttributes; } class TextBlock extends Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); - - updateSize(cell: dia.Cell, size: dia.Size): void; - - updateContent(cell: dia.Cell, content: string): void; + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } } namespace chess { + class KingWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class KingBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class QueenWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class QueenBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class RookWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class RookBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class BishopWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class BishopBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class KnightWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class KnightBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class PawnWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class PawnBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } } namespace devs { - /** - * @deprecated - */ - interface ModelAttributes extends GenericAttributes { + + interface ModelSelectors extends dia.Cell.Selectors { + '.label'?: attributes.SVGTextAttributes; + '.body'?: attributes.SVGRectAttributes; + } + + interface ModelAttributes extends dia.Element.GenericAttributes { inPorts?: string[]; outPorts?: string[]; - ports?: {[key: string]: any}; } - /** - * @deprecated - */ class Model extends basic.Generic { - constructor(attributes?: ModelAttributes, options?: {[key: string]: any}); + + constructor(attributes?: ModelAttributes, opt?: { [key: string]: any }); changeInGroup(properties: any, opt?: any): boolean; @@ -1556,223 +1637,249 @@ export namespace shapes { removeInPort(port: string, opt?: any): this; } - /** - * @deprecated - */ class Coupled extends Model { - constructor(attributes?: ModelAttributes, options?: {[key: string]: any}); + } - /** - * @deprecated - */ class Atomic extends Model { - constructor(attributes?: ModelAttributes, options?: {[key: string]: any}); + } class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } } namespace erd { + + interface PolygonalSelectors extends dia.Cell.Selectors { + '.label'?: attributes.SVGPolygonAttributes; + '.body'?: attributes.SVGPolygonAttributes; + 'text'?: attributes.SVGTextAttributes; + } + + interface EllipsoidSelectors extends dia.Cell.Selectors { + '.label'?: attributes.SVGEllipseAttributes; + '.body'?: attributes.SVGEllipseAttributes; + 'text'?: attributes.SVGTextAttributes; + } + class Entity extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class WeakEntity extends Entity { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class Relationship extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class IdentifyingRelationship extends Relationship { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); - } - interface AttributeAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; } class Attribute extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Multivalued extends Attribute { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class Derived extends Attribute { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class Key extends Attribute { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class Normal extends Attribute { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); - } - interface ISAAttrs extends dia.Element { - polygon?: ShapeAttrs; } class ISA extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Line extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); cardinality(value: string | number): void; } } namespace fsa { + class State extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class StartState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); + } + + interface CirculoidSelectors extends dia.Cell.Selectors { + '.outer'?: attributes.SVGCircleAttributes; + '.inner'?: attributes.SVGCircleAttributes; } class EndState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } } namespace logic { - interface LogicAttrs extends ShapeAttrs { - ref?: string; - 'ref-x'?: number | string; - 'ref-dx'?: number | string; - 'ref-y'?: number | string; - 'ref-dy'?: number | string; - magnet?: boolean; - 'class'?: string; - port?: string; - } - interface IOAttrs extends dia.TextAttrs { - circle?: LogicAttrs; + abstract class Gate extends basic.Generic { + } - class Gate extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + interface GateSelectors extends dia.Cell.Selectors { + '.body'?: attributes.SVGRectAttributes; + '.wire'?: attributes.SVGPathAttributes; + 'circle'?: attributes.SVGCircleAttributes; + 'text'?: attributes.SVGTextAttributes; } class IO extends Gate { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Input extends IO { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } class Output extends IO { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + } - class Gate11 extends Gate { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + interface Gate11Selectors extends dia.Cell.Selectors { + '.input'?: attributes.SVGCircleAttributes; + '.output'?: attributes.SVGCircleAttributes; + '.body'?: attributes.SVGImageAttributes; + 'image'?: attributes.SVGImageAttributes; } - class Gate21 extends Gate { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + class Gate11 extends Gate { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } - interface Image { - 'xlink:href'?: string; + interface Gate21Selectors extends dia.Cell.Selectors { + '.input'?: attributes.SVGCircleAttributes; + '.input1'?: attributes.SVGCircleAttributes; + '.input2'?: attributes.SVGCircleAttributes; + '.output'?: attributes.SVGCircleAttributes; + '.body'?: attributes.SVGImageAttributes; + 'image'?: attributes.SVGImageAttributes; } - interface ImageAttrs extends LogicAttrs { - image?: Image; + class Gate21 extends Gate { + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Repeater extends Gate11 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input: any): any; } class Not extends Gate11 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input: any): boolean; } class Or extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } class And extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } class Nor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } class Nand extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } class Xor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } class Xnor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); operation(input1: any, input2: any): boolean; } - interface WireArgs extends dia.LinkAttributes { - router?: {[key: string]: any}; - connector?: {[key: string]: any}; - } - class Wire extends dia.Link { - constructor(attributes?: WireArgs, options?: {[key: string]: any}); + } } namespace org { - interface MemberAttrs { - rect?: ShapeAttrs; - image?: ShapeAttrs; + + interface MemberSelectors extends dia.Cell.Selectors { + '.card'?: attributes.SVGRectAttributes; + '.rank'?: attributes.SVGTextAttributes; + '.name'?: attributes.SVGTextAttributes; + 'image'?: attributes.SVGImageAttributes; } class Member extends dia.Element { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } } namespace pn { + class Place extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor(attributes?: dia.Element.Attributes, opt?: { [key: string]: any }); } class PlaceView extends dia.ElementView { @@ -1780,136 +1887,287 @@ export namespace shapes { } class Transition extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } } namespace uml { - interface ClassAttributes extends GenericAttributes { + + interface ClassAttributes extends dia.Element.GenericAttributes { name: string[]; attributes: string[]; methods: string[]; } class Class extends basic.Generic { - constructor(attributes?: ClassAttributes, options?: {[key: string]: any}); + + constructor(attributes?: ClassAttributes, opt?: { [key: string]: any }); getClassName(): string[]; - updateRectangles(): void; + protected updateRectangles(): void; } class ClassView extends dia.ElementView { + } class Abstract extends Class { - constructor(attributes?: ClassAttributes, options?: {[key: string]: any}); + constructor(attributes?: ClassAttributes, opt?: { [key: string]: any }); } class AbstractView extends ClassView { - constructor(attributes?: ClassAttributes, options?: {[key: string]: any}); + constructor(attributes?: ClassAttributes, opt?: { [key: string]: any }); } class Interface extends Class { - constructor(attributes?: ClassAttributes, options?: {[key: string]: any}); + constructor(attributes?: ClassAttributes, opt?: { [key: string]: any }); } class InterfaceView extends ClassView { - constructor(attributes?: ClassAttributes, options?: {[key: string]: any}); + constructor(attributes?: ClassAttributes, opt?: { [key: string]: any }); } class Generalization extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } class Implementation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } class Aggregation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } class Composition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } class Association extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } - interface StateAttributes extends GenericAttributes { - events?: string[]; + interface StateSelectors extends dia.Cell.Selectors { + '.uml-state-body'?: attributes.SVGRectAttributes; + '.uml-state-separator'?: attributes.SVGPathAttributes; + '.uml-state-name'?: attributes.SVGTextAttributes; + '.uml-state-events'?: attributes.SVGTextAttributes; } class State extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); - updateName(): void; + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); - updateEvents(): void; + protected updateName(): void; - updatePath(): void; + protected updateEvents(): void; + + protected updatePath(): void; } class StartState extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); + } + + interface EndStateSelectors extends dia.Cell.Selectors { + 'circle.outer'?: attributes.SVGCircleAttributes; + 'circle.inner'?: attributes.SVGCircleAttributes; } class EndState extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: {[key: string]: any}); + constructor( + attributes?: dia.Element.GenericAttributes, + opt?: { [key: string]: any } + ); } class Transition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: {[key: string]: any}); + } } } +// util + export namespace util { - namespace format { - export function number(specifier: string, value: number): string; - } + export function hashCode(str: string): string; + + export function getByPath(object: { [key: string]: any }, path: string | string[], delim?: string): any; + + export function setByPath(object: { [key: string]: any }, path: string | string[], value: any, delim?: string): any; + + export function unsetByPath(object: { [key: string]: any }, path: string | string[], delim?: string): any; + + export function flattenObject(object: { [key: string]: any }, delim?: string, stop?: (node: any) => boolean): any; export function uuid(): string; - export function guid(obj?: {[key: string]: any}): string; + export function guid(obj?: { [key: string]: any }): string; - export function nextFrame(callback: () => void, context?: {[key: string]: any}): number; + export function toKebabCase(str: string): string; - export function cancelFrame(requestId: number): void; + export function normalizeEvent(evt: JQuery.Event): JQuery.Event; - export function flattenObject(object: {[key: string]: any}, delim: string, stop: (node: any) => boolean): any; + export function nextFrame(callback: () => void, context?: { [key: string]: any }): number; - export function getByPath(object: {[key: string]: any}, path: string, delim: string): any; + export function cancelFrame(requestId: number): void; - export function setByPath(object: {[key: string]: any}, path: string, value: any, delim: string): any; + export var shapePerimeterConnectionPoint: dia.LinkView.GetConnectionPoint; - export function unsetByPath(object: {[key: string]: any}, path: string, delim: string): any; + export function parseCssNumber(str: string, restrictUnits?: string[]): { value: number; unit?: string; }; - export function breakText(text: string, size: dia.Size, attrs?: dia.SVGAttributes, options?: { svgDocument?: SVGElement }): string; + export function breakText(text: string, size: dia.Size, attrs?: attributes.NativeSVGAttributes, opt?: { svgDocument?: SVGElement }): string; - export function normalizeSides(box: number | { x?: number, y?: number, height?: number, width?: number }): dia.BBox; + export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; export function getElementBBox(el: Element): dia.BBox; - export function setAttributesBySelector(el: Element, attrs: dia.SVGAttributes): void; + export function sortElements( + elements: Element[] | string | JQuery, + comparator: (a: Element, b: Element) => number + ): Element[]; - export function sortElements(elements: Element[] - | string - | JQuery, comparator: (a: Element, b: Element) => number): Element[]; + export function setAttributesBySelector(el: Element, attrs: { [selector: string]: { [attribute: string]: any } }): void; - export function shapePerimeterConnectionPoint(linkView: dia.LinkView, view: dia.ElementView, magnet: SVGElement, ref: dia.Point): dia.Point; + export function normalizeSides(sides: number | { top?: number, bottom?: number, left?: number, right?: number }): dia.PaddingJSON; - export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; + export function template(html: string): (data: any) => string; export function toggleFullScreen(el?: Element): void; + export namespace timing { + + type TimingFunction = (time: number) => number; + + export var linear: TimingFunction; + export var quad: TimingFunction; + export var cubic: TimingFunction; + export var inout: TimingFunction; + export var exponential: TimingFunction; + export var bounce: TimingFunction; + + export function reverse(f: TimingFunction): TimingFunction; + + export function reflect(f: TimingFunction): TimingFunction; + + export function clamp(f: TimingFunction, min?: number, max?: number): TimingFunction; + + export function back(s?: number): TimingFunction; + + export function elastic(x?: number): TimingFunction; + } + + export namespace interpolate { + + type InterpolateFunction = (start: T, end: T) => ((time: number) => T); + + export var number: InterpolateFunction; + export var object: InterpolateFunction<{ [key: string]: any }>; + export var hexColor: InterpolateFunction; + export var unit: InterpolateFunction; + } + + export namespace filter { + + interface FilterArgumentsMap { + 'outline': { + color?: string; + opacity?: number; + margin?: number; + width?: number; + }; + 'highlight': { + color?: string; + blur?: number; + opacity?: number; + width?: number; + }; + 'blur': { + x?: number; + y?: number; + }; + 'dropShadow': { + dx?: number; + dy?: number; + opacity?: number; + color?: string; + blur?: number; + }; + 'grayscale': { + amount?: number; + }; + 'sepia': { + amount?: number; + }; + 'saturate': { + amount?: number; + }; + 'hueRotate': { + angle?: number; + }; + 'invert': { + amount?: number; + }; + 'brightness': { + amount?: number; + }; + 'contrast': { + amount?: number; + }; + } + + type FilterFunction = (args: FilterArgumentsMap[K]) => string; + + export var outline: FilterFunction<'outline'>; + export var highlight: FilterFunction<'highlight'>; + export var blur: FilterFunction<'blur'>; + export var dropShadow: FilterFunction<'dropShadow'>; + export var grayscale: FilterFunction<'grayscale'>; + export var sepia: FilterFunction<'sepia'>; + export var saturate: FilterFunction<'saturate'>; + export var hueRotate: FilterFunction<'hueRotate'>; + export var invert: FilterFunction<'invert'>; + export var brightness: FilterFunction<'brightness'>; + export var contrast: FilterFunction<'contrast'>; + } + + namespace format { + + interface NumberLocale { + currency: [string, string], + decimal: string, + thousands: string, + grouping: number[] + } + + export function number(specifier: string, value: number, locale?: NumberLocale): string; + + export function string(str: string, value: string): string; + + export function convert(type: string, value: number, precision: number): string; + + export function round(value: number, precision?: number): number + + export function precision(value: number, precision: number): number; + + export function prefix(value: number, precision: number): { scale: (d: number) => number; symbol: string; } | undefined + } + // Not documented but used in examples /** @deprecated use lodash _.defaultsDeep */ export function deepSupplement(objects: any, defaultIndicator?: any): any; @@ -1923,40 +2181,85 @@ export namespace util { /** @deprecated use lodash _.mixin */ export function deepMixin(objects: any[]): any; + } -export namespace layout { +// env - interface LayoutOptions { - nodeSep?: number; - edgeSep?: number; - rankSep?: number; - rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; - marginX?: number; - marginY?: number; - resizeCluster?: boolean; - setPosition?: (element: dia.Element, position: dia.BBox) => void; - setLinkVertices?: (link: dia.Link, vertices: Position[]) => void; - } +export namespace env { + + export function addTest(name: string, fn: () => boolean): void; + + export function test(name: string): boolean; +} + +// layout + +export namespace layout { export namespace DirectedGraph { - export function layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; + + interface Edge { + minLen?: number; + weight?: number; + labelpos?: 'l' | 'c' | 'r'; + labeloffset?: number; + width?: number; + height?: number; + } + + interface Node { + width?: number; + height?: number; + } + + interface LayoutOptions { + rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; + ranker?: 'network-simplex' | 'tight-tree' | 'longest-path'; + nodeSep?: number; + edgeSep?: number; + rankSep?: number; + marginX?: number; + marginY?: number; + resizeCluster?: boolean; + clusterPadding?: dia.Padding; + setPosition?: (element: dia.Element, position: dia.BBox) => void; + setVertices?: boolean | ((link: dia.Link, vertices: dia.Point[]) => void); + setLabels?: boolean | ((link: dia.Link, position: dia.Point, points: dia.Point[]) => void); + debugTiming?: boolean; + exportElement?: (element: dia.Element) => Node; + exportLink?: (link: dia.Link) => Edge; + // deprecated + setLinkVertices?: boolean; + } + + export function layout(graph: dia.Graph | dia.Cell[], opt?: LayoutOptions): g.Rect; } } +// mvc + export namespace mvc { + interface ViewOptions extends Backbone.ViewOptions { + theme?: string; + } + class View extends Backbone.View { - constructor(opt: any); - constructor(); + + constructor(opt?: ViewOptions); theme: string; + themeClassNamePrefix: string + defaultTheme: string; - setTheme(theme: string, opt: any): void; + requireSetThemeOverride: boolean; + + setTheme(theme: string, opt?: { override?: boolean }): this; - getEventNamespace(): this; + getEventNamespace(): string; protected init(): void; @@ -1968,4 +2271,425 @@ export namespace mvc { } } +// routers + +export namespace routers { + + interface NormalRouterArguments { + + } + + interface ManhattanRouterArguments { + excludeTypes?: string[]; + excludeEnds?: 'source' | 'target'; + startDirections?: ['left' | 'right' | 'top' | 'bottom']; + endDirections?: ['left' | 'right' | 'top' | 'bottom']; + step?: number; + maximumLoops?: number; + } + + interface OrthogonalRouterArguments { + elementPadding?: number; + } + + interface OneSideRouterArguments { + side?: 'bottom' | 'top' | 'left' | 'right'; + padding?: number; + } + + interface RouterArgumentsMap { + 'normal': NormalRouterArguments; + 'manhattan': ManhattanRouterArguments; + 'metro': ManhattanRouterArguments; + 'orthogonal': OrthogonalRouterArguments; + 'oneSide': OneSideRouterArguments; + } + + type RouterType = string & keyof RouterArgumentsMap; + + interface GenericRouter { + ( + points: dia.Point[], + args?: RouterArgumentsMap[K], + linkView?: dia.LinkView + ): dia.Point[]; + } + + interface GenericRouterJSON { + name: K; + args?: RouterArgumentsMap[K]; + } + + type Router = GenericRouter; + + type RouterJSON = GenericRouterJSON; + + export var manhattan: GenericRouter<'manhattan'>; + export var metro: GenericRouter<'metro'>; + export var normal: GenericRouter<'normal'>; + export var orthogonal: GenericRouter<'orthogonal'>; + export var oneSide: GenericRouter<'oneSide'>; +} + +// connectors + +export namespace connectors { + + interface NormalConnectorArguments { + + } + + interface RoundedConnectorArguments { + radius?: number + } + + interface SmoothConnectorArguments { + + } + + interface JumpOverConnectorArguments { + size?: number; + jump?: 'arc' | 'gap' | 'cubic' + } + + interface ConnectorArgumentsMap { + 'normal': NormalConnectorArguments; + 'rounded': RoundedConnectorArguments; + 'smooth': SmoothConnectorArguments; + 'jumpover': JumpOverConnectorArguments; + } + + type ConnectorType = string & keyof ConnectorArgumentsMap; + + interface GenericConnector { + ( + sourcePoint: dia.Point, + targetPoint: dia.Point, + vertices: dia.Point[], + args?: ConnectorArgumentsMap[K], + linkView?: dia.LinkView + ): string; + } + + interface GenericConnectorJSON { + name: K; + args?: ConnectorArgumentsMap[K]; + } + + type Connector = GenericConnector; + + type ConnectorJSON = GenericConnectorJSON; + + export var normal: GenericConnector<'normal'>; + export var rounded: GenericConnector<'rounded'>; + export var smooth: GenericConnector<'smooth'>; + export var jumpover: GenericConnector<'jumpover'>; +} + +// highlighters + +export namespace highlighters { + + interface AddClassHighlighterArguments { + className?: string; + } + + interface OpacityHighlighterArguments { + + } + + interface StrokeHighlighterArguments { + padding?: number; + rx?: number; + ry?: number; + attrs?: attributes.NativeSVGAttributes; + } + + interface HighlighterArgumentsMap { + 'addClass': AddClassHighlighterArguments; + 'opacity': OpacityHighlighterArguments; + 'stroke': StrokeHighlighterArguments; + } + + type HighlighterType = string & keyof HighlighterArgumentsMap; + + interface GenericHighlighterJSON { + name: K; + opt?: HighlighterArgumentsMap[K]; + } + + interface GenericHighlighter { + highlight(cellView: dia.CellView, magnetEl: SVGElement, opt?: HighlighterArgumentsMap[K]): void; + + unhighlight(cellView: dia.CellView, magnetEl: SVGElement, opt?: HighlighterArgumentsMap[K]): void; + } + + type Highlighter = GenericHighlighter; + + type HighlighterJSON = GenericHighlighterJSON; + + export var addClass: GenericHighlighter<'addClass'>; + export var opacity: GenericHighlighter<'opacity'>; + export var stroke: GenericHighlighter<'stroke'>; +} + +export namespace attributes { + + interface SVGCoreAttributes { + 'id'?: string; + 'xml:base'?: string; + 'xml:lang'?: string; + 'xml:space'?: string; + 'tabindex'?: number; + } + + interface SVGConditionalProcessingAttributes { + 'requiredExtensions'?: boolean; + 'requiredFeatures'?: string; + 'systemLanguage'?: string; + } + + interface SVGXLinkAttributes { + 'xlink:href'?: string; + 'xlink:type'?: string; + 'xlink:role'?: string; + 'xlink:arcrole'?: string; + 'xlink:title'?: string; + 'xlink:show'?: string; + 'xlink:actuate'?: string; + } + + interface SVGPresentationAttributes { + 'alignment-baseline'?: any; + 'baseline-shift'?: any; + 'clip'?: any; + 'clip-path'?: any; + 'clip-rule'?: any; + 'color'?: any; + 'color-interpolation'?: any; + 'color-interpolation-filters'?: any; + 'color-profile'?: any; + 'color-rendering'?: any; + 'cursor'?: any; + 'direction'?: any; + 'display'?: any; + 'dominant-baseline'?: any; + 'enable-background'?: any; + 'fill'?: any; + 'fill-opacity'?: any; + 'fill-rule'?: any; + 'filter'?: any; + 'flood-color'?: any; + 'flood-opacity'?: any; + 'font-family'?: any; + 'font-size'?: any; + 'font-size-adjust'?: any; + 'font-stretch'?: any; + 'font-style'?: any; + 'font-variant'?: any; + 'font-weight'?: any; + 'glyph-orientation-horizontal'?: any; + 'glyph-orientation-vertical'?: any; + 'image-rendering'?: any; + 'kerning'?: any; + 'letter-spacing'?: any; + 'lighting-color'?: any; + 'marker-end'?: any; + 'marker-mid'?: any; + 'marker-start'?: any; + 'mask'?: any; + 'opacity'?: any; + 'overflow'?: any; + 'pointer-events'?: any; + 'shape-rendering'?: any; + 'stop-color'?: any; + 'stop-opacity'?: any; + 'stroke'?: any; + 'stroke-dasharray'?: any; + 'stroke-dashoffset'?: any; + 'stroke-linecap'?: any; + 'stroke-linejoin'?: any; + 'stroke-miterlimit'?: any; + 'stroke-opacity'?: any; + 'stroke-width'?: any; + 'text-anchor'?: any; + 'text-decoration'?: any; + 'text-rendering'?: any; + 'unicode-bidi'?: any; + 'visibility'?: any; + 'word-spacing'?: any; + 'writing-mode'?: any; + } + + interface NativeSVGAttributes extends SVGCoreAttributes, SVGPresentationAttributes, SVGConditionalProcessingAttributes, SVGXLinkAttributes { + 'class'?: string; + 'style'?: string; + 'transform'?: string; + 'externalResourcesRequired'?: boolean; + + [key: string]: any; + } + + interface SVGAttributes extends NativeSVGAttributes { + // Special attributes + filter?: string | { [key: string]: any }; + fill?: string | { [key: string]: any }; + stroke?: string | { [key: string]: any }; + sourceMarker?: { [key: string]: any }; + targetMarker?: { [key: string]: any }; + vertexMarker?: { [key: string]: any }; + text?: string; + textWrap?: { [key: string]: any }; + lineHeight?: number | string; + textPath?: any; + annotations?: any; + port?: string; + style?: string; + html?: string; + ref?: string; + refX?: string | number; + refy?: string | number; + refX2?: string | number; + refy2?: string | number; + refDx?: string | number; + refDy?: string | number; + refWidth?: string | number; + refHeight?: string | number; + refRx?: string | number; + refRy?: string | number; + refCx?: string | number; + refCy?: string | number; + resetOffset?: boolean; + xAlignment?: 'middle' | 'right' | number | string; + yAlignment?: 'middle' | 'bottom' | number | string; + event?: string; + magnet?: boolean | string; + // CamelCase variants of native attributes + alignmentBaseline?: any; + baselineShift?: any; + clipPath?: any; + clipRule?: any; + colorInterpolation?: any; + colorInterpolationFilters?: any; + colorProfile?: any; + colorRendering?: any; + dominantBaseline?: any; + enableBackground?: any; + fillOpacity?: any; + fillRule?: any; + floodColor?: any; + floodOpacity?: any; + fontFamily?: any; + fontSize?: any; + fontSizeAdjust?: any; + fontStretch?: any; + fontStyle?: any; + fontVariant?: any; + fontWeight?: any; + glyphOrientationHorizontal?: any; + glyphOrientationVertical?: any; + imageRendering?: any; + letterSpacing?: any; + lightingColor?: any; + markerEnd?: any; + markerMid?: any; + markerStart?: any; + pointerEvents?: any; + shapeRendering?: any; + stopColor?: any; + stopOpacity?: any; + strokeDasharray?: any; + strokeDashoffset?: any; + strokeLinecap?: any; + strokeLinejoin?: any; + strokeMiterlimit?: any; + strokeOpacity?: any; + strokeWidth?: any; + textAnchor?: any; + textDecoration?: any; + textRendering?: any; + unicodeBidi?: any; + wordSpacing?: any; + writingMode?: any; + xlinkHref?: string; + xlinkShow?: string; + xlinkType?: string; + xlinkRole?: string; + xlinkArcrole?: string; + xlinkTitle?: string; + xlinkActuate?: string; + xmlSpace?: string; + xmlBase?: string; + xmlLang?: string; + // Backwards compatibility + 'ref-x'?: string | number; + 'ref-y'?: string | number; + 'ref-dx'?: string | number; + 'ref-dy'?: string | number; + 'ref-width'?: string | number; + 'ref-height'?: string | number; + 'x-alignment'?: 'middle' | 'right' | number | string; + 'y-alignment'?: 'middle' | 'bottom' | number | string; + } + + interface SVGTextAttributes extends SVGAttributes { + x?: string | number; + y?: string | number; + dx?: string | number; + dy?: string | number; + rotate?: string; + textAnchor?: string; + textLength?: number; + lengthAdjust?: string; + 'text-anchor'?: string; + 'text-lenght'?: number; + 'length-adjust'?: string; + } + + interface SVGRectAttributes extends SVGAttributes { + x?: string | number; + y?: string | number; + width?: string | number; + height?: string | number; + ry?: string | number; + rx?: string | number; + } + + interface SVGCircleAttributes extends SVGAttributes { + cx?: string | number; + cy?: string | number; + r?: string | number; + } + + interface SVGEllipseAttributes extends SVGAttributes { + cx?: string | number; + cy?: string | number; + rx?: string | number; + ry?: string | number; + } + + interface SVGPolygonAttributes extends SVGAttributes { + points?: string; + } + + interface SVGPolylineAttributes extends SVGAttributes { + points?: string; + } + + interface SVGImageAttributes extends SVGAttributes { + x?: string | number; + y?: string | number; + width?: string | number; + height?: string | number; + preserveAspectRatio?: string; + } + + interface SVGPathAttributes extends SVGAttributes { + d?: string; + pathLength?: number; + 'path-length'?: number; + } + +} + export function setTheme(theme: string): void; diff --git a/dist/joint.js b/dist/joint.js index ff617df48..f62897f00 100644 --- a/dist/joint.js +++ b/dist/joint.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -3847,7 +3847,7 @@ V = Vectorizer = (function() { var joint = { - version: '1.2.0-beta', + version: '2.0.0', config: { // The class name prefix config is for advanced use only. @@ -6089,7 +6089,7 @@ joint.dia.Graph = Backbone.Model.extend({ var commonAncestor = joint.util.toArray(cellsAncestors.shift()).find(function(ancestor) { return cellsAncestors.every(function(cellAncestors) { - return cellAncestors.includes(ancestor) + return cellAncestors.includes(ancestor); }); }); @@ -6448,18 +6448,18 @@ joint.dia.Graph = Backbone.Model.extend({ }, // Disconnect links connected to the cell `model`. - disconnectLinks: function(model, options) { + disconnectLinks: function(model, opt) { this.getConnectedLinks(model).forEach(function(link) { - link.set(link.get('source').id === model.id ? 'source' : 'target', { x: 0, y: 0 }, options); + link.set(link.get('source').id === model.id ? 'source' : 'target', { x: 0, y: 0 }, opt); }); }, // Remove links connected to the cell `model` completely. - removeLinks: function(model, options) { + removeLinks: function(model, opt) { - joint.util.invoke(this.getConnectedLinks(model), 'remove', options); + joint.util.invoke(this.getConnectedLinks(model), 'remove', opt); }, // Find all elements at given point @@ -6489,7 +6489,7 @@ joint.dia.Graph = Backbone.Model.extend({ opt = joint.util.defaults(opt || {}, { searchBy: 'bbox' }); var bbox = element.getBBox(); - var elements = (opt.searchBy == 'bbox') + var elements = (opt.searchBy === 'bbox') ? this.findModelsInArea(bbox) : this.findModelsFromPoint(bbox[opt.searchBy]()); @@ -6528,6 +6528,8 @@ joint.dia.Graph = Backbone.Model.extend({ }); joint.util.invoke(cells, 'translate', dx, dy, opt); + + return this; }, resize: function(width, height, opt) { @@ -6567,7 +6569,7 @@ joint.dia.Graph = Backbone.Model.extend({ hasActiveBatch: function(name) { if (name) { - return this._batches[name]; + return !!this._batches[name]; } else { return joint.util.toArray(this._batches).some(function(batches) { return batches > 0; @@ -6660,10 +6662,58 @@ joint.util.wrapWith(joint.dia.Graph.prototype, ['resetCells', 'addCells', 'remov 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: util.isPlainObject, set: function(filter) { @@ -9273,13 +9323,13 @@ joint.dia.Link = joint.dia.Cell.extend({ return connectionAncestor || null; }, - // Is source, target and the link itself embedded in a given element? - isRelationshipEmbeddedIn: function(element) { + // Is source, target and the link itself embedded in a given cell? + isRelationshipEmbeddedIn: function(cell) { - var elementId = joint.util.isString(element) ? element : element.id; + var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id; var ancestor = this.getRelationshipAncestor(); - return !!ancestor && (ancestor.id === elementId || ancestor.isEmbeddedIn(elementId)); + return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId)); } }, { @@ -10392,10 +10442,10 @@ joint.dia.LinkView = joint.dia.CellView.extend({ } else if (paperOptions.linkConnectionPoint) { - var view = end === 'target' ? this.targetView : this.sourceView; - var magnet = end === 'target' ? this.targetMagnet : this.sourceMagnet; + var view = (end === 'target') ? this.targetView : this.sourceView; + var magnet = (end === 'target') ? this.targetMagnet : this.sourceMagnet; - spot = paperOptions.linkConnectionPoint(this, view, magnet, reference); + spot = paperOptions.linkConnectionPoint(this, view, magnet, reference, end); } else { @@ -10520,7 +10570,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ if (availableMagnets.length > 0) { // highlight all available magnets for (var j = 0, m = availableMagnets.length; j < m; j++) { - view.highlight(availableMagnets[j], { magnetAvailability: true }) + view.highlight(availableMagnets[j], { magnetAvailability: true }); } // highlight the entire view view.highlight(null, { elementAvailability: true }); @@ -10543,7 +10593,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ var view = this.paper.findViewByModel(id); if (view) { for (var j = 0, m = markedMagnets.length; j < m; j++) { - view.unhighlight(markedMagnets[j], { magnetAvailability: true }) + view.unhighlight(markedMagnets[j], { magnetAvailability: true }); } view.unhighlight(null, { elementAvailability: true }); } @@ -11235,6 +11285,8 @@ joint.dia.Paper = joint.mvc.View.extend({ if (this._background) { this.updateBackgroundImage(this._background); } + + return this; }, // For storing the current transformation matrix (CTM) of the paper's viewport. @@ -12494,7 +12546,7 @@ joint.dia.Paper = joint.mvc.View.extend({ options.height = gridSize * (ctm.d || 1) * (options.scaleFactor || 1); if (!refs.exist(id)) { - refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))) + refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))); } var patternDefVel = refs.get(id); @@ -17344,7 +17396,7 @@ joint.layout.DirectedGraph = { var target = cell.get('target'); // Links that end at a point are ignored. - if (!source.id || !target.id) return; + if (!source.id || !target.id) break; // Note that if we are creating a multigraph we can name the edges. If // we try to name edges on a non-multigraph an exception is thrown. diff --git a/dist/joint.layout.DirectedGraph.js b/dist/joint.layout.DirectedGraph.js index 3673c0fa9..d942f4cfc 100644 --- a/dist/joint.layout.DirectedGraph.js +++ b/dist/joint.layout.DirectedGraph.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -249,7 +249,7 @@ joint.layout.DirectedGraph = { var target = cell.get('target'); // Links that end at a point are ignored. - if (!source.id || !target.id) return; + if (!source.id || !target.id) break; // Note that if we are creating a multigraph we can name the edges. If // we try to name edges on a non-multigraph an exception is thrown. diff --git a/dist/joint.layout.DirectedGraph.min.js b/dist/joint.layout.DirectedGraph.min.js index 8abf91807..a5ed04a06 100644 --- a/dist/joint.layout.DirectedGraph.min.js +++ b/dist/joint.layout.DirectedGraph.min.js @@ -1,8 +1,8 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -if("object"==typeof exports)var graphlib=require("graphlib"),dagre=require("dagre");graphlib=graphlib||"undefined"!=typeof window&&window.graphlib,dagre=dagre||"undefined"!=typeof window&&window.dagre,joint.layout.DirectedGraph={exportElement:function(a){return a.size()},exportLink:function(a){var b=a.get("labelSize")||{},c={minLen:a.get("minLen")||1,weight:a.get("weight")||1,labelpos:a.get("labelPosition")||"c",labeloffset:a.get("labelOffset")||0,width:b.width||0,height:b.height||0};return c},importElement:function(a,b,c){var d=this.getCell(b),e=c.node(b);a.setPosition?a.setPosition(d,e):d.set("position",{x:e.x-e.width/2,y:e.y-e.height/2})},importLink:function(a,b,c){var d=this.getCell(b.name),e=c.edge(b),f=e.points||[];if((a.setVertices||a.setLinkVertices)&&(joint.util.isFunction(a.setVertices)?a.setVertices(d,f):d.set("vertices",f.slice(1,f.length-1))),a.setLabels&&"x"in e&&"y"in e){var h={x:e.x,y:e.y};if(joint.util.isFunction(a.setLabels))a.setLabels(d,h,f);else{var i=g.Polyline(f),j=i.closestPointLength(h),k=i.pointAtLength(j),l=j/i.length();d.label(0,{position:{distance:l,offset:g.Point(h).difference(k).toJSON()}})}}},layout:function(a,b){var c;c=a instanceof joint.dia.Graph?a:(new joint.dia.Graph).resetCells(a,{dry:!0}),a=null,b=joint.util.defaults(b||{},{resizeClusters:!0,clusterPadding:10,exportElement:this.exportElement,exportLink:this.exportLink});var d=c.toGraphLib({directed:!0,multigraph:!0,compound:!0,setNodeLabel:b.exportElement,setEdgeLabel:b.exportLink,setEdgeName:function(a){return a.id}}),e={},f=b.marginX||0,h=b.marginY||0;if(b.rankDir&&(e.rankdir=b.rankDir),b.align&&(e.align=b.align),b.nodeSep&&(e.nodesep=b.nodeSep),b.edgeSep&&(e.edgesep=b.edgeSep),b.rankSep&&(e.ranksep=b.rankSep),b.ranker&&(e.ranker=b.ranker),f&&(e.marginx=f),h&&(e.marginy=h),d.setGraph(e),dagre.layout(d,{debugTiming:!!b.debugTiming}),c.startBatch("layout"),c.fromGraphLib(d,{importNode:this.importElement.bind(c,b),importEdge:this.importLink.bind(c,b)}),b.resizeClusters){var i=d.nodes().filter(function(a){return d.children(a).length>0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i>8-g%1*8)){if(e=f.charCodeAt(g+=.75),e>255)throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");d=d<<8|e}return i}),b.atob||(b.atob=function(b){var d=String(b).replace(/=+$/,"");if(d.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,f,g=0,h=0,i="";f=d.charAt(h++);~f&&(e=g%4?64*e+f:f,g++%4)?i+=String.fromCharCode(255&e>>(-2*g&6)):0)f=c.indexOf(f);return i})}(),function(){function a(a,b){return this.slice(a,b)}function b(a,b){arguments.length<2&&(b=0);for(var c=0,d=a.length;c>>0;if(0===e)return!1;for(var f=0|b,g=Math.max(f>=0?f:e-Math.abs(f),0);g>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;e0?1:-1)*Math.floor(Math.abs(b)):b},d=Math.pow(2,53)-1,e=function(a){var b=c(a);return Math.min(Math.max(b,0),d)};return function(a){var c=this,d=Object(a);if(null==a)throw new TypeError("Array.from requires an array-like object - not null or undefined");var f,g=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof g){if(!b(g))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(f=arguments[2])}for(var h,i=e(d.length),j=b(c)?Object(new c(i)):new Array(i),k=0;k>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;ethis.length)&&this.indexOf(a,b)!==-1}),String.prototype.startsWith||(String.prototype.startsWith=function(a,b){return this.substr(b||0,a.length)===a}),Number.isFinite=Number.isFinite||function(a){return"number"==typeof a&&isFinite(a)},Number.isNaN=Number.isNaN||function(a){return a!==a}; var g=function(){var a={},b=Math,c=b.abs,d=b.cos,e=b.sin,f=b.sqrt,g=b.min,h=b.max,i=b.atan2,j=b.round,k=b.floor,l=b.PI,m=b.random,n=b.pow;a.bezier={curveThroughPoints:function(a){for(var b=this.getCurveControlPoints(a),c=["M",a[0].x,a[0].y],d=0;dj.x+h/2,n=fj.x?g-e:g+e,d=h*h/(f-k)-h*h*(g-l)*(c-l)/(i*i*(f-k))+k):(d=g>j.y?f+e:f-e,c=i*i/(g-l)-i*i*(f-k)*(d-k)/(h*h*(g-l))+l),a.point(d,c).theta(b)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a),b&&a.rotate(q(this.x,this.y),b);var c,d=a.x-this.x,e=a.y-this.y;if(0===d)return c=this.bbox().pointNearestToPoint(a),b?c.rotate(q(this.x,this.y),-b):c;var g=e/d,h=g*g,i=this.a*this.a,j=this.b*this.b,k=f(1/(1/i+h/j));k=d<0?-k:k;var l=g*k;return c=q(this.x+k,this.y+l),b?c.rotate(q(this.x,this.y),-b):c},toString:function(){return q(this.x,this.y).toString()+" "+this.a+" "+this.b}};var p=a.Line=function(a,b){return this instanceof p?a instanceof p?p(a.start,a.end):(this.start=q(a),void(this.end=q(b))):new p(a,b)};a.Line.prototype={bearing:function(){var a=w(this.start.y),b=w(this.end.y),c=this.start.x,f=this.end.x,g=w(f-c),h=e(g)*d(b),j=d(a)*e(b)-e(a)*d(b)*d(g),k=v(i(h,j)),l=["NE","E","SE","S","SW","W","NW","N"],m=k-22.5;return m<0&&(m+=360),m=parseInt(m/45),l[m]},clone:function(){return p(this.start,this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.end.x===a.end.x&&this.end.y===a.end.y},intersect:function(a){if(a instanceof p){var b=q(this.end.x-this.start.x,this.end.y-this.start.y),c=q(a.end.x-a.start.x,a.end.y-a.start.y),d=b.x*c.y-b.y*c.x,e=q(a.start.x-this.start.x,a.start.y-this.start.y),f=e.x*c.y-e.y*c.x,g=e.x*b.y-e.y*b.x;if(0===d||f*d<0||g*d<0)return null;if(d>0){if(f>d||g>d)return null}else if(f0?l:null}return null},length:function(){return f(this.squaredLength())},midpoint:function(){return q((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},pointAt:function(a){var b=(1-a)*this.start.x+a*this.end.x,c=(1-a)*this.start.y+a*this.end.y;return q(b,c)},pointOffset:function(a){return((this.end.x-this.start.x)*(a.y-this.start.y)-(this.end.y-this.start.y)*(a.x-this.start.x))/2},vector:function(){return q(this.end.x-this.start.x,this.end.y-this.start.y)},closestPoint:function(a){return this.pointAt(this.closestPointNormalizedLength(a))},closestPointNormalizedLength:function(a){var b=this.vector().dot(p(this.start,a).vector());return Math.min(1,Math.max(0,b/this.squaredLength()))},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},toString:function(){return this.start.toString()+" "+this.end.toString()}},a.Line.prototype.intersection=a.Line.prototype.intersect;var q=a.Point=function(a,b){if(!(this instanceof q))return new q(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseInt(c[0],10),b=parseInt(c[1],10)}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};a.Point.fromPolar=function(a,b,f){f=f&&q(f)||q(0,0);var g=c(a*d(b)),h=c(a*e(b)),i=t(v(b));return i<90?h=-h:i<180?(g=-g,h=-h):i<270&&(g=-g),q(f.x+g,f.y+h)},a.Point.random=function(a,b,c,d){return q(k(m()*(b-a+1)+a),k(m()*(d-c+1)+c))},a.Point.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=g(h(this.x,a.x),a.x+a.width),this.y=g(h(this.y,a.y),a.y+a.height),this)},bearing:function(a){return p(this,a).bearing()},changeInAngle:function(a,b,c){return q(this).offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return q(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),q(this.x-(a||0),this.y-(b||0))},distance:function(a){return p(this,a).length()},squaredDistance:function(a){return p(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return f(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return c(a.x-this.x)+c(a.y-this.y)},move:function(a,b){var c=w(q(a).theta(this));return this.offset(d(c)*b,-e(c)*b)},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 q(a).move(this,this.distance(a))},rotate:function(a,b){b=(b+360)%360,this.toPolar(a),this.y+=w(b);var c=q.fromPolar(this.x,this.y,a);return this.x=c.x,this.y=c.y,this},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this},scale:function(a,b,c){return c=c&&q(c)||q(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=u(this.x,a),this.y=u(this.y,b||a),this},theta:function(a){a=q(a);var b=-(a.y-this.y),c=a.x-this.x,d=i(b,c);return d<0&&(d=2*l+d),180*d/l},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=q(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&q(a)||q(0,0);var b=this.x,c=this.y;return this.x=f((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=w(a.theta(q(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}};var r=a.Rect=function(a,b,c,d){return this instanceof r?(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 r(a,b,c,d)};a.Rect.fromEllipse=function(a){return a=o(a),r(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},a.Rect.prototype={bbox:function(a){var b=w(a||0),f=c(e(b)),g=c(d(b)),h=this.width*g+this.height*f,i=this.width*f+this.height*g;return r(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return q(this.x,this.y+this.height)},bottomLine:function(){return p(this.bottomLeft(),this.corner())},bottomMiddle:function(){return q(this.x+this.width/2,this.y+this.height)},center:function(){return q(this.x+this.width/2,this.y+this.height/2)},clone:function(){return r(this)},containsPoint:function(a){return a=q(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=r(this).normalize(),c=r(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 q(this.x+this.width,this.y+this.height)},equals:function(a){var b=r(this).normalize(),c=r(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=Math.max(b.x,d.x),g=Math.max(b.y,d.y);return r(f,g,Math.min(c.x,e.x)-f,Math.min(c.y,e.y)-g)},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a);var c,d=q(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[p(this.origin(),this.topRight()),p(this.topRight(),this.corner()),p(this.corner(),this.bottomLeft()),p(this.bottomLeft(),this.origin())],f=p(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 p(this.origin(),this.bottomLeft())},leftMiddle:function(){return q(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 q.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 q(this.x,this.y)},pointNearestToPoint:function(a){if(a=q(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return q(this.x+this.width,a.y);case"left":return q(this.x,a.y);case"bottom":return q(a.x,this.y+this.height);case"top":return q(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return p(this.topRight(),this.corner())},rightMiddle:function(){return q(this.x+this.width,this.y+this.height/2)},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this.width=j(this.width*b)/b,this.height=j(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(b,c){b=a.Rect(b),c||(c=b.center());var d,e,f,g,h,i,j,k,l=c.x,m=c.y;d=e=f=g=h=i=j=k=1/0;var n=b.origin();n.xl&&(e=(this.x+this.width-l)/(o.x-l)),o.y>m&&(i=(this.y+this.height-m)/(o.y-m));var p=b.topRight();p.x>l&&(f=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:Math.min(d,e,f,g),sy:Math.min(h,i,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return Math.min(c.sx,c.sy)},sideNearestToPoint:function(a){a=q(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 cc.x&&(c=d[a]);var e=[];for(b=d.length,a=0;a2){var h=e[e.length-1];e.unshift(h)}for(var i,j,k,l,m,n,o={},p=[];0!==e.length;)if(i=e.pop(),j=i[0],!o.hasOwnProperty(i[0]+"@@"+i[1]))for(var q=!1;!q;)if(p.length<2)p.push(i),q=!0;else{k=p.pop(),l=k[0],m=p.pop(),n=m[0];var r=n.cross(l,j);if(r<0)p.push(m),p.push(k),p.push(i),q=!0;else if(0===r){var t=1e-10,u=l.angleBetween(n,j);Math.abs(u-180)2&&p.pop();var v,w=-1;for(b=p.length,a=0;a0){var z=p.slice(w),A=p.slice(0,w);y=z.concat(A)}else y=p;var B=[];for(b=y.length,a=0;a1){var g,h,i=[];for(g=0,h=f.childNodes.length;gu&&(u=z),c=d("tspan",y.attrs),b.includeAnnotationIndices&&c.attr("annotations",y.annotations),y.attrs.class&&c.addClass(y.attrs.class),e&&x===w&&p!==s&&(y.t+=e),c.node.textContent=y.t}else e&&x===w&&p!==s&&(y+=e),c=document.createTextNode(y||" ");r.append(c)}"auto"===b.lineHeight&&u&&0!==p&&r.attr("dy",1.2*u+"px")}else e&&p!==s&&(t+=e),r.node.textContent=t;0===p&&(o=u)}else r.addClass("v-empty-line"),r.node.style.fillOpacity=0,r.node.style.strokeOpacity=0,r.node.textContent="-";d(g).append(r),l+=t.length+1}var A=this.attr("y");return null===A&&this.attr("y",o||"0.8em"),this},d.prototype.removeAttr=function(a){var b=d.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},d.prototype.attr=function(a,b){if(d.isUndefined(a)){for(var c=this.node.attributes,e={},f=0;f'+(a||"")+"",f=d.parseXML(e,{async:!1});return f.documentElement},d.idCounter=0,d.uniqueId=function(){return"v-"+ ++d.idCounter},d.toNode=function(a){return d.isV(a)?a.node:a.nodeName&&a||a[0]},d.ensureId=function(a){return a=d.toNode(a),a.id||(a.id=d.uniqueId())},d.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},d.isUndefined=function(a){return"undefined"==typeof a},d.isString=function(a){return"string"==typeof a},d.isObject=function(a){return a&&"object"==typeof a},d.isArray=Array.isArray,d.parseXML=function(a,b){b=b||{};var c;try{var e=new DOMParser;d.isUndefined(b.async)||(e.async=b.async),c=e.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},d.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var c=a.split(":");return{ns:b[c[0]],local:c[1]}}return{ns:null,local:a}},d.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,d.transformSeparatorRegex=/[ ,]+/,d.transformationListRegex=/^(\w+)\((.*)\)/,d.transformStringToMatrix=function(a){var b=d.createSVGMatrix(),c=a&&a.match(d.transformRegex);if(!c)return b;for(var e=0,f=c.length;e=0){var g=d.transformStringToMatrix(a),h=d.decomposeMatrix(g);b=[h.translateX,h.translateY],e=[h.scaleX,h.scaleY],c=[h.rotation];var i=[];0===b[0]&&0===b[0]||i.push("translate("+b+")"),1===e[0]&&1===e[1]||i.push("scale("+e+")"),0!==c[0]&&i.push("rotate("+c+")"),a=i.join(" ")}else{var j=a.match(/translate\((.*?)\)/);j&&(b=j[1].split(f));var k=a.match(/rotate\((.*?)\)/);k&&(c=k[1].split(f));var l=a.match(/scale\((.*?)\)/);l&&(e=l[1].split(f))}}var m=e&&e[0]?parseFloat(e[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:m,sy:e&&e[1]?parseFloat(e[1]):m}}},d.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}},d.decomposeMatrix=function(a){var b=d.deltaTransformPoint(a,{x:0,y:1}),c=d.deltaTransformPoint(a,{x:1,y:0}),e=180/Math.PI*Math.atan2(b.y,b.x)-90,f=180/Math.PI*Math.atan2(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:Math.sqrt(a.a*a.a+a.b*a.b),scaleY:Math.sqrt(a.c*a.c+a.d*a.d),skewX:e,skewY:f,rotation:e}},d.matrixToScale=function(a){var b,c,e,f;return a?(b=d.isUndefined(a.a)?1:a.a,f=d.isUndefined(a.d)?1:a.d,c=a.b,e=a.c):b=f=1,{sx:c?Math.sqrt(b*b+c*c):b,sy:e?Math.sqrt(e*e+f*f):f}},d.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=d.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(Math.atan2(b.y,b.x))-90)}},d.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},d.isV=function(a){return a instanceof d},d.isVElement=d.isV;var e=d("svg").node;return d.createSVGMatrix=function(a){var b=e.createSVGMatrix();for(var c in a)b[c]=a[c];return b},d.createSVGTransform=function(a){return d.isUndefined(a)?e.createSVGTransform():(a instanceof SVGMatrix||(a=d.createSVGMatrix(a)),e.createSVGTransformFromMatrix(a))},d.createSVGPoint=function(a,b){var c=e.createSVGPoint();return c.x=a,c.y=b,c},d.transformRect=function(a,b){var c=e.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 f=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var h=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var i=c.matrixTransform(b),j=Math.min(d.x,f.x,h.x,i.x),k=Math.max(d.x,f.x,h.x,i.x),l=Math.min(d.y,f.y,h.y,i.y),m=Math.max(d.y,f.y,h.y,i.y);return g.Rect(j,l,k-j,m-l)},d.transformPoint=function(a,b){return g.Point(d.createSVGPoint(a.x,a.y).matrixTransform(b))},d.styleToObject=function(a){for(var b={},c=a.split(";"),d=0;d=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*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L"+f*n+","+f*o+"A"+f+","+f+" 0 "+k+",0 "+f*l+","+f*m+"Z":"M"+g*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L0,0Z"},d.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?d.isObject(a[c])&&d.isObject(b[c])?a[c]=d.mergeAttrs(a[c],b[c]):d.isObject(a[c])?a[c]=d.mergeAttrs(a[c],d.styleToObject(b[c])):d.isObject(b[c])?a[c]=d.mergeAttrs(d.styleToObject(a[c]),b[c]):a[c]=d.mergeAttrs(d.styleToObject(a[c]),d.styleToObject(b[c])):a[c]=b[c];return a},d.annotateString=function(a,b,c){b=b||[],c=c||{};for(var e,f,g,h=c.offset||0,i=[],j=[],k=0;k=n&&k=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},d.convertLineToPathData=function(a){a=d(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},d.convertPolygonToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b)+" Z":null},d.convertPolylineToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b):null},d.svgPointsToPath=function(a){var b;for(b=0;b0){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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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()});joint.util.invoke(d,"translate",a,b,c)},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 a?this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xmlSpace:{set:"xml:space"},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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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(){this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background)},_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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; +var joint={version:"2.0.0",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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 a?!!this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){ +var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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))}},{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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e,a)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; joint.dia.Element.define("erd.Entity",{size:{width:150,height:60},attrs:{".outer":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"100,0 100,60 0,60 0,0"},".inner":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"95,5 95,55 5,55 5,5",display:"none"},text:{text:"Entity","font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Entity.define("erd.WeakEntity",{attrs:{".inner":{display:"auto"},text:{text:"Weak Entity"}}}),joint.dia.Element.define("erd.Relationship",{size:{width:80,height:80},attrs:{".outer":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,0 80,40 40,80 0,40"},".inner":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,5 75,40 40,75 5,40",display:"none"},text:{text:"Relationship","font-family":"Arial","font-size":12,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Relationship.define("erd.IdentifyingRelationship",{attrs:{".inner":{display:"auto"},text:{text:"Identifying"}}}),joint.dia.Element.define("erd.Attribute",{size:{width:100,height:50},attrs:{ellipse:{transform:"translate(50, 25)"},".outer":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:50,ry:25,fill:"#E67E22"},".inner":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:45,ry:20,fill:"#E67E22",display:"none"},text:{"font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Attribute.define("erd.Multivalued",{attrs:{".inner":{display:"block"},text:{text:"multivalued"}}}),joint.shapes.erd.Attribute.define("erd.Derived",{attrs:{".outer":{"stroke-dasharray":"3,5"},text:{text:"derived"}}}),joint.shapes.erd.Attribute.define("erd.Key",{attrs:{ellipse:{"stroke-width":4},text:{text:"key","font-weight":"800","text-decoration":"underline"}}}),joint.shapes.erd.Attribute.define("erd.Normal",{attrs:{text:{text:"Normal"}}}),joint.dia.Element.define("erd.ISA",{type:"erd.ISA",size:{width:100,height:50},attrs:{polygon:{points:"0,0 50,50 100,0",fill:"#F1C40F",stroke:"#F39C12","stroke-width":2},text:{text:"ISA","font-size":18,"ref-x":.5,"ref-y":.3,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.dia.Link.define("erd.Line",{},{cardinality:function(a){this.set("labels",[{position:-20,attrs:{text:{dy:-8,text:a}}}])}}); joint.shapes.basic.Circle.define("fsa.State",{attrs:{circle:{"stroke-width":3},text:{"font-weight":"800"}}}),joint.dia.Element.define("fsa.StartState",{size:{width:20,height:20},attrs:{circle:{transform:"translate(10, 10)",r:10,fill:"#000000"}}},{markup:''}),joint.dia.Element.define("fsa.EndState",{size:{width:20,height:20},attrs:{".outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#000000"},".inner":{transform:"translate(10, 10)",r:6,fill:"#000000"}}},{markup:''}),joint.dia.Link.define("fsa.Arrow",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z"}},smooth:!0}); joint.dia.Element.define("org.Member",{size:{width:180,height:70},attrs:{rect:{width:170,height:60},".card":{fill:"#FFFFFF",stroke:"#000000","stroke-width":2,"pointer-events":"visiblePainted",rx:10,ry:10},image:{width:48,height:48,ref:".card","ref-x":10,"ref-y":5},".rank":{"text-decoration":"underline",ref:".card","ref-x":.9,"ref-y":.2,"font-family":"Courier New","font-size":14,"text-anchor":"end"},".name":{"font-weight":"800",ref:".card","ref-x":.9,"ref-y":.6,"font-family":"Courier New","font-size":14,"text-anchor":"end"}}},{markup:''}),joint.dia.Link.define("org.Arrow",{source:{selector:".card"},target:{selector:".card"},attrs:{".connection":{stroke:"#585858","stroke-width":3}},z:-1}); @@ -60,7 +60,7 @@ joint.shapes.basic.Generic.define("devs.Model",{inPorts:[],outPorts:[],size:{wid joint.shapes.basic.Generic.define("uml.Class",{attrs:{rect:{width:200},".uml-class-name-rect":{stroke:"black","stroke-width":2,fill:"#3498db"},".uml-class-attrs-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-methods-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-name-text":{ref:".uml-class-name-rect","ref-y":.5,"ref-x":.5,"text-anchor":"middle","y-alignment":"middle","font-weight":"bold",fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-attrs-text":{ref:".uml-class-attrs-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-methods-text":{ref:".uml-class-methods-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"}},name:[],attributes:[],methods:[]},{markup:['','','',"",'',""].join(""),initialize:function(){this.on("change:name change:attributes change:methods",function(){this.updateRectangles(),this.trigger("uml-update")},this),this.updateRectangles(),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},getClassName:function(){return this.get("name")},updateRectangles:function(){var a=this.get("attrs"),b=[{type:"name",text:this.getClassName()},{type:"attrs",text:this.get("attributes")},{type:"methods",text:this.get("methods")}],c=0;b.forEach(function(b){var d=Array.isArray(b.text)?b.text:[b.text],e=20*d.length+20;a[".uml-class-"+b.type+"-text"].text=d.join("\n"),a[".uml-class-"+b.type+"-rect"].height=e,a[".uml-class-"+b.type+"-rect"].transform="translate(0,"+c+")",c+=e})}}),joint.shapes.uml.ClassView=joint.dia.ElementView.extend({},{initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"uml-update",function(){this.update(),this.resize()})}}),joint.shapes.uml.Class.define("uml.Abstract",{attrs:{".uml-class-name-rect":{fill:"#e74c3c"},".uml-class-attrs-rect":{fill:"#c0392b"},".uml-class-methods-rect":{fill:"#c0392b"}}},{getClassName:function(){return["<>",this.get("name")]}}),joint.shapes.uml.AbstractView=joint.shapes.uml.ClassView,joint.shapes.uml.Class.define("uml.Interface",{attrs:{".uml-class-name-rect":{fill:"#f1c40f"},".uml-class-attrs-rect":{fill:"#f39c12"},".uml-class-methods-rect":{fill:"#f39c12"}}},{getClassName:function(){return["<>",this.get("name")]}}),joint.shapes.uml.InterfaceView=joint.shapes.uml.ClassView,joint.dia.Link.define("uml.Generalization",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"}}}),joint.dia.Link.define("uml.Implementation",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"},".connection":{"stroke-dasharray":"3,3"}}}),joint.dia.Link.define("uml.Aggregation",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"white"}}}),joint.dia.Link.define("uml.Composition",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"black"}}}),joint.dia.Link.define("uml.Association"),joint.shapes.basic.Generic.define("uml.State",{attrs:{".uml-state-body":{width:200,height:200,rx:10,ry:10,fill:"#ecf0f1",stroke:"#bdc3c7","stroke-width":3},".uml-state-separator":{stroke:"#bdc3c7","stroke-width":2},".uml-state-name":{ref:".uml-state-body","ref-x":.5,"ref-y":5,"text-anchor":"middle",fill:"#000000","font-family":"Courier New","font-size":14},".uml-state-events":{ref:".uml-state-separator","ref-x":5,"ref-y":5,fill:"#000000","font-family":"Courier New","font-size":14}},name:"State",events:[]},{markup:['','','',"",'','','',""].join(""),initialize:function(){this.on({"change:name":this.updateName,"change:events":this.updateEvents,"change:size":this.updatePath},this),this.updateName(),this.updateEvents(),this.updatePath(),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},updateName:function(){this.attr(".uml-state-name/text",this.get("name"))},updateEvents:function(){this.attr(".uml-state-events/text",this.get("events").join("\n"))},updatePath:function(){var a="M 0 20 L "+this.get("size").width+" 20";this.attr(".uml-state-separator/d",a,{silent:!0})}}),joint.shapes.basic.Circle.define("uml.StartState",{type:"uml.StartState",attrs:{circle:{fill:"#34495e",stroke:"#2c3e50","stroke-width":2,rx:1}}}),joint.shapes.basic.Generic.define("uml.EndState",{size:{width:20,height:20},attrs:{"circle.outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#2c3e50"},"circle.inner":{transform:"translate(10, 10)",r:6,fill:"#34495e"}}},{markup:''}),joint.dia.Link.define("uml.Transition",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z",fill:"#34495e",stroke:"#2c3e50"},".connection":{stroke:"#2c3e50"}}}); joint.shapes.basic.Generic.define("logic.Gate",{size:{width:80,height:40},attrs:{".":{magnet:!1},".body":{width:100,height:50},circle:{r:7,stroke:"black",fill:"transparent","stroke-width":2}}},{operation:function(){return!0}}),joint.shapes.logic.Gate.define("logic.IO",{size:{width:60,height:30},attrs:{".body":{fill:"white",stroke:"black","stroke-width":2},".wire":{ref:".body","ref-y":.5,stroke:"black"},text:{fill:"black",ref:".body","ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle","font-weight":"bold","font-variant":"small-caps","text-transform":"capitalize","font-size":"14px"}}},{markup:''}),joint.shapes.logic.IO.define("logic.Input",{attrs:{".wire":{"ref-dx":0,d:"M 0 0 L 23 0"},circle:{ref:".body","ref-dx":30,"ref-y":.5,magnet:!0,class:"output",port:"out"},text:{text:"input"}}}),joint.shapes.logic.IO.define("logic.Output",{attrs:{".wire":{"ref-x":0,d:"M 0 0 L -23 0"},circle:{ref:".body","ref-x":-30,"ref-y":.5,magnet:"passive",class:"input",port:"in"},text:{text:"output"}}}),joint.shapes.logic.Gate.define("logic.Gate11",{attrs:{".input":{ref:".body","ref-x":-2,"ref-y":.5,magnet:"passive",port:"in"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:''}),joint.shapes.logic.Gate.define("logic.Gate21",{attrs:{".input1":{ref:".body","ref-x":-2,"ref-y":.3,magnet:"passive",port:"in1"},".input2":{ref:".body","ref-x":-2,"ref-y":.7,magnet:"passive",port:"in2"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:''}),joint.shapes.logic.Gate11.define("logic.Repeater",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdm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Y2N1bXVsYXRlIgogICAgICAgZD0iTSAyOC45Njg3NSwyLjU5Mzc1IEwgMjguOTY4NzUsNSBMIDI4Ljk2ODc1LDQ1IEwgMjguOTY4NzUsNDcuNDA2MjUgTCAzMS4xMjUsNDYuMzQzNzUgTCA3Mi4xNTYyNSwyNi4zNDM3NSBMIDcyLjE1NjI1LDIzLjY1NjI1IEwgMzEuMTI1LDMuNjU2MjUgTCAyOC45Njg3NSwyLjU5Mzc1IHogTSAzMS45Njg3NSw3LjQwNjI1IEwgNjguMDkzNzUsMjUgTCAzMS45Njg3NSw0Mi41OTM3NSBMIDMxLjk2ODc1LDcuNDA2MjUgeiIKICAgICAgIGlkPSJwYXRoMjYzOCIKICAgICAgIHNvZGlwb2RpOm5vZGV0eXBlcz0iY2NjY2NjY2NjY2NjYyIgLz4KICA8L2c+Cjwvc3ZnPgo="}}},{operation:function(a){return a}}),joint.shapes.logic.Gate11.define("logic.Not",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9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4Ljk2ODc1LDQ1IEwgMjguOTY4NzUsNDcuNDA2MjUgTCAzMS4xMjUsNDYuMzQzNzUgTCA3Mi4xNTYyNSwyNi4zNDM3NSBMIDcyLjE1NjI1LDIzLjY1NjI1IEwgMzEuMTI1LDMuNjU2MjUgTCAyOC45Njg3NSwyLjU5Mzc1IHogTSAzMS45Njg3NSw3LjQwNjI1IEwgNjguMDkzNzUsMjUgTCAzMS45Njg3NSw0Mi41OTM3NSBMIDMxLjk2ODc1LDcuNDA2MjUgeiIKICAgICAgIGlkPSJwYXRoMjYzOCIKICAgICAgIHNvZGlwb2RpOm5vZGV0eXBlcz0iY2NjY2NjY2NjY2NjYyIgLz4KICAgIDxwYXRoCiAgICAgICBzb2RpcG9kaTp0eXBlPSJhcmMiCiAgICAgICBzdHlsZT0iZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDozO3N0cm9rZS1saW5lam9pbjptaXRlcjttYXJrZXI6bm9uZTtzdHJva2Utb3BhY2l0eToxO3Zpc2liaWxpdHk6dmlzaWJsZTtkaXNwbGF5OmlubGluZTtvdmVyZmxvdzp2aXNpYmxlO2VuYWJsZS1iYWNrZ3JvdW5kOmFjY3VtdWxhdGUiCiAgICAgICBpZD0icGF0aDI2NzEiCiAgICAgICBzb2RpcG9kaTpjeD0iNzYiCiAgICAgICBzb2RpcG9kaTpjeT0iMjUiCiAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgIHNvZGlwb2RpOnJ5PSI0IgogICAgICAgZD0iTSA4MCwyNSBBIDQsNCAwIDEgMSA3MiwyNSBBIDQsNCAwIDEgMSA4MCwyNSB6IgogICAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTEsMCkiIC8+CiAgPC9nPgo8L3N2Zz4K"}}},{operation:function(a){return!a}}),joint.shapes.logic.Gate21.define("logic.Or",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj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uODU3MTQyOSBDIDUwLjMyNzM4MSw3Ljg1NzE0MjkgNTAuNDA5MjI3LDcuODU3MTQyOSA1MC40NDY0MjksNy44NTcxNDI5IEMgNTAuNDY1MDI5LDcuODU3MTQyOSA1MC40NzE1NDMsNy44NTcxNDI5IDUwLjQ3NjE5LDcuODU3MTQyOSBDIDYwLjIzNjg1Myw3Ljg1NzE0MyA2Ny4xNDI4NTcsMTUuNDk3MDk4IDY3LjE0Mjg1NywyNSBDIDY3LjE0Mjg1NywzNC41MDI5MDIgNTkuNzYwNjYyLDQyLjE0Mjg1NyA1MCw0Mi4xNDI4NTcgTCAzMi44NTcxNDMsNDIuMTQyODU3IEwgMzIuODU3MTQzLDcuODU3MTQyOSB6IgogICAgICAgaWQ9InBhdGgyODg0IgogICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJjY2NjY2NzY2NjY3Nzc3NzY2NjIiAvPgogIDwvZz4KPC9zdmc+Cg=="}}},{operation:function(a,b){return a&&b}}),joint.shapes.logic.Gate21.define("logic.Nor",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb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IEwgMy41LDgxLjUgQyA1LjM3MzU4ODQsNzguMzkxNTY2IDguMjUsNzIuNDUwNjUgOC4yNSw2NC41IEMgOC4yNSw1Ni41MjY2NDYgNS4zNDE0Njg2LDUwLjU5OTgxNSAzLjQ2ODc1LDQ3LjUgeiIKICAgICAgICAgaWQ9InBhdGg0OTczIgogICAgICAgICBzb2RpcG9kaTpub2RldHlwZXM9ImNjc2NjY2NzY2NjY2NjY2Njc2Njc2MiIC8+CiAgICAgIDxwYXRoCiAgICAgICAgIHNvZGlwb2RpOnR5cGU9ImFyYyIKICAgICAgICAgc3R5bGU9ImZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MztzdHJva2UtbGluZWpvaW46bWl0ZXI7bWFya2VyOm5vbmU7c3Ryb2tlLW9wYWNpdHk6MTt2aXNpYmlsaXR5OnZpc2libGU7ZGlzcGxheTppbmxpbmU7b3ZlcmZsb3c6dmlzaWJsZTtlbmFibGUtYmFja2dyb3VuZDphY2N1bXVsYXRlIgogICAgICAgICBpZD0icGF0aDI2MDQiCiAgICAgICAgIHNvZGlwb2RpOmN4PSI3NSIKICAgICAgICAgc29kaXBvZGk6Y3k9IjI1IgogICAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgICAgc29kaXBvZGk6cnk9IjQiCiAgICAgICAgIGQ9Ik0gNzksMjUgQSA0LDQgMCAxIDEgNzEsMjUgQSA0LDQgMCAxIDEgNzksMjUgeiIKICAgICAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI2LjUsMzkuNSkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K" }}},{operation:function(a,b){return!(a||b)}}),joint.shapes.logic.Gate21.define("logic.Nand",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ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0iMjUiCiAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgIHNvZGlwb2RpOnJ5PSI0IgogICAgICAgZD0iTSA3OSwyNSBBIDQsNCAwIDEgMSA3MSwyNSBBIDQsNCAwIDEgMSA3OSwyNSB6IiAvPgogIDwvZz4KPC9zdmc+Cg=="}}},{operation:function(a,b){return!(a&&b)}}),joint.shapes.logic.Gate21.define("logic.Xor",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0iNTAiCiAgIGlkPSJzdmcyIgogICBzb2RpcG9kaTp2ZXJzaW9uPSIwLjMyIgogICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjQ2IgogICB2ZXJzaW9uPSIxLjAiCiAgIHNvZGlwb2RpOm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||b)}}),joint.dia.Link.define("logic.Wire",{attrs:{".connection":{"stroke-width":2},".marker-vertex":{r:7}},router:{name:"orthogonal"},connector:{name:"rounded",args:{radius:10}}},{arrowheadMarkup:['','',""].join(""),vertexMarkup:['','','','','',"Remove vertex.","","",""].join("")}); -if("object"==typeof exports)var graphlib=require("graphlib"),dagre=require("dagre");graphlib=graphlib||"undefined"!=typeof window&&window.graphlib,dagre=dagre||"undefined"!=typeof window&&window.dagre,joint.layout.DirectedGraph={exportElement:function(a){return a.size()},exportLink:function(a){var b=a.get("labelSize")||{},c={minLen:a.get("minLen")||1,weight:a.get("weight")||1,labelpos:a.get("labelPosition")||"c",labeloffset:a.get("labelOffset")||0,width:b.width||0,height:b.height||0};return c},importElement:function(a,b,c){var d=this.getCell(b),e=c.node(b);a.setPosition?a.setPosition(d,e):d.set("position",{x:e.x-e.width/2,y:e.y-e.height/2})},importLink:function(a,b,c){var d=this.getCell(b.name),e=c.edge(b),f=e.points||[];if((a.setVertices||a.setLinkVertices)&&(joint.util.isFunction(a.setVertices)?a.setVertices(d,f):d.set("vertices",f.slice(1,f.length-1))),a.setLabels&&"x"in e&&"y"in e){var h={x:e.x,y:e.y};if(joint.util.isFunction(a.setLabels))a.setLabels(d,h,f);else{var i=g.Polyline(f),j=i.closestPointLength(h),k=i.pointAtLength(j),l=j/i.length();d.label(0,{position:{distance:l,offset:g.Point(h).difference(k).toJSON()}})}}},layout:function(a,b){var c;c=a instanceof joint.dia.Graph?a:(new joint.dia.Graph).resetCells(a,{dry:!0}),a=null,b=joint.util.defaults(b||{},{resizeClusters:!0,clusterPadding:10,exportElement:this.exportElement,exportLink:this.exportLink});var d=c.toGraphLib({directed:!0,multigraph:!0,compound:!0,setNodeLabel:b.exportElement,setEdgeLabel:b.exportLink,setEdgeName:function(a){return a.id}}),e={},f=b.marginX||0,h=b.marginY||0;if(b.rankDir&&(e.rankdir=b.rankDir),b.align&&(e.align=b.align),b.nodeSep&&(e.nodesep=b.nodeSep),b.edgeSep&&(e.edgesep=b.edgeSep),b.rankSep&&(e.ranksep=b.rankSep),b.ranker&&(e.ranker=b.ranker),f&&(e.marginx=f),h&&(e.marginy=h),d.setGraph(e),dagre.layout(d,{debugTiming:!!b.debugTiming}),c.startBatch("layout"),c.fromGraphLib(d,{importNode:this.importElement.bind(c,b),importEdge:this.importLink.bind(c,b)}),b.resizeClusters){var i=d.nodes().filter(function(a){return d.children(a).length>0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i 0; @@ -6622,10 +6624,58 @@ joint.util.wrapWith(joint.dia.Graph.prototype, ['resetCells', 'addCells', 'remov 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: util.isPlainObject, set: function(filter) { @@ -9235,13 +9285,13 @@ joint.dia.Link = joint.dia.Cell.extend({ return connectionAncestor || null; }, - // Is source, target and the link itself embedded in a given element? - isRelationshipEmbeddedIn: function(element) { + // Is source, target and the link itself embedded in a given cell? + isRelationshipEmbeddedIn: function(cell) { - var elementId = joint.util.isString(element) ? element : element.id; + var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id; var ancestor = this.getRelationshipAncestor(); - return !!ancestor && (ancestor.id === elementId || ancestor.isEmbeddedIn(elementId)); + return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId)); } }, { @@ -10354,10 +10404,10 @@ joint.dia.LinkView = joint.dia.CellView.extend({ } else if (paperOptions.linkConnectionPoint) { - var view = end === 'target' ? this.targetView : this.sourceView; - var magnet = end === 'target' ? this.targetMagnet : this.sourceMagnet; + var view = (end === 'target') ? this.targetView : this.sourceView; + var magnet = (end === 'target') ? this.targetMagnet : this.sourceMagnet; - spot = paperOptions.linkConnectionPoint(this, view, magnet, reference); + spot = paperOptions.linkConnectionPoint(this, view, magnet, reference, end); } else { @@ -10482,7 +10532,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ if (availableMagnets.length > 0) { // highlight all available magnets for (var j = 0, m = availableMagnets.length; j < m; j++) { - view.highlight(availableMagnets[j], { magnetAvailability: true }) + view.highlight(availableMagnets[j], { magnetAvailability: true }); } // highlight the entire view view.highlight(null, { elementAvailability: true }); @@ -10505,7 +10555,7 @@ joint.dia.LinkView = joint.dia.CellView.extend({ var view = this.paper.findViewByModel(id); if (view) { for (var j = 0, m = markedMagnets.length; j < m; j++) { - view.unhighlight(markedMagnets[j], { magnetAvailability: true }) + view.unhighlight(markedMagnets[j], { magnetAvailability: true }); } view.unhighlight(null, { elementAvailability: true }); } @@ -11197,6 +11247,8 @@ joint.dia.Paper = joint.mvc.View.extend({ if (this._background) { this.updateBackgroundImage(this._background); } + + return this; }, // For storing the current transformation matrix (CTM) of the paper's viewport. @@ -12456,7 +12508,7 @@ joint.dia.Paper = joint.mvc.View.extend({ options.height = gridSize * (ctm.d || 1) * (options.scaleFactor || 1); if (!refs.exist(id)) { - refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))) + refs.add(id, V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup))); } var patternDefVel = refs.get(id); @@ -17306,7 +17358,7 @@ joint.layout.DirectedGraph = { var target = cell.get('target'); // Links that end at a point are ignored. - if (!source.id || !target.id) return; + if (!source.id || !target.id) break; // Note that if we are creating a multigraph we can name the edges. If // we try to name edges on a non-multigraph an exception is thrown. diff --git a/dist/joint.nowrap.min.js b/dist/joint.nowrap.min.js index ebaf37824..fe340a8a5 100644 --- a/dist/joint.nowrap.min.js +++ b/dist/joint.nowrap.min.js @@ -1,4 +1,4 @@ -/*! JointJS v1.2.0-beta (2017-10-19) - JavaScript diagramming library +/*! JointJS v2.0.0 (2017-10-23) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public @@ -8,11 +8,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. !function(){function a(a){this.message=a}var b="undefined"!=typeof exports?exports:this,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a.prototype=new Error,a.prototype.name="InvalidCharacterError",b.btoa||(b.btoa=function(b){for(var d,e,f=String(b),g=0,h=c,i="";f.charAt(0|g)||(h="=",g%1);i+=h.charAt(63&d>>8-g%1*8)){if(e=f.charCodeAt(g+=.75),e>255)throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");d=d<<8|e}return i}),b.atob||(b.atob=function(b){var d=String(b).replace(/=+$/,"");if(d.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,f,g=0,h=0,i="";f=d.charAt(h++);~f&&(e=g%4?64*e+f:f,g++%4)?i+=String.fromCharCode(255&e>>(-2*g&6)):0)f=c.indexOf(f);return i})}(),function(){function a(a,b){return this.slice(a,b)}function b(a,b){arguments.length<2&&(b=0);for(var c=0,d=a.length;c>>0;if(0===e)return!1;for(var f=0|b,g=Math.max(f>=0?f:e-Math.abs(f),0);g>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;e0?1:-1)*Math.floor(Math.abs(b)):b},d=Math.pow(2,53)-1,e=function(a){var b=c(a);return Math.min(Math.max(b,0),d)};return function(a){var c=this,d=Object(a);if(null==a)throw new TypeError("Array.from requires an array-like object - not null or undefined");var f,g=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof g){if(!b(g))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(f=arguments[2])}for(var h,i=e(d.length),j=b(c)?Object(new c(i)):new Array(i),k=0;k>>0;if("function"!=typeof a)throw new TypeError("predicate must be a function");for(var d=arguments[1],e=0;ethis.length)&&this.indexOf(a,b)!==-1}),String.prototype.startsWith||(String.prototype.startsWith=function(a,b){return this.substr(b||0,a.length)===a}),Number.isFinite=Number.isFinite||function(a){return"number"==typeof a&&isFinite(a)},Number.isNaN=Number.isNaN||function(a){return a!==a}; var g=function(){var a={},b=Math,c=b.abs,d=b.cos,e=b.sin,f=b.sqrt,g=b.min,h=b.max,i=b.atan2,j=b.round,k=b.floor,l=b.PI,m=b.random,n=b.pow;a.bezier={curveThroughPoints:function(a){for(var b=this.getCurveControlPoints(a),c=["M",a[0].x,a[0].y],d=0;dj.x+h/2,n=fj.x?g-e:g+e,d=h*h/(f-k)-h*h*(g-l)*(c-l)/(i*i*(f-k))+k):(d=g>j.y?f+e:f-e,c=i*i/(g-l)-i*i*(f-k)*(d-k)/(h*h*(g-l))+l),a.point(d,c).theta(b)},equals:function(a){return!!a&&a.x===this.x&&a.y===this.y&&a.a===this.a&&a.b===this.b},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a),b&&a.rotate(q(this.x,this.y),b);var c,d=a.x-this.x,e=a.y-this.y;if(0===d)return c=this.bbox().pointNearestToPoint(a),b?c.rotate(q(this.x,this.y),-b):c;var g=e/d,h=g*g,i=this.a*this.a,j=this.b*this.b,k=f(1/(1/i+h/j));k=d<0?-k:k;var l=g*k;return c=q(this.x+k,this.y+l),b?c.rotate(q(this.x,this.y),-b):c},toString:function(){return q(this.x,this.y).toString()+" "+this.a+" "+this.b}};var p=a.Line=function(a,b){return this instanceof p?a instanceof p?p(a.start,a.end):(this.start=q(a),void(this.end=q(b))):new p(a,b)};a.Line.prototype={bearing:function(){var a=w(this.start.y),b=w(this.end.y),c=this.start.x,f=this.end.x,g=w(f-c),h=e(g)*d(b),j=d(a)*e(b)-e(a)*d(b)*d(g),k=v(i(h,j)),l=["NE","E","SE","S","SW","W","NW","N"],m=k-22.5;return m<0&&(m+=360),m=parseInt(m/45),l[m]},clone:function(){return p(this.start,this.end)},equals:function(a){return!!a&&this.start.x===a.start.x&&this.start.y===a.start.y&&this.end.x===a.end.x&&this.end.y===a.end.y},intersect:function(a){if(a instanceof p){var b=q(this.end.x-this.start.x,this.end.y-this.start.y),c=q(a.end.x-a.start.x,a.end.y-a.start.y),d=b.x*c.y-b.y*c.x,e=q(a.start.x-this.start.x,a.start.y-this.start.y),f=e.x*c.y-e.y*c.x,g=e.x*b.y-e.y*b.x;if(0===d||f*d<0||g*d<0)return null;if(d>0){if(f>d||g>d)return null}else if(f0?l:null}return null},length:function(){return f(this.squaredLength())},midpoint:function(){return q((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},pointAt:function(a){var b=(1-a)*this.start.x+a*this.end.x,c=(1-a)*this.start.y+a*this.end.y;return q(b,c)},pointOffset:function(a){return((this.end.x-this.start.x)*(a.y-this.start.y)-(this.end.y-this.start.y)*(a.x-this.start.x))/2},vector:function(){return q(this.end.x-this.start.x,this.end.y-this.start.y)},closestPoint:function(a){return this.pointAt(this.closestPointNormalizedLength(a))},closestPointNormalizedLength:function(a){var b=this.vector().dot(p(this.start,a).vector());return Math.min(1,Math.max(0,b/this.squaredLength()))},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},toString:function(){return this.start.toString()+" "+this.end.toString()}},a.Line.prototype.intersection=a.Line.prototype.intersect;var q=a.Point=function(a,b){if(!(this instanceof q))return new q(a,b);if("string"==typeof a){var c=a.split(a.indexOf("@")===-1?" ":"@");a=parseInt(c[0],10),b=parseInt(c[1],10)}else Object(a)===a&&(b=a.y,a=a.x);this.x=void 0===a?0:a,this.y=void 0===b?0:b};a.Point.fromPolar=function(a,b,f){f=f&&q(f)||q(0,0);var g=c(a*d(b)),h=c(a*e(b)),i=t(v(b));return i<90?h=-h:i<180?(g=-g,h=-h):i<270&&(g=-g),q(f.x+g,f.y+h)},a.Point.random=function(a,b,c,d){return q(k(m()*(b-a+1)+a),k(m()*(d-c+1)+c))},a.Point.prototype={adhereToRect:function(a){return a.containsPoint(this)?this:(this.x=g(h(this.x,a.x),a.x+a.width),this.y=g(h(this.y,a.y),a.y+a.height),this)},bearing:function(a){return p(this,a).bearing()},changeInAngle:function(a,b,c){return q(this).offset(-a,-b).theta(c)-this.theta(c)},clone:function(){return q(this)},difference:function(a,b){return Object(a)===a&&(b=a.y,a=a.x),q(this.x-(a||0),this.y-(b||0))},distance:function(a){return p(this,a).length()},squaredDistance:function(a){return p(this,a).squaredLength()},equals:function(a){return!!a&&this.x===a.x&&this.y===a.y},magnitude:function(){return f(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(a){return c(a.x-this.x)+c(a.y-this.y)},move:function(a,b){var c=w(q(a).theta(this));return this.offset(d(c)*b,-e(c)*b)},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 q(a).move(this,this.distance(a))},rotate:function(a,b){b=(b+360)%360,this.toPolar(a),this.y+=w(b);var c=q.fromPolar(this.x,this.y,a);return this.x=c.x,this.y=c.y,this},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this},scale:function(a,b,c){return c=c&&q(c)||q(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=u(this.x,a),this.y=u(this.y,b||a),this},theta:function(a){a=q(a);var b=-(a.y-this.y),c=a.x-this.x,d=i(b,c);return d<0&&(d=2*l+d),180*d/l},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=q(0,0);return b.angleBetween(this,a)},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(a){a=a&&q(a)||q(0,0);var b=this.x,c=this.y;return this.x=f((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y)),this.y=w(a.theta(q(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}};var r=a.Rect=function(a,b,c,d){return this instanceof r?(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 r(a,b,c,d)};a.Rect.fromEllipse=function(a){return a=o(a),r(a.x-a.a,a.y-a.b,2*a.a,2*a.b)},a.Rect.prototype={bbox:function(a){var b=w(a||0),f=c(e(b)),g=c(d(b)),h=this.width*g+this.height*f,i=this.width*f+this.height*g;return r(this.x+(this.width-h)/2,this.y+(this.height-i)/2,h,i)},bottomLeft:function(){return q(this.x,this.y+this.height)},bottomLine:function(){return p(this.bottomLeft(),this.corner())},bottomMiddle:function(){return q(this.x+this.width/2,this.y+this.height)},center:function(){return q(this.x+this.width/2,this.y+this.height/2)},clone:function(){return r(this)},containsPoint:function(a){return a=q(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=r(this).normalize(),c=r(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 q(this.x+this.width,this.y+this.height)},equals:function(a){var b=r(this).normalize(),c=r(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=Math.max(b.x,d.x),g=Math.max(b.y,d.y);return r(f,g,Math.min(c.x,e.x)-f,Math.min(c.y,e.y)-g)},intersectionWithLineFromCenterToPoint:function(a,b){a=q(a);var c,d=q(this.x+this.width/2,this.y+this.height/2);b&&a.rotate(d,b);for(var e=[p(this.origin(),this.topRight()),p(this.topRight(),this.corner()),p(this.corner(),this.bottomLeft()),p(this.bottomLeft(),this.origin())],f=p(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 p(this.origin(),this.bottomLeft())},leftMiddle:function(){return q(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 q.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 q(this.x,this.y)},pointNearestToPoint:function(a){if(a=q(a),this.containsPoint(a)){var b=this.sideNearestToPoint(a);switch(b){case"right":return q(this.x+this.width,a.y);case"left":return q(this.x,a.y);case"bottom":return q(a.x,this.y+this.height);case"top":return q(a.x,this.y)}}return a.adhereToRect(this)},rightLine:function(){return p(this.topRight(),this.corner())},rightMiddle:function(){return q(this.x+this.width,this.y+this.height/2)},round:function(a){var b=n(10,a||0);return this.x=j(this.x*b)/b,this.y=j(this.y*b)/b,this.width=j(this.width*b)/b,this.height=j(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(b,c){b=a.Rect(b),c||(c=b.center());var d,e,f,g,h,i,j,k,l=c.x,m=c.y;d=e=f=g=h=i=j=k=1/0;var n=b.origin();n.xl&&(e=(this.x+this.width-l)/(o.x-l)),o.y>m&&(i=(this.y+this.height-m)/(o.y-m));var p=b.topRight();p.x>l&&(f=(this.x+this.width-l)/(p.x-l)),p.ym&&(k=(this.y+this.height-m)/(q.y-m)),{sx:Math.min(d,e,f,g),sy:Math.min(h,i,j,k)}},maxRectUniformScaleToFit:function(a,b){var c=this.maxRectScaleToFit(a,b);return Math.min(c.sx,c.sy)},sideNearestToPoint:function(a){a=q(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 cc.x&&(c=d[a]);var e=[];for(b=d.length,a=0;a2){var h=e[e.length-1];e.unshift(h)}for(var i,j,k,l,m,n,o={},p=[];0!==e.length;)if(i=e.pop(),j=i[0],!o.hasOwnProperty(i[0]+"@@"+i[1]))for(var q=!1;!q;)if(p.length<2)p.push(i),q=!0;else{k=p.pop(),l=k[0],m=p.pop(),n=m[0];var r=n.cross(l,j);if(r<0)p.push(m),p.push(k),p.push(i),q=!0;else if(0===r){var t=1e-10,u=l.angleBetween(n,j);Math.abs(u-180)2&&p.pop();var v,w=-1;for(b=p.length,a=0;a0){var z=p.slice(w),A=p.slice(0,w);y=z.concat(A)}else y=p;var B=[];for(b=y.length,a=0;a1){var g,h,i=[];for(g=0,h=f.childNodes.length;gu&&(u=z),c=d("tspan",y.attrs),b.includeAnnotationIndices&&c.attr("annotations",y.annotations),y.attrs.class&&c.addClass(y.attrs.class),e&&x===w&&p!==s&&(y.t+=e),c.node.textContent=y.t}else e&&x===w&&p!==s&&(y+=e),c=document.createTextNode(y||" ");r.append(c)}"auto"===b.lineHeight&&u&&0!==p&&r.attr("dy",1.2*u+"px")}else e&&p!==s&&(t+=e),r.node.textContent=t;0===p&&(o=u)}else r.addClass("v-empty-line"),r.node.style.fillOpacity=0,r.node.style.strokeOpacity=0,r.node.textContent="-";d(g).append(r),l+=t.length+1}var A=this.attr("y");return null===A&&this.attr("y",o||"0.8em"),this},d.prototype.removeAttr=function(a){var b=d.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},d.prototype.attr=function(a,b){if(d.isUndefined(a)){for(var c=this.node.attributes,e={},f=0;f'+(a||"")+"",f=d.parseXML(e,{async:!1});return f.documentElement},d.idCounter=0,d.uniqueId=function(){return"v-"+ ++d.idCounter},d.toNode=function(a){return d.isV(a)?a.node:a.nodeName&&a||a[0]},d.ensureId=function(a){return a=d.toNode(a),a.id||(a.id=d.uniqueId())},d.sanitizeText=function(a){return(a||"").replace(/ /g,"\xa0")},d.isUndefined=function(a){return"undefined"==typeof a},d.isString=function(a){return"string"==typeof a},d.isObject=function(a){return a&&"object"==typeof a},d.isArray=Array.isArray,d.parseXML=function(a,b){b=b||{};var c;try{var e=new DOMParser;d.isUndefined(b.async)||(e.async=b.async),c=e.parseFromString(a,"text/xml")}catch(a){c=void 0}if(!c||c.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+a);return c},d.qualifyAttr=function(a){if(a.indexOf(":")!==-1){var c=a.split(":");return{ns:b[c[0]],local:c[1]}}return{ns:null,local:a}},d.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,d.transformSeparatorRegex=/[ ,]+/,d.transformationListRegex=/^(\w+)\((.*)\)/,d.transformStringToMatrix=function(a){var b=d.createSVGMatrix(),c=a&&a.match(d.transformRegex);if(!c)return b;for(var e=0,f=c.length;e=0){var g=d.transformStringToMatrix(a),h=d.decomposeMatrix(g);b=[h.translateX,h.translateY],e=[h.scaleX,h.scaleY],c=[h.rotation];var i=[];0===b[0]&&0===b[0]||i.push("translate("+b+")"),1===e[0]&&1===e[1]||i.push("scale("+e+")"),0!==c[0]&&i.push("rotate("+c+")"),a=i.join(" ")}else{var j=a.match(/translate\((.*?)\)/);j&&(b=j[1].split(f));var k=a.match(/rotate\((.*?)\)/);k&&(c=k[1].split(f));var l=a.match(/scale\((.*?)\)/);l&&(e=l[1].split(f))}}var m=e&&e[0]?parseFloat(e[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:m,sy:e&&e[1]?parseFloat(e[1]):m}}},d.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}},d.decomposeMatrix=function(a){var b=d.deltaTransformPoint(a,{x:0,y:1}),c=d.deltaTransformPoint(a,{x:1,y:0}),e=180/Math.PI*Math.atan2(b.y,b.x)-90,f=180/Math.PI*Math.atan2(c.y,c.x);return{translateX:a.e,translateY:a.f,scaleX:Math.sqrt(a.a*a.a+a.b*a.b),scaleY:Math.sqrt(a.c*a.c+a.d*a.d),skewX:e,skewY:f,rotation:e}},d.matrixToScale=function(a){var b,c,e,f;return a?(b=d.isUndefined(a.a)?1:a.a,f=d.isUndefined(a.d)?1:a.d,c=a.b,e=a.c):b=f=1,{sx:c?Math.sqrt(b*b+c*c):b,sy:e?Math.sqrt(e*e+f*f):f}},d.matrixToRotate=function(a){var b={x:0,y:1};return a&&(b=d.deltaTransformPoint(a,b)),{angle:g.normalizeAngle(g.toDeg(Math.atan2(b.y,b.x))-90)}},d.matrixToTranslate=function(a){return{tx:a&&a.e||0,ty:a&&a.f||0}},d.isV=function(a){return a instanceof d},d.isVElement=d.isV;var e=d("svg").node;return d.createSVGMatrix=function(a){var b=e.createSVGMatrix();for(var c in a)b[c]=a[c];return b},d.createSVGTransform=function(a){return d.isUndefined(a)?e.createSVGTransform():(a instanceof SVGMatrix||(a=d.createSVGMatrix(a)),e.createSVGTransformFromMatrix(a))},d.createSVGPoint=function(a,b){var c=e.createSVGPoint();return c.x=a,c.y=b,c},d.transformRect=function(a,b){var c=e.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 f=c.matrixTransform(b);c.x=a.x+a.width,c.y=a.y+a.height;var h=c.matrixTransform(b);c.x=a.x,c.y=a.y+a.height;var i=c.matrixTransform(b),j=Math.min(d.x,f.x,h.x,i.x),k=Math.max(d.x,f.x,h.x,i.x),l=Math.min(d.y,f.y,h.y,i.y),m=Math.max(d.y,f.y,h.y,i.y);return g.Rect(j,l,k-j,m-l)},d.transformPoint=function(a,b){return g.Point(d.createSVGPoint(a.x,a.y).matrixTransform(b))},d.styleToObject=function(a){for(var b={},c=a.split(";"),d=0;d=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*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L"+f*n+","+f*o+"A"+f+","+f+" 0 "+k+",0 "+f*l+","+f*m+"Z":"M"+g*l+","+g*m+"A"+g+","+g+" 0 "+k+",1 "+g*n+","+g*o+"L0,0Z"},d.mergeAttrs=function(a,b){for(var c in b)"class"===c?a[c]=a[c]?a[c]+" "+b[c]:b[c]:"style"===c?d.isObject(a[c])&&d.isObject(b[c])?a[c]=d.mergeAttrs(a[c],b[c]):d.isObject(a[c])?a[c]=d.mergeAttrs(a[c],d.styleToObject(b[c])):d.isObject(b[c])?a[c]=d.mergeAttrs(d.styleToObject(a[c]),b[c]):a[c]=d.mergeAttrs(d.styleToObject(a[c]),d.styleToObject(b[c])):a[c]=b[c];return a},d.annotateString=function(a,b,c){b=b||[],c=c||{};for(var e,f,g,h=c.offset||0,i=[],j=[],k=0;k=n&&k=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},d.convertLineToPathData=function(a){a=d(a);var b=["M",a.attr("x1"),a.attr("y1"),"L",a.attr("x2"),a.attr("y2")].join(" ");return b},d.convertPolygonToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b)+" Z":null},d.convertPolylineToPathData=function(a){var b=d.getPointsFromSvgNode(d(a).node);return b.length>0?d.svgPointsToPath(b):null},d.svgPointsToPath=function(a){var b;for(b=0;b0){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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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()});joint.util.invoke(d,"translate",a,b,c)},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 a?this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=a.dia.attributes={xlinkHref:{set:"xlink:href"},xlinkShow:{set:"xlink:show"},xmlSpace:{set:"xml:space"},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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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)?a:a.id,c=this.getRelationshipAncestor();return!!c&&(c.id===b||c.isEmbeddedIn(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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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(){this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background)},_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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; +var joint={version:"2.0.0",config:{classNamePrefix:"joint-",defaultTheme:"default"},dia:{},ui:{},layout:{},shapes:{},format:{},connectors:{},highlighters:{},routers:{},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()},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||{};var e=b.width,f=b.height,g=d.svgDocument||V("svg").node,h=V("").attr(c||{}).node,i=h.firstChild,j=document.createTextNode("");h.style.opacity=0,h.style.display="block",i.style.display="block",i.appendChild(j),g.appendChild(h),d.svgDocument||document.body.appendChild(g);for(var k,l,m=a.split(" "),n=[],o=[],p=0,q=0,r=m.length;pf){o.splice(Math.floor(f/l));break}}}return d.svgDocument?g.removeChild(h):document.body.removeChild(g),o.join("\n")},imageToDataUri:function(a,b){if(!a||"data:"===a.substr(0,"data:".length))return setTimeout(function(){b(null,a)},0);var c=function(b,c){if(200===b.status){var d=new FileReader;d.onload=function(a){var b=a.target.result;c(null,b)},d.onerror=function(){c(new Error("Failed to load image "+a))},d.readAsDataURL(b.response)}else c(new Error("Failed to load image "+a))},d=function(b,c){var d=function(a){for(var b=32768,c=[],d=0;d=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)}}},sortedIndex:_.sortedIndexBy||_.sortedIndex,uniq:_.uniqBy||_.uniq,uniqueId:_.uniqueId,sortBy:_.sortBy,isFunction:_.isFunction,result:_.result,union:_.union,invoke:_.invokeMap||_.invoke,difference:_.difference,intersection:_.intersection,omit:_.omit,pick:_.pick,has:_.has,bindAll:_.bindAll,assign:_.assign,defaults:_.defaults,defaultsDeep:_.defaultsDeep,isPlainObject:_.isPlainObject,isEmpty:_.isEmpty,isEqual:_.isEqual,noop:function(){},cloneDeep:_.cloneDeep,toArray:_.toArray,flattenDeep:_.flattenDeep,camelCase:_.camelCase,groupBy:_.groupBy,forIn:_.forIn,without:_.without,debounce:_.debounce,clone:_.clone,isBoolean:function(a){var b=Object.prototype.toString;return a===!0||a===!1||!!a&&"object"==typeof a&&"[object Boolean]"===b.call(a)},isObject:function(a){return!!a&&("object"==typeof a||"function"==typeof a)},isNumber:function(a){var b=Object.prototype.toString;return"number"==typeof a||!!a&&"object"==typeof a&&"[object Number]"===b.call(a)},isString:function(a){var b=Object.prototype.toString;return"string"==typeof a||!!a&&"object"==typeof a&&"[object String]"===b.call(a)},merge:function(){if(_.mergeWith){var a=Array.from(arguments),b=a[a.length-1],c=this.isFunction(b)?b:this.noop;return a.push(function(a,b){var d=c(a,b);return void 0!==d?d:Array.isArray(a)&&!Array.isArray(b)?b:void 0}),_.mergeWith.apply(this,a)}return _.merge.apply(this,arguments)}}};joint.mvc.View=Backbone.View.extend({options:{},theme:null,themeClassNamePrefix:joint.util.addClassNamePrefix("theme-"),requireSetThemeOverride:!1,defaultTheme:joint.config.defaultTheme,constructor:function(a){this.requireSetThemeOverride=a&&!!a.theme,this.options=joint.util.assign({},this.options,a),Backbone.View.call(this,a)},initialize:function(a){joint.util.bindAll(this,"setTheme","onSetTheme","remove","onRemove"),joint.mvc.views[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},_ensureElement:function(){if(this.el)this.setElement(joint.util.result(this,"el"));else{var a=joint.util.result(this,"tagName"),b=joint.util.assign({},joint.util.result(this,"attributes"));this.id&&(b.id=joint.util.result(this,"id")),this.setElement(this._createElement(a)),this._setAttributes(b)}this._ensureElClassName()},_setAttributes:function(a){this.svgElement?this.vel.attr(a):this.$el.attr(a)},_createElement:function(a){return this.svgElement?document.createElementNS(V.namespace.xmlns,a):document.createElement(a)},_setElement:function(a){this.$el=a instanceof Backbone.$?a:Backbone.$(a),this.el=this.$el[0],this.svgElement&&(this.vel=V(this.el))},_ensureElClassName:function(){var a=joint.util.result(this,"className"),b=joint.util.addClassNamePrefix(a);this.svgElement?this.vel.removeClass(a).addClass(b):this.$el.removeClass(a).addClass(b)},init:function(){},onRender:function(){},setTheme:function(a,b){return b=b||{},this.theme&&this.requireSetThemeOverride&&!b.override?this:(this.removeThemeClassName(),this.addThemeClassName(a),this.onSetTheme(this.theme,a),this.theme=a,this)},addThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.addClass(b),this},removeThemeClassName:function(a){a=a||this.theme;var b=this.themeClassNamePrefix+a;return this.$el.removeClass(b),this},onSetTheme:function(a,b){},remove:function(){return this.onRemove(),joint.mvc.views[this.cid]=null,Backbone.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid}},{extend:function(){var a=Array.from(arguments),b=a[0]&&joint.util.assign({},a[0])||{},c=a[1]&&joint.util.assign({},a[1])||{},d=b.render||this.prototype&&this.prototype.render||null;return b.render=function(){return d&&d.apply(this,arguments),this.onRender(),this},Backbone.View.extend.call(this,b,c)}}),joint.dia.GraphCells=Backbone.Collection.extend({cellNamespace:joint.shapes,initialize:function(a,b){b.cellNamespace&&(this.cellNamespace=b.cellNamespace),this.graph=b.graph},model:function(a,b){var c=b.collection,d=c.cellNamespace,e="link"===a.type?joint.dia.Link:joint.util.getByPath(d,a.type,".")||joint.dia.Element,f=new e(a,b);return f.graph=c.graph,f},comparator:function(a){return a.get("z")||0}}),joint.dia.Graph=Backbone.Model.extend({_batches:{},initialize:function(a,b){b=b||{};var c=new joint.dia.GraphCells([],{model:b.cellModel,cellNamespace:b.cellNamespace,graph:this});Backbone.Model.prototype.set.call(this,"cells",c),c.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this.on("batch:stop",this._onBatchStop,this),this._out={},this._in={},this._nodes={},this._edges={},c.on("add",this._restructureOnAdd,this),c.on("remove",this._restructureOnRemove,this),c.on("reset",this._restructureOnReset,this),c.on("change:source",this._restructureOnChangeSource,this),c.on("change:target",this._restructureOnChangeTarget,this),c.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.hasActiveBatch("to-front")||this.hasActiveBatch("to-back")||this.get("cells").sort()},_onBatchStop:function(a){var b=a&&a.batchName;"to-front"!==b&&"to-back"!==b||this.hasActiveBatch(b)||this.get("cells").sort()},_restructureOnAdd:function(a){if(a.isLink()){this._edges[a.id]=!0;var b=a.get("source"),c=a.get("target");b.id&&((this._out[b.id]||(this._out[b.id]={}))[a.id]=!0),c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)}else this._nodes[a.id]=!0},_restructureOnRemove:function(a){if(a.isLink()){delete this._edges[a.id];var b=a.get("source"),c=a.get("target");b.id&&this._out[b.id]&&this._out[b.id][a.id]&&delete this._out[b.id][a.id],c.id&&this._in[c.id]&&this._in[c.id][a.id]&&delete this._in[c.id][a.id]}else delete this._nodes[a.id]},_restructureOnReset:function(a){a=a.models,this._out={},this._in={},this._nodes={},this._edges={},a.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(a){var b=a.previous("source");b.id&&this._out[b.id]&&delete this._out[b.id][a.id];var c=a.get("source");c.id&&((this._out[c.id]||(this._out[c.id]={}))[a.id]=!0)},_restructureOnChangeTarget:function(a){var b=a.previous("target");b.id&&this._in[b.id]&&delete this._in[b.id][a.id];var c=a.get("target");c.id&&((this._in[c.id]||(this._in[c.id]={}))[a.id]=!0)},getOutboundEdges:function(a){return this._out&&this._out[a]||{}},getInboundEdges:function(a){return this._in&&this._in[a]||{}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.cells=this.get("cells").toJSON(),a},fromJSON:function(a,b){if(!a.cells)throw new Error("Graph JSON must contain cells array.");return this.set(a,b)},set:function(a,b,c){var d;return"object"==typeof a?(d=a,c=b):(d={})[a]=b,d.hasOwnProperty("cells")&&(this.resetCells(d.cells,c),d=joint.util.omit(d,"cells")),Backbone.Model.prototype.set.call(this,d,c)},clear:function(a){a=joint.util.assign({},a,{clear:!0});var b=this.get("cells");if(0===b.length)return this;this.startBatch("clear",a);var c=b.sortBy(function(a){return a.isLink()?1:2});do c.shift().remove(a);while(c.length>0);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},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 a?!!this._batches[a]:joint.util.toArray(this._batches).some(function(a){return a>0})}}),joint.util.wrapWith(joint.dia.Graph.prototype,["resetCells","addCells","removeCells"],"cells"),function(a,b,c,d,e){function f(a){return e.isString(a)&&"%"===a.slice(-1)}function g(a,b){return function(c,d){var e=f(c);c=parseFloat(c),e&&(c/=100);var g={};if(isFinite(c)){var h=e||c>=0&&c<=1?c*d[b]:Math.max(c+d[b],0);g[a]=h}return g}}function h(a,b,d){return function(e,g){var h=f(e);e=parseFloat(e),h&&(e/=100);var i;if(isFinite(e)){var j=g[d]();i=h||e>0&&e<1?j[a]+g[b]*e:j[a]+e}var k=c.Point();return k[a]=i||0,k}}function i(a,b,d){return function(e,g){var h;h="middle"===e?g[b]/2:e===d?g[b]:isFinite(e)?e>-1&&e<1?-g[b]*e:-e:f(e)?g[b]*parseFloat(e)/100:0;var i=c.Point();return i[a]=-(g[a]+h),i}}var j=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){return{"marker-start":"url(#"+this.paper.defineMarker(a)+")"}}},targetMarker:{qualify:e.isPlainObject,set:function(a){return a=e.assign({transform:"rotate(180)"},a),{"marker-end":"url(#"+this.paper.defineMarker(a)+")"}}},vertexMarker:{qualify:e.isPlainObject,set:function(a){return{"marker-mid":"url(#"+this.paper.defineMarker(a)+")"}}},text:{set:function(b,c,e,f){var g=d(e),h="joint-text",i=g.data(h),j=a.util.pick(f,"lineHeight","annotations","textPath","x","eol"),k=j.fontSize=f["font-size"]||f.fontSize,l=JSON.stringify([b,j]);void 0!==i&&i===l||(k&&e.setAttribute("font-size",k),V(e).text(""+b,j),g.data(h,l))}},textWrap:{qualify:e.isPlainObject,set:function(b,c,d,e){var g=b.width||0;f(g)?c.width*=parseFloat(g)/100:g<=0?c.width+=g:c.width=g;var h=b.height||0;f(h)?c.height*=parseFloat(h)/100:h<=0?c.height+=h:c.height=h;var i=a.util.breakText(""+b.text,c,{"font-weight":e["font-weight"]||e.fontWeight,"font-size":e["font-size"]||e.fontSize,"font-family":e["font-family"]||e.fontFamily},{svgDocument:this.paper.svg});V(d).text(i)}},lineHeight:{qualify:function(a,b,c){return void 0!==c.text}},textPath:{qualify:function(a,b,c){return void 0!==c.text}},annotations:{qualify:function(a,b,c){return void 0!==c.text}},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:h("x","width","origin")},refY:{position:h("y","height","origin")},refDx:{position:h("x","width","corner")},refDy:{position:h("y","height","corner")},refWidth:{set:g("width","width")},refHeight:{set:g("height","height")},refRx:{set:g("rx","width")},refRy:{set:g("ry","height")},refCx:{set:g("cx","width")},refCy:{set:g("cy","height")},xAlignment:{offset:i("x","width","right")},yAlignment:{offset:i("y","height","bottom")},resetOffset:{offset:function(a,b){return a?{x:-b.x,y:-b.y}:{x:0,y:0}}}};j.refX2=j.refX,j.refY2=j.refY,j["ref-x"]=j.refX,j["ref-y"]=j.refY,j["ref-dy"]=j.refDy,j["ref-dx"]=j.refDx,j["ref-width"]=j.refWidth,j["ref-height"]=j.refHeight,j["x-alignment"]=j.xAlignment,j["y-alignment"]=j.yAlignment}(joint,_,g,$,joint.util),joint.dia.Cell=Backbone.Model.extend({constructor:function(a,b){var c,d=a||{};this.cid=joint.util.uniqueId("c"),this.attributes={},b&&b.collection&&(this.collection=b.collection),b&&b.parse&&(d=this.parse(d,b)||{}),(c=joint.util.result(this,"defaults"))&&(d=joint.util.merge({},c,d)),this.set(d,b),this.changed={},this.initialize.apply(this,arguments)},translate:function(a,b,c){throw new Error("Must define a translate() method.")},toJSON:function(){var a=this.constructor.prototype.defaults.attrs||{},b=this.attributes.attrs,c={};joint.util.forIn(b,function(b,d){var e=a[d];joint.util.forIn(b,function(a,b){joint.util.isObject(a)&&!Array.isArray(a)?joint.util.forIn(a,function(a,f){e&&e[b]&&joint.util.isEqual(e[b][f],a)||(c[d]=c[d]||{},(c[d][b]||(c[d][b]={}))[f]=a)}):e&&joint.util.isEqual(e[b],a)||(c[d]=c[d]||{},c[d][b]=a)})});var d=joint.util.cloneDeep(joint.util.omit(this.attributes,"attrs"));return d.attrs=c,d},initialize:function(a){a&&a.id||this.set("id",joint.util.uuid(),{silent:!0}),this._transitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},processPorts:function(){var a=this.ports,b={};joint.util.forIn(this.get("attrs"),function(a,c){a&&a.port&&(void 0!==a.port.id?b[a.port.id]=a.port:b[a.port]={id:a.port})});var c={};if(joint.util.forIn(a,function(a,d){b[d]||(c[d]=!0)}),this.graph&&!joint.util.isEmpty(c)){var d=this.graph.getConnectedLinks(this,{inbound:!0});d.forEach(function(a){c[a.get("target").port]&&a.remove()});var e=this.graph.getConnectedLinks(this,{outbound:!0});e.forEach(function(a){c[a.get("source").port]&&a.remove()})}this.ports=b},remove:function(a){a=a||{};var b=this.graph;b&&b.startBatch("remove");var c=this.get("parent");if(c){var d=b&&b.getCell(c);d.unembed(this)}return joint.util.invoke(this.getEmbeddedCells(),"remove",a),this.trigger("remove",this,this.collection,a),b&&b.stopBatch("remove"),this},toFront:function(a){if(this.graph){a=a||{};var b=(this.graph.getLastCell().get("z")||0)+1;if(this.startBatch("to-front").set("z",b,a),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.forEach(function(c){c.set("z",++b,a)})}this.stopBatch("to-front")}return this},toBack:function(a){if(this.graph){a=a||{};var b=(this.graph.getFirstCell().get("z")||0)-1;if(this.startBatch("to-back"),a.deep){var c=this.getEmbeddedCells({deep:!0,breadthFirst:!0});c.reverse().forEach(function(c){c.set("z",b--,a)})}this.set("z",b,a).stopBatch("to-back")}return this},embed:function(a,b){if(this===a||this.isEmbeddedIn(a))throw new Error("Recursive embedding not allowed.");this.startBatch("embed");var c=joint.util.assign([],this.get("embeds"));return c[a.isLink()?"unshift":"push"](a.id),a.set("parent",this.id,b),this.set("embeds",joint.util.uniq(c),b),this.stopBatch("embed"),this},unembed:function(a,b){return this.startBatch("unembed"),a.unset("parent",b),this.set("embeds",joint.util.without(this.get("embeds"),a.id),b),this.stopBatch("unembed"),this},getAncestors:function(){var a=[],b=this.get("parent");if(!this.graph)return a;for(;void 0!==b;){var c=this.graph.getCell(b);if(void 0===c)break;a.push(c),b=c.get("parent")}return a},getEmbeddedCells:function(a){if(a=a||{},this.graph){var b;if(a.deep)if(a.breadthFirst){b=[];for(var c=this.getEmbeddedCells();c.length>0;){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.get("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).get("parent")}return!1}return d===c},isEmbedded:function(){return!!this.get("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},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){var d={};for(var e in a)if(a.hasOwnProperty(e))for(var f=c[e]=this.findBySelector(e,b),g=0,h=f.length;g-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},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 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(" ")},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()},_initializePorts:function(){},update:function(a,b){this._removePorts();var c=this.model,d=c.attr();this.updateDOMSubtreeAttributes(this.el,d,{rootBBox:g.Rect(c.size()),scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:b===d?null:b}),this._renderPorts()},renderMarkup:function(){var a=this.model.get("markup")||this.model.markup;if(!a)throw new Error("properties.markup is missing while the default render() implementation is used.");var b=joint.util.template(a)(),c=V(b);this.vel.append(c)},render:function(){this.$el.empty(),this.renderMarkup(),this.rotatableNode=this.vel.findOne(".rotatable");var a=this.scalableNode=this.vel.findOne(".scalable");return a&&this.update(),this.resize(),this.rotate(),this.translate(),this},resize:function(a,b,c){var d=this.model,e=d.get("size")||{width:1,height:1},f=d.get("angle")||0,g=this.scalableNode;if(!g)return 0!==f&&this.rotate(),void this.update();var h=!1;g.node.getElementsByTagName("path").length>0&&(h=!0);var i=g.getBBox({recursive:h}),j=e.width/(i.width||1),k=e.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("+-f+","+e.width/2+","+e.height/2+")");var n=g.getBBox({target:this.paper.viewport});d.set("position",{x:n.x,y:n.y},c),this.rotate()}this.update()},translate:function(a,b,c){var d=this.model.get("position")||{x:0,y:0};this.vel.attr("transform","translate("+d.x+","+d.y+")")},rotate:function(){var a=this.rotatableNode;if(a){var b=this.model.get("angle")||0,c=this.model.get("size")||{width:1,height:1},d=c.width/2,e=c.height/2;0!==b?a.attr("transform","rotate("+b+","+d+","+e+")"):a.removeAttr("transform")}},getBBox:function(a){if(a&&a.useModelGeometry){var b=this.model.getBBox().bbox(this.model.get("angle"));return this.paper.localToPaperRect(b)}return joint.dia.CellView.prototype.getBBox.apply(this,arguments)},prepareEmbedding:function(a){a=a||{};var b=a.model||this.model,c=a.paper||this.paper,d=c.model;b.startBatch("to-front",a),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.get("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=c.model.findModelsUnderElement(b,{searchBy:d.findParentBy});d.frontParentOnly&&(e=e.slice(-1));for(var f=null,g=this._candidateEmbedView,h=e.length-1;h>=0;h--){var i=e[h];if(g&&g.model.id==i.id){f=g;break}var j=i.findView(c);if(d.validateEmbedding.call(c,this,j)){f=j;break}}f&&f!=g&&(this.clearEmbedding(),this._candidateEmbedView=f.highlight(null,{embedding:!0})),!f&&g&&this.clearEmbedding()},clearEmbedding:function(){var a=this._candidateEmbedView;a&&(a.unhighlight(null,{embedding:!0}),this._candidateEmbedView=null)},finalizeEmbedding:function(a){a=a||{};var b=this._candidateEmbedView,c=a.model||this.model,d=a.paper||this.paper;b&&(b.model.embed(c,{ui:!0}),b.unhighlight(null,{embedding:!0}),delete this._candidateEmbedView),joint.util.invoke(d.model.getConnectedLinks(c,{deep:!0}),"reparent",{ui:!0})},pointerdown:function(a,b,c){var d=this.paper;if(a.target.getAttribute("magnet")&&this.can("addLinkFromMagnet")&&d.options.validateMagnet.call(d,this,a.target)){this.model.startBatch("add-link");var e=d.getDefaultLink(this,a.target);e.set({source:{id:this.model.id,selector:this.getSelector(a.target),port:a.target.getAttribute("port")},target:{x:b,y:c}}),d.model.addCell(e);var f=this._linkView=d.findViewByModel(e);f.pointerdown(a,b,c),f.startArrowheadMove("target",{whenNotAllowed:"remove"})}else this._dx=b,this._dy=c,this.restrictedArea=d.getRestrictedArea(this),joint.dia.CellView.prototype.pointerdown.apply(this,arguments),this.notify("element:pointerdown",a,b,c)},pointermove:function(a,b,c){if(this._linkView)this._linkView.pointermove(a,b,c);else{var d=this.paper.options.gridSize;if(this.can("elementMove")){var e=this.model.get("position"),f=g.snapToGrid(e.x,d)-e.x+g.snapToGrid(b-this._dx,d),h=g.snapToGrid(e.y,d)-e.y+g.snapToGrid(c-this._dy,d);this.model.translate(f,h,{restrictedArea:this.restrictedArea,ui:!0}),this.paper.options.embeddingMode&&(this._inProcessOfEmbedding||(this.prepareEmbedding(),this._inProcessOfEmbedding=!0),this.processEmbedding())}this._dx=g.snapToGrid(b,d),this._dy=g.snapToGrid(c,d),joint.dia.CellView.prototype.pointermove.apply(this,arguments),this.notify("element:pointermove",a,b,c)}},pointerup:function(a,b,c){this._linkView?(this._linkView.pointerup(a,b,c),this._linkView=null,this.model.stopBatch("add-link")):(this._inProcessOfEmbedding&&(this.finalizeEmbedding(),this._inProcessOfEmbedding=!1),this.notify("element:pointerup",a,b,c),joint.dia.CellView.prototype.pointerup.apply(this,arguments))},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)}}),joint.dia.Link=joint.dia.Cell.extend({markup:['','','','','','','',''].join(""),labelMarkup:['',"","",""].join(""),toolMarkup:['','','','',"Remove link.","",'','','',"Link options.","",""].join(""),vertexMarkup:['','','','',"Remove vertex.","",""].join(""),arrowheadMarkup:['','',""].join(""),defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(){return this.set({source:g.point(0,0),target:g.point(0,0)})},label:function(a,b,c){return a=a||0,arguments.length<=1?this.prop(["labels",a]):this.prop(["labels",a],b,c)},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.get("source");d.id||(c.source=a(d));var e=this.get("target");e.id||(c.target=a(e));var f=this.get("vertices");return f&&f.length>0&&(c.vertices=f.map(a)),this.set(c,b)},reparent:function(a){var b;if(this.graph){var c=this.graph.getCell(this.get("source").id),d=this.graph.getCell(this.get("target").id),e=this.graph.getCell(this.get("parent"));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.get("source").id,c=this.get("target").id;if(!b||!c)return!1;var d=b===c;if(!d&&a.deep&&this.graph){var e=this.graph.getCell(b),f=this.graph.getCell(c);d=e.isEmbeddedIn(f)||f.isEmbeddedIn(e)}return d},getSourceElement:function(){var a=this.get("source");return a&&a.id&&this.graph&&this.graph.getCell(a.id)||null},getTargetElement:function(){ +var a=this.get("target");return a&&a.id&&this.graph&&this.graph.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))}},{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:100,doubleLinkTools:!1,longLinkLength:160,linkToolsOffset:40,doubleLinkToolsOffset:60,sampleInterval:50},_z:null,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._markerCache={},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),c.translateBy&&this.model.get("target").id||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onTargetChange:function(a,b,c){this.watchTarget(a,b),c.translateBy||(c.updateConnectionOnly=!0,this.update(this.model,null,c))},onVerticesChange:function(a,b,c){this.renderVertexMarkers(),c.translateBy&&c.translateBy!==this.model.id||(c.updateConnectionOnly=!0,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.$el.empty();var a=this.model,b=a.get("markup")||a.markup,c=V(b);if(Array.isArray(c)||(c=[c]),this._V={},c.forEach(function(a){var b=a.attr("class");b&&(b=joint.util.removeClassNamePrefix(b),this._V[$.camelCase(b)]=a)},this),!this._V.connection)throw new Error("link: no connection path in the markup");return this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(c),this.renderLabels(),this.watchSource(a,a.get("source")).watchTarget(a,a.get("target")).update(),this},renderLabels:function(){var a=this._V.labels;if(!a)return this;a.empty();var b=this.model,c=b.get("labels")||[],d=this._labelCache={},e=c.length;if(0===e)return this;for(var f=joint.util.template(b.get("labelMarkup")||b.labelMarkup),g=V(f()),h=0;hd?d:l,l=l<0?d+l:l,l=l>1?l:d*l):l=d/2,h=c.getPointAtLength(l),joint.util.isObject(m))h=g.point(h).offset(m);else if(Number.isFinite(m)){b||(b=this._samples||this._V.connection.sample(this.options.sampleInterval));for(var n,o,p,q=1/0,r=0,s=b.length;r=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()g);)c=d.slice();return h===-1&&(h=0,c.splice(h,0,a)),this.model.set("vertices",c,{ui:!0}),h},sendToken:function(a,b,c){function d(a,b){return function(){a.remove(),"function"==typeof b&&b()}}var e,f;joint.util.isObject(b)?(e=b.duration,f="reverse"===b.direction):(e=b,f=!1),e=e||1e3;var g={dur:e+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};f&&(g.keyPoints="1;0",g.keyTimes="0;1");var h=V(a),i=this._V.connection;h.appendTo(this.paper.viewport).animateAlongPath(g,i),setTimeout(d(h,c),e)},findRoute:function(a){var b=joint.routers,c=this.model.get("router"),d=this.paper.options.defaultRouter;if(!c)if(this.model.get("manhattan"))c={name:"orthogonal"};else{if(!d)return a;c=d}var e=c.args||{},f=joint.util.isFunction(c)?c:b[c.name];if(!joint.util.isFunction(f))throw new Error('unknown router: "'+c.name+'"');var g=f.call(this,a||[],e,this);return g},getPathData:function(a){var b=joint.connectors,c=this.model.get("connector"),d=this.paper.options.defaultConnector;c||(c=this.model.get("smooth")?{name:"smooth"}:d||{});var e=joint.util.isFunction(c)?c:b[c.name],f=c.args||{};if(!joint.util.isFunction(e))throw new Error('unknown connector: "'+c.name+'"');var g=e.call(this,this._markerCache.sourcePoint,this._markerCache.targetPoint,a||this.model.get("vertices")||{},f,this);return g},getConnectionPoint:function(a,b,c){var d;if(joint.util.isEmpty(b)&&(b={x:0,y:0}),joint.util.isEmpty(c)&&(c={x:0,y:0}),b.id){var e,f=g.Rect("source"===a?this.sourceBBox:this.targetBBox);if(c.id){var h=g.Rect("source"===a?this.targetBBox:this.sourceBBox);e=h.intersectionWithLineFromCenterToPoint(f.center()),e=e||h.center()}else e=g.Point(c);var i=this.paper.options;if(i.perpendicularLinks||this.options.perpendicular){var j,k=f.origin(),l=f.corner();if(k.y<=e.y&&e.y<=l.y)switch(j=f.sideNearestToPoint(e)){case"left":d=g.Point(k.x,e.y);break;case"right":d=g.Point(l.x,e.y);break;default:d=f.center()}else if(k.x<=e.x&&e.x<=l.x)switch(j=f.sideNearestToPoint(e)){case"top":d=g.Point(e.x,k.y);break;case"bottom":d=g.Point(e.x,l.y);break;default:d=f.center()}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else if(i.linkConnectionPoint){var m="target"===a?this.targetView:this.sourceView,n="target"===a?this.targetMagnet:this.sourceMagnet;d=i.linkConnectionPoint(this,m,n,e,a)}else d=f.intersectionWithLineFromCenterToPoint(e),d=d||f.center()}else d=g.Point(b);return d},getConnectionLength:function(){return this._V.connection.node.getTotalLength()},getPointAtLength:function(a){return this._V.connection.node.getPointAtLength(a)},_beforeArrowheadMove:function(){this._z=this.model.get("z"),this.model.toFront(),this.el.style.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets()},_afterArrowheadMove:function(){null!==this._z&&(this.model.set("z",this._z,{ui:!0}),this._z=null),this.el.style.pointerEvents="visiblePainted",this.paper.options.markAvailable&&this._unmarkAvailableMagnets()},_createValidateConnectionArgs:function(a){function b(a,b){return c[f]=a,c[f+1]=a.el===b?void 0:b,c}var c=[];c[4]=a,c[5]=this;var d,e=0,f=0;"source"===a?(e=2,d="target"):(f=2,d="source");var g=this.model.get(d);return g.id&&(c[e]=this.paper.findViewByModel(g.id),c[e+1]=g.selector&&c[e].el.querySelector(g.selector)),b},_markAvailableMagnets:function(){function a(a,b){var c=a.paper,d=c.options.validateConnection;return d.apply(c,this._validateConnectionArgs(a,b))}var b=this.paper,c=b.model.getElements();this._marked={};for(var d=0,e=c.length;d0){for(var i=0,j=h.length;i").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),V(b).transform(a,{absolute:!0}),this._viewportMatrix=a,this._viewportTransformString=b.getAttribute("transform"),this},clientMatrix:function(){return V.createSVGMatrix(this.viewport.getScreenCTM())},_onSort:function(){this.model.hasActiveBatch("add")||this.sortViews()},_onBatchStop:function(a){var b=a&&a.batchName;"add"!==b||this.model.hasActiveBatch("add")||this.sortViews()},onRemove:function(){this.removeViews(),this.unbindDocumentEvents()},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)}},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.el).find("image").on("dragstart",function(){return!1}),b},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)},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){var b;if(a instanceof joint.dia.Link)b=a;else{if(!(a instanceof joint.dia.LinkView))throw new Error("Must provide link model or view.");b=a.model}if(!this.options.multiLinks){var c=b.get("source"),d=b.get("target");if(c.id&&d.id){var e=b.getSourceElement();if(e){var f=this.model.getConnectedLinks(e,{outbound:!0,inbound:!1}),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)}).length;if(g>1)return!1}}}return!!(this.options.linkPinning||joint.util.has(b.get("source"),"id")&&joint.util.has(b.get("target"),"id"))},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)}},mousedblclick: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)}},mouseclick: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)}},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)))},contextmenu:function(a){a=joint.util.normalizeEvent(a),this.options.preventContextMenu&&a.preventDefault();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){this.bindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(!this.guard(a,b)){this._mousemoved=0;var c=this.snapToGrid({x:a.clientX,y:a.clientY});b?(a.preventDefault(),this.sourceView=b,b.pointerdown(a,c.x,c.y)):(this.options.preventDefaultBlankAction&&a.preventDefault(),this.trigger("blank:pointerdown",a,c.x,c.y))}},pointermove:function(a){var b=this.sourceView;if(b){a.preventDefault();var c=++this._mousemoved;if(c>this.options.moveThreshold){a=joint.util.normalizeEvent(a);var d=this.snapToGrid({x:a.clientX,y:a.clientY});b.pointermove(a,d.x,d.y)}}},pointerup:function(a){this.unbindDocumentEvents(),a=joint.util.normalizeEvent(a);var b=this.snapToGrid({x:a.clientX,y:a.clientY});this.sourceView?(this.sourceView.pointerup(a,b.x,b.y),this.sourceView=null):this.trigger("blank:pointerup",a,b.x,b.y)},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)}},cellMouseover:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseover(a)}},cellMouseout:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);if(b){if(this.guard(a,b))return;b.mouseout(a)}},cellMouseenter:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseenter(a)},cellMouseleave:function(a){a=joint.util.normalizeEvent(a);var b=this.findView(a.target);b&&!this.guard(a,b)&&b.mouseleave(a)},cellEvent:function(a){a=joint.util.normalizeEvent(a);var b=a.currentTarget,c=b.getAttribute("event");if(c){var d=this.findView(b);if(d&&!this.guard(a,d)){var e=this.snapToGrid({x:a.clientX,y:a.clientY});d.event(a,c,e.x,e.y)}}},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:'',portMarkup:'',portLabelMarkup:'',_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)throw new Error("ElementView: Invalid port markup - multiple roots.");b.attr({port:a.id,"port-group":a.group});var d=V(this.portContainerMarkup).append(b).append(c);return this._portElementsCache[a.id]={portElement:d,portLabelElement:c},d},_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("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: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)}}),joint.routers.manhattan=function(a,b,c,d){"use strict";function e(a){this.map={},this.options=a,this.mapGridSize=100}function f(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function g(b){return a.point(0===b.x?0:Math.abs(b.x)/b.x,0===b.y?0:Math.abs(b.y)/b.y)}function h(b,c,d,e){for(var f,h=[],i=g(e.difference(c)),j=c;f=b[j];){var k=g(j.difference(f));k.equals(i)||(h.unshift(j),i=k),j=f}var l=g(a.point(j).difference(d));return l.equals(i)||h.unshift(j),h}function i(a,b,c){var e=c.step,f=a.center(),g=d.isObject(c.directionMap)?Object.keys(c.directionMap):[],h=d.toArray(b);return g.reduce(function(b,d){if(h.includes(d)){var g=c.directionMap[d],i=g.x*a.width/2,j=g.y*a.height/2,k=f.clone().offset(i,j);a.containsPoint(k)&&k.offset(g.x*e,g.y*e),b.push(k.snapToGrid(e))}return b},[])}function j(b,c,d){var e=360/d;return Math.floor(a.normalizeAngle(b.theta(c)+e/2)/e)*e}function k(a,b){var c=Math.abs(a-b);return c>180?360-c:c}function l(a,b){for(var c=1/0,d=0,e=b.length;d0&&n.length>0){for(var r=new f,s={},t={},u=0,v=m.length;u0;){var E=r.pop(),F=a.point(E),G=t[E],H=I,I=s[E]?j(s[E],F,B):null!=g.previousDirAngle?g.previousDirAngle:j(o,F,B);if(D.indexOf(E)>=0&&(z=k(I,j(F,p,B)),F.equals(p)||z<180))return g.previousDirAngle=I,h(s,F,o,p);for(u=0;ug.maxAllowedDirectionChange)){var J=F.clone().offset(y.offsetX,y.offsetY),K=J.toString();if(!r.isClose(K)&&e.isPointAccessible(J)){var L=G+y.cost+g.penalties[z];(!r.isOpen(K)||L90){var h=e;e=f,f=h}var i=d%90<45?e:f,j=g.line(a,i),k=90*Math.ceil(d/90),l=g.point.fromPolar(j.squaredLength(),g.toRad(k+135),i),m=g.line(b,l),n=j.intersection(m);return n?[n.round(),b]:[b]}};return function(c,d,e){return joint.routers.manhattan(c,a.assign({},b,d),e)}}(joint.util),joint.routers.normal=function(a,b,c){return a},joint.routers.oneSide=function(a,b,c){var d,e,f,g=b.side||"bottom",h=b.padding||40,i=c.sourceBBox,j=c.targetBBox,k=i.center(),l=j.center();switch(g){case"bottom":f=1,d="y",e="height";break;case"top":f=-1,d="y",e="height";break;case"left":f=-1,d="x",e="width";break;case"right":f=1,d="x",e="width";break;default:throw new Error("Router: invalid side")}return k[d]+=f*(i[e]/2+h),l[d]+=f*(j[e]/2+h),f*(k[d]-l[d])>0?l[d]=k[d]:k[d]=l[d],[k].concat(a,l)},joint.routers.orthogonal=function(a){function b(a,b){return a.x==b.x?a.y>b.y?"N":"S":a.y==b.y?a.x>b.x?"W":"E":null}function c(a,b){return a["W"==b||"E"==b?"width":"height"]}function d(a,b){return g.rect(a).moveAndExpand({x:-b,y:-b,width:2*b,height:2*b})}function e(a){return g.rect(a.x,a.y,0,0)}function f(a,b){var c=Math.min(a.x,b.x),d=Math.min(a.y,b.y),e=Math.max(a.x+a.width,b.x+b.width),f=Math.max(a.y+a.height,b.y+b.height);return g.rect(c,d,e-c,f-d)}function h(a,b,c){var d=g.point(a.x,b.y);return c.containsPoint(d)&&(d=g.point(b.x,a.y)),d}function i(a,c,d){var e=g.point(a.x,c.y),f=g.point(c.x,a.y),h=b(a,e),i=b(a,f),j=o[d],k=h==d||h!=j&&(i==j||i!=d)?e:f;return{points:[k],direction:b(k,c)}}function j(a,c,d){var e=h(a,c,d);return{points:[e],direction:b(e,c)}}function k(d,e,f,i){var j,k={},l=[g.point(d.x,e.y),g.point(e.x,d.y)],m=l.filter(function(a){return!f.containsPoint(a)}),n=m.filter(function(a){return b(a,d)!=i});if(n.length>0)j=n.filter(function(a){return b(d,a)==i}).pop(),j=j||n[0],k.points=[j],k.direction=b(j,e);else{j=a.difference(l,m)[0];var o=g.point(e).move(j,-c(f,i)/2),p=h(o,d,f);k.points=[p,o],k.direction=b(o,e)}return k}function l(a,d,e,f){var h=j(d,a,f),k=h.points[0];if(e.containsPoint(k)){h=j(a,d,e);var l=h.points[0];if(f.containsPoint(l)){var m=g.point(a).move(l,-c(e,b(a,l))/2),n=g.point(d).move(k,-c(f,b(d,k))/2),o=g.line(m,n).midpoint(),p=j(a,o,e),q=i(o,d,p.direction);h.points=[p.points[0],q.points[0]],h.direction=q.direction}}return h}function m(a,c,e,i,j){var k,l,m,n={},o=d(f(e,i),1),q=o.center().distance(c)>o.center().distance(a),r=q?c:a,s=q?a:c;return j?(k=g.point.fromPolar(o.width+o.height,p[j],r),k=o.pointNearestToPoint(k).move(k,-1)):k=o.pointNearestToPoint(r).move(r,1),l=h(k,s,o),k.round().equals(l.round())?(l=g.point.fromPolar(o.width+o.height,g.toRad(k.theta(r))+Math.PI/2,s),l=o.pointNearestToPoint(l).move(s,1).round(),m=h(k,l,o),n.points=q?[l,m,k]:[k,m,l]):n.points=q?[l,k]:[k,l],n.direction=q?b(k,c):b(l,c),n}function n(c,f,h){var n=f.elementPadding||20,o=[],p=d(h.sourceBBox,n),q=d(h.targetBBox,n);c=a.toArray(c).map(g.point),c.unshift(p.center()),c.push(q.center());for(var r,s=0,t=c.length-1;sv)||"jumpover"!==d.name)}),y=x.map(function(a){return r.findViewByModel(a)}),z=d(a,b,f),A=y.map(function(a){return null==a?[]:a===this?z:d(a.sourcePoint,a.targetPoint,a.route)},this),B=z.reduce(function(a,b){var c=x.reduce(function(a,c,d){if(c!==u){var e=g(b,A[d]);a.push.apply(a,e)}return a},[]).sort(function(a,c){return h(b.start,a)-h(b.start,c)});return c.length>0?a.push.apply(a,i(b,c,o)):a.push(b),a},[]);return j(B,o,p)}}(_,g,joint.util),function(a,b,c,d){function e(a,b,d){var e=a.toJSON();return e.angle=b||0,c.util.defaults({},d,e)}function f(a,c,d){return a.map(function(a,b,c){var d=this.pointAt((b+.5)/c.length);return(a.dx||a.dy)&&d.offset(a.dx||0,a.dy||0),e(d.round(),0,a)},b.line(c,d))}function g(a,c,d,f){var g=c.center(),h=c.width/c.height,i=c.topMiddle(),j=b.Ellipse.fromRect(c);return a.map(function(a,b,c){var k=d+f(b,c.length),l=i.clone().rotate(g,-k).scale(h,1,g),m=a.compensateRotation?-j.tangentTheta(l):0;return(a.dx||a.dy)&&l.offset(a.dx||0,a.dy||0),a.dr&&l.move(g,a.dr),e(l.round(),m,a)})}function h(a,c){var e=c.x;d.isString(e)&&(e=parseFloat(e)/100*a.width);var f=c.y;return d.isString(f)&&(f=parseFloat(f)/100*a.height),b.point(e||0,f||0)}c.layout.Port={absolute:function(a,b,c){return a.map(h.bind(null,b))},fn:function(a,b,c){return c.fn(a,b,c)},line:function(a,b,c){var d=h(b,c.start||b.origin()),e=h(b,c.end||b.corner());return f(a,d,e)},left:function(a,b,c){return f(a,b.origin(),b.bottomLeft())},right:function(a,b,c){return f(a,b.topRight(),b.corner())},top:function(a,b,c){return f(a,b.origin(),b.topRight())},bottom:function(a,b,c){return f(a,b.bottomLeft(),b.corner())},ellipseSpread:function(a,b,c){var d=c.startAngle||0,e=c.step||360/a.length;return g(a,b,d,function(a){return a*e})},ellipse:function(a,b,c){var d=c.startAngle||0,e=c.step||20;return g(a,b,d,function(a,b){return(a+.5-b/2)*e})}}}(_,g,joint,joint.util),function(a,b,c,d){function e(a,b){return d.defaultsDeep({},a,b,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function f(a,b,c,f){f=d.defaults({},f,{offset:15});var h,i,j,k,l=b.center().theta(a),m=g(b),n=f.offset,o=0;lm[2]?(j=".3em",h=n,i=0,k="start"):lo[2]?(k=".3em",i=-m,j=0,l="end"):h-270&&i<-90?(g="start",j=i-180):g="end";var m=Math.round;return e({x:m(k.x),y:m(k.y),angle:c?j:0,attrs:{".":{y:l,"text-anchor":g}}})}c.layout.PortLabel={manual:function(a,b,c){return e(c,a)},left:function(a,b,c){return e(c,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(a,b,c){return e(c,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(a,b,c){return e(c,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(a,b,c){return e(c,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(a,b,c){return f(a,b,!0,c)},outside:function(a,b,c){return f(a,b,!1,c)},insideOriented:function(a,b,c){return h(a,b,!0,c)},inside:function(a,b,c){return h(a,b,!1,c)},radial:function(a,b,c){return i(a.difference(b.center()),!1,c)},radialOriented:function(a,b,c){return i(a.difference(b.center()),!0,c)}}}(_,g,joint,joint.util),joint.highlighters.addClass={className:joint.util.addClassNamePrefix("highlighted"),highlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).addClass(e)},unhighlight:function(a,b,c){var d=c||{},e=d.className||this.className;V(b).removeClass(e)}},joint.highlighters.opacity={highlight:function(a,b){V(b).addClass(joint.util.addClassNamePrefix("highlight-opacity"))},unhighlight:function(a,b){V(b).removeClass(joint.util.addClassNamePrefix("highlight-opacity"))}},joint.highlighters.stroke={defaultOptions:{padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},_views:{},getHighlighterId:function(a,b){return a.id+JSON.stringify(b)},removeHighlighter:function(a){this._views[a]&&(this._views[a].remove(),this._views[a]=null)},highlight:function(a,b,c){var d=this.getHighlighterId(b,c);if(!this._views[d]){var e,f=joint.util.defaults(c||{},this.defaultOptions),g=V(b);try{var h=g.convertToPathData()}catch(a){e=g.bbox(!0),h=V.rectToPath(joint.util.assign({},f,e))}var i=V("path").attr({d:h,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"}).attr(f.attrs),j=g.getTransformToElement(a.el),k=f.padding;if(k){e||(e=g.bbox(!0));var l=e.x+e.width/2,m=e.y+e.height/2;e=V.transformRect(e,j);var n=Math.max(e.width,1),o=Math.max(e.height,1),p=(n+k)/n,q=(o+k)/o,r=V.createSVGMatrix({a:p,b:0,c:0,d:q,e:l-p*l,f:m-q*m});j=j.multiply(r)}i.transform(j);var s=this._views[d]=new joint.mvc.View({svgElement:!0,className:"highlight-stroke",el:i.node}),t=this.removeHighlighter.bind(this,d),u=a.model;s.listenTo(u,"remove",t),s.listenTo(u.graph,"reset",t),a.vel.append(i)}},unhighlight:function(a,b,c){this.removeHighlighter(this.getHighlighterId(b,c))}}; joint.dia.Element.define("erd.Entity",{size:{width:150,height:60},attrs:{".outer":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"100,0 100,60 0,60 0,0"},".inner":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"95,5 95,55 5,55 5,5",display:"none"},text:{text:"Entity","font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Entity.define("erd.WeakEntity",{attrs:{".inner":{display:"auto"},text:{text:"Weak Entity"}}}),joint.dia.Element.define("erd.Relationship",{size:{width:80,height:80},attrs:{".outer":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,0 80,40 40,80 0,40"},".inner":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,5 75,40 40,75 5,40",display:"none"},text:{text:"Relationship","font-family":"Arial","font-size":12,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Relationship.define("erd.IdentifyingRelationship",{attrs:{".inner":{display:"auto"},text:{text:"Identifying"}}}),joint.dia.Element.define("erd.Attribute",{size:{width:100,height:50},attrs:{ellipse:{transform:"translate(50, 25)"},".outer":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:50,ry:25,fill:"#E67E22"},".inner":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:45,ry:20,fill:"#E67E22",display:"none"},text:{"font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.shapes.erd.Attribute.define("erd.Multivalued",{attrs:{".inner":{display:"block"},text:{text:"multivalued"}}}),joint.shapes.erd.Attribute.define("erd.Derived",{attrs:{".outer":{"stroke-dasharray":"3,5"},text:{text:"derived"}}}),joint.shapes.erd.Attribute.define("erd.Key",{attrs:{ellipse:{"stroke-width":4},text:{text:"key","font-weight":"800","text-decoration":"underline"}}}),joint.shapes.erd.Attribute.define("erd.Normal",{attrs:{text:{text:"Normal"}}}),joint.dia.Element.define("erd.ISA",{type:"erd.ISA",size:{width:100,height:50},attrs:{polygon:{points:"0,0 50,50 100,0",fill:"#F1C40F",stroke:"#F39C12","stroke-width":2},text:{text:"ISA","font-size":18,"ref-x":.5,"ref-y":.3,"y-alignment":"middle","text-anchor":"middle"}}},{markup:''}),joint.dia.Link.define("erd.Line",{},{cardinality:function(a){this.set("labels",[{position:-20,attrs:{text:{dy:-8,text:a}}}])}}); joint.shapes.basic.Circle.define("fsa.State",{attrs:{circle:{"stroke-width":3},text:{"font-weight":"800"}}}),joint.dia.Element.define("fsa.StartState",{size:{width:20,height:20},attrs:{circle:{transform:"translate(10, 10)",r:10,fill:"#000000"}}},{markup:''}),joint.dia.Element.define("fsa.EndState",{size:{width:20,height:20},attrs:{".outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#000000"},".inner":{transform:"translate(10, 10)",r:6,fill:"#000000"}}},{markup:''}),joint.dia.Link.define("fsa.Arrow",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z"}},smooth:!0}); joint.dia.Element.define("org.Member",{size:{width:180,height:70},attrs:{rect:{width:170,height:60},".card":{fill:"#FFFFFF",stroke:"#000000","stroke-width":2,"pointer-events":"visiblePainted",rx:10,ry:10},image:{width:48,height:48,ref:".card","ref-x":10,"ref-y":5},".rank":{"text-decoration":"underline",ref:".card","ref-x":.9,"ref-y":.2,"font-family":"Courier New","font-size":14,"text-anchor":"end"},".name":{"font-weight":"800",ref:".card","ref-x":.9,"ref-y":.6,"font-family":"Courier New","font-size":14,"text-anchor":"end"}}},{markup:''}),joint.dia.Link.define("org.Arrow",{source:{selector:".card"},target:{selector:".card"},attrs:{".connection":{stroke:"#585858","stroke-width":3}},z:-1}); @@ -22,4 +22,4 @@ joint.shapes.basic.Generic.define("devs.Model",{inPorts:[],outPorts:[],size:{wid joint.shapes.basic.Generic.define("uml.Class",{attrs:{rect:{width:200},".uml-class-name-rect":{stroke:"black","stroke-width":2,fill:"#3498db"},".uml-class-attrs-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-methods-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-name-text":{ref:".uml-class-name-rect","ref-y":.5,"ref-x":.5,"text-anchor":"middle","y-alignment":"middle","font-weight":"bold",fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-attrs-text":{ref:".uml-class-attrs-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-methods-text":{ref:".uml-class-methods-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"}},name:[],attributes:[],methods:[]},{markup:['','','',"",'',""].join(""),initialize:function(){this.on("change:name change:attributes change:methods",function(){this.updateRectangles(),this.trigger("uml-update")},this),this.updateRectangles(),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},getClassName:function(){return this.get("name")},updateRectangles:function(){var a=this.get("attrs"),b=[{type:"name",text:this.getClassName()},{type:"attrs",text:this.get("attributes")},{type:"methods",text:this.get("methods")}],c=0;b.forEach(function(b){var d=Array.isArray(b.text)?b.text:[b.text],e=20*d.length+20;a[".uml-class-"+b.type+"-text"].text=d.join("\n"),a[".uml-class-"+b.type+"-rect"].height=e,a[".uml-class-"+b.type+"-rect"].transform="translate(0,"+c+")",c+=e})}}),joint.shapes.uml.ClassView=joint.dia.ElementView.extend({},{initialize:function(){joint.dia.ElementView.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"uml-update",function(){this.update(),this.resize()})}}),joint.shapes.uml.Class.define("uml.Abstract",{attrs:{".uml-class-name-rect":{fill:"#e74c3c"},".uml-class-attrs-rect":{fill:"#c0392b"},".uml-class-methods-rect":{fill:"#c0392b"}}},{getClassName:function(){return["<>",this.get("name")]}}),joint.shapes.uml.AbstractView=joint.shapes.uml.ClassView,joint.shapes.uml.Class.define("uml.Interface",{attrs:{".uml-class-name-rect":{fill:"#f1c40f"},".uml-class-attrs-rect":{fill:"#f39c12"},".uml-class-methods-rect":{fill:"#f39c12"}}},{getClassName:function(){return["<>",this.get("name")]}}),joint.shapes.uml.InterfaceView=joint.shapes.uml.ClassView,joint.dia.Link.define("uml.Generalization",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"}}}),joint.dia.Link.define("uml.Implementation",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"},".connection":{"stroke-dasharray":"3,3"}}}),joint.dia.Link.define("uml.Aggregation",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"white"}}}),joint.dia.Link.define("uml.Composition",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"black"}}}),joint.dia.Link.define("uml.Association"),joint.shapes.basic.Generic.define("uml.State",{attrs:{".uml-state-body":{width:200,height:200,rx:10,ry:10,fill:"#ecf0f1",stroke:"#bdc3c7","stroke-width":3},".uml-state-separator":{stroke:"#bdc3c7","stroke-width":2},".uml-state-name":{ref:".uml-state-body","ref-x":.5,"ref-y":5,"text-anchor":"middle",fill:"#000000","font-family":"Courier New","font-size":14},".uml-state-events":{ref:".uml-state-separator","ref-x":5,"ref-y":5,fill:"#000000","font-family":"Courier New","font-size":14}},name:"State",events:[]},{markup:['','','',"",'','','',""].join(""),initialize:function(){this.on({"change:name":this.updateName,"change:events":this.updateEvents,"change:size":this.updatePath},this),this.updateName(),this.updateEvents(),this.updatePath(),joint.shapes.basic.Generic.prototype.initialize.apply(this,arguments)},updateName:function(){this.attr(".uml-state-name/text",this.get("name"))},updateEvents:function(){this.attr(".uml-state-events/text",this.get("events").join("\n"))},updatePath:function(){var a="M 0 20 L "+this.get("size").width+" 20";this.attr(".uml-state-separator/d",a,{silent:!0})}}),joint.shapes.basic.Circle.define("uml.StartState",{type:"uml.StartState",attrs:{circle:{fill:"#34495e",stroke:"#2c3e50","stroke-width":2,rx:1}}}),joint.shapes.basic.Generic.define("uml.EndState",{size:{width:20,height:20},attrs:{"circle.outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#2c3e50"},"circle.inner":{transform:"translate(10, 10)",r:6,fill:"#34495e"}}},{markup:''}),joint.dia.Link.define("uml.Transition",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z",fill:"#34495e",stroke:"#2c3e50"},".connection":{stroke:"#2c3e50"}}}); joint.shapes.basic.Generic.define("logic.Gate",{size:{width:80,height:40},attrs:{".":{magnet:!1},".body":{width:100,height:50},circle:{r:7,stroke:"black",fill:"transparent","stroke-width":2}}},{operation:function(){return!0}}),joint.shapes.logic.Gate.define("logic.IO",{size:{width:60,height:30},attrs:{".body":{fill:"white",stroke:"black","stroke-width":2},".wire":{ref:".body","ref-y":.5,stroke:"black"},text:{fill:"black",ref:".body","ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle","font-weight":"bold","font-variant":"small-caps","text-transform":"capitalize","font-size":"14px"}}},{markup:''}),joint.shapes.logic.IO.define("logic.Input",{attrs:{".wire":{"ref-dx":0,d:"M 0 0 L 23 0"},circle:{ref:".body","ref-dx":30,"ref-y":.5,magnet:!0,class:"output",port:"out"},text:{text:"input"}}}),joint.shapes.logic.IO.define("logic.Output",{attrs:{".wire":{"ref-x":0,d:"M 0 0 L -23 0"},circle:{ref:".body","ref-x":-30,"ref-y":.5,magnet:"passive",class:"input",port:"in"},text:{text:"output"}}}),joint.shapes.logic.Gate.define("logic.Gate11",{attrs:{".input":{ref:".body","ref-x":-2,"ref-y":.5,magnet:"passive",port:"in"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:''}),joint.shapes.logic.Gate.define("logic.Gate21",{attrs:{".input1":{ref:".body","ref-x":-2,"ref-y":.3,magnet:"passive",port:"in1"},".input2":{ref:".body","ref-x":-2,"ref-y":.7,magnet:"passive",port:"in2"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:''}),joint.shapes.logic.Gate11.define("logic.Repeater",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0i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2MjUgTCAyOC45Njg3NSwyLjU5Mzc1IHogTSAzMS45Njg3NSw3LjQwNjI1IEwgNjguMDkzNzUsMjUgTCAzMS45Njg3NSw0Mi41OTM3NSBMIDMxLjk2ODc1LDcuNDA2MjUgeiIKICAgICAgIGlkPSJwYXRoMjYzOCIKICAgICAgIHNvZGlwb2RpOm5vZGV0eXBlcz0iY2NjY2NjY2NjY2NjYyIgLz4KICA8L2c+Cjwvc3ZnPgo="}}},{operation:function(a){return a}}),joint.shapes.logic.Gate11.define("logic.Not",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0iNTAiCiAgIGlkPSJzdmcyIgogICBzb2RpcG9kaTp2ZXJzaW9uPSIwLjMyIgogICBpbmtzY2FwZT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jUgTCAzMS45Njg3NSw0Mi41OTM3NSBMIDMxLjk2ODc1LDcuNDA2MjUgeiIKICAgICAgIGlkPSJwYXRoMjYzOCIKICAgICAgIHNvZGlwb2RpOm5vZGV0eXBlcz0iY2NjY2NjY2NjY2NjYyIgLz4KICAgIDxwYXRoCiAgICAgICBzb2RpcG9kaTp0eXBlPSJhcmMiCiAgICAgICBzdHlsZT0iZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDozO3N0cm9rZS1saW5lam9pbjptaXRlcjttYXJrZXI6bm9uZTtzdHJva2Utb3BhY2l0eToxO3Zpc2liaWxpdHk6dmlzaWJsZTtkaXNwbGF5OmlubGluZTtvdmVyZmxvdzp2aXNpYmxlO2VuYWJsZS1iYWNrZ3JvdW5kOmFjY3VtdWxhdGUiCiAgICAgICBpZD0icGF0aDI2NzEiCiAgICAgICBzb2RpcG9kaTpjeD0iNzYiCiAgICAgICBzb2RpcG9kaTpjeT0iMjUiCiAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgIHNvZGlwb2RpOnJ5PSI0IgogICAgICAgZD0iTSA4MCwyNSBBIDQsNCAwIDEgMSA3MiwyNSBBIDQsNCAwIDEgMSA4MCwyNSB6IgogICAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTEsMCkiIC8+CiAgPC9nPgo8L3N2Zz4K"}}},{operation:function(a){return!a}}),joint.shapes.logic.Gate21.define("logic.Or",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y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TcsMTUuNDk3MDk4IDY3LjE0Mjg1NywyNSBDIDY3LjE0Mjg1NywzNC41MDI5MDIgNTkuNzYwNjYyLDQyLjE0Mjg1NyA1MCw0Mi4xNDI4NTcgTCAzMi44NTcxNDMsNDIuMTQyODU3IEwgMzIuODU3MTQzLDcuODU3MTQyOSB6IgogICAgICAgaWQ9InBhdGgyODg0IgogICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJjY2NjY2NzY2NjY3Nzc3NzY2NjIiAvPgogIDwvZz4KPC9zdmc+Cg=="}}},{operation:function(a,b){return a&&b}}),joint.shapes.logic.Gate21.define("logic.Nor",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0iNTAiCiAgIGlkPSJzdmcyIg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2NjY2NzY2NjY2NjY2Njc2Njc2MiIC8+CiAgICAgIDxwYXRoCiAgICAgICAgIHNvZGlwb2RpOnR5cGU9ImFyYyIKICAgICAgICAgc3R5bGU9ImZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MztzdHJva2UtbGluZWpvaW46bWl0ZXI7bWFya2VyOm5vbmU7c3Ryb2tlLW9wYWNpdHk6MTt2aXNpYmlsaXR5OnZpc2libGU7ZGlzcGxheTppbmxpbmU7b3ZlcmZsb3c6dmlzaWJsZTtlbmFibGUtYmFja2dyb3VuZDphY2N1bXVsYXRlIgogICAgICAgICBpZD0icGF0aDI2MDQiCiAgICAgICAgIHNvZGlwb2RpOmN4PSI3NSIKICAgICAgICAgc29kaXBvZGk6Y3k9IjI1IgogICAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgICAgc29kaXBvZGk6cnk9IjQiCiAgICAgICAgIGQ9Ik0gNzksMjUgQSA0LDQgMCAxIDEgNzEsMjUgQSA0LDQgMCAxIDEgNzksMjUgeiIKICAgICAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI2LjUsMzkuNSkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K" }}},{operation:function(a,b){return!(a||b)}}),joint.shapes.logic.Gate21.define("logic.Nand",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmP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2My43ODEyNSBDIDM1Ljc1OTM4Nyw0NC43MTU1OSAxOS41MDY1NzQsNDQuNSAxNC43NSw0NC41IEwgMC43NSw0NC41IEwgLTIuNDA2MjUsNDQuNSB6IE0gMy40Njg3NSw0Ny41IEwgMTQuNzUsNDcuNSBDIDE5LjQzNDE3Myw0Ny41IDMzLjAzNjg1LDQ3LjM2OTc5MyA0Mi43MTg3NSw2NC41IEMgMzcuOTUxOTY0LDcyLjkyOTA3NSAzMi4xOTc0NjksNzcuMTgzOTEgMjcsNzkuMzEyNSBDIDIxLjYzOTMzOSw4MS41MDc5MjQgMTcuMTU4MDc1LDgxLjUwMDAwMSAxNC43NSw4MS41IEwgMy41LDgxLjUgQyA1LjM3MzU4ODQsNzguMzkxNTY2IDguMjUsNzIuNDUwNjUgOC4yNSw2NC41IEMgOC4yNSw1Ni41MjY2NDYgNS4zNDE0Njg2LDUwLjU5OTgxNSAzLjQ2ODc1LDQ3LjUgeiIKICAgICAgICAgaWQ9InBhdGg0OTczIgogICAgICAgICBzb2RpcG9kaTpub2RldHlwZXM9ImNjc2NjY2NzY2NjY2NjY2Njc2Njc2MiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K"}}},{operation:function(a,b){return(!a||b)&&(a||!b)}}),joint.shapes.logic.Gate21.define("logic.Xnor",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L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FnZXNoYWRvdz0iMiIKICAgICBpbmtzY2FwZTp6b29tPSI0IgogICAgIGlua3NjYXBlOmN4PSI5NS43MjM2NiIKICAgICBpbmtzY2FwZTpjeT0iLTI2Ljc3NTAyMyIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0icHgiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0ibGF5ZXIxIgogICAgIHNob3dncmlkPSJ0cnVlIgogICAgIGlua3NjYXBlOmdyaWQtYmJveD0idHJ1ZSIKICAgICBpbmtzY2FwZTpncmlkLXBvaW50cz0idHJ1ZSIKICAgICBncmlkdG9sZXJhbmNlPSIxMDAwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctd2lkdGg9IjEzOTkiCiAgICAgaW5rc2NhcGU6d2luZG93LWhlaWdodD0iODc0IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIzMyIKICAgICBpbmtzY2FwZTp3aW5kb3cteT0iMCIKICAgICBpbmtzY2FwZTpzbmFwLWJib3g9InRydWUiPgogICAgPGlua3NjYXBlOmdyaWQKICAgICAgIGlkPSJHcmlkRnJvbVByZTA0NlNldHRpbmdzIgogICAgICAgdHlwZT0ieHlncmlkIgogICAgICAgb3JpZ2lueD0iMHB4IgogICAgICAgb3JpZ2lueT0iMHB4IgogICAgICAgc3BhY2luZ3g9IjFweCIKICAgICAgIHNwYWNpbmd5PSIxcHgiCiAgICAgICBjb2xvcj0iIzAwMDBmZiIKICAgICAgIGVtcGNvbG9yPSIjMDAwMGZmIgogICAgICAgb3BhY2l0eT0iMC4yIgogICAgICAgZW1wb3BhY2l0eT0iMC40IgogICAgICAgZW1wc3BhY2luZz0iNSIKICAgICAgIHZpc2libGU9InRydWUiCiAgICAgICBlbmFibGVkPSJ0cnVlIiAvPgogIDwvc29kaXBvZGk6bmFtZWR2aWV3PgogIDxtZXRhZGF0YQogICAgIGlkPSJtZXRhZGF0YTciPgogICAgPHJkZjpSREY+CiAgICAgIDxjYzpXb3JrCiAgICA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ODEuNSBDIDUuMzczNTg4NCw3OC4zOTE1NjYgOC4yNSw3Mi40NTA2NSA4LjI1LDY0LjUgQyA4LjI1LDU2LjUyNjY0NiA1LjM0MTQ2ODYsNTAuNTk5ODE1IDMuNDY4NzUsNDcuNSB6IgogICAgICAgICBpZD0icGF0aDQ5NzMiCiAgICAgICAgIHNvZGlwb2RpOm5vZGV0eXBlcz0iY2NzY2NjY3NjY2NjY2NjY2NzY2NzYyIgLz4KICAgIDwvZz4KICAgIDxwYXRoCiAgICAgICBzb2RpcG9kaTp0eXBlPSJhcmMiCiAgICAgICBzdHlsZT0iZmlsbDpub25lO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDozO3N0cm9rZS1saW5lam9pbjptaXRlcjttYXJrZXI6bm9uZTtzdHJva2Utb3BhY2l0eToxO3Zpc2liaWxpdHk6dmlzaWJsZTtkaXNwbGF5OmlubGluZTtvdmVyZmxvdzp2aXNpYmxlO2VuYWJsZS1iYWNrZ3JvdW5kOmFjY3VtdWxhdGUiCiAgICAgICBpZD0icGF0aDM1NTEiCiAgICAgICBzb2RpcG9kaTpjeD0iNzUiCiAgICAgICBzb2RpcG9kaTpjeT0iMjUiCiAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgIHNvZGlwb2RpOnJ5PSI0IgogICAgICAgZD0iTSA3OSwyNSBBIDQsNCAwIDEgMSA3MSwyNSBBIDQsNCAwIDEgMSA3OSwyNSB6IiAvPgogIDwvZz4KPC9zdmc+Cg=="}}},{operation:function(a,b){return(!a||!b)&&(a||b)}}),joint.dia.Link.define("logic.Wire",{attrs:{".connection":{"stroke-width":2},".marker-vertex":{r:7}},router:{name:"orthogonal"},connector:{name:"rounded",args:{radius:10}}},{arrowheadMarkup:['','',""].join(""),vertexMarkup:['','','','','',"Remove vertex.","","",""].join("")}); -if("object"==typeof exports)var graphlib=require("graphlib"),dagre=require("dagre");graphlib=graphlib||"undefined"!=typeof window&&window.graphlib,dagre=dagre||"undefined"!=typeof window&&window.dagre,joint.layout.DirectedGraph={exportElement:function(a){return a.size()},exportLink:function(a){var b=a.get("labelSize")||{},c={minLen:a.get("minLen")||1,weight:a.get("weight")||1,labelpos:a.get("labelPosition")||"c",labeloffset:a.get("labelOffset")||0,width:b.width||0,height:b.height||0};return c},importElement:function(a,b,c){var d=this.getCell(b),e=c.node(b);a.setPosition?a.setPosition(d,e):d.set("position",{x:e.x-e.width/2,y:e.y-e.height/2})},importLink:function(a,b,c){var d=this.getCell(b.name),e=c.edge(b),f=e.points||[];if((a.setVertices||a.setLinkVertices)&&(joint.util.isFunction(a.setVertices)?a.setVertices(d,f):d.set("vertices",f.slice(1,f.length-1))),a.setLabels&&"x"in e&&"y"in e){var h={x:e.x,y:e.y};if(joint.util.isFunction(a.setLabels))a.setLabels(d,h,f);else{var i=g.Polyline(f),j=i.closestPointLength(h),k=i.pointAtLength(j),l=j/i.length();d.label(0,{position:{distance:l,offset:g.Point(h).difference(k).toJSON()}})}}},layout:function(a,b){var c;c=a instanceof joint.dia.Graph?a:(new joint.dia.Graph).resetCells(a,{dry:!0}),a=null,b=joint.util.defaults(b||{},{resizeClusters:!0,clusterPadding:10,exportElement:this.exportElement,exportLink:this.exportLink});var d=c.toGraphLib({directed:!0,multigraph:!0,compound:!0,setNodeLabel:b.exportElement,setEdgeLabel:b.exportLink,setEdgeName:function(a){return a.id}}),e={},f=b.marginX||0,h=b.marginY||0;if(b.rankDir&&(e.rankdir=b.rankDir),b.align&&(e.align=b.align),b.nodeSep&&(e.nodesep=b.nodeSep),b.edgeSep&&(e.edgesep=b.edgeSep),b.rankSep&&(e.ranksep=b.rankSep),b.ranker&&(e.ranker=b.ranker),f&&(e.marginx=f),h&&(e.marginy=h),d.setGraph(e),dagre.layout(d,{debugTiming:!!b.debugTiming}),c.startBatch("layout"),c.fromGraphLib(d,{importNode:this.importElement.bind(c,b),importEdge:this.importLink.bind(c,b)}),b.resizeClusters){var i=d.nodes().filter(function(a){return d.children(a).length>0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i0}).map(c.getCell.bind(c)).sort(function(a,b){return b.getAncestors().length-a.getAncestors().length});joint.util.invoke(i,"fitEmbeds",{padding:b.clusterPadding})}c.stopBatch("layout");var j=d.graph();return g.Rect(f,h,Math.abs(j.width-2*f),Math.abs(j.height-2*h))},fromGraphLib:function(a,b){b=b||{};var c=b.importNode||joint.util.noop,d=b.importEdge||joint.util.noop,e=this instanceof joint.dia.Graph?this:new joint.dia.Graph;return a.nodes().forEach(function(d){c.call(e,d,a,e,b)}),a.edges().forEach(function(c){d.call(e,c,a,e,b)}),e},toGraphLib:function(a,b){b=b||{};for(var c=joint.util.pick(b,"directed","compound","multigraph"),d=new graphlib.Graph(c),e=b.setNodeLabel||joint.util.noop,f=b.setEdgeLabel||joint.util.noop,g=b.setEdgeName||joint.util.noop,h=a.get("cells"),i=0,j=h.length;i (https://github.com/DavidDurman)", "Roman Bruckner (https://github.com/kumilingus)", "Charles Hill (https://github.com/chill117)", - "Vladimir Talas (https://github.com/vtalas)" + "Vladimir Talas (https://github.com/vtalas)", + "Zbynek Stara (https://github.com/zbynekstara)" ], "repository": { "type": "git",