@qwu4xyv/system-flow
Version:
xyflow core system that powers React Flow and Svelte Flow.
1 lines • 89.2 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XYFlowSystem={})}(this,(function(t){"use strict";const e={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${t} handle id: "${n?o:n}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var o,r,i,a,s,u;t.ConnectionMode=void 0,(o=t.ConnectionMode||(t.ConnectionMode={})).Strict="strict",o.Loose="loose",t.PanOnScrollMode=void 0,(r=t.PanOnScrollMode||(t.PanOnScrollMode={})).Free="free",r.Vertical="vertical",r.Horizontal="horizontal",t.SelectionMode=void 0,(i=t.SelectionMode||(t.SelectionMode={})).Partial="partial",i.Full="full",t.ConnectionLineType=void 0,(a=t.ConnectionLineType||(t.ConnectionLineType={})).Bezier="default",a.Straight="straight",a.Step="step",a.SmoothStep="smoothstep",a.SimpleBezier="simplebezier",t.MarkerType=void 0,(s=t.MarkerType||(t.MarkerType={})).Arrow="arrow",s.ArrowClosed="arrowclosed",t.Position=void 0,(u=t.Position||(t.Position={})).Left="left",u.Top="top",u.Right="right",u.Bottom="bottom";const c=t=>"id"in t&&"source"in t&&"target"in t,l=(t,e=[0,0])=>{const{width:n,height:o}=C(t),r="internals"in t?t.internals.positionAbsolute:t.position,i=t.origin||e,a=n*i[0],s=o*i[1];return{position:{x:t.position.x-a,y:t.position.y-s},positionAbsolute:{x:r.x-a,y:r.y-s}}},h=(t,e={nodeOrigin:[0,0]})=>{if(0===t.length)return{x:0,y:0,width:0,height:0};const n=t.reduce(((t,n)=>{const o=M(n,e.nodeOrigin);return x(t,o)}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return _(n)},d=(t,e={nodeOrigin:[0,0]})=>{if(0===t.size)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return t.forEach((t=>{if(null==e.filter||e.filter(t)){const o=M(t,e.nodeOrigin);n=x(n,o)}})),_(n)},f=(t,e)=>{const n=new Set;return t.forEach((t=>{n.add(t.id)})),e.filter((t=>n.has(t.source)||n.has(t.target)))};function p({nodeId:t,nextPosition:n,nodeLookup:o,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){const s=o.get(t),u=s.parentId?o.get(s.parentId):void 0,{x:c,y:h}=u?l(u,u.origin||r).positionAbsolute:{x:0,y:0};let d=function(t,e){return e&&"parent"!==e?[e[0],[e[1][0]-(t.measured?.width??0),e[1][1]-(t.measured?.height??0)]]:e}(s,s.extent||i);if("parent"!==s.extent||s.expandParent)u&&$(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+h],[s.extent[1][0]+c,s.extent[1][1]+h]]);else if(u){const t=s.measured.width,e=s.measured.height,n=u.measured.width,o=u.measured.height;if(t&&e&&n&&o){const i=s.origin||r,a=c+t*i[0],u=h+e*i[1];d=[[a,u],[a+n-t,u+o-e]]}}else a?.("005",e.error005());const f=$(d)?m(n,d):n;return{position:{x:f.x-c,y:f.y-h},positionAbsolute:f}}const g=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),m=(t={x:0,y:0},e)=>({x:g(t.x,e[0][0],e[1][0]),y:g(t.y,e[0][1],e[1][1])}),y=(t,e,n)=>t<e?g(Math.abs(t-e),1,50)/50:t>n?-g(Math.abs(t-n),1,50)/50:0,v=(t,e)=>[20*y(t.x,35,e.width-35),20*y(t.y,35,e.height-35)],x=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),w=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),_=({x:t,y:e,x2:n,y2:o})=>({x:t,y:e,width:n-t,height:o-e}),b=(t,e=[0,0])=>{const{x:n,y:o}=l(t,e).positionAbsolute;return{x:n,y:o,width:t.measured?.width??t.width??0,height:t.measured?.height??t.height??0}},M=(t,e=[0,0])=>{const{x:n,y:o}=l(t,e).positionAbsolute;return{x:n,y:o,x2:n+(t.measured?.width??t.width??0),y2:o+(t.measured?.height??t.height??0)}},E=(t,e)=>_(x(w(t),w(e))),P=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),o=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*o)},S=t=>!isNaN(t)&&isFinite(t),z=(t,e)=>{},N=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),k=({x:t,y:e},[n,o,r],i=!1,a=[1,1])=>{const s={x:(t-n)/r,y:(e-o)/r};return i?N(s,a):s},T=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o}),A=(t,e,n,o,r,i)=>{const a=e/(t.width*(1+i)),s=n/(t.height*(1+i)),u=Math.min(a,s),c=g(u,o,r);return{x:e/2-(t.x+t.width/2)*c,y:n/2-(t.y+t.height/2)*c,zoom:c}},I=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function $(t){return void 0!==t&&"parent"!==t}function C(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function O(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:o}){const{x:r,y:i}=R(t),a=k({x:r,y:i},o),{x:s,y:u}=n?N(a,e):a;return{xSnapped:s,ySnapped:u,...a}}const H=t=>({width:t.offsetWidth,height:t.offsetHeight}),X=t=>t.getRootNode?.()||window?.document,Y=["INPUT","SELECT","TEXTAREA"];const B=t=>"clientX"in t,R=(t,e)=>{const n=B(t),o=n?t.clientX:t.touches?.[0].clientX,r=n?t.clientY:t.touches?.[0].clientY;return{x:o-(e?.left??0),y:r-(e?.top??0)}},D=(t,e,n,o=[0,0])=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const i=Array.from(r),a=e.getBoundingClientRect(),s=a.width*o[0],u=a.height*o[1];return i.map((t=>{const e=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),position:t.getAttribute("data-handlepos"),x:(e.left-a.left-s)/n,y:(e.top-a.top-u)/n,...H(t)}}))};function L({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s}){const u=.125*t+.375*r+.375*a+.125*n,c=.125*e+.375*i+.375*s+.125*o;return[u,c,Math.abs(u-t),Math.abs(c-e)]}function V(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function q({pos:e,x1:n,y1:o,x2:r,y2:i,c:a}){switch(e){case t.Position.Left:return[n-V(n-r,a),o];case t.Position.Right:return[n+V(r-n,a),o];case t.Position.Top:return[n,o-V(o-i,a)];case t.Position.Bottom:return[n,o+V(i-o,a)]}}function Z({sourceX:t,sourceY:e,targetX:n,targetY:o}){const r=Math.abs(n-t)/2,i=n<t?n+r:n-r,a=Math.abs(o-e)/2;return[i,o<e?o+a:o-a,r,a]}const G=({source:t,sourceHandle:e,target:n,targetHandle:o})=>`xy-edge__${t}${e||""}-${n}${o||""}`;const j={[t.Position.Left]:{x:-1,y:0},[t.Position.Right]:{x:1,y:0},[t.Position.Top]:{x:0,y:-1},[t.Position.Bottom]:{x:0,y:1}},W=({source:e,sourcePosition:n=t.Position.Bottom,target:o})=>n===t.Position.Left||n===t.Position.Right?e.x<o.x?{x:1,y:0}:{x:-1,y:0}:e.y<o.y?{x:0,y:1}:{x:0,y:-1},F=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function K(t){return t&&!(!t.internals.handleBounds&&!t.handles?.length)&&!!(t.measured.width||t.width||t.initialWidth)}function U(t){if(!t)return null;const e=[],n=[];for(const o of t)o.width=o.width??1,o.height=o.height??1,"source"===o.type?e.push(o):"target"===o.type&&n.push(o);return{source:e,target:n}}function Q(e,n,o=null){const r=(o?.x??0)+n.internals.positionAbsolute.x,i=(o?.y??0)+n.internals.positionAbsolute.y,{width:a,height:s}=o??C(n);switch(e){case t.Position.Top:return[r+a/2,i];case t.Position.Right:return[r+a,i+s/2];case t.Position.Bottom:return[r+a/2,i+s];case t.Position.Left:return[r,i+s/2]}}function J(t,e){return t&&(e?t.find((t=>t.id===e)):t[0])||null}function tt(t,e){if(!t)return"";if("string"==typeof t)return t;return`${e?`${e}__`:""}${Object.keys(t).sort().map((e=>`${e}=${t[e]}`)).join("&")}`}function et(t,e={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{}}){const n=e?.elevateNodesOnSelect?1e3:0;for(const[,o]of t){const r=o.parentId;if(!r)continue;if(!t.has(r))throw new Error(`Parent node ${r} not found`);const i=t.get(r),{x:a,y:s,z:u}=nt(o,t,{...o.position,z:(S(o.zIndex)?o.zIndex:0)+(o.selected?n:0)},i?.origin??e.nodeOrigin),c=o.internals.positionAbsolute,l=a!==c.x||s!==c.y;(l||u!==o.internals.z)&&(o.internals={...o.internals,positionAbsolute:l?{x:a,y:s}:c,z:u})}}function nt(t,e,n,o=[0,0]){if(!t.parentId)return n;const r=e.get(t.parentId),i=l(r,o).position;return nt(r,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r.internals.z??0)>(n.z??0)?r.internals.z??0:n.z??0},r.origin||o)}function ot(t,e,n,o){const r=[],i=new Map;for(const n of t){const t=e.get(n.parentId);if(!t)continue;const r=i.get(n.parentId)?.expandedRect??b(t,t.origin??o),a=E(r,n.rect);i.set(n.parentId,{expandedRect:a,parent:t})}return i.size>0&&i.forEach((({expandedRect:e,parent:o},i)=>{const{position:a}=l(o,o.origin),s=C(o),u=e.x<a.x?Math.round(Math.abs(a.x-e.x)):0,c=e.y<a.y?Math.round(Math.abs(a.y-e.y)):0;if(u>0||c>0){r.push({id:i,type:"position",position:{x:a.x-u,y:a.y-c}});const e=n.get(i);e?.forEach((e=>{t.some((t=>t.id===e.id))||r.push({id:e.id,type:"position",position:{x:e.position.x+u,y:e.position.y+c}})}))}(s.width<e.width||s.height<e.height)&&r.push({id:i,type:"dimensions",setAttributes:!0,dimensions:{width:Math.max(s.width,Math.round(e.width)),height:Math.max(s.height,Math.round(e.height))}})})),r}var rt={value:()=>{}};function it(){for(var t,e=0,n=arguments.length,o={};e<n;++e){if(!(t=arguments[e]+"")||t in o||/[\s.]/.test(t))throw new Error("illegal type: "+t);o[t]=[]}return new at(o)}function at(t){this._=t}function st(t,e){for(var n,o=0,r=t.length;o<r;++o)if((n=t[o]).name===e)return n.value}function ut(t,e,n){for(var o=0,r=t.length;o<r;++o)if(t[o].name===e){t[o]=rt,t=t.slice(0,o).concat(t.slice(o+1));break}return null!=n&&t.push({name:e,value:n}),t}at.prototype=it.prototype={constructor:at,on:function(t,e){var n,o,r=this._,i=(o=r,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!o.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=i[a]).type)r[n]=ut(r[n],t.name,e);else if(null==e)for(n in r)r[n]=ut(r[n],t.name,null);return this}for(;++a<s;)if((n=(t=i[a]).type)&&(n=st(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new at(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,n=(o=this._[t]).length;i<n;++i)o[i].value.apply(e,r)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)}};var ct="http://www.w3.org/1999/xhtml",lt={svg:"http://www.w3.org/2000/svg",xhtml:ct,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ht(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),lt.hasOwnProperty(e)?{space:lt[e],local:t}:t}function dt(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===ct&&e.documentElement.namespaceURI===ct?e.createElement(t):e.createElementNS(n,t)}}function ft(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function pt(t){var e=ht(t);return(e.local?ft:dt)(e)}function gt(){}function mt(t){return null==t?gt:function(){return this.querySelector(t)}}function yt(){return[]}function vt(t){return null==t?yt:function(){return this.querySelectorAll(t)}}function xt(t){return function(){return null==(e=t.apply(this,arguments))?[]:Array.isArray(e)?e:Array.from(e);var e}}function wt(t){return function(){return this.matches(t)}}function _t(t){return function(e){return e.matches(t)}}var bt=Array.prototype.find;function Mt(){return this.firstElementChild}var Et=Array.prototype.filter;function Pt(){return Array.from(this.children)}function St(t){return new Array(t.length)}function zt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function Nt(t,e,n,o,r,i){for(var a,s=0,u=e.length,c=i.length;s<c;++s)(a=e[s])?(a.__data__=i[s],o[s]=a):n[s]=new zt(t,i[s]);for(;s<u;++s)(a=e[s])&&(r[s]=a)}function kt(t,e,n,o,r,i,a){var s,u,c,l=new Map,h=e.length,d=i.length,f=new Array(h);for(s=0;s<h;++s)(u=e[s])&&(f[s]=c=a.call(u,u.__data__,s,e)+"",l.has(c)?r[s]=u:l.set(c,u));for(s=0;s<d;++s)c=a.call(t,i[s],s,i)+"",(u=l.get(c))?(o[s]=u,u.__data__=i[s],l.delete(c)):n[s]=new zt(t,i[s]);for(s=0;s<h;++s)(u=e[s])&&l.get(f[s])===u&&(r[s]=u)}function Tt(t){return t.__data__}function At(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function It(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function $t(t){return function(){this.removeAttribute(t)}}function Ct(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ot(t,e){return function(){this.setAttribute(t,e)}}function Ht(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Xt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Yt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Bt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Rt(t){return function(){this.style.removeProperty(t)}}function Dt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Lt(t,e,n){return function(){var o=e.apply(this,arguments);null==o?this.style.removeProperty(t):this.style.setProperty(t,o,n)}}function Vt(t,e){return t.style.getPropertyValue(e)||Bt(t).getComputedStyle(t,null).getPropertyValue(e)}function qt(t){return function(){delete this[t]}}function Zt(t,e){return function(){this[t]=e}}function Gt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function jt(t){return t.trim().split(/^|\s+/)}function Wt(t){return t.classList||new Ft(t)}function Ft(t){this._node=t,this._names=jt(t.getAttribute("class")||"")}function Kt(t,e){for(var n=Wt(t),o=-1,r=e.length;++o<r;)n.add(e[o])}function Ut(t,e){for(var n=Wt(t),o=-1,r=e.length;++o<r;)n.remove(e[o])}function Qt(t){return function(){Kt(this,t)}}function Jt(t){return function(){Ut(this,t)}}function te(t,e){return function(){(e.apply(this,arguments)?Kt:Ut)(this,t)}}function ee(){this.textContent=""}function ne(t){return function(){this.textContent=t}}function oe(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function re(){this.innerHTML=""}function ie(t){return function(){this.innerHTML=t}}function ae(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function se(){this.nextSibling&&this.parentNode.appendChild(this)}function ue(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ce(){return null}function le(){var t=this.parentNode;t&&t.removeChild(this)}function he(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function de(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function fe(t){return function(){var e=this.__on;if(e){for(var n,o=0,r=-1,i=e.length;o<i;++o)n=e[o],t.type&&n.type!==t.type||n.name!==t.name?e[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?e.length=r:delete this.__on}}}function pe(t,e,n){return function(){var o,r=this.__on,i=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===t.type&&o.name===t.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=e);this.addEventListener(t.type,i,n),o={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(o):this.__on=[o]}}function ge(t,e,n){var o=Bt(t),r=o.CustomEvent;"function"==typeof r?r=new r(e,n):(r=o.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function me(t,e){return function(){return ge(this,t,e)}}function ye(t,e){return function(){return ge(this,t,e.apply(this,arguments))}}zt.prototype={constructor:zt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Ft.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ve=[null];function xe(t,e){this._groups=t,this._parents=e}function we(){return new xe([[document.documentElement]],ve)}function _e(t){return"string"==typeof t?new xe([[document.querySelector(t)]],[document.documentElement]):new xe([[t]],ve)}function be(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=t.clientX,o.y=t.clientY,[(o=o.matrixTransform(e.getScreenCTM().inverse())).x,o.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}xe.prototype=we.prototype={constructor:xe,select:function(t){"function"!=typeof t&&(t=mt(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=e[r],u=s.length,c=o[r]=new Array(u),l=0;l<u;++l)(i=s[l])&&(a=t.call(i,i.__data__,l,s))&&("__data__"in i&&(a.__data__=i.__data__),c[l]=a);return new xe(o,this._parents)},selectAll:function(t){t="function"==typeof t?xt(t):vt(t);for(var e=this._groups,n=e.length,o=[],r=[],i=0;i<n;++i)for(var a,s=e[i],u=s.length,c=0;c<u;++c)(a=s[c])&&(o.push(t.call(a,a.__data__,c,s)),r.push(a));return new xe(o,r)},selectChild:function(t){return this.select(null==t?Mt:function(t){return function(){return bt.call(this.children,t)}}("function"==typeof t?t:_t(t)))},selectChildren:function(t){return this.selectAll(null==t?Pt:function(t){return function(){return Et.call(this.children,t)}}("function"==typeof t?t:_t(t)))},filter:function(t){"function"!=typeof t&&(t=wt(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a=e[r],s=a.length,u=o[r]=[],c=0;c<s;++c)(i=a[c])&&t.call(i,i.__data__,c,a)&&u.push(i);return new xe(o,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Tt);var n,o=e?kt:Nt,r=this._parents,i=this._groups;"function"!=typeof t&&(n=t,t=function(){return n});for(var a=i.length,s=new Array(a),u=new Array(a),c=new Array(a),l=0;l<a;++l){var h=r[l],d=i[l],f=d.length,p=At(t.call(h,h&&h.__data__,l,r)),g=p.length,m=u[l]=new Array(g),y=s[l]=new Array(g);o(h,d,m,y,c[l]=new Array(f),p,e);for(var v,x,w=0,_=0;w<g;++w)if(v=m[w]){for(w>=_&&(_=w+1);!(x=y[_])&&++_<g;);v._next=x||null}}return(s=new xe(s,r))._enter=u,s._exit=c,s},enter:function(){return new xe(this._enter||this._groups.map(St),this._parents)},exit:function(){return new xe(this._exit||this._groups.map(St),this._parents)},join:function(t,e,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof t?(o=t(o))&&(o=o.selection()):o=o.append(t+""),null!=e&&(r=e(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,o=e._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),u=0;u<a;++u)for(var c,l=n[u],h=o[u],d=l.length,f=s[u]=new Array(d),p=0;p<d;++p)(c=l[p]||h[p])&&(f[p]=c);for(;u<r;++u)s[u]=n[u];return new xe(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var o,r=t[e],i=r.length-1,a=r[i];--i>=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=It);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],u=s.length,c=r[i]=new Array(u),l=0;l<u;++l)(a=s[l])&&(c[l]=a);c.sort(e)}return new xe(r,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o=t[e],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r,i=e[n],a=0,s=i.length;a<s;++a)(r=i[a])&&t.call(r,r.__data__,a,i);return this},attr:function(t,e){var n=ht(t);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==e?n.local?Ct:$t:"function"==typeof e?n.local?Yt:Xt:n.local?Ht:Ot)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?Rt:"function"==typeof e?Lt:Dt)(t,e,null==n?"":n)):Vt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?qt:"function"==typeof e?Gt:Zt)(t,e)):this.node()[t]},classed:function(t,e){var n=jt(t+"");if(arguments.length<2){for(var o=Wt(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof e?te:e?Qt:Jt)(n,e))},text:function(t){return arguments.length?this.each(null==t?ee:("function"==typeof t?oe:ne)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?re:("function"==typeof t?ae:ie)(t)):this.node().innerHTML},raise:function(){return this.each(se)},lower:function(){return this.each(ue)},append:function(t){var e="function"==typeof t?t:pt(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:pt(t),o=null==e?ce:"function"==typeof e?e:mt(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(le)},clone:function(t){return this.select(t?de:he)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var o,r,i=function(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=i.length;if(!(arguments.length<2)){for(s=e?pe:fe,o=0;o<a;++o)this.each(s(i[o],e,n));return this}var s=this.node().__on;if(s)for(var u,c=0,l=s.length;c<l;++c)for(o=0,u=s[c];o<a;++o)if((r=i[o]).type===u.type&&r.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?ye:me)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o,r=t[e],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};const Me={passive:!1},Ee={capture:!0,passive:!1};function Pe(t){t.stopImmediatePropagation()}function Se(t){t.preventDefault(),t.stopImmediatePropagation()}function ze(t){var e=t.document.documentElement,n=_e(t).on("dragstart.drag",Se,Ee);"onselectstart"in e?n.on("selectstart.drag",Se,Ee):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Ne(t,e){var n=t.document.documentElement,o=_e(t).on("dragstart.drag",null);e&&(o.on("click.drag",Se,Ee),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ke=t=>()=>t;function Te(t,{sourceEvent:e,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:c,dispatch:l}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:l}})}function Ae(t){return!t.ctrlKey&&!t.button}function Ie(){return this.parentNode}function $e(t,e){return null==e?{x:t.x,y:t.y}:e}function Ce(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oe(){var t,e,n,o,r=Ae,i=Ie,a=$e,s=Ce,u={},c=it("start","drag","end"),l=0,h=0;function d(t){t.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,Me).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(a,s){if(!o&&r.call(this,a,s)){var u=x(this,i.call(this,a,s),a,s,"mouse");u&&(_e(a.view).on("mousemove.drag",p,Ee).on("mouseup.drag",g,Ee),ze(a.view),Pe(a),n=!1,t=a.clientX,e=a.clientY,u("start",a))}}function p(o){if(Se(o),!n){var r=o.clientX-t,i=o.clientY-e;n=r*r+i*i>h}u.mouse("drag",o)}function g(t){_e(t.view).on("mousemove.drag mouseup.drag",null),Ne(t.view,n),Se(t),u.mouse("end",t)}function m(t,e){if(r.call(this,t,e)){var n,o,a=t.changedTouches,s=i.call(this,t,e),u=a.length;for(n=0;n<u;++n)(o=x(this,s,t,e,a[n].identifier,a[n]))&&(Pe(t),o("start",t,a[n]))}}function y(t){var e,n,o=t.changedTouches,r=o.length;for(e=0;e<r;++e)(n=u[o[e].identifier])&&(Se(t),n("drag",t,o[e]))}function v(t){var e,n,r=t.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),e=0;e<i;++e)(n=u[r[e].identifier])&&(Pe(t),n("end",t,r[e]))}function x(t,e,n,o,r,i){var s,h,f,p=c.copy(),g=be(i||n,e);if(null!=(f=a.call(t,new Te("beforestart",{sourceEvent:n,target:d,identifier:r,active:l,x:g[0],y:g[1],dx:0,dy:0,dispatch:p}),o)))return s=f.x-g[0]||0,h=f.y-g[1]||0,function n(i,a,c){var m,y=g;switch(i){case"start":u[r]=n,m=l++;break;case"end":delete u[r],--l;case"drag":g=be(c||a,e),m=l}p.call(i,t,new Te(i,{sourceEvent:a,subject:f,target:d,identifier:r,active:m,x:g[0]+s,y:g[1]+h,dx:g[0]-y[0],dy:g[1]-y[1],dispatch:p}),o)}}return d.filter=function(t){return arguments.length?(r="function"==typeof t?t:ke(!!t),d):r},d.container=function(t){return arguments.length?(i="function"==typeof t?t:ke(t),d):i},d.subject=function(t){return arguments.length?(a="function"==typeof t?t:ke(t),d):a},d.touchable=function(t){return arguments.length?(s="function"==typeof t?t:ke(!!t),d):s},d.on=function(){var t=c.on.apply(c,arguments);return t===c?d:t},d.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,d):Math.sqrt(h)},d}function He(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return!!n&&(!!n.selected||He(n,e))}function Xe(t,e,n){let o=t;do{if(o?.matches(e))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1}function Ye({nodeId:t,dragItems:e,nodeLookup:n}){const o=[];for(const[t,r]of e){const e=n.get(t);e&&o.push({...e,position:r.position})}if(!t)return[o[0],o];const r=n.get(t);return[{...r,position:e.get(t)?.position||r.position},o]}function Be(t,e,n,o){return(e[n]||[]).reduce(((e,r)=>(`${t.id}-${r.id}-${n}`!==o&&e.push({id:r.id||null,type:n,nodeId:t.id,x:t.internals.positionAbsolute.x+r.x+r.width/2,y:t.internals.positionAbsolute.y+r.y+r.height/2}),e)),[])}function Re(t,e){return t||(e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null)}function De(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}Te.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const Le=()=>!0;let Ve=null;function qe(e,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:s,lib:u,flowId:c,isValidConnection:l=Le}){const h="target"===a,d=n?s.querySelector(`.${u}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:f,y:p}=R(e),g=s.elementFromPoint(f,p),m=g?.classList.contains(`${u}-flow__handle`)?g:d,y={handleDomNode:m,isValid:!1,connection:null,endHandle:null};if(m){const e=Re(void 0,m),n=m.getAttribute("data-nodeid"),a=m.getAttribute("data-handleid"),s=m.classList.contains("connectable"),u=m.classList.contains("connectableend");if(!n)return y;const c={source:h?n:r,sourceHandle:h?a:i,target:h?r:n,targetHandle:h?i:a};y.connection=c;s&&u&&(o===t.ConnectionMode.Strict?h&&"source"===e||!h&&"target"===e:n!==r||a!==i)&&(y.endHandle={nodeId:n,handleId:a,type:e},y.isValid=l(c))}return y}const Ze={onPointerDown:function(t,{connectionMode:e,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:a,domNode:s,nodeLookup:u,lib:c,autoPanOnConnect:l,flowId:h,panBy:d,cancelConnection:f,onConnectStart:p,onConnect:g,onConnectEnd:m,isValidConnection:y=Le,onEdgeUpdateEnd:x,updateConnection:w,getTransform:_,getConnectionStartHandle:b}){const M=X(t.target);let E,P=0;const{x:S,y:z}=R(t),N=M?.elementFromPoint(S,z),A=Re(i,N),I=s?.getBoundingClientRect();if(!I||!A)return;let $=R(t,I),C=!1,O=null,H=!1,Y=null;const B=function({nodeLookup:t,nodeId:e,handleId:n,handleType:o}){const r=[];for(const[,i]of t)if(i.internals.handleBounds){const t=`${e}-${n}-${o}`,a=Be(i,i.internals.handleBounds,"source",t),s=Be(i,i.internals.handleBounds,"target",t);r.push(...a,...s)}return r}({nodeLookup:u,nodeId:r,handleId:o,handleType:A});function D(){if(!l||!I)return;const[t,e]=v($,I);d({x:t,y:e}),P=requestAnimationFrame(D)}function L(t){b()||V(t);const i=_();$=R(t,I),E=function(t,e,n){let o=[],r=1/0;for(const i of n){const n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));n<=e&&(n<r?o=[i]:n===r&&o.push(i),r=n)}return o.length?1===o.length?o[0]:o.find((t=>"target"===t.type))||o[0]:null}(k($,i,!1,[1,1]),n,B),C||(D(),C=!0);const s=qe(t,{handle:E,connectionMode:e,fromNodeId:r,fromHandleId:o,fromType:a?"target":"source",isValidConnection:y,doc:M,lib:c,flowId:h});Y=s.handleDomNode,O=s.connection,H=s.isValid,w({connectionStartHandle:Ve,connectionPosition:E&&H?T({x:E.x,y:E.y},i):$,connectionStatus:De(!!E,H),connectionEndHandle:s.endHandle})}function V(t){(E||Y)&&O&&H&&g?.(O),m?.(t),i&&x?.(t),f(),cancelAnimationFrame(P),C=!1,H=!1,O=null,Y=null,Ve=null,M.removeEventListener("mousemove",L),M.removeEventListener("mouseup",V),M.removeEventListener("touchmove",L),M.removeEventListener("touchend",V)}Ve={nodeId:r,handleId:o,type:A},w({connectionPosition:$,connectionStatus:null,connectionStartHandle:Ve,connectionEndHandle:null}),p?.(t,{nodeId:r,handleId:o,handleType:A}),M.addEventListener("mousemove",L),M.addEventListener("mouseup",V),M.addEventListener("touchmove",L),M.addEventListener("touchend",V)},isValid:qe};function Ge(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function je(t,e){var n=Object.create(t.prototype);for(var o in e)n[o]=e[o];return n}function We(){}var Fe=.7,Ke=1/Fe,Ue="\\s*([+-]?\\d+)\\s*",Qe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",tn=/^#([0-9a-f]{3,8})$/,en=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),nn=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),on=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${Qe}\\)$`),rn=new RegExp(`^rgba\\(${Je},${Je},${Je},${Qe}\\)$`),an=new RegExp(`^hsl\\(${Qe},${Je},${Je}\\)$`),sn=new RegExp(`^hsla\\(${Qe},${Je},${Je},${Qe}\\)$`),un={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function cn(){return this.rgb().formatHex()}function ln(){return this.rgb().formatRgb()}function hn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=tn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?dn(e):3===n?new gn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?fn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?fn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=en.exec(t))?new gn(e[1],e[2],e[3],1):(e=nn.exec(t))?new gn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=on.exec(t))?fn(e[1],e[2],e[3],e[4]):(e=rn.exec(t))?fn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=an.exec(t))?_n(e[1],e[2]/100,e[3]/100,1):(e=sn.exec(t))?_n(e[1],e[2]/100,e[3]/100,e[4]):un.hasOwnProperty(t)?dn(un[t]):"transparent"===t?new gn(NaN,NaN,NaN,0):null}function dn(t){return new gn(t>>16&255,t>>8&255,255&t,1)}function fn(t,e,n,o){return o<=0&&(t=e=n=NaN),new gn(t,e,n,o)}function pn(t,e,n,o){return 1===arguments.length?((r=t)instanceof We||(r=hn(r)),r?new gn((r=r.rgb()).r,r.g,r.b,r.opacity):new gn):new gn(t,e,n,null==o?1:o);var r}function gn(t,e,n,o){this.r=+t,this.g=+e,this.b=+n,this.opacity=+o}function mn(){return`#${wn(this.r)}${wn(this.g)}${wn(this.b)}`}function yn(){const t=vn(this.opacity);return`${1===t?"rgb(":"rgba("}${xn(this.r)}, ${xn(this.g)}, ${xn(this.b)}${1===t?")":`, ${t})`}`}function vn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function xn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function wn(t){return((t=xn(t))<16?"0":"")+t.toString(16)}function _n(t,e,n,o){return o<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Mn(t,e,n,o)}function bn(t){if(t instanceof Mn)return new Mn(t.h,t.s,t.l,t.opacity);if(t instanceof We||(t=hn(t)),!t)return new Mn;if(t instanceof Mn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,o=t.b/255,r=Math.min(e,n,o),i=Math.max(e,n,o),a=NaN,s=i-r,u=(i+r)/2;return s?(a=e===i?(n-o)/s+6*(n<o):n===i?(o-e)/s+2:(e-n)/s+4,s/=u<.5?i+r:2-i-r,a*=60):s=u>0&&u<1?0:a,new Mn(a,s,u,t.opacity)}function Mn(t,e,n,o){this.h=+t,this.s=+e,this.l=+n,this.opacity=+o}function En(t){return(t=(t||0)%360)<0?t+360:t}function Pn(t){return Math.max(0,Math.min(1,t||0))}function Sn(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Ge(We,hn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:cn,formatHex:cn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return bn(this).formatHsl()},formatRgb:ln,toString:ln}),Ge(gn,pn,je(We,{brighter(t){return t=null==t?Ke:Math.pow(Ke,t),new gn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Fe:Math.pow(Fe,t),new gn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new gn(xn(this.r),xn(this.g),xn(this.b),vn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:mn,formatHex:mn,formatHex8:function(){return`#${wn(this.r)}${wn(this.g)}${wn(this.b)}${wn(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:yn,toString:yn})),Ge(Mn,(function(t,e,n,o){return 1===arguments.length?bn(t):new Mn(t,e,n,null==o?1:o)}),je(We,{brighter(t){return t=null==t?Ke:Math.pow(Ke,t),new Mn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Fe:Math.pow(Fe,t),new Mn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*e,r=2*n-o;return new gn(Sn(t>=240?t-240:t+120,r,o),Sn(t,r,o),Sn(t<120?t+240:t-120,r,o),this.opacity)},clamp(){return new Mn(En(this.h),Pn(this.s),Pn(this.l),vn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=vn(this.opacity);return`${1===t?"hsl(":"hsla("}${En(this.h)}, ${100*Pn(this.s)}%, ${100*Pn(this.l)}%${1===t?")":`, ${t})`}`}}));var zn=t=>()=>t;function Nn(t){return 1==(t=+t)?kn:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(o){return Math.pow(t+o*e,n)}}(e,n,t):zn(isNaN(e)?n:e)}}function kn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):zn(isNaN(t)?e:t)}var Tn=function t(e){var n=Nn(e);function o(t,e){var o=n((t=pn(t)).r,(e=pn(e)).r),r=n(t.g,e.g),i=n(t.b,e.b),a=kn(t.opacity,e.opacity);return function(e){return t.r=o(e),t.g=r(e),t.b=i(e),t.opacity=a(e),t+""}}return o.gamma=t,o}(1);function An(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var In=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$n=new RegExp(In.source,"g");function Cn(t,e){var n,o,r,i=In.lastIndex=$n.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=In.exec(t))&&(o=$n.exec(e));)(r=o.index)>i&&(r=e.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,u.push({i:a,x:An(n,o)})),i=$n.lastIndex;return i<e.length&&(r=e.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,o=0;o<e;++o)s[(n=u[o]).i]=n.x(t);return s.join("")})}var On,Hn=180/Math.PI,Xn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yn(t,e,n,o,r,i){var a,s,u;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*o)&&(n-=t*u,o-=e*u),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,u/=s),t*o<e*n&&(t=-t,e=-e,u=-u,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(e,t)*Hn,skewX:Math.atan(u)*Hn,scaleX:a,scaleY:s}}function Bn(t,e,n,o){function r(t){return t.length?t.pop()+" ":""}return function(i,a){var s=[],u=[];return i=t(i),a=t(a),function(t,o,r,i,a,s){if(t!==r||o!==i){var u=a.push("translate(",null,e,null,n);s.push({i:u-4,x:An(t,r)},{i:u-2,x:An(o,i)})}else(r||i)&&a.push("translate("+r+e+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,u),function(t,e,n,i){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:An(t,e)})):e&&n.push(r(n)+"rotate("+e+o)}(i.rotate,a.rotate,s,u),function(t,e,n,i){t!==e?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:An(t,e)}):e&&n.push(r(n)+"skewX("+e+o)}(i.skewX,a.skewX,s,u),function(t,e,n,o,i,a){if(t!==n||e!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:An(t,n)},{i:s-2,x:An(e,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,u),i=a=null,function(t){for(var e,n=-1,o=u.length;++n<o;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var Rn=Bn((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Xn:Yn(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),Dn=Bn((function(t){return null==t?Xn:(On||(On=document.createElementNS("http://www.w3.org/2000/svg","g")),On.setAttribute("transform",t),(t=On.transform.baseVal.consolidate())?Yn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Xn)}),", ",")",")");function Ln(t){return((t=Math.exp(t))+1/t)/2}var Vn,qn,Zn=function t(e,n,o){function r(t,r){var i,a,s=t[0],u=t[1],c=t[2],l=r[0],h=r[1],d=r[2],f=l-s,p=h-u,g=f*f+p*p;if(g<1e-12)a=Math.log(d/c)/e,i=function(t){return[s+t*f,u+t*p,c*Math.exp(e*t*a)]};else{var m=Math.sqrt(g),y=(d*d-c*c+o*g)/(2*c*n*m),v=(d*d-c*c-o*g)/(2*d*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);a=(w-x)/e,i=function(t){var o,r=t*a,i=Ln(x),l=c/(n*m)*(i*(o=e*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(t){return((t=Math.exp(t))-1/t)/2}(x));return[s+l*f,u+l*p,c*i/Ln(e*r+x)]}}return i.duration=1e3*a*e/Math.SQRT2,i}return r.rho=function(e){var n=Math.max(.001,+e),o=n*n;return t(n,o,o*o)},r}(Math.SQRT2,2,4),Gn=0,jn=0,Wn=0,Fn=1e3,Kn=0,Un=0,Qn=0,Jn="object"==typeof performance&&performance.now?performance:Date,to="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function eo(){return Un||(to(no),Un=Jn.now()+Qn)}function no(){Un=0}function oo(){this._call=this._time=this._next=null}function ro(t,e,n){var o=new oo;return o.restart(t,e,n),o}function io(){Un=(Kn=Jn.now())+Qn,Gn=jn=0;try{!function(){eo(),++Gn;for(var t,e=Vn;e;)(t=Un-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gn}()}finally{Gn=0,function(){var t,e,n=Vn,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Vn=e);qn=t,so(o)}(),Un=0}}function ao(){var t=Jn.now(),e=t-Kn;e>Fn&&(Qn-=e,Kn=t)}function so(t){Gn||(jn&&(jn=clearTimeout(jn)),t-Un>24?(t<1/0&&(jn=setTimeout(io,t-Jn.now()-Qn)),Wn&&(Wn=clearInterval(Wn))):(Wn||(Kn=Jn.now(),Wn=setInterval(ao,Fn)),Gn=1,to(io)))}function uo(t,e,n){var o=new oo;return e=null==e?0:+e,o.restart((n=>{o.stop(),t(n+e)}),e,n),o}oo.prototype=ro.prototype={constructor:oo,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?eo():+n)+(null==e?0:+e),this._next||qn===this||(qn?qn._next=this:Vn=this,qn=this),this._call=t,this._time=n,so()},stop:function(){this._call&&(this._call=null,this._time=1/0,so())}};var co=it("start","end","cancel","interrupt"),lo=[],ho=0,fo=1,po=2,go=3,mo=4,yo=5,vo=6;function xo(t,e,n,o,r,i){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var o,r=t.__transition;function i(t){n.state=fo,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(i){var c,l,h,d;if(n.state!==fo)return u();for(c in r)if((d=r[c]).name===n.name){if(d.state===go)return uo(a);d.state===mo?(d.state=vo,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[c]):+c<e&&(d.state=vo,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete r[c])}if(uo((function(){n.state===go&&(n.state=mo,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=po,n.on.call("start",t,t.__data__,n.index,n.group),n.state===po){for(n.state=go,o=new Array(h=n.tween.length),c=0,l=-1;c<h;++c)(d=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(o[++l]=d);o.length=l+1}}function s(e){for(var r=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=yo,1),i=-1,a=o.length;++i<a;)o[i].call(t,r);n.state===yo&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var o in n.state=vo,n.timer.stop(),delete r[e],r)return;delete t.__transition}r[e]=n,n.timer=ro(i,0,n.time)}(t,n,{name:e,index:o,group:r,on:co,tween:lo,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ho})}function wo(t,e){var n=bo(t,e);if(n.state>ho)throw new Error("too late; already scheduled");return n}function _o(t,e){var n=bo(t,e);if(n.state>go)throw new Error("too late; already running");return n}function bo(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Mo(t,e){var n,o,r,i=t.__transition,a=!0;if(i){for(r in e=null==e?null:e+"",i)(n=i[r]).name===e?(o=n.state>po&&n.state<yo,n.state=vo,n.timer.stop(),n.on.call(o?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete t.__transition}}function Eo(t,e){var n,o;return function(){var r=_o(this,t),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===e){(o=o.slice()).splice(a,1);break}r.tween=o}}function Po(t,e,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=_o(this,t),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:e,value:n},u=0,c=r.length;u<c;++u)if(r[u].name===e){r[u]=s;break}u===c&&r.push(s)}i.tween=r}}function So(t,e,n){var o=t._id;return t.each((function(){var t=_o(this,o);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return bo(t,o).value[e]}}function zo(t,e){var n;return("number"==typeof e?An:e instanceof hn?Tn:(n=hn(e))?(e=n,Tn):Cn)(t,e)}function No(t){return function(){this.removeAttribute(t)}}function ko(t){return function(){this.removeAttributeNS(t.space,t.local)}}function To(t,e,n){var o,r,i=n+"";return function(){var a=this.getAttribute(t);return a===i?null:a===o?r:r=e(o=a,n)}}function Ao(t,e,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===i?null:a===o?r:r=e(o=a,n)}}function Io(t,e,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(t))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=e(o=a,u));this.removeAttribute(t)}}function $o(t,e,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=e(o=a,u));this.removeAttributeNS(t.space,t.local)}}function Co(t,e){var n,o;function r(){var r=e.apply(this,arguments);return r!==o&&(n=(o=r)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,r)),n}return r._value=e,r}function Oo(t,e){var n,o;function r(){var r=e.apply(this,arguments);return r!==o&&(n=(o=r)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,r)),n}return r._value=e,r}function Ho(t,e){return function(){wo(this,t).delay=+e.apply(this,arguments)}}function Xo(t,e){return e=+e,function(){wo(this,t).delay=e}}function Yo(t,e){return function(){_o(this,t).duration=+e.apply(this,arguments)}}function Bo(t,e){return e=+e,function(){_o(this,t).duration=e}}var Ro=we.prototype.constructor;function Do(t){return function(){this.style.removeProperty(t)}}var Lo=0;function Vo(t,e,n,o){this._groups=t,this._parents=e,this._name=n,this._id=o}function qo(){return++Lo}var Zo=we.prototype;Vo.prototype={constructor:Vo,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=mt(t));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,u,c=o[a],l=c.length,h=i[a]=new Array(l),d=0;d<l;++d)(s=c[d])&&(u=t.call(s,s.__data__,d,c))&&("__data__"in s&&(u.__data__=s.__data__),h[d]=u,xo(h[d],e,n,d,h,bo(s,n)));return new Vo(i,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=vt(t));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var u,c=o[s],l=c.length,h=0;h<l;++h)if(u=c[h]){for(var d,f=t.call(u,u.__data__,h,c),p=bo(u,n),g=0,m=f.length;g<m;++g)(d=f[g])&&xo(d,e,n,g,f,p);i.push(f),a.push(u)}return new Vo(i,a,e,n)},selectChild:Zo.selectChild,selectChildren:Zo.selectChildren,filter:function(t){"function"!=typeof t&&(t=wt(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a=e[r],s=a.length,u=o[r]=[],c=0;c<s;++c)(i=a[c])&&t.call(i,i.__data__,c,a)&&u.push(i);return new Vo(o,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,o=e.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var u,c=e[s],l=n[s],h=c.length,d=a[s]=new Array(h),f=0;f<h;++f)(u=c[f]||l[f])&&(d[f]=u);for(;s<o;++s)a[s]=e[s];return new Vo(a,this._parents,this._name,this._id)},selection:function(){return new Ro(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=qo(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,c=0;c<u;++c)if(a=s[c]){var l=bo(a,e);xo(a,t,n,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new Vo(o,this._parents,t,n)},call:Zo.call,nodes:Zo.nodes,node:Zo.node,size:Zo.size,empty:Zo.empty,each:Zo.each,on:function(t,e){var n=this._id;return arguments.length<2?bo(this.node(),n).on.on(t):this.each(function(t,e,n){var o,r,i=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?wo:_o;return function(){var a=i(this,t),s=a.on;s!==o&&(r=(o=s).copy()).on(e,n),a.on=r}}(n,t,e))},attr:function(t,e){var n=ht(t),o="transform"===n?Dn:zo;return this.attrTween(t,"function"==typeof e?(n.local?$o:Io)(n,o,So(this,"attr."+t,e)):null==e?(n.local?ko:No)(n):(n.local?Ao:To)(n,o,e))},attrTween:function(t,e){