/*
 * jsPlumb 1.2.3-RC1
 * 
 * Provides a way to visually connect elements on an HTML page.
 * 
 * http://morrisonpitt.com/jsPlumb/demo.html
 * http://code.google.com/p/jsPlumb
 * 
 * Dual licensed under MIT and GPL2.
 * 
 */ 
(function(){var n=function(){var g=this,k=/MSIE/.test(navigator.userAgent)&&!window.opera,u=null,t=function(){var a={};this.bind=function(b,d){var e=a[b];if(!e){e=[];a[b]=e}e.push(d)};this.fireUpdate=function(b,d){if(a[b])for(var e=0;e<a[b].length;e++)try{a[b][e](d)}catch(h){}}},l={},m={},r={},p=[],D={},s={},A=true,f=[],q={},E="DEFAULT",L=1200,B=function(a,b,d){var e=function(i,w){if(i===w)return true;else if(typeof i=="object"&&typeof w=="object"){var z=true,x;for(x in i)if(!e(i[x],w[x])){z=false;
break}for(x in w)if(!e(w[x],i[x])){z=false;break}return z}};d=+d||0;for(var h=a.length;d<h;d++)if(e(a[d],b))return d;return-1},H=function(a,b,d){var e=a[b];if(e==null){e=[];a[b]=e}e.push(d);return e},N=function(a,b){var d=O(a,"id"),e=l[d];if(e){var h=""+(new Date).getTime();W(d,b);for(var i=p[d],w=f[d],z=0;z<e.length;z++){var x=e[z],C=x.connections;if(x.anchor.isSelective&&C.length>0){var v=C[0],I=v.endpoints[0]==x?1:0,G=I==0?v.sourceId:v.targetId,j=p[G];G=f[G];j=x.anchor.compute([i.left,i.top],w,
x,[j.left,j.top],G,v.endpoints[I])}else j=x.anchor.compute([i.left,i.top],w,x);x.paint(j);for(v=0;v<C.length;v++){C[v].paint(d,b,false,h);I=C[v].endpoints[0]==x?1:0;if(C[v].endpoints[I].anchor.isSelective){G=I==0?C[v].sourceId:C[v].targetId;j=p[G];G=f[G];j=C[v].endpoints[I].anchor.compute([j.left,j.top],G,C[v].endpoints[I],[i.left,i.top],w,x);C[v].endpoints[I].paint(j)}}}}},R=function(a,b){var d=null;if(typeof a=="object"&&a.length){d=[];for(var e=0;e<a.length;e++){var h=F(a[e]),i=O(h,"id");d.push(b(h,
i))}}else{h=F(a);i=O(h,"id");d=b(h,i)}return d},ba=function(a,b){var d=q[a];if(d)for(var e in d)try{d[e][a](b)}catch(h){}},ca={},F=function(a){if(typeof a=="string"){var b=ca[a];if(!b){b=c.CurrentLibrary.getElementObject(a);ca[a]=b}return b}else return c.CurrentLibrary.getElementObject(a)},O=function(a,b){var d=F(a);return c.CurrentLibrary.getAttribute(d,b)},da=function(a,b,d){a=F(a);c.CurrentLibrary.setAttribute(a,b,d)},ga=function(a){a=F(a);return c.CurrentLibrary.getOffset(a)},ha=function(a){a=
F(a);return c.CurrentLibrary.getSize(a)},Y=function(a,b){var d=F(a),e=O(d,"id");if(!e){e=arguments.length==2?b:"_jsPlumb_"+new String((new Date).getTime());da(d,"id",e)}return e},$=function(a,b,d){if(b=b==null?A:b)if(c.CurrentLibrary.isDragSupported(a)){d=d||g.Defaults.DragOptions||c.Defaults.DragOptions;d=c.extend({},d);b=c.CurrentLibrary.dragEvents.drag;d[b]=T(d[b],function(){var e=c.CurrentLibrary.getUIPosition(arguments);N(a,e);e=F(a);c.CurrentLibrary.addClass(e,"jsPlumb_dragged")});b=s[Y(a)];
d.disabled=b==null?false:!b;c.CurrentLibrary.initDraggable(a,d)}},ia=function(a,b,d){var e=document.createElement("canvas"),h=e;b?c.CurrentLibrary.appendElement(h,b):document.body.appendChild(h);e.style.position="absolute";if(a)e.className=a;Y(e,d);if(k){c.sizeCanvas(e,0,0,L,L);e=G_vmlCanvasManager.initElement(e)}return e},ea=function(a,b){var d=l[a];if(d&&d.length)for(var e=0;e<d.length;e++)for(var h=0;h<d[e].connections.length;h++)if(b(d[e].connections[h]))return},S=function(a,b){if(a!=null)if(b)c.CurrentLibrary.removeElement(a,
b);else try{document.body.removeChild(a)}catch(d){}},Z=function(a,b,d){a=a[b];if(a!=null){d=B(a,d);if(d>=0){delete a[d];a.splice(d,1);return true}}return false},ja=function(a,b){var d=O(a,"id");ea(d,function(e){e.canvas.style.display=b})},ma=function(a){ea(a,function(b){b.canvas.style.display="none"==b.canvas.style.display?"block":"none"})},W=function(a,b,d){if(d||b==null){b=F(a);f[a]=ha(b);p[a]=ga(b)}else p[a]=b},T=function(a,b){a=a||function(){};b=b||function(){};return function(){var d=null;try{d=
b.apply(this,arguments)}catch(e){}try{a.apply(this,arguments)}catch(h){}return d}},ka=function(a){var b=this;this.x=a.x||0;this.y=a.y||0;var d=a.orientation||[0,0],e=null;this.offsets=a.offsets||[0,0];this.compute=function(h,i,w){e=[h[0]+b.x*i[0]+b.offsets[0],h[1]+b.y*i[1]+b.offsets[1]];i=w?w.container:null;h={left:0,top:0};if(i!=null){var z=F(i);i=ga(z);w=c.CurrentLibrary.getScrollLeft(z);z=c.CurrentLibrary.getScrollTop(z);h.left=i.left-w;h.top=i.top-z;e[0]-=h.left;e[1]-=h.top}return e};this.getOrientation=
function(){return d};this.equals=function(h){if(!h)return false;var i=h.getOrientation(),w=this.getOrientation();return this.x==h.x&&this.y==h.y&&this.offsets[0]==h.offsets[0]&&this.offsets[1]==h.offsets[1]&&w[0]==i[0]&&w[1]==i[1]}},na=function(a){var b=a.reference,d=ha(F(a.referenceCanvas)),e=0,h=0,i=null;this.compute=function(w){h=e=0;return[w[0]+d[0]/2,w[1]+d[1]/2]};this.getOrientation=function(){if(i)return i;else{var w=b.getOrientation();return[Math.abs(w[0])*e*-1,Math.abs(w[1])*h*-1]}};this.over=
function(w){i=w.getOrientation()};this.out=function(){i=null}},oa=function(a){this.isDynamic=this.isSelective=true;var b=a||[];this.addAnchor=function(h){b.push(h)};var d=b.length>0?b[0]:null;this.locked=false;var e=this;this.compute=function(h,i,w,z,x,C){if(e.locked||z==null||x==null)return d.compute(h,i,w,z,x,C);for(var v=z[0]+x[0]/2,I=z[1]+x[1]/2,G=-1,j=Infinity,M=0;M<b.length;M++){var P=Math.sqrt(Math.pow(v-(h[0]+b[M].x*i[0]),2)+Math.pow(I-(h[1]+b[M].y*i[1]),2));if(P<j){G=M+0;j=P}}d=b[G];return d.compute(h,
i,w,z,x,C)};this.getOrientation=function(){return d!=null?d.getOrientation():[0,0]};this.over=function(h){d!=null&&d.over(h)};this.out=function(){d!=null&&d.out()}},la=function(a){t.apply(this);var b=this,d=new String("_jsplumb_c_"+(new Date).getTime());this.getId=function(){return d};this.container=a.container||g.Defaults.Container;this.source=F(a.source);this.target=F(a.target);if(a.sourceEndpoint)this.source=a.sourceEndpoint.getElement();if(a.targetEndpoint)this.target=a.targetEndpoint.getElement();
this.sourceId=O(this.source,"id");this.targetId=O(this.target,"id");this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.scope=a.scope;this.endpoints=[];this.endpointStyles=[];var e=function(x,C,v,I){if(x){b.endpoints[C]=x;x.addConnection(b)}else{if(!v.endpoints)v.endpoints=[null,null];x=v.endpoints[C]||v.endpoint||g.Defaults.Endpoints[C]||c.Defaults.Endpoints[C]||g.Defaults.Endpoint||c.Defaults.Endpoint||new c.Endpoints.Dot;if(!v.endpointStyles)v.endpointStyles=[null,null];var G=
v.endpointStyles[C]||v.endpointStyle||g.Defaults.EndpointStyles[C]||c.Defaults.EndpointStyles[C]||g.Defaults.EndpointStyle||c.Defaults.EndpointStyle,j=v.anchors?v.anchors[C]:g.Defaults.Anchors[C]||c.Defaults.Anchors[C]||g.Defaults.Anchor||c.Defaults.Anchor||c.Anchors.BottomCenter,M=v.uuids?v.uuids[C]:null;v=v.uuids?new aa({style:G,endpoint:x,connections:[b],uuid:M,anchor:j,source:I,container:b.container}):new aa({style:G,endpoint:x,connections:[b],anchor:j,source:I,container:b.container});return b.endpoints[C]=
v}},h=e(a.sourceEndpoint,0,a,b.source);h&&H(l,this.sourceId,h);(e=e(a.targetEndpoint,1,a,b.target))&&H(l,this.targetId,e);if(!this.scope)this.scope=this.endpoints[0].scope;this.connector=this.endpoints[0].connector||this.endpoints[1].connector||a.connector||g.Defaults.Connector||c.Defaults.Connector||new c.Connectors.Bezier;this.paintStyle=this.endpoints[0].connectorStyle||this.endpoints[1].connectorStyle||a.paintStyle||g.Defaults.PaintStyle||c.Defaults.PaintStyle;this.backgroundPaintStyle=this.endpoints[0].connectorBackgroundStyle||
this.endpoints[1].connectorBackgroundStyle||a.backgroundPaintStyle||g.Defaults.BackgroundPaintStyle||c.Defaults.BackgroundPaintStyle;this.overlays=a.overlays||[];this.addOverlay=function(x){overlays.push(x)};this.labelStyle=a.labelStyle||g.Defaults.LabelStyle||c.Defaults.LabelStyle;(this.label=a.label)&&this.overlays.push(new c.Overlays.Label({labelStyle:this.labelStyle,label:this.label}));W(this.sourceId);W(this.targetId);this.distanceFrom=function(x){return b.connector.distanceFrom(x)};this.setLabel=
function(x){b.label=x;g.repaint(b.source)};e=p[this.sourceId];h=f[this.sourceId];var i=p[this.targetId];otherWH=f[this.targetId];var w=this.endpoints[0].anchor.compute([e.left,e.top],h,this.endpoints[0],[i.left,i.top],otherWH,this.endpoints[1]);this.endpoints[0].paint(w);w=this.endpoints[1].anchor.compute([i.left,i.top],otherWH,this.endpoints[1],[e.left,e.top],h,this.endpoints[0]);this.endpoints[1].paint(w);var z=ia(c.connectorClass,b.container);this.canvas=z;this.paint=function(x,C,v){var I=this.targetId,
G=this.sourceId;if(this.canvas.getContext){W(x,C,v);W(I);C=p[G];v=p[I];var j=f[G],M=f[I];I=z.getContext("2d");G=this.endpoints[0].anchor.compute([C.left,C.top],j,this.endpoints[0],[v.left,v.top],M,this.endpoints[1]);this.endpoints[0].anchor.getOrientation();C=this.endpoints[1].anchor.compute([v.left,v.top],M,this.endpoints[1],[C.left,C.top],j,this.endpoints[0]);this.endpoints[1].anchor.getOrientation();for(j=v=0;j<b.overlays.length;j++){M=b.overlays[j];M=M.computeMaxSize(b.connector,I);if(M>v)v=M}var P=
this.connector.compute(G,C,this.endpoints[0].anchor,this.endpoints[1].anchor,this.paintStyle.lineWidth,v);c.sizeCanvas(z,P[0],P[1],P[2],P[3]);G=function(J,Q){J.save();c.extend(J,Q);if(Q.gradient&&!k){for(var X=b.connector.createGradient(P,J,x==this.sourceId),U=0;U<Q.gradient.stops.length;U++)X.addColorStop(Q.gradient.stops[U][0],Q.gradient.stops[U][1]);J.strokeStyle=X}b.connector.paint(P,J);J.restore()};this.backgroundPaintStyle!=null&&G(I,this.backgroundPaintStyle);G(I,this.paintStyle);for(j=0;j<
b.overlays.length;j++){M=b.overlays[j];M.draw(b.connector,I)}}};this.repaint=function(){this.paint(this.sourceId,null,true)};$(b.source,a.draggable,a.dragOptions);$(b.target,a.draggable,a.dragOptions);this.source.resize&&this.source.resize(function(){c.repaint(b.sourceId)})},aa=function(a){a=a||{};c.extend({},a);var b=this,d=new String("_jsplumb_e_"+(new Date).getTime());this.getId=function(){return d};b.anchor=a.anchor||c.Anchors.TopCenter;var e=a.endpoint||new c.Endpoints.Dot,h=a.style||g.Defaults.EndpointStyle||
c.Defaults.EndpointStyle;this.connectorStyle=a.connectorStyle;this.connector=a.connector;this.isSource=a.isSource||false;this.isTarget=a.isTarget||false;var i=a.source,w=a.uuid;if(w)m[w]=b;this.container=a.container||g.Defaults.Container||c.Defaults.Container;var z=O(i,"id"),x=a.maxConnections||1;this.canvas=a.canvas||ia(c.endpointClass,this.container,a.uuid);this.connections=a.connections||[];this.scope=a.scope||E;var C=a.reattach||false,v=null,I=null;this.dragAllowedWhenFull=a.dragAllowedWhenFull||
true;this.addConnection=function(o){b.connections.push(o)};this.detach=function(o){var K=B(b.connections,o);if(K>=0){var y=o.endpoints[0]==b?o.endpoints[1]:o.endpoints[0];b.connections.splice(K,1);y.detach(o)}};this.detachAll=function(){for(;b.connections.length>0;)b.detach(b.connections[0])};this.detachFrom=function(o){for(var K=[],y=0;y<b.connections.length;y++)if(b.connections[y].endpoints[1]==o||b.connections[y].endpoints[0]==o)K.push(b.connections[y]);for(y=0;y<K.length;y++){o.detach(K[y]);b.detach(K[y])}};
this.getElement=function(){return i};this.getUuid=function(){return w};this.makeInPlaceCopy=function(){return new aa({anchor:b.anchor,source:i,style:h,endpoint:e})};this.isConnectedTo=function(o){var K=false;if(o)for(var y=0;y<b.connections.length;y++)if(b.connections[y].endpoints[1]==o){K=true;break}return K};this.isFloating=function(){return v!=null};this.isFull=function(){return x<1?false:b.connections.length>=x};this.setDragAllowedWhenFull=function(o){b.dragAllowedWhenFull=o};this.equals=function(o){return this.anchor.equals(o.anchor)&&
true};this.paint=function(o,K,y){u&&u.debug("Painting Endpoint with elementId ["+z+"]; anchorPoint is ["+o+"]");if(o==null){o=p[z];var V=f[z];if(o==null||V==null){W(z);o=p[z];V=f[z]}o=b.anchor.compute([o.left,o.top],V,b)}e.paint(o,b.anchor.getOrientation(),y||b.canvas,h,K||h)};this.removeConnection=this.detach;if(a.isSource&&c.CurrentLibrary.isDragSupported(i)){var G=null;var j=d=null,M=false,P=null,J=a.dragOptions||{},Q=c.extend({},c.CurrentLibrary.defaultDragOptions);J=c.extend(Q,J);J.scope=J.scope||
b.scope;Q=c.CurrentLibrary.dragEvents.start;var X=c.CurrentLibrary.dragEvents.stop,U=c.CurrentLibrary.dragEvents.drag;J[Q]=T(J[Q],function(){j=b.connections.length<x?null:b.connections[0];if(b.isFull()&&!b.dragAllowedWhenFull)return false;W(z);I=b.makeInPlaceCopy();I.paint();G=document.createElement("div");var o=F(G),K=G,y=b.container;y?c.CurrentLibrary.appendElement(K,y):document.body.appendChild(K);K=""+new String((new Date).getTime());da(o,"id",K);W(K);da(F(b.canvas),"dragId",K);da(F(b.canvas),
"elId",z);y=new na({reference:b.anchor,referenceCanvas:b.canvas});v=new aa({style:{fillStyle:"rgba(0,0,0,0)"},endpoint:e,anchor:y,source:o});if(j==null){b.anchor.locked=true;j=new la({sourceEndpoint:b,targetEndpoint:v,source:F(i),target:F(G),anchors:[b.anchor,y],paintStyle:a.connectorStyle,connector:a.connector})}else{M=true;o=j.sourceId==z?0:1;j.floatingAnchorIndex=o;b.removeConnection(j);if(o==0){P=[j.source,j.sourceId];j.source=F(G);j.sourceId=K}else{P=[j.target,j.targetId];j.target=F(G);j.targetId=
K}j.endpoints[o==0?1:0].anchor.locked=true;j.suspendedEndpoint=j.endpoints[o];j.endpoints[o]=v}D[K]=j;v.addConnection(j);H(l,K,v)});J[U]=T(J[U],function(){var o=c.CurrentLibrary.getUIPosition(arguments);c.CurrentLibrary.setOffset(G,o);N(F(G),o)});J[X]=T(J[X],function(){Z(l,d,v);for(var o=[G,v.canvas],K=0;K<o.length;K++)S(o[K],i);S(I.canvas,i);o=j.floatingAnchorIndex==null?1:j.floatingAnchorIndex;j.endpoints[o==0?1:0].anchor.locked=false;if(j.endpoints[o]==v)if(M&&j.suspendedEndpoint)if(C){j.floatingAnchorIndex=
null;if(o==0){j.source=P[0];j.sourceId=P[1]}else{j.target=P[0];j.targetId=P[1]}j.endpoints[o]=j.suspendedEndpoint;j.suspendedEndpoint.addConnection(j);c.repaint(P[1])}else{j.endpoints[0].removeConnection(j);j.endpoints[1].removeConnection(j);S(j.canvas,b.container);Z(r,j.scope,j);ba("jsPlumbConnectionDetached",{source:j.source,target:j.target,sourceId:j.sourceId,targetId:j.targetId,sourceEndpoint:j.endpoints[0],targetEndpoint:j.endpoints[1]})}else{S(j.canvas,b.container);b.removeConnection(j)}b.anchor.locked=
false;j=null;delete v;delete I;b.paint()});Q=F(b.canvas);c.CurrentLibrary.initDraggable(Q,J)}if(a.isTarget&&c.CurrentLibrary.isDropSupported(i)){J=a.dropOptions||g.Defaults.DropOptions||c.Defaults.DropOptions;J=c.extend({},J);J.scope=J.scope||b.scope;Q=c.CurrentLibrary.dragEvents.drop;X=c.CurrentLibrary.dragEvents.over;U=c.CurrentLibrary.dragEvents.out;J[Q]=T(J[Q],function(){var o=c.CurrentLibrary.getDragObject(arguments),K=O(F(o),"dragId");o=O(F(o),"elId");var y=D[K],V=y.floatingAnchorIndex==null?
1:y.floatingAnchorIndex,pa=V==0?1:0;if(!b.isFull()&&!(V==0&&!b.isSource)&&!(V==1&&!b.isTarget)){if(V==0){y.source=i;y.sourceId=z}else{y.target=i;y.targetId=z}y.endpoints[V].removeConnection(y);y.suspendedEndpoint&&y.suspendedEndpoint.removeConnection(y);y.endpoints[V]=b;b.addConnection(y);y.endpoints[pa].addConnection(y);H(r,y.scope,y);$(i,a.draggable,{});c.repaint(o);ba("jsPlumbConnection",{source:y.source,target:y.target,sourceId:y.sourceId,targetId:y.targetId,sourceEndpoint:y.endpoints[0],targetEndpoint:y.endpoints[1]})}delete D[K]});
J[X]=T(J[X],function(){var o=c.CurrentLibrary.getDragObject(arguments);o=O(F(o),"dragId");o=D[o];o.endpoints[o.floatingAnchorIndex==null?1:o.floatingAnchorIndex].anchor.over(b.anchor)});J[U]=T(J[U],function(){var o=c.CurrentLibrary.getDragObject(arguments);o=O(F(o),"dragId");o=D[o];o.endpoints[o.floatingAnchorIndex==null?1:o.floatingAnchorIndex].anchor.out()});c.CurrentLibrary.initDroppable(F(b.canvas),J)}return b};this.Defaults={Anchor:null,Anchors:[null,null],BackgroundPaintStyle:null,Connector:null,
Container:null,DragOptions:{},DropOptions:{},Endpoint:null,Endpoints:[null,null],EndpointStyle:{fillStyle:null},EndpointStyles:[null,null],LabelStyle:{fillStyle:"rgba(0,0,0,0)",color:"black"},MaxConnections:null,PaintStyle:{lineWidth:10,strokeStyle:"red"},Scope:"_jsPlumb_DefaultScope"};this.connectorClass="_jsPlumb_connector";this.endpointClass="_jsPlumb_endpoint";this.Anchors={};this.Connectors={};this.Endpoints={};this.Overlays={};this.addEndpoint=function(a,b){b=c.extend({},b);var d=F(a),e=O(d,
"id");b.source=d;W(e);d=new aa(b);H(l,e,d);var h=p[e];e=d.anchor.compute([h.left,h.top],f[e],d);d.paint(e);return d};this.addEndpoints=function(a,b){for(var d=[],e=0;e<b.length;e++)d.push(g.addEndpoint(a,b[e]));return d};this.animate=function(a,b,d){var e=F(a),h=O(a,"id");d=d||{};a=c.CurrentLibrary.dragEvents.step;var i=c.CurrentLibrary.dragEvents.complete;d[a]=T(d[a],function(){g.repaint(h)});d[i]=T(d[i],function(){g.repaint(h)});c.CurrentLibrary.animate(e,b,d)};this.clearCache=function(){delete ca;
ca={}};this.autoConnect=function(a){var b=[],d=[],e=a.endpoint||g.Defaults.EndpointStyle||c.Defaults.EndpointStyle,h=x||g.Defaults.DynamicAnchors||c.Defaults.DynamicAnchors,i=function(C,v){for(var I=0;I<C.length;I++)v.push(C[I])},w=a.source,z=a.target,x=a.anchors;typeof w=="string"?b.push(F(w)):i(w,b);typeof z=="string"?d.push(F(z)):i(z,d);a=c.extend(a,{source:null,target:null,anchors:null});for(i=0;i<b.length;i++)for(w=0;w<d.length;w++){z=c.addEndpoint(b[i],c.extend({anchor:c.makeDynamicAnchor(h)},
e));x=c.addEndpoint(d[w],c.extend({anchor:c.makeDynamicAnchor(h)},e));g.connect(c.extend(a,{sourceEndpoint:z,targetEndpoint:x}))}};this.connect=function(a){var b=c.extend({},a);if(a.uuids){var d=function(e){var h=m[a.uuids[e]];if(!h)throw"Endpoint with UUID "+a.uuids[e]+" not found.";return h};b.sourceEndpoint=d(0);b.targetEndpoint=d(1)}if(!(b.sourceEndpoint&&b.sourceEndpoint.isFull()))if(!(b.targetEndpoint&&b.targetEndpoint.isFull())){b=new la(b);H(r,b.scope,b);ba("jsPlumbConnection",{source:b.source,
target:b.target,sourceId:b.sourceId,targetId:b.targetId,sourceEndpoint:b.endpoints[0],targetEndpoint:b.endpoints[1]});N(b.source);return b}};var fa=function(a){ba("jsPlumbConnectionDetached",{source:a.source,target:a.target,sourceId:a.sourceId,targetId:a.targetId,sourceEndpoint:a.endpoints[0],targetEndpoint:a.endpoints[1]})};this.detach=function(a,b){if(arguments.length==2){var d=function(e){if(e.sourceId==a&&e.targetId==b||e.targetId==a&&e.sourceId==b){S(e.canvas,e.container);e.endpoints[0].removeConnection(e);
e.endpoints[1].removeConnection(e);Z(r,e.scope,e);fa(e);return true}};ea(a,d)}else if(arguments.length==1){d=c.extend({},a);if(d.uuids)m[d.uuids[0]].detachFrom(m[d.uuids[1]]);else if(d.sourceEndpoint&&d.targetEndpoint)d.sourceEndpoint.detachFrom(d.targetEndpoint);else{a=Y(d.source);b=Y(d.target);d=function(e){if(e.sourceId==a&&e.targetId==b||e.targetId==a&&e.sourceId==b){S(e.canvas,e.container);e.endpoints[0].removeConnection(e);e.endpoints[1].removeConnection(e);Z(r,e.scope,e);fa(e);return true}};
ea(a,d)}}};this.detachAll=function(a){a=O(a,"id");if((a=l[a])&&a.length)for(var b=0;b<a.length;b++){var d=a[b].connections.length;if(d>0)for(var e=0;e<d;e++){var h=a[b].connections[0];S(h.canvas,h.container);h.endpoints[0].removeConnection(h);h.endpoints[1].removeConnection(h);Z(r,h.scope,h);fa(h)}}};this.detachEverything=function(){for(var a in l){var b=l[a];if(b&&b.length)for(var d=0;d<b.length;d++){var e=b[d].connections.length;if(e>0)for(var h=0;h<e;h++){var i=b[d].connections[0];S(i.canvas,i.container);
i.endpoints[0].removeConnection(i);i.endpoints[1].removeConnection(i);fa(i)}}}delete r;r={}};this.draggable=function(a,b){if(typeof a=="object"&&a.length)for(var d=0;d<a.length;d++){var e=F(a[d]);e&&$(e,true,b)}else(e=F(a))&&$(e,true,b)};this.extend=function(a,b){return c.CurrentLibrary.extend(a,b)};this.getConnections=function(a){var b={};a=a||{};var d=function(z){var x=[];if(z)if(typeof z=="string")x.push(z);else x=z;return x},e=d(a.scope),h=d(a.source);a=d(a.target);for(var i in r)if(e.length>
0?B(e,i)!=-1:true){b[i]=[];for(d=0;d<r[i].length;d++){var w=r[i][d];(h.length>0?B(h,w.sourceId)!=-1:true)&&(a.length>0?B(a,w.targetId)!=-1:true)&&b[i].push({sourceId:w.sourceId,targetId:w.targetId,source:w.source,target:w.target,sourceEndpoint:w.endpoints[0],targetEndpoint:w.endpoints[1]})}}return b};this.getDefaultScope=function(){return E};this.getEndpoint=function(a){return m[a]};this.getId=Y;this.hide=function(a){ja(a,"none")};this.makeAnchor=function(a,b){var d={};if(arguments.length==1)c.extend(d,
a);else{d={x:a,y:b};if(arguments.length>=4)d.orientation=[arguments[2],arguments[3]];if(arguments.length==6)d.offsets=[arguments[4],arguments[5]]}var e=new ka(d);e.clone=function(){return new ka(d)};return e};this.makeDynamicAnchor=function(a){return new oa(a)};this.repaint=function(a){var b=function(e){e=F(e);N(e)};if(typeof a=="object")for(var d=0;d<a.length;d++)b(a[d]);else b(a)};this.repaintEverything=function(){for(var a in l)N(F(a))};this.removeAllEndpoints=function(a){a=O(a,"id");c.detachAll(a);
var b=l[a],d;for(d in b)S(b[d].canvas,b[d].getElement());l[a]=[]};this.removeEveryEndpoint=function(){for(var a in l){var b=l[a];if(b&&b.length)for(var d=0;d<b.length;d++)S(b[d].canvas,b[d].container)}delete l;l={}};this.removeEndpoint=function(a,b){var d=O(a,"id");l[d]&&Z(l,d,b)&&S(b.canvas,b.getElement())};this.reset=function(){this.detachEverything();this.removeEveryEndpoint();this.clearCache()};this.setAutomaticRepaint=function(){};this.setDefaultNewCanvasSize=function(a){L=a};this.setDefaultScope=
function(a){E=a};this.setDraggable=function(a,b){return R(a,function(d,e){s[e]=b;c.CurrentLibrary.isDragSupported(d)&&c.CurrentLibrary.setDraggable(d,b)})};this.setDraggableByDefault=function(a){A=a};this.setDebugLog=function(a){u=a};this.setRepaintFunction=function(){};this.show=function(a){ja(a,"block")};this.sizeCanvas=function(a,b,d,e,h){if(a){a.style.height=h+"px";a.height=h;a.style.width=e+"px";a.width=e;a.style.left=b+"px";a.style.top=d+"px"}};this.getTestHarness=function(){return{endpointCount:function(a){return(a=
l[a])?a.length:0},connectionCount:function(a){a=a||E;return(a=r[a])?a.length:0},findIndex:B,getId:Y}};this.toggleVisible=this.toggle=ma;this.toggleDraggable=function(a){return R(a,function(b,d){var e=s[d]==null?A:s[d];e=!e;s[d]=e;c.CurrentLibrary.setDraggable(b,e);return e})};this.unload=function(){delete l;delete p;delete f;delete D;delete s};this.wrap=T;this.addListener=function(a,b){if(typeof a=="object"&&a.length)for(var d=0;d<a.length;d++)H(q,a[d],b);else H(q,a,b)}},c=window.jsPlumb=new n;c.getInstance=
function(g){var k=new n;g&&c.extend(k.Defaults,g);return k}})();
(function(){jsPlumb.Anchors.TopCenter=jsPlumb.makeAnchor(0.5,0,0,-1);jsPlumb.Anchors.BottomCenter=jsPlumb.makeAnchor(0.5,1,0,1);jsPlumb.Anchors.LeftMiddle=jsPlumb.makeAnchor(0,0.5,-1,0);jsPlumb.Anchors.RightMiddle=jsPlumb.makeAnchor(1,0.5,1,0);jsPlumb.Anchors.Center=jsPlumb.makeAnchor(0.5,0.5,0,0);jsPlumb.Anchors.TopRight=jsPlumb.makeAnchor(1,0,0,-1);jsPlumb.Anchors.BottomRight=jsPlumb.makeAnchor(1,1,0,1);jsPlumb.Anchors.TopLeft=jsPlumb.makeAnchor(0,0,0,-1);jsPlumb.Anchors.BottomLeft=jsPlumb.makeAnchor(0,
1,0,1);jsPlumb.Anchors.AutoDefault=function(){return jsPlumb.makeDynamicAnchor([jsPlumb.Anchors.TopCenter,jsPlumb.Anchors.RightMiddle,jsPlumb.Anchors.BottomCenter,jsPlumb.Anchors.LeftMiddle])};jsPlumb.Defaults.DynamicAnchors=[jsPlumb.Anchors.TopCenter,jsPlumb.Anchors.RightMiddle,jsPlumb.Anchors.BottomCenter,jsPlumb.Anchors.LeftMiddle];jsPlumb.Connectors.Straight=function(){var n=this,c=null,g,k,u,t,l,m,r,p,D;this.compute=function(s,A,f,q,E,L){f=Math.abs(s[0]-A[0]);q=Math.abs(s[1]-A[1]);var B=0.45*
f,H=0.45*q;f*=1.9;q*=1.9;var N=Math.min(s[0],A[0])-B,R=Math.min(s[1],A[1])-H;E=Math.max(2*E,L);if(f<E){f=E;N=s[0]+(A[0]-s[0])/2-E/2;B=(f-Math.abs(s[0]-A[0]))/2}if(q<E){q=E;R=s[1]+(A[1]-s[1])/2-E/2;H=(q-Math.abs(s[1]-A[1]))/2}m=s[0]<A[0]?B:f-B;r=s[1]<A[1]?H:q-H;p=s[0]<A[0]?f-B:B;D=s[1]<A[1]?q-H:H;c=[N,R,f,q,m,r,p,D];u=p-m;t=D-r;g=t/u;k=-1*(g*m-r);l=Math.atan(g);return c};this.paint=function(s,A){A.beginPath();A.moveTo(s[4],s[5]);A.lineTo(s[6],s[7]);A.stroke()};this.pointOnPath=function(s){s=m+s*u;
return[s,g==Infinity?s+k:g*s+k]};this.gradientAtPoint=function(){return g};this.pointAlongPathFrom=function(s,A){var f=n.pointOnPath(s),q=A>0?1:-1,E=Math.abs(A*Math.sin(l));if(r>D)E*=-1;var L=Math.abs(A*Math.cos(l));if(m>p)L*=-1;return[f[0]+q*L,f[1]+q*E]};this.perpendicularToPathAt=function(s,A,f){s=n.pointAlongPathFrom(s,A);A=n.gradientAtPoint(s.location);var q=Math.atan(-1/A);A=f/2*Math.sin(q);f=f/2*Math.cos(q);return[[s[0]+f,s[1]+A],[s[0]-f,s[1]-A]]};this.createGradient=function(s,A){return A.createLinearGradient(s[4],
s[5],s[6],s[7])}};jsPlumb.Connectors.Bezier=function(n){var c=this;this.majorAnchor=n||150;this.minorAnchor=10;var g=null;this._findControlPoint=function(f,q,E,L,B){L=L.getOrientation();B=B.getOrientation();var H=[],N=c.majorAnchor,R=c.minorAnchor;if(L[0]!=B[0]||L[1]==B[1]){B[0]==0?H.push(E[0]<q[0]?f[0]+R:f[0]-R):H.push(f[0]+N*B[0]);B[1]==0?H.push(E[1]<q[1]?f[1]+R:f[1]-R):H.push(f[1]+N*L[1])}else{L[0]==0?H.push(q[0]<E[0]?f[0]+R:f[0]-R):H.push(f[0]-N*L[0]);L[1]==0?H.push(q[1]<E[1]?f[1]+R:f[1]-R):H.push(f[1]+
N*B[1])}return H};var k,u,t,l,m,r,p,D,s;this.compute=function(f,q,E,L,B,H){B=B||0;D=Math.abs(f[0]-q[0])+B;s=Math.abs(f[1]-q[1])+B;r=Math.min(f[0],q[0])-B/2;p=Math.min(f[1],q[1])-B/2;t=f[0]<q[0]?D-B/2:B/2;m=f[1]<q[1]?s-B/2:B/2;l=f[0]<q[0]?B/2:D-B/2;_ty=f[1]<q[1]?B/2:s-B/2;k=c._findControlPoint([t,m],f,q,E,L);u=c._findControlPoint([l,_ty],q,f,L,E);f=Math.min(Math.min(t,l),Math.min(k[0],u[0]));q=Math.max(Math.max(t,l),Math.max(k[0],u[0]));if(q>D)D=q;if(f<0){r+=f;f=Math.abs(f);D+=f;k[0]+=f;t+=f;l+=f;
u[0]+=f}f=Math.min(Math.min(m,_ty),Math.min(k[1],u[1]));q=Math.max(Math.max(m,_ty),Math.max(k[1],u[1]));if(q>s)s=q;if(f<0){p+=f;f=Math.abs(f);s+=f;k[1]+=f;m+=f;_ty+=f;u[1]+=f}if(H&&D<H){f=(H-D)/2;D=H;r-=f;t+=f;l+=f;k[0]+=f;u[0]+=f}return g=[r,p,D,s,t,m,l,_ty,k[0],k[1],u[0],u[1]]};this.paint=function(f,q){q.beginPath();q.moveTo(f[4],f[5]);q.bezierCurveTo(f[8],f[9],f[10],f[11],f[6],f[7]);q.stroke()};this.pointOnPath=function(f){return[t*f*f*f+k[0]*3*f*f*(1-f)+u[0]*3*f*(1-f)*(1-f)+l*(1-f)*(1-f)*(1-f),
m*f*f*f+k[1]*3*f*f*(1-f)+u[1]*3*f*(1-f)*(1-f)+_ty*(1-f)*(1-f)*(1-f)]};this.gradientAtPoint=function(f){var q=c.pointOnPath(f);f=[t*f*f+k[0]*2*f*(1-f)+u[0]*(1-f)*(1-f),m*f*f+k[1]*2*f*(1-f)+u[1]*(1-f)*(1-f)];return Math.atan((f[1]-q[1])/(f[0]-q[0]))};var A=function(f,q){for(var E=c.pointOnPath(f),L=0,B=f,H=q>0?1:-1,N=null;L<Math.abs(q);){B+=0.0050*H;N=c.pointOnPath(B);L+=Math.sqrt(Math.pow(N[0]-E[0],2)+Math.pow(N[1]-E[1],2));E=N}return{point:N,location:B}};this.pointAlongPathFrom=function(f,q){return A(f,
q).point};this.perpendicularToPathAt=function(f,q,E){f=A(f,q);q=c.gradientAtPoint(f.location);var L=Math.atan(-1/q);q=E/2*Math.sin(L);E=E/2*Math.cos(L);return[[f.point[0]+E,f.point[1]+q],[f.point[0]-E,f.point[1]-q]]};this.createGradient=function(f,q,E){return E?q.createLinearGradient(f[4],f[5],f[6],f[7]):q.createLinearGradient(f[6],f[7],f[4],f[5])}};jsPlumb.Endpoints.Dot=function(n){n=n||{radius:10};var c=this;this.radius=n.radius;var g=0.5*this.radius,k=this.radius/3,u=function(t){try{return parseInt(t)}catch(l){if(t.substring(t.length-
1)=="%")return parseInt(t.substring(0,t-1))}};this.paint=function(t,l,m,r,p){var D=r.radius||c.radius;jsPlumb.sizeCanvas(m,t[0]-D,t[1]-D,D*2,D*2);t=m.getContext("2d");m=jsPlumb.extend({},r);if(m.fillStyle==null)m.fillStyle=p.strokeStyle;jsPlumb.extend(t,m);p=/MSIE/.test(navigator.userAgent)&&!window.opera;if(r.gradient&&!p){p=r.gradient;m=g;var s=k;if(p.offset)m=u(p.offset);if(p.innerRadius)s=u(p.innerRadius);p=[m,s];l=t.createRadialGradient(D,D,D,D+(l[0]==1?p[0]*-1:p[0]),D+(l[1]==1?p[0]*-1:p[0]),
p[1]);for(p=0;p<r.gradient.stops.length;p++)l.addColorStop(r.gradient.stops[p][0],r.gradient.stops[p][1]);t.fillStyle=l}t.beginPath();t.arc(D,D,D,0,Math.PI*2,true);t.closePath();t.fill()}};jsPlumb.Endpoints.Rectangle=function(n){n=n||{width:20,height:20};var c=this;this.width=n.width;this.height=n.height;this.paint=function(g,k,u,t,l){var m=t.width||c.width,r=t.height||c.height;jsPlumb.sizeCanvas(u,g[0]-m/2,g[1]-r/2,m,r);g=u.getContext("2d");u=jsPlumb.extend({},t);if(u.fillStyle==null)u.fillStyle=
l.strokeStyle;jsPlumb.extend(g,u);l=/MSIE/.test(navigator.userAgent)&&!window.opera;if(t.gradient&&!l){k=g.createLinearGradient(k[0]==1?m:k[0]==0?m/2:0,k[1]==1?r:k[1]==0?r/2:0,k[0]==-1?m:k[0]==0?r/2:0,k[1]==-1?r:k[1]==0?r/2:0);for(l=0;l<t.gradient.stops.length;l++)k.addColorStop(t.gradient.stops[l][0],t.gradient.stops[l][1]);g.fillStyle=k}g.beginPath();g.rect(0,0,m,r);g.closePath();g.fill()}};jsPlumb.Endpoints.Triangle=function(n){n=n||{width:15,height:15};var c=this;this.width=n.width;this.height=
n.height;this.paint=function(g,k,u,t){var l=t.width||c.width,m=t.height||c.height;jsPlumb.sizeCanvas(u,g[0]-l/2,g[1]-m/2,l,m);g=u.getContext("2d");var r=u=0,p=0;if(k[0]==1){u=l;r=m;p=180}if(k[1]==-1){u=l;p=90}if(k[1]==1){r=m;p=-90}g.fillStyle=t.fillStyle;g.translate(u,r);g.rotate(p*Math.PI/180);g.beginPath();g.moveTo(0,0);g.lineTo(l/2,m/2);g.lineTo(0,m);g.closePath();g.fill()}};jsPlumb.Endpoints.Image=function(n){var c=this;this.img=new Image;this.img.onload=function(){c.ready=true};this.img.src=
n.url;var g=function(k,u,t,l){u=c.img.width||l.width;l=c.img.height||l.height;jsPlumb.sizeCanvas(t,k[0]-u/2,k[1]-l/2,u,l);t.getContext("2d").drawImage(c.img,0,0)};this.paint=function(k,u,t,l,m){c.ready?g(k,u,t,l,m):window.setTimeout(function(){c.paint(k,u,t,l,m)},200)}};jsPlumb.Overlays.Arrow=function(n){n=n||{};var c=this,g=n.length||20,k=n.width||20,u=n.fillStyle||"black",t=n.strokeStyle,l=n.lineWidth||1;this.loc=n.location||0.5;var m=n.foldback||0.623;this.computeMaxSize=function(){return k*1.5};
this.draw=function(r,p){var D=r.pointAlongPathFrom(c.loc,g/2);r.pointAlongPathFrom(c.loc,-g/2);var s=r.perpendicularToPathAt(c.loc,-g/2,k),A;A=c.loc;A=m==0.5?r.pointOnPath(A):r.pointAlongPathFrom(A,g*(0.5-m));p.lineWidth=l;p.beginPath();p.moveTo(D[0],D[1]);p.lineTo(s[0][0],s[0][1]);p.lineTo(A[0],A[1]);p.lineTo(s[1][0],s[1][1]);p.lineTo(D[0],D[1]);p.closePath();if(t){p.strokeStyle=t;p.stroke()}p.fillStyle=u;p.fill()}};jsPlumb.Overlays.PlainArrow=function(n){n=n||{};n=jsPlumb.extend(n,{foldback:1});
jsPlumb.Overlays.Arrow.call(this,n)};jsPlumb.Overlays.Diamond=function(n){n=n||{};n=jsPlumb.extend(n,{length:(n.length||40)/2,foldback:2});jsPlumb.Overlays.Arrow.call(this,n)};jsPlumb.Overlays.Label=function(n){this.labelStyle=n.labelStyle||jsPlumb.Defaults.LabelStyle;this.label=n.label;var c=this,g=null,k=null,u=null,t=null;this.location=n.location||0.5;this.computeMaxSize=function(l,m){if(u){m.save();if(c.labelStyle.font)m.font=c.labelStyle.font;var r=m.measureText(u).width,p=m.measureText("M").width;
t=c.labelStyle.padding||0.25;g=r+2*r*t;k=p+2*p*t;m.restore();return Math.max(g,k)*1.5}return 0};this.draw=function(l,m){if(u=typeof c.label=="function"?c.label(c):c.label){if(c.labelStyle.font)m.font=c.labelStyle.font;var r=m.measureText(u).width,p=m.measureText("M").width;t=c.labelStyle.padding||0.25;g=r+2*r*t;k=p+2*p*t;r=l.pointOnPath(c.location);if(c.labelStyle.font)m.font=c.labelStyle.font;m.fillStyle=c.labelStyle.fillStyle?c.labelStyle.fillStyle:"rgba(0,0,0,0)";m.fillRect(r[0]-g/2,r[1]-k/2,g,
k);if(c.labelStyle.color)m.fillStyle=c.labelStyle.color;m.textBaseline="middle";m.textAlign="center";m.fillText(u,r[0],r[1]);if(c.labelStyle.borderWidth>0){m.strokeStyle=c.labelStyle.borderStyle||"black";m.strokeRect(r[0]-g/2,r[1]-k/2,g,k)}}}}})();
(function(n){n.fn.plumb=function(c){c=n.extend({},c);return this.each(function(){var g=n.extend({source:n(this)},c);jsPlumb.connect(g)})};n.fn.detach=function(c){return this.each(function(){if(c){var g=n(this).attr("id");if(typeof c=="string")c=[c];for(var k=0;k<c.length;k++)jsPlumb.detach(g,c[k])}})};n.fn.detachAll=function(){return this.each(function(){var c=n(this).attr("id");jsPlumb.detachAll(c)})};n.fn.addEndpoint=function(c){var g=[];this.each(function(){g.push(jsPlumb.addEndpoint(n(this).attr("id"),
c))});return g[0]};n.fn.addEndpoints=function(c){var g=[];return this.each(function(){for(var k=jsPlumb.addEndpoints(n(this).attr("id"),c),u=0;u<k.length;u++)g.push(k[u])})};n.fn.removeEndpoint=function(c){this.each(function(){jsPlumb.removeEndpoint(n(this).attr("id"),c)})}})(jQuery);
(function(n){jsPlumb.CurrentLibrary={dragEvents:{start:"start",stop:"stop",drag:"drag",step:"step",over:"over",out:"out",drop:"drop",complete:"complete"},bind:function(c,g,k){c=jsPlumb.CurrentLibrary.getElementObject(c);c.bind(g,k)},appendElement:function(c,g){jsPlumb.CurrentLibrary.getElementObject(g).append(c)},extend:function(c,g){return n.extend(c,g)},getElementObject:function(c){return typeof c=="string"?n("#"+c):n(c)},getOffset:function(c){return c.offset()},getSize:function(c){return[c.outerWidth(),
c.outerHeight()]},getAttribute:function(c,g){return c.attr(g)},setAttribute:function(c,g,k){c.attr(g,k)},addClass:function(c,g){c.addClass(g)},initDraggable:function(c,g){g.helper=null;g.scope=g.scope||jsPlumb.Defaults.Scope;c.draggable(g)},isDragSupported:function(c){return c.draggable},setDraggable:function(c,g){c.draggable("option","disabled",!g)},initDroppable:function(c,g){g.scope=g.scope||jsPlumb.Defaults.Scope;c.droppable(g)},isDropSupported:function(c){return c.droppable},animate:function(c,
g,k){c.animate(g,k)},getUIPosition:function(c){c=c[1];return c.offset||c.absolutePosition},getDragObject:function(c){return c[1].draggable},removeElement:function(c){jsPlumb.CurrentLibrary.getElementObject(c).remove()},getScrollLeft:function(c){return c.scrollLeft()},getScrollTop:function(c){return c.scrollTop()},setOffset:function(c,g){jsPlumb.CurrentLibrary.getElementObject(c).offset(g)}}})(jQuery);
