UNPKG

d3-dag

Version:

Layout algorithms for visualizing directed acylic graphs.

30 lines (28 loc) 148 kB
var L6=Object.create;var{getPrototypeOf:x6,defineProperty:L0,getOwnPropertyNames:D1,getOwnPropertyDescriptor:f6}=Object,z1=Object.prototype.hasOwnProperty;function L1($){return this[$]}var b6,w6,h=($,X,Y)=>{var Z=$!=null&&typeof $==="object";if(Z){var K=X?b6??=new WeakMap:w6??=new WeakMap,U=K.get($);if(U)return U}Y=$!=null?L6(x6($)):{};let J=X||!$||!$.__esModule?L0(Y,"default",{value:$,enumerable:!0}):Y;for(let F of D1($))if(!z1.call(J,F))L0(J,F,{get:L1.bind($,F),enumerable:!0});if(Z)K.set($,J);return J},k6=($)=>{var X=(j1??=new WeakMap).get($),Y;if(X)return X;if(X=L0({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var Z of D1($))if(!z1.call(X,Z))L0(X,Z,{get:L1.bind($,Z),enumerable:!(Y=f6($,Z))||Y.enumerable})}return j1.set($,X),X},j1,V0=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var v6=($)=>$;function y6($,X){this[$]=v6.bind(null,X)}var h6=($,X)=>{for(var Y in X)L0($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:y6.bind(X,Y)})};var f5=V0((EZ,x5)=>{var u0=0.000000000000000000000000000000000000000000000000000000000001,z5,L5;do u0+=u0,z5=1+0.1*u0,L5=1+0.2*u0;while(z5<=1||L5<=1);x5.exports=u0});var w5=V0((WZ,b5)=>{function YX($,X,Y){let Z,K;for(let U=1;U<=Y;U+=1){$[U][U]=1/$[U][U],K=-$[U][U];for(let J=1;J<U;J+=1)$[J][U]*=K;if(Z=U+1,Y<Z)break;for(let J=Z;J<=Y;J+=1){K=$[U][J],$[U][J]=0;for(let F=1;F<=U;F+=1)$[F][J]+=K*$[F][U]}}}b5.exports=YX});var v5=V0((GZ,k5)=>{function ZX($,X,Y,Z){let K,U;for(K=1;K<=Y;K+=1){U=0;for(let J=1;J<K;J+=1)U+=$[J][K]*Z[J];Z[K]=(Z[K]-U)/$[K][K]}for(let J=1;J<=Y;J+=1){K=Y+1-J,Z[K]/=$[K][K],U=-Z[K];for(let F=1;F<K;F+=1)Z[F]+=U*$[F][K]}}k5.exports=ZX});var h5=V0((IZ,y5)=>{function KX($,X,Y,Z){let K,U,J;for(let F=1;F<=Y;F+=1){if(Z[1]=F,J=0,K=F-1,K<1){if(J=$[F][F]-J,J<=0)break;$[F][F]=Math.sqrt(J)}else{for(let R=1;R<=K;R+=1){U=$[R][F];for(let B=1;B<R;B+=1)U-=$[B][F]*$[B][R];U/=$[R][R],$[R][F]=U,J+=U*U}if(J=$[F][F]-J,J<=0)break;$[F][F]=Math.sqrt(J)}Z[1]=0}}y5.exports=KX});var u5=V0((CZ,m5)=>{var q1=f5(),UX=w5(),JX=v5(),FX=h5();function BX($,X,Y,Z,K,U,J,F,R,B,H,V,M,P=0,A,_,q){let Q,E,W,C,N,G,O,S,j,T,L,x,k,m,v=Math.min(Z,H),z=2*Z+v*(v+5)/2+2*H+1;for(let I=1;I<=Z;I+=1)_[I]=X[I];for(let I=Z+1;I<=z;I+=1)_[I]=0;for(let I=1;I<=H;I+=1)M[I]=0,U[I]=0;let u=[];if(q[1]===0){if(FX($,Y,Z,u),u[1]!==0){q[1]=2;return}JX($,Y,Z,X),UX($,Y,Z)}else{for(let I=1;I<=Z;I+=1){K[I]=0;for(let w=1;w<=I;w+=1)K[I]+=$[w][I]*X[w]}for(let I=1;I<=Z;I+=1){X[I]=0;for(let w=I;w<=Z;w+=1)X[I]+=$[I][w]*K[w]}}J[1]=0;for(let I=1;I<=Z;I+=1){K[I]=X[I],J[1]+=_[I]*K[I],_[I]=0;for(let w=I+1;w<=Z;w+=1)$[w][I]=0}J[1]=-J[1]/2,q[1]=0;let y=Z,b=y+Z,f=b+v,g=f+v+1,l=g+v*(v+1)/2,o=l+H;for(let I=1;I<=H;I+=1){G=0;for(let w=1;w<=Z;w+=1)G+=F[w][I]*F[w][I];_[o+I]=Math.sqrt(G)}C=P,A[1]=0,A[2]=0;function Z0(){A[1]+=1,z=l;for(let I=1;I<=H;I+=1){z+=1,G=-R[I];for(let w=1;w<=Z;w+=1)G+=F[w][I]*K[w];if(Math.abs(G)<q1)G=0;if(I>V)_[z]=G;else if(_[z]=-Math.abs(G),G>0){for(let w=1;w<=Z;w+=1)F[w][I]=-F[w][I];R[I]=-R[I]}}for(let I=1;I<=C;I+=1)_[l+M[I]]=0;W=0,N=0;for(let I=1;I<=H;I+=1)if(_[l+I]<N*_[o+I])W=I,N=_[l+I]/_[o+I];if(W===0){for(let I=1;I<=C;I+=1)U[M[I]]=_[f+I];return 999}return 0}function $0(){for(let I=1;I<=Z;I+=1){G=0;for(let w=1;w<=Z;w+=1)G+=$[w][I]*F[w][W];_[I]=G}Q=y;for(let I=1;I<=Z;I+=1)_[Q+I]=0;for(let I=C+1;I<=Z;I+=1)for(let w=1;w<=Z;w+=1)_[Q+w]=_[Q+w]+$[w][I]*_[I];x=!0;for(let I=C;I>=1;I-=1){G=_[I],z=g+I*(I+3)/2,Q=z-I;for(let w=I+1;w<=C;w+=1)G-=_[z]*_[b+w],z+=w;if(G/=_[Q],_[b+I]=G,M[I]<=V)continue;if(G<=0)continue;x=!1,E=I}if(!x){O=_[f+E]/_[b+E];for(let I=1;I<=C;I+=1){if(M[I]<=V)continue;if(_[b+I]<=0)continue;if(N=_[f+I]/_[b+I],N<O)O=N,E=I}}G=0;for(let I=y+1;I<=y+Z;I+=1)G+=_[I]*_[I];if(Math.abs(G)<=q1){if(x)return q[1]=1,999;for(let I=1;I<=C;I+=1)_[f+I]=_[f+I]-O*_[b+I];return _[f+C+1]=_[f+C+1]+O,700}G=0;for(let I=1;I<=Z;I+=1)G+=_[y+I]*F[I][W];if(S=-_[l+W]/G,k=!0,!x){if(O<S)S=O,k=!1}for(let I=1;I<=Z;I+=1)if(K[I]+=S*_[y+I],Math.abs(K[I])<q1)K[I]=0;J[1]+=S*G*(S/2+_[f+C+1]);for(let I=1;I<=C;I+=1)_[f+I]=_[f+I]-S*_[b+I];if(_[f+C+1]=_[f+C+1]+S,k){C+=1,M[C]=W,z=g+(C-1)*C/2+1;for(let I=1;I<=C-1;I+=1)_[z]=_[I],z+=1;if(C===Z)_[z]=_[Z];else{for(let I=Z;I>=C+1;I-=1){if(_[I]===0)continue;if(j=Math.max(Math.abs(_[I-1]),Math.abs(_[I])),T=Math.min(Math.abs(_[I-1]),Math.abs(_[I])),_[I-1]>=0)N=Math.abs(j*Math.sqrt(1+T*T/(j*j)));else N=-Math.abs(j*Math.sqrt(1+T*T/(j*j)));if(j=_[I-1]/N,T=_[I]/N,j===1)continue;if(j===0){_[I-1]=T*N;for(let w=1;w<=Z;w+=1)N=$[w][I-1],$[w][I-1]=$[w][I],$[w][I]=N}else{_[I-1]=N,L=T/(1+j);for(let w=1;w<=Z;w+=1)N=j*$[w][I-1]+T*$[w][I],$[w][I]=L*($[w][I-1]+N)-$[w][I],$[w][I-1]=N}}_[z]=_[C]}}else{G=-R[W];for(let I=1;I<=Z;I+=1)G+=K[I]*F[I][W];if(W>V)_[l+W]=G;else if(_[l+W]=-Math.abs(G),G>0){for(let I=1;I<=Z;I+=1)F[I][W]=-F[I][W];R[W]=-R[W]}return 700}return 0}function G0(){if(z=g+E*(E+1)/2+1,Q=z+E,_[Q]===0)return 798;if(j=Math.max(Math.abs(_[Q-1]),Math.abs(_[Q])),T=Math.min(Math.abs(_[Q-1]),Math.abs(_[Q])),_[Q-1]>=0)N=Math.abs(j*Math.sqrt(1+T*T/(j*j)));else N=-Math.abs(j*Math.sqrt(1+T*T/(j*j)));if(j=_[Q-1]/N,T=_[Q]/N,j===1)return 798;if(j===0){for(let I=E+1;I<=C;I+=1)N=_[Q-1],_[Q-1]=_[Q],_[Q]=N,Q+=I;for(let I=1;I<=Z;I+=1)N=$[I][E],$[I][E]=$[I][E+1],$[I][E+1]=N}else{L=T/(1+j);for(let I=E+1;I<=C;I+=1)N=j*_[Q-1]+T*_[Q],_[Q]=L*(_[Q-1]+N)-_[Q],_[Q-1]=N,Q+=I;for(let I=1;I<=Z;I+=1)N=j*$[I][E]+T*$[I][E+1],$[I][E+1]=L*($[I][E]+N)-$[I][E+1],$[I][E]=N}return 0}function I0(){Q=z-E;for(let I=1;I<=E;I+=1)_[Q]=_[z],z+=1,Q+=1;if(_[f+E]=_[f+E+1],M[E]=M[E+1],E+=1,E<C)return 797;return 0}function M0(){return _[f+C]=_[f+C+1],_[f+C+1]=0,M[C]=0,C-=1,A[2]+=1,0}m=0;while(!0){if(m=Z0(),m===999)return;while(!0){if(m=$0(),m===0)break;if(m===999)return;if(m===700)if(E===C)M0();else{while(!0)if(G0(),m=I0(),m!==797)break;M0()}}}}m5.exports=BX});var c5=V0((g5)=>{var RX=u5();function HX($,X,Y,Z=[],K=0,U=[0,0]){let J=[],F=[],R=[],B=[],H=[],V=[],M="",P=$.length-1,A=Y[1].length-1;if(!Z)for(let Q=1;Q<=A;Q+=1)Z[Q]=0;if(P!==$[1].length-1)M="Dmat is not symmetric!";if(P!==X.length-1)M="Dmat and dvec are incompatible!";if(P!==Y.length-1)M="Amat and dvec are incompatible!";if(A!==Z.length-1)M="Amat and bvec are incompatible!";if(K>A||K<0)M="Value of meq is invalid!";if(M!=="")return{message:M};for(let Q=1;Q<=A;Q+=1)F[Q]=0,B[Q]=0;let _=0,q=Math.min(P,A);for(let Q=1;Q<=P;Q+=1)R[Q]=0;J[1]=0;for(let Q=1;Q<=2*P+q*(q+5)/2+2*A+1;Q+=1)H[Q]=0;for(let Q=1;Q<=2;Q+=1)V[Q]=0;if(RX($,X,P,P,R,B,J,Y,Z,P,A,K,F,_,V,H,U),U[1]===1)M="constraints are inconsistent, no solution!";if(U[1]===2)M="matrix D in quadratic function is not positive definite!";return{solution:R,Lagrangian:B,value:J,unconstrained_solution:X,iterations:V,iact:F,message:M}}g5.solveQP=HX});var l5=V0((OZ,p5)=>{p5.exports=c5()});var vX={};h6(vX,{zherebko:()=>L$,unsugify:()=>I$,twolayerOpt:()=>z6,twolayerGreedy:()=>V$,twolayerAgg:()=>F$,tweakSugiyama:()=>j$,tweakSize:()=>B6,tweakShape:()=>_6,tweakGridHandles:()=>D$,tweakGrid:()=>R6,tweakFlip:()=>D0,tweakDirection:()=>z$,sugiyama:()=>j0,sugifyLayer:()=>G$,sugifyCompact:()=>Y6,sugiNodeLength:()=>C$,splitNodeSize:()=>X$,sizedSeparation:()=>P$,shapeTopBottom:()=>M6,shapeRect:()=>N1,shapeEllipse:()=>H6,layeringTopological:()=>S$,layeringSimplex:()=>W$,layeringLongestPath:()=>T$,layerSeparation:()=>E$,laneOpt:()=>N6,laneGreedy:()=>e0,grid:()=>$$,graphStratify:()=>C6,graphJson:()=>r1,graphHierarchy:()=>W6,graphConnect:()=>Q6,graph:()=>i,decrossTwoLayer:()=>q$,decrossOpt:()=>O$,decrossDfs:()=>E0,dagre:()=>A6,coordTopological:()=>j6,coordSimplex:()=>_$,coordQuad:()=>T6,coordGreedy:()=>N$,coordCenter:()=>O6,cachedNodeSize:()=>Q0,aggWeightedMedian:()=>E1,aggMedian:()=>d5,aggMean:()=>J$});module.exports=k6(vX);function x1($,X){if(X.size!==$.size)return!1;else{for(let Y of $)if(!X.has(Y))return!1;return!0}}function f1($){for(let X of $)return X;return}function x0($){for(let X of $)return $.delete(X),X;return}function C0($,X,Y){let Z=$.get(X);if(Z===void 0)$.set(X,[Y]);else Z.push(Y)}function d0($,X,Y){let Z=$.get(X);if(Z===void 0)$.set(X,new Set([Y]));else Z.add(Y)}function w$($,X,Y){let Z=$.get(X);if(Z!==void 0){if(Z.delete(Y),!Z.size)$.delete(X)}}var{toString:m6}=Object.prototype;function k$($){return m6.call($)==="[object RegExp]"}function v$($){let X=typeof $;return $!==null&&(X==="object"||X==="function")}var{propertyIsEnumerable:u6}=Object.prototype;function y$($){return[...Object.keys($),...Object.getOwnPropertySymbols($).filter((X)=>u6.call($,X))]}var g6=["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","implements","interface","let","package","private","protected","public","static","arguments","eval"],c6=["globalThis","Infinity","NaN","undefined"];function h$({includeGlobalProperties:$=!1}={}){return new Set([...g6,...$?c6:[]])}var p6=/[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*/u,b1=`(?<![@#$_\\p{ID_Continue}\\p{ID_Start}])(?!(?:${[...h$({includeGlobalProperties:!0})].join("|")})(?![$_\\p{ID_Continue}]))${p6.source}`,l6=new RegExp(b1,"u"),d6=new RegExp(`^${b1}$`,"u");function m$({exact:$=!0}={}){return $?d6:l6}var u$=h(require("node:vm")),s6=new u$.default.Script("returnValue = functionToRun()");function g$($,{timeout:X,context:Y=u$.default.createContext()}={}){let Z=(...K)=>{return Y.functionToRun=()=>$(...K),s6.runInNewContext(Y,{timeout:X}),Y.returnValue};return Object.defineProperty(Z,"name",{value:`functionTimeout(${$.name||"<anonymous>"})`,configurable:!0}),Z}function w1($){return $?.code==="ERR_SCRIPT_EXECUTION_TIMEOUT"}var X0=require("url"),v1=h(require("path")),y1=h(require("fs")),l$=h(require("vm")),P0=h(require("worker_threads")),c$=Symbol.for("worker"),f0=Symbol.for("events");class d${constructor(){Object.defineProperty(this,f0,{value:new Map})}dispatchEvent($){if($.target=$.currentTarget=this,this["on"+$.type])try{this["on"+$.type]($)}catch(Y){console.error(Y)}let X=this[f0].get($.type);if(X==null)return;X.forEach((Y)=>{try{Y.call(this,$)}catch(Z){console.error(Z)}})}addEventListener($,X){let Y=this[f0].get($);if(!Y)this[f0].set($,Y=[]);Y.push(X)}removeEventListener($,X){let Y=this[f0].get($);if(Y){let Z=Y.indexOf(X);if(Z!==-1)Y.splice(Z,1)}}}function p$($,X){this.type=$,this.timeStamp=Date.now(),this.target=this.currentTarget=this.data=null}var s$=typeof Worker==="function"?Worker:P0.default.isMainThread?h1():o6(),n6=X0.pathToFileURL(process.cwd()+"/");function h1(){class $ extends d${constructor(X,Y){super();let{name:Z,type:K}=Y||{};X+="";let U;if(/^data:/.test(X))U=X;else U=X0.fileURLToPath(new X0.URL(X,n6));let J=new P0.default.Worker(X0.fileURLToPath("file:///home/runner/work/d3-dag/d3-dag/node_modules/web-worker/src/node/index.js"),{workerData:{mod:U,name:Z,type:K}});Object.defineProperty(this,c$,{value:J}),J.on("message",(F)=>{let R=new p$("message");R.data=F,this.dispatchEvent(R)}),J.on("error",(F)=>{F.type="error",this.dispatchEvent(F)}),J.on("exit",()=>{this.dispatchEvent(new p$("close"))})}postMessage(X,Y){this[c$].postMessage(X,Y)}terminate(){this[c$].terminate()}}return $.prototype.onmessage=$.prototype.onerror=$.prototype.onclose=null,$}function o6(){if(typeof global.WorkerGlobalScope==="function")return;let{mod:$,name:X,type:Y}=P0.default.workerData;if(!$)return h1();let Z=global.self=global,K=[];function U(){let B=K;K=null,B.forEach((H)=>{Z.dispatchEvent(H)})}P0.default.parentPort.on("message",(B)=>{let H=new p$("message");if(H.data=B,K==null)Z.dispatchEvent(H);else K.push(H)}),P0.default.parentPort.on("error",(B)=>{B.type="Error",Z.dispatchEvent(B)});class J extends d${postMessage(B,H){P0.default.parentPort.postMessage(B,H)}close(){process.exit()}importScripts(){for(let B=0;B<arguments.length;B++){let H=arguments[B],V;if(/^data:/.test(H))V=m1(H).data;else V=y1.default.readFileSync(new X0.URL(v1.default.posix.normalize(H),X0.pathToFileURL($)),"utf-8");l$.default.runInThisContext(V,{filename:H})}}}let F=Object.getPrototypeOf(global);delete F.constructor,Object.defineProperties(J.prototype,F),F=Object.setPrototypeOf(global,new J),["postMessage","addEventListener","removeEventListener","dispatchEvent"].forEach((B)=>{F[B]=F[B].bind(global)}),global.name=X,global.WorkerGlobalScope=J;let R=/^data:/.test($);if(Y==="module")(R?import($):import(X0.pathToFileURL($))).catch((B)=>{if(R&&B.message==="Not supported")return console.warn("Worker(): Importing data: URLs requires Node 12.10+. Falling back to classic worker."),k1($,X);console.error(B)}).then(U);else{try{if(/^data:/.test($))k1($,X);else global.importScripts($)}catch(B){console.error(B)}Promise.resolve().then(U)}}function k1($,X){let{data:Y}=m1($);return l$.default.runInThisContext(Y,{filename:"worker.<"+(X||"data:")+">"})}function m1($){let[X,Y,Z,K]=$.match(/^data: *([^;,]*)(?: *; *([^,]*))? *,(.*)$/)||[];if(!X)throw Error("Invalid Data URL.");if(K=decodeURIComponent(K),Z)switch(Z.toLowerCase()){case"base64":K=Buffer.from(K,"base64").toString();break;default:throw Error('Unknown Data URL encoding "'+Z+'"')}return{type:Y,data:K}}class c1 extends Error{constructor($){super($);this.name="TimeoutError"}}class p1 extends Error{constructor($){super();this.name="AbortError",this.message=$}}var u1=($)=>globalThis.DOMException===void 0?new p1($):new DOMException($),g1=($)=>{let X=$.reason===void 0?u1("This operation was aborted."):$.reason;return X instanceof Error?X:u1(X)};function n$($,X){let{milliseconds:Y,fallback:Z,message:K,customTimers:U={setTimeout,clearTimeout}}=X,J,F,B=new Promise((H,V)=>{if(typeof Y!=="number"||Math.sign(Y)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${Y}\``);if(X.signal){let{signal:P}=X;if(P.aborted)V(g1(P));F=()=>{V(g1(P))},P.addEventListener("abort",F,{once:!0})}if(Y===Number.POSITIVE_INFINITY){$.then(H,V);return}let M=new c1;J=U.setTimeout.call(void 0,()=>{if(Z){try{H(Z())}catch(P){V(P)}return}if(typeof $.cancel==="function")$.cancel();if(K===!1)H();else if(K instanceof Error)V(K);else M.message=K??`Promise timed out after ${Y} milliseconds`,V(M)},Y),(async()=>{try{H(await $)}catch(P){V(P)}})()}).finally(()=>{if(B.clear(),F&&X.signal)X.signal.removeEventListener("abort",F)});return B.clear=()=>{U.clearTimeout.call(void 0,J),J=void 0},B}var i6=($)=>{let X=$.addEventListener||$.on||$.addListener,Y=$.removeEventListener||$.off||$.removeListener;if(!X||!Y)throw TypeError("Emitter is not compatible");return{addListener:X.bind($),removeListener:Y.bind($)}};function t6($,X,Y){let Z,K=new Promise((U,J)=>{if(Y={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...Y},!(Y.count>=0&&(Y.count===Number.POSITIVE_INFINITY||Number.isInteger(Y.count))))throw TypeError("The `count` option should be at least 0 or more");Y.signal?.throwIfAborted();let F=[X].flat(),R=[],{addListener:B,removeListener:H}=i6($),V=(...P)=>{let A=Y.multiArgs?P:P[0];if(Y.filter&&!Y.filter(A))return;if(R.push(A),Y.count===R.length)Z(),U(R)},M=(P)=>{Z(),J(P)};Z=()=>{for(let P of F)H(P,V);for(let P of Y.rejectionEvents)H(P,M)};for(let P of F)B(P,V);for(let P of Y.rejectionEvents)B(P,M);if(Y.signal)Y.signal.addEventListener("abort",()=>{M(Y.signal.reason)},{once:!0});if(Y.resolveImmediately)U(R)});if(K.cancel=Z,typeof Y.timeout==="number"){let U=n$(K,{milliseconds:Y.timeout});return U.cancel=Z,U}return K}function N0($,X,Y){if(typeof Y==="function")Y={filter:Y};Y={...Y,count:1,resolveImmediately:!1};let Z=t6($,X,Y),K=Z.then((U)=>U[0]);return K.cancel=Z.cancel,K}var r6=Boolean(globalThis.process?.versions?.node),a6=($)=>new globalThis.Blob([$],{type:"text/javascript"}),e6=($)=>{return`data:text/javascript;base64,${globalThis.Buffer.from($).toString("base64")}`};function l1($){let X,Y,Z=()=>{if(X)URL.revokeObjectURL(X);Y?.terminate()};if(r6)Y=new s$(e6($),{type:"module"});else X=URL.createObjectURL(a6($)),Y=new s$(X,{type:"module"});return{worker:Y,cleanup:Z}}var $7=($)=>` globalThis.onmessage = async ({data: arguments_}) => { try { const output = await (${$.toString()})(...arguments_); globalThis.postMessage({output}); } catch (error) { globalThis.postMessage({error}); } }; `;function s0($){let X=$7($),Y=()=>l1(X);async function Z({worker:U,arguments_:J}){let F=N0(U,"message",{rejectionEvents:["error","messageerror"]});U.postMessage(J);let{data:{output:R,error:B}}=await F;if(B)throw B;return R}let K=async(...U)=>{let{worker:J,cleanup:F}=Y();try{return await Z({arguments_:U,worker:J})}finally{F()}};return K.withSignal=(U)=>async(...J)=>{U.throwIfAborted();let{worker:F,cleanup:R}=Y(),B=N0(U,[],{rejectionEvents:["abort"]});try{return await Promise.race([Z({arguments_:J,worker:F}),B])}catch(H){throw U.throwIfAborted(),H}finally{B.cancel(),R()}},K}var X7=($)=>` const nothing = Symbol('nothing'); let iterator = nothing; globalThis.onmessage = async ({data: arguments_}) => { try { if (iterator === nothing) { iterator = await (${$.toString()})(...arguments_); } const output = await iterator.next(); globalThis.postMessage({output}); } catch (error) { globalThis.postMessage({error}); } }; `;function d1($){let X=X7($),Y=()=>l1(X),Z=(...K)=>({async*[Symbol.asyncIterator](){let{worker:U,cleanup:J}=Y();try{let F=!0;while(!0){let R=N0(U,"message",{rejectionEvents:["error","messageerror"]});U.postMessage(F?K:void 0),F=!1;let{data:{output:B,error:H}}=await R;if(H)throw H;let{value:V,done:M}=B;if(M)break;yield V}}finally{J()}}});return Z.withSignal=(K)=>(...U)=>({async*[Symbol.asyncIterator](){K.throwIfAborted();let{worker:J,cleanup:F}=Y(),R=N0(K,[],{rejectionEvents:["abort"]});try{let B=!0;while(!0){let H=Promise.race([N0(J,"message",{rejectionEvents:["error","messageerror"]}),R]);J.postMessage(B?U:void 0),B=!1;let{data:{output:V,error:M}}=await H;if(M)throw M;let{value:P,done:A}=V;if(A)break;yield P}}catch(B){throw K.throwIfAborted(),B}finally{R.cancel(),F()}}}),Z}var Y7={},Z7=($)=>{if($===void 0||Number.isNaN($))return;let X=Math.max(1,Math.trunc(Math.abs($)));if(!Number.isFinite(X))return;return X};function s1($,X,{timeout:Y,throwOnTimeout:Z}={}){try{return g$(()=>structuredClone($).test(X),{timeout:Z7(Y),context:Y7})()}catch(K){if(w1(K)&&!Z)return!1;throw K}}var FY=s0(($,X,Y)=>{return new RegExp($,X).test(Y)}),BY=s0(($,X,Y)=>{let K=new RegExp($,X).exec(Y);if(K===null)return;return{match:K[0],index:K.index,groups:K.slice(1),namedGroups:K.groups??{},input:K.input}}),RY=d1(function*($,X,Y){let Z=new RegExp($,X),K=Y.matchAll(Z);for(let U of K)yield{match:U[0],index:U.index,groups:U.slice(1),namedGroups:U.groups??{},input:U.input}});var K7=m$();function o$($){if(typeof $!=="string")throw TypeError(`Expected a string, got \`${typeof $}\`.`);if($.length>1e5)return!1;return s1(K7,$,{timeout:1000})}var U7={"\n":String.raw`\n`,"\r":String.raw`\r`,"\t":String.raw`\t`,"\b":String.raw`\b`,"\f":String.raw`\f`,"\v":String.raw`\v`,"\x00":String.raw`\0`};function i$($,X,Y){let Z=[];return function K(U,J={},F=""){let R=J.indent||"\t",B;if(J.inlineCharacterLimit===void 0)B={newline:` `,newlineOrSpace:` `,pad:F,indent:F+R};else B={newline:"@@__STRINGIFY_OBJECT_NEW_LINE__@@",newlineOrSpace:"@@__STRINGIFY_OBJECT_NEW_LINE_OR_SPACE__@@",pad:"@@__STRINGIFY_OBJECT_PAD__@@",indent:"@@__STRINGIFY_OBJECT_INDENT__@@"};let H=(P)=>{if(J.inlineCharacterLimit===void 0)return P;let A=P.replaceAll(B.newline,"").replaceAll(B.newlineOrSpace," ").replaceAll(B.pad,"").replaceAll(B.indent,"");if(A.length<=J.inlineCharacterLimit)return A;return P.replaceAll(B.newline,` `).replaceAll(B.newlineOrSpace,` `).replaceAll(B.pad,F).replaceAll(B.indent,F+R)};if(Z.includes(U))return'"[Circular]"';let V=typeof U;if(U===null||U===void 0||V==="number"||V==="boolean"||V==="function"||k$(U))return String(U);if(V==="bigint")return String(U)+"n";if(V==="symbol"){let{description:P}=U;if(P===void 0)return"Symbol()";if(P?.startsWith("Symbol.")&&Symbol[P.slice(7)]===U)return P;let A=Symbol.keyFor(U);if(A!==void 0)return`Symbol.for(${K(A,J)})`;return`Symbol(${K(P,J)})`}if(U instanceof Date)return Number.isNaN(U.getTime())?"new Date('Invalid Date')":`new Date('${U.toISOString()}')`;if(U instanceof Map||U instanceof Set){let P=U instanceof Map,A=P?"Map":"Set";if(U.size===0)return`new ${A}()`;Z.push(U);let _=[...U].map((q)=>{if(P){let[Q,E]=q;return B.indent+`[${K(Q,J,F+R)}, ${K(E,J,F+R)}]`}return B.indent+K(q,J,F+R)}).join(","+B.newlineOrSpace);return Z.pop(),H(`new ${A}([${B.newline}${_}${B.newline}${B.pad}])`)}if(Array.isArray(U)){if(U.length===0)return"[]";Z.push(U);let P=U.map((A,_)=>{let q=K(A,J,F+R);if(J.transform)q=J.transform(U,_,q);return B.indent+q}).join(","+B.newlineOrSpace);return Z.pop(),H(`[${B.newline}${P}${B.newline}${B.pad}]`)}if(v$(U)){let P=y$(U);if(J.filter)P=P.filter((_)=>J.filter(U,_));if(P.length===0)return"{}";Z.push(U);let A=P.map((_)=>{let q=typeof _==="symbol",Q;if(q)Q=`[${K(_,J)}]`;else if(o$(_))Q=_;else Q=K(_,J);let E=K(U[_],J,F+R);if(J.transform)E=J.transform(U,_,E);return B.indent+Q+": "+E}).join(","+B.newlineOrSpace);return Z.pop(),H(`{${B.newline}${A}${B.newline}${B.pad}}`)}let M=String(U).replaceAll("\\","\\\\").replaceAll(/[\u0000-\u001F\u007F]/g,(P)=>U7[P]??`\\u${P.codePointAt(0).toString(16).padStart(4,"0")}`);if(J.singleQuotes===!1)return`"${M.replaceAll('"',String.raw`\"`)}"`;return`'${M.replaceAll("'",String.raw`\'`)}'`}($,X,Y)}function*A0($,...X){let Y=new Set,Z;while((Z=X.pop())!==void 0){if(Y.has(Z))continue;yield Z,Y.add(Z),X.push(...$(Z))}}function t$($,X){let Y=[];for(let[Z,K]of n(X))Y.push($[Z]),Y.push(K);return Y.push($[$.length-1]),Y.join("")}function D($,...X){let Y=c(X,(Z)=>i$(Z,{indent:" ",singleQuotes:!1,inlineCharacterLimit:60}));return Error(t$($,Y))}function n1($){return`internal error: ${$}; if you encounter this please submit an issue at: https://github.com/erikbrinkman/d3-dag/issues`}function s($,...X){let Y=c(X,(Z)=>Z.toString());return Error(n1(t$($,Y)))}function a($,X,...Y){let[Z,...K]=$,U=c(Y,(R)=>R.toString()),J=t$(K,U),F=X.name||"anonymous";return Error("d3dagBuiltin"in X?n1(`builtin ${Z}'${F}'${J}`):`custom ${Z}'${F}'${J}`)}function*n($){let X=0;for(let Y of $)yield[X++,Y]}function*U0($,X){for(let[Y,Z]of n($))yield*X(Z,Y)}function o1($,X,Y){let Z=Y;for(let[K,U]of n($))Z=X(Z,U,K);return Z}function*c($,X){for(let[Y,Z]of n($))yield X(Z,Y)}function*J0($,X){for(let[Y,Z]of n($))if(X(Z,Y))yield Z}function r$($,X){for(let[Y,Z]of n($))if(X(Z,Y))return!0;return!1}function i1($,X){return!r$($,(Y,Z)=>!X(Y,Z))}function*J7($,X,Y,Z){let K=Math.min(Y,$.length);for(let U=X;U<K;U+=Z)yield $[U]}function*F7($,X,Y,Z){let K=Math.max(Y,-1);for(let U=X;U>K;U+=Z)yield $[U]}function p($,X=0,Y=$.length,Z=1){if(Z>0)return J7($,X,Y,Z);else if(Z<0)return F7($,X,Y,Z);else throw D`can't slice with zero stride`}function*e(...$){for(let X of $)yield*X}function*d($){let X=$[Symbol.iterator](),Y=X.next();if(!Y.done){let Z=Y.value,K;while(!(K=X.next()).done)yield[Z,K.value],Z=K.value}}function t1($){for(let X of $)return X}function n0($){return typeof $==="object"&&$!==null&&Symbol.iterator in $&&typeof $[Symbol.iterator]==="function"}function B7($){if(typeof $!=="object"||$===null)return!1;let X="x"in $?$.x:void 0,Y="y"in $?$.y:void 0,Z="data"in $?$.data:void 0;if(typeof X!=="number"&&X!==void 0||typeof Y!=="number"&&Y!==void 0)return!1;let K={x:X,y:Y,data:Z};return!0}function R7($){if(!Array.isArray($)||$.length!==2)return!1;let X=$,[Y,Z]=X;return typeof Y==="number"&&typeof Z==="number"}function H7($){if(typeof $!=="object"||$===null||!("source"in $)||!("target"in $)||!("points"in $))return!1;let{source:X,target:Y,points:Z}=$,K="data"in $?$.data:void 0;if(typeof X!=="number"||typeof Y!=="number"||!Array.isArray(Z)||!Z.every(R7))return!1;let U={source:X,target:Y,points:Z,data:K};return!0}function e$($){let X=[],Y,Z=new Map;for(let[J,F]of n($.nodes()))if(Z.set(F,J),X.push({x:F.ux,y:F.uy,data:F.data}),F===$)Y=J;let K=[];for(let{source:J,target:F,data:R,points:B}of $.links())K.push({source:Z.get(J),target:Z.get(F),points:B,data:R});return{nodes:X,links:K,index:Y,v:1}}function M7($,X,Y,Z,K){let U=i(),J=$.map(({x:F,y:R,data:B})=>{let H=U.node(Z(B));return H.ux=F,H.uy=R,H});for(let{source:F,target:R,points:B,data:H}of X){let V=U.link(J[F],J[R],K(H));V.points=B.map(([M,P])=>[M,P])}if(Y===void 0)return U;else return J[Y]}function a$($){function X(K){if(typeof K!=="object"||K===null)throw D`parsedJson was null or wasn't an object: ${K}`;else if(!("nodes"in K)||!("links"in K))throw D`parsedJson didn't have 'nodes' and 'links' properties: ${K}`;let{nodes:U,links:J}=K,F="index"in K?K.index:void 0;if(!Array.isArray(U)||!Array.isArray(J))throw D`'nodes' and 'links' weren't arrays: ${K}`;else if(!U.every(B7)||!J.every(H7)||F!==void 0&&typeof F!=="number")throw D`'nodes' and 'links' didn't have the appropriate structure: ${K}`;return M7(U,J,F,$.nodeDatum,$.linkDatum)}function Y(K){if(K===void 0)return $.nodeDatum;else{let{nodeDatum:U,...J}=$;return a$({nodeDatum:K,...J})}}X.nodeDatum=Y;function Z(K){if(K===void 0)return $.linkDatum;else{let{linkDatum:U,...J}=$;return a$({linkDatum:K,...J})}}return X.linkDatum=Z,X}function r1(...$){if($.length)throw D`got arguments to graphJson(${$}), but constructor takes no arguments; these were probably meant as data which should be called as \`graphJson()(...)\``;else return a$({nodeDatum:(X)=>X,linkDatum:(X)=>X})}class Y5{node;indeg;outdeg;stat;constructor($,X,Y,Z="inactive"){this.node=$;this.indeg=X;this.outdeg=Y;this.stat=Z}bucket(){let $=this.indeg===0?-1/0:this.outdeg===0?1/0:this.indeg-this.outdeg;return this.stat==="top"?Math.min($,0):this.stat==="bottom"?Math.max($,0):$}isTop(){return this.indeg<=this.outdeg&&this.stat!=="bottom"||this.stat==="top"}}function a1($,X){let Y=$[X];if(Y===void 0){let Z=new Set;return $[X]=Z,Z}else return Y}function e1($){let X;while($.length&&!(X=$[$.length-1])?.size)$.pop();return X||void 0}function Z5($,X=()=>{return}){let Y=new Map,Z=new Map,K=new Set,U=new Set,J=[],F=[];function R(W){if(W===-1/0)return K;else if(W===1/0)return U;else if(W<=0)return a1(J,-W);else return a1(F,W-1)}for(let W of $){let C=W.nparentLinks(),N=W.nchildLinks(),G=new Y5(W,C,N),O=X(W);if(Y.set(W,G),O===void 0)G.stat="active",R(G.bucket()).add(G);else d0(Z,O,G)}let B=[...Z].sort(([W],[C])=>W-C).map(([,W])=>W),H=0,V=B.length,M=B.length?B[H++]:new Set,P=B.length>1?B[--V]:new Set;for(let W of M)W.stat="top",R(W.bucket()).add(W);for(let W of P)W.stat="bottom",R(W.bucket()).add(W);function A(){let W;if(W=x0(K)??x0(U))return W;let C=e1(J),N=e1(F);if(N)return x0(J.length>F.length?C:N);else if(C)return x0(C)}let _=Array(Y.size),q=0,Q=Y.size,E;while(E=A()){let{node:W}=E,C=E.isTop()?q++:--Q;E.stat="ranked",_[C]=W;for(let[N,G]of W.parentCounts()){let O=Y.get(N);if(R(O.bucket()).delete(O),O.outdeg-=G,O.stat!=="ranked"&&O.stat!=="inactive")R(O.bucket()).add(O)}for(let[N,G]of W.childCounts()){let O=Y.get(N);if(R(O.bucket()).delete(O),O.indeg-=G,O.stat!=="ranked"&&O.stat!=="inactive")R(O.bucket()).add(O)}if(M.delete(E),!M.size&&H<V){M=B[H++];for(let N of M)N.stat="top",R(N.bucket()).add(N)}if(P.delete(E),!P.size&&H<V){P=B[--V];for(let N of P)N.stat="bottom",R(N.bucket()).add(N)}}return _}function $5($,X){let Y=new Set,Z=new Set,K=[],U;for(let J of $){if(Z.has(J))continue;K.push(J);while(U=K.pop()){if(Y.delete(U),Z.has(U))continue;Z.add(U),K.push(...X(U))}Y.add(J)}return Y}function _7($){let X=new Map(c($,(K)=>[K,K.nparents()])),Y=[...c(J0(X,([,K])=>K===0),([K])=>K)];for(let K of Y)X.delete(K);let Z;while(Z=Y.pop())for(let K of Z.children()){let U=X.get(K)-1;if(U)X.set(K,U);else X.delete(K),Y.push(K)}return!X.size}class K5{#X=0;#$=0;#U=0;#Y=!0;#K=new Set;#H=new Set;*nodes(){for(let $ of this.split())yield*$.nodes()}topological($){return Z5(this.nodes(),$)}*links(){for(let $ of this.nodes())yield*$.childLinks()}nnodes(){return this.#X}nlinks(){return this.#$}*roots(){for(let $ of this.split())yield*$.roots()}*leaves(){for(let $ of this.split())yield*$.leaves()}*sources(){for(let $ of this.split())yield*$.sources()}*sinks(){for(let $ of this.split())yield*$.sinks()}*split(){yield*this.#K;let $;while($=f1(this.#H))yield $,$.nnodes()}connected(){let $=!1;for(let X of this.split())if($)return!1;else $=!0;return!0}multi(){return!!this.#U}acyclic(){if(this.#Y===null){for(let $ of this.split())if(!$.acyclic())return this.#Y=!1,!1;return this.#Y=!0,!0}else return this.#Y}node($){return this.#X+=1,new $1(this,this.#K,this.#H,this.#M,this.#_,this.#J,$)}link($,X,Y){return $.link($,X,Y)}#M=()=>{this.#X-=1};#_=($,X)=>{if(this.#$+=1,$)this.#U+=1;else if(!X&&this.#Y===!0)this.#Y=null};#J=($)=>{if(this.#$-=1,$)this.#U-=1;else if(this.#Y===!1)this.#Y=null};toJSON(){return e$(this)}}function X5($){for(let X of $.values())for(let Y of X)return Y}function O0($){return $ instanceof $1}class $1{data;#X;#$;#U;#Y;#K;#H;#M=0;#_=0;#J=new Map;#P=0;#B=new Map;#F;#Z;ux;uy;get x(){if(this.ux===void 0)throw D`can't get \`x\` when \`ux\` is undefined`;else return this.ux}set x($){this.ux=$}get y(){if(this.uy===void 0)throw D`can't get \`y\` when \`uy\` is undefined`;else return this.uy}set y($){this.uy=$}constructor($,X,Y,Z,K,U,J){this.data=J;this.#X=$,this.#K=X,this.#H=Y,this.#$=Z,this.#U=K,this.#Y=U,this.#F=this,this.#Z={nnodes:1,nlinks:0,multis:0,acyclic:!0,roots:[this],leaves:[this],sources:new Set([this]),sinks:new Set([this])},this.#K.add(this)}#V(){let $=this;while($.#F!==$)$.#F=$.#F.#F,$=$.#F;return $}#R(){let $=this.#V();if($.#Z===void 0)throw s`undefined cached info`;else if($.#Z!==null)return $.#Z;else{let X=0,Y=0,Z=0;for(let K of this.nodes())X+=1,Y+=K.nchildLinks(),Z+=K.#M,K.#F=this,K.#Z=void 0,this.#H.delete(K);return this.#K.add(this),this.#Z={nnodes:X,nlinks:Y,multis:Z,acyclic:null,roots:null,leaves:null,sources:null,sinks:null}}}#A=($)=>{let{source:X,target:Y}=$,Z=X.nchildLinksTo(Y)>1;if(Z){X.#M-=1;let K=X.#R();K.nlinks-=1,K.multis-=1}else{let K=X.#V();K.#Z=null,this.#K.delete(K),this.#H.add(X),X.#F=X,X.#Z=null,this.#H.add(Y),Y.#F=Y,Y.#Z=null}this.#Y(Z),w$(X.#B,Y,$),X.#P-=1,w$(Y.#J,X,$),Y.#_-=1};*nodes(){yield*A0(($)=>e($.children(),$.parents()),this)}topological($){return Z5(this.nodes(),$)}*links(){for(let $ of this.nodes())yield*$.childLinks()}nnodes(){return this.#R().nnodes}nlinks(){return this.#R().nlinks}*split(){yield this}connected(){return!0}multi(){return this.#R().multis>0}acyclic(){let $=this.#R();return $.acyclic===null?$.acyclic=_7(this.nodes()):$.acyclic}node($){if(this.#X)return this.#X.node($);else throw D`can't add a node from a deleted node`}link($,X,Y){if(!this.#X)throw D`can't add a link from a deleted node`;else if($===X)throw D`tried to create a link between the same node, but self loops are not supported`;else if(O0($)&&O0(X)&&$.#X===X.#X&&this.#X===$.#X){let Z=new U5(this.#X,$,X,this.#A,Y),K=$.nchildLinksTo(X)>0,U=$.#V(),J=U.#Z,F=X.#V(),R=F.#Z;if(K&&J)$.#M+=1,J.nlinks+=1,J.multis+=1;else if(K)$.#M+=1;else if(U===F&&J){if(J.nlinks+=1,J.acyclic===!0)J.acyclic=null;J.sources?.delete(X),J.sinks?.delete($)}else if(U!==F&&J&&R){let[B,H,V,M]=J.nnodes>R.nnodes?[U,J,F,R]:[F,R,U,J];if(this.#K.delete(V),V.#F=B,V.#Z=void 0,H.nnodes+=M.nnodes,H.nlinks+=M.nlinks+1,H.multis+=M.multis,H.acyclic=H.acyclic===!1||M.acyclic===!1?!1:H.acyclic===!0&&M.acyclic===!0?!0:null,H.roots=null,H.leaves=null,H.sources&&M.sources){for(let P of M.sources)H.sources.add(P);H.sources.delete(X)}else H.sources=null;if(H.sinks&&M.sinks){for(let P of M.sinks)H.sinks.add(P);H.sinks.delete($)}else H.sinks=null}else if(U!==F)U.#Z=null,F.#Z=null;return this.#U(K,U!==F),$.#P+=1,d0($.#B,X,Z),X.#_+=1,d0(X.#J,$,Z),Z}else throw D`when creating a link, both source and target must be current members of the same graph, and can't have been deleted`}nparents(){return this.#J.size}nchildren(){return this.#B.size}nparentLinks(){return this.#_}nchildLinks(){return this.#P}nparentLinksTo($){return O0($)?this.#J.get($)?.size??0:0}*parentLinksTo($){if(O0($)){let X=this.#J.get($);if(X)yield*X}}nchildLinksTo($){return O0($)?this.#B.get($)?.size??0:0}*childLinksTo($){if(O0($)){let X=this.#B.get($);if(X)yield*X}}*parents(){yield*this.#J.keys()}*children(){yield*this.#B.keys()}*parentCounts(){for(let[$,X]of this.#J)yield[$,X.size]}*childCounts(){for(let[$,X]of this.#B)yield[$,X.size]}*parentLinks(){for(let $ of this.#J.values())yield*$}*childLinks(){for(let $ of this.#B.values())yield*$}*ancestors(){yield*A0(($)=>$.parents(),this)}*descendants(){yield*A0(($)=>$.children(),this)}*roots(){let $=this.#R();if(!$.roots)$.roots=[...$5(this.nodes(),(X)=>X.children())];yield*$.roots}*leaves(){let $=this.#R();if(!$.leaves)$.leaves=[...$5(this.nodes(),(X)=>X.parents())];yield*$.leaves}*sources(){let $=this.#R();if(!$.sources){$.sources=new Set;for(let X of this.nodes())if(X.nparents()===0)$.sources.add(X)}yield*$.sources}*sinks(){let $=this.#R();if(!$.sinks){$.sinks=new Set;for(let X of this.nodes())if(X.nchildren()===0)$.sinks.add(X)}yield*$.sinks}parent($,X){return this.link($,this,X)}child($,X){return this.link(this,$,X)}delete(){if(this.#X){let $;while($=X5(this.#B))$.delete();while($=X5(this.#J))$.delete();this.#K.delete(this),this.#H.delete(this),this.#$(),this.#X=null,this.#Z=null}}toJSON(){return e$(this)}}class U5{source;target;data;#X;#$;points=[];constructor($,X,Y,Z,K){this.source=X;this.target=Y;this.data=K;this.#X=$,this.#$=Z}delete(){if(this.#X)this.#$(this),this.#X=null}}function i(){return new K5}function o0($,X){let Y;if(X===void 0){for(let Z of $)if(Z!=null&&(Y<Z||Y===void 0&&Z>=Z))Y=Z}else{let Z=-1;for(let K of $)if((K=X(K,++Z,$))!=null&&(Y<K||Y===void 0&&K>=K))Y=K}return Y}function i0($,X){let Y;if(X===void 0){for(let Z of $)if(Z!=null&&(Y>Z||Y===void 0&&Z>=Z))Y=Z}else{let Z=-1;for(let K of $)if((K=X(K,++Z,$))!=null&&(Y>K||Y===void 0&&K>=K))Y=K}return Y}function B0($,X){return $==null||X==null?NaN:$<X?-1:$>X?1:$>=X?0:NaN}function J5($=B0){if($===B0)return X1;if(typeof $!=="function")throw TypeError("compare is not a function");return(X,Y)=>{let Z=$(X,Y);if(Z||Z===0)return Z;return($(Y,Y)===0)-($(X,X)===0)}}function X1($,X){return($==null||!($>=$))-(X==null||!(X>=X))||($<X?-1:$>X?1:0)}function t0($,X,Y=0,Z=1/0,K){if(X=Math.floor(X),Y=Math.floor(Math.max(0,Y)),Z=Math.floor(Math.min($.length-1,Z)),!(Y<=X&&X<=Z))return $;K=K===void 0?X1:J5(K);while(Z>Y){if(Z-Y>600){let R=Z-Y+1,B=X-Y+1,H=Math.log(R),V=0.5*Math.exp(2*H/3),M=0.5*Math.sqrt(H*V*(R-V)/R)*(B-R/2<0?-1:1),P=Math.max(Y,Math.floor(X-B*V/R+M)),A=Math.min(Z,Math.floor(X+(R-B)*V/R+M));t0($,X,P,A,K)}let U=$[X],J=Y,F=Z;if(b0($,Y,X),K($[Z],U)>0)b0($,Y,Z);while(J<F){b0($,J,F),++J,--F;while(K($[J],U)<0)++J;while(K($[F],U)>0)--F}if(K($[Y],U)===0)b0($,Y,F);else++F,b0($,F,Z);if(F<=X)Y=F+1;if(X<=F)Z=F-1}return $}function b0($,X,Y){let Z=$[X];$[X]=$[Y],$[Y]=Z}function*F5($,X){if(X===void 0){for(let Y of $)if(Y!=null&&(Y=+Y)>=Y)yield Y}else{let Y=-1;for(let Z of $)if((Z=X(Z,++Y,$))!=null&&(Z=+Z)>=Z)yield Z}}function Y1($,X,Y){if($=Float64Array.from(F5($,Y)),!(Z=$.length)||isNaN(X=+X))return;if(X<=0||Z<2)return i0($);if(X>=1)return o0($);var Z,K=(Z-1)*X,U=Math.floor(K),J=o0(t0($,U).subarray(0,U+1)),F=i0($.subarray(U+1));return J+(F-J)*(K-U)}function R0($,X){return Y1($,0.5,X)}function w0($,X=B0){let Y,Z=!1;if(X.length===1){let K;for(let U of $){let J=X(U);if(Z?B0(J,K)<0:B0(J,J)===0)Y=U,K=J,Z=!0}}else for(let K of $)if(Z?X(K,Y)<0:X(K,K)===0)Y=K,Z=!0;return Y}function Y0($){return new Set(J0(e($.children(),$.parents()),(X)=>X.y>$.y))}function M5($,X){for(let K of $)if(K.ux===void 0)throw a`lane ${X} didn't assign an x to every node`;else if(K.x<0)throw a`lane ${X} assigned an x less than 0: ${K.x}`;let Y=new Set($.map((K)=>K.x));if(!x1(Y,new Set(c(Y,(K,U)=>U)))){let K=[...Y].sort((U,J)=>U-J).join(", ");throw a`lane ${X} didn't assign increasing positive integers for x coordinates: ${K}`}let Z=new Map;for(let[K,U]of $.entries()){let J=Z.get(U);if(J!==void 0){for(let F of p($,J+1,K))if(F.x===U.x)throw a`lane ${X} assigned nodes to an overlapping lane: ${U.x}`}for(let F of U.children())if(!Z.has(F))Z.set(F,K)}return Y.size}class _5{uncompressed;indices=[];constructor($){this.uncompressed=$}getIndex($,X){let Y=[];for(let[U,J]of this.indices.entries())if(J<=$)Y.push(U);if(this.uncompressed)Y.push(this.indices.length);let Z=X===void 0?0:X,K=w0(Y,(U)=>[Math.abs(Z-U),U])??this.indices.length;return this.setIndex(K,$),K}setIndex($,X){this.indices[$]=X}offset(){return 0}}class V5{uncompressed;posIndices=[0];negIndices=[];constructor($){this.uncompressed=$}nextNeg(){return-this.negIndices.length-1}nextPos(){return this.posIndices.length}getIndex($,X){let Y=[];for(let[J,F]of this.negIndices.entries())if(F<=$)Y.push(-J-1);for(let[J,F]of this.posIndices.entries())if(F<=$)Y.push(J);if(this.uncompressed)Y.push(this.nextNeg()),Y.push(this.nextPos());let Z=X===void 0?0:X,K=this.negIndices.length<this.posIndices.length-1?this.nextNeg():this.nextPos(),U=w0(Y,(J)=>[Math.abs(Z-J),Math.abs(J),-J])??K;return this.setIndex(U,$),U}setIndex($,X){if($<0)this.negIndices[-$-1]=X;else this.posIndices[$]=X}offset(){return this.negIndices.length}}function U9($,X){if(X)return new V5(!$);else return new _5(!$)}function J9($,X){for(let Z of $){if(Z.ux===void 0)Z.x=X.getIndex(Z.y);for(let K of[...Y0(Z)].sort((U,J)=>J.y-U.y))if(K.ux===void 0)K.x=X.getIndex(Z.y,Z.x),X.setIndex(K.x,K.y)}let Y=X.offset();for(let Z of $)Z.x+=Y}function F9($,X){let Y=new Map;for(let K of $)for(let U of Y0(K)){let J=Y.get(U);if(J===void 0||K.y<J.y)Y.set(U,K)}for(let K of p($,$.length-1,-1,-1)){if(K.ux===void 0){let J=R0(c(Y0(K),(F)=>F.x));K.x=X.getIndex($.length-K.y,J)}let U=Y.get(K);if(U!==void 0){if(U.ux===void 0)U.x=K.x;X.setIndex(K.x,$.length-U.y)}}let Z=X.offset();for(let K of $)K.x+=Z}function a0($,X,Y){function Z(F){for(let B of F)B.ux=void 0;let R=U9(X,Y);if($)J9(F,R);else F9(F,R)}function K(F){if(F===void 0)return $;else return a0(F,X,Y)}Z.topDown=K;function U(F){if(F===void 0)return X;else return a0($,F,Y)}Z.compressed=U;function J(F){if(F===void 0)return Y;else return a0($,X,F)}return Z.bidirectional=J,Z.d3dagBuiltin=!0,Z}function e0(...$){if($.length)throw D`got arguments to laneGreedy(${$}); you probably forgot to construct laneGreedy before passing to lane: \`grid().lane(laneGreedy())\``;return a0(!0,!0,!1)}function T0($,X){function Y(R){let B;if(!R.nnodes())B={width:0,height:0};else{let H=R.topological($.rank);for(let[q,Q]of H.entries())Q.y=q;$.lane(H);let V=M5(H,$.lane),{xgap:M,ygap:P}=X,A,_;if(typeof $.nodeSize==="function"){let q=Array(V).fill(0);_=-P;for(let Q of H){let[E,W]=$.nodeSize(Q);if(E<=0||W<=0)throw D`nodeSize must be positive, but got: [${E}, ${W}]`;q[Q.x]=Math.max(q[Q.x],E),_+=P,Q.y=_+W/2,_+=W}A=-M;for(let[Q,E]of q.entries())A+=M,q[Q]=A+E/2,A+=E;for(let Q of H)Q.x=q[Q.x]}else{let[q,Q]=$.nodeSize;for(let E of H)E.x=(E.x+0.5)*q+E.x*M,E.y=(E.y+0.5)*Q+E.y*P;A=V*(q+M)-M,_=H.length*(Q+P)-P}for(let q of R.links()){let{source:Q,target:E,points:W}=q;if(W.splice(0),Q.x===E.x)W.push([Q.x,Q.y],[E.x,E.y]);else{if(W.push([Q.x,Q.y]),Q.y<E.y)W.push([E.x,Q.y]);else W.push([Q.x,E.y]);W.push([E.x,E.y])}}B={width:A,height:_}}for(let H of $.tweaks)B=H(R,B);return B}function Z(R){if(R===void 0)return $.lane;else{let{lane:B,...H}=$;return T0({...H,lane:R},X)}}Y.lane=Z;function K(R){if(R===void 0)return $.rank;else{let{rank:B,...H}=$;return T0({...H,rank:R},X)}}Y.rank=K;function U(R){if(R===void 0)return $.tweaks;else{let{tweaks:B,...H}=$;return T0({...H,tweaks:R},X)}}Y.tweaks=U;function J(R){if(R===void 0)return $.nodeSize;else if(typeof R!=="function"&&(R[0]<=0||R[1]<=0)){let[B,H]=R;throw D`constant nodeSize must be positive, but got: [${B}, ${H}]`}else{let{nodeSize:B,...H}=$;return T0({...H,nodeSize:R},X)}}Y.nodeSize=J;function F(R){if(R!==void 0){let[B,H]=R;if(B<0||H<0)throw D`gaps must be non-negative, but got [${B}, ${H}]`;return T0($,{xgap:B,ygap:H})}else{let{xgap:B,ygap:H}=X;return[B,H]}}return Y.gap=F,Y}function $$(...$){if($.length)throw D`got arguments to grid(${$}), but constructor takes no arguments; these were probably meant as data which should be called as \`grid()(...)\``;return T0({lane:e0(),rank:()=>{return},nodeSize:[1,1],tweaks:[]},{xgap:1,ygap:1})}function Q0($){if(typeof $!=="function"){let[X,Y]=$;if(X<=0||Y<=0)throw D`all node sizes must be positive, but got width ${X} and height ${Y}`;return()=>[X,Y]}else{let X=new Map;return(Z)=>{let K=X.get(Z);if(K===void 0){K=$(Z);let[U,J]=K;if(U<=0||J<=0)throw D`all node sizes must be positive, but got width ${U} and height ${J} for node with data: ${Z.data}; make sure the callback passed to \`sugiyama().nodeSize(...)\` is doing that`;X.set(Z,K)}return K}}}function X$($){if(typeof $!=="function"){let[X,Y]=$;return[()=>X,()=>Y]}else{let X=$;return[(Y)=>X(Y)[0],(Y)=>X(Y)[1]]}}var I5=h(require("fs")),C5=h(require("child_process"));class M1{constructor($,X,Y,Z){this.feasible=Y,this.evaluation=X,this.bounded=Z,this._tableau=$,this.solutionSet={}}generateSolutionSet(){let $={},X=this._tableau,Y=X.varIndexByRow,Z=X.variablesPerIndex,K=X.matrix,U=X.width,J=X.rhsColumn,F=X.height-1,R=Math.round(1/X.precision);for(let B=1;B<=F;B+=1){let H=Y[B],V=Z[H];if(V===void 0||V.isSlack===!0)continue;let M=K[B*U+J];$[V.id]=Math.round((Number.EPSILON+M)*R)/R}return $}}class N5 extends M1{constructor($,X,Y,Z,K){super($,X,Y,Z);this.iter=K}}class U${constructor($=64){this.heap=Array($),this.size=0,this.seqCounter=0,this.pool=Array(64),this.poolSize=0}allocEntry($,X){if(this.poolSize>0){let Y=this.pool[--this.poolSize];return Y.branch=$,Y.seq=X,Y}return{branch:$,seq:X}}freeEntry($){if(this.poolSize<256)this.pool[this.poolSize++]=$}get length(){return this.size}isEmpty(){return this.size===0}clear(){this.size=0,this.seqCounter=0}isBefore($,X){if($.branch.relaxedEvaluation!==X.branch.relaxedEvaluation)return $.branch.relaxedEvaluation<X.branch.relaxedEvaluation;return $.seq>X.seq}push($){let X=this.heap,Y=this.size;if(this.size++,Y>=X.length)X.length=X.length*2;let Z=this.allocEntry($,this.seqCounter++);while(Y>0){let K=Y-1>>1,U=X[K];if(!this.isBefore(Z,U))break;X[Y]=U,Y=K}X[Y]=Z}pop(){if(this.size===0)return;let $=this.heap,X=$[0],Y=X.branch;if(this.size--,this.freeEntry(X),this.size===0)return Y;let Z=$[this.size],K=0,U=this.size>>1;while(K<U){let J=(K<<1)+1,F=$[J],R=J+1;if(R<this.size&&this.isBefore($[R],F))J=R,F=$[R];if(!this.isBefore(F,Z))break;$[K]=F,K=J}return $[K]=Z,Y}peek(){return this.size>0?this.heap[0].branch:void 0}}function P5($,X,Y){return{type:$,varIndex:X,value:Y}}function F1($,X){return{relaxedEvaluation:$,cuts:X}}function R1(){let $=(Y,Z)=>{var K;if(Y.restore(),Y.addCutConstraints(Z),Y.simplex(),(K=Y.model)===null||K===void 0?void 0:K.useMIRCuts){let U=Y.computeFractionalVolume(!0);while(U>0){Y.applyMIRCuts(),Y.simplex();let J=Y.computeFractionalVolume(!0);if(J>=0.9*U)break;U=J}}};return{applyCuts:$,branchAndCut:(Y)=>{var Z,K,U,J,F;let R=new U$,B=0,H=(K=(Z=Y.model)===null||Z===void 0?void 0:Z.tolerance)!==null&&K!==void 0?K:0,V=!0,M=1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;if((U=Y.model)===null||U===void 0?void 0:U.timeout)M=Date.now()+Y.model.timeout;let P=1/0,A=null,_=[],q=Y.optionalObjectives,Q=q.length;for(let C=0;C<Q;C+=1)_.push(1/0);let E=F1(-1/0,[]),W;R.push(E);while(!R.isEmpty()&&V===!0&&Date.now()<M){if((J=Y.model)===null||J===void 0?void 0:J.isMinimization)W=Y.bestPossibleEval*(1+H);else W=Y.bestPossibleEval*(1-H);if(H>0){if(P<W)V=!1}let C=R.pop();if(C.relaxedEvaluation>=P)continue;let N=C.cuts;if($(Y,N),B++,Y.feasible===!1)continue;let G=Y.evaluation;if(G>P)continue;if(G===P){let O=!0;for(let S=0;S<Q;S+=1){let j=q[S].reducedCosts[0],T=_[S];if(j>T)break;else if(j<T){O=!1;break}}if(O)continue}if(Y.isIntegral()===!0){if(Y.__isIntegral=!0,B===1){Y.branchAndCutIterations=B;return}A=C,P=G;for(let O=0;O<Q;O+=1)_[O]=q[O].reducedCosts[0];if((F=Y.model)===null||F===void 0?void 0:F.keep_solutions){let O=Y.model.tableau.getSolution(),S=O.generateSolutionSet();if(S.result=O.evaluation,!Y.model.solutions)Y.model.solutions=[];Y.model.solutions.push(S)}}else{if(B===1)Y.save();let O=Y.getMostFractionalVar(),S=O.index,j=O.value,T=[],L=[],x=N.length;for(let v=0;v<x;v+=1){let z=N[v];if(z.varIndex===S)if(z.type==="min")L.push(z);else T.push(z);else T.push(z),L.push(z)}let k=P5("min",S,Math.ceil(j));T.push(k);let m=P5("max",S,Math.floor(j));L.push(m),R.push(F1(G,T)),R.push(F1(G,L))}}if(A!==null)$(Y,A.cuts);Y.branchAndCutIterations=B}}}class _1{constructor(){this.pairs=[],this.positions=new Map}add($,X){let Y=`${$}_${X}`,Z=this.pairs.length;this.pairs.push([$,X]);let K=this.positions.get(Y);if(K===void 0)return this.positions.set(Y,[Z]),[];for(let U of K){let J=Z-U;if(J>this.pairs.length-Z)continue;let F=!0;for(let R=1;R<J&&U+J+R<this.pairs.length;R++){let B=this.pairs[U+R],H=this.pairs[U+J+R];if(B[0]!==H[0]||B[1]!==H[1]){F=!1;break}}if(F)return[U,J]}return K.push(Z),[]}}function B9(){if(this.bounded=!0,this.phase1(),this.feasible===!0)this.phase2();return this}function R9(){let $=this.matrix,X=this.width,Y=this.rhsColumn,Z=X-1,K=this.height-1,J=-this.precision,F=0,R=1e4;while(F<R){let B=0,H=J;for(let A=1;A<=K;A++){let _=$[A*X+Y];if(_<H)H=_,B=A}if(B===0)return this.feasible=!0,this.setEvaluation(),F;let V=0,M=1/0,P=B*X;for(let A=1;A<=Z;A++){let _=$[P+A];if(_<J){let q=$[A];if(q>=J){let Q=q/-_;if(Q<M)M=Q,V=A}}}if(V===0)return this.feasible=!1,-1;this.pivot(B,V),F++}return this.feasible=!1,F}function H9(){let X=this.model.checkForCycles?new _1:null,Y=this.matrix,Z=this.width,K=this.rhsColumn,U=this.width-1,J=this.height-1,F=this.precision,R=-F,B=this.unrestrictedVars,H=this.varIndexByRow,V=this.varIndexByCol,M=10,P=Math.max(J,U),A=0,_=!1,q=-1/0,Q=null,E=null,W=null,C=null,N=null;while(!0){let G=0,O=R;for(let T=1;T<=J;T++){if(B[H[T]]===!0)continue;let L=Y[T*Z+K];if(L<O)O=L,G=T}if(G===0)return this.feasible=!0,A;if(!_&&A>0&&O<=q){if(A>=10&&Q===null)Q=Y.slice(),E=H.slice(),W=V.slice(),C=this.rowByVarIndex.slice(),N=this.colByVarIndex.slice();if(A>=P){if(_=!0,Q){Y.set(Q);for(let T=0;T<E.length;T++)H[T]=E[T];for(let T=0;T<W.length;T++)V[T]=W[T];for(let T=0;T<C.length;T++)this.rowByVarIndex[T]=C[T];for(let T=0;T<N.length;T++)this.colByVarIndex[T]=N[T];A=0;continue}}}if(A===0)q=O;let S=0,j=G*Z;if(_){for(let T=1;T<=U;T++)if(Y[j+T]<R){S=T;break}if(S===0)for(let T=1;T<=U;T++){let L=Y[j+T];if(B[V[T]]===!0&&(L<R||L>F)){S=T;break}}}else{let T=-1/0;for(let L=1;L<=U;L++){let x=Y[j+L];if(x<R){let k=-Y[L]/x;if(T<k)T=k,S=L}}if(S===0)for(let L=1;L<=U;L++){let x=Y[j+L];if(B[V[L]]===!0&&(x<R||x>F)){S=L;break}}}if(S===0)return this.feasible=!1,A;if(X){let T=X.add(H[G],V[S]);if(T.length>0)return this.model.messages.push("Cycle in phase 1"),this.model.messages.push("Start :"+T[0]),this.model.messages.push("Length :"+T[1]),this.feasible=!1,A}this.pivot(G,S),A+=1}}function M9(){let X=this.model.checkForCycles?new _1:null,Y=this.matrix,Z=this.width,K=this.rhsColumn,U=this.width-1,J=this.height-1,F=this.precision,R=-F,B=this.optionalObjectives.length,H=null,V=this.unrestrictedVars,M=this.varIndexByCol,P=this.varIndexByRow,A=0,_,q,Q=100,E=5,W=!1,C=Y[K],N=0,G=0,O=0,S=U,j=this.pricingBatchSize>0?this.pricingBatchSize:Math.min(500,Math.max(50,Math.floor(Math.sqrt(S)))),T=S>j*2;while(!0){if(B>0)H=[];if(!W&&A>0&&A%Q===0){let z=Y[K],u=Math.abs(z-C),y=Math.max(1,Math.abs(C));if(u/y<0.0000000001){if(N++,N>=E)W=!0,G=A,O=z}else N=0;C=z}if(W&&A-G>J){let z=Y[K],u=Math.abs(z-O),y=Math.max(1,Math.abs(O));if(u/y<0.0000000001)return this.setEvaluation(),this.simplexIters+=1,A;G=A,O=z}let L=0,x=F,k=!1;if(W)for(let z=1;z<=U;z++){if(_=Y[z],q=V[M[z]]===!0,q&&_<0){L=z,x=-_,k=!0;break}if(_>F){L=z,x=_,k=!1;break}}else if(T){let z=this.pricingBatchStart,u=0,y=Math.ceil(S/j);while(L===0&&u<y){let b=this.pricingBatchStart,f=Math.min(b+j-1,U);for(let g=b;g<=f;g++){if(_=Y[g],q=V[M[g]]===!0,B>0&&R<_&&_<F){H===null||H===void 0||H.push(g);continue}if(q&&_<0){if(-_>x)x=-_,L=g,k=!0;continue}if(_>x)x=_,L=g,k=!1}this.pricingBatchStart=f>=U?1:f+1,u++}if(L!==0)this.pricingBatchStart=z}else for(let z=1;z<=U;z++){if(_=Y[z],q=V[M[z]]===!0,B>0&&R<_&&_<F){H===null||H===void 0||H.push(z);continue}if(q&&_<0){if(-_>x)x=-_,L=z,k=!0;continue}if(_>x)x=_,L=z,k=!1}if(B>0){let z=0;while(L===0&&H&&H.length>0&&z<B){let u=[],y=this.optionalObjectives[z].reducedCosts;x=F;for(let b=0;b<H.length;b++){let f=H[b];if(_=y[f],q=V[M[f]]===!0,R<_&&_<F){u.push(f);continue}if(q&&_<0){if(-_>x)x=-_,L=f,k=!0;continue}if(_>x)x=_,L=f,k=!1}H=u,z+=1}}if(L===0)return this.setEvaluation(),this.simplexIters+=1,A;let m=0,v=1/0;for(let z=1;z<=J;z++){let u=z*Z,y=Y[u+K],b=Y[u+L];if(R<b&&b<F)continue;if(b>0&&F>y&&y>R){v=0,m=z;break}let f=k?-y/b:y/b;if(f>F&&v>f)v=f,m=z}if(v===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=M[L],A;if(X){let z=X.add(P[m],M[L]);if(z.length>0)return this.model.messages.push("Cycle in phase 2"),this.model.messages.push("Start :"+z[0]),this.model.messages.push("Length :"+z[1]),this.feasible=!1,A}this.pivot(m,L),A+=1}}var k0=new Int32Array(1024),Y$=new Float64Array(1024);function _9($,X){let Y=this.matrix,Z=this.width;if(Z>k0.length)k0=new Int32Array(Z*2),Y$=new Float64Array(Z*2);let K=$*Z,U=Y[K+X],J=1/U,F=this.height,R=this.varIndexByRow[$],B=this.varIndexByCol[X];this.varIndexByRow[$]=B,this.varIndexByCol[X]=R,this.rowByVarIndex[B]=$,this.rowByVarIndex[R]=-1,this.colByVarIndex[B]=-1,this.colByVarIndex[R]=X;let H=0;for(let P=0;P<Z;P++){let A=K+P,_=Y[A];if(!(_>=-0.0000000000000001&&_<=0.0000000000000001)){let q=_/U;Y[A]=q,k0[H]=P,Y$[H]=q,H++}else Y[A]=0}Y[K+X]=J;for(let P=0;P<F;P++)if(P!==$){let A=P*Z,_=Y[A+X];if(!(_>=-0.0000000000000001&&_<=0.0000000000000001)){let q=_;if(!(q>=-0.0000000000000001&&q<=0.0000000000000001)){for(let Q=0;Q<H;Q++){let E=k0[Q],W=Y$[Q];if(!(W>=-0.0000000000000001&&W<=0.0000000000000001))Y[A+E]-=q*W;else if(W!==0)Y[K+E]=0}Y[A+X]=-q/U}else if(q!==0)Y[A+X]=0}}let V=this.optionalObjectives,M=V.length;if(M>0)for(let P=0;P<M;P++){let A=V[P].reducedCosts,_=A[X];if(_!==0){for(let q=0;q<H;q++){let Q=k0[q];A[Q]-=_*Y$[q]}A[X]=-_*J}}}function V9($){for(let X=0;X<$.length-1;X++)for(let Y=X+1;Y<$.length;Y++){let Z=$[X],K=$[Y];if(Z[0]===K[0]&&Z[1]===K[1]){if(Y-X>$.length-Y)break;let U=!0;for(let J=1;J<Y-X;J++){let F=$[X+J],R=$[Y+J];if(F[0]!==R[0]||F[1]!==R[1]){U=!1;break}}if(U)return[X,Y-X]}}return[]}class h0{construc