UNPKG

70-react-network-diagrams

Version:
30 lines (28 loc) 223 kB
(function(ie,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react"),require("underscore"),require("prop-types"),require("d3-scale"),require("victor"),require("keymirror"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","underscore","prop-types","d3-scale","victor","keymirror","react-dom"],B):(ie=typeof globalThis<"u"?globalThis:ie||self,B(ie.ReactNetworkDiagrams={},ie.React,ie._,ie.PropTypes,ie.d3,ie.Vector$2,ie.keyMirror,ie.ReactDOM))})(this,function(ie,B,E,c,Mn,xe,it,vs){"use strict";function Cs(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const n in i)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>i[n]})}}return e.default=i,Object.freeze(e)}const k=Cs(B);var ft={exports:{}},st={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Nn;function Is(){if(Nn)return st;Nn=1;var i=B,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,u){var d,g={},b=null,m=null;u!==void 0&&(b=""+u),a.key!==void 0&&(b=""+a.key),a.ref!==void 0&&(m=a.ref);for(d in a)s.call(a,d)&&!r.hasOwnProperty(d)&&(g[d]=a[d]);if(l&&l.defaultProps)for(d in a=l.defaultProps,a)g[d]===void 0&&(g[d]=a[d]);return{$$typeof:e,type:l,key:b,ref:m,props:g,_owner:t.current}}return st.Fragment=n,st.jsx=o,st.jsxs=o,st}var rt={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Xn;function xs(){return Xn||(Xn=1,process.env.NODE_ENV!=="production"&&function(){var i=B,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),t=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),C=Symbol.iterator,I="@@iterator";function p(f){if(f===null||typeof f!="object")return null;var F=C&&f[C]||f[I];return typeof F=="function"?F:null}var v=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(f){{for(var F=arguments.length,R=new Array(F>1?F-1:0),P=1;P<F;P++)R[P-1]=arguments[P];w("error",f,R)}}function w(f,F,R){{var P=v.ReactDebugCurrentFrame,K=P.getStackAddendum();K!==""&&(F+="%s",R=R.concat([K]));var ne=R.map(function(z){return String(z)});ne.unshift("Warning: "+F),Function.prototype.apply.call(console[f],console,ne)}}var A=!1,x=!1,G=!1,S=!1,O=!1,N;N=Symbol.for("react.module.reference");function V(f){return!!(typeof f=="string"||typeof f=="function"||f===s||f===r||O||f===t||f===u||f===d||S||f===m||A||x||G||typeof f=="object"&&f!==null&&(f.$$typeof===b||f.$$typeof===g||f.$$typeof===o||f.$$typeof===l||f.$$typeof===a||f.$$typeof===N||f.getModuleId!==void 0))}function j(f,F,R){var P=f.displayName;if(P)return P;var K=F.displayName||F.name||"";return K!==""?R+"("+K+")":R}function T(f){return f.displayName||"Context"}function Y(f){if(f==null)return null;if(typeof f.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case s:return"Fragment";case n:return"Portal";case r:return"Profiler";case t:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof f=="object")switch(f.$$typeof){case l:var F=f;return T(F)+".Consumer";case o:var R=f;return T(R._context)+".Provider";case a:return j(f,f.render,"ForwardRef");case g:var P=f.displayName||null;return P!==null?P:Y(f.type)||"Memo";case b:{var K=f,ne=K._payload,z=K._init;try{return Y(z(ne))}catch{return null}}}return null}var q=Object.assign,L=0,H,ee,te,ae,he,Se,J;function se(){}se.__reactDisabledLog=!0;function be(){{if(L===0){H=console.log,ee=console.info,te=console.warn,ae=console.error,he=console.group,Se=console.groupCollapsed,J=console.groupEnd;var f={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:f,log:f,warn:f,error:f,group:f,groupCollapsed:f,groupEnd:f})}L++}}function fe(){{if(L--,L===0){var f={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:q({},f,{value:H}),info:q({},f,{value:ee}),warn:q({},f,{value:te}),error:q({},f,{value:ae}),group:q({},f,{value:he}),groupCollapsed:q({},f,{value:Se}),groupEnd:q({},f,{value:J})})}L<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=v.ReactCurrentDispatcher,le;function de(f,F,R){{if(le===void 0)try{throw Error()}catch(K){var P=K.stack.trim().match(/\n( *(at )?)/);le=P&&P[1]||""}return` `+le+f}}var Ce=!1,Ve;{var He=typeof WeakMap=="function"?WeakMap:Map;Ve=new He}function M(f,F){if(!f||Ce)return"";{var R=Ve.get(f);if(R!==void 0)return R}var P;Ce=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ne;ne=re.current,re.current=null,be();try{if(F){var z=function(){throw Error()};if(Object.defineProperty(z.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(z,[])}catch(Ae){P=Ae}Reflect.construct(f,[],z)}else{try{z.call()}catch(Ae){P=Ae}f.call(z.prototype)}}else{try{throw Error()}catch(Ae){P=Ae}f()}}catch(Ae){if(Ae&&P&&typeof Ae.stack=="string"){for(var Z=Ae.stack.split(` `),Ie=P.stack.split(` `),ue=Z.length-1,pe=Ie.length-1;ue>=1&&pe>=0&&Z[ue]!==Ie[pe];)pe--;for(;ue>=1&&pe>=0;ue--,pe--)if(Z[ue]!==Ie[pe]){if(ue!==1||pe!==1)do if(ue--,pe--,pe<0||Z[ue]!==Ie[pe]){var Be=` `+Z[ue].replace(" at new "," at ");return f.displayName&&Be.includes("<anonymous>")&&(Be=Be.replace("<anonymous>",f.displayName)),typeof f=="function"&&Ve.set(f,Be),Be}while(ue>=1&&pe>=0);break}}}finally{Ce=!1,re.current=ne,fe(),Error.prepareStackTrace=K}var nt=f?f.displayName||f.name:"",Ue=nt?de(nt):"";return typeof f=="function"&&Ve.set(f,Ue),Ue}function Le(f,F,R){return M(f,!1)}function Fe(f){var F=f.prototype;return!!(F&&F.isReactComponent)}function we(f,F,R){if(f==null)return"";if(typeof f=="function")return M(f,Fe(f));if(typeof f=="string")return de(f);switch(f){case u:return de("Suspense");case d:return de("SuspenseList")}if(typeof f=="object")switch(f.$$typeof){case a:return Le(f.render);case g:return we(f.type,F,R);case b:{var P=f,K=P._payload,ne=P._init;try{return we(ne(K),F,R)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,ss={},rs=v.ReactDebugCurrentFrame;function jt(f){if(f){var F=f._owner,R=we(f.type,f._source,F?F.type:null);rs.setExtraStackFrame(R)}else rs.setExtraStackFrame(null)}function yl(f,F,R,P,K){{var ne=Function.call.bind(je);for(var z in f)if(ne(f,z)){var Z=void 0;try{if(typeof f[z]!="function"){var Ie=Error((P||"React class")+": "+R+" type `"+z+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof f[z]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ie.name="Invariant Violation",Ie}Z=f[z](F,z,P,R,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ue){Z=ue}Z&&!(Z instanceof Error)&&(jt(K),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",P||"React class",R,z,typeof Z),jt(null)),Z instanceof Error&&!(Z.message in ss)&&(ss[Z.message]=!0,jt(K),y("Failed %s type: %s",R,Z.message),jt(null))}}}var Sl=Array.isArray;function Gn(f){return Sl(f)}function Al(f){{var F=typeof Symbol=="function"&&Symbol.toStringTag,R=F&&f[Symbol.toStringTag]||f.constructor.name||"Object";return R}}function El(f){try{return os(f),!1}catch{return!0}}function os(f){return""+f}function as(f){if(El(f))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Al(f)),os(f)}var ls=v.ReactCurrentOwner,wl={key:!0,ref:!0,__self:!0,__source:!0},us,cs;function Gl(f){if(je.call(f,"ref")){var F=Object.getOwnPropertyDescriptor(f,"ref").get;if(F&&F.isReactWarning)return!1}return f.ref!==void 0}function Ol(f){if(je.call(f,"key")){var F=Object.getOwnPropertyDescriptor(f,"key").get;if(F&&F.isReactWarning)return!1}return f.key!==void 0}function Fl(f,F){typeof f.ref=="string"&&ls.current}function Bl(f,F){{var R=function(){us||(us=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};R.isReactWarning=!0,Object.defineProperty(f,"key",{get:R,configurable:!0})}}function Rl(f,F){{var R=function(){cs||(cs=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};R.isReactWarning=!0,Object.defineProperty(f,"ref",{get:R,configurable:!0})}}var Ml=function(f,F,R,P,K,ne,z){var Z={$$typeof:e,type:f,key:F,ref:R,props:z,_owner:ne};return Z._store={},Object.defineProperty(Z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.defineProperty(Z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(Z.props),Object.freeze(Z)),Z};function Nl(f,F,R,P,K){{var ne,z={},Z=null,Ie=null;R!==void 0&&(as(R),Z=""+R),Ol(F)&&(as(F.key),Z=""+F.key),Gl(F)&&(Ie=F.ref,Fl(F,K));for(ne in F)je.call(F,ne)&&!wl.hasOwnProperty(ne)&&(z[ne]=F[ne]);if(f&&f.defaultProps){var ue=f.defaultProps;for(ne in ue)z[ne]===void 0&&(z[ne]=ue[ne])}if(Z||Ie){var pe=typeof f=="function"?f.displayName||f.name||"Unknown":f;Z&&Bl(z,pe),Ie&&Rl(z,pe)}return Ml(f,Z,Ie,K,P,ls.current,z)}}var On=v.ReactCurrentOwner,ds=v.ReactDebugCurrentFrame;function tt(f){if(f){var F=f._owner,R=we(f.type,f._source,F?F.type:null);ds.setExtraStackFrame(R)}else ds.setExtraStackFrame(null)}var Fn;Fn=!1;function Bn(f){return typeof f=="object"&&f!==null&&f.$$typeof===e}function ps(){{if(On.current){var f=Y(On.current.type);if(f)return` Check the render method of \``+f+"`."}return""}}function Xl(f){return""}var hs={};function Vl(f){{var F=ps();if(!F){var R=typeof f=="string"?f:f.displayName||f.name;R&&(F=` Check the top-level render call using <`+R+">.")}return F}}function fs(f,F){{if(!f._store||f._store.validated||f.key!=null)return;f._store.validated=!0;var R=Vl(F);if(hs[R])return;hs[R]=!0;var P="";f&&f._owner&&f._owner!==On.current&&(P=" It was passed a child from "+Y(f._owner.type)+"."),tt(f),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',R,P),tt(null)}}function gs(f,F){{if(typeof f!="object")return;if(Gn(f))for(var R=0;R<f.length;R++){var P=f[R];Bn(P)&&fs(P,F)}else if(Bn(f))f._store&&(f._store.validated=!0);else if(f){var K=p(f);if(typeof K=="function"&&K!==f.entries)for(var ne=K.call(f),z;!(z=ne.next()).done;)Bn(z.value)&&fs(z.value,F)}}}function Wl(f){{var F=f.type;if(F==null||typeof F=="string")return;var R;if(typeof F=="function")R=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===a||F.$$typeof===g))R=F.propTypes;else return;if(R){var P=Y(F);yl(R,f.props,"prop",P,f)}else if(F.PropTypes!==void 0&&!Fn){Fn=!0;var K=Y(F);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dl(f){{for(var F=Object.keys(f.props),R=0;R<F.length;R++){var P=F[R];if(P!=="children"&&P!=="key"){tt(f),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",P),tt(null);break}}f.ref!==null&&(tt(f),y("Invalid attribute `ref` supplied to `React.Fragment`."),tt(null))}}var bs={};function ms(f,F,R,P,K,ne){{var z=V(f);if(!z){var Z="";(f===void 0||typeof f=="object"&&f!==null&&Object.keys(f).length===0)&&(Z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ie=Xl();Ie?Z+=Ie:Z+=ps();var ue;f===null?ue="null":Gn(f)?ue="array":f!==void 0&&f.$$typeof===e?(ue="<"+(Y(f.type)||"Unknown")+" />",Z=" Did you accidentally export a JSX literal instead of a component?"):ue=typeof f,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ue,Z)}var pe=Nl(f,F,R,K,ne);if(pe==null)return pe;if(z){var Be=F.children;if(Be!==void 0)if(P)if(Gn(Be)){for(var nt=0;nt<Be.length;nt++)gs(Be[nt],f);Object.freeze&&Object.freeze(Be)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else gs(Be,f)}if(je.call(F,"key")){var Ue=Y(f),Ae=Object.keys(F).filter(function(Hl){return Hl!=="key"}),Rn=Ae.length>0?"{key: someKey, "+Ae.join(": ..., ")+": ...}":"{key: someKey}";if(!bs[Ue+Rn]){var Tl=Ae.length>0?"{"+Ae.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,Rn,Ue,Tl,Ue),bs[Ue+Rn]=!0}}return f===s?Dl(pe):Wl(pe),pe}}function Pl(f,F,R){return ms(f,F,R,!0)}function kl(f,F,R){return ms(f,F,R,!1)}var Ll=kl,jl=Pl;rt.Fragment=s,rt.jsx=Ll,rt.jsxs=jl}()),rt}var Vn;function ys(){return Vn||(Vn=1,process.env.NODE_ENV==="production"?ft.exports=Is():ft.exports=xs()),ft.exports}var h=ys();class Ge extends B.Component{render(){let e=[];E.isArray(this.props.label)?e=E.clone(this.props.label):e.push(this.props.label);const n=[],s=this.props.x,t=this.props.y,r=this.props.r,o=this.props.textAnchor?this.props.textAnchor:"middle",l=`rotate(${r} ${s}, ${t})`,a=this.props.style.fontSize?this.props.style.fontSize:10,u=this.props.yOffset,d=this.props.xOffset;(this.props.labelPosition==="top"||this.props.labelPosition==="center")&&e.reverse();let g,b,m;return this.props.labelPosition==="center"&&(m=t+e.length/2*a),E.each(e,(C,I)=>{switch(g=s+d,this.props.labelPosition){case"top":b=t-u-I*a;break;case"bottom":b=t+u+a+I*a;break;case"center":b=m-u-I*a;break}n.push(h.jsx("tspan",{x:g,y:b,children:C},"label-line-"+I))}),h.jsx("g",{children:h.jsx("text",{textAnchor:o,style:this.props.style,transform:l,className:this.props.labelClassed,children:n},"connection-label")})}}Ge.propTypes={r:c.number,xOffset:c.number,yOffset:c.number},Ge.defaultProps={r:0,xOffset:0,yOffset:0};const Oe=xe;class $e extends B.Component{handleClick(e){e.stopPropagation(),this.props.onSelectionChange&&this.props.onSelectionChange("edge",this.props.name)}render(){let e="edge-curved",n="edge-label",s="normal";this.props.selected&&(e+=" selected",n+="selected",s="selected"),this.props.muted&&(e+=" muted",n+="muted",s="muted"),this.props.invisible&&(e+=" edge-event-region",n+=" edge-event-region"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed);const t=new Oe(this.props.x1,this.props.y1),r=new Oe(this.props.x2,this.props.y2),o=r.clone().subtract(t),l=o.clone().norm(),a=o.length();let u=90;(o.y<0&&this.props.curveDirection==="left"||o.y>0&&this.props.curveDirection==="right")&&(u=-90);const d=l.clone().rotateDeg(u),g=new Oe(a/2,a/2),b=l.clone().multiply(g).add(t),m=new Oe(this.props.offset,this.props.offset);m.multiply(d);const C=b.clone().add(m),I=this.props.position,p=this.props.arrowWidth||this.props.width*1.5,v=this.props.arrowHeight||this.props.width*2,y=15,w=new Oe(y,y),x=C.clone().subtract(t).clone().norm(),S=C.clone().subtract(r).clone().norm(),O=x.clone().multiply(w).add(t),N=S.clone().multiply(w).add(r),V=new Oe(-x.y,x.x),j=new Oe(I,I),T=V.clone().multiply(j).add(O),Y=new Oe(-S.y,S.x),q=new Oe(-I,-I),L=Y.clone().multiply(q).add(N),H=new Oe(-v,-v),ee=new Oe(p/2,p/2),te=new Oe(-p/2,-p/2),ae=S.clone().multiply(H).add(L),he=Y.clone().multiply(ee).add(L),Se=Y.clone().multiply(te).add(L),J=this.props.offset,se=(a*a+4*J*J)/(8*J),be=0,fe=0,re=u===90?0:1;let le="";le+="M"+t.x+","+t.y,le+=" L "+T.x+" "+T.y,le+=" A "+se+" "+se+" "+be+" "+fe+" "+re+" "+L.x+" "+L.y,this.props.arrow||(le+=" L "+r.x+" "+r.y);let de="M"+ae.x+","+ae.y+" ";de+="L"+he.x+","+he.y,de+="L"+Se.x+","+Se.y;let Ce=1;this.props.invisible?Ce=0:this.props.muted&&(Ce=.3);const Ve=Math.abs(L.y-T.y),He=Math.abs(L.x-T.x);let M=Math.atan2(Ve,He)*180/Math.PI;const Le=C.x;let Fe=C.y+this.props.position;(r.y<t.y&&t.x<r.x||t.x>r.x&&r.y>t.y)&&(M=-M),t.x>r.x&&(Fe=C.y-this.props.position);let we=null;return this.props.label&&(we=h.jsx(Ge,{x:Le,y:Fe,r:M,textAnchor:this.props.textAnchor,classed:n,style:this.props.labelStyle[s],label:this.props.label,xOffset:this.props.labelOffsetX,yOffset:this.props.labelOffsetY,labelPosition:this.props.labelPosition})),this.props.arrow?h.jsxs("g",{children:[h.jsxs("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:Ce,children:[h.jsx("path",{d:le,fill:"none",className:e,onClick:je=>this.handleClick(je)}),h.jsx("path",{d:de,className:e,stroke:this.props.color,fill:this.props.color,strokeWidth:"1"})]}),we]}):h.jsxs("g",{children:[h.jsx("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:Ce,children:h.jsx("path",{d:le,fill:"none",className:e,onClick:je=>this.handleClick(je)})}),we]})}}$e.propTypes={offset:c.number,width:c.number,color:c.string,curveDirection:c.string,arrow:c.bool,position:c.number,selected:c.bool,muted:c.bool},$e.defaultProps={offset:20,width:1,color:"#ddd",curveDirection:"left",arrow:!1,position:0,selected:!1,muted:!1};class Te extends B.Component{handleClick(e){this.props.onSelectionChange&&this.props.onSelectionChange("edge",this.props.name),e.stopPropagation()}render(){let e="edge-linear",n="edge-label",s="normal";this.props.selected&&(e+=" selected",n+="selected",s="selected"),this.props.muted&&(e+=" muted",n+="muted",s="muted"),this.props.invisible&&(e+=" edge-event-region",n+=" edge-event-region"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed);const t=new xe(this.props.x1,this.props.y1),r=new xe(this.props.x2,this.props.y2),l=r.clone().subtract(t).clone().norm(),a=new xe(-l.y,l.x);new xe(this.props.offset,this.props.offset).multiply(a);const d=this.props.position,g=this.props.arrowWidth||this.props.width*1.5,b=this.props.arrowHeight||this.props.width*2,m=this.props.position!==0?15:8,C=new xe(m,m),p=r.clone().subtract(t).clone().norm(),y=t.clone().subtract(r).clone().norm(),w=p.clone().multiply(C).add(t),A=y.clone().multiply(C).add(r),x=new xe(-p.y,p.x),G=new xe(d,d),S=x.clone().multiply(G).add(w),O=new xe(-y.y,y.x),N=new xe(-d,-d),V=O.clone().multiply(N).add(A),j=new xe(-b,-b),T=new xe(g/2,g/2),Y=new xe(-g/2,-g/2),q=y.clone().multiply(j).add(V),L=O.clone().multiply(T).add(V),H=O.clone().multiply(Y).add(V);let ee="";ee+="M"+t.x+","+t.y,ee+=" L "+S.x+" "+S.y,ee+=" L "+V.x+" "+V.y,this.props.arrow||(ee+=" L "+r.x+" "+r.y);let te="M"+q.x+","+q.y+" ";te+="L"+L.x+","+L.y,te+="L"+H.x+","+H.y;let ae=1;this.props.invisible?ae=0:this.props.muted&&(ae=.3);const he=Math.abs(V.y-S.y),Se=Math.abs(V.x-S.x);let J=Math.atan2(he,Se)*180/Math.PI;const se=(S.x+V.x)/2,be=(S.y+V.y)/2;(r.y<t.y&&t.x<r.x||t.x>r.x&&r.y>t.y)&&(J=-J);let fe=null;return this.props.label&&(fe=h.jsx(Ge,{x:se,y:be,r:J,textAnchor:this.props.textAnchor,classed:n,style:this.props.labelStyle[s],label:this.props.label,xOffset:this.props.labelOffsetX,yOffset:this.props.labelOffsetY,labelPosition:this.props.labelPosition})),this.props.arrow?h.jsxs("g",{children:[h.jsxs("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:ae,children:[h.jsx("path",{className:e,d:ee,fill:"none",onClick:re=>this.handleClick(re)}),h.jsx("path",{className:e,d:te,fill:this.props.color,strokeWidth:"1"})]}),fe]}):h.jsxs("g",{children:[h.jsx("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:ae,children:h.jsx("path",{className:e,d:ee,fill:"none",onClick:re=>this.handleClick(re)})}),fe]})}}Te.propTypes={width:c.number,color:c.string,position:c.number,arrow:c.bool,selected:c.bool,muted:c.bool},Te.defaultProps={width:1,color:"#ddd",position:0,arrow:!1,selected:!1,muted:!1};class gt extends B.Component{render(){const e=`${this.props.source}--${this.props.target}`,n=`${this.props.target}--${this.props.source}`,s=this.props.width*.75;return this.props.shape==="curved"?h.jsxs("g",{children:[h.jsx($e,{name:this.props.name,x1:this.props.x1,y1:this.props.y1,x2:this.props.x2,y2:this.props.y2,arrow:!0,position:s,color:this.props.sourceTargetColor,width:this.props.width,classed:this.props.classed,curveDirection:this.props.curveDirection,offset:this.props.offset,selected:this.props.selected,onSelectionChange:this.props.onSelectionChange,muted:this.props.muted},e),h.jsx($e,{name:this.props.name,x1:this.props.x2,y1:this.props.y2,x2:this.props.x1,y2:this.props.y1,arrow:!0,position:s,color:this.props.targetSourceColor,width:this.props.width,classed:this.props.classed,curveDirection:this.props.curveDirection,offset:this.props.offset,selected:this.props.selected,onSelectionChange:this.props.onSelectionChange,muted:this.props.muted},n),h.jsx($e,{name:this.props.name,x1:this.props.x2,y1:this.props.y2,x2:this.props.x1,y2:this.props.y1,position:0,width:5,classed:this.props.classed,onSelectionChange:this.props.onSelectionChange,curveDirection:this.props.curveDirection,offset:this.props.offset,invisible:!0},`${e}-event-region`)]}):h.jsxs("g",{children:[h.jsx(Te,{name:this.props.name,x1:this.props.x1,y1:this.props.y1,x2:this.props.x2,y2:this.props.y2,arrow:!0,color:this.props.sourceTargetColor,width:this.props.width,position:s,className:this.props.classed,selected:this.props.selected,muted:this.props.muted,onSelectionChange:this.props.onSelectionChange},e),h.jsx(Te,{name:this.props.name,x1:this.props.x2,y1:this.props.y2,x2:this.props.x1,y2:this.props.y1,arrow:!0,color:this.props.targetSourceColor,width:this.props.width,position:s,className:this.props.classed,selected:this.props.selected,muted:this.props.muted,onSelectionChange:this.props.onSelectionChange},n),h.jsx(Te,{name:this.props.name,x1:this.props.x2,y1:this.props.y2,x2:this.props.x1,y2:this.props.y1,width:5,position:0,className:this.props.classed,onSelectionChange:this.props.onSelectionChange,invisible:!0},`${n}-event-region`)]})}}gt.propTypes={width:c.number,spacing:c.number,offset:c.number,sourceTargetColor:c.string,targetSourceColor:c.string,selected:c.bool,muted:c.bool},gt.defaultProps={width:1,spacing:3.5,offset:18,sourceTargetColor:"#C9CACC",targetSourceColor:"#C9CACC",selected:!1,muted:!1};class Ss extends B.Component{render(){let e;switch(this.props.labelPosition){case"left":e="end";break;case"top":case"bottom":e="middle";break;default:e="start"}return h.jsx("text",{x:this.props.x,y:this.props.y,label:this.props.label,textAnchor:e,className:"map-label",children:this.props.label})}}class bt extends B.Component{render(){let e=this.props.x,n=this.props.y;const s=this.props.lineHeight/2,t=[];if(this.props.nodeTypes.length>0&&(E.each(this.props.nodeTypes,(r,o)=>{if(r.shape==="square"){const l="map-node-shape-square-"+r.classed,a=e-r.radius,u=n,d=2*r.radius,g={stroke:r.stroke,fill:r.fill},b=e+this.props.exampleWidth,m=n+s;t.push(h.jsxs("g",{children:[h.jsx("rect",{x:a,y:u,width:d,height:d,style:g,className:l}),h.jsx("text",{x:b,y:m+4,textAnchor:"begin",children:r.text})]},`node-${o}`)),n+=this.props.lineHeight}else{const l=e+this.props.exampleWidth,a=n+s,u="map-node-shape-circle-"+r.classed,d={stroke:r.stroke,fill:r.fill};t.push(h.jsxs("g",{children:[h.jsx("circle",{style:d,cx:e,cy:a,r:r.radius,className:u}),h.jsx("text",{x:l,y:a+4,textAnchor:"begin",children:r.text})]},`node-${o}`)),n+=this.props.lineHeight}}),this.props.columns&&(e+=this.props.columnWidth,n=this.props.y)),this.props.edgeTypes.length>0&&(E.each(this.props.edgeTypes,(r,o)=>{const l=e,a=n+s-r.strokeWidth/2,u=l+this.props.exampleWidth+this.props.gutter,d=n+s;t.push(h.jsxs("g",{children:[h.jsx("line",{x1:l,y1:a,x2:l+this.props.exampleWidth,y2:a,stroke:this.props.edgeColor,strokeWidth:r.strokeWidth}),h.jsx("text",{x:u,y:d,textAnchor:"begin",children:r.text})]},`edge-${o}`)),n+=this.props.lineHeight}),this.props.columns&&(e+=this.props.columnWidth,n=this.props.y)),this.props.colorSwatches.length>0){const r=this.props.exampleWidth,o=this.props.lineHeight-4;let l=0;E.each(this.props.colorSwatches,(a,u)=>{l&&l%this.props.itemsPerColumn===0&&(e+=this.props.columnWidth,n=this.props.y);const d=e,g=n,b=d+this.props.exampleWidth+this.props.gutter,m=n+s;t.push(h.jsxs("g",{children:[h.jsx("rect",{x:d,y:g,width:r,height:o,stroke:a.stroke,fill:a.fill}),h.jsx("text",{x:b,y:m,textAnchor:"begin",children:a.text})]},`color-${u}`)),n+=this.props.lineHeight,l+=1}),this.props.columns&&(e+=this.props.columnWidth,n=this.props.y)}return h.jsx("g",{children:t})}}bt.propTypes={x:c.number,y:c.number,lineHeight:c.number,columns:c.bool,itemsPerColumn:c.number,columnWidth:c.number,exampleWidth:c.number,gutter:c.number,edgeColor:c.string,nodeTypes:c.array,edgeTypes:c.array,colorSwatches:c.array},bt.defaultProps={x:0,y:0,lineHeight:20,columns:!0,itemsPerColumn:4,columnWidth:100,exampleWidth:20,gutter:8,edgeColor:"#333",nodeTypes:[],edgeTypes:[],colorSwatches:[]};let Qe=class extends B.Component{static spec(){return[{attr:"name",label:"Name",type:"text"},{attr:"x",label:"Position x",type:"integer"},{attr:"y",label:"Position y",type:"integer"},{attr:"label_dx",label:"Label offset x",type:"integer"},{attr:"label_dy",label:"Label offset y",type:"integer"},{attr:"label_position",label:"Label position",type:"choice",options:[{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"},{value:"topleft",label:"Top left"},{value:"topright",label:"Top right"},{value:"bottomleft",label:"Bottom left"},{value:"bottomright",label:"Bottom right"}]}]}handMouseClick(e){e.stopPropagation();const n=this.props.id||this.props.name;this.props.onSelectionChange&&this.props.onSelectionChange("node",n)}handleMouseOver(){}handleMouseDown(e){e.stopPropagation();const n=this.props.id||this.props.name;this.props.onMouseDown&&this.props.onMouseDown(n,e)}render(){let e="map-node",n="map-node-label",s="normal";this.props.selected&&(s="selected",e+=" selected",n+=" selected"),this.props.muted&&(s="muted",e+=" muted",n+=" muted"),this.props.highlighted&&(s="highlighted",e+=" highlighted",n+=" highlighted");const t=this.props.offset?this.props.offset:this.props.radius*1.33,r=8;let o=this.props.x,l=this.props.y,a=0,u="middle",d=`rotate(${a} ${o}, ${l})`,g;switch(typeof this.props.labelPosition=="object"?g=this.props.labelPosition.value:g=this.props.labelPosition,g){case"left":o-=t,l+=5,u="end";break;case"right":o+=t,l+=5,u="start";break;case"top":l-=t;break;case"topright":l-=t,o+=t,u="start";break;case"topleft":l-=t,o-=t,u="end";break;case"bottom":l+=t+r;break;case"bottomright":l+=t+r,o+=t,u="start";break;case"bottomleft":l+=t+r,o-=t,u="end";break;case"bottomleftangled":o+=2,l+=t+r,a=-45,d=`rotate(${a} ${o}, ${l})`,u="end";break;case"bottomrightangled":o-=2,l+=t+r,a=45,d=`rotate(${a} ${o}, ${l})`,u="start";break;case"topleftangled":l-=t,a=45,d=`rotate(${a} ${o}, ${l})`,u="end";break;case"toprightangled":l-=t,a=-45,d=`rotate(${a} ${o}, ${l})`,u="start";break}o+=this.props.labelOffsetX,l+=this.props.labelOffsetY;let b;if(this.props.shape==="cloud"){e+=" map-node-shape-cloud",n+=" map-node-label-cloud";let m=`M${this.props.x},${this.props.y+5}`;switch(m+="l-25,0 c-10,0 -10,-10 -5,-15",m+="c5,-5 15,-5 15,0 c0,-15 25,-15 25,-5 c10,-10 25,15 10,20 Z",b=h.jsx("path",{d:m,style:this.props.style[s],className:e}),this.props.labelPosition){case"top":case"topright":case"topleft":l+=7;break;case"bottom":case"bottomleft":case"bottomright":l-=15;break}o-=3}else if(this.props.shape==="square"){e+=" map-node-shape-square",n+=" map-node-shape-square";const m=this.props.x-this.props.radius,C=this.props.y-this.props.radius,I=2*this.props.radius;switch(b=h.jsx("rect",{x:m,y:C,rx:this.props.rx,ry:this.props.ry,width:I,height:I,style:this.props.style[s],className:e}),this.props.labelPosition){case"left":o-=2;break;case"right":o+=2;break}}else e+=" map-node-shape-circle",n+=" map-node-label-circle",b=h.jsx("circle",{cx:this.props.x,cy:this.props.y,r:this.props.radius,style:this.props.style[s],className:e});return this.props.label?h.jsxs("g",{onClick:m=>this.handMouseClick(m),onMouseOver:this.handleMouseOver,onMouseDown:m=>this.handleMouseDown(m),onMouseMove:this.handleMouseMove,children:[b,h.jsx("text",{x:o,y:l,textAnchor:u,transform:d,style:this.props.labelStyle[s],className:n,children:this.props.label})]}):h.jsx("g",{onClick:m=>this.handMouseClick(m),onMouseOver:this.handleMouseOver,onMouseDown:m=>this.handleMouseDown(m),onMouseMove:this.handleMouseMove,onMouseUp:this.handleMouseUp,children:b})}};Qe.propTypes={radius:c.number,selected:c.bool,shape:c.oneOf(["circle","square","cloud"]),style:c.object,isDragging:c.bool,labelOffsetX:c.number,labelOffsetY:c.number,rx:c.number,ry:c.number},Qe.defaultProps={radius:5,selected:!1,shape:"circle",style:{},isDragging:!1,labelOffsetX:0,labelOffsetY:0,rx:0,ry:0};const Ye=xe;class Tt extends B.Component{handleClick(e){e.stopPropagation(),this.props.onSelectionChange&&this.props.onSelectionChange("edge",this.props.name)}rotateOffset(e,n,s,t){const r=Math.PI/180*t,o=Math.cos(r),l=Math.sin(r),a=n-(n-e)*o,u=s-(n-e)*l;return[a,u]}render(){let e="edge-angled",n="edge-label",s="normal";this.props.selected&&(e+=" selected",n+="selected",s="selected"),this.props.muted&&(e+=" muted",n+="muted",s="muted"),this.props.invisible&&(e+=" edge-event-region",n+=" edge-event-region"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed);const t=this.props.position,r=this.props.offset,o=new Ye(this.props.x1,this.props.y1),l=new Ye(this.props.x2,this.props.y2);let a,u;const d=this.props.arrowWidth||this.props.width*1.5,g=this.props.arrowHeight||this.props.width*2;switch(this.props.curveDirection){case"left":o.x<l.x&&o.y<l.y?(a=90+t,u=-t):l.x<o.x&&l.y<o.y?(a=180+t,u=-90-t):o.x<l.x&&o.y>l.y?(a=-90-t,u=t):l.x<o.x&&l.y>o.y?(a=180-t,u=90+t):o.x>l.x&&o.y===l.y?(a=180-t,u=180+t):o.x===l.x&&o.y>l.y?(a=-90-t,u=-90+t):o.x===l.x&&o.y<l.y?(a=90-t,u=90+t):(a=-t,u=t);break;case"right":o.x<l.x&&o.y<l.y?(a=-t,u=90+t):l.x<o.x&&l.y<o.y?(a=-90-t,u=180+t):o.x<l.x&&o.y>l.y?(a=t,u=-90-t):l.x<o.x&&l.y>o.y?(a=90+t,u=180-t):o.x>l.x&&o.y===l.y?(a=180+t,u=180-t):o.x===l.x&&o.y>l.y?(a=-90+t,u=-90-t):o.x===l.x&&o.y<l.y?(a=90+t,u=90-t):(a=t,u=-t);break}const b=this.rotateOffset(o.x+r,o.x,o.y,a),m=this.rotateOffset(l.x-r,l.x,l.y,u),C=new Ye(b[0],b[1]),I=new Ye(m[0],m[1]),p=I.clone(),v=r-g,y=this.rotateOffset(l.x-v,l.x,l.y,u),w=this.rotateOffset(p.x-d/2,p.x,p.y,90+u),A=this.rotateOffset(p.x+d/2,p.x,p.y,90+u),x=new Ye(w[0],w[1]),G=new Ye(A[0],A[1]),S=new Ye(y[0],y[1]);let O="";O+="M "+o.x+","+o.y,O+=" L "+C.x+","+C.y;const N=(o.x+l.x)/2;let V=(o.y+l.y)/2;switch(this.props.curveDirection){case"left":o.x<l.x&&o.y<l.y||o.x<l.x&&o.y>l.y?(O+=" L "+C.x+","+I.y,V=l.y):(O+=" L "+I.x+","+C.y,V=o.y);break;case"right":o.x<l.x&&o.y<l.y||o.x<l.x&&o.y>l.y?(O+=" L "+I.x+","+C.y,V=o.y):(O+=" L "+C.x+","+I.y,V=l.y);break}O+=" L "+I.x+","+I.y,this.props.arrow||(O+=" L "+l.x+" "+l.y);let j="M"+S.x+","+S.y+" ";j+="L"+x.x+","+x.y,j+="L"+G.x+","+G.y,j+="L"+S.x+","+S.y;let T=1;this.props.invisible?T=0:this.props.muted&&(T=.3);let Y=null;return this.props.label&&(Y=h.jsx(Ge,{x:N,y:V,textAnchor:this.props.textAnchor,classed:n,style:this.props.labelStyle[s],label:this.props.label,xOffset:this.props.labelOffsetX,yOffset:this.props.labelOffsetY,labelPosition:this.props.labelPosition})),this.props.arrow?h.jsxs("g",{children:[h.jsxs("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:T,children:[h.jsx("path",{d:O,fill:"none",className:e,onClick:q=>this.handleClick(q)}),h.jsx("path",{d:j,className:e,stroke:this.props.color,fill:this.props.color,strokeWidth:"1"})]}),Y]}):h.jsxs("g",{children:[h.jsx("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:T,children:h.jsx("path",{d:O,fill:"none",className:e,onClick:q=>this.handleClick(q)})}),Y]})}}Tt.propTypes={offset:c.number,width:c.number,color:c.string,curveDirection:c.string,arrow:c.bool,position:c.number,selected:c.bool,muted:c.bool},Tt.defaultProps={offset:15,width:1,color:"#ddd",curveDirection:"left",arrow:!1,position:30,selected:!1,muted:!1};class Ht extends B.Component{handleClick(e){this.props.onSelectionChange&&this.props.onSelectionChange("edge",this.props.name),e.stopPropagation()}_rotateOffset(e,n,s,t){const r=Math.PI/180*t,o=Math.cos(r),l=Math.sin(r),a=n-(n-e)*o,u=s-(n-e)*l;return[a,u]}render(){let e="edge-square",n="edge-label",s="normal";this.props.selected&&(e+=" selected",n+="selected",s="selected"),this.props.muted&&(e+=" muted",n+="muted",s="muted"),this.props.invisible&&(e+=" edge-event-region",n+=" edge-event-region"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed);const t=this.props.size,r=this.props.fillColor||"none",o=this.props.y1-this.props.size/2;this.props.selected&&(e+=" selected"),this.props.muted&&(e+=" muted"),this.props.invisible&&(e+=" edge-event-region"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed);let l=1;this.props.invisible?l=0:this.props.muted&&(l=.3);let a;if(this.props.y1===this.props.y2)a=Math.abs(this.props.x2-this.props.x1);else{const O=Math.abs(this.props.y2-this.props.y1),N=Math.abs(this.props.x2-this.props.x1);a=Math.sqrt(O*O+N*N)}const u=Math.atan2(this.props.y2-this.props.y1,this.props.x2-this.props.x1)*180/Math.PI,d=`rotate(${u} ${this.props.x1}, ${this.props.y1})`,g=(this.props.x1+this.props.x2)/2,b=(this.props.y1+this.props.y2)/2,m=g+t/2,C=this._rotateOffset(m,g,b,u+90),I=this._rotateOffset(m,g,b,u-90),p=C[0],v=C[1],y=I[0],w=I[1];let A="";A+="M"+p+","+v,A+=" L "+y+" "+w;let x,G;switch(this.props.labelPosition){case"top":x=y,G=w;break;case"bottom":x=p,G=v;break;default:x=g,G=b;break}let S=null;return this.props.label&&(S=h.jsx(Ge,{x,y:G,r:u,textAnchor:this.props.textAnchor,classed:n,style:this.props.labelStyle[s],label:this.props.label,xOffset:this.props.labelOffsetX,yOffset:this.props.labelOffsetY,labelPosition:this.props.labelPosition})),this.props.centerLine?h.jsxs("g",{children:[h.jsxs("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:l,onClick:O=>this.handleClick(O),children:[h.jsx("rect",{className:e,width:a,height:t,transform:d,x:this.props.x1,y:o,rx:this.props.roundedX,ry:this.props.roundedY,fill:r}),h.jsx("path",{className:e,d:A,fill:"none"})]}),S]}):h.jsxs("g",{children:[h.jsx("g",{strokeWidth:this.props.width,stroke:this.props.color,opacity:l,children:h.jsx("rect",{className:e,width:a,height:t,transform:d,x:this.props.x1,y:o,rx:this.props.roundedX,ry:this.props.roundedY,fill:r,onClick:O=>this.handleClick(O)})}),S]})}}Ht.propTypes={roundedX:c.number,roundedY:c.number,color:c.string,position:c.number,arrow:c.bool,selected:c.bool,muted:c.bool,size:c.number},Ht.defaultProps={roundedX:0,roundedY:0,color:"#ddd",position:0,arrow:!1,selected:!1,muted:!1,size:40};class Ze extends B.Component{render(){let e="edge";return this.props.selected&&(e+=" selected"),this.props.muted&&(e+=" muted"),E.isUndefined(this.props.classed)||(e+=" "+this.props.classed),this.props.shape==="curved"?h.jsx($e,{x1:this.props.x1,x2:this.props.x2,y1:this.props.y1,y2:this.props.y2,label:this.props.label,labelPosition:this.props.labelPosition,labelStyle:this.props.labelStyle,labelOffsetX:this.props.labelOffsetX,labelOffsetY:this.props.labelOffsetY,textAnchor:this.props.textAnchor,color:this.props.color,width:this.props.width,selected:this.props.selected,muted:this.props.muted,classed:e,arrow:this.props.arrow,arrowWidth:this.props.arrowWidth,arrowHeight:this.props.arrowHeight,position:this.props.position,curveDirection:this.props.curveDirection,offset:this.props.offset,name:this.props.name,invisible:this.props.invisible,onSelectionChange:this.props.onSelectionChange},this.props.name):this.props.shape==="square"?h.jsx(Ht,{x1:this.props.x1,x2:this.props.x2,y1:this.props.y1,y2:this.props.y2,label:this.props.label,labelPosition:this.props.labelPosition,labelStyle:this.props.labelStyle,labelOffsetX:this.props.labelOffsetX,labelOffsetY:this.props.labelOffsetY,textAnchor:this.props.textAnchor,color:this.props.color,width:this.props.width,selected:this.props.selected,muted:this.props.muted,classed:e,roundedX:this.props.roundedX,roundedY:this.props.roundedY,fillColor:this.props.fillColor,size:this.props.size,centerLine:this.props.centerLine,name:this.props.name,invisible:this.props.invisible,onSelectionChange:this.props.onSelectionChange},this.props.name):this.props.shape==="angled"?h.jsx(Tt,{x1:this.props.x1,x2:this.props.x2,y1:this.props.y1,y2:this.props.y2,label:this.props.label,labelPosition:this.props.labelPosition,labelStyle:this.props.labelStyle,labelOffsetX:this.props.labelOffsetX,labelOffsetY:this.props.labelOffsetY,textAnchor:this.props.textAnchor,color:this.props.color,width:this.props.width,selected:this.props.selected,muted:this.props.muted,classed:e,arrow:this.props.arrow,arrowWidth:this.props.arrowWidth,arrowHeight:this.props.arrowHeight,position:this.props.position,curveDirection:this.props.curveDirection,offset:this.props.offset,name:this.props.name,invisible:this.props.invisible,onSelectionChange:this.props.onSelectionChange},this.props.name):h.jsx(Te,{x1:this.props.x1,x2:this.props.x2,y1:this.props.y1,y2:this.props.y2,label:this.props.label,labelPosition:this.props.labelPosition,labelStyle:this.props.labelStyle,labelOffsetX:this.props.labelOffsetX,labelOffsetY:this.props.labelOffsetY,textAnchor:this.props.textAnchor,color:this.props.color,width:this.props.width,selected:this.props.selected,muted:this.props.muted,classed:e,arrow:this.props.arrow,arrowWidth:this.props.arrowWidth,arrowHeight:this.props.arrowHeight,position:this.props.position,name:this.props.name,invisible:this.props.invisible,onSelectionChange:this.props.onSelectionChange},this.props.name)}}Ze.propTypes={color:c.string,width:c.number,position:c.number,selected:c.bool,muted:c.bool,invisible:c.bool,arrow:c.bool,fillColor:c.string},Ze.defaultProps={color:"#ddd",width:4,position:0,selected:!1,muted:!1,invisible:!1,arrow:!1,fillColor:"none"};function As(i){const e=document.documentElement,n=i.getBoundingClientRect(),s=n.top+window.pageYOffset-e.clientTop,t=n.left+window.pageXOffset-e.clientLeft;return{top:s,left:t}}class ze extends B.Component{constructor(e){super(e),this.state={dragging:null}}handleNodeMouseDown(e,n){const{xScale:s,yScale:t}=this.scale(),{x:r,y:o}=this.getOffsetMousePosition(n),l={id:e,x0:s.invert(r),y0:t.invert(o)};this.setState({dragging:l})}handleSelectionChange(e,n){this.props.onNodeSelected?e==="node"&&this.props.onNodeSelected(n):this.props.onEdgeSelected?e==="edge"&&this.props.onEdgeSelected(n):this.props.onSelectionChange&&this.props.onSelectionChange(e,n)}handleMouseMove(e){if(e.preventDefault(),this.state.dragging){const{id:n}=this.state.dragging,{xScale:s,yScale:t}=this.scale(),{x:r,y:o}=this.getOffsetMousePosition(e);this.props.onNodeDrag&&this.props.onNodeDrag(n,s.invert(r),t.invert(o))}}handleMouseUp(e){e.stopPropagation(),this.setState({dragging:null})}handleClick(e){if(!(this.props.onNodeSelected||this.props.onEdgeSelected)){if(this.props.onPositionSelected){const{xScale:n,yScale:s}=this.scale(),{x:t,y:r}=this.getOffsetMousePosition(e);this.props.onPositionSelected(n.invert(t),s.invert(r))}this.props.onSelectionChange&&this.props.onSelectionChange(null)}}getOffsetMousePosition(e){const n=this.map,s=As(n),t=e.pageX-s.left,r=e.pageY-s.top;return{x:Math.round(t),y:Math.round(r)}}scale(){return{xScale:Mn.scaleLinear().domain([this.props.bounds.x1,this.props.bounds.x2]).range([this.props.margin,this.props.width-this.props.margin*2]),yScale:Mn.scaleLinear().domain([this.props.bounds.y1,this.props.bounds.y2]).range([this.props.margin,this.props.height-this.props.margin*2])}}render(){const{xScale:e,yScale:n}=this.scale(),s=this.props.selection.nodes.length,t=this.props.selection.edges.length,r={};E.each(this.props.topology.edges,p=>{r[`${p.source}--${p.target}`]=p,r[`${p.target}--${p.source}`]=p});const o=[];E.each(this.props.selection.edges,p=>{const v=r[p];v&&(o.push(v.source),o.push(v.target))});const l={},a=E.map(this.props.topology.nodes,p=>{const{name:v,id:y,label:w,...A}=p;A.id=y||v,A.x=e(p.x),A.y=n(p.y),A.label=w||v;const x=E.contains(this.props.selection.nodes,A.id),G=E.contains(o,p.name);return A.selected=x||G,A.muted=s&&!A.selected||t&&!A.selected,l[p.name]={x:A.x,y:A.y},h.jsx(Qe,{...A,onSelectionChange:(S,O)=>this.handleSelectionChange(S,O),onMouseDown:(S,O)=>this.handleNodeMouseDown(S,O),onMouseMove:(S,O,N,V)=>this.props.onNodeMouseMove(O,N,V),onMouseUp:(S,O,N)=>this.props.onNodeMouseUp(O,N)},A.id)}),u={};E.each(this.props.paths,p=>{const v=p.name,y=p.steps;for(let w=0;w<y.length-1;w++){const A=y[w],x=y[w+1];let G,S;if(E.has(l,A)&&E.has(l,x))l[A].x<l[x].x||l[A].y<l[x].y?(G=A,S=x):(G=x,S=A),E.has(u,G)||(u[G]={targetMap:{}}),E.has(u[G].targetMap,S)||(u[G].targetMap[S]=[]),u[G].targetMap[S].push(v);else{if(!E.has(l,A))throw new Error(`Missing node in path '${v}': ${A}`);if(!E.has(l,x))throw new Error(`Missing node in path '${v}': ${x}`)}}});const d={};E.each(this.props.paths,p=>{const v=p.steps;if(v.length>1)for(let y=0;y<v.length-1;y++){const w=v[y],A=v[y+1],x=`${w}--${A}`,G=`${A}--${w}`;d[x]=p,d[G]=p}});const g=E.map(this.props.topology.edges,p=>{const v=E.contains(this.props.selection.edges,p.name);if(!E.has(l,p.source)||!E.has(l,p.target))return;const y=this.props.edgeDrawingMethod;let w="linear";!E.isUndefined(p.shape)&&!E.isNull(p.shape)&&(w=p.shape);let A="left";!E.isUndefined(p.curveDirection)&&!E.isNull(p.curveDirection)&&(A=p.curveDirection);const G=(t&&!v||s)!==0;if(y==="simple")return h.jsx(Ze,{x1:l[p.source].x,x2:l[p.target].x,y1:l[p.source].y,y2:l[p.target].y,source:p.source,target:p.target,shape:w,curveDirection:A,color:p.stroke,width:p.width,classed:p.classed,name:p.name,selected:v,muted:G,onSelectionChange:(S,O)=>this.handleSelectionChange(S,O)},p.name);if(y==="bidirectionalArrow")return h.jsx(gt,{x1:l[p.source].x,x2:l[p.target].x,y1:l[p.source].y,y2:l[p.target].y,source:p.source,target:p.target,shape:w,curveDirection:A,offset:p.offset,sourceTargetColor:p.sourceTargetColor,targetSourceColor:p.targetSourceColor,width:p.width,classed:p.classed,name:p.name,selected:v,muted:G,onSelectionChange:(S,O)=>this.handleSelectionChange(S,O)},p.name);if(y==="pathBidirectionalArrow")return E.has(d,p.name)?h.jsx(gt,{x1:l[p.source].x,x2:l[p.target].x,y1:l[p.source].y,y2:l[p.target].y,source:p.source,target:p.target,shape:w,curveDirection:A,sourceTargetColor:p.sourceTargetColor,targetSourceColor:p.targetSourceColor,width:p.width,classed:p.classed,name:p.name,selected:v,muted:G,onSelectionChange:(S,O)=>this.handleSelectionChange(S,O)},p.name):h.jsx(Ze,{x1:l[p.source].x,x2:l[p.target].x,y1:l[p.source].y,y2:l[p.target].y,source:p.source,target:p.target,shape:w,curveDirection:A,color:p.stroke,width:1,classed:p.classed,name:p.name,selected:v,muted:G,onSelectionChange:(S,O)=>this.handleSelectionChange(S,O)},p.name)}),b=E.map(this.props.paths,p=>{const v=p.name,y=p.steps,w=[],A=p.color||"steelblue",x=p.width||1;if(y.length>1)for(let G=0;G<y.length-1;G++){let S,O,N;const V=y[G],j=y[G+1];l[V].x<l[j].x||l[V].y<l[j].y?(S=V,O=j,N=1):(S=j,O=V,N=-1);const T=u[S].targetMap[O],q=(E.indexOf(T,v)-(T.length-1)/2)*N,L=`${V}--${j}`,H=r[L];let ee="linear";H&&!E.isUndefined(H.shape)&&!E.isNull(H.shape)&&(ee=H.shape);let te="left";H&&!E.isUndefined(H.curveDirection)&&!E.isNull(H.curveDirection)&&(te=H.curveDirection),this.props.edgeDrawingMethod==="simple"&&w.push(h.jsx(Ze,{x1:l[V].x,y1:l[V].y,x2:l[j].x,y2:l[j].y,position:q*6,source:V,color:A,target:j,shape:ee,curveDirection:te,width:x,classed:`path-${v}`,name:`${v}--${L}`},`${v}--${L}`))}return h.jsx("g",{children:w},v)}),m=E.map(this.props.topology.labels,p=>{const v=e(p.x),y=n(p.y);return h.jsx(Ss,{x:v,y,label:p.label,labelPosition:p.labelPosition},p.label)});let C=null;E.isNull(this.props.legendItems)||(C=h.jsx(bt,{x:this.props.legendItems.x,y:this.props.legendItems.y,edgeTypes:this.props.legendItems.edgeTypes,nodeTypes:this.props.legendItems.nodeTypes,colorSwatches:this.props.legendItems.colorSwatches}));let I;return this.state.dragging?I={cursor:"pointer"}:this.props.onPositionSelected||this.props.onNodeSelected||this.props.onEdgeSelected?I={cursor:"crosshair"}:I={cursor:"default"},h.jsx("svg",{style:I,ref:p=>{this.map=p},width:this.props.width,height:this.props.height,className:"noselect map-container",onClick:p=>this.handleClick(p),onMouseMove:p=>this.handleMouseMove(p),onMouseUp:p=>this.handleMouseUp(p),children:h.jsxs("g",{children:[g,b,a,m,C]})})}}ze.propTypes={topology:c.object.isRequired,width:c.number,height:c.number,margin:c.number,bounds:c.shape({x1:c.number,y1:c.number,x2:c.number,y2:c.number}),edgeDrawingMethod:c.oneOf(["simple","bidirectionalArrow","pathBidirectionalArrow"]),legendItems:c.shape({x:c.number,y:c.number,edgeTypes:c.object,nodeTypes:c.object,colorSwatches:c.object}),selection:c.object,paths:c.array,pathWidth:c.number},ze.defaultProps={width:800,height:600,margin:20,bounds:{x1:0,y1:0,x2:1,y2:1},edgeDrawingMethod:"simple",legendItems:null,selection:{nodes:{},edges:{}},paths:[],pathWidth:5};class ve extends B.Component{render(){return h.jsx("g",{children:h.jsx(Qe,{x:this.props.x,y:this.props.y,style:this.props.style.node,labelStyle:this.props.style.label,labelPosition:this.props.labelPosition,label:this.props.label,radius:this.props.radius,rx:this.props.roundedX,ry:this.props.roundedY,offset:this.props.offset,shape:this.props.shape,muted:this.props.muted,selected:this.props.selected,highlighted:this.props.highlighted},this.props.label)})}}ve.propTypes={label:c.string,labelPosition:c.oneOf(["left","right","top","topright","topleft","bottom","bottomright","bottomleft","bottomleftangled","bottomrightangled","topleftangled","toprightangled"]),offset:c.number,shape:c.oneOf(["circle","square","cloud"]),radius:c.number,roundedX:c.number,roundedY:c.number,style:c.object,muted:c.bool,selected:c.bool,highlighted:c.bool},ve.defaultProps={radius:7,shape:"circle",offset:0,labelPosition:"top",muted:!1,selected:!1,highlighted:!1};class mt extends B.Component{constructor(e){super(e),this.state={width:0},this.handleResize=this.handleResize.bind(this)}componentDidMount(){window.addEventListener("resize",()=>this.handleResize()),this.handleResize()}componentWillUnmount(){window.removeEventListener("resize",()=>this.handleResize())}handleResize(){this.container&&this.setState({width:this.container.offsetWidth})}render(){const e={width:this.state.width};this.props.aspect&&(e.height=this.state.width/this.props.aspect);const n=B.Children.only(this.props.children),s=this.state.width?B.cloneElement(n,e):null;return h.jsx("div",{ref:t=>{this.container=t},style:this.props.style,...this.props,children:s})}}mt.propTypes={children:c.node};class Yt extends B.Component{bounds(){if(this.props.bounds)return this.props.bounds;const e=E.min(this.props.topology.nodes,r=>r.x).x,n=E.min(this.props.topology.nodes,r=>r.y).y,s=E.max(this.props.topology.nodes,r=>r.x).x,t=E.max(this.props.topology.nodes,r=>r.y).y;return{x1:e,x2:s,y1:n,y2:t}}nodeSize(e){return this.props.nodeSizeMap[e]||7}nodeShape(e){return this.props.nodeShapeMap[e]||"circle"}edgeThickness(e){return this.props.edgeThicknessMap[e]||5}edgeShape(e){return E.has(this.props.edgeShapeMap,e)?this.props.edgeShapeMap[e].shape:"linear"}edgeCurveDirection(e){let n;return E.has(this.props.edgeShapeMap,e)&&this.props.edgeShapeMap[e].shape==="curved"?this.props.edgeShapeMap[e].direction:n}edgeCurveOffset(e){let n;return E.has(this.props.edgeShapeMap,e)&&this.props.edgeShapeMap[e].shape==="curved"?this.props.edgeShapeMap[e].offset:n}selectEdgeColor(e){const n=e/1e9;for(let s=0;s<this.props.edgeColorMap.length;s++){const t=this.props.edgeColorMap[s];if(n>=t.range[0])return t.color}return"#C9CACC"}filteredPaths(){return E.filter(this.props.topology.paths,e=>E.isArray(this.props.showPaths)?E.contains(this.props.showPaths,e.name):!0)}buildTopology(){const e={};if(E.isNull(this.props.topology))return null;const n={node:{normal:{fill:"#B0B0B0",stroke:"#9E9E9E",cursor:"pointer"},selected:{fill:"#37B6D3",stroke:"rgba(55, 182, 211, 0.22)",strokeWidth:10,cursor:"pointer"},muted:{fill:"#B0B0B0",stroke:"#9E9E9E",opacity:.6,cursor:"pointer"}},label:{normal:{fill:"#696969",stroke:"none",fontSize:9},selected:{fill:"#333",stroke:"none",fontSize:11},muted:{fill:"#696969",stroke:"none",fontSize:8,opacity:.6}}};if(e.nodes=E.map(this.props.topology.nodes,s=>{const t=E.clone(s);t.radius=this.nodeSize(s.type),t.labelPosition=s.label_position,t.labelOffsetX=s.label_dx,t.labelOffsetY=s.label_dy;const r=E.has(this.props.stylesMap,s.type)?this.props.stylesMap[s.type]:n;return t.style=r.node,t.labelStyle=r.label,t.shape=this.nodeShape(s.name),t}),e.edges=E.map(this.props.topology.edges,s=>{const t=`${s.source}--${s.target}`;return{width:this.edgeThickness(s.capacity),classed:s.capacity,source:s.source,target:s.target,totalCapacity:s.total_capacity,ifac