UNPKG

d3-dag

Version:

Layout algorithms for visualizing directed acylic graphs.

30 lines (28 loc) 142 kB
var C0=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var r1=C0((tK,t1)=>{var f0=0.000000000000000000000000000000000000000000000000000000000001,o1,i1;do f0+=f0,o1=1+0.1*f0,i1=1+0.2*f0;while(o1<=1||i1<=1);t1.exports=f0});var e1=C0((rK,a1)=>{function e6($,X,Y){let K,Z;for(let U=1;U<=Y;U+=1){$[U][U]=1/$[U][U],Z=-$[U][U];for(let F=1;F<U;F+=1)$[F][U]*=Z;if(K=U+1,Y<K)break;for(let F=K;F<=Y;F+=1){Z=$[U][F],$[U][F]=0;for(let R=1;R<=U;R+=1)$[R][F]+=Z*$[R][U]}}}a1.exports=e6});var X5=C0((aK,$5)=>{function $7($,X,Y,K){let Z,U;for(Z=1;Z<=Y;Z+=1){U=0;for(let F=1;F<Z;F+=1)U+=$[F][Z]*K[F];K[Z]=(K[Z]-U)/$[Z][Z]}for(let F=1;F<=Y;F+=1){Z=Y+1-F,K[Z]/=$[Z][Z],U=-K[Z];for(let R=1;R<Z;R+=1)K[R]+=U*$[R][Z]}}$5.exports=$7});var K5=C0((eK,Y5)=>{function X7($,X,Y,K){let Z,U,F;for(let R=1;R<=Y;R+=1){if(K[1]=R,F=0,Z=R-1,Z<1){if(F=$[R][R]-F,F<=0)break;$[R][R]=Math.sqrt(F)}else{for(let J=1;J<=Z;J+=1){U=$[J][R];for(let B=1;B<J;B+=1)U-=$[B][R]*$[B][J];U/=$[J][J],$[J][R]=U,F+=U*U}if(F=$[R][R]-F,F<=0)break;$[R][R]=Math.sqrt(F)}K[1]=0}}Y5.exports=X7});var U5=C0(($Z,Z5)=>{var w$=r1(),Y7=e1(),K7=X5(),Z7=K5();function U7($,X,Y,K,Z,U,F,R,J,B,E,M,_,A=0,P,V,W){let H,Q,q,N,C,G,T,S,D,O,z,x,k,h,v=Math.min(K,E),L=2*K+v*(v+5)/2+2*E+1;for(let I=1;I<=K;I+=1)V[I]=X[I];for(let I=K+1;I<=L;I+=1)V[I]=0;for(let I=1;I<=E;I+=1)_[I]=0,U[I]=0;let m=[];if(W[1]===0){if(Z7($,Y,K,m),m[1]!==0){W[1]=2;return}K7($,Y,K,X),Y7($,Y,K)}else{for(let I=1;I<=K;I+=1){Z[I]=0;for(let w=1;w<=I;w+=1)Z[I]+=$[w][I]*X[w]}for(let I=1;I<=K;I+=1){X[I]=0;for(let w=I;w<=K;w+=1)X[I]+=$[I][w]*Z[w]}}F[1]=0;for(let I=1;I<=K;I+=1){Z[I]=X[I],F[1]+=V[I]*Z[I],V[I]=0;for(let w=I+1;w<=K;w+=1)$[w][I]=0}F[1]=-F[1]/2,W[1]=0;let y=K,b=y+K,f=b+v,u=f+v+1,p=u+v*(v+1)/2,n=p+E;for(let I=1;I<=E;I+=1){G=0;for(let w=1;w<=K;w+=1)G+=R[w][I]*R[w][I];V[n+I]=Math.sqrt(G)}N=A,P[1]=0,P[2]=0;function X0(){P[1]+=1,L=p;for(let I=1;I<=E;I+=1){L+=1,G=-J[I];for(let w=1;w<=K;w+=1)G+=R[w][I]*Z[w];if(Math.abs(G)<w$)G=0;if(I>M)V[L]=G;else if(V[L]=-Math.abs(G),G>0){for(let w=1;w<=K;w+=1)R[w][I]=-R[w][I];J[I]=-J[I]}}for(let I=1;I<=N;I+=1)V[p+_[I]]=0;q=0,C=0;for(let I=1;I<=E;I+=1)if(V[p+I]<C*V[n+I])q=I,C=V[p+I]/V[n+I];if(q===0){for(let I=1;I<=N;I+=1)U[_[I]]=V[f+I];return 999}return 0}function e(){for(let I=1;I<=K;I+=1){G=0;for(let w=1;w<=K;w+=1)G+=$[w][I]*R[w][q];V[I]=G}H=y;for(let I=1;I<=K;I+=1)V[H+I]=0;for(let I=N+1;I<=K;I+=1)for(let w=1;w<=K;w+=1)V[H+w]=V[H+w]+$[w][I]*V[I];x=!0;for(let I=N;I>=1;I-=1){G=V[I],L=u+I*(I+3)/2,H=L-I;for(let w=I+1;w<=N;w+=1)G-=V[L]*V[b+w],L+=w;if(G/=V[H],V[b+I]=G,_[I]<=M)continue;if(G<=0)continue;x=!1,Q=I}if(!x){T=V[f+Q]/V[b+Q];for(let I=1;I<=N;I+=1){if(_[I]<=M)continue;if(V[b+I]<=0)continue;if(C=V[f+I]/V[b+I],C<T)T=C,Q=I}}G=0;for(let I=y+1;I<=y+K;I+=1)G+=V[I]*V[I];if(Math.abs(G)<=w$){if(x)return W[1]=1,999;for(let I=1;I<=N;I+=1)V[f+I]=V[f+I]-T*V[b+I];return V[f+N+1]=V[f+N+1]+T,700}G=0;for(let I=1;I<=K;I+=1)G+=V[y+I]*R[I][q];if(S=-V[p+q]/G,k=!0,!x){if(T<S)S=T,k=!1}for(let I=1;I<=K;I+=1)if(Z[I]+=S*V[y+I],Math.abs(Z[I])<w$)Z[I]=0;F[1]+=S*G*(S/2+V[f+N+1]);for(let I=1;I<=N;I+=1)V[f+I]=V[f+I]-S*V[b+I];if(V[f+N+1]=V[f+N+1]+S,k){N+=1,_[N]=q,L=u+(N-1)*N/2+1;for(let I=1;I<=N-1;I+=1)V[L]=V[I],L+=1;if(N===K)V[L]=V[K];else{for(let I=K;I>=N+1;I-=1){if(V[I]===0)continue;if(D=Math.max(Math.abs(V[I-1]),Math.abs(V[I])),O=Math.min(Math.abs(V[I-1]),Math.abs(V[I])),V[I-1]>=0)C=Math.abs(D*Math.sqrt(1+O*O/(D*D)));else C=-Math.abs(D*Math.sqrt(1+O*O/(D*D)));if(D=V[I-1]/C,O=V[I]/C,D===1)continue;if(D===0){V[I-1]=O*C;for(let w=1;w<=K;w+=1)C=$[w][I-1],$[w][I-1]=$[w][I],$[w][I]=C}else{V[I-1]=C,z=O/(1+D);for(let w=1;w<=K;w+=1)C=D*$[w][I-1]+O*$[w][I],$[w][I]=z*($[w][I-1]+C)-$[w][I],$[w][I-1]=C}}V[L]=V[N]}}else{G=-J[q];for(let I=1;I<=K;I+=1)G+=Z[I]*R[I][q];if(q>M)V[p+q]=G;else if(V[p+q]=-Math.abs(G),G>0){for(let I=1;I<=K;I+=1)R[I][q]=-R[I][q];J[q]=-J[q]}return 700}return 0}function M0(){if(L=u+Q*(Q+1)/2+1,H=L+Q,V[H]===0)return 798;if(D=Math.max(Math.abs(V[H-1]),Math.abs(V[H])),O=Math.min(Math.abs(V[H-1]),Math.abs(V[H])),V[H-1]>=0)C=Math.abs(D*Math.sqrt(1+O*O/(D*D)));else C=-Math.abs(D*Math.sqrt(1+O*O/(D*D)));if(D=V[H-1]/C,O=V[H]/C,D===1)return 798;if(D===0){for(let I=Q+1;I<=N;I+=1)C=V[H-1],V[H-1]=V[H],V[H]=C,H+=I;for(let I=1;I<=K;I+=1)C=$[I][Q],$[I][Q]=$[I][Q+1],$[I][Q+1]=C}else{z=O/(1+D);for(let I=Q+1;I<=N;I+=1)C=D*V[H-1]+O*V[H],V[H]=z*(V[H-1]+C)-V[H],V[H-1]=C,H+=I;for(let I=1;I<=K;I+=1)C=D*$[I][Q]+O*$[I][Q+1],$[I][Q+1]=z*($[I][Q]+C)-$[I][Q+1],$[I][Q]=C}return 0}function A0(){H=L-Q;for(let I=1;I<=Q;I+=1)V[H]=V[L],L+=1,H+=1;if(V[f+Q]=V[f+Q+1],_[Q]=_[Q+1],Q+=1,Q<N)return 797;return 0}function J0(){return V[f+N]=V[f+N+1],V[f+N+1]=0,_[N]=0,N-=1,P[2]+=1,0}h=0;while(!0){if(h=X0(),h===999)return;while(!0){if(h=e(),h===0)break;if(h===999)return;if(h===700)if(Q===N)J0();else{while(!0)if(M0(),h=A0(),h!==797)break;J0()}}}}Z5.exports=U7});function J1($,X){if(X.size!==$.size)return!1;else{for(let Y of $)if(!X.has(Y))return!1;return!0}}function B1($){for(let X of $)return X;return}function T0($){for(let X of $)return $.delete(X),X;return}function P0($,X,Y){let K=$.get(X);if(K===void 0)$.set(X,[Y]);else K.push(Y)}function m0($,X,Y){let K=$.get(X);if(K===void 0)$.set(X,new Set([Y]));else K.add(Y)}function U$($,X,Y){let K=$.get(X);if(K!==void 0){if(K.delete(Y),!K.size)$.delete(X)}}var{toString:z5}=Object.prototype;function F$($){return z5.call($)==="[object RegExp]"}function R$($){let X=typeof $;return $!==null&&(X==="object"||X==="function")}var{propertyIsEnumerable:x5}=Object.prototype;function J$($){return[...Object.keys($),...Object.getOwnPropertySymbols($).filter((X)=>x5.call($,X))]}var f5=["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"],b5=["globalThis","Infinity","NaN","undefined"];function B$({includeGlobalProperties:$=!1}={}){return new Set([...f5,...$?b5:[]])}var w5=/[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*/u,E1=`(?<![@#$_\\p{ID_Continue}\\p{ID_Start}])(?!(?:${[...B$({includeGlobalProperties:!0})].join("|")})(?![$_\\p{ID_Continue}]))${w5.source}`,k5=new RegExp(E1,"u"),v5=new RegExp(`^${E1}$`,"u");function E$({exact:$=!0}={}){return $?v5:k5}function _$($){let X=(...Y)=>$(...Y);return Object.defineProperty(X,"name",{value:`functionTimeout(${$.name||"<anonymous>"})`,configurable:!0}),X}function _1(){return!1}var V$=typeof Worker<"u"?Worker:void 0;class A1 extends Error{constructor($){super($);this.name="TimeoutError"}}class P1 extends Error{constructor($){super();this.name="AbortError",this.message=$}}var V1=($)=>globalThis.DOMException===void 0?new P1($):new DOMException($),M1=($)=>{let X=$.reason===void 0?V1("This operation was aborted."):$.reason;return X instanceof Error?X:V1(X)};function M$($,X){let{milliseconds:Y,fallback:K,message:Z,customTimers:U={setTimeout,clearTimeout}}=X,F,R,B=new Promise((E,M)=>{if(typeof Y!=="number"||Math.sign(Y)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${Y}\``);if(X.signal){let{signal:A}=X;if(A.aborted)M(M1(A));R=()=>{M(M1(A))},A.addEventListener("abort",R,{once:!0})}if(Y===Number.POSITIVE_INFINITY){$.then(E,M);return}let _=new A1;F=U.setTimeout.call(void 0,()=>{if(K){try{E(K())}catch(A){M(A)}return}if(typeof $.cancel==="function")$.cancel();if(Z===!1)E();else if(Z instanceof Error)M(Z);else _.message=Z??`Promise timed out after ${Y} milliseconds`,M(_)},Y),(async()=>{try{E(await $)}catch(A){M(A)}})()}).finally(()=>{if(B.clear(),R&&X.signal)X.signal.removeEventListener("abort",R)});return B.clear=()=>{U.clearTimeout.call(void 0,F),F=void 0},B}var y5=($)=>{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 h5($,X,Y){let K,Z=new Promise((U,F)=>{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 R=[X].flat(),J=[],{addListener:B,removeListener:E}=y5($),M=(...A)=>{let P=Y.multiArgs?A:A[0];if(Y.filter&&!Y.filter(P))return;if(J.push(P),Y.count===J.length)K(),U(J)},_=(A)=>{K(),F(A)};K=()=>{for(let A of R)E(A,M);for(let A of Y.rejectionEvents)E(A,_)};for(let A of R)B(A,M);for(let A of Y.rejectionEvents)B(A,_);if(Y.signal)Y.signal.addEventListener("abort",()=>{_(Y.signal.reason)},{once:!0});if(Y.resolveImmediately)U(J)});if(Z.cancel=K,typeof Y.timeout==="number"){let U=M$(Z,{milliseconds:Y.timeout});return U.cancel=K,U}return Z}function H0($,X,Y){if(typeof Y==="function")Y={filter:Y};Y={...Y,count:1,resolveImmediately:!1};let K=h5($,X,Y),Z=K.then((U)=>U[0]);return Z.cancel=K.cancel,Z}var m5=Boolean(globalThis.process?.versions?.node),u5=($)=>new globalThis.Blob([$],{type:"text/javascript"}),g5=($)=>{return`data:text/javascript;base64,${globalThis.Buffer.from($).toString("base64")}`};function H1($){let X,Y,K=()=>{if(X)URL.revokeObjectURL(X);Y?.terminate()};if(m5)Y=new V$(g5($),{type:"module"});else X=URL.createObjectURL(u5($)),Y=new V$(X,{type:"module"});return{worker:Y,cleanup:K}}var c5=($)=>` globalThis.onmessage = async ({data: arguments_}) => { try { const output = await (${$.toString()})(...arguments_); globalThis.postMessage({output}); } catch (error) { globalThis.postMessage({error}); } }; `;function u0($){let X=c5($),Y=()=>H1(X);async function K({worker:U,arguments_:F}){let R=H0(U,"message",{rejectionEvents:["error","messageerror"]});U.postMessage(F);let{data:{output:J,error:B}}=await R;if(B)throw B;return J}let Z=async(...U)=>{let{worker:F,cleanup:R}=Y();try{return await K({arguments_:U,worker:F})}finally{R()}};return Z.withSignal=(U)=>async(...F)=>{U.throwIfAborted();let{worker:R,cleanup:J}=Y(),B=H0(U,[],{rejectionEvents:["abort"]});try{return await Promise.race([K({arguments_:F,worker:R}),B])}catch(E){throw U.throwIfAborted(),E}finally{B.cancel(),J()}},Z}var p5=($)=>` 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 W1($){let X=p5($),Y=()=>H1(X),K=(...Z)=>({async*[Symbol.asyncIterator](){let{worker:U,cleanup:F}=Y();try{let R=!0;while(!0){let J=H0(U,"message",{rejectionEvents:["error","messageerror"]});U.postMessage(R?Z:void 0),R=!1;let{data:{output:B,error:E}}=await J;if(E)throw E;let{value:M,done:_}=B;if(_)break;yield M}}finally{F()}}});return K.withSignal=(Z)=>(...U)=>({async*[Symbol.asyncIterator](){Z.throwIfAborted();let{worker:F,cleanup:R}=Y(),J=H0(Z,[],{rejectionEvents:["abort"]});try{let B=!0;while(!0){let E=Promise.race([H0(F,"message",{rejectionEvents:["error","messageerror"]}),J]);F.postMessage(B?U:void 0),B=!1;let{data:{output:M,error:_}}=await E;if(_)throw _;let{value:A,done:P}=M;if(P)break;yield A}}catch(B){throw Z.throwIfAborted(),B}finally{J.cancel(),R()}}}),K}var l5={},d5=($)=>{if($===void 0||Number.isNaN($))return;let X=Math.max(1,Math.trunc(Math.abs($)));if(!Number.isFinite(X))return;return X};function Q1($,X,{timeout:Y,throwOnTimeout:K}={}){try{return _$(()=>structuredClone($).test(X),{timeout:d5(Y),context:l5})()}catch(Z){if(_1(Z)&&!K)return!1;throw Z}}var H9=u0(($,X,Y)=>{return new RegExp($,X).test(Y)}),W9=u0(($,X,Y)=>{let Z=new RegExp($,X).exec(Y);if(Z===null)return;return{match:Z[0],index:Z.index,groups:Z.slice(1),namedGroups:Z.groups??{},input:Z.input}}),Q9=W1(function*($,X,Y){let K=new RegExp($,X),Z=Y.matchAll(K);for(let U of Z)yield{match:U[0],index:U.index,groups:U.slice(1),namedGroups:U.groups??{},input:U.input}});var s5=E$();function A$($){if(typeof $!=="string")throw TypeError(`Expected a string, got \`${typeof $}\`.`);if($.length>1e5)return!1;return Q1(s5,$,{timeout:1000})}var n5={"\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 P$($,X,Y){let K=[];return function Z(U,F={},R=""){let J=F.indent||"\t",B;if(F.inlineCharacterLimit===void 0)B={newline:` `,newlineOrSpace:` `,pad:R,indent:R+J};else B={newline:"@@__STRINGIFY_OBJECT_NEW_LINE__@@",newlineOrSpace:"@@__STRINGIFY_OBJECT_NEW_LINE_OR_SPACE__@@",pad:"@@__STRINGIFY_OBJECT_PAD__@@",indent:"@@__STRINGIFY_OBJECT_INDENT__@@"};let E=(A)=>{if(F.inlineCharacterLimit===void 0)return A;let P=A.replaceAll(B.newline,"").replaceAll(B.newlineOrSpace," ").replaceAll(B.pad,"").replaceAll(B.indent,"");if(P.length<=F.inlineCharacterLimit)return P;return A.replaceAll(B.newline,` `).replaceAll(B.newlineOrSpace,` `).replaceAll(B.pad,R).replaceAll(B.indent,R+J)};if(K.includes(U))return'"[Circular]"';let M=typeof U;if(U===null||U===void 0||M==="number"||M==="boolean"||M==="function"||F$(U))return String(U);if(M==="bigint")return String(U)+"n";if(M==="symbol"){let{description:A}=U;if(A===void 0)return"Symbol()";if(A?.startsWith("Symbol.")&&Symbol[A.slice(7)]===U)return A;let P=Symbol.keyFor(U);if(P!==void 0)return`Symbol.for(${Z(P,F)})`;return`Symbol(${Z(A,F)})`}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 A=U instanceof Map,P=A?"Map":"Set";if(U.size===0)return`new ${P}()`;K.push(U);let V=[...U].map((W)=>{if(A){let[H,Q]=W;return B.indent+`[${Z(H,F,R+J)}, ${Z(Q,F,R+J)}]`}return B.indent+Z(W,F,R+J)}).join(","+B.newlineOrSpace);return K.pop(),E(`new ${P}([${B.newline}${V}${B.newline}${B.pad}])`)}if(Array.isArray(U)){if(U.length===0)return"[]";K.push(U);let A=U.map((P,V)=>{let W=Z(P,F,R+J);if(F.transform)W=F.transform(U,V,W);return B.indent+W}).join(","+B.newlineOrSpace);return K.pop(),E(`[${B.newline}${A}${B.newline}${B.pad}]`)}if(R$(U)){let A=J$(U);if(F.filter)A=A.filter((V)=>F.filter(U,V));if(A.length===0)return"{}";K.push(U);let P=A.map((V)=>{let W=typeof V==="symbol",H;if(W)H=`[${Z(V,F)}]`;else if(A$(V))H=V;else H=Z(V,F);let Q=Z(U[V],F,R+J);if(F.transform)Q=F.transform(U,V,Q);return B.indent+H+": "+Q}).join(","+B.newlineOrSpace);return K.pop(),E(`{${B.newline}${P}${B.newline}${B.pad}}`)}let _=String(U).replaceAll("\\","\\\\").replaceAll(/[\u0000-\u001F\u007F]/g,(A)=>n5[A]??`\\u${A.codePointAt(0).toString(16).padStart(4,"0")}`);if(F.singleQuotes===!1)return`"${_.replaceAll('"',String.raw`\"`)}"`;return`'${_.replaceAll("'",String.raw`\'`)}'`}($,X,Y)}function*E0($,...X){let Y=new Set,K;while((K=X.pop())!==void 0){if(Y.has(K))continue;yield K,Y.add(K),X.push(...$(K))}}function H$($,X){let Y=[];for(let[K,Z]of s(X))Y.push($[K]),Y.push(Z);return Y.push($[$.length-1]),Y.join("")}function j($,...X){let Y=g(X,(K)=>P$(K,{indent:" ",singleQuotes:!1,inlineCharacterLimit:60}));return Error(H$($,Y))}function q1($){return`internal error: ${$}; if you encounter this please submit an issue at: https://github.com/erikbrinkman/d3-dag/issues`}function d($,...X){let Y=g(X,(K)=>K.toString());return Error(q1(H$($,Y)))}function r($,X,...Y){let[K,...Z]=$,U=g(Y,(J)=>J.toString()),F=H$(Z,U),R=X.name||"anonymous";return Error("d3dagBuiltin"in X?q1(`builtin ${K}'${R}'${F}`):`custom ${K}'${R}'${F}`)}function*s($){let X=0;for(let Y of $)yield[X++,Y]}function*K0($,X){for(let[Y,K]of s($))yield*X(K,Y)}function G1($,X,Y){let K=Y;for(let[Z,U]of s($))K=X(K,U,Z);return K}function*g($,X){for(let[Y,K]of s($))yield X(K,Y)}function*Z0($,X){for(let[Y,K]of s($))if(X(K,Y))yield K}function W$($,X){for(let[Y,K]of s($))if(X(K,Y))return!0;return!1}function I1($,X){return!W$($,(Y,K)=>!X(Y,K))}function*o5($,X,Y,K){let Z=Math.min(Y,$.length);for(let U=X;U<Z;U+=K)yield $[U]}function*i5($,X,Y,K){let Z=Math.max(Y,-1);for(let U=X;U>Z;U+=K)yield $[U]}function c($,X=0,Y=$.length,K=1){if(K>0)return o5($,X,Y,K);else if(K<0)return i5($,X,Y,K);else throw j`can't slice with zero stride`}function*a(...$){for(let X of $)yield*X}function*l($){let X=$[Symbol.iterator](),Y=X.next();if(!Y.done){let K=Y.value,Z;while(!(Z=X.next()).done)yield[K,Z.value],K=Z.value}}function N1($){for(let X of $)return X}function g0($){return typeof $==="object"&&$!==null&&Symbol.iterator in $&&typeof $[Symbol.iterator]==="function"}function t5($){if(typeof $!=="object"||$===null)return!1;let X="x"in $?$.x:void 0,Y="y"in $?$.y:void 0,K="data"in $?$.data:void 0;if(typeof X!=="number"&&X!==void 0||typeof Y!=="number"&&Y!==void 0)return!1;let Z={x:X,y:Y,data:K};return!0}function r5($){if(!Array.isArray($)||$.length!==2)return!1;let X=$,[Y,K]=X;return typeof Y==="number"&&typeof K==="number"}function a5($){if(typeof $!=="object"||$===null||!("source"in $)||!("target"in $)||!("points"in $))return!1;let{source:X,target:Y,points:K}=$,Z="data"in $?$.data:void 0;if(typeof X!=="number"||typeof Y!=="number"||!Array.isArray(K)||!K.every(r5))return!1;let U={source:X,target:Y,points:K,data:Z};return!0}function q$($){let X=[],Y,K=new Map;for(let[F,R]of s($.nodes()))if(K.set(R,F),X.push({x:R.ux,y:R.uy,data:R.data}),R===$)Y=F;let Z=[];for(let{source:F,target:R,data:J,points:B}of $.links())Z.push({source:K.get(F),target:K.get(R),points:B,data:J});return{nodes:X,links:Z,index:Y,v:1}}function e5($,X,Y,K,Z){let U=i(),F=$.map(({x:R,y:J,data:B})=>{let E=U.node(K(B));return E.ux=R,E.uy=J,E});for(let{source:R,target:J,points:B,data:E}of X){let M=U.link(F[R],F[J],Z(E));M.points=B.map(([_,A])=>[_,A])}if(Y===void 0)return U;else return F[Y]}function Q$($){function X(Z){if(typeof Z!=="object"||Z===null)throw j`parsedJson was null or wasn't an object: ${Z}`;else if(!("nodes"in Z)||!("links"in Z))throw j`parsedJson didn't have 'nodes' and 'links' properties: ${Z}`;let{nodes:U,links:F}=Z,R="index"in Z?Z.index:void 0;if(!Array.isArray(U)||!Array.isArray(F))throw j`'nodes' and 'links' weren't arrays: ${Z}`;else if(!U.every(t5)||!F.every(a5)||R!==void 0&&typeof R!=="number")throw j`'nodes' and 'links' didn't have the appropriate structure: ${Z}`;return e5(U,F,R,$.nodeDatum,$.linkDatum)}function Y(Z){if(Z===void 0)return $.nodeDatum;else{let{nodeDatum:U,...F}=$;return Q$({nodeDatum:Z,...F})}}X.nodeDatum=Y;function K(Z){if(Z===void 0)return $.linkDatum;else{let{linkDatum:U,...F}=$;return Q$({linkDatum:Z,...F})}}return X.linkDatum=K,X}function $6(...$){if($.length)throw j`got arguments to graphJson(${$}), but constructor takes no arguments; these were probably meant as data which should be called as \`graphJson()(...)\``;else return Q$({nodeDatum:(X)=>X,linkDatum:(X)=>X})}class D1{node;indeg;outdeg;stat;constructor($,X,Y,K="inactive"){this.node=$;this.indeg=X;this.outdeg=Y;this.stat=K}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 C1($,X){let Y=$[X];if(Y===void 0){let K=new Set;return $[X]=K,K}else return Y}function T1($){let X;while($.length&&!(X=$[$.length-1])?.size)$.pop();return X||void 0}function j1($,X=()=>{return}){let Y=new Map,K=new Map,Z=new Set,U=new Set,F=[],R=[];function J(q){if(q===-1/0)return Z;else if(q===1/0)return U;else if(q<=0)return C1(F,-q);else return C1(R,q-1)}for(let q of $){let N=q.nparentLinks(),C=q.nchildLinks(),G=new D1(q,N,C),T=X(q);if(Y.set(q,G),T===void 0)G.stat="active",J(G.bucket()).add(G);else m0(K,T,G)}let B=[...K].sort(([q],[N])=>q-N).map(([,q])=>q),E=0,M=B.length,_=B.length?B[E++]:new Set,A=B.length>1?B[--M]:new Set;for(let q of _)q.stat="top",J(q.bucket()).add(q);for(let q of A)q.stat="bottom",J(q.bucket()).add(q);function P(){let q;if(q=T0(Z)??T0(U))return q;let N=T1(F),C=T1(R);if(C)return T0(F.length>R.length?N:C);else if(N)return T0(N)}let V=Array(Y.size),W=0,H=Y.size,Q;while(Q=P()){let{node:q}=Q,N=Q.isTop()?W++:--H;Q.stat="ranked",V[N]=q;for(let[C,G]of q.parentCounts()){let T=Y.get(C);if(J(T.bucket()).delete(T),T.outdeg-=G,T.stat!=="ranked"&&T.stat!=="inactive")J(T.bucket()).add(T)}for(let[C,G]of q.childCounts()){let T=Y.get(C);if(J(T.bucket()).delete(T),T.indeg-=G,T.stat!=="ranked"&&T.stat!=="inactive")J(T.bucket()).add(T)}if(_.delete(Q),!_.size&&E<M){_=B[E++];for(let C of _)C.stat="top",J(C.bucket()).add(C)}if(A.delete(Q),!A.size&&E<M){A=B[--M];for(let C of A)C.stat="bottom",J(C.bucket()).add(C)}}return V}function O1($,X){let Y=new Set,K=new Set,Z=[],U;for(let F of $){if(K.has(F))continue;Z.push(F);while(U=Z.pop()){if(Y.delete(U),K.has(U))continue;K.add(U),Z.push(...X(U))}Y.add(F)}return Y}function X6($){let X=new Map(g($,(Z)=>[Z,Z.nparents()])),Y=[...g(Z0(X,([,Z])=>Z===0),([Z])=>Z)];for(let Z of Y)X.delete(Z);let K;while(K=Y.pop())for(let Z of K.children()){let U=X.get(Z)-1;if(U)X.set(Z,U);else X.delete(Z),Y.push(Z)}return!X.size}class L1{#X=0;#$=0;#U=0;#Y=!0;#Z=new Set;#E=new Set;*nodes(){for(let $ of this.split())yield*$.nodes()}topological($){return j1(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.#Z;let $;while($=B1(this.#E))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 G$(this,this.#Z,this.#E,this.#_,this.#V,this.#F,$)}link($,X,Y){return $.link($,X,Y)}#_=()=>{this.#X-=1};#V=($,X)=>{if(this.#$+=1,$)this.#U+=1;else if(!X&&this.#Y===!0)this.#Y=null};#F=($)=>{if(this.#$-=1,$)this.#U-=1;else if(this.#Y===!1)this.#Y=null};toJSON(){return q$(this)}}function S1($){for(let X of $.values())for(let Y of X)return Y}function W0($){return $ instanceof G$}class G${data;#X;#$;#U;#Y;#Z;#E;#_=0;#V=0;#F=new Map;#A=0;#J=new Map;#R;#K;ux;uy;get x(){if(this.ux===void 0)throw j`can't get \`x\` when \`ux\` is undefined`;else return this.ux}set x($){this.ux=$}get y(){if(this.uy===void 0)throw j`can't get \`y\` when \`uy\` is undefined`;else return this.uy}set y($){this.uy=$}constructor($,X,Y,K,Z,U,F){this.data=F;this.#X=$,this.#Z=X,this.#E=Y,this.#$=K,this.#U=Z,this.#Y=U,this.#R=this,this.#K={nnodes:1,nlinks:0,multis:0,acyclic:!0,roots:[this],leaves:[this],sources:new Set([this]),sinks:new Set([this])},this.#Z.add(this)}#M(){let $=this;while($.#R!==$)$.#R=$.#R.#R,$=$.#R;return $}#B(){let $=this.#M();if($.#K===void 0)throw d`undefined cached info`;else if($.#K!==null)return $.#K;else{let X=0,Y=0,K=0;for(let Z of this.nodes())X+=1,Y+=Z.nchildLinks(),K+=Z.#_,Z.#R=this,Z.#K=void 0,this.#E.delete(Z);return this.#Z.add(this),this.#K={nnodes:X,nlinks:Y,multis:K,acyclic:null,roots:null,leaves:null,sources:null,sinks:null}}}#P=($)=>{let{source:X,target:Y}=$,K=X.nchildLinksTo(Y)>1;if(K){X.#_-=1;let Z=X.#B();Z.nlinks-=1,Z.multis-=1}else{let Z=X.#M();Z.#K=null,this.#Z.delete(Z),this.#E.add(X),X.#R=X,X.#K=null,this.#E.add(Y),Y.#R=Y,Y.#K=null}this.#Y(K),U$(X.#J,Y,$),X.#A-=1,U$(Y.#F,X,$),Y.#V-=1};*nodes(){yield*E0(($)=>a($.children(),$.parents()),this)}topological($){return j1(this.nodes(),$)}*links(){for(let $ of this.nodes())yield*$.childLinks()}nnodes(){return this.#B().nnodes}nlinks(){return this.#B().nlinks}*split(){yield this}connected(){return!0}multi(){return this.#B().multis>0}acyclic(){let $=this.#B();return $.acyclic===null?$.acyclic=X6(this.nodes()):$.acyclic}node($){if(this.#X)return this.#X.node($);else throw j`can't add a node from a deleted node`}link($,X,Y){if(!this.#X)throw j`can't add a link from a deleted node`;else if($===X)throw j`tried to create a link between the same node, but self loops are not supported`;else if(W0($)&&W0(X)&&$.#X===X.#X&&this.#X===$.#X){let K=new z1(this.#X,$,X,this.#P,Y),Z=$.nchildLinksTo(X)>0,U=$.#M(),F=U.#K,R=X.#M(),J=R.#K;if(Z&&F)$.#_+=1,F.nlinks+=1,F.multis+=1;else if(Z)$.#_+=1;else if(U===R&&F){if(F.nlinks+=1,F.acyclic===!0)F.acyclic=null;F.sources?.delete(X),F.sinks?.delete($)}else if(U!==R&&F&&J){let[B,E,M,_]=F.nnodes>J.nnodes?[U,F,R,J]:[R,J,U,F];if(this.#Z.delete(M),M.#R=B,M.#K=void 0,E.nnodes+=_.nnodes,E.nlinks+=_.nlinks+1,E.multis+=_.multis,E.acyclic=E.acyclic===!1||_.acyclic===!1?!1:E.acyclic===!0&&_.acyclic===!0?!0:null,E.roots=null,E.leaves=null,E.sources&&_.sources){for(let A of _.sources)E.sources.add(A);E.sources.delete(X)}else E.sources=null;if(E.sinks&&_.sinks){for(let A of _.sinks)E.sinks.add(A);E.sinks.delete($)}else E.sinks=null}else if(U!==R)U.#K=null,R.#K=null;return this.#U(Z,U!==R),$.#A+=1,m0($.#J,X,K),X.#V+=1,m0(X.#F,$,K),K}else throw j`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.#F.size}nchildren(){return this.#J.size}nparentLinks(){return this.#V}nchildLinks(){return this.#A}nparentLinksTo($){return W0($)?this.#F.get($)?.size??0:0}*parentLinksTo($){if(W0($)){let X=this.#F.get($);if(X)yield*X}}nchildLinksTo($){return W0($)?this.#J.get($)?.size??0:0}*childLinksTo($){if(W0($)){let X=this.#J.get($);if(X)yield*X}}*parents(){yield*this.#F.keys()}*children(){yield*this.#J.keys()}*parentCounts(){for(let[$,X]of this.#F)yield[$,X.size]}*childCounts(){for(let[$,X]of this.#J)yield[$,X.size]}*parentLinks(){for(let $ of this.#F.values())yield*$}*childLinks(){for(let $ of this.#J.values())yield*$}*ancestors(){yield*E0(($)=>$.parents(),this)}*descendants(){yield*E0(($)=>$.children(),this)}*roots(){let $=this.#B();if(!$.roots)$.roots=[...O1(this.nodes(),(X)=>X.children())];yield*$.roots}*leaves(){let $=this.#B();if(!$.leaves)$.leaves=[...O1(this.nodes(),(X)=>X.parents())];yield*$.leaves}*sources(){let $=this.#B();if(!$.sources){$.sources=new Set;for(let X of this.nodes())if(X.nparents()===0)$.sources.add(X)}yield*$.sources}*sinks(){let $=this.#B();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($=S1(this.#J))$.delete();while($=S1(this.#F))$.delete();this.#Z.delete(this),this.#E.delete(this),this.#$(),this.#X=null,this.#K=null}}toJSON(){return q$(this)}}class z1{source;target;data;#X;#$;points=[];constructor($,X,Y,K,Z){this.source=X;this.target=Y;this.data=Z;this.#X=$,this.#$=K}delete(){if(this.#X)this.#$(this),this.#X=null}}function i(){return new L1}function c0($,X){let Y;if(X===void 0){for(let K of $)if(K!=null&&(Y<K||Y===void 0&&K>=K))Y=K}else{let K=-1;for(let Z of $)if((Z=X(Z,++K,$))!=null&&(Y<Z||Y===void 0&&Z>=Z))Y=Z}return Y}function p0($,X){let Y;if(X===void 0){for(let K of $)if(K!=null&&(Y>K||Y===void 0&&K>=K))Y=K}else{let K=-1;for(let Z of $)if((Z=X(Z,++K,$))!=null&&(Y>Z||Y===void 0&&Z>=Z))Y=Z}return Y}function F0($,X){return $==null||X==null?NaN:$<X?-1:$>X?1:$>=X?0:NaN}function x1($=F0){if($===F0)return I$;if(typeof $!=="function")throw TypeError("compare is not a function");return(X,Y)=>{let K=$(X,Y);if(K||K===0)return K;return($(Y,Y)===0)-($(X,X)===0)}}function I$($,X){return($==null||!($>=$))-(X==null||!(X>=X))||($<X?-1:$>X?1:0)}function l0($,X,Y=0,K=1/0,Z){if(X=Math.floor(X),Y=Math.floor(Math.max(0,Y)),K=Math.floor(Math.min($.length-1,K)),!(Y<=X&&X<=K))return $;Z=Z===void 0?I$:x1(Z);while(K>Y){if(K-Y>600){let J=K-Y+1,B=X-Y+1,E=Math.log(J),M=0.5*Math.exp(2*E/3),_=0.5*Math.sqrt(E*M*(J-M)/J)*(B-J/2<0?-1:1),A=Math.max(Y,Math.floor(X-B*M/J+_)),P=Math.min(K,Math.floor(X+(J-B)*M/J+_));l0($,X,A,P,Z)}let U=$[X],F=Y,R=K;if(O0($,Y,X),Z($[K],U)>0)O0($,Y,K);while(F<R){O0($,F,R),++F,--R;while(Z($[F],U)<0)++F;while(Z($[R],U)>0)--R}if(Z($[Y],U)===0)O0($,Y,R);else++R,O0($,R,K);if(R<=X)Y=R+1;if(X<=R)K=R-1}return $}function O0($,X,Y){let K=$[X];$[X]=$[Y],$[Y]=K}function*f1($,X){if(X===void 0){for(let Y of $)if(Y!=null&&(Y=+Y)>=Y)yield Y}else{let Y=-1;for(let K of $)if((K=X(K,++Y,$))!=null&&(K=+K)>=K)yield K}}function N$($,X,Y){if($=Float64Array.from(f1($,Y)),!(K=$.length)||isNaN(X=+X))return;if(X<=0||K<2)return p0($);if(X>=1)return c0($);var K,Z=(K-1)*X,U=Math.floor(Z),F=c0(l0($,U).subarray(0,U+1)),R=p0($.subarray(U+1));return F+(R-F)*(Z-U)}function R0($,X){return N$($,0.5,X)}function S0($,X=F0){let Y,K=!1;if(X.length===1){let Z;for(let U of $){let F=X(U);if(K?F0(F,Z)<0:F0(F,F)===0)Y=U,Z=F,K=!0}}else for(let Z of $)if(K?X(Z,Y)<0:X(Z,Z)===0)Y=Z,K=!0;return Y}function $0($){return new Set(Z0(a($.children(),$.parents()),(X)=>X.y>$.y))}function b1($,X){for(let Z of $)if(Z.ux===void 0)throw r`lane ${X} didn't assign an x to every node`;else if(Z.x<0)throw r`lane ${X} assigned an x less than 0: ${Z.x}`;let Y=new Set($.map((Z)=>Z.x));if(!J1(Y,new Set(g(Y,(Z,U)=>U)))){let Z=[...Y].sort((U,F)=>U-F).join(", ");throw r`lane ${X} didn't assign increasing positive integers for x coordinates: ${Z}`}let K=new Map;for(let[Z,U]of $.entries()){let F=K.get(U);if(F!==void 0){for(let R of c($,F+1,Z))if(R.x===U.x)throw r`lane ${X} assigned nodes to an overlapping lane: ${U.x}`}for(let R of U.children())if(!K.has(R))K.set(R,Z)}return Y.size}class w1{uncompressed;indices=[];constructor($){this.uncompressed=$}getIndex($,X){let Y=[];for(let[U,F]of this.indices.entries())if(F<=$)Y.push(U);if(this.uncompressed)Y.push(this.indices.length);let K=X===void 0?0:X,Z=S0(Y,(U)=>[Math.abs(K-U),U])??this.indices.length;return this.setIndex(Z,$),Z}setIndex($,X){this.indices[$]=X}offset(){return 0}}class k1{uncompressed;posIndices=[0];negIndices=[];constructor($){this.uncompressed=$}nextNeg(){return-this.negIndices.length-1}nextPos(){return this.posIndices.length}getIndex($,X){let Y=[];for(let[F,R]of this.negIndices.entries())if(R<=$)Y.push(-F-1);for(let[F,R]of this.posIndices.entries())if(R<=$)Y.push(F);if(this.uncompressed)Y.push(this.nextNeg()),Y.push(this.nextPos());let K=X===void 0?0:X,Z=this.negIndices.length<this.posIndices.length-1?this.nextNeg():this.nextPos(),U=S0(Y,(F)=>[Math.abs(K-F),Math.abs(F),-F])??Z;return this.setIndex(U,$),U}setIndex($,X){if($<0)this.negIndices[-$-1]=X;else this.posIndices[$]=X}offset(){return this.negIndices.length}}function Y6($,X){if(X)return new k1(!$);else return new w1(!$)}function K6($,X){for(let K of $){if(K.ux===void 0)K.x=X.getIndex(K.y);for(let Z of[...$0(K)].sort((U,F)=>F.y-U.y))if(Z.ux===void 0)Z.x=X.getIndex(K.y,K.x),X.setIndex(Z.x,Z.y)}let Y=X.offset();for(let K of $)K.x+=Y}function Z6($,X){let Y=new Map;for(let Z of $)for(let U of $0(Z)){let F=Y.get(U);if(F===void 0||Z.y<F.y)Y.set(U,Z)}for(let Z of c($,$.length-1,-1,-1)){if(Z.ux===void 0){let F=R0(g($0(Z),(R)=>R.x));Z.x=X.getIndex($.length-Z.y,F)}let U=Y.get(Z);if(U!==void 0){if(U.ux===void 0)U.x=Z.x;X.setIndex(Z.x,$.length-U.y)}}let K=X.offset();for(let Z of $)Z.x+=K}function d0($,X,Y){function K(R){for(let B of R)B.ux=void 0;let J=Y6(X,Y);if($)K6(R,J);else Z6(R,J)}function Z(R){if(R===void 0)return $;else return d0(R,X,Y)}K.topDown=Z;function U(R){if(R===void 0)return X;else return d0($,R,Y)}K.compressed=U;function F(R){if(R===void 0)return Y;else return d0($,X,R)}return K.bidirectional=F,K.d3dagBuiltin=!0,K}function C$(...$){if($.length)throw j`got arguments to laneGreedy(${$}); you probably forgot to construct laneGreedy before passing to lane: \`grid().lane(laneGreedy())\``;return d0(!0,!0,!1)}function Q0($,X){function Y(J){let B;if(!J.nnodes())B={width:0,height:0};else{let E=J.topological($.rank);for(let[W,H]of E.entries())H.y=W;$.lane(E);let M=b1(E,$.lane),{xgap:_,ygap:A}=X,P,V;if(typeof $.nodeSize==="function"){let W=Array(M).fill(0);V=-A;for(let H of E){let[Q,q]=$.nodeSize(H);if(Q<=0||q<=0)throw j`nodeSize must be positive, but got: [${Q}, ${q}]`;W[H.x]=Math.max(W[H.x],Q),V+=A,H.y=V+q/2,V+=q}P=-_;for(let[H,Q]of W.entries())P+=_,W[H]=P+Q/2,P+=Q;for(let H of E)H.x=W[H.x]}else{let[W,H]=$.nodeSize;for(let Q of E)Q.x=(Q.x+0.5)*W+Q.x*_,Q.y=(Q.y+0.5)*H+Q.y*A;P=M*(W+_)-_,V=E.length*(H+A)-A}for(let W of J.links()){let{source:H,target:Q,points:q}=W;if(q.splice(0),H.x===Q.x)q.push([H.x,H.y],[Q.x,Q.y]);else{if(q.push([H.x,H.y]),H.y<Q.y)q.push([Q.x,H.y]);else q.push([H.x,Q.y]);q.push([Q.x,Q.y])}}B={width:P,height:V}}for(let E of $.tweaks)B=E(J,B);return B}function K(J){if(J===void 0)return $.lane;else{let{lane:B,...E}=$;return Q0({...E,lane:J},X)}}Y.lane=K;function Z(J){if(J===void 0)return $.rank;else{let{rank:B,...E}=$;return Q0({...E,rank:J},X)}}Y.rank=Z;function U(J){if(J===void 0)return $.tweaks;else{let{tweaks:B,...E}=$;return Q0({...E,tweaks:J},X)}}Y.tweaks=U;function F(J){if(J===void 0)return $.nodeSize;else if(typeof J!=="function"&&(J[0]<=0||J[1]<=0)){let[B,E]=J;throw j`constant nodeSize must be positive, but got: [${B}, ${E}]`}else{let{nodeSize:B,...E}=$;return Q0({...E,nodeSize:J},X)}}Y.nodeSize=F;function R(J){if(J!==void 0){let[B,E]=J;if(B<0||E<0)throw j`gaps must be non-negative, but got [${B}, ${E}]`;return Q0($,{xgap:B,ygap:E})}else{let{xgap:B,ygap:E}=X;return[B,E]}}return Y.gap=R,Y}function T$(...$){if($.length)throw j`got arguments to grid(${$}), but constructor takes no arguments; these were probably meant as data which should be called as \`grid()(...)\``;return Q0({lane:C$(),rank:()=>{return},nodeSize:[1,1],tweaks:[]},{xgap:1,ygap:1})}function q0($){if(typeof $!=="function"){let[X,Y]=$;if(X<=0||Y<=0)throw j`all node sizes must be positive, but got width ${X} and height ${Y}`;return()=>[X,Y]}else{let X=new Map;return(K)=>{let Z=X.get(K);if(Z===void 0){Z=$(K);let[U,F]=Z;if(U<=0||F<=0)throw j`all node sizes must be positive, but got width ${U} and height ${F} for node with data: ${K.data}; make sure the callback passed to \`sugiyama().nodeSize(...)\` is doing that`;X.set(K,Z)}return Z}}}function O$($){if(typeof $!=="function"){let[X,Y]=$;return[()=>X,()=>Y]}else{let X=$;return[(Y)=>X(Y)[0],(Y)=>X(Y)[1]]}}class z${constructor($,X,Y,K){this.feasible=Y,this.evaluation=X,this.bounded=K,this._tableau=$,this.solutionSet={}}generateSolutionSet(){let $={},X=this._tableau,Y=X.varIndexByRow,K=X.variablesPerIndex,Z=X.matrix,U=X.width,F=X.rhsColumn,R=X.height-1,J=Math.round(1/X.precision);for(let B=1;B<=R;B+=1){let E=Y[B],M=K[E];if(M===void 0||M.isSlack===!0)continue;let _=Z[B*U+F];$[M.id]=Math.round((Number.EPSILON+_)*J)/J}return $}}class c1 extends z${constructor($,X,Y,K,Z){super($,X,Y,K);this.iter=Z}}class i0{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 K=this.allocEntry($,this.seqCounter++);while(Y>0){let Z=Y-1>>1,U=X[Z];if(!this.isBefore(K,U))break;X[Y]=U,Y=Z}X[Y]=K}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 K=$[this.size],Z=0,U=this.size>>1;while(Z<U){let F=(Z<<1)+1,R=$[F],J=F+1;if(J<this.size&&this.isBefore($[J],R))F=J,R=$[J];if(!this.isBefore(R,K))break;$[Z]=R,Z=F}return $[Z]=K,Y}peek(){return this.size>0?this.heap[0].branch:void 0}}function v1($,X,Y){return{type:$,varIndex:X,value:Y}}function S$($,X){return{relaxedEvaluation:$,cuts:X}}function j$(){let $=(Y,K)=>{var Z;if(Y.restore(),Y.addCutConstraints(K),Y.simplex(),(Z=Y.model)===null||Z===void 0?void 0:Z.useMIRCuts){let U=Y.computeFractionalVolume(!0);while(U>0){Y.applyMIRCuts(),Y.simplex();let F=Y.computeFractionalVolume(!0);if(F>=0.9*U)break;U=F}}};return{applyCuts:$,branchAndCut:(Y)=>{var K,Z,U,F,R;let J=new i0,B=0,E=(Z=(K=Y.model)===null||K===void 0?void 0:K.tolerance)!==null&&Z!==void 0?Z:0,M=!0,_=1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;if((U=Y.model)===null||U===void 0?void 0:U.timeout)_=Date.now()+Y.model.timeout;let A=1/0,P=null,V=[],W=Y.optionalObjectives,H=W.length;for(let N=0;N<H;N+=1)V.push(1/0);let Q=S$(-1/0,[]),q;J.push(Q);while(!J.isEmpty()&&M===!0&&Date.now()<_){if((F=Y.model)===null||F===void 0?void 0:F.isMinimization)q=Y.bestPossibleEval*(1+E);else q=Y.bestPossibleEval*(1-E);if(E>0){if(A<q)M=!1}let N=J.pop();if(N.relaxedEvaluation>=A)continue;let C=N.cuts;if($(Y,C),B++,Y.feasible===!1)continue;let G=Y.evaluation;if(G>A)continue;if(G===A){let T=!0;for(let S=0;S<H;S+=1){let D=W[S].reducedCosts[0],O=V[S];if(D>O)break;else if(D<O){T=!1;break}}if(T)continue}if(Y.isIntegral()===!0){if(Y.__isIntegral=!0,B===1){Y.branchAndCutIterations=B;return}P=N,A=G;for(let T=0;T<H;T+=1)V[T]=W[T].reducedCosts[0];if((R=Y.model)===null||R===void 0?void 0:R.keep_solutions){let T=Y.model.tableau.getSolution(),S=T.generateSolutionSet();if(S.result=T.evaluation,!Y.model.solutions)Y.model.solutions=[];Y.model.solutions.push(S)}}else{if(B===1)Y.save();let T=Y.getMostFractionalVar(),S=T.index,D=T.value,O=[],z=[],x=C.length;for(let v=0;v<x;v+=1){let L=C[v];if(L.varIndex===S)if(L.type==="min")z.push(L);else O.push(L);else O.push(L),z.push(L)}let k=v1("min",S,Math.ceil(D));O.push(k);let h=v1("max",S,Math.floor(D));z.push(h),J.push(S$(G,O)),J.push(S$(G,z))}}if(P!==null)$(Y,P.cuts);Y.branchAndCutIterations=B}}}class x${constructor(){this.pairs=[],this.positions=new Map}add($,X){let Y=`${$}_${X}`,K=this.pairs.length;this.pairs.push([$,X]);let Z=this.positions.get(Y);if(Z===void 0)return this.positions.set(Y,[K]),[];for(let U of Z){let F=K-U;if(F>this.pairs.length-K)continue;let R=!0;for(let J=1;J<F&&U+F+J<this.pairs.length;J++){let B=this.pairs[U+J],E=this.pairs[U+F+J];if(B[0]!==E[0]||B[1]!==E[1]){R=!1;break}}if(R)return[U,F]}return Z.push(K),[]}}function U6(){if(this.bounded=!0,this.phase1(),this.feasible===!0)this.phase2();return this}function F6(){let $=this.matrix,X=this.width,Y=this.rhsColumn,K=X-1,Z=this.height-1,F=-this.precision,R=0,J=1e4;while(R<J){let B=0,E=F;for(let P=1;P<=Z;P++){let V=$[P*X+Y];if(V<E)E=V,B=P}if(B===0)return this.feasible=!0,this.setEvaluation(),R;let M=0,_=1/0,A=B*X;for(let P=1;P<=K;P++){let V=$[A+P];if(V<F){let W=$[P];if(W>=F){let H=W/-V;if(H<_)_=H,M=P}}}if(M===0)return this.feasible=!1,-1;this.pivot(B,M),R++}return this.feasible=!1,R}function R6(){let X=this.model.checkForCycles?new x$:null,Y=this.matrix,K=this.width,Z=this.rhsColumn,U=this.width-1,F=this.height-1,R=this.precision,J=-R,B=this.unrestrictedVars,E=this.varIndexByRow,M=this.varIndexByCol,_=10,A=Math.max(F,U),P=0,V=!1,W=-1/0,H=null,Q=null,q=null,N=null,C=null;while(!0){let G=0,T=J;for(let O=1;O<=F;O++){if(B[E[O]]===!0)continue;let z=Y[O*K+Z];if(z<T)T=z,G=O}if(G===0)return this.feasible=!0,P;if(!V&&P>0&&T<=W){if(P>=10&&H===null)H=Y.slice(),Q=E.slice(),q=M.slice(),N=this.rowByVarIndex.slice(),C=this.colByVarIndex.slice();if(P>=A){if(V=!0,H){Y.set(H);for(let O=0;O<Q.length;O++)E[O]=Q[O];for(let O=0;O<q.length;O++)M[O]=q[O];for(let O=0;O<N.length;O++)this.rowByVarIndex[O]=N[O];for(let O=0;O<C.length;O++)this.colByVarIndex[O]=C[O];P=0;continue}}}if(P===0)W=T;let S=0,D=G*K;if(V){for(let O=1;O<=U;O++)if(Y[D+O]<J){S=O;break}if(S===0)for(let O=1;O<=U;O++){let z=Y[D+O];if(B[M[O]]===!0&&(z<J||z>R)){S=O;break}}}else{let O=-1/0;for(let z=1;z<=U;z++){let x=Y[D+z];if(x<J){let k=-Y[z]/x;if(O<k)O=k,S=z}}if(S===0)for(let z=1;z<=U;z++){let x=Y[D+z];if(B[M[z]]===!0&&(x<J||x>R)){S=z;break}}}if(S===0)return this.feasible=!1,P;if(X){let O=X.add(E[G],M[S]);if(O.length>0)return this.model.messages.push("Cycle in phase 1"),this.model.messages.push("Start :"+O[0]),this.model.messages.push("Length :"+O[1]),this.feasible=!1,P}this.pivot(G,S),P+=1}}function J6(){let X=this.model.checkForCycles?new x$:null,Y=this.matrix,K=this.width,Z=this.rhsColumn,U=this.width-1,F=this.height-1,R=this.precision,J=-R,B=this.optionalObjectives.length,E=null,M=this.unrestrictedVars,_=this.varIndexByCol,A=this.varIndexByRow,P=0,V,W,H=100,Q=5,q=!1,N=Y[Z],C=0,G=0,T=0,S=U,D=this.pricingBatchSize>0?this.pricingBatchSize:Math.min(500,Math.max(50,Math.floor(Math.sqrt(S)))),O=S>D*2;while(!0){if(B>0)E=[];if(!q&&P>0&&P%H===0){let L=Y[Z],m=Math.abs(L-N),y=Math.max(1,Math.abs(N));if(m/y<0.0000000001){if(C++,C>=Q)q=!0,G=P,T=L}else C=0;N=L}if(q&&P-G>F){let L=Y[Z],m=Math.abs(L-T),y=Math.max(1,Math.abs(T));if(m/y<0.0000000001)return this.setEvaluation(),this.simplexIters+=1,P;G=P,T=L}let z=0,x=R,k=!1;if(q)for(let L=1;L<=U;L++){if(V=Y[L],W=M[_[L]]===!0,W&&V<0){z=L,x=-V,k=!0;break}if(V>R){z=L,x=V,k=!1;break}}else if(O){let L=this.pricingBatchStart,m=0,y=Math.ceil(S/D);while(z===0&&m<y){let b=this.pricingBatchStart,f=Math.min(b+D-1,U);for(let u=b;u<=f;u++){if(V=Y[u],W=M[_[u]]===!0,B>0&&J<V&&V<R){E===null||E===void 0||E.push(u);continue}if(W&&V<0){if(-V>x)x=-V,z=u,k=!0;continue}if(V>x)x=V,z=u,k=!1}this.pricingBatchStart=f>=U?1:f+1,m++}if(z!==0)this.pricingBatchStart=L}else for(let L=1;L<=U;L++){if(V=Y[L],W=M[_[L]]===!0,B>0&&J<V&&V<R){E===null||E===void 0||E.push(L);continue}if(W&&V<0){if(-V>x)x=-V,z=L,k=!0;continue}if(V>x)x=V,z=L,k=!1}if(B>0){let L=0;while(z===0&&E&&E.length>0&&L<B){let m=[],y=this.optionalObjectives[L].reducedCosts;x=R;for(let b=0;b<E.length;b++){let f=E[b];if(V=y[f],W=M[_[f]]===!0,J<V&&V<R){m.push(f);continue}if(W&&V<0){if(-V>x)x=-V,z=f,k=!0;continue}if(V>x)x=V,z=f,k=!1}E=m,L+=1}}if(z===0)return this.setEvaluation(),this.simplexIters+=1,P;let h=0,v=1/0;for(let L=1;L<=F;L++){let m=L*K,y=Y[m+Z],b=Y[m+z];if(J<b&&b<R)continue;if(b>0&&R>y&&y>J){v=0,h=L;break}let f=k?-y/b:y/b;if(f>R&&v>f)v=f,h=L}if(v===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=_[z],P;if(X){let L=X.add(A[h],_[z]);if(L.length>0)return this.model.messages.push("Cycle in phase 2"),this.model.messages.push("Start :"+L[0]),this.model.messages.push("Length :"+L[1]),this.feasible=!1,P}this.pivot(h,z),P+=1}}var D0=new Int32Array(1024),s0=new Float64Array(1024);function B6($,X){let Y=this.matrix,K=this.width;if(K>D0.length)D0=new Int32Array(K*2),s0=new Float64Array(K*2);let Z=$*K,U=Y[Z+X],F=1/U,R=this.height,J=this.varIndexByRow[$],B=this.varIndexByCol[X];this.varIndexByRow[$]=B,this.varIndexByCol[X]=J,this.rowByVarIndex[B]=$,this.rowByVarIndex[J]=-1,this.colByVarIndex[B]=-1,this.colByVarIndex[J]=X;let E=0;for(let A=0;A<K;A++){let P=Z+A,V=Y[P];if(!(V>=-0.0000000000000001&&V<=0.0000000000000001)){let W=V/U;Y[P]=W,D0[E]=A,s0[E]=W,E++}else Y[P]=0}Y[Z+X]=F;for(let A=0;A<R;A++)if(A!==$){let P=A*K,V=Y[P+X];if(!(V>=-0.0000000000000001&&V<=0.0000000000000001)){let W=V;if(!(W>=-0.0000000000000001&&W<=0.0000000000000001)){for(let H=0;H<E;H++){let Q=D0[H],q=s0[H];if(!(q>=-0.0000000000000001&&q<=0.0000000000000001))Y[P+Q]-=W*q;else if(q!==0)Y[Z+Q]=0}Y[P+X]=-W/U}else if(W!==0)Y[P+X]=0}}let M=this.optionalObjectives,_=M.length;if(_>0)for(let A=0;A<_;A++){let P=M[A].reducedCosts,V=P[X];if(V!==0){for(let W=0;W<E;W++){let H=D0[W];P[H]-=V*s0[W]}P[X]=-V*F}}}function E6($){for(let X=0;X<$.length-1;X++)for(let Y=X+1;Y<$.length;Y++){let K=$[X],Z=$[Y];if(K[0]===Z[0]&&K[1]===Z[1]){if(Y-X>$.length-Y)break;let U=!0;for(let F=1;F<Y-X;F++){let R=$[X+F],J=$[Y+F];if(R[0]!==J[0]||R[1]!==J[1]){U=!1;break}}if(U)return[X,Y-X]}}return[]}class z0{constructor($,X,Y,K){this.id=$,this.cost=X,this.index=Y,this.value=0,this.priority=K}}class p1 extends z0{constructor($,X,Y,K){super($,X,Y,K);this.isInteger=!0}}class x0 extends z0{constructor($,X){super($,0,X,0);this.isSlack=!0}}class f${constructor($,X){this.variable=$,this.coefficient=X}}function l1($,X,Y){if(Y===0||Y==="required")return null;let K=X===void 0?1:X,Z=Y===void 0?1:Y,U=$.isMinimization===!1?-K:K;return $.addVariable(U,"r"+$.relaxationIndex++,!1,!1,Z)}class G0{constructor($,X,Y,K){this.slack=new x0("s"+Y,Y),this.index=Y,this.model=K,this.rhs=$,this.isUpperBound=X,this.terms=[],this.termsByVarIndex={},this.relaxation=null}addTerm($,X){let Y=X.index,K=this.termsByVarIndex[Y];if(K===void 0){let Z=new f$(X,$);this.termsByVarIndex[Y]=Z,this.terms.push(Z);let U=this.isUpperBound===!0?-$:$;this.model.updateConstraintCoefficient(this,X,U)}else{let Z=K.coefficient+$;this.setVariableCoefficient(Z,X)}return this}removeTerm($){return this}setRightHandSide($){if($!==this.rhs){let X=$-this.rhs;if(this.isUpperBound===!0)X=-X;this.rhs=$,this.model.updateRightHandSide(this,X)}return this}setVariableCoefficient($,X){let Y=X.index;if(Y===-1){console.warn("[Constraint.setVariableCoefficient] Trying to change coefficient of inexistant variable.");return}let K=this.termsByVarIndex[Y];if(K===void 0)this.addTerm($,X);else if($!==K.coefficient){let Z=$-K.coefficient;if(this.isUpperBound===!0)Z=-Z;K.coefficient=$,this.model.updateConstraintCoefficient(this,X,Z)}return this}relax($,X){this.relaxation=l1(this.model,$,X),this._relax(this.relaxation)}_relax($){if($===null)return;if(this.isUpperBound)this.setVariableCoefficient(-1,$);else this.setVariableCoefficient(1,$)}}class L${constructor($,X){this.isEquality=!0,this.upperBound=$,this.lowerBound=X,this.model=$.model,this.rhs=$.rhs,this.relaxation=null}addTerm($,X){return this.upperBound.addTerm($,X),this.lowerBound.addTerm($,X),this}removeTerm($){return this.upperBound.removeTerm($),this.lowerBound.removeTerm($),this}setRightHandSide($){this.upperBound.setRightHandSide($),this.lowerBound.setRightHandSide($),this.rhs=$}relax($,X){this.relaxation=l1(this.model,$,X),this.upperBound.relaxation=this.relaxation,this.upperBound._relax(this.relaxation),this.lowerBound.relaxation=this.relaxation,this.lowerBound._relax(this.relaxation)}}class d1{constructor($){this.value=$}}function _6($){let X=$.length,Y=this.height,K=Y+X,Z=this.width,U=Z-1,F=this.matrix,R=K*Z;if(F.length<R){let P=Math.ceil(R*1.5),V=new Float64Array(P);V.set(F),this.matrix=V}let J=this.matrix;this.height=K,this.nVars=this.width+this.height-2;let B=this.rhsColumn,E=this.rowByVarIndex,M=this.colByVarIndex,_=this.varIndexByRow,A=this.variablesPerIndex;for(let P=0;P<X;P+=1){let V=$[P],W=Y+P,H=W*Z,Q=V.type==="min"?-1:1,q=V.varIndex,N=E[q];if(N===-1){J[H+B]=Q*V.value;for(let C=1;C<=U;C+=1)J[H+C]=0;J[H+M[q]]=Q}else{let C=N*Z,G=J[C+B];J[H+B]=Q*(V.value-G);for(let T=1;T<=U;T+=1)J[H+T]=-Q*J[C+T]}N=this.getNewElementIndex(),_[W]=N,E[N]=W,M[N]=-1,A[N]=new x0("s"+N,N),this.nVars+=1}}function V6($){if($===this.costRowIndex)return!1;let X=this.width,Y=this.matrix,K=$*X,Z=this.variablesPerIndex[this.varIndexByRow[$]];if(Z===void 0||!Z.isInteger)return!1;let U=Y[K+this.rhsColumn],F=U-Math.floor(U);if(F<this.precision||F>1-this.precision)return!1;let R=this.height,J=R*X,B=(R+1)*X;if(Y.length<B){let H=Math.ceil(B*1.5),Q=new Float64Array(H);Q.set(Y),this.matrix=Q}let E=this.matrix;this.height+=1,this.nVars+=1;let M=this.getNewElementIndex();this.varIndexByRow[R]=M,this.rowByVarIndex[M]=R,this.colByVarIndex[M]=-1,this.variablesPerIndex[M]=new x0("s"+M,M);let _=this.rhsColumn;E[J+_]=Math.floor(U);let A=this.variablesPerIndex,P=this.varIndexByCol,V=P.length,W=1-F;for(let H=1;H<V;H+=1){let Q=A[P[H]],q=E[K+H];if(Q!==void 0&&Q.isInteger){let N=Math.floor(q),C=N+Math.max(0,q-N-F)/W;E[J+H]=C}else E[J+H]=Math.min(0,q/W)}for(let H=0;H<X;H+=1)E[J+H]-=E[K+H];return!0}function M6($){if($===this.costRowIndex)return!1;let X=this.width,Y=this.matrix,K=$*X,Z=this.variablesPerIndex[this.varIndexByRow[$]];if(Z===void 0||!Z.isInteger)return!1;let U=Y[K+this.rhsColumn],F=U-Math.floor(U);if(F<this.precision||F>1-this.precision)return!1;let R=this.height,J=R*X,B=(R+1)*X;if(Y.length<B){let H=Math.ceil(B*1.5),Q=new Float64Array(H);Q.set(Y),this.matrix=Q}let E=this.matrix;this.height+=1,this.nVars+=1;let M=this.getNewElementIndex();this.varIndexByRow[R]=M,this.rowByVarIndex[M]=R,this.colByVarIndex[M]=-1,this.variablesPerIndex[M]=new x0("s"+M,M);let _=this.rhsColumn;E[J+_]=-F;let A=this.variablesPerIndex,P=this.varIndexByCol,V=P.length,W=1-F;for(let H=1;H<V;H+=1){let Q=A[P[H]],q=E[K+H],N=q-Math.floor(q);if(Q!==void 0&&Q.isInteger)E[J+H]=N<=F?-N:-(1-N)*F/N;else E[J+H]=q>=0?-q:q*F/W}return!0}function A6(){let $=this.height,X=0,Y=10;for(let K=1;K<$&&X<Y;K++)if(this.addLowerBoundMIRCut(K))X++}function P6($){let X=this.width,Y=this.rowByVarIndex[$];if(Y===-1){let K=this.colByVarIndex[$];for(let Z=1;Z<this.height;Z+=1){let U=this.matrix[Z*X+K];if(U<-this.precision||this.precision<U){Y=Z;break}}this.pivot(Y,K)}return Y}function H6($){let X=this.width,Y=this.colByVarIndex[$];if(Y===-1){let K=this.rowByVarIndex[$],Z=K*X;for(let U=1;U<this.height;U+=1){let F=this.matrix[Z+U];if(F<-this.precision||this.precision<F){Y=U;break}}this.pivot(K,Y)}return Y}function W6(){let $=this.width,X=this.matrix,Y=this.rhsColumn,K=this.variables.length,Z=Math.round(1/this.precision);for(let U=0;U<K;U+=1){let F=this.variables[U],R=F.index,J=this.rowByVarIndex[R];if(J===-1)F.value=0;else{let B=X[J*$+Y];F.value=Math.round((B+Number.EPSILON)*Z)/Z}}}function Q6($,X){let Y=this.width,K=this.matrix,Z=this.rhsColumn,U=this.height-1,F=this.rowByVarIndex[$.index];if(F===-1){let R=this.colByVarIndex[$.index];for(let B=0;B<=U;B+=1){let E=B*Y;K[E+Z]-=X*K[E+R]}let J=this.optionalObjectives.length;if(J>0)for(let B=0;B<J;B+=1){let E=this.optionalObjectives[B].reducedCosts;E[Z]-=X*E[R]}}else K[F*Y+Z]-=X}function q6($,X,Y){if($.index===X.index)throw Error("[Tableau.updateConstraintCoefficient] constraint index should not be equal to variable index !");let K=this.width,Z=this.matrix,F=this.putInBase($.index)*K,R=this.colByVarIndex[X.index];if(R===-1){let B=this.rowByVarIndex[X.index]*K;for(let E=0;E<K;E+=1)Z[F+E]+=Y*Z[B+E]}else Z[F+R]-=Y}function G6($,X){let Y=this.width,K=this.matrix,Z=$.index,U=Y-1,F=this.colByVarIndex[Z];if(F===-1){let R=this.rowByVarIndex[Z]*Y;if($.priority===0)for(let J=0;J<=U;J+=1)K[J]+=X*K[R+J];else{let J=this.objectivesByPriority[$.priority].reducedCosts;for(let B=0;B<=U;B+=