Jarvis/static/js/plugins/D3-dag/d3-dag_0.11.1.min.js

16 lines
94 KiB
JavaScript

// d3-dag Version 0.11.1. Copyright 2022 Erik Brinkman.
var d3 = Object.assign(d3 || {}, (() => {
var d3=(()=>{var Yn=Object.create;var ge=Object.defineProperty,Xn=Object.defineProperties,eo=Object.getOwnPropertyDescriptor,to=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertyNames,Ie=Object.getOwnPropertySymbols,no=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Ut=(e,t,r)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))ct.call(t,r)&&Ut(e,r,t[r]);if(Ie)for(var r of Ie(t))Gt.call(t,r)&&Ut(e,r,t[r]);return e},T=(e,t)=>Xn(e,to(t)),qt=e=>ge(e,"__esModule",{value:!0});var B=(e,t)=>{var r={};for(var n in e)ct.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ie)for(var n of Ie(e))t.indexOf(n)<0&&Gt.call(e,n)&&(r[n]=e[n]);return r};var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),oo=(e,t)=>{for(var r in t)ge(e,r,{get:t[r],enumerable:!0})},jt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ro(t))!ct.call(e,o)&&(r||o!=="default")&&ge(e,o,{get:()=>t[o],enumerable:!(n=eo(t,o))||n.enumerable});return e},ft=(e,t)=>jt(qt(ge(e!=null?Yn(no(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),io=(e=>(t,r)=>e&&e.get(t)||(r=jt(qt({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var bt=_((Ji,dr)=>{function ur(e,t,r,n){this.feasible=r,this.evaluation=t,this.bounded=n,this._tableau=e}dr.exports=ur;ur.prototype.generateSolutionSet=function(){for(var e={},t=this._tableau,r=t.varIndexByRow,n=t.variablesPerIndex,o=t.matrix,a=t.rhsColumn,i=t.height-1,s=Math.round(1/t.precision),u=1;u<=i;u+=1){var c=r[u],d=n[c];if(!(d===void 0||d.isSlack===!0)){var l=o[u][a];e[d.id]=Math.round((Number.EPSILON+l)*s)/s}}return e}});var fr=_((Ki,cr)=>{var lr=bt();function Re(e,t,r,n,o){lr.call(this,e,t,r,n),this.iter=o}cr.exports=Re;Re.prototype=Object.create(lr.prototype);Re.constructor=Re});var K=_((Yi,pr)=>{var Lo=bt(),So=fr();function ee(e){this.model=null,this.matrix=null,this.width=0,this.height=0,this.costRowIndex=0,this.rhsColumn=0,this.variablesPerIndex=[],this.unrestrictedVars=null,this.feasible=!0,this.evaluation=0,this.simplexIters=0,this.varIndexByRow=null,this.varIndexByCol=null,this.rowByVarIndex=null,this.colByVarIndex=null,this.precision=e||1e-8,this.optionalObjectives=[],this.objectivesByPriority={},this.savedState=null,this.availableIndexes=[],this.lastElementIndex=0,this.variables=null,this.nVars=0,this.bounded=!0,this.unboundedVarIndex=null,this.branchAndCutIterations=0}pr.exports=ee;ee.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()};function xt(e,t){this.priority=e,this.reducedCosts=new Array(t);for(var r=0;r<t;r+=1)this.reducedCosts[r]=0}xt.prototype.copy=function(){var e=new xt(this.priority,this.reducedCosts.length);return e.reducedCosts=this.reducedCosts.slice(),e};ee.prototype.setOptionalObjective=function(e,t,r){var n=this.objectivesByPriority[e];if(n===void 0){var o=Math.max(this.width,t+1);n=new xt(e,o),this.objectivesByPriority[e]=n,this.optionalObjectives.push(n),this.optionalObjectives.sort(function(a,i){return a.priority-i.priority})}n.reducedCosts[t]=r};ee.prototype.initialize=function(e,t,r,n){this.variables=r,this.unrestrictedVars=n,this.width=e,this.height=t;for(var o=new Array(e),a=0;a<e;a++)o[a]=0;this.matrix=new Array(t);for(var i=0;i<t;i++)this.matrix[i]=o.slice();this.varIndexByRow=new Array(this.height),this.varIndexByCol=new Array(this.width),this.varIndexByRow[0]=-1,this.varIndexByCol[0]=-1,this.nVars=e+t-2,this.rowByVarIndex=new Array(this.nVars),this.colByVarIndex=new Array(this.nVars),this.lastElementIndex=this.nVars};ee.prototype._resetMatrix=function(){var e=this.model.variables,t=this.model.constraints,r=e.length,n=t.length,o,a,i=this.matrix[0],s=this.model.isMinimization===!0?-1:1;for(o=0;o<r;o+=1){var u=e[o],c=u.priority,d=s*u.cost;c===0?i[o+1]=d:this.setOptionalObjective(c,o+1,d),a=e[o].index,this.rowByVarIndex[a]=-1,this.colByVarIndex[a]=o+1,this.varIndexByCol[o+1]=a}for(var l=1,p=0;p<n;p+=1){var g=t[p],m=g.index;this.rowByVarIndex[m]=l,this.colByVarIndex[m]=-1,this.varIndexByRow[l]=m;var f,N,h,b=g.terms,O=b.length,x=this.matrix[l++];if(g.isUpperBound){for(f=0;f<O;f+=1)N=b[f],h=this.colByVarIndex[N.variable.index],x[h]=N.coefficient;x[0]=g.rhs}else{for(f=0;f<O;f+=1)N=b[f],h=this.colByVarIndex[N.variable.index],x[h]=-N.coefficient;x[0]=-g.rhs}}};ee.prototype.setModel=function(e){this.model=e;var t=e.nVariables+1,r=e.nConstraints+1;return this.initialize(t,r,e.variables,e.unrestrictedVariables),this._resetMatrix(),this};ee.prototype.getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var e=this.lastElementIndex;return this.lastElementIndex+=1,e};ee.prototype.density=function(){for(var e=0,t=this.matrix,r=0;r<this.height;r++)for(var n=t[r],o=0;o<this.width;o++)n[o]!==0&&(e+=1);return e/(this.height*this.width)};ee.prototype.setEvaluation=function(){var e=Math.round(1/this.precision),t=this.matrix[this.costRowIndex][this.rhsColumn],r=Math.round((Number.EPSILON+t)*e)/e;this.evaluation=r,this.simplexIters===0&&(this.bestPossibleEval=r)};ee.prototype.getSolution=function(){var e=this.model.isMinimization===!0?this.evaluation:-this.evaluation;return this.model.getNumberOfIntegerVariables()>0?new So(this,e,this.feasible,this.bounded,this.branchAndCutIterations):new Lo(this,e,this.feasible,this.bounded)}});var hr=_(()=>{var De=K();De.prototype.simplex=function(){return this.bounded=!0,this.phase1(),this.feasible===!0&&this.phase2(),this};De.prototype.phase1=function(){for(var e=this.model.checkForCycles,t=[],r=this.matrix,n=this.rhsColumn,o=this.width-1,a=this.height-1,i,s=0;;){for(var u=0,c=-this.precision,d=1;d<=a;d++){i=this.unrestrictedVars[this.varIndexByRow[d]]===!0;var l=r[d][n];l<c&&(c=l,u=d)}if(u===0)return this.feasible=!0,s;for(var p=0,g=-1/0,m=r[0],f=r[u],N=1;N<=o;N++){var h=f[N];if(i=this.unrestrictedVars[this.varIndexByCol[N]]===!0,i||h<-this.precision){var b=-m[N]/h;g<b&&(g=b,p=N)}}if(p===0)return this.feasible=!1,s;if(e){t.push([this.varIndexByRow[u],this.varIndexByCol[p]]);var O=this.checkForCycles(t);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,s}this.pivot(u,p),s+=1}};De.prototype.phase2=function(){for(var e=this.model.checkForCycles,t=[],r=this.matrix,n=this.rhsColumn,o=this.width-1,a=this.height-1,i=this.precision,s=this.optionalObjectives.length,u=null,c=0,d,l;;){var p=r[this.costRowIndex];s>0&&(u=[]);for(var g=0,m=i,f=!1,N=1;N<=o;N++){if(d=p[N],l=this.unrestrictedVars[this.varIndexByCol[N]]===!0,s>0&&-i<d&&d<i){u.push(N);continue}if(l&&d<0){-d>m&&(m=-d,g=N,f=!0);continue}d>m&&(m=d,g=N,f=!1)}if(s>0)for(var h=0;g===0&&u.length>0&&h<s;){var b=[],O=this.optionalObjectives[h].reducedCosts;m=i;for(var x=0;x<u.length;x++){if(N=u[x],d=O[N],l=this.unrestrictedVars[this.varIndexByCol[N]]===!0,-i<d&&d<i){b.push(N);continue}if(l&&d<0){-d>m&&(m=-d,g=N,f=!0);continue}d>m&&(m=d,g=N,f=!1)}u=b,h+=1}if(g===0)return this.setEvaluation(),this.simplexIters+=1,c;for(var w=0,y=1/0,L=this.varIndexByRow,D=1;D<=a;D++){var C=r[D],S=C[n],z=C[g];if(!(-i<z&&z<i)){if(z>0&&i>S&&S>-i){y=0,w=D;break}var k=f?-S/z:S/z;k>i&&y>k&&(y=k,w=D)}}if(y===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=this.varIndexByCol[g],c;if(e){t.push([this.varIndexByRow[w],this.varIndexByCol[g]]);var V=this.checkForCycles(t);if(V.length>0)return this.model.messages.push("Cycle in phase 2"),this.model.messages.push("Start :"+V[0]),this.model.messages.push("Length :"+V[1]),this.feasible=!1,c}this.pivot(w,g,!0),c+=1}};var yt=[];De.prototype.pivot=function(e,t){var r=this.matrix,n=r[e][t],o=this.height-1,a=this.width-1,i=this.varIndexByRow[e],s=this.varIndexByCol[t];this.varIndexByRow[e]=s,this.varIndexByCol[t]=i,this.rowByVarIndex[s]=e,this.rowByVarIndex[i]=-1,this.colByVarIndex[s]=-1,this.colByVarIndex[i]=t;for(var u=r[e],c=0,d=0;d<=a;d++)u[d]>=-1e-16&&u[d]<=1e-16?u[d]=0:(u[d]/=n,yt[c]=d,c+=1);u[t]=1/n;for(var l,p,g,m=this.precision,f=0;f<=o;f++)if(f!==e&&!(r[f][t]>=-1e-16&&r[f][t]<=1e-16)){var N=r[f];if(l=N[t],l>=-1e-16&&l<=1e-16)l!==0&&(N[t]=0);else{for(p=0;p<c;p++)d=yt[p],g=u[d],g>=-1e-16&&g<=1e-16?g!==0&&(u[d]=0):N[d]=N[d]-l*g;N[t]=-l/n}}var h=this.optionalObjectives.length;if(h>0)for(var b=0;b<h;b+=1){var O=this.optionalObjectives[b].reducedCosts;if(l=O[t],l!==0){for(p=0;p<c;p++)d=yt[p],g=u[d],g!==0&&(O[d]=O[d]-l*g);O[t]=-l/n}}};De.prototype.checkForCycles=function(e){for(var t=0;t<e.length-1;t++)for(var r=t+1;r<e.length;r++){var n=e[t],o=e[r];if(n[0]===o[0]&&n[1]===o[1]){if(r-t>e.length-r)break;for(var a=!0,i=1;i<r-t;i++){var s=e[t+i],u=e[r+i];if(s[0]!==u[0]||s[1]!==u[1]){a=!1;break}}if(a)return[t,r-t]}}return[]}});var $e=_((ta,Nr)=>{function Ot(e,t,r,n){this.id=e,this.cost=t,this.index=r,this.value=0,this.priority=n}function mr(e,t,r,n){Ot.call(this,e,t,r,n)}mr.prototype.isInteger=!0;function wt(e,t){Ot.call(this,e,0,t,0)}wt.prototype.isSlack=!0;function gr(e,t){this.variable=e,this.coefficient=t}function vr(e,t,r){return r===0||r==="required"?null:(t=t||1,r=r||1,e.isMinimization===!1&&(t=-t),e.addVariable(t,"r"+e.relaxationIndex++,!1,!1,r))}function de(e,t,r,n){this.slack=new wt("s"+r,r),this.index=r,this.model=n,this.rhs=e,this.isUpperBound=t,this.terms=[],this.termsByVarIndex={},this.relaxation=null}de.prototype.addTerm=function(e,t){var r=t.index,n=this.termsByVarIndex[r];if(n===void 0)n=new gr(t,e),this.termsByVarIndex[r]=n,this.terms.push(n),this.isUpperBound===!0&&(e=-e),this.model.updateConstraintCoefficient(this,t,e);else{var o=n.coefficient+e;this.setVariableCoefficient(o,t)}return this};de.prototype.removeTerm=function(e){return this};de.prototype.setRightHandSide=function(e){if(e!==this.rhs){var t=e-this.rhs;this.isUpperBound===!0&&(t=-t),this.rhs=e,this.model.updateRightHandSide(this,t)}return this};de.prototype.setVariableCoefficient=function(e,t){var r=t.index;if(r===-1){console.warn("[Constraint.setVariableCoefficient] Trying to change coefficient of inexistant variable.");return}var n=this.termsByVarIndex[r];if(n===void 0)this.addTerm(e,t);else if(e!==n.coefficient){var o=e-n.coefficient;this.isUpperBound===!0&&(o=-o),n.coefficient=e,this.model.updateConstraintCoefficient(this,t,o)}return this};de.prototype.relax=function(e,t){this.relaxation=vr(this.model,e,t),this._relax(this.relaxation)};de.prototype._relax=function(e){e!==null&&(this.isUpperBound?this.setVariableCoefficient(-1,e):this.setVariableCoefficient(1,e))};function me(e,t){this.upperBound=e,this.lowerBound=t,this.model=e.model,this.rhs=e.rhs,this.relaxation=null}me.prototype.isEquality=!0;me.prototype.addTerm=function(e,t){return this.upperBound.addTerm(e,t),this.lowerBound.addTerm(e,t),this};me.prototype.removeTerm=function(e){return this.upperBound.removeTerm(e),this.lowerBound.removeTerm(e),this};me.prototype.setRightHandSide=function(e){this.upperBound.setRightHandSide(e),this.lowerBound.setRightHandSide(e),this.rhs=e};me.prototype.relax=function(e,t){this.relaxation=vr(this.model,e,t),this.upperBound.relaxation=this.relaxation,this.upperBound._relax(this.relaxation),this.lowerBound.relaxation=this.relaxation,this.lowerBound._relax(this.relaxation)};Nr.exports={Constraint:de,Variable:Ot,IntegerVariable:mr,SlackVariable:wt,Equality:me,Term:gr}});var br=_(()=>{var Ge=K(),Dt=$e().SlackVariable;Ge.prototype.addCutConstraints=function(e){for(var t=e.length,r=this.height,n=r+t,o=r;o<n;o+=1)this.matrix[o]===void 0&&(this.matrix[o]=this.matrix[o-1].slice());this.height=n,this.nVars=this.width+this.height-2;for(var a,i=this.width-1,s=0;s<t;s+=1){var u=e[s],c=r+s,d=u.type==="min"?-1:1,l=u.varIndex,p=this.rowByVarIndex[l],g=this.matrix[c];if(p===-1){for(g[this.rhsColumn]=d*u.value,a=1;a<=i;a+=1)g[a]=0;g[this.colByVarIndex[l]]=d}else{var m=this.matrix[p],f=m[this.rhsColumn];for(g[this.rhsColumn]=d*(u.value-f),a=1;a<=i;a+=1)g[a]=-d*m[a]}var N=this.getNewElementIndex();this.varIndexByRow[c]=N,this.rowByVarIndex[N]=c,this.colByVarIndex[N]=-1,this.variablesPerIndex[N]=new Dt("s"+N,N),this.nVars+=1}};Ge.prototype._addLowerBoundMIRCut=function(e){if(e===this.costRowIndex)return!1;var t=this.model,r=this.matrix,n=this.variablesPerIndex[this.varIndexByRow[e]];if(!n.isInteger)return!1;var o=r[e][this.rhsColumn],a=o-Math.floor(o);if(a<this.precision||1-this.precision<a)return!1;var i=this.height;r[i]=r[i-1].slice(),this.height+=1,this.nVars+=1;var s=this.getNewElementIndex();this.varIndexByRow[i]=s,this.rowByVarIndex[s]=i,this.colByVarIndex[s]=-1,this.variablesPerIndex[s]=new Dt("s"+s,s),r[i][this.rhsColumn]=Math.floor(o);for(var u=1;u<this.varIndexByCol.length;u+=1){var c=this.variablesPerIndex[this.varIndexByCol[u]];if(!c.isInteger)r[i][u]=Math.min(0,r[e][u]/(1-a));else{var d=r[e][u],l=Math.floor(d)+Math.max(0,d-Math.floor(d)-a)/(1-a);r[i][u]=l}}for(var p=0;p<this.width;p+=1)r[i][p]-=r[e][p];return!0};Ge.prototype._addUpperBoundMIRCut=function(e){if(e===this.costRowIndex)return!1;var t=this.model,r=this.matrix,n=this.variablesPerIndex[this.varIndexByRow[e]];if(!n.isInteger)return!1;var o=r[e][this.rhsColumn],a=o-Math.floor(o);if(a<this.precision||1-this.precision<a)return!1;var i=this.height;r[i]=r[i-1].slice(),this.height+=1,this.nVars+=1;var s=this.getNewElementIndex();this.varIndexByRow[i]=s,this.rowByVarIndex[s]=i,this.colByVarIndex[s]=-1,this.variablesPerIndex[s]=new Dt("s"+s,s),r[i][this.rhsColumn]=-a;for(var u=1;u<this.varIndexByCol.length;u+=1){var c=this.variablesPerIndex[this.varIndexByCol[u]],d=r[e][u],l=d-Math.floor(d);c.isInteger?l<=a?r[i][u]=-l:r[i][u]=-(1-l)*a/l:d>=0?r[i][u]=-d:r[i][u]=d*a/(1-a)}return!0};Ge.prototype.applyMIRCuts=function(){}});var xr=_(()=>{var te=K();te.prototype._putInBase=function(e){var t=this.rowByVarIndex[e];if(t===-1){for(var r=this.colByVarIndex[e],n=1;n<this.height;n+=1){var o=this.matrix[n][r];if(o<-this.precision||this.precision<o){t=n;break}}this.pivot(t,r)}return t};te.prototype._takeOutOfBase=function(e){var t=this.colByVarIndex[e];if(t===-1){for(var r=this.rowByVarIndex[e],n=this.matrix[r],o=1;o<this.height;o+=1){var a=n[o];if(a<-this.precision||this.precision<a){t=o;break}}this.pivot(r,t)}return t};te.prototype.updateVariableValues=function(){for(var e=this.variables.length,t=Math.round(1/this.precision),r=0;r<e;r+=1){var n=this.variables[r],o=n.index,a=this.rowByVarIndex[o];if(a===-1)n.value=0;else{var i=this.matrix[a][this.rhsColumn];n.value=Math.round((i+Number.EPSILON)*t)/t}}};te.prototype.updateRightHandSide=function(e,t){var r=this.height-1,n=this.rowByVarIndex[e.index];if(n===-1){for(var o=this.colByVarIndex[e.index],a=0;a<=r;a+=1){var i=this.matrix[a];i[this.rhsColumn]-=t*i[o]}var s=this.optionalObjectives.length;if(s>0)for(var u=0;u<s;u+=1){var c=this.optionalObjectives[u].reducedCosts;c[this.rhsColumn]-=t*c[o]}}else this.matrix[n][this.rhsColumn]-=t};te.prototype.updateConstraintCoefficient=function(e,t,r){if(e.index===t.index)throw new Error("[Tableau.updateConstraintCoefficient] constraint index should not be equal to variable index !");var n=this._putInBase(e.index),o=this.colByVarIndex[t.index];if(o===-1)for(var a=this.rowByVarIndex[t.index],i=0;i<this.width;i+=1)this.matrix[n][i]+=r*this.matrix[a][i];else this.matrix[n][o]-=r};te.prototype.updateCost=function(e,t){var r=e.index,n=this.width-1,o=this.colByVarIndex[r];if(o===-1){var a=this.matrix[this.rowByVarIndex[r]],i;if(e.priority===0){var s=this.matrix[0];for(i=0;i<=n;i+=1)s[i]+=t*a[i]}else{var u=this.objectivesByPriority[e.priority].reducedCosts;for(i=0;i<=n;i+=1)u[i]+=t*a[i]}}else this.matrix[0][o]-=t};te.prototype.addConstraint=function(e){var t=e.isUpperBound?1:-1,r=this.height,n=this.matrix[r];n===void 0&&(n=this.matrix[0].slice(),this.matrix[r]=n);for(var o=this.width-1,a=0;a<=o;a+=1)n[a]=0;n[this.rhsColumn]=t*e.rhs;for(var i=e.terms,s=i.length,u=0;u<s;u+=1){var c=i[u],d=c.coefficient,l=c.variable.index,p=this.rowByVarIndex[l];if(p===-1)n[this.colByVarIndex[l]]+=t*d;else{var g=this.matrix[p],m=g[this.rhsColumn];for(a=0;a<=o;a+=1)n[a]-=t*d*g[a]}}var f=e.index;this.varIndexByRow[r]=f,this.rowByVarIndex[f]=r,this.colByVarIndex[f]=-1,this.height+=1};te.prototype.removeConstraint=function(e){var t=e.index,r=this.height-1,n=this._putInBase(t),o=this.matrix[r];this.matrix[r]=this.matrix[n],this.matrix[n]=o,this.varIndexByRow[n]=this.varIndexByRow[r],this.varIndexByRow[r]=-1,this.rowByVarIndex[t]=-1,this.availableIndexes[this.availableIndexes.length]=t,e.slack.index=-1,this.height-=1};te.prototype.addVariable=function(e){var t=this.height-1,r=this.width,n=this.model.isMinimization===!0?-e.cost:e.cost,o=e.priority,a=this.optionalObjectives.length;if(a>0)for(var i=0;i<a;i+=1)this.optionalObjectives[i].reducedCosts[r]=0;o===0?this.matrix[0][r]=n:(this.setOptionalObjective(o,r,n),this.matrix[0][r]=0);for(var s=1;s<=t;s+=1)this.matrix[s][r]=0;var u=e.index;this.varIndexByCol[r]=u,this.rowByVarIndex[u]=-1,this.colByVarIndex[u]=r,this.width+=1};te.prototype.removeVariable=function(e){var t=e.index,r=this._takeOutOfBase(t),n=this.width-1;if(r!==n){for(var o=this.height-1,a=0;a<=o;a+=1){var i=this.matrix[a];i[r]=i[n]}var s=this.optionalObjectives.length;if(s>0)for(var u=0;u<s;u+=1){var c=this.optionalObjectives[u].reducedCosts;c[r]=c[n]}var d=this.varIndexByCol[n];this.varIndexByCol[r]=d,this.colByVarIndex[d]=r}this.varIndexByCol[n]=-1,this.colByVarIndex[t]=-1,this.availableIndexes[this.availableIndexes.length]=t,e.index=-1,this.width-=1}});var yr=_(()=>{var Co=K();Co.prototype.log=function(e,t){console.log("****",e,"****"),console.log("Nb Variables",this.width-1),console.log("Nb Constraints",this.height-1),console.log("Basic Indexes",this.varIndexByRow),console.log("Non Basic Indexes",this.varIndexByCol),console.log("Rows",this.rowByVarIndex),console.log("Cols",this.colByVarIndex);var r=5,n="",o=[" "],a,i,s,u,c,d,l,p,g,m,f,N,h;for(i=1;i<this.width;i+=1)d=this.varIndexByCol[i],c=this.variablesPerIndex[d],c===void 0?l="c"+d:l=c.id,p=l.length,g=Math.abs(p-5),m=" ",f=" ",p>5?m+=" ":f+=" ",o[i]=m,n+=f+l;console.log(n);var b,O=this.matrix[this.costRowIndex],x=" ";for(a=1;a<this.width;a+=1)b=" ",x+=b,x+=o[a],x+=O[a].toFixed(r);for(b=" ",x+=b+o[0]+O[0].toFixed(r),console.log(x+" Z"),u=1;u<this.height;u+=1){for(N=this.matrix[u],h=" ",i=1;i<this.width;i+=1)b=" ",h+=b+o[i]+N[i].toFixed(r);b=" ",h+=b+o[0]+N[0].toFixed(r),d=this.varIndexByRow[u],c=this.variablesPerIndex[d],c===void 0?l="c"+d:l=c.id,console.log(h+" "+l)}console.log("");var w=this.optionalObjectives.length;if(w>0){console.log(" Optional objectives:");for(var y=0;y<w;y+=1){var L=this.optionalObjectives[y].reducedCosts,D="";for(a=1;a<this.width;a+=1)b=L[a]<0?"":" ",D+=b,D+=o[a],D+=L[a].toFixed(r);b=L[0]<0?"":" ",D+=b+o[0]+L[0].toFixed(r),console.log(D+" z"+y)}}return console.log("Feasible?",this.feasible),console.log("evaluation",this.evaluation),this}});var Or=_(()=>{var Ue=K();Ue.prototype.copy=function(){var e=new Ue(this.precision);e.width=this.width,e.height=this.height,e.nVars=this.nVars,e.model=this.model,e.variables=this.variables,e.variablesPerIndex=this.variablesPerIndex,e.unrestrictedVars=this.unrestrictedVars,e.lastElementIndex=this.lastElementIndex,e.varIndexByRow=this.varIndexByRow.slice(),e.varIndexByCol=this.varIndexByCol.slice(),e.rowByVarIndex=this.rowByVarIndex.slice(),e.colByVarIndex=this.colByVarIndex.slice(),e.availableIndexes=this.availableIndexes.slice();for(var t=[],r=0;r<this.optionalObjectives.length;r++)t[r]=this.optionalObjectives[r].copy();e.optionalObjectives=t;for(var n=this.matrix,o=new Array(this.height),a=0;a<this.height;a++)o[a]=n[a].slice();return e.matrix=o,e};Ue.prototype.save=function(){this.savedState=this.copy()};Ue.prototype.restore=function(){if(this.savedState!==null){var e=this.savedState,t=e.matrix;this.nVars=e.nVars,this.model=e.model,this.variables=e.variables,this.variablesPerIndex=e.variablesPerIndex,this.unrestrictedVars=e.unrestrictedVars,this.lastElementIndex=e.lastElementIndex,this.width=e.width,this.height=e.height;var r,n;for(r=0;r<this.height;r+=1){var o=t[r],a=this.matrix[r];for(n=0;n<this.width;n+=1)a[n]=o[n]}var i=e.varIndexByRow;for(n=0;n<this.height;n+=1)this.varIndexByRow[n]=i[n];for(;this.varIndexByRow.length>this.height;)this.varIndexByRow.pop();var s=e.varIndexByCol;for(r=0;r<this.width;r+=1)this.varIndexByCol[r]=s[r];for(;this.varIndexByCol.length>this.width;)this.varIndexByCol.pop();for(var u=e.rowByVarIndex,c=e.colByVarIndex,d=0;d<this.nVars;d+=1)this.rowByVarIndex[d]=u[d],this.colByVarIndex[d]=c[d];if(e.optionalObjectives.length>0&&this.optionalObjectives.length>0){this.optionalObjectives=[],this.optionalObjectivePerPriority={};for(var l=0;l<e.optionalObjectives.length;l++){var p=e.optionalObjectives[l].copy();this.optionalObjectives[l]=p,this.optionalObjectivePerPriority[p.priority]=p}}}}});var Lr=_(()=>{var wr=K();function Dr(e,t){this.index=e,this.value=t}wr.prototype.getMostFractionalVar=function(){for(var e=0,t=null,r=null,n=.5,o=this.model.integerVariables,a=o.length,i=0;i<a;i++){var s=o[i].index,u=this.rowByVarIndex[s];if(u!==-1){var c=this.matrix[u][this.rhsColumn],d=Math.abs(c-Math.round(c));e<d&&(e=d,t=s,r=c)}}return new Dr(t,r)};wr.prototype.getFractionalVarWithLowestCost=function(){for(var e=1/0,t=null,r=null,n=this.model.integerVariables,o=n.length,a=0;a<o;a++){var i=n[a],s=i.index,u=this.rowByVarIndex[s];if(u!==-1){var c=this.matrix[u][this.rhsColumn];if(Math.abs(c-Math.round(c))>this.precision){var d=i.cost;e>d&&(e=d,t=s,r=c)}}}return new Dr(t,r)}});var Sr=_(()=>{var Lt=K();Lt.prototype.countIntegerValues=function(){for(var e=0,t=1;t<this.height;t+=1)if(this.variablesPerIndex[this.varIndexByRow[t]].isInteger){var r=this.matrix[t][this.rhsColumn];r=r-Math.floor(r),r<this.precision&&-r<this.precision&&(e+=1)}return e};Lt.prototype.isIntegral=function(){for(var e=this.model.integerVariables,t=e.length,r=0;r<t;r++){var n=this.rowByVarIndex[e[r].index];if(n!==-1){var o=this.matrix[n][this.rhsColumn];if(Math.abs(o-Math.round(o))>this.precision)return!1}}return!0};Lt.prototype.computeFractionalVolume=function(e){for(var t=-1,r=1;r<this.height;r+=1)if(this.variablesPerIndex[this.varIndexByRow[r]].isInteger){var n=this.matrix[r][this.rhsColumn];n=Math.abs(n);var o=Math.min(n-Math.floor(n),Math.floor(n+1));if(o<this.precision){if(!e)return 0}else t===-1?t=n:t*=n}return t===-1?0:t}});var Ir=_((ha,Cr)=>{hr();br();xr();yr();Or();Lr();Sr();Cr.exports=K()});var Ct=_(()=>{var kr=K();function zr(e,t,r){this.type=e,this.varIndex=t,this.value=r}function St(e,t){this.relaxedEvaluation=e,this.cuts=t}function Io(e,t){return t.relaxedEvaluation-e.relaxedEvaluation}kr.prototype.applyCuts=function(e){if(this.restore(),this.addCutConstraints(e),this.simplex(),this.model.useMIRCuts)for(var t=!0;t;){var r=this.computeFractionalVolume(!0);this.applyMIRCuts(),this.simplex();var n=this.computeFractionalVolume(!0);n>=.9*r&&(t=!1)}};kr.prototype.branchAndCut=function(){var e=[],t=0,r=this.model.tolerance,n=!0,o=1e99;this.model.timeout&&(o=Date.now()+this.model.timeout);for(var a=1/0,i=null,s=[],u=0;u<this.optionalObjectives.length;u+=1)s.push(1/0);var c=new St(-1/0,[]),d;for(e.push(c);e.length>0&&n===!0&&Date.now()<o;)if(this.model.isMinimization?d=this.bestPossibleEval*(1+r):d=this.bestPossibleEval*(1-r),r>0&&a<d&&(n=!1),c=e.pop(),!(c.relaxedEvaluation>a)){var l=c.cuts;if(this.applyCuts(l),t++,this.feasible!==!1){var p=this.evaluation;if(!(p>a)){if(p===a){for(var g=!0,m=0;m<this.optionalObjectives.length&&!(this.optionalObjectives[m].reducedCosts[0]>s[m]);m+=1)if(this.optionalObjectives[m].reducedCosts[0]<s[m]){g=!1;break}if(g)continue}if(this.isIntegral()===!0){if(this.__isIntegral=!0,t===1){this.branchAndCutIterations=t;return}i=c,a=p;for(var f=0;f<this.optionalObjectives.length;f+=1)s[f]=this.optionalObjectives[f].reducedCosts[0]}else{t===1&&this.save();for(var N=this.getMostFractionalVar(),h=N.index,b=[],O=[],x=l.length,w=0;w<x;w+=1){var y=l[w];y.varIndex===h?y.type==="min"?O.push(y):b.push(y):(b.push(y),O.push(y))}var L=Math.ceil(N.value),D=Math.floor(N.value),C=new zr("min",h,L);b.push(C);var S=new zr("max",h,D);O.push(S),e.push(new St(p,b)),e.push(new St(p,O)),e.sort(Io)}}}}i!==null&&this.applyCuts(i.cuts),this.branchAndCutIterations=t}});var Tr=_((ba,Ar)=>{var ko=K(),va=Ct(),Le=$e(),qe=Le.Constraint,Mr=Le.Equality,zo=Le.Variable,Mo=Le.IntegerVariable,Na=Le.Term;function G(e,t){this.tableau=new ko(e),this.name=t,this.variables=[],this.integerVariables=[],this.unrestrictedVariables={},this.constraints=[],this.nConstraints=0,this.nVariables=0,this.isMinimization=!0,this.tableauInitialized=!1,this.relaxationIndex=1,this.useMIRCuts=!1,this.checkForCycles=!0,this.messages=[]}Ar.exports=G;G.prototype.minimize=function(){return this.isMinimization=!0,this};G.prototype.maximize=function(){return this.isMinimization=!1,this};G.prototype._getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var e=this.lastElementIndex;return this.lastElementIndex+=1,e};G.prototype._addConstraint=function(e){var t=e.slack;this.tableau.variablesPerIndex[t.index]=t,this.constraints.push(e),this.nConstraints+=1,this.tableauInitialized===!0&&this.tableau.addConstraint(e)};G.prototype.smallerThan=function(e){var t=new qe(e,!0,this.tableau.getNewElementIndex(),this);return this._addConstraint(t),t};G.prototype.greaterThan=function(e){var t=new qe(e,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(t),t};G.prototype.equal=function(e){var t=new qe(e,!0,this.tableau.getNewElementIndex(),this);this._addConstraint(t);var r=new qe(e,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(r),new Mr(t,r)};G.prototype.addVariable=function(e,t,r,n,o){if(typeof o=="string")switch(o){case"required":o=0;break;case"strong":o=1;break;case"medium":o=2;break;case"weak":o=3;break;default:o=0;break}var a=this.tableau.getNewElementIndex();t==null&&(t="v"+a),e==null&&(e=0),o==null&&(o=0);var i;return r?(i=new Mo(t,e,a,o),this.integerVariables.push(i)):i=new zo(t,e,a,o),this.variables.push(i),this.tableau.variablesPerIndex[a]=i,n&&(this.unrestrictedVariables[a]=!0),this.nVariables+=1,this.tableauInitialized===!0&&this.tableau.addVariable(i),i};G.prototype._removeConstraint=function(e){var t=this.constraints.indexOf(e);if(t===-1){console.warn("[Model.removeConstraint] Constraint not present in model");return}this.constraints.splice(t,1),this.nConstraints-=1,this.tableauInitialized===!0&&this.tableau.removeConstraint(e),e.relaxation&&this.removeVariable(e.relaxation)};G.prototype.removeConstraint=function(e){return e.isEquality?(this._removeConstraint(e.upperBound),this._removeConstraint(e.lowerBound)):this._removeConstraint(e),this};G.prototype.removeVariable=function(e){var t=this.variables.indexOf(e);if(t===-1){console.warn("[Model.removeVariable] Variable not present in model");return}return this.variables.splice(t,1),this.tableauInitialized===!0&&this.tableau.removeVariable(e),this};G.prototype.updateRightHandSide=function(e,t){return this.tableauInitialized===!0&&this.tableau.updateRightHandSide(e,t),this};G.prototype.updateConstraintCoefficient=function(e,t,r){return this.tableauInitialized===!0&&this.tableau.updateConstraintCoefficient(e,t,r),this};G.prototype.setCost=function(e,t){var r=e-t.cost;return this.isMinimization===!1&&(r=-r),t.cost=e,this.tableau.updateCost(t,r),this};G.prototype.loadJson=function(e){this.isMinimization=e.opType!=="max";for(var t=e.variables,r=e.constraints,n={},o={},a=Object.keys(r),i=a.length,s=0;s<i;s+=1){var u=a[s],c=r[u],d=c.equal,l=c.weight,p=c.priority,g=l!==void 0||p!==void 0,m,f;if(d===void 0){var N=c.min;N!==void 0&&(m=this.greaterThan(N),n[u]=m,g&&m.relax(l,p));var h=c.max;h!==void 0&&(f=this.smallerThan(h),o[u]=f,g&&f.relax(l,p))}else{m=this.greaterThan(d),n[u]=m,f=this.smallerThan(d),o[u]=f;var b=new Mr(m,f);g&&b.relax(l,p)}}var O=Object.keys(t),x=O.length;this.tolerance=e.tolerance||0,e.timeout&&(this.timeout=e.timeout),e.options&&(e.options.timeout&&(this.timeout=e.options.timeout),this.tolerance===0&&(this.tolerance=e.options.tolerance||0),e.options.useMIRCuts&&(this.useMIRCuts=e.options.useMIRCuts),typeof e.options.exitOnCycles=="undefined"?this.checkForCycles=!0:this.checkForCycles=e.options.exitOnCycles);for(var w=e.ints||{},y=e.binaries||{},L=e.unrestricted||{},D=e.optimize,C=0;C<x;C+=1){var S=O[C],z=t[S],k=z[D]||0,V=!!y[S],E=!!w[S]||V,P=!!L[S],M=this.addVariable(k,S,E,P);V&&this.smallerThan(1).addTerm(1,M);var $=Object.keys(z);for(s=0;s<$.length;s+=1){var j=$[s];if(j!==D){var q=z[j],R=n[j];R!==void 0&&R.addTerm(q,M);var ne=o[j];ne!==void 0&&ne.addTerm(q,M)}}}return this};G.prototype.getNumberOfIntegerVariables=function(){return this.integerVariables.length};G.prototype.solve=function(){return this.tableauInitialized===!1&&(this.tableau.setModel(this),this.tableauInitialized=!0),this.tableau.solve()};G.prototype.isFeasible=function(){return this.tableau.feasible};G.prototype.save=function(){return this.tableau.save()};G.prototype.restore=function(){return this.tableau.restore()};G.prototype.activateMIRCuts=function(e){this.useMIRCuts=e};G.prototype.debug=function(e){this.checkForCycles=e};G.prototype.log=function(e){return this.tableau.log(e)}});var Vr=_(Er=>{Er.CleanObjectiveAttributes=function(e){var t,r,n;if(typeof e.optimize=="string")if(e.constraints[e.optimize]){t=Math.random();for(r in e.variables)e.variables[r][e.optimize]&&(e.variables[r][t]=e.variables[r][e.optimize]);return e.constraints[t]=e.constraints[e.optimize],delete e.constraints[e.optimize],e}else return e;else{for(n in e.optimize)if(e.constraints[n])if(e.constraints[n]==="equal")delete e.optimize[n];else{t=Math.random();for(r in e.variables)e.variables[r][n]&&(e.variables[r][t]=e.variables[r][n]);e.constraints[t]=e.constraints[n],delete e.constraints[n]}return e}}});var je=_((ya,Pr)=>{function Ao(e){var t={is_blank:/^\W{0,}$/,is_objective:/(max|min)(imize){0,}\:/i,is_int:/^(?!\/\*)\W{0,}int/i,is_bin:/^(?!\/\*)\W{0,}bin/i,is_constraint:/(\>|\<){0,}\=/i,is_unrestricted:/^\S{0,}unrestricted/i,parse_lhs:/(\-|\+){0,1}\s{0,1}\d{0,}\.{0,}\d{0,}\s{0,}[A-Za-z]\S{0,}/gi,parse_rhs:/(\-|\+){0,1}\d{1,}\.{0,}\d{0,}\W{0,}\;{0,1}$/i,parse_dir:/(\>|\<){0,}\=/gi,parse_int:/[^\s|^\,]+/gi,parse_bin:/[^\s|^\,]+/gi,get_num:/(\-|\+){0,1}(\W|^)\d+\.{0,1}\d{0,}/g,get_word:/[A-Za-z].*/},r={opType:"",optimize:"_obj",constraints:{},variables:{}},n={">=":"min","<=":"max","=":"equal"},o="",a=0,i=null,s="",u="",c="",d=0;typeof e=="string"&&(e=e.split(`
`));for(var l=0;l<e.length;l++)if(c="__"+l,o=e[l],a=0,i=null,t.is_objective.test(o))r.opType=o.match(/(max|min)/gi)[0],i=o.match(t.parse_lhs).map(function(m){return m.replace(/\s+/,"")}).slice(1),i.forEach(function(m){s=m.match(t.get_num),s===null?m.substr(0,1)==="-"?s=-1:s=1:s=s[0],s=parseFloat(s),u=m.match(t.get_word)[0].replace(/\;$/,""),r.variables[u]=r.variables[u]||{},r.variables[u]._obj=s});else if(t.is_int.test(o))i=o.match(t.parse_int).slice(1),r.ints=r.ints||{},i.forEach(function(m){m=m.replace(";",""),r.ints[m]=1});else if(t.is_bin.test(o))i=o.match(t.parse_bin).slice(1),r.binaries=r.binaries||{},i.forEach(function(m){m=m.replace(";",""),r.binaries[m]=1});else if(t.is_constraint.test(o)){var p=o.indexOf(":"),g=p===-1?o:o.slice(p+1);i=g.match(t.parse_lhs).map(function(m){return m.replace(/\s+/,"")}),i.forEach(function(m){s=m.match(t.get_num),s===null?m.substr(0,1)==="-"?s=-1:s=1:s=s[0],s=parseFloat(s),u=m.match(t.get_word)[0],r.variables[u]=r.variables[u]||{},r.variables[u][c]=s}),d=parseFloat(o.match(t.parse_rhs)[0]),o=n[o.match(t.parse_dir)[0]],r.constraints[c]=r.constraints[c]||{},r.constraints[c][o]=d}else t.is_unrestricted.test(o)&&(i=o.match(t.parse_int).slice(1),r.unrestricted=r.unrestricted||{},i.forEach(function(m){m=m.replace(";",""),r.unrestricted[m]=1}));return r}function To(e){if(!e)throw new Error("Solver requires a model to operate on");var t="",r=[],n=1,o={max:"<=",min:">=",equal:"="},a=new RegExp("[^A-Za-z0-9_[{}/.&#$%~'@^]","gi");if(e.opType){t+=e.opType+":";for(var i in e.variables)e.variables[i][i]=e.variables[i][i]?e.variables[i][i]:1,e.variables[i][e.optimize]&&(t+=" "+e.variables[i][e.optimize]+" "+i.replace(a,"_"))}else t+="max:";t+=`;
`;for(var s in e.constraints)for(var u in e.constraints[s])if(typeof o[u]!="undefined"){for(var c in e.variables)typeof e.variables[c][s]!="undefined"&&(t+=" "+e.variables[c][s]+" "+c.replace(a,"_"));t+=" "+o[u]+" "+e.constraints[s][u],t+=`;
`}if(e.ints){t+=`
`;for(var d in e.ints)t+="int "+d.replace(a,"_")+`;
`}if(e.unrestricted){t+=`
`;for(var l in e.unrestricted)t+="unrestricted "+l.replace(a,"_")+`;
`}return t}Pr.exports=function(e){return e.length?Ao(e):To(e)}});var Br=_(()=>{});var _r=_(()=>{});var Rr=_(It=>{It.reformat=je();function Wr(e){return e=e.replace("\\r\\n",`\r
`),e=e.split(`\r
`),e=e.filter(function(t){var r;return r=new RegExp(" 0$","gi"),!(r.test(t)===!0||(r=new RegExp("\\d$","gi"),r.test(t)===!1))}).map(function(t){return t.split(/\:{0,1} +(?=\d)/)}).reduce(function(t,r,n){return t[r[0]]=r[1],t},{}),e}It.solve=function(e){return new Promise(function(t,r){typeof window!="undefined"&&r("Function Not Available in Browser");var n=je()(e);e.external||r("Data for this function must be contained in the 'external' attribute. Not seeing anything there."),e.external.binPath||r("No Executable | Binary path provided in arguments as 'binPath'"),e.external.args||r("No arguments array for cli | bash provided on 'args' attribute"),e.external.tempName||r("No 'tempName' given. This is necessary to produce a staging file for the solver to operate on");var o=Br();o.writeFile(e.external.tempName,n,function(a,i){if(a)r(a);else{var s=_r().execFile;e.external.args.push(e.external.tempName),s(e.external.binPath,e.external.args,function(u,c){if(u)if(u.code===1)t(Wr(c));else{var d={"-2":"Out of Memory","1":"SUBOPTIMAL","2":"INFEASIBLE","3":"UNBOUNDED","4":"DEGENERATE","5":"NUMFAILURE","6":"USER-ABORT","7":"TIMEOUT","9":"PRESOLVED","25":"ACCURACY ERROR","255":"FILE-ERROR"},l={code:u.code,meaning:d[u.code],data:c};r(l)}else t(Wr(c))})}})})}});var Gr=_((Ca,$r)=>{$r.exports={lpsolve:Rr()}});var kt=_((Ia,Ur)=>{Ur.exports=function(e,t){var r=t.optimize,n=JSON.parse(JSON.stringify(t.optimize)),o=Object.keys(t.optimize),a,i=0,s={},u="",c={},d=[],l,p,g,m,f;for(delete t.optimize,l=0;l<o.length;l++)n[o[l]]=0;for(l=0;l<o.length;l++){t.optimize=o[l],t.opType=r[o[l]],a=e.Solve(t,void 0,void 0,!0);for(m in o)if(!t.variables[o[m]]){a[o[m]]=a[o[m]]?a[o[m]]:0;for(g in t.variables)t.variables[g][o[m]]&&a[g]&&(a[o[m]]+=a[g]*t.variables[g][o[m]])}for(u="base",p=0;p<o.length;p++)a[o[p]]?u+="-"+(a[o[p]]*1e3|0)/1e3:u+="-0";if(!s[u]){for(s[u]=1,i++,p=0;p<o.length;p++)a[o[p]]&&(n[o[p]]+=a[o[p]]);delete a.feasible,delete a.result,d.push(a)}}for(l=0;l<o.length;l++)t.constraints[o[l]]={equal:n[o[l]]/i};t.optimize="cheater-"+Math.random(),t.opType="max";for(l in t.variables)t.variables[l].cheater=1;for(l in d)for(g in d[l])c[g]=c[g]||{min:1e99,max:-1e99};for(l in c)for(g in d)d[g][l]?(d[g][l]>c[l].max&&(c[l].max=d[g][l]),d[g][l]<c[l].min&&(c[l].min=d[g][l])):(d[g][l]=0,c[l].min=0);return a=e.Solve(t,void 0,void 0,!0),{midpoint:a,vertices:d,ranges:c}}});var Fr=_((ka,jr)=>{var Eo=Ir(),zt=Tr(),Vo=Ct(),Fe=$e(),qr=Vr(),Po=Fe.Constraint,Bo=Fe.Variable,_o=Fe.Numeral,Wo=Fe.Term,He=Gr(),Ze=function(){"use strict";this.Model=zt,this.branchAndCut=Vo,this.Constraint=Po,this.Variable=Bo,this.Numeral=_o,this.Term=Wo,this.Tableau=Eo,this.lastSolvedModel=null,this.External=He,this.Solve=function(e,t,r,n){if(n)for(var o in qr)e=qr[o](e);if(!e)throw new Error("Solver requires a model to operate on");if(typeof e.optimize=="object"&&Object.keys(e.optimize>1))return kt()(this,e);if(e.external){var a=Object.keys(He);if(a=JSON.stringify(a),!e.external.solver)throw new Error("The model you provided has an 'external' object that doesn't have a solver attribute. Use one of the following:"+a);if(!He[e.external.solver])throw new Error("No support (yet) for "+e.external.solver+". Please use one of these instead:"+a);return He[e.external.solver].solve(e)}else{e instanceof zt||(e=new zt(t).loadJson(e));var i=e.solve();if(this.lastSolvedModel=e,i.solutionSet=i.generateSolutionSet(),r)return i;var s={};return s.feasible=i.feasible,s.result=i.evaluation,s.bounded=i.bounded,i._tableau.__isIntegral&&(s.isIntegral=!0),Object.keys(i.solutionSet).forEach(function(u){i.solutionSet[u]!==0&&(s[u]=i.solutionSet[u])}),s}},this.ReformatLP=je(),this.MultiObjective=function(e){return kt()(this,e)}};typeof define=="function"?define([],function(){return new Ze}):typeof window=="object"?window.solver=new Ze:typeof self=="object"&&(self.solver=new Ze);jr.exports=new Ze});var Yr=_((_a,Kr)=>{"use strict";var Se=1e-60,Qr,Jr;do Se+=Se,Qr=1+.1*Se,Jr=1+.2*Se;while(Qr<=1||Jr<=1);Kr.exports=Se});var en=_((Wa,Xr)=>{"use strict";function $o(e,t,r){let n,o;for(let a=1;a<=r;a+=1){e[a][a]=1/e[a][a],o=-e[a][a];for(let i=1;i<a;i+=1)e[i][a]*=o;if(n=a+1,r<n)break;for(let i=n;i<=r;i+=1){o=e[a][i],e[a][i]=0;for(let s=1;s<=a;s+=1)e[s][i]+=o*e[s][a]}}}Xr.exports=$o});var rn=_((Ra,tn)=>{"use strict";function Go(e,t,r,n){let o,a;for(o=1;o<=r;o+=1){a=0;for(let i=1;i<o;i+=1)a+=e[i][o]*n[i];n[o]=(n[o]-a)/e[o][o]}for(let i=1;i<=r;i+=1){o=r+1-i,n[o]/=e[o][o],a=-n[o];for(let s=1;s<o;s+=1)n[s]+=a*e[s][o]}}tn.exports=Go});var on=_(($a,nn)=>{"use strict";function Uo(e,t,r,n){let o,a,i;for(let s=1;s<=r;s+=1){if(n[1]=s,i=0,o=s-1,o<1){if(i=e[s][s]-i,i<=0)break;e[s][s]=Math.sqrt(i)}else{for(let u=1;u<=o;u+=1){a=e[u][s];for(let c=1;c<u;c+=1)a-=e[c][s]*e[c][u];a/=e[u][u],e[u][s]=a,i+=a*a}if(i=e[s][s]-i,i<=0)break;e[s][s]=Math.sqrt(i)}n[1]=0}}nn.exports=Uo});var sn=_((Ga,an)=>{"use strict";var At=Yr(),qo=en(),jo=rn(),Fo=on();function Ho(e,t,r,n,o,a,i,s,u,c,d,l,p,g=0,m,f,N){let h,b,O,x,w,y,L,D,C,S,z,k,V,E,P=Math.min(n,d),M=2*n+P*(P+5)/2+2*d+1;for(let v=1;v<=n;v+=1)f[v]=t[v];for(let v=n+1;v<=M;v+=1)f[v]=0;for(let v=1;v<=d;v+=1)p[v]=0,a[v]=0;let $=[];if(N[1]===0){if(Fo(e,r,n,$),$[1]!==0){N[1]=2;return}jo(e,r,n,t),qo(e,r,n)}else{for(let v=1;v<=n;v+=1){o[v]=0;for(let I=1;I<=v;I+=1)o[v]+=e[I][v]*t[I]}for(let v=1;v<=n;v+=1){t[v]=0;for(let I=v;I<=n;I+=1)t[v]+=e[v][I]*o[I]}}i[1]=0;for(let v=1;v<=n;v+=1){o[v]=t[v],i[1]+=f[v]*o[v],f[v]=0;for(let I=v+1;I<=n;I+=1)e[I][v]=0}i[1]=-i[1]/2,N[1]=0;let j=n,q=j+n,R=q+P,ne=R+P+1,Y=ne+P*(P+1)/2,lt=Y+d;for(let v=1;v<=d;v+=1){y=0;for(let I=1;I<=n;I+=1)y+=s[I][v]*s[I][v];f[lt+v]=Math.sqrt(y)}x=g,m[1]=0,m[2]=0;function Zn(){m[1]+=1,M=Y;for(let v=1;v<=d;v+=1){M+=1,y=-u[v];for(let I=1;I<=n;I+=1)y+=s[I][v]*o[I];if(Math.abs(y)<At&&(y=0),v>l)f[M]=y;else if(f[M]=-Math.abs(y),y>0){for(let I=1;I<=n;I+=1)s[I][v]=-s[I][v];u[v]=-u[v]}}for(let v=1;v<=x;v+=1)f[Y+p[v]]=0;O=0,w=0;for(let v=1;v<=d;v+=1)f[Y+v]<w*f[lt+v]&&(O=v,w=f[Y+v]/f[lt+v]);if(O===0){for(let v=1;v<=x;v+=1)a[p[v]]=f[R+v];return 999}return 0}function Qn(){for(let v=1;v<=n;v+=1){y=0;for(let I=1;I<=n;I+=1)y+=e[I][v]*s[I][O];f[v]=y}h=j;for(let v=1;v<=n;v+=1)f[h+v]=0;for(let v=x+1;v<=n;v+=1)for(let I=1;I<=n;I+=1)f[h+I]=f[h+I]+e[I][v]*f[v];k=!0;for(let v=x;v>=1;v-=1){y=f[v],M=ne+v*(v+3)/2,h=M-v;for(let I=v+1;I<=x;I+=1)y-=f[M]*f[q+I],M+=I;y/=f[h],f[q+v]=y,!(p[v]<=l)&&(y<=0||(k=!1,b=v))}if(!k){L=f[R+b]/f[q+b];for(let v=1;v<=x;v+=1)p[v]<=l||f[q+v]<=0||(w=f[R+v]/f[q+v],w<L&&(L=w,b=v))}y=0;for(let v=j+1;v<=j+n;v+=1)y+=f[v]*f[v];if(Math.abs(y)<=At){if(k)return N[1]=1,999;for(let v=1;v<=x;v+=1)f[R+v]=f[R+v]-L*f[q+v];return f[R+x+1]=f[R+x+1]+L,700}y=0;for(let v=1;v<=n;v+=1)y+=f[j+v]*s[v][O];D=-f[Y+O]/y,V=!0,k||L<D&&(D=L,V=!1);for(let v=1;v<=n;v+=1)o[v]+=D*f[j+v],Math.abs(o[v])<At&&(o[v]=0);i[1]+=D*y*(D/2+f[R+x+1]);for(let v=1;v<=x;v+=1)f[R+v]=f[R+v]-D*f[q+v];if(f[R+x+1]=f[R+x+1]+D,V){x+=1,p[x]=O,M=ne+(x-1)*x/2+1;for(let v=1;v<=x-1;v+=1)f[M]=f[v],M+=1;if(x===n)f[M]=f[n];else{for(let v=n;v>=x+1;v-=1)if(f[v]!==0&&(C=Math.max(Math.abs(f[v-1]),Math.abs(f[v])),S=Math.min(Math.abs(f[v-1]),Math.abs(f[v])),f[v-1]>=0?w=Math.abs(C*Math.sqrt(1+S*S/(C*C))):w=-Math.abs(C*Math.sqrt(1+S*S/(C*C))),C=f[v-1]/w,S=f[v]/w,C!==1))if(C===0){f[v-1]=S*w;for(let I=1;I<=n;I+=1)w=e[I][v-1],e[I][v-1]=e[I][v],e[I][v]=w}else{f[v-1]=w,z=S/(1+C);for(let I=1;I<=n;I+=1)w=C*e[I][v-1]+S*e[I][v],e[I][v]=z*(e[I][v-1]+w)-e[I][v],e[I][v-1]=w}f[M]=f[x]}}else{y=-u[O];for(let v=1;v<=n;v+=1)y+=o[v]*s[v][O];if(O>l)f[Y+O]=y;else if(f[Y+O]=-Math.abs(y),y>0){for(let v=1;v<=n;v+=1)s[v][O]=-s[v][O];u[O]=-u[O]}return 700}return 0}function Jn(){if(M=ne+b*(b+1)/2+1,h=M+b,f[h]===0||(C=Math.max(Math.abs(f[h-1]),Math.abs(f[h])),S=Math.min(Math.abs(f[h-1]),Math.abs(f[h])),f[h-1]>=0?w=Math.abs(C*Math.sqrt(1+S*S/(C*C))):w=-Math.abs(C*Math.sqrt(1+S*S/(C*C))),C=f[h-1]/w,S=f[h]/w,C===1))return 798;if(C===0){for(let v=b+1;v<=x;v+=1)w=f[h-1],f[h-1]=f[h],f[h]=w,h+=v;for(let v=1;v<=n;v+=1)w=e[v][b],e[v][b]=e[v][b+1],e[v][b+1]=w}else{z=S/(1+C);for(let v=b+1;v<=x;v+=1)w=C*f[h-1]+S*f[h],f[h]=z*(f[h-1]+w)-f[h],f[h-1]=w,h+=v;for(let v=1;v<=n;v+=1)w=C*e[v][b]+S*e[v][b+1],e[v][b+1]=z*(e[v][b]+w)-e[v][b+1],e[v][b]=w}return 0}function Kn(){h=M-b;for(let v=1;v<=b;v+=1)f[h]=f[M],M+=1,h+=1;return f[R+b]=f[R+b+1],p[b]=p[b+1],b+=1,b<x?797:0}function $t(){return f[R+x]=f[R+x+1],f[R+x+1]=0,p[x]=0,x-=1,m[2]+=1,0}for(E=0;;){if(E=Zn(),E===999)return;for(;E=Qn(),E!==0;){if(E===999)return;if(E===700)if(b===x)$t();else{for(;Jn(),E=Kn(),E===797;);$t()}}}}an.exports=Ho});var dn=_(un=>{"use strict";var Zo=sn();function Qo(e,t,r,n=[],o=0,a=[0,0]){let i=[],s=[],u=[],c=[],d=[],l=[],p="",g=e.length-1,m=r[1].length-1;if(!n)for(let h=1;h<=m;h+=1)n[h]=0;if(g!==e[1].length-1&&(p="Dmat is not symmetric!"),g!==t.length-1&&(p="Dmat and dvec are incompatible!"),g!==r.length-1&&(p="Amat and dvec are incompatible!"),m!==n.length-1&&(p="Amat and bvec are incompatible!"),(o>m||o<0)&&(p="Value of meq is invalid!"),p!=="")return{message:p};for(let h=1;h<=m;h+=1)s[h]=0,c[h]=0;let f=0,N=Math.min(g,m);for(let h=1;h<=g;h+=1)u[h]=0;i[1]=0;for(let h=1;h<=2*g+N*(N+5)/2+2*m+1;h+=1)d[h]=0;for(let h=1;h<=2;h+=1)l[h]=0;return Zo(e,t,g,g,u,c,i,r,n,g,m,o,s,f,l,d,a),a[1]===1&&(p="constraints are inconsistent, no solution!"),a[1]===2&&(p="matrix D in quadratic function is not positive definite!"),{solution:u,Lagrangian:c,value:i,unconstrained_solution:t,iterations:l,iact:s,message:p}}un.solveQP=Qo});var cn=_((qa,ln)=>{"use strict";ln.exports=dn()});var Bn=_((au,Pn)=>{"use strict";var ui=function(e,t){return e<t};function U(e){if(!(this instanceof U))return new U(e);this.array=[],this.size=0,this.compare=e||ui}U.prototype.clone=function(){var e=new U(this.compare);return e.size=this.size,e.array=this.array.slice(0,this.size),e};U.prototype.add=function(e){var t=this.size;this.array[this.size]=e,this.size+=1;for(var r,n;t>0&&(r=t-1>>1,n=this.array[r],!!this.compare(e,n));)this.array[t]=n,t=r;this.array[t]=e};U.prototype.heapify=function(e){this.array=e,this.size=e.length;var t;for(t=this.size>>1;t>=0;t--)this._percolateDown(t)};U.prototype._percolateUp=function(e,t){for(var r=this.array[e],n,o;e>0&&(n=e-1>>1,o=this.array[n],!(!t&&!this.compare(r,o)));)this.array[e]=o,e=n;this.array[e]=r};U.prototype._percolateDown=function(e){for(var t=this.size,r=this.size>>>1,n=this.array[e],o,a,i;e<r&&(o=(e<<1)+1,a=o+1,i=this.array[o],a<t&&this.compare(this.array[a],i)&&(o=a,i=this.array[a]),!!this.compare(i,n));)this.array[e]=i,e=o;this.array[e]=n};U.prototype._removeAt=function(e){if(!(e>this.size-1||e<0))return this._percolateUp(e,!0),this.poll()};U.prototype.remove=function(e){for(var t=0;t<this.size;t++)if(!this.compare(this.array[t],e)&&!this.compare(e,this.array[t]))return this._removeAt(t),!0;return!1};U.prototype.removeOne=function(e){if(typeof e=="function"){for(var t=0;t<this.size;t++)if(e(this.array[t]))return this._removeAt(t)}};U.prototype.removeMany=function(e,t){if(typeof e!="function"||this.size<1)return[];t=t?Math.min(t,this.size):this.size;for(var r=0,n=new Array(t),o=0,a=new Array(this.size);r<t&&!this.isEmpty();){var i=this.poll();e(i)?n[r++]=i:a[o++]=i}n.length=r;for(var s=0;s<o;)this.add(a[s++]);return n};U.prototype.peek=function(){if(this.size!=0)return this.array[0]};U.prototype.poll=function(){if(this.size!=0){var e=this.array[0];return this.size>1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,e}};U.prototype.replaceTop=function(e){if(this.size!=0){var t=this.array[0];return this.array[0]=e,this._percolateDown(0),t}};U.prototype.trim=function(){this.array=this.array.slice(0,this.size)};U.prototype.isEmpty=function(){return this.size===0};U.prototype.forEach=function(e){if(!(this.isEmpty()||typeof e!="function"))for(var t=0,r=this.clone();!r.isEmpty();)e(r.poll(),t++)};U.prototype.kSmallest=function(e){if(this.size==0)return[];e=Math.min(this.size,e);var t=new U(this.compare);let r=Math.min((e>0?Math.pow(2,e-1):0)+1,this.size);t.size=r,t.array=this.array.slice(0,r);for(var n=new Array(e),o=0;o<e;o++)n[o]=t.poll();return n};Pn.exports=U});var di={};oo(di,{aggMeanFactory:()=>gn,aggMedianFactory:()=>Nn,aggWeightedMedianFactory:()=>Et,coordCenter:()=>zn,coordGreedy:()=>Mn,coordQuad:()=>Tn,coordSimplex:()=>tt,coordTopological:()=>En,dagConnect:()=>Kt,dagHierarchy:()=>Te,dagStratify:()=>rr,decrossDfs:()=>Ce,decrossOpt:()=>Vn,decrossTwoLayer:()=>ut,grid:()=>sr,laneGreedy:()=>_e,laneOpt:()=>Zr,layeringCoffmanGraham:()=>Rn,layeringLongestPath:()=>Gn,layeringSimplex:()=>dt,layeringTopological:()=>Un,sugiCoordVertical:()=>Bt,sugify:()=>ot,sugiyama:()=>kn,twolayerAgg:()=>rt,twolayerGreedy:()=>nt,twolayerOpt:()=>qn,unsugify:()=>it,zherebko:()=>Hn});function*Q(e){let t=0;for(let r of e)yield[t++,r]}function*F(e,t){for(let[r,n]of Q(e))yield*t(n,r)}function pt(e,t,r){let n=t,o=r;for(let[a,i]of Q(e))o=n(o,i,a);return o}function*W(e,t){for(let[r,n]of Q(e))yield t(n,r)}function*Ft(e,t){for(let[r,n]of Q(e))t(n,r)&&(yield n)}function fe(e,t){for(let[r,n]of Q(e))if(t(n,r))return!0;return!1}function Ht(e,t){return!fe(e,(r,n)=>!t(r,n))}function*ke(e){for(let t=e.length;t!=0;)yield e[--t]}function ve(e){if(!e)throw new Error("internal error: failed assert")}function Zt(e,t){if(t.size!==e.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}function Qt(e,t){t.size<e.size&&([t,e]=[e,t]);for(let r of e)if(t.has(r))return!0;return!1}function ze(e){let{done:t,value:r}=e.values().next();if(!t)return e.delete(r),r}function ue(e,t,r){let n=e.get(t);n===void 0?e.set(t,[r]):n.push(r)}function Me(e,t,r){let n=e.get(t);n===void 0?e.set(t,new Set([r])):n.add(r)}function ao(){let e=new WeakSet;return(t,r)=>{if(typeof r=="object"&&r!==null){if(e.has(r))return"[circular]";e.add(r)}return r}}function H(e,...t){let[r,...n]=e;return[r].concat(...n.map((o,a)=>[JSON.stringify(t[a],ao()),o])).join("")}function*Z(e){let[t,...r]=e;for(let n of r)yield[t,n],t=n}function*X(e,...t){let r=new Set,n;for(;(n=t.pop())!==void 0;)r.has(n)||(yield n,r.add(n),t.push(...e(n)))}function J(e){let t=new Map;for(let r of e)for(let n of r.ichildren())ue(t,n,r);return t}function Ae(e){let t=new Map;for(let r of e)for(let[n,o]of r.ichildrenCounts())ue(t,n,[r,o]);return t}var Ne=class{constructor(t,r,n=[],o=!1){this.child=t;this.data=r;this.points=n;this.reversed=o}},Jt=class{constructor(t,r,n,o,a){this.source=t;this.target=r;this.data=n;this.points=o;this.reversed=a}},oe=class{constructor(t){t&&(this.proots=t)}[Symbol.iterator](){return this.idescendants()[Symbol.iterator]()}iroots(){return{[Symbol.iterator]:()=>this.proots[Symbol.iterator]()}}roots(){return[...this.iroots()]}*idepth(){yield*X(r=>r.ichildren(),...this.iroots())}*ibreadth(){let t=new Set,r=this.roots(),n=[];do{n=r.reverse(),r=[];let o;for(;o=n.pop();)t.has(o)||(t.add(o),yield o,r.push(...o.ichildren()))}while(r.length)}*ibefore(){let t=new Map;for(let o of this)for(let a of o.ichildren())t.set(a,(t.get(a)||0)+1);let r=this.roots(),n;for(;n=r.pop();){yield n;for(let o of n.ichildren()){let a=t.get(o);a>1?t.set(o,a-1):r.push(o)}}}*iafter(){let t=this.roots(),r=new Set,n;for(;n=t.pop();)r.has(n)||(Ht(n.ichildren(),o=>r.has(o))?(r.add(n),yield n):t.push(n,...n.ichildren()))}idescendants(t="depth"){if(t==="depth")return this.idepth();if(t==="breadth")return this.ibreadth();if(t==="before")return this.ibefore();if(t==="after")return this.iafter();throw new Error(`unknown iteration style: ${t}`)}descendants(t="depth"){return[...this.idescendants(t)]}ilinks(){return F(this,t=>t.ichildLinks())}links(){return[...this.ilinks()]}size(){return pt(this,t=>t+1,0)}sum(t){let r=new Map;for(let[n,o]of Q(this.idescendants("after"))){let a=t(o,n),i=new Map;i.set(o,a);for(let s of o.ichildren()){let u=r.get(s);for(let[c,d]of u.entries())i.set(c,d)}o.value=pt(i.values(),(s,u)=>s+u,0),r.set(o,i)}return this}count(){let t=new Map;for(let r of this.idescendants("after"))if(r.ichildren()[Symbol.iterator]().next().done)t.set(r,new Set([r])),r.value=1;else{let n=new Set;for(let o of r.ichildren()){let a=t.get(o);for(let i of a)n.add(i)}t.set(r,n),r.value=n.size}return this}height(){for(let t of this.idescendants("after"))t.value=Math.max(0,...W(t.ichildren(),r=>r.value+1));return this}depth(){var r;let t=J(this);for(let n of this.idescendants("before"))n.value=Math.max(0,...W((r=t.get(n))!=null?r:[],o=>o.value+1));return this}*isplit(){let t=J(this);function*r(o){var a;yield*o.ichildren(),yield*(a=t.get(o))!=null?a:[]}let n=new Set(this.iroots());for(let o of this.iroots()){if(!n.delete(o))continue;let a=[o];for(let i of X(r,o))n.delete(i)&&a.push(i);yield a.length>1?new oe(a):a[0]}}split(){return[...this.isplit()]}connected(){let t=this.isplit()[Symbol.iterator]();t.next();let{done:r}=t.next();return!!r}multidag(){return this.pmultidag===void 0?this.pmultidag=fe(this.iroots(),t=>t.multidag()):this.pmultidag}},be=class extends oe{constructor(t){super();this.data=t;this.dataChildren=[]}childrenCountsMap(){var t;if(this.cachedChildrenCounts===void 0){let r=new Map;for(let{child:n}of this.dataChildren)r.set(n,((t=r.get(n))!=null?t:0)+1);return this.cachedChildrenCounts=r.size===this.dataChildren.length?null:r}else return this.cachedChildrenCounts}iroots(){let t=[this];return{[Symbol.iterator]:()=>t[Symbol.iterator]()}}nchildren(){var t,r;return(r=(t=this.childrenCountsMap())==null?void 0:t.size)!=null?r:this.dataChildren.length}nchildLinks(){return this.dataChildren.length}nchildLinksTo(t){var r,n;return(n=(r=this.childrenCountsMap())==null?void 0:r.get(t))!=null?n:1}*ichildren(){let t=this.childrenCountsMap();if(t===null)for(let{child:r}of this.dataChildren)yield r;else yield*t.keys()}children(){return[...this.ichildren()]}*ichildrenCounts(){let t=this.childrenCountsMap();if(t===null)for(let{child:r}of this.dataChildren)yield[r,1];else yield*t}childrenCounts(){return[...this.ichildrenCounts()]}*ichildLinks(){for(let{child:t,data:r,points:n,reversed:o}of this.dataChildren)yield new Jt(this,t,r,n,o)}childLinks(){return[...this.ichildLinks()]}isplit(){return this.iroots()}split(){return this.roots()}connected(){return!0}multidag(){return this.pmultidag===void 0?this.pmultidag=this.childrenCountsMap()!==null||fe(this.ichildren(),t=>t.multidag()):this.pmultidag}};function ht(e){if(typeof e!="string")throw new Error(`id is supposed to be string but got type ${typeof e}`);return e}function mt(e,t){if(!e.length)throw new Error("dag contained no roots; this often indicates a cycle");for(let i of new oe(e))for(let s of i.ichildren())if(s===i)throw new Error(H`node '${i.data}' contained a self loop`);if(!t)return;let r=new Set,n=new Set,o=null;function a(i){if(r.has(i))return[];if(n.has(i))return o=i,[i];{n.add(i);let s=[];for(let u of i.ichildren())if(s=a(u),s.length)break;return n.delete(i),r.add(i),s.length&&o!==null&&s.push(i),o===i&&(o=null),s}}for(let i of e){let s=a(i);if(s.length){let u=s.reverse().map(({data:c})=>H`'${c}'`).join(" -> ");throw new Error(`dag contained a cycle: ${u}`)}}}function so(e){return e&&ze(e)}function gt(e){var g,m,f;let t=new Map;for(let N of e)for(let{child:h}of N.dataChildren)ue(t,h,N);let r=new Map(W(e,N=>{var h,b;return[N,{indeg:(b=(h=t.get(N))==null?void 0:h.length)!=null?b:0,outdeg:N.nchildLinks(),node:N}]})),n=Math.max(...W(Ft(r.values(),({indeg:N,outdeg:h})=>N>0&&h>0),({indeg:N,outdeg:h})=>h-N));if(n===-1/0){let N=[];for(let{indeg:h,node:b}of r.values())h===0&&N.push(b);return N}let o=new Set,a=new Set,i=new Map;for(let N of r.values()){let{outdeg:h,indeg:b}=N;if(b===0)o.add(N);else if(h===0)a.add(N);else{let O=h-b;Me(i,O,N)}}let s=0,u=e.length,c=n,d=new Array(e.length);for(;s<u;){let N=(m=(g=ze(o))!=null?g:ze(a))!=null?m:so(i.get(c));if(N===void 0)--c;else{let{node:h,indeg:b,outdeg:O}=N,x=N.rank=b>0&&O===0?--u:s++;d[x]=h;for(let w of(f=t.get(h))!=null?f:[]){let y=r.get(w);if(y.rank===void 0&&y.indeg>0&&y.outdeg>0){let L=y.outdeg-y.indeg;i.get(L).delete(y),--y.outdeg,y.outdeg>0?Me(i,L-1,y):a.add(y)}}for(let{child:w}of h.dataChildren){let y=r.get(w);if(!(y.rank!==void 0||y.indeg===0))if(y.outdeg===0)--y.indeg,y.indeg===0&&(a.delete(y),o.add(y));else{let L=y.outdeg-y.indeg;L===c&&++c,i.get(L).delete(y),--y.indeg,y.indeg===0?o.add(y):Me(i,L+1,y)}}}}let l=[],p=new Set;for(let[N,h]of d.entries()){let b=[];for(let O of h.dataChildren){let x=r.get(O.child);x.rank<N?x.node.dataChildren.push(new Ne(h,O.data,O.points,!0)):b.push(O)}b.length===h.nchildLinks()&&!p.has(h)&&l.push(h);for(let{child:O}of b)p.add(O);h.dataChildren=b}return l}function uo(e,t){let r=[];for(let[n,o]of e.entries())t.has(n)||r.push(o);return r}function pe(e){function t(s){if(!s.length)throw new Error("can't connect empty data");let u=new Map,c=new Set;for(let[l,p]of s.entries()){let g=ht(e.sourceId(p,l)),m=u.get(g);m===void 0&&(m=new be(e.nodeDatum(g,l)),u.set(g,m));let f=ht(e.targetId(p,l)),N=u.get(f);N===void 0&&(N=new be(e.nodeDatum(f,l)),u.set(f,N)),(g!==f||!e.single)&&(m.dataChildren.push(new Ne(N,p)),c.add(f))}let d=e.decycle?gt([...u.values()]):uo(u,c);return mt(d,!e.decycle),d.length>1?new oe(d):d[0]}function r(s){if(s===void 0)return e.sourceId;{let u=e,{sourceId:c}=u,d=B(u,["sourceId"]);return pe(T(A({},d),{sourceId:s}))}}t.sourceId=r;function n(s){if(s===void 0)return e.targetId;{let u=e,{targetId:c}=u,d=B(u,["targetId"]);return pe(T(A({},d),{targetId:s}))}}t.targetId=n;function o(s){if(s===void 0)return e.nodeDatum;{let u=e,{nodeDatum:c}=u,d=B(u,["nodeDatum"]);return pe(T(A({},d),{nodeDatum:s}))}}t.nodeDatum=o;function a(s){return s===void 0?e.single:pe(T(A({},e),{single:s}))}t.single=a;function i(s){return s===void 0?e.decycle:pe(T(A({},e),{decycle:s}))}return t.decycle=i,t}function lo(e){try{return typeof e[0]=="string"}catch(t){return!1}}function co(e){if(lo(e))return e[0];throw new Error(`default source id expected datum[0] to be a string but got datum: ${e}`)}function fo(e){try{return typeof e[1]=="string"}catch(t){return!1}}function po(e){if(fo(e))return e[1];throw new Error(`default target id expected datum[1] to be a string but got datum: ${e}`)}function ho(e){return{id:e}}function Kt(...e){if(e.length)throw new Error(`got arguments to connect(${e}), but constructor takes no arguments. These were probably meant as data which should be called as connect()(...)`);return pe({sourceId:co,targetId:po,nodeDatum:ho,single:!1,decycle:!1})}function xe(e){function t(...i){var f;if(!i.length)throw new Error("must pass in at least one node");let s=new Map,u=[];function c(N){let h=s.get(N);return h===void 0&&(h=new be(N),s.set(N,h),u.push(h)),h}let d=i.map(c),l,p=0;for(;l=u.pop();)l.dataChildren=((f=e.childrenData(l.data,p++))!=null?f:[]).map(([N,h])=>new Ne(c(N),h));let g=new Set(d);for(let N of s.values())for(let{child:h}of N.dataChildren)if(g.delete(h)&&e.roots)throw new Error(H`node '${N.data}' pointed to a root`);let m=e.decycle?gt([...s.values()]):g.size?[...g]:d;return mt(m,!e.decycle),m.length>1?new oe(m):m[0]}function r(i){if(i===void 0)return e.children;{let s=e,{children:u,childrenData:c}=s,d=B(s,["children","childrenData"]);return xe(T(A({},d),{children:i,childrenData:Yt(i)}))}}t.children=r;function n(i){if(i===void 0)return e.childrenData;{let s=e,{children:u,childrenData:c}=s,d=B(s,["children","childrenData"]);return xe(T(A({},d),{children:mo(i),childrenData:i}))}}t.childrenData=n;function o(i){return i===void 0?e.roots:xe(T(A({},e),{roots:i}))}t.roots=o;function a(i){return i===void 0?e.decycle:xe(T(A({},e),{decycle:i}))}return t.decycle=a,t}function Yt(e){function t(r,n){var o;return((o=e(r,n))!=null?o:[]).map(a=>[a,void 0])}return t.wrapped=e,t}function mo(e){function t(r,n){var o;return((o=e(r,n))!=null?o:[]).map(([a])=>a)}return t.wrapped=e,t}function go(e){try{let t=e.children;return t===void 0||t instanceof Array}catch(t){return!1}}function Xt(e){if(go(e))return e.children;throw new Error(H`default children function expected datum to have a children field but got: ${e}`)}function Te(...e){if(e.length)throw new Error(`got arguments to hierarchy(${e}), but constructor takes no arguments. These were probably meant as data which should be called as hierarchy()(...)`);return xe({children:Xt,childrenData:Yt(Xt),roots:!0,decycle:!1})}function ye(e){function t(i){var d;if(!i.length)throw new Error("can't stratify empty data");let s=new Map;for(let[l,p]of i.entries()){let g=ht(e.id(p,l)),m=(d=e.parentData(p,l))!=null?d:[],f=new be(p);if(s.has(g))throw new Error(`found a duplicate id: ${r}`);s.set(g,[f,m])}let u=[];for(let[l,p]of s.values()){for(let[g,m]of p){let f=s.get(g);if(!f)throw new Error(`missing id: ${g}`);let[N]=f;N.dataChildren.push(new Ne(l,m))}p.length||u.push(l)}let c=e.decycle?gt([...W(s.values(),([l])=>l)]):u;return mt(c,!e.decycle),c.length>1?new oe(c):c[0]}function r(i){if(i===void 0)return e.id;{let s=e,{id:u}=s,c=B(s,["id"]);return ye(T(A({},c),{id:i}))}}t.id=r;function n(i){if(i===void 0)return e.parentData;{let s=e,{parentIds:u,parentData:c}=s,d=B(s,["parentIds","parentData"]);return ye(T(A({},d),{parentIds:vo(i),parentData:i}))}}t.parentData=n;function o(i){if(i===void 0)return e.parentIds;{let s=e,{parentIds:u,parentData:c}=s,d=B(s,["parentIds","parentData"]);return ye(T(A({},d),{parentIds:i,parentData:er(i)}))}}t.parentIds=o;function a(i){return i===void 0?e.decycle:ye(T(A({},e),{decycle:i}))}return t.decycle=a,t}function er(e){function t(r,n){var o;return((o=e(r,n))!=null?o:[]).map(a=>[a,void 0])}return t.wrapped=e,t}function vo(e){function t(r,n){var o;return((o=e(r,n))!=null?o:[]).map(([a])=>a)}return t.wrapped=e,t}function No(e){try{return typeof e.id=="string"}catch(t){return!1}}function bo(e){if(No(e))return e.id;throw new Error(H`default id function expected datum to have an id field but got '${e}'`)}function xo(e){try{let t=e.parentIds;return t===void 0||t instanceof Array&&t.every(r=>typeof r=="string")}catch(t){return!1}}function tr(e){if(xo(e))return e.parentIds;throw new Error(`default parentIds function expected datum to have a parentIds field but got: ${e}`)}function rr(...e){if(e.length)throw new Error(`got arguments to stratify(${e}), but constructor takes no arguments. These were probably meant as data which should be called as stratify()(...)`);return ye({id:bo,parentIds:tr,parentData:er(tr),decycle:!1})}function ie(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function*nr(e,t){if(t===void 0)for(let r of e)r!=null&&(r=+r)>=r&&(yield r);else{let r=-1;for(let n of e)(n=t(n,++r,e))!=null&&(n=+n)>=n&&(yield n)}}function or(e=ie){if(e===ie)return vt;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{let n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function vt(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:e>t?1:0)}function Ee(e,t){let r;if(t===void 0)for(let n of e)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let o of e)(o=t(o,++n,e))!=null&&(r<o||r===void 0&&o>=o)&&(r=o)}return r}function Ve(e,t){let r;if(t===void 0)for(let n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let o of e)(o=t(o,++n,e))!=null&&(r>o||r===void 0&&o>=o)&&(r=o)}return r}function Pe(e,t,r=0,n=e.length-1,o){for(o=o===void 0?vt:or(o);n>r;){if(n-r>600){let u=n-r+1,c=t-r+1,d=Math.log(u),l=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*l*(u-l)/u)*(c-u/2<0?-1:1),g=Math.max(r,Math.floor(t-c*l/u+p)),m=Math.min(n,Math.floor(t+(u-c)*l/u+p));Pe(e,t,g,m,o)}let a=e[t],i=r,s=n;for(Oe(e,r,t),o(e[n],a)>0&&Oe(e,r,n);i<s;){for(Oe(e,i,s),++i,--s;o(e[i],a)<0;)++i;for(;o(e[s],a)>0;)--s}o(e[r],a)===0?Oe(e,r,s):(++s,Oe(e,s,n)),s<=t&&(r=s+1),t<=s&&(n=s-1)}return e}function Oe(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function Nt(e,t,r){if(e=Float64Array.from(nr(e,r)),!!(n=e.length)){if((t=+t)<=0||n<2)return Ve(e);if(t>=1)return Ee(e);var n,o=(n-1)*t,a=Math.floor(o),i=Ee(Pe(e,a).subarray(0,a+1)),s=Ve(e.subarray(a+1));return i+(s-i)*(o-a)}}function he(e,t){return Nt(e,.5,t)}function we(e,t=ie){let r,n=!1;if(t.length===1){let o;for(let a of e){let i=t(a);(n?ie(i,o)<0:ie(i,i)===0)&&(r=a,o=i,n=!0)}}else for(let o of e)(n?t(o,r)<0:t(o,o)===0)&&(r=o,n=!0);return r}var ir=class{constructor(t){this.uncompressed=t;this.indices=[]}getIndex(t,r){var i;let n=[];for(let[s,u]of this.indices.entries())u<=t&&n.push(s);this.uncompressed&&n.push(this.indices.length);let o=r!=null?r:0,a=(i=we(n,s=>[Math.abs(o-s),s]))!=null?i:this.indices.length;return this.setIndex(a,t),a}setIndex(t,r){this.indices[t]=r}offset(){return 0}},ar=class{constructor(t){this.uncompressed=t;this.posIndices=[0];this.negIndices=[]}nextNeg(){return-this.negIndices.length-1}nextPos(){return this.posIndices.length}getIndex(t,r){var s;let n=[];for(let[u,c]of this.negIndices.entries())c<=t&&n.push(-u-1);for(let[u,c]of this.posIndices.entries())c<=t&&n.push(u);this.uncompressed&&(n.push(this.nextNeg()),n.push(this.nextPos()));let o=r!=null?r:0,a=this.negIndices.length<this.posIndices.length-1?this.nextNeg():this.nextPos(),i=(s=we(n,u=>[Math.abs(o-u),Math.abs(u),-u]))!=null?s:a;return this.setIndex(i,t),i}setIndex(t,r){t<0?this.negIndices[-t-1]=r:this.posIndices[t]=r}offset(){return this.negIndices.length}};function yo(e,t){return t?new ar(!e):new ir(!e)}function Oo(e,t){for(let n of e)n.x=void 0;for(let n of e){n.x===void 0&&(n.x=t.getIndex(n.y));for(let o of[...n.ichildren()].sort((a,i)=>i.y-a.y))o.x===void 0&&(o.x=t.getIndex(n.y,n.x),t.setIndex(o.x,o.y))}let r=t.offset();for(let n of e)n.x+=r}function wo(e,t){var o;let r=new Map;for(let a of e){a.x=void 0;for(let i of a.ichildren()){let s=r.get(i);(s===void 0||a.y<s.y)&&r.set(i,a)}}for(let a of ke(e)){if(a.x===void 0){let s=he(W(a.ichildren(),u=>u.x));a.x=t.getIndex(e.length-a.y,s)}let i=r.get(a);i!==void 0&&((o=i.x)!=null||(i.x=a.x),t.setIndex(a.x,e.length-i.y))}let n=t.offset();for(let a of e)a.x+=n}function Be(e,t,r){function n(s){let u=yo(t,r);e?Oo(s,u):wo(s,u)}function o(s){return s===void 0?e:Be(s,t,r)}n.topDown=o;function a(s){return s===void 0?t:Be(e,s,r)}n.compressed=a;function i(s){return s===void 0?r:Be(e,t,s)}return n.bidirectional=i,n}function _e(...e){if(e.length)throw new Error(`got arguments to greedy(${e}), but constructor takes no arguments.`);return Be(!0,!0,!1)}function Do(e){for(let n of e){if(n.x===void 0)throw new Error(H`coord didn't assign an x to node '${n}'`);if(n.x<0)throw new Error(`coord assigned an x (${n.x}) less than 0`)}let t=new Set(e.map(n=>n.x));if(!Zt(t,new Set(W(t,(n,o)=>o)))){let n=[...t].join(", ");throw new Error(`didn't assign increasing positive integers for x coordinates: ${n}`)}let r=new Map;for(let[n,o]of e.entries()){let a=r.get(o);if(a!==void 0){for(let i of e.slice(a+1,n))if(i.x===o.x)throw new Error(H`node ${i} was assigned an overlapping lane with ${o}`)}for(let i of o.ichildren())r.has(i)||r.set(i,n)}return t.size}function We(e){function t(a){if(a.multidag())throw new Error("grid layout doesn't make sense to apply to multidags, consider pruning the edges");let{nodeWidth:i,nodeHeight:s,size:u,lane:c}=e,d=[...a.idescendants("before")];for(let[m,f]of d.entries())f.y=m;c(d);let l=Do(d);for(let m of d)m.x=(m.x+.5)*i,m.y=(m.y+.5)*s;let p=l*i,g=d.length*s;if(u!==null){let[m,f]=u;for(let N of d)N.x*=m/p,N.y*=f/g;p=m,g=f}for(let{source:m,target:f,points:N}of a.ilinks())N.length=0,m.x!==f.x&&N.push({x:m.x,y:m.y}),N.push({x:f.x,y:m.y}),N.push({x:f.x,y:f.y});return{width:p,height:g}}function r(a){if(a===void 0)return e.lane;{let i=e,{lane:s}=i,u=B(i,["lane"]);return We(T(A({},u),{lane:a}))}}t.lane=r;function n(a){if(a===void 0){let{nodeWidth:i,nodeHeight:s}=e;return[i,s]}else{let[i,s]=a;return We(T(A({},e),{nodeWidth:i,nodeHeight:s}))}}t.nodeSize=n;function o(a){if(a!==void 0)return We(T(A({},e),{size:a}));if(e.size===null)return null;{let[i,s]=e.size;return[i,s]}}return t.size=o,t}function sr(...e){if(e.length)throw new Error(`got arguments to grid(${e}), but constructor takes no arguments.`);return We({lane:_e(),nodeWidth:1,nodeHeight:1,size:null})}var Hr=ft(Fr());function re(e,t,r,n,o={}){let s=Hr.Solve.call({},{optimize:e,opType:t,constraints:n,variables:r,ints:o}),{feasible:a}=s,i=B(s,["feasible"]);if(!a)throw new Error("could not find a feasible simplex solution");return i}function Ro(e){let t=[],r=new Set;for(let n of e){if(!r.has(n)){let o=t.findIndex(i=>i<=n.y),a=o===-1?t.length:o;t[a]=n.y}for(let o of[...n.ichildren()].sort((a,i)=>i.y-a.y))if(!r.has(o)){let a=t.findIndex(s=>s<=n.y),i=a===-1?t.length:a;t[i]=o.y,r.add(o)}}return t.length}function Mt(e,t){function r(a){var g,m,f;let i={},s={},u={},c=new Map(W(a,(N,h)=>[N,h])),d=e?Ro(a):a.length-1;for(let N of a.keys())i[N]={opt:0,[N]:1},s[N]={max:d-1};let l=new Map;for(let[N,h]of a.entries()){let b=l.get(h);if(b!==void 0)for(let[O,x]of a.slice(b+1,N).entries()){let w=O+b+1,y=`${N}-${w}-above`;i[y]={opt:0,[y]:1},s[y]={max:1},u[y]=1;let L=`${y}-span`;i[N][L]=1,i[w][L]=-1,i[y][L]=-d,s[L]={min:1-d,max:-1};for(let D of x.ichildren()){if(D===h)continue;let C=c.get(D),S=`${y}-${C}-cross`;i[S]={opt:1,[S]:1},s[S]={max:1},u[S]=1;let z=`${S}-left`;i[N][z]=-1,i[C][z]=1,i[y][z]=d,i[S][z]=-d,s[z]={max:d};let k=`${S}-right`;i[N][k]=-1,i[C][k]=1,i[y][k]=d,i[S][k]=d,s[k]={min:0}}}for(let O of h.ichildren())l.has(O)||l.set(O,N)}if(t){let N=a.reduce((h,b)=>h+b.children().length,0);for(let[h,b]of a.entries())for(let O of b.ichildren()){let x=c.get(O),w=`${h}-${x}-dist`;i[w]={opt:1/N};let y=`${w}-upper`;i[h][y]=1,i[x][y]=-1,i[w][y]=-d,s[y]={max:0};let L=`${w}-lower`;i[h][L]=1,i[x][L]=-1,i[w][L]=d,s[L]={min:0}}}let p=re("opt","min",i,s,u);if(t||e)for(let[N,h]of a.entries())h.x=(g=p[N])!=null?g:0;else{let N=new Set;for(let b of a.keys())N.add((m=p[b])!=null?m:0);let h=new Map(W([...N].sort(),(b,O)=>[b,O]));for(let[b,O]of a.entries())O.x=h.get((f=p[b])!=null?f:0)}}function n(a){return a===void 0?e:Mt(a,t)}r.compressed=n;function o(a){return a===void 0?t:Mt(e,a)}return r.dist=o,r}function Zr(...e){if(e.length)throw new Error(`got arguments to opt(${e}), but constructor takes no arguments.`);return Mt(!1,!0)}var fn=ft(cn());function Jo(e,t,r,n,o){if(!t.length)return[];let a=[[0]],i=[0],s=[[0]],u=[0];for(let l of e){let p=[0];p.push(...l),a.push(p)}i.push(...t),s.push(...t.map(()=>[0]));for(let l of r)for(let[p,g]of l.entries())s[p+1].push(-g);u.push(...n.map(l=>-l));let{solution:c,message:d}=(0,fn.solveQP)(a,i,s,u,o);if(d.length)throw new Error(`quadratic program failed: ${d}`);return c.shift(),c}function Qe(e,t,r,n,o=0){t.pop(),e.pop(),e.forEach(i=>i.pop()),r.forEach(i=>i.pop());let a=Jo(e,t,r,n,o);return a.push(0),a}function pn(e){return new Map(e.flatMap(t=>t).map((t,r)=>[t,r]))}function Je(e,t,r){let n=1+Math.max(...t.values()),o=[],a=[];for(let u of e)for(let[c,d]of Z(u)){let l=t.get(c),p=t.get(d),g=new Array(n).fill(0);g[l]=1,g[p]=-1,o.push(g),a.push(-(r(c)+r(d))/2)}let i=new Array(n).fill(0);return[[...new Array(n)].map(()=>new Array(n).fill(0)),i,o,a]}function Tt(e,t,r,n){e[r][r]+=n,e[r][t]-=n,e[t][r]-=n,e[t][t]+=n}function Ke(e,t,r,n,o){e[n][n]+=o,e[n][r]-=2*o,e[n][t]+=o,e[r][n]-=2*o,e[r][r]+=4*o,e[r][t]-=2*o,e[t][n]+=o,e[t][r]-=2*o,e[t][t]+=o}function Ye(e,t,r,n){let o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let s of e){let u=s[0],c=s[s.length-1];o=Math.min(o,n[r.get(u)]-t(u)/2),a=Math.max(a,n[r.get(c)]+t(c)/2)}let i=a-o;for(let s of e)for(let u of s)u.x=Math.min(Math.max(0,n[r.get(u)]-o),i);return i}function Xe(e){let t=J(F(e,a=>a));function*r(a){var i;yield*a.ichildren(),yield*(i=t.get(a))!=null?i:[]}let n=0,o=new Map;for(let a of F(e,i=>i))if(!o.has(a)){for(let i of X(r,a))o.set(i,n);n++}return o}function et(e,t){let r=[],n=[],o=new Set;for(let a of e){let i=new Set(a.map(s=>t.get(s)));Qt(o,i)||r.push(n=[]),n.push(a),o=i}return r}function Ko(e){let[t,r,n]=e;if(t<=0||r<=0||n<=0)throw new Error("const accessors should return non-negative values");let o=()=>e;return o.value=e,o}function Yo(e){return"value"in e&&typeof e.value=="object"&&e.value.length===3&&e.value.every(t=>typeof t=="number")}function Xo(e,t){if(Yo(t)){let[r,n,o]=t.value;if(r<=0||n<=0||o<=0)throw new Error(`simplex weights must be positive, but got: ${r}, ${n}, ${o}`);return(i,s)=>{switch(+("node"in i.data)+ +("node"in s.data)){case 0:return o;case 1:return n;case 2:return r;default:throw new Error("internal error")}}}else{let r=new Map;for(let o of F(e,a=>a))if("node"in o.data){let a=o.data.node,i=new Map;for(let s of a.ichildLinks()){let{target:u}=s,c=t(s),[d,l,p]=c;if(d<=0||l<=0||p<=0)throw new Error(`simplex weights must be positive, but got: ${d}, ${l}, ${p}`);i.set(u,c)}r.set(a,i)}return(o,a)=>{if("link"in o.data){let{source:i,target:s}=o.data.link,[,u,c]=r.get(i).get(s);return"link"in a.data?c:u}else if("link"in a.data){let{source:i,target:s}=a.data.link,[,u]=r.get(i).get(s);return u}else{let[i]=r.get(o.data.node).get(a.data.node);return i}}}}function hn(e){function t(o,a){var m;let i={},s={},u=Xo(o,e.weight),c=new Map;for(let[f,N]of Q(F(o,h=>h))){let h=f.toString();c.set(N,h),i[h]={}}function d(f){return c.get(f)}for(let f of o)for(let[N,h]of Z(f)){let b=d(N),O=d(h),x=`layer ${b} -> ${O}`,w=(a(N)+a(h))/2;s[x]={min:w},i[b][x]=-1,i[O][x]=1}for(let f of F(o,N=>N)){let N=d(f);for(let h of f.ichildren()){let b=d(h),O=`link ${N} -> ${b}`,x=`${O} parent`;s[x]={min:0};let w=`${O} child`;s[w]={min:0},i[N][x]=1,i[N][w]=-1,i[b][x]=-1,i[b][w]=1;let y=u(f,h);i[O]={opt:y,[x]:1,[w]:1}}}let l=re("opt","min",i,s),p=0,g=0;for(let f of o){for(let b of f)b.x=(m=l[d(b)])!=null?m:0;let N=f[0];p=Math.min(p,N.x-a(N)/2);let h=f[f.length-1];g=Math.max(g,h.x+a(h)/2)}for(let f of F(o,N=>N))f.x-=p;return g-p}function r(o,a){let i=Xe(o),s=et(o,i),u=s.map(d=>t(d,a)),c=Math.max(...u);if(c<=0)throw new Error("must assign nonzero width to at least one node");for(let[d,l]of s.entries()){let p=(c-u[d])/2;for(let g of l)for(let m of g)m.x+=p}return c}function n(o){if(o===void 0)return e.weight;{let a=e,{weight:i}=a,s=B(a,["weight"]);return hn(T(A({},s),{weight:o}))}}return r.weight=n,r}function tt(...e){if(e.length)throw new Error(`got arguments to simplex(${e}), but constructor takes no arguments.`);return hn({weight:Ko([1,2,8])})}var mn=class{constructor(){this.mean=0;this.count=0}add(t){this.mean+=(t-this.mean)/++this.count}val(){return this.count?this.mean:void 0}},gn=()=>new mn,vn=class{constructor(){this.vals=[]}add(t){this.vals.push(t)}val(){return he(this.vals)}},Nn=()=>new vn,bn=class{constructor(){this.vals=[]}add(t){this.vals.push(t)}val(){if(this.vals.sort((t,r)=>t-r),this.vals.length!==0){if(this.vals.length===2)return(this.vals[0]+this.vals[1])/2;if(this.vals.length%2===0){let t=this.vals.length/2,r=this.vals[0],n=this.vals[t-1],o=this.vals[t],a=this.vals[this.vals.length-1],i=n-r,s=a-o;return(n*s+o*i)/(i+s)}else return this.vals[(this.vals.length-1)/2]}}},Et=()=>new bn;function ei(e,t){let r=e();for(let n of t)r.add(n);return r.val()}function xn(e,t){let r=new Map;for(let d of e){let l=t.get(d);l!==void 0&&ue(r,l,d)}let n=[...r.entries()].sort(([d],[l])=>d-l).flatMap(([,d])=>d),o=new Map(e.map((d,l)=>[d,l])),a=e.filter(d=>t.get(d)===void 0),i=new Array(a.length).fill(null);function s(d,l,p,g){if(l<=d)return;let m=Math.floor((d+l)/2),f=a[m],N=o.get(f),h=0,b=[h];for(let x=p;x<g;++x)h+=o.get(n[x])<N?-1:1,b.push(h);let O=p+b.indexOf(Math.min(...b));i[m]=O,s(d,m,p,O),s(m+1,l,O,g)}s(0,a.length,0,n.length),i.push(n.length+1);let u=0,c=0;for(let[d,l]of n.entries()){for(;i[c]==d;)e[u++]=a[c++];e[u++]=l}for(;i[c]==n.length;)e[u++]=a[c++]}function yn({factory:e}){function t(n,o,a){if(a){let i=new Map(o.map(u=>[u,e()]));for(let[u,c]of n.entries())for(let d of c.ichildren())i.get(d).add(u);let s=new Map([...i.entries()].map(([u,c])=>[u,c.val()]));xn(o,s)}else{let i=new Map(o.map((u,c)=>[u,c])),s=new Map(n.map(u=>{let c=ei(e,W(u.ichildren(),d=>i.get(d)));return[u,c]}));xn(n,s)}}function r(n){return n===void 0?e:yn({factory:n})}return t.aggregator=r,t}function rt(...e){if(e.length)throw new Error(`got arguments to agg(${e}), but constructor takes no arguments.`);return yn({factory:Et})}function On(e,t){let r=new Map,n=new Map(e.map((a,i)=>[a,i]));function o(a,i){var u;let s=(u=r.get(a))==null?void 0:u.get(i);if(s!==void 0)return s;{let c=0;for(let p of t(a))for(let g of t(i))c+=Math.sign(n.get(p)-n.get(g));let d=r.get(a);d===void 0?r.set(a,new Map([[i,c]])):d.set(i,c);let l=r.get(i);return l===void 0?r.set(i,new Map([[a,-c]])):l.set(a,-c),c}}return o}function ti(e,t){let r=[[0,e.length]],n;for(;n=r.pop();){let[o,a]=n;if(o>=a)continue;let i=0,s=a;for(let u=o;u<a-1;++u){let c=t(e[u],e[u+1]);c>i&&(i=c,s=u)}s!==a&&([e[s],e[s+1]]=[e[s+1],e[s]],r.push([o,s],[s+2,a]))}}function ri(e,t){let r=new Array(e.length*(e.length-1)/2);for(;;){let n=0;for(let u=1;u<e.length;++u){let c=0,d=n;for(let l=u-1;l>=0;--l)r[d]=c,c+=t(e[l],e[u]),d-=e.length-l-1;n+=e.length-u}let o=0,a=0,i=0,s=0;for(let u=0;u<e.length-1;++u){let c=0;for(let d=u+1;d<e.length;++d){c+=t(e[u],e[d]);let l=r[o++]+c;l>a&&(a=l,i=u,s=d)}}if(a===0)break;[e[i],e[s]]=[e[s],e[i]]}}function Vt({baseOp:e,doScan:t}){function r(a,i,s){e(a,i,s);let u,c;if(s){let d=J(a);c=On(a,l=>{var p;return(p=d.get(l))!=null?p:[]}),u=i}else c=On(i,d=>d.ichildren()),u=a;t?ri(u,c):ti(u,c)}function n(a){return a===void 0?e:Vt({baseOp:a,doScan:t})}r.base=n;function o(a){return a===void 0?t:Vt({baseOp:e,doScan:a})}return r.scan=o,r}function nt(...e){if(e.length)throw new Error(`got arguments to greedy(${e}), but constructor takes no arguments.`);return Vt({baseOp:()=>{},doScan:!1})}function ni(e){if(e.value===void 0)throw new Error(H`node with data '${e.data}' did not get a defined value during layering`);if(e.value<0)throw new Error(H`node with data '${e.data}' got an invalid (negative) value during layering: ${e.value}`);return e.value}function ot(e){let t=new Map(W(e,i=>[i,{node:i,layer:ni(i)}]));for(let{source:i,target:s}of e.ilinks()){let u=i.nchildLinksTo(s)>1;if(u&&i.value+1>=s.value)throw new Error(H`layering left child data '${s.data}' (${s.value}) whose layer was not two more than its parent data '${i.data}' (${i.value})`);if(!u&&i.value>=s.value)throw new Error(H`layering left child data '${s.data}' (${s.value}) whose layer was not greater than its parent data '${i.data}' (${i.value})`)}function r(i){let s=i.layer+1;return("node"in i?i.node.childLinks():[i.link]).map(c=>{let d=t.get(c.target);return d.layer===s?d:{link:c,layer:s}})}let o=Te().children(r)(...W(e.iroots(),i=>t.get(i)));ve(!o.multidag());let a=[];for(let i of o)(a[i.data.layer]||(a[i.data.layer]=[])).push(i);if(!a[0]||!a[0].length)throw new Error("no nodes were assigned to layer 0");for(let i of a)ve(i&&i.length);return a}function it(e){for(let t of e)for(let r of t){if("link"in r.data)continue;r.data.node.x=r.x,r.data.node.y=r.y;let n=new Map(W(r.data.node.ichildLinks(),({points:o,target:a})=>[a,o]));for(let o of r.ichildren()){let a=[{x:r.x,y:r.y}];for(;"link"in o.data;)a.push({x:o.x,y:o.y}),[o]=o.ichildren();a.push({x:o.x,y:o.y});let i=n.get(o.data.node);i.splice(0,i.length,...a)}}}function wn(e,t){for(let r of e){let n=0;for(let o of r){if(o.x===void 0)throw new Error(H`coord didn't assign an x to node '${o}'`);if(o.x<n)throw new Error(H`coord assigned an x (${o.x}) smaller than a previous node in the layer '${o}'`);n=o.x}if(n>t)throw new Error(`coord assigned an x (${n}) greater than width (${t})`)}}function Dn(e,t,r){for(let n of e)for(let o of n)o.x*=t,o.y*=r}function at(e){let t=0;for(let[r,n]of Z(e)){let o=new Map(n.map((a,i)=>[a,i]));for(let[a,i]of r.entries())for(let s of r.slice(a+1))for(let u of i.ichildren())for(let c of s.ichildren())u!==c&&o.get(u)>o.get(c)&&t++}return t}function Ln(e){function t(n){let o;if(e.topDown)o=X(a=>a.ichildren(),...F(ke(n),a=>a));else{let a=J(F(n,i=>i));o=X(i=>{var s;return(s=a.get(i))!=null?s:[]},...F(n,i=>i))}for(let a of n)a.splice(0);for(let a of o)n[a.data.layer].push(a)}function r(n){return n===void 0?e.topDown:Ln({topDown:n})}return t.topDown=r,t}function Ce(...e){if(e.length)throw new Error(`got arguments to dfs(${e}), but constructor takes no arguments.`);return Ln({topDown:!0})}function st(e){function t(a){let i=a.slice().reverse(),s=a.map(c=>c.slice()),u=at(s);for(let c of e.inits){c(a);let d=!0;for(let l=0;l<e.passes&&d;++l){d=!1;for(let[m,f]of Z(a)){let N=f.slice();e.order(m,f,!0),f.some((h,b)=>N[b]!==h)&&(d=!0)}let p=at(a);p<u&&(u=p,s=a.map(m=>m.slice()));for(let[m,f]of Z(i)){let N=f.slice();e.order(f,m,!1),f.some((h,b)=>N[b]!==h)&&(d=!0)}let g=at(a);g<u&&(u=g,s=a.map(m=>m.slice()))}}a.splice(0,a.length,...s)}function r(a){if(a===void 0)return e.order;{let i=e,{order:s}=i,u=B(i,["order"]);return st(T(A({},u),{order:a}))}}t.order=r;function n(a){if(a===void 0)return[...e.inits];if(a.length){let i=e,{inits:s}=i,u=B(i,["inits"]);return st(T(A({},u),{inits:[...a]}))}else throw new Error("inits must be a non-empty array, maybe you intended the singleton noop: `[() => undefined]`")}t.inits=n;function o(a){if(a===void 0)return e.passes;if(a<=0)throw new Error("number of passes must be positive");return st(T(A({},e),{passes:a}))}return t.passes=o,t}function ut(...e){if(e.length)throw new Error(`got arguments to twoLayer(${e}), but constructor takes no arguments.`);return st({order:nt().base(rt()),inits:[Ce(),Ce().topDown(!1)],passes:24})}function Pt(e){function t(o){var N;let a={},i={},s={},u=new Map(W(o,(h,b)=>[h,b.toString()]));function c(h){return u.get(h)}function d(h){return a[c(h)]}function l(h,b,O,x=1){let w=d(b),y=d(O),L=`${h}: ${c(b)} -> ${c(O)}`;i[L]={min:x},w[L]=-1,y[L]=1}function p(h,b,O){l(`${h} before`,b,O,0),l(`${h} after`,O,b,0)}let g=[],m=new Map;for(let h of o){let b=c(h);s[b]=1,a[b]={opt:0};let O=e.rank(h);O!==void 0&&g.push([O,h]);let x=e.group(h);if(x!==void 0){let w=m.get(x);w?w.push(h):m.set(x,[h])}}for(let h of o)for(let[b,O]of h.ichildrenCounts())l("link",h,b,O>1?2:1),d(h).opt+=O,d(b).opt-=O;let f=g.sort(([h],[b])=>h-b);for(let[[h,b],[O,x]]of Z(f))h<O?l("rank",b,x):p("rank",b,x);for(let h of m.values())for(let[b,O]of Z(h))p("group",b,O);try{let h=re("opt","max",a,i,s);for(let b of o)b.value=(N=h[c(b)])!=null?N:0}catch(h){throw ve(g.length||m.size),new Error("could not find a feasible simplex layout, check that rank or group accessors are not ill-defined")}}function r(o){if(o===void 0)return e.rank;{let a=e,{rank:i}=a,s=B(a,["rank"]);return Pt(T(A({},s),{rank:o}))}}t.rank=r;function n(o){if(o===void 0)return e.group;{let a=e,{group:i}=a,s=B(a,["group"]);return Pt(T(A({},s),{group:o}))}}return t.group=n,t}function Sn(){}function dt(...e){if(e.length)throw new Error(`got arguments to simplex(${e}), but constructor takes no arguments.`);return Pt({rank:Sn,group:Sn})}function Cn(e){let t=e();function r(n){return"node"in n.data?e(n.data.node):t}return r.wrapped=e,r}function oi(e,t=!0){let r=new Map;function n(i){let s=r.get(i);if(s===void 0){s=e(i);let[u,c]=s;if(t&&(u<0||c<0))throw new Error(H`all node sizes must be non-negative, but got width ${u} and height ${c} for node '${i}'`);r.set(i,s)}return s}return[i=>n(i)[0],i=>n(i)[1]]}function Bt(e,t){let r=0;for(let n of e){let o=Math.max(...n.map(t));for(let a of n)a.y=r+o/2;r+=o}return r}function le(e){function t(u){e.layering(u);let c=ot(u),[d,l]=oi(e.sugiNodeSize),p=Bt(c,l);if(p<=0)throw new Error("at least one node must have positive height, but total height was zero");e.decross(c);let g=e.coord(c,d);if(wn(c,g),e.size!==null){let[m,f]=e.size;Dn(c,m/g,f/p),g=m,p=f}return it(c),{width:g,height:p}}function r(u){if(u===void 0)return e.layering;{let c=e,{layering:d}=c,l=B(c,["layering"]);return le(T(A({},l),{layering:u}))}}t.layering=r;function n(u){if(u===void 0)return e.decross;{let c=e,{decross:d}=c,l=B(c,["decross"]);return le(T(A({},l),{decross:u}))}}t.decross=n;function o(u){if(u===void 0)return e.coord;{let c=e,{coord:d}=c,l=B(c,["coord"]);return le(T(A({},l),{coord:u}))}}t.coord=o;function a(u){return u!==void 0?le(T(A({},e),{size:u})):e.size}t.size=a;function i(u){if(u!==void 0){let c=e,{nodeSize:d,sugiNodeSize:l}=c,p=B(c,["nodeSize","sugiNodeSize"]);return le(T(A({},p),{nodeSize:u,sugiNodeSize:Cn(u)}))}else return e.nodeSize}t.nodeSize=i;function s(u){if(u!==void 0){let c=e,{sugiNodeSize:d,nodeSize:l}=c,p=B(c,["sugiNodeSize","nodeSize"]);return le(T(A({},p),{sugiNodeSize:u,nodeSize:null}))}else return e.sugiNodeSize}return t.sugiNodeSize=s,t}function In(e){return[+(e!==void 0),1]}function kn(...e){if(e.length)throw new Error(`got arguments to sugiyama(${e}), but constructor takes no arguments.`);return le({layering:dt(),decross:ut(),coord:tt(),size:null,nodeSize:In,sugiNodeSize:Cn(In)})}function zn(...e){if(e.length)throw new Error(`got arguments to center(${e}), but constructor takes no arguments.`);function t(r,n){let o=r.map(i=>{let s=0;for(let u of i){let c=n(u);u.x=s+c/2,s+=c}return s}),a=Math.max(...o);if(a<=0)throw new Error("must assign nonzero width to at least one node");for(let[i,s]of r.entries()){let u=o[i],c=(a-u)/2;for(let d of s)d.x+=c}return a}return t}function Mn(...e){if(e.length)throw new Error(`got arguments to greedy(${e}), but constructor takes no arguments.`);function t(r,n){let o=ii,a=new Map;for(let l of r)for(let p of l)a.set(p,p.nchildren()+("node"in p.data?0:-3));for(let l of r)for(let p of l)for(let g of p.ichildren())a.set(g,a.get(g)+1);let[i,...s]=r,u=0,c=0;for(let l of i){let p=n(l);l.x=c+p/2,c+=p}for(let l of s){o(i,l);let p=l.map((g,m)=>[m,g]).sort(([g,m],[f,N])=>{let h=a.get(m),b=a.get(N);return h===b?g-f:b-h});for(let[g,m]of p){let f=n(m),N=m.x+f/2;for(let b of l.slice(g+1)){let O=n(b)/2;N=(b.x=Math.max(b.x,N+O))+O}c=Math.max(c,N);let h=m.x-f/2;for(let b of l.slice(0,g).reverse()){let O=n(b)/2;h=(b.x=Math.min(b.x,h-O))-O}u=Math.min(u,h)}i=l}for(let l of r)for(let p of l)p.x-=u;let d=c-u;if(d<=0)throw new Error("must assign nonzero width to at least one node");return d}return t}function ii(e,t){for(let n of t)n.x=0;let r=new Map;for(let n of e)for(let o of n.ichildren()){let a=(r.get(o)||0)+1;r.set(o,a),o.x+=(n.x-o.x)/a}}function ae(e){if(e<0)throw new Error("const accessors should return non-negative values");let t=()=>e;return t.value=e,t}function ce(e){return"value"in e&&typeof e.value=="number"}function ai(e,t){if(ce(e)){let r=e.value;for(let n of F(t,o=>o))if("node"in n.data){let o=n.data.node;for(let a of o.ichildLinks())if(e(a)!==r)throw new Error("passed in a vertWeak accessor with a `value` property that wasn't a const accessor")}return()=>r}else{let r=new Map;for(let n of F(t,o=>o))if("node"in n.data){let o=n.data.node,a=new Map(W(o.ichildLinks(),i=>[i.target,e(i)]));r.set(o,a)}return(n,o)=>r.get(n).get(o)}}function An(e){if(ce(e))return e;{let t=new Map;return r=>{let{source:n,target:o}=r,a=t.get(n);a===void 0&&(a=new Map,t.set(n,a));let i=a.get(o);if(i===void 0){let s=e(r);if(s<0)throw new Error("link weights must be non-negative");return a.set(o,s),s}else return i}}}function si(e){if(ce(e))return e;{let t=new Map;return r=>{let n=t.get(r);if(n===void 0){let o=e(r);if(o<0)throw new Error("node weights must be non-negative");return t.set(r,o),o}else return n}}}function se(e){function t(d,l,p){var C;let{comp:g}=e,m=pn(d),[f,N,h,b]=Je(d,m,l),O=ai(e.vertWeak,d),x=An(e.vertStrong),w=An(e.linkCurve),y=si(e.nodeCurve);for(let S of F(d,z=>z)){let z=m.get(S),k=S.data,V="node"in k?k.node:k.link.source;for(let E of S.ichildren()){let P=m.get(E),M=E.data,$="node"in M?M.node:M.link.target,j="node"in k?O(V,$):x(k.link),q="node"in M?O(V,$):x(M.link),R="node"in M?y(M.node):w(M.link);Tt(f,z,P,j+q);for(let ne of E.ichildren()){let Y=m.get(ne);Ke(f,z,P,Y,R)}}}let L=new Map;for(let S of d)for(let[z,k]of Z(S)){let V=p.get(z),E=p.get(k);if(V!==E){let P=L.get(V);P===void 0?L.set(V,new Set([E])):P.add(E)}}let D=new Map;for(let[S,z]of L.entries()){let k=new Set;for(let V of z){let E=X(M=>{var $;return($=L.get(M))!=null?$:[]},V);fe(E,M=>M===S)||k.add(V)}D.set(S,k)}for(let S of d)for(let[z,k]of Z(S)){let V=p.get(z),E=p.get(k);V!==E&&((C=D.get(V))==null?void 0:C.has(E))&&Tt(f,m.get(z),m.get(k),g)}try{let S=Qe(f,N,h,b);return Ye(d,l,m,S)}catch(S){throw S instanceof Error&&S.message==="quadratic program failed: matrix D in quadratic function is not positive definite!"?new Error("quad objective wasn't well defined, this happens when too many of the weights were set to zero (or really small). Try changing the weight accessors to return nonzero values in more instances."):S}}function r(d,l){let p=Xe(d),g=et(d,p),m=g.map(N=>t(N,l,p)),f=Math.max(...m);if(f<=0)throw new Error("must assign nonzero width to at least one node");for(let[N,h]of g.entries()){let b=(f-m[N])/2;for(let O of h)for(let x of O)x.x+=b}return f}function n(d){if(d===void 0){let{vertWeak:p,vertStrong:g}=e;return ce(p)&&ce(g)?[p.value,g.value]:null}else{let[p,g]=d;if(p<0||g<0)throw new Error(`weights must be non-negative, but were ${p} and ${g}`);{let l=e,{vertWeak:m,vertStrong:f}=l,N=B(l,["vertWeak","vertStrong"]);return se(T(A({},N),{vertWeak:ae(p),vertStrong:ae(g)}))}}}r.vertical=n;function o(d){if(d===void 0)return e.vertWeak;{let l=e,{vertWeak:p}=l,g=B(l,["vertWeak"]);return se(T(A({},g),{vertWeak:d}))}}r.vertWeak=o;function a(d){if(d===void 0)return e.vertStrong;{let l=e,{vertStrong:p}=l,g=B(l,["vertStrong"]);return se(T(A({},g),{vertStrong:d}))}}r.vertStrong=a;function i(d){if(d===void 0){let{linkCurve:p,nodeCurve:g}=e;return ce(p)&&ce(g)?[g.value,p.value]:null}else{let[p,g]=d;if(p<0||g<0)throw new Error(`weights must be non-negative, but were ${p} and ${g}`);{let l=e,{linkCurve:m,nodeCurve:f}=l,N=B(l,["linkCurve","nodeCurve"]);return se(T(A({},N),{linkCurve:ae(g),nodeCurve:ae(p)}))}}}r.curve=i;function s(d){if(d===void 0)return e.linkCurve;{let l=e,{linkCurve:p}=l,g=B(l,["linkCurve"]);return se(T(A({},g),{linkCurve:d}))}}r.linkCurve=s;function u(d){if(d===void 0)return e.nodeCurve;{let l=e,{nodeCurve:p}=l,g=B(l,["nodeCurve"]);return se(T(A({},g),{nodeCurve:d}))}}r.nodeCurve=u;function c(d){if(d===void 0)return e.comp;if(d<=0)throw new Error(`weight must be positive, but was ${d}`);return se(T(A({},e),{comp:d}))}return r.component=c,r}function Tn(...e){if(e.length)throw new Error(`got arguments to quad(${e}), but constructor takes no arguments.`);return se({vertWeak:ae(1),vertStrong:ae(0),linkCurve:ae(1),nodeCurve:ae(0),comp:1})}function En(...e){if(e.length)throw new Error(`got arguments to topological(${e}), but constructor takes no arguments.`);function t(r,n){for(let p of r)if(p.reduce((m,f)=>m+ +("node"in f.data),0)!==1)throw new Error("topological() only works with a topological layering");let o=new Map,a=0;for(let p of r)for(let g of p)"link"in g.data&&o.set(g,a++);for(let p of r)for(let g of p)"node"in g.data&&o.set(g,a);let[i,s,u,c]=Je(r,o,n);for(let p of r)for(let g of p){let m=o.get(g);for(let f of g.ichildren()){let N=o.get(f);if("link"in f.data)for(let h of f.ichildren()){let b=o.get(h);Ke(i,m,N,b,1)}}}let d=Qe(i,s,u,c),l=Ye(r,n,o,d);if(l<=0)throw new Error("must assign nonzero width to at least one node");return l}return t}function _t(e){function t(o){let a=o.reduce((x,w)=>x+w.length*Math.max(w.length-1,0)/2,0),i=o.reduce((x,w)=>x+w.reduce((y,L)=>y+L.nchildren(),0),0);if(e.large!=="large"&&a>1200)throw new Error('size of dag to decrossOpt is too large and will likely crash instead of complete, enable "large" graphs to run anyway');if(e.large!=="large"&&e.large!=="medium"&&(a>400||i>100))throw new Error('size of dag to decrossOpt is too large and will likely not complete, enable "medium" graphs to run anyway');let s=[];for(let[x,w]of Z(o)){let y=new Set(x.flatMap(k=>k.children())),L=w.filter(k=>!y.has(k)),D=x.map(k=>k.children()).filter(k=>k.length>1);s.push([L,D]);let C=x.filter(k=>!k.nchildren()),z=[...J(x).values()];s.push([C,z])}let u=s.reduce((x,[w,y])=>y.reduce((L,D)=>L+D.length*D.length,0)*w.length,0)/4,c=1/(u+1),d=c/(a+1),l={},p={},g={},m=new Map;{let x=0;for(let w of o)for(let y of w)m.set(y,x++)}function f(...x){return x.map(w=>m.get(w)).sort((w,y)=>w-y).join(" => ")}function N(x){for(let[w,y]of x.slice(0,x.length-1).entries())for(let L of x.slice(w+1)){let D=f(y,L);g[D]=1,p[D]={max:1},l[D]={opt:-d,[D]:1}}for(let[w,y]of x.slice(0,x.length-1).entries())for(let[L,D]of x.slice(w+1).entries())for(let C of x.slice(w+L+2)){let S=f(y,D),z=f(y,C),k=f(D,C),V=f(y,D,C),E=V+"+";p[E]={max:1},l[S][E]=1,l[z][E]=-1,l[k][E]=1;let P=V+"-";p[P]={min:0},l[S][P]=1,l[z][P]=-1,l[k][P]=1}}function h(x){for(let[w,y]of x.slice(0,x.length-1).entries())for(let L of x.slice(w+1)){let D=f(y,L);for(let C of y.ichildren())for(let S of L.ichildren()){if(C===S)continue;let z=f(C,S),k=`slack (${D}) (${z})`,V=`${k} +`,E=`${k} -`;l[k]={opt:1,[V]:1,[E]:1};let P=Math.sign(m.get(C)-m.get(S)),M=Math.max(P,0);p[V]={min:M},l[D][V]=1,l[z][V]=P,p[E]={min:-M},l[D][E]=-1,l[z][E]=-P}}}function b(x,w){for(let y of x)for(let L of w)for(let[D,C]of L.entries())for(let S of L.slice(D+1)){let k=`dist ${[C,y,S].map(M=>m.get(M)).join(" => ")}`,V=`${k} normal`,E=`${k} reversed`;l[k]={opt:c,[V]:1,[E]:1};let P=0;for(let[M,$]of[[C,y],[C,S],[y,S]]){let j=f(M,$),q=Math.sign(m.get(M)-m.get($));P+=+(q>0),l[j][V]=-q,l[j][E]=q}p[V]={min:1-P},p[E]={min:P-2}}}for(let x of o)N(x);for(let x of o.slice(0,o.length-1))h(x);if(e.dist)for(let[x,w]of s)b(x,w);let O=re("opt","min",l,p,g);for(let x of o)x.sort((w,y)=>O[f(w,y)]||-1)}function r(o){return o===void 0?e.large:_t(T(A({},e),{large:o}))}t.large=r;function n(o){return o===void 0?e.dist:_t(T(A({},e),{dist:o}))}return t.dist=n,t}function Vn(...e){if(e.length)throw new Error(`got arguments to opt(${e}), but constructor takes no arguments.`);return _t({large:"small",dist:!1})}var _n=ft(Bn());function Wn(e){function t(n){var g;let o=e.width||Math.floor(Math.sqrt(n.size()+.5));function a([m],[f]){for(let[N,h]of m.entries()){let b=f[N];if(b===void 0)return!1;if(h<b)return!0;if(b<h)return!1}return!0}let i=new _n.default(a),s=new Map(W(n,m=>[m,[]])),u=Ae(n);for(let m of n.iroots())i.add([[],m]);let c=0,d=0,l=0,p;for(;p=i.poll();){let[,m]=p,f=(g=u.get(m))==null?void 0:g.reduce((N,[h,b])=>Math.max(N,h.value+ +(b>1)),0);l<o&&(f===void 0||f<d)?(m.value=d,l++):(m.value=d=Math.max(f!=null?f:0,d)+1,l=1);for(let N of m.ichildren()){let h=s.get(N);h.push(c),h.length===u.get(N).length&&i.add([h.reverse(),N])}c++}}function r(n){if(n===void 0)return e.width;if(n<0)throw new Error(`width must be non-negative: ${n}`);return Wn(T(A({},e),{width:n}))}return t.width=r,t}function Rn(...e){if(e.length)throw new Error(`got arguments to coffmanGraham(${e}), but constructor takes no arguments.`);return Wn({width:0})}function $n(e){function t(n){var o;if(e.topDown){let a=Ae(n);for(let i of n.idescendants("before"))i.value=Math.max(0,...W((o=a.get(i))!=null?o:[],([s,u])=>s.value+(u>1?2:1)))}else{let a=0;for(let i of n.idescendants("after"))i.value=Math.max(0,...W(i.ichildrenCounts(),([s,u])=>s.value+(u>1?2:1))),a=Math.max(a,i.value);for(let i of n)i.value=a-i.value}}function r(n){return n===void 0?e.topDown:$n(T(A({},e),{topDown:n}))}return t.topDown=r,t}function Gn(...e){if(e.length)throw new Error(`got arguments to longestPath(${e}), but constructor takes no arguments.`);return $n({topDown:!0})}function Un(...e){if(e.length)throw new Error(`got arguments to topological(${e}), but constructor takes no arguments.`);function t(r){let n=0,o;for(let a of r.idescendants("before"))o!==void 0&&o.nchildLinksTo(a)>1&&++n,a.value=n++,o=a}return t}function Wt(e){function t(o,a,i){let s=i?a:o,u=s.length*Math.max(s.length-1,0)/2,c=o.reduce((L,D)=>L+D.nchildren(),0);if(e.large!=="large"&&u>1200)throw new Error('size of dag to twolayerOpt is too large and will likely crash, enable "large" dags to run anyway');if(e.large!=="large"&&e.large!=="medium"&&(u>400||c>100))throw new Error('size of dag to twolayerOpt is too large and will likely not finish, enable "medium" dags to run anyway');let d={},l={},p={},g=new Map(s.map((L,D)=>[L,D]));function m(...L){return L.map(D=>g.get(D)).sort((D,C)=>D-C).join(" => ")}let f,N;if(i){let L=new Set(o.flatMap(D=>D.children()));f=a.filter(D=>!L.has(D)),N=o.map(D=>D.children()).filter(D=>D.length>1)}else f=o.filter(D=>!D.nchildren()),N=[...J(o).values()];let b=N.reduce((L,D)=>L+D.length*D.length,0)*f.length/4,O=1/(b+1),x=O/(u+1),w=new Map(a.map((L,D)=>[L,D]));for(let[L,D]of s.slice(0,s.length-1).entries())for(let C of s.slice(L+1)){let S=m(D,C);p[S]=1,l[S]={max:1},d[S]={opt:-x,[S]:1}}for(let[L,D]of s.slice(0,s.length-1).entries())for(let[C,S]of s.slice(L+1).entries())for(let z of s.slice(L+C+2)){let k=m(D,S),V=m(D,z),E=m(S,z),P=m(D,S,z),M=P+"+";l[M]={max:1},d[k][M]=1,d[V][M]=-1,d[E][M]=1;let $=P+"-";l[$]={min:0},d[k][$]=1,d[V][$]=-1,d[E][$]=1}for(let[L,D]of o.slice(0,o.length-1).entries())for(let C of o.slice(L+1))for(let S of D.ichildren())for(let z of C.ichildren()){if(S===z)continue;let k=i?m(S,z):m(D,C);d[k].opt+=Math.sign(w.get(S)-w.get(z))}if(e.dist)for(let L of f)for(let D of N)for(let[C,S]of D.entries())for(let z of D.slice(C+1)){let V=`dist ${[S,L,z].map($=>g.get($)).join(" => ")}`,E=`${V} normal`,P=`${V} reversed`;d[V]={opt:O,[E]:1,[P]:1};let M=0;for(let[$,j]of[[S,L],[S,z],[L,z]]){let q=m($,j),R=Math.sign(g.get($)-g.get(j));M+=+(R>0),d[q][E]=-R,d[q][P]=R}l[E]={min:1-M},l[P]={min:M-2}}let y=re("opt","min",d,l,p);s.sort((L,D)=>y[m(L,D)]||-1)}function r(o){return o===void 0?e.large:Wt(T(A({},e),{large:o}))}t.large=r;function n(o){return o===void 0?e.dist:Wt(T(A({},e),{dist:o}))}return t.dist=n,t}function qn(...e){if(e.length)throw new Error(`got arguments to opt(${e}), but constructor takes no arguments.`);return Wt({large:"small",dist:!1})}function jn(e,t){let r=e.findIndex(n=>n<=t);return r>=0?r:e.length}function Fn(e){var i;let t=new Map(e),r=[];for(let[s,[u,c]]of e.entries()){let d=!1,l=(i=e[s+1])==null?void 0:i[0];for(let[p,{target:g}]of Q(u.ichildLinks())){let m=t.get(g);l===g&&!d?d=!0:r.push([c,m,u,p])}}r.sort(([s,u],[c,d])=>u===d?c-s:u-d);let n=new Map,o=[],a=[];for(let[s,u,c,d]of r){let l=n.get(c);l===void 0&&(l=[],n.set(c,l));let p=jn(a,s),g=jn(o,s);p<g?(l[d]=-p-1,a[p]=u-1):(l[d]=g+1,o[g]=u-1)}return n}function Rt(e,t,r,n){function o(s){var h;let u=[],c=0,d;for(let b of s.idescendants("before"))d!==void 0&&d.nchildLinksTo(b)>1&&++c,u.push([b,c++]),d=b;let l=Fn(u),p=0,g=0;for(let b of l.values())for(let O of b)O!==void 0&&(p=Math.min(p,O),g=Math.max(g,O));let m=-p*r+e/2;for(let[b,O]of u)b.x=m,b.y=(O+.5)*t;for(let b of s){let O=(h=l.get(b))!=null?h:[];for(let[x,{target:w,points:y}]of Q(b.ichildLinks())){y.length=0,y.push({x:b.x,y:b.y});let L=O[x];if(L!==void 0){let D=(L-p+.5)*r+(L>0?e-r:0),C=b.y+t,S=w.y-t;S-C>t/2?y.push({x:D,y:C},{x:D,y:S}):y.push({x:D,y:C})}y.push({x:w.x,y:w.y})}}let f=(g-p)*r+e,N=c*t;if(n===null)return{width:f,height:N};{let[b,O]=n;for(let[x]of u)x.x*=b/f,x.y*=O/N;for(let{points:x}of s.ilinks()){let w=x.map(({x:y,y:L})=>({x:y*b/f,y:L*O/N}));x.splice(0,x.length,...w)}return{width:b,height:O}}}function a(s){if(s===void 0)return[e,t,r];{let[u,c,d]=s;return Rt(u,c,d,n)}}o.nodeSize=a;function i(s){if(s!==void 0)return Rt(e,t,r,s);if(n===null)return n;{let[u,c]=n;return[u,c]}}return o.size=i,o}function Hn(...e){if(e.length)throw new Error(`got arguments to zherebko(${e}), but constructor takes no arguments.`);return Rt(1,1,1,null)}return io(di);})();
return d3; })())