(function(){var m=function(){var f=this,g=/MSIE/.test(navigator.userAgent)&&!window.opera,o=null,n=function(){c.repaintEverything()},i=true,j={},v={},s={},x=[],G={},H={},L=true,D=[],da={},Y="DEFAULT",ea=1200,Q=function(a,b,d){var e=function(l,p){if(l===p)return true;else if(typeof l=="object"&&typeof p=="object"){var q=true;for(var t in l)if(!e(l[t],p[t])){q=false;break}for(t in p)if(!e(p[t],l[t])){q=false;break}return q}};d=+d||0;for(var h=a.length;d=0){delete a[d];a.splice(d,1);return true}}return false},ja=function(a,b){var d=F(a,"id");ba(d,function(e){e.canvas.style.display=b})},na=function(a){ba(a,function(b){b.canvas.style.display="none"==b.canvas.style.display?"block":"none"})},O=function(a,b,d){if(d||b==null){b=w(a);D[a]=ha(b);x[a]=ga(b)}else x[a]=b},J=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,l,p){e=[h[0]+b.x*l[0]+b.offsets[0],h[1]+b.y*l[1]+b.offsets[1]];l=p?p.container:null;h={left:0,top:0};if(l!=null){var q=w(l);l=ga(q);p=c.CurrentLibrary.getScrollLeft(q);q=c.CurrentLibrary.getScrollTop(q);h.left=l.left-p;h.top=l.top-q;e[0]-=h.left;e[1]-=h.top}return e};this.getOrientation=function(){return d};this.equals=function(h){if(!h)return false; var l=h.getOrientation(),p=this.getOrientation();return this.x==h.x&&this.y==h.y&&this.offsets[0]==h.offsets[0]&&this.offsets[1]==h.offsets[1]&&p[0]==l[0]&&p[1]==l[1]}},oa=function(a){var b=a.reference,d=ha(w(a.referenceCanvas)),e=0,h=0,l=null;this.compute=function(p){h=e=0;return[p[0]+d[0]/2,p[1]+d[1]/2]};this.getOrientation=function(){if(l)return l;else{var p=b.getOrientation();return[Math.abs(p[0])*e*-1,Math.abs(p[1])*h*-1]}};this.over=function(p){l=p.getOrientation()};this.out=function(){l=null}}, la=function(a){var b=this,d=new String("_jsplumb_c_"+(new Date).getTime());this.getId=function(){return d};this.container=a.container||f.Defaults.Container;this.source=w(a.source);this.target=w(a.target);if(a.sourceEndpoint)this.source=a.sourceEndpoint.getElement();if(a.targetEndpoint)this.target=a.targetEndpoint.getElement();this.sourceId=F(this.source,"id");this.targetId=F(this.target,"id");this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.scope=a.scope;this.endpoints=[];this.endpointStyles= [];var e=function(p,q,t,E){if(p){b.endpoints[q]=p;p.addConnection(b)}else{if(!t.endpoints)t.endpoints=[null,null];p=t.endpoints[q]||t.endpoint||f.Defaults.Endpoints[q]||c.Defaults.Endpoints[q]||f.Defaults.Endpoint||c.Defaults.Endpoint||new c.Endpoints.Dot;if(!t.endpointStyles)t.endpointStyles=[null,null];var A=t.endpointStyles[q]||t.endpointStyle||f.Defaults.EndpointStyles[q]||c.Defaults.EndpointStyles[q]||f.Defaults.EndpointStyle||c.Defaults.EndpointStyle,y=t.anchors?t.anchors[q]:f.Defaults.Anchors[q]|| c.Defaults.Anchors[q]||f.Defaults.Anchor||c.Defaults.Anchor||c.Anchors.BottomCenter,C=t.uuids?t.uuids[q]:null;t=t.uuids?new V({style:A,endpoint:p,connections:[b],uuid:C,anchor:y,source:E,container:b.container}):new V({style:A,endpoint:p,connections:[b],anchor:y,source:E,container:b.container});return b.endpoints[q]=t}},h=e(a.sourceEndpoint,0,a,b.source);h&&N(j,this.sourceId,h);(e=e(a.targetEndpoint,1,a,b.target))&&N(j,this.targetId,e);if(!this.scope)this.scope=this.endpoints[0].scope;this.connector= this.endpoints[0].connector||this.endpoints[1].connector||a.connector||f.Defaults.Connector||c.Defaults.Connector||new c.Connectors.Bezier;this.paintStyle=this.endpoints[0].connectorStyle||this.endpoints[1].connectorStyle||a.paintStyle||f.Defaults.PaintStyle||c.Defaults.PaintStyle;O(this.sourceId);O(this.targetId);e=x[this.sourceId];h=D[this.sourceId];e=this.endpoints[0].anchor.compute([e.left,e.top],h,this.endpoints[0]);this.endpoints[0].paint(e);e=x[this.targetId];h=D[this.targetId];e=this.endpoints[1].anchor.compute([e.left, e.top],h,this.endpoints[1]);this.endpoints[1].paint(e);var l=ia(c.connectorClass,b.container);this.canvas=l;this.paint=function(p,q,t){o&&o.debug("Painting Connection; element in motion is "+p+"; ui is ["+q+"]; recalc is ["+t+"]");var E=p!=this.sourceId,A=E?this.sourceId:this.targetId,y=E?0:1,C=E?1:0;if(this.canvas.getContext){O(p,q,t);O(A);t=x[p];q=x[A];p=D[p];var r=D[A];A=l.getContext("2d");t=this.endpoints[C].anchor.compute([t.left,t.top],p,this.endpoints[C]);this.endpoints[C].anchor.getOrientation(); q=this.endpoints[y].anchor.compute([q.left,q.top],r,this.endpoints[y]);this.endpoints[y].anchor.getOrientation();y=this.connector.compute(t,q,this.endpoints[C].anchor,this.endpoints[y].anchor,this.paintStyle.lineWidth);c.sizeCanvas(l,y[0],y[1],y[2],y[3]);c.extend(A,this.paintStyle);if(this.paintStyle.gradient&&!g){E=E?A.createLinearGradient(y[4],y[5],y[6],y[7]):A.createLinearGradient(y[6],y[7],y[4],y[5]);for(C=0;C=0){var u=k.endpoints[0]==b?k.endpoints[1]:k.endpoints[0];b.connections.splice(z,1);u.detach(k)}};this.detachAll=function(){for(;b.connections.length>0;)b.detach(b.connections[0])};this.detachFrom=function(k){for(var z=[],u=0;u=t};this.setDragAllowedWhenFull=function(k){b.dragAllowedWhenFull=k};this.equals=function(k){return this.anchor.equals(k.anchor)&& true};this.paint=function(k,z,u){o&&o.debug("Painting Endpoint with elementId ["+q+"]; anchorPoint is ["+k+"]");if(k==null){k=x[q];var K=D[q];if(k==null||K==null){O(q);k=x[q];K=D[q]}k=b.anchor.compute([k.left,k.top],K,b)}e.paint(k,b.anchor.getOrientation(),u||b.canvas,h,z||h)};this.removeConnection=this.detach;if(a.isSource&&c.CurrentLibrary.isDragSupported(l)){var C=null;var r=d=null,ma=false,P=null,B=a.dragOptions||{},M=c.extend({},c.CurrentLibrary.defaultDragOptions);B=c.extend(M,B);B.scope=B.scope|| b.scope;M=c.CurrentLibrary.dragEvents.start;var W=c.CurrentLibrary.dragEvents.stop,X=c.CurrentLibrary.dragEvents.drag;B[M]=J(B[M],function(){r=b.connections.length0)for(var e=0;e0)for(var h=0;h 0?Q(e,l)!=-1:true){b[l]=[];for(d=0;d0?Q(h,p.sourceId)!=-1:true)&&(a.length>0?Q(a,p.targetId)!=-1:true)&&b[l].push({sourceId:p.sourceId,targetId:p.targetId,source:p.source,target:p.target,sourceEndpoint:p.endpoints[0],targetEndpoint:p.endpoints[1]})}}return b};this.getDefaultScope=function(){return Y};this.getEndpoint=function(a){return v[a]};this.getId=R;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.repaint=function(a){var b=function(e){e=w(e);T(e)};if(typeof a=="object")for(var d=0;dj)j=o;if(g<0){s+=g;g=Math.abs(g);j+=g;D[0]+=g;G+=g;L+=g;f[0]+=g}g=Math.min(Math.min(H,i),Math.min(D[1], f[1]));o=Math.max(Math.max(H,i),Math.max(D[1],f[1]));if(o>v)v=o;if(g<0){x+=g;g=Math.abs(g);v+=g;D[1]+=g;H+=g;i+=g;f[1]+=g}return[s,x,j,v,G,H,L,i,D[0],D[1],f[0],f[1]]};this.paint=function(f,g){g.beginPath();g.moveTo(f[4],f[5]);g.bezierCurveTo(f[8],f[9],f[10],f[11],f[6],f[7]);g.stroke()}};jsPlumb.Endpoints.Dot=function(m){m=m||{radius:10};var c=this;this.radius=m.radius;var f=0.5*this.radius,g=this.radius/3,o=function(n){try{return parseInt(n)}catch(i){if(n.substring(n.length-1)=="%")return parseInt(n.substring(0, n-1))}};this.paint=function(n,i,j,v,s){var x=v.radius||c.radius;jsPlumb.sizeCanvas(j,n[0]-x,n[1]-x,x*2,x*2);n=j.getContext("2d");j=jsPlumb.extend({},v);if(j.fillStyle==null)j.fillStyle=s.strokeStyle;jsPlumb.extend(n,j);s=/MSIE/.test(navigator.userAgent)&&!window.opera;if(v.gradient&&!s){s=v.gradient;j=f;var G=g;if(s.offset)j=o(s.offset);if(s.innerRadius)G=o(s.innerRadius);s=[j,G];i=n.createRadialGradient(x,x,x,x+(i[0]==1?s[0]*-1:s[0]),x+(i[1]==1?s[0]*-1:s[0]),s[1]);for(s=0;s